From ef6f2f133e67373ecbe9aeea5977ca5a1de89c75 Mon Sep 17 00:00:00 2001 From: jadebenn Date: Wed, 27 Dec 2023 22:18:20 -0600 Subject: [PATCH] chore: Eradicate C-style casts and further clean up some code (#1361) * cast and code cleanup * cast cleanup * bug fixes and improvements * no getBoolField method exists * fixes * unbroke sg cannon scoring * removing comments * Remove the c-style cast warning I added from CMakeLists now that they're gone (it triggers on 3rd party dependencies and slows down compilation) * (Hopefully) fix MacOS compilation error * partially-implemented feedback * more updates to account for feedback * change bool default --------- Co-authored-by: jadebenn --- dChatServer/ChatPacketHandler.cpp | 10 +++--- dChatServer/PlayerContainer.cpp | 2 +- dCommon/AmfSerialize.cpp | 16 ++++----- dCommon/BrickByBrickFix.cpp | 2 +- dCommon/Diagnostics.cpp | 8 ++--- dCommon/GeneralUtils.cpp | 2 +- dCommon/LDFFormat.h | 22 ++++++------ dCommon/Metrics.cpp | 32 ++++++++--------- dCommon/NiPoint3.cpp | 23 +++++++++---- dCommon/SHA512.cpp | 2 ++ dCommon/dClient/AssetManager.cpp | 12 +++---- dCommon/dClient/Pack.cpp | 8 ++--- dCommon/dEnums/StringifiedEnum.h | 2 +- dCommon/dEnums/dCommonVars.h | 4 +-- .../CDComponentsRegistryTable.cpp | 9 +++-- .../CDClientTables/CDMissionEmailTable.cpp | 3 +- dDatabase/GameDatabase/MigrationRunner.cpp | 4 +-- dGame/Entity.cpp | 4 +-- dGame/EntityManager.cpp | 12 +++---- dGame/dBehaviors/Behavior.cpp | 4 +-- dGame/dBehaviors/BehaviorContext.cpp | 2 +- dGame/dBehaviors/SwitchMultipleBehavior.cpp | 2 +- dGame/dComponents/BaseCombatAIComponent.cpp | 6 ++-- dGame/dComponents/BaseCombatAIComponent.h | 2 +- dGame/dComponents/BuffComponent.cpp | 8 ++--- dGame/dComponents/CharacterComponent.cpp | 10 +++--- dGame/dComponents/DestroyableComponent.cpp | 4 +-- dGame/dComponents/MissionComponent.cpp | 2 +- dGame/dComponents/ModuleAssemblyComponent.cpp | 2 +- dGame/dComponents/MovingPlatformComponent.cpp | 8 ++--- dGame/dComponents/PetComponent.cpp | 10 +++--- dGame/dComponents/PetComponent.h | 2 +- .../dComponents/PropertyEntranceComponent.cpp | 6 ++-- .../PropertyManagementComponent.cpp | 2 +- dGame/dComponents/RacingControlComponent.cpp | 24 ++++++------- dGame/dComponents/RebuildComponent.cpp | 4 +-- .../dComponents/ScriptedActivityComponent.cpp | 4 +-- dGame/dComponents/SkillComponent.cpp | 8 ++--- dGame/dGameMessages/GameMessageHandler.cpp | 6 ++-- dGame/dGameMessages/GameMessages.cpp | 12 +++---- dGame/dGameMessages/PropertyDataMessage.cpp | 22 ++++++------ .../PropertySelectQueryProperty.cpp | 12 +++---- dGame/dInventory/Item.cpp | 2 +- dGame/dInventory/ItemSet.cpp | 2 +- dGame/dMission/Mission.cpp | 4 +-- dGame/dUtilities/Loot.cpp | 4 +-- dGame/dUtilities/Preconditions.cpp | 2 +- dGame/dUtilities/SlashCommandHandler.cpp | 18 +++++----- dNavigation/dNavMesh.cpp | 2 +- dNavigation/dTerrain/RawChunk.cpp | 18 +++++----- dNet/AuthPackets.cpp | 32 ++++++++--------- dNet/BitStreamUtils.h | 4 +-- dNet/ChatPackets.cpp | 28 +++++++-------- dNet/PacketUtils.cpp | 2 +- .../02_server/Map/AG/NpcAgCourseStarter.cpp | 6 ++-- dScripts/02_server/Map/AM/AmDrawBridge.cpp | 2 +- dScripts/02_server/Map/NS/NsLegoClubDoor.cpp | 2 +- dScripts/02_server/Map/NS/NsLupTeleport.cpp | 2 +- .../02_server/Map/NS/Waves/ZoneNsWaves.cpp | 2 +- .../boss_instance/NjMonastryBossInstance.cpp | 12 +++---- dScripts/BaseSurvivalServer.cpp | 6 ++-- dScripts/BaseWavesServer.cpp | 10 +++--- .../ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp | 34 +++++++++---------- .../OBJECTS/FvRaceSmashEggImagineServer.cpp | 4 +-- .../RACING/OBJECTS/RaceImagineCrateServer.cpp | 2 +- .../ai/RACING/OBJECTS/RaceImaginePowerup.cpp | 2 +- .../ai/RACING/OBJECTS/RaceSmashServer.cpp | 4 +-- dZoneManager/Zone.cpp | 6 ++-- 68 files changed, 281 insertions(+), 270 deletions(-) diff --git a/dChatServer/ChatPacketHandler.cpp b/dChatServer/ChatPacketHandler.cpp index 46a54888..d1f0fc74 100644 --- a/dChatServer/ChatPacketHandler.cpp +++ b/dChatServer/ChatPacketHandler.cpp @@ -66,7 +66,7 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) { BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GET_FRIENDS_LIST_RESPONSE); bitStream.Write(0); bitStream.Write(1); //Length of packet -- just writing one as it doesn't matter, client skips it. - bitStream.Write((uint16_t)player->friends.size()); + bitStream.Write(player->friends.size()); for (auto& data : player->friends) { data.Serialize(bitStream); @@ -705,7 +705,7 @@ void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeader bitStream.Write(ucLootFlag); bitStream.Write(ucNumOfOtherPlayers); bitStream.Write(ucResponseCode); - bitStream.Write(static_cast(wsLeaderName.size())); + bitStream.Write(wsLeaderName.size()); for (const auto character : wsLeaderName) { bitStream.Write(character); } @@ -730,7 +730,7 @@ void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderI bitStream.Write(0); // BinaryBuffe, no clue what's in here bitStream.Write(ucLootFlag); bitStream.Write(ucNumOfOtherPlayers); - bitStream.Write(static_cast(wsLeaderName.size())); + bitStream.Write(wsLeaderName.size()); for (const auto character : wsLeaderName) { bitStream.Write(character); } @@ -771,7 +771,7 @@ void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTria bitStream.Write(bLocal); bitStream.Write(bNoLootOnDeath); bitStream.Write(i64PlayerID); - bitStream.Write(static_cast(wsPlayerName.size())); + bitStream.Write(wsPlayerName.size()); for (const auto character : wsPlayerName) { bitStream.Write(character); } @@ -802,7 +802,7 @@ void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband bitStream.Write(bLocal); bitStream.Write(i64LeaderID); bitStream.Write(i64PlayerID); - bitStream.Write(static_cast(wsPlayerName.size())); + bitStream.Write(wsPlayerName.size()); for (const auto character : wsPlayerName) { bitStream.Write(character); } diff --git a/dChatServer/PlayerContainer.cpp b/dChatServer/PlayerContainer.cpp index d9b33825..f309ea0a 100644 --- a/dChatServer/PlayerContainer.cpp +++ b/dChatServer/PlayerContainer.cpp @@ -354,7 +354,7 @@ void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam) { if (!deleteTeam) { bitStream.Write(team->lootFlag); - bitStream.Write(static_cast(team->memberIDs.size())); + bitStream.Write(team->memberIDs.size()); for (const auto memberID : team->memberIDs) { bitStream.Write(memberID); } diff --git a/dCommon/AmfSerialize.cpp b/dCommon/AmfSerialize.cpp index 08f1eaad..3072b8e1 100644 --- a/dCommon/AmfSerialize.cpp +++ b/dCommon/AmfSerialize.cpp @@ -54,17 +54,17 @@ void RakNet::BitStream::Write(AMFBaseValue& value) { * RakNet writes in the correct byte order - do not reverse this. */ void WriteUInt29(RakNet::BitStream* bs, uint32_t v) { - unsigned char b4 = (unsigned char)v; + unsigned char b4 = static_cast(v); if (v < 0x00200000) { b4 = b4 & 0x7F; if (v > 0x7F) { unsigned char b3; v = v >> 7; - b3 = ((unsigned char)(v)) | 0x80; + b3 = static_cast(v) | 0x80; if (v > 0x7F) { unsigned char b2; v = v >> 7; - b2 = ((unsigned char)(v)) | 0x80; + b2 = static_cast(v) | 0x80; bs->Write(b2); } @@ -76,11 +76,11 @@ void WriteUInt29(RakNet::BitStream* bs, uint32_t v) { unsigned char b3; v = v >> 8; - b3 = ((unsigned char)(v)) | 0x80; + b3 = static_cast(v) | 0x80; v = v >> 7; - b2 = ((unsigned char)(v)) | 0x80; + b2 = static_cast(v) | 0x80; v = v >> 7; - b1 = ((unsigned char)(v)) | 0x80; + b1 = static_cast(v) | 0x80; bs->Write(b1); bs->Write(b2); @@ -105,8 +105,8 @@ void WriteFlagNumber(RakNet::BitStream* bs, uint32_t v) { * RakNet writes in the correct byte order - do not reverse this. */ void WriteAMFString(RakNet::BitStream* bs, const std::string& str) { - WriteFlagNumber(bs, (uint32_t)str.size()); - bs->Write(str.c_str(), (uint32_t)str.size()); + WriteFlagNumber(bs, static_cast(str.size())); + bs->Write(str.c_str(), static_cast(str.size())); } /** diff --git a/dCommon/BrickByBrickFix.cpp b/dCommon/BrickByBrickFix.cpp index f8a9e022..b771c986 100644 --- a/dCommon/BrickByBrickFix.cpp +++ b/dCommon/BrickByBrickFix.cpp @@ -51,7 +51,7 @@ uint32_t BrickByBrickFix::TruncateBrokenBrickByBrickXml() { if (actualUncompressedSize != -1) { uint32_t previousSize = completeUncompressedModel.size(); - completeUncompressedModel.append((char*)uncompressedChunk.get()); + completeUncompressedModel.append(reinterpret_cast(uncompressedChunk.get())); completeUncompressedModel.resize(previousSize + actualUncompressedSize); } else { LOG("Failed to inflate chunk %i for model %llu. Error: %i", chunkCount, model.id, err); diff --git a/dCommon/Diagnostics.cpp b/dCommon/Diagnostics.cpp index 264744f9..2dd4a850 100644 --- a/dCommon/Diagnostics.cpp +++ b/dCommon/Diagnostics.cpp @@ -197,10 +197,10 @@ void MakeBacktrace() { sigact.sa_sigaction = CritErrHdlr; sigact.sa_flags = SA_RESTART | SA_SIGINFO; - if (sigaction(SIGSEGV, &sigact, (struct sigaction*)nullptr) != 0 || - sigaction(SIGFPE, &sigact, (struct sigaction*)nullptr) != 0 || - sigaction(SIGABRT, &sigact, (struct sigaction*)nullptr) != 0 || - sigaction(SIGILL, &sigact, (struct sigaction*)nullptr) != 0) { + if (sigaction(SIGSEGV, &sigact, nullptr) != 0 || + sigaction(SIGFPE, &sigact, nullptr) != 0 || + sigaction(SIGABRT, &sigact, nullptr) != 0 || + sigaction(SIGILL, &sigact, nullptr) != 0) { fprintf(stderr, "error setting signal handler for %d (%s)\n", SIGSEGV, strsignal(SIGSEGV)); diff --git a/dCommon/GeneralUtils.cpp b/dCommon/GeneralUtils.cpp index 99ca687a..b45165fa 100644 --- a/dCommon/GeneralUtils.cpp +++ b/dCommon/GeneralUtils.cpp @@ -53,7 +53,7 @@ bool _IsSuffixChar(uint8_t c) { bool GeneralUtils::_NextUTF8Char(std::string_view& slice, uint32_t& out) { size_t rem = slice.length(); if (slice.empty()) return false; - const uint8_t* bytes = (const uint8_t*)&slice.front(); + const uint8_t* bytes = reinterpret_cast(&slice.front()); if (rem > 0) { uint8_t first = bytes[0]; if (first < 0x80) { // 1 byte character diff --git a/dCommon/LDFFormat.h b/dCommon/LDFFormat.h index 0921d04c..7bcc91a2 100644 --- a/dCommon/LDFFormat.h +++ b/dCommon/LDFFormat.h @@ -63,15 +63,15 @@ private: //! Writes the key to the packet void WriteKey(RakNet::BitStream* packet) { - packet->Write(static_cast(this->key.length() * sizeof(uint16_t))); + packet->Write(this->key.length() * sizeof(uint16_t)); for (uint32_t i = 0; i < this->key.length(); ++i) { - packet->Write(static_cast(this->key[i])); + packet->Write(this->key[i]); } } //! Writes the value to the packet void WriteValue(RakNet::BitStream* packet) { - packet->Write(static_cast(this->GetValueType())); + packet->Write(this->GetValueType()); packet->Write(this->value); } @@ -179,30 +179,30 @@ template<> inline eLDFType LDFData::GetValueType(void) { return LDF // The specialized version for std::u16string (UTF-16) template<> inline void LDFData::WriteValue(RakNet::BitStream* packet) { - packet->Write(static_cast(this->GetValueType())); + packet->Write(this->GetValueType()); - packet->Write(static_cast(this->value.length())); + packet->Write(this->value.length()); for (uint32_t i = 0; i < this->value.length(); ++i) { - packet->Write(static_cast(this->value[i])); + packet->Write(this->value[i]); } } // The specialized version for bool template<> inline void LDFData::WriteValue(RakNet::BitStream* packet) { - packet->Write(static_cast(this->GetValueType())); + packet->Write(this->GetValueType()); - packet->Write(static_cast(this->value)); + packet->Write(this->value); } // The specialized version for std::string (UTF-8) template<> inline void LDFData::WriteValue(RakNet::BitStream* packet) { - packet->Write(static_cast(this->GetValueType())); + packet->Write(this->GetValueType()); - packet->Write(static_cast(this->value.length())); + packet->Write(this->value.length()); for (uint32_t i = 0; i < this->value.length(); ++i) { - packet->Write(static_cast(this->value[i])); + packet->Write(this->value[i]); } } diff --git a/dCommon/Metrics.cpp b/dCommon/Metrics.cpp index b97b5435..5232cf78 100644 --- a/dCommon/Metrics.cpp +++ b/dCommon/Metrics.cpp @@ -107,7 +107,7 @@ void Metrics::EndMeasurement(MetricVariable variable) { } float Metrics::ToMiliseconds(int64_t nanoseconds) { - return (float)nanoseconds / 1e6; + return static_cast(nanoseconds) / 1e6; } std::string Metrics::MetricVariableToString(MetricVariable variable) { @@ -193,34 +193,34 @@ size_t Metrics::GetPeakRSS() { /* Windows -------------------------------------------------- */ PROCESS_MEMORY_COUNTERS info; GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info)); - return (size_t)info.PeakWorkingSetSize; + return static_cast(info.PeakWorkingSetSize); #elif (defined(_AIX) || defined(__TOS__AIX__)) || (defined(__sun__) || defined(__sun) || defined(sun) && (defined(__SVR4) || defined(__svr4__))) /* AIX and Solaris ------------------------------------------ */ struct psinfo psinfo; int fd = -1; if ((fd = open("/proc/self/psinfo", O_RDONLY)) == -1) - return (size_t)0L; /* Can't open? */ + return static_cast(0L); /* Can't open? */ if (read(fd, &psinfo, sizeof(psinfo)) != sizeof(psinfo)) { close(fd); - return (size_t)0L; /* Can't read? */ + return static_cast(0L); /* Can't read? */ } close(fd); - return (size_t)(psinfo.pr_rssize * 1024L); + return static_cast(psinfo.pr_rssize * 1024L); #elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__)) /* BSD, Linux, and OSX -------------------------------------- */ struct rusage rusage; getrusage(RUSAGE_SELF, &rusage); #if defined(__APPLE__) && defined(__MACH__) - return (size_t)rusage.ru_maxrss; + return static_cast(rusage.ru_maxrss); #else - return (size_t)(rusage.ru_maxrss * 1024L); + return static_cast(rusage.ru_maxrss * 1024L); #endif #else /* Unknown OS ----------------------------------------------- */ - return (size_t)0L; /* Unsupported. */ + return static_cast(0L); /* Unsupported. */ #endif } @@ -234,33 +234,33 @@ size_t Metrics::GetCurrentRSS() { /* Windows -------------------------------------------------- */ PROCESS_MEMORY_COUNTERS info; GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info)); - return (size_t)info.WorkingSetSize; + return static_cast(info.WorkingSetSize); #elif defined(__APPLE__) && defined(__MACH__) /* OSX ------------------------------------------------------ */ struct mach_task_basic_info info; mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT; if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO, - (task_info_t)&info, &infoCount) != KERN_SUCCESS) - return (size_t)0L; /* Can't access? */ - return (size_t)info.resident_size; + reinterpret_cast(&info), &infoCount) != KERN_SUCCESS) + return static_cast(0L); /* Can't access? */ + return static_cast(info.resident_size); #elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__) /* Linux ---------------------------------------------------- */ long rss = 0L; FILE* fp = NULL; if ((fp = fopen("/proc/self/statm", "r")) == NULL) - return (size_t)0L; /* Can't open? */ + return static_cast(0L); /* Can't open? */ if (fscanf(fp, "%*s%ld", &rss) != 1) { fclose(fp); - return (size_t)0L; /* Can't read? */ + return static_cast(0L); /* Can't read? */ } fclose(fp); - return (size_t)rss * (size_t)sysconf(_SC_PAGESIZE); + return static_cast(rss) * static_cast(sysconf(_SC_PAGESIZE)); #else /* AIX, BSD, Solaris, and Unknown OS ------------------------ */ - return (size_t)0L; /* Unsupported. */ + return static_cast(0L); /* Unsupported. */ #endif } diff --git a/dCommon/NiPoint3.cpp b/dCommon/NiPoint3.cpp index 5ad06f30..3394deb7 100644 --- a/dCommon/NiPoint3.cpp +++ b/dCommon/NiPoint3.cpp @@ -114,13 +114,13 @@ bool NiPoint3::operator!=(const NiPoint3& point) const { //! Operator for subscripting float& NiPoint3::operator[](int i) { float* base = &x; - return (float&)base[i]; + return base[i]; } //! Operator for subscripting const float& NiPoint3::operator[](int i) const { const float* base = &x; - return (float&)base[i]; + return base[i]; } //! Operator for addition of vectors @@ -181,7 +181,7 @@ bool NiPoint3::IsWithinAxisAlignedBox(const NiPoint3& minPoint, const NiPoint3& if (this->y < minPoint.y) return false; if (this->y > maxPoint.y) return false; - return (this->z < maxPoint.z&& this->z > minPoint.z); + return (this->z < maxPoint.z && this->z > minPoint.z); } //! Checks to see if the point (or vector) is within a sphere @@ -232,10 +232,21 @@ NiPoint3 NiPoint3::MoveTowards(const NiPoint3& current, const NiPoint3& target, float dx = target.x - current.x; float dy = target.y - current.y; float dz = target.z - current.z; - float lengthSquared = (float)((double)dx * (double)dx + (double)dy * (double)dy + (double)dz * (double)dz); - if ((double)lengthSquared == 0.0 || (double)maxDistanceDelta >= 0.0 && (double)lengthSquared <= (double)maxDistanceDelta * (double)maxDistanceDelta) + + float lengthSquared = static_cast( + static_cast(dx) * static_cast(dx) + + static_cast(dy) * static_cast(dy) + + static_cast(dz) * static_cast(dz) + ); + + if (static_cast(lengthSquared) == 0.0 + || static_cast(maxDistanceDelta) >= 0.0 + && static_cast(lengthSquared) + <= static_cast(maxDistanceDelta) * static_cast(maxDistanceDelta)) { return target; - float length = (float)std::sqrt((double)lengthSquared); + } + + float length = std::sqrt(lengthSquared); return NiPoint3(current.x + dx / length * maxDistanceDelta, current.y + dy / length * maxDistanceDelta, current.z + dz / length * maxDistanceDelta); } diff --git a/dCommon/SHA512.cpp b/dCommon/SHA512.cpp index f5a71d99..e3c2d9f7 100644 --- a/dCommon/SHA512.cpp +++ b/dCommon/SHA512.cpp @@ -1,3 +1,5 @@ +// Source: http://www.zedwood.com/article/cpp-sha512-function + #include "SHA512.h" #include diff --git a/dCommon/dClient/AssetManager.cpp b/dCommon/dClient/AssetManager.cpp index 00bae6ce..98a71e37 100644 --- a/dCommon/dClient/AssetManager.cpp +++ b/dCommon/dClient/AssetManager.cpp @@ -81,8 +81,8 @@ bool AssetManager::HasFile(const char* name) { std::replace(fixedName.begin(), fixedName.end(), '/', '\\'); if (fixedName.rfind("client\\res\\", 0) != 0) fixedName = "client\\res\\" + fixedName; - uint32_t crc = crc32b(0xFFFFFFFF, (uint8_t*)fixedName.c_str(), fixedName.size()); - crc = crc32b(crc, (Bytef*)"\0\0\0\0", 4); + uint32_t crc = crc32b(0xFFFFFFFF, reinterpret_cast(const_cast(fixedName.c_str())), fixedName.size()); + crc = crc32b(crc, reinterpret_cast(const_cast("\0\0\0\0")), 4); for (const auto& item : this->m_PackIndex->GetPackFileIndices()) { if (item.m_Crc == crc) { @@ -113,7 +113,7 @@ bool AssetManager::GetFile(const char* name, char** data, uint32_t* len) { #endif fseek(file, 0, SEEK_END); *len = ftell(file); - *data = (char*)malloc(*len); + *data = static_cast(malloc(*len)); fseek(file, 0, SEEK_SET); int32_t readInData = fread(*data, sizeof(uint8_t), *len, file); fclose(file); @@ -129,8 +129,8 @@ bool AssetManager::GetFile(const char* name, char** data, uint32_t* len) { fixedName = "client\\res\\" + fixedName; } int32_t packIndex = -1; - uint32_t crc = crc32b(0xFFFFFFFF, (uint8_t*)fixedName.c_str(), fixedName.size()); - crc = crc32b(crc, (Bytef*)"\0\0\0\0", 4); + uint32_t crc = crc32b(0xFFFFFFFF, reinterpret_cast(const_cast(fixedName.c_str())), fixedName.size()); + crc = crc32b(crc, reinterpret_cast(const_cast("\0\0\0\0")), 4); for (const auto& item : this->m_PackIndex->GetPackFileIndices()) { if (item.m_Crc == crc) { @@ -167,7 +167,7 @@ uint32_t AssetManager::crc32b(uint32_t base, uint8_t* message, size_t l) { crc = base; for (i = 0; i < l; i++) { // xor next byte to upper bits of crc - crc ^= (((unsigned int)message[i]) << 24); + crc ^= (static_cast(message[i]) << 24); for (j = 0; j < 8; j++) { // Do eight times. msb = crc >> 31; crc <<= 1; diff --git a/dCommon/dClient/Pack.cpp b/dCommon/dClient/Pack.cpp index 11345fc9..cf32a53f 100644 --- a/dCommon/dClient/Pack.cpp +++ b/dCommon/dClient/Pack.cpp @@ -76,7 +76,7 @@ bool Pack::ReadFileFromPack(uint32_t crc, char** data, uint32_t* len) { fseek(file, pos, SEEK_SET); if (!isCompressed) { - char* tempData = (char*)malloc(pkRecord.m_UncompressedSize); + char* tempData = static_cast(malloc(pkRecord.m_UncompressedSize)); int32_t readInData = fread(tempData, sizeof(uint8_t), pkRecord.m_UncompressedSize, file); *data = tempData; @@ -90,7 +90,7 @@ bool Pack::ReadFileFromPack(uint32_t crc, char** data, uint32_t* len) { fseek(file, pos, SEEK_SET); - char* decompressedData = (char*)malloc(pkRecord.m_UncompressedSize); + char* decompressedData = static_cast(malloc(pkRecord.m_UncompressedSize)); uint32_t currentReadPos = 0; while (true) { @@ -100,12 +100,12 @@ bool Pack::ReadFileFromPack(uint32_t crc, char** data, uint32_t* len) { int32_t readInData = fread(&size, sizeof(uint32_t), 1, file); pos += 4; // Move pointer position 4 to the right - char* chunk = (char*)malloc(size); + char* chunk = static_cast(malloc(size)); int32_t readInData2 = fread(chunk, sizeof(int8_t), size, file); pos += size; // Move pointer position the amount of bytes read to the right int32_t err; - currentReadPos += ZCompression::Decompress((uint8_t*)chunk, size, reinterpret_cast(decompressedData + currentReadPos), ZCompression::MAX_SD0_CHUNK_SIZE, err); + currentReadPos += ZCompression::Decompress(reinterpret_cast(chunk), size, reinterpret_cast(decompressedData + currentReadPos), ZCompression::MAX_SD0_CHUNK_SIZE, err); free(chunk); } diff --git a/dCommon/dEnums/StringifiedEnum.h b/dCommon/dEnums/StringifiedEnum.h index ee7402ec..16eafdca 100644 --- a/dCommon/dEnums/StringifiedEnum.h +++ b/dCommon/dEnums/StringifiedEnum.h @@ -10,13 +10,13 @@ namespace StringifiedEnum { static_assert(std::is_enum_v, "Not an enum"); // Check type constexpr auto sv = &magic_enum::enum_entries(); - std::string_view output; const auto it = std::lower_bound( sv->begin(), sv->end(), e, [&](const std::pair& lhs, const T rhs) { return lhs.first < rhs; } ); + std::string_view output; if (it != sv->end() && it->first == e) { output = it->second; } else { diff --git a/dCommon/dEnums/dCommonVars.h b/dCommon/dEnums/dCommonVars.h index dc7a1d54..513e9c8f 100644 --- a/dCommon/dEnums/dCommonVars.h +++ b/dCommon/dEnums/dCommonVars.h @@ -148,11 +148,11 @@ public: if (size > maxSize) size = maxSize; for (uint32_t i = 0; i < size; ++i) { - bitStream.Write(static_cast(friendName[i])); + bitStream.Write(friendName[i]); } for (uint32_t j = 0; j < remSize; ++j) { - bitStream.Write(static_cast(0)); + bitStream.Write(0); } bitStream.Write(0); //??? diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDComponentsRegistryTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDComponentsRegistryTable.cpp index ac547a24..3cf7ac62 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDComponentsRegistryTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDComponentsRegistryTable.cpp @@ -10,7 +10,7 @@ void CDComponentsRegistryTable::LoadValuesFromDatabase() { entry.component_type = static_cast(tableData.getIntField("component_type", 0)); entry.component_id = tableData.getIntField("component_id", -1); - this->mappedEntries.insert_or_assign(((uint64_t)entry.component_type) << 32 | ((uint64_t)entry.id), entry.component_id); + this->mappedEntries.insert_or_assign(static_cast(entry.component_type) << 32 | static_cast(entry.id), entry.component_id); this->mappedEntries.insert_or_assign(entry.id, 0); tableData.nextRow(); @@ -22,7 +22,7 @@ void CDComponentsRegistryTable::LoadValuesFromDatabase() { int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) { auto exists = mappedEntries.find(id); if (exists != mappedEntries.end()) { - auto iter = mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id)); + auto iter = mappedEntries.find(static_cast(componentType) << 32 | static_cast(id)); return iter == mappedEntries.end() ? defaultValue : iter->second; } @@ -38,15 +38,14 @@ int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponent entry.component_type = static_cast(tableData.getIntField("component_type", 0)); entry.component_id = tableData.getIntField("component_id", -1); - this->mappedEntries.insert_or_assign(((uint64_t)entry.component_type) << 32 | ((uint64_t)entry.id), entry.component_id); + this->mappedEntries.insert_or_assign(static_cast(entry.component_type) << 32 | static_cast(entry.id), entry.component_id); tableData.nextRow(); } mappedEntries.insert_or_assign(id, 0); - auto iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id)); + auto iter = this->mappedEntries.find(static_cast(componentType) << 32 | static_cast(id)); return iter == this->mappedEntries.end() ? defaultValue : iter->second; } - diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMissionEmailTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDMissionEmailTable.cpp index 207d3815..0babef13 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMissionEmailTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMissionEmailTable.cpp @@ -25,7 +25,7 @@ void CDMissionEmailTable::LoadValuesFromDatabase() { entry.notificationGroup = tableData.getIntField("notificationGroup", -1); entry.missionID = tableData.getIntField("missionID", -1); entry.attachmentLOT = tableData.getIntField("attachmentLOT", 0); - entry.localize = (bool)tableData.getIntField("localize", -1); + entry.localize = static_cast(tableData.getIntField("localize", 1)); entry.locStatus = tableData.getIntField("locStatus", -1); entry.gate_version = tableData.getStringField("gate_version", ""); @@ -50,4 +50,3 @@ std::vector CDMissionEmailTable::Query(std::function& CDMissionEmailTable::GetEntries() const { return this->entries; } - diff --git a/dDatabase/GameDatabase/MigrationRunner.cpp b/dDatabase/GameDatabase/MigrationRunner.cpp index 6bc3954d..8034a3e2 100644 --- a/dDatabase/GameDatabase/MigrationRunner.cpp +++ b/dDatabase/GameDatabase/MigrationRunner.cpp @@ -95,7 +95,7 @@ void MigrationRunner::RunSQLiteMigrations() { // Check if there is an entry in the migration history table on the cdclient database. cdstmt = CDClientDatabase::CreatePreppedStmt("SELECT name FROM migration_history WHERE name = ?;"); - cdstmt.bind((int32_t) 1, migration.name.c_str()); + cdstmt.bind(static_cast(1), migration.name.c_str()); auto cdres = cdstmt.execQuery(); if (!cdres.eof()) continue; @@ -124,7 +124,7 @@ void MigrationRunner::RunSQLiteMigrations() { // Insert into cdclient database. cdstmt = CDClientDatabase::CreatePreppedStmt("INSERT INTO migration_history (name) VALUES (?);"); - cdstmt.bind((int32_t) 1, migration.name.c_str()); + cdstmt.bind(static_cast(1), migration.name.c_str()); cdstmt.execQuery(); CDClientDatabase::ExecuteQuery("COMMIT;"); } diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index cbbbb4d4..0caeada8 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -982,9 +982,9 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke } outBitStream->Write(m_ChildEntities.size() > 0); if (m_ChildEntities.size() > 0) { - outBitStream->Write((uint16_t)m_ChildEntities.size()); + outBitStream->Write(m_ChildEntities.size()); for (Entity* child : m_ChildEntities) { - outBitStream->Write((uint64_t)child->GetObjectID()); + outBitStream->Write(child->GetObjectID()); } } } diff --git a/dGame/EntityManager.cpp b/dGame/EntityManager.cpp index cfbd71d9..493e910e 100644 --- a/dGame/EntityManager.cpp +++ b/dGame/EntityManager.cpp @@ -181,8 +181,8 @@ void EntityManager::SerializeEntities() { m_SerializationCounter++; RakNet::BitStream stream; - stream.Write(static_cast(ID_REPLICA_MANAGER_SERIALIZE)); - stream.Write(static_cast(entity->GetNetworkId())); + stream.Write(ID_REPLICA_MANAGER_SERIALIZE); + stream.Write(entity->GetNetworkId()); entity->WriteBaseReplicaData(&stream, eReplicaPacketType::SERIALIZATION); entity->WriteComponents(&stream, eReplicaPacketType::SERIALIZATION); @@ -366,9 +366,9 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr RakNet::BitStream stream; - stream.Write(static_cast(ID_REPLICA_MANAGER_CONSTRUCTION)); + stream.Write(ID_REPLICA_MANAGER_CONSTRUCTION); stream.Write(true); - stream.Write(static_cast(entity->GetNetworkId())); + stream.Write(entity->GetNetworkId()); entity->WriteBaseReplicaData(&stream, eReplicaPacketType::CONSTRUCTION); entity->WriteComponents(&stream, eReplicaPacketType::CONSTRUCTION); @@ -416,8 +416,8 @@ void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr) RakNet::BitStream stream; - stream.Write(static_cast(ID_REPLICA_MANAGER_DESTRUCTION)); - stream.Write(static_cast(entity->GetNetworkId())); + stream.Write(ID_REPLICA_MANAGER_DESTRUCTION); + stream.Write(entity->GetNetworkId()); Game::server->Send(&stream, sysAddr, sysAddr == UNASSIGNED_SYSTEM_ADDRESS); diff --git a/dGame/dBehaviors/Behavior.cpp b/dGame/dBehaviors/Behavior.cpp index b32c7c52..c70b34c7 100644 --- a/dGame/dBehaviors/Behavior.cpp +++ b/dGame/dBehaviors/Behavior.cpp @@ -368,11 +368,11 @@ void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID if (!type.empty()) { typeQuery.bind(1, typeString.c_str()); - typeQuery.bind(2, (int)effectId); + typeQuery.bind(2, static_cast(effectId)); result = typeQuery.execQuery(); } else { - idQuery.bind(1, (int)effectId); + idQuery.bind(1, static_cast(effectId)); result = idQuery.execQuery(); } diff --git a/dGame/dBehaviors/BehaviorContext.cpp b/dGame/dBehaviors/BehaviorContext.cpp index d23ee596..77376558 100644 --- a/dGame/dBehaviors/BehaviorContext.cpp +++ b/dGame/dBehaviors/BehaviorContext.cpp @@ -249,7 +249,7 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime) { entry.behavior->SyncCalculation(this, bitStream, entry.branchContext); if (!clientInitalized) { - echo.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed()); + echo.sBitStream.assign(reinterpret_cast(bitStream->GetData()), bitStream->GetNumberOfBytesUsed()); // Write message RakNet::BitStream message; diff --git a/dGame/dBehaviors/SwitchMultipleBehavior.cpp b/dGame/dBehaviors/SwitchMultipleBehavior.cpp index 947c331f..faaa0d23 100644 --- a/dGame/dBehaviors/SwitchMultipleBehavior.cpp +++ b/dGame/dBehaviors/SwitchMultipleBehavior.cpp @@ -42,7 +42,7 @@ void SwitchMultipleBehavior::Load() { "(select bP2.value FROM BehaviorParameter bP2 WHERE bP2.behaviorID = ?1 AND bP2.parameterID LIKE 'value %' " "AND replace(bP1.parameterID, 'behavior ', '') = replace(bP2.parameterID, 'value ', '')) as value " "FROM BehaviorParameter bP1 WHERE bP1.behaviorID = ?1 AND bP1.parameterID LIKE 'behavior %';"); - query.bind(1, (int)this->m_behaviorId); + query.bind(1, static_cast(this->m_behaviorId)); auto result = query.execQuery(); diff --git a/dGame/dComponents/BaseCombatAIComponent.cpp b/dGame/dComponents/BaseCombatAIComponent.cpp index 1961e6d6..50837629 100644 --- a/dGame/dComponents/BaseCombatAIComponent.cpp +++ b/dGame/dComponents/BaseCombatAIComponent.cpp @@ -40,7 +40,7 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id): //Grab the aggro information from BaseCombatAI: auto componentQuery = CDClientDatabase::CreatePreppedStmt( "SELECT aggroRadius, tetherSpeed, pursuitSpeed, softTetherRadius, hardTetherRadius FROM BaseCombatAIComponent WHERE id = ?;"); - componentQuery.bind(1, (int)id); + componentQuery.bind(1, static_cast(id)); auto componentResult = componentQuery.execQuery(); @@ -77,7 +77,7 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id): */ auto skillQuery = CDClientDatabase::CreatePreppedStmt( "SELECT skillID, cooldown, behaviorID FROM SkillBehavior WHERE skillID IN (SELECT skillID FROM ObjectSkills WHERE objectTemplate = ?);"); - skillQuery.bind(1, (int)parent->GetLOT()); + skillQuery.bind(1, static_cast(parent->GetLOT())); auto result = skillQuery.execQuery(); @@ -523,7 +523,7 @@ bool BaseCombatAIComponent::IsMech() { void BaseCombatAIComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(m_DirtyStateOrTarget || bIsInitialUpdate); if (m_DirtyStateOrTarget || bIsInitialUpdate) { - outBitStream->Write(uint32_t(m_State)); + outBitStream->Write(m_State); outBitStream->Write(m_Target); m_DirtyStateOrTarget = false; } diff --git a/dGame/dComponents/BaseCombatAIComponent.h b/dGame/dComponents/BaseCombatAIComponent.h index a08b008e..8ae04611 100644 --- a/dGame/dComponents/BaseCombatAIComponent.h +++ b/dGame/dComponents/BaseCombatAIComponent.h @@ -19,7 +19,7 @@ class Entity; /** * The current state of the AI */ -enum class AiState : int { +enum class AiState : uint32_t { idle = 0, // Doing nothing aggro, // Waiting for an enemy to cross / running back to spawn tether, // Chasing an enemy diff --git a/dGame/dComponents/BuffComponent.cpp b/dGame/dComponents/BuffComponent.cpp index c901c19d..32d7d1d4 100644 --- a/dGame/dComponents/BuffComponent.cpp +++ b/dGame/dComponents/BuffComponent.cpp @@ -41,7 +41,7 @@ void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUp for (const auto& [id, buff] : m_Buffs) { outBitStream->Write(id); outBitStream->Write(buff.time != 0.0f); - if (buff.time != 0.0f) outBitStream->Write(static_cast(buff.time * 1000.0f)); + if (buff.time != 0.0f) outBitStream->Write(buff.time * 1000.0f); outBitStream->Write(buff.cancelOnDeath); outBitStream->Write(buff.cancelOnZone); outBitStream->Write(buff.cancelOnDamaged); @@ -147,8 +147,8 @@ void BuffComponent::ApplyBuff(const int32_t id, const float duration, const LWOO addedByTeammate = std::count(team->members.begin(), team->members.end(), m_Parent->GetObjectID()) > 0; } - GameMessages::SendAddBuff(const_cast(m_Parent->GetObjectID()), source, (uint32_t)id, - (uint32_t)duration * 1000, addImmunity, cancelOnDamaged, cancelOnDeath, + GameMessages::SendAddBuff(const_cast(m_Parent->GetObjectID()), source, static_cast(id), + static_cast(duration) * 1000, addImmunity, cancelOnDamaged, cancelOnDeath, cancelOnLogout, cancelOnRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone, addedByTeammate, applyOnTeammates); float tick = 0; @@ -431,7 +431,7 @@ const std::vector& BuffComponent::GetBuffParameters(int32_t buffI } auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM BuffParameters WHERE BuffID = ?;"); - query.bind(1, (int)buffId); + query.bind(1, static_cast(buffId)); auto result = query.execQuery(); diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index 1e441293..6ba7db29 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -135,7 +135,7 @@ void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInit outBitStream->Write0(); outBitStream->Write(m_IsLanding); if (m_IsLanding) { - outBitStream->Write(uint16_t(m_LastRocketConfig.size())); + outBitStream->Write(m_LastRocketConfig.size()); for (uint16_t character : m_LastRocketConfig) { outBitStream->Write(character); } @@ -157,7 +157,7 @@ void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInit outBitStream->Write(m_DirtySocialInfo); if (m_DirtySocialInfo) { outBitStream->Write(m_GuildID); - outBitStream->Write(static_cast(m_GuildName.size())); + outBitStream->Write(m_GuildName.size()); if (!m_GuildName.empty()) outBitStream->WriteBits(reinterpret_cast(m_GuildName.c_str()), static_cast(m_GuildName.size()) * sizeof(wchar_t) * 8); @@ -229,7 +229,7 @@ void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { uint32_t mapID; child->QueryAttribute("map", &mapID); - m_ZoneStatistics.insert({ (LWOMAPID)mapID, statistics }); + m_ZoneStatistics.insert({ static_cast(mapID), statistics }); child = child->NextSiblingElement(); } @@ -515,9 +515,9 @@ void CharacterComponent::TrackPositionUpdate(const NiPoint3& newPosition) { const auto distance = NiPoint3::Distance(newPosition, m_Parent->GetPosition()); if (m_IsRacing) { - UpdatePlayerStatistic(DistanceDriven, (uint64_t)distance); + UpdatePlayerStatistic(DistanceDriven, static_cast(distance)); } else { - UpdatePlayerStatistic(MetersTraveled, (uint64_t)distance); + UpdatePlayerStatistic(MetersTraveled, static_cast(distance)); } } diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 8c5321f4..c90cadf5 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -154,7 +154,7 @@ void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn outBitStream->Write(m_fMaxArmor); outBitStream->Write(m_fMaxImagination); - outBitStream->Write(uint32_t(m_FactionIDs.size())); + outBitStream->Write(m_FactionIDs.size()); for (size_t i = 0; i < m_FactionIDs.size(); ++i) { outBitStream->Write(m_FactionIDs[i]); } @@ -380,7 +380,7 @@ void DestroyableComponent::AddFaction(const int32_t factionID, const bool ignore auto query = CDClientDatabase::CreatePreppedStmt( "SELECT enemyList FROM Factions WHERE faction = ?;"); - query.bind(1, (int)factionID); + query.bind(1, static_cast(factionID)); auto result = query.execQuery(); diff --git a/dGame/dComponents/MissionComponent.cpp b/dGame/dComponents/MissionComponent.cpp index 33869030..7219589a 100644 --- a/dGame/dComponents/MissionComponent.cpp +++ b/dGame/dComponents/MissionComponent.cpp @@ -458,7 +458,7 @@ const std::vector& MissionComponent::QueryAchievements(eMissionTaskTyp bool MissionComponent::RequiresItem(const LOT lot) { auto query = CDClientDatabase::CreatePreppedStmt( "SELECT type FROM Objects WHERE id = ?;"); - query.bind(1, (int)lot); + query.bind(1, static_cast(lot)); auto result = query.execQuery(); diff --git a/dGame/dComponents/ModuleAssemblyComponent.cpp b/dGame/dComponents/ModuleAssemblyComponent.cpp index 9089c14c..5b7042df 100644 --- a/dGame/dComponents/ModuleAssemblyComponent.cpp +++ b/dGame/dComponents/ModuleAssemblyComponent.cpp @@ -57,7 +57,7 @@ void ModuleAssemblyComponent::Serialize(RakNet::BitStream* outBitStream, bool bI outBitStream->Write(m_UseOptionalParts); - outBitStream->Write(static_cast(m_AssemblyPartsLOTs.size())); + outBitStream->Write(m_AssemblyPartsLOTs.size()); for (char16_t character : m_AssemblyPartsLOTs) { outBitStream->Write(character); } diff --git a/dGame/dComponents/MovingPlatformComponent.cpp b/dGame/dComponents/MovingPlatformComponent.cpp index a95735fd..c28d3cea 100644 --- a/dGame/dComponents/MovingPlatformComponent.cpp +++ b/dGame/dComponents/MovingPlatformComponent.cpp @@ -35,7 +35,7 @@ MoverSubComponent::~MoverSubComponent() = default; void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { outBitStream->Write(true); - outBitStream->Write(static_cast(mState)); + outBitStream->Write(mState); outBitStream->Write(mDesiredWaypointIndex); outBitStream->Write(mShouldStopAtDesiredWaypoint); outBitStream->Write(mInReverse); @@ -90,9 +90,9 @@ void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bI // Is on rail outBitStream->Write1(); - outBitStream->Write(static_cast(m_PathName.size())); + outBitStream->Write(m_PathName.size()); for (const auto& c : m_PathName) { - outBitStream->Write(static_cast(c)); + outBitStream->Write(c); } // Starting point @@ -107,7 +107,7 @@ void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bI if (hasPlatform) { auto* mover = static_cast(m_MoverSubComponent); - outBitStream->Write(static_cast(m_MoverSubComponentType)); + outBitStream->Write(m_MoverSubComponentType); if (m_MoverSubComponentType == eMoverSubComponentType::simpleMover) { // TODO diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index 1780437e..901d7485 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -113,8 +113,8 @@ void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpd outBitStream->Write1(); // Always serialize as dirty for now - outBitStream->Write(static_cast(m_Status)); - outBitStream->Write(static_cast(tamed ? m_Ability : PetAbilityType::Invalid)); // Something with the overhead icon? + outBitStream->Write(m_Status); + outBitStream->Write(tamed ? m_Ability : PetAbilityType::Invalid); // Something with the overhead icon? const bool interacting = m_Interaction != LWOOBJID_EMPTY; @@ -136,12 +136,12 @@ void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpd const auto nameData = GeneralUtils::UTF8ToUTF16(m_Name); const auto ownerNameData = GeneralUtils::UTF8ToUTF16(m_OwnerName); - outBitStream->Write(static_cast(nameData.size())); + outBitStream->Write(nameData.size()); for (const auto c : nameData) { outBitStream->Write(c); } - outBitStream->Write(static_cast(ownerNameData.size())); + outBitStream->Write(ownerNameData.size()); for (const auto c : ownerNameData) { outBitStream->Write(c); } @@ -190,7 +190,7 @@ void PetComponent::OnUse(Entity* originator) { if (cached == buildCache.end()) { auto query = CDClientDatabase::CreatePreppedStmt( "SELECT ValidPiecesLXF, PuzzleModelLot, Timelimit, NumValidPieces, imagCostPerBuild FROM TamingBuildPuzzles WHERE NPCLot = ?;"); - query.bind(1, (int)m_Parent->GetLOT()); + query.bind(1, static_cast(m_Parent->GetLOT())); auto result = query.execQuery(); diff --git a/dGame/dComponents/PetComponent.h b/dGame/dComponents/PetComponent.h index 980bb146..ca4b5a74 100644 --- a/dGame/dComponents/PetComponent.h +++ b/dGame/dComponents/PetComponent.h @@ -6,7 +6,7 @@ #include "Preconditions.h" #include "eReplicaComponentType.h" -enum class PetAbilityType +enum class PetAbilityType : uint32_t { Invalid, GoToObject, diff --git a/dGame/dComponents/PropertyEntranceComponent.cpp b/dGame/dComponents/PropertyEntranceComponent.cpp index 4d7ea16d..c49d8985 100644 --- a/dGame/dComponents/PropertyEntranceComponent.cpp +++ b/dGame/dComponents/PropertyEntranceComponent.cpp @@ -163,7 +163,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl const auto modApproved = playerPropertyLookupResults->getBoolean(10); const auto dateLastUpdated = playerPropertyLookupResults->getInt64(11); const auto reputation = playerPropertyLookupResults->getUInt(14); - const auto performanceCost = (float)playerPropertyLookupResults->getDouble(16); + const auto performanceCost = playerPropertyLookupResults->getFloat(16); playerEntry = SetPropertyValues(playerEntry, cloneId, character->GetName(), propertyName, propertyDescription, reputation, true, true, modApproved, true, true, privacyOption, dateLastUpdated, performanceCost); } else { @@ -187,7 +187,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl propertyLookup->setString(2, searchString.c_str()); propertyLookup->setString(3, searchString.c_str()); propertyLookup->setString(4, searchString.c_str()); - propertyLookup->setInt(5, sortMethod == SORT_TYPE_FEATURED || sortMethod == SORT_TYPE_FRIENDS ? (uint32_t)PropertyPrivacyOption::Friends : (uint32_t)PropertyPrivacyOption::Public); + propertyLookup->setInt(5, sortMethod == SORT_TYPE_FEATURED || sortMethod == SORT_TYPE_FRIENDS ? static_cast(PropertyPrivacyOption::Friends) : static_cast(PropertyPrivacyOption::Public)); propertyLookup->setInt(6, numResults); propertyLookup->setInt(7, startIndex); @@ -203,7 +203,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl const auto modApproved = propertyEntry->getBoolean(10); const auto dateLastUpdated = propertyEntry->getInt(11); const float reputation = propertyEntry->getInt(14); - const auto performanceCost = (float)propertyEntry->getDouble(16); + const auto performanceCost = propertyEntry->getFloat(16); PropertySelectQueryProperty entry{}; diff --git a/dGame/dComponents/PropertyManagementComponent.cpp b/dGame/dComponents/PropertyManagementComponent.cpp index 7877b2c9..de37308f 100644 --- a/dGame/dComponents/PropertyManagementComponent.cpp +++ b/dGame/dComponents/PropertyManagementComponent.cpp @@ -92,7 +92,7 @@ std::vector PropertyManagementComponent::GetPaths() const { auto query = CDClientDatabase::CreatePreppedStmt( "SELECT path FROM PropertyTemplate WHERE mapID = ?;"); - query.bind(1, (int)zoneId); + query.bind(1, static_cast(zoneId)); auto result = query.execQuery(); diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index 6c8df280..ef1d0f32 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -401,18 +401,18 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu if (missionComponent == nullptr) return; - missionComponent->Progress(eMissionTaskType::RACING, 0, (LWOOBJID)eRacingTaskParam::COMPETED_IN_RACE); // Progress task for competing in a race - missionComponent->Progress(eMissionTaskType::RACING, data->smashedTimes, (LWOOBJID)eRacingTaskParam::SAFE_DRIVER); // Finish a race without being smashed. + missionComponent->Progress(eMissionTaskType::RACING, 0, static_cast(eRacingTaskParam::COMPETED_IN_RACE)); // Progress task for competing in a race + missionComponent->Progress(eMissionTaskType::RACING, data->smashedTimes, static_cast(eRacingTaskParam::SAFE_DRIVER)); // Finish a race without being smashed. // If solo racing is enabled OR if there are 3 players in the race, progress placement tasks. if (m_SoloRacing || m_LoadedPlayers > 2) { - missionComponent->Progress(eMissionTaskType::RACING, data->finished, (LWOOBJID)eRacingTaskParam::FINISH_WITH_PLACEMENT); // Finish in 1st place on a race + missionComponent->Progress(eMissionTaskType::RACING, data->finished, static_cast(eRacingTaskParam::FINISH_WITH_PLACEMENT)); // Finish in 1st place on a race if (data->finished == 1) { - missionComponent->Progress(eMissionTaskType::RACING, Game::zoneManager->GetZone()->GetWorldID(), (LWOOBJID)eRacingTaskParam::FIRST_PLACE_MULTIPLE_TRACKS); // Finish in 1st place on multiple tracks. - missionComponent->Progress(eMissionTaskType::RACING, Game::zoneManager->GetZone()->GetWorldID(), (LWOOBJID)eRacingTaskParam::WIN_RACE_IN_WORLD); // Finished first place in specific world. + missionComponent->Progress(eMissionTaskType::RACING, Game::zoneManager->GetZone()->GetWorldID(), static_cast(eRacingTaskParam::FIRST_PLACE_MULTIPLE_TRACKS)); // Finish in 1st place on multiple tracks. + missionComponent->Progress(eMissionTaskType::RACING, Game::zoneManager->GetZone()->GetWorldID(), static_cast(eRacingTaskParam::WIN_RACE_IN_WORLD)); // Finished first place in specific world. } if (data->finished == m_LoadedPlayers) { - missionComponent->Progress(eMissionTaskType::RACING, Game::zoneManager->GetZone()->GetWorldID(), (LWOOBJID)eRacingTaskParam::LAST_PLACE_FINISH); // Finished first place in specific world. + missionComponent->Progress(eMissionTaskType::RACING, Game::zoneManager->GetZone()->GetWorldID(), static_cast(eRacingTaskParam::LAST_PLACE_FINISH)); // Finished first place in specific world. } } } else if ((id == "ACT_RACE_EXIT_THE_RACE?" || id == "Exit") && button == m_ActivityExitConfirm) { @@ -439,7 +439,7 @@ void RacingControlComponent::Serialize(RakNet::BitStream* outBitStream, bool bIs // BEGIN Scripted Activity outBitStream->Write1(); - outBitStream->Write(static_cast(m_RacingPlayers.size())); + outBitStream->Write(m_RacingPlayers.size()); for (const auto& player : m_RacingPlayers) { outBitStream->Write(player.playerID); @@ -461,7 +461,7 @@ void RacingControlComponent::Serialize(RakNet::BitStream* outBitStream, bool bIs // END Scripted Activity outBitStream->Write1(); - outBitStream->Write(static_cast(m_RacingPlayers.size())); + outBitStream->Write(m_RacingPlayers.size()); outBitStream->Write(!m_AllPlayersReady); if (!m_AllPlayersReady) { @@ -495,7 +495,7 @@ void RacingControlComponent::Serialize(RakNet::BitStream* outBitStream, bool bIs outBitStream->Write(bIsInitialUpdate); if (bIsInitialUpdate) { outBitStream->Write(m_RemainingLaps); - outBitStream->Write(static_cast(m_PathName.size())); + outBitStream->Write(m_PathName.size()); for (const auto character : m_PathName) { outBitStream->Write(character); } @@ -794,7 +794,7 @@ void RacingControlComponent::Update(float deltaTime) { const auto& position = waypoint.position; - if (std::abs((int)respawnIndex - (int)player.respawnIndex) > 10 && + if (std::abs(static_cast(respawnIndex) - static_cast(player.respawnIndex)) > 10 && player.respawnIndex != path->pathWaypoints.size() - 1) { ++respawnIndex; @@ -848,7 +848,7 @@ void RacingControlComponent::Update(float deltaTime) { if (missionComponent != nullptr) { // Progress lap time tasks - missionComponent->Progress(eMissionTaskType::RACING, (lapTime) * 1000, (LWOOBJID)eRacingTaskParam::LAP_TIME); + missionComponent->Progress(eMissionTaskType::RACING, (lapTime) * 1000, static_cast(eRacingTaskParam::LAP_TIME)); if (player.lap == 3) { m_Finished++; @@ -864,7 +864,7 @@ void RacingControlComponent::Update(float deltaTime) { LeaderboardManager::SaveScore(playerEntity->GetObjectID(), m_ActivityID, static_cast(player.raceTime), static_cast(player.bestLapTime), static_cast(player.finished == 1)); // Entire race time - missionComponent->Progress(eMissionTaskType::RACING, (raceTime) * 1000, (LWOOBJID)eRacingTaskParam::TOTAL_TRACK_TIME); + missionComponent->Progress(eMissionTaskType::RACING, (raceTime) * 1000, static_cast(eRacingTaskParam::TOTAL_TRACK_TIME)); auto* characterComponent = playerEntity->GetComponent(); if (characterComponent != nullptr) { diff --git a/dGame/dComponents/RebuildComponent.cpp b/dGame/dComponents/RebuildComponent.cpp index bcdf4f70..25bab2e5 100644 --- a/dGame/dComponents/RebuildComponent.cpp +++ b/dGame/dComponents/RebuildComponent.cpp @@ -81,14 +81,14 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia Entity* builder = GetBuilder(); if (builder) { - outBitStream->Write((uint32_t)1); + outBitStream->Write(1); outBitStream->Write(builder->GetObjectID()); for (int i = 0; i < 10; i++) { outBitStream->Write(0.0f); } } else { - outBitStream->Write((uint32_t)0); + outBitStream->Write(0); } // END Scripted Activity diff --git a/dGame/dComponents/ScriptedActivityComponent.cpp b/dGame/dComponents/ScriptedActivityComponent.cpp index 838fe5ed..8bcddd05 100644 --- a/dGame/dComponents/ScriptedActivityComponent.cpp +++ b/dGame/dComponents/ScriptedActivityComponent.cpp @@ -468,7 +468,7 @@ float_t ScriptedActivityComponent::GetActivityValue(LWOOBJID playerID, uint32_t auto* data = GetActivityPlayerData(playerID); if (data != nullptr) { - value = data->values[std::min(index, (uint32_t)9)]; + value = data->values[std::min(index, static_cast(9))]; } return value; @@ -477,7 +477,7 @@ float_t ScriptedActivityComponent::GetActivityValue(LWOOBJID playerID, uint32_t void ScriptedActivityComponent::SetActivityValue(LWOOBJID playerID, uint32_t index, float_t value) { auto* data = AddActivityPlayerData(playerID); if (data != nullptr) { - data->values[std::min(index, (uint32_t)9)] = value; + data->values[std::min(index, static_cast(9))] = value; } Game::entityManager->SerializeEntity(m_Parent); diff --git a/dGame/dComponents/SkillComponent.cpp b/dGame/dComponents/SkillComponent.cpp index 7762345e..b65c7d21 100644 --- a/dGame/dComponents/SkillComponent.cpp +++ b/dGame/dComponents/SkillComponent.cpp @@ -89,7 +89,7 @@ void SkillComponent::SyncPlayerProjectile(const LWOOBJID projectileId, RakNet::B auto query = CDClientDatabase::CreatePreppedStmt( "SELECT behaviorID FROM SkillBehavior WHERE skillID = (SELECT skillID FROM ObjectSkills WHERE objectTemplate = ?);"); - query.bind(1, (int)sync_entry.lot); + query.bind(1, static_cast(sync_entry.lot)); auto result = query.execQuery(); @@ -299,7 +299,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c } //start.optionalTargetID = target; - start.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed()); + start.sBitStream.assign(reinterpret_cast(bitStream->GetData()), bitStream->GetNumberOfBytesUsed()); // Write message RakNet::BitStream message; @@ -409,7 +409,7 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry) auto query = CDClientDatabase::CreatePreppedStmt( "SELECT behaviorID FROM SkillBehavior WHERE skillID = (SELECT skillID FROM ObjectSkills WHERE objectTemplate = ?);"); - query.bind(1, (int)entry.lot); + query.bind(1, static_cast(entry.lot)); auto result = query.execQuery(); if (result.eof()) { @@ -430,7 +430,7 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry) DoClientProjectileImpact projectileImpact; - projectileImpact.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed()); + projectileImpact.sBitStream.assign(reinterpret_cast(bitStream->GetData()), bitStream->GetNumberOfBytesUsed()); projectileImpact.i64OwnerID = this->m_Parent->GetObjectID(); projectileImpact.i64OrgID = entry.id; projectileImpact.i64TargetID = entry.branchContext.target; diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index 63b9d7e9..b9e5284d 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -269,7 +269,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System auto* skill_component = entity->GetComponent(); if (skill_component != nullptr) { - auto* bs = new RakNet::BitStream((unsigned char*)message.sBitStream.c_str(), message.sBitStream.size(), false); + auto* bs = new RakNet::BitStream(reinterpret_cast(const_cast(message.sBitStream.c_str())), message.sBitStream.size(), false); skill_component->SyncPlayerProjectile(message.i64LocalID, bs, message.i64TargetID); @@ -296,7 +296,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System bool success = false; if (behaviorId > 0) { - RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)startSkill.sBitStream.c_str(), startSkill.sBitStream.size(), false); + RakNet::BitStream* bs = new RakNet::BitStream(reinterpret_cast(const_cast(startSkill.sBitStream.c_str())), startSkill.sBitStream.size(), false); auto* skillComponent = entity->GetComponent(); @@ -353,7 +353,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System } if (usr != nullptr) { - RakNet::BitStream* bs = new RakNet::BitStream((unsigned char*)sync.sBitStream.c_str(), sync.sBitStream.size(), false); + RakNet::BitStream* bs = new RakNet::BitStream(reinterpret_cast(const_cast(sync.sBitStream.c_str())), sync.sBitStream.size(), false); auto* skillComponent = entity->GetComponent(); diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 09f9fdbb..e6c1290b 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -389,7 +389,7 @@ void GameMessages::SendPlatformResync(Entity* entity, const SystemAddress& sysAd bitStream.Write(bReverse); bitStream.Write(bStopAtDesiredWaypoint); bitStream.Write(eCommand); - bitStream.Write(static_cast(movementState)); + bitStream.Write(static_cast(movementState)); bitStream.Write(eUnexpectedCommand); bitStream.Write(fIdleTimeElapsed); bitStream.Write(fMoveTimeElapsed); @@ -582,7 +582,7 @@ void GameMessages::SendNotifyMissionTask(Entity* entity, const SystemAddress& sy bitStream.Write(missionID); bitStream.Write(taskMask); - bitStream.Write((unsigned char)updates.size()); + bitStream.Write(updates.size()); for (uint32_t i = 0; i < updates.size(); ++i) { bitStream.Write(updates[i]); @@ -1950,7 +1950,7 @@ void GameMessages::SendBBBSaveResponse(const LWOOBJID& objectId, const LWOOBJID& bitStream.Write(buffer[i]); SEND_PACKET; - PacketUtils::SavePacket("eGameMessageType::BBB_SAVE_RESPONSE.bin", (char*)bitStream.GetData(), bitStream.GetNumberOfBytesUsed()); + //PacketUtils::SavePacket("eGameMessageType::BBB_SAVE_RESPONSE.bin", reinterpret_cast(bitStream.GetData()), bitStream.GetNumberOfBytesUsed()); } // Property @@ -4916,7 +4916,7 @@ void GameMessages::HandleFireEventServerSide(RakNet::BitStream* inStream, Entity mapId = Game::zoneManager->GetZoneID().GetMapID(); // Fallback to sending the player back to the same zone. } - LOG("Player %llu has requested zone transfer to (%i, %i).", sender->GetObjectID(), (int)mapId, (int)cloneId); + LOG("Player %llu has requested zone transfer to (%i, %i).", sender->GetObjectID(), static_cast(mapId), static_cast(cloneId)); auto* character = player->GetCharacter(); @@ -5282,7 +5282,7 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity) /*uint32_t deathTypeLength = deathType.size(); inStream->Read(deathTypeLength); for (uint32_t k = 0; k < deathTypeLength; k++) { - inStream->Read(static_cast(deathType[k])); + inStream->Read(deathType[k]); }*/ inStream->Read(directionRelative_AngleXZ); @@ -6070,7 +6070,7 @@ void GameMessages::HandleUpdatePlayerStatistic(RakNet::BitStream* inStream, Enti auto* characterComponent = entity->GetComponent(); if (characterComponent != nullptr) { - characterComponent->UpdatePlayerStatistic((StatisticID)updateID, (uint64_t)std::max(updateValue, int64_t(0))); + characterComponent->UpdatePlayerStatistic(static_cast(updateID), static_cast(std::max(updateValue, static_cast(0)))); } } diff --git a/dGame/dGameMessages/PropertyDataMessage.cpp b/dGame/dGameMessages/PropertyDataMessage.cpp index e39cfeca..29bc8ea9 100644 --- a/dGame/dGameMessages/PropertyDataMessage.cpp +++ b/dGame/dGameMessages/PropertyDataMessage.cpp @@ -17,21 +17,21 @@ void GameMessages::PropertyDataMessage::Serialize(RakNet::BitStream& stream) con stream.Write(cloneId); // clone id const auto& name = GeneralUtils::UTF8ToUTF16(Name); - stream.Write(uint32_t(name.size())); + stream.Write(name.size()); for (uint32_t i = 0; i < name.size(); ++i) { - stream.Write(uint16_t(name[i])); + stream.Write(name[i]); } const auto& description = GeneralUtils::UTF8ToUTF16(Description); - stream.Write(uint32_t(description.size())); + stream.Write(description.size()); for (uint32_t i = 0; i < description.size(); ++i) { - stream.Write(uint16_t(description[i])); + stream.Write(description[i]); } const auto& owner = GeneralUtils::UTF8ToUTF16(OwnerName); - stream.Write(uint32_t(owner.size())); + stream.Write(owner.size()); for (uint32_t i = 0; i < owner.size(); ++i) { - stream.Write(uint16_t(owner[i])); + stream.Write(owner[i]); } stream.Write(OwnerId); @@ -49,9 +49,9 @@ void GameMessages::PropertyDataMessage::Serialize(RakNet::BitStream& stream) con stream.Write(0); const auto& spawn = GeneralUtils::ASCIIToUTF16(SpawnName); - stream.Write(uint32_t(spawn.size())); + stream.Write(spawn.size()); for (uint32_t i = 0; i < spawn.size(); ++i) { - stream.Write(uint16_t(spawn[i])); + stream.Write(spawn[i]); } stream.Write(0); // String length @@ -71,9 +71,9 @@ void GameMessages::PropertyDataMessage::Serialize(RakNet::BitStream& stream) con // Does this go here??? // const auto& rejectionReasonConverted = GeneralUtils::UTF8ToUTF16(rejectionReason); - // stream.Write(uint32_t(rejectionReasonConverted.size())); + // stream.Write(rejectionReasonConverted.size()); // for (uint32_t i = 0; i < rejectionReasonConverted.size(); ++i) { - // stream.Write(uint16_t(rejectionReasonConverted[i])); + // stream.Write(rejectionReasonConverted[i]); // } stream.Write(0); @@ -93,7 +93,7 @@ void GameMessages::PropertyDataMessage::Serialize(RakNet::BitStream& stream) con stream.Write(PrivacyOption); - stream.Write(uint32_t(Paths.size())); + stream.Write(Paths.size()); for (const auto& path : Paths) { stream.Write(path.x); diff --git a/dGame/dGameMessages/PropertySelectQueryProperty.cpp b/dGame/dGameMessages/PropertySelectQueryProperty.cpp index 6e975879..2a256764 100644 --- a/dGame/dGameMessages/PropertySelectQueryProperty.cpp +++ b/dGame/dGameMessages/PropertySelectQueryProperty.cpp @@ -4,21 +4,21 @@ void PropertySelectQueryProperty::Serialize(RakNet::BitStream& stream) const { stream.Write(CloneId); const auto& owner = GeneralUtils::UTF8ToUTF16(OwnerName); - stream.Write(uint32_t(owner.size())); + stream.Write(owner.size()); for (uint32_t i = 0; i < owner.size(); ++i) { - stream.Write(static_cast(owner[i])); + stream.Write(owner[i]); } const auto& name = GeneralUtils::UTF8ToUTF16(Name); - stream.Write(uint32_t(name.size())); + stream.Write(name.size()); for (uint32_t i = 0; i < name.size(); ++i) { - stream.Write(static_cast(name[i])); + stream.Write(name[i]); } const auto& description = GeneralUtils::UTF8ToUTF16(Description); - stream.Write(uint32_t(description.size())); + stream.Write(description.size()); for (uint32_t i = 0; i < description.size(); ++i) { - stream.Write(static_cast(description[i])); + stream.Write(description[i]); } stream.Write(Reputation); diff --git a/dGame/dInventory/Item.cpp b/dGame/dInventory/Item.cpp index 9e4b46f6..06c6900f 100644 --- a/dGame/dInventory/Item.cpp +++ b/dGame/dInventory/Item.cpp @@ -251,7 +251,7 @@ bool Item::Consume() { auto skills = skillsTable->Query([=](const CDObjectSkills entry) { return entry.objectTemplate == static_cast(lot); - }); + }); auto success = false; diff --git a/dGame/dInventory/ItemSet.cpp b/dGame/dInventory/ItemSet.cpp index a8e58739..3364b63b 100644 --- a/dGame/dInventory/ItemSet.cpp +++ b/dGame/dInventory/ItemSet.cpp @@ -19,7 +19,7 @@ ItemSet::ItemSet(const uint32_t id, InventoryComponent* inventoryComponent) { auto query = CDClientDatabase::CreatePreppedStmt( "SELECT skillSetWith2, skillSetWith3, skillSetWith4, skillSetWith5, skillSetWith6, itemIDs FROM ItemSets WHERE setID = ?;"); - query.bind(1, (int)id); + query.bind(1, static_cast(id)); auto result = query.execQuery(); diff --git a/dGame/dMission/Mission.cpp b/dGame/dMission/Mission.cpp index 5eb02117..6799b834 100644 --- a/dGame/dMission/Mission.cpp +++ b/dGame/dMission/Mission.cpp @@ -329,9 +329,9 @@ void Mission::Complete(const bool yieldRewards) { missionComponent->Progress(eMissionTaskType::META, info.id); - missionComponent->Progress(eMissionTaskType::RACING, info.id, (LWOOBJID)eRacingTaskParam::COMPLETE_ANY_RACING_TASK); + missionComponent->Progress(eMissionTaskType::RACING, info.id, static_cast(eRacingTaskParam::COMPLETE_ANY_RACING_TASK)); - missionComponent->Progress(eMissionTaskType::RACING, info.id, (LWOOBJID)eRacingTaskParam::COMPLETE_TRACK_TASKS); + missionComponent->Progress(eMissionTaskType::RACING, info.id, static_cast(eRacingTaskParam::COMPLETE_TRACK_TASKS)); auto* missionEmailTable = CDClientManager::Instance().GetTable(); diff --git a/dGame/dUtilities/Loot.cpp b/dGame/dUtilities/Loot.cpp index 09c465bf..25c81e74 100644 --- a/dGame/dUtilities/Loot.cpp +++ b/dGame/dUtilities/Loot.cpp @@ -242,7 +242,7 @@ void Loot::GiveActivityLoot(Entity* player, Entity* source, uint32_t activityID, GiveLoot(player, selectedReward->LootMatrixIndex, eLootSourceType::ACTIVITY); - uint32_t coins = (int)(minCoins + GeneralUtils::GenerateRandomNumber(0, 1) * (maxCoins - minCoins)); + uint32_t coins = static_cast(minCoins + GeneralUtils::GenerateRandomNumber(0, 1) * (maxCoins - minCoins)); auto* character = player->GetCharacter(); @@ -280,7 +280,7 @@ void Loot::DropLoot(Entity* player, Entity* killedObject, std::unordered_map(0, 1) * (maxCoins - minCoins)); + uint32_t coins = static_cast(minCoins + GeneralUtils::GenerateRandomNumber(0, 1) * (maxCoins - minCoins)); GameMessages::SendDropClientLoot(player, source, LOT_NULL, coins, spawnPosition); } diff --git a/dGame/dUtilities/Preconditions.cpp b/dGame/dUtilities/Preconditions.cpp index 46ee7c18..12059b5b 100644 --- a/dGame/dUtilities/Preconditions.cpp +++ b/dGame/dUtilities/Preconditions.cpp @@ -19,7 +19,7 @@ std::map Preconditions::cache = {}; Precondition::Precondition(const uint32_t condition) { auto query = CDClientDatabase::CreatePreppedStmt( "SELECT type, targetLOT, targetCount FROM Preconditions WHERE id = ?;"); - query.bind(1, (int)condition); + query.bind(1, static_cast(condition)); auto result = query.execQuery(); diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index 05817e3b..104b1232 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -1191,9 +1191,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit auto dest = static_cast(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); if (dest) { - dest->SetHealth((int)dest->GetMaxHealth()); - dest->SetArmor((int)dest->GetMaxArmor()); - dest->SetImagination((int)dest->GetMaxImagination()); + dest->SetHealth(static_cast(dest->GetMaxHealth())); + dest->SetArmor(static_cast(dest->GetMaxArmor())); + dest->SetImagination(static_cast(dest->GetMaxImagination())); } Game::entityManager->SerializeEntity(entity); @@ -1317,7 +1317,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit int32_t type; if (args.size() >= 2 && GeneralUtils::TryParse(args[1], type)) { - lootType = (eLootSourceType)type; + lootType = static_cast(type); } GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, lootType); @@ -1357,7 +1357,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit if (!characterComponent) return; auto levelComponent = entity->GetComponent(); auto query = CDClientDatabase::CreatePreppedStmt("SELECT requiredUScore from LevelProgressionLookup WHERE id = ?;"); - query.bind(1, (int)requestedLevel); + query.bind(1, static_cast(requestedLevel)); auto result = query.execQuery(); if (result.eof()) return; @@ -1741,13 +1741,13 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit ChatPackets::SendSystemMessage( sysAddr, - u"Peak RSS: " + GeneralUtils::to_u16string((float)((double)Metrics::GetPeakRSS() / 1.024e6)) + + u"Peak RSS: " + GeneralUtils::to_u16string(static_cast(static_cast(Metrics::GetPeakRSS()) / 1.024e6)) + u"MB" ); ChatPackets::SendSystemMessage( sysAddr, - u"Current RSS: " + GeneralUtils::to_u16string((float)((double)Metrics::GetCurrentRSS() / 1.024e6)) + + u"Current RSS: " + GeneralUtils::to_u16string(static_cast(static_cast(Metrics::GetCurrentRSS()) / 1.024e6)) + u"MB" ); @@ -1792,7 +1792,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit totalRuns += 1; bool doBreak = false; for (const auto& kv : lootRoll) { - if ((uint32_t)kv.first == targetLot) { + if (static_cast(kv.first) == targetLot) { doBreak = true; } } @@ -1807,7 +1807,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit + u" times. It ran " + GeneralUtils::to_u16string(totalRuns) + u" times. Averaging out at " - + GeneralUtils::to_u16string((float)totalRuns / loops); + + GeneralUtils::to_u16string(static_cast(totalRuns) / loops); ChatPackets::SendSystemMessage(sysAddr, message); } diff --git a/dNavigation/dNavMesh.cpp b/dNavigation/dNavMesh.cpp index c1d752bd..ab9ed2d5 100644 --- a/dNavigation/dNavMesh.cpp +++ b/dNavigation/dNavMesh.cpp @@ -105,7 +105,7 @@ void dNavMesh::LoadNavmesh() { if (!tileHeader.tileRef || !tileHeader.dataSize) break; - unsigned char* data = (unsigned char*)dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM); + unsigned char* data = static_cast(dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM)); if (!data) break; memset(data, 0, tileHeader.dataSize); readLen = fread(data, tileHeader.dataSize, 1, fp); diff --git a/dNavigation/dTerrain/RawChunk.cpp b/dNavigation/dTerrain/RawChunk.cpp index e4f753cd..fe7ac8a2 100644 --- a/dNavigation/dTerrain/RawChunk.cpp +++ b/dNavigation/dTerrain/RawChunk.cpp @@ -20,40 +20,40 @@ RawChunk::RawChunk(std::ifstream& stream) { uint32_t colorMapSize; BinaryIO::BinaryRead(stream, colorMapSize); - stream.seekg((uint32_t)stream.tellg() + (colorMapSize * colorMapSize * 4)); + stream.seekg(static_cast(stream.tellg()) + (colorMapSize * colorMapSize * 4)); uint32_t lightmapSize; BinaryIO::BinaryRead(stream, lightmapSize); - stream.seekg((uint32_t)stream.tellg() + (lightmapSize)); + stream.seekg(static_cast(stream.tellg()) + (lightmapSize)); uint32_t colorMapSize2; BinaryIO::BinaryRead(stream, colorMapSize2); - stream.seekg((uint32_t)stream.tellg() + (colorMapSize2 * colorMapSize2 * 4)); + stream.seekg(static_cast(stream.tellg()) + (colorMapSize2 * colorMapSize2 * 4)); uint8_t unknown; BinaryIO::BinaryRead(stream, unknown); uint32_t blendmapSize; BinaryIO::BinaryRead(stream, blendmapSize); - stream.seekg((uint32_t)stream.tellg() + (blendmapSize)); + stream.seekg(static_cast(stream.tellg()) + (blendmapSize)); uint32_t pointSize; BinaryIO::BinaryRead(stream, pointSize); - stream.seekg((uint32_t)stream.tellg() + (pointSize * 9 * 4)); + stream.seekg(static_cast(stream.tellg()) + (pointSize * 9 * 4)); - stream.seekg((uint32_t)stream.tellg() + (colorMapSize * colorMapSize)); + stream.seekg(static_cast(stream.tellg()) + (colorMapSize * colorMapSize)); uint32_t endCounter; BinaryIO::BinaryRead(stream, endCounter); - stream.seekg((uint32_t)stream.tellg() + (endCounter * 2)); + stream.seekg(static_cast(stream.tellg()) + (endCounter * 2)); if (endCounter != 0) { - stream.seekg((uint32_t)stream.tellg() + (32)); + stream.seekg(static_cast(stream.tellg()) + (32)); for (int i = 0; i < 0x10; i++) { uint16_t finalCountdown; BinaryIO::BinaryRead(stream, finalCountdown); - stream.seekg((uint32_t)stream.tellg() + (finalCountdown * 2)); + stream.seekg(static_cast(stream.tellg()) + (finalCountdown * 2)); } } diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index 4e84eeca..83c1f58e 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -64,12 +64,12 @@ void AuthPackets::SendHandshake(dServer* server, const SystemAddress& sysAddr, c return; } bitStream.Write(netVersion); - bitStream.Write(uint32_t(0x93)); + bitStream.Write(0x93); if (serverType == ServerType::Auth) bitStream.Write(uint32_t(1)); //Conn: auth - else bitStream.Write(uint32_t(4)); //Conn: world + else bitStream.Write(4); //Conn: world - bitStream.Write(uint32_t(0)); //Server process ID + bitStream.Write(0); //Server process ID bitStream.Write(nextServerPort); server->Send(&bitStream, sysAddr, false); @@ -155,7 +155,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd RakNet::BitStream packet; BitStreamUtils::WriteHeader(packet, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE); - packet.Write(static_cast(responseCode)); + packet.Write(GeneralUtils::CastUnderlyingType(responseCode)); // Event Gating packet.Write(LUString(Game::config->GetValue("event_1"))); @@ -189,8 +189,8 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd packet.Write(LUString("")); // Write the Character and Chat Ports - packet.Write(static_cast(wServerPort)); - packet.Write(static_cast(0)); + packet.Write(wServerPort); + packet.Write(0); // CDN Key packet.Write(LUString("")); @@ -198,26 +198,26 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd // CDN Ticket packet.Write(LUString("00000000-0000-0000-0000-000000000000", 37)); - packet.Write(static_cast(0)); // Language + packet.Write(0); // Language // Write the localization packet.Write(LUString("US", 3)); - packet.Write(static_cast(false)); // Just upgraded from F2P - packet.Write(static_cast(false)); // User is F2P - packet.Write(static_cast(0)); // Time Remaining in F2P + packet.Write(false); // Just upgraded from F2P + packet.Write(false); // User is F2P + packet.Write(0); // Time Remaining in F2P // Write custom error message - packet.Write(static_cast(errorMsg.length())); + packet.Write(errorMsg.length()); packet.Write(LUWString(errorMsg, static_cast(errorMsg.length()))); // Here write auth logs - packet.Write(static_cast(20)); + packet.Write(20); for (uint32_t i = 0; i < 20; ++i) { - packet.Write(static_cast(8)); - packet.Write(static_cast(44)); - packet.Write(static_cast(14000)); - packet.Write(static_cast(0)); + packet.Write(8); + packet.Write(44); + packet.Write(14000); + packet.Write(0); } server->Send(&packet, sysAddr, false); diff --git a/dNet/BitStreamUtils.h b/dNet/BitStreamUtils.h index 6daa1c17..7403d0e1 100644 --- a/dNet/BitStreamUtils.h +++ b/dNet/BitStreamUtils.h @@ -47,9 +47,9 @@ struct LUWString { namespace BitStreamUtils { template void WriteHeader(RakNet::BitStream& bitStream, eConnectionType connectionType, T internalPacketID) { - bitStream.Write(MessageID(ID_USER_PACKET_ENUM)); + bitStream.Write(ID_USER_PACKET_ENUM); bitStream.Write(connectionType); - bitStream.Write(static_cast(internalPacketID)); + bitStream.Write(static_cast(internalPacketID)); bitStream.Write(0); } diff --git a/dNet/ChatPackets.cpp b/dNet/ChatPackets.cpp index 20f8aafa..63eff5ef 100644 --- a/dNet/ChatPackets.cpp +++ b/dNet/ChatPackets.cpp @@ -17,20 +17,20 @@ void ChatPackets::SendChatMessage(const SystemAddress& sysAddr, char chatChannel CBITSTREAM; BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GENERAL_CHAT_MESSAGE); - bitStream.Write(static_cast(0)); + bitStream.Write(0); bitStream.Write(chatChannel); - bitStream.Write(static_cast(message.size())); + bitStream.Write(message.size()); bitStream.Write(LUWString(senderName)); bitStream.Write(playerObjectID); - bitStream.Write(static_cast(0)); - bitStream.Write(static_cast(0)); + bitStream.Write(0); + bitStream.Write(0); for (uint32_t i = 0; i < message.size(); ++i) { - bitStream.Write(static_cast(message[i])); + bitStream.Write(message[i]); } - bitStream.Write(static_cast(0)); + bitStream.Write(0); SEND_PACKET_BROADCAST; } @@ -39,21 +39,21 @@ void ChatPackets::SendSystemMessage(const SystemAddress& sysAddr, const std::u16 CBITSTREAM; BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GENERAL_CHAT_MESSAGE); - bitStream.Write(static_cast(0)); - bitStream.Write(static_cast(4)); + bitStream.Write(0); + bitStream.Write(4); - bitStream.Write(static_cast(message.size())); + bitStream.Write(message.size()); bitStream.Write(LUWString("", 33)); - bitStream.Write(static_cast(0)); - bitStream.Write(static_cast(0)); - bitStream.Write(static_cast(0)); + bitStream.Write(0); + bitStream.Write(0); + bitStream.Write(0); for (uint32_t i = 0; i < message.size(); ++i) { - bitStream.Write(static_cast(message[i])); + bitStream.Write(message[i]); } - bitStream.Write(static_cast(0)); + bitStream.Write(0); //This is so Wincent's announcement works: if (sysAddr != UNASSIGNED_SYSTEM_ADDRESS) { diff --git a/dNet/PacketUtils.cpp b/dNet/PacketUtils.cpp index 6b39c2f2..95c3b2b1 100644 --- a/dNet/PacketUtils.cpp +++ b/dNet/PacketUtils.cpp @@ -45,7 +45,7 @@ std::string PacketUtils::ReadString(uint32_t startLoc, Packet* packet, bool wide if (packet->length > startLoc) { uint32_t i = 0; - while (packet->data[startLoc + i] != '\0' && packet->length > (uint32_t)(startLoc + i) && maxLen > i) { + while (packet->data[startLoc + i] != '\0' && packet->length > static_cast(startLoc + i) && maxLen > i) { readString.push_back(packet->data[startLoc + i]); if (wide) { diff --git a/dScripts/02_server/Map/AG/NpcAgCourseStarter.cpp b/dScripts/02_server/Map/AG/NpcAgCourseStarter.cpp index b47260f9..515603a0 100644 --- a/dScripts/02_server/Map/AG/NpcAgCourseStarter.cpp +++ b/dScripts/02_server/Map/AG/NpcAgCourseStarter.cpp @@ -52,7 +52,7 @@ void NpcAgCourseStarter::OnMessageBoxResponse(Entity* self, Entity* sender, int3 time_t startTime = std::time(0) + 4; // Offset for starting timer - data->values[1] = *(float*)&startTime; + data->values[1] = *reinterpret_cast(&startTime); Game::entityManager->SerializeEntity(self); } else if (identifier == u"FootRaceCancel") { @@ -81,9 +81,9 @@ void NpcAgCourseStarter::OnFireEventServerSide(Entity* self, Entity* sender, std scriptedActivityComponent->RemoveActivityPlayerData(sender->GetObjectID()); } else if (args == "course_finish") { time_t endTime = std::time(0); - time_t finish = (endTime - *(time_t*)&data->values[1]); + time_t finish = (endTime - *reinterpret_cast(&data->values[1])); - data->values[2] = *(float*)&finish; + data->values[2] = *reinterpret_cast(&finish); auto* missionComponent = sender->GetComponent(); if (missionComponent != nullptr) { diff --git a/dScripts/02_server/Map/AM/AmDrawBridge.cpp b/dScripts/02_server/Map/AM/AmDrawBridge.cpp index e6b80764..11d52cd7 100644 --- a/dScripts/02_server/Map/AM/AmDrawBridge.cpp +++ b/dScripts/02_server/Map/AM/AmDrawBridge.cpp @@ -99,7 +99,7 @@ void AmDrawBridge::MoveBridgeDown(Entity* self, Entity* bridge, bool down) { const auto travelTime = 2.0f; - forwardVect = forwardVect * (float)((degrees / travelTime) * (3.14f / 180.0f)); + forwardVect = forwardVect * static_cast((degrees / travelTime) * (3.14f / 180.0f)); simplePhysicsComponent->SetAngularVelocity(forwardVect); diff --git a/dScripts/02_server/Map/NS/NsLegoClubDoor.cpp b/dScripts/02_server/Map/NS/NsLegoClubDoor.cpp index 35d4735c..959466e9 100644 --- a/dScripts/02_server/Map/NS/NsLegoClubDoor.cpp +++ b/dScripts/02_server/Map/NS/NsLegoClubDoor.cpp @@ -4,7 +4,7 @@ #include "Amf3.h" void NsLegoClubDoor::OnStartup(Entity* self) { - self->SetVar(u"currentZone", (int32_t)Game::zoneManager->GetZoneID().GetMapID()); + self->SetVar(u"currentZone", static_cast(Game::zoneManager->GetZoneID().GetMapID())); self->SetVar(u"choiceZone", m_ChoiceZoneID); self->SetVar(u"teleportAnim", m_TeleportAnim); self->SetVar(u"teleportString", m_TeleportString); diff --git a/dScripts/02_server/Map/NS/NsLupTeleport.cpp b/dScripts/02_server/Map/NS/NsLupTeleport.cpp index c75143fc..6886b4cd 100644 --- a/dScripts/02_server/Map/NS/NsLupTeleport.cpp +++ b/dScripts/02_server/Map/NS/NsLupTeleport.cpp @@ -4,7 +4,7 @@ #include "Amf3.h" void NsLupTeleport::OnStartup(Entity* self) { - self->SetVar(u"currentZone", (int32_t)Game::zoneManager->GetZoneID().GetMapID()); + self->SetVar(u"currentZone", static_cast(Game::zoneManager->GetZoneID().GetMapID())); self->SetVar(u"choiceZone", m_ChoiceZoneID); self->SetVar(u"teleportAnim", m_TeleportAnim); self->SetVar(u"teleportString", m_TeleportString); diff --git a/dScripts/02_server/Map/NS/Waves/ZoneNsWaves.cpp b/dScripts/02_server/Map/NS/Waves/ZoneNsWaves.cpp index 184132fe..43ba30df 100644 --- a/dScripts/02_server/Map/NS/Waves/ZoneNsWaves.cpp +++ b/dScripts/02_server/Map/NS/Waves/ZoneNsWaves.cpp @@ -437,7 +437,7 @@ std::vector ZoneNsWaves::GetWaves() { }, {}, {}, "Treasure_Camera", 5.0f, - (uint32_t)-1, + static_cast(-1), true, 60, }, diff --git a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp index 137a9ed3..ccb12e30 100644 --- a/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp +++ b/dScripts/02_server/Map/njhub/boss_instance/NjMonastryBossInstance.cpp @@ -53,9 +53,9 @@ void NjMonastryBossInstance::OnPlayerLoaded(Entity* self, Entity* player) { // Buff the player auto* destroyableComponent = player->GetComponent(); if (destroyableComponent != nullptr) { - destroyableComponent->SetHealth((int32_t)destroyableComponent->GetMaxHealth()); - destroyableComponent->SetArmor((int32_t)destroyableComponent->GetMaxArmor()); - destroyableComponent->SetImagination((int32_t)destroyableComponent->GetMaxImagination()); + destroyableComponent->SetHealth(static_cast(destroyableComponent->GetMaxHealth())); + destroyableComponent->SetArmor(static_cast(destroyableComponent->GetMaxArmor())); + destroyableComponent->SetImagination(static_cast(destroyableComponent->GetMaxImagination())); } // Add player ID to instance @@ -117,7 +117,7 @@ void NjMonastryBossInstance::OnPlayerExit(Entity* self, Entity* player) { void NjMonastryBossInstance::OnActivityTimerDone(Entity* self, const std::string& name) { auto split = GeneralUtils::SplitString(name, TimerSplitChar); auto timerName = split[0]; - auto objectID = split.size() > 1 ? (LWOOBJID)std::stoull(split[1]) : LWOOBJID_EMPTY; + auto objectID = split.size() > 1 ? static_cast(std::stoull(split[1])) : LWOOBJID_EMPTY; if (timerName == WaitingForPlayersTimer) { StartFight(self); @@ -309,7 +309,7 @@ void NjMonastryBossInstance::HandleLowerFrakjawSpawned(Entity* self, Entity* low if (destroyableComponent != nullptr) { const auto doubleHealth = destroyableComponent->GetHealth() * 2; destroyableComponent->SetHealth(doubleHealth); - destroyableComponent->SetMaxHealth((float_t)doubleHealth); + destroyableComponent->SetMaxHealth(static_cast(doubleHealth)); } ActivityTimerStart(self, FrakjawSpawnInTimer + std::to_string(lowerFrakjaw->GetObjectID()), @@ -328,7 +328,7 @@ void NjMonastryBossInstance::HandleLowerFrakjawHit(Entity* self, Entity* lowerFr return; // Progress the fight to the last wave if frakjaw has less than 50% of his health left - if (destroyableComponent->GetHealth() <= (uint32_t)destroyableComponent->GetMaxHealth() / 2 && !self->GetVar(OnLastWaveVarbiale)) { + if (destroyableComponent->GetHealth() <= static_cast(destroyableComponent->GetMaxHealth()) / 2 && !self->GetVar(OnLastWaveVarbiale)) { self->SetVar(OnLastWaveVarbiale, true); // Stun frakjaw during the cinematic diff --git a/dScripts/BaseSurvivalServer.cpp b/dScripts/BaseSurvivalServer.cpp index ffa86968..93476d78 100644 --- a/dScripts/BaseSurvivalServer.cpp +++ b/dScripts/BaseSurvivalServer.cpp @@ -115,7 +115,7 @@ void BaseSurvivalServer::BasePlayerExit(Entity* self, Entity* player) { SetActivityValue(self, player->GetObjectID(), 1, 0); self->SetNetworkVar(NumberOfPlayersVariable, - std::min((uint32_t)0, self->GetNetworkVar(NumberOfPlayersVariable) - 1)); + std::min(static_cast(0), self->GetNetworkVar(NumberOfPlayersVariable) - 1)); } void BaseSurvivalServer::BaseFireEvent(Entity* self, Entity* sender, const std::string& args, int32_t param1, int32_t param2, @@ -370,7 +370,7 @@ void BaseSurvivalServer::GameOver(Entity* self) { for (const auto& survivalMission : missionsToUpdate) { auto* mission = missionComponent->GetMission(survivalMission.first); - if (mission != nullptr && (uint32_t)time >= survivalMission.second + if (mission != nullptr && static_cast(time) >= survivalMission.second && (mission->GetMissionState() == eMissionState::ACTIVE || mission->GetMissionState() == eMissionState::COMPLETE_ACTIVE)) { @@ -421,7 +421,7 @@ void BaseSurvivalServer::SpawnerReset(SpawnerNetworkCollection& spawnerNetworkCo } } - state.totalSpawned = std::max((uint32_t)totalSpawned, state.totalSpawned); + state.totalSpawned = std::max(static_cast(totalSpawned), state.totalSpawned); } void BaseSurvivalServer::SpawnerUpdate(Entity* self, SpawnerNetworkCollection& spawnerNetworkCollection, uint32_t amount) { diff --git a/dScripts/BaseWavesServer.cpp b/dScripts/BaseWavesServer.cpp index 1090d8c5..9be19806 100644 --- a/dScripts/BaseWavesServer.cpp +++ b/dScripts/BaseWavesServer.cpp @@ -95,7 +95,7 @@ void BaseWavesServer::BasePlayerExit(Entity* self, Entity* player) { SetActivityValue(self, player->GetObjectID(), 2, 0); self->SetNetworkVar(NumberOfPlayersVariable, - std::min((uint32_t)0, self->GetNetworkVar(NumberOfPlayersVariable) - 1)); + std::min(static_cast(0), self->GetNetworkVar(NumberOfPlayersVariable) - 1)); } // Done @@ -212,7 +212,7 @@ void BaseWavesServer::OnActivityTimerDone(Entity* self, const std::string& name) const auto currentTime = ActivityTimerGetCurrentTime(self, ClockTickTimer); const auto currentWave = state.waveNumber; - self->SetNetworkVar(WaveCompleteVariable, { currentWave, (uint32_t)currentTime }); + self->SetNetworkVar(WaveCompleteVariable, { currentWave, static_cast(currentTime) }); } else if (name == GameOverWinTimer) { GameOver(self, true); } else if (name == CinematicDoneTimer) { @@ -421,7 +421,7 @@ void BaseWavesServer::SpawnWave(Entity* self) { const auto wave = waves.at(state.waveNumber); // Handles meta info to the client about the current round - if (wave.winDelay != (uint32_t)-1) { + if (wave.winDelay != static_cast(-1)) { self->SetNetworkVar(WonWaveVariable, true); // Close the game if we don't expect a notification from an other entity to end it @@ -436,7 +436,7 @@ void BaseWavesServer::SpawnWave(Entity* self) { } } } else { - if (wave.timeLimit != (uint32_t)-1) { + if (wave.timeLimit != static_cast(-1)) { ActivityTimerStart(self, TimedWaveTimer, 1.0f, wave.timeLimit); self->SetNetworkVar(StartTimedWaveVariable, { wave.timeLimit, state.waveNumber + 1 }); } else { @@ -548,7 +548,7 @@ bool BaseWavesServer::UpdateSpawnedEnemies(Entity* self, LWOOBJID enemyID, uint3 } // Might seem odd to send the next wave but the client isn't 0-indexed so it thinks it completed the correct wave - self->SetNetworkVar(WaveCompleteVariable, { state.waveNumber, (uint32_t)currentTime }); + self->SetNetworkVar(WaveCompleteVariable, { state.waveNumber, static_cast(currentTime) }); return true; } diff --git a/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp b/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp index 2c520670..55c82b95 100644 --- a/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp +++ b/dScripts/ai/MINIGAME/SG_GF/SERVER/SGCannon.cpp @@ -171,7 +171,7 @@ void SGCannon::SuperChargeTimerFunc(Entity* self) { void SGCannon::SpawnWaveTimerFunc(Entity* self) { if (self->GetVar(GameStartedVariable)) { self->SetVar(WaveStatusVariable, true); - const auto wave = (int32_t)self->GetVar(ThisWaveVariable); + const auto wave = static_cast(self->GetVar(ThisWaveVariable)); if (wave != 0 && self->GetVar(SuperChargePausedVariable)) { StartChargedCannon(self, self->GetVar(CurrentSuperChargedTimeVariable)); @@ -187,7 +187,7 @@ void SGCannon::SpawnWaveTimerFunc(Entity* self) { LOG("Current wave spawn: %i/%i", wave, m_Waves.size()); // All waves completed - const auto timeLimit = (float_t)self->GetVar(TimeLimitVariable); + const auto timeLimit = static_cast(self->GetVar(TimeLimitVariable)); if (wave >= m_Waves.size()) { ActivityTimerStart(self, GameOverTimer, timeLimit, timeLimit); } else { @@ -262,7 +262,7 @@ void SGCannon::GameOverTimerFunc(Entity* self) { void SGCannon::DoSpawnTimerFunc(Entity* self, const std::string& name) { if (self->GetVar(GameStartedVariable)) { LOG_DEBUG("time name %s %s", name.c_str(), name.substr(7).c_str()); - const auto spawnNumber = (uint32_t)std::stoi(name.substr(7)); + const auto spawnNumber = static_cast(std::stoi(name.substr(7))); const auto& activeSpawns = self->GetVar>(ActiveSpawnsVariable); LOG_DEBUG("size %i, %i", activeSpawns.size(), spawnNumber); if (activeSpawns.size() <= spawnNumber) { @@ -518,7 +518,7 @@ void SGCannon::SpawnObject(Entity* self, const SGEnemy& toSpawn, bool spawnNow) } void SGCannon::RecordPlayerScore(Entity* self) { - const auto totalScore = self->GetVar(TotalScoreVariable); + const auto totalScore = self->GetVar(TotalScoreVariable); const auto currentWave = self->GetVar(ThisWaveVariable); if (currentWave > 0) { @@ -555,7 +555,7 @@ void SGCannon::PlaySceneAnimation(Entity* self, const std::u16string& animationN } void SGCannon::PauseChargeCannon(Entity* self) { - const auto time = std::max((uint32_t)std::ceil(ActivityTimerGetCurrentTime(self, SuperChargeTimer)), (uint32_t)1); + const auto time = std::max(static_cast(std::ceil(ActivityTimerGetCurrentTime(self, SuperChargeTimer))), static_cast(1)); self->SetVar(SuperChargePausedVariable, true); self->SetVar(CurrentSuperChargedTimeVariable, time); @@ -587,17 +587,17 @@ void SGCannon::StopGame(Entity* self, bool cancel) { auto* missionComponent = player->GetComponent(); if (missionComponent != nullptr) { - missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, self->GetVar(TotalScoreVariable), self->GetObjectID(), "performact_score"); + missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, self->GetVar(TotalScoreVariable), self->GetObjectID(), "performact_score"); missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, self->GetVar(MaxStreakVariable), self->GetObjectID(), "performact_streak"); - missionComponent->Progress(eMissionTaskType::ACTIVITY, m_CannonLot, 0, "", self->GetVar(TotalScoreVariable)); + missionComponent->Progress(eMissionTaskType::ACTIVITY, m_CannonLot, 0, "", self->GetVar(TotalScoreVariable)); } - Loot::GiveActivityLoot(player, self, GetGameID(self), self->GetVar(TotalScoreVariable)); + Loot::GiveActivityLoot(player, self, GetGameID(self), self->GetVar(TotalScoreVariable)); SaveScore(self, player->GetObjectID(), - static_cast(self->GetVar(TotalScoreVariable)), static_cast(self->GetVar(MaxStreakVariable)), percentage); + static_cast(self->GetVar(TotalScoreVariable)), static_cast(self->GetVar(MaxStreakVariable)), percentage); - StopActivity(self, player->GetObjectID(), self->GetVar(TotalScoreVariable), self->GetVar(MaxStreakVariable), percentage); + StopActivity(self, player->GetObjectID(), self->GetVar(TotalScoreVariable), self->GetVar(MaxStreakVariable), percentage); self->SetNetworkVar(AudioFinalWaveDoneVariable, true); // Give the player the model rewards they earned @@ -609,7 +609,7 @@ void SGCannon::StopGame(Entity* self, bool cancel) { } self->SetNetworkVar(u"UI_Rewards", - GeneralUtils::to_u16string(self->GetVar(TotalScoreVariable)) + u"_0_0_0_0_0_0" + GeneralUtils::to_u16string(self->GetVar(TotalScoreVariable)) + u"_0_0_0_0_0_0" ); } @@ -634,7 +634,7 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time ActivityTimerStart(self, timerName, respawnTime, respawnTime); } - int score = spawnInfo.score; + int32_t score = spawnInfo.score; if (score > 0) { score += score * GetCurrentBonus(self); @@ -652,7 +652,7 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time auto lastSuperTotal = self->GetVar(u"LastSuperTotal"); - auto scScore = self->GetVar(TotalScoreVariable) - lastSuperTotal; + auto scScore = self->GetVar(TotalScoreVariable) - lastSuperTotal; LOG("LastSuperTotal: %i, scScore: %i, constants.chargedPoints: %i", lastSuperTotal, scScore, constants.chargedPoints @@ -661,7 +661,7 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time if (!self->GetVar(SuperChargeActiveVariable) && scScore >= constants.chargedPoints && score >= 0) { StartChargedCannon(self); self->SetNetworkVar(u"SuperChargeBar", 100.0f); - self->SetVar(u"LastSuperTotal", self->GetVar(TotalScoreVariable)); + self->SetVar(u"LastSuperTotal", self->GetVar(TotalScoreVariable)); } UpdateStreak(self); @@ -673,13 +673,13 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time target->GetPosition() ); - auto newScore = (int)self->GetVar(TotalScoreVariable) + score; + auto newScore = self->GetVar(TotalScoreVariable) + score; if (newScore < 0) { newScore = 0; } - self->SetVar(TotalScoreVariable, newScore); + self->SetVar(TotalScoreVariable, newScore); self->SetNetworkVar(u"updateScore", newScore); @@ -1038,7 +1038,7 @@ void SGCannon::ResetVars(Entity* self) { self->SetVar(LastSuperTotalVariable, 0); self->SetVar(CurrentRewardVariable, LOT_NULL); self->SetVar>(RewardsVariable, {}); - self->SetVar(TotalScoreVariable, 0); + self->SetVar(TotalScoreVariable, 0); self->SetVar(u"m_curStreak", 0); self->SetNetworkVar(u"SuperChargeBar", 0); diff --git a/dScripts/ai/RACING/OBJECTS/FvRaceSmashEggImagineServer.cpp b/dScripts/ai/RACING/OBJECTS/FvRaceSmashEggImagineServer.cpp index 2bdb0364..cdd0f89b 100644 --- a/dScripts/ai/RACING/OBJECTS/FvRaceSmashEggImagineServer.cpp +++ b/dScripts/ai/RACING/OBJECTS/FvRaceSmashEggImagineServer.cpp @@ -30,8 +30,8 @@ void FvRaceSmashEggImagineServer::OnDie(Entity* self, Entity* killer) { } if (missionComponent == nullptr) return; // Dragon eggs have their own smash server so we handle mission progression for them here. - missionComponent->Progress(eMissionTaskType::RACING, 0, (LWOOBJID)eRacingTaskParam::SMASHABLES); - missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), (LWOOBJID)eRacingTaskParam::SMASH_SPECIFIC_SMASHABLE); + missionComponent->Progress(eMissionTaskType::RACING, 0, static_cast(eRacingTaskParam::SMASHABLES)); + missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), static_cast(eRacingTaskParam::SMASH_SPECIFIC_SMASHABLE)); } } diff --git a/dScripts/ai/RACING/OBJECTS/RaceImagineCrateServer.cpp b/dScripts/ai/RACING/OBJECTS/RaceImagineCrateServer.cpp index 20a3c0cc..8aff0365 100644 --- a/dScripts/ai/RACING/OBJECTS/RaceImagineCrateServer.cpp +++ b/dScripts/ai/RACING/OBJECTS/RaceImagineCrateServer.cpp @@ -50,7 +50,7 @@ void RaceImagineCrateServer::OnDie(Entity* self, Entity* killer) { // Progress racing smashable missions if (missionComponent == nullptr) return; - missionComponent->Progress(eMissionTaskType::RACING, 0, (LWOOBJID)eRacingTaskParam::SMASHABLES); + missionComponent->Progress(eMissionTaskType::RACING, 0, static_cast(eRacingTaskParam::SMASHABLES)); } } } diff --git a/dScripts/ai/RACING/OBJECTS/RaceImaginePowerup.cpp b/dScripts/ai/RACING/OBJECTS/RaceImaginePowerup.cpp index d55eeffd..17e263fb 100644 --- a/dScripts/ai/RACING/OBJECTS/RaceImaginePowerup.cpp +++ b/dScripts/ai/RACING/OBJECTS/RaceImaginePowerup.cpp @@ -32,6 +32,6 @@ void RaceImaginePowerup::OnFireEventServerSide(Entity* self, Entity* sender, std auto* missionComponent = sender->GetComponent(); if (missionComponent == nullptr) return; - missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), (LWOOBJID)eRacingTaskParam::COLLECT_IMAGINATION); + missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), static_cast(eRacingTaskParam::COLLECT_IMAGINATION)); } } diff --git a/dScripts/ai/RACING/OBJECTS/RaceSmashServer.cpp b/dScripts/ai/RACING/OBJECTS/RaceSmashServer.cpp index 5fcb2ff4..340ab98e 100644 --- a/dScripts/ai/RACING/OBJECTS/RaceSmashServer.cpp +++ b/dScripts/ai/RACING/OBJECTS/RaceSmashServer.cpp @@ -23,9 +23,9 @@ void RaceSmashServer::OnDie(Entity* self, Entity* killer) { // Progress racing smashable missions if (missionComponent == nullptr) return; - missionComponent->Progress(eMissionTaskType::RACING, 0, (LWOOBJID)eRacingTaskParam::SMASHABLES); + missionComponent->Progress(eMissionTaskType::RACING, 0, static_cast(eRacingTaskParam::SMASHABLES)); // Progress missions that ask us to smash a specific smashable. - missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), (LWOOBJID)eRacingTaskParam::SMASH_SPECIFIC_SMASHABLE); + missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), static_cast(eRacingTaskParam::SMASH_SPECIFIC_SMASHABLE)); } } } diff --git a/dZoneManager/Zone.cpp b/dZoneManager/Zone.cpp index 463f0a8a..cbaccded 100644 --- a/dZoneManager/Zone.cpp +++ b/dZoneManager/Zone.cpp @@ -59,7 +59,7 @@ void Zone::LoadZoneIntoMemory() { if (m_FileFormatVersion >= Zone::FileFormatVersion::Alpha) BinaryIO::BinaryRead(file, mapRevision); BinaryIO::BinaryRead(file, m_WorldID); - if ((uint16_t)m_WorldID != m_ZoneID.GetMapID()) LOG("WorldID: %i doesn't match MapID %i! Is this intended?", m_WorldID, m_ZoneID.GetMapID()); + if (static_cast(m_WorldID) != m_ZoneID.GetMapID()) LOG("WorldID: %i doesn't match MapID %i! Is this intended?", m_WorldID, m_ZoneID.GetMapID()); AddRevision(LWOSCENEID_INVALID, mapRevision); @@ -147,7 +147,7 @@ void Zone::LoadZoneIntoMemory() { } else { LOG("Failed to open: %s", m_ZoneFilePath.c_str()); } - + m_ZonePath = m_ZoneFilePath.substr(0, m_ZoneFilePath.rfind('/') + 1); } @@ -243,7 +243,7 @@ void Zone::LoadScene(std::istream& file) { void Zone::LoadLUTriggers(std::string triggerFile, SceneRef& scene) { auto file = Game::assetManager->GetFile((m_ZonePath + triggerFile).c_str()); - + std::stringstream data; data << file.rdbuf();