Pickle said:
Seems kind of backwards way to fix it (not the valgrind idea, but removing the deletes). Where were the deletes before? I would hope they would all be in the destrcutor of the arenastate. But if this was the case it doesnt make sense that there would be crashes during the running of the game since the deletes/deconstructors would only be run last.
there are no deletes at the moment as they have always caused crashes that's why it works but with memory leaks. If I try deleting something it is in the Destructor of the ArenaState, and although it doesn't really make sense, the moment that you enter the Selection box, he first construct the state, then do its init maybe he also renders it and then it gets deleted again (I saw this in the stdout.txt when doing couts, and I think this is just how the preview thing works...?) that's why it crashes as soon as you enter the selection box... there are some things that are deleted, the moment you hit a monster (which is also a pointer) it gets deleted with delete but this also crashes when doing just delete, but it worked like this:
Code:
m_MonsterArr[position] = new ArenaMonster();
delete m_MonsterArr[position];
m_MonsterArr[position] = 0;
It's really weird as this class (the MonsterList, that contains a Monster array and some functions for adding and deleting them) is completely the same as one I used for a game in my school's engine where it worked perfectly. So the crashes must have something to do with the way that Penjin works as I'm sure I'm not doing anything wrong in terms of C++ coding...