diff options
author | Shauren <shauren.trinity@gmail.com> | 2017-06-07 17:23:50 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2017-06-07 17:23:50 +0200 |
commit | 4226eb2ea56a13f1e499b80e51cb73748cff82a1 (patch) | |
tree | 3cf644eaebb18b2426583c948d163d14176a220b | |
parent | 7e9a0414708ed1f9373c4c0e87ade501d3f7bc98 (diff) |
Core/Misc: Some /W4 warning fixes
-rw-r--r-- | src/common/Cryptography/SHA256.cpp | 4 | ||||
-rw-r--r-- | src/common/Cryptography/SHA256.h | 8 | ||||
-rw-r--r-- | src/common/DataStores/DB2FileLoader.cpp | 4 | ||||
-rw-r--r-- | src/common/Utilities/EventMap.cpp | 4 | ||||
-rw-r--r-- | src/common/Utilities/EventMap.h | 4 | ||||
-rw-r--r-- | src/common/Utilities/Random.cpp | 4 | ||||
-rw-r--r-- | src/common/Utilities/Util.cpp | 2 | ||||
-rw-r--r-- | src/server/game/DataStores/DB2Stores.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 4 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Vehicle/Vehicle.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Grids/Notifiers/GridNotifiers.h | 2 | ||||
-rw-r--r-- | src/server/game/Miscellaneous/SharedDefines.h | 2 | ||||
-rw-r--r-- | src/server/game/Server/Protocol/Opcodes.h | 8 | ||||
-rw-r--r-- | src/server/game/Server/WorldSocket.h | 2 | ||||
-rw-r--r-- | src/server/shared/JSON/ProtobufJSON.cpp | 2 | ||||
-rw-r--r-- | src/server/shared/Realm/RealmList.cpp | 18 |
18 files changed, 38 insertions, 38 deletions
diff --git a/src/common/Cryptography/SHA256.cpp b/src/common/Cryptography/SHA256.cpp index abb254d7f3a..976c9ade2ac 100644 --- a/src/common/Cryptography/SHA256.cpp +++ b/src/common/Cryptography/SHA256.cpp @@ -31,9 +31,9 @@ SHA256Hash::~SHA256Hash() SHA256_Init(&mC); } -void SHA256Hash::UpdateData(const uint8 *dta, int len) +void SHA256Hash::UpdateData(uint8 const* data, size_t len) { - SHA256_Update(&mC, dta, len); + SHA256_Update(&mC, data, len); } void SHA256Hash::UpdateData(const std::string &str) diff --git a/src/common/Cryptography/SHA256.h b/src/common/Cryptography/SHA256.h index 1ad46bba51e..93583eb227d 100644 --- a/src/common/Cryptography/SHA256.h +++ b/src/common/Cryptography/SHA256.h @@ -35,14 +35,14 @@ class TC_COMMON_API SHA256Hash void UpdateBigNumbers(BigNumber* bn0, ...); - void UpdateData(const uint8 *dta, int len); - void UpdateData(const std::string &str); + void UpdateData(uint8 const* data, size_t len); + void UpdateData(std::string const& str); void Initialize(); void Finalize(); - uint8 *GetDigest(void) { return mDigest; } - int GetLength(void) const { return SHA256_DIGEST_LENGTH; } + uint8 *GetDigest() { return mDigest; } + uint32 GetLength() const { return SHA256_DIGEST_LENGTH; } private: SHA256_CTX mC; diff --git a/src/common/DataStores/DB2FileLoader.cpp b/src/common/DataStores/DB2FileLoader.cpp index 0dc9edb19f0..6e2b455f48d 100644 --- a/src/common/DataStores/DB2FileLoader.cpp +++ b/src/common/DataStores/DB2FileLoader.cpp @@ -1125,7 +1125,7 @@ uint32 DB2FileLoaderSparseImpl::RecordGetVarInt(unsigned char const* record, uin uint16 DB2FileLoaderSparseImpl::GetFieldOffset(uint32 field, uint32 arrayIndex) const { - return _fieldAndArrayOffsets[_fieldAndArrayOffsets[field] + arrayIndex]; + return uint16(_fieldAndArrayOffsets[_fieldAndArrayOffsets[field] + arrayIndex]); } uint16 DB2FileLoaderSparseImpl::GetFieldSize(uint32 field) const @@ -1139,7 +1139,7 @@ std::size_t* DB2FileLoaderSparseImpl::RecordCreateDetachedFieldOffsets(std::size if (oldOffsets != _fieldAndArrayOffsets) return oldOffsets; - uint32 size = _loadInfo->Meta->FieldCount + _loadInfo->FieldCount - (!_loadInfo->Meta->HasIndexFieldInData() ? 1 : 0); + std::size_t size = _loadInfo->Meta->FieldCount + _loadInfo->FieldCount - (!_loadInfo->Meta->HasIndexFieldInData() ? 1 : 0); std::size_t* newOffsets = new std::size_t[size]; memcpy(newOffsets, _fieldAndArrayOffsets, size * sizeof(std::size_t)); return newOffsets; diff --git a/src/common/Utilities/EventMap.cpp b/src/common/Utilities/EventMap.cpp index e1c46d0ae65..49d7b5ab7d4 100644 --- a/src/common/Utilities/EventMap.cpp +++ b/src/common/Utilities/EventMap.cpp @@ -33,7 +33,7 @@ void EventMap::SetPhase(uint8 phase) _phase = uint8(1 << (phase - 1)); } -void EventMap::ScheduleEvent(uint32 eventId, Milliseconds const& minTime, Milliseconds const& maxTime, uint32 group /*= 0*/, uint32 phase /*= 0*/) +void EventMap::ScheduleEvent(uint32 eventId, Milliseconds const& minTime, Milliseconds const& maxTime, uint32 group /*= 0*/, uint8 phase /*= 0*/) { ScheduleEvent(eventId, urand(uint32(minTime.count()), uint32(maxTime.count())), group, phase); } @@ -49,7 +49,7 @@ void EventMap::ScheduleEvent(uint32 eventId, uint32 time, uint32 group /*= 0*/, _eventMap.insert(EventStore::value_type(_time + time, eventId)); } -void EventMap::RescheduleEvent(uint32 eventId, Milliseconds const& minTime, Milliseconds const& maxTime, uint32 group /*= 0*/, uint32 phase /*= 0*/) +void EventMap::RescheduleEvent(uint32 eventId, Milliseconds const& minTime, Milliseconds const& maxTime, uint32 group /*= 0*/, uint8 phase /*= 0*/) { RescheduleEvent(eventId, urand(uint32(minTime.count()), uint32(maxTime.count())), group, phase); } diff --git a/src/common/Utilities/EventMap.h b/src/common/Utilities/EventMap.h index 22899ea6b60..249ad3a12ab 100644 --- a/src/common/Utilities/EventMap.h +++ b/src/common/Utilities/EventMap.h @@ -134,7 +134,7 @@ public: * @param group The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group. * @param phase The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases. */ - void ScheduleEvent(uint32 eventId, Milliseconds const& minTime, Milliseconds const& maxTime, uint32 group = 0, uint32 phase = 0); + void ScheduleEvent(uint32 eventId, Milliseconds const& minTime, Milliseconds const& maxTime, uint32 group = 0, uint8 phase = 0); /** * @name ScheduleEvent @@ -168,7 +168,7 @@ public: * @param group The group which the event is associated to. Has to be between 1 and 8. 0 means it has no group. * @param phase The phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases. */ - void RescheduleEvent(uint32 eventId, Milliseconds const& minTime, Milliseconds const& maxTime, uint32 group = 0, uint32 phase = 0); + void RescheduleEvent(uint32 eventId, Milliseconds const& minTime, Milliseconds const& maxTime, uint32 group = 0, uint8 phase = 0); /** * @name RescheduleEvent diff --git a/src/common/Utilities/Random.cpp b/src/common/Utilities/Random.cpp index 890ba1b8fce..e53209cc1cb 100644 --- a/src/common/Utilities/Random.cpp +++ b/src/common/Utilities/Random.cpp @@ -66,8 +66,8 @@ Milliseconds randtime(Milliseconds const& min, Milliseconds const& max) { long long diff = max.count() - min.count(); ASSERT(diff >= 0); - ASSERT(diff <= (uint32)-1); - return min + Milliseconds(urand(0, diff)); + ASSERT(diff <= 0xFFFFFFFF); + return min + Milliseconds(urand(0, uint32(diff))); } uint32 rand32() diff --git a/src/common/Utilities/Util.cpp b/src/common/Utilities/Util.cpp index 05dfee273d8..315f8290c84 100644 --- a/src/common/Utilities/Util.cpp +++ b/src/common/Utilities/Util.cpp @@ -570,6 +570,6 @@ void HexStrToByteArray(std::string const& str, uint8* out, bool reverse /*= fals bool StringToBool(std::string const& str) { std::string lowerStr = str; - std::transform(str.begin(), str.end(), lowerStr.begin(), ::tolower); + std::transform(str.begin(), str.end(), lowerStr.begin(), [](char c) { return char(::tolower(c)); }); return lowerStr == "1" || lowerStr == "true" || lowerStr == "yes"; } diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp index bbecf711f7a..f2a061da326 100644 --- a/src/server/game/DataStores/DB2Stores.cpp +++ b/src/server/game/DataStores/DB2Stores.cpp @@ -1412,7 +1412,7 @@ EmotesTextSoundEntry const* DB2Manager::GetTextSoundEmoteFor(uint32 emote, uint8 if (itr != _emoteTextSounds.end()) return itr->second; - itr = _emoteTextSounds.find(EmotesTextSoundContainer::key_type(emote, race, gender, 0)); + itr = _emoteTextSounds.find(EmotesTextSoundContainer::key_type(emote, race, gender, uint8(0))); if (itr != _emoteTextSounds.end()) return itr->second; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 0396786871c..7e1db91d6c3 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1283,7 +1283,7 @@ float Creature::_GetHealthMod(int32 Rank) } } -void Creature::LowerPlayerDamageReq(uint32 unDamage) +void Creature::LowerPlayerDamageReq(uint64 unDamage) { if (m_PlayerDamageReq) m_PlayerDamageReq > unDamage ? m_PlayerDamageReq -= unDamage : m_PlayerDamageReq = 0; diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 03d69454e2b..c50853724b0 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -295,9 +295,9 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma void SetDisableReputationGain(bool disable) { DisableReputationGain = disable; } bool IsReputationGainDisabled() const { return DisableReputationGain; } bool IsDamageEnoughForLootingAndReward() const { return (m_creatureInfo->flags_extra & CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ) || (m_PlayerDamageReq == 0); } - void LowerPlayerDamageReq(uint32 unDamage); + void LowerPlayerDamageReq(uint64 unDamage); void ResetPlayerDamageReq() { m_PlayerDamageReq = GetHealth() / 2; } - uint32 m_PlayerDamageReq; + uint64 m_PlayerDamageReq; uint32 GetOriginalEntry() const { return m_originalEntry; } void SetOriginalEntry(uint32 entry) { m_originalEntry = entry; } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index f4c50f0144f..22387bfc31b 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -13851,7 +13851,7 @@ void Unit::SendThreatListUpdate() { WorldPackets::Combat::ThreatInfo info; info.UnitGUID = (*itr)->getUnitGuid(); - info.Threat = (*itr)->getThreat() * 100; + info.Threat = int32((*itr)->getThreat() * 100); packet.ThreatList.push_back(info); } SendMessageToSet(packet.Write(), false); diff --git a/src/server/game/Entities/Vehicle/Vehicle.cpp b/src/server/game/Entities/Vehicle/Vehicle.cpp index 6ae0bc5caf2..39a9f6b2f40 100644 --- a/src/server/game/Entities/Vehicle/Vehicle.cpp +++ b/src/server/game/Entities/Vehicle/Vehicle.cpp @@ -35,7 +35,7 @@ Vehicle::Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry) : UsableSeatNum(0), _me(unit), _vehicleInfo(vehInfo), _creatureEntry(creatureEntry), _status(STATUS_NONE), _lastShootPos() { - for (uint32 i = 0; i < MAX_VEHICLE_SEATS; ++i) + for (int8 i = 0; i < MAX_VEHICLE_SEATS; ++i) { if (uint32 seatId = _vehicleInfo->SeatID[i]) if (VehicleSeatEntry const* veSeat = sVehicleSeatStore.LookupEntry(seatId)) diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index ffb0f818eb6..2de7397ac14 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -770,7 +770,7 @@ namespace Trinity private: Unit const* i_obj; float i_range; - uint32 i_hp; + uint64 i_hp; }; class FriendlyCCedInRange diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 3f337a2273f..52d705d1341 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -2253,7 +2253,7 @@ enum Targets TOTAL_SPELL_TARGETS }; -enum SpellMissInfo +enum SpellMissInfo : uint8 { SPELL_MISS_NONE = 0, SPELL_MISS_MISS = 1, diff --git a/src/server/game/Server/Protocol/Opcodes.h b/src/server/game/Server/Protocol/Opcodes.h index 58834139c01..fdf6b9997ce 100644 --- a/src/server/game/Server/Protocol/Opcodes.h +++ b/src/server/game/Server/Protocol/Opcodes.h @@ -35,15 +35,15 @@ enum ConnectionType : int8 CONNECTION_TYPE_DEFAULT = -1 }; -enum OpcodeMisc : uint32 +enum OpcodeMisc : uint16 { MAX_OPCODE = 0x3FFF, NUM_OPCODE_HANDLERS = (MAX_OPCODE + 1), - UNKNOWN_OPCODE = (0xFFFF + 1), + UNKNOWN_OPCODE = 0xFFFF, NULL_OPCODE = 0xBADD }; -enum OpcodeClient : uint32 +enum OpcodeClient : uint16 { CMSG_ACCEPT_GUILD_INVITE = 0x35FB, CMSG_ACCEPT_LEVEL_GRANT = 0x34EF, @@ -759,7 +759,7 @@ enum OpcodeClient : uint32 CMSG_BF_MGR_QUEUE_EXIT_REQUEST = 0xBADD, }; -enum OpcodeServer : uint32 +enum OpcodeServer : uint16 { SMSG_ABORT_NEW_WORLD = 0x25AD, SMSG_ACCOUNT_CRITERIA_UPDATE = 0x2652, diff --git a/src/server/game/Server/WorldSocket.h b/src/server/game/Server/WorldSocket.h index 57a1f05142b..fcee856c93b 100644 --- a/src/server/game/Server/WorldSocket.h +++ b/src/server/game/Server/WorldSocket.h @@ -36,7 +36,7 @@ class EncryptablePacket; class WorldPacket; class WorldSession; enum ConnectionType : int8; -enum OpcodeClient : uint32; +enum OpcodeClient : uint16; namespace WorldPackets { diff --git a/src/server/shared/JSON/ProtobufJSON.cpp b/src/server/shared/JSON/ProtobufJSON.cpp index dcf7dc0436f..540d18c7b3f 100644 --- a/src/server/shared/JSON/ProtobufJSON.cpp +++ b/src/server/shared/JSON/ProtobufJSON.cpp @@ -325,7 +325,7 @@ bool Deserializer::Double(double d) switch (field->cpp_type()) { case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT: - SET_FIELD(message, field, Float, d); + SET_FIELD(message, field, Float, float(d)); break; case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE: SET_FIELD(message, field, Double, d); diff --git a/src/server/shared/Realm/RealmList.cpp b/src/server/shared/Realm/RealmList.cpp index c579b741d8e..66346614278 100644 --- a/src/server/shared/Realm/RealmList.cpp +++ b/src/server/shared/Realm/RealmList.cpp @@ -278,11 +278,11 @@ std::vector<uint8> RealmList::GetRealmEntryJSON(Battlenet::RealmHandle const& id std::string json = "JamJSONRealmEntry:" + JSON::Serialize(realmEntry); - uLong compressedLength = compressBound(json.length()); + uLong compressedLength = compressBound(uLong(json.length())); compressed.resize(compressedLength + 4); - *reinterpret_cast<uint32*>(compressed.data()) = json.length() + 1; + *reinterpret_cast<uint32*>(compressed.data()) = uint32(json.length() + 1); - if (compress(compressed.data() + 4, &compressedLength, reinterpret_cast<uint8 const*>(json.c_str()), json.length() + 1) == Z_OK) + if (compress(compressed.data() + 4, &compressedLength, reinterpret_cast<uint8 const*>(json.c_str()), uLong(json.length() + 1)) == Z_OK) compressed.resize(compressedLength + 4); else compressed.clear(); @@ -337,12 +337,12 @@ std::vector<uint8> RealmList::GetRealmList(uint32 build, std::string const& subR std::string json = "JSONRealmListUpdates:" + JSON::Serialize(realmList); - uLong compressedLength = compressBound(json.length()); + uLong compressedLength = compressBound(uLong(json.length())); std::vector<uint8> compressed; compressed.resize(4 + compressedLength); - *reinterpret_cast<uint32*>(compressed.data()) = json.length() + 1; + *reinterpret_cast<uint32*>(compressed.data()) = uint32(json.length() + 1); - compress(compressed.data() + 4, &compressedLength, reinterpret_cast<uint8 const*>(json.c_str()), json.length() + 1); + compress(compressed.data() + 4, &compressedLength, reinterpret_cast<uint8 const*>(json.c_str()), uLong(json.length() + 1)); compressed.resize(compressedLength + 4); @@ -367,12 +367,12 @@ uint32 RealmList::JoinRealm(uint32 realmAddress, uint32 build, boost::asio::ip:: std::string json = "JSONRealmListServerIPAddresses:" + JSON::Serialize(serverAddresses); - uLong compressedLength = compressBound(json.length()); + uLong compressedLength = compressBound(uLong(json.length())); std::vector<uint8> compressed; compressed.resize(4 + compressedLength); - *reinterpret_cast<uint32*>(compressed.data()) = json.length() + 1; + *reinterpret_cast<uint32*>(compressed.data()) = uint32(json.length() + 1); - if (compress(compressed.data() + 4, &compressedLength, reinterpret_cast<uint8 const*>(json.c_str()), json.length() + 1) != Z_OK) + if (compress(compressed.data() + 4, &compressedLength, reinterpret_cast<uint8 const*>(json.c_str()), uLong(json.length() + 1)) != Z_OK) return ERROR_UTIL_SERVER_FAILED_TO_SERIALIZE_RESPONSE; BigNumber serverSecret; |