mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-21 19:45:10 +00:00
add some bounds checks
This commit is contained in:
parent
4ba9970972
commit
3e39f5651a
4 changed files with 13 additions and 6 deletions
|
@ -253,6 +253,10 @@ void bhv_normal_cap_loop(void) {
|
|||
if (cap_set_hitbox() == 1)
|
||||
save_file_clear_flags(SAVE_FLAG_CAP_ON_GROUND);
|
||||
|
||||
if (o->globalPlayerIndex >= MAX_PLAYERS) {
|
||||
o->globalPlayerIndex = 0;
|
||||
}
|
||||
|
||||
obj_set_model(o, gMarioStates[network_local_index_from_global(o->globalPlayerIndex)].character->capModelId);
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,8 @@ void network_receive_network_players(struct Packet *p) {
|
|||
packet_read(p, &playerName, sizeof(u8) * MAX_CONFIG_STRING);
|
||||
packet_read(p, &discordId, sizeof(u8) * 64);
|
||||
|
||||
if (globalIndex > MAX_PLAYERS) { continue; }
|
||||
|
||||
u8 localIndex = network_player_connected(npType, globalIndex, modelIndex, &palette, playerName, discordId);
|
||||
LOG_INFO("received network player [%d == %d] (%d)", globalIndex, npType, localIndex);
|
||||
if (localIndex != UNKNOWN_GLOBAL_INDEX) {
|
||||
|
|
|
@ -159,6 +159,8 @@ void network_receive_spawn_objects(struct Packet* p) {
|
|||
name = gNetworkPlayers[p->localIndex].name;
|
||||
}
|
||||
|
||||
const char *bhvName = get_behavior_name_from_id(data.behaviorId);
|
||||
|
||||
// Don't overwrite existing sync objects
|
||||
{
|
||||
u32 syncID = data.rawData[0x04]; // o->oSyncID
|
||||
|
@ -167,15 +169,15 @@ void network_receive_spawn_objects(struct Packet* p) {
|
|||
if (so->o->behavior == get_behavior_from_id(data.behaviorId)) {
|
||||
LOG_ERROR("recieved duplicate sync object with id %d from %s (%s)", syncID, name, id);
|
||||
} else {
|
||||
LOG_ERROR("recieved duplicate sync object with id %d with different behavior %s from %s (%s)", syncID, get_behavior_name_from_id(data.behaviorId), name, id);
|
||||
LOG_ERROR("recieved duplicate sync object with id %d with different behavior %s from %s (%s)", syncID, bhvName, name, id);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("rx spawn object %s from %s (%s)", get_behavior_name_from_id(data.behaviorId), name, id);
|
||||
LOG_CONSOLE("rx spawn object %s from %s\\#dcdcdc\\ (%s)", get_behavior_name_from_id(data.behaviorId), name, id);
|
||||
snprintf(gLastRemoteBhv, 256, "%s %s (%s)", get_behavior_name_from_id(data.behaviorId), name, id);
|
||||
LOG_INFO("rx spawn object %s from %s (%s)", bhvName, name, id);
|
||||
LOG_CONSOLE("rx spawn object %s from %s\\#dcdcdc\\ (%s)", bhvName, name, id);
|
||||
snprintf(gLastRemoteBhv, 256, "%s %s (%s)", bhvName, name, id);
|
||||
|
||||
struct Object* parentObj = NULL;
|
||||
if (data.parentId == (u32)-1) {
|
||||
|
|
|
@ -351,6 +351,7 @@ void* main_game_init(UNUSED void* dummy) {
|
|||
audio_init();
|
||||
sound_init();
|
||||
network_player_init();
|
||||
mumble_init();
|
||||
|
||||
gGameInited = true;
|
||||
}
|
||||
|
@ -465,8 +466,6 @@ int main(int argc, char *argv[]) {
|
|||
network_init(NT_NONE, false);
|
||||
}
|
||||
|
||||
mumble_init();
|
||||
|
||||
// main loop
|
||||
while (true) {
|
||||
debug_context_reset();
|
||||
|
|
Loading…
Reference in a new issue