From 572bc4620aa8d0d3bc7769e5d22a9e8a0ce7cf45 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 12 Dec 2010 17:54:10 +0000 Subject: [PATCH] - changed automap initialization so that static data only gets initialized once upon startup instead of each time a level starts. - initialize AUTOPAGE only once when the level starts, not each time the automap is switched on. SVN r3031 (trunk) --- src/am_map.cpp | 68 ++++++++++++++++----------------- src/am_map.h | 3 ++ src/d_main.cpp | 1 + src/textures/texturemanager.cpp | 3 -- 4 files changed, 36 insertions(+), 39 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index cf8876157..d3fbc1140 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -64,6 +64,12 @@ #include "po_man.h" #include "a_keys.h" +//============================================================================= +// +// Automap colors +// +//============================================================================= + struct AMColor { int Index; @@ -119,6 +125,12 @@ static BYTE RavenPaletteVals[11*3] = 0, 0, 0, 0, 0, 0, }; +//============================================================================= +// +// globals +// +//============================================================================= + #define MAPBITS 12 #define MapDiv SafeDivScale12 #define MapMul MulScale12 @@ -287,28 +299,28 @@ struct islope_t // A line drawing of the player pointing right, // starting from the middle. // -TArray MapArrow; -TArray CheatMapArrow; -TArray CheatKey; +static TArray MapArrow; +static TArray CheatMapArrow; +static TArray CheatKey; #define R (MAPUNIT) // [RH] Avoid lots of warnings without compiler-specific #pragmas #define L(a,b,c,d) { {(fixed_t)((a)*R),(fixed_t)((b)*R)}, {(fixed_t)((c)*R),(fixed_t)((d)*R)} } -mline_t triangle_guy[] = { +static mline_t triangle_guy[] = { L (-.867,-.5, .867,-.5), L (.867,-.5, 0,1), L (0,1, -.867,-.5) }; #define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t)) -mline_t thintriangle_guy[] = { +static mline_t thintriangle_guy[] = { L (-.5,-.7, 1,0), L (1,0, -.5,.7), L (-.5,.7, -.5,-.7) }; #define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) -mline_t square_guy[] = { +static mline_t square_guy[] = { L (0,1,1,0), L (1,0,0,-1), L (0,-1,-1,0), @@ -332,8 +344,6 @@ CUSTOM_CVAR (Int, am_cheat, 0, 0) static int grid = 0; -static int leveljuststarted = 1; // kluge until AM_LevelInit() is called - bool automapactive = false; // location of window on screen @@ -515,16 +525,26 @@ void AM_ParseArrow(TArray &Arrow, const char *lumpname) } } -void AM_InitArrows() +void AM_StaticInit() { - MapArrow.Clear(); CheatMapArrow.Clear(); + CheatKey.Clear(); if (gameinfo.mMapArrow.IsNotEmpty()) AM_ParseArrow(MapArrow, gameinfo.mMapArrow); if (gameinfo.mCheatMapArrow.IsNotEmpty()) AM_ParseArrow(CheatMapArrow, gameinfo.mCheatMapArrow); AM_ParseArrow(CheatKey, "maparrows/key.txt"); if (MapArrow.Size() == 0) I_FatalError("No automap arrow defined"); + + char namebuf[9]; + + for (int i = 0; i < 10; i++) + { + mysnprintf (namebuf, countof(namebuf), "AMMNUM%d", i); + marknums[i] = TexMan.CheckForTexture (namebuf, FTexture::TEX_MiscPatch); + } + markpointnum = 0; + mapback.SetInvalid(); } //============================================================================= @@ -1004,28 +1024,6 @@ static void AM_initColors (bool overlayed) lastpal = palette; } -//============================================================================= -// -// -// -//============================================================================= - -void AM_loadPics () -{ - int i; - char namebuf[9]; - - for (i = 0; i < 10; i++) - { - mysnprintf (namebuf, countof(namebuf), "AMMNUM%d", i); - marknums[i] = TexMan.CheckForTexture (namebuf, FTexture::TEX_MiscPatch); - } - - const char *autopage = level.info->mapbg[0] == 0? "AUTOPAGE" : (const char*)&level.info->mapbg[0]; - - mapback = TexMan.CheckForTexture(autopage, FTexture::TEX_MiscPatch); -} - //============================================================================= // // @@ -1048,9 +1046,8 @@ bool AM_clearMarks () void AM_LevelInit () { - if (MapArrow.Size() == 0) AM_InitArrows(); - - leveljuststarted = 0; + const char *autopage = level.info->mapbg[0] == 0? "AUTOPAGE" : (const char*)&level.info->mapbg[0]; + mapback = TexMan.CheckForTexture(autopage, FTexture::TEX_MiscPatch); AM_clearMarks(); @@ -1088,7 +1085,6 @@ void AM_Start () if (!stopped) AM_Stop(); stopped = false; AM_initVariables(); - AM_loadPics(); } diff --git a/src/am_map.h b/src/am_map.h index 20da6b96b..e4fe50856 100644 --- a/src/am_map.h +++ b/src/am_map.h @@ -25,6 +25,9 @@ struct event_t; class FArchive; + +void AM_StaticInit(); + // Called by main loop. bool AM_Responder (event_t* ev, bool last); diff --git a/src/d_main.cpp b/src/d_main.cpp index fd03a5c4a..d1fb87382 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2226,6 +2226,7 @@ void D_DoomMain (void) Printf ("P_Init: Init Playloop state.\n"); StartScreen->LoadingStatus ("Init game engine", 0x3f); + AM_StaticInit(); P_Init (); P_SetupWeapons_ntohton(); diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index fc49d07d8..72eb59f29 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -48,9 +48,6 @@ #include "cmdlib.h" #include "g_level.h" -extern void R_InitBuildTiles(); - - FTextureManager TexMan; //==========================================================================