2010-02-18 18:13:53 -07:00
|
|
|
// Map cleaner. Removes all the snow, mud spills, blood and vomit from map tiles.
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <integers.h>
|
|
|
|
#include <vector>
|
2010-02-19 08:36:54 -07:00
|
|
|
#include <algorithm>
|
|
|
|
#include <sstream>
|
2010-02-18 18:13:53 -07:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include <DFTypes.h>
|
|
|
|
#include <DFHackAPI.h>
|
|
|
|
|
2010-02-19 08:36:54 -07:00
|
|
|
// returns a lower case version of the string
|
|
|
|
string tolower (const string & s)
|
|
|
|
{
|
|
|
|
string d (s);
|
|
|
|
|
|
|
|
transform (d.begin (), d.end (), d.begin (), (int(*)(int)) tolower);
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
string groupBy2(const string & s)
|
|
|
|
{
|
|
|
|
string d;
|
|
|
|
for(int i =2;i<s.length();i++){
|
|
|
|
if(i%2==0)
|
|
|
|
{
|
|
|
|
d+= s.substr(i-2,2) + " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d+=s.substr(s.length()-2,2);
|
|
|
|
return(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t endian_swap(uint32_t x)
|
|
|
|
{
|
|
|
|
x = (x>>24) |
|
|
|
|
((x<<8) & 0x00FF0000) |
|
|
|
|
((x>>8) & 0x0000FF00) |
|
|
|
|
(x<<24);
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-18 18:13:53 -07:00
|
|
|
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++){
|
2010-02-22 19:25:57 -07:00
|
|
|
uint32_t found = tolower(input).find(tolower(it->second[i]));
|
2010-02-18 18:13:53 -07:00
|
|
|
if(found != string::npos){
|
2010-02-19 08:36:54 -07:00
|
|
|
stringstream value;
|
|
|
|
value << setfill('0') << setw(8) << hex << endian_swap(i);
|
|
|
|
cout << it->first << " " << it->second[i] << " " << groupBy2(value.str()) << endl;
|
2010-02-18 18:13:53 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|