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 <jonahebenn@yahoo.com>
This commit is contained in:
jadebenn 2023-12-27 22:18:20 -06:00 committed by GitHub
parent 46ac039a3b
commit ef6f2f133e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
68 changed files with 281 additions and 270 deletions

View File

@ -66,7 +66,7 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GET_FRIENDS_LIST_RESPONSE); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::GET_FRIENDS_LIST_RESPONSE);
bitStream.Write<uint8_t>(0); bitStream.Write<uint8_t>(0);
bitStream.Write<uint16_t>(1); //Length of packet -- just writing one as it doesn't matter, client skips it. bitStream.Write<uint16_t>(1); //Length of packet -- just writing one as it doesn't matter, client skips it.
bitStream.Write((uint16_t)player->friends.size()); bitStream.Write<uint16_t>(player->friends.size());
for (auto& data : player->friends) { for (auto& data : player->friends) {
data.Serialize(bitStream); data.Serialize(bitStream);
@ -705,7 +705,7 @@ void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeader
bitStream.Write(ucLootFlag); bitStream.Write(ucLootFlag);
bitStream.Write(ucNumOfOtherPlayers); bitStream.Write(ucNumOfOtherPlayers);
bitStream.Write(ucResponseCode); bitStream.Write(ucResponseCode);
bitStream.Write(static_cast<uint32_t>(wsLeaderName.size())); bitStream.Write<uint32_t>(wsLeaderName.size());
for (const auto character : wsLeaderName) { for (const auto character : wsLeaderName) {
bitStream.Write(character); bitStream.Write(character);
} }
@ -730,7 +730,7 @@ void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderI
bitStream.Write<uint32_t>(0); // BinaryBuffe, no clue what's in here bitStream.Write<uint32_t>(0); // BinaryBuffe, no clue what's in here
bitStream.Write(ucLootFlag); bitStream.Write(ucLootFlag);
bitStream.Write(ucNumOfOtherPlayers); bitStream.Write(ucNumOfOtherPlayers);
bitStream.Write(static_cast<uint32_t>(wsLeaderName.size())); bitStream.Write<uint32_t>(wsLeaderName.size());
for (const auto character : wsLeaderName) { for (const auto character : wsLeaderName) {
bitStream.Write(character); bitStream.Write(character);
} }
@ -771,7 +771,7 @@ void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTria
bitStream.Write(bLocal); bitStream.Write(bLocal);
bitStream.Write(bNoLootOnDeath); bitStream.Write(bNoLootOnDeath);
bitStream.Write(i64PlayerID); bitStream.Write(i64PlayerID);
bitStream.Write(static_cast<uint32_t>(wsPlayerName.size())); bitStream.Write<uint32_t>(wsPlayerName.size());
for (const auto character : wsPlayerName) { for (const auto character : wsPlayerName) {
bitStream.Write(character); bitStream.Write(character);
} }
@ -802,7 +802,7 @@ void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband
bitStream.Write(bLocal); bitStream.Write(bLocal);
bitStream.Write(i64LeaderID); bitStream.Write(i64LeaderID);
bitStream.Write(i64PlayerID); bitStream.Write(i64PlayerID);
bitStream.Write(static_cast<uint32_t>(wsPlayerName.size())); bitStream.Write<uint32_t>(wsPlayerName.size());
for (const auto character : wsPlayerName) { for (const auto character : wsPlayerName) {
bitStream.Write(character); bitStream.Write(character);
} }

View File

@ -354,7 +354,7 @@ void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam) {
if (!deleteTeam) { if (!deleteTeam) {
bitStream.Write(team->lootFlag); bitStream.Write(team->lootFlag);
bitStream.Write(static_cast<char>(team->memberIDs.size())); bitStream.Write<char>(team->memberIDs.size());
for (const auto memberID : team->memberIDs) { for (const auto memberID : team->memberIDs) {
bitStream.Write(memberID); bitStream.Write(memberID);
} }

View File

@ -54,17 +54,17 @@ void RakNet::BitStream::Write<AMFBaseValue&>(AMFBaseValue& value) {
* RakNet writes in the correct byte order - do not reverse this. * RakNet writes in the correct byte order - do not reverse this.
*/ */
void WriteUInt29(RakNet::BitStream* bs, uint32_t v) { void WriteUInt29(RakNet::BitStream* bs, uint32_t v) {
unsigned char b4 = (unsigned char)v; unsigned char b4 = static_cast<unsigned char>(v);
if (v < 0x00200000) { if (v < 0x00200000) {
b4 = b4 & 0x7F; b4 = b4 & 0x7F;
if (v > 0x7F) { if (v > 0x7F) {
unsigned char b3; unsigned char b3;
v = v >> 7; v = v >> 7;
b3 = ((unsigned char)(v)) | 0x80; b3 = static_cast<unsigned char>(v) | 0x80;
if (v > 0x7F) { if (v > 0x7F) {
unsigned char b2; unsigned char b2;
v = v >> 7; v = v >> 7;
b2 = ((unsigned char)(v)) | 0x80; b2 = static_cast<unsigned char>(v) | 0x80;
bs->Write(b2); bs->Write(b2);
} }
@ -76,11 +76,11 @@ void WriteUInt29(RakNet::BitStream* bs, uint32_t v) {
unsigned char b3; unsigned char b3;
v = v >> 8; v = v >> 8;
b3 = ((unsigned char)(v)) | 0x80; b3 = static_cast<unsigned char>(v) | 0x80;
v = v >> 7; v = v >> 7;
b2 = ((unsigned char)(v)) | 0x80; b2 = static_cast<unsigned char>(v) | 0x80;
v = v >> 7; v = v >> 7;
b1 = ((unsigned char)(v)) | 0x80; b1 = static_cast<unsigned char>(v) | 0x80;
bs->Write(b1); bs->Write(b1);
bs->Write(b2); 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. * RakNet writes in the correct byte order - do not reverse this.
*/ */
void WriteAMFString(RakNet::BitStream* bs, const std::string& str) { void WriteAMFString(RakNet::BitStream* bs, const std::string& str) {
WriteFlagNumber(bs, (uint32_t)str.size()); WriteFlagNumber(bs, static_cast<uint32_t>(str.size()));
bs->Write(str.c_str(), (uint32_t)str.size()); bs->Write(str.c_str(), static_cast<uint32_t>(str.size()));
} }
/** /**

View File

@ -51,7 +51,7 @@ uint32_t BrickByBrickFix::TruncateBrokenBrickByBrickXml() {
if (actualUncompressedSize != -1) { if (actualUncompressedSize != -1) {
uint32_t previousSize = completeUncompressedModel.size(); uint32_t previousSize = completeUncompressedModel.size();
completeUncompressedModel.append((char*)uncompressedChunk.get()); completeUncompressedModel.append(reinterpret_cast<char*>(uncompressedChunk.get()));
completeUncompressedModel.resize(previousSize + actualUncompressedSize); completeUncompressedModel.resize(previousSize + actualUncompressedSize);
} else { } else {
LOG("Failed to inflate chunk %i for model %llu. Error: %i", chunkCount, model.id, err); LOG("Failed to inflate chunk %i for model %llu. Error: %i", chunkCount, model.id, err);

View File

@ -197,10 +197,10 @@ void MakeBacktrace() {
sigact.sa_sigaction = CritErrHdlr; sigact.sa_sigaction = CritErrHdlr;
sigact.sa_flags = SA_RESTART | SA_SIGINFO; sigact.sa_flags = SA_RESTART | SA_SIGINFO;
if (sigaction(SIGSEGV, &sigact, (struct sigaction*)nullptr) != 0 || if (sigaction(SIGSEGV, &sigact, nullptr) != 0 ||
sigaction(SIGFPE, &sigact, (struct sigaction*)nullptr) != 0 || sigaction(SIGFPE, &sigact, nullptr) != 0 ||
sigaction(SIGABRT, &sigact, (struct sigaction*)nullptr) != 0 || sigaction(SIGABRT, &sigact, nullptr) != 0 ||
sigaction(SIGILL, &sigact, (struct sigaction*)nullptr) != 0) { sigaction(SIGILL, &sigact, nullptr) != 0) {
fprintf(stderr, "error setting signal handler for %d (%s)\n", fprintf(stderr, "error setting signal handler for %d (%s)\n",
SIGSEGV, SIGSEGV,
strsignal(SIGSEGV)); strsignal(SIGSEGV));

View File

@ -53,7 +53,7 @@ bool _IsSuffixChar(uint8_t c) {
bool GeneralUtils::_NextUTF8Char(std::string_view& slice, uint32_t& out) { bool GeneralUtils::_NextUTF8Char(std::string_view& slice, uint32_t& out) {
size_t rem = slice.length(); size_t rem = slice.length();
if (slice.empty()) return false; if (slice.empty()) return false;
const uint8_t* bytes = (const uint8_t*)&slice.front(); const uint8_t* bytes = reinterpret_cast<const uint8_t*>(&slice.front());
if (rem > 0) { if (rem > 0) {
uint8_t first = bytes[0]; uint8_t first = bytes[0];
if (first < 0x80) { // 1 byte character if (first < 0x80) { // 1 byte character

View File

@ -63,15 +63,15 @@ private:
//! Writes the key to the packet //! Writes the key to the packet
void WriteKey(RakNet::BitStream* packet) { void WriteKey(RakNet::BitStream* packet) {
packet->Write(static_cast<uint8_t>(this->key.length() * sizeof(uint16_t))); packet->Write<uint8_t>(this->key.length() * sizeof(uint16_t));
for (uint32_t i = 0; i < this->key.length(); ++i) { for (uint32_t i = 0; i < this->key.length(); ++i) {
packet->Write(static_cast<uint16_t>(this->key[i])); packet->Write<uint16_t>(this->key[i]);
} }
} }
//! Writes the value to the packet //! Writes the value to the packet
void WriteValue(RakNet::BitStream* packet) { void WriteValue(RakNet::BitStream* packet) {
packet->Write(static_cast<uint8_t>(this->GetValueType())); packet->Write<uint8_t>(this->GetValueType());
packet->Write(this->value); packet->Write(this->value);
} }
@ -179,30 +179,30 @@ template<> inline eLDFType LDFData<std::string>::GetValueType(void) { return LDF
// The specialized version for std::u16string (UTF-16) // The specialized version for std::u16string (UTF-16)
template<> template<>
inline void LDFData<std::u16string>::WriteValue(RakNet::BitStream* packet) { inline void LDFData<std::u16string>::WriteValue(RakNet::BitStream* packet) {
packet->Write(static_cast<uint8_t>(this->GetValueType())); packet->Write<uint8_t>(this->GetValueType());
packet->Write(static_cast<uint32_t>(this->value.length())); packet->Write<uint32_t>(this->value.length());
for (uint32_t i = 0; i < this->value.length(); ++i) { for (uint32_t i = 0; i < this->value.length(); ++i) {
packet->Write(static_cast<uint16_t>(this->value[i])); packet->Write<uint16_t>(this->value[i]);
} }
} }
// The specialized version for bool // The specialized version for bool
template<> template<>
inline void LDFData<bool>::WriteValue(RakNet::BitStream* packet) { inline void LDFData<bool>::WriteValue(RakNet::BitStream* packet) {
packet->Write(static_cast<uint8_t>(this->GetValueType())); packet->Write<uint8_t>(this->GetValueType());
packet->Write(static_cast<uint8_t>(this->value)); packet->Write<uint8_t>(this->value);
} }
// The specialized version for std::string (UTF-8) // The specialized version for std::string (UTF-8)
template<> template<>
inline void LDFData<std::string>::WriteValue(RakNet::BitStream* packet) { inline void LDFData<std::string>::WriteValue(RakNet::BitStream* packet) {
packet->Write(static_cast<uint8_t>(this->GetValueType())); packet->Write<uint8_t>(this->GetValueType());
packet->Write(static_cast<uint32_t>(this->value.length())); packet->Write<uint32_t>(this->value.length());
for (uint32_t i = 0; i < this->value.length(); ++i) { for (uint32_t i = 0; i < this->value.length(); ++i) {
packet->Write(static_cast<uint8_t>(this->value[i])); packet->Write<uint8_t>(this->value[i]);
} }
} }

View File

@ -107,7 +107,7 @@ void Metrics::EndMeasurement(MetricVariable variable) {
} }
float Metrics::ToMiliseconds(int64_t nanoseconds) { float Metrics::ToMiliseconds(int64_t nanoseconds) {
return (float)nanoseconds / 1e6; return static_cast<float>(nanoseconds) / 1e6;
} }
std::string Metrics::MetricVariableToString(MetricVariable variable) { std::string Metrics::MetricVariableToString(MetricVariable variable) {
@ -193,34 +193,34 @@ size_t Metrics::GetPeakRSS() {
/* Windows -------------------------------------------------- */ /* Windows -------------------------------------------------- */
PROCESS_MEMORY_COUNTERS info; PROCESS_MEMORY_COUNTERS info;
GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info)); GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info));
return (size_t)info.PeakWorkingSetSize; return static_cast<size_t>(info.PeakWorkingSetSize);
#elif (defined(_AIX) || defined(__TOS__AIX__)) || (defined(__sun__) || defined(__sun) || defined(sun) && (defined(__SVR4) || defined(__svr4__))) #elif (defined(_AIX) || defined(__TOS__AIX__)) || (defined(__sun__) || defined(__sun) || defined(sun) && (defined(__SVR4) || defined(__svr4__)))
/* AIX and Solaris ------------------------------------------ */ /* AIX and Solaris ------------------------------------------ */
struct psinfo psinfo; struct psinfo psinfo;
int fd = -1; int fd = -1;
if ((fd = open("/proc/self/psinfo", O_RDONLY)) == -1) if ((fd = open("/proc/self/psinfo", O_RDONLY)) == -1)
return (size_t)0L; /* Can't open? */ return static_cast<size_t>(0L); /* Can't open? */
if (read(fd, &psinfo, sizeof(psinfo)) != sizeof(psinfo)) { if (read(fd, &psinfo, sizeof(psinfo)) != sizeof(psinfo)) {
close(fd); close(fd);
return (size_t)0L; /* Can't read? */ return static_cast<size_t>(0L); /* Can't read? */
} }
close(fd); close(fd);
return (size_t)(psinfo.pr_rssize * 1024L); return static_cast<size_t>(psinfo.pr_rssize * 1024L);
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__)) #elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
/* BSD, Linux, and OSX -------------------------------------- */ /* BSD, Linux, and OSX -------------------------------------- */
struct rusage rusage; struct rusage rusage;
getrusage(RUSAGE_SELF, &rusage); getrusage(RUSAGE_SELF, &rusage);
#if defined(__APPLE__) && defined(__MACH__) #if defined(__APPLE__) && defined(__MACH__)
return (size_t)rusage.ru_maxrss; return static_cast<size_t>(rusage.ru_maxrss);
#else #else
return (size_t)(rusage.ru_maxrss * 1024L); return static_cast<size_t>(rusage.ru_maxrss * 1024L);
#endif #endif
#else #else
/* Unknown OS ----------------------------------------------- */ /* Unknown OS ----------------------------------------------- */
return (size_t)0L; /* Unsupported. */ return static_cast<size_t>(0L); /* Unsupported. */
#endif #endif
} }
@ -234,33 +234,33 @@ size_t Metrics::GetCurrentRSS() {
/* Windows -------------------------------------------------- */ /* Windows -------------------------------------------------- */
PROCESS_MEMORY_COUNTERS info; PROCESS_MEMORY_COUNTERS info;
GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info)); GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info));
return (size_t)info.WorkingSetSize; return static_cast<size_t>(info.WorkingSetSize);
#elif defined(__APPLE__) && defined(__MACH__) #elif defined(__APPLE__) && defined(__MACH__)
/* OSX ------------------------------------------------------ */ /* OSX ------------------------------------------------------ */
struct mach_task_basic_info info; struct mach_task_basic_info info;
mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT; mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO, if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO,
(task_info_t)&info, &infoCount) != KERN_SUCCESS) reinterpret_cast<task_info_t>(&info), &infoCount) != KERN_SUCCESS)
return (size_t)0L; /* Can't access? */ return static_cast<size_t>(0L); /* Can't access? */
return (size_t)info.resident_size; return static_cast<size_t>(info.resident_size);
#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__) #elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
/* Linux ---------------------------------------------------- */ /* Linux ---------------------------------------------------- */
long rss = 0L; long rss = 0L;
FILE* fp = NULL; FILE* fp = NULL;
if ((fp = fopen("/proc/self/statm", "r")) == NULL) if ((fp = fopen("/proc/self/statm", "r")) == NULL)
return (size_t)0L; /* Can't open? */ return static_cast<size_t>(0L); /* Can't open? */
if (fscanf(fp, "%*s%ld", &rss) != 1) { if (fscanf(fp, "%*s%ld", &rss) != 1) {
fclose(fp); fclose(fp);
return (size_t)0L; /* Can't read? */ return static_cast<size_t>(0L); /* Can't read? */
} }
fclose(fp); fclose(fp);
return (size_t)rss * (size_t)sysconf(_SC_PAGESIZE); return static_cast<size_t>(rss) * static_cast<size_t>(sysconf(_SC_PAGESIZE));
#else #else
/* AIX, BSD, Solaris, and Unknown OS ------------------------ */ /* AIX, BSD, Solaris, and Unknown OS ------------------------ */
return (size_t)0L; /* Unsupported. */ return static_cast<size_t>(0L); /* Unsupported. */
#endif #endif
} }

