I would really like to believe that this just makes foes work in demos

This commit is contained in:
Antonio Martinez 2025-08-03 18:10:05 -04:00 committed by AJ Martinez
parent ec36f6bb01
commit 528eaf0e64
2 changed files with 4 additions and 11 deletions

View file

@ -321,6 +321,7 @@ void G_ReadDemoExtraData(void)
players[p].botvars.difficulty = READUINT8(demobuf.p); players[p].botvars.difficulty = READUINT8(demobuf.p);
players[p].botvars.diffincrease = READINT16(demobuf.p); // needed to avoid having to duplicate logic players[p].botvars.diffincrease = READINT16(demobuf.p); // needed to avoid having to duplicate logic
players[p].botvars.rival = (boolean)READUINT8(demobuf.p); players[p].botvars.rival = (boolean)READUINT8(demobuf.p);
players[p].botvars.foe = (boolean)READUINT8(demobuf.p);
} }
} }
if (extradata & DXD_PLAYSTATE) if (extradata & DXD_PLAYSTATE)
@ -497,6 +498,7 @@ void G_WriteDemoExtraData(void)
WRITEUINT8(demobuf.p, players[i].botvars.difficulty); WRITEUINT8(demobuf.p, players[i].botvars.difficulty);
WRITEINT16(demobuf.p, players[i].botvars.diffincrease); // needed to avoid having to duplicate logic WRITEINT16(demobuf.p, players[i].botvars.diffincrease); // needed to avoid having to duplicate logic
WRITEUINT8(demobuf.p, (UINT8)players[i].botvars.rival); WRITEUINT8(demobuf.p, (UINT8)players[i].botvars.rival);
WRITEUINT8(demobuf.p, (UINT8)players[i].botvars.foe);
} }
} }
if (demo_extradata[i] & DXD_PLAYSTATE) if (demo_extradata[i] & DXD_PLAYSTATE)
@ -2111,6 +2113,7 @@ void G_BeginRecording(void)
WRITEUINT8(demobuf.p, player->botvars.difficulty); WRITEUINT8(demobuf.p, player->botvars.difficulty);
WRITEINT16(demobuf.p, player->botvars.diffincrease); // needed to avoid having to duplicate logic WRITEINT16(demobuf.p, player->botvars.diffincrease); // needed to avoid having to duplicate logic
WRITEUINT8(demobuf.p, (UINT8)player->botvars.rival); WRITEUINT8(demobuf.p, (UINT8)player->botvars.rival);
WRITEUINT8(demobuf.p, (UINT8)player->botvars.foe);
} }
// Name // Name
@ -3222,6 +3225,7 @@ void G_DoPlayDemoEx(const char *defdemoname, lumpnum_t deflumpnum)
players[p].botvars.difficulty = READUINT8(demobuf.p); players[p].botvars.difficulty = READUINT8(demobuf.p);
players[p].botvars.diffincrease = READINT16(demobuf.p); // needed to avoid having to duplicate logic players[p].botvars.diffincrease = READINT16(demobuf.p); // needed to avoid having to duplicate logic
players[p].botvars.rival = (boolean)READUINT8(demobuf.p); players[p].botvars.rival = (boolean)READUINT8(demobuf.p);
players[p].botvars.foe = (boolean)READUINT8(demobuf.p);
} }
K_UpdateShrinkCheat(&players[p]); K_UpdateShrinkCheat(&players[p]);

View file

@ -152,23 +152,17 @@ static INT16 K_RivalScore(player_t *bot)
static boolean CompareRivals(player_t *a, player_t *b) static boolean CompareRivals(player_t *a, player_t *b)
{ {
CONS_Printf("compare foes\n");
if (a == NULL) if (a == NULL)
return false; return false;
if (b == NULL) if (b == NULL)
return true; return true;
CONS_Printf("%s %d VS %s %d\n", player_names[a-players], K_RivalScore(a), player_names[b-players], K_RivalScore(b));
if (K_RivalScore(a) != K_RivalScore(b)) if (K_RivalScore(a) != K_RivalScore(b))
{ {
// Push bad position to the back. // Push bad position to the back.
CONS_Printf("returning known\n");
return (K_RivalScore(a) > K_RivalScore(b)); return (K_RivalScore(a) > K_RivalScore(b));
} }
CONS_Printf("returning shuffle\n");
// They are equals, so just randomize // They are equals, so just randomize
return (P_Random(PR_BOTS) & 1); return (P_Random(PR_BOTS) & 1);
} }
@ -176,7 +170,6 @@ static boolean CompareRivals(player_t *a, player_t *b)
static void K_AssignFoes(void) static void K_AssignFoes(void)
{ {
std::vector<player_t *> bots; std::vector<player_t *> bots;
CONS_Printf("foe assignment\n");
for (UINT8 i = 0; i < MAXPLAYERS; i++) for (UINT8 i = 0; i < MAXPLAYERS; i++)
{ {
if (playeringame[i] == false) if (playeringame[i] == false)
@ -186,20 +179,16 @@ static void K_AssignFoes(void)
if (!player->spectator && player->bot) if (!player->spectator && player->bot)
{ {
CONS_Printf("added %s\n", player_names[i]);
bots.push_back(player); bots.push_back(player);
player->botvars.foe = false; player->botvars.foe = false;
} }
} }
CONS_Printf("sort foes\n");
std::stable_sort(bots.begin(), bots.end(), CompareRivals); std::stable_sort(bots.begin(), bots.end(), CompareRivals);
UINT8 i = 0; UINT8 i = 0;
for (auto &bot : bots) for (auto &bot : bots)
{ {
CONS_Printf("assign foes\n");
if (bot != NULL) if (bot != NULL)
bot->botvars.foe = true; bot->botvars.foe = true;