From 2927ed29d858bf986acbd64e4f213f426593a38b Mon Sep 17 00:00:00 2001 From: GustavoBlaze Date: Mon, 23 Jan 2017 22:39:16 -0200 Subject: [PATCH 1/4] Bug idle animations of the creatures solved These changes we join the idle animations with the walking animations --- src/client/thingtype.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/client/thingtype.cpp b/src/client/thingtype.cpp index 2f225a6f..ff1f2c35 100644 --- a/src/client/thingtype.cpp +++ b/src/client/thingtype.cpp @@ -271,6 +271,10 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS bool hasFrameGroups = (category == ThingCategoryCreature && g_game.getFeature(Otc::GameIdleAnimations)); uint8 groupCount = hasFrameGroups ? fin->getU8() : 1; + + m_animationPhases = 0; + int lastTotalSprites = 0; + for(int i = 0; i < groupCount; ++i) { uint8 frameGroupType = FrameGroupDefault; if(hasFrameGroups) @@ -293,21 +297,25 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS m_numPatternZ = fin->getU8(); else m_numPatternZ = 1; - m_animationPhases = fin->getU8(); + int n_phases = fin->getU8(); - if(m_animationPhases > 1 && g_game.getFeature(Otc::GameEnhancedAnimations)) { + m_animationPhases += n_phases; + + if(n_phases > 1 && g_game.getFeature(Otc::GameEnhancedAnimations)) { m_animator = AnimatorPtr(new Animator); - m_animator->unserialize(m_animationPhases, fin); + m_animator->unserialize(n_phases, fin); } - int totalSprites = m_size.area() * m_layers * m_numPatternX * m_numPatternY * m_numPatternZ * m_animationPhases; + int totalSprites = m_size.area() * m_layers * m_numPatternX * m_numPatternY * m_numPatternZ * n_phases; - if(totalSprites > 4096) + if((lastTotalSprites+totalSprites) > 4096) stdext::throw_exception("a thing type has more than 4096 sprites"); - m_spritesIndex.resize(totalSprites); - for(int i = 0; i < totalSprites; i++) + m_spritesIndex.resize((lastTotalSprites+totalSprites)); + for(int i = lastTotalSprites; i < (lastTotalSprites+totalSprites); i++) m_spritesIndex[i] = g_game.getFeature(Otc::GameSpritesU32) ? fin->getU32() : fin->getU16(); + + lastTotalSprites += totalSprites; } m_textures.resize(m_animationPhases); From a4400a4ff1088af90abda2fd2f00bc550e7afb6a Mon Sep 17 00:00:00 2001 From: GustavoBlaze Date: Tue, 24 Jan 2017 14:56:21 -0200 Subject: [PATCH 2/4] applying the otclient code style changing the variables names --- src/client/thingtype.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/client/thingtype.cpp b/src/client/thingtype.cpp index ff1f2c35..d2407191 100644 --- a/src/client/thingtype.cpp +++ b/src/client/thingtype.cpp @@ -271,9 +271,8 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS bool hasFrameGroups = (category == ThingCategoryCreature && g_game.getFeature(Otc::GameIdleAnimations)); uint8 groupCount = hasFrameGroups ? fin->getU8() : 1; - m_animationPhases = 0; - int lastTotalSprites = 0; + int realTotalSprites = 0; for(int i = 0; i < groupCount; ++i) { uint8 frameGroupType = FrameGroupDefault; @@ -297,25 +296,25 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS m_numPatternZ = fin->getU8(); else m_numPatternZ = 1; - int n_phases = fin->getU8(); + + int groupAnimationsPhases = fin->getU8(); + m_animationPhases += groupAnimationsPhases; - m_animationPhases += n_phases; - - if(n_phases > 1 && g_game.getFeature(Otc::GameEnhancedAnimations)) { + if(groupAnimationsPhases > 1 && g_game.getFeature(Otc::GameEnhancedAnimations)) { m_animator = AnimatorPtr(new Animator); - m_animator->unserialize(n_phases, fin); + m_animator->unserialize(groupAnimationsPhases, fin); } - int totalSprites = m_size.area() * m_layers * m_numPatternX * m_numPatternY * m_numPatternZ * n_phases; + int totalSprites = m_size.area() * m_layers * m_numPatternX * m_numPatternY * m_numPatternZ * groupAnimationsPhases; - if((lastTotalSprites+totalSprites) > 4096) + if((realTotalSprites+totalSprites) > 4096) stdext::throw_exception("a thing type has more than 4096 sprites"); - m_spritesIndex.resize((lastTotalSprites+totalSprites)); - for(int i = lastTotalSprites; i < (lastTotalSprites+totalSprites); i++) + m_spritesIndex.resize((realTotalSprites+totalSprites)); + for(int i = lastTotalSprites; i < (realTotalSprites+totalSprites); i++) m_spritesIndex[i] = g_game.getFeature(Otc::GameSpritesU32) ? fin->getU32() : fin->getU16(); - lastTotalSprites += totalSprites; + realTotalSprites += totalSprites; } m_textures.resize(m_animationPhases); From bc20e165845816046366ba4a7972c1053abaa504 Mon Sep 17 00:00:00 2001 From: GustavoBlaze Date: Tue, 24 Jan 2017 14:58:11 -0200 Subject: [PATCH 3/4] Applying the otclient code style changing the variables names --- src/client/thingtype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/thingtype.cpp b/src/client/thingtype.cpp index d2407191..0705bac7 100644 --- a/src/client/thingtype.cpp +++ b/src/client/thingtype.cpp @@ -311,7 +311,7 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS stdext::throw_exception("a thing type has more than 4096 sprites"); m_spritesIndex.resize((realTotalSprites+totalSprites)); - for(int i = lastTotalSprites; i < (realTotalSprites+totalSprites); i++) + for(int i = realTotalSprites; i < (realTotalSprites+totalSprites); i++) m_spritesIndex[i] = g_game.getFeature(Otc::GameSpritesU32) ? fin->getU32() : fin->getU16(); realTotalSprites += totalSprites; From 743e73d755709a3410544f410748ffef5894c205 Mon Sep 17 00:00:00 2001 From: GustavoBlaze Date: Tue, 24 Jan 2017 15:27:58 -0200 Subject: [PATCH 4/4] Applying the otclient code style --- src/client/thingtype.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/thingtype.cpp b/src/client/thingtype.cpp index 0705bac7..7a9fb5b1 100644 --- a/src/client/thingtype.cpp +++ b/src/client/thingtype.cpp @@ -272,7 +272,7 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS uint8 groupCount = hasFrameGroups ? fin->getU8() : 1; m_animationPhases = 0; - int realTotalSprites = 0; + int totalSpritesCount = 0; for(int i = 0; i < groupCount; ++i) { uint8 frameGroupType = FrameGroupDefault; @@ -307,14 +307,14 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS int totalSprites = m_size.area() * m_layers * m_numPatternX * m_numPatternY * m_numPatternZ * groupAnimationsPhases; - if((realTotalSprites+totalSprites) > 4096) + if((totalSpritesCount+totalSprites) > 4096) stdext::throw_exception("a thing type has more than 4096 sprites"); - m_spritesIndex.resize((realTotalSprites+totalSprites)); - for(int i = realTotalSprites; i < (realTotalSprites+totalSprites); i++) + m_spritesIndex.resize((totalSpritesCount+totalSprites)); + for(int i = totalSpritesCount; i < (totalSpritesCount+totalSprites); i++) m_spritesIndex[i] = g_game.getFeature(Otc::GameSpritesU32) ? fin->getU32() : fin->getU16(); - realTotalSprites += totalSprites; + totalSpritesCount += totalSprites; } m_textures.resize(m_animationPhases);