diff --git a/src/game/chr.c b/src/game/chr.c index 0eed5c512..08cb6fbd5 100644 --- a/src/game/chr.c +++ b/src/game/chr.c @@ -4952,7 +4952,7 @@ struct prop *chrGetTargetProp(struct chrdata *chr) struct prop *ret; if (chr->target == -1) { - ret = g_Vars.allyplayers[chr->p1p2]->prop; + ret = g_Vars.players[chr->p1p2]->prop; } else { ret = g_Vars.props + chr->target; } diff --git a/src/game/chraction.c b/src/game/chraction.c index 5223bd4a4..794956119 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -14227,21 +14227,20 @@ s32 chrResolveId(struct chrdata *ref, s32 id) break; case CHR_P1P2: { - u32 index = g_Vars.currentallyplayernum; - struct player *player = g_Vars.allyplayers[index]; - if (player && player->prop && player->prop->chr) { + u32 index = g_Vars.coopplayernum >= 0 ? ref->p1p2 : g_Vars.bondplayernum; + struct player *player = g_Vars.players[index]; + if (player && player->prop && player->prop->chr && !g_Vars.antiplayers[index]) { id = player->prop->chr->chrnum; } } break; case CHR_P1P2_OPPOSITE: - u32 index = g_Vars.bondplayernum; - if (g_Vars.currentcoopplayernum != g_Vars.currentplayernum) { - index = g_Vars.currentcoopplayernum; - } - struct player *player = g_Vars.players[index]; - if (player && player->prop && player->prop->chr) { - id = player->prop->chr->chrnum; + if (g_Vars.coopplayernum >= 0) { + s32 index = (MAX_PLAYERS-1)-ref->p1p2;; + struct player *player = g_Vars.players[index]; + if (player && player->prop && player->prop->chr && !g_Vars.antiplayers[index]) { + id = player->prop->chr->chrnum; + } } break; case CHR_TARGET: @@ -14272,21 +14271,18 @@ s32 chrResolveId(struct chrdata *ref, s32 id) break; case CHR_P1P2: { - u32 index = g_Vars.currentallyplayernum; - struct player *player = g_Vars.allyplayers[index]; + struct player *player = g_Vars.players[g_Vars.bondplayernum]; if (player && player->prop && player->prop->chr) { id = player->prop->chr->chrnum; } } break; case CHR_P1P2_OPPOSITE: - u32 index = g_Vars.bondplayernum; - if (g_Vars.currentcoopplayernum != g_Vars.currentplayernum) { - index = g_Vars.currentcoopplayernum; - } - struct player *player = g_Vars.players[index]; - if (player && player->prop && player->prop->chr) { - id = player->prop->chr->chrnum; + if (g_Vars.coopplayernum >= 0) { + struct player *player = g_Vars.players[g_Vars.coopplayernum]; + if (player && player->prop && player->prop->chr) { + id = player->prop->chr->chrnum; + } } break; } diff --git a/src/game/chraicommands.c b/src/game/chraicommands.c index d4edfc02b..0db3b9c8b 100644 --- a/src/game/chraicommands.c +++ b/src/game/chraicommands.c @@ -516,8 +516,6 @@ struct player** getPlayerPool(u32 chrId) { playerpool = (struct player**)g_Vars.coopplayers; break; case CHR_P1P2: - playerpool = (struct player**)g_Vars.allyplayers; - break; default: playerpool = (struct player**)g_Vars.players; break; @@ -1682,7 +1680,7 @@ bool aiIfSeesSuspiciousItem(void) */ bool aiIfCheckFovWithTarget(void) { - bool pass; + bool pass = 0; u8 *cmd = g_Vars.ailist + g_Vars.aioffset; u16 temptarget = g_Vars.chrdata->target; @@ -1691,7 +1689,7 @@ bool aiIfCheckFovWithTarget(void) if (cmd[3]) { if (isChrTargetCoop(g_Vars.chrdata)) { temptarget = g_Vars.chrdata->target; - for (s32 i = 0; i < PLAYERCOUNT(); i++) { + for (s32 i = 0; i < MAX_PLAYERS; i++) { if (pass) break; if (!g_Vars.coopplayers[i]) continue; chrSetTargetProp(g_Vars.chrdata, g_Vars.coopplayers[i]->prop); @@ -1702,7 +1700,7 @@ bool aiIfCheckFovWithTarget(void) } else { if (isChrTargetCoop(g_Vars.chrdata)) { temptarget = g_Vars.chrdata->target; - for (s32 i = 0; i < PLAYERCOUNT(); i++) { + for (s32 i = 0; i < MAX_PLAYERS; i++) { if (pass) break; if (!g_Vars.coopplayers[i]) continue; chrSetTargetProp(g_Vars.chrdata, g_Vars.coopplayers[i]->prop); @@ -1714,7 +1712,7 @@ bool aiIfCheckFovWithTarget(void) } else { if (isChrTargetCoop(g_Vars.chrdata)) { temptarget = g_Vars.chrdata->target; - for (s32 i = 0; i < PLAYERCOUNT(); i++) { + for (s32 i = 0; i < MAX_PLAYERS; i++) { if (pass) break; if (!g_Vars.coopplayers[i]) continue; chrSetTargetProp(g_Vars.chrdata, g_Vars.coopplayers[i]->prop); @@ -9271,10 +9269,10 @@ bool aiToggleP1P2(void) struct chrdata *chr = chrFindById(g_Vars.chrdata, cmd[2]); if (chr) { - if (g_Vars.allyplayers[g_Vars.currentallyplayernum]->isdead) { - chr->p1p2 = 0; - } else { - chr->p1p2 = g_Vars.currentallyplayernum; + if (chr->p1p2 == g_Vars.bondplayernum && !g_Vars.coop->isdead) { + chr->p1p2 = g_Vars.coopplayernum; + } else if (!g_Vars.bond->isdead) { + chr->p1p2 = g_Vars.bondplayernum; } } } @@ -9300,9 +9298,9 @@ bool aiChrSetP1P2(void) if (!g_Vars.players[playernum]->isdead) { if (chr2->prop == g_Vars.coop->prop) { - chr1->p1p2 = g_Vars.currentallyplayernum; + chr1->p1p2 = g_Vars.coopplayernum; } else { - chr1->p1p2 = 0; + chr1->p1p2 = g_Vars.bondplayernum; } } } diff --git a/src/game/lv.c b/src/game/lv.c index b3c2b4b6e..c3468bd32 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -1338,14 +1338,6 @@ Gfx *lvRender(Gfx *gdl) gdl = nbombsRender(gdl); } - // printf("g_Vars.currentplayernum = %d\n", g_Vars.currentplayernum); - // printf("g_Vars.currentantiplayernum = %d\n", g_Vars.currentantiplayernum); - // printf("g_Vars.currentallyplayernum = %d\n", g_Vars.currentallyplayernum); - // printf("g_Vars.currentcoopplayernum = %d\n", g_Vars.currentcoopplayernum); - // printf("p1p2 playernum: %x\n", playermgrGetPlayerNumByProp(chrFindByLiteralId(chrResolveId(0, CHR_P1P2))->prop)); - // printf("p1p2_opposite_prop: %x\n",(chrFindByLiteralId(chrResolveId(0, CHR_P1P2_OPPOSITE)))); - // printf("bond_prop: %x\n", g_Vars.bond->prop); - if (var80075d60 == 2) { gdl = playerRenderHud(gdl); diff --git a/src/game/playermgr.c b/src/game/playermgr.c index 1e4f82cae..04118aa7a 100644 --- a/src/game/playermgr.c +++ b/src/game/playermgr.c @@ -129,18 +129,6 @@ void playermgrAllocatePlayersFromRoles(void) g_Vars.bond = g_Vars.players[g_Vars.bondplayernum]; - // setup ally players here - // we'll need to update this - // when the coop list changes - s32 allyindex = 0; - g_Vars.allyplayers[0] = g_Vars.bond; - for (s32 i = 0; i < MAX_PLAYERS; i++) { - if (g_Vars.coopplayers[i]) { - g_Vars.allyplayers[++allyindex] = g_Vars.coopplayers[i]; - } - } - g_Vars.currentallyplayernum = allyindex; - setCurrentPlayerNum(0); // don't think this needed for player loading but probably is there to restart the playerloop } @@ -793,6 +781,7 @@ void setCurrentCoopNum(s32 playernum) { if (g_Vars.coopplayers[playernum]) { g_Vars.currentcoopplayernum = playernum; + g_Vars.currentallyplayernum = playernum % (getNumAllyPlayers() - 1); g_Vars.coopplayernum = playernum; g_Vars.coop = g_Vars.coopplayers[playernum]; g_Vars.antiplayernum = -1; @@ -805,15 +794,15 @@ void setCurrentPlayerNum(s32 playernum) g_Vars.currentplayernum = playernum; g_Vars.currentplayer = g_Vars.players[playernum]; g_Vars.currentplayerstats = &g_Vars.playerstats[playernum]; - if (g_Vars.antiplayers[playernum]) { + if (g_Vars.currentplayernum == g_Vars.bondplayernum) { + g_Vars.currentallyplayernum = g_Vars.bondplayernum; + } + else if (g_Vars.antiplayers[playernum]) { setCurrentAntiNum(playernum); } else if (g_Vars.coopplayers[playernum]) { setCurrentCoopNum(playernum); } - - g_Vars.currentallyplayernum++; - if (!g_Vars.allyplayers[g_Vars.currentallyplayernum]) g_Vars.currentallyplayernum = 0; g_Vars.currentplayerindex = playermgrGetOrderOfPlayer(playernum); } diff --git a/src/game/title.c b/src/game/title.c index 40f45df98..a8aeaaf76 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -2238,21 +2238,6 @@ s32 getNumAllyPlayers(void) } -s32 getNumAntiPlayers(void) -{ - s32 count = 0; - s32 i; - - for (i = 0; i < MAX_PLAYERS; i++) { - if (g_Vars.playerroles[i] && g_Vars.playerroles[i] == PLAYERROLE_ANTI) { - count++; - } - } - - return count; - -} - s32 getNumTeamModePlayers(void) { s32 count = 0; diff --git a/src/include/game/title.h b/src/include/game/title.h index 7cd5c023c..4752c72ae 100644 --- a/src/include/game/title.h +++ b/src/include/game/title.h @@ -63,7 +63,6 @@ void titleExitLegal(void); s32 getNumPlayers(void); s32 getNumTeamModePlayers(void); s32 getNumAllyPlayers(void); -s32 getNumAntiPlayers(void); void setNumPlayers(s32 numplayers); void titleExitNoController(void);