Hello again everybody on GameDev.net forums you guys are always so helpful in my quest to learn and complete the game that I'm working on. So here is another problem I'm having that I'm hoping you guys can assist me with.
So let me give you a little run down on how my engine works, I have a class that builds the window and once its done doing that it passes control basically over to a game class that does most of the work or delegates the work to other systems. This game class instantiates the Render Manager class object, and an input manager object and a game state manager object as well. The render manager, and input manager objects are passed into the game state manager class so that the various states of the game can render and access input.
Now this system has worked just great since I started using it the first couple of states in the system work great I have the company logo's being displayed on a timed setting and they transition between each one easily and with no problems. Then the system changes the state over to the Main Menu and that state works great it changes the input scope over to that system and accepts input specific for that state and everything is happy. When that state accepts input to move on to the New Game it changes the current state over to the New Game and things seem to be fine. Now the New Game state is not complete I'm using it to test out various other systems like dialog boxes as well as my map system for displaying the main game play of the game on screen.
Hope your still with me on this so far... Now I should point out that before I started using the game state system I had created a temporary variable inside of the main Game class for the Map system and had tested out how it works made sure that everything gets loaded properly and that it accepted input and was drawing things to the screen just fine. So when I created the New Game State I simply copied over how I was creating the map to the New Game State I used the same variable, copied the lines that I used for setting it up and everything.
The Update call is called inside of the states update method which is called by the State Manager which is called by the game class, the draw call is setup the same way as well. Now when I build everything and start running the game the engine switches between the states just fine and when it gets to the switch over to the New Game state it does so just fine but by the time it reaches the point of doing an update and doing a draw call the map class's rendering object has become NULL again as if it was never received and before I'm asked I have verified that it is getting passed in and verified that it was received correctly in fact I stepped through every line of the Initialize process of the map system and up until the point where the initialize map method returns back to the state all objects that the map contains are in great shape and everything is happy.
But by the time it reaches the first update and the first draw call it loses the graphics object as well as a few other object variables now I realize this has something to do with how I'm holding onto the pointers for these variables what I'm trying to figure out is what would be the best course of action for this system should I be holding onto a smart_pointer or shared_pointer or what is your suggestion. I've been looking at this code now for a couple of days and honestly I'm just not seeing the answer right now. I know its going to be something simple that I'm missing here but that is why I'm here hoping that a fresh brain can point out what I'm missing.
So as always thank you in advance for any and all assistance you guys can provide.