attempt to fix attack particle calculation for oos issue

This commit is contained in:
Mark Vejvoda 2013-09-26 19:36:24 +00:00
parent 37c2ace11a
commit a73cf8470b
3 changed files with 16 additions and 15 deletions

View File

@ -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);
}
// =====================================================

View File

@ -137,7 +137,7 @@ protected:
vector<AnimationAttributes> 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<string,vector<pair<string, string> > > &loadedFileList,

View File

@ -137,9 +137,10 @@ bool UnitUpdater::updateUnit(Unit *unit) {
//start attack particle system
if(unit->getCurrSkill()->getClass() == scAttack) {
const AttackSkillType *ast= static_cast<const AttackSkillType*>(unit->getCurrSkill());
double attackStartTime = truncateDecimal<double>(ast->getAttackStartTime());
double lastAnimProgress = truncateDecimal<double>(unit->getLastAnimProgressAsFloat());
double animProgress = truncateDecimal<double>(attackStartTime < unit->getAnimProgressAsFloat());
double attackStartTime = truncateDecimal<double>(ast->getAttackStartTime(),16);
double lastAnimProgress = truncateDecimal<double>(unit->getLastAnimProgressAsFloat(),16);
double animProgress = truncateDecimal<double>(unit->getAnimProgressAsFloat(),16);
bool startAttackParticleSystemNow = (attackStartTime >= lastAnimProgress && attackStartTime < animProgress);
char szBuf[8096]="";