diff --git a/src/game/behaviors/cap.inc.c b/src/game/behaviors/cap.inc.c index 1c9ae210..84f58e67 100644 --- a/src/game/behaviors/cap.inc.c +++ b/src/game/behaviors/cap.inc.c @@ -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); } diff --git a/src/pc/network/packets/packet_network_players.c b/src/pc/network/packets/packet_network_players.c index 1c19ca5c..eeb86566 100644 --- a/src/pc/network/packets/packet_network_players.c +++ b/src/pc/network/packets/packet_network_players.c @@ -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) { diff --git a/src/pc/network/packets/packet_spawn_objects.c b/src/pc/network/packets/packet_spawn_objects.c index 37ee7373..f18280f0 100644 --- a/src/pc/network/packets/packet_spawn_objects.c +++ b/src/pc/network/packets/packet_spawn_objects.c @@ -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) { diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 62eb0410..f3e0809d 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -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();