Jump to content
  • Advertisement
Sign in to follow this  
Ravnerous

Loading TMX files with SDL2 using Baylej's C library

This topic is 843 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Having a little trouble loading in a TiledMap with Baylej's C TMX Loader. I'm looking at his SDL example and the map is loading mostly okay. The only it that the tiles list under the map variable is NULL.

I'm using his example .tmx files. I tried in XML, CSV and zlib, all with the same result.

 

 

This is my barebones code. Just trying to attempt to get the tiles to show up under the map in the debugger.

http://pastebin.com/XaTb4vjE

 

(Sorry for copy pasting code, It's not letting me link a pastebin).

If anyone has had this problem I'd appreciate some insight, as I am pretty stumped.

 

Cheers.

 

Edit: Here is a picture of my debugger, if you look at the bottom of locals you can see that tiles in NULL after loading the map in.

http://i.imgur.com/PlyStj8.png

Edited by Ravnerous

Share this post


Link to post
Share on other sites
Advertisement
bool TMXLoader::LoadMap(std::string location)
{
    tmx_map *map = tmx_load(location.c_str());
 
    return true;
}
Unless you are inspecting map on this line, the tmx_map is lost once this method returns.

Share this post


Link to post
Share on other sites

Yes, but I didn't step over the return and the rest of the object is still intact.

 

I put a quick printf before the return, redebugged and I still have the same results.

 

Thanks for the reply :)

Share this post


Link to post
Share on other sites
tilecount is populated which would suggest that your tiles are getting parsed properly.

What do you see if you expand the tiles node in the debugger?

Share this post


Link to post
Share on other sites
What Fastcall is saying is that you make a call and store the result in a pointer, but then never do anything with that pointer. The data isn't lost until execution returns; in this case when you return true. When you check the value before return the value will still be valid as you are still within the lifetime of the routine. Your variable is null because you never store that value in the routine and then it returns execution.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!