View File

@ -114,13 +114,13 @@ bool NiPoint3::operator!=(const NiPoint3& point) const {
//! Operator for subscripting //! Operator for subscripting
float& NiPoint3::operator[](int i) { float& NiPoint3::operator[](int i) {
float* base = &x; float* base = &x;
return (float&)base[i]; return base[i];
} }
//! Operator for subscripting //! Operator for subscripting
const float& NiPoint3::operator[](int i) const { const float& NiPoint3::operator[](int i) const {
const float* base = &x; const float* base = &x;
return (float&)base[i]; return base[i];
} }
//! Operator for addition of vectors //! 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 < minPoint.y) return false;
if (this->y > maxPoint.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 //! 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 dx = target.x - current.x;
float dy = target.y - current.y; float dy = target.y - current.y;
float dz = target.z - current.z; 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<float>(
static_cast<double>(dx) * static_cast<double>(dx) +
static_cast<double>(dy) * static_cast<double>(dy) +
static_cast<double>(dz) * static_cast<double>(dz)
);
if (static_cast<double>(lengthSquared) == 0.0
|| static_cast<double>(maxDistanceDelta) >= 0.0
&& static_cast<double>(lengthSquared)
<= static_cast<double>(maxDistanceDelta) * static_cast<double>(maxDistanceDelta)) {
return target; 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); return NiPoint3(current.x + dx / length * maxDistanceDelta, current.y + dy / length * maxDistanceDelta, current.z + dz / length * maxDistanceDelta);
} }

View File

@ -1,3 +1,5 @@
// Source: http://www.zedwood.com/article/cpp-sha512-function
#include "SHA512.h" #include "SHA512.h"
#include <cstring> #include <cstring>

View File

