From f5cf3b82006ffe51f9462ddc8a6f65dce55a03d6 Mon Sep 17 00:00:00 2001 From: Matthew Cline Date: Thu, 29 Oct 2009 00:59:40 -0700 Subject: Pre- and post-savefile callbacks. The constructor of class SavefileCallback can be used to add a callback which is called before a game is saved and after it's restored. This is useful to move data in and out of you.props, or after a restore if there's data not stored in the savefile which can be easily regenerated. NOTE: I experienced some weirdness with C++ global constructors, and since global constructors probably differ with compiler and system, until this has been tested on all compiler/system combinations, any code which uses the callbacks should fail gracefully if the callbacks aren't called. --- crawl-ref/source/newgame.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crawl-ref/source/newgame.cc') diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index ffb56cf046..e36fa10a01 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -898,6 +898,11 @@ game_start: fix_up_jiyva_name(); _save_newgame_options(); + + // Pretend that a savefile was just loaded, in order to + // get things setup properly. + SavefileCallback::post_restore(); + return (true); } -- cgit v1.2.3-54-g00ecf