Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Maploader for Tile editor  (Read 1204 times)

0 Members and 1 Guest are viewing this topic.

Nival

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Maploader for Tile editor
« on: January 27, 2018, 06:42:42 pm »
Hi guys, can anyone help me to load map from .tmx file, i tried to make it with tinyxml , coppied code from topics but always get error at "   image = tilesetElement->FirstChildElement("image");
                                          std::string imagepath = image->Attribute("source");"  -  read access violation.

Code in attachment

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Maploader for Tile editor
« Reply #1 on: January 27, 2018, 07:26:21 pm »
I recommend using tmxlite or if you must sfml-tmxloader.

Secondly you should learn some modern C++ where never use owning raw pointers and instead make use of unique (and shared) pointers and thus pretty much do away with manual memory management.

As for the crash:

image = tilesetElement->FirstChildElement("image");
std::string imagepath = image->Attribute("source");

It's most likely that FirstChildElement("image") returned nullptr and then you try to access it, causing an access violation, thus crash.
« Last Edit: January 27, 2018, 07:52:04 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nival

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Maploader for Tile editor
« Reply #2 on: January 27, 2018, 07:38:33 pm »
I recommend using tmxlite or if you must sfml-tmxloader.

Secondly you should learn some modern C++ where never use owning raw pointers and instead make use of unique (and shared) pointers and thus pretty much do away with manual memory management.

As for the crash:

        image = tilesetElement->FirstChildElement("image");
        std::string imagepath = image->Attribute("source");

It's most likely that FirstChildElement("image") returned false and then you try to access it, causing an access violation, thus crash.
Thanks, it's rly returned false i'll try to use libs that u adviced

 

anything