Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


TinyXML cant compare Attribute to the char

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
paupav
Master Cheater
Reputation: 13

Joined: 15 Apr 2011
Posts: 314
Location: P. Sherman 42, Wallaby Way, Sydney

PostPosted: Sat Dec 20, 2014 7:13 pm    Post subject: TinyXML cant compare Attribute to the char Reply with quote

Code:
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:

Code:
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.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Dec 20, 2014 10:51 pm    Post subject: Reply with quote

You should be calling ->Value() on the attribute to obtain the value data. The value still is a const char* so you will need to convert it to something else if you want to test it as a bool / int value. You can use atoi or similar functions to do that.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
paupav
Master Cheater
Reputation: 13

Joined: 15 Apr 2011
Posts: 314
Location: P. Sherman 42, Wallaby Way, Sydney

PostPosted: Mon Dec 22, 2014 5:17 pm    Post subject: Reply with quote

Thanks I've solved it.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites