Load New Map

I’m having trouble clearing the map with all its models, nodes, etc. so I can load a different map. Actually I am testing it by loading the same map again, and I’m getting some really weird and irritating results.

Anyway, what I would like to know is how to properly clear everything from memory so I can load the new map.

I am working with classes that hold for instance my player, an npc, physics objects, etc. and I am using ennox’s PhysX wrapper.

Currently I have my game set up to load an egg file with all the models and objects that I want in the map, then I find, for instance, inside this loaded egg file, a node called PlayerStart. Then I create the player at this node’s position and keep a pointer to it inside my World class. Pointers to all the loaded objects are kept inside different arrays, for instance I have an array for entities and an array for pathfinding nodes. Then just before I load a new map I remove all these objects by iterating through the arrays and calling each objects remove function, then the object gets deleted and set to be equal to None. Then I delete the array, and set it to be equal to a new clean array “[]”. Then the new map gets loaded.

The problem I am having is that sometimes I have models, completely different from what should be in its position, appearing on top of other models and when clearing and loading the map again these extra models are gone, then they reappear again randomly when reloading the map. And the worst is that sometimes, randomly, just after everything gets loaded the game just exits without any warnings or errors.

I’m getting very irritated and I have to get this fixed. Any ideas are welcome and if you think I should approach the whole thing differently, I am open to suggestion.

Please help!

Sounds like you’re using the right approach. The way to clear the map is to remember everything you put on it, and remove all of them.

Perhaps there are some things you have overlooked or forgotten about. Have you stopped all of your old tasks and intervals?

David

Check for your events as well. Been screwed a few times because i forgot to do an ignore to events i previously accepted.