diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9be3c5387..48a0a99f0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -624,6 +624,7 @@ file( GLOB HEADER_FILES common/scripting/vm/*h common/scripting/jit/*h common/scripting/interface/*.h + common/scripting/backend/*.h utility/*.h scripting/*.h scripting/backend/*.h @@ -1043,9 +1044,7 @@ set (PCH_SOURCES scripting/thingdef.cpp scripting/thingdef_data.cpp scripting/thingdef_properties.cpp - scripting/backend/codegen.cpp scripting/backend/codegen_doom.cpp - scripting/backend/vmbuilder.cpp scripting/decorate/olddecorations.cpp scripting/decorate/thingdef_exp.cpp scripting/decorate/thingdef_parse.cpp @@ -1147,6 +1146,7 @@ set (PCH_SOURCES common/engine/renderstyle.cpp common/engine/v_colortables.cpp common/engine/serializer.cpp + common/engine/m_random.cpp common/objects/dobject.cpp common/objects/dobjgc.cpp common/objects/dobjtype.cpp @@ -1159,8 +1159,9 @@ set (PCH_SOURCES common/scripting/vm/vmexec.cpp common/scripting/vm/vmframe.cpp common/scripting/interface/stringformat.cpp + common/scripting/backend/vmbuilder.cpp + common/scripting/backend/codegen.cpp - utility/m_random.cpp utility/nodebuilder/nodebuild.cpp utility/nodebuilder/nodebuild_classify_nosse2.cpp utility/nodebuilder/nodebuild_events.cpp @@ -1252,6 +1253,8 @@ include_directories( . common/scripting/vm common/scripting/jit common/scripting/core + common/scripting/interface + common/scripting/backend g_statusbar console playsim diff --git a/src/utility/m_random.cpp b/src/common/engine/m_random.cpp similarity index 93% rename from src/utility/m_random.cpp rename to src/common/engine/m_random.cpp index 41fc4e50c..3af14526b 100644 --- a/src/utility/m_random.cpp +++ b/src/common/engine/m_random.cpp @@ -59,7 +59,6 @@ #include -#include "doomstat.h" #include "m_random.h" #include "serializer.h" #include "m_crc32.h" @@ -80,11 +79,7 @@ // EXTERNAL DATA DECLARATIONS ---------------------------------------------- -extern FRandom pr_spawnmobj; -extern FRandom pr_acs; -extern FRandom pr_chase; -extern FRandom pr_exrandom; -extern FRandom pr_damagemobj; +FRandom pr_exrandom("EX_Random"); // PUBLIC DATA DEFINITIONS ------------------------------------------------- @@ -260,25 +255,6 @@ void FRandom::Init(uint32_t seed) SFMTObj::Init(NameCRC, seed); } -//========================================================================== -// -// FRandom :: StaticSumSeeds -// -// This function produces a uint32_t that can be used to check the consistancy -// of network games between different machines. Only a select few RNGs are -// used for the sum, because not all RNGs are important to network sync. -// -//========================================================================== - -uint32_t FRandom::StaticSumSeeds () -{ - return - pr_spawnmobj.sfmt.u[0] + pr_spawnmobj.idx + - pr_acs.sfmt.u[0] + pr_acs.idx + - pr_chase.sfmt.u[0] + pr_chase.idx + - pr_damagemobj.sfmt.u[0] + pr_damagemobj.idx; -} - //========================================================================== // // FRandom :: StaticWriteRNGState diff --git a/src/utility/m_random.h b/src/common/engine/m_random.h similarity index 98% rename from src/utility/m_random.h rename to src/common/engine/m_random.h index 24742efed..d9eec6c44 100644 --- a/src/utility/m_random.h +++ b/src/common/engine/m_random.h @@ -48,6 +48,11 @@ public: FRandom (const char *name); ~FRandom (); + int Seed() const + { + return sfmt.u[0] + idx; + } + // Returns a random number in the range [0,255] int operator()() { @@ -163,7 +168,6 @@ public: // Static interface static void StaticClearRandom (); - static uint32_t StaticSumSeeds (); static void StaticReadRNGState (FSerializer &arc); static void StaticWriteRNGState (FSerializer &file); static FRandom *StaticFindRNG(const char *name); diff --git a/src/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp similarity index 100% rename from src/scripting/backend/codegen.cpp rename to src/common/scripting/backend/codegen.cpp diff --git a/src/scripting/backend/codegen.h b/src/common/scripting/backend/codegen.h similarity index 100% rename from src/scripting/backend/codegen.h rename to src/common/scripting/backend/codegen.h diff --git a/src/scripting/backend/vmbuilder.cpp b/src/common/scripting/backend/vmbuilder.cpp similarity index 100% rename from src/scripting/backend/vmbuilder.cpp rename to src/common/scripting/backend/vmbuilder.cpp diff --git a/src/scripting/backend/vmbuilder.h b/src/common/scripting/backend/vmbuilder.h similarity index 100% rename from src/scripting/backend/vmbuilder.h rename to src/common/scripting/backend/vmbuilder.h diff --git a/src/g_game.cpp b/src/g_game.cpp index cf8ea599c..0c9baf9ea 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1047,7 +1047,29 @@ bool G_Responder (event_t *ev) ev->type == EV_Mouse); } +//========================================================================== +// +// FRandom :: StaticSumSeeds +// +// This function produces a uint32_t that can be used to check the consistancy +// of network games between different machines. Only a select few RNGs are +// used for the sum, because not all RNGs are important to network sync. +// +//========================================================================== +extern FRandom pr_spawnmobj; +extern FRandom pr_acs; +extern FRandom pr_chase; +extern FRandom pr_damagemobj; + +static uint32_t StaticSumSeeds() +{ + return + pr_spawnmobj.Seed() + + pr_acs.Seed() + + pr_chase.Seed() + + pr_damagemobj.Seed(); +} // // G_Ticker @@ -1166,7 +1188,7 @@ void G_Ticker () // [RH] Include some random seeds and player stuff in the consistancy // check, not just the player's x position like BOOM. - uint32_t rngsum = FRandom::StaticSumSeeds (); + uint32_t rngsum = StaticSumSeeds (); //Added by MC: For some of that bot stuff. The main bot function. primaryLevel->BotInfo.Main (primaryLevel); diff --git a/src/gamedata/d_dehacked.cpp b/src/gamedata/d_dehacked.cpp index e76509508..42995c0ae 100644 --- a/src/gamedata/d_dehacked.cpp +++ b/src/gamedata/d_dehacked.cpp @@ -62,7 +62,7 @@ #include "serializer.h" #include "thingdef.h" #include "v_text.h" -#include "backend/vmbuilder.h" +#include "vmbuilder.h" #include "types.h" #include "m_argv.h" #include "actorptrselect.h" diff --git a/src/scripting/decorate/olddecorations.cpp b/src/scripting/decorate/olddecorations.cpp index f0749048c..15722cd6f 100644 --- a/src/scripting/decorate/olddecorations.cpp +++ b/src/scripting/decorate/olddecorations.cpp @@ -41,7 +41,7 @@ #include "p_lnspec.h" #include "decallib.h" #include "thingdef.h" -#include "backend/codegen.h" +#include "codegen.h" // TYPES ------------------------------------------------------------------- diff --git a/src/scripting/decorate/thingdef_exp.cpp b/src/scripting/decorate/thingdef_exp.cpp index 141b73d47..40e106baa 100644 --- a/src/scripting/decorate/thingdef_exp.cpp +++ b/src/scripting/decorate/thingdef_exp.cpp @@ -42,10 +42,10 @@ #include "cmdlib.h" #include "a_pickups.h" #include "thingdef.h" -#include "backend/codegen.h" +#include "codegen.h" #include "backend/codegen_doom.h" -FRandom pr_exrandom ("EX_Random"); +extern FRandom pr_exrandom; static FxExpression *ParseRandom(FScanner &sc, FName identifier, PClassActor *cls); static FxExpression *ParseRandomPick(FScanner &sc, FName identifier, PClassActor *cls); diff --git a/src/scripting/decorate/thingdef_parse.cpp b/src/scripting/decorate/thingdef_parse.cpp index 3dcba999c..6526a2130 100644 --- a/src/scripting/decorate/thingdef_parse.cpp +++ b/src/scripting/decorate/thingdef_parse.cpp @@ -43,7 +43,7 @@ #include "a_pickups.h" #include "thingdef.h" #include "a_morph.h" -#include "backend/codegen.h" +#include "codegen.h" #include "backend/codegen_doom.h" #include "filesystem.h" #include "v_text.h" diff --git a/src/scripting/decorate/thingdef_states.cpp b/src/scripting/decorate/thingdef_states.cpp index ff7c9c3e4..e9481eee0 100644 --- a/src/scripting/decorate/thingdef_states.cpp +++ b/src/scripting/decorate/thingdef_states.cpp @@ -43,7 +43,7 @@ #include "p_lnspec.h" #include "p_local.h" #include "thingdef.h" -#include "backend/codegen.h" +#include "codegen.h" #include "backend/codegen_doom.h" #ifndef _MSC_VER #include "i_system.h" // for strlwr() diff --git a/src/scripting/thingdef.cpp b/src/scripting/thingdef.cpp index 8772f1eb4..0a5089ddf 100644 --- a/src/scripting/thingdef.cpp +++ b/src/scripting/thingdef.cpp @@ -49,7 +49,7 @@ #include "a_weapons.h" #include "p_conversation.h" #include "v_text.h" -#include "backend/codegen.h" +#include "codegen.h" #include "stats.h" #include "info.h" #include "thingdef.h" diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index 6add94538..633e43bdb 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -50,7 +50,7 @@ #include "thingdef.h" #include "a_morph.h" #include "teaminfo.h" -#include "backend/vmbuilder.h" +#include "vmbuilder.h" #include "a_keys.h" #include "g_levellocals.h" #include "types.h" diff --git a/src/scripting/zscript/zcc_compile.h b/src/scripting/zscript/zcc_compile.h index 040d28bd3..2235b7796 100644 --- a/src/scripting/zscript/zcc_compile.h +++ b/src/scripting/zscript/zcc_compile.h @@ -2,7 +2,7 @@ #define ZCC_COMPILE_H #include -#include "backend/codegen.h" +#include "codegen.h" struct Baggage; struct FPropertyInfo;