Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/MapReader.cpp
Show First 20 Lines • Show All 365 Lines • ▼ Show 20 Lines | XERO_ITER_EL(root, child) | ||||
} | } | ||||
} | } | ||||
return PSRETURN_OK; | return PSRETURN_OK; | ||||
} | } | ||||
void CMapSummaryReader::GetMapSettings(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) | void CMapSummaryReader::GetMapSettings(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) | ||||
{ | { | ||||
ScriptInterface::Request rq(scriptInterface); | ScriptRequest rq(scriptInterface); | ||||
ScriptInterface::CreateObject(rq, ret); | ScriptInterface::CreateObject(rq, ret); | ||||
if (m_ScriptSettings.empty()) | if (m_ScriptSettings.empty()) | ||||
return; | return; | ||||
JS::RootedValue scriptSettingsVal(rq.cx); | JS::RootedValue scriptSettingsVal(rq.cx); | ||||
scriptInterface.ParseJSON(m_ScriptSettings, &scriptSettingsVal); | scriptInterface.ParseJSON(m_ScriptSettings, &scriptSettingsVal); | ||||
▲ Show 20 Lines • Show All 878 Lines • ▼ Show 20 Lines | int CMapReader::LoadRMSettings() | ||||
ENSURE(pSimulation2); | ENSURE(pSimulation2); | ||||
pSimulation2->SetMapSettings(m_ScriptSettings); | pSimulation2->SetMapSettings(m_ScriptSettings); | ||||
return 0; | return 0; | ||||
} | } | ||||
int CMapReader::GenerateMap() | int CMapReader::GenerateMap() | ||||
{ | { | ||||
ScriptInterface::Request rq(pSimulation2->GetScriptInterface()); | ScriptRequest rq(pSimulation2->GetScriptInterface()); | ||||
if (!m_MapGen) | if (!m_MapGen) | ||||
{ | { | ||||
// Initialize map generator | // Initialize map generator | ||||
m_MapGen = new CMapGenerator(); | m_MapGen = new CMapGenerator(); | ||||
VfsPath scriptPath; | VfsPath scriptPath; | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | int CMapReader::GenerateMap() | ||||
// return progress | // return progress | ||||
return progress; | return progress; | ||||
}; | }; | ||||
int CMapReader::ParseTerrain() | int CMapReader::ParseTerrain() | ||||
{ | { | ||||
TIMER(L"ParseTerrain"); | TIMER(L"ParseTerrain"); | ||||
ScriptInterface::Request rq(pSimulation2->GetScriptInterface()); | ScriptRequest rq(pSimulation2->GetScriptInterface()); | ||||
// parse terrain from map data | // parse terrain from map data | ||||
// an error here should stop the loading process | // an error here should stop the loading process | ||||
#define GET_TERRAIN_PROPERTY(val, prop, out)\ | #define GET_TERRAIN_PROPERTY(val, prop, out)\ | ||||
if (!pSimulation2->GetScriptInterface().GetProperty(val, #prop, out))\ | if (!pSimulation2->GetScriptInterface().GetProperty(val, #prop, out))\ | ||||
{ LOGERROR("CMapReader::ParseTerrain() failed to get '%s' property", #prop);\ | { LOGERROR("CMapReader::ParseTerrain() failed to get '%s' property", #prop);\ | ||||
throw PSERROR_Game_World_MapLoadFailed("Error parsing terrain data.\nCheck application log for details"); } | throw PSERROR_Game_World_MapLoadFailed("Error parsing terrain data.\nCheck application log for details"); } | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
#undef GET_TERRAIN_PROPERTY | #undef GET_TERRAIN_PROPERTY | ||||
return 0; | return 0; | ||||
} | } | ||||
int CMapReader::ParseEntities() | int CMapReader::ParseEntities() | ||||
{ | { | ||||
TIMER(L"ParseEntities"); | TIMER(L"ParseEntities"); | ||||
ScriptInterface::Request rq(pSimulation2->GetScriptInterface()); | ScriptRequest rq(pSimulation2->GetScriptInterface()); | ||||
// parse entities from map data | // parse entities from map data | ||||
std::vector<Entity> entities; | std::vector<Entity> entities; | ||||
if (!pSimulation2->GetScriptInterface().GetProperty(m_MapData, "entities", entities)) | if (!pSimulation2->GetScriptInterface().GetProperty(m_MapData, "entities", entities)) | ||||
LOGWARNING("CMapReader::ParseEntities() failed to get 'entities' property"); | LOGWARNING("CMapReader::ParseEntities() failed to get 'entities' property"); | ||||
CSimulation2& sim = *pSimulation2; | CSimulation2& sim = *pSimulation2; | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | int CMapReader::ParseEntities() | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
int CMapReader::ParseEnvironment() | int CMapReader::ParseEnvironment() | ||||
{ | { | ||||
// parse environment settings from map data | // parse environment settings from map data | ||||
ScriptInterface::Request rq(pSimulation2->GetScriptInterface()); | ScriptRequest rq(pSimulation2->GetScriptInterface()); | ||||
#define GET_ENVIRONMENT_PROPERTY(val, prop, out)\ | #define GET_ENVIRONMENT_PROPERTY(val, prop, out)\ | ||||
if (!pSimulation2->GetScriptInterface().GetProperty(val, #prop, out))\ | if (!pSimulation2->GetScriptInterface().GetProperty(val, #prop, out))\ | ||||
LOGWARNING("CMapReader::ParseEnvironment() failed to get '%s' property", #prop); | LOGWARNING("CMapReader::ParseEnvironment() failed to get '%s' property", #prop); | ||||
JS::RootedValue envObj(rq.cx); | JS::RootedValue envObj(rq.cx); | ||||
GET_ENVIRONMENT_PROPERTY(m_MapData, Environment, &envObj) | GET_ENVIRONMENT_PROPERTY(m_MapData, Environment, &envObj) | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | |||||
#undef GET_ENVIRONMENT_PROPERTY | #undef GET_ENVIRONMENT_PROPERTY | ||||
return 0; | return 0; | ||||
} | } | ||||
int CMapReader::ParseCamera() | int CMapReader::ParseCamera() | ||||
{ | { | ||||
ScriptInterface::Request rq(pSimulation2->GetScriptInterface()); | ScriptRequest rq(pSimulation2->GetScriptInterface()); | ||||
// parse camera settings from map data | // parse camera settings from map data | ||||
// defaults if we don't find player starting camera | // defaults if we don't find player starting camera | ||||
float declination = DEGTORAD(30.f), rotation = DEGTORAD(-45.f); | float declination = DEGTORAD(30.f), rotation = DEGTORAD(-45.f); | ||||
CVector3D translation = CVector3D(100, 150, -100); | CVector3D translation = CVector3D(100, 150, -100); | ||||
#define GET_CAMERA_PROPERTY(val, prop, out)\ | #define GET_CAMERA_PROPERTY(val, prop, out)\ | ||||
if (!pSimulation2->GetScriptInterface().GetProperty(val, #prop, out))\ | if (!pSimulation2->GetScriptInterface().GetProperty(val, #prop, out))\ | ||||
Show All 33 Lines |
Wildfire Games · Phabricator