8 player fix for existing scenarios. Closed slots don't have to be set any more.
This commit is contained in:
parent
775386190a
commit
bb637920fa
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2005 Martiño Figueroa
|
||||
// Copyright (C) 2001-2005 Marti<EFBFBD>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// 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");
|
||||
|
||||
for(int i= 0; i<GameConstants::maxPlayers; ++i){
|
||||
const XmlNode* playerNode = playersNode->getChild("player", i);
|
||||
ControlType factionControl = strToControllerType( playerNode->getAttribute("control")->getValue() );
|
||||
string factionTypeName;
|
||||
XmlNode* playerNode;
|
||||
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;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
|
@ -109,6 +109,7 @@ public:
|
|||
XmlAttribute *getAttribute(const string &name) const;
|
||||
XmlNode *getChild(int i) 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;
|
||||
XmlNode *getParent() const;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// 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());
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
int count= 0;
|
||||
|
|
Loading…
Reference in New Issue