Added embryo function for getting item descriptions

develop
simon 2010-04-28 18:24:27 +02:00
parent 3e16c75944
commit 3cab327704
3 changed files with 70 additions and 58 deletions

@ -93,6 +93,8 @@ namespace DFHack
bool ReadDescriptorColors(void); bool ReadDescriptorColors(void);
void ReadAllMaterials(void); void ReadAllMaterials(void);
std::string getDescription(t_material & mat);
/* /*
bool ReadInorganicMaterials (std::vector<t_matgloss> & output); bool ReadInorganicMaterials (std::vector<t_matgloss> & output);
bool ReadOrganicMaterials (std::vector<t_matgloss> & output); bool ReadOrganicMaterials (std::vector<t_matgloss> & output);

@ -294,3 +294,70 @@ void Materials::ReadAllMaterials(void)
this->ReadCreatureTypesEx(); this->ReadCreatureTypesEx();
this->ReadDescriptorColors(); this->ReadDescriptorColors();
} }
std::string Materials::getDescription(t_material & mat)
{
std::string out;
switch(mat.typeA)
{
case 0:
if(mat.typeD>=0)
{
if(mat.typeD<=this->inorganic.size())
{
out.append(this->inorganic[mat.typeD].id);
out.append(" bar");
}
else
out = "invalid bar";
}
else
out = "any metal bar";
break;
case 1:
out = "cut gem";
break;
case 2:
out = "block";
break;
case 3:
switch(mat.typeC)
{
case 3: out = "raw green glass"; break;
case 4: out = "raw clear glass"; break;
case 5: out = "raw crystal glass"; break;
default: out = "raw gems"; break;
}
break;
case 4:
out = "raw stone";
break;
case 5:
out = "wood log";
break;
case 24:
out = "weapon?";
break;
case 26:
out = "footwear";
break;
case 28:
out = "headwear";
break;
case 54:
out = "leather";
break;
case 57:
out = "cloth";
break;
case 71:
out = "food";
break;
default:
out = "unknown";
break;
}
return out;
}

@ -242,64 +242,7 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
{ {
for(unsigned int i = 0; i < mymat.size(); i++) for(unsigned int i = 0; i < mymat.size(); i++)
{ {
strcpy(maintype, "???"); printf("\t%s(%d)\t%d %d %d - %.8x\n", Materials->getDescription(mymat[i]).c_str(), mymat[i].typeA, mymat[i].typeB, mymat[i].typeC, mymat[i].typeD, mymat[i].flags);
switch(mymat[i].typeA)
{
case 0:
if(mymat[i].typeD>=0)
{
if(mymat[i].typeD<=Materials->inorganic.size())
sprintf(maintype, "%s bar", Materials->inorganic[mymat[i].typeD].id);
else
strcpy(maintype, "invalid metal bar");
}
else
strcpy(maintype, "any metal bar");
break;
case 1:
strcpy(maintype, "cut gem");
break;
case 2:
strcpy(maintype, "block");
break;
case 3:
switch(mymat[i].typeC)
{
case 3: strcpy(maintype, "raw green glass"); break;
case 4: strcpy(maintype, "raw clear glass"); break;
case 5: strcpy(maintype, "raw crystal glass"); break;
default: strcpy(maintype, "raw gems"); break;
}
break;
case 4:
strcpy(maintype, "raw stone");
break;
case 5:
strcpy(maintype, "wood log");
break;
case 24:
strcpy(maintype, "weapon?");
break;
case 26:
strcpy(maintype, "footwear");
break;
case 28:
strcpy(maintype, "headwear");
break;
case 54:
strcpy(maintype, "leather");
break;
case 57:
strcpy(maintype, "cloth");
break;
case 71:
strcpy(maintype, "food");
break;
default:
strcpy(maintype, "unknown");
break;
}
printf("\t%s(%d)\t%d %d %d - %.8x\n", maintype, mymat[i].typeA, mymat[i].typeB, mymat[i].typeC, mymat[i].typeD, mymat[i].flags);
} }
} }
} }