http://oi41.tinypic.com/b46erc.jpg
The red outlined areas are the spots that the name should be placed, but instead its a bunch of characters that I can't read.
This is my loading code from the xml file
Code: Select all
void GameLoop::loadGame()
{
//xml stored save file
//read data
io::IXMLReader *reader = graphics->getFileSystem()->createXMLReader("saves/save.xml");
stringw currentSection;
int num_ships;
int num_cargo;
while(reader->read())
{
switch(reader->getNodeType())
{
case io::EXN_ELEMENT:
{
//read from playerstats
if(core::stringw(L"playerStats").equals_ignore_case(reader->getNodeName()))
{
CPlayer->loadObject(reader);
}
//load from cargo elemeent
//the extra code is because there are nested elements
if(currentSection==L"" && core::stringw(L"playerCargo").equals_ignore_case(reader->getNodeName()))
{
currentSection=L"playerCargo";
num_cargo = reader->getAttributeValueAsInt(0);
}
else if (currentSection.equals_ignore_case(L"playerCargo"))
{
CPlayer->loadCargo(reader,num_cargo);
}
//read from shipstats element
if(currentSection==L"" && core::stringw(L"shipStats").equals_ignore_case(reader->getNodeName()))
{
currentSection=L"shipStats";
num_ships = reader->getAttributeValueAsInt(0);
}
else if (currentSection.equals_ignore_case(L"shipStats"))
{
Manager->loadObjects(reader,num_ships);
}
}
break;
case io::EXN_ELEMENT_END:
{
currentSection=L"";
}
break;
}
}
}
Code: Select all
void gameManager::loadObjects(io::IXMLReader *reader, int numobjects)
{
CShip *newship;
//for num of ships inside of file
for(u32 i = 0;i<numobjects;i++)
{
if(core::stringw(intToString(i)).equals_ignore_case(reader->getNodeName()))
{
//create ship
//and set ship stats
ship_faction faction;
int t = reader->getAttributeValueAsInt(L"faction");
if(t==0)
{
faction = FACTION_TERRAN_FEDERATION;
}
if(t==1)
{
faction = FACTION_PROVIAN_CONSORTIUM;
}
if(t==2)
{
faction = FACTION_PIRATE;
}
if(t==3)
{
faction = FACTION_NEUTRAL;
}
ship_base *sclass;
int s = reader->getAttributeValueAsInt(L"ship");
for(unsigned int i=0; i<ships().ship_list.size();i++)
{
if(ships().ship_list[i]->index==s)
{
sclass = ships().ship_list[i];
}
}
vector3df pos;
vector3df rot;
pos.X = reader->getAttributeValueAsFloat(L"posX");
pos.Y = reader->getAttributeValueAsFloat(L"posY");
pos.Z = reader->getAttributeValueAsFloat(L"posZ");
rot.X = reader->getAttributeValueAsFloat(L"rotX");
rot.Y = reader->getAttributeValueAsFloat(L"rotY");
rot.Z = reader->getAttributeValueAsFloat(L"rotZ");
const wchar_t *name = reader->getAttributeValue(L"name");
//why the hell does the name keep bugging up
newship = new CShip(graphics,sound,pos,rot,sclass,faction,name);
newship->setHullPoints(reader->getAttributeValueAsInt(L"hullPoints"));
newship->setShieldPoints(reader->getAttributeValueAsInt(L"shieldPoints"));
newship->setArmorPoints(reader->getAttributeValueAsInt(L"armorPoints"));
addShip(newship);
//newship->setVelocity(reader->getAttributeValueAsFloat(L"velocity"));
}
}
}