Fix Atlas and autostart.
Fix non-POD in varargs. Remove misleading max_players config variable (the engine doesn't care about it, all the limits are hard-coded). Remove civ-center-based player civ initialisation hack. Add dummy player_defaults.json. Clean up formatting a bit. This was SVN commit r8498.
This commit is contained in:
parent
d6bf303740
commit
10c5dbcba4
@ -69,9 +69,6 @@ font.misc = verdana16
|
||||
; Colour of the sky (in "r g b" format)
|
||||
skycolor = "0 0 0"
|
||||
|
||||
; Maximum number of players in a session (default 6).
|
||||
max_players = 8
|
||||
|
||||
; GENERAL PREFERENCES:
|
||||
|
||||
sound.mastergain = 0.5
|
||||
|
@ -17,7 +17,7 @@ function initCivNameList()
|
||||
var civList = [ { "name": civ.Name, "code": civ.Code } for each (civ in g_CivData) ];
|
||||
|
||||
// Alphabetically sort the list, ignoring case
|
||||
civList.sort(sortIgnoreCase);
|
||||
civList.sort(sortNameIgnoreCase);
|
||||
|
||||
var civListNames = [ civ.name for each (civ in civList) ];
|
||||
var civListCodes = [ civ.code for each (civ in civList) ];
|
||||
|
@ -120,8 +120,8 @@ function parseJSONData(pathname)
|
||||
|
||||
// ====================================================================
|
||||
|
||||
// A sorting function for arrays, that ignores case
|
||||
function sortIgnoreCase (x, y)
|
||||
// A sorting function for arrays of objects with 'name' properties, ignoring case
|
||||
function sortNameIgnoreCase(x, y)
|
||||
{
|
||||
var lowerX = x.name.toLowerCase();
|
||||
var lowerY = y.name.toLowerCase();
|
||||
@ -210,10 +210,10 @@ function initPlayerDefaults()
|
||||
function iColorToString(color)
|
||||
{
|
||||
var string = "0 0 0";
|
||||
if(color.r && color.g && color.b)
|
||||
if (color && color.r && color.g && color.b)
|
||||
string = color.r + " " + color.g + " " + color.b;
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// ====================================================================
|
||||
|
@ -31,7 +31,7 @@ var g_GameAttributes = {
|
||||
}
|
||||
|
||||
// Max number of players for any map
|
||||
var g_MaxPlayers = g_ConfigDB.system["max_players"] || 8;
|
||||
var g_MaxPlayers = 8;
|
||||
|
||||
// Number of players for currently selected map
|
||||
var g_NumPlayers = 0;
|
||||
@ -44,8 +44,9 @@ var g_CivData = {};
|
||||
|
||||
|
||||
function init(attribs)
|
||||
{
|
||||
switch (attribs.type) {
|
||||
{
|
||||
switch (attribs.type)
|
||||
{
|
||||
case "offline":
|
||||
g_IsNetworked = false;
|
||||
g_IsController = true;
|
||||
@ -93,7 +94,7 @@ function init(attribs)
|
||||
|
||||
var numPlayers = getGUIObjectByName("numPlayersSelection");
|
||||
var players = [];
|
||||
for(var i = 1; i <= g_MaxPlayers; ++i)
|
||||
for (var i = 1; i <= g_MaxPlayers; ++i)
|
||||
players.push(i);
|
||||
numPlayers.list = players;
|
||||
numPlayers.list_data = players;
|
||||
@ -107,7 +108,7 @@ function init(attribs)
|
||||
if (this.selected != -1)
|
||||
g_GameAttributes.settings.GameType = this.list_data[this.selected];
|
||||
|
||||
if(!g_IsInGuiUpdate)
|
||||
if (!g_IsInGuiUpdate)
|
||||
onGameAttributesChange();
|
||||
};
|
||||
victoryConditions.selected = -1;
|
||||
@ -121,7 +122,7 @@ function init(attribs)
|
||||
if (this.selected != -1)
|
||||
g_GameAttributes.settings.Size = parseInt(this.list_data[this.selected]);
|
||||
|
||||
if(!g_IsInGuiUpdate)
|
||||
if (!g_IsInGuiUpdate)
|
||||
onGameAttributesChange();
|
||||
};
|
||||
mapSize.selected = -1;
|
||||
@ -130,7 +131,7 @@ function init(attribs)
|
||||
{ // Update attributes so other players can see change
|
||||
g_GameAttributes.settings.RevealMap = this.checked;
|
||||
|
||||
if(!g_IsInGuiUpdate)
|
||||
if (!g_IsInGuiUpdate)
|
||||
onGameAttributesChange();
|
||||
};
|
||||
|
||||
@ -138,7 +139,7 @@ function init(attribs)
|
||||
{ // Update attributes so other players can see change
|
||||
g_GameAttributes.settings.LockTeams = this.checked;
|
||||
|
||||
if(!g_IsInGuiUpdate)
|
||||
if (!g_IsInGuiUpdate)
|
||||
onGameAttributesChange();
|
||||
};
|
||||
}
|
||||
@ -195,7 +196,7 @@ function init(attribs)
|
||||
if (this.selected != -1)
|
||||
g_GameAttributes.settings.PlayerData[playerID].Team = this.list_data[this.selected];
|
||||
|
||||
if(!g_IsInGuiUpdate)
|
||||
if (!g_IsInGuiUpdate)
|
||||
onGameAttributesChange();
|
||||
};
|
||||
|
||||
@ -206,7 +207,7 @@ function init(attribs)
|
||||
if (this.selected != -1)
|
||||
g_GameAttributes.settings.PlayerData[playerID].Civ = this.list_data[this.selected];
|
||||
|
||||
if(!g_IsInGuiUpdate)
|
||||
if (!g_IsInGuiUpdate)
|
||||
onGameAttributesChange();
|
||||
};
|
||||
}
|
||||
@ -236,9 +237,11 @@ function handleNetMessage(message)
|
||||
{
|
||||
log("Net message: "+uneval(message));
|
||||
|
||||
switch (message.type) {
|
||||
switch (message.type)
|
||||
{
|
||||
case "netstatus":
|
||||
switch (message.status) {
|
||||
switch (message.status)
|
||||
{
|
||||
case "disconnected":
|
||||
Engine.DisconnectNetworkGame();
|
||||
Engine.PopGuiPage();
|
||||
@ -324,7 +327,7 @@ function initCivNameList()
|
||||
var civList = [ { "name": civ.Name, "code": civ.Code } for each (civ in g_CivData) ];
|
||||
|
||||
// Alphabetically sort the list, ignoring case
|
||||
civList.sort(sortIgnoreCase);
|
||||
civList.sort(sortNameIgnoreCase);
|
||||
|
||||
var civListNames = [ civ.name for each (civ in civList) ];
|
||||
var civListCodes = [ civ.code for each (civ in civList) ];
|
||||
@ -348,7 +351,8 @@ function initMapNameList()
|
||||
var mapSelectionBox = getGUIObjectByName("mapSelection")
|
||||
var mapFiles;
|
||||
|
||||
switch (g_GameAttributes.mapType) {
|
||||
switch (g_GameAttributes.mapType)
|
||||
{
|
||||
case "scenario":
|
||||
mapFiles = getXMLFileList(g_GameAttributes.mapPath);
|
||||
break;
|
||||
@ -369,7 +373,7 @@ function initMapNameList()
|
||||
var mapList = [ { "name": getMapDisplayName(file), "file": file } for each (file in mapFiles) ];
|
||||
|
||||
// Alphabetically sort the list, ignoring case
|
||||
mapList.sort(sortIgnoreCase);
|
||||
mapList.sort(sortNameIgnoreCase);
|
||||
|
||||
var mapListNames = [ map.name for each (map in mapList) ];
|
||||
var mapListFiles = [ map.file for each (map in mapList) ];
|
||||
@ -390,7 +394,8 @@ function loadMapData(name)
|
||||
{
|
||||
if (!g_MapData[name])
|
||||
{
|
||||
switch(g_GameAttributes.mapType) {
|
||||
switch (g_GameAttributes.mapType)
|
||||
{
|
||||
case "scenario":
|
||||
g_MapData[name] = Engine.LoadMapSettings(g_GameAttributes.mapPath+name);
|
||||
break;
|
||||
@ -448,7 +453,8 @@ function selectMapType(type)
|
||||
g_MapData = {};
|
||||
|
||||
// Select correct path
|
||||
switch (g_GameAttributes.mapType) {
|
||||
switch (g_GameAttributes.mapType)
|
||||
{
|
||||
case "scenario":
|
||||
g_GameAttributes.mapPath = "maps/scenarios/";
|
||||
break;
|
||||
@ -487,7 +493,8 @@ function selectMap(name)
|
||||
var mapSettings = (mapData && mapData.settings ? mapData.settings : {});
|
||||
|
||||
// Load map type specific settings (so we can overwrite them in the GUI)
|
||||
switch (g_GameAttributes.mapType) {
|
||||
switch (g_GameAttributes.mapType)
|
||||
{
|
||||
case "scenario":
|
||||
g_NumPlayers = (mapSettings.PlayerData ? mapSettings.PlayerData.length : g_MaxPlayers);
|
||||
break;
|
||||
@ -550,7 +557,8 @@ function onGameAttributesChange()
|
||||
var numPlayersBox = getGUIObjectByName("numPlayersBox");
|
||||
|
||||
// Handle map type specific logic
|
||||
switch (g_GameAttributes.mapType) {
|
||||
switch (g_GameAttributes.mapType)
|
||||
{
|
||||
case "random":
|
||||
|
||||
g_GameAttributes.script = mapSettings.Script;
|
||||
@ -795,7 +803,8 @@ function addChatMessage(msg)
|
||||
}
|
||||
|
||||
var formatted;
|
||||
switch (msg.type) {
|
||||
switch (msg.type)
|
||||
{
|
||||
case "connect":
|
||||
formatted = '[font="serif-bold-13"][color="'+ color +'"]' + username + '[/color][/font] [color="64 64 64"]has joined[/color]';
|
||||
break;
|
||||
|
@ -15,13 +15,13 @@ function init(data)
|
||||
var sprite = "";
|
||||
var loadingBkgArray = buildDirEntList("art/textures/ui/loading/", "*.dds", false);
|
||||
if (loadingBkgArray.length == 0)
|
||||
console.write ("ERROR: Failed to find any matching textures for the loading screen background.");
|
||||
error("Failed to find any matching textures for the loading screen background.");
|
||||
else
|
||||
{
|
||||
// Get a random index from the list of loading screen backgrounds.
|
||||
sprite = "stretched:" + loadingBkgArray[getRandom (0, loadingBkgArray.length-1)];
|
||||
sprite = sprite.replace ("art/textures/ui/", "");
|
||||
sprite = sprite.replace (".cached.dds", ""); // cope with pre-cached textures
|
||||
sprite = sprite.replace("art/textures/ui/", "");
|
||||
sprite = sprite.replace(".cached.dds", ""); // cope with pre-cached textures
|
||||
}
|
||||
getGUIObjectByName ("ldConcept").sprite = sprite;
|
||||
|
||||
@ -31,7 +31,8 @@ function init(data)
|
||||
var ldTitleBar = getGUIObjectByName ("ldTitleBar");
|
||||
var ldText = getGUIObjectByName ("ldText");
|
||||
|
||||
switch(data.attribs.mapType) {
|
||||
switch(data.attribs.mapType)
|
||||
{
|
||||
case "scenario":
|
||||
ldTitleBar.caption = "Loading Scenario";
|
||||
ldText.caption = "Loading " + mapName + "\nPlease wait...";
|
||||
@ -52,9 +53,9 @@ function init(data)
|
||||
|
||||
|
||||
// Pick a random tip of the day (each line is a separate tip).
|
||||
var tipArray = readFileLines("gui/text/tips.txt");
|
||||
var tipArray = readFileLines("gui/text/tips.txt");
|
||||
// Set tip string.
|
||||
getGUIObjectByName ("ldTip").caption = tipArray[getRandom(0, tipArray.length-1)];
|
||||
getGUIObjectByName("ldTip").caption = tipArray[getRandom(0, tipArray.length-1)];
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
|
@ -75,7 +75,7 @@ function init(initData, hotloadData)
|
||||
|
||||
// Cache civ data
|
||||
g_CivData = loadCivData();
|
||||
g_CivData["gaia"] = { "Code": "gaia", "Name": "Gaia"};
|
||||
g_CivData["gaia"] = { "Code": "gaia", "Name": "Gaia" };
|
||||
|
||||
getGUIObjectByName("civIcon").sprite = g_Players[Engine.GetPlayerID()].civ+"Icon";
|
||||
|
||||
|
@ -23,7 +23,7 @@ function getPlayerData(playerAssignments)
|
||||
|
||||
var name = playerState.name;
|
||||
var civ = playerState.civ;
|
||||
var color = {"r": playerState.colour["r"]*255, "g": playerState.colour["g"]*255, "b": playerState.colour["b"]*255, "a": playerState.colour["a"]*255};
|
||||
var color = {"r": playerState.colour.r*255, "g": playerState.colour.g*255, "b": playerState.colour.b*255, "a": playerState.colour.a*255};
|
||||
|
||||
var player = {"name": name, "civ": civ, "color": color, "team": playerState.team, "diplomacy": playerState.diplomacy, "state": playerState.state};
|
||||
players.push(player);
|
||||
|
BIN
binaries/data/mods/public/maps/scenarios/_default.xml
(Stored with Git LFS)
BIN
binaries/data/mods/public/maps/scenarios/_default.xml
(Stored with Git LFS)
Binary file not shown.
@ -0,0 +1,11 @@
|
||||
{"PlayerData": [
|
||||
{"Team":-1, "Civ":"gaia", "Name":"Gaia", "Colour":{"r":255,"g":255,"b":255}},
|
||||
{"Team":-1, "Civ":"hele", "Name":"Player 1", "Colour":{"r":255,"g":0,"b":0}},
|
||||
{"Team":-1, "Civ":"celt", "Name":"Player 2", "Colour":{"r":0,"g":0,"b":255}},
|
||||
{"Team":-1, "Civ":"celt", "Name":"Player 3", "Colour":{"r":0,"g":0,"b":255}},
|
||||
{"Team":-1, "Civ":"celt", "Name":"Player 4", "Colour":{"r":0,"g":0,"b":255}},
|
||||
{"Team":-1, "Civ":"celt", "Name":"Player 5", "Colour":{"r":0,"g":0,"b":255}},
|
||||
{"Team":-1, "Civ":"celt", "Name":"Player 6", "Colour":{"r":0,"g":0,"b":255}},
|
||||
{"Team":-1, "Civ":"celt", "Name":"Player 7", "Colour":{"r":0,"g":0,"b":255}},
|
||||
{"Team":-1, "Civ":"celt", "Name":"Player 8", "Colour":{"r":0,"g":0,"b":255}}
|
||||
]}
|
@ -2,9 +2,8 @@ function InitGame(settings)
|
||||
{
|
||||
// This will be called after the map (settings) have been loaded, before the simulation has started.
|
||||
// TODO: Is this even needed?
|
||||
if (!settings)
|
||||
if (!settings)
|
||||
settings = {};
|
||||
|
||||
}
|
||||
|
||||
Engine.RegisterGlobal("InitGame", InitGame);
|
||||
|
@ -1038,13 +1038,6 @@ int CXMLReader::ReadEntities(XMBElement parent, double end_time)
|
||||
// per-player camera start locations.
|
||||
if (m_MapReader.m_CameraStartupTarget == INVALID_ENTITY && PlayerID == m_MapReader.m_PlayerID && !cmpPosition.null())
|
||||
m_MapReader.m_CameraStartupTarget = ent;
|
||||
|
||||
// HACK: we also special-case civil centres to set the reported civ
|
||||
// for a (non-Gaia) player. This ought to be specified in the map file itself.
|
||||
// (The Identity component is script-only and this is a temporary hack anyway,
|
||||
// so we just eval a script.)
|
||||
if (PlayerID >= 1)
|
||||
sim.GetScriptInterface().Eval(("var ent = " + CStr(ent) + "; QueryOwnerInterface(ent, IID_Player).SetCiv(Engine.QueryInterface(ent, IID_Identity).GetCiv())").c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -985,9 +985,11 @@ static bool Autostart(const CmdLineArgs& args)
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface();
|
||||
CScriptValRooted attrs;
|
||||
g_Game->GetSimulation2()->GetScriptInterface().Eval("({})", attrs);
|
||||
g_Game->GetSimulation2()->GetScriptInterface().SetProperty(attrs.get(), "map", std::string(autostartMap), false);
|
||||
scriptInterface.Eval("({})", attrs);
|
||||
scriptInterface.SetProperty(attrs.get(), "mapType", std::string("scenario"), false);
|
||||
scriptInterface.SetProperty(attrs.get(), "map", std::string(autostartMap), false);
|
||||
|
||||
g_Game->SetPlayerID(1);
|
||||
g_Game->StartGame(attrs);
|
||||
|
@ -892,7 +892,7 @@ CScriptVal CComponentManager::Script_ReadJSONFile(void* cbdata, std::string file
|
||||
|
||||
if (!FileExists(g_VFS, path))
|
||||
{
|
||||
LOGERROR(L"File 'simulation/data/%hs' does not exist", fileName);
|
||||
LOGERROR(L"File 'simulation/data/%hs' does not exist", fileName.c_str());
|
||||
return CScriptVal();
|
||||
}
|
||||
|
||||
@ -902,7 +902,7 @@ CScriptVal CComponentManager::Script_ReadJSONFile(void* cbdata, std::string file
|
||||
|
||||
if (ret != PSRETURN_OK)
|
||||
{
|
||||
LOGERROR(L"Failed to load file '%s': %s", path.string(), GetErrorString(ret));
|
||||
LOGERROR(L"Failed to load file '%ls': %hs", path.string().c_str(), GetErrorString(ret));
|
||||
return CScriptVal();
|
||||
}
|
||||
|
||||
@ -910,4 +910,4 @@ CScriptVal CComponentManager::Script_ReadJSONFile(void* cbdata, std::string file
|
||||
|
||||
return (componentManager->m_ScriptInterface.ParseJSON(content)).get();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -59,9 +59,11 @@ namespace
|
||||
{
|
||||
CStrW mapBase = map.BeforeLast(L".pmp"); // strip the file extension, if any
|
||||
|
||||
ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface();
|
||||
CScriptValRooted attrs;
|
||||
g_Game->GetSimulation2()->GetScriptInterface().Eval("({})", attrs);
|
||||
g_Game->GetSimulation2()->GetScriptInterface().SetProperty(attrs.get(), "map", std::wstring(mapBase), false);
|
||||
scriptInterface.Eval("({})", attrs);
|
||||
scriptInterface.SetProperty(attrs.get(), "mapType", std::string("scenario"), false);
|
||||
scriptInterface.SetProperty(attrs.get(), "map", std::wstring(mapBase), false);
|
||||
|
||||
g_Game->StartGame(attrs);
|
||||
LDR_NonprogressiveLoad();
|
||||
|
Loading…
Reference in New Issue
Block a user