merge of peterix's branch

develop
belal 2010-02-19 10:59:22 -05:00
commit 3581c08a7a
17 changed files with 138 additions and 51 deletions

@ -1,5 +1,5 @@
// Hotkey and Note Dump
// Or Hot Keynote Dump? :P
#include <iostream>
#include <climits>
#include <integers.h>
@ -21,40 +21,38 @@ int main (void)
return 1;
}
DFHack::memory_info mem = DF.getMemoryInfo();
DFHack::memory_info mem = DF.getMemoryInfo();
// 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;
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++)
{
DFHack::t_note temp;
DF.ReadNote(i,temp);
cout << "x: " << temp.x << "\ty: " << temp.y << "\tz: " << temp.z <<
"\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);
for(uint32_t i =0;i< NUM_HOTKEYS;i++)
{
if(hotkeys[i].mode != -1){
cout << "x: " << hotkeys[i].x << " y: " << hotkeys[i].y << " z: " << hotkeys[i].z <<
" text: " << hotkeys[i].name << endl;
}
}
DF.FinishReadNotes();
DF.Detach();
DFHack::t_note temp;
DF.ReadNote(i,temp);
cout << "x: " << temp.x << "\ty: " << temp.y << "\tz: " << temp.z <<
"\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);
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.Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();

@ -16,6 +16,7 @@ using namespace DFHack;
#include <signal.h>
string error;
API * pDF = 0;
static void finish(int sig);
@ -185,9 +186,21 @@ int pickColor(int tiletype)
string getGCCClassName (Process * p, uint32_t vptr)
{
int typeinfo = p->readDWord(vptr - 4);
int typestring = p->readDWord(typeinfo + 4);
return p->readCString(typestring);
int typeinfo = p->readDWord(vptr - 0x4);
int typestring = p->readDWord(typeinfo + 0x4);
string raw = p->readCString(typestring);
size_t start = raw.find_first_of("abcdefghijklmnopqrstuvwxyz");// trim numbers
size_t end = raw.length();
return raw.substr(start,end-start - 2); // trim the 'st' from the end
}
string getMSVCClassName (Process * p, uint32_t vptr)
{
int rtti = p->readDWord(vptr - 0x4);
int typeinfo = p->readDWord(rtti + 0xC);
string raw = p->readCString(typeinfo + 0xC); // skips the .?AV
raw.resize(raw.length() - 4);// trim st@@ from end
return raw;
}
main(int argc, char *argv[])
@ -241,17 +254,23 @@ main(int argc, char *argv[])
// init the API
DFHack::API DF("Memory.xml");
pDF = &DF;
// attach
if(!DF.Attach())
{
error = "Can't find DF.";
pDF = 0;
finish(0);
}
Process* p = DF.getProcess();
// init the map
DF.InitMap();
if(!DF.InitMap())
{
error = "Can't find a map to look at.";
pDF = 0;
finish(0);
}
DF.getSize(x_max_a,y_max_a,z_max_a);
x_max = x_max_a;
@ -262,6 +281,7 @@ main(int argc, char *argv[])
if(!DF.ReadStoneMatgloss(stonetypes))
{
error = "Can't read stone types.";
pDF = 0;
finish(0);
}
@ -269,6 +289,7 @@ main(int argc, char *argv[])
if(!DF.ReadGeology( layerassign ))
{
error = "Can't read local geology.";
pDF = 0;
finish(0);
}
@ -283,6 +304,7 @@ main(int argc, char *argv[])
// walk the map!
for (;;)
{
DF.Resume();
int c = getch(); /* refresh, accept single keystroke of input */
clrscr();
/* process the command keystroke */
@ -371,8 +393,10 @@ main(int argc, char *argv[])
{
if(vein != -1 && vein < veinVector.size())
{
string str = getGCCClassName(p, veinVector[vein].vtable);
if(str == "34block_square_event_frozen_liquidst")
//string str = getGCCClassName(p, veinVector[vein].vtable);
string className = p->readClassName(veinVector[vein].vtable);
//string str = "34block_square_event_frozen_liquidst";
if(className == "block_square_event_frozen_liquid")
{
t_frozenliquidvein frozen;
uint32_t size = sizeof(t_frozenliquidvein);
@ -391,7 +415,7 @@ main(int argc, char *argv[])
}
}
}
else if (str == "28block_square_event_mineralst")
else if (className == "block_square_event_mineral")
{
//iterate through vein rows
for(uint32_t j = 0;j<16;j++)
@ -411,17 +435,23 @@ main(int argc, char *argv[])
cprintf("%s",stonetypes[veinVector[vein].type].name);
}
gotoxy(0,51);
cprintf("%s, address 0x%x",str.c_str(),veinVector[vein].address_of);
cprintf("%s, address 0x%x",className.c_str(),veinVector[vein].address_of);
}
}
DF.Resume();
wrefresh(stdscr);
}
pDF = 0;
finish(0);
}
static void finish(int sig)
{
// ugly
if(pDF)
{
pDF->ForceResume();
pDF->Detach();
}
endwin();
if(!error.empty())
{

@ -907,7 +907,8 @@ bool API::InitReadNotes( uint32_t &numnotes )
}
bool API::ReadNote (const int32_t &index, t_note & note)
{
assert (d->notesInited);
if(!d->notesInited)
return false;
// read pointer from vector at position
uint32_t temp = * (uint32_t *) d->p_notes->at (index);
note.symbol = g_pProcess->readByte(temp);
@ -938,7 +939,8 @@ bool API::InitReadHotkeys( )
}
bool API::ReadHotkeys(t_hotkey hotkeys[])
{
assert (d->hotkeyInited);
if (!d->hotkeyInited)
return false;
uint32_t currHotkey = d->hotkey_start;
for(uint32_t i = 0 ; i < NUM_HOTKEYS ;i++)
{

@ -636,4 +636,14 @@ void SHMProcess::writeSTLString(const uint32_t address, const std::string writeS
full_barrier
((shm_write_small *)d->my_shm)->pingpong = DFPP_WRITE_STL_STRING;
d->waitWhile(DFPP_WRITE_STL_STRING);
}
string SHMProcess::readClassName (uint32_t vptr)
{
int typeinfo = readDWord(vptr - 0x4);
int typestring = readDWord(typeinfo + 0x4);
string raw = readCString(typestring);
size_t start = raw.find_first_of("abcdefghijklmnopqrstuvwxyz");// trim numbers
size_t end = raw.length();
return raw.substr(start,end-start - 2); // trim the 'st' from the end
}

@ -581,4 +581,13 @@ const string WineProcess::readSTLString (uint32_t offset)
string ret = temp;
delete temp;
return ret;
}
string WineProcess::readClassName (uint32_t vptr)
{
int rtti = readDWord(vptr - 0x4);
int typeinfo = readDWord(rtti + 0xC);
string raw = readCString(typeinfo + 0xC); // skips the .?AV
raw.resize(raw.length() - 4);// trim st@@ from end
return raw;
}

@ -526,4 +526,14 @@ const string NormalProcess::readSTLString (uint32_t offset)
string ret(temp);
delete temp;
return ret;
}
string NormalProcess::readClassName (uint32_t vptr)
{
int typeinfo = readDWord(vptr - 0x4);
int typestring = readDWord(typeinfo + 0x4);
string raw = readCString(typestring);
size_t start = raw.find_first_of("abcdefghijklmnopqrstuvwxyz");// trim numbers
size_t end = raw.length();
return raw.substr(start,end-start - 2); // trim the 'st' from the end
}

@ -723,4 +723,13 @@ void SHMProcess::writeSTLString(const uint32_t address, const std::string writeS
full_barrier
((shm_write_small *)d->my_shm)->pingpong = DFPP_WRITE_STL_STRING;
d->waitWhile(DFPP_WRITE_STL_STRING);
}
string SHMProcess::readClassName (uint32_t vptr)
{
int rtti = readDWord(vptr - 0x4);
int typeinfo = readDWord(rtti + 0xC);
string raw = readCString(typeinfo + 0xC); // skips the .?AV
raw.resize(raw.length() - 4);// trim st@@ from end
return raw;
}

@ -463,4 +463,13 @@ const string NormalProcess::readSTLString (uint32_t offset)
string ret = temp;
delete temp;
return ret;
}
string NormalProcess::readClassName (uint32_t vptr)
{
int rtti = readDWord(vptr - 0x4);
int typeinfo = readDWord(rtti + 0xC);
string raw = readCString(typeinfo + 0xC); // skips the .?AV
raw.resize(raw.length() - 4);// trim st@@ from end
return raw;
}

