Changeset View
Changeset View
Standalone View
Standalone View
source/ps/GameSetup/GameSetup.cpp
Show First 20 Lines • Show All 1,264 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < numPlayers; ++i) | ||||
JS::RootedValue player(rq.cx); | JS::RootedValue player(rq.cx); | ||||
// We could load player_defaults.json here, but that would complicate the logic | // We could load player_defaults.json here, but that would complicate the logic | ||||
// even more and autostart is only intended for developers anyway | // even more and autostart is only intended for developers anyway | ||||
Script::CreateObject(rq, &player, "Civ", "athen"); | Script::CreateObject(rq, &player, "Civ", "athen"); | ||||
Script::SetPropertyInt(rq, playerData, i, player); | Script::SetPropertyInt(rq, playerData, i, player); | ||||
} | } | ||||
// Set biome if wanted | |||||
if (args.Has("autostart-biome")) | |||||
{ | |||||
CStr biome = args.Get("autostart-biome"); | |||||
Script::SetProperty(rq, settings, "Biome", biome); | |||||
} | |||||
mapType = "random"; | mapType = "random"; | ||||
} | } | ||||
else if (mapDirectory == L"scenarios" || mapDirectory == L"skirmishes") | else if (mapDirectory == L"scenarios" || mapDirectory == L"skirmishes") | ||||
{ | { | ||||
// Initialize general settings from the map data so some values | // Initialize general settings from the map data so some values | ||||
// (e.g. name of map) are always present, even when autostart is | // (e.g. name of map) are always present, even when autostart is | ||||
// partially configured | // partially configured | ||||
CStr8 mapSettingsJSON = LoadSettingsOfScenarioMap("maps/" + autoStartName + ".xml"); | CStr8 mapSettingsJSON = LoadSettingsOfScenarioMap("maps/" + autoStartName + ".xml"); | ||||
Show All 14 Lines | else | ||||
throw PSERROR_Game_World_MapLoadFailed("Unrecognized map type.\nConsult readme.txt for the currently supported types."); | throw PSERROR_Game_World_MapLoadFailed("Unrecognized map type.\nConsult readme.txt for the currently supported types."); | ||||
} | } | ||||
Script::SetProperty(rq, attrs, "mapType", mapType); | Script::SetProperty(rq, attrs, "mapType", mapType); | ||||
Script::SetProperty(rq, attrs, "map", "maps/" + autoStartName); | Script::SetProperty(rq, attrs, "map", "maps/" + autoStartName); | ||||
Script::SetProperty(rq, settings, "mapType", mapType); | Script::SetProperty(rq, settings, "mapType", mapType); | ||||
Script::SetProperty(rq, settings, "CheatsEnabled", true); | Script::SetProperty(rq, settings, "CheatsEnabled", true); | ||||
if (args.Has("autostart-forpreview")) | |||||
{ | |||||
Script::SetProperty(rq, settings, "RevealMap", true); | |||||
Script::SetProperty(rq, settings, "ExploreMap", true); | |||||
} | |||||
// The seed is used for both random map generation and simulation | // The seed is used for both random map generation and simulation | ||||
u32 seed = 0; | u32 seed = 0; | ||||
if (args.Has("autostart-seed")) | if (args.Has("autostart-seed")) | ||||
{ | { | ||||
CStr seedArg = args.Get("autostart-seed"); | CStr seedArg = args.Get("autostart-seed"); | ||||
if (seedArg == "-1") | if (seedArg == "-1") | ||||
seed = rand(); | seed = rand(); | ||||
else | else | ||||
▲ Show 20 Lines • Show All 315 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator