From 20a74354c513a56b410e018436036ff5c2b1543f Mon Sep 17 00:00:00 2001 From: belal Date: Thu, 18 Feb 2010 20:13:53 -0500 Subject: [PATCH] findnameindexes - finds the indexes for a compound name, not very smart, but it works! Signed-off-by: belal --- examples/CMakeLists.txt | 5 ---- tools/CMakeLists.txt | 9 +++++++ tools/findnameindexes.cpp | 49 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 tools/findnameindexes.cpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c16c1104f..058d5014c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -37,11 +37,6 @@ TARGET_LINK_LIBRARIES(dfsuspend dfhack) ADD_EXECUTABLE(dfitemdump dfitemdump.cpp) TARGET_LINK_LIBRARIES(dfitemdump dfhack) -# digger - designate for digging by tile class -# Author: mizipzor -ADD_EXECUTABLE(dfdigger digger.cpp) -TARGET_LINK_LIBRARIES(dfdigger dfhack) - # hotkeynotedump - dumps the hotkeys and notes for the loaded map # Author: belal ADD_EXECUTABLE(dfhotkeynotedump hotkeynotedump.cpp) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 6a6fa9f95..ab93a9660 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -26,10 +26,19 @@ TARGET_LINK_LIBRARIES(dfincremental dfhack) ADD_EXECUTABLE(dfbauxite dfbauxite.cpp) TARGET_LINK_LIBRARIES(dfbauxite dfhack) +# digger - designate for digging by tile class +# Author: mizipzor +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 dfreveal diff --git a/tools/findnameindexes.cpp b/tools/findnameindexes.cpp new file mode 100644 index 000000000..7765e5656 --- /dev/null +++ b/tools/findnameindexes.cpp @@ -0,0 +1,49 @@ +// Map cleaner. Removes all the snow, mud spills, blood and vomit from map tiles. + +#include +#include +#include +#include +using namespace std; + +#include +#include + +int main (void) +{ + DFHack::API DF ("Memory.xml"); + if(!DF.Attach()) + { + cerr << "DF not found" << endl; + return 1; + } + map< string, vector > names; + if(!DF.InitReadNameTables(names)) + { + cerr << "Could not get Names" << endl; + return 1; + } + string input; + DF.ForceResume(); + cout << "\nSelect Name to search or q to Quit" << endl; + getline (cin, input); + while(input != "q"){ + for( map< string, vector >::iterator it = names.begin();it != names.end(); it++){ + for(uint32_t i = 0; i < it->second.size(); i++){ + uint32_t found = input.find(it->second[i]); + if(found != string::npos){ + cout << it->first << " " << it->second[i] << " " << setfill('0') << setw(8) << hex << i << endl; + } + } + } + DF.Resume(); + getline(cin,input); + } + DF.Detach(); + DF.FinishReadNameTables(); + #ifndef LINUX_BUILD + cout << "Done. Press any key to continue" << endl; + cin.ignore(); + #endif + return 0; +}