Changeset View
Changeset View
Standalone View
Standalone View
source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | |||||
QUERYHANDLER(GenerateMap) | QUERYHANDLER(GenerateMap) | ||||
{ | { | ||||
try | try | ||||
{ | { | ||||
InitGame(); | InitGame(); | ||||
// Random map | // Random map | ||||
const ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface(); | const ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface(); | ||||
ScriptInterface::Request rq(scriptInterface); | ScriptRequest rq(scriptInterface); | ||||
JS::RootedValue settings(rq.cx); | JS::RootedValue settings(rq.cx); | ||||
scriptInterface.ParseJSON(*msg->settings, &settings); | scriptInterface.ParseJSON(*msg->settings, &settings); | ||||
scriptInterface.SetProperty(settings, "mapType", "random"); | scriptInterface.SetProperty(settings, "mapType", "random"); | ||||
JS::RootedValue attrs(rq.cx); | JS::RootedValue attrs(rq.cx); | ||||
ScriptInterface::CreateObject( | ScriptInterface::CreateObject( | ||||
rq, | rq, | ||||
Show All 11 Lines | catch (PSERROR_Game_World_MapLoadFailed&) | ||||
// Cancel loading | // Cancel loading | ||||
LDR_Cancel(); | LDR_Cancel(); | ||||
// Since map generation failed and we don't know why, use the blank map as a fallback | // Since map generation failed and we don't know why, use the blank map as a fallback | ||||
InitGame(); | InitGame(); | ||||
const ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface(); | const ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface(); | ||||
ScriptInterface::Request rq(scriptInterface); | ScriptRequest rq(scriptInterface); | ||||
// Set up 8-element array of empty objects to satisfy init | // Set up 8-element array of empty objects to satisfy init | ||||
JS::RootedValue playerData(rq.cx); | JS::RootedValue playerData(rq.cx); | ||||
ScriptInterface::CreateArray(rq, &playerData); | ScriptInterface::CreateArray(rq, &playerData); | ||||
for (int i = 0; i < 8; ++i) | for (int i = 0; i < 8; ++i) | ||||
{ | { | ||||
JS::RootedValue player(rq.cx); | JS::RootedValue player(rq.cx); | ||||
Show All 22 Lines | QUERYHANDLER(GenerateMap) | ||||
} | } | ||||
} | } | ||||
MESSAGEHANDLER(LoadMap) | MESSAGEHANDLER(LoadMap) | ||||
{ | { | ||||
InitGame(); | InitGame(); | ||||
const ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface(); | const ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface(); | ||||
ScriptInterface::Request rq(scriptInterface); | ScriptRequest rq(scriptInterface); | ||||
// Scenario | // Scenario | ||||
CStrW map = *msg->filename; | CStrW map = *msg->filename; | ||||
CStrW mapBase = map.BeforeLast(L".pmp"); // strip the file extension, if any | CStrW mapBase = map.BeforeLast(L".pmp"); // strip the file extension, if any | ||||
JS::RootedValue attrs(rq.cx); | JS::RootedValue attrs(rq.cx); | ||||
ScriptInterface::CreateObject( | ScriptInterface::CreateObject( | ||||
▲ Show 20 Lines • Show All 460 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator