Jump to content

Trouble with Map::Load(..)


Vulcan
 Share

Recommended Posts

I ran into a problem with loading map as I use a state machine to switch in and out between main menu and game level. First I didn't notice that the map wasn't unloaded as I thought it was unloaded when that state exited. But when I try to go back second time from menu it crashes and debugger points at Map::Load(..).

But how do I unload the map (when unloading state) so it could load another map later?

 

I have tryied with world->Clear() and world->Release() but without luck. How can I overcome this problem?

Link to comment
Share on other sites

Can we see some sections of code? I'm pretty sure you should be able to call Map::Load() any number of times. If it's failing maybe what you are passing it is invalid? Are you passing it a variable? Is that variable correctly set within your states when you go back into it?

Link to comment
Share on other sites

I have a created a sample project to replicate the error at Map::Load(). I noticed that different map files gave different results so I decided to include two map files (one that works and one that don't). Also noted that the skybox wasn't showing on one of them.

 

Look in Game.cpp at Game::Start() where Map::Load error occurs. If someone spots something bad/odd/weird code I would like to know so I could improve my code.

 

I have uploaded it here (look at the top of page to get download link):

http://speedy.sh/bCaPE/CrashMapLoad.zip

Link to comment
Share on other sites

After peppering the code to figure what it does I realized that Game::Exit() never was called. I did fix that but now I got an error after using _world->Clear() and then crashes on next _camera statement (when starting the map second time).

 

_camera->Move(strafe, 0, move);

 

EDIT: How can I reset camera?

Link to comment
Share on other sites

Is _camera valid? Cameras are entities that are in the world so clearing the world should clear the camera so make sure after you clear the world and load the map that either the map has a camera in it and you get it and assign it to _camera, or recreate your _camera variable after clearing the world.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...