Add range checks to model index

This commit is contained in:
MysterD 2021-08-18 22:58:54 -07:00
parent 4688ffe1f0
commit b8e70fb46f
2 changed files with 3 additions and 2 deletions

View File

@ -13,7 +13,7 @@ struct NetworkPlayer* gNetworkPlayerServer = NULL;
static char sDefaultPlayerName[] = "Player";
void network_player_init(void) {
gNetworkPlayers[0].modelIndex = configPlayerModel;
gNetworkPlayers[0].modelIndex = (configPlayerModel < CT_MAX) ? configPlayerModel : 0;
gNetworkPlayers[0].paletteIndex = configPlayerPalette;
}
@ -187,6 +187,7 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 mode
if (name[0] == '\0') {
name = sDefaultPlayerName;
}
if (modelIndex >= CT_MAX) { modelIndex = 0; }
if (type == NPT_LOCAL) {
struct NetworkPlayer* np = &gNetworkPlayers[0];

View File

@ -98,7 +98,7 @@ void network_receive_network_players(struct Packet* p) {
gNetworkSystem->save_id(localIndex, networkId);
}
} else {
np->modelIndex = modelIndex;
np->modelIndex = (modelIndex < CT_MAX) ? modelIndex : 0;
np->paletteIndex = paletteIndex;
network_player_update_model(localIndex);
}