mirror of
https://gitlab.com/ryandwyer/perfect-dark
synced 2026-06-06 19:41:15 -04:00
Cache the playercount instead of calculating it many times
This commit is contained in:
@@ -30,6 +30,7 @@ void playermgrReset(void)
|
||||
g_Vars.players[1] = NULL;
|
||||
g_Vars.players[2] = NULL;
|
||||
g_Vars.players[3] = NULL;
|
||||
g_Vars.playercount = 0;
|
||||
g_Vars.currentplayer = NULL;
|
||||
g_Vars.currentplayerindex = 0;
|
||||
g_Vars.currentplayerstats = NULL;
|
||||
@@ -49,6 +50,7 @@ void playermgrAllocatePlayers(s32 count)
|
||||
g_Vars.players[1] = NULL;
|
||||
g_Vars.players[2] = NULL;
|
||||
g_Vars.players[3] = NULL;
|
||||
g_Vars.playercount = 0;
|
||||
|
||||
if (count > 0) {
|
||||
s32 i;
|
||||
@@ -67,6 +69,7 @@ void playermgrAllocatePlayers(s32 count)
|
||||
g_Vars.coop = NULL;
|
||||
g_Vars.anti = g_Vars.players[g_Vars.antiplayernum];
|
||||
}
|
||||
|
||||
} else {
|
||||
playermgrAllocatePlayer(0);
|
||||
setCurrentPlayerNum(0);
|
||||
@@ -212,6 +215,7 @@ void playermgrAllocatePlayer(s32 index)
|
||||
s32 i;
|
||||
|
||||
g_Vars.players[index] = mempAlloc(sizeof(struct player), MEMPOOL_STAGE);
|
||||
g_Vars.playercount++;
|
||||
|
||||
g_Vars.players[index]->cameramode = CAMERAMODE_DEFAULT;
|
||||
g_Vars.players[index]->memcampos.x = 0;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#define LINEHEIGHT (VERSION == VERSION_JPN_FINAL ? 14 : 11)
|
||||
#define MIXCOLOUR(dialog, property) dialog->transitionfrac < 0.0f ? g_MenuColourPalettes[dialog->type].property : colourBlend(g_MenuColourPalettes[dialog->type2].property, g_MenuColourPalettes[dialog->type].property, dialog->colourweight)
|
||||
#define MPCHR(index) ((index) < 4 ? &g_PlayerConfigsArray[index].base : &g_BotConfigsArray[(index) - 4].base)
|
||||
#define PLAYERCOUNT() ((g_Vars.players[0] ? 1 : 0) + (g_Vars.players[1] ? 1 : 0) + (g_Vars.players[2] ? 1 : 0) + (g_Vars.players[3] ? 1 : 0))
|
||||
#define PLAYERCOUNT() g_Vars.playercount
|
||||
#define RANDOMFRAC() (random() * (1.0f / U32_MAX))
|
||||
#define SECSTOTIME240(secs) (secs * 240)
|
||||
#define SECSTOTIME60(secs) (secs * 60)
|
||||
|
||||
@@ -235,6 +235,7 @@ struct g_vars {
|
||||
// 00f0 = One bit per pak. Does something with the pak if counter expired.
|
||||
// 0f00 = One bit per pak. Does something with the pak if counter expired (likely opposite of the above).
|
||||
/*0x4e4*/ u16 unk0004e4;
|
||||
u8 playercount;
|
||||
|
||||
/*0x4e8*/ u32 unk0004e8;
|
||||
/*0x4ec*/ u32 unk0004ec;
|
||||
|
||||
Reference in New Issue
Block a user