skelmud update:player file corruption
by Sorressean on Nov.22, 2009, under skelmud
One of the recent issues I’ve noticed while working on Skelmud, is that the player data may or may not have been saved between the last time it was modified, and the current time of the shutdown. My solution to this was two-fold.
First, I defined a signal handler, and set the callback for the signals used to kill applications. The signal basically sets a “running flag” to false. This means that the game loop will stop after its current iteration. After the body of the loop the gameloop calls server->Shutdown, which is where the fun comes in. The idea is to go through all the player objects, and save them, then kill their associated socket. After that is done, the zones can be saved. To avoid needlessly saving zones, I have built a “modified” flag into the zones, which should be set if the room is edited via OLC, and removed when the room is saved.