From a613da43dd99ce21b4ceab325c7bfaabe9783e94 Mon Sep 17 00:00:00 2001 From: ChillyDoom Date: Sat, 8 Nov 2014 17:38:09 +0000 Subject: [PATCH 1/7] - Bot movement is now calculated locally. --- src/b_bot.cpp | 14 ++++-- src/b_bot.h | 3 -- src/b_game.cpp | 66 +++++++++++++------------- src/d_main.cpp | 19 -------- src/d_net.cpp | 108 ++++++++---------------------------------- src/g_game.cpp | 6 +++ src/p_interaction.cpp | 2 +- src/p_mobj.cpp | 2 +- src/version.h | 2 +- 9 files changed, 71 insertions(+), 151 deletions(-) diff --git a/src/b_bot.cpp b/src/b_bot.cpp index eb2052a26..dc6f2cdc4 100644 --- a/src/b_bot.cpp +++ b/src/b_bot.cpp @@ -30,8 +30,6 @@ DBot::DBot () void DBot::Clear () { - savedyaw = 0; - savedpitch = 0; angle = 0; dest = NULL; prev = NULL; @@ -59,9 +57,15 @@ void DBot::Serialize (FArchive &arc) { Super::Serialize (arc); - arc << savedyaw - << savedpitch - << angle + if (SaveVersion < 4515) + { + angle_t savedyaw; + int savedpitch; + arc << savedyaw + << savedpitch; + } + + arc << angle << dest << prev << enemy diff --git a/src/b_bot.h b/src/b_bot.h index 375b09abb..1862faee5 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -165,9 +165,6 @@ public: void Clear (); void Serialize (FArchive &arc); - angle_t savedyaw; - int savedpitch; - angle_t angle; // The wanted angle that the bot try to get every tic. // (used to get a smooth view movement) TObjPtr dest; // Move Destination. diff --git a/src/b_game.cpp b/src/b_game.cpp index f13c168db..853ba7f23 100644 --- a/src/b_game.cpp +++ b/src/b_game.cpp @@ -102,7 +102,7 @@ void FCajunMaster::Main (int buf) BotThinkCycles.Reset(); - if (consoleplayer != Net_Arbitrator || demoplayback) + if (demoplayback) return; if (gamestate != GS_LEVEL) @@ -122,37 +122,40 @@ void FCajunMaster::Main (int buf) BotThinkCycles.Unclock(); } - //Add new bots? - if (wanted_botnum > botnum && !freeze) + if (consoleplayer == Net_Arbitrator) { - if (t_join == ((wanted_botnum - botnum) * SPAWN_DELAY)) + //Add new bots? + if (wanted_botnum > botnum && !freeze) { - if (!SpawnBot (getspawned[spawn_tries])) - wanted_botnum--; - spawn_tries++; + if (t_join == ((wanted_botnum - botnum) * SPAWN_DELAY)) + { + if (!SpawnBot (getspawned[spawn_tries])) + wanted_botnum--; + spawn_tries++; + } + + t_join--; } - t_join--; - } - - //Check if player should go observer. Or un observe - if (bot_observer && !observer && !netgame) - { - Printf ("%s is now observer\n", players[consoleplayer].userinfo.GetName()); - observer = true; - players[consoleplayer].mo->UnlinkFromWorld (); - players[consoleplayer].mo->flags = MF_DROPOFF|MF_NOBLOCKMAP|MF_NOCLIP|MF_NOTDMATCH|MF_NOGRAVITY|MF_FRIENDLY; - players[consoleplayer].mo->flags2 |= MF2_FLY; - players[consoleplayer].mo->LinkToWorld (); - } - else if (!bot_observer && observer && !netgame) //Go back - { - Printf ("%s returned to the fray\n", players[consoleplayer].userinfo.GetName()); - observer = false; - players[consoleplayer].mo->UnlinkFromWorld (); - players[consoleplayer].mo->flags = MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_PICKUP|MF_NOTDMATCH|MF_FRIENDLY; - players[consoleplayer].mo->flags2 &= ~MF2_FLY; - players[consoleplayer].mo->LinkToWorld (); + //Check if player should go observer. Or un observe + if (bot_observer && !observer && !netgame) + { + Printf ("%s is now observer\n", players[consoleplayer].userinfo.GetName()); + observer = true; + players[consoleplayer].mo->UnlinkFromWorld (); + players[consoleplayer].mo->flags = MF_DROPOFF|MF_NOBLOCKMAP|MF_NOCLIP|MF_NOTDMATCH|MF_NOGRAVITY|MF_FRIENDLY; + players[consoleplayer].mo->flags2 |= MF2_FLY; + players[consoleplayer].mo->LinkToWorld (); + } + else if (!bot_observer && observer && !netgame) //Go back + { + Printf ("%s returned to the fray\n", players[consoleplayer].userinfo.GetName()); + observer = false; + players[consoleplayer].mo->UnlinkFromWorld (); + players[consoleplayer].mo->flags = MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_PICKUP|MF_NOTDMATCH|MF_FRIENDLY; + players[consoleplayer].mo->flags2 &= ~MF2_FLY; + players[consoleplayer].mo->LinkToWorld (); + } } m_Thinking = false; @@ -348,11 +351,8 @@ void FCajunMaster::TryAddBot (BYTE **stream, int player) if (DoAddBot ((BYTE *)info, skill)) { - if (consoleplayer == Net_Arbitrator) - { - //Increment this. - botnum++; - } + //Increment this. + botnum++; if (thebot != NULL) { diff --git a/src/d_main.cpp b/src/d_main.cpp index e08b1539e..7eb09c4e4 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -975,25 +975,6 @@ void D_DoomLoop () I_StartTic (); D_ProcessEvents (); G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]); - //Added by MC: For some of that bot stuff. The main bot function. - int i; - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && players[i].Bot != NULL && players[i].mo) - { - players[i].Bot->savedyaw = players[i].mo->angle; - players[i].Bot->savedpitch = players[i].mo->pitch; - } - } - bglobal.Main (maketic%BACKUPTICS); - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && players[i].Bot != NULL && players[i].mo) - { - players[i].mo->angle = players[i].Bot->savedyaw; - players[i].mo->pitch = players[i].Bot->savedpitch; - } - } if (advancedemo) D_DoAdvanceDemo (); C_Ticker (); diff --git a/src/d_net.cpp b/src/d_net.cpp index 3d0d20b41..c3e656c45 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -824,7 +824,6 @@ void GetPackets (void) } if (netbuffer[0] & NCMD_QUITTERS) - { numplayers = netbuffer[k++]; for (int i = 0; i < numplayers; ++i) @@ -902,64 +901,18 @@ void GetPackets (void) for (i = 0; i < numplayers; ++i) { - int node = (players[playerbytes[i]].Bot == NULL) ? - nodeforplayer[playerbytes[i]] : netnode; + int node = nodeforplayer[playerbytes[i]]; SkipTicCmd (&start, nettics[node] - realstart); for (tics = nettics[node]; tics < realend; tics++) ReadTicCmd (&start, playerbytes[i], tics); - } - // Update the number of tics received from each node. This must - // be separate from the above loop in case the master is also - // sending bot movements. If it's not separate, then the bots - // will only move on the master, because the other players will - // read the master's tics and then think they already got all - // the tics for the bots and skip the bot tics included in the - // packet. - for (i = 0; i < numplayers; ++i) - { - if (players[playerbytes[i]].Bot == NULL) - { - nettics[nodeforplayer[playerbytes[i]]] = realend; - } - } - } - } -} -void AdjustBots (int gameticdiv) -{ - // [RH] This loop adjusts the bots' rotations for ticcmds that have - // been already created but not yet executed. This way, the bot is still - // able to create ticcmds that accurately reflect the state it wants to - // be in even when gametic lags behind maketic. - for (int i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && players[i].Bot != NULL && players[i].mo) - { - players[i].Bot->savedyaw = players[i].mo->angle; - players[i].Bot->savedpitch = players[i].mo->pitch; - for (int j = gameticdiv; j < maketic/ticdup; j++) - { - players[i].mo->angle += (netcmds[i][j%BACKUPTICS].ucmd.yaw << 16) * ticdup; - players[i].mo->pitch -= (netcmds[i][j%BACKUPTICS].ucmd.pitch << 16) * ticdup; + nettics[nodeforplayer[playerbytes[i]]] = realend; } } } } -void UnadjustBots () -{ - for (int i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && players[i].Bot != NULL && players[i].mo) - { - players[i].mo->angle = players[i].Bot->savedyaw; - players[i].mo->pitch = players[i].Bot->savedpitch; - } - } -} - // // NetUpdate // Builds ticcmds for console player, @@ -1006,9 +959,7 @@ void NetUpdate (void) newtics = 0; } - // build new ticcmds for console player (and bots if I am the arbitrator) - AdjustBots (gametic / ticdup); - + // build new ticcmds for console player for (i = 0; i < newtics; i++) { I_StartTic (); @@ -1018,11 +969,6 @@ void NetUpdate (void) //Printf ("mk:%i ",maketic); G_BuildTiccmd (&localcmds[maketic % LOCALCMDTICS]); - if (maketic % ticdup == 0) - { - //Added by MC: For some of that bot stuff. The main bot function. - bglobal.Main ((maketic / ticdup) % BACKUPTICS); - } maketic++; if (ticdup == 1 || maketic == 0) @@ -1102,8 +1048,6 @@ void NetUpdate (void) } } - UnadjustBots (); - if (singletics) return; // singletic update is synchronous @@ -1123,14 +1067,11 @@ void NetUpdate (void) if (consoleplayer == Net_Arbitrator) { - for (j = 0; j < MAXPLAYERS; j++) + for (j = 0; j < doomcom.numnodes; j++) { - if (playeringame[j]) + if (nodeingame[j] && NetMode == NET_PacketServer) { - if (players[j].Bot != NULL || NetMode == NET_PacketServer) - { - count++; - } + count++; } } @@ -1265,15 +1206,12 @@ void NetUpdate (void) netbuffer[0] |= NCMD_MULTI; netbuffer[k++] = count; - for (l = 1, j = 0; j < MAXPLAYERS; j++) + for (l = 1, j = 0; j < doomcom.numnodes; j++) { - if (playeringame[j] && j != playerfornode[i] && j != consoleplayer) + if (nodeingame[j] && j != i && j != nodeforplayer[consoleplayer] && NetMode == NET_PacketServer) { - if (players[j].Bot != NULL || NetMode == NET_PacketServer) - { - playerbytes[l++] = j; - netbuffer[k++] = j; - } + playerbytes[l++] = playerfornode[j]; + netbuffer[k++] = playerfornode[j]; } } } @@ -1293,7 +1231,7 @@ void NetUpdate (void) prev %= BACKUPTICS; // The local player has their tics sent first, followed by - // the other players/bots. + // the other players. if (l == 0) { WriteWord (localcmds[localstart].consistancy, &cmddata); @@ -1308,23 +1246,17 @@ void NetUpdate (void) } else if (i != 0) { - if (players[playerbytes[l]].Bot != NULL) - { - WriteWord (0, &cmddata); // fake consistancy word - } - else - { - int len; - BYTE *spec; + int len; + BYTE *spec; - WriteWord (netcmds[playerbytes[l]][start].consistancy, &cmddata); - spec = NetSpecs[playerbytes[l]][start].GetData (&len); - if (spec != NULL) - { - memcpy (cmddata, spec, len); - cmddata += len; - } + WriteWord (netcmds[playerbytes[l]][start].consistancy, &cmddata); + spec = NetSpecs[playerbytes[l]][start].GetData (&len); + if (spec != NULL) + { + memcpy (cmddata, spec, len); + cmddata += len; } + WriteUserCmdMessage (&netcmds[playerbytes[l]][start].ucmd, prev >= 0 ? &netcmds[playerbytes[l]][prev].ucmd : NULL, &cmddata); } diff --git a/src/g_game.cpp b/src/g_game.cpp index 1ea1c6b68..af4a5411e 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1127,6 +1127,12 @@ void G_Ticker () // check, not just the player's x position like BOOM. DWORD rngsum = FRandom::StaticSumSeeds (); + if ((gametic % ticdup) == 0) + { + //Added by MC: For some of that bot stuff. The main bot function. + bglobal.Main (buf); + } + for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index d0d115217..88d95b25e 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -606,7 +606,7 @@ void AActor::Die (AActor *source, AActor *inflictor, int dmgflags) player->respawn_time = level.time + TICRATE; //Added by MC: Respawn bots - if (bglobal.botnum && consoleplayer == Net_Arbitrator && !demoplayback) + if (bglobal.botnum && !demoplayback) { if (player->Bot != NULL) player->Bot->t_respawn = (pr_botrespawn()%15)+((bglobal.botnum-1)*2)+TICRATE+1; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index bae4563b3..c7bfcea21 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3228,7 +3228,7 @@ void AActor::Tick () } } - if (bglobal.botnum && consoleplayer == Net_Arbitrator && !demoplayback && + if (bglobal.botnum && !demoplayback && ((flags & (MF_SPECIAL|MF_MISSILE)) || (flags3 & MF3_ISMONSTER))) { BotSupportCycles.Clock(); diff --git a/src/version.h b/src/version.h index d9597d2f4..f091f416a 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4514 +#define SAVEVER 4515 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) From 8532b52ffb38f99f8f1374fab0d99ff85e4a1cec Mon Sep 17 00:00:00 2001 From: ChillyDoom Date: Sat, 8 Nov 2014 17:38:56 +0000 Subject: [PATCH 2/7] - Bots are no longer removed when the net arbitrator disconnects. --- src/d_net.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index c3e656c45..4fcd66bd4 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -691,9 +691,6 @@ void PlayerIsGone (int netnode, int netconsole) if (netconsole == Net_Arbitrator) { - bglobal.RemoveAllBots(true); - Printf("Removed all bots\n"); - // Pick a new network arbitrator for (int i = 0; i < MAXPLAYERS; i++) { From 8b85e6d00b2545b6e8c60c8edacd1e84d08d2e68 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Sat, 8 Nov 2014 17:59:45 +0100 Subject: [PATCH 3/7] - Port an empty version of 'A_FaceConsolePlayer'. Hissies will be happy now. --- src/thingdef/thingdef_codeptr.cpp | 11 +++++++++++ wadsrc/static/actors/actor.txt | 1 + 2 files changed, 12 insertions(+) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 2732337c7..81d0fc4b7 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3781,6 +3781,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_RaiseSiblings) } } +//=========================================================================== +// +// [TP] A_FaceConsolePlayer +// +//=========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_FaceConsolePlayer) { + ACTION_PARAM_START (1); + ACTION_PARAM_ANGLE (MaxTurnAngle, 0); + // NOTE: It does nothing for zdoom. +} + //=========================================================================== // // A_MonsterRefire diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index e253f53ac..468b0f7b5 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -186,6 +186,7 @@ ACTOR Actor native //: Thinker action native A_ClearSoundTarget(); action native A_FireAssaultGun(); action native A_CheckTerrain(); + action native A_FaceConsolePlayer(float MaxTurnAngle = 0); // [TP] action native A_MissileAttack(); action native A_MeleeAttack(); From 87207bdb6d5c02c332c30ab941cba19951cc546e Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Sun, 9 Nov 2014 00:16:10 -0600 Subject: [PATCH 4/7] - Fixed: The mask didn't incorporate RGF_MISSILES, causing it to fail. --- src/thingdef/thingdef_codeptr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 2732337c7..ff7fb9dd2 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -4678,7 +4678,7 @@ enum RadiusGiveFlags RGF_OBJECTS = 1 << 3, RGF_VOODOO = 1 << 4, RGF_CORPSES = 1 << 5, - RGF_MASK = 63, + RGF_MASK = 2111, RGF_NOTARGET = 1 << 6, RGF_NOTRACER = 1 << 7, RGF_NOMASTER = 1 << 8, From e3640b5bf510cec6ec726c5060fe709d97fbb8c0 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Sun, 9 Nov 2014 21:06:50 +1300 Subject: [PATCH 5/7] Stop DLevelScript from recursively Serializing --- src/p_acs.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- src/version.h | 2 +- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 4150ee231..59a5840fd 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2881,9 +2881,55 @@ DACSThinker::~DACSThinker () void DACSThinker::Serialize (FArchive &arc) { int scriptnum; + int scriptcount = 0; Super::Serialize (arc); - arc << Scripts << LastScript; + if (SaveVersion < 4515) + arc << Scripts << LastScript; + else + { + if (arc.IsStoring()) + { + DLevelScript *script; + script = Scripts; + while (true) + { + scriptcount++; + + // We want to store this list backwards, so we can't loose the last pointer + if (script->next == NULL) + break; + script = script->next; + } + arc << scriptcount; + + while (script) + { + arc << script; + script = script->prev; + } + } + else + { + // We are running through this list backwards, so the next entry is the last processed + DLevelScript *next = NULL; + arc << scriptcount; + for (int i = 0; i < scriptcount; i++) + { + arc << Scripts; + + Scripts->next = next; + Scripts->prev = NULL; + if (next != NULL) + next->prev = Scripts; + + next = Scripts; + + if (i == 0) + LastScript = Scripts; + } + } + } if (arc.IsStoring ()) { ScriptMap::Iterator it(RunningScripts); @@ -2969,7 +3015,8 @@ void DLevelScript::Serialize (FArchive &arc) DWORD i; Super::Serialize (arc); - arc << next << prev; + if (SaveVersion < 4515) + arc << next << prev; P_SerializeACSScriptNumber(arc, script, false); diff --git a/src/version.h b/src/version.h index d9597d2f4..f091f416a 100644 --- a/src/version.h +++ b/src/version.h @@ -76,7 +76,7 @@ const char *GetVersionString(); // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. -#define SAVEVER 4514 +#define SAVEVER 4515 #define SAVEVERSTRINGIFY2(x) #x #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) From 5170abfeed08d20826abe453638234c4a1fc6461 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Sun, 9 Nov 2014 22:57:14 +1300 Subject: [PATCH 6/7] DACSThinker can exist with no scripts --- src/p_acs.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 59a5840fd..03de8b3df 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -2892,7 +2892,7 @@ void DACSThinker::Serialize (FArchive &arc) { DLevelScript *script; script = Scripts; - while (true) + while (script) { scriptcount++; @@ -2914,6 +2914,8 @@ void DACSThinker::Serialize (FArchive &arc) // We are running through this list backwards, so the next entry is the last processed DLevelScript *next = NULL; arc << scriptcount; + Scripts = NULL; + LastScript = NULL; for (int i = 0; i < scriptcount; i++) { arc << Scripts; From d64a4a17ff9a306e55d451190d96a46bccc29a38 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 9 Nov 2014 12:11:58 +0100 Subject: [PATCH 7/7] - fixed: PRINT_LOG no longer worked since replacing the console buffer. --- src/c_console.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/c_console.cpp b/src/c_console.cpp index e7c7dc30b..9dcaa0820 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -561,6 +561,11 @@ int PrintString (int printlevel, const char *outline) maybedrawnow (false, false); } } + else if (Logfile != NULL) + { + fputs (outline, Logfile); + fflush (Logfile); + } return (int)strlen (outline); }