diff --git a/source/glest_game/types/skill_type.cpp b/source/glest_game/types/skill_type.cpp index fa86f420..b43bc016 100644 --- a/source/glest_game/types/skill_type.cpp +++ b/source/glest_game/types/skill_type.cpp @@ -140,7 +140,7 @@ bool AttackBoost::isAffected(const Unit *source, const Unit *dest) const { } if(destUnitMightApply == true) { - float distance = source->getCenteredPos().dist(dest->getCenteredPos()); + double distance = source->getCenteredPos().dist(dest->getCenteredPos()); if(distance <= radius) { result = true; } @@ -516,7 +516,7 @@ const AnimationAttributes SkillType::getAnimationAttribute(int index) const { return animationAttributes[index]; } -Model *SkillType::getAnimation(float animProgress, const Unit *unit, +Model *SkillType::getAnimation(double animProgress, const Unit *unit, int *lastAnimationIndex, int *animationRandomCycleCount) const { int modelIndex = 0; //printf("Count [%d] animProgress = [%f] for skill [%s] animationRandomCycleCount = %d\n",animations.size(),animProgress,name.c_str(),*animationRandomCycleCount); @@ -665,7 +665,7 @@ void SkillType::saveGame(XmlNode *rootNode) { // // SoundContainer sounds; // float soundStartTime; - skillTypeNode->addAttribute("soundStartTime",floatToStr(soundStartTime,16), mapTagReplacements); + skillTypeNode->addAttribute("soundStartTime",doubleToStr(soundStartTime,16), mapTagReplacements); // RandomGen random; skillTypeNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements); // AttackBoost attackBoost; @@ -897,7 +897,7 @@ void AttackSkillType::saveGame(XmlNode *rootNode) { attackFieldsNode->addAttribute("value",intToStr(attackFields[i]), mapTagReplacements); } // float attackStartTime; - attackSkillTypeNode->addAttribute("attackStartTime",floatToStr(attackStartTime,16), mapTagReplacements); + attackSkillTypeNode->addAttribute("attackStartTime",doubleToStr(attackStartTime,16), mapTagReplacements); // string spawnUnit; attackSkillTypeNode->addAttribute("spawnUnit",spawnUnit, mapTagReplacements); // int spawnUnitcount; @@ -1220,7 +1220,7 @@ void FogOfWarSkillType::saveGame(XmlNode *rootNode) { fogSkillTypeNode->addAttribute("enable-fog",intToStr(fowEnable), mapTagReplacements); fogSkillTypeNode->addAttribute("apply-team",intToStr(applyToTeam), mapTagReplacements); - fogSkillTypeNode->addAttribute("duration",floatToStr(durationTime,16), mapTagReplacements); + fogSkillTypeNode->addAttribute("duration",doubleToStr(durationTime,16), mapTagReplacements); } // ===================================================== diff --git a/source/glest_game/types/skill_type.h b/source/glest_game/types/skill_type.h index e9e71ea5..bdfe4d64 100644 --- a/source/glest_game/types/skill_type.h +++ b/source/glest_game/types/skill_type.h @@ -137,7 +137,7 @@ protected: vector animationAttributes; SoundContainer sounds; - float soundStartTime; + double soundStartTime; RandomGen random; AttackBoost attackBoost; @@ -175,9 +175,9 @@ public: int getHpCost() const {return hpCost;} int getSpeed() const {return speed;} int getAnimSpeed() const {return animSpeed;} - Model *getAnimation(float animProgress=0, const Unit *unit=NULL, int *lastAnimationIndex=NULL, int *animationRandomCycleCount=NULL) const; + Model *getAnimation(double animProgress=0, const Unit *unit=NULL, int *lastAnimationIndex=NULL, int *animationRandomCycleCount=NULL) const; StaticSound *getSound() const {return sounds.getRandSound();} - float getSoundStartTime() const {return soundStartTime;} + double getSoundStartTime() const {return soundStartTime;} bool isAttackBoostEnabled() const { return attackBoost.enabled; } const AttackBoost * getAttackBoost() const { return &attackBoost; } @@ -226,7 +226,7 @@ private: int attackRange; const AttackType *attackType; bool attackFields[fieldCount]; - float attackStartTime; + double attackStartTime; string spawnUnit; int spawnUnitcount; @@ -253,7 +253,7 @@ public: inline int getAttackRange() const {return attackRange;} inline const AttackType *getAttackType() const {return attackType;} inline bool getAttackField(Field field) const {return attackFields[field];} - inline float getAttackStartTime() const {return attackStartTime;} + inline double getAttackStartTime() const {return attackStartTime;} inline string getSpawnUnit() const {return spawnUnit;} inline int getSpawnUnitCount() const {return spawnUnitcount;} @@ -419,13 +419,13 @@ class FogOfWarSkillType: public SkillType { private: bool fowEnable; bool applyToTeam; - float durationTime; + double durationTime; public: FogOfWarSkillType(); bool getFowEnable() const {return fowEnable;} bool getApplyToTeam() const {return applyToTeam;} - float getDurationTime() const {return durationTime;} + double getDurationTime() const {return durationTime;} virtual void load(const XmlNode *sn, const XmlNode *attackBoostsNode, const string &dir, const TechTree *tt, const FactionType *ft, std::map > > &loadedFileList, diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 251279e6..418457ef 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -137,9 +137,10 @@ bool UnitUpdater::updateUnit(Unit *unit) { //start attack particle system if(unit->getCurrSkill()->getClass() == scAttack) { const AttackSkillType *ast= static_cast(unit->getCurrSkill()); - double attackStartTime = truncateDecimal(ast->getAttackStartTime()); - double lastAnimProgress = truncateDecimal(unit->getLastAnimProgressAsFloat()); - double animProgress = truncateDecimal(attackStartTime < unit->getAnimProgressAsFloat()); + + double attackStartTime = truncateDecimal(ast->getAttackStartTime(),16); + double lastAnimProgress = truncateDecimal(unit->getLastAnimProgressAsFloat(),16); + double animProgress = truncateDecimal(unit->getAnimProgressAsFloat(),16); bool startAttackParticleSystemNow = (attackStartTime >= lastAnimProgress && attackStartTime < animProgress); char szBuf[8096]="";