From 02e6e46d5f66e7f198626580036e6896604876ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 17 Feb 2011 01:54:45 +0100 Subject: [PATCH] Grass veins --- data/Memory-ng.xml | 7 --- library/include/dfhack/modules/Maps.h | 16 ++++++- library/modules/Maps.cpp | 21 ++++++++- library/shm/mod-maps.h | 1 + tools/supported/veinlook.cpp | 66 +++++++++++++++++++-------- 5 files changed, 82 insertions(+), 29 deletions(-) diff --git a/data/Memory-ng.xml b/data/Memory-ng.xml index 37b10b83b..98d8be319 100644 --- a/data/Memory-ng.xml +++ b/data/Memory-ng.xml @@ -1970,13 +1970,6 @@ 0x016a12c0 vector - -
MAYBE... THE DETAILS WILL BE DIFFERENT -
-
-
-
-
diff --git a/library/include/dfhack/modules/Maps.h b/library/include/dfhack/modules/Maps.h index a9ce94a06..110877c62 100644 --- a/library/include/dfhack/modules/Maps.h +++ b/library/include/dfhack/modules/Maps.h @@ -99,7 +99,17 @@ namespace DFHack /// this is NOT part of the DF vein, but an address of the vein as seen by DFhack. uint32_t address_of; }; - + + struct t_grassvein + { + uint32_t vtable; + /// material vector index + uint32_t material; + /// 16x16 array of covering 'intensity' + uint8_t intensity[16][16]; + /// this is NOT part of the DF vein, but an address of the vein as seen by DFhack. + uint32_t address_of; + }; enum BiomeOffset { eNorthWest, @@ -426,7 +436,9 @@ namespace DFHack bool ReadVeins(uint32_t x, uint32_t y, uint32_t z, std::vector* veins, std::vector* ices = 0, - std::vector* splatter = 0); + std::vector* splatter = 0, + std::vector* grass = 0 + ); private: struct Private; diff --git a/library/modules/Maps.cpp b/library/modules/Maps.cpp index db507edac..1657b3498 100644 --- a/library/modules/Maps.cpp +++ b/library/modules/Maps.cpp @@ -136,6 +136,10 @@ Maps::Maps(DFContextShared* _d) mem->resolveClassnameToVPtr("block_square_event_frozen_liquid", off.vein_ice_vptr); off.vein_mineral_vptr = 0; mem->resolveClassnameToVPtr("block_square_event_mineral",off.vein_mineral_vptr); + off.vein_spatter_vptr = 0; + mem->resolveClassnameToVPtr("block_square_event_material_spatterst",off.vein_spatter_vptr); + off.vein_grass_vptr = 0; + mem->resolveClassnameToVPtr("block_square_event_grassst",off.vein_grass_vptr); // upload offsets to SHM server if possible d->maps_module = 0; @@ -532,18 +536,20 @@ bool Maps::WriteGlobalFeature(uint32_t x, uint32_t y, uint32_t z, int16_t global /* * Block events */ -bool Maps::ReadVeins(uint32_t x, uint32_t y, uint32_t z, vector * veins, vector * ices, vector *splatter) +bool Maps::ReadVeins(uint32_t x, uint32_t y, uint32_t z, vector * veins, vector * ices, vector *splatter, vector *grass) { MAPS_GUARD t_vein v; t_frozenliquidvein fv; t_spattervein sv; + t_grassvein gv; Process* p = d->owner; uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z]; if(veins) veins->clear(); if(ices) ices->clear(); if(splatter) splatter->clear(); + if(grass) splatter->clear(); Server::Maps::maps_offsets &off = d->offsets; if (addr) @@ -583,6 +589,14 @@ try_again: // store it in the vector splatter->push_back (sv); } + else if(grass && type == off.vein_grass_vptr) + { + // read the splatter vein data (dereference pointer) + p->read (temp, sizeof(t_grassvein), (uint8_t *) &gv); + gv.address_of = temp; + // store it in the vector + grass->push_back (gv); + } else { string cname = p->readClassName(type); @@ -601,6 +615,11 @@ try_again: off.vein_spatter_vptr = type; goto try_again; } + else if(grass && cname=="block_square_event_grassst") + { + off.vein_grass_vptr = type; + goto try_again; + } #ifdef DEBUG else { diff --git a/library/shm/mod-maps.h b/library/shm/mod-maps.h index aafc355cd..46c8894eb 100644 --- a/library/shm/mod-maps.h +++ b/library/shm/mod-maps.h @@ -57,6 +57,7 @@ typedef struct uint32_t vein_mineral_vptr; uint32_t vein_ice_vptr; uint32_t vein_spatter_vptr; + uint32_t vein_grass_vptr; /* GEOLOGY */ diff --git a/tools/supported/veinlook.cpp b/tools/supported/veinlook.cpp index 222209796..81fcde949 100644 --- a/tools/supported/veinlook.cpp +++ b/tools/supported/veinlook.cpp @@ -536,6 +536,7 @@ main(int argc, char *argv[]) vector veinVector; vector IceVeinVector; vector splatter; + vector grass; t_temperatures b_temp1; t_temperatures b_temp2; @@ -582,21 +583,24 @@ main(int argc, char *argv[]) y_max = y_max_a; z_max = z_max_a; - bool hasimats = false; - bool hascmats = false; + bool hasInorgMats = false; + bool hasPlantMats = false; + bool hasCreatureMats = false; if(hasmats) { - - hascmats = true; // get stone matgloss mapping if(Mats->ReadInorganicMaterials()) { - hasimats = true; + hasInorgMats = true; } if(Mats->ReadCreatureTypes()) { - hascmats = true; + hasCreatureMats = true; + } + if(Mats->ReadOrganicMaterials()) + { + hasPlantMats = true; } } /* @@ -733,6 +737,7 @@ main(int argc, char *argv[]) IceVeinVector.clear(); effects.clear(); splatter.clear(); + grass.clear(); dirtybit = 0; // Supend, read/write data @@ -742,11 +747,15 @@ main(int argc, char *argv[]) if(hasmats) { Mats->Start(); - if(hasimats) + if(hasInorgMats) { Mats->ReadInorganicMaterials(); } - if(hascmats) + if(hasPlantMats) + { + Mats->ReadOrganicMaterials(); + } + if(hasCreatureMats) { Mats->ReadCreatureTypes(); } @@ -766,23 +775,21 @@ main(int argc, char *argv[]) for(int i = -1; i <= 1; i++) for(int j = -1; j <= 1; j++) { mapblock40d * Block = &blocks[i+1][j+1]; - - if(Maps->isValidBlock(cursorX+i,cursorY+j,cursorZ)) { Maps->ReadBlock40d(cursorX+i,cursorY+j,cursorZ, Block); // extra processing of the block in the middle if(i == 0 && j == 0) { - if(hasimats) + if(hasInorgMats) do_features(DF, Block, cursorX, cursorY, 50,10, Mats->inorganic); // read veins - Maps->ReadVeins(cursorX+i,cursorY+j,cursorZ,&veinVector,&IceVeinVector,&splatter); - + Maps->ReadVeins(cursorX+i,cursorY+j,cursorZ,&veinVector,&IceVeinVector,&splatter,&grass); + // get pointer to block blockaddr = Maps->getBlockPtr(cursorX+i,cursorY+j,cursorZ); blockaddr2 = Block->origin; - + // dig all veins and trees if(dig) { @@ -877,11 +884,12 @@ main(int argc, char *argv[]) uint32_t mineralsize = veinVector.size(); uint32_t icesize = IceVeinVector.size(); uint32_t splattersize = splatter.size(); - uint32_t totalVeinSize = mineralsize+ icesize + splattersize; + uint32_t grasssize = grass.size(); + uint32_t totalVeinSize = mineralsize+ icesize + splattersize + grasssize; 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() || !splatter.empty()) + if(!veinVector.empty() || !IceVeinVector.empty() || !splatter.empty() || !grass.empty()) { if(vein != -1 && vein < totalVeinSize) { @@ -911,7 +919,7 @@ main(int argc, char *argv[]) } } } - if(hasimats) + if(hasInorgMats) { gotoxy(50,3); cprintf("Mineral: %s",Mats->inorganic[veinVector[vein].type].id); @@ -937,7 +945,7 @@ main(int argc, char *argv[]) gotoxy(50,3); cprintf("ICE"); } - else + else if(vein < mineralsize + icesize + splattersize) { realvein = vein - mineralsize - icesize; t_spattervein &bloodmud = splatter[realvein]; @@ -954,12 +962,32 @@ main(int argc, char *argv[]) } } } - if(hascmats) + if(hasCreatureMats) { gotoxy(50,3); cprintf("Spatter: %s",PrintSplatterType(splatter[realvein].mat1,splatter[realvein].mat2,Mats->race).c_str()); } } + else + { + realvein = vein - mineralsize - icesize - splattersize; + t_grassvein & grassy =grass[realvein]; + for(uint32_t yyy = 0; yyy < 16; yyy++) + { + for(uint32_t xxx = 0; xxx < 16; xxx++) + { + uint8_t intensity = grassy.intensity[xxx][yyy]; + if(intensity) + { + attron(A_STANDOUT); + putch(xxx+16,yyy+16,'X', COLOR_RED); + attroff(A_STANDOUT); + } + } + } + gotoxy(50,3); + cprintf("Grass: 0x%x, %s",grassy.address_of, Mats->organic[grassy.material].id); + } } } mapblock40d * Block = &blocks[1][1];