|
|
@ -20,53 +20,62 @@ struct matGlosses
|
|
|
|
vector<DFHack::t_matgloss> creatureMat;
|
|
|
|
vector<DFHack::t_matgloss> creatureMat;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
string getMaterialType(DFHack::t_item item, const vector<string> & buildingTypes,const matGlosses & mat){
|
|
|
|
const char * getMaterialType(DFHack::t_item item, const vector<string> & buildingTypes,const matGlosses & mat)
|
|
|
|
if(item.type == 85 || item.type == 113 || item.type == 117) // item_plant or item_thread or item_seeds
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return(string(mat.plantMat[item.material.type].id));
|
|
|
|
string itemtype = buildingTypes[item.type];
|
|
|
|
}
|
|
|
|
// plant thread seeds
|
|
|
|
else if(item.type == 109 || item.type == 114 || item.type == 115 || item.type == 116 || item.type==128 || item.type == 129|| item.type == 130|| item.type == 131) // item_skin_raw item_bones item_skill item_fish_raw item_pet item_skin_tanned item_shell
|
|
|
|
if(itemtype == "item_plant" || itemtype == "item_thread" || itemtype == "item_seeds" || itemtype == "item_leaves")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return(string(mat.creatureMat[item.material.type].id));
|
|
|
|
return mat.plantMat[item.material.type].id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(item.type == 124){ //wood
|
|
|
|
// item_skin_raw item_bones item_skull item_fish_raw item_pet item_skin_tanned item_shell
|
|
|
|
return(string(mat.woodMat[item.material.type].id));
|
|
|
|
else if(itemtype == "item_skin_raw" ||
|
|
|
|
}
|
|
|
|
itemtype == "item_skin_tanned" ||
|
|
|
|
else if(item.type == 118){ //blocks
|
|
|
|
itemtype == "item_fish_raw" ||
|
|
|
|
return(string(mat.metalMat[item.material.index].id));
|
|
|
|
itemtype == "item_pet" ||
|
|
|
|
|
|
|
|
itemtype == "item_shell" ||
|
|
|
|
|
|
|
|
itemtype == "item_horn"||
|
|
|
|
|
|
|
|
itemtype == "item_skull" ||
|
|
|
|
|
|
|
|
itemtype == "item_bones" ||
|
|
|
|
|
|
|
|
itemtype == "item_corpse"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return mat.creatureMat[item.material.type].id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(item.type == 86){ // item_glob I don't know what those are in game, just ignore them
|
|
|
|
else if(itemtype == "item_wood")
|
|
|
|
return(string(""));
|
|
|
|
{
|
|
|
|
|
|
|
|
return mat.woodMat[item.material.type].id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
switch (item.material.type)
|
|
|
|
switch (item.material.type)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 0:
|
|
|
|
return(string(mat.woodMat[item.material.index].id));
|
|
|
|
return mat.woodMat[item.material.index].id;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
return(string(mat.stoneMat[item.material.index].id));
|
|
|
|
return mat.stoneMat[item.material.index].id;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
return(string(mat.metalMat[item.material.index].id));
|
|
|
|
return mat.metalMat[item.material.index].id;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 12: // don't ask me why this has such a large jump, maybe this is not actually the matType for plants, but they all have this set to 12
|
|
|
|
case 12: // don't ask me why this has such a large jump, maybe this is not actually the matType for plants, but they all have this set to 12
|
|
|
|
return(string(mat.plantMat[item.material.index].id));
|
|
|
|
return mat.plantMat[item.material.index].id;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 3:
|
|
|
|
case 9:
|
|
|
|
case 9:
|
|
|
|
case 10:
|
|
|
|
case 10:
|
|
|
|
case 11:
|
|
|
|
case 11:
|
|
|
|
case 121:
|
|
|
|
case 121:
|
|
|
|
return(string(mat.creatureMat[item.material.index].id));
|
|
|
|
return mat.creatureMat[item.material.index].id;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
//DF.setCursorCoords(item.x,item.y,item.z);
|
|
|
|
return 0;
|
|
|
|
return(string(""));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void printItem(DFHack::t_item item, const vector<string> & buildingTypes,const matGlosses & mat){
|
|
|
|
void printItem(DFHack::t_item item, const vector<string> & buildingTypes,const matGlosses & mat)
|
|
|
|
|
|
|
|
{
|
|
|
|
cout << dec << "Item at x:" << item.x << " y:" << item.y << " z:" << item.z << endl;
|
|
|
|
cout << dec << "Item at x:" << item.x << " y:" << item.y << " z:" << item.z << endl;
|
|
|
|
cout << "Type: " << (int) item.type << " " << buildingTypes[item.type] << " Address: " << hex << item.origin << endl;
|
|
|
|
cout << "Type: " << (int) item.type << " " << buildingTypes[item.type] << " Address: " << hex << item.origin << endl;
|
|
|
|
cout << "Material: ";
|
|
|
|
cout << "Material: ";
|
|
|
@ -78,12 +87,14 @@ int main ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
DFHack::API DF ("Memory.xml");
|
|
|
|
DFHack::API DF ("Memory.xml");
|
|
|
|
|
|
|
|
cout << "This utility lets you mass-designate items by type and material." << endl <<"Like set on fire all MICROCLINE item_stone..." << endl
|
|
|
|
|
|
|
|
<< "Some unusual combinations might be untested and cause the program to crash..."<< endl << "so, watch your step and backup your fort" << endl;
|
|
|
|
if(!DF.Attach())
|
|
|
|
if(!DF.Attach())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
cerr << "DF not found" << endl;
|
|
|
|
cerr << "DF not found" << endl;
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DF.Suspend();
|
|
|
|
DF.InitViewAndCursor();
|
|
|
|
DF.InitViewAndCursor();
|
|
|
|
matGlosses mat;
|
|
|
|
matGlosses mat;
|
|
|
|
DF.ReadPlantMatgloss(mat.plantMat);
|
|
|
|
DF.ReadPlantMatgloss(mat.plantMat);
|
|
|
@ -103,16 +114,34 @@ int main ()
|
|
|
|
DFHack::t_item temp;
|
|
|
|
DFHack::t_item temp;
|
|
|
|
DF.ReadItem(i,temp);
|
|
|
|
DF.ReadItem(i,temp);
|
|
|
|
if(temp.type != -1)
|
|
|
|
if(temp.type != -1)
|
|
|
|
count[buildingtypes[temp.type]][getMaterialType(temp,buildingtypes,mat)].push_back(i);
|
|
|
|
{
|
|
|
|
|
|
|
|
const char * material = getMaterialType(temp,buildingtypes,mat);
|
|
|
|
|
|
|
|
if (material != 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
count[buildingtypes[temp.type]][material].push_back(i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cerr << "bad material string for item type: " << buildingtypes[temp.type] << "!" << endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
map< string, map<string,vector<uint32_t> > >::iterator it1;
|
|
|
|
map< string, map<string,vector<uint32_t> > >::iterator it1;
|
|
|
|
int i =0;
|
|
|
|
int i =0;
|
|
|
|
for(it1 = count.begin(); it1!=count.end();it1++){
|
|
|
|
for(it1 = count.begin(); it1!=count.end();it1++)
|
|
|
|
|
|
|
|
{
|
|
|
|
cout << i << ": " << it1->first << "\n";
|
|
|
|
cout << i << ": " << it1->first << "\n";
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cout << endl << "Select A Item Type:";
|
|
|
|
if(i == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cout << "No items found" << endl;
|
|
|
|
|
|
|
|
DF.FinishReadBuildings();
|
|
|
|
|
|
|
|
DF.Detach();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cout << endl << "Select an item type from the list:";
|
|
|
|
int number;
|
|
|
|
int number;
|
|
|
|
string in;
|
|
|
|
string in;
|
|
|
|
stringstream ss;
|
|
|
|
stringstream ss;
|
|
|
@ -121,7 +150,8 @@ int main ()
|
|
|
|
ss >> number;
|
|
|
|
ss >> number;
|
|
|
|
int j = 0;
|
|
|
|
int j = 0;
|
|
|
|
it1 = count.begin();
|
|
|
|
it1 = count.begin();
|
|
|
|
while(j < number && it1!=count.end()){
|
|
|
|
while(j < number && it1!=count.end())
|
|
|
|
|
|
|
|
{
|
|
|
|
it1++;
|
|
|
|
it1++;
|
|
|
|
j++;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -132,40 +162,47 @@ int main ()
|
|
|
|
cout << i << ":\t" << it2->first << " [" << it2->second.size() << "]" << endl;
|
|
|
|
cout << i << ":\t" << it2->first << " [" << it2->second.size() << "]" << endl;
|
|
|
|
i++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cout << endl << "Select A Material Type: ";
|
|
|
|
cout << endl << "Select a material type: ";
|
|
|
|
int number2;
|
|
|
|
int number2;
|
|
|
|
ss.clear();
|
|
|
|
ss.clear();
|
|
|
|
getline(cin, in);
|
|
|
|
getline(cin, in);
|
|
|
|
ss.str(in);
|
|
|
|
ss.str(in);
|
|
|
|
ss >> number2;
|
|
|
|
ss >> number2;
|
|
|
|
cout << "Select A Designation: " << flush;
|
|
|
|
|
|
|
|
|
|
|
|
decideAgain:
|
|
|
|
|
|
|
|
cout << "Select a designation - (d)ump, (f)orbid, (m)melt, on fi(r)e :" << flush;
|
|
|
|
string designationType;
|
|
|
|
string designationType;
|
|
|
|
getline(cin,designationType);
|
|
|
|
getline(cin,designationType);
|
|
|
|
//uint32_t changeFlag;
|
|
|
|
|
|
|
|
DFHack::t_itemflags changeFlag = {0};
|
|
|
|
DFHack::t_itemflags changeFlag = {0};
|
|
|
|
if(designationType == "d"){
|
|
|
|
if(designationType == "d" || designationType == "dump")
|
|
|
|
|
|
|
|
{
|
|
|
|
changeFlag.bits.dump = 1;
|
|
|
|
changeFlag.bits.dump = 1;
|
|
|
|
//changeFlag = (1 << 21);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(designationType == "f"){
|
|
|
|
else if(designationType == "f" || designationType == "forbid")
|
|
|
|
|
|
|
|
{
|
|
|
|
changeFlag.bits.forbid = 1;
|
|
|
|
changeFlag.bits.forbid = 1;
|
|
|
|
//changeFlag = (1 << 19);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(designationType == "m"){
|
|
|
|
else if(designationType == "m" || designationType == "melt")
|
|
|
|
|
|
|
|
{
|
|
|
|
changeFlag.bits.melt = 1;
|
|
|
|
changeFlag.bits.melt = 1;
|
|
|
|
//changeFlag = (1 << 23);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(designationType == "r"){
|
|
|
|
else if(designationType == "r" || designationType == "flame")
|
|
|
|
|
|
|
|
{
|
|
|
|
changeFlag.bits.on_fire = 1;
|
|
|
|
changeFlag.bits.on_fire = 1;
|
|
|
|
//changeFlag = (1 << 22);
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
goto decideAgain;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
j=0;
|
|
|
|
j=0;
|
|
|
|
it2= it1->second.begin();
|
|
|
|
it2= it1->second.begin();
|
|
|
|
while(j < number2 && it2!=it1->second.end()){
|
|
|
|
while(j < number2 && it2!=it1->second.end())
|
|
|
|
|
|
|
|
{
|
|
|
|
it2++;
|
|
|
|
it2++;
|
|
|
|
j++;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(uint32_t k = 0;k< it2->second.size();k++){
|
|
|
|
for(uint32_t k = 0;k< it2->second.size();k++)
|
|
|
|
|
|
|
|
{
|
|
|
|
DFHack::t_item temp;
|
|
|
|
DFHack::t_item temp;
|
|
|
|
DF.ReadItem(it2->second[k],temp);
|
|
|
|
DF.ReadItem(it2->second[k],temp);
|
|
|
|
temp.flags.whole |= changeFlag.whole;
|
|
|
|
temp.flags.whole |= changeFlag.whole;
|
|
|
|