summaryrefslogtreecommitdiff
path: root/library/include/Core.h
diff options
context:
space:
mode:
Diffstat (limited to 'library/include/Core.h')
-rw-r--r--library/include/Core.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/library/include/Core.h b/library/include/Core.h
index 653298d8..e1f1cf3f 100644
--- a/library/include/Core.h
+++ b/library/include/Core.h
@@ -75,7 +75,9 @@ namespace DFHack
SC_MAP_UNLOADED = 3,
SC_VIEWSCREEN_CHANGED = 4,
SC_CORE_INITIALIZED = 5,
- SC_BEGIN_UNLOAD = 6
+ SC_BEGIN_UNLOAD = 6,
+ SC_PAUSED = 7,
+ SC_UNPAUSED = 8
};
// Core is a singleton. Why? Because it is closely tied to SDL calls. It tracks the global state of DF.
@@ -172,6 +174,10 @@ namespace DFHack
struct Private;
Private *d;
+ friend class CoreSuspendClaimer;
+ int ClaimSuspend(bool force_base);
+ void DisclaimSuspend(int level);
+
bool Init();
int Update (void);
int TileUpdate (void);
@@ -179,6 +185,7 @@ namespace DFHack
int DFH_SDL_Event(SDL::Event* event);
bool ncurses_wgetch(int in, int & out);
+ void doUpdate(color_ostream &out, bool first_update);
void onUpdate(color_ostream &out);
void onStateChange(color_ostream &out, state_change_event event);
@@ -228,6 +235,7 @@ namespace DFHack
// for state change tracking
void *last_local_map_ptr;
df::viewscreen *top_viewscreen;
+ bool last_pause_state;
// Very important!
bool started;
@@ -246,4 +254,20 @@ namespace DFHack
CoreSuspender(Core *core) : core(core) { core->Suspend(); }
~CoreSuspender() { core->Resume(); }
};
+
+ /** Claims the current thread already has the suspend lock.
+ * Strictly for use in callbacks from DF.
+ */
+ class CoreSuspendClaimer {
+ Core *core;
+ int level;
+ public:
+ CoreSuspendClaimer(bool base = false) : core(&Core::getInstance()) {
+ level = core->ClaimSuspend(base);
+ }
+ CoreSuspendClaimer(Core *core, bool base = false) : core(core) {
+ level = core->ClaimSuspend(base);
+ }
+ ~CoreSuspendClaimer() { core->DisclaimSuspend(level); }
+ };
}