Grass veins

develop
Petr Mrázek 2011-02-17 01:54:45 +01:00
parent 72fd88cff3
commit 02e6e46d5f
5 changed files with 82 additions and 29 deletions

@ -1970,13 +1970,6 @@
<Group name="Creatures" valid="false" >
0x016a12c0 vector
</Group>
<Group name="Materials" valid="false" >
<Address name="creature_type_vector" value="0x16E533C" valid="true" /> MAYBE... THE DETAILS WILL BE DIFFERENT
<Address name="inorganics" value="0x16e527C" valid="true" />
<Address name="organics_all" value="0x16e529C" valid="true" />
<Address name="organics_plants" value="0x16e52AC" valid="true" />
<Address name="organics_trees" value="0x16e52CC" valid="true" />
</Group>
<Group name="Constructions">
<Address name="vector" value="0x168d930"/>
</Group>

@ -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<t_vein>* veins,
std::vector<t_frozenliquidvein>* ices = 0,
std::vector<t_spattervein>* splatter = 0);
std::vector<t_spattervein>* splatter = 0,
std::vector<t_grassvein>* grass = 0
);
private:
struct Private;

@ -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 <t_vein>* veins, vector <t_frozenliquidvein>* ices, vector <t_spattervein> *splatter)
bool Maps::ReadVeins(uint32_t x, uint32_t y, uint32_t z, vector <t_vein>* veins, vector <t_frozenliquidvein>* ices, vector <t_spattervein> *splatter, vector <t_grassvein> *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
{

@ -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
*/

@ -536,6 +536,7 @@ main(int argc, char *argv[])
vector<t_vein> veinVector;
vector<t_frozenliquidvein> IceVeinVector;
vector<t_spattervein> splatter;
vector<t_grassvein> 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];