diff options
| author | silinoron <none@none> | 2010-08-22 12:39:39 -0700 |
|---|---|---|
| committer | silinoron <none@none> | 2010-08-22 12:39:39 -0700 |
| commit | 5cbae843d58431237a270a0960a5d0c324d5cb1e (patch) | |
| tree | edac1313ed45bb5ae3a6375043ef6b08d6490bf6 /src/server/game/Movement | |
| parent | 399e35f8f53aeabcda8af513a37bb855340663e5 (diff) | |
Core/Game: fix all warnings related to converting doubles and floats.
--HG--
branch : trunk
Diffstat (limited to 'src/server/game/Movement')
6 files changed, 77 insertions, 79 deletions
diff --git a/src/server/game/Movement/DestinationHolderImp.h b/src/server/game/Movement/DestinationHolderImp.h index 95ff90a6a2a..851f9ea0ff6 100644 --- a/src/server/game/Movement/DestinationHolderImp.h +++ b/src/server/game/Movement/DestinationHolderImp.h @@ -156,9 +156,9 @@ DestinationHolder<TRAVELLER>::GetLocationNow(const Map * map, float &x, float &y else if (HasDestination()) { double percent_passed = (double)i_timeElapsed / (double)i_totalTravelTime; - const float distanceX = ((i_destX - i_fromX) * percent_passed); - const float distanceY = ((i_destY - i_fromY) * percent_passed); - const float distanceZ = ((i_destZ - i_fromZ) * percent_passed); + const float distanceX = (float)((i_destX - i_fromX) * percent_passed); + const float distanceY = (float)((i_destY - i_fromY) * percent_passed); + const float distanceZ = (float)((i_destZ - i_fromZ) * percent_passed); x = i_fromX + distanceX; y = i_fromY + distanceY; float z2 = i_fromZ + distanceZ; @@ -207,9 +207,9 @@ DestinationHolder<TRAVELLER>::GetLocationNowNoMicroMovement(float &x, float &y, else { double percent_passed = (double)i_timeElapsed / (double)i_totalTravelTime; - x = i_fromX + ((i_destX - i_fromX) * percent_passed); - y = i_fromY + ((i_destY - i_fromY) * percent_passed); - z = i_fromZ + ((i_destZ - i_fromZ) * percent_passed); + x = (float)(i_fromX + ((i_destX - i_fromX) * percent_passed)); + y = (float)(i_fromY + ((i_destY - i_fromY) * percent_passed)); + z = (float)(i_fromZ + ((i_destZ - i_fromZ) * percent_passed)); } } diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 07ade6ac101..5094589f921 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -325,7 +325,7 @@ void MotionMaster::MoveJumpTo(float angle, float speedXY, float speedZ) void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ) { uint32 moveFlag = SPLINEFLAG_TRAJECTORY | SPLINEFLAG_WALKING; - uint32 time = speedZ * 100; + uint32 time = uint32(speedZ * 100); i_owner->addUnitState(UNIT_STAT_CHARGING | UNIT_STAT_JUMPING); i_owner->m_TempSpeed = speedXY; diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp index 62f5f53ad96..6abf3320d13 100644 --- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp @@ -49,8 +49,8 @@ ConfusedMovementGenerator<T>::Initialize(T &unit) for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx) { - float wanderX = x + wander_distance*rand_norm() - wander_distance/2; - float wanderY = y + wander_distance*rand_norm() - wander_distance/2; + float wanderX = x + wander_distance*(float)rand_norm() - wander_distance/2; + float wanderY = y + wander_distance*(float)rand_norm() - wander_distance/2; Trinity::NormalizeMapCoord(wanderX); Trinity::NormalizeMapCoord(wanderY); diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp index ca98c18ebb7..138469477db 100644 --- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp @@ -101,59 +101,59 @@ FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float &z) distance /= 4; break; case 3: - angle = i_cur_angle + M_PI/4.0f; + angle = i_cur_angle + static_cast<float>(M_PI/4); break; case 4: - angle = i_cur_angle - M_PI/4.0f; + angle = i_cur_angle - static_cast<float>(M_PI/4); break; case 5: - angle = i_cur_angle + M_PI/4.0f; + angle = i_cur_angle + static_cast<float>(M_PI/4); distance /= 2; break; case 6: - angle = i_cur_angle - M_PI/4.0f; + angle = i_cur_angle - static_cast<float>(M_PI/4); distance /= 2; break; case 7: - angle = i_cur_angle + M_PI/2.0f; + angle = i_cur_angle + static_cast<float>(M_PI/2); break; case 8: - angle = i_cur_angle - M_PI/2.0f; + angle = i_cur_angle - static_cast<float>(M_PI/2); break; case 9: - angle = i_cur_angle + M_PI/2.0f; + angle = i_cur_angle + static_cast<float>(M_PI/2); distance /= 2; break; case 10: - angle = i_cur_angle - M_PI/2.0f; + angle = i_cur_angle - static_cast<float>(M_PI/2); distance /= 2; break; case 11: - angle = i_cur_angle + M_PI/4.0f; + angle = i_cur_angle + static_cast<float>(M_PI/4); distance /= 4; break; case 12: - angle = i_cur_angle - M_PI/4.0f; + angle = i_cur_angle - static_cast<float>(M_PI/4); distance /= 4; break; case 13: - angle = i_cur_angle + M_PI/2.0f; + angle = i_cur_angle + static_cast<float>(M_PI/2); distance /= 4; break; case 14: - angle = i_cur_angle - M_PI/2.0f; + angle = i_cur_angle - static_cast<float>(M_PI/2); distance /= 4; break; case 15: - angle = i_cur_angle + M_PI*3/4.0f; + angle = i_cur_angle + static_cast<float>(M_PI*3/4.0f); distance /= 2; break; case 16: - angle = i_cur_angle - M_PI*3/4.0f; + angle = i_cur_angle - static_cast<float>(M_PI*3/4.0f); distance /= 2; break; case 17: - angle = i_cur_angle + M_PI; + angle = i_cur_angle + static_cast<float>(M_PI); distance /= 2; break; } @@ -183,8 +183,8 @@ FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float &z) if (!(new_z - z) || distance / fabs(new_z - z) > 1.0f) { - float new_z_left = _map->GetHeight(temp_x + 1.0f*cos(angle+M_PI/2),temp_y + 1.0f*sin(angle+M_PI/2),z,true); - float new_z_right = _map->GetHeight(temp_x + 1.0f*cos(angle-M_PI/2),temp_y + 1.0f*sin(angle-M_PI/2),z,true); + float new_z_left = _map->GetHeight(temp_x + (float)(cos(angle+M_PI/2)),temp_y + (float)(sin(angle+M_PI/2)),z,true); + float new_z_right = _map->GetHeight(temp_x + (float)(cos(angle-M_PI/2)),temp_y + (float)(sin(angle-M_PI/2)),z,true); if (fabs(new_z_left - new_z) < 1.2f && fabs(new_z_right - new_z) < 1.2f) { x = temp_x; @@ -249,13 +249,13 @@ FleeingMovementGenerator<T>::_setMoveData(T &owner) else { cur_dist = cur_dist_xyz; - angle_to_caster = owner.GetAngle(i_caster_x, i_caster_y) + M_PI; + angle_to_caster = owner.GetAngle(i_caster_x, i_caster_y) + static_cast<float>(M_PI); } } else { cur_dist = cur_dist_xyz; - angle_to_caster = owner.GetAngle(i_caster_x, i_caster_y) + M_PI; + angle_to_caster = owner.GetAngle(i_caster_x, i_caster_y) + static_cast<float>(M_PI); } // if we too close may use 'path-finding' else just stop @@ -266,24 +266,24 @@ FleeingMovementGenerator<T>::_setMoveData(T &owner) if (i_cur_angle == 0.0f && i_last_distance_from_caster == 0.0f) //just started, first time { - angle = rand_norm()*(1.0f - cur_dist/MIN_QUIET_DISTANCE) * M_PI/3 + rand_norm()*M_PI*2/3; + angle = (float)rand_norm()*(1.0f - cur_dist/MIN_QUIET_DISTANCE) * static_cast<float>(M_PI/3) + (float)rand_norm()*static_cast<float>(M_PI*2/3); i_to_distance_from_caster = MIN_QUIET_DISTANCE; i_only_forward = true; } else if (cur_dist < MIN_QUIET_DISTANCE) { - angle = M_PI/6 + rand_norm()*M_PI*2/3; - i_to_distance_from_caster = cur_dist*2/3 + rand_norm()*(MIN_QUIET_DISTANCE - cur_dist*2/3); + angle = static_cast<float>(M_PI/6) + (float)rand_norm()*static_cast<float>(M_PI*2/3); + i_to_distance_from_caster = cur_dist*2/3 + (float)rand_norm()*(MIN_QUIET_DISTANCE - cur_dist*2/3); } else if (cur_dist > MAX_QUIET_DISTANCE) { - angle = rand_norm()*M_PI/3 + M_PI*2/3; - i_to_distance_from_caster = MIN_QUIET_DISTANCE + 2.5f + rand_norm()*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE - 2.5f); + angle = (float)rand_norm()*static_cast<float>(M_PI/3) + static_cast<float>(M_PI*2/3); + i_to_distance_from_caster = MIN_QUIET_DISTANCE + 2.5f + (float)rand_norm()*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE - 2.5f); } else { - angle = rand_norm()*M_PI; - i_to_distance_from_caster = MIN_QUIET_DISTANCE + 2.5f + rand_norm()*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE - 2.5f); + angle = (float)rand_norm()*static_cast<float>(M_PI); + i_to_distance_from_caster = MIN_QUIET_DISTANCE + 2.5f + (float)rand_norm()*(MAX_QUIET_DISTANCE - MIN_QUIET_DISTANCE - 2.5f); } int8 sign = rand_norm() > 0.5f ? 1 : -1; diff --git a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp index 54d9ad16f7d..b1c078f78f1 100644 --- a/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/IdleMovementGenerator.cpp @@ -57,13 +57,13 @@ bool RotateMovementGenerator::Update(Unit& owner, const uint32& diff) float angle = owner.GetOrientation(); if (m_direction == ROTATE_DIRECTION_LEFT) { - angle += (float)diff * M_PI * 2 / m_maxDuration; - while (angle >= M_PI * 2) angle -= M_PI * 2; + angle += (float)diff * static_cast<float>(M_PI * 2) / m_maxDuration; + while (angle >= static_cast<float>(M_PI * 2)) angle -= static_cast<float>(M_PI * 2); } else { - angle -= (float)diff * M_PI * 2 / m_maxDuration; - while (angle < 0) angle += M_PI * 2; + angle -= (float)diff * static_cast<float>(M_PI * 2) / m_maxDuration; + while (angle < 0) angle += static_cast<float>(M_PI * 2); } owner.SetOrientation(angle); owner.SendMovementFlagUpdate(); // this is a hack. we do not have anything correct to send in the beginning diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp index 719adedb5c6..edf2838dd90 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp @@ -63,57 +63,55 @@ RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature) for (uint32 i = 0; ; ++i) { + const float angle = (float)rand_norm()*static_cast<float>(M_PI*2); + const float range = (float)rand_norm()*wander_distance; + const float distanceX = range * cos(angle); + const float distanceY = range * sin(angle); - const float angle = rand_norm()*(M_PI*2); - const float range = rand_norm()*wander_distance; - const float distanceX = range * cos(angle); - const float distanceY = range * sin(angle); + nx = X + distanceX; + ny = Y + distanceY; - nx = X + distanceX; - ny = Y + distanceY; + // prevent invalid coordinates generation + Trinity::NormalizeMapCoord(nx); + Trinity::NormalizeMapCoord(ny); - // prevent invalid coordinates generation - Trinity::NormalizeMapCoord(nx); - Trinity::NormalizeMapCoord(ny); + dist = (nx - X)*(nx - X) + (ny - Y)*(ny - Y); - dist = (nx - X)*(nx - X) + (ny - Y)*(ny - Y); - - if (i == 5) - { - nz = Z; - break; - } - - if (is_air_ok) // 3D system above ground and above water (flying mode) - { - const float distanceZ = rand_norm() * sqrtf(dist)/2; // Limit height change - nz = Z + distanceZ; - float tz = map->GetHeight(nx, ny, nz-2.0f, false); // Map check only, vmap needed here but need to alter vmaps checks for height. - float wz = map->GetWaterLevel(nx, ny); - if (tz >= nz || wz >= nz) - continue; // Problem here, we must fly above the ground and water, not under. Let's try on next tick - } - //else if (is_water_ok) // 3D system under water and above ground (swimming mode) - else // 2D only - { - dist = dist >= 100.0f ? 10.0f : sqrtf(dist); // 10.0 is the max that vmap high can check (MAX_CAN_FALL_DISTANCE) + if (i == 5) + { + nz = Z; + break; + } - // The fastest way to get an accurate result 90% of the time. - // Better result can be obtained like 99% accuracy with a ray light, but the cost is too high and the code is too long. - nz = map->GetHeight(nx,ny,Z+dist-2.0f,false); // Map check - if (fabs(nz-Z)>dist) + if (is_air_ok) // 3D system above ground and above water (flying mode) + { + const float distanceZ = (float)(rand_norm()) * sqrtf(dist)/2; // Limit height change + nz = Z + distanceZ; + float tz = map->GetHeight(nx, ny, nz-2.0f, false); // Map check only, vmap needed here but need to alter vmaps checks for height. + float wz = map->GetWaterLevel(nx, ny); + if (tz >= nz || wz >= nz) + continue; // Problem here, we must fly above the ground and water, not under. Let's try on next tick + } + //else if (is_water_ok) // 3D system under water and above ground (swimming mode) + else // 2D only { - nz = map->GetHeight(nx,ny,Z-2.0f,true); // Vmap Horizontal or above + dist = dist >= 100.0f ? 10.0f : sqrtf(dist); // 10.0 is the max that vmap high can check (MAX_CAN_FALL_DISTANCE) + + // The fastest way to get an accurate result 90% of the time. + // Better result can be obtained like 99% accuracy with a ray light, but the cost is too high and the code is too long. + nz = map->GetHeight(nx,ny,Z+dist-2.0f,false); // Map check if (fabs(nz-Z)>dist) { - nz = map->GetHeight(nx,ny,Z+dist-2.0f,true); // Vmap Higher + nz = map->GetHeight(nx,ny,Z-2.0f,true); // Vmap Horizontal or above if (fabs(nz-Z)>dist) - continue; // let's forget this bad coords where a z cannot be find and retry at next tick + { + nz = map->GetHeight(nx,ny,Z+dist-2.0f,true); // Vmap Higher + if (fabs(nz-Z)>dist) + continue; // let's forget this bad coords where a z cannot be find and retry at next tick + } } } - } - - break; + break; } Traveller<Creature> traveller(creature); |
