From 06e5dd1d86f3bec914d5921f0425a816d01011b1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 29 Jan 2019 04:27:21 +0100 Subject: [PATCH] - Handle level in bot code --- src/b_bot.h | 6 +++--- src/b_game.cpp | 12 ++++++------ src/d_main.cpp | 2 +- src/d_net.cpp | 4 ++-- src/g_game.cpp | 2 +- src/g_level.cpp | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/b_bot.h b/src/b_bot.h index a24f07a46..cdcda5b6a 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -120,8 +120,8 @@ public: void Init (); void End(); bool SpawnBot (const char *name, int color = NOCOLOR); - void TryAddBot (uint8_t **stream, int player); - void RemoveAllBots (bool fromlist); + void TryAddBot (FLevelLocals *Level, uint8_t **stream, int player); + void RemoveAllBots (FLevelLocals *Level, bool fromlist); bool LoadBots (); void ForgetBots (); @@ -153,7 +153,7 @@ public: private: //(b_game.cpp) - bool DoAddBot (uint8_t *info, botskill_t skill); + bool DoAddBot (FLevelLocals *Level, uint8_t *info, botskill_t skill); protected: bool ctf; diff --git a/src/b_game.cpp b/src/b_game.cpp index 3dd90d224..beed7f3b3 100644 --- a/src/b_game.cpp +++ b/src/b_game.cpp @@ -340,7 +340,7 @@ bool FCajunMaster::SpawnBot (const char *name, int color) return true; } -void FCajunMaster::TryAddBot (uint8_t **stream, int player) +void FCajunMaster::TryAddBot (FLevelLocals *Level, uint8_t **stream, int player) { int botshift = ReadByte (stream); char *info = ReadString (stream); @@ -363,7 +363,7 @@ void FCajunMaster::TryAddBot (uint8_t **stream, int player) } } - if (DoAddBot ((uint8_t *)info, skill)) + if (DoAddBot (Level,(uint8_t *)info, skill)) { //Increment this. botnum++; @@ -384,7 +384,7 @@ void FCajunMaster::TryAddBot (uint8_t **stream, int player) delete[] info; } -bool FCajunMaster::DoAddBot (uint8_t *info, botskill_t skill) +bool FCajunMaster::DoAddBot (FLevelLocals *Level, uint8_t *info, botskill_t skill) { int bnum; @@ -405,7 +405,7 @@ bool FCajunMaster::DoAddBot (uint8_t *info, botskill_t skill) D_ReadUserInfoStrings (bnum, &info, false); multiplayer = true; //Prevents cheating and so on; emulates real netgame (almost). - players[bnum].Bot = level.CreateThinker(); + players[bnum].Bot = Level->CreateThinker(); players[bnum].Bot->player = &players[bnum]; players[bnum].Bot->skill = skill; playeringame[bnum] = true; @@ -417,11 +417,11 @@ bool FCajunMaster::DoAddBot (uint8_t *info, botskill_t skill) else Printf ("%s joined the game\n", players[bnum].userinfo.GetName()); - level.DoReborn (bnum, true); + Level->DoReborn (bnum, true); return true; } -void FCajunMaster::RemoveAllBots (bool fromlist) +void FCajunMaster::RemoveAllBots (FLevelLocals *Level, bool fromlist) { int i, j; diff --git a/src/d_main.cpp b/src/d_main.cpp index 098eb6876..e835e33a1 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -954,7 +954,7 @@ void D_Display () void D_ErrorCleanup () { savegamerestore = false; - bglobal.RemoveAllBots (true); + bglobal.RemoveAllBots (&level, true); D_QuitNetGame (); if (demorecording || demoplayback) G_CheckDemoStatus (); diff --git a/src/d_net.cpp b/src/d_net.cpp index f062e8ddf..abd703d13 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2230,11 +2230,11 @@ void Net_DoCommand (int type, uint8_t **stream, int player) break; case DEM_ADDBOT: - bglobal.TryAddBot (stream, player); + bglobal.TryAddBot (&level, stream, player); break; case DEM_KILLBOTS: - bglobal.RemoveAllBots (true); + bglobal.RemoveAllBots (&level, true); Printf ("Removed all bots\n"); break; diff --git a/src/g_game.cpp b/src/g_game.cpp index 6490ab25e..119e99ee5 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1893,7 +1893,7 @@ void G_DoLoadGame () // Read intermission data for hubs G_SerializeHub(arc); - bglobal.RemoveAllBots(true); + bglobal.RemoveAllBots(&level, true); FString cvar; arc("importantcvars", cvar); diff --git a/src/g_level.cpp b/src/g_level.cpp index 0017d9334..07b98057c 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1161,7 +1161,7 @@ void FLevelLocals::WorldDone (void) //Added by mc if (deathmatch) { - bglobal.RemoveAllBots(consoleplayer != Net_Arbitrator); + bglobal.RemoveAllBots(this, consoleplayer != Net_Arbitrator); } if (flags & LEVEL_CHANGEMAPCHEAT)