Skip to content

Commit

Permalink
Fix a crash related to the occlusion fix and flows. Fixed an error in…
Browse files Browse the repository at this point in the history
… the material lookup code. Reformatted code to OTB.

Putting this stuff in its own branch since I'm not sure this is the
correct format.  DFHack documentation doesn't matchthe actual code
format, so I went with what the code actually looks like.
  • Loading branch information
Caldfir authored and RosaryMala committed Dec 15, 2012
1 parent 0f1915c commit 5536203
Show file tree
Hide file tree
Showing 49 changed files with 11,779 additions and 11,467 deletions.
1,311 changes: 638 additions & 673 deletions Block.cpp

Large diffs are not rendered by default.

252 changes: 126 additions & 126 deletions Block.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,92 +8,93 @@

//not sure where to put these...

inline bool IDisWall(int in){
//if not a custom type, do a lookup in dfHack's interface
return isWallTerrain( (tiletype::tiletype) in );
inline bool IDisWall(int in)
{
//if not a custom type, do a lookup in dfHack's interface
return isWallTerrain( (tiletype::tiletype) in );
}

inline bool IDisFloor(int in){
//if not a custom type, do a lookup in dfHack's interface
return isFloorTerrain( (tiletype::tiletype) in );
inline bool IDisFloor(int in)
{
//if not a custom type, do a lookup in dfHack's interface
return isFloorTerrain( (tiletype::tiletype) in );
}

inline bool IDhasOpaqueFloor(int in){
//ignores possible transparent materials
return !FlowPassableDown( (tiletype::tiletype) in );
inline bool IDhasOpaqueFloor(int in)
{
//ignores possible transparent materials
return !FlowPassableDown( (tiletype::tiletype) in );
}

inline bool IDhasOpaqueSides(int in){
//ignores possible transparent materials
return !FlowPassable( (tiletype::tiletype) in );
inline bool IDhasOpaqueSides(int in)
{
//ignores possible transparent materials
return !FlowPassable( (tiletype::tiletype) in );
}

class WorldSegment;

struct Effect
{
DFHack::t_matglossPair matt;
int16_t density;
struct Effect {
DFHack::t_matglossPair matt;
int16_t density;
};

struct Worn_Item
{
DFHack::t_matglossPair matt;
DFHack::t_matglossPair dyematt;
int8_t rating;
Worn_Item();
struct Worn_Item {
DFHack::t_matglossPair matt;
DFHack::t_matglossPair dyematt;
int8_t rating;
Worn_Item();
};

struct Unit_Inventory
{
//[item_type][item_subtype][item_number]
std::vector<std::vector<std::vector<Worn_Item>>> item;
struct Unit_Inventory {
//[item_type][item_subtype][item_number]
std::vector<std::vector<std::vector<Worn_Item>>> item;
};


class Block
{
public:
Block(WorldSegment* ownerSegment, df::tiletype type);
~Block(void);
static void* operator new (size_t size);
static void operator delete (void *p);
bool visible;

WorldSegment* ownerSegment;

uint32_t x, y, z;
int drawx, drawy, drawz;
df::tiletype_shape_basic tileShapeBasic;
df::tiletype_shape tileShape;
df::tiletype_special tileSpecial;
df::tiletype_material tileMaterial;
df::tiletype tileType;
DFHack::t_matglossPair material;
Block(WorldSegment* ownerSegment, df::tiletype type);
~Block(void);
static void* operator new (size_t size);
static void operator delete (void *p);
bool visible;

WorldSegment* ownerSegment;

uint32_t x, y, z;
int drawx, drawy, drawz;
df::tiletype_shape_basic tileShapeBasic;
df::tiletype_shape tileShape;
df::tiletype_special tileSpecial;
df::tiletype_material tileMaterial;
df::tiletype tileType;
DFHack::t_matglossPair material;
DFHack::t_matglossPair layerMaterial;
DFHack::t_matglossPair veinMaterial;
bool hasVein;

bool depthBorderNorth;
bool depthBorderWest;
bool depthBorderDown;
int shadow;

uint8_t wallborders;
uint8_t floorborders;
uint8_t openborders;
uint8_t rampborders;
uint8_t upstairborders;
uint8_t downstairborders;
uint8_t lightborders;
bool creaturePresent;
bool buildingPresent;
bool fog_of_war;
bool hasVein;

bool depthBorderNorth;
bool depthBorderWest;
bool depthBorderDown;
int shadow;

uint8_t wallborders;
uint8_t floorborders;
uint8_t openborders;
uint8_t rampborders;
uint8_t upstairborders;
uint8_t downstairborders;
uint8_t lightborders;

bool creaturePresent;
bool buildingPresent;
bool fog_of_war;
DFHack::t_matglossPair ramp;
DFHack::t_matglossPair water;

//following are neighbor water levels (unused)
//following are neighbor water levels (unused)
//DFHack::t_matglossPair abovewater;
//DFHack::t_matglossPair belowwater;
//DFHack::t_matglossPair rightwater;
Expand All @@ -104,78 +105,77 @@ class Block
DFHack::Units::t_unit * creature;
DFHack::t_matglossPair tree;

int mudlevel;
int snowlevel;
int bloodlevel;
ALLEGRO_COLOR bloodcolor;
int mudlevel;
int snowlevel;
int bloodlevel;
ALLEGRO_COLOR bloodcolor;

uint8_t grasslevel;
uint32_t grassmat;
uint8_t grasslevel;
uint32_t grassmat;

uint8_t engraving_character;
uint8_t engraving_character;
df::engraving_flags engraving_flags;
uint8_t engraving_quality;
uint8_t engraving_quality;

//vector<uint8_t> grasslevels;
//vector<uint32_t> grassmats;
//vector<uint8_t> grasslevels;
//vector<uint32_t> grassmats;

//struct BlockEffects //size 40
//{
// uint16_t count;
// uint16_t type;
//struct BlockEffects //size 40
//{
// uint16_t count;
// uint16_t type;
// DFHack::t_matglossPair material;
// int16_t lifetime;
// int16_t x_direction;
// int16_t y_direction;
// uint8_t canCreateNew;//??
//} blockeffects;

//individual effects
Effect Eff_Miasma;
Effect Eff_Steam;
Effect Eff_Mist;
Effect Eff_MaterialDust;
Effect Eff_MagmaMist;
Effect Eff_Smoke;
Effect Eff_Dragonfire;
Effect Eff_Fire;
Effect Eff_Web;
Effect Eff_MaterialGas;
Effect Eff_MaterialVapor;
Effect Eff_OceanWave;
Effect Eff_SeaFoam;
struct {
// int16_t lifetime;
// int16_t x_direction;
// int16_t y_direction;
// uint8_t canCreateNew;//??
//} blockeffects;

//individual effects
Effect Eff_Miasma;
Effect Eff_Steam;
Effect Eff_Mist;
Effect Eff_MaterialDust;
Effect Eff_MagmaMist;
Effect Eff_Smoke;
Effect Eff_Dragonfire;
Effect Eff_Fire;
Effect Eff_Web;
Effect Eff_MaterialGas;
Effect Eff_MaterialVapor;
Effect Eff_OceanWave;
Effect Eff_SeaFoam;
struct {
DFHack::Buildings::t_building info;
std::vector<c_sprite> sprites;
uint32_t index;
Block * parent;
} building;

bool IsVisible(){
return IDisWall(tileType) || IDisFloor(tileType);
}
void Draw();
void Drawcreaturetext();
void DrawRamptops();
void DrawPixel(int drawx, int drawy);

uint16_t temp1;
uint16_t temp2;

uint16_t consForm;

bool obscuringCreature;
bool obscuringBuilding;

struct SS_Item
{
DFHack::t_matglossPair item;
DFHack::t_matglossPair matt;
DFHack::t_matglossPair dyematt;
} Item;

//These are actually applied to the creature standing here, but there's only one creature shown, so it's okay.
Unit_Inventory * inv;
std::vector<c_sprite> sprites;
uint32_t index;
Block * parent;
} building;

bool IsVisible() {
return IDisWall(tileType) || IDisFloor(tileType);
}
void Draw();
void Drawcreaturetext();
void DrawRamptops();
void DrawPixel(int drawx, int drawy);

uint16_t temp1;
uint16_t temp2;

uint16_t consForm;

bool obscuringCreature;
bool obscuringBuilding;

struct SS_Item {
DFHack::t_matglossPair item;
DFHack::t_matglossPair matt;
DFHack::t_matglossPair dyematt;
} Item;

//These are actually applied to the creature standing here, but there's only one creature shown, so it's okay.
Unit_Inventory * inv;


private:
Expand Down
Loading

0 comments on commit 5536203

Please sign in to comment.