diff --git a/src/game/characters.h b/src/game/characters.h index ece148ab2..bf87f3103 100644 --- a/src/game/characters.h +++ b/src/game/characters.h @@ -4,6 +4,8 @@ #include "types.h" // NOTE: do not include any additional headers +#define PALETTE_MAX 24 + enum CharacterType { CT_MARIO, CT_LUIGI, diff --git a/src/game/mario_misc.c b/src/game/mario_misc.c index 6eed1766b..673042a41 100644 --- a/src/game/mario_misc.c +++ b/src/game/mario_misc.c @@ -85,7 +85,7 @@ struct GraphNodeObject gMirrorMario[MAX_PLAYERS]; // copy of Mario's geo node f gdSPDefLights1((pr >> 1), (pg >> 1), (pb >> 1), pr, pg, pb, 0x28, 0x28, 0x28), \ } -struct PlayerColor gPlayerColors[] = { +struct PlayerColor gPlayerColors[PALETTE_MAX] = { // default mario DEFINE_PLAYER_COLOR(0xff, 0x00, 0x00, /**/ 0x00, 0x00, 0xff), // default luigi diff --git a/src/pc/djui/djui_panel_player.c b/src/pc/djui/djui_panel_player.c index fa968c3e4..d91bebee2 100644 --- a/src/pc/djui/djui_panel_player.c +++ b/src/pc/djui/djui_panel_player.c @@ -91,7 +91,7 @@ void djui_panel_player_create(struct DjuiBase* caller) { djui_base_set_size(&selectionbox1->base, 1.0f, 32); djui_interactable_hook_value_change(&selectionbox1->base, djui_panel_player_value_changed); - char* paletteChoices[24] = { + char* paletteChoices[PALETTE_MAX] = { "Mario", "Luigi", "Waluigi", @@ -117,7 +117,7 @@ void djui_panel_player_create(struct DjuiBase* caller) { "Fire Waluigi", "Fire Wario", }; - struct DjuiSelectionbox* selectionbox2 = djui_selectionbox_create(&body->base, "Palette", paletteChoices, 24, &configPlayerPalette); + struct DjuiSelectionbox* selectionbox2 = djui_selectionbox_create(&body->base, "Palette", paletteChoices, PALETTE_MAX, &configPlayerPalette); djui_base_set_size_type(&selectionbox2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&selectionbox2->base, 1.0f, 32); djui_interactable_hook_value_change(&selectionbox2->base, djui_panel_player_value_changed); diff --git a/src/pc/network/packets/packet_player_settings.c b/src/pc/network/packets/packet_player_settings.c index cb684a9ad..45cd6e14e 100644 --- a/src/pc/network/packets/packet_player_settings.c +++ b/src/pc/network/packets/packet_player_settings.c @@ -42,6 +42,10 @@ void network_receive_player_settings(struct Packet* p) { return; } + // sanity check + if (playerModel >= CT_MAX) { playerModel = CT_MARIO; } + if (playerPalette >= PALETTE_MAX) { playerPalette = 0; } + struct NetworkPlayer* np = network_player_from_global_index(globalId); snprintf(np->name, MAX_PLAYER_STRING, "%s", playerName); np->modelIndex = playerModel; diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 75b864ed6..061952774 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -224,7 +224,7 @@ void main_func(void) { mod_list_init(); configfile_load(configfile_name()); if (configPlayerModel >= CT_MAX) { configPlayerModel = 0; } - if (configPlayerPalette >= 24) { configPlayerPalette = 0; } + if (configPlayerPalette >= PALETTE_MAX) { configPlayerPalette = 0; } if (gCLIOpts.FullScreen == 1) configWindow.fullscreen = true;