From 06a72ffb7e22e14b701a45ba88b9a95c9922de48 Mon Sep 17 00:00:00 2001 From: Henrique Date: Sun, 21 Aug 2011 00:21:35 -0300 Subject: [PATCH 1/3] stack fix, creature names and health bar, still buggy --- src/otclient/core/creature.cpp | 13 +++++-- src/otclient/core/creature.h | 1 + src/otclient/core/map.cpp | 33 ++++++++++------ src/otclient/core/map.h | 2 +- src/otclient/core/tile.cpp | 71 +++++++++++++--------------------- src/otclient/otclient.cpp | 2 +- 6 files changed, 60 insertions(+), 62 deletions(-) diff --git a/src/otclient/core/creature.cpp b/src/otclient/core/creature.cpp index ba101a7e..6126a583 100644 --- a/src/otclient/core/creature.cpp +++ b/src/otclient/core/creature.cpp @@ -1,8 +1,9 @@ -#include "creature.h" + #include "creature.h" #include "datmanager.h" #include #include #include "game.h" +#include Creature::Creature() : Thing(THING_CREATURE) { @@ -41,9 +42,11 @@ void Creature::draw(int x, int y) g_graphics.bindBlendFunc(BLEND_NORMAL); g_graphics.bindColor(Color::white); } +} +void Creature::drawName(int x, int y) +{ // health bar - // TODO: draw outside framebuffer Color healthColor = Color::black; if(m_healthPercent > 60 && m_healthPercent <= 100) { healthColor.setRed(0.0f); @@ -59,7 +62,7 @@ void Creature::draw(int x, int y) healthColor.setGreen(0.00f); } - Rect healthRect = Rect(x - 14, y - 11, 27, 4); + Rect healthRect = Rect(x-(14.5), y-2, 27, 4); g_graphics.bindColor(Color::black); g_graphics.drawBoundingRect(healthRect); @@ -69,6 +72,10 @@ void Creature::draw(int x, int y) // restore white color g_graphics.bindColor(Color::white); + + // name + FontPtr font = g_fonts.getDefaultFont(); + font->renderText(m_name, Rect(x-50, y-16, 100, 16), AlignTopCenter); } const ThingAttributes& Creature::getAttributes() diff --git a/src/otclient/core/creature.h b/src/otclient/core/creature.h index 60f96443..99c35449 100644 --- a/src/otclient/core/creature.h +++ b/src/otclient/core/creature.h @@ -19,6 +19,7 @@ public: virtual ~Creature() { } virtual void draw(int x, int y); + void drawName(int x, int y); void setName(const std::string& name) { m_name = name; } void setHealthPercent(uint8 healthPercent) { m_healthPercent = healthPercent; } diff --git a/src/otclient/core/map.cpp b/src/otclient/core/map.cpp index a3d5d510..6cf05d5b 100644 --- a/src/otclient/core/map.cpp +++ b/src/otclient/core/map.cpp @@ -6,7 +6,7 @@ Map g_map; -void Map::draw(int x, int y) +void Map::draw(const Rect& rect) { if(!m_framebuffer) m_framebuffer = FrameBufferPtr(new FrameBuffer(15*32, 11*32)); @@ -50,17 +50,13 @@ void Map::draw(int x, int y) if(iz == drawFloorStop) break; - for(int step = 0; step < 4; ++step) { + // +1 in draws cause 64x64 items may affect view. - - // +1 in draws cause 64x64 items may affect view. - - for(int ix = -7+(playerPos.z-iz); ix < + 8+7; ++ix) { - for(int iy = -5+(playerPos.z-iz); iy < + 6+7; ++iy) { - Position itemPos = Position(playerPos.x + ix, playerPos.y + iy, iz); - if(const TilePtr& tile = m_tiles[itemPos]) - tile->draw((ix + 7 - (playerPos.z-iz))*32, (iy + 5 - (playerPos.z-iz))*32, step); - } + for(int ix = -7+(playerPos.z-iz); ix < + 8+7; ++ix) { + for(int iy = -5+(playerPos.z-iz); iy < + 6+7; ++iy) { + Position itemPos = Position(playerPos.x + ix, playerPos.y + iy, iz); + if(const TilePtr& tile = m_tiles[itemPos]) + tile->draw((ix + 7 - (playerPos.z-iz))*32, (iy + 5 - (playerPos.z-iz))*32, 0); } } } @@ -73,7 +69,20 @@ void Map::draw(int x, int y) m_framebuffer->unbind(); g_graphics.bindColor(Color::white); - m_framebuffer->draw(Rect(x, y, g_graphics.getScreenSize())); + m_framebuffer->draw(rect); + + // calculate stretch factor + float horizontalStretchFactor = (rect.width() - rect.x()) / (float)(15*32); + float verticalStretchFactor = (rect.height() - rect.y()) / (float)(11*32); + + // draw player names and health bars + for(int ix = -7; ix <= 7; ++ix) { + for(int iy = -5; iy <= 5; ++iy) { + Position itemPos = Position(playerPos.x + ix, playerPos.y + iy, playerPos.z); + if(const TilePtr& tile = m_tiles[itemPos]) + tile->draw(((ix + 7)*32+5)*horizontalStretchFactor, ((iy + 5)*32 - 8)*verticalStretchFactor, 1); + } + } } void Map::addThing(ThingPtr thing, uint8 stackpos) diff --git a/src/otclient/core/map.h b/src/otclient/core/map.h index a2482b0d..8009618c 100644 --- a/src/otclient/core/map.h +++ b/src/otclient/core/map.h @@ -8,7 +8,7 @@ class Map { public: - void draw(int x, int y); + void draw(const Rect& rect); void addThing(ThingPtr thing, uint8 stackpos = 0); ThingPtr getThing(const Position& pos, uint8 stackpos); diff --git a/src/otclient/core/tile.cpp b/src/otclient/core/tile.cpp index 625bc060..ddf258e3 100644 --- a/src/otclient/core/tile.cpp +++ b/src/otclient/core/tile.cpp @@ -13,23 +13,20 @@ Tile::Tile() void Tile::draw(int x, int y, int step) { - // STEP 0 = draw ground, top 1 - // STEP 1 = top 2 - // STEP 2 = top 3 - // STEP 3 = bottom, creatures, names, etc + // STEP 0 = draw map + // STEP 1 = draw creature names + // STEP 2 = draw speak FontPtr font = g_fonts.getDefaultFont(); - if(step == 0 && m_drawNextOffset != 0) { - logDebug("error with tile offset."); - return; - } - if(step == 0) { + m_drawNextOffset = 0; + if(m_ground) m_ground->draw(x, y); - for(const ThingPtr& thing : m_itemsTop) { + for(auto it = m_itemsTop.rbegin(), end = m_itemsTop.rend(); it != end; ++it) { + const ThingPtr& thing = *it; const ThingAttributes& thingAttributes = thing->getAttributes(); if(thingAttributes.alwaysOnTopOrder == 1) { @@ -40,7 +37,8 @@ void Tile::draw(int x, int y, int step) } } - for(const ThingPtr& thing : m_itemsTop) { + for(auto it = m_itemsTop.rbegin(), end = m_itemsTop.rend(); it != end; ++it) { + const ThingPtr& thing = *it; const ThingAttributes& thingAttributes = thing->getAttributes(); if(thingAttributes.alwaysOnTopOrder == 2) { @@ -50,21 +48,21 @@ void Tile::draw(int x, int y, int step) } } - for(const ThingPtr& thing : m_itemsBottom) { + for(auto it = m_itemsBottom.rbegin(), end = m_itemsBottom.rend(); it != end; ++it) { + const ThingPtr& thing = *it; const ThingAttributes& thingAttributes = thing->getAttributes(); thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); //font->renderText("B0", Rect(x + 5, y+5, 100, 100)); m_drawNextOffset += thingAttributes.drawNextOffset; } - for(const ThingPtr& thing : m_creatures) { - const ThingAttributes& thingAttributes = thing->getAttributes(); + for(auto it = m_creatures.rbegin(), end = m_creatures.rend(); it != end; ++it) { + const ThingPtr& thing = *it; thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); - - m_drawNextOffset += thingAttributes.drawNextOffset; } - for(const ThingPtr& thing : m_itemsTop) { + for(auto it = m_itemsTop.rbegin(), end = m_itemsTop.rend(); it != end; ++it) { + const ThingPtr& thing = *it; const ThingAttributes& thingAttributes = thing->getAttributes(); if(thingAttributes.alwaysOnTopOrder == 3) { @@ -74,24 +72,19 @@ void Tile::draw(int x, int y, int step) } } - for(const ThingPtr& thing : m_effects) { + for(auto it = m_effects.rbegin(), end = m_effects.rend(); it != end; ++it) { + const ThingPtr& thing = *it; thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); } - - m_drawNextOffset = 0; } else if(step == 1) { - - - - } - else if(step == 2) { - + for(auto it = m_creatures.rbegin(), end = m_creatures.rend(); it != end; ++it) { + const ThingPtr& thing = *it; + const CreaturePtr& creature = thing->asCreature(); + creature->drawName(x - m_drawNextOffset, y - m_drawNextOffset); + } - } - else if(step == 3) { - } } @@ -100,18 +93,6 @@ void Tile::addThing(ThingPtr thing, uint8 stackpos) if(!thing) return; - //8308 - //2526 - //5296 - - const ThingAttributes& item1 = g_dat.getItemAttributes(8308); - const ThingAttributes& item2 = g_dat.getItemAttributes(2526); - const ThingAttributes& item3 = g_dat.getItemAttributes(5296); - - int j = item1.alwaysOnTopOrder + item2.alwaysOnTopOrder + item3.alwaysOnTopOrder; - j++; - - if(thing->getPosition() == g_game.getLocalPlayer()->getPosition() + Position(-1, 0, 0) && thing->getAttributes().alwaysOnTop) { logDebug((int)thing->getId()); } @@ -123,16 +104,16 @@ void Tile::addThing(ThingPtr thing, uint8 stackpos) m_ground = thing; else { if(thingAttributes.alwaysOnTop) - m_itemsTop.push_front(thing); + m_itemsTop.push_back(thing); else - m_itemsBottom.push_front(thing); + m_itemsBottom.push_back(thing); } } else if(thing->asCreature()) { - m_creatures.push_front(thing); + m_creatures.push_back(thing); } else if(thing->asEffect()) { - m_effects.push_front(thing); + m_effects.push_back(thing); } } diff --git a/src/otclient/otclient.cpp b/src/otclient/otclient.cpp index 7f5c5d19..b98170ff 100644 --- a/src/otclient/otclient.cpp +++ b/src/otclient/otclient.cpp @@ -209,7 +209,7 @@ void OTClient::render() { //TODO: UIMap for map drawing if(g_game.isOnline()) - g_map.draw(0, 0); + g_map.draw(Rect(0, 0, g_graphics.getScreenSize())); // everything is rendered by UI components g_ui.render(); From 377a249f528aa8847d790bff7c167c6c09605748 Mon Sep 17 00:00:00 2001 From: Henrique Date: Sun, 21 Aug 2011 00:24:43 -0300 Subject: [PATCH 2/3] remove text draw on tiles --- src/otclient/core/tile.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/otclient/core/tile.cpp b/src/otclient/core/tile.cpp index 5bbb94ad..ddf258e3 100644 --- a/src/otclient/core/tile.cpp +++ b/src/otclient/core/tile.cpp @@ -31,7 +31,7 @@ void Tile::draw(int x, int y, int step) if(thingAttributes.alwaysOnTopOrder == 1) { thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); - font->renderText("T1", Rect(x + 5, y+5, 100, 100)); + //font->renderText("T1", Rect(x + 5, y+5, 100, 100)); m_drawNextOffset += thingAttributes.drawNextOffset; } @@ -43,7 +43,7 @@ void Tile::draw(int x, int y, int step) if(thingAttributes.alwaysOnTopOrder == 2) { thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); - font->renderText("T2", Rect(x + 5, y+5, 100, 100)); + //font->renderText("T2", Rect(x + 5, y+5, 100, 100)); m_drawNextOffset += thingAttributes.drawNextOffset; } } @@ -52,7 +52,7 @@ void Tile::draw(int x, int y, int step) const ThingPtr& thing = *it; const ThingAttributes& thingAttributes = thing->getAttributes(); thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); - font->renderText("B0", Rect(x + 5, y+5, 100, 100)); + //font->renderText("B0", Rect(x + 5, y+5, 100, 100)); m_drawNextOffset += thingAttributes.drawNextOffset; } @@ -67,7 +67,7 @@ void Tile::draw(int x, int y, int step) if(thingAttributes.alwaysOnTopOrder == 3) { thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); - font->renderText("T3", Rect(x + 5, y+5, 100, 100)); + //font->renderText("T3", Rect(x + 5, y+5, 100, 100)); m_drawNextOffset += thingAttributes.drawNextOffset; } } From 80211b99856f4000837b499b91b947638a74183c Mon Sep 17 00:00:00 2001 From: Henrique Date: Sun, 21 Aug 2011 16:09:23 -0300 Subject: [PATCH 3/3] health bar improvement, drawOffset bug fix --- modules/core_fonts/core_fonts.otmod | 5 ++ src/otclient/core/creature.cpp | 48 ++++++++------- src/otclient/core/creature.h | 2 +- src/otclient/core/map.cpp | 22 +++++-- src/otclient/core/tile.cpp | 92 ++++++++++++----------------- src/otclient/core/tile.h | 10 ++-- 6 files changed, 93 insertions(+), 86 deletions(-) diff --git a/modules/core_fonts/core_fonts.otmod b/modules/core_fonts/core_fonts.otmod index e3a401a7..2514df3d 100644 --- a/modules/core_fonts/core_fonts.otmod +++ b/modules/core_fonts/core_fonts.otmod @@ -12,6 +12,11 @@ Module importFont('helvetica-12px') importFont('helvetica-14px-bold') importFont('terminus-14px-bold') + + importFont('tibia-8px-antialised') + importFont('tibia-10px-antialised') + importFont('tibia-10px-monochrome') + importFont('tibia-12px-rounded') setDefaultFont('helvetica-12px') return true diff --git a/src/otclient/core/creature.cpp b/src/otclient/core/creature.cpp index 6126a583..c06180f5 100644 --- a/src/otclient/core/creature.cpp +++ b/src/otclient/core/creature.cpp @@ -44,38 +44,44 @@ void Creature::draw(int x, int y) } } -void Creature::drawName(int x, int y) +void Creature::drawInformation(int x, int y, bool useGray) { - // health bar - Color healthColor = Color::black; - if(m_healthPercent > 60 && m_healthPercent <= 100) { - healthColor.setRed(0.0f); - healthColor.setGreen(0.75f); - } else if(m_healthPercent > 30 && m_healthPercent <= 60) { - healthColor.setRed(0.75f); - healthColor.setGreen(0.75f); - } else if(m_healthPercent > 10 && m_healthPercent <= 30) { - healthColor.setRed(0.75f); - healthColor.setGreen(0.00f); - } else if(m_healthPercent > 0 && m_healthPercent <= 10) { - healthColor.setRed(0.25f); - healthColor.setGreen(0.00f); + Color fillColor = Color(96, 96, 96); + + if(!useGray) { + // health bar + fillColor = Color::black; + if(m_healthPercent > 60 && m_healthPercent <= 100) { + fillColor.setRed(0.0f); + fillColor.setGreen(0.75f); + } else if(m_healthPercent > 30 && m_healthPercent <= 60) { + fillColor.setRed(0.75f); + fillColor.setGreen(0.75f); + } else if(m_healthPercent > 10 && m_healthPercent <= 30) { + fillColor.setRed(0.75f); + fillColor.setGreen(0.00f); + } else if(m_healthPercent > 0 && m_healthPercent <= 10) { + fillColor.setRed(0.25f); + fillColor.setGreen(0.00f); + } } - Rect healthRect = Rect(x-(14.5), y-2, 27, 4); + Rect backgroundRect = Rect(x-(14.5), y-2, 27, 4); + Rect healthRect = backgroundRect.expanded(-1); + healthRect.setWidth((m_healthPercent/100.0)*25); g_graphics.bindColor(Color::black); - g_graphics.drawBoundingRect(healthRect); + g_graphics.drawFilledRect(backgroundRect); - g_graphics.bindColor(healthColor); - g_graphics.drawFilledRect(healthRect.expanded(-1)); + g_graphics.bindColor(fillColor); + g_graphics.drawFilledRect(healthRect); // restore white color g_graphics.bindColor(Color::white); // name - FontPtr font = g_fonts.getDefaultFont(); - font->renderText(m_name, Rect(x-50, y-16, 100, 16), AlignTopCenter); + FontPtr font = g_fonts.getFont("tibia-12px-rounded"); + font->renderText(m_name, Rect(x-50, y-16, 100, 16), AlignTopCenter, fillColor); } const ThingAttributes& Creature::getAttributes() diff --git a/src/otclient/core/creature.h b/src/otclient/core/creature.h index 99c35449..6872a032 100644 --- a/src/otclient/core/creature.h +++ b/src/otclient/core/creature.h @@ -19,7 +19,7 @@ public: virtual ~Creature() { } virtual void draw(int x, int y); - void drawName(int x, int y); + void drawInformation(int x, int y, bool useGray); void setName(const std::string& name) { m_name = name; } void setHealthPercent(uint8 healthPercent) { m_healthPercent = healthPercent; } diff --git a/src/otclient/core/map.cpp b/src/otclient/core/map.cpp index 6cf05d5b..35a5d81a 100644 --- a/src/otclient/core/map.cpp +++ b/src/otclient/core/map.cpp @@ -18,10 +18,11 @@ void Map::draw(const Rect& rect) // player is above 7 + int drawFloorStop = 0; if(playerPos.z <= 7) { // player pos it 8-6. check if we can draw upper floors. - int drawFloorStop = 0; + // if there is a window on north, east, south or west //Position direction[4] = {Position(0, -1, 0), Position(1, 0, 0), Position(0, 1, 0), Position(-1, 0, 0)}; @@ -56,7 +57,7 @@ void Map::draw(const Rect& rect) for(int iy = -5+(playerPos.z-iz); iy < + 6+7; ++iy) { Position itemPos = Position(playerPos.x + ix, playerPos.y + iy, iz); if(const TilePtr& tile = m_tiles[itemPos]) - tile->draw((ix + 7 - (playerPos.z-iz))*32, (iy + 5 - (playerPos.z-iz))*32, 0); + tile->draw((ix + 7 - (playerPos.z-iz))*32, (iy + 5 - (playerPos.z-iz))*32); } } } @@ -79,8 +80,21 @@ void Map::draw(const Rect& rect) for(int ix = -7; ix <= 7; ++ix) { for(int iy = -5; iy <= 5; ++iy) { Position itemPos = Position(playerPos.x + ix, playerPos.y + iy, playerPos.z); - if(const TilePtr& tile = m_tiles[itemPos]) - tile->draw(((ix + 7)*32+5)*horizontalStretchFactor, ((iy + 5)*32 - 8)*verticalStretchFactor, 1); + if(const TilePtr& tile = m_tiles[itemPos]) { + std::deque creatures = tile->getCreatures(); + for(auto it = creatures.rbegin(), end = creatures.rend(); it != end; ++it) { + const ThingPtr& thing = *it; + const CreaturePtr& creature = thing->asCreature(); + + int x = (ix + 7)*32 + 5 - tile->getDrawNextOffset(); + int y = (iy + 5)*32 - 8 - tile->getDrawNextOffset(); + + // TODO: create isCovered function. + bool useGray = (drawFloorStop != playerPos.z-1); + + creature->drawInformation(x*horizontalStretchFactor, y*verticalStretchFactor, useGray); + } + } } } } diff --git a/src/otclient/core/tile.cpp b/src/otclient/core/tile.cpp index ddf258e3..843c8dd7 100644 --- a/src/otclient/core/tile.cpp +++ b/src/otclient/core/tile.cpp @@ -11,80 +11,64 @@ Tile::Tile() m_drawNextOffset = 0; } -void Tile::draw(int x, int y, int step) +void Tile::draw(int x, int y) { - // STEP 0 = draw map - // STEP 1 = draw creature names - // STEP 2 = draw speak - FontPtr font = g_fonts.getDefaultFont(); - if(step == 0) { - m_drawNextOffset = 0; + m_drawNextOffset = 0; - if(m_ground) - m_ground->draw(x, y); + if(m_ground) + m_ground->draw(x, y); - for(auto it = m_itemsTop.rbegin(), end = m_itemsTop.rend(); it != end; ++it) { - const ThingPtr& thing = *it; - const ThingAttributes& thingAttributes = thing->getAttributes(); + for(auto it = m_itemsTop.rbegin(), end = m_itemsTop.rend(); it != end; ++it) { + const ThingPtr& thing = *it; + const ThingAttributes& thingAttributes = thing->getAttributes(); - if(thingAttributes.alwaysOnTopOrder == 1) { - thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); - //font->renderText("T1", Rect(x + 5, y+5, 100, 100)); + if(thingAttributes.alwaysOnTopOrder == 1) { + thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); + //font->renderText("T1", Rect(x + 5, y+5, 100, 100)); - m_drawNextOffset += thingAttributes.drawNextOffset; - } + m_drawNextOffset += thingAttributes.drawNextOffset; } + } - for(auto it = m_itemsTop.rbegin(), end = m_itemsTop.rend(); it != end; ++it) { - const ThingPtr& thing = *it; - const ThingAttributes& thingAttributes = thing->getAttributes(); - - if(thingAttributes.alwaysOnTopOrder == 2) { - thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); - //font->renderText("T2", Rect(x + 5, y+5, 100, 100)); - m_drawNextOffset += thingAttributes.drawNextOffset; - } - } + for(auto it = m_itemsTop.rbegin(), end = m_itemsTop.rend(); it != end; ++it) { + const ThingPtr& thing = *it; + const ThingAttributes& thingAttributes = thing->getAttributes(); - for(auto it = m_itemsBottom.rbegin(), end = m_itemsBottom.rend(); it != end; ++it) { - const ThingPtr& thing = *it; - const ThingAttributes& thingAttributes = thing->getAttributes(); + if(thingAttributes.alwaysOnTopOrder == 2) { thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); - //font->renderText("B0", Rect(x + 5, y+5, 100, 100)); + //font->renderText("T2", Rect(x + 5, y+5, 100, 100)); m_drawNextOffset += thingAttributes.drawNextOffset; } + } - for(auto it = m_creatures.rbegin(), end = m_creatures.rend(); it != end; ++it) { - const ThingPtr& thing = *it; - thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); - } + for(auto it = m_itemsBottom.rbegin(), end = m_itemsBottom.rend(); it != end; ++it) { + const ThingPtr& thing = *it; + const ThingAttributes& thingAttributes = thing->getAttributes(); + thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); + //font->renderText("B0", Rect(x + 5, y+5, 100, 100)); + m_drawNextOffset += thingAttributes.drawNextOffset; + } - for(auto it = m_itemsTop.rbegin(), end = m_itemsTop.rend(); it != end; ++it) { - const ThingPtr& thing = *it; - const ThingAttributes& thingAttributes = thing->getAttributes(); + for(auto it = m_creatures.rbegin(), end = m_creatures.rend(); it != end; ++it) { + const ThingPtr& thing = *it; + thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); + } - if(thingAttributes.alwaysOnTopOrder == 3) { - thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); - //font->renderText("T3", Rect(x + 5, y+5, 100, 100)); - m_drawNextOffset += thingAttributes.drawNextOffset; - } - } + for(auto it = m_itemsTop.rbegin(), end = m_itemsTop.rend(); it != end; ++it) { + const ThingPtr& thing = *it; + const ThingAttributes& thingAttributes = thing->getAttributes(); - for(auto it = m_effects.rbegin(), end = m_effects.rend(); it != end; ++it) { - const ThingPtr& thing = *it; - thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); + if(thingAttributes.alwaysOnTopOrder == 3) { + thing->draw(x, y); + //font->renderText("T3", Rect(x + 5, y+5, 100, 100)); } } - else if(step == 1) { - for(auto it = m_creatures.rbegin(), end = m_creatures.rend(); it != end; ++it) { - const ThingPtr& thing = *it; - const CreaturePtr& creature = thing->asCreature(); - creature->drawName(x - m_drawNextOffset, y - m_drawNextOffset); - } - + for(auto it = m_effects.rbegin(), end = m_effects.rend(); it != end; ++it) { + const ThingPtr& thing = *it; + thing->draw(x - m_drawNextOffset, y - m_drawNextOffset); } } diff --git a/src/otclient/core/tile.h b/src/otclient/core/tile.h index 8acdc31a..7c196585 100644 --- a/src/otclient/core/tile.h +++ b/src/otclient/core/tile.h @@ -4,17 +4,12 @@ #include "declarations.h" #include -enum RenderStep -{ - -}; - class Tile : public LuaObject { public: Tile(); - void draw(int x, int y, int step); + void draw(int x, int y); void addThing(ThingPtr thing, uint8 stackpos); ThingPtr getThing(uint8 stackpos); @@ -27,6 +22,9 @@ public: int getStackSize(); + std::deque getCreatures() { return m_creatures; } + int getDrawNextOffset() { return m_drawNextOffset; } + private: ThingPtr m_ground; std::deque m_itemsBottom;