findnameindexes - finds the indexes for a compound name, not very smart, but it works!

Signed-off-by: belal <jimbelal@gmail.com>
develop
belal 2010-02-18 20:13:53 -05:00
parent 423bad2820
commit 20a74354c5
3 changed files with 58 additions and 5 deletions

@ -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)

@ -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

@ -0,0 +1,49 @@
// Map cleaner. Removes all the snow, mud spills, blood and vomit from map tiles.
#include <iostream>
#include <iomanip>
#include <integers.h>
#include <vector>
using namespace std;
#include <DFTypes.h>
#include <DFHackAPI.h>
int main (void)
{
DFHack::API DF ("Memory.xml");
if(!DF.Attach())
{
cerr << "DF not found" << endl;
return 1;
}
map< string, vector<string> > 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<string> >::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;
}