From 41475d19187d4a173f8540b5204c9608fa5bc26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 6 Nov 2009 01:04:17 +0000 Subject: [PATCH] manual merge of patch from http://www.bay12games.com/forum/index.php?topic=41916.msg850579#msg850579 --- doc/state/lever/linux/lever_off | 81 ++++++++++++++++++++++++++++++++ doc/state/lever/linux/lever_on | 81 ++++++++++++++++++++++++++++++++ doc/state/lever/windows-d16/diff | 23 +++++++++ library/DFHackAPI.cpp | 8 +++- library/DFHackAPI.h | 4 ++ library/DFTypes.h | 2 + output/Memory.xml | 6 ++- tools/CMakeLists.txt | 14 +++++- tools/attachtest.cpp | 4 +- tools/buildingsdump.cpp | 26 ++++++++-- tools/cleanmap.cpp | 2 + tools/creaturedump.cpp | 18 ++++++- tools/expbench.cpp | 4 +- tools/materialtest.cpp | 4 +- tools/prospector.cpp | 5 +- tools/reveal.cpp | 2 + 16 files changed, 273 insertions(+), 11 deletions(-) create mode 100644 doc/state/lever/linux/lever_off create mode 100644 doc/state/lever/linux/lever_on create mode 100644 doc/state/lever/windows-d16/diff diff --git a/doc/state/lever/linux/lever_off b/doc/state/lever/linux/lever_off new file mode 100644 index 000000000..5e6886fbe --- /dev/null +++ b/doc/state/lever/linux/lever_off @@ -0,0 +1,81 @@ + 0x00cdfd950 +0x0000 e8 69 6c 08 +0x0004 90 00 00 00 +0x0008 8f 00 00 00 +0x000c 90 00 00 00 + +0x0010 90 00 00 00 +0x0014 8f 00 00 00 +0x0018 8f 00 00 00 +0x001c 0f 00 00 00 + +0x0020 01 00 00 00 +0x0024 01 00 87 00 +0x0028 00 00 00 00 +0x002c f8 dc 0d 10 + +0x0030 f8 c6 0d 10 +0x0034 78 c2 0d 10 +0x0038 b0 7c 0d 10 +0x003c fe 52 01 00 + +0x0040 a6 00 df 0a +0x0044 1b ee 00 00 +0x0048 30 96 a7 10 +0x004c 30 96 a7 10 + +0x0050 34 96 a7 10 +0x0054 00 00 00 00 +0x0058 00 00 00 00 +0x005c 00 00 00 00 + +0x0060 00 00 00 00 +0x0064 00 00 00 00 +0x0068 00 00 00 00 +0x006c 00 00 00 00 + +0x0070 00 00 00 00 +0x0074 00 00 00 00 +0x0078 00 00 00 00 +0x007c 00 00 00 00 + +0x0080 00 00 00 00 +0x0084 00 00 00 00 +0x0088 00 00 00 00 +0x008c 00 00 00 00 + +0x0090 00 00 00 00 +0x0094 00 00 00 00 +0x0098 01 00 00 00 +0x009c 00 47 e4 0d + +0x00a0 18 47 e4 0d +0x00a4 18 47 e4 0d +0x00a8 00 00 00 00 +0x00ac 00 00 00 00 + +0x00b0 00 00 00 00 +0x00b4 00 00 00 00 +0x00b8 80 47 e4 0d +0x00bc 94 47 e4 0d + +0x00c0 94 47 e4 0d +0x00c4 00 00 00 00 +0x00c8 00 00 00 00 +0x00cc 00 00 00 00 + +0x00d0 00 00 00 00 +0x00d4 00 00 00 00 +0x00d8 00 00 00 00 +0x00dc 00 00 00 00 + +0x00e0 c0 c6 2d 00 +0x00e4 05 00 00 00 +0x00e8 14 00 00 00 +0x00ec 01 07 01 07 + +0x00f0 10 00 00 00 +0x00f4 b9 00 00 00 +0x00f8 68 59 6c 08 +0x00fc 98 00 00 00 +Done. Press any key to continue diff --git a/doc/state/lever/linux/lever_on b/doc/state/lever/linux/lever_on new file mode 100644 index 000000000..7ca9fdeed --- /dev/null +++ b/doc/state/lever/linux/lever_on @@ -0,0 +1,81 @@ + 0x00cdfd950 +0x0000 e8 69 6c 08 +0x0004 90 00 00 00 +0x0008 8f 00 00 00 +0x000c 90 00 00 00 + +0x0010 90 00 00 00 +0x0014 8f 00 00 00 +0x0018 8f 00 00 00 +0x001c 0f 00 00 00 + +0x0020 01 00 00 00 +0x0024 01 00 87 00 +0x0028 00 00 00 00 +0x002c f8 dc 0d 10 + +0x0030 f8 c6 0d 10 +0x0034 78 c2 0d 10 +0x0038 b0 7c 0d 10 +0x003c 34 51 01 00 + +0x0040 a6 00 df 0a +0x0044 1b ee 00 00 +0x0048 00 00 00 00 +0x004c 00 00 00 00 + +0x0050 00 00 00 00 +0x0054 00 00 00 00 +0x0058 00 00 00 00 +0x005c 00 00 00 00 + +0x0060 00 00 00 00 +0x0064 00 00 00 00 +0x0068 00 00 00 00 +0x006c 00 00 00 00 + +0x0070 00 00 00 00 +0x0074 00 00 00 00 +0x0078 00 00 00 00 +0x007c 00 00 00 00 + +0x0080 00 00 00 00 +0x0084 00 00 00 00 +0x0088 00 00 00 00 +0x008c 00 00 00 00 + +0x0090 00 00 00 00 +0x0094 00 00 00 00 +0x0098 01 00 00 00 +0x009c 00 47 e4 0d + +0x00a0 18 47 e4 0d +0x00a4 18 47 e4 0d +0x00a8 00 00 00 00 +0x00ac 00 00 01 00 + +0x00b0 00 00 00 00 +0x00b4 00 00 00 00 +0x00b8 80 47 e4 0d +0x00bc 94 47 e4 0d + +0x00c0 94 47 e4 0d +0x00c4 00 00 00 00 +0x00c8 00 00 00 00 +0x00cc 00 00 00 00 + +0x00d0 00 00 00 00 +0x00d4 00 00 00 00 +0x00d8 00 00 00 00 +0x00dc 00 00 00 00 + +0x00e0 c0 c6 2d 00 +0x00e4 05 00 00 00 +0x00e8 14 00 00 00 +0x00ec 01 07 01 07 + +0x00f0 10 00 00 00 +0x00f4 b9 00 00 00 +0x00f8 68 59 6c 08 +0x00fc 98 00 00 00 +Done. Press any key to continue diff --git a/doc/state/lever/windows-d16/diff b/doc/state/lever/windows-d16/diff new file mode 100644 index 000000000..36338dc9d --- /dev/null +++ b/doc/state/lever/windows-d16/diff @@ -0,0 +1,23 @@ +< OFF +> ON + + + +20c20 +< 15 0x003c 1c 53 01 00 +--- +> 15 0x003c 39 55 01 00 +28,30c28,30 +< 21 0x0054 00 00 00 00 +< 22 0x0058 00 00 00 00 +< 23 0x005c 00 00 00 00 +--- +> 21 0x0054 e0 53 a1 01 +> 22 0x0058 e0 53 a1 01 +> 23 0x005c e4 53 a1 01 + +this is a good candidate for lever state +82c82 +< 64 0x0100 00 00 00 00 +--- +> 64 0x0100 00 00 01 00 diff --git a/library/DFHackAPI.cpp b/library/DFHackAPI.cpp index 4410e3b29..d1b070a43 100644 --- a/library/DFHackAPI.cpp +++ b/library/DFHackAPI.cpp @@ -647,7 +647,10 @@ uint32_t DFHackAPIImpl::InitReadCreatures() creature_type_offset = offset_descriptor->getOffset("creature_type"); creature_flags1_offset = offset_descriptor->getOffset("creature_flags1"); creature_flags2_offset = offset_descriptor->getOffset("creature_flags2"); - assert(creatures && creature_pos_offset && creature_type_offset && creature_flags1_offset && creature_flags2_offset); + creature_first_name_offset = offset_descriptor->getOffset("first_name"); + creature_nick_name_offset = offset_descriptor->getOffset("nick_name"); + assert(creatures && creature_pos_offset && creature_type_offset && + creature_flags1_offset && creature_flags2_offset && creature_nick_name_offset); p_cre = new DfVector(dm->readVector(creatures, 4)); return p_cre->getSize(); } @@ -664,6 +667,9 @@ bool DFHackAPIImpl::ReadCreature(const uint32_t &index, t_creature & furball) Mread(temp + creature_type_offset, sizeof(uint32_t), (uint8_t *) &furball.type); Mread(temp + creature_flags1_offset, sizeof(uint32_t), (uint8_t *) &furball.flags1); Mread(temp + creature_flags2_offset, sizeof(uint32_t), (uint8_t *) &furball.flags2); + // names. + furball.first_name = dm->readSTLString(temp+creature_first_name_offset); + furball.nick_name = dm->readSTLString(temp+creature_nick_name_offset); return true; } diff --git a/library/DFHackAPI.h b/library/DFHackAPI.h index 282e9c179..d5fc8b3dc 100644 --- a/library/DFHackAPI.h +++ b/library/DFHackAPI.h @@ -41,6 +41,8 @@ distribution. # endif #endif +#define BUILD_DFHACK_LIB + #include #include #include "integers.h" @@ -190,6 +192,8 @@ private: uint32_t creature_type_offset; uint32_t creature_flags1_offset; uint32_t creature_flags2_offset; + uint32_t creature_first_name_offset; + uint32_t creature_nick_name_offset; ProcessManager* pm; Process* p; diff --git a/library/DFTypes.h b/library/DFTypes.h index 4b5ab4c3e..4c14240d1 100644 --- a/library/DFTypes.h +++ b/library/DFTypes.h @@ -388,6 +388,8 @@ struct t_creature uint32_t type; t_creaturflags1 flags1; t_creaturflags2 flags2; + string first_name; + string nick_name; }; // TODO: research this further? consult DF hacker wizards? diff --git a/output/Memory.xml b/output/Memory.xml index d09632a4a..e31b5100e 100644 --- a/output/Memory.xml +++ b/output/Memory.xml @@ -86,6 +86,8 @@ 0x1D64 + 0x00 + 0x1C 0x94 0x88 0x8C @@ -136,7 +138,7 @@ - + @@ -378,6 +380,8 @@
0x093326AC
+ 0x00 + 0x04 0x4C 0x44 0x90 diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index dd6060bf2..1051ba6c7 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -40,5 +40,17 @@ TARGET_LINK_LIBRARIES(dfmaterialtest dfhack) IF(UNIX) -install(TARGETS dfexpbench dfreveal dfreveal dfprospector dfcleanmap dfcreaturedump dfattachtest dfmaterialtest RUNTIME DESTINATION bin) +install(TARGETS +dfexpbench +dfreveal +dfreveal +dfprospector +dfcleanmap +dfcreaturedump +dfattachtest +dfmaterialtest +dfbuildingsdump +RUNTIME DESTINATION bin + +) ENDIF(UNIX) \ No newline at end of file diff --git a/tools/attachtest.cpp b/tools/attachtest.cpp index 68b70ad68..f58b524fa 100644 --- a/tools/attachtest.cpp +++ b/tools/attachtest.cpp @@ -65,8 +65,10 @@ int main (void) time_diff = difftime(end, start); cout << "attach tests done in " << time_diff << " seconds." << endl; - cout << "Press any key to continue" << endl; + #ifndef LINUX_BUILD + cout << "Done. Press any key to continue" << endl; cin.ignore(); + #endif delete pDF; return 0; diff --git a/tools/buildingsdump.cpp b/tools/buildingsdump.cpp index 69937fb91..d41749bc2 100644 --- a/tools/buildingsdump.cpp +++ b/tools/buildingsdump.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -62,7 +63,7 @@ void interleave_hex (DFHackAPI& DF, vector < uint32_t > & addresses, uint32_t le cout << setfill('0'); // output a header - cout << " "; + cout << "line offset "; for (int obj = 0; obj < addresses.size(); obj++) { cout << "0x" << hex << setw(9) << addresses[obj] << " "; @@ -75,6 +76,9 @@ void interleave_hex (DFHackAPI& DF, vector < uint32_t > & addresses, uint32_t le { cout << endl; } + cout << setfill(' '); + cout << dec << setw(4) << offs/4 << " "; + cout << setfill('0'); cout << "0x" << hex << setw(4) << offs << " "; for (int object = 0; object < bufs.size(); object++) { @@ -108,7 +112,21 @@ void print_bits ( T val, std::ostream& out ) int main (int argc,const char* argv[]) { - if (argc != 2) return 1; + if (argc < 2 || argc > 3) + { + cout << "usage:" << endl; + cout << argv[0] << " object_name [number of lines]" << endl; + return 0; + } + int lines = 16; + if(argc == 3) + { + string s = argv[2]; //blah. I don't care + istringstream ins; // Declare an input string stream. + ins.str(s); // Specify string to read. + ins >> lines; // Reads the integers from the string. + } + vector creaturestypes; DFHackAPI *pDF = CreateDFHackAPI("Memory.xml"); @@ -133,11 +151,13 @@ int main (int argc,const char* argv[]) addresses.push_back(temp.origin); } } - interleave_hex(DF,addresses,16); + interleave_hex(DF,addresses,lines / 4); DF.FinishReadBuildings(); DF.Detach(); delete pDF; +#ifndef LINUX_BUILD cout << "Done. Press any key to continue" << endl; cin.ignore(); +#endif return 0; } \ No newline at end of file diff --git a/tools/cleanmap.cpp b/tools/cleanmap.cpp index a46bec338..8651b6d2d 100644 --- a/tools/cleanmap.cpp +++ b/tools/cleanmap.cpp @@ -49,7 +49,9 @@ int main (void) } DF.Detach(); delete pDF; + #ifndef LINUX_BUILD cout << "Done. Press any key to continue" << endl; cin.ignore(); + #endif return 0; } \ No newline at end of file diff --git a/tools/creaturedump.cpp b/tools/creaturedump.cpp index 929a9f5af..fa45d1d2e 100644 --- a/tools/creaturedump.cpp +++ b/tools/creaturedump.cpp @@ -46,7 +46,21 @@ int main (void) t_creature temp; DF.ReadCreature(i, temp); cout << "creature type " << creaturestypes[temp.type].id << ", position:" << temp.x << " " << temp.y << " "<< temp.z << endl; - + bool addendl = false; + if(!temp.first_name.empty()) + { + cout << "first name: " << temp.first_name; + addendl = true; + } + if(!temp.nick_name.empty()) + { + cout << ", nick name: " << temp.nick_name; + addendl = true; + } + if(addendl) + { + cout << endl; + } /* * FLAGS 1 */ @@ -112,7 +126,9 @@ int main (void) DF.FinishReadCreatures(); DF.Detach(); delete pDF; + #ifndef LINUX_BUILD cout << "Done. Press any key to continue" << endl; cin.ignore(); + #endif return 0; } \ No newline at end of file diff --git a/tools/expbench.cpp b/tools/expbench.cpp index fd6f40b3f..ab718b4b6 100644 --- a/tools/expbench.cpp +++ b/tools/expbench.cpp @@ -63,8 +63,10 @@ int main (void) cout << num_blocks << " blocks read" << endl; cout << bytes_read / (1024 * 1024) << " MB" << endl; cout << "map export tests done in " << time_diff << " seconds." << endl; - cout << "Press any key to continue" << endl; + #ifndef LINUX_BUILD + cout << "Done. Press any key to continue" << endl; cin.ignore(); + #endif delete pDF; return 0; } \ No newline at end of file diff --git a/tools/materialtest.cpp b/tools/materialtest.cpp index 5b1e52744..d182cba6d 100644 --- a/tools/materialtest.cpp +++ b/tools/materialtest.cpp @@ -39,8 +39,10 @@ int main (void) DF.Detach(); delete pDF; - + #ifndef LINUX_BUILD + cout << "Done. Press any key to continue" << endl; cin.ignore(); + #endif return 0; } \ No newline at end of file diff --git a/tools/prospector.cpp b/tools/prospector.cpp index 183097d8f..cc7f68eb2 100644 --- a/tools/prospector.cpp +++ b/tools/prospector.cpp @@ -159,7 +159,7 @@ int main (int argc, const char* argv[]) { materials[tempvein[xi][yi]] = 1; } - } + } } } } @@ -171,7 +171,10 @@ int main (int argc, const char* argv[]) cout << stonetypes[p->first].id << " : " << p->second << endl; } DF.Detach(); + #ifndef LINUX_BUILD + cout << "Done. Press any key to continue" << endl; cin.ignore(); + #endif delete pDF; return 0; } \ No newline at end of file diff --git a/tools/reveal.cpp b/tools/reveal.cpp index f64fdaa0a..4404c6106 100644 --- a/tools/reveal.cpp +++ b/tools/reveal.cpp @@ -49,7 +49,9 @@ int main (void) } DF.Detach(); delete pDF; + #ifndef LINUX_BUILD cout << "Done. Press any key to continue" << endl; cin.ignore(); + #endif return 0; } \ No newline at end of file