more dat renaming

master
Eduardo Bart 13 years ago
parent 6187bdbbdb
commit 1a080dbf15

@ -67,8 +67,8 @@ namespace Otc
DatLight,
DatDontHide,
DatTranslucent,
DatDrawShift,
DatDrawHeight,
DatDisplacment,
DatElevation,
DatLyingCorpse,
DatAnimateAlways,
DatMinimapColor,
@ -77,7 +77,7 @@ namespace Otc
DatIgnoreLook,
DatClothe,
DatAnimation,
LastDatFlag
LastDatFlag = 255
};
enum ThingAttributesGroup {

@ -72,17 +72,17 @@ void Creature::draw(int x, int y)
const ThingAttributes& attributes = getAttributes();
// Render creature
for(m_yDiv = 0; m_yDiv < attributes.ydiv; m_yDiv++) {
for(m_yPattern = 0; m_yPattern < attributes.yPattern; m_yPattern++) {
// continue if we dont have this addon.
if(m_yDiv > 0 && !(m_outfit.addons & (1 << (m_yDiv-1))))
if(m_yPattern > 0 && !(m_outfit.addons & (1 << (m_yPattern-1))))
continue;
// draw white item
internalDraw(x, y, 0);
// draw mask if exists
if(attributes.blendframes > 1) {
if(attributes.layers > 1) {
// switch to blend color mode
g_graphics.bindBlendFunc(Fw::BlendColorzing);
@ -109,7 +109,7 @@ void Creature::draw(int x, int y)
}
// Update animation and position
if(m_walking && attributes.animcount > 1) {
if(m_walking && attributes.animationPhases > 1) {
if(g_platform.getTicks() - m_lastTicks >= m_walkTimePerPixel) {
int pixelsWalked = std::floor((g_platform.getTicks() - m_lastTicks) / m_walkTimePerPixel);
@ -126,8 +126,8 @@ void Creature::draw(int x, int y)
m_walkOffsetX = std::max(m_walkOffsetX - pixelsWalked, 0);
int walkOffset = std::max(std::abs(m_walkOffsetX), std::abs(m_walkOffsetY));
if(walkOffset % (int)std::ceil(32 / (float)attributes.animcount) == 0) {
if(m_lastWalkAnim+1 == attributes.animcount)
if(walkOffset % (int)std::ceil(32 / (float)attributes.animationPhases) == 0) {
if(m_lastWalkAnim+1 == attributes.animationPhases)
m_lastWalkAnim = 1;
else
m_lastWalkAnim++;
@ -225,15 +225,15 @@ void Creature::walk(const Position& position)
g_map.addThing(asThing());
if(m_walking) {
// Calculate xDiv
// Calculate xPattern
if(m_direction >= 4) {
if(m_direction == Otc::NorthEast || m_direction == Otc::SouthEast)
m_xDiv = Otc::East;
m_xPattern = Otc::East;
else if(m_direction == Otc::NorthWest || m_direction == Otc::SouthWest)
m_xDiv = Otc::West;
m_xPattern = Otc::West;
}
else {
m_xDiv = m_direction;
m_xPattern = m_direction;
}
// get walk speed
@ -241,7 +241,7 @@ void Creature::walk(const Position& position)
ThingPtr ground = g_map.getThing(m_position, 0);
if(ground)
groundSpeed = ground->getAttributes().speed;
groundSpeed = ground->getAttributes().groundSpeed;
float walkTime = walkTimeFactor * 1000.0 * (float)groundSpeed / m_speed;
walkTime = walkTime == 0 ? 1000 : walkTime;

@ -78,7 +78,7 @@ void DatManager::parseThingAttributes(std::stringstream& fin, ThingAttributes& t
uint8 opt;
fin.read((char*)&opt, 1);
if(opt == 0xFF)
if(opt == Otc::LastDatFlag)
break;
parseThingAttributesOpt(fin, thingAttributes, opt);
@ -86,22 +86,25 @@ void DatManager::parseThingAttributes(std::stringstream& fin, ThingAttributes& t
thingAttributes.width = Fw::getU8(fin);
thingAttributes.height = Fw::getU8(fin);
if(thingAttributes.width > 1 || thingAttributes.height > 1)
Fw::getU8(fin); // ??
thingAttributes.exactSize = Fw::getU8(fin);
else
thingAttributes.exactSize = 32;
thingAttributes.blendframes = Fw::getU8(fin);
thingAttributes.xdiv = Fw::getU8(fin);
thingAttributes.ydiv = Fw::getU8(fin);
thingAttributes.zdiv = Fw::getU8(fin);
thingAttributes.animcount = Fw::getU8(fin);
thingAttributes.layers = Fw::getU8(fin);
thingAttributes.xPattern = Fw::getU8(fin);
thingAttributes.yPattern = Fw::getU8(fin);
thingAttributes.zPattern = Fw::getU8(fin);
thingAttributes.animationPhases = Fw::getU8(fin);
int totalSprites = thingAttributes.width
* thingAttributes.height
* thingAttributes.blendframes
* thingAttributes.xdiv
* thingAttributes.ydiv
* thingAttributes.zdiv
* thingAttributes.animcount;
* thingAttributes.layers
* thingAttributes.xPattern
* thingAttributes.yPattern
* thingAttributes.zPattern
* thingAttributes.animationPhases;
thingAttributes.sprites.resize(totalSprites);
for(uint16 i = 0; i < totalSprites; i++)
@ -112,107 +115,107 @@ void DatManager::parseThingAttributesOpt(std::stringstream& fin, ThingAttributes
{
switch(opt) {
case Otc::DatGround: // Grounds, must be drawn first
thingAttributes.speed = Fw::getU16(fin);
thingAttributes.group = Otc::ThingGroundGroup;
thingAttributes.groundSpeed = Fw::getU16(fin);
thingAttributes.isGround = true;
break;
case Otc::DatGroundClip: // Objects that clips (has transparent pixels) and must be drawn just after ground (e.g: ground borders)
thingAttributes.alwaysOnTop = true;
thingAttributes.alwaysOnTopOrder = 1;
thingAttributes.isGroundClip = true;
break;
case Otc::DatOnBottom: // Bottom items, must be drawn above general items and below creatures (e.g: stairs)
thingAttributes.alwaysOnTop = true;
thingAttributes.alwaysOnTopOrder = 2;
thingAttributes.isOnBottom = true;
break;
case Otc::DatOnTop: // Top items, must be drawn above creatures (e.g: doors)
thingAttributes.alwaysOnTop = true;
thingAttributes.alwaysOnTopOrder = 3;
thingAttributes.isOnTop = true;
break;
case Otc::DatContainer: // Containers
thingAttributes.group = Otc::ThingContainerGroup;
thingAttributes.isContainer = true;
break;
case Otc::DatStackable: // Stackable
thingAttributes.stackable = true;
thingAttributes.isStackable = true;
break;
case Otc::DatForceUse: // Items that are automatically used when step over?
thingAttributes.isForceUse = true;
break;
case Otc::DatMultiUse: // Usable items
thingAttributes.useable = true;
thingAttributes.isMultiUse = true;
break;
case Otc::DatWritable: // Writable
thingAttributes.group = Otc::ThingWriteableGroup;
thingAttributes.readable = true;
thingAttributes.subParam08 = Fw::getU16(fin);
thingAttributes.isWritable = true;
thingAttributes.maxTextLength = Fw::getU16(fin);
break;
case Otc::DatWritableOnce: // Writable once. objects that can't be edited by players
thingAttributes.readable = true;
thingAttributes.subParam08 = Fw::getU16(fin);
thingAttributes.isWritableOnce = true;
thingAttributes.maxTextLength = Fw::getU16(fin);
break;
case Otc::DatFluidContainer: // Fluid containers
thingAttributes.group = Otc::ThingFluidGroup;
Fw::getU8(fin);
thingAttributes.fluidParam = Fw::getU8(fin);
break;
case Otc::DatSplash: // Splashes
thingAttributes.group = Otc::ThingSplashGroup;
thingAttributes.isStackable = true;
break;
case Otc::DatBlockWalk: // Blocks solid objects (creatures, walls etc)
thingAttributes.blockSolid = true;
thingAttributes.isNotWalkable = true;
break;
case Otc::DatNotMovable: // Not movable
thingAttributes.moveable = false;
thingAttributes.isNotMoveable = true;
break;
case Otc::DatBlockProjectile: // Blocks missiles (walls, magic wall etc)
thingAttributes.blockProjectile = true;
thingAttributes.isNotProjectable = true;
break;
case Otc::DatBlockPathFind: // Blocks pathfind algorithms (monsters)
thingAttributes.blockPathFind = true;
thingAttributes.isNotPathable = true;
break;
case Otc::DatPickupable: // Pickupable
thingAttributes.pickupable = true;
thingAttributes.isPickupable = true;
break;
case Otc::DatHangable: // Hangable objects (wallpaper etc)
thingAttributes.isHangable = true;
break;
case Otc::DatHookSouth: // Horizontal walls
thingAttributes.isHorizontal = true;
thingAttributes.isHookSouth = true;
break;
case Otc::DatHookEast: // Vertical walls
thingAttributes.isVertical = true;
thingAttributes.isHookEast = true;
break;
case Otc::DatRotable: // Rotable
thingAttributes.rotable = true;
thingAttributes.isRotable = true;
break;
case Otc::DatLight: // Light info
thingAttributes.hasLight = true;
thingAttributes.lightLevel = Fw::getU16(fin);
thingAttributes.lightColor = Fw::getU16(fin);
break;
case Otc::DatDontHide: // A few monuments that are not supposed to be hidden by floors
break;
case Otc::DatTranslucent: // Grounds that are translucent
thingAttributes.changesFloor = true;
thingAttributes.isTranslucent = true;
break;
case Otc::DatDrawShift: // Must shift draw
thingAttributes.hasHeight = true;
thingAttributes.drawOffset = Fw::getU16(fin);
Fw::getU16(fin);
case Otc::DatDisplacment: // Must shift draw
thingAttributes.xDisplacment = Fw::getU16(fin);
thingAttributes.yDisplacment = Fw::getU16(fin);
break;
case Otc::DatDrawHeight: // pixels characters height
thingAttributes.drawNextOffset = Fw::getU16(fin);
case Otc::DatElevation: // Must elevate draw
thingAttributes.elevation = Fw::getU16(fin);
break;
case Otc::DatLyingCorpse: // Some corpses
thingAttributes.isLyingCorpse = true;
break;
case Otc::DatAnimateAlways: // Unknown, check if firesword is a kind of AnimateAlways.
thingAttributes.isAnimatedAlways = true;
break;
case Otc::DatMinimapColor: // Minimap color
thingAttributes.hasMiniMapColor = true;
thingAttributes.miniMapColor = Fw::getU16(fin);
break;
case Otc::DatLensHelp: // Used for giving players tips?
Fw::getU16(fin);
thingAttributes.isLensHelp = true;
thingAttributes.lensHelpParam = Fw::getU16(fin);
break;
case Otc::DatFullGround: // Grounds that has no transparent pixels
thingAttributes.isFullGround = true;
break;
case Otc::DatIgnoreLook: // Ignore look, then looks at the item on the bottom of it
thingAttributes.lookThrough = true;
thingAttributes.isIgnoreLook = true;
break;
case Otc::DatClothe: // Clothes
break;

@ -37,7 +37,7 @@ void Effect::draw(int x, int y)
if(!m_finished) {
if(g_platform.getTicks() - m_lastTicks > 75) {
const ThingAttributes& attributes = getAttributes();
if(m_animation+1 == attributes.animcount) {
if(m_animation+1 == attributes.animationPhases) {
g_dispatcher.addEvent(std::bind(&Map::removeThingByPtr, &g_map, asThing()));
m_finished = true;
}

@ -36,9 +36,9 @@ void Item::draw(int x, int y)
{
const ThingAttributes& attributes = g_dat.getItemAttributes(m_id);
if(attributes.animcount > 1) {
if(attributes.animationPhases > 1) {
if(g_platform.getTicks() - m_lastTicks > 500) {
if(m_animation+1 == attributes.animcount)
if(m_animation+1 == attributes.animationPhases)
m_animation = 0;
else
m_animation++;
@ -48,11 +48,11 @@ void Item::draw(int x, int y)
}
/*if(attributes.group == Otc::ThingSplashGroup || attributes.group == Otc::ThingFluidGroup) {
//xdiv = m_count % attributes.xdiv;
//ydiv = m_count / attributes.ydiv;
//xPattern = m_count % attributes.xPattern;
//yPattern = m_count / attributes.yPattern;
}*/
for(int b = 0; b < attributes.blendframes; b++)
for(int b = 0; b < attributes.layers; b++)
internalDraw(x, y, b);
}
@ -72,10 +72,10 @@ void Item::onPositionChange(const Position&)
{
const ThingAttributes& attributes = g_dat.getItemAttributes(m_id);
if(!attributes.moveable) {
m_xDiv = m_position.x % attributes.xdiv;
m_yDiv = m_position.y % attributes.ydiv;
m_zDiv = m_position.z % attributes.zdiv;
if(attributes.isNotMoveable) {
m_xPattern = m_position.x % attributes.xPattern;
m_yPattern = m_position.y % attributes.yPattern;
m_zPattern = m_position.z % attributes.zPattern;
}
}
@ -83,26 +83,26 @@ void Item::onCountChange(int)
{
const ThingAttributes& attributes = g_dat.getItemAttributes(m_id);
if(attributes.stackable && attributes.xdiv == 4 && attributes.ydiv == 2) {
if(attributes.isStackable && attributes.xPattern == 4 && attributes.yPattern == 2) {
if(m_count < 5) {
m_xDiv = m_count-1;
m_yDiv = 0;
m_xPattern = m_count-1;
m_yPattern = 0;
}
else if(m_count < 10) {
m_xDiv = 0;
m_yDiv = 1;
m_xPattern = 0;
m_yPattern = 1;
}
else if(m_count < 25) {
m_xDiv = 1;
m_yDiv = 1;
m_xPattern = 1;
m_yPattern = 1;
}
else if(m_count < 50) {
m_xDiv = 2;
m_yDiv = 1;
m_xPattern = 2;
m_yPattern = 1;
}
else if(m_count <= 100) {
m_xDiv = 3;
m_yDiv = 1;
m_xPattern = 3;
m_yPattern = 1;
}
}
}

@ -26,9 +26,9 @@
Thing::Thing(Otc::ThingType type) : m_id(0), m_type(type)
{
m_xDiv = 0;
m_yDiv = 0;
m_zDiv = 0;
m_xPattern = 0;
m_yPattern = 0;
m_zPattern = 0;
m_animation = 0;
}
@ -40,7 +40,7 @@ void Thing::setPosition(const Position& position)
onPositionChange(oldPosition);
}
void Thing::internalDraw(int x, int y, int blendframes, Otc::SpriteMask mask)
void Thing::internalDraw(int x, int y, int layers, Otc::SpriteMask mask)
{
const ThingAttributes& attributes = getAttributes();
@ -48,11 +48,11 @@ void Thing::internalDraw(int x, int y, int blendframes, Otc::SpriteMask mask)
for(int xi = 0; xi < attributes.width; xi++) {
int sprIndex = xi +
yi * attributes.width +
blendframes * attributes.width * attributes.height +
m_xDiv * attributes.width * attributes.height * attributes.blendframes +
m_yDiv * attributes.width * attributes.height * attributes.blendframes * attributes.xdiv +
m_zDiv * attributes.width * attributes.height * attributes.blendframes * attributes.xdiv * attributes.ydiv +
m_animation * attributes.width * attributes.height * attributes.blendframes * attributes.xdiv * attributes.ydiv * attributes.zdiv;
layers * attributes.width * attributes.height +
m_xPattern * attributes.width * attributes.height * attributes.layers +
m_yPattern * attributes.width * attributes.height * attributes.layers * attributes.xPattern +
m_zPattern * attributes.width * attributes.height * attributes.layers * attributes.xPattern * attributes.yPattern +
m_animation * attributes.width * attributes.height * attributes.layers * attributes.xPattern * attributes.yPattern * attributes.zPattern;
int spriteId = attributes.sprites[sprIndex];
if(!spriteId)
@ -60,8 +60,8 @@ void Thing::internalDraw(int x, int y, int blendframes, Otc::SpriteMask mask)
TexturePtr spriteTex = g_sprites.getSpriteTexture(spriteId, mask);
Rect drawRect((x - xi*32) - attributes.drawOffset,
(y - yi*32) - attributes.drawOffset,
Rect drawRect((x - xi*32) - attributes.xDisplacment,
(y - yi*32) - attributes.yDisplacment,
32, 32);
g_graphics.drawTexturedRect(drawRect, spriteTex);
}

@ -59,13 +59,13 @@ public:
virtual LocalPlayerPtr asLocalPlayer() { return nullptr; }
protected:
void internalDraw(int x, int y, int blendframes, Otc::SpriteMask mask = Otc::SpriteNoMask);
void internalDraw(int x, int y, int layers, Otc::SpriteMask mask = Otc::SpriteNoMask);
uint32 m_id;
Otc::ThingType m_type;
Position m_position;
int m_xDiv, m_yDiv, m_zDiv, m_animation;
int m_xPattern, m_yPattern, m_zPattern, m_animation;
};
#endif

@ -28,49 +28,101 @@
struct ThingAttributes
{
ThingAttributes() {
group = Otc::ThingNoGroup;
blockSolid = false;
hasHeight = false;
blockPathFind = false;
blockProjectile = false;
alwaysOnTop = false;
alwaysOnTopOrder = 0;
stackable = false;
useable = false;
moveable = true;
pickupable = false;
rotable = false;
readable = false;
lookThrough = false;
speed = 0;
lightLevel = 0;
lightColor = 0;
isVertical = false;
isHorizontal = false;
layers = 0;
width = height = 0;
exactSize = 0;
xPattern = yPattern = zPattern = 0;
animationPhases = 0;
xDisplacment = yDisplacment = 0;
elevation = 0;
isGround = false;
isGroundClip = false;
isOnBottom = false;
isOnTop = false;
isContainer = false;
isStackable = false;
isForceUse = false;
isMultiUse = false;
isWritable = false;
isWritableOnce = false;
isFluidContainer = false;
isSplash = false;
isNotWalkable = false;
isNotMoveable = false;
isNotProjectable = false;
isNotPathable = false;
isPickupable = false;
isHangable = false;
miniMapColor = 0;
isHookSouth = false;
isHookEast = false;
isRotable = false;
isDontHide = false;
isTranslucent = false;
isLyingCorpse = false;
isAnimatedAlways = false;
isLensHelp = false;
isFullGround = false;
isIgnoreLook = false;
isClothe = false;
hasLight = false;
hasMiniMapColor = false;
changesFloor = false;
subParam07 = 0;
subParam08 = 0;
width = 0;
height = 0;
blendframes = 0;
xdiv = 0;
ydiv = 0;
zdiv = 0;
animcount = 0;
drawOffset = 0;
drawNextOffset = 0;
}
bool stackable, alwaysOnTop, useable, readable, moveable, blockSolid, blockProjectile, blockPathFind, pickupable,
isHangable, isHorizontal, isVertical, rotable, hasHeight, lookThrough, hasMiniMapColor, changesFloor;
uint8 alwaysOnTopOrder, width, height, blendframes, xdiv, ydiv, zdiv, animcount, drawOffset, drawNextOffset;
uint16 speed, subParam07, subParam08, lightLevel, lightColor, miniMapColor;
groundSpeed = 0;
fluidParam = 0;
maxTextLength = 0;
lightLevel = lightColor = 0;
miniMapColor = 0;
lensHelpParam = 0;
}
uint8 layers;
uint8 width, height;
uint8 exactSize;
uint8 xPattern, yPattern, zPattern;
uint8 animationPhases;
uint16 xDisplacment, yDisplacment;
uint16 elevation;
std::vector<int> sprites;
Otc::ThingAttributesGroup group;
bool isGround;
bool isGroundClip;
bool isOnBottom;
bool isOnTop;
bool isContainer;
bool isStackable;
bool isForceUse;
bool isMultiUse;
bool isWritable;
bool isWritableOnce;
bool isFluidContainer;
bool isSplash;
bool isNotWalkable;
bool isNotMoveable;
bool isNotProjectable;
bool isNotPathable;
bool isPickupable;
bool isHangable;
bool isHookSouth;
bool isHookEast;
bool isRotable;
bool isDontHide;
bool isTranslucent;
bool isLyingCorpse;
bool isAnimatedAlways;
bool isLensHelp;
bool isFullGround;
bool isIgnoreLook;
bool isClothe;
bool hasLight;
bool hasMiniMapColor;
uint16 groundSpeed;
uint8 fluidParam;
uint16 maxTextLength;
uint16 lightLevel, lightColor;
uint16 miniMapColor;
uint16 lensHelpParam;
};
typedef std::vector<ThingAttributes> ThingAttributesList;

@ -45,9 +45,9 @@ void Tile::draw(int x, int y)
const ThingPtr& thing = *it;
const ThingAttributes& thingAttributes = thing->getAttributes();
if(thingAttributes.alwaysOnTopOrder == 1) {
if(thingAttributes.isGroundClip) {
thing->draw(x - m_drawNextOffset, y - m_drawNextOffset);
m_drawNextOffset += thingAttributes.drawNextOffset;
m_drawNextOffset += thingAttributes.elevation;
}
}
@ -55,9 +55,9 @@ void Tile::draw(int x, int y)
const ThingPtr& thing = *it;
const ThingAttributes& thingAttributes = thing->getAttributes();
if(thingAttributes.alwaysOnTopOrder == 2) {
if(thingAttributes.isOnBottom) {
thing->draw(x - m_drawNextOffset, y - m_drawNextOffset);
m_drawNextOffset += thingAttributes.drawNextOffset;
m_drawNextOffset += thingAttributes.elevation;
}
}
@ -65,7 +65,7 @@ void Tile::draw(int x, int y)
const ThingPtr& thing = *it;
const ThingAttributes& thingAttributes = thing->getAttributes();
thing->draw(x - m_drawNextOffset, y - m_drawNextOffset);
m_drawNextOffset += thingAttributes.drawNextOffset;
m_drawNextOffset += thingAttributes.elevation;
}
for(auto it = m_creatures.rbegin(), end = m_creatures.rend(); it != end; ++it) {
@ -82,7 +82,7 @@ void Tile::draw(int x, int y)
const ThingPtr& thing = *it;
const ThingAttributes& thingAttributes = thing->getAttributes();
if(thingAttributes.alwaysOnTopOrder == 3) {
if(thingAttributes.isOnTop) {
thing->draw(x, y);
}
}
@ -97,10 +97,10 @@ void Tile::addThing(ThingPtr thing, int stackpos)
const ThingAttributes& thingAttributes = thing->getAttributes();
if(thing->asItem()) {
if(thingAttributes.group == Otc::ThingGroundGroup)
if(thingAttributes.isGround)
m_ground = thing;
else {
if(thingAttributes.alwaysOnTop)
if(thingAttributes.isGroundClip || thingAttributes.isOnBottom || thingAttributes.isOnTop)
m_itemsTop.push_back(thing);
else {
if(stackpos == -1)
@ -173,7 +173,7 @@ void Tile::removeThingByPtr(ThingPtr thing)
if(thing->asItem()) {
const ThingAttributes& thingAttributes = thing->getAttributes();
if(!thingAttributes.alwaysOnTop) {
if(!(thingAttributes.isGroundClip || thingAttributes.isOnBottom || thingAttributes.isOnTop)) {
for(auto it = m_itemsBottom.begin(), end = m_itemsBottom.end(); it != end; ++it) {
if(*it == thing) {
m_itemsBottom.erase(it);
@ -240,7 +240,7 @@ int Tile::getStackSize(int stop)
bool Tile::isOpaque()
{
if(m_ground && !m_ground->getAttributes().changesFloor)
if(m_ground && !m_ground->getAttributes().isTranslucent)
return true;
return false;
}

@ -1038,7 +1038,7 @@ ItemPtr ProtocolGame::internalGetItem(InputMessage& msg, uint16 id)
item->setId(id);
const ThingAttributes& itemAttributes = g_dat.getItemAttributes(id);
if(itemAttributes.stackable || itemAttributes.group == Otc::ThingFluidGroup || itemAttributes.group == Otc::ThingSplashGroup)
if(itemAttributes.isStackable || itemAttributes.isFluidContainer || itemAttributes.isSplash == Otc::ThingSplashGroup)
item->setCount(msg.getU8());
return item;

Loading…
Cancel
Save