From d2070837d292379c6fbf73eceed33eaabb222903 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Wed, 28 Jul 2004 19:27:35 +0000 Subject: [PATCH] Global variables are nasty. Hacked g_Terrain into a pointer so that it doesn't crash when automatically destructing, although it ought to be handled in a nicer way. This was SVN commit r839. --- source/graphics/Terrain.h | 5 ++++- source/main.cpp | 5 +++++ source/ps/World.cpp | 2 +- source/ps/World.h | 3 ++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/source/graphics/Terrain.h b/source/graphics/Terrain.h index 9c11337058..abf1fdcbc2 100755 --- a/source/graphics/Terrain.h +++ b/source/graphics/Terrain.h @@ -77,6 +77,9 @@ private: u16* m_Heightmap; }; -extern CTerrain g_Terrain; +extern CTerrain* g_Terrain_ptr; +#ifndef g_Terrain +#define g_Terrain (*g_Terrain_ptr) +#endif #endif diff --git a/source/main.cpp b/source/main.cpp index 04ba1746b8..25f8b6901a 100755 --- a/source/main.cpp +++ b/source/main.cpp @@ -662,6 +662,8 @@ static void Shutdown() { psShutdown(); // Must delete g_GUI before g_ScriptingHost + delete g_Game; + delete &g_Scheduler; delete &g_Mouseover; @@ -679,6 +681,7 @@ static void Shutdown() // destroy terrain related stuff delete &g_TexMan; + delete &g_Terrain; // destroy renderer delete &g_Renderer; @@ -827,6 +830,8 @@ PREVTSC=CURTSC; MICROLOG(L"init renderer"); g_Renderer.Open(g_xres,g_yres,g_bpp); + + g_Terrain_ptr = new CTerrain; // terr_init loads a bunch of resources as well as setting up the terrain terr_init(); diff --git a/source/ps/World.cpp b/source/ps/World.cpp index c7d71aa36d..bdb552fa0b 100755 --- a/source/ps/World.cpp +++ b/source/ps/World.cpp @@ -9,7 +9,7 @@ #include "Game.h" #include "Terrain.h" -CTerrain g_Terrain; +CTerrain* g_Terrain_ptr = NULL; void CWorld::Initialize(CGameAttributes *pAttribs) { diff --git a/source/ps/World.h b/source/ps/World.h index d401e7eaff..83faa72a9d 100755 --- a/source/ps/World.h +++ b/source/ps/World.h @@ -5,7 +5,8 @@ class CGame; class CGameAttributes; class CTerrain; -extern CTerrain g_Terrain; +extern CTerrain* g_Terrain_ptr; +#define g_Terrain (*g_Terrain_ptr) #include "UnitManager.h"