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"