Fixed tick count offset, hotkey support is back from the dead (untested)

develop
Petr Mrázek 2011-06-15 06:09:24 +02:00
parent 71d46d533f
commit b29871cb8c
4 changed files with 40 additions and 62 deletions

@ -805,6 +805,7 @@
<Address name="current_cursor_creature" description="A vector? of creatures currently under the cursor."/> <Address name="current_cursor_creature" description="A vector? of creatures currently under the cursor."/>
<Address name="current_menu_state" description="A numeric value that describes the state of the current GUI element (switching between menus will change this)."/> <Address name="current_menu_state" description="A numeric value that describes the state of the current GUI element (switching between menus will change this)."/>
<Address name="view_screen" description="Pointer to the current view screen object (GUI screen)."/> <Address name="view_screen" description="Pointer to the current view screen object (GUI screen)."/>
<Address name="hotkeys" description="Address where the array of hotkeys starts.">
</Group> </Group>
<Group name="Maps" description="Offsets used by the Maps module."> <Group name="Maps" description="Offsets used by the Maps module.">
<Address name="map_data" description="Pointer to the start of the map structure."/> <Address name="map_data" description="Pointer to the start of the map structure."/>
@ -989,12 +990,6 @@
<Offset name="custom_workshop_name"/> <Offset name="custom_workshop_name"/>
<Offset name="custom_workshop_type"/> <Offset name="custom_workshop_type"/>
</Group> </Group>
<Group name="Hotkeys">
<Address name="start"/>
<Offset name="mode"/>
<Offset name="coords"/>
<HexValue name="sizeof"/>
</Group>
<Group name="Items"> <Group name="Items">
<!-- most of those seem completely unused! --> <!-- most of those seem completely unused! -->
<Address name="items_vector" /> <Address name="items_vector" />
@ -1134,6 +1129,7 @@
<Address name="current_cursor_creature" value="0xae82cc" valid="false" /> <Address name="current_cursor_creature" value="0xae82cc" valid="false" />
<Address name="current_menu_state" value="0x017f6f38" /> <Address name="current_menu_state" value="0x017f6f38" />
<Address name="view_screen" value="0xae82cc" valid="false" /> <Address name="view_screen" value="0xae82cc" valid="false" />
<Address name="hotkeys" value="0x01476ecc">
</Group> </Group>
<Group name="Maps"> <Group name="Maps">
<Address name="map_data" value="0x016AD718" /> <Address name="map_data" value="0x016AD718" />
@ -1305,12 +1301,7 @@
<Offset name="custom_workshop_name" value="0x4" /> <Offset name="custom_workshop_name" value="0x4" />
<Offset name="custom_workshop_type" value="0x20" /> <Offset name="custom_workshop_type" value="0x20" />
</Group> </Group>
<Group name="Hotkeys">
<Address name="start" value="0x01476ecc" />
<Offset name="mode" value="0x1C" />
<Offset name="coords" value="0x20" />
<HexValue name="sizeof" value="0x2C" />
</Group>
<!-- addresses from belal: vectors might need 8 subtracted from them <!-- addresses from belal: vectors might need 8 subtracted from them
buildings 0x0166f9a8 buildings 0x0166f9a8
constructions 0xffffffff constructions 0xffffffff
@ -2216,7 +2207,8 @@
<Address name="control_mode" value="0xb33814" /> <Address name="control_mode" value="0xb33814" />
<Address name="game_mode" value="0xb33818"/> <Address name="game_mode" value="0xb33818"/>
<Address name="current_year" value="0xef6268" /> <Address name="current_year" value="0xef6268" />
<Address name="current_tick" value="0xe17180" /> <!--<Address name="current_tick" value="0xe17180" />-->
<Address name="current_tick" value="0xec3170" />
<Address name="current_weather" value="0x14eb7a0" /> <Address name="current_weather" value="0x14eb7a0" />
</Group> </Group>
<Group name="GUI"> <Group name="GUI">
@ -2244,21 +2236,24 @@
<PETimeStamp value="0x4D90764F" /> <PETimeStamp value="0x4D90764F" />
<MD5 value="6ada05fc94785b53efe6aa5728b3756b" /> <MD5 value="6ada05fc94785b53efe6aa5728b3756b" />
<Offsets> <Offsets>
<Group name="Gui">
<Address name="hotkeys" value="0x14f5cc8" />
</Group>
<Group name="Creatures"> <Group name="Creatures">
<Group name="creature"> <Group name="creature">
<Offset name="flags3" value="0xE8"/> <Offset name="flags3" value="0xE8"/>
</Group> </Group>
</Group> </Group>
<Group name="Items" valid="true"> <Group name="Items" valid="true">
<Address name="items_vector" value="0x16c4540"/> <Address name="items_vector" value="0x16c4540"/>
<Offset name="id" value="0x14"/> <Offset name="id" value="0x14"/>
<Offset name="item_ref_vector" value="0x28" /> <Offset name="item_ref_vector" value="0x28" />
<Offset name="owner_ref_id_field" value="0x4" /> <Offset name="owner_ref_id_field" value="0x4" />
<Offset name="item_wear_accessor" value="0xCC" /> <Offset name="item_wear_accessor" value="0xCC" />
<Offset name="item_quantity_accessor" value="0x214" /> 0x194 TEST <Offset name="item_quantity_accessor" value="0x214" /> 0x194 TEST
<Offset name="item_quality_accessor" value="0x25C" /> <Offset name="item_quality_accessor" value="0x25C" />
</Group> </Group>
</Offsets> </Offsets>
cmake cmake
item vector: item vector:
@ -3022,6 +3017,9 @@
<MD5 value="fc15065c4d1977ca019c6dad220413d1" /> <MD5 value="fc15065c4d1977ca019c6dad220413d1" />
<Offsets> <Offsets>
WORLD: 0x93f77a0 WORLD: 0x93f77a0
<Group name="Gui">
<Address name="hotkeys" value="0x93f740c" />
</Group>
<Group name="Creatures"> <Group name="Creatures">
Maybe, possibly. Maybe, possibly.
<Address name="current_civ" value="0x093f2b50 0x93f2cdc" /> <Address name="current_civ" value="0x093f2b50 0x93f2cdc" />