@ -96,6 +96,8 @@ namespace DFHack
virtual void writeSTLString(const uint32_t address, const std::string writeString) = 0;
// read a vector from memory
virtual DfVector readVector (uint32_t offset, uint32_t item_size) = 0;
// get class name of an object with rtti/type info
virtual string readClassName(uint32_t vptr) = 0;
virtual const std::string readCString (uint32_t offset) = 0;
@ -152,6 +154,8 @@ namespace DFHack
void writeSTLString(const uint32_t address, const std::string writeString){};
// read a vector from memory
DfVector readVector (uint32_t offset, uint32_t item_size);
// get class name of an object with rtti/type info
string readClassName(uint32_t vptr);
const std::string readCString (uint32_t offset);
@ -203,6 +207,8 @@ namespace DFHack
void writeSTLString(const uint32_t address, const std::string writeString);
// read a vector from memory
DfVector readVector (uint32_t offset, uint32_t item_size);
// get class name of an object with rtti/type info
string readClassName(uint32_t vptr);
const std::string readCString (uint32_t offset);
@ -254,6 +260,8 @@ namespace DFHack
void writeSTLString(const uint32_t address, const std::string writeString){};
// read a vector from memory
DfVector readVector (uint32_t offset, uint32_t item_size);
// get class name of an object with rtti/type info
string readClassName(uint32_t vptr);
const std::string readCString (uint32_t offset);

