bool win::checkIfFScreen(sf::RenderWindow &window)
{
TiXmlDocument doc;
TiXmlElement * fullscreen;
if(!doc.LoadFile("videoSettings.xml"))
{
fullscreen = new TiXmlElement( "Window" );
fullscreen->SetAttribute("Fullscreen: ", 0);
doc.LinkEndChild( fullscreen );
fullscreen->Attribute("Fullscreen: ");
std::cout << typeid(*fullscreen->Attribute("Fullscreen: ")).name() << std::endl;
doc.SaveFile("videoSettings.xml");
return false;
}
if(*(fullscreen->Attribute("Fullscreen: ")) == '0')
return false;
return true;
}
Idea:
So, I wanna store information about persons preference if he wants for the game to be fullscreen or windowed. I've created this bool function that checks if there is "videoSettings.xml" file and returns information about users preference. If the file doesn't exists it will be create with Fullscreen set to 0 (which basically means that the game will be windowed and the user could change it later in the game's settings).
Part that doesn't work:
if(*(fullscreen->Attribute("Fullscreen: ")) == '0')
return false;
After adding this two lines I've got Segmentation fault (core dumped).
It seems that that value is stored as char.
EDIT: This lines solved everything :) .
TiXmlHandle docHandle ( &doc );
TiXmlElement *child = docHandle.FirstChild( "Window" ).ToElement();
if(child)
if(*child->Attribute("fullscreen") == '1')
return true;
else if(*child->Attribute("fullscreen") == '0')
return false;
Thank you @frasnian .