mirror of
https://github.com/glest/glest-source.git
synced 2025-08-13 20:03:58 +02:00
8 player fix for existing scenarios. Closed slots don't have to be set any more.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
// Copyright (C) 2001-2005 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -143,10 +143,19 @@ void MenuStateScenario::loadScenarioInfo(string file, ScenarioInfo *scenarioInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
const XmlNode *playersNode= scenarioNode->getChild("players");
|
const XmlNode *playersNode= scenarioNode->getChild("players");
|
||||||
|
|
||||||
for(int i= 0; i<GameConstants::maxPlayers; ++i){
|
for(int i= 0; i<GameConstants::maxPlayers; ++i){
|
||||||
const XmlNode* playerNode = playersNode->getChild("player", i);
|
XmlNode* playerNode;
|
||||||
ControlType factionControl = strToControllerType( playerNode->getAttribute("control")->getValue() );
|
string factionTypeName;
|
||||||
string factionTypeName;
|
ControlType factionControl;
|
||||||
|
|
||||||
|
if(playersNode->hasChildAtIndex("player",i)){
|
||||||
|
playerNode = playersNode->getChild("player", i);
|
||||||
|
factionControl = strToControllerType( playerNode->getAttribute("control")->getValue() );
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
factionControl=ctClosed;
|
||||||
|
}
|
||||||
|
|
||||||
scenarioInfo->factionControls[i] = factionControl;
|
scenarioInfo->factionControls[i] = factionControl;
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest Shared Library (www.glest.org)
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -109,6 +109,7 @@ public:
|
|||||||
XmlAttribute *getAttribute(const string &name) const;
|
XmlAttribute *getAttribute(const string &name) const;
|
||||||
XmlNode *getChild(int i) const;
|
XmlNode *getChild(int i) const;
|
||||||
XmlNode *getChild(const string &childName, int childIndex=0) const;
|
XmlNode *getChild(const string &childName, int childIndex=0) const;
|
||||||
|
bool hasChildAtIndex(const string &childName, int childIndex=0) const;
|
||||||
bool hasChild(const string &childName) const;
|
bool hasChild(const string &childName) const;
|
||||||
XmlNode *getParent() const;
|
XmlNode *getParent() const;
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest Shared Library (www.glest.org)
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -269,6 +269,24 @@ XmlNode *XmlNode::getChild(const string &childName, int i) const{
|
|||||||
throw runtime_error("Node \""+getName()+"\" doesn't have "+intToStr(i+1)+" children named \""+childName+"\"\n\nTree: "+getTreeString());
|
throw runtime_error("Node \""+getName()+"\" doesn't have "+intToStr(i+1)+" children named \""+childName+"\"\n\nTree: "+getTreeString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool XmlNode::hasChildAtIndex(const string &childName, int i) const
|
||||||
|
{
|
||||||
|
int count= 0;
|
||||||
|
for(int j = 0; j < children.size(); ++j)
|
||||||
|
{
|
||||||
|
if(children[j]->getName()==childName)
|
||||||
|
{
|
||||||
|
if(count==i){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool XmlNode::hasChild(const string &childName) const
|
bool XmlNode::hasChild(const string &childName) const
|
||||||
{
|
{
|
||||||
int count= 0;
|
int count= 0;
|
||||||
|
Reference in New Issue
Block a user