From 479c732a72f7ab788019c96b70566c8b1ad245ed Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 30 Sep 2022 19:40:37 +0200 Subject: [PATCH] - moved some more things out of build.h --- source/build/include/build.h | 41 ------------------------------------ source/core/defparser.cpp | 16 ++++++++------ source/core/gamecontrol.h | 1 + source/core/gamefuncs.h | 11 ++++++++++ source/core/maphack.cpp | 15 +++++++++++-- source/core/palette.h | 8 +++++++ 6 files changed, 43 insertions(+), 49 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 6fee52aea..fdde5b7b8 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -23,21 +23,6 @@ static_assert('\xff' == 255, "Char must be unsigned!"); typedef int64_t coord_t; -enum -{ - MAXWALLSB = 6144, - - // Maximum number of component tiles in a multi-psky: - MAXUNIQHUDID = 256, //Extra slots so HUD models can store animation state without messing game sprites - - TSPR_TEMP = 99, - - CLIPMASK0 = (1 << 16) + 1, - CLIPMASK1 = (256 << 16) + 64 -}; - - - #define POINT2(i) (wall[wall[i].point2]) @@ -46,19 +31,6 @@ enum int32_t getwalldist(vec2_t const in, int const wallnum, vec2_t * const out); -struct usermaphack_t -{ - FString mhkfile; - FString title; - uint8_t md4[16]{}; -}; - -enum { - PALETTE_MAIN = 1<<0, - PALETTE_SHADE = 1<<1, - PALETTE_TRANSLUC = 1<<2, -}; - enum { ENGINECOMPATIBILITY_NONE = 0, ENGINECOMPATIBILITY_19950829, // Powerslave/Exhumed @@ -66,22 +38,9 @@ enum { ENGINECOMPATIBILITY_19961112, // Duke 3d v1.5, Redneck Rampage }; -inline int leveltimer; -inline int32_t Numsprites; -inline int32_t display_mirror; -inline int32_t randomseed; -inline uint8_t paletteloaded; -inline int32_t g_visibility = 512, g_relvisibility = 0; inline int32_t enginecompatibility_mode; -void setVideoMode(); - -class F2DDrawer; - - -struct HitInfoBase; - inline int32_t ksqrt(uint64_t num) { return int(sqrt(double(num))); diff --git a/source/core/defparser.cpp b/source/core/defparser.cpp index 6d732ba28..ae460500e 100644 --- a/source/core/defparser.cpp +++ b/source/core/defparser.cpp @@ -44,12 +44,13 @@ #include "mapinfo.h" #include "hw_voxels.h" #include "psky.h" +#include "gamefuncs.h" #include "models/modeldata.h" int tileSetHightileReplacement(int picnum, int palnum, const char* filename, float alphacut, float xscale, float yscale, float specpower, float specfactor, bool indexed = false); int tileSetSkybox(int picnum, int palnum, FString* facenames, bool indexed = false); void tileRemoveReplacement(int num); -void AddUserMapHack(usermaphack_t&); +void AddUserMapHack(const FString& title, const FString& mhkfile, uint8_t* md4); static void defsparser(FScanner& sc); @@ -826,7 +827,10 @@ void parseMusic(FScanner& sc, FScriptPosition& pos) void parseMapinfo(FScanner& sc, FScriptPosition& pos) { - usermaphack_t mhk; + FString title; + FString mhkfile; + uint8_t md4b[16]{}; + FScanner::SavedPos blockend; TArray md4s; @@ -835,8 +839,8 @@ void parseMapinfo(FScanner& sc, FScriptPosition& pos) { sc.MustGetString(); if (sc.Compare("mapfile")) sc.GetString(); - else if (sc.Compare("maptitle")) sc.GetString(mhk.title); - else if (sc.Compare("mhkfile")) sc.GetString(mhk.mhkfile); + else if (sc.Compare("maptitle")) sc.GetString(title); + else if (sc.Compare("mhkfile")) sc.GetString(mhkfile); else if (sc.Compare("mapmd4")) { sc.GetString(); @@ -848,9 +852,9 @@ void parseMapinfo(FScanner& sc, FScriptPosition& pos) for (int i = 0; i < 16; i++) { char smallbuf[3] = { md4[2 * i], md4[2 * i + 1], 0 }; - mhk.md4[i] = (uint8_t)strtol(smallbuf, nullptr, 16); + md4b[i] = (uint8_t)strtol(smallbuf, nullptr, 16); } - AddUserMapHack(mhk); + AddUserMapHack(title, mhkfile, md4b); } } diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index 1c0708754..a60fd4cf4 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -46,6 +46,7 @@ void DeferredStartGame(MapRecord* map, int skill, bool nostopsound = false); void ChangeLevel(MapRecord* map, int skill, bool bossexit = false); void CompleteLevel(MapRecord* map); bool CheckCheatmode(bool printmsg = true, bool sponly = false); +void setVideoMode(); void TITLE_InformName(const char* newname); diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 3bdec772d..8c73dac49 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -18,9 +18,20 @@ extern bool hw_int_useindexedcolortextures; EXTERN_CVAR(Bool, hw_useindexedcolortextures) EXTERN_CVAR(Bool, r_voxels) +inline int leveltimer; +inline int Numsprites; +inline int display_mirror; +inline int randomseed; +inline int g_visibility = 512, g_relvisibility = 0; constexpr int SLOPEVAL_FACTOR = 4096; +enum +{ + CLIPMASK0 = (1 << 16) + 1, + CLIPMASK1 = (256 << 16) + 64 +}; + //========================================================================== // // breadth first search, this gets used multiple times throughout the engine, mainly for iterating over sectors. diff --git a/source/core/maphack.cpp b/source/core/maphack.cpp index 80b356eec..eb0158126 100644 --- a/source/core/maphack.cpp +++ b/source/core/maphack.cpp @@ -39,12 +39,23 @@ #include "md4.h" #include "hw_sections.h" #include "mapinfo.h" +#include "gamefuncs.h" + +struct usermaphack_t +{ + FString mhkfile; + FString title; + uint8_t md4[16]{}; +}; static TArray usermaphacks; -void AddUserMapHack(usermaphack_t& mhk) +void AddUserMapHack(const FString& title, const FString& mhkfile, uint8_t* md4) { - usermaphacks.Push(mhk); + usermaphacks.Reserve(1); + usermaphacks.Last().title = title; + usermaphacks.Last().mhkfile = mhkfile; + memcpy(usermaphacks.Last().md4, md4, 16); } static int32_t LoadMapHack(const char *filename, SpawnSpriteDef& sprites) diff --git a/source/core/palette.h b/source/core/palette.h index cd36c99e4..e57387393 100644 --- a/source/core/palette.h +++ b/source/core/palette.h @@ -197,4 +197,12 @@ FRenderStyle GetRenderStyle(int blend, int def); float GetAlphaFromBlend(uint32_t maskprops, uint32_t blend); void DrawFullscreenBlends(); +enum { + PALETTE_MAIN = 1 << 0, + PALETTE_SHADE = 1 << 1, + PALETTE_TRANSLUC = 1 << 2, +}; + +inline uint8_t paletteloaded; + #endif