2004-07-27 23:00:53 +02:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
#include "CStr.h"
|
|
|
|
#include "CLogger.h"
|
|
|
|
#include "Errors.h"
|
|
|
|
|
|
|
|
#include "World.h"
|
|
|
|
#include "MapReader.h"
|
|
|
|
#include "Game.h"
|
|
|
|
#include "Terrain.h"
|
2004-07-31 17:57:18 +02:00
|
|
|
#include "LightEnv.h"
|
|
|
|
#include "BaseEntityCollection.h"
|
2004-08-05 15:07:51 +02:00
|
|
|
#include "EntityManager.h"
|
2004-07-27 23:00:53 +02:00
|
|
|
|
2004-08-15 22:57:31 +02:00
|
|
|
#define LOG_CATEGORY "world"
|
|
|
|
|
2004-07-31 17:57:18 +02:00
|
|
|
extern CLightEnv g_LightEnv;
|
2004-07-27 23:00:53 +02:00
|
|
|
|
|
|
|
void CWorld::Initialize(CGameAttributes *pAttribs)
|
|
|
|
{
|
2004-07-31 17:57:18 +02:00
|
|
|
g_EntityTemplateCollection.loadTemplates();
|
|
|
|
|
2004-08-11 22:18:30 +02:00
|
|
|
CStr mapfilename("maps/scenarios/");
|
2004-08-16 17:19:17 +02:00
|
|
|
mapfilename+=pAttribs->GetValue("mapFile");
|
2004-07-31 17:57:18 +02:00
|
|
|
try {
|
|
|
|
CMapReader reader;
|
|
|
|
reader.LoadMap(mapfilename, &m_Terrain, &m_UnitManager, &g_LightEnv);
|
|
|
|
} catch (...) {
|
2004-08-15 22:57:31 +02:00
|
|
|
LOG(ERROR, LOG_CATEGORY, "Failed to load map %s", mapfilename.c_str());
|
2004-07-31 17:57:18 +02:00
|
|
|
throw PSERROR_Game_World_MapLoadFailed();
|
2004-07-27 23:00:53 +02:00
|
|
|
}
|
|
|
|
}
|
2004-08-05 15:07:51 +02:00
|
|
|
|
|
|
|
CWorld::~CWorld()
|
|
|
|
{
|
|
|
|
// The Entity Manager should perhaps be converted into a CWorld member..
|
|
|
|
// But for now, we'll just create and delete the global singleton instance
|
|
|
|
// following the creation and deletion of CWorld.
|
|
|
|
// The reason for not keeping the instance around is that we require a
|
|
|
|
// clean slate for each game start.
|
|
|
|
delete &m_EntityManager;
|
|
|
|
}
|