Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Core: Fix warnings #5870

Merged
merged 1 commit into from

2 participants

@Elron103

Hey there,

compiling a new TrinityCore version, I noticed several compiler warnings.

Versions

  • TrinityCore: be871b2 + several custom modifications
  • CMake for Windows: 2.8.6
  • Compiler: Microsoft Visual Studio C++ Express 2008

Description / Fix Explanation

The most important compile warnings have been introduced in revision:
72675d5

The variable "uint16 index = 0;" is passed to a function, which expects an uint8 variable. This causes the compile warning:

11>........\src\server\game\Entities\Player\Player.cpp(18482) : warning C4244: 'argument' : conversion from 'uint16' to 'const uint8', possible loss of data

It is safe to change the variable type to uint8 because the maximum value of index will be 62. The if ... else structure of the code keeps the maximum number that low.

There are several other warnings, which are mostly caused by a conversion of floats => ints or times => ints. It is always safe to force the conversion there.

As it seems, the warnings are not fixed until now.

Original source: #4818

@Elron103 Elron103 referenced this pull request
Closed

[Fix] Compile warnings #4818

@leak leak merged commit e37a4e5 into TrinityCore:master
@eilo eilo referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2012
  1. @Elron103

    Core: Fix warnings

    Elron103 authored
This page is out of date. Refresh to see the latest.
View
2  src/server/game/Entities/Pet/Pet.cpp
@@ -912,7 +912,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetCreateHealth(40*petlevel);
SetCreateMana(28 + 10*petlevel);
}
- SetBonusDamage(m_owner->SpellBaseDamageBonus(SPELL_SCHOOL_MASK_FIRE) * 0.5f);
+ SetBonusDamage(int32(m_owner->SpellBaseDamageBonus(SPELL_SCHOOL_MASK_FIRE) * 0.5f));
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 4 - petlevel));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 4 + petlevel));
break;
View
10 src/server/game/Entities/Player/Player.cpp
@@ -18507,7 +18507,7 @@ void Player::SaveToDB(bool create /*=false*/)
outDebugValues();
PreparedStatement* stmt = NULL;
- uint16 index = 0;
+ uint8 index = 0;
if (create)
{
@@ -18546,12 +18546,12 @@ void Player::SaveToDB(bool create /*=false*/)
//save, far from tavern/city
//save, but in tavern/city
stmt->setUInt32(index++, m_resetTalentsCost);
- stmt->setUInt32(index++, m_resetTalentsTime);
+ stmt->setUInt32(index++, uint32(m_resetTalentsTime));
stmt->setUInt16(index++, (uint16)m_ExtraFlags);
stmt->setUInt8(index++, m_stableSlots);
stmt->setUInt16(index++, (uint16)m_atLoginFlags);
stmt->setUInt16(index++, GetZoneId());
- stmt->setUInt32(index++, m_deathExpireTime);
+ stmt->setUInt32(index++, uint32(m_deathExpireTime));
ss.str("");
ss << m_taxi.SaveTaxiDestinationsToString();
@@ -18657,12 +18657,12 @@ void Player::SaveToDB(bool create /*=false*/)
//save, far from tavern/city
//save, but in tavern/city
stmt->setUInt32(index++, m_resetTalentsCost);
- stmt->setUInt32(index++, m_resetTalentsTime);
+ stmt->setUInt32(index++, uint32(m_resetTalentsTime));
stmt->setUInt16(index++, (uint16)m_ExtraFlags);
stmt->setUInt8(index++, m_stableSlots);
stmt->setUInt16(index++, (uint16)m_atLoginFlags);
stmt->setUInt16(index++, GetZoneId());
- stmt->setUInt32(index++, m_deathExpireTime);
+ stmt->setUInt32(index++, uint32(m_deathExpireTime));
ss.str("");
ss << m_taxi.SaveTaxiDestinationsToString();
View
2  src/server/game/Instances/InstanceSaveMgr.cpp
@@ -580,7 +580,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
if (period < DAY)
period = DAY;
- uint32 next_reset = ((resetTime + MINUTE) / DAY * DAY) + period + diff;
+ uint32 next_reset = uint32(((resetTime + MINUTE) / DAY * DAY) + period + diff);
SetResetTimeFor(mapid, difficulty, next_reset);
ScheduleReset(true, time_t(next_reset-3600), InstResetEvent(1, mapid, difficulty, 0));
View
2  src/server/scripts/Outland/blades_edge_mountains.cpp
@@ -774,7 +774,7 @@ class npc_simon_bunny : public CreatureScript
colorSequence.clear();
playableSequence.clear();
playerSequence.clear();
- me->SetFloatValue(OBJECT_FIELD_SCALE_X, large ? 2 : 1);
+ me->SetFloatValue(OBJECT_FIELD_SCALE_X, large ? 2.0f : 1.0f);
std::list<WorldObject*> ClusterList;
Trinity::AllWorldObjectsInRange objects(me, searchDistance);
Something went wrong with that request. Please try again.