@ -38,6 +38,8 @@ distribution.
#include <io.h> #include <io.h>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <istream>
#include <string>
#define MAX_CONSOLE_LINES 250; #define MAX_CONSOLE_LINES 250;
@ -62,7 +64,7 @@ void RedirectIOToConsole()
long lStdHandle; long lStdHandle;
CONSOLE_SCREEN_BUFFER_INFO coninfo; CONSOLE_SCREEN_BUFFER_INFO coninfo;
FILE *fp; FILE *fp;
DWORD oldMode, newMode;
// allocate a console for this app // allocate a console for this app
AllocConsole(); AllocConsole();
@ -85,6 +87,9 @@ void RedirectIOToConsole()
fp = _fdopen( hConHandle, "r" ); fp = _fdopen( hConHandle, "r" );
*stdin = *fp; *stdin = *fp;
setvbuf( stdin, NULL, _IONBF, 0 ); 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 // redirect unbuffered STDERR to the console
lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE); lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
@ -819,3 +824,4 @@ bool FirstCall()
inited = true; inited = true;
return 1; return 1;
} }

@ -27,12 +27,13 @@ namespace DFHack
*/ */
struct t_hotkey struct t_hotkey
{ {
char name[10]; std::string name;
int16_t mode; int16_t mode;
int32_t x; int32_t x;
int32_t y; int32_t y;
int32_t z; int32_t z;
}; };
typedef t_hotkey hotkey_array[16];
/** /**
* \ingroup grp_gui * \ingroup grp_gui
*/ */
@ -69,7 +70,7 @@ namespace DFHack
/* /*
* Hotkeys (DF's zoom locations) * Hotkeys (DF's zoom locations)
*/ */
bool ReadHotkeys(t_hotkey hotkeys[]); hotkey_array * hotkeys;
/* /*
* Window size in tiles * Window size in tiles

@ -48,7 +48,7 @@ struct Gui::Private
Private() Private()
{ {
Started = ViewScreeInited = MenuStateInited = false; Started = ViewScreeInited = MenuStateInited = false;
StartedHotkeys = StartedScreen = false; StartedScreen = false;
} }
bool ViewScreeInited; bool ViewScreeInited;
uint32_t view_screen_offset; uint32_t view_screen_offset;
@ -63,12 +63,6 @@ struct Gui::Private
uint32_t cursor_xyz_offset; uint32_t cursor_xyz_offset;
uint32_t window_dims_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; bool StartedScreen;
uint32_t screen_tiles_ptr_offset; uint32_t screen_tiles_ptr_offset;
@ -85,6 +79,14 @@ Gui::Gui(DFContextShared * _d)
VersionInfo * mem = d->d->offset_descriptor; VersionInfo * mem = d->d->offset_descriptor;
OffsetGroup * OG_Gui = mem->getGroup("GUI"); OffsetGroup * OG_Gui = mem->getGroup("GUI");
try 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->current_menu_state_offset = OG_Gui->getAddress("current_menu_state");
d->MenuStateInited = true; d->MenuStateInited = true;
@ -109,16 +111,6 @@ Gui::Gui(DFContextShared * _d)
} }
catch(Error::All &){}; catch(Error::All &){};
try 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->screen_tiles_ptr_offset = OG_Position->getAddress ("screen_tiles_pointer");
d->StartedScreen = true; d->StartedScreen = true;
@ -166,25 +158,6 @@ bool Gui::ReadViewScreen (t_viewscreen &screen)
return d->d->offset_descriptor->resolveObjectToClassID (last, screen.type); 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) bool Gui::getViewCoords (int32_t &x, int32_t &y, int32_t &z)
{ {
if (!d->Started) return false; if (!d->Started) return false;