From 1476390f1435bd46359ae1d757c70b32694eb85d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 8 Apr 2010 11:18:31 +0200 Subject: [PATCH] Spatter veins in veinlook --- examples/miscutils.h | 82 ++++++++++++++++++++++++++++++++++++++++ examples/spatterdump.cpp | 78 +------------------------------------- examples/veinlook.cpp | 36 ++++++++++++++++-- 3 files changed, 116 insertions(+), 80 deletions(-) diff --git a/examples/miscutils.h b/examples/miscutils.h index b1cf49fcb..bfe768aae 100644 --- a/examples/miscutils.h +++ b/examples/miscutils.h @@ -10,6 +10,8 @@ #include using namespace std; +#include + void DumpObjStr0Vector (const char * name, DFHack::Process *p, uint32_t addr) { cout << "----==== " << name << " ====----" << endl; @@ -134,4 +136,84 @@ void print_bits ( T val, std::ostream& out ) } } +// this is probably completely bogus +std::string PrintSplatterType (int16_t mat1, int32_t mat2, vector &creature_types) +{ + std::string ret; + switch (mat1) + { + case 0: + return "Rock"; + break; + case 1: + return "Amber"; + break; + case 2: + return "Coral"; + break; + case 3: + return "Green Glass"; + break; + case 4: + return "Clear Glass"; + break; + case 5: + return "Crystal Glass"; + break; + case 6: + return "Ice"; + break; + case 7: + return "Coal"; + break; + case 8: + return "Potash"; + break; + case 9: + return "Ash"; + break; + case 10: + return "Pearlash"; + break; + case 11: + return "Lye"; + break; + case 12: + return "Mud"; + break; + case 13: + return "Vomit"; + break; + case 14: + return "Salt"; + break; + case 15: + return "Filth"; + break; + case 16: + return "Frozen? Filth"; + break; + case 18: + return "Grime"; + break; + case 0xF2: + return "Very Specific Blood (references a named creature)"; + break; + case 0x2A: + case 0x2B: + if(mat2 != -1) + { + ret += creature_types[mat2].id; + ret += " "; + } + ret += "Blood"; + return ret; + break; + default: + return "Unknown"; + break; + } +} + + #endif \ No newline at end of file diff --git a/examples/spatterdump.cpp b/examples/spatterdump.cpp index ad3498259..6190eba24 100644 --- a/examples/spatterdump.cpp +++ b/examples/spatterdump.cpp @@ -24,81 +24,6 @@ using namespace std; using namespace DFHack; -void PrintSplatterType (int16_t mat1, int32_t mat2, vector creature_types) -{ - switch (mat1) - { - case 0: - cout <<"Rock"; - break; - case 1: - cout <<"Amber"; - break; - case 2: - cout <<"Coral"; - break; - case 3: - cout <<"Green Glass"; - break; - case 4: - cout <<"Clear Glass"; - break; - case 5: - cout <<"Crystal Glass"; - break; - case 6: - cout <<"Ice"; - break; - case 7: - cout <<"Coal"; - break; - case 8: - cout <<"Potash"; - break; - case 9: - cout <<"Ash"; - break; - case 10: - cout <<"Pearlash"; - break; - case 11: - cout <<"Lye"; - break; - case 12: - cout <<"Mud"; - break; - case 13: - cout <<"Vomit"; - break; - case 14: - cout <<"Salt"; - break; - case 15: - cout <<"Filth"; - break; - case 16: - cout <<"Frozen? Filth"; - break; - case 18: - cout <<"Grime"; - break; - case 0xF2: - cout << "Very Specific Blood (references a named creature)"; - break; - case 0x2A: - case 0x2B: - if(mat2 != -1) - { - cout << creature_types[mat2].id << " "; - } - cout<<"Blood"; - break; - default: - cout <<"Unknown"; - break; - } -} - char shades[10] = {'#','$','O','=','+','|','-','^','.',' '}; int main (int numargs, const char ** args) { @@ -158,8 +83,7 @@ int main (int numargs, const char ** args) for(int i = 0; i < splatter.size(); i++) { printf("Splatter %d\nmat1: %d\nunknown: %d\nmat2: %d\nmat3: %d\n",i,splatter[i].mat1,splatter[i].unk1,splatter[i].mat2,splatter[i].mat3); - PrintSplatterType(splatter[i].mat1,splatter[i].mat2,creature_types); - cout << endl; + cout << PrintSplatterType(splatter[i].mat1,splatter[i].mat2,creature_types) << endl; printf("Address 0x%08x\n",splatter[i].address_of); for(uint32_t yyy = 0; yyy < 16; yyy++) { diff --git a/examples/veinlook.cpp b/examples/veinlook.cpp index ddd2da577..3f16036d1 100644 --- a/examples/veinlook.cpp +++ b/examples/veinlook.cpp @@ -21,6 +21,7 @@ using namespace std; #include #include #include +#include "miscutils.h" using namespace DFHack; @@ -307,6 +308,7 @@ main(int argc, char *argv[]) materials.clear(); mapblock40d blocks[3][3]; vector stonetypes; + vector creature_types; vector effects; vector< vector > layerassign; vector veinVector; @@ -355,6 +357,13 @@ main(int argc, char *argv[]) pDF = 0; finish(0); } + + if(!Mats->ReadCreatureTypes(creature_types)) + { + error = "Can't read stone types."; + pDF = 0; + finish(0); + } /* // get region geology if(!DF.ReadGeology( layerassign )) @@ -558,11 +567,12 @@ main(int argc, char *argv[]) gotoxy(0,50); uint32_t mineralsize = veinVector.size(); uint32_t icesize = IceVeinVector.size(); - uint32_t totalVeinSize = mineralsize+ icesize; + uint32_t splattersize = splatter.size(); + uint32_t totalVeinSize = mineralsize+ icesize + splattersize; if(vein == totalVeinSize) vein = totalVeinSize - 1; if(vein < -1) vein = -1; cprintf("X %d/%d, Y %d/%d, Z %d/%d. Vein %d of %d",cursorX+1,x_max,cursorY+1,y_max,cursorZ,z_max,vein+1,totalVeinSize); - if(!veinVector.empty() || !IceVeinVector.empty()) + if(!veinVector.empty() || !IceVeinVector.empty() || !splatter.empty()) { if(vein != -1 && vein < totalVeinSize) { @@ -595,7 +605,7 @@ main(int argc, char *argv[]) gotoxy(0,51); cprintf("Mineral: %s",stonetypes[veinVector[vein].type].id); } - else + else if (vein < mineralsize + icesize) { realvein = vein - mineralsize; t_frozenliquidvein &frozen = IceVeinVector[realvein]; @@ -615,6 +625,26 @@ main(int argc, char *argv[]) gotoxy(0,51); cprintf("ICE"); } + else + { + realvein = vein - mineralsize - icesize; + t_spattervein &bloodmud = splatter[realvein]; + for(uint32_t yyy = 0; yyy < 16; yyy++) + { + for(uint32_t xxx = 0; xxx < 16; xxx++) + { + uint8_t intensity = splatter[realvein].intensity[xxx][yyy]; + if(intensity) + { + attron(A_STANDOUT); + putch(xxx+16,yyy+16,'*', COLOR_RED); + attroff(A_STANDOUT); + } + } + } + gotoxy(0,51); + cprintf("Spatter: %s",PrintSplatterType(splatter[realvein].mat1,splatter[realvein].mat2,creature_types).c_str()); + } } } gotoxy (0,52);