@ -81,8 +81,8 @@ bool AssetManager::HasFile(const char* name) {
std::replace(fixedName.begin(), fixedName.end(), '/', '\\'); std::replace(fixedName.begin(), fixedName.end(), '/', '\\');
if (fixedName.rfind("client\\res\\", 0) != 0) fixedName = "client\\res\\" + fixedName; if (fixedName.rfind("client\\res\\", 0) != 0) fixedName = "client\\res\\" + fixedName;
uint32_t crc = crc32b(0xFFFFFFFF, (uint8_t*)fixedName.c_str(), fixedName.size()); uint32_t crc = crc32b(0xFFFFFFFF, reinterpret_cast<uint8_t*>(const_cast<char*>(fixedName.c_str())), fixedName.size());
crc = crc32b(crc, (Bytef*)"\0\0\0\0", 4); crc = crc32b(crc, reinterpret_cast<Bytef*>(const_cast<char*>("\0\0\0\0")), 4);
for (const auto& item : this->m_PackIndex->GetPackFileIndices()) { for (const auto& item : this->m_PackIndex->GetPackFileIndices()) {
if (item.m_Crc == crc) { if (item.m_Crc == crc) {
@ -113,7 +113,7 @@ bool AssetManager::GetFile(const char* name, char** data, uint32_t* len) {
#endif #endif
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
*len = ftell(file); *len = ftell(file);
*data = (char*)malloc(*len); *data = static_cast<char*>(malloc(*len));
fseek(file, 0, SEEK_SET); fseek(file, 0, SEEK_SET);
int32_t readInData = fread(*data, sizeof(uint8_t), *len, file); int32_t readInData = fread(*data, sizeof(uint8_t), *len, file);
fclose(file); fclose(file);
@ -129,8 +129,8 @@ bool AssetManager::GetFile(const char* name, char** data, uint32_t* len) {
fixedName = "client\\res\\" + fixedName; fixedName = "client\\res\\" + fixedName;
} }
int32_t packIndex = -1; int32_t packIndex = -1;
uint32_t crc = crc32b(0xFFFFFFFF, (uint8_t*)fixedName.c_str(), fixedName.size()); uint32_t crc = crc32b(0xFFFFFFFF, reinterpret_cast<uint8_t*>(const_cast<char*>(fixedName.c_str())), fixedName.size());
crc = crc32b(crc, (Bytef*)"\0\0\0\0", 4); crc = crc32b(crc, reinterpret_cast<Bytef*>(const_cast<char*>("\0\0\0\0")), 4);
for (const auto& item : this->m_PackIndex->GetPackFileIndices()) { for (const auto& item : this->m_PackIndex->GetPackFileIndices()) {
if (item.m_Crc == crc) { if (item.m_Crc == crc) {
@ -167,7 +167,7 @@ uint32_t AssetManager::crc32b(uint32_t base, uint8_t* message, size_t l) {
crc = base; crc = base;
for (i = 0; i < l; i++) { for (i = 0; i < l; i++) {
// xor next byte to upper bits of crc // xor next byte to upper bits of crc
crc ^= (((unsigned int)message[i]) << 24); crc ^= (static_cast<unsigned int>(message[i]) << 24);
for (j = 0; j < 8; j++) { // Do eight times. for (j = 0; j < 8; j++) { // Do eight times.
msb = crc >> 31; msb = crc >> 31;
crc <<= 1; crc <<= 1;

View File

@ -76,7 +76,7 @@ bool Pack::ReadFileFromPack(uint32_t crc, char** data, uint32_t* len) {
fseek(file, pos, SEEK_SET); fseek(file, pos, SEEK_SET);
if (!isCompressed) { if (!isCompressed) {
char* tempData = (char*)malloc(pkRecord.m_UncompressedSize); char* tempData = static_cast<char*>(malloc(pkRecord.m_UncompressedSize));
int32_t readInData = fread(tempData, sizeof(uint8_t), pkRecord.m_UncompressedSize, file); int32_t readInData = fread(tempData, sizeof(uint8_t), pkRecord.m_UncompressedSize, file);
*data = tempData; *data = tempData;
@ -90,7 +90,7 @@ bool Pack::ReadFileFromPack(uint32_t crc, char** data, uint32_t* len) {
fseek(file, pos, SEEK_SET); fseek(file, pos, SEEK_SET);
char* decompressedData = (char*)malloc(pkRecord.m_UncompressedSize); char* decompressedData = static_cast<char*>(malloc(pkRecord.m_UncompressedSize));
uint32_t currentReadPos = 0; uint32_t currentReadPos = 0;
while (true) { 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); int32_t readInData = fread(&size, sizeof(uint32_t), 1, file);
pos += 4; // Move pointer position 4 to the right pos += 4; // Move pointer position 4 to the right
char* chunk = (char*)malloc(size); char* chunk = static_cast<char*>(malloc(size));
int32_t readInData2 = fread(chunk, sizeof(int8_t), size, file); int32_t readInData2 = fread(chunk, sizeof(int8_t), size, file);
pos += size; // Move pointer position the amount of bytes read to the right pos += size; // Move pointer position the amount of bytes read to the right
int32_t err; int32_t err;
currentReadPos += ZCompression::Decompress((uint8_t*)chunk, size, reinterpret_cast<uint8_t*>(decompressedData + currentReadPos), ZCompression::MAX_SD0_CHUNK_SIZE, err); currentReadPos += ZCompression::Decompress(reinterpret_cast<uint8_t*>(chunk), size, reinterpret_cast<uint8_t*>(decompressedData + currentReadPos), ZCompression::MAX_SD0_CHUNK_SIZE, err);
free(chunk); free(chunk);
} }

View File

@ -10,13 +10,13 @@ namespace StringifiedEnum {
static_assert(std::is_enum_v<T>, "Not an enum"); // Check type static_assert(std::is_enum_v<T>, "Not an enum"); // Check type
constexpr auto sv = &magic_enum::enum_entries<T>(); constexpr auto sv = &magic_enum::enum_entries<T>();
std::string_view output;
const auto it = std::lower_bound( const auto it = std::lower_bound(
sv->begin(), sv->end(), e, sv->begin(), sv->end(), e,
[&](const std::pair<T, std::string_view>& lhs, const T rhs) { return lhs.first < rhs; } [&](const std::pair<T, std::string_view>& lhs, const T rhs) { return lhs.first < rhs; }
); );
std::string_view output;
if (it != sv->end() && it->first == e) { if (it != sv->end() && it->first == e) {
output = it->second; output = it->second;
} else { } else {

View File

@ -148,11 +148,11 @@ public:
if (size > maxSize) size = maxSize; if (size > maxSize) size = maxSize;
for (uint32_t i = 0; i < size; ++i) { for (uint32_t i = 0; i < size; ++i) {
bitStream.Write(static_cast<uint16_t>(friendName[i])); bitStream.Write<uint16_t>(friendName[i]);
} }
for (uint32_t j = 0; j < remSize; ++j) { for (uint32_t j = 0; j < remSize; ++j) {
bitStream.Write(static_cast<uint16_t>(0)); bitStream.Write<uint16_t>(0);
} }
bitStream.Write<uint32_t>(0); //??? bitStream.Write<uint32_t>(0); //???

View File

@ -10,7 +10,7 @@ void CDComponentsRegistryTable::LoadValuesFromDatabase() {
entry.component_type = static_cast<eReplicaComponentType>(tableData.getIntField("component_type", 0)); entry.component_type = static_cast<eReplicaComponentType>(tableData.getIntField("component_type", 0));
entry.component_id = tableData.getIntField("component_id", -1); 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<uint64_t>(entry.component_type) << 32 | static_cast<uint64_t>(entry.id), entry.component_id);
this->mappedEntries.insert_or_assign(entry.id, 0); this->mappedEntries.insert_or_assign(entry.id, 0);
tableData.nextRow(); tableData.nextRow();
@ -22,7 +22,7 @@ void CDComponentsRegistryTable::LoadValuesFromDatabase() {
int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) { int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponentType componentType, int32_t defaultValue) {
auto exists = mappedEntries.find(id); auto exists = mappedEntries.find(id);
if (exists != mappedEntries.end()) { if (exists != mappedEntries.end()) {
auto iter = mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id)); auto iter = mappedEntries.find(static_cast<uint64_t>(componentType) << 32 | static_cast<uint64_t>(id));
return iter == mappedEntries.end() ? defaultValue : iter->second; return iter == mappedEntries.end() ? defaultValue : iter->second;
} }
@ -38,15 +38,14 @@ int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, eReplicaComponent
entry.component_type = static_cast<eReplicaComponentType>(tableData.getIntField("component_type", 0)); entry.component_type = static_cast<eReplicaComponentType>(tableData.getIntField("component_type", 0));
entry.component_id = tableData.getIntField("component_id", -1); 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<uint64_t>(entry.component_type) << 32 | static_cast<uint64_t>(entry.id), entry.component_id);
tableData.nextRow(); tableData.nextRow();
} }
mappedEntries.insert_or_assign(id, 0); 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<uint64_t>(componentType) << 32 | static_cast<uint64_t>(id));
return iter == this->mappedEntries.end() ? defaultValue : iter->second; return iter == this->mappedEntries.end() ? defaultValue : iter->second;
} }

View File

@ -25,7 +25,7 @@ void CDMissionEmailTable::LoadValuesFromDatabase() {
entry.notificationGroup = tableData.getIntField("notificationGroup", -1); entry.notificationGroup = tableData.getIntField("notificationGroup", -1);
entry.missionID = tableData.getIntField("missionID", -1); entry.missionID = tableData.getIntField("missionID", -1);
entry.attachmentLOT = tableData.getIntField("attachmentLOT", 0); entry.attachmentLOT = tableData.getIntField("attachmentLOT", 0);
entry.localize = (bool)tableData.getIntField("localize", -1); entry.localize = static_cast<bool>(tableData.getIntField("localize", 1));
entry.locStatus = tableData.getIntField("locStatus", -1); entry.locStatus = tableData.getIntField("locStatus", -1);
entry.gate_version = tableData.getStringField("gate_version", ""); entry.gate_version = tableData.getStringField("gate_version", "");
@ -50,4 +50,3 @@ std::vector<CDMissionEmail> CDMissionEmailTable::Query(std::function<bool(CDMiss
const std::vector<CDMissionEmail>& CDMissionEmailTable::GetEntries() const { const std::vector<CDMissionEmail>& CDMissionEmailTable::GetEntries() const {
return this->entries; return this->entries;
} }

View File

@ -95,7 +95,7 @@ void MigrationRunner::RunSQLiteMigrations() {
// Check if there is an entry in the migration history table on the cdclient database. // 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 = CDClientDatabase::CreatePreppedStmt("SELECT name FROM migration_history WHERE name = ?;");
cdstmt.bind((int32_t) 1, migration.name.c_str()); cdstmt.bind(static_cast<int32_t>(1), migration.name.c_str());
auto cdres = cdstmt.execQuery(); auto cdres = cdstmt.execQuery();
if (!cdres.eof()) continue; if (!cdres.eof()) continue;
@ -124,7 +124,7 @@ void MigrationRunner::RunSQLiteMigrations() {
// Insert into cdclient database. // Insert into cdclient database.
cdstmt = CDClientDatabase::CreatePreppedStmt("INSERT INTO migration_history (name) VALUES (?);"); cdstmt = CDClientDatabase::CreatePreppedStmt("INSERT INTO migration_history (name) VALUES (?);");
cdstmt.bind((int32_t) 1, migration.name.c_str()); cdstmt.bind(static_cast<int32_t>(1), migration.name.c_str());
cdstmt.execQuery(); cdstmt.execQuery();
CDClientDatabase::ExecuteQuery("COMMIT;"); CDClientDatabase::ExecuteQuery("COMMIT;");
} }

View File

@ -982,9 +982,9 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke
} }
outBitStream->Write(m_ChildEntities.size() > 0); outBitStream->Write(m_ChildEntities.size() > 0);
if (m_ChildEntities.size() > 0) { if (m_ChildEntities.size() > 0) {
outBitStream->Write((uint16_t)m_ChildEntities.size()); outBitStream->Write<uint16_t>(m_ChildEntities.size());
for (Entity* child : m_ChildEntities) { for (Entity* child : m_ChildEntities) {
outBitStream->Write((uint64_t)child->GetObjectID()); outBitStream->Write<uint64_t>(child->GetObjectID());
} }
} }
} }

View File

@ -181,8 +181,8 @@ void EntityManager::SerializeEntities() {
m_SerializationCounter++; m_SerializationCounter++;
RakNet::BitStream stream; RakNet::BitStream stream;
stream.Write(static_cast<char>(ID_REPLICA_MANAGER_SERIALIZE)); stream.Write<char>(ID_REPLICA_MANAGER_SERIALIZE);
stream.Write(static_cast<unsigned short>(entity->GetNetworkId())); stream.Write<unsigned short>(entity->GetNetworkId());
entity->WriteBaseReplicaData(&stream, eReplicaPacketType::SERIALIZATION); entity->WriteBaseReplicaData(&stream, eReplicaPacketType::SERIALIZATION);
entity->WriteComponents(&stream, eReplicaPacketType::SERIALIZATION); entity->WriteComponents(&stream, eReplicaPacketType::SERIALIZATION);
@ -366,9 +366,9 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr
RakNet::BitStream stream; RakNet::BitStream stream;
stream.Write(static_cast<char>(ID_REPLICA_MANAGER_CONSTRUCTION)); stream.Write<char>(ID_REPLICA_MANAGER_CONSTRUCTION);
stream.Write(true); stream.Write(true);
stream.Write(static_cast<unsigned short>(entity->GetNetworkId())); stream.Write<unsigned short>(entity->GetNetworkId());
entity->WriteBaseReplicaData(&stream, eReplicaPacketType::CONSTRUCTION); entity->WriteBaseReplicaData(&stream, eReplicaPacketType::CONSTRUCTION);
entity->WriteComponents(&stream, eReplicaPacketType::CONSTRUCTION); entity->WriteComponents(&stream, eReplicaPacketType::CONSTRUCTION);
@ -416,8 +416,8 @@ void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr)
RakNet::BitStream stream; RakNet::BitStream stream;
stream.Write(static_cast<char>(ID_REPLICA_MANAGER_DESTRUCTION)); stream.Write<char>(ID_REPLICA_MANAGER_DESTRUCTION);
stream.Write(static_cast<unsigned short>(entity->GetNetworkId())); stream.Write<unsigned short>(entity->GetNetworkId());
Game::server->Send(&stream, sysAddr, sysAddr == UNASSIGNED_SYSTEM_ADDRESS); Game::server->Send(&stream, sysAddr, sysAddr == UNASSIGNED_SYSTEM_ADDRESS);

View File

@ -368,11 +368,11 @@ void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID
if (!type.empty()) { if (!type.empty()) {
typeQuery.bind(1, typeString.c_str()); typeQuery.bind(1, typeString.c_str());
typeQuery.bind(2, (int)effectId); typeQuery.bind(2, static_cast<int>(effectId));
result = typeQuery.execQuery(); result = typeQuery.execQuery();
} else { } else {
idQuery.bind(1, (int)effectId); idQuery.bind(1, static_cast<int>(effectId));
result = idQuery.execQuery(); result = idQuery.execQuery();
} }

View File

@ -249,7 +249,7 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime) {
entry.behavior->SyncCalculation(this, bitStream, entry.branchContext); entry.behavior->SyncCalculation(this, bitStream, entry.branchContext);
if (!clientInitalized) { if (!clientInitalized) {
echo.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed()); echo.sBitStream.assign(reinterpret_cast<char*>(bitStream->GetData()), bitStream->GetNumberOfBytesUsed());
// Write message // Write message
RakNet::BitStream message; RakNet::BitStream message;

View File

@ -42,7 +42,7 @@ void SwitchMultipleBehavior::Load() {
"(select bP2.value FROM BehaviorParameter bP2 WHERE bP2.behaviorID = ?1 AND bP2.parameterID LIKE 'value %' " "(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 " "AND replace(bP1.parameterID, 'behavior ', '') = replace(bP2.parameterID, 'value ', '')) as value "
"FROM BehaviorParameter bP1 WHERE bP1.behaviorID = ?1 AND bP1.parameterID LIKE 'behavior %';"); "FROM BehaviorParameter bP1 WHERE bP1.behaviorID = ?1 AND bP1.parameterID LIKE 'behavior %';");
query.bind(1, (int)this->m_behaviorId); query.bind(1, static_cast<int>(this->m_behaviorId));
auto result = query.execQuery(); auto result = query.execQuery();

View File

@ -40,7 +40,7 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id):
//Grab the aggro information from BaseCombatAI: //Grab the aggro information from BaseCombatAI:
auto componentQuery = CDClientDatabase::CreatePreppedStmt( auto componentQuery = CDClientDatabase::CreatePreppedStmt(
"SELECT aggroRadius, tetherSpeed, pursuitSpeed, softTetherRadius, hardTetherRadius FROM BaseCombatAIComponent WHERE id = ?;"); "SELECT aggroRadius, tetherSpeed, pursuitSpeed, softTetherRadius, hardTetherRadius FROM BaseCombatAIComponent WHERE id = ?;");
componentQuery.bind(1, (int)id); componentQuery.bind(1, static_cast<int>(id));
auto componentResult = componentQuery.execQuery(); auto componentResult = componentQuery.execQuery();
@ -77,7 +77,7 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id):
*/ */
auto skillQuery = CDClientDatabase::CreatePreppedStmt( auto skillQuery = CDClientDatabase::CreatePreppedStmt(
"SELECT skillID, cooldown, behaviorID FROM SkillBehavior WHERE skillID IN (SELECT skillID FROM ObjectSkills WHERE objectTemplate = ?);"); "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<int>(parent->GetLOT()));
auto result = skillQuery.execQuery(); auto result = skillQuery.execQuery();
@ -523,7 +523,7 @@ bool BaseCombatAIComponent::IsMech() {
void BaseCombatAIComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { void BaseCombatAIComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_DirtyStateOrTarget || bIsInitialUpdate); outBitStream->Write(m_DirtyStateOrTarget || bIsInitialUpdate);
if (m_DirtyStateOrTarget || bIsInitialUpdate) { if (m_DirtyStateOrTarget || bIsInitialUpdate) {
outBitStream->Write(uint32_t(m_State)); outBitStream->Write(m_State);
outBitStream->Write(m_Target); outBitStream->Write(m_Target);
m_DirtyStateOrTarget = false; m_DirtyStateOrTarget = false;
} }

View File

@ -19,7 +19,7 @@ class Entity;
/** /**
* The current state of the AI * The current state of the AI
*/ */
enum class AiState : int { enum class AiState : uint32_t {
idle = 0, // Doing nothing idle = 0, // Doing nothing
aggro, // Waiting for an enemy to cross / running back to spawn aggro, // Waiting for an enemy to cross / running back to spawn
tether, // Chasing an enemy tether, // Chasing an enemy

View File

@ -41,7 +41,7 @@ void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUp
for (const auto& [id, buff] : m_Buffs) { for (const auto& [id, buff] : m_Buffs) {
outBitStream->Write<uint32_t>(id); outBitStream->Write<uint32_t>(id);
outBitStream->Write(buff.time != 0.0f); outBitStream->Write(buff.time != 0.0f);
if (buff.time != 0.0f) outBitStream->Write(static_cast<uint32_t>(buff.time * 1000.0f)); if (buff.time != 0.0f) outBitStream->Write<uint32_t>(buff.time * 1000.0f);
outBitStream->Write(buff.cancelOnDeath); outBitStream->Write(buff.cancelOnDeath);
outBitStream->Write(buff.cancelOnZone); outBitStream->Write(buff.cancelOnZone);
outBitStream->Write(buff.cancelOnDamaged); 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; addedByTeammate = std::count(team->members.begin(), team->members.end(), m_Parent->GetObjectID()) > 0;
} }
GameMessages::SendAddBuff(const_cast<LWOOBJID&>(m_Parent->GetObjectID()), source, (uint32_t)id, GameMessages::SendAddBuff(const_cast<LWOOBJID&>(m_Parent->GetObjectID()), source, static_cast<uint32_t>(id),
(uint32_t)duration * 1000, addImmunity, cancelOnDamaged, cancelOnDeath, static_cast<uint32_t>(duration) * 1000, addImmunity, cancelOnDamaged, cancelOnDeath,
cancelOnLogout, cancelOnRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone, addedByTeammate, applyOnTeammates); cancelOnLogout, cancelOnRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone, addedByTeammate, applyOnTeammates);
float tick = 0; float tick = 0;
@ -431,7 +431,7 @@ const std::vector<BuffParameter>& BuffComponent::GetBuffParameters(int32_t buffI
} }
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM BuffParameters WHERE BuffID = ?;"); auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM BuffParameters WHERE BuffID = ?;");
query.bind(1, (int)buffId); query.bind(1, static_cast<int>(buffId));
auto result = query.execQuery(); auto result = query.execQuery();

View File

@ -135,7 +135,7 @@ void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInit
outBitStream->Write0(); outBitStream->Write0();
outBitStream->Write(m_IsLanding); outBitStream->Write(m_IsLanding);
if (m_IsLanding) { if (m_IsLanding) {
outBitStream->Write(uint16_t(m_LastRocketConfig.size())); outBitStream->Write<uint16_t>(m_LastRocketConfig.size());
for (uint16_t character : m_LastRocketConfig) { for (uint16_t character : m_LastRocketConfig) {
outBitStream->Write(character); outBitStream->Write(character);
} }
@ -157,7 +157,7 @@ void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInit
outBitStream->Write(m_DirtySocialInfo); outBitStream->Write(m_DirtySocialInfo);
if (m_DirtySocialInfo) { if (m_DirtySocialInfo) {
outBitStream->Write(m_GuildID); outBitStream->Write(m_GuildID);
outBitStream->Write<unsigned char>(static_cast<unsigned char>(m_GuildName.size())); outBitStream->Write<unsigned char>(m_GuildName.size());
if (!m_GuildName.empty()) if (!m_GuildName.empty())
outBitStream->WriteBits(reinterpret_cast<const unsigned char*>(m_GuildName.c_str()), static_cast<unsigned char>(m_GuildName.size()) * sizeof(wchar_t) * 8); outBitStream->WriteBits(reinterpret_cast<const unsigned char*>(m_GuildName.c_str()), static_cast<unsigned char>(m_GuildName.size()) * sizeof(wchar_t) * 8);
@ -229,7 +229,7 @@ void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
uint32_t mapID; uint32_t mapID;
child->QueryAttribute("map", &mapID); child->QueryAttribute("map", &mapID);
m_ZoneStatistics.insert({ (LWOMAPID)mapID, statistics }); m_ZoneStatistics.insert({ static_cast<LWOMAPID>(mapID), statistics });
child = child->NextSiblingElement(); child = child->NextSiblingElement();
} }
@ -515,9 +515,9 @@ void CharacterComponent::TrackPositionUpdate(const NiPoint3& newPosition) {
const auto distance = NiPoint3::Distance(newPosition, m_Parent->GetPosition()); const auto distance = NiPoint3::Distance(newPosition, m_Parent->GetPosition());
if (m_IsRacing) { if (m_IsRacing) {
UpdatePlayerStatistic(DistanceDriven, (uint64_t)distance); UpdatePlayerStatistic(DistanceDriven, static_cast<uint64_t>(distance));
} else { } else {
UpdatePlayerStatistic(MetersTraveled, (uint64_t)distance); UpdatePlayerStatistic(MetersTraveled, static_cast<uint64_t>(distance));
} }
} }

View File

@ -154,7 +154,7 @@ void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn
outBitStream->Write(m_fMaxArmor); outBitStream->Write(m_fMaxArmor);
outBitStream->Write(m_fMaxImagination); outBitStream->Write(m_fMaxImagination);
outBitStream->Write(uint32_t(m_FactionIDs.size())); outBitStream->Write<uint32_t>(m_FactionIDs.size());
for (size_t i = 0; i < m_FactionIDs.size(); ++i) { for (size_t i = 0; i < m_FactionIDs.size(); ++i) {
outBitStream->Write(m_FactionIDs[i]); outBitStream->Write(m_FactionIDs[i]);
} }
@ -380,7 +380,7 @@ void DestroyableComponent::AddFaction(const int32_t factionID, const bool ignore
auto query = CDClientDatabase::CreatePreppedStmt( auto query = CDClientDatabase::CreatePreppedStmt(
"SELECT enemyList FROM Factions WHERE faction = ?;"); "SELECT enemyList FROM Factions WHERE faction = ?;");
query.bind(1, (int)factionID); query.bind(1, static_cast<int>(factionID));
auto result = query.execQuery(); auto result = query.execQuery();

View File

@ -458,7 +458,7 @@ const std::vector<uint32_t>& MissionComponent::QueryAchievements(eMissionTaskTyp
bool MissionComponent::RequiresItem(const LOT lot) { bool MissionComponent::RequiresItem(const LOT lot) {
auto query = CDClientDatabase::CreatePreppedStmt( auto query = CDClientDatabase::CreatePreppedStmt(
"SELECT type FROM Objects WHERE id = ?;"); "SELECT type FROM Objects WHERE id = ?;");
query.bind(1, (int)lot); query.bind(1, static_cast<int>(lot));
auto result = query.execQuery(); auto result = query.execQuery();

View File

@ -57,7 +57,7 @@ void ModuleAssemblyComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
outBitStream->Write(m_UseOptionalParts); outBitStream->Write(m_UseOptionalParts);
outBitStream->Write(static_cast<uint16_t>(m_AssemblyPartsLOTs.size())); outBitStream->Write<uint16_t>(m_AssemblyPartsLOTs.size());
for (char16_t character : m_AssemblyPartsLOTs) { for (char16_t character : m_AssemblyPartsLOTs) {
outBitStream->Write(character); outBitStream->Write(character);
} }

View File

@ -35,7 +35,7 @@ MoverSubComponent::~MoverSubComponent() = default;
void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write<bool>(true); outBitStream->Write<bool>(true);
outBitStream->Write<uint32_t>(static_cast<uint32_t>(mState)); outBitStream->Write(mState);
outBitStream->Write<int32_t>(mDesiredWaypointIndex); outBitStream->Write<int32_t>(mDesiredWaypointIndex);
outBitStream->Write(mShouldStopAtDesiredWaypoint); outBitStream->Write(mShouldStopAtDesiredWaypoint);
outBitStream->Write(mInReverse); outBitStream->Write(mInReverse);
@ -90,9 +90,9 @@ void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
// Is on rail // Is on rail
outBitStream->Write1(); outBitStream->Write1();
outBitStream->Write(static_cast<uint16_t>(m_PathName.size())); outBitStream->Write<uint16_t>(m_PathName.size());
for (const auto& c : m_PathName) { for (const auto& c : m_PathName) {
outBitStream->Write(static_cast<uint16_t>(c)); outBitStream->Write<uint16_t>(c);
} }
// Starting point // Starting point
@ -107,7 +107,7 @@ void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
if (hasPlatform) { if (hasPlatform) {
auto* mover = static_cast<MoverSubComponent*>(m_MoverSubComponent); auto* mover = static_cast<MoverSubComponent*>(m_MoverSubComponent);
outBitStream->Write<uint32_t>(static_cast<uint32_t>(m_MoverSubComponentType)); outBitStream->Write(m_MoverSubComponentType);
if (m_MoverSubComponentType == eMoverSubComponentType::simpleMover) { if (m_MoverSubComponentType == eMoverSubComponentType::simpleMover) {
// TODO // TODO

View File

@ -113,8 +113,8 @@ void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpd
outBitStream->Write1(); // Always serialize as dirty for now outBitStream->Write1(); // Always serialize as dirty for now
outBitStream->Write<uint32_t>(static_cast<unsigned int>(m_Status)); outBitStream->Write<uint32_t>(m_Status);
outBitStream->Write<uint32_t>(static_cast<uint32_t>(tamed ? m_Ability : PetAbilityType::Invalid)); // Something with the overhead icon? outBitStream->Write(tamed ? m_Ability : PetAbilityType::Invalid); // Something with the overhead icon?
const bool interacting = m_Interaction != LWOOBJID_EMPTY; 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 nameData = GeneralUtils::UTF8ToUTF16(m_Name);
const auto ownerNameData = GeneralUtils::UTF8ToUTF16(m_OwnerName); const auto ownerNameData = GeneralUtils::UTF8ToUTF16(m_OwnerName);
outBitStream->Write(static_cast<uint8_t>(nameData.size())); outBitStream->Write<uint8_t>(nameData.size());
for (const auto c : nameData) { for (const auto c : nameData) {
outBitStream->Write(c); outBitStream->Write(c);
} }
outBitStream->Write(static_cast<uint8_t>(ownerNameData.size())); outBitStream->Write<uint8_t>(ownerNameData.size());
for (const auto c : ownerNameData) { for (const auto c : ownerNameData) {
outBitStream->Write(c); outBitStream->Write(c);
} }
@ -190,7 +190,7 @@ void PetComponent::OnUse(Entity* originator) {
if (cached == buildCache.end()) { if (cached == buildCache.end()) {
auto query = CDClientDatabase::CreatePreppedStmt( auto query = CDClientDatabase::CreatePreppedStmt(
"SELECT ValidPiecesLXF, PuzzleModelLot, Timelimit, NumValidPieces, imagCostPerBuild FROM TamingBuildPuzzles WHERE NPCLot = ?;"); "SELECT ValidPiecesLXF, PuzzleModelLot, Timelimit, NumValidPieces, imagCostPerBuild FROM TamingBuildPuzzles WHERE NPCLot = ?;");
query.bind(1, (int)m_Parent->GetLOT()); query.bind(1, static_cast<int>(m_Parent->GetLOT()));
auto result = query.execQuery(); auto result = query.execQuery();

View File

@ -6,7 +6,7 @@
#include "Preconditions.h" #include "Preconditions.h"
#include "eReplicaComponentType.h" #include "eReplicaComponentType.h"
enum class PetAbilityType enum class PetAbilityType : uint32_t
{ {
Invalid, Invalid,
GoToObject, GoToObject,

View File

@ -163,7 +163,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
const auto modApproved = playerPropertyLookupResults->getBoolean(10); const auto modApproved = playerPropertyLookupResults->getBoolean(10);
const auto dateLastUpdated = playerPropertyLookupResults->getInt64(11); const auto dateLastUpdated = playerPropertyLookupResults->getInt64(11);
const auto reputation = playerPropertyLookupResults->getUInt(14); 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); playerEntry = SetPropertyValues(playerEntry, cloneId, character->GetName(), propertyName, propertyDescription, reputation, true, true, modApproved, true, true, privacyOption, dateLastUpdated, performanceCost);
} else { } else {
@ -187,7 +187,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
propertyLookup->setString(2, searchString.c_str()); propertyLookup->setString(2, searchString.c_str());
propertyLookup->setString(3, searchString.c_str()); propertyLookup->setString(3, searchString.c_str());
propertyLookup->setString(4, 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<uint32_t>(PropertyPrivacyOption::Friends) : static_cast<uint32_t>(PropertyPrivacyOption::Public));
propertyLookup->setInt(6, numResults); propertyLookup->setInt(6, numResults);
propertyLookup->setInt(7, startIndex); propertyLookup->setInt(7, startIndex);
@ -203,7 +203,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
const auto modApproved = propertyEntry->getBoolean(10); const auto modApproved = propertyEntry->getBoolean(10);
const auto dateLastUpdated = propertyEntry->getInt(11); const auto dateLastUpdated = propertyEntry->getInt(11);
const float reputation = propertyEntry->getInt(14); const float reputation = propertyEntry->getInt(14);
const auto performanceCost = (float)propertyEntry->getDouble(16); const auto performanceCost = propertyEntry->getFloat(16);
PropertySelectQueryProperty entry{}; PropertySelectQueryProperty entry{};

View File

@ -92,7 +92,7 @@ std::vector<NiPoint3> PropertyManagementComponent::GetPaths() const {
auto query = CDClientDatabase::CreatePreppedStmt( auto query = CDClientDatabase::CreatePreppedStmt(
"SELECT path FROM PropertyTemplate WHERE mapID = ?;"); "SELECT path FROM PropertyTemplate WHERE mapID = ?;");
query.bind(1, (int)zoneId); query.bind(1, static_cast<int>(zoneId));
auto result = query.execQuery(); auto result = query.execQuery();

View File

@ -401,18 +401,18 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu
if (missionComponent == nullptr) return; 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, 0, static_cast<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, data->smashedTimes, static_cast<LWOOBJID>(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 solo racing is enabled OR if there are 3 players in the race, progress placement tasks.
if (m_SoloRacing || m_LoadedPlayers > 2) { 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<LWOOBJID>(eRacingTaskParam::FINISH_WITH_PLACEMENT)); // Finish in 1st place on a race
if (data->finished == 1) { 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(), static_cast<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<LWOOBJID>(eRacingTaskParam::WIN_RACE_IN_WORLD)); // Finished first place in specific world.
} }
if (data->finished == m_LoadedPlayers) { 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<LWOOBJID>(eRacingTaskParam::LAST_PLACE_FINISH)); // Finished first place in specific world.
} }
} }
} else if ((id == "ACT_RACE_EXIT_THE_RACE?" || id == "Exit") && button == m_ActivityExitConfirm) { } 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 // BEGIN Scripted Activity
outBitStream->Write1(); outBitStream->Write1();
outBitStream->Write(static_cast<uint32_t>(m_RacingPlayers.size())); outBitStream->Write<uint32_t>(m_RacingPlayers.size());
for (const auto& player : m_RacingPlayers) { for (const auto& player : m_RacingPlayers) {
outBitStream->Write(player.playerID); outBitStream->Write(player.playerID);
@ -461,7 +461,7 @@ void RacingControlComponent::Serialize(RakNet::BitStream* outBitStream, bool bIs
// END Scripted Activity // END Scripted Activity
outBitStream->Write1(); outBitStream->Write1();
outBitStream->Write(static_cast<uint16_t>(m_RacingPlayers.size())); outBitStream->Write<uint16_t>(m_RacingPlayers.size());
outBitStream->Write(!m_AllPlayersReady); outBitStream->Write(!m_AllPlayersReady);
if (!m_AllPlayersReady) { if (!m_AllPlayersReady) {
@ -495,7 +495,7 @@ void RacingControlComponent::Serialize(RakNet::BitStream* outBitStream, bool bIs
outBitStream->Write(bIsInitialUpdate); outBitStream->Write(bIsInitialUpdate);
if (bIsInitialUpdate) { if (bIsInitialUpdate) {
outBitStream->Write(m_RemainingLaps); outBitStream->Write(m_RemainingLaps);
outBitStream->Write(static_cast<uint16_t>(m_PathName.size())); outBitStream->Write<uint16_t>(m_PathName.size());
for (const auto character : m_PathName) { for (const auto character : m_PathName) {
outBitStream->Write(character); outBitStream->Write(character);
} }
@ -794,7 +794,7 @@ void RacingControlComponent::Update(float deltaTime) {
const auto& position = waypoint.position; const auto& position = waypoint.position;
if (std::abs((int)respawnIndex - (int)player.respawnIndex) > 10 && if (std::abs(static_cast<int>(respawnIndex) - static_cast<int>(player.respawnIndex)) > 10 &&
player.respawnIndex != path->pathWaypoints.size() - 1) { player.respawnIndex != path->pathWaypoints.size() - 1) {
++respawnIndex; ++respawnIndex;
@ -848,7 +848,7 @@ void RacingControlComponent::Update(float deltaTime) {
if (missionComponent != nullptr) { if (missionComponent != nullptr) {
// Progress lap time tasks // Progress lap time tasks
missionComponent->Progress(eMissionTaskType::RACING, (lapTime) * 1000, (LWOOBJID)eRacingTaskParam::LAP_TIME); missionComponent->Progress(eMissionTaskType::RACING, (lapTime) * 1000, static_cast<LWOOBJID>(eRacingTaskParam::LAP_TIME));
if (player.lap == 3) { if (player.lap == 3) {
m_Finished++; m_Finished++;
@ -864,7 +864,7 @@ void RacingControlComponent::Update(float deltaTime) {
LeaderboardManager::SaveScore(playerEntity->GetObjectID(), m_ActivityID, static_cast<float>(player.raceTime), static_cast<float>(player.bestLapTime), static_cast<float>(player.finished == 1)); LeaderboardManager::SaveScore(playerEntity->GetObjectID(), m_ActivityID, static_cast<float>(player.raceTime), static_cast<float>(player.bestLapTime), static_cast<float>(player.finished == 1));
// Entire race time // Entire race time
missionComponent->Progress(eMissionTaskType::RACING, (raceTime) * 1000, (LWOOBJID)eRacingTaskParam::TOTAL_TRACK_TIME); missionComponent->Progress(eMissionTaskType::RACING, (raceTime) * 1000, static_cast<LWOOBJID>(eRacingTaskParam::TOTAL_TRACK_TIME));
auto* characterComponent = playerEntity->GetComponent<CharacterComponent>(); auto* characterComponent = playerEntity->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {

View File

@ -81,14 +81,14 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia
Entity* builder = GetBuilder(); Entity* builder = GetBuilder();
if (builder) { if (builder) {
outBitStream->Write((uint32_t)1); outBitStream->Write<uint32_t>(1);
outBitStream->Write(builder->GetObjectID()); outBitStream->Write(builder->GetObjectID());
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
outBitStream->Write(0.0f); outBitStream->Write(0.0f);
} }
} else { } else {
outBitStream->Write((uint32_t)0); outBitStream->Write<uint32_t>(0);
} }
// END Scripted Activity // END Scripted Activity

View File

@ -468,7 +468,7 @@ float_t ScriptedActivityComponent::GetActivityValue(LWOOBJID playerID, uint32_t
auto* data = GetActivityPlayerData(playerID); auto* data = GetActivityPlayerData(playerID);
if (data != nullptr) { if (data != nullptr) {
value = data->values[std::min(index, (uint32_t)9)]; value = data->values[std::min(index, static_cast<uint32_t>(9))];
} }
return value; 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) { void ScriptedActivityComponent::SetActivityValue(LWOOBJID playerID, uint32_t index, float_t value) {
auto* data = AddActivityPlayerData(playerID); auto* data = AddActivityPlayerData(playerID);
if (data != nullptr) { if (data != nullptr) {
data->values[std::min(index, (uint32_t)9)] = value; data->values[std::min(index, static_cast<uint32_t>(9))] = value;
} }
Game::entityManager->SerializeEntity(m_Parent); Game::entityManager->SerializeEntity(m_Parent);

View File

@ -89,7 +89,7 @@ void SkillComponent::SyncPlayerProjectile(const LWOOBJID projectileId, RakNet::B
auto query = CDClientDatabase::CreatePreppedStmt( auto query = CDClientDatabase::CreatePreppedStmt(
"SELECT behaviorID FROM SkillBehavior WHERE skillID = (SELECT skillID FROM ObjectSkills WHERE objectTemplate = ?);"); "SELECT behaviorID FROM SkillBehavior WHERE skillID = (SELECT skillID FROM ObjectSkills WHERE objectTemplate = ?);");
query.bind(1, (int)sync_entry.lot); query.bind(1, static_cast<int>(sync_entry.lot));
auto result = query.execQuery(); auto result = query.execQuery();
@ -299,7 +299,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c
} }
//start.optionalTargetID = target; //start.optionalTargetID = target;
start.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed()); start.sBitStream.assign(reinterpret_cast<char*>(bitStream->GetData()), bitStream->GetNumberOfBytesUsed());
// Write message // Write message
RakNet::BitStream message; RakNet::BitStream message;
@ -409,7 +409,7 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry)
auto query = CDClientDatabase::CreatePreppedStmt( auto query = CDClientDatabase::CreatePreppedStmt(
"SELECT behaviorID FROM SkillBehavior WHERE skillID = (SELECT skillID FROM ObjectSkills WHERE objectTemplate = ?);"); "SELECT behaviorID FROM SkillBehavior WHERE skillID = (SELECT skillID FROM ObjectSkills WHERE objectTemplate = ?);");
query.bind(1, (int)entry.lot); query.bind(1, static_cast<int>(entry.lot));
auto result = query.execQuery(); auto result = query.execQuery();
if (result.eof()) { if (result.eof()) {
@ -430,7 +430,7 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry)
DoClientProjectileImpact projectileImpact; DoClientProjectileImpact projectileImpact;
projectileImpact.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed()); projectileImpact.sBitStream.assign(reinterpret_cast<char*>(bitStream->GetData()), bitStream->GetNumberOfBytesUsed());
projectileImpact.i64OwnerID = this->m_Parent->GetObjectID(); projectileImpact.i64OwnerID = this->m_Parent->GetObjectID();
projectileImpact.i64OrgID = entry.id; projectileImpact.i64OrgID = entry.id;
projectileImpact.i64TargetID = entry.branchContext.target; projectileImpact.i64TargetID = entry.branchContext.target;

View File

@ -269,7 +269,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
auto* skill_component = entity->GetComponent<SkillComponent>(); auto* skill_component = entity->GetComponent<SkillComponent>();
if (skill_component != nullptr) { 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<unsigned char*>(const_cast<char*>(message.sBitStream.c_str())), message.sBitStream.size(), false);
skill_component->SyncPlayerProjectile(message.i64LocalID, bs, message.i64TargetID); skill_component->SyncPlayerProjectile(message.i64LocalID, bs, message.i64TargetID);
@ -296,7 +296,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
bool success = false; bool success = false;
if (behaviorId > 0) { 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<unsigned char*>(const_cast<char*>(startSkill.sBitStream.c_str())), startSkill.sBitStream.size(), false);
auto* skillComponent = entity->GetComponent<SkillComponent>(); auto* skillComponent = entity->GetComponent<SkillComponent>();
@ -353,7 +353,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
} }
if (usr != nullptr) { 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<unsigned char*>(const_cast<char*>(sync.sBitStream.c_str())), sync.sBitStream.size(), false);
auto* skillComponent = entity->GetComponent<SkillComponent>(); auto* skillComponent = entity->GetComponent<SkillComponent>();

View File

@ -389,7 +389,7 @@ void GameMessages::SendPlatformResync(Entity* entity, const SystemAddress& sysAd
bitStream.Write(bReverse); bitStream.Write(bReverse);
bitStream.Write(bStopAtDesiredWaypoint); bitStream.Write(bStopAtDesiredWaypoint);
bitStream.Write(eCommand); bitStream.Write(eCommand);
bitStream.Write<int32_t>(static_cast<int32_t>(movementState)); bitStream.Write(static_cast<int32_t>(movementState));
bitStream.Write(eUnexpectedCommand); bitStream.Write(eUnexpectedCommand);
bitStream.Write(fIdleTimeElapsed); bitStream.Write(fIdleTimeElapsed);
bitStream.Write(fMoveTimeElapsed); bitStream.Write(fMoveTimeElapsed);
@ -582,7 +582,7 @@ void GameMessages::SendNotifyMissionTask(Entity* entity, const SystemAddress& sy
bitStream.Write(missionID); bitStream.Write(missionID);
bitStream.Write(taskMask); bitStream.Write(taskMask);
bitStream.Write((unsigned char)updates.size()); bitStream.Write<unsigned char>(updates.size());
for (uint32_t i = 0; i < updates.size(); ++i) { for (uint32_t i = 0; i < updates.size(); ++i) {
bitStream.Write(updates[i]); bitStream.Write(updates[i]);
@ -1950,7 +1950,7 @@ void GameMessages::SendBBBSaveResponse(const LWOOBJID& objectId, const LWOOBJID&
bitStream.Write(buffer[i]); bitStream.Write(buffer[i]);
SEND_PACKET; SEND_PACKET;
PacketUtils::SavePacket("eGameMessageType::BBB_SAVE_RESPONSE.bin", (char*)bitStream.GetData(), bitStream.GetNumberOfBytesUsed()); //PacketUtils::SavePacket("eGameMessageType::BBB_SAVE_RESPONSE.bin", reinterpret_cast<char*>(bitStream.GetData()), bitStream.GetNumberOfBytesUsed());
} }
// Property // 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. 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<int>(mapId), static_cast<int>(cloneId));
auto* character = player->GetCharacter(); auto* character = player->GetCharacter();
@ -5282,7 +5282,7 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity)
/*uint32_t deathTypeLength = deathType.size(); /*uint32_t deathTypeLength = deathType.size();
inStream->Read(deathTypeLength); inStream->Read(deathTypeLength);
for (uint32_t k = 0; k < deathTypeLength; k++) { for (uint32_t k = 0; k < deathTypeLength; k++) {
inStream->Read(static_cast<uint16_t>(deathType[k])); inStream->Read<uint16_t>(deathType[k]);
}*/ }*/
inStream->Read(directionRelative_AngleXZ); inStream->Read(directionRelative_AngleXZ);
@ -6070,7 +6070,7 @@ void GameMessages::HandleUpdatePlayerStatistic(RakNet::BitStream* inStream, Enti
auto* characterComponent = entity->GetComponent<CharacterComponent>(); auto* characterComponent = entity->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->UpdatePlayerStatistic((StatisticID)updateID, (uint64_t)std::max(updateValue, int64_t(0))); characterComponent->UpdatePlayerStatistic(static_cast<StatisticID>(updateID), static_cast<uint64_t>(std::max(updateValue, static_cast<int64_t>(0))));
} }
} }

View File

@ -17,21 +17,21 @@ void GameMessages::PropertyDataMessage::Serialize(RakNet::BitStream& stream) con
stream.Write<uint32_t>(cloneId); // clone id stream.Write<uint32_t>(cloneId); // clone id
const auto& name = GeneralUtils::UTF8ToUTF16(Name); const auto& name = GeneralUtils::UTF8ToUTF16(Name);
stream.Write(uint32_t(name.size())); stream.Write<uint32_t>(name.size());
for (uint32_t i = 0; i < name.size(); ++i) { for (uint32_t i = 0; i < name.size(); ++i) {
stream.Write(uint16_t(name[i])); stream.Write<uint16_t>(name[i]);
} }
const auto& description = GeneralUtils::UTF8ToUTF16(Description); const auto& description = GeneralUtils::UTF8ToUTF16(Description);
stream.Write(uint32_t(description.size())); stream.Write<uint32_t>(description.size());
for (uint32_t i = 0; i < description.size(); ++i) { for (uint32_t i = 0; i < description.size(); ++i) {
stream.Write(uint16_t(description[i])); stream.Write<uint16_t>(description[i]);
} }
const auto& owner = GeneralUtils::UTF8ToUTF16(OwnerName); const auto& owner = GeneralUtils::UTF8ToUTF16(OwnerName);
stream.Write(uint32_t(owner.size())); stream.Write<uint32_t>(owner.size());
for (uint32_t i = 0; i < owner.size(); ++i) { for (uint32_t i = 0; i < owner.size(); ++i) {
stream.Write(uint16_t(owner[i])); stream.Write<uint16_t>(owner[i]);
} }
stream.Write<LWOOBJID>(OwnerId); stream.Write<LWOOBJID>(OwnerId);
@ -49,9 +49,9 @@ void GameMessages::PropertyDataMessage::Serialize(RakNet::BitStream& stream) con
stream.Write<uint32_t>(0); stream.Write<uint32_t>(0);
const auto& spawn = GeneralUtils::ASCIIToUTF16(SpawnName); const auto& spawn = GeneralUtils::ASCIIToUTF16(SpawnName);
stream.Write(uint32_t(spawn.size())); stream.Write<uint32_t>(spawn.size());
for (uint32_t i = 0; i < spawn.size(); ++i) { for (uint32_t i = 0; i < spawn.size(); ++i) {
stream.Write(uint16_t(spawn[i])); stream.Write<uint16_t>(spawn[i]);
} }
stream.Write<uint32_t>(0); // String length stream.Write<uint32_t>(0); // String length
@ -71,9 +71,9 @@ void GameMessages::PropertyDataMessage::Serialize(RakNet::BitStream& stream) con
// Does this go here??? // Does this go here???
// const auto& rejectionReasonConverted = GeneralUtils::UTF8ToUTF16(rejectionReason); // const auto& rejectionReasonConverted = GeneralUtils::UTF8ToUTF16(rejectionReason);
// stream.Write(uint32_t(rejectionReasonConverted.size())); // stream.Write<uint32_t>(rejectionReasonConverted.size());
// for (uint32_t i = 0; i < rejectionReasonConverted.size(); ++i) { // for (uint32_t i = 0; i < rejectionReasonConverted.size(); ++i) {
// stream.Write(uint16_t(rejectionReasonConverted[i])); // stream.Write<uint16_t>(rejectionReasonConverted[i]);
// } // }
stream.Write<uint32_t>(0); stream.Write<uint32_t>(0);
@ -93,7 +93,7 @@ void GameMessages::PropertyDataMessage::Serialize(RakNet::BitStream& stream) con
stream.Write<char>(PrivacyOption); stream.Write<char>(PrivacyOption);
stream.Write(uint32_t(Paths.size())); stream.Write<uint32_t>(Paths.size());
for (const auto& path : Paths) { for (const auto& path : Paths) {
stream.Write(path.x); stream.Write(path.x);

View File

@ -4,21 +4,21 @@ void PropertySelectQueryProperty::Serialize(RakNet::BitStream& stream) const {
stream.Write(CloneId); stream.Write(CloneId);
const auto& owner = GeneralUtils::UTF8ToUTF16(OwnerName); const auto& owner = GeneralUtils::UTF8ToUTF16(OwnerName);
stream.Write(uint32_t(owner.size())); stream.Write<uint32_t>(owner.size());
for (uint32_t i = 0; i < owner.size(); ++i) { for (uint32_t i = 0; i < owner.size(); ++i) {
stream.Write(static_cast<uint16_t>(owner[i])); stream.Write<uint16_t>(owner[i]);
} }
const auto& name = GeneralUtils::UTF8ToUTF16(Name); const auto& name = GeneralUtils::UTF8ToUTF16(Name);
stream.Write(uint32_t(name.size())); stream.Write<uint32_t>(name.size());
for (uint32_t i = 0; i < name.size(); ++i) { for (uint32_t i = 0; i < name.size(); ++i) {
stream.Write(static_cast<uint16_t>(name[i])); stream.Write<uint16_t>(name[i]);
} }
const auto& description = GeneralUtils::UTF8ToUTF16(Description); const auto& description = GeneralUtils::UTF8ToUTF16(Description);
stream.Write(uint32_t(description.size())); stream.Write<uint32_t>(description.size());
for (uint32_t i = 0; i < description.size(); ++i) { for (uint32_t i = 0; i < description.size(); ++i) {
stream.Write(static_cast<uint16_t>(description[i])); stream.Write<uint16_t>(description[i]);
} }
stream.Write(Reputation); stream.Write(Reputation);

View File

@ -19,7 +19,7 @@ ItemSet::ItemSet(const uint32_t id, InventoryComponent* inventoryComponent) {
auto query = CDClientDatabase::CreatePreppedStmt( auto query = CDClientDatabase::CreatePreppedStmt(
"SELECT skillSetWith2, skillSetWith3, skillSetWith4, skillSetWith5, skillSetWith6, itemIDs FROM ItemSets WHERE setID = ?;"); "SELECT skillSetWith2, skillSetWith3, skillSetWith4, skillSetWith5, skillSetWith6, itemIDs FROM ItemSets WHERE setID = ?;");
query.bind(1, (int)id); query.bind(1, static_cast<int>(id));
auto result = query.execQuery(); auto result = query.execQuery();

View File

@ -329,9 +329,9 @@ void Mission::Complete(const bool yieldRewards) {
missionComponent->Progress(eMissionTaskType::META, info.id); 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<LWOOBJID>(eRacingTaskParam::COMPLETE_ANY_RACING_TASK));
missionComponent->Progress(eMissionTaskType::RACING, info.id, (LWOOBJID)eRacingTaskParam::COMPLETE_TRACK_TASKS); missionComponent->Progress(eMissionTaskType::RACING, info.id, static_cast<LWOOBJID>(eRacingTaskParam::COMPLETE_TRACK_TASKS));
auto* missionEmailTable = CDClientManager::Instance().GetTable<CDMissionEmailTable>(); auto* missionEmailTable = CDClientManager::Instance().GetTable<CDMissionEmailTable>();

View File

@ -242,7 +242,7 @@ void Loot::GiveActivityLoot(Entity* player, Entity* source, uint32_t activityID,
GiveLoot(player, selectedReward->LootMatrixIndex, eLootSourceType::ACTIVITY); GiveLoot(player, selectedReward->LootMatrixIndex, eLootSourceType::ACTIVITY);
uint32_t coins = (int)(minCoins + GeneralUtils::GenerateRandomNumber<float>(0, 1) * (maxCoins - minCoins)); uint32_t coins = static_cast<uint32_t>(minCoins + GeneralUtils::GenerateRandomNumber<float>(0, 1) * (maxCoins - minCoins));
auto* character = player->GetCharacter(); auto* character = player->GetCharacter();
@ -280,7 +280,7 @@ void Loot::DropLoot(Entity* player, Entity* killedObject, std::unordered_map<LOT
} }
} }
uint32_t coins = (int)(minCoins + GeneralUtils::GenerateRandomNumber<float>(0, 1) * (maxCoins - minCoins)); uint32_t coins = static_cast<uint32_t>(minCoins + GeneralUtils::GenerateRandomNumber<float>(0, 1) * (maxCoins - minCoins));
GameMessages::SendDropClientLoot(player, source, LOT_NULL, coins, spawnPosition); GameMessages::SendDropClientLoot(player, source, LOT_NULL, coins, spawnPosition);
} }

View File

@ -19,7 +19,7 @@ std::map<uint32_t, Precondition*> Preconditions::cache = {};
Precondition::Precondition(const uint32_t condition) { Precondition::Precondition(const uint32_t condition) {
auto query = CDClientDatabase::CreatePreppedStmt( auto query = CDClientDatabase::CreatePreppedStmt(
"SELECT type, targetLOT, targetCount FROM Preconditions WHERE id = ?;"); "SELECT type, targetLOT, targetCount FROM Preconditions WHERE id = ?;");
query.bind(1, (int)condition); query.bind(1, static_cast<int>(condition));
auto result = query.execQuery(); auto result = query.execQuery();

View File

@ -1191,9 +1191,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
auto dest = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE)); auto dest = static_cast<DestroyableComponent*>(entity->GetComponent(eReplicaComponentType::DESTROYABLE));
if (dest) { if (dest) {
dest->SetHealth((int)dest->GetMaxHealth()); dest->SetHealth(static_cast<int32_t>(dest->GetMaxHealth()));
dest->SetArmor((int)dest->GetMaxArmor()); dest->SetArmor(static_cast<int32_t>(dest->GetMaxArmor()));
dest->SetImagination((int)dest->GetMaxImagination()); dest->SetImagination(static_cast<int32_t>(dest->GetMaxImagination()));
} }
Game::entityManager->SerializeEntity(entity); Game::entityManager->SerializeEntity(entity);
@ -1317,7 +1317,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
int32_t type; int32_t type;
if (args.size() >= 2 && GeneralUtils::TryParse(args[1], type)) { if (args.size() >= 2 && GeneralUtils::TryParse(args[1], type)) {
lootType = (eLootSourceType)type; lootType = static_cast<eLootSourceType>(type);
} }
GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, lootType); GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, lootType);
@ -1357,7 +1357,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
if (!characterComponent) return; if (!characterComponent) return;
auto levelComponent = entity->GetComponent<LevelProgressionComponent>(); auto levelComponent = entity->GetComponent<LevelProgressionComponent>();
auto query = CDClientDatabase::CreatePreppedStmt("SELECT requiredUScore from LevelProgressionLookup WHERE id = ?;"); auto query = CDClientDatabase::CreatePreppedStmt("SELECT requiredUScore from LevelProgressionLookup WHERE id = ?;");
query.bind(1, (int)requestedLevel); query.bind(1, static_cast<int>(requestedLevel));
auto result = query.execQuery(); auto result = query.execQuery();
if (result.eof()) return; if (result.eof()) return;
@ -1741,13 +1741,13 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
ChatPackets::SendSystemMessage( ChatPackets::SendSystemMessage(
sysAddr, sysAddr,
u"Peak RSS: " + GeneralUtils::to_u16string((float)((double)Metrics::GetPeakRSS() / 1.024e6)) + u"Peak RSS: " + GeneralUtils::to_u16string(static_cast<float>(static_cast<double>(Metrics::GetPeakRSS()) / 1.024e6)) +
u"MB" u"MB"
); );
ChatPackets::SendSystemMessage( ChatPackets::SendSystemMessage(
sysAddr, sysAddr,
u"Current RSS: " + GeneralUtils::to_u16string((float)((double)Metrics::GetCurrentRSS() / 1.024e6)) + u"Current RSS: " + GeneralUtils::to_u16string(static_cast<float>(static_cast<double>(Metrics::GetCurrentRSS()) / 1.024e6)) +
u"MB" u"MB"
); );
@ -1792,7 +1792,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
totalRuns += 1; totalRuns += 1;
bool doBreak = false; bool doBreak = false;
for (const auto& kv : lootRoll) { for (const auto& kv : lootRoll) {
if ((uint32_t)kv.first == targetLot) { if (static_cast<uint32_t>(kv.first) == targetLot) {
doBreak = true; doBreak = true;
} }
} }
@ -1807,7 +1807,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
+ u" times. It ran " + u" times. It ran "
+ GeneralUtils::to_u16string(totalRuns) + GeneralUtils::to_u16string(totalRuns)
+ u" times. Averaging out at " + u" times. Averaging out at "
+ GeneralUtils::to_u16string((float)totalRuns / loops); + GeneralUtils::to_u16string(static_cast<float>(totalRuns) / loops);
ChatPackets::SendSystemMessage(sysAddr, message); ChatPackets::SendSystemMessage(sysAddr, message);
} }

View File

@ -105,7 +105,7 @@ void dNavMesh::LoadNavmesh() {
if (!tileHeader.tileRef || !tileHeader.dataSize) if (!tileHeader.tileRef || !tileHeader.dataSize)
break; break;
unsigned char* data = (unsigned char*)dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM); unsigned char* data = static_cast<unsigned char*>(dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM));
if (!data) break; if (!data) break;
memset(data, 0, tileHeader.dataSize); memset(data, 0, tileHeader.dataSize);
readLen = fread(data, tileHeader.dataSize, 1, fp); readLen = fread(data, tileHeader.dataSize, 1, fp);

View File

@ -20,40 +20,40 @@ RawChunk::RawChunk(std::ifstream& stream) {
uint32_t colorMapSize; uint32_t colorMapSize;
BinaryIO::BinaryRead(stream, colorMapSize); BinaryIO::BinaryRead(stream, colorMapSize);
stream.seekg((uint32_t)stream.tellg() + (colorMapSize * colorMapSize * 4)); stream.seekg(static_cast<uint32_t>(stream.tellg()) + (colorMapSize * colorMapSize * 4));
uint32_t lightmapSize; uint32_t lightmapSize;
BinaryIO::BinaryRead(stream, lightmapSize); BinaryIO::BinaryRead(stream, lightmapSize);
stream.seekg((uint32_t)stream.tellg() + (lightmapSize)); stream.seekg(static_cast<uint32_t>(stream.tellg()) + (lightmapSize));
uint32_t colorMapSize2; uint32_t colorMapSize2;
BinaryIO::BinaryRead(stream, colorMapSize2); BinaryIO::BinaryRead(stream, colorMapSize2);
stream.seekg((uint32_t)stream.tellg() + (colorMapSize2 * colorMapSize2 * 4)); stream.seekg(static_cast<uint32_t>(stream.tellg()) + (colorMapSize2 * colorMapSize2 * 4));
uint8_t unknown; uint8_t unknown;
BinaryIO::BinaryRead(stream, unknown); BinaryIO::BinaryRead(stream, unknown);
uint32_t blendmapSize; uint32_t blendmapSize;
BinaryIO::BinaryRead(stream, blendmapSize); BinaryIO::BinaryRead(stream, blendmapSize);
stream.seekg((uint32_t)stream.tellg() + (blendmapSize)); stream.seekg(static_cast<uint32_t>(stream.tellg()) + (blendmapSize));
uint32_t pointSize; uint32_t pointSize;
BinaryIO::BinaryRead(stream, pointSize); BinaryIO::BinaryRead(stream, pointSize);
stream.seekg((uint32_t)stream.tellg() + (pointSize * 9 * 4)); stream.seekg(static_cast<uint32_t>(stream.tellg()) + (pointSize * 9 * 4));
stream.seekg((uint32_t)stream.tellg() + (colorMapSize * colorMapSize)); stream.seekg(static_cast<uint32_t>(stream.tellg()) + (colorMapSize * colorMapSize));
uint32_t endCounter; uint32_t endCounter;
BinaryIO::BinaryRead(stream, endCounter); BinaryIO::BinaryRead(stream, endCounter);
stream.seekg((uint32_t)stream.tellg() + (endCounter * 2)); stream.seekg(static_cast<uint32_t>(stream.tellg()) + (endCounter * 2));
if (endCounter != 0) { if (endCounter != 0) {
stream.seekg((uint32_t)stream.tellg() + (32)); stream.seekg(static_cast<uint32_t>(stream.tellg()) + (32));
for (int i = 0; i < 0x10; i++) { for (int i = 0; i < 0x10; i++) {
uint16_t finalCountdown; uint16_t finalCountdown;
BinaryIO::BinaryRead(stream, finalCountdown); BinaryIO::BinaryRead(stream, finalCountdown);
stream.seekg((uint32_t)stream.tellg() + (finalCountdown * 2)); stream.seekg(static_cast<uint32_t>(stream.tellg()) + (finalCountdown * 2));
} }
} }

View File

@ -64,12 +64,12 @@ void AuthPackets::SendHandshake(dServer* server, const SystemAddress& sysAddr, c
return; return;
} }
bitStream.Write<uint32_t>(netVersion); bitStream.Write<uint32_t>(netVersion);
bitStream.Write(uint32_t(0x93)); bitStream.Write<uint32_t>(0x93);
if (serverType == ServerType::Auth) bitStream.Write(uint32_t(1)); //Conn: auth if (serverType == ServerType::Auth) bitStream.Write(uint32_t(1)); //Conn: auth
else bitStream.Write(uint32_t(4)); //Conn: world else bitStream.Write<uint32_t>(4); //Conn: world
bitStream.Write(uint32_t(0)); //Server process ID bitStream.Write<uint32_t>(0); //Server process ID
bitStream.Write(nextServerPort); bitStream.Write(nextServerPort);
server->Send(&bitStream, sysAddr, false); server->Send(&bitStream, sysAddr, false);
@ -155,7 +155,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
RakNet::BitStream packet; RakNet::BitStream packet;
BitStreamUtils::WriteHeader(packet, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE); BitStreamUtils::WriteHeader(packet, eConnectionType::CLIENT, eClientMessageType::LOGIN_RESPONSE);
packet.Write(static_cast<uint8_t>(responseCode)); packet.Write<uint8_t>(GeneralUtils::CastUnderlyingType(responseCode));
// Event Gating // Event Gating
packet.Write(LUString(Game::config->GetValue("event_1"))); packet.Write(LUString(Game::config->GetValue("event_1")));
@ -189,8 +189,8 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
packet.Write(LUString("")); packet.Write(LUString(""));
// Write the Character and Chat Ports // Write the Character and Chat Ports
packet.Write(static_cast<uint16_t>(wServerPort)); packet.Write<uint16_t>(wServerPort);
packet.Write(static_cast<uint16_t>(0)); packet.Write<uint16_t>(0);
// CDN Key // CDN Key
packet.Write(LUString("")); packet.Write(LUString(""));
@ -198,26 +198,26 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
// CDN Ticket // CDN Ticket
packet.Write(LUString("00000000-0000-0000-0000-000000000000", 37)); packet.Write(LUString("00000000-0000-0000-0000-000000000000", 37));
packet.Write(static_cast<uint32_t>(0)); // Language packet.Write<uint32_t>(0); // Language
// Write the localization // Write the localization
packet.Write(LUString("US", 3)); packet.Write(LUString("US", 3));
packet.Write(static_cast<uint8_t>(false)); // Just upgraded from F2P packet.Write<uint8_t>(false); // Just upgraded from F2P
packet.Write(static_cast<uint8_t>(false)); // User is F2P packet.Write<uint8_t>(false); // User is F2P
packet.Write(static_cast<uint64_t>(0)); // Time Remaining in F2P packet.Write<uint64_t>(0); // Time Remaining in F2P
// Write custom error message // Write custom error message
packet.Write(static_cast<uint16_t>(errorMsg.length())); packet.Write<uint16_t>(errorMsg.length());
packet.Write(LUWString(errorMsg, static_cast<uint32_t>(errorMsg.length()))); packet.Write(LUWString(errorMsg, static_cast<uint32_t>(errorMsg.length())));
// Here write auth logs // Here write auth logs
packet.Write(static_cast<uint32_t>(20)); packet.Write<uint32_t>(20);
for (uint32_t i = 0; i < 20; ++i) { for (uint32_t i = 0; i < 20; ++i) {
packet.Write(static_cast<uint32_t>(8)); packet.Write<uint32_t>(8);
packet.Write(static_cast<uint32_t>(44)); packet.Write<uint32_t>(44);
packet.Write(static_cast<uint32_t>(14000)); packet.Write<uint32_t>(14000);
packet.Write(static_cast<uint32_t>(0)); packet.Write<uint32_t>(0);
} }
server->Send(&packet, sysAddr, false); server->Send(&packet, sysAddr, false);

View File

@ -47,9 +47,9 @@ struct LUWString {
namespace BitStreamUtils { namespace BitStreamUtils {
template<typename T> template<typename T>
void WriteHeader(RakNet::BitStream& bitStream, eConnectionType connectionType, T internalPacketID) { void WriteHeader(RakNet::BitStream& bitStream, eConnectionType connectionType, T internalPacketID) {
bitStream.Write<uint8_t>(MessageID(ID_USER_PACKET_ENUM)); bitStream.Write<MessageID>(ID_USER_PACKET_ENUM);
bitStream.Write<eConnectionType>(connectionType); bitStream.Write<eConnectionType>(connectionType);
bitStream.Write<uint32_t>(static_cast<uint32_t>(internalPacketID)); bitStream.Write(static_cast<uint32_t>(internalPacketID));
bitStream.Write<uint8_t>(0); bitStream.Write<uint8_t>(0);
} }

View File

@ -17,20 +17,20 @@ void ChatPackets::SendChatMessage(const SystemAddress& sysAddr, char chatChannel
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GENERAL_CHAT_MESSAGE); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GENERAL_CHAT_MESSAGE);
bitStream.Write(static_cast<uint64_t>(0)); bitStream.Write<uint64_t>(0);
bitStream.Write(chatChannel); bitStream.Write(chatChannel);
bitStream.Write(static_cast<uint32_t>(message.size())); bitStream.Write<uint32_t>(message.size());
bitStream.Write(LUWString(senderName)); bitStream.Write(LUWString(senderName));
bitStream.Write(playerObjectID); bitStream.Write(playerObjectID);
bitStream.Write(static_cast<uint16_t>(0)); bitStream.Write<uint16_t>(0);
bitStream.Write(static_cast<char>(0)); bitStream.Write<char>(0);
for (uint32_t i = 0; i < message.size(); ++i) { for (uint32_t i = 0; i < message.size(); ++i) {
bitStream.Write(static_cast<uint16_t>(message[i])); bitStream.Write<uint16_t>(message[i]);
} }
bitStream.Write(static_cast<uint16_t>(0)); bitStream.Write<uint16_t>(0);
SEND_PACKET_BROADCAST; SEND_PACKET_BROADCAST;
} }
@ -39,21 +39,21 @@ void ChatPackets::SendSystemMessage(const SystemAddress& sysAddr, const std::u16
CBITSTREAM; CBITSTREAM;
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GENERAL_CHAT_MESSAGE); BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GENERAL_CHAT_MESSAGE);
bitStream.Write(static_cast<uint64_t>(0)); bitStream.Write<uint64_t>(0);
bitStream.Write(static_cast<char>(4)); bitStream.Write<char>(4);
bitStream.Write(static_cast<uint32_t>(message.size())); bitStream.Write<uint32_t>(message.size());
bitStream.Write(LUWString("", 33)); bitStream.Write(LUWString("", 33));
bitStream.Write(static_cast<uint64_t>(0)); bitStream.Write<uint64_t>(0);
bitStream.Write(static_cast<uint16_t>(0)); bitStream.Write<uint16_t>(0);
bitStream.Write(static_cast<char>(0)); bitStream.Write<char>(0);
for (uint32_t i = 0; i < message.size(); ++i) { for (uint32_t i = 0; i < message.size(); ++i) {
bitStream.Write(static_cast<uint16_t>(message[i])); bitStream.Write<uint16_t>(message[i]);
} }
bitStream.Write(static_cast<uint16_t>(0)); bitStream.Write<uint16_t>(0);
//This is so Wincent's announcement works: //This is so Wincent's announcement works:
if (sysAddr != UNASSIGNED_SYSTEM_ADDRESS) { if (sysAddr != UNASSIGNED_SYSTEM_ADDRESS) {

View File

@ -45,7 +45,7 @@ std::string PacketUtils::ReadString(uint32_t startLoc, Packet* packet, bool wide
if (packet->length > startLoc) { if (packet->length > startLoc) {
uint32_t i = 0; 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<uint32_t>(startLoc + i) && maxLen > i) {
readString.push_back(packet->data[startLoc + i]); readString.push_back(packet->data[startLoc + i]);
if (wide) { if (wide) {

View File

@ -52,7 +52,7 @@ void NpcAgCourseStarter::OnMessageBoxResponse(Entity* self, Entity* sender, int3
time_t startTime = std::time(0) + 4; // Offset for starting timer time_t startTime = std::time(0) + 4; // Offset for starting timer
data->values[1] = *(float*)&startTime; data->values[1] = *reinterpret_cast<float*>(&startTime);
Game::entityManager->SerializeEntity(self); Game::entityManager->SerializeEntity(self);
} else if (identifier == u"FootRaceCancel") { } else if (identifier == u"FootRaceCancel") {
@ -81,9 +81,9 @@ void NpcAgCourseStarter::OnFireEventServerSide(Entity* self, Entity* sender, std
scriptedActivityComponent->RemoveActivityPlayerData(sender->GetObjectID()); scriptedActivityComponent->RemoveActivityPlayerData(sender->GetObjectID());
} else if (args == "course_finish") { } else if (args == "course_finish") {
time_t endTime = std::time(0); time_t endTime = std::time(0);
time_t finish = (endTime - *(time_t*)&data->values[1]); time_t finish = (endTime - *reinterpret_cast<time_t*>(&data->values[1]));
data->values[2] = *(float*)&finish; data->values[2] = *reinterpret_cast<float*>(&finish);
auto* missionComponent = sender->GetComponent<MissionComponent>(); auto* missionComponent = sender->GetComponent<MissionComponent>();
if (missionComponent != nullptr) { if (missionComponent != nullptr) {

View File

@ -99,7 +99,7 @@ void AmDrawBridge::MoveBridgeDown(Entity* self, Entity* bridge, bool down) {
const auto travelTime = 2.0f; const auto travelTime = 2.0f;
forwardVect = forwardVect * (float)((degrees / travelTime) * (3.14f / 180.0f)); forwardVect = forwardVect * static_cast<float>((degrees / travelTime) * (3.14f / 180.0f));
simplePhysicsComponent->SetAngularVelocity(forwardVect); simplePhysicsComponent->SetAngularVelocity(forwardVect);

View File

@ -4,7 +4,7 @@
#include "Amf3.h" #include "Amf3.h"
void NsLegoClubDoor::OnStartup(Entity* self) { void NsLegoClubDoor::OnStartup(Entity* self) {
self->SetVar(u"currentZone", (int32_t)Game::zoneManager->GetZoneID().GetMapID()); self->SetVar(u"currentZone", static_cast<int32_t>(Game::zoneManager->GetZoneID().GetMapID()));
self->SetVar(u"choiceZone", m_ChoiceZoneID); self->SetVar(u"choiceZone", m_ChoiceZoneID);
self->SetVar(u"teleportAnim", m_TeleportAnim); self->SetVar(u"teleportAnim", m_TeleportAnim);
self->SetVar(u"teleportString", m_TeleportString); self->SetVar(u"teleportString", m_TeleportString);

View File

@ -4,7 +4,7 @@
#include "Amf3.h" #include "Amf3.h"
void NsLupTeleport::OnStartup(Entity* self) { void NsLupTeleport::OnStartup(Entity* self) {
self->SetVar(u"currentZone", (int32_t)Game::zoneManager->GetZoneID().GetMapID()); self->SetVar(u"currentZone", static_cast<int32_t>(Game::zoneManager->GetZoneID().GetMapID()));
self->SetVar(u"choiceZone", m_ChoiceZoneID); self->SetVar(u"choiceZone", m_ChoiceZoneID);
self->SetVar(u"teleportAnim", m_TeleportAnim); self->SetVar(u"teleportAnim", m_TeleportAnim);
self->SetVar(u"teleportString", m_TeleportString); self->SetVar(u"teleportString", m_TeleportString);

View File

@ -437,7 +437,7 @@ std::vector<Wave> ZoneNsWaves::GetWaves() {
}, {}, {}, }, {}, {},
"Treasure_Camera", "Treasure_Camera",
5.0f, 5.0f,
(uint32_t)-1, static_cast<uint32_t>(-1),
true, true,
60, 60,
}, },

View File

@ -53,9 +53,9 @@ void NjMonastryBossInstance::OnPlayerLoaded(Entity* self, Entity* player) {
// Buff the player // Buff the player
auto* destroyableComponent = player->GetComponent<DestroyableComponent>(); auto* destroyableComponent = player->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr) { if (destroyableComponent != nullptr) {
destroyableComponent->SetHealth((int32_t)destroyableComponent->GetMaxHealth()); destroyableComponent->SetHealth(static_cast<int32_t>(destroyableComponent->GetMaxHealth()));
destroyableComponent->SetArmor((int32_t)destroyableComponent->GetMaxArmor()); destroyableComponent->SetArmor(static_cast<int32_t>(destroyableComponent->GetMaxArmor()));
destroyableComponent->SetImagination((int32_t)destroyableComponent->GetMaxImagination()); destroyableComponent->SetImagination(static_cast<int32_t>(destroyableComponent->GetMaxImagination()));
} }
// Add player ID to instance // 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) { void NjMonastryBossInstance::OnActivityTimerDone(Entity* self, const std::string& name) {
auto split = GeneralUtils::SplitString(name, TimerSplitChar); auto split = GeneralUtils::SplitString(name, TimerSplitChar);
auto timerName = split[0]; auto timerName = split[0];
auto objectID = split.size() > 1 ? (LWOOBJID)std::stoull(split[1]) : LWOOBJID_EMPTY; auto objectID = split.size() > 1 ? static_cast<LWOOBJID>(std::stoull(split[1])) : LWOOBJID_EMPTY;
if (timerName == WaitingForPlayersTimer) { if (timerName == WaitingForPlayersTimer) {
StartFight(self); StartFight(self);
@ -309,7 +309,7 @@ void NjMonastryBossInstance::HandleLowerFrakjawSpawned(Entity* self, Entity* low
if (destroyableComponent != nullptr) { if (destroyableComponent != nullptr) {
const auto doubleHealth = destroyableComponent->GetHealth() * 2; const auto doubleHealth = destroyableComponent->GetHealth() * 2;
destroyableComponent->SetHealth(doubleHealth); destroyableComponent->SetHealth(doubleHealth);
destroyableComponent->SetMaxHealth((float_t)doubleHealth); destroyableComponent->SetMaxHealth(static_cast<float_t>(doubleHealth));
} }
ActivityTimerStart(self, FrakjawSpawnInTimer + std::to_string(lowerFrakjaw->GetObjectID()), ActivityTimerStart(self, FrakjawSpawnInTimer + std::to_string(lowerFrakjaw->GetObjectID()),
@ -328,7 +328,7 @@ void NjMonastryBossInstance::HandleLowerFrakjawHit(Entity* self, Entity* lowerFr
return; return;
// Progress the fight to the last wave if frakjaw has less than 50% of his health left // 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<bool>(OnLastWaveVarbiale)) { if (destroyableComponent->GetHealth() <= static_cast<uint32_t>(destroyableComponent->GetMaxHealth()) / 2 && !self->GetVar<bool>(OnLastWaveVarbiale)) {
self->SetVar<bool>(OnLastWaveVarbiale, true); self->SetVar<bool>(OnLastWaveVarbiale, true);
// Stun frakjaw during the cinematic // Stun frakjaw during the cinematic

View File

@ -115,7 +115,7 @@ void BaseSurvivalServer::BasePlayerExit(Entity* self, Entity* player) {
SetActivityValue(self, player->GetObjectID(), 1, 0); SetActivityValue(self, player->GetObjectID(), 1, 0);
self->SetNetworkVar<uint32_t>(NumberOfPlayersVariable, self->SetNetworkVar<uint32_t>(NumberOfPlayersVariable,
std::min((uint32_t)0, self->GetNetworkVar<uint32_t>(NumberOfPlayersVariable) - 1)); std::min(static_cast<uint32_t>(0), self->GetNetworkVar<uint32_t>(NumberOfPlayersVariable) - 1));
} }
void BaseSurvivalServer::BaseFireEvent(Entity* self, Entity* sender, const std::string& args, int32_t param1, int32_t param2, 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) { for (const auto& survivalMission : missionsToUpdate) {
auto* mission = missionComponent->GetMission(survivalMission.first); auto* mission = missionComponent->GetMission(survivalMission.first);
if (mission != nullptr && (uint32_t)time >= survivalMission.second if (mission != nullptr && static_cast<uint32_t>(time) >= survivalMission.second
&& (mission->GetMissionState() == eMissionState::ACTIVE && (mission->GetMissionState() == eMissionState::ACTIVE
|| mission->GetMissionState() == eMissionState::COMPLETE_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<uint32_t>(totalSpawned), state.totalSpawned);
} }
void BaseSurvivalServer::SpawnerUpdate(Entity* self, SpawnerNetworkCollection& spawnerNetworkCollection, uint32_t amount) { void BaseSurvivalServer::SpawnerUpdate(Entity* self, SpawnerNetworkCollection& spawnerNetworkCollection, uint32_t amount) {

View File

@ -95,7 +95,7 @@ void BaseWavesServer::BasePlayerExit(Entity* self, Entity* player) {
SetActivityValue(self, player->GetObjectID(), 2, 0); SetActivityValue(self, player->GetObjectID(), 2, 0);
self->SetNetworkVar<uint32_t>(NumberOfPlayersVariable, self->SetNetworkVar<uint32_t>(NumberOfPlayersVariable,
std::min((uint32_t)0, self->GetNetworkVar<uint32_t>(NumberOfPlayersVariable) - 1)); std::min(static_cast<uint32_t>(0), self->GetNetworkVar<uint32_t>(NumberOfPlayersVariable) - 1));
} }
// Done // Done
@ -212,7 +212,7 @@ void BaseWavesServer::OnActivityTimerDone(Entity* self, const std::string& name)
const auto currentTime = ActivityTimerGetCurrentTime(self, ClockTickTimer); const auto currentTime = ActivityTimerGetCurrentTime(self, ClockTickTimer);
const auto currentWave = state.waveNumber; const auto currentWave = state.waveNumber;
self->SetNetworkVar<uint32_t>(WaveCompleteVariable, { currentWave, (uint32_t)currentTime }); self->SetNetworkVar<uint32_t>(WaveCompleteVariable, { currentWave, static_cast<uint32_t>(currentTime) });
} else if (name == GameOverWinTimer) { } else if (name == GameOverWinTimer) {
GameOver(self, true); GameOver(self, true);
} else if (name == CinematicDoneTimer) { } else if (name == CinematicDoneTimer) {
@ -421,7 +421,7 @@ void BaseWavesServer::SpawnWave(Entity* self) {
const auto wave = waves.at(state.waveNumber); const auto wave = waves.at(state.waveNumber);
// Handles meta info to the client about the current round // Handles meta info to the client about the current round
if (wave.winDelay != (uint32_t)-1) { if (wave.winDelay != static_cast<uint32_t>(-1)) {
self->SetNetworkVar<bool>(WonWaveVariable, true); self->SetNetworkVar<bool>(WonWaveVariable, true);
// Close the game if we don't expect a notification from an other entity to end it // 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 { } else {
if (wave.timeLimit != (uint32_t)-1) { if (wave.timeLimit != static_cast<uint32_t>(-1)) {
ActivityTimerStart(self, TimedWaveTimer, 1.0f, wave.timeLimit); ActivityTimerStart(self, TimedWaveTimer, 1.0f, wave.timeLimit);
self->SetNetworkVar<uint32_t>(StartTimedWaveVariable, { wave.timeLimit, state.waveNumber + 1 }); self->SetNetworkVar<uint32_t>(StartTimedWaveVariable, { wave.timeLimit, state.waveNumber + 1 });
} else { } 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 // 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<uint32_t>(WaveCompleteVariable, { state.waveNumber, (uint32_t)currentTime }); self->SetNetworkVar<uint32_t>(WaveCompleteVariable, { state.waveNumber, static_cast<uint32_t>(currentTime) });
return true; return true;
} }

View File

@ -171,7 +171,7 @@ void SGCannon::SuperChargeTimerFunc(Entity* self) {
void SGCannon::SpawnWaveTimerFunc(Entity* self) { void SGCannon::SpawnWaveTimerFunc(Entity* self) {
if (self->GetVar<bool>(GameStartedVariable)) { if (self->GetVar<bool>(GameStartedVariable)) {
self->SetVar<bool>(WaveStatusVariable, true); self->SetVar<bool>(WaveStatusVariable, true);
const auto wave = (int32_t)self->GetVar<uint32_t>(ThisWaveVariable); const auto wave = static_cast<int32_t>(self->GetVar<uint32_t>(ThisWaveVariable));
if (wave != 0 && self->GetVar<bool>(SuperChargePausedVariable)) { if (wave != 0 && self->GetVar<bool>(SuperChargePausedVariable)) {
StartChargedCannon(self, self->GetVar<uint32_t>(CurrentSuperChargedTimeVariable)); StartChargedCannon(self, self->GetVar<uint32_t>(CurrentSuperChargedTimeVariable));
@ -187,7 +187,7 @@ void SGCannon::SpawnWaveTimerFunc(Entity* self) {
LOG("Current wave spawn: %i/%i", wave, m_Waves.size()); LOG("Current wave spawn: %i/%i", wave, m_Waves.size());
// All waves completed // All waves completed
const auto timeLimit = (float_t)self->GetVar<uint32_t>(TimeLimitVariable); const auto timeLimit = static_cast<float_t>(self->GetVar<uint32_t>(TimeLimitVariable));
if (wave >= m_Waves.size()) { if (wave >= m_Waves.size()) {
ActivityTimerStart(self, GameOverTimer, timeLimit, timeLimit); ActivityTimerStart(self, GameOverTimer, timeLimit, timeLimit);
} else { } else {
@ -262,7 +262,7 @@ void SGCannon::GameOverTimerFunc(Entity* self) {
void SGCannon::DoSpawnTimerFunc(Entity* self, const std::string& name) { void SGCannon::DoSpawnTimerFunc(Entity* self, const std::string& name) {
if (self->GetVar<bool>(GameStartedVariable)) { if (self->GetVar<bool>(GameStartedVariable)) {
LOG_DEBUG("time name %s %s", name.c_str(), name.substr(7).c_str()); 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<uint32_t>(std::stoi(name.substr(7)));
const auto& activeSpawns = self->GetVar<std::vector<SGEnemy>>(ActiveSpawnsVariable); const auto& activeSpawns = self->GetVar<std::vector<SGEnemy>>(ActiveSpawnsVariable);
LOG_DEBUG("size %i, %i", activeSpawns.size(), spawnNumber); LOG_DEBUG("size %i, %i", activeSpawns.size(), spawnNumber);
if (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) { void SGCannon::RecordPlayerScore(Entity* self) {
const auto totalScore = self->GetVar<uint32_t>(TotalScoreVariable); const auto totalScore = self->GetVar<int32_t>(TotalScoreVariable);
const auto currentWave = self->GetVar<uint32_t>(ThisWaveVariable); const auto currentWave = self->GetVar<uint32_t>(ThisWaveVariable);
if (currentWave > 0) { if (currentWave > 0) {
@ -555,7 +555,7 @@ void SGCannon::PlaySceneAnimation(Entity* self, const std::u16string& animationN
} }
void SGCannon::PauseChargeCannon(Entity* self) { 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<uint32_t>(std::ceil(ActivityTimerGetCurrentTime(self, SuperChargeTimer))), static_cast<uint32_t>(1));
self->SetVar<bool>(SuperChargePausedVariable, true); self->SetVar<bool>(SuperChargePausedVariable, true);
self->SetVar<uint32_t>(CurrentSuperChargedTimeVariable, time); self->SetVar<uint32_t>(CurrentSuperChargedTimeVariable, time);
@ -587,17 +587,17 @@ void SGCannon::StopGame(Entity* self, bool cancel) {
auto* missionComponent = player->GetComponent<MissionComponent>(); auto* missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent != nullptr) { if (missionComponent != nullptr) {
missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, self->GetVar<uint32_t>(TotalScoreVariable), self->GetObjectID(), "performact_score"); missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, self->GetVar<int32_t>(TotalScoreVariable), self->GetObjectID(), "performact_score");
missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, self->GetVar<uint32_t>(MaxStreakVariable), self->GetObjectID(), "performact_streak"); missionComponent->Progress(eMissionTaskType::PERFORM_ACTIVITY, self->GetVar<uint32_t>(MaxStreakVariable), self->GetObjectID(), "performact_streak");
missionComponent->Progress(eMissionTaskType::ACTIVITY, m_CannonLot, 0, "", self->GetVar<uint32_t>(TotalScoreVariable)); missionComponent->Progress(eMissionTaskType::ACTIVITY, m_CannonLot, 0, "", self->GetVar<int32_t>(TotalScoreVariable));
} }
Loot::GiveActivityLoot(player, self, GetGameID(self), self->GetVar<uint32_t>(TotalScoreVariable)); Loot::GiveActivityLoot(player, self, GetGameID(self), self->GetVar<int32_t>(TotalScoreVariable));
SaveScore(self, player->GetObjectID(), SaveScore(self, player->GetObjectID(),
static_cast<float>(self->GetVar<uint32_t>(TotalScoreVariable)), static_cast<float>(self->GetVar<uint32_t>(MaxStreakVariable)), percentage); static_cast<float>(self->GetVar<int32_t>(TotalScoreVariable)), static_cast<float>(self->GetVar<uint32_t>(MaxStreakVariable)), percentage);
StopActivity(self, player->GetObjectID(), self->GetVar<uint32_t>(TotalScoreVariable), self->GetVar<uint32_t>(MaxStreakVariable), percentage); StopActivity(self, player->GetObjectID(), self->GetVar<int32_t>(TotalScoreVariable), self->GetVar<uint32_t>(MaxStreakVariable), percentage);
self->SetNetworkVar<bool>(AudioFinalWaveDoneVariable, true); self->SetNetworkVar<bool>(AudioFinalWaveDoneVariable, true);
// Give the player the model rewards they earned // Give the player the model rewards they earned
@ -609,7 +609,7 @@ void SGCannon::StopGame(Entity* self, bool cancel) {
} }
self->SetNetworkVar<std::u16string>(u"UI_Rewards", self->SetNetworkVar<std::u16string>(u"UI_Rewards",
GeneralUtils::to_u16string(self->GetVar<uint32_t>(TotalScoreVariable)) + u"_0_0_0_0_0_0" GeneralUtils::to_u16string(self->GetVar<int32_t>(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); ActivityTimerStart(self, timerName, respawnTime, respawnTime);
} }
int score = spawnInfo.score; int32_t score = spawnInfo.score;
if (score > 0) { if (score > 0) {
score += score * GetCurrentBonus(self); score += score * GetCurrentBonus(self);
@ -652,7 +652,7 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time
auto lastSuperTotal = self->GetVar<uint32_t>(u"LastSuperTotal"); auto lastSuperTotal = self->GetVar<uint32_t>(u"LastSuperTotal");
auto scScore = self->GetVar<uint32_t>(TotalScoreVariable) - lastSuperTotal; auto scScore = self->GetVar<int32_t>(TotalScoreVariable) - lastSuperTotal;
LOG("LastSuperTotal: %i, scScore: %i, constants.chargedPoints: %i", LOG("LastSuperTotal: %i, scScore: %i, constants.chargedPoints: %i",
lastSuperTotal, scScore, constants.chargedPoints lastSuperTotal, scScore, constants.chargedPoints
@ -661,7 +661,7 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time
if (!self->GetVar<bool>(SuperChargeActiveVariable) && scScore >= constants.chargedPoints && score >= 0) { if (!self->GetVar<bool>(SuperChargeActiveVariable) && scScore >= constants.chargedPoints && score >= 0) {
StartChargedCannon(self); StartChargedCannon(self);
self->SetNetworkVar<float>(u"SuperChargeBar", 100.0f); self->SetNetworkVar<float>(u"SuperChargeBar", 100.0f);
self->SetVar<uint32_t>(u"LastSuperTotal", self->GetVar<uint32_t>(TotalScoreVariable)); self->SetVar<uint32_t>(u"LastSuperTotal", self->GetVar<int32_t>(TotalScoreVariable));
} }
UpdateStreak(self); UpdateStreak(self);
@ -673,13 +673,13 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time
target->GetPosition() target->GetPosition()
); );
auto newScore = (int)self->GetVar<uint32_t>(TotalScoreVariable) + score; auto newScore = self->GetVar<int32_t>(TotalScoreVariable) + score;
if (newScore < 0) { if (newScore < 0) {
newScore = 0; newScore = 0;
} }
self->SetVar<uint32_t>(TotalScoreVariable, newScore); self->SetVar<int32_t>(TotalScoreVariable, newScore);
self->SetNetworkVar<uint32_t>(u"updateScore", newScore); self->SetNetworkVar<uint32_t>(u"updateScore", newScore);
@ -1038,7 +1038,7 @@ void SGCannon::ResetVars(Entity* self) {
self->SetVar<uint32_t>(LastSuperTotalVariable, 0); self->SetVar<uint32_t>(LastSuperTotalVariable, 0);
self->SetVar<LOT>(CurrentRewardVariable, LOT_NULL); self->SetVar<LOT>(CurrentRewardVariable, LOT_NULL);
self->SetVar<std::vector<LOT>>(RewardsVariable, {}); self->SetVar<std::vector<LOT>>(RewardsVariable, {});
self->SetVar<uint32_t>(TotalScoreVariable, 0); self->SetVar<int32_t>(TotalScoreVariable, 0);
self->SetVar<uint32_t>(u"m_curStreak", 0); self->SetVar<uint32_t>(u"m_curStreak", 0);
self->SetNetworkVar<float>(u"SuperChargeBar", 0); self->SetNetworkVar<float>(u"SuperChargeBar", 0);

View File

@ -30,8 +30,8 @@ void FvRaceSmashEggImagineServer::OnDie(Entity* self, Entity* killer) {
} }
if (missionComponent == nullptr) return; if (missionComponent == nullptr) return;
// Dragon eggs have their own smash server so we handle mission progression for them here. // 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, 0, static_cast<LWOOBJID>(eRacingTaskParam::SMASHABLES));
missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), (LWOOBJID)eRacingTaskParam::SMASH_SPECIFIC_SMASHABLE); missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), static_cast<LWOOBJID>(eRacingTaskParam::SMASH_SPECIFIC_SMASHABLE));
} }
} }

View File

@ -50,7 +50,7 @@ void RaceImagineCrateServer::OnDie(Entity* self, Entity* killer) {
// Progress racing smashable missions // Progress racing smashable missions
if (missionComponent == nullptr) return; if (missionComponent == nullptr) return;
missionComponent->Progress(eMissionTaskType::RACING, 0, (LWOOBJID)eRacingTaskParam::SMASHABLES); missionComponent->Progress(eMissionTaskType::RACING, 0, static_cast<LWOOBJID>(eRacingTaskParam::SMASHABLES));
} }
} }
} }

View File

@ -32,6 +32,6 @@ void RaceImaginePowerup::OnFireEventServerSide(Entity* self, Entity* sender, std
auto* missionComponent = sender->GetComponent<MissionComponent>(); auto* missionComponent = sender->GetComponent<MissionComponent>();
if (missionComponent == nullptr) return; if (missionComponent == nullptr) return;
missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), (LWOOBJID)eRacingTaskParam::COLLECT_IMAGINATION); missionComponent->Progress(eMissionTaskType::RACING, self->GetLOT(), static_cast<LWOOBJID>(eRacingTaskParam::COLLECT_IMAGINATION));
} }
} }

View File

@ -23,9 +23,9 @@ void RaceSmashServer::OnDie(Entity* self, Entity* killer) {
// Progress racing smashable missions // Progress racing smashable missions
if (missionComponent == nullptr) return; if (missionComponent == nullptr) return;
missionComponent->Progress(eMissionTaskType::RACING, 0, (LWOOBJID)eRacingTaskParam::SMASHABLES); missionComponent->Progress(eMissionTaskType::RACING, 0, static_cast<LWOOBJID>(eRacingTaskParam::SMASHABLES));
// Progress missions that ask us to smash a specific smashable. // 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<LWOOBJID>(eRacingTaskParam::SMASH_SPECIFIC_SMASHABLE));
} }
} }
} }

View File

@ -59,7 +59,7 @@ void Zone::LoadZoneIntoMemory() {
if (m_FileFormatVersion >= Zone::FileFormatVersion::Alpha) BinaryIO::BinaryRead(file, mapRevision); if (m_FileFormatVersion >= Zone::FileFormatVersion::Alpha) BinaryIO::BinaryRead(file, mapRevision);
BinaryIO::BinaryRead(file, m_WorldID); 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<LWOMAPID>(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); AddRevision(LWOSCENEID_INVALID, mapRevision);