Add appropriate error message for when trying to load texture pack zip with too many entries (Thanks Mr.Knowledge)

This commit is contained in:
UnknownShadow200 2020-08-28 12:42:37 +10:00
parent 0a29905f99
commit 2a439f09a3
4 changed files with 13 additions and 11 deletions

View File

@ -238,12 +238,12 @@ static struct ChatCommand* Commands_FindMatch(const String* cmdName) {
String name;
for (cmd = cmds_head; cmd; cmd = cmd->next) {
name = String_FromReadonly(cmd->Name);
name = String_FromReadonly(cmd->name);
if (String_CaselessEquals(&name, cmdName)) return cmd;
}
for (cmd = cmds_head; cmd; cmd = cmd->next) {
name = String_FromReadonly(cmd->Name);
name = String_FromReadonly(cmd->name);
if (!String_CaselessStarts(&name, cmdName)) continue;
if (match) {
@ -269,7 +269,7 @@ static void Commands_PrintDefault(void) {
String_InitArray(str, strBuffer);
for (cmd = cmds_head; cmd; cmd = cmd->next) {
name = String_FromReadonly(cmd->Name);
name = String_FromReadonly(cmd->name);
if ((str.length + name.length + 2) > str.capacity) {
Chat_Add(&str);
@ -308,7 +308,7 @@ static void Commands_Execute(const String* input) {
cmd = Commands_FindMatch(&args[0]);
if (!cmd) return;
if (cmd->SingleplayerOnly && !Server.IsSinglePlayer) {
if (cmd->singleplayerOnly && !Server.IsSinglePlayer) {
Chat_Add1("&e/client: \"&f%s&e\" can only be used in singleplayer.", &args[0]);
return;
}
@ -327,9 +327,9 @@ static void HelpCommand_Execute(const String* args, int argsCount) {
cmd = Commands_FindMatch(&args[0]);
if (!cmd) return;
for (i = 0; i < Array_Elems(cmd->Help); i++) {
if (!cmd->Help[i]) continue;
Chat_AddRaw(cmd->Help[i]);
for (i = 0; i < Array_Elems(cmd->help); i++) {
if (!cmd->help[i]) continue;
Chat_AddRaw(cmd->help[i]);
}
}

View File

@ -36,11 +36,11 @@ extern double Chat_AnnouncementReceived;
struct ChatCommand;
/* Represents a client-side command/action. */
struct ChatCommand {
const char* Name; /* Full name of this command */
const char* name; /* Full name of this command */
/* Function pointer for the actual action the command performs */
void (*Execute)(const String* args, int argsCount);
cc_bool SingleplayerOnly; /* Whether this command is only usable in singleplayer */
const char* Help[5]; /* Messages to show when a player uses /help on this command */
cc_bool singleplayerOnly; /* Whether this command is only usable in singleplayer */
const char* help[5]; /* Messages to show when a player uses /help on this command */
struct ChatCommand* next; /* Next command in linked-list of client commands */
};
/* Registers a client-side command, allowing it to be used with /client [cmd name] */

View File

@ -80,6 +80,8 @@ static const char* GetCCErrorDesc(cc_result res) {
case WAV_ERR_DATA_TYPE: return "Unsupported WAV audio format";
case WAV_ERR_NO_DATA: return "No audio in WAV";
case ZIP_ERR_TOO_MANY_ENTRIES: return "Cannot load .zip files with over 1024 entries";
case PNG_ERR_INVALID_SIG: return "Only PNG images supported";
case PNG_ERR_INVALID_HDR_SIZE: return "Invalid PNG header size";
case PNG_ERR_TOO_WIDE: return "PNG image too wide";

View File

@ -447,7 +447,7 @@ static void Codebook_DecodeVectors(struct VorbisState* ctx, struct Codebook* c,
#define FLOOR_MAX_CLASSES 16
#define FLOOR_MAX_VALUES (FLOOR_MAX_PARTITIONS * 8 + 2)
struct Floor {
cc_uint8 partitions, multiplier; cc_int32 range, values;
cc_uint8 partitions, multiplier; int range, values;
cc_uint8 partitionClasses[FLOOR_MAX_PARTITIONS];
cc_uint8 classDimensions[FLOOR_MAX_CLASSES];
cc_uint8 classSubClasses[FLOOR_MAX_CLASSES];