From b8e70fb46fd368f3b855f75b05d0260728c98be7 Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 18 Aug 2021 22:58:54 -0700 Subject: [PATCH] Add range checks to model index --- src/pc/network/network_player.c | 3 ++- src/pc/network/packets/packet_network_players.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pc/network/network_player.c b/src/pc/network/network_player.c index 22e2143c..703574cd 100644 --- a/src/pc/network/network_player.c +++ b/src/pc/network/network_player.c @@ -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]; diff --git a/src/pc/network/packets/packet_network_players.c b/src/pc/network/packets/packet_network_players.c index 73adc0f8..f71578b0 100644 --- a/src/pc/network/packets/packet_network_players.c +++ b/src/pc/network/packets/packet_network_players.c @@ -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); }