Well, I extended the Chr struct for my player, and the Item class for my objects. But I did not add a custom save method yet. Should I have?
This is all code i've added about saving and loading, located inside the update function:
Code:
if(Kb.bp(KB_F3)) {
Game::World.load("savegame");
}
if(Kb.bp(KB_F2)) {
Game::World.save("savegame");
}
I've also tried loading the path.world from the tutorials into my game. It also crashes. So i guess it's about the code, not the world. Still, everything works as long as i don't try to load a savegame.
While debugging i noticed the game halts during the day/night update, almost like in the tutorials.
Code:
(sky = Lerp(tl[prev].sky, tl[next].sky, step);
And indeed, those variables are not defined anymore. But if I disable that part of the program, the problem just happens someplace else. When I disable all input checking functions, the day/night functions and the soundsystem, it's ok. If I re-enable just one of them it works also. Doesn't matter which one.
Clearly some parts of the memory get overwritten. But if I was reckless with memory management in other parts of the game, why would it happen only when loading?