summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/libutil.h
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-26 16:57:36 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-26 16:57:36 +0000
commit9d1463d7bdca2b485c5f8caa9b86782f29e30f8c (patch)
treedeeaa2d0b2a05d8ba346b941e9d47fcc3e40e95d /crawl-ref/source/libutil.h
parent5f2f20b49792c771ebd67442042f97344e2a6a56 (diff)
downloadcrawl-ref-9d1463d7bdca2b485c5f8caa9b86782f29e30f8c.tar.gz
crawl-ref-9d1463d7bdca2b485c5f8caa9b86782f29e30f8c.zip
Added support for a validation hook for maps to check if they're A-Ok.
Tweaked savefile format (breaks saves) to allow the game to perform emergency saves if level-generation fails (followers are lost, needs to be fixed). [1743698] Re-refixed SP_ELF stub (Eino). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1659 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/libutil.h')
-rw-r--r--crawl-ref/source/libutil.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/crawl-ref/source/libutil.h b/crawl-ref/source/libutil.h
index 1191ca6312..e327ab6d74 100644
--- a/crawl-ref/source/libutil.h
+++ b/crawl-ref/source/libutil.h
@@ -116,23 +116,29 @@ void usleep( unsigned long time );
int snprintf( char *str, size_t size, const char *format, ... );
#endif
-// Sets a boolean to a new value in the scope of the object instance.
-class unwind_bool
+template <typename T>
+class unwind_var
{
public:
- unwind_bool(bool &val_, bool newval) : val(val_), oldval(val_)
+ unwind_var(T &val_, T newval, T reset_to) : val(val_), oldval(reset_to)
{
val = newval;
}
- ~unwind_bool()
+ unwind_var(T &val_, T newval) : val(val_), oldval(val_)
+ {
+ val = newval;
+ }
+ ~unwind_var()
{
val = oldval;
}
private:
- bool &val;
- bool oldval;
+ T &val;
+ T oldval;
};
+typedef unwind_var<bool> unwind_bool;
+
class base_pattern
{
public: