make veinlook work with less offsets (maybe)

develop
Petr Mrázek 2011-02-15 00:45:37 +01:00
parent 6c9652258d
commit ad5e207276
2 changed files with 54 additions and 26 deletions

@ -57,6 +57,8 @@ struct Maps::Private
OffsetGroup *OG_vector;
bool Inited;
bool Started;
bool hasGeology;
bool hasFeatures;
// map between feature address and the read object
map <uint32_t, t_feature> local_feature_store;
@ -74,6 +76,7 @@ Maps::Maps(DFContextShared* _d)
DFHack::VersionInfo * mem = p->getDescriptor();
Server::Maps::maps_offsets &off = d->offsets;
d->hasFeatures = d->hasGeology = true;
// get the offsets once here
OffsetGroup *OG_Maps = mem->getGroup("Maps");
@ -87,7 +90,6 @@ Maps::Maps(DFContextShared* _d)
off.region_z_offset = OG_Maps->getAddress ("region_z");
off.world_size_x = OG_Maps->getAddress ("world_size_x");
off.world_size_y = OG_Maps->getAddress ("world_size_y");
OffsetGroup *OG_MapBlock = OG_Maps->getGroup("block");
{
off.tile_type_offset = OG_MapBlock->getOffset ("type");
@ -100,18 +102,31 @@ Maps::Maps(DFContextShared* _d)
off.temperature1_offset = OG_MapBlock->getOffset ("temperature1");
off.temperature2_offset = OG_MapBlock->getOffset ("temperature2");
}
OffsetGroup *OG_Geology = OG_Maps->getGroup("geology");
try
{
OffsetGroup *OG_Geology = OG_Maps->getGroup("geology");
{
off.world_regions = OG_Geology->getAddress ("ptr2_region_array");
off.region_size = OG_Geology->getHexValue ("region_size");
off.region_geo_index_offset = OG_Geology->getOffset ("region_geo_index_off");
off.geolayer_geoblock_offset = OG_Geology->getOffset ("geolayer_geoblock_offset");
off.world_geoblocks_vector = OG_Geology->getAddress ("geoblock_vector");
off.type_inside_geolayer = OG_Geology->getOffset ("type_inside_geolayer");
}
}
catch(Error::AllMemdef &)
{
d->hasGeology = false;
}
try
{
d->OG_global_features = OG_Maps->getGroup("features")->getGroup("global");
d->OG_local_features = OG_Maps->getGroup("features")->getGroup("local");
}
catch(Error::AllMemdef &)
{
off.world_regions = OG_Geology->getAddress ("ptr2_region_array");
off.region_size = OG_Geology->getHexValue ("region_size");
off.region_geo_index_offset = OG_Geology->getOffset ("region_geo_index_off");
off.geolayer_geoblock_offset = OG_Geology->getOffset ("geolayer_geoblock_offset");
off.world_geoblocks_vector = OG_Geology->getAddress ("geoblock_vector");
off.type_inside_geolayer = OG_Geology->getOffset ("type_inside_geolayer");
d->hasFeatures = false;
}
d->OG_global_features = OG_Maps->getGroup("features")->getGroup("global");
d->OG_local_features = OG_Maps->getGroup("features")->getGroup("local");
}
d->OG_vector = mem->getGroup("vector");
@ -661,6 +676,7 @@ __int16 __userpurge GetGeologicalRegion<ax>(__int16 block_X<cx>, int X<ebx>, __i
bool Maps::ReadGeology (vector < vector <uint16_t> >& assign)
{
MAPS_GUARD
if(!d->hasGeology) return false;
Process *p = d->owner;
// get needed addresses and offsets. Now this is what I call crazy.
uint16_t worldSizeX, worldSizeY;
@ -730,6 +746,7 @@ bool Maps::ReadGeology (vector < vector <uint16_t> >& assign)
bool Maps::ReadLocalFeatures( std::map <planecoord, std::vector<t_feature *> > & local_features )
{
MAPS_GUARD
if(!d->hasFeatures) return false;
// can't be used without a map!
if(!d->block)
return false;
@ -822,6 +839,7 @@ bool Maps::ReadLocalFeatures( std::map <planecoord, std::vector<t_feature *> > &
bool Maps::ReadGlobalFeatures( std::vector <t_feature> & features)
{
MAPS_GUARD
if(!d->hasGeology) return false;
// can't be used without a map!
if(!d->block)
return false;

@ -574,21 +574,18 @@ main(int argc, char *argv[])
y_max = y_max_a;
z_max = z_max_a;
bool hasimats = 1;
bool hascmats = 1;
// get stone matgloss mapping
if(!Mats->ReadInorganicMaterials())
{
error = "Can't read stone types.";
pDF = 0;
finish(0);
hasimats = 0;
}
/*
if(!Mats->ReadCreatureTypes())
{
error = "Can't read stone types.";
pDF = 0;
finish(0);
hascmats = 0;
}
*/
/*
// get region geology
if(!DF.ReadGeology( layerassign ))
@ -730,8 +727,14 @@ main(int argc, char *argv[])
// restart cleared modules
Maps->Start();
Mats->Start();
Mats->ReadInorganicMaterials();
Mats->ReadCreatureTypes();
if(hasimats)
{
Mats->ReadInorganicMaterials();
}
if(hascmats)
{
Mats->ReadCreatureTypes();
}
uint32_t effectnum;
/*
if(DF.InitReadEffects(effectnum))
@ -755,7 +758,8 @@ main(int argc, char *argv[])
// extra processing of the block in the middle
if(i == 0 && j == 0)
{
do_features(DF, Block, cursorX, cursorY, 50,10, Mats->inorganic);
if(hasimats)
do_features(DF, Block, cursorX, cursorY, 50,10, Mats->inorganic);
// read veins
Maps->ReadVeins(cursorX+i,cursorY+j,cursorZ,&veinVector,&IceVeinVector,&splatter);
@ -891,8 +895,11 @@ main(int argc, char *argv[])
}
}
}
gotoxy(50,3);
cprintf("Mineral: %s",Mats->inorganic[veinVector[vein].type].id);
if(hasimats)
{
gotoxy(50,3);
cprintf("Mineral: %s",Mats->inorganic[veinVector[vein].type].id);
}
}
else if (vein < mineralsize + icesize)
{
@ -931,8 +938,11 @@ main(int argc, char *argv[])
}
}
}
gotoxy(50,3);
cprintf("Spatter: %s",PrintSplatterType(splatter[realvein].mat1,splatter[realvein].mat2,Mats->race).c_str());
if(hascmats)
{
gotoxy(50,3);
cprintf("Spatter: %s",PrintSplatterType(splatter[realvein].mat1,splatter[realvein].mat2,Mats->race).c_str());
}
}
}
}