From b29871cb8c3d428925f001a379441c2ba21cd840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 15 Jun 2011 06:09:24 +0200 Subject: [PATCH] Fixed tick count offset, hotkey support is back from the dead (untested) --- Memory.xml | 44 +++++++++++++-------------- library/Core-windows.cpp | 8 ++++- library/include/dfhack/modules/Gui.h | 5 ++-- library/modules/Gui.cpp | 45 ++++++---------------------- 4 files changed, 40 insertions(+), 62 deletions(-) diff --git a/Memory.xml b/Memory.xml index c61576bcf..10f11db7a 100644 --- a/Memory.xml +++ b/Memory.xml @@ -805,6 +805,7 @@
+
@@ -989,12 +990,6 @@ - -
- - - -
@@ -1134,6 +1129,7 @@
+
@@ -1305,12 +1301,7 @@ - -
- - - - + +
@@ -2244,21 +2236,24 @@ + +
+ - -
- - - - - 0x194 TEST - - - + +
+ + + + + 0x194 TEST + + + cmake item vector: @@ -3022,6 +3017,9 @@ WORLD: 0x93f77a0 + +
+ Maybe, possibly.
diff --git a/library/Core-windows.cpp b/library/Core-windows.cpp index adb4c1cff..c98465e1e 100644 --- a/library/Core-windows.cpp +++ b/library/Core-windows.cpp @@ -38,6 +38,8 @@ distribution. #include #include #include +#include +#include #define MAX_CONSOLE_LINES 250; @@ -62,7 +64,7 @@ void RedirectIOToConsole() long lStdHandle; CONSOLE_SCREEN_BUFFER_INFO coninfo; FILE *fp; - + DWORD oldMode, newMode; // allocate a console for this app AllocConsole(); @@ -85,6 +87,9 @@ void RedirectIOToConsole() fp = _fdopen( hConHandle, "r" ); *stdin = *fp; setvbuf( stdin, NULL, _IONBF, 0 ); + GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),&oldMode); + newMode = oldMode | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT; + SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),newMode); // redirect unbuffered STDERR to the console lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE); @@ -819,3 +824,4 @@ bool FirstCall() inited = true; return 1; } + diff --git a/library/include/dfhack/modules/Gui.h b/library/include/dfhack/modules/Gui.h index 7a77ce4d6..f27b1fd67 100644 --- a/library/include/dfhack/modules/Gui.h +++ b/library/include/dfhack/modules/Gui.h @@ -27,12 +27,13 @@ namespace DFHack */ struct t_hotkey { - char name[10]; + std::string name; int16_t mode; int32_t x; int32_t y; int32_t z; }; + typedef t_hotkey hotkey_array[16]; /** * \ingroup grp_gui */ @@ -69,7 +70,7 @@ namespace DFHack /* * Hotkeys (DF's zoom locations) */ - bool ReadHotkeys(t_hotkey hotkeys[]); + hotkey_array * hotkeys; /* * Window size in tiles diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index e2cb65fc0..4e2e6f700 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -48,7 +48,7 @@ struct Gui::Private Private() { Started = ViewScreeInited = MenuStateInited = false; - StartedHotkeys = StartedScreen = false; + StartedScreen = false; } bool ViewScreeInited; uint32_t view_screen_offset; @@ -63,12 +63,6 @@ struct Gui::Private uint32_t cursor_xyz_offset; uint32_t window_dims_offset; - bool StartedHotkeys; - uint32_t hotkey_start; - uint32_t hotkey_mode_offset; - uint32_t hotkey_xyz_offset; - uint32_t hotkey_size; - bool StartedScreen; uint32_t screen_tiles_ptr_offset; @@ -85,6 +79,14 @@ Gui::Gui(DFContextShared * _d) VersionInfo * mem = d->d->offset_descriptor; OffsetGroup * OG_Gui = mem->getGroup("GUI"); try + { + hotkeys = (hotkey_array *) OG_Gui->getAddress("hotkeys"); + } + catch(Error::All &) + { + hotkeys = 0; + }; + try { d->current_menu_state_offset = OG_Gui->getAddress("current_menu_state"); d->MenuStateInited = true; @@ -109,16 +111,6 @@ Gui::Gui(DFContextShared * _d) } catch(Error::All &){}; try - { - OffsetGroup * OG_Hotkeys = mem->getGroup("Hotkeys"); - d->hotkey_start = OG_Hotkeys->getAddress("start"); - d->hotkey_mode_offset = OG_Hotkeys->getOffset ("mode"); - d->hotkey_xyz_offset = OG_Hotkeys->getOffset("coords"); - d->hotkey_size = OG_Hotkeys->getHexValue("size"); - d->StartedHotkeys = true; - } - catch(Error::All &){}; - try { d->screen_tiles_ptr_offset = OG_Position->getAddress ("screen_tiles_pointer"); d->StartedScreen = true; @@ -166,25 +158,6 @@ bool Gui::ReadViewScreen (t_viewscreen &screen) return d->d->offset_descriptor->resolveObjectToClassID (last, screen.type); } -bool Gui::ReadHotkeys(t_hotkey hotkeys[]) -{ - if (!d->StartedHotkeys) - { - return false; - } - uint32_t currHotkey = d->hotkey_start; - Process * p = d->owner; - - for(uint32_t i = 0 ; i < NUM_HOTKEYS ;i++) - { - p->readSTLString(currHotkey,hotkeys[i].name,10); - hotkeys[i].mode = p->readWord(currHotkey+d->hotkey_mode_offset); - p->read (currHotkey + d->hotkey_xyz_offset, 3*sizeof (int32_t), (uint8_t *) &hotkeys[i].x); - currHotkey+=d->hotkey_size; - } - return true; -} - bool Gui::getViewCoords (int32_t &x, int32_t &y, int32_t &z) { if (!d->Started) return false;