From 0e58203d92d8feafdc69de3e30d64e6e79bcb0f8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 13 Sep 2020 20:15:46 +0200 Subject: [PATCH] - fixed rintersect and removed some unused bits from engine.cpp. --- source/build/include/build.h | 6 -- source/build/src/engine.cpp | 92 +++-------------------------- source/core/gamecontrol.cpp | 7 ++- source/core/mainloop.cpp | 1 - source/core/textures/buildtiles.cpp | 2 + source/games/duke/src/game.cpp | 1 - 6 files changed, 15 insertions(+), 94 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 5d3032894..aff8b8e0b 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -67,11 +67,6 @@ enum rendmode_t { # define MINXDIM 640 # define MINYDIM 480 -// additional space beyond wall, in walltypes: -# define M32_FIXME_WALLS 512 -# define M32_FIXME_SECTORS 2 - - #define MAXWALLSB ((MAXWALLS>>2)+(MAXWALLS>>3)) #define MAXVOXELS 1024 @@ -588,7 +583,6 @@ typedef struct artheader_t { int32_t enginePreInit(void); // a partial setup of the engine used for launch windows int32_t engineInit(void); -int32_t enginePostInit(void); void engineUnInit(void); void initspritelists(void); diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 78f05c08c..7be582938 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -69,11 +69,6 @@ char g_haveVoxels; int32_t novoxmips = 1; -//These variables need to be copied into BUILD -#define MAXXSIZ 256 -#define MAXYSIZ 256 -#define MAXZSIZ 255 - int32_t voxscale[MAXVOXELS]; static int32_t beforedrawrooms = 1; @@ -834,12 +829,12 @@ int32_t rintersect(int32_t x1, int32_t y1, int32_t z1, else if (bot < 0 && (topt > 0 || topu > 0 || topu <= bot)) return -1; - int64_t t = IntToFixed(topt) / bot; - *intx = x1 + FixedToInt(vx*t); - *inty = y1 + FixedToInt(vy*t); - *intz = z1 + FixedToInt(vz*t); + int64_t t = (topt << 16) / bot; + *intx = x1 + ((vx*t) >> 16); + *inty = y1 + ((vy*t) >> 16); + *intz = z1 + ((vz*t) >> 16); - t = IntToFixed(topu) / bot; + t = (topu << 16) / bot; assert((unsigned)t < 65536); @@ -908,33 +903,25 @@ const int16_t* getpsky(int32_t picnum, int32_t* dapyscale, int32_t* dapskybits, // static int32_t preinitcalled = 0; -#if !defined DEBUG_MAIN_ARRAYS static spriteext_t spriteext_s[MAXSPRITES+MAXUNIQHUDID]; static spritesmooth_t spritesmooth_s[MAXSPRITES+MAXUNIQHUDID]; -static sectortype sector_s[MAXSECTORS + M32_FIXME_SECTORS]; -static walltype wall_s[MAXWALLS + M32_FIXME_WALLS]; -#ifndef NEW_MAP_FORMAT +static sectortype sector_s[MAXSECTORS]; +static walltype wall_s[MAXWALLS]; static wallext_t wallext_s[MAXWALLS]; -#endif static spritetype sprite_s[MAXSPRITES]; static tspritetype tsprite_s[MAXSPRITESONSCREEN]; -#endif int32_t enginePreInit(void) { polymost_initosdfuncs(); -#if !defined DEBUG_MAIN_ARRAYS sector = sector_s; wall = wall_s; -# ifndef NEW_MAP_FORMAT wallext = wallext_s; -# endif sprite = sprite_s; tsprite = tsprite_s; spriteext = spriteext_s; spritesmooth = spritesmooth_s; -#endif preinitcalled = 1; @@ -997,21 +984,6 @@ int32_t engineInit(void) return 0; } -// -// E_PostInit -// -int32_t enginePostInit(void) -{ - if (!(paletteloaded & PALETTE_MAIN)) - I_FatalError("No palette found."); - - V_LoadTranslations(); // loading the translations must be delayed until the palettes have been fully set up. - lookups.postLoadTables(); - TileFiles.SetupReverseTileMap(); - TileFiles.PostLoadSetup(); - return 0; -} - // // uninitengine // @@ -1224,14 +1196,6 @@ static inline int32_t sameside(const _equation *eq, const vec2f_t *p1, c return (sign1 * sign2) > 0.f; } -// x1, y1: in/out -// rest x/y: out - - - -#ifdef DEBUG_MASK_DRAWING -int32_t g_maskDrawMode = 0; -#endif static inline int comparetsprites(int const k, int const l) { @@ -2053,21 +2017,8 @@ static int32_t engineFinishLoadBoard(const char *filename, const vec3_t *dapos, { memset(spriteext, 0, sizeof(spriteext_t)*MAXSPRITES); -#ifndef NEW_MAP_FORMAT memset(wallext, 0, sizeof(wallext_t)*MAXWALLS); -#endif - -#ifdef USE_OPENGL memset(spritesmooth, 0, sizeof(spritesmooth_t)*(MAXSPRITES+MAXUNIQHUDID)); - -# ifdef POLYMER - if (videoGetRenderMode() == REND_POLYMER) - { - if ((myflags&4)==0) - polymer_loadboard(); - } -# endif -#endif } guniqhudid = 0; @@ -2162,15 +2113,6 @@ int32_t engineLoadBoard(const char *filename, char flags, vec3_t *dapos, int16_t { int32_t ok = 0; -#ifdef NEW_MAP_FORMAT - // Check for map-text first. - if (!memcmp(&mapversion, "--ED", 4)) - { - mapversion = 10; - ok = 1; - } - else -#endif { // Not map-text. We expect a little-endian version int now. mapversion = B_LITTLE32(mapversion); @@ -3815,26 +3757,6 @@ void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z) -// -// setrendermode -// -int32_t videoSetRenderMode(int32_t renderer) -{ - UNREFERENCED_PARAMETER(renderer); - -#ifdef USE_OPENGL - - renderer = REND_POLYMOST; - - rendmode = renderer; - if (videoGetRenderMode() >= REND_POLYMOST) - glrendmode = rendmode; - -#endif - - return 0; -} - // // setrollangle // diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 69171cf0e..b83dfe9fb 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -924,7 +924,12 @@ int RunGame() SetupGameButtons(); gi->app_init(); M_Init(); - enginePostInit(); // This must not be done earlier! + if (!(paletteloaded & PALETTE_MAIN)) + I_FatalError("No palette found."); + + V_LoadTranslations(); // loading the translations must be delayed until the palettes have been fully set up. + lookups.postLoadTables(); + TileFiles.PostLoadSetup(); videoInit(); D_CheckNetGame(); diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index 10a4606e4..fdb88c842 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -33,7 +33,6 @@ */ -// For TryRunTics the following applies: // For TryRunTics the following applies: //----------------------------------------------------------------------------- // diff --git a/source/core/textures/buildtiles.cpp b/source/core/textures/buildtiles.cpp index e76def804..1cdd83e32 100644 --- a/source/core/textures/buildtiles.cpp +++ b/source/core/textures/buildtiles.cpp @@ -503,6 +503,8 @@ uint8_t* BuildTiles::tileMakeWritable(int num) void BuildTiles::PostLoadSetup() { + SetupReverseTileMap(); + for (auto& tile : tiledata) { FGameTexture* detailTex = nullptr, * glowTex = nullptr, * normalTex = nullptr, *specTex = nullptr; diff --git a/source/games/duke/src/game.cpp b/source/games/duke/src/game.cpp index 0d9054c91..6a56dc525 100644 --- a/source/games/duke/src/game.cpp +++ b/source/games/duke/src/game.cpp @@ -326,7 +326,6 @@ void GameInterface::app_init() initTiles(); fi.InitFonts(); genspriteremaps(); - TileFiles.PostLoadSetup(); SetupGameButtons(); InitCheats(); checkcommandline();