From 617e6b302b6676ee3287c0aacdc61f941f0e5c4d Mon Sep 17 00:00:00 2001 From: BeniS Date: Mon, 3 Dec 2012 13:17:41 +1300 Subject: [PATCH] Fix for creature lights. * Will now load the dat values for creature lights (ed if you know a more conventional way for this please let me know). * No need to draw light for the outfit the creature draw will handle it. Note: not sure if the from8bit method should limit at 256 or not, but tibia dat contains colors 216+. --- modules/gamelib/game.lua | 2 +- src/framework/util/color.h | 2 +- src/otclient/creature.cpp | 2 +- src/otclient/lightview.cpp | 4 ++-- src/otclient/lightview.h | 2 +- src/otclient/protocolgameparse.cpp | 14 ++++++++++++-- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/modules/gamelib/game.lua b/modules/gamelib/game.lua index 8d50bb0c..59cbecf0 100644 --- a/modules/gamelib/game.lua +++ b/modules/gamelib/game.lua @@ -50,7 +50,7 @@ function g_game.getSupportedProtocols() return { 810, 853, 854, 860, 861, 862, 870, 910, 940, 944, 953, 954, 960, 961, - 963, 970 + 963, 970, 971 } end diff --git a/src/framework/util/color.h b/src/framework/util/color.h index 7e5933d0..263182fd 100644 --- a/src/framework/util/color.h +++ b/src/framework/util/color.h @@ -71,7 +71,7 @@ public: bool operator!=(const Color& other) const { return other.rgba() != rgba(); } static Color from8bit(int color) { - if(color >= 216 || color <= 0) + if(color >= 256 || color <= 0) return Color(0, 0, 0); int r = int(color / 36) % 6 * 51; diff --git a/src/otclient/creature.cpp b/src/otclient/creature.cpp index 76c1aa7e..1b533c32 100644 --- a/src/otclient/creature.cpp +++ b/src/otclient/creature.cpp @@ -78,7 +78,7 @@ void Creature::draw(const Point& dest, float scaleFactor, bool animate, LightVie g_painter->setColor(Color::white); } - internalDrawOutfit(dest + animationOffset * scaleFactor, scaleFactor, animate, animate, m_direction, lightView); + internalDrawOutfit(dest + animationOffset * scaleFactor, scaleFactor, animate, animate, m_direction); m_footStepDrawn = true; if(lightView) { diff --git a/src/otclient/lightview.cpp b/src/otclient/lightview.cpp index 4cdaf393..4337213b 100644 --- a/src/otclient/lightview.cpp +++ b/src/otclient/lightview.cpp @@ -30,11 +30,11 @@ LightView::LightView() { m_lightbuffer = g_framebuffers.createFrameBuffer(); - generateLightBuble(); + generateLightBubble(); reset(); } -void LightView::generateLightBuble() +void LightView::generateLightBubble() { m_lightRadius = 128; int circleDiameter = m_lightRadius * 2; diff --git a/src/otclient/lightview.h b/src/otclient/lightview.h index 959552b5..c44dec42 100644 --- a/src/otclient/lightview.h +++ b/src/otclient/lightview.h @@ -47,7 +47,7 @@ public: private: void drawGlobalLight(const Light& light); void drawLightSource(const Point& center, const Color& color, int radius); - void generateLightBuble(); + void generateLightBubble(); TexturePtr m_lightTexture; int m_lightRadius; diff --git a/src/otclient/protocolgameparse.cpp b/src/otclient/protocolgameparse.cpp index 833f4306..cc97893d 100644 --- a/src/otclient/protocolgameparse.cpp +++ b/src/otclient/protocolgameparse.cpp @@ -1638,13 +1638,23 @@ CreaturePtr ProtocolGame::getCreature(const InputMessagePtr& msg, int type) creature->setHealthPercent(healthPercent); creature->setDirection(direction); creature->setOutfit(outfit); - creature->setLight(light); creature->setSpeed(speed); creature->setSkull(skull); creature->setShield(shield); + creature->setPassable(!unpass); if(emblem != -1) creature->setEmblem(emblem); - creature->setPassable(!unpass); + + ThingTypePtr thing = creature->getThingType(); + if(thing) { + Light newLight = thing->getLight(); + if(light.color > 0 && light.color != 215) + newLight.color = light.color; + if(light.intensity > 0) + newLight.intensity = light.intensity; + + creature->setLight(newLight); + } if(creature == m_localPlayer && !m_localPlayer->isKnown()) m_localPlayer->setKnown(true);