summaryrefslogtreecommitdiff
path: root/Creatures.cpp
diff options
context:
space:
mode:
authorJapa2010-08-31 15:44:46 +0000
committerJapa2010-08-31 15:44:46 +0000
commitfce2e4c3304db3ac29046c769b54ea0f219f3321 (patch)
tree9d2a5f1ad63b665eff6e4f5a0b007cdb1ae7d009 /Creatures.cpp
parentf9cee067c9d5d1a636dbd38a29fcfbda06d60276 (diff)
downloadstonesense-fce2e4c3304db3ac29046c769b54ea0f219f3321.tar.gz
stonesense-fce2e4c3304db3ac29046c769b54ea0f219f3321.tar.bz2
stonesense-fce2e4c3304db3ac29046c769b54ea0f219f3321.tar.xz
Updated DFhack yet again, and added a few more sprite features.
Diffstat (limited to 'Creatures.cpp')
-rw-r--r--Creatures.cpp71
1 files changed, 39 insertions, 32 deletions
diff --git a/Creatures.cpp b/Creatures.cpp
index 3a1a3b4..6ad4086 100644
--- a/Creatures.cpp
+++ b/Creatures.cpp
@@ -354,47 +354,54 @@ void ReadCreaturesToSegment( DFHack::Context& DF, WorldSegment* segment)
{
Creatures->ReadCreature( index, *tempcreature );*/
uint32_t index = 0;
- while((index = Creatures->ReadCreatureInBox( index, *tempcreature, x1,y1,z1,x2,y2,z2)) != -1 )
+ try
{
- index++;
- if( IsCreatureVisible( tempcreature ) )
+ while((index = Creatures->ReadCreatureInBox( index, *tempcreature, x1,y1,z1,x2,y2,z2)) != -1 )
{
- Block* b = segment->getBlock (tempcreature->x, tempcreature->y, tempcreature->z );
- if(!b)
- {
- //inside segment, but no block to represent it
- b = new Block(segment);
- b->x = tempcreature->x;
- b->y = tempcreature->y;
- b->z = tempcreature->z;
- // fake block occupancy where needed. This is starting to get hacky...
- b->creaturePresent=true;
- segment->addBlock( b );
- }
- if (!b->creature)
- {
- b->creaturePresent=true;
- b->creature = tempcreature;
- // add shadow to nearest floor block
- for (int bz = tempcreature->z;bz>=z1;bz--)
+ index++;
+ if( IsCreatureVisible( tempcreature ) )
+ {
+ Block* b = segment->getBlock (tempcreature->x, tempcreature->y, tempcreature->z );
+ if(!b)
+ {
+ //inside segment, but no block to represent it
+ b = new Block(segment);
+ b->x = tempcreature->x;
+ b->y = tempcreature->y;
+ b->z = tempcreature->z;
+ // fake block occupancy where needed. This is starting to get hacky...
+ b->creaturePresent=true;
+ segment->addBlock( b );
+ }
+ if (!b->creature)
{
- b = segment->getBlock (tempcreature->x, tempcreature->y, bz );
- if (!b) continue;
- if (b->floorType > 0 || b->wallType > 0 || b->ramp.type > 0)
+ b->creaturePresent=true;
+ b->creature = tempcreature;
+ // add shadow to nearest floor block
+ for (int bz = tempcreature->z;bz>=z1;bz--)
{
- // todo figure out appropriate shadow size
- int tempShadow = GetCreatureShadowMap( tempcreature );
- if (b->shadow < tempShadow)
- b->shadow=tempShadow;
- break;
+ b = segment->getBlock (tempcreature->x, tempcreature->y, bz );
+ if (!b) continue;
+ if (b->floorType > 0 || b->wallType > 0 || b->ramp.type > 0)
+ {
+ // todo figure out appropriate shadow size
+ int tempShadow = GetCreatureShadowMap( tempcreature );
+ if (b->shadow < tempShadow)
+ b->shadow=tempShadow;
+ break;
+ }
}
+ // need a new tempcreature now
+ // old tempcreature should be deleted when b is
+ tempcreature = new t_creature;
}
- // need a new tempcreature now
- // old tempcreature should be deleted when b is
- tempcreature = new t_creature;
}
}
}
+ catch (exception &e)
+ {
+ WriteErr("DFhack exeption: %s\n", e.what());
+ }
delete(tempcreature); // there will be one left over
Creatures->Finish();
}