diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-10-29 00:59:40 -0700 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-10-29 00:59:40 -0700 |
commit | f5cf3b82006ffe51f9462ddc8a6f65dce55a03d6 (patch) | |
tree | 02619aa602cf52d8d2700d9225bb0c2b1ba5c0c8 /crawl-ref/source/files.h | |
parent | e083e2c09aad37199affe880180f2eda90d213ac (diff) | |
download | crawl-ref-f5cf3b82006ffe51f9462ddc8a6f65dce55a03d6.tar.gz crawl-ref-f5cf3b82006ffe51f9462ddc8a6f65dce55a03d6.zip |
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.
Diffstat (limited to 'crawl-ref/source/files.h')
-rw-r--r-- | crawl-ref/source/files.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crawl-ref/source/files.h b/crawl-ref/source/files.h index 3c05196f4a..80dcf2c3ec 100644 --- a/crawl-ref/source/files.h +++ b/crawl-ref/source/files.h @@ -145,4 +145,15 @@ private: std::string filename; }; +class SavefileCallback +{ +public: + typedef void (*callback)(bool saving); + + SavefileCallback(callback func); + + static void pre_save(); + static void post_restore(); +}; + #endif |