5
output/.gitignore vendored

@ -1,3 +1,8 @@
<<<<<<< HEAD
Debug
Release
=======
Debug
Release
>>>>>>> remotes/peterix/master
RelWithDebInfo

@ -1520,7 +1520,8 @@
<Address name="matgloss">0x9374E88</Address>
<HexValue name="matgloss_skip">0xC</HexValue>
<Address name="notes">0x09332C98</Address>
<!--<Address name="notes">0x09332C98</Address>-->
<Address name="notes">0x0931EA64</Address>
<Offset name="note_foreground">0x2</Offset>
<Offset name="note_background">0x4</Offset>
<Offset name="note_name">0x8</Offset>

@ -9,6 +9,5 @@ if [ $? -eq 0 ]; then
mv libs/libSDL* unused_libs/
fi
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"./libs" # Update library search path.
export LD_PRELOAD="./libs/dfconnect.so" # Hack DF!
export LD_PRELOAD="./libs/libdfconnect.so" # Hack DF!
./dwarfort.exe $* # Go, go, go! :)

Binary file not shown.

@ -158,7 +158,7 @@ void SHM_Act (void)
case DFPP_CL_ERROR:
case DFPP_RUNNING:
fprintf(stderr, "no. of waits: %d\n", numwaits);
//fprintf(stderr, "no. of waits: %d\n", numwaits);
//MessageBox(0,"Broke out of loop properly","FUN", MB_OK);
break;

@ -31,13 +31,10 @@ TARGET_LINK_LIBRARIES(dfbauxite dfhack)
ADD_EXECUTABLE(dfdigger digger.cpp)
TARGET_LINK_LIBRARIES(dfdigger dfhack)
# itemdesignator - change some item designations (dump, forbid, on-fire) for all items of a given type and material
ADD_EXECUTABLE(dfitemdesignator itemdesignator.cpp)
TARGET_LINK_LIBRARIES(dfitemdesignator dfhack)
ADD_EXECUTABLE(dffindnameindexes findnameindexes.cpp)
TARGET_LINK_LIBRARIES(dffindnameindexes dfhack)
IF(UNIX)
install(TARGETS