stack/render order working more like tibia

This commit is contained in:
Eduardo Bart 2011-08-31 18:41:04 -03:00
parent 0b4d7ace05
commit 3b5dd3ecf9
3 changed files with 21 additions and 4 deletions

View File

@ -42,10 +42,24 @@ void Tile::draw(int x, int y)
// first bottom items // first bottom items
for(const ThingPtr& thing : m_things) { for(const ThingPtr& thing : m_things) {
const ThingType& type = thing->getType(); const ThingType& type = thing->getType();
if(thing->asCreature() || type.isOnTop) if(!type.isGround && !type.isGroundClip && !type.isOnBottom)
continue; break;
thing->draw(x - m_drawElevation, y - m_drawElevation); thing->draw(x - m_drawElevation, y - m_drawElevation);
m_drawElevation += type.elevation; m_drawElevation += type.elevation;
if(m_drawElevation > MAX_DRAW_ELEVATION)
m_drawElevation = MAX_DRAW_ELEVATION;
}
// now common items
for(auto it = m_things.rbegin(); it != m_things.rend(); ++it) {
const ThingPtr& thing = *it;
const ThingType& type = thing->getType();
if(type.isOnTop || type.isOnBottom || type.isGround || type.isGroundClip)
break;
thing->draw(x - m_drawElevation, y - m_drawElevation);
m_drawElevation += type.elevation;
if(m_drawElevation > MAX_DRAW_ELEVATION)
m_drawElevation = MAX_DRAW_ELEVATION;
} }
// creatures // creatures
@ -164,7 +178,7 @@ bool Tile::isFullyOpaque()
ThingPtr firstObject = getThing(0); ThingPtr firstObject = getThing(0);
if(firstObject) { if(firstObject) {
const ThingType& type = firstObject->getType(); const ThingType& type = firstObject->getType();
if(type.isGround && !type.isTranslucent) if(type.isFullGround)
return true; return true;
} }
return false; return false;

View File

@ -28,6 +28,9 @@
class Tile : public LuaObject class Tile : public LuaObject
{ {
enum {
MAX_DRAW_ELEVATION = 24
};
public: public:
Tile(const Position& position); Tile(const Position& position);

View File

@ -903,7 +903,7 @@ void ProtocolGame::setTileDescription(InputMessage& msg, Position position)
logWarning("Too many things!"); logWarning("Too many things!");
ThingPtr thing = internalGetThing(msg); ThingPtr thing = internalGetThing(msg);
g_map.addThing(thing, position); g_map.addThing(thing, position, 255);
} }
stackPos++; stackPos++;
} }