Converted percentages to use int instead of float

May help prevent floating point calculation errors in multiplayer.
This commit is contained in:
Mike Hoffert 2014-07-19 18:59:11 -06:00
parent 0a68e3a6a4
commit ef0cf706b3
3 changed files with 8 additions and 8 deletions

View File

@ -1959,7 +1959,7 @@ void Unit::born(const CommandType *ct) {
this->hp= type->getStartHpValue(); this->hp= type->getStartHpValue();
} }
else { else {
this->hp= type->getStartHpPercentage() * type->getTotalMaxHp(&totalUpgrade); this->hp= type->getTotalMaxHp(&totalUpgrade) * 100 / type->getStartHpPercentage();
} }
if(original_hp != this->hp) { if(original_hp != this->hp) {
@ -1975,7 +1975,7 @@ void Unit::born(const CommandType *ct) {
this->ep= type->getStartEpValue(); this->ep= type->getStartEpValue();
} }
else { else {
this->ep= type->getStartEpPercentage() * type->getTotalMaxEp(&totalUpgrade); this->ep= type->getTotalMaxEp(&totalUpgrade) * 100 / type->getStartEpPercentage();
} }
} }

View File

@ -271,7 +271,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree,
//startHpPercentage -- the *relative* value to use for starting HP //startHpPercentage -- the *relative* value to use for starting HP
if(parametersNode->getChild("max-hp")->hasAttribute("start-percentage")) { if(parametersNode->getChild("max-hp")->hasAttribute("start-percentage")) {
startHpPercentage= parametersNode->getChild("max-hp")->getAttribute("start-percentage")->getFloatValue(); startHpPercentage= parametersNode->getChild("max-hp")->getAttribute("start-percentage")->getIntValue();
startHpType= stPercentage; startHpType= stPercentage;
} }
@ -301,7 +301,7 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree,
//startEpPercentage -- the *relative* value to use for starting EP //startEpPercentage -- the *relative* value to use for starting EP
if(parametersNode->getChild("max-ep")->hasAttribute("start-percentage")) { if(parametersNode->getChild("max-ep")->hasAttribute("start-percentage")) {
startEpPercentage= parametersNode->getChild("max-ep")->getAttribute("start-percentage")->getFloatValue(); startEpPercentage= parametersNode->getChild("max-ep")->getAttribute("start-percentage")->getIntValue();
startEpType= stPercentage; startEpType= stPercentage;
} }
addItemToVault(&(this->startEpPercentage),this->startEpPercentage); addItemToVault(&(this->startEpPercentage),this->startEpPercentage);

View File

@ -110,12 +110,12 @@ private:
int id; int id;
int maxHp; int maxHp;
int startHpValue; int startHpValue;
double startHpPercentage; int startHpPercentage;
StartType startHpType; StartType startHpType;
int hpRegeneration; int hpRegeneration;
int maxEp; int maxEp;
int startEpValue; int startEpValue;
double startEpPercentage; int startEpPercentage;
StartType startEpType; StartType startEpType;
int epRegeneration; int epRegeneration;
int maxUnitCount; int maxUnitCount;
@ -190,12 +190,12 @@ public:
inline int getMaxHp() const {return maxHp;} inline int getMaxHp() const {return maxHp;}
inline int getHpRegeneration() const {return hpRegeneration;} inline int getHpRegeneration() const {return hpRegeneration;}
inline int getStartHpValue() const {return startHpValue;} inline int getStartHpValue() const {return startHpValue;}
inline double getStartHpPercentage() const {return startHpPercentage;} inline int getStartHpPercentage() const {return startHpPercentage;}
inline StartType getStartHpType() const {return startHpType;} inline StartType getStartHpType() const {return startHpType;}
inline int getMaxEp() const {return maxEp;} inline int getMaxEp() const {return maxEp;}
inline int getEpRegeneration() const {return epRegeneration;} inline int getEpRegeneration() const {return epRegeneration;}
inline int getStartEpValue() const {return startEpValue;} inline int getStartEpValue() const {return startEpValue;}
inline double getStartEpPercentage() const {return startEpPercentage;} inline int getStartEpPercentage() const {return startEpPercentage;}
inline StartType getStartEpType() const {return startEpType;} inline StartType getStartEpType() const {return startEpType;}
inline int getMaxUnitCount() const {return maxUnitCount;} inline int getMaxUnitCount() const {return maxUnitCount;}
inline bool getField(Field field) const {return fields[field];} inline bool getField(Field field) const {return fields[field];}