Hotkey reading

develop
Petr Mrázek 2010-04-11 02:32:50 +02:00
parent c58abe8ef9
commit d96d2018a8
7 changed files with 55 additions and 71 deletions

@ -397,41 +397,6 @@ void API::FinishReadSettlements()
d->settlementsInited = false;
}
bool API::InitReadHotkeys( )
{
try
{
memory_info * minfo = d->offset_descriptor;
d->hotkey_start = minfo->getAddress("hotkey_start");
d->hotkey_mode_offset = minfo->getOffset ("hotkey_mode");
d->hotkey_xyz_offset = minfo->getOffset("hotkey_xyz");
d->hotkey_size = minfo->getHexValue("hotkey_size");
d->hotkeyInited = true;
return true;
}
catch (Error::MissingMemoryDefinition&)
{
d->hotkeyInited = false;
throw;
}
}
bool API::ReadHotkeys(t_hotkey hotkeys[])
{
if (!d->hotkeyInited) return false;
uint32_t currHotkey = d->hotkey_start;
for(uint32_t i = 0 ; i < NUM_HOTKEYS ;i++)
{
d->p->readSTLString(currHotkey,hotkeys[i].name,10);
hotkeys[i].mode = g_pProcess->readWord(currHotkey+d->hotkey_mode_offset);
g_pProcess->read (currHotkey + d->hotkey_xyz_offset, 3*sizeof (int32_t), (uint8_t *) &hotkeys[i].x);
currHotkey+=d->hotkey_size;
}
return true;
}
bool API::getItemIndexesInBox(vector<uint32_t> &indexes,
const uint16_t x1, const uint16_t y1, const uint16_t z1,
const uint16_t x2, const uint16_t y2, const uint16_t z2)

