diff --git a/source/glest_game/graphics/particle_type.h b/source/glest_game/graphics/particle_type.h index 2c4605f7..0ed38bbd 100644 --- a/source/glest_game/graphics/particle_type.h +++ b/source/glest_game/graphics/particle_type.h @@ -57,16 +57,16 @@ protected: string type; Texture2D *texture; Model *model; - float modelCycle; + double modelCycle; string primitive; Vec3d offset; Vec4f color; Vec4f colorNoEnergy; - float size; - float sizeNoEnergy; - float speed; - float gravity; - float emissionRate; + double size; + double sizeNoEnergy; + double speed; + double gravity; + double emissionRate; int energyMax; int energyVar; string mode; @@ -123,9 +123,9 @@ protected: class ParticleSystemTypeProjectile: public ParticleSystemType{ private: string trajectory; - float trajectorySpeed; - float trajectoryScale; - float trajectoryFrequency; + double trajectorySpeed; + double trajectoryScale; + double trajectoryFrequency; public: ParticleSystemTypeProjectile(); @@ -153,11 +153,11 @@ public: virtual void saveGame(XmlNode *rootNode); private: - float emissionRateFade; - float verticalSpreadA; - float verticalSpreadB; - float horizontalSpreadA; - float horizontalSpreadB; + double emissionRateFade; + double verticalSpreadA; + double verticalSpreadB; + double horizontalSpreadA; + double horizontalSpreadB; }; }}//end namespace diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 8c3d7312..32ea8c9d 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -1267,12 +1267,14 @@ void Unit::setTargetPos(const Vec2i &targetPos) { Vec2i relPos= targetPos - pos; //map->clampPos(relPos); - Vec2f relPosf= Vec2f((float)relPos.x, (float)relPos.y); + Vec2d relPosf= Vec2d((double)relPos.x, (double)relPos.y); #ifdef USE_STREFLOP targetRotation= radToDeg(streflop::atan2(static_cast(relPosf.x), static_cast(relPosf.y))); #else targetRotation= radToDeg(atan2(relPosf.x, relPosf.y)); #endif + targetRotation = truncateDecimal(targetRotation,16); + targetRef= NULL; this->targetPos= targetPos; @@ -1439,15 +1441,21 @@ Vec3d Unit::getVectorFlat(const Vec2i &lastPosValue, const Vec2i &curPosValue) c double y2= computeHeight(curPosValue); if(currSkill->getClass() == scMove) { - v.x= lastPosValue.x + getProgressAsFloat() * (curPosValue.x - lastPosValue.x); - v.z= lastPosValue.y + getProgressAsFloat() * (curPosValue.y - lastPosValue.y); - v.y= y1 + getProgressAsFloat() * (y2-y1); + double progressAsDouble = getProgressAsFloat(); + + v.x= lastPosValue.x + progressAsDouble * (curPosValue.x - lastPosValue.x); + v.z= lastPosValue.y + progressAsDouble * (curPosValue.y - lastPosValue.y); + v.y= y1 + progressAsDouble * (y2-y1); } else { v.x= static_cast(curPosValue.x); v.z= static_cast(curPosValue.y); v.y= y2; } + v.x = truncateDecimal(v.x,16); + v.y = truncateDecimal(v.y,16); + v.z = truncateDecimal(v.z,16); + v.x += type->getSize() / 2.f - 0.5f; v.z += type->getSize() / 2.f - 0.5f; @@ -3349,9 +3357,11 @@ double Unit::computeHeight(const Vec2i &pos) const { } double height= map->getCell(pos)->getHeight(); + height = truncateDecimal(height,16); if(currField == fAir) { const double airHeight=game->getWorld()->getTileset()->getAirHeight(); + height += airHeight; height = truncateDecimal(height,16); @@ -3381,12 +3391,13 @@ void Unit::updateTarget(){ //update target pos targetPos= target->getCellPos(); Vec2i relPos= targetPos - pos; - Vec2d relPosf= Vec2d((float)relPos.x, (float)relPos.y); + Vec2d relPosf= Vec2d((double)relPos.x, (double)relPos.y); #ifdef USE_STREFLOP targetRotation= radToDeg(streflop::atan2(static_cast(relPosf.x), static_cast(relPosf.y))); #else targetRotation= radToDeg(atan2(relPosf.x, relPosf.y)); #endif + targetRotation = truncateDecimal(targetRotation,16); //update target vec targetVec= target->getCurrVector(); diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index c1b403b2..978309bd 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -119,7 +119,7 @@ bool UnitUpdater::updateUnit(Unit *unit) { //play skill sound const SkillType *currSkill= unit->getCurrSkill(); if(currSkill->getSound() != NULL) { - float soundStartTime= currSkill->getSoundStartTime(); + double soundStartTime= currSkill->getSoundStartTime(); if(soundStartTime >= unit->getLastAnimProgressAsFloat() && soundStartTime < unit->getAnimProgressAsFloat()) { if(map->getSurfaceCell(Map::toSurfCoords(unit->getPos()))->isVisible(world->getThisTeamIndex()) || (game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true)) { @@ -2817,7 +2817,7 @@ void UnitUpdater::saveGame(XmlNode *rootNode) { // RandomGen random; //unitupdaterNode->addAttribute("random",intToStr(random.getLastNumber()), mapTagReplacements); // float attackWarnRange; - unitupdaterNode->addAttribute("attackWarnRange",floatToStr(attackWarnRange,16), mapTagReplacements); + unitupdaterNode->addAttribute("attackWarnRange",doubleToStr(attackWarnRange,16), mapTagReplacements); // AttackWarnings attackWarnings; // // Mutex mutexUnitRangeCellsLookupItemCache; diff --git a/source/glest_game/world/unit_updater.h b/source/glest_game/world/unit_updater.h index 807ebe83..ea49f164 100644 --- a/source/glest_game/world/unit_updater.h +++ b/source/glest_game/world/unit_updater.h @@ -81,7 +81,7 @@ private: Game *game; //RandomGen random; Mutex mutexAttackWarnings; - float attackWarnRange; + double attackWarnRange; AttackWarnings attackWarnings; Mutex mutexUnitRangeCellsLookupItemCache;