some research into DF materials

develop
Petr Mrázek 2010-02-11 02:03:22 +00:00
parent 9412608581
commit 01eaa3b9b4
2 changed files with 76 additions and 19 deletions

@ -20,14 +20,18 @@ struct matGlosses
vector<DFHack::t_matgloss> creatureMat; vector<DFHack::t_matgloss> creatureMat;
}; };
const char * getMaterialType(DFHack::t_item item, const vector<string> & buildingTypes,const matGlosses & mat) string getMaterialType(DFHack::t_item item, const vector<string> & buildingTypes,const matGlosses & mat)
{ {
string itemtype = buildingTypes[item.type]; string itemtype = buildingTypes[item.type];
// plant thread seeds // plant thread seeds
if(itemtype == "item_plant" || itemtype == "item_thread" || itemtype == "item_seeds" || itemtype == "item_leaves") if(itemtype == "item_plant" || itemtype == "item_thread" || itemtype == "item_seeds" || itemtype == "item_leaves" )
{ {
return mat.plantMat[item.material.type].id; return mat.plantMat[item.material.type].id;
} }
else if (itemtype == "item_drink") // drinks must have different offset for materials
{
return "Booze or something";
}
// item_skin_raw item_bones item_skull item_fish_raw item_pet item_skin_tanned item_shell // item_skin_raw item_bones item_skull item_fish_raw item_pet item_skin_tanned item_shell
else if(itemtype == "item_skin_raw" || else if(itemtype == "item_skin_raw" ||
itemtype == "item_skin_tanned" || itemtype == "item_skin_tanned" ||
@ -37,7 +41,8 @@ const char * getMaterialType(DFHack::t_item item, const vector<string> & buildin
itemtype == "item_horn"|| itemtype == "item_horn"||
itemtype == "item_skull" || itemtype == "item_skull" ||
itemtype == "item_bones" || itemtype == "item_bones" ||
itemtype == "item_corpse" itemtype == "item_corpse" ||
itemtype == "item_meat"
) )
{ {
return mat.creatureMat[item.material.type].id; return mat.creatureMat[item.material.type].id;
@ -46,34 +51,82 @@ const char * getMaterialType(DFHack::t_item item, const vector<string> & buildin
{ {
return mat.woodMat[item.material.type].id; return mat.woodMat[item.material.type].id;
} }
else if(itemtype == "item_bar")
{
return mat.metalMat[item.material.type].id;
}
else else
{ {
/*
Mat_Wood,
Mat_Stone,
Mat_Metal,
Mat_Plant,
Mat_Leather = 10,
Mat_SilkCloth = 11,
Mat_PlantCloth = 12,
Mat_GreenGlass = 13,
Mat_ClearGlass = 14,
Mat_CrystalGlass = 15,
Mat_Ice = 17,
Mat_Charcoal =18,
Mat_Potash = 19,
Mat_Ashes = 20,
Mat_PearlAsh = 21,
Mat_Soap = 24,
*/
switch (item.material.type) switch (item.material.type)
{ {
case 0: case DFHack::Mat_Wood:
return mat.woodMat[item.material.index].id; return mat.woodMat[item.material.index].id;
break; break;
case 1: case DFHack::Mat_Stone:
return mat.stoneMat[item.material.index].id; return mat.stoneMat[item.material.index].id;
break; break;
case 2: case DFHack::Mat_Metal:
return 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 DFHack::Mat_Plant:
return mat.plantMat[item.material.index].id; case DFHack::Mat_PlantCloth:
break; //return mat.plantMat[item.material.index].id;
case 3: return string(mat.plantMat[item.material.index].id) + " plant";
case 9:
case 10:
case 11:
case 121:
return mat.creatureMat[item.material.index].id;
break; break;
case 3: // bone
return string(mat.creatureMat[item.material.index].id) + " bone";
case 25: // fat
return string(mat.creatureMat[item.material.index].id) + " fat";
case 23: // tallow
return string(mat.creatureMat[item.material.index].id) + " tallow";
case 9: // shell
return string(mat.creatureMat[item.material.index].id) + " shell";
case DFHack::Mat_Leather: // really a generic creature material. meat for item_food, leather for item_box...
return string(mat.creatureMat[item.material.index].id);
case DFHack::Mat_SilkCloth:
return string(mat.creatureMat[item.material.index].id) + " silk";
case DFHack::Mat_Soap:
return string(mat.creatureMat[item.material.index].id) + " soap";
case DFHack::Mat_GreenGlass:
return "Green Glass";
case DFHack::Mat_ClearGlass:
return "Clear Glass";
case DFHack::Mat_CrystalGlass:
return "Crystal Glass";
case DFHack::Mat_Ice:
return "Ice";
case DFHack::Mat_Charcoal:
return "Charcoal";
/*case DFHack::Mat_Potash:
return "Potash";*/
case DFHack::Mat_Ashes:
return "Ashes";
case DFHack::Mat_PearlAsh:
return "Pearlash";
default: default:
cout << "unknown material hit: " << item.material.type << " " << itemtype << endl; cout << "unknown material hit: " << item.material.type << " " << item.material.index << " " << itemtype << endl;
return 0; return "Invalid";
} }
} }
return "Invalid";
} }
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)
{ {
@ -117,8 +170,8 @@ int main ()
DF.ReadItem(i,temp); DF.ReadItem(i,temp);
if(temp.type != -1) if(temp.type != -1)
{ {
const char * material = getMaterialType(temp,buildingtypes,mat); string material = getMaterialType(temp,buildingtypes,mat);
if (material != 0) if (material != "Invalid")
{ {
count[buildingtypes[temp.type]][material].push_back(i); count[buildingtypes[temp.type]][material].push_back(i);
} }

@ -19,6 +19,9 @@ int main (void)
cerr << "DF not found" << endl; cerr << "DF not found" << endl;
return 1; return 1;
} }
vector <DFHack::t_matgloss> Woods;
DF.ReadPlantMatgloss(Woods);
vector <DFHack::t_matgloss> Plants; vector <DFHack::t_matgloss> Plants;
DF.ReadPlantMatgloss(Plants); DF.ReadPlantMatgloss(Plants);
@ -31,6 +34,7 @@ int main (void)
vector <DFHack::t_matgloss> CreatureTypes; vector <DFHack::t_matgloss> CreatureTypes;
DF.ReadCreatureMatgloss(CreatureTypes); DF.ReadCreatureMatgloss(CreatureTypes);
cout << "Wood: " << Woods[0].id << endl;
cout << "Plant: " << Plants[0].id << endl; cout << "Plant: " << Plants[0].id << endl;
cout << "Metal: " << Metals[0].id << endl; cout << "Metal: " << Metals[0].id << endl;
cout << "Stone: " << Stones[0].id << endl; cout << "Stone: " << Stones[0].id << endl;