@ -40,9 +40,15 @@ struct Position::Private
uint32_t cursor_xyz_offset;
uint32_t window_dims_offset;
uint32_t hotkey_start;
uint32_t hotkey_mode_offset;
uint32_t hotkey_xyz_offset;
uint32_t hotkey_size;
APIPrivate *d;
bool Inited;
bool Started;
bool StartedHotkeys;
//uint32_t biome_stuffs;
//vector<uint16_t> v_geology[eBiomeCount];
};
@ -51,36 +57,47 @@ Position::Position(APIPrivate * d_)
{
d = new Private;
d->d = d_;
d->Inited = d->Started = false;
memory_info * mem = d->d->offset_descriptor;
d->window_x_offset = mem->getAddress ("window_x");
d->window_y_offset = mem->getAddress ("window_y");
d->window_z_offset = mem->getAddress ("window_z");
d->cursor_xyz_offset = mem->getAddress ("cursor_xyz");
d->window_dims_offset = mem->getAddress ("window_dims");
d->Inited = d->Started = true;
d->Inited = true;
d->StartedHotkeys = d->Started = false;
memory_info * mem;
try
{
mem = d->d->offset_descriptor;
d->window_x_offset = mem->getAddress ("window_x");
d->window_y_offset = mem->getAddress ("window_y");
d->window_z_offset = mem->getAddress ("window_z");
d->cursor_xyz_offset = mem->getAddress ("cursor_xyz");
d->window_dims_offset = mem->getAddress ("window_dims");
d->Started = true;
d->hotkey_start = mem->getAddress("hotkey_start");
d->hotkey_mode_offset = mem->getOffset ("hotkey_mode");
d->hotkey_xyz_offset = mem->getOffset("hotkey_xyz");
d->hotkey_size = mem->getHexValue("hotkey_size");
d->StartedHotkeys = true;
}
catch(exception &){};
}
Position::~Position()
{
delete d;
}
/*
bool Position::InitViewAndCursor()
bool Position::ReadHotkeys(t_hotkey hotkeys[])
{
try
{
d->Inited = true;
return true;
}
catch (Error::MissingMemoryDefinition&)
if (!d->StartedHotkeys) return false;
uint32_t currHotkey = d->hotkey_start;
for(uint32_t i = 0 ; i < NUM_HOTKEYS ;i++)
{
d->cursorWindowInited = false;
throw;
g_pProcess->readSTLString(currHotkey,hotkeys[i].name,10);
hotkeys[i].mode = g_pProcess->readWord(currHotkey+d->hotkey_mode_offset);
g_pProcess->read (currHotkey + d->hotkey_xyz_offset, 3*sizeof (int32_t), (uint8_t *) &hotkeys[i].x);
currHotkey+=d->hotkey_size;
}
return true;
}
*/
bool Position::getViewCoords (int32_t &x, int32_t &y, int32_t &z)
{
if (!d->Inited) return false;

@ -83,10 +83,6 @@ namespace DFHack
uint32_t note_background_offset;
uint32_t note_name_offset;
uint32_t note_xyz_offset;
uint32_t hotkey_start;
uint32_t hotkey_mode_offset;
uint32_t hotkey_xyz_offset;
uint32_t hotkey_size;
uint32_t settlement_name_offset;
uint32_t settlement_world_xy_offset;

@ -44,8 +44,8 @@ TARGET_LINK_LIBRARIES(dfsuspend dfhack)
# hotkeynotedump - dumps the hotkeys and notes for the loaded map
# Author: belal
# ADD_EXECUTABLE(dfhotkeynotedump hotkeynotedump.cpp)
# TARGET_LINK_LIBRARIES(dfhotkeynotedump dfhack)
ADD_EXECUTABLE(dfhotkeynotedump hotkeynotedump.cpp)
TARGET_LINK_LIBRARIES(dfhotkeynotedump dfhack)
# findnameindexes
# Author: belal

@ -9,11 +9,11 @@ using namespace std;
#include <DFTypes.h>
#include <DFHackAPI.h>
#include <DFMemInfo.h>
#include <modules/Position.h>
int main (void)
{
vector<DFHack::t_matgloss> creaturestypes;
DFHack::API DF("Memory.xml");
try
{
@ -29,18 +29,17 @@ int main (void)
}
DFHack::memory_info * mem = DF.getMemoryInfo();
DFHack::Position * Pos = DF.getPosition();
// get stone matgloss mapping
/*
uint32_t numNotes;
if(!DF.InitReadNotes(numNotes))
{
cerr << "Can't get notes" << endl;
return 1;
}
if(!DF.InitReadHotkeys())
{
cerr << "Can't get hotkeys" << endl;
return 1;
}
*/
/*
cout << "Notes" << endl;
for(uint32_t i = 0; i < numNotes; i++)
{
@ -50,15 +49,16 @@ int main (void)
"\tsymbol: " << temp.symbol << "\tfg: " << temp.foreground << "\tbg: " << temp.background <<
"\ttext: " << temp.name << endl;
}
*/
cout << "Hotkeys" << endl;
DFHack::t_hotkey hotkeys[NUM_HOTKEYS];
DF.ReadHotkeys(hotkeys);
Pos->ReadHotkeys(hotkeys);
for(uint32_t i =0;i< NUM_HOTKEYS;i++)
{
cout << "x: " << hotkeys[i].x << "\ty: " << hotkeys[i].y << "\tz: " << hotkeys[i].z <<
"\ttext: " << hotkeys[i].name << endl;
}
DF.FinishReadNotes();
//DF.FinishReadNotes();
DF.Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;

@ -3181,6 +3181,12 @@ map_data_1b60_offset 0x1B9c
:(
Hotkeys
=======
<Address name="hotkey_start">0x01476ecc</Address>
<Offset name="hotkey_mode">0x1C</Offset>
<Offset name="hotkey_xyz">0x20</Offset>
<HexValue name="hotkey_size">0x2C</HexValue>
<!--
addresses from belal: vectors might need 8 subtracted from them

@ -271,7 +271,7 @@ int main (int argc, const char* argv[])
// init the map
if(!Maps->Start())
{
cerr << "Can't init map." << endl;
cerr << "Can't init map. Make sure you have a map loaded in DF." << endl;
DF.Detach();
#ifndef LINUX_BUILD
cin.ignore();
@ -308,7 +308,7 @@ int main (int argc, const char* argv[])
#endif
return 1;
}
printf("%d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x\n", cx,cy,cz, tt, veinmat, des.whole);
printf("%d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, veinmat, des.whole);
stack <Point> flood;
flood.push(xy);
uint32_t tx_max = x_max * 16;