Fix rare stackpos bug caused by chameleon rune
This commit is contained in:
parent
b39623d437
commit
66760656e9
|
@ -135,8 +135,10 @@ void Creature::internalDrawOutfit(Point dest, float scaleFactor, bool animateWal
|
||||||
}
|
}
|
||||||
// outfit is a creature imitating an item or the invisible effect
|
// outfit is a creature imitating an item or the invisible effect
|
||||||
} else {
|
} else {
|
||||||
|
ThingType *type = g_things.rawGetThingType(m_outfit.getAuxId(), m_outfit.getCategory());
|
||||||
|
|
||||||
int animationPhase = 0;
|
int animationPhase = 0;
|
||||||
int animationPhases = getAnimationPhases();
|
int animationPhases = type->getAnimationPhases();
|
||||||
int animateTicks = Otc::ITEM_TICKS_PER_FRAME;
|
int animateTicks = Otc::ITEM_TICKS_PER_FRAME;
|
||||||
|
|
||||||
// when creature is an effect we cant render the first and last animation phase,
|
// when creature is an effect we cant render the first and last animation phase,
|
||||||
|
@ -154,14 +156,20 @@ void Creature::internalDrawOutfit(Point dest, float scaleFactor, bool animateWal
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_outfit.getCategory() == ThingCategoryEffect)
|
if(m_outfit.getCategory() == ThingCategoryEffect)
|
||||||
animationPhase = std::min(animationPhase+1, getAnimationPhases());
|
animationPhase = std::min(animationPhase+1, animationPhases);
|
||||||
|
|
||||||
rawGetThingType()->draw(dest - (getDisplacement() * scaleFactor), scaleFactor, 0, 0, 0, 0, animationPhase);
|
type->draw(dest - (getDisplacement() * scaleFactor), scaleFactor, 0, 0, 0, 0, animationPhase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::drawOutfit(const Rect& destRect, bool resize)
|
void Creature::drawOutfit(const Rect& destRect, bool resize)
|
||||||
{
|
{
|
||||||
|
int exactSize;
|
||||||
|
if(m_outfit.getCategory() == ThingCategoryCreature)
|
||||||
|
exactSize = getExactSize();
|
||||||
|
else
|
||||||
|
exactSize = g_things.rawGetThingType(m_outfit.getAuxId(), m_outfit.getCategory())->getExactSize();
|
||||||
|
|
||||||
if(g_graphics.canUseFBO()) {
|
if(g_graphics.canUseFBO()) {
|
||||||
const FrameBufferPtr& outfitBuffer = g_framebuffers.getTemporaryFrameBuffer();
|
const FrameBufferPtr& outfitBuffer = g_framebuffers.getTemporaryFrameBuffer();
|
||||||
outfitBuffer->resize(Size(2*Otc::TILE_PIXELS, 2*Otc::TILE_PIXELS));
|
outfitBuffer->resize(Size(2*Otc::TILE_PIXELS, 2*Otc::TILE_PIXELS));
|
||||||
|
@ -173,7 +181,7 @@ void Creature::drawOutfit(const Rect& destRect, bool resize)
|
||||||
|
|
||||||
Rect srcRect;
|
Rect srcRect;
|
||||||
if(resize)
|
if(resize)
|
||||||
srcRect.resize(getExactSize(), getExactSize());
|
srcRect.resize(exactSize, exactSize);
|
||||||
else
|
else
|
||||||
srcRect.resize(2*Otc::TILE_PIXELS*0.75f, 2*Otc::TILE_PIXELS*0.75f);
|
srcRect.resize(2*Otc::TILE_PIXELS*0.75f, 2*Otc::TILE_PIXELS*0.75f);
|
||||||
srcRect.moveBottomRight(Point(2*Otc::TILE_PIXELS - 1, 2*Otc::TILE_PIXELS - 1));
|
srcRect.moveBottomRight(Point(2*Otc::TILE_PIXELS - 1, 2*Otc::TILE_PIXELS - 1));
|
||||||
|
@ -181,7 +189,7 @@ void Creature::drawOutfit(const Rect& destRect, bool resize)
|
||||||
} else {
|
} else {
|
||||||
float scaleFactor;
|
float scaleFactor;
|
||||||
if(resize)
|
if(resize)
|
||||||
scaleFactor = destRect.width() / (float)getExactSize();
|
scaleFactor = destRect.width() / (float)exactSize;
|
||||||
else
|
else
|
||||||
scaleFactor = destRect.width() / (float)(2*Otc::TILE_PIXELS*0.75f);
|
scaleFactor = destRect.width() / (float)(2*Otc::TILE_PIXELS*0.75f);
|
||||||
Point dest = destRect.bottomRight() - (Point(Otc::TILE_PIXELS,Otc::TILE_PIXELS) - getDisplacement())*scaleFactor;
|
Point dest = destRect.bottomRight() - (Point(Otc::TILE_PIXELS,Otc::TILE_PIXELS) - getDisplacement())*scaleFactor;
|
||||||
|
@ -506,7 +514,7 @@ void Creature::setDirection(Otc::Direction direction)
|
||||||
|
|
||||||
void Creature::setOutfit(const Outfit& outfit)
|
void Creature::setOutfit(const Outfit& outfit)
|
||||||
{
|
{
|
||||||
if(!g_things.isValidDatId(outfit.getId(), outfit.getCategory()))
|
if(!g_things.isValidDatId(outfit.getCategory() == ThingCategoryCreature ? outfit.getId() : outfit.getAuxId(), outfit.getCategory()))
|
||||||
return;
|
return;
|
||||||
m_walkAnimationPhase = 0; // might happen when player is walking and outfit is changed.
|
m_walkAnimationPhase = 0; // might happen when player is walking and outfit is changed.
|
||||||
m_outfit = outfit;
|
m_outfit = outfit;
|
||||||
|
@ -637,34 +645,31 @@ int Creature::getStepDuration()
|
||||||
|
|
||||||
Point Creature::getDisplacement()
|
Point Creature::getDisplacement()
|
||||||
{
|
{
|
||||||
Point displacement = Thing::getDisplacement();
|
|
||||||
if(m_outfit.getCategory() == ThingCategoryEffect)
|
if(m_outfit.getCategory() == ThingCategoryEffect)
|
||||||
displacement = Point(8, 8);
|
return Point(8, 8);
|
||||||
return displacement;
|
return Thing::getDisplacement();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Creature::getDisplacementX()
|
int Creature::getDisplacementX()
|
||||||
{
|
{
|
||||||
int displacementX = Thing::getDisplacementX();
|
|
||||||
if(m_outfit.getCategory() == ThingCategoryEffect)
|
if(m_outfit.getCategory() == ThingCategoryEffect)
|
||||||
displacementX = 8;
|
return 8;
|
||||||
return displacementX;
|
return Thing::getDisplacementX();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Creature::getDisplacementY()
|
int Creature::getDisplacementY()
|
||||||
{
|
{
|
||||||
int displacementY = Thing::getDisplacementY();
|
|
||||||
if(m_outfit.getCategory() == ThingCategoryEffect)
|
if(m_outfit.getCategory() == ThingCategoryEffect)
|
||||||
displacementY = 8;
|
return 8;
|
||||||
return displacementY;
|
return Thing::getDisplacementY();
|
||||||
}
|
}
|
||||||
|
|
||||||
const ThingTypePtr& Creature::getThingType()
|
const ThingTypePtr& Creature::getThingType()
|
||||||
{
|
{
|
||||||
return g_things.getThingType(m_outfit.getId(), m_outfit.getCategory());
|
return g_things.getThingType(m_outfit.getId(), ThingCategoryCreature);
|
||||||
}
|
}
|
||||||
|
|
||||||
ThingType* Creature::rawGetThingType()
|
ThingType* Creature::rawGetThingType()
|
||||||
{
|
{
|
||||||
return g_things.rawGetThingType(m_outfit.getId(), m_outfit.getCategory());
|
return g_things.rawGetThingType(m_outfit.getId(), ThingCategoryCreature);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
Outfit::Outfit()
|
Outfit::Outfit()
|
||||||
{
|
{
|
||||||
m_category = ThingCategoryCreature;
|
m_category = ThingCategoryCreature;
|
||||||
m_id = 0;
|
m_id = 128;
|
||||||
|
m_auxId = 0;
|
||||||
resetClothes();
|
resetClothes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
static Color getColor(int color);
|
static Color getColor(int color);
|
||||||
|
|
||||||
void setId(int id) { m_id = id; }
|
void setId(int id) { m_id = id; }
|
||||||
|
void setAuxId(int id) { m_auxId = id; }
|
||||||
void setHead(int head) { m_head = head; m_headColor = getColor(head); }
|
void setHead(int head) { m_head = head; m_headColor = getColor(head); }
|
||||||
void setBody(int body) { m_body = body; m_bodyColor = getColor(body); }
|
void setBody(int body) { m_body = body; m_bodyColor = getColor(body); }
|
||||||
void setLegs(int legs) { m_legs = legs; m_legsColor = getColor(legs); }
|
void setLegs(int legs) { m_legs = legs; m_legsColor = getColor(legs); }
|
||||||
|
@ -50,6 +51,7 @@ public:
|
||||||
void resetClothes();
|
void resetClothes();
|
||||||
|
|
||||||
int getId() const { return m_id; }
|
int getId() const { return m_id; }
|
||||||
|
int getAuxId() const { return m_auxId; }
|
||||||
int getHead() const { return m_head; }
|
int getHead() const { return m_head; }
|
||||||
int getBody() const { return m_body; }
|
int getBody() const { return m_body; }
|
||||||
int getLegs() const { return m_legs; }
|
int getLegs() const { return m_legs; }
|
||||||
|
@ -65,7 +67,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ThingCategory m_category;
|
ThingCategory m_category;
|
||||||
int m_id, m_head, m_body, m_legs, m_feet, m_addons, m_mount;
|
int m_id, m_auxId, m_head, m_body, m_legs, m_feet, m_addons, m_mount;
|
||||||
Color m_headColor, m_bodyColor, m_legsColor, m_feetColor;
|
Color m_headColor, m_bodyColor, m_legsColor, m_feetColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1451,24 +1451,24 @@ Outfit ProtocolGame::getOutfit(const InputMessagePtr& msg)
|
||||||
outfit.setLegs(legs);
|
outfit.setLegs(legs);
|
||||||
outfit.setFeet(feet);
|
outfit.setFeet(feet);
|
||||||
outfit.setAddons(addons);
|
outfit.setAddons(addons);
|
||||||
|
|
||||||
|
if(g_game.getFeature(Otc::GamePlayerMounts)) {
|
||||||
|
int mount = msg->getU16();
|
||||||
|
outfit.setMount(mount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int lookTypeEx = msg->getU16();
|
int lookTypeEx = msg->getU16();
|
||||||
if(lookTypeEx == 0) {
|
if(lookTypeEx == 0) {
|
||||||
outfit.setCategory(ThingCategoryEffect);
|
outfit.setCategory(ThingCategoryEffect);
|
||||||
outfit.setId(13);
|
outfit.setAuxId(13);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
outfit.setCategory(ThingCategoryItem);
|
outfit.setCategory(ThingCategoryItem);
|
||||||
outfit.setId(lookTypeEx);
|
outfit.setAuxId(lookTypeEx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(g_game.getFeature(Otc::GamePlayerMounts)) {
|
|
||||||
int mount = msg->getU16();
|
|
||||||
outfit.setMount(mount);
|
|
||||||
}
|
|
||||||
|
|
||||||
return outfit;
|
return outfit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue