diff --git a/source/graphics/GameView.cpp b/source/graphics/GameView.cpp index 9be40cb3ec..c19ad0e601 100755 --- a/source/graphics/GameView.cpp +++ b/source/graphics/GameView.cpp @@ -24,6 +24,7 @@ #include "sdl.h" #include "input.h" #include "lib.h" +#include "timer.h" extern int g_xres, g_yres; extern bool g_active; @@ -165,27 +166,12 @@ void CGameView::RenderNoCull() void CGameView::InitResources() { + TIMER(CGameView__InitResources); + g_TexMan.LoadTerrainTextures(); g_ObjMan.LoadObjects(); - const char* fns[CRenderer::NumAlphaMaps] = { - "art/textures/terrain/alphamaps/special/blendcircle.png", - "art/textures/terrain/alphamaps/special/blendlshape.png", - "art/textures/terrain/alphamaps/special/blendedge.png", - "art/textures/terrain/alphamaps/special/blendedgecorner.png", - "art/textures/terrain/alphamaps/special/blendedgetwocorners.png", - "art/textures/terrain/alphamaps/special/blendfourcorners.png", - "art/textures/terrain/alphamaps/special/blendtwooppositecorners.png", - "art/textures/terrain/alphamaps/special/blendlshapecorner.png", - "art/textures/terrain/alphamaps/special/blendtwocorners.png", - "art/textures/terrain/alphamaps/special/blendcorner.png", - "art/textures/terrain/alphamaps/special/blendtwoedges.png", - "art/textures/terrain/alphamaps/special/blendthreecorners.png", - "art/textures/terrain/alphamaps/special/blendushape.png", - "art/textures/terrain/alphamaps/special/blendbad.png" - }; - - g_Renderer.LoadAlphaMaps(fns); + g_Renderer.LoadAlphaMaps(); } void CGameView::UnloadResources() diff --git a/source/graphics/MapReader.cpp b/source/graphics/MapReader.cpp index 0608f036b0..6e779bb095 100755 --- a/source/graphics/MapReader.cpp +++ b/source/graphics/MapReader.cpp @@ -14,6 +14,8 @@ #include "Terrain.h" #include "TextureManager.h" +#include "timer.h" + // CMapReader constructor: nothing to do at the minute CMapReader::CMapReader() { @@ -22,8 +24,13 @@ CMapReader::CMapReader() // LoadMap: try to load the map from given file; reinitialise the scene to new data if successful void CMapReader::LoadMap(const char* filename, CTerrain *pTerrain, CUnitManager *pUnitMan, CLightEnv *pLightEnv) { + TIMER(__CMapReader__LoadMap); + CFileUnpacker unpacker; - unpacker.Read(filename,"PSMP"); + { + TIMER(____CMapReader__LoadMap__read); + unpacker.Read(filename,"PSMP"); + } // check version if (unpacker.GetVersion()Initialize(m_MapSize,&m_Heightmap[0]); @@ -198,6 +209,8 @@ void CMapReader::ApplyData(CFileUnpacker& unpacker, CTerrain *pTerrain, CUnitMan void CMapReader::ReadXML(const char* filename) { + TIMER(____CMapReader__ReadXML); + #ifdef SCED // HACK: ScEd uses absolute filenames, not VFS paths. I can't be bothered // to make Xeromyces work with non-VFS, so just cheat: diff --git a/source/graphics/ObjectManager.cpp b/source/graphics/ObjectManager.cpp index 1dd48134b3..302b466a30 100755 --- a/source/graphics/ObjectManager.cpp +++ b/source/graphics/ObjectManager.cpp @@ -4,6 +4,7 @@ #include #include "CLogger.h" #include "lib/res/res.h" +#include "timer.h" #define LOG_CATEGORY "graphics" @@ -80,6 +81,8 @@ void CObjectManager::DeleteObject(CObjectEntry* entry) void CObjectManager::LoadObjects() { + TIMER(__CObjectManager__LoadObjects); + // find all the object types by directory name BuildObjectTypes(0); diff --git a/source/graphics/TextureManager.cpp b/source/graphics/TextureManager.cpp index 4fa1e41536..66633751bf 100755 --- a/source/graphics/TextureManager.cpp +++ b/source/graphics/TextureManager.cpp @@ -7,6 +7,7 @@ #include "ogl.h" #include "res/ogl_tex.h" #include "CLogger.h" +#include "timer.h" #define LOG_CATEGORY "graphics" @@ -136,6 +137,8 @@ void CTextureManager::BuildTerrainTypes() void CTextureManager::LoadTerrainTextures() { + TIMER(__CTextureManager__LoadTerrainTextures); + // find all the terrain types by directory name BuildTerrainTypes(); diff --git a/source/ps/Game.cpp b/source/ps/Game.cpp index c671e2614c..04492b81be 100755 --- a/source/ps/Game.cpp +++ b/source/ps/Game.cpp @@ -5,6 +5,7 @@ #ifndef NO_GUI #include "gui/CGUI.h" #endif +#include "timer.h" CGame *g_Game=NULL; @@ -26,7 +27,7 @@ CGame::CGame(): m_pLocalPlayer(NULL), m_GameStarted(false) { - debug_out("CGame::CGame(): Game object CREATED\n"); + debug_out("CGame::CGame(): Game object CREATED; initializing..\n"); } #ifdef _MSC_VER @@ -62,6 +63,7 @@ PSRETURN CGame::StartGame(CGameAttributes *pAttribs) m_World.Initialize(pAttribs); m_Simulation.Initialize(pAttribs); + debug_out("GAME STARTED, ALL INIT COMPLETE\n"); m_GameStarted=true; #ifndef NO_GUI @@ -88,7 +90,7 @@ CPlayer *CGame::GetPlayer(uint idx) if (idx > m_NumPlayers) { // debug_warn("Invalid player ID"); - LOG(ERROR, "", "Invalid player ID %d (outside 0..%d)", idx, m_NumPlayers); +// LOG(ERROR, "", "Invalid player ID %d (outside 0..%d)", idx, m_NumPlayers); return m_Players[0]; } // Be a bit more paranoid - maybe m_Players hasn't been set large enough diff --git a/source/ps/World.cpp b/source/ps/World.cpp index 3fa2a4f090..2470effbbe 100755 --- a/source/ps/World.cpp +++ b/source/ps/World.cpp @@ -11,6 +11,7 @@ #include "LightEnv.h" #include "BaseEntityCollection.h" #include "EntityManager.h" +#include "timer.h" #define LOG_CATEGORY "world" @@ -18,6 +19,8 @@ CLightEnv g_LightEnv; void CWorld::Initialize(CGameAttributes *pAttribs) { + TIMER(CWorld__Initialize); + // TODO: Find a better way of handling these global things ONCE(g_EntityTemplateCollection.loadTemplates()); diff --git a/source/renderer/Renderer.cpp b/source/renderer/Renderer.cpp index f83f677973..3bcbe623ea 100755 --- a/source/renderer/Renderer.cpp +++ b/source/renderer/Renderer.cpp @@ -35,6 +35,7 @@ #include "ogl.h" #include "res/mem.h" #include "res/ogl_tex.h" +#include "timer.h" #define LOG_CATEGORY "graphics" @@ -1152,10 +1153,31 @@ inline void CopyTriple(unsigned char* dst,const unsigned char* src) // LoadAlphaMaps: load the 14 default alpha maps, pack them into one composite texture and // calculate the coordinate of each alphamap within this packed texture .. need to add // validation that all maps are the same size -bool CRenderer::LoadAlphaMaps(const char* fnames[]) +bool CRenderer::LoadAlphaMaps() { + TIMER(__CRenderer__LoadAlphaMaps); + Handle textures[NumAlphaMaps]; + + const char* fnames[CRenderer::NumAlphaMaps] = { + "art/textures/terrain/alphamaps/special/blendcircle.png", + "art/textures/terrain/alphamaps/special/blendlshape.png", + "art/textures/terrain/alphamaps/special/blendedge.png", + "art/textures/terrain/alphamaps/special/blendedgecorner.png", + "art/textures/terrain/alphamaps/special/blendedgetwocorners.png", + "art/textures/terrain/alphamaps/special/blendfourcorners.png", + "art/textures/terrain/alphamaps/special/blendtwooppositecorners.png", + "art/textures/terrain/alphamaps/special/blendlshapecorner.png", + "art/textures/terrain/alphamaps/special/blendtwocorners.png", + "art/textures/terrain/alphamaps/special/blendcorner.png", + "art/textures/terrain/alphamaps/special/blendtwoedges.png", + "art/textures/terrain/alphamaps/special/blendthreecorners.png", + "art/textures/terrain/alphamaps/special/blendushape.png", + "art/textures/terrain/alphamaps/special/blendbad.png" + }; + + int i; for (i=0;i