format codebase

This commit is contained in:
aronwk-aaron
2022-07-28 08:39:57 -05:00
parent 4f7aa11067
commit 19e77a38d8
881 changed files with 34700 additions and 38689 deletions

View File

@ -98,8 +98,7 @@ int main(int argc, char** argv) {
if (framesSinceMasterDisconnect >= 30) if (framesSinceMasterDisconnect >= 30)
break; //Exit our loop, shut down. break; //Exit our loop, shut down.
} } else framesSinceMasterDisconnect = 0;
else framesSinceMasterDisconnect = 0;
//In world we'd update our other systems here. //In world we'd update our other systems here.
@ -134,8 +133,7 @@ int main(int argc, char** argv) {
delete stmt; delete stmt;
framesSinceLastSQLPing = 0; framesSinceLastSQLPing = 0;
} } else framesSinceLastSQLPing++;
else framesSinceLastSQLPing++;
//Sleep our thread since auth can afford to. //Sleep our thread since auth can afford to.
t += std::chrono::milliseconds(mediumFramerate); //Auth can run at a lower "fps" t += std::chrono::milliseconds(mediumFramerate); //Auth can run at a lower "fps"
@ -151,7 +149,7 @@ int main(int argc, char** argv) {
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
dLogger * SetupLogger() { dLogger* SetupLogger() {
std::string logPath = "./logs/AuthServer_" + std::to_string(time(nullptr)) + ".log"; std::string logPath = "./logs/AuthServer_" + std::to_string(time(nullptr)) + ".log";
bool logToConsole = false; bool logToConsole = false;
bool logDebugStatements = false; bool logDebugStatements = false;

View File

@ -21,8 +21,7 @@ dChatFilter::dChatFilter(const std::string& filepath, bool dontGenerateDCF) {
if (!BinaryIO::DoesFileExist(filepath + ".dcf") || m_DontGenerateDCF) { if (!BinaryIO::DoesFileExist(filepath + ".dcf") || m_DontGenerateDCF) {
ReadWordlistPlaintext(filepath + ".txt", true); ReadWordlistPlaintext(filepath + ".txt", true);
if (!m_DontGenerateDCF) ExportWordlistToDCF(filepath + ".dcf", true); if (!m_DontGenerateDCF) ExportWordlistToDCF(filepath + ".dcf", true);
} } else if (!ReadWordlistDCF(filepath + ".dcf", true)) {
else if (!ReadWordlistDCF(filepath + ".dcf", true)) {
ReadWordlistPlaintext(filepath + ".txt", true); ReadWordlistPlaintext(filepath + ".txt", true);
ExportWordlistToDCF(filepath + ".dcf", true); ExportWordlistToDCF(filepath + ".dcf", true);
} }
@ -85,8 +84,7 @@ bool dChatFilter::ReadWordlistDCF(const std::string& filepath, bool whiteList) {
} }
return true; return true;
} } else {
else {
file.close(); file.close();
return false; return false;
} }

View File

@ -48,7 +48,7 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
GeneralUtils::SetBit(fd.friendID, static_cast<size_t>(eObjectBits::OBJECT_BIT_CHARACTER)); GeneralUtils::SetBit(fd.friendID, static_cast<size_t>(eObjectBits::OBJECT_BIT_CHARACTER));
fd.isBestFriend = res->getInt(2) == 3; //0 = friends, 1 = left_requested, 2 = right_requested, 3 = both_accepted - are now bffs fd.isBestFriend = res->getInt(2) == 3; //0 = friends, 1 = left_requested, 2 = right_requested, 3 = both_accepted - are now bffs
if (fd.isBestFriend) player->countOfBestFriends+=1; if (fd.isBestFriend) player->countOfBestFriends += 1;
fd.friendName = res->getString(3); fd.friendName = res->getString(3);
//Now check if they're online: //Now check if they're online:
@ -60,8 +60,7 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
//Since this friend is online, we need to update them on the fact that we've just logged in: //Since this friend is online, we need to update them on the fact that we've just logged in:
SendFriendUpdate(fr, player, 1, fd.isBestFriend); SendFriendUpdate(fr, player, 1, fd.isBestFriend);
} } else {
else {
fd.isOnline = false; fd.isOnline = false;
fd.zoneID = LWOZONEID(); fd.zoneID = LWOZONEID();
} }
@ -209,8 +208,8 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
updateQuery->executeUpdate(); updateQuery->executeUpdate();
// Sent the best friend update here if the value is 3 // Sent the best friend update here if the value is 3
if (bestFriendStatus == 3U) { if (bestFriendStatus == 3U) {
requestee->countOfBestFriends+=1; requestee->countOfBestFriends += 1;
requestor->countOfBestFriends+=1; requestor->countOfBestFriends += 1;
if (requestee->sysAddr != UNASSIGNED_SYSTEM_ADDRESS) SendFriendResponse(requestee.get(), requestor, AddFriendResponseType::ACCEPTED, false, true); if (requestee->sysAddr != UNASSIGNED_SYSTEM_ADDRESS) SendFriendResponse(requestee.get(), requestor, AddFriendResponseType::ACCEPTED, false, true);
if (requestor->sysAddr != UNASSIGNED_SYSTEM_ADDRESS) SendFriendResponse(requestor, requestee.get(), AddFriendResponseType::ACCEPTED, false, true); if (requestor->sysAddr != UNASSIGNED_SYSTEM_ADDRESS) SendFriendResponse(requestor, requestee.get(), AddFriendResponseType::ACCEPTED, false, true);
for (auto& friendData : requestor->friends) { for (auto& friendData : requestor->friends) {
@ -371,8 +370,7 @@ void ChatPacketHandler::HandleRemoveFriend(Packet* packet) {
SendRemoveFriend(goonB, goonAName, true); SendRemoveFriend(goonB, goonAName, true);
} }
void ChatPacketHandler::HandleChatMessage(Packet* packet) void ChatPacketHandler::HandleChatMessage(Packet* packet) {
{
CINSTREAM; CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY; LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID); inStream.Read(playerID);
@ -401,8 +399,7 @@ void ChatPacketHandler::HandleChatMessage(Packet* packet)
if (team == nullptr) return; if (team == nullptr) return;
for (const auto memberId : team->memberIDs) for (const auto memberId : team->memberIDs) {
{
auto* otherMember = playerContainer.GetPlayerData(memberId); auto* otherMember = playerContainer.GetPlayerData(memberId);
if (otherMember == nullptr) return; if (otherMember == nullptr) return;
@ -493,8 +490,7 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) {
} }
} }
void ChatPacketHandler::HandleTeamInvite(Packet* packet) void ChatPacketHandler::HandleTeamInvite(Packet* packet) {
{
CINSTREAM; CINSTREAM;
LWOOBJID playerID; LWOOBJID playerID;
inStream.Read(playerID); inStream.Read(playerID);
@ -503,27 +499,23 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet)
auto* player = playerContainer.GetPlayerData(playerID); auto* player = playerContainer.GetPlayerData(playerID);
if (player == nullptr) if (player == nullptr) {
{
return; return;
} }
auto* team = playerContainer.GetTeam(playerID); auto* team = playerContainer.GetTeam(playerID);
if (team == nullptr) if (team == nullptr) {
{
team = playerContainer.CreateTeam(playerID); team = playerContainer.CreateTeam(playerID);
} }
auto* other = playerContainer.GetPlayerData(invitedPlayer); auto* other = playerContainer.GetPlayerData(invitedPlayer);
if (other == nullptr) if (other == nullptr) {
{
return; return;
} }
if (playerContainer.GetTeam(other->playerID) != nullptr) if (playerContainer.GetTeam(other->playerID) != nullptr) {
{
return; return;
} }
@ -539,8 +531,7 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet)
Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s", playerID, invitedPlayer.c_str()); Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s", playerID, invitedPlayer.c_str());
} }
void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet) void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet) {
{
CINSTREAM; CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY; LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID); inStream.Read(playerID);
@ -554,22 +545,19 @@ void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet)
Game::logger->Log("ChatPacketHandler", "Accepted invite: %llu -> %llu (%d)", playerID, leaderID, declined); Game::logger->Log("ChatPacketHandler", "Accepted invite: %llu -> %llu (%d)", playerID, leaderID, declined);
if (declined) if (declined) {
{
return; return;
} }
auto* team = playerContainer.GetTeam(leaderID); auto* team = playerContainer.GetTeam(leaderID);
if (team == nullptr) if (team == nullptr) {
{
Game::logger->Log("ChatPacketHandler", "Failed to find team for leader (%llu)", leaderID); Game::logger->Log("ChatPacketHandler", "Failed to find team for leader (%llu)", leaderID);
team = playerContainer.GetTeam(playerID); team = playerContainer.GetTeam(playerID);
} }
if (team == nullptr) if (team == nullptr) {
{
Game::logger->Log("ChatPacketHandler", "Failed to find team for player (%llu)", playerID); Game::logger->Log("ChatPacketHandler", "Failed to find team for player (%llu)", playerID);
return; return;
} }
@ -577,8 +565,7 @@ void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet)
playerContainer.AddMember(team, playerID); playerContainer.AddMember(team, playerID);
} }
void ChatPacketHandler::HandleTeamLeave(Packet* packet) void ChatPacketHandler::HandleTeamLeave(Packet* packet) {
{
CINSTREAM; CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY; LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID); inStream.Read(playerID);
@ -590,14 +577,12 @@ void ChatPacketHandler::HandleTeamLeave(Packet* packet)
Game::logger->Log("ChatPacketHandler", "(%llu) leaving team", playerID); Game::logger->Log("ChatPacketHandler", "(%llu) leaving team", playerID);
if (team != nullptr) if (team != nullptr) {
{
playerContainer.RemoveMember(team, playerID, false, false, true); playerContainer.RemoveMember(team, playerID, false, false, true);
} }
} }
void ChatPacketHandler::HandleTeamKick(Packet* packet) void ChatPacketHandler::HandleTeamKick(Packet* packet) {
{
CINSTREAM; CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY; LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID); inStream.Read(playerID);
@ -611,12 +596,9 @@ void ChatPacketHandler::HandleTeamKick(Packet* packet)
LWOOBJID kickedId = LWOOBJID_EMPTY; LWOOBJID kickedId = LWOOBJID_EMPTY;
if (kicked != nullptr) if (kicked != nullptr) {
{
kickedId = kicked->playerID; kickedId = kicked->playerID;
} } else {
else
{
kickedId = playerContainer.GetId(GeneralUtils::ASCIIToUTF16(kickedPlayer)); kickedId = playerContainer.GetId(GeneralUtils::ASCIIToUTF16(kickedPlayer));
} }
@ -624,16 +606,14 @@ void ChatPacketHandler::HandleTeamKick(Packet* packet)
auto* team = playerContainer.GetTeam(playerID); auto* team = playerContainer.GetTeam(playerID);
if (team != nullptr) if (team != nullptr) {
{
if (team->leaderID != playerID || team->leaderID == kickedId) return; if (team->leaderID != playerID || team->leaderID == kickedId) return;
playerContainer.RemoveMember(team, kickedId, false, true, false); playerContainer.RemoveMember(team, kickedId, false, true, false);
} }
} }
void ChatPacketHandler::HandleTeamPromote(Packet* packet) void ChatPacketHandler::HandleTeamPromote(Packet* packet) {
{
CINSTREAM; CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY; LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID); inStream.Read(playerID);
@ -649,16 +629,14 @@ void ChatPacketHandler::HandleTeamPromote(Packet* packet)
auto* team = playerContainer.GetTeam(playerID); auto* team = playerContainer.GetTeam(playerID);
if (team != nullptr) if (team != nullptr) {
{
if (team->leaderID != playerID) return; if (team->leaderID != playerID) return;
playerContainer.PromoteMember(team, promoted->playerID); playerContainer.PromoteMember(team, promoted->playerID);
} }
} }
void ChatPacketHandler::HandleTeamLootOption(Packet* packet) void ChatPacketHandler::HandleTeamLootOption(Packet* packet) {
{
CINSTREAM; CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY; LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID); inStream.Read(playerID);
@ -671,8 +649,7 @@ void ChatPacketHandler::HandleTeamLootOption(Packet* packet)
auto* team = playerContainer.GetTeam(playerID); auto* team = playerContainer.GetTeam(playerID);
if (team != nullptr) if (team != nullptr) {
{
if (team->leaderID != playerID) return; if (team->leaderID != playerID) return;
team->lootFlag = option; team->lootFlag = option;
@ -683,8 +660,7 @@ void ChatPacketHandler::HandleTeamLootOption(Packet* packet)
} }
} }
void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet) void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet) {
{
CINSTREAM; CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY; LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID); inStream.Read(playerID);
@ -693,28 +669,22 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet)
auto* team = playerContainer.GetTeam(playerID); auto* team = playerContainer.GetTeam(playerID);
auto* data = playerContainer.GetPlayerData(playerID); auto* data = playerContainer.GetPlayerData(playerID);
if (team != nullptr && data != nullptr) if (team != nullptr && data != nullptr) {
{ if (team->local && data->zoneID.GetMapID() != team->zoneId.GetMapID() && data->zoneID.GetCloneID() != team->zoneId.GetCloneID()) {
if (team->local && data->zoneID.GetMapID() != team->zoneId.GetMapID() && data->zoneID.GetCloneID() != team->zoneId.GetCloneID())
{
playerContainer.RemoveMember(team, playerID, false, false, true, true); playerContainer.RemoveMember(team, playerID, false, false, true, true);
return; return;
} }
if (team->memberIDs.size() <= 1 && !team->local) if (team->memberIDs.size() <= 1 && !team->local) {
{
playerContainer.DisbandTeam(team); playerContainer.DisbandTeam(team);
return; return;
} }
if (!team->local) if (!team->local) {
{
ChatPacketHandler::SendTeamSetLeader(data, team->leaderID); ChatPacketHandler::SendTeamSetLeader(data, team->leaderID);
} } else {
else
{
ChatPacketHandler::SendTeamSetLeader(data, LWOOBJID_EMPTY); ChatPacketHandler::SendTeamSetLeader(data, LWOOBJID_EMPTY);
} }
@ -722,16 +692,14 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet)
const auto leaderName = GeneralUtils::ASCIIToUTF16(std::string(data->playerName.c_str())); const auto leaderName = GeneralUtils::ASCIIToUTF16(std::string(data->playerName.c_str()));
for (const auto memberId : team->memberIDs) for (const auto memberId : team->memberIDs) {
{
auto* otherMember = playerContainer.GetPlayerData(memberId); auto* otherMember = playerContainer.GetPlayerData(memberId);
if (memberId == playerID) continue; if (memberId == playerID) continue;
const auto memberName = playerContainer.GetName(memberId); const auto memberName = playerContainer.GetName(memberId);
if (otherMember != nullptr) if (otherMember != nullptr) {
{
ChatPacketHandler::SendTeamSetOffWorldFlag(otherMember, data->playerID, data->zoneID); ChatPacketHandler::SendTeamSetOffWorldFlag(otherMember, data->playerID, data->zoneID);
} }
ChatPacketHandler::SendTeamAddPlayer(data, false, team->local, false, memberId, memberName, otherMember != nullptr ? otherMember->zoneID : LWOZONEID(0, 0, 0)); ChatPacketHandler::SendTeamAddPlayer(data, false, team->local, false, memberId, memberName, otherMember != nullptr ? otherMember->zoneID : LWOZONEID(0, 0, 0));
@ -741,8 +709,7 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet)
} }
} }
void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender) void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender) {
{
CBITSTREAM; CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
@ -757,8 +724,7 @@ void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender)
SEND_PACKET; SEND_PACKET;
} }
void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName) void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName) {
{
CBITSTREAM; CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
@ -777,8 +743,7 @@ void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeader
bitStream.Write(ucNumOfOtherPlayers); bitStream.Write(ucNumOfOtherPlayers);
bitStream.Write(ucResponseCode); bitStream.Write(ucResponseCode);
bitStream.Write(static_cast<uint32_t>(wsLeaderName.size())); bitStream.Write(static_cast<uint32_t>(wsLeaderName.size()));
for (const auto character : wsLeaderName) for (const auto character : wsLeaderName) {
{
bitStream.Write(character); bitStream.Write(character);
} }
@ -786,8 +751,7 @@ void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeader
SEND_PACKET; SEND_PACKET;
} }
void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName) void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName) {
{
CBITSTREAM; CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
@ -804,8 +768,7 @@ void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderI
bitStream.Write(ucLootFlag); bitStream.Write(ucLootFlag);
bitStream.Write(ucNumOfOtherPlayers); bitStream.Write(ucNumOfOtherPlayers);
bitStream.Write(static_cast<uint32_t>(wsLeaderName.size())); bitStream.Write(static_cast<uint32_t>(wsLeaderName.size()));
for (const auto character : wsLeaderName) for (const auto character : wsLeaderName) {
{
bitStream.Write(character); bitStream.Write(character);
} }
@ -813,8 +776,7 @@ void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderI
SEND_PACKET; SEND_PACKET;
} }
void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64PlayerID) void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64PlayerID) {
{
CBITSTREAM; CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
@ -831,8 +793,7 @@ void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64Play
SEND_PACKET; SEND_PACKET;
} }
void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID) void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID) {
{
CBITSTREAM; CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
@ -848,13 +809,11 @@ void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTria
bitStream.Write(bNoLootOnDeath); bitStream.Write(bNoLootOnDeath);
bitStream.Write(i64PlayerID); bitStream.Write(i64PlayerID);
bitStream.Write(static_cast<uint32_t>(wsPlayerName.size())); bitStream.Write(static_cast<uint32_t>(wsPlayerName.size()));
for (const auto character : wsPlayerName) for (const auto character : wsPlayerName) {
{
bitStream.Write(character); bitStream.Write(character);
} }
bitStream.Write1(); bitStream.Write1();
if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID()) if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID()) {
{
zoneID = LWOZONEID(zoneID.GetMapID(), zoneID.GetInstanceID(), 0); zoneID = LWOZONEID(zoneID.GetMapID(), zoneID.GetInstanceID(), 0);
} }
bitStream.Write(zoneID); bitStream.Write(zoneID);
@ -863,8 +822,7 @@ void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTria
SEND_PACKET; SEND_PACKET;
} }
void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName) void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName) {
{
CBITSTREAM; CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
@ -882,8 +840,7 @@ void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband
bitStream.Write(i64LeaderID); bitStream.Write(i64LeaderID);
bitStream.Write(i64PlayerID); bitStream.Write(i64PlayerID);
bitStream.Write(static_cast<uint32_t>(wsPlayerName.size())); bitStream.Write(static_cast<uint32_t>(wsPlayerName.size()));
for (const auto character : wsPlayerName) for (const auto character : wsPlayerName) {
{
bitStream.Write(character); bitStream.Write(character);
} }
@ -891,8 +848,7 @@ void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband
SEND_PACKET; SEND_PACKET;
} }
void ChatPacketHandler::SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID) void ChatPacketHandler::SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID) {
{
CBITSTREAM; CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER); PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
@ -904,8 +860,7 @@ void ChatPacketHandler::SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i
bitStream.Write(GAME_MSG::GAME_MSG_TEAM_SET_OFF_WORLD_FLAG); bitStream.Write(GAME_MSG::GAME_MSG_TEAM_SET_OFF_WORLD_FLAG);
bitStream.Write(i64PlayerID); bitStream.Write(i64PlayerID);
if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID()) if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID()) {
{
zoneID = LWOZONEID(zoneID.GetMapID(), zoneID.GetInstanceID(), 0); zoneID = LWOZONEID(zoneID.GetMapID(), zoneID.GetInstanceID(), 0);
} }
bitStream.Write(zoneID); bitStream.Write(zoneID);
@ -943,12 +898,9 @@ void ChatPacketHandler::SendFriendUpdate(PlayerData* friendData, PlayerData* pla
bitStream.Write(playerData->zoneID.GetMapID()); bitStream.Write(playerData->zoneID.GetMapID());
bitStream.Write(playerData->zoneID.GetInstanceID()); bitStream.Write(playerData->zoneID.GetInstanceID());
if (playerData->zoneID.GetCloneID() == friendData->zoneID.GetCloneID()) if (playerData->zoneID.GetCloneID() == friendData->zoneID.GetCloneID()) {
{
bitStream.Write(0); bitStream.Write(0);
} } else {
else
{
bitStream.Write(playerData->zoneID.GetCloneID()); bitStream.Write(playerData->zoneID.GetCloneID());
} }

View File

@ -58,8 +58,7 @@ int main(int argc, char** argv) {
try { try {
Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password); Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password);
} } catch (sql::SQLException& ex) {
catch (sql::SQLException& ex) {
Game::logger->Log("ChatServer", "Got an error while connecting to the database: %s", ex.what()); Game::logger->Log("ChatServer", "Got an error while connecting to the database: %s", ex.what());
Database::Destroy("ChatServer"); Database::Destroy("ChatServer");
delete Game::server; delete Game::server;
@ -104,8 +103,7 @@ int main(int argc, char** argv) {
if (framesSinceMasterDisconnect >= 30) if (framesSinceMasterDisconnect >= 30)
break; //Exit our loop, shut down. break; //Exit our loop, shut down.
} } else framesSinceMasterDisconnect = 0;
else framesSinceMasterDisconnect = 0;
//In world we'd update our other systems here. //In world we'd update our other systems here.
@ -122,8 +120,7 @@ int main(int argc, char** argv) {
if (framesSinceLastFlush >= 900) { if (framesSinceLastFlush >= 900) {
Game::logger->Flush(); Game::logger->Flush();
framesSinceLastFlush = 0; framesSinceLastFlush = 0;
} } else framesSinceLastFlush++;
else framesSinceLastFlush++;
//Every 10 min we ping our sql server to keep it alive hopefully: //Every 10 min we ping our sql server to keep it alive hopefully:
if (framesSinceLastSQLPing >= 40000) { if (framesSinceLastSQLPing >= 40000) {
@ -141,8 +138,7 @@ int main(int argc, char** argv) {
delete stmt; delete stmt;
framesSinceLastSQLPing = 0; framesSinceLastSQLPing = 0;
} } else framesSinceLastSQLPing++;
else framesSinceLastSQLPing++;
//Sleep our thread since auth can afford to. //Sleep our thread since auth can afford to.
t += std::chrono::milliseconds(mediumFramerate); //Chat can run at a lower "fps" t += std::chrono::milliseconds(mediumFramerate); //Chat can run at a lower "fps"
@ -158,7 +154,7 @@ int main(int argc, char** argv) {
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
dLogger * SetupLogger() { dLogger* SetupLogger() {
std::string logPath = "./logs/ChatServer_" + std::to_string(time(nullptr)) + ".log"; std::string logPath = "./logs/ChatServer_" + std::to_string(time(nullptr)) + ".log";
bool logToConsole = false; bool logToConsole = false;
bool logDebugStatements = false; bool logDebugStatements = false;

View File

@ -70,17 +70,15 @@ void PlayerContainer::RemovePlayer(Packet* packet) {
auto* team = GetTeam(playerID); auto* team = GetTeam(playerID);
if (team != nullptr) if (team != nullptr) {
{
const auto memberName = GeneralUtils::ASCIIToUTF16(std::string(player->playerName.c_str())); const auto memberName = GeneralUtils::ASCIIToUTF16(std::string(player->playerName.c_str()));
for (const auto memberId : team->memberIDs) for (const auto memberId : team->memberIDs) {
{
auto* otherMember = GetPlayerData(memberId); auto* otherMember = GetPlayerData(memberId);
if (otherMember == nullptr) continue; if (otherMember == nullptr) continue;
ChatPacketHandler::SendTeamSetOffWorldFlag(otherMember, playerID, {0, 0, 0}); ChatPacketHandler::SendTeamSetOffWorldFlag(otherMember, playerID, { 0, 0, 0 });
} }
} }
@ -97,8 +95,7 @@ void PlayerContainer::RemovePlayer(Packet* packet) {
insertLog->executeUpdate(); insertLog->executeUpdate();
} }
void PlayerContainer::MuteUpdate(Packet* packet) void PlayerContainer::MuteUpdate(Packet* packet) {
{
CINSTREAM; CINSTREAM;
LWOOBJID playerID; LWOOBJID playerID;
inStream.Read(playerID); //skip header inStream.Read(playerID); //skip header
@ -108,8 +105,7 @@ void PlayerContainer::MuteUpdate(Packet* packet)
auto* player = this->GetPlayerData(playerID); auto* player = this->GetPlayerData(playerID);
if (player == nullptr) if (player == nullptr) {
{
Game::logger->Log("PlayerContainer", "Failed to find user: %llu", playerID); Game::logger->Log("PlayerContainer", "Failed to find user: %llu", playerID);
return; return;
@ -120,8 +116,7 @@ void PlayerContainer::MuteUpdate(Packet* packet)
BroadcastMuteUpdate(playerID, expire); BroadcastMuteUpdate(playerID, expire);
} }
void PlayerContainer::CreateTeamServer(Packet* packet) void PlayerContainer::CreateTeamServer(Packet* packet) {
{
CINSTREAM; CINSTREAM;
LWOOBJID playerID; LWOOBJID playerID;
inStream.Read(playerID); //skip header inStream.Read(playerID); //skip header
@ -133,8 +128,7 @@ void PlayerContainer::CreateTeamServer(Packet* packet)
members.reserve(membersSize); members.reserve(membersSize);
for (size_t i = 0; i < membersSize; i++) for (size_t i = 0; i < membersSize; i++) {
{
LWOOBJID member; LWOOBJID member;
inStream.Read(member); inStream.Read(member);
members.push_back(member); members.push_back(member);
@ -146,16 +140,14 @@ void PlayerContainer::CreateTeamServer(Packet* packet)
auto* team = CreateLocalTeam(members); auto* team = CreateLocalTeam(members);
if (team != nullptr) if (team != nullptr) {
{
team->zoneId = zoneId; team->zoneId = zoneId;
} }
UpdateTeamsOnWorld(team, false); UpdateTeamsOnWorld(team, false);
} }
void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time) void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time) {
{
CBITSTREAM; CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_MUTE_UPDATE); PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_MUTE_UPDATE);
@ -165,30 +157,23 @@ void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time)
Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true);
} }
TeamData* PlayerContainer::CreateLocalTeam(std::vector<LWOOBJID> members) TeamData* PlayerContainer::CreateLocalTeam(std::vector<LWOOBJID> members) {
{ if (members.empty()) {
if (members.empty())
{
return nullptr; return nullptr;
} }
TeamData* newTeam = nullptr; TeamData* newTeam = nullptr;
for (const auto member : members) for (const auto member : members) {
{
auto* team = GetTeam(member); auto* team = GetTeam(member);
if (team != nullptr) if (team != nullptr) {
{
RemoveMember(team, member, false, false, true); RemoveMember(team, member, false, false, true);
} }
if (newTeam == nullptr) if (newTeam == nullptr) {
{
newTeam = CreateTeam(member, true); newTeam = CreateTeam(member, true);
} } else {
else
{
AddMember(newTeam, member); AddMember(newTeam, member);
} }
} }
@ -200,8 +185,7 @@ TeamData* PlayerContainer::CreateLocalTeam(std::vector<LWOOBJID> members)
return newTeam; return newTeam;
} }
TeamData* PlayerContainer::CreateTeam(LWOOBJID leader, bool local) TeamData* PlayerContainer::CreateTeam(LWOOBJID leader, bool local) {
{
auto* team = new TeamData(); auto* team = new TeamData();
team->teamID = ++mTeamIDCounter; team->teamID = ++mTeamIDCounter;
@ -215,10 +199,8 @@ TeamData* PlayerContainer::CreateTeam(LWOOBJID leader, bool local)
return team; return team;
} }
TeamData* PlayerContainer::GetTeam(LWOOBJID playerID) TeamData* PlayerContainer::GetTeam(LWOOBJID playerID) {
{ for (auto* team : mTeams) {
for (auto* team : mTeams)
{
if (std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID) == team->memberIDs.end()) continue; if (std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID) == team->memberIDs.end()) continue;
return team; return team;
@ -227,8 +209,7 @@ TeamData* PlayerContainer::GetTeam(LWOOBJID playerID)
return nullptr; return nullptr;
} }
void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID) void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID) {
{
const auto index = std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID); const auto index = std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID);
if (index != team->memberIDs.end()) return; if (index != team->memberIDs.end()) return;
@ -245,19 +226,15 @@ void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID)
ChatPacketHandler::SendTeamInviteConfirm(member, false, leader->playerID, leader->zoneID, team->lootFlag, 0, 0, leaderName); ChatPacketHandler::SendTeamInviteConfirm(member, false, leader->playerID, leader->zoneID, team->lootFlag, 0, 0, leaderName);
if (!team->local) if (!team->local) {
{
ChatPacketHandler::SendTeamSetLeader(member, leader->playerID); ChatPacketHandler::SendTeamSetLeader(member, leader->playerID);
} } else {
else
{
ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY); ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY);
} }
UpdateTeamsOnWorld(team, false); UpdateTeamsOnWorld(team, false);
for (const auto memberId : team->memberIDs) for (const auto memberId : team->memberIDs) {
{
auto* otherMember = GetPlayerData(memberId); auto* otherMember = GetPlayerData(memberId);
if (otherMember == member) continue; if (otherMember == member) continue;
@ -266,32 +243,27 @@ void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID)
ChatPacketHandler::SendTeamAddPlayer(member, false, team->local, false, memberId, otherMemberName, otherMember != nullptr ? otherMember->zoneID : LWOZONEID(0, 0, 0)); ChatPacketHandler::SendTeamAddPlayer(member, false, team->local, false, memberId, otherMemberName, otherMember != nullptr ? otherMember->zoneID : LWOZONEID(0, 0, 0));
if (otherMember != nullptr) if (otherMember != nullptr) {
{
ChatPacketHandler::SendTeamAddPlayer(otherMember, false, team->local, false, member->playerID, memberName, member->zoneID); ChatPacketHandler::SendTeamAddPlayer(otherMember, false, team->local, false, member->playerID, memberName, member->zoneID);
} }
} }
} }
void PlayerContainer::RemoveMember(TeamData* team, LWOOBJID playerID, bool disband, bool kicked, bool leaving, bool silent) void PlayerContainer::RemoveMember(TeamData* team, LWOOBJID playerID, bool disband, bool kicked, bool leaving, bool silent) {
{
const auto index = std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID); const auto index = std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID);
if (index == team->memberIDs.end()) return; if (index == team->memberIDs.end()) return;
auto* member = GetPlayerData(playerID); auto* member = GetPlayerData(playerID);
if (member != nullptr && !silent) if (member != nullptr && !silent) {
{
ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY); ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY);
} }
const auto memberName = GetName(playerID); const auto memberName = GetName(playerID);
for (const auto memberId : team->memberIDs) for (const auto memberId : team->memberIDs) {
{ if (silent && memberId == playerID) {
if (silent && memberId == playerID)
{
continue; continue;
} }
@ -306,25 +278,19 @@ void PlayerContainer::RemoveMember(TeamData* team, LWOOBJID playerID, bool disba
UpdateTeamsOnWorld(team, false); UpdateTeamsOnWorld(team, false);
if (team->memberIDs.size() <= 1) if (team->memberIDs.size() <= 1) {
{
DisbandTeam(team); DisbandTeam(team);
} } else {
else if (playerID == team->leaderID) {
{
if (playerID == team->leaderID)
{
PromoteMember(team, team->memberIDs[0]); PromoteMember(team, team->memberIDs[0]);
} }
} }
} }
void PlayerContainer::PromoteMember(TeamData* team, LWOOBJID newLeader) void PlayerContainer::PromoteMember(TeamData* team, LWOOBJID newLeader) {
{
team->leaderID = newLeader; team->leaderID = newLeader;
for (const auto memberId : team->memberIDs) for (const auto memberId : team->memberIDs) {
{
auto* otherMember = GetPlayerData(memberId); auto* otherMember = GetPlayerData(memberId);
if (otherMember == nullptr) continue; if (otherMember == nullptr) continue;
@ -333,14 +299,12 @@ void PlayerContainer::PromoteMember(TeamData* team, LWOOBJID newLeader)
} }
} }
void PlayerContainer::DisbandTeam(TeamData* team) void PlayerContainer::DisbandTeam(TeamData* team) {
{
const auto index = std::find(mTeams.begin(), mTeams.end(), team); const auto index = std::find(mTeams.begin(), mTeams.end(), team);
if (index == mTeams.end()) return; if (index == mTeams.end()) return;
for (const auto memberId : team->memberIDs) for (const auto memberId : team->memberIDs) {
{
auto* otherMember = GetPlayerData(memberId); auto* otherMember = GetPlayerData(memberId);
if (otherMember == nullptr) continue; if (otherMember == nullptr) continue;
@ -358,8 +322,7 @@ void PlayerContainer::DisbandTeam(TeamData* team)
delete team; delete team;
} }
void PlayerContainer::TeamStatusUpdate(TeamData* team) void PlayerContainer::TeamStatusUpdate(TeamData* team) {
{
const auto index = std::find(mTeams.begin(), mTeams.end(), team); const auto index = std::find(mTeams.begin(), mTeams.end(), team);
if (index == mTeams.end()) return; if (index == mTeams.end()) return;
@ -370,14 +333,12 @@ void PlayerContainer::TeamStatusUpdate(TeamData* team)
const auto leaderName = GeneralUtils::ASCIIToUTF16(std::string(leader->playerName.c_str())); const auto leaderName = GeneralUtils::ASCIIToUTF16(std::string(leader->playerName.c_str()));
for (const auto memberId : team->memberIDs) for (const auto memberId : team->memberIDs) {
{
auto* otherMember = GetPlayerData(memberId); auto* otherMember = GetPlayerData(memberId);
if (otherMember == nullptr) continue; if (otherMember == nullptr) continue;
if (!team->local) if (!team->local) {
{
ChatPacketHandler::SendTeamStatus(otherMember, team->leaderID, leader->zoneID, team->lootFlag, 0, leaderName); ChatPacketHandler::SendTeamStatus(otherMember, team->leaderID, leader->zoneID, team->lootFlag, 0, leaderName);
} }
} }
@ -385,20 +346,17 @@ void PlayerContainer::TeamStatusUpdate(TeamData* team)
UpdateTeamsOnWorld(team, false); UpdateTeamsOnWorld(team, false);
} }
void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam) void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam) {
{
CBITSTREAM; CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_TEAM_UPDATE); PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_TEAM_UPDATE);
bitStream.Write(team->teamID); bitStream.Write(team->teamID);
bitStream.Write(deleteTeam); bitStream.Write(deleteTeam);
if (!deleteTeam) if (!deleteTeam) {
{
bitStream.Write(team->lootFlag); bitStream.Write(team->lootFlag);
bitStream.Write(static_cast<char>(team->memberIDs.size())); bitStream.Write(static_cast<char>(team->memberIDs.size()));
for (const auto memberID : team->memberIDs) for (const auto memberID : team->memberIDs) {
{
bitStream.Write(memberID); bitStream.Write(memberID);
} }
} }
@ -406,8 +364,7 @@ void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam)
Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true); Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true);
} }
std::u16string PlayerContainer::GetName(LWOOBJID playerID) std::u16string PlayerContainer::GetName(LWOOBJID playerID) {
{
const auto& pair = mNames.find(playerID); const auto& pair = mNames.find(playerID);
if (pair == mNames.end()) return u""; if (pair == mNames.end()) return u"";
@ -415,12 +372,9 @@ std::u16string PlayerContainer::GetName(LWOOBJID playerID)
return pair->second; return pair->second;
} }
LWOOBJID PlayerContainer::GetId(const std::u16string& playerName) LWOOBJID PlayerContainer::GetId(const std::u16string& playerName) {
{ for (const auto& pair : mNames) {
for (const auto& pair : mNames) if (pair.second == playerName) {
{
if (pair.second == playerName)
{
return pair.first; return pair.first;
} }
} }
@ -428,7 +382,6 @@ LWOOBJID PlayerContainer::GetId(const std::u16string& playerName)
return LWOOBJID_EMPTY; return LWOOBJID_EMPTY;
} }
bool PlayerContainer::GetIsMuted(PlayerData* data) bool PlayerContainer::GetIsMuted(PlayerData* data) {
{
return data->muteExpire == 1 || data->muteExpire > time(NULL); return data->muteExpire == 1 || data->muteExpire > time(NULL);
} }

View File

@ -20,7 +20,7 @@ struct PlayerData {
struct TeamData { struct TeamData {
LWOOBJID teamID = LWOOBJID_EMPTY; // Internal use LWOOBJID teamID = LWOOBJID_EMPTY; // Internal use
LWOOBJID leaderID = LWOOBJID_EMPTY; LWOOBJID leaderID = LWOOBJID_EMPTY;
std::vector<LWOOBJID> memberIDs {}; std::vector<LWOOBJID> memberIDs{};
uint8_t lootFlag = 0; uint8_t lootFlag = 0;
bool local = false; bool local = false;
LWOZONEID zoneId = {}; LWOZONEID zoneId = {};

View File

@ -7,7 +7,7 @@
class AMFValue; class AMFValue;
class AMFDeserialize { class AMFDeserialize {
public: public:
/** /**
* Read an AMF3 value from a bitstream. * Read an AMF3 value from a bitstream.
* *
@ -15,7 +15,7 @@ class AMFDeserialize {
* @return Returns an AMFValue with all the information from the bitStream in it. * @return Returns an AMFValue with all the information from the bitStream in it.
*/ */
AMFValue* Read(RakNet::BitStream* inStream); AMFValue* Read(RakNet::BitStream* inStream);
private: private:
/** /**
* @brief Private method to read a U29 integer from a bitstream * @brief Private method to read a U29 integer from a bitstream
* *

View File

@ -193,7 +193,7 @@ template<>
void RakNet::BitStream::Write<AMFDoubleValue>(AMFDoubleValue value) { void RakNet::BitStream::Write<AMFDoubleValue>(AMFDoubleValue value) {
this->Write(AMFDouble); this->Write(AMFDouble);
double d = value.GetDoubleValue(); double d = value.GetDoubleValue();
WriteAMFU64(this, *((unsigned long long*)&d)); WriteAMFU64(this, *((unsigned long long*) & d));
} }
// Writes an AMFStringValue to BitStream // Writes an AMFStringValue to BitStream

View File

@ -11,7 +11,7 @@
\brief A class that implements native writing of AMF values to RakNet::BitStream \brief A class that implements native writing of AMF values to RakNet::BitStream
*/ */
// We are using the RakNet namespace // We are using the RakNet namespace
namespace RakNet { namespace RakNet {
//! Writes an AMFValue pointer to a RakNet::BitStream //! Writes an AMFValue pointer to a RakNet::BitStream
/*! /*!

View File

@ -10,7 +10,7 @@ void BinaryIO::WriteString(const std::string& stringToWrite, std::ofstream& outs
} }
//For reading null-terminated strings //For reading null-terminated strings
std::string BinaryIO::ReadString(std::ifstream & instream) { std::string BinaryIO::ReadString(std::ifstream& instream) {
std::string toReturn; std::string toReturn;
char buffer; char buffer;
@ -37,7 +37,7 @@ std::string BinaryIO::ReadString(std::ifstream& instream, size_t size) {
return toReturn; return toReturn;
} }
std::string BinaryIO::ReadWString(std::ifstream & instream) { std::string BinaryIO::ReadWString(std::ifstream& instream) {
size_t size; size_t size;
BinaryRead(instream, size); BinaryRead(instream, size);
//toReturn.resize(size); //toReturn.resize(size);

View File

@ -9,7 +9,7 @@ namespace BinaryIO {
} }
template<typename T> template<typename T>
std::istream & BinaryRead(std::istream& stream, T& value) { std::istream& BinaryRead(std::istream& stream, T& value) {
if (!stream.good()) if (!stream.good())
printf("bla"); printf("bla");
@ -17,7 +17,7 @@ namespace BinaryIO {
} }
void WriteString(const std::string& stringToWrite, std::ofstream& outstream); void WriteString(const std::string& stringToWrite, std::ofstream& outstream);
std::string ReadString(std::ifstream & instream); std::string ReadString(std::ifstream& instream);
std::string ReadString(std::ifstream& instream, size_t size); std::string ReadString(std::ifstream& instream, size_t size);
std::string ReadWString(std::ifstream& instream); std::string ReadWString(std::ifstream& instream);

View File

@ -171,7 +171,7 @@ void CatchUnhandled(int sig) {
ErrorCallback, ErrorCallback,
nullptr); nullptr);
struct bt_ctx ctx = {state, 0}; struct bt_ctx ctx = { state, 0 };
Bt(state); Bt(state);
#endif #endif

View File

@ -50,7 +50,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();
const uint8_t* bytes = (const uint8_t*) &slice.front(); const uint8_t* bytes = (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
@ -193,7 +193,7 @@ std::string GeneralUtils::UTF16ToWTF8(const std::u16string_view& string, size_t
} }
bool GeneralUtils::CaseInsensitiveStringCompare(const std::string& a, const std::string& b) { bool GeneralUtils::CaseInsensitiveStringCompare(const std::string& a, const std::string& b) {
return std::equal(a.begin(), a.end (), b.begin(), b.end(),[](char a, char b) { return tolower(a) == tolower(b); }); return std::equal(a.begin(), a.end(), b.begin(), b.end(), [](char a, char b) { return tolower(a) == tolower(b); });
} }
// MARK: Bits // MARK: Bits
@ -215,14 +215,13 @@ bool GeneralUtils::CheckBit(int64_t value, uint32_t index) {
bool GeneralUtils::ReplaceInString(std::string& str, const std::string& from, const std::string& to) { bool GeneralUtils::ReplaceInString(std::string& str, const std::string& from, const std::string& to) {
size_t start_pos = str.find(from); size_t start_pos = str.find(from);
if(start_pos == std::string::npos) if (start_pos == std::string::npos)
return false; return false;
str.replace(start_pos, from.length(), to); str.replace(start_pos, from.length(), to);
return true; return true;
} }
std::vector<std::wstring> GeneralUtils::SplitString(std::wstring& str, wchar_t delimiter) std::vector<std::wstring> GeneralUtils::SplitString(std::wstring& str, wchar_t delimiter) {
{
std::vector<std::wstring> vector = std::vector<std::wstring>(); std::vector<std::wstring> vector = std::vector<std::wstring>();
std::wstring current; std::wstring current;
@ -239,8 +238,7 @@ std::vector<std::wstring> GeneralUtils::SplitString(std::wstring& str, wchar_t d
return vector; return vector;
} }
std::vector<std::u16string> GeneralUtils::SplitString(std::u16string& str, char16_t delimiter) std::vector<std::u16string> GeneralUtils::SplitString(std::u16string& str, char16_t delimiter) {
{
std::vector<std::u16string> vector = std::vector<std::u16string>(); std::vector<std::u16string> vector = std::vector<std::u16string>();
std::u16string current; std::u16string current;
@ -257,22 +255,17 @@ std::vector<std::u16string> GeneralUtils::SplitString(std::u16string& str, char1
return vector; return vector;
} }
std::vector<std::string> GeneralUtils::SplitString(const std::string& str, char delimiter) std::vector<std::string> GeneralUtils::SplitString(const std::string& str, char delimiter) {
{
std::vector<std::string> vector = std::vector<std::string>(); std::vector<std::string> vector = std::vector<std::string>();
std::string current = ""; std::string current = "";
for (size_t i = 0; i < str.length(); i++) for (size_t i = 0; i < str.length(); i++) {
{
char c = str[i]; char c = str[i];
if (c == delimiter) if (c == delimiter) {
{
vector.push_back(current); vector.push_back(current);
current = ""; current = "";
} } else {
else
{
current += c; current += c;
} }
} }
@ -282,7 +275,7 @@ std::vector<std::string> GeneralUtils::SplitString(const std::string& str, char
return vector; return vector;
} }
std::u16string GeneralUtils::ReadWString(RakNet::BitStream *inStream) { std::u16string GeneralUtils::ReadWString(RakNet::BitStream* inStream) {
uint32_t length; uint32_t length;
inStream->Read<uint32_t>(length); inStream->Read<uint32_t>(length);
@ -300,8 +293,7 @@ std::u16string GeneralUtils::ReadWString(RakNet::BitStream *inStream) {
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <Windows.h> #include <Windows.h>
std::vector<std::string> GeneralUtils::GetFileNamesFromFolder(const std::string& folder) std::vector<std::string> GeneralUtils::GetFileNamesFromFolder(const std::string& folder) {
{
std::vector<std::string> names; std::vector<std::string> names;
std::string search_path = folder + "/*.*"; std::string search_path = folder + "/*.*";
WIN32_FIND_DATA fd; WIN32_FIND_DATA fd;

View File

@ -18,7 +18,7 @@
\brief A namespace containing general utility functions \brief A namespace containing general utility functions
*/ */
//! The general utils namespace //! The general utils namespace
namespace GeneralUtils { namespace GeneralUtils {
//! Converts a plain ASCII string to a UTF-16 string //! Converts a plain ASCII string to a UTF-16 string
/*! /*!
@ -120,8 +120,7 @@ namespace GeneralUtils {
if constexpr (std::is_integral_v<T>) { // constexpr only necessary on first statement if constexpr (std::is_integral_v<T>) { // constexpr only necessary on first statement
std::uniform_int_distribution<T> distribution(min, max); std::uniform_int_distribution<T> distribution(min, max);
return distribution(Game::randomEngine); return distribution(Game::randomEngine);
} } else if (std::is_floating_point_v<T>) {
else if (std::is_floating_point_v<T>) {
std::uniform_real_distribution<T> distribution(min, max); std::uniform_real_distribution<T> distribution(min, max);
return distribution(Game::randomEngine); return distribution(Game::randomEngine);
} }
@ -131,7 +130,7 @@ namespace GeneralUtils {
bool ReplaceInString(std::string& str, const std::string& from, const std::string& to); bool ReplaceInString(std::string& str, const std::string& from, const std::string& to);
std::u16string ReadWString(RakNet::BitStream *inStream); std::u16string ReadWString(RakNet::BitStream* inStream);
std::vector<std::wstring> SplitString(std::wstring& str, wchar_t delimiter); std::vector<std::wstring> SplitString(std::wstring& str, wchar_t delimiter);
@ -145,78 +144,64 @@ namespace GeneralUtils {
T Parse(const char* value); T Parse(const char* value);
template <> template <>
inline int32_t Parse(const char* value) inline int32_t Parse(const char* value) {
{
return std::stoi(value); return std::stoi(value);
} }
template <> template <>
inline int64_t Parse(const char* value) inline int64_t Parse(const char* value) {
{
return std::stoll(value); return std::stoll(value);
} }
template <> template <>
inline float Parse(const char* value) inline float Parse(const char* value) {
{
return std::stof(value); return std::stof(value);
} }
template <> template <>
inline double Parse(const char* value) inline double Parse(const char* value) {
{
return std::stod(value); return std::stod(value);
} }
template <> template <>
inline uint32_t Parse(const char* value) inline uint32_t Parse(const char* value) {
{
return std::stoul(value); return std::stoul(value);
} }
template <> template <>
inline uint64_t Parse(const char* value) inline uint64_t Parse(const char* value) {
{
return std::stoull(value); return std::stoull(value);
} }
template <typename T> template <typename T>
bool TryParse(const char* value, T& dst) bool TryParse(const char* value, T& dst) {
{ try {
try
{
dst = Parse<T>(value); dst = Parse<T>(value);
return true; return true;
} } catch (...) {
catch (...)
{
return false; return false;
} }
} }
template <typename T> template <typename T>
T Parse(const std::string& value) T Parse(const std::string& value) {
{
return Parse<T>(value.c_str()); return Parse<T>(value.c_str());
} }
template <typename T> template <typename T>
bool TryParse(const std::string& value, T& dst) bool TryParse(const std::string& value, T& dst) {
{
return TryParse<T>(value.c_str(), dst); return TryParse<T>(value.c_str(), dst);
} }
template<typename T> template<typename T>
std::u16string to_u16string(T value) std::u16string to_u16string(T value) {
{
return GeneralUtils::ASCIIToUTF16(std::to_string(value)); return GeneralUtils::ASCIIToUTF16(std::to_string(value));
} }
// From boost::hash_combine // From boost::hash_combine
template <class T> template <class T>
void hash_combine(std::size_t& s, const T& v) void hash_combine(std::size_t& s, const T& v) {
{
std::hash<T> h; std::hash<T> h;
s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2); s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2);
} }

View File

@ -8,7 +8,7 @@
#include <vector> #include <vector>
//! Returns a pointer to a LDFData value based on string format //! Returns a pointer to a LDFData value based on string format
LDFBaseData * LDFBaseData::DataFromString(const std::string& format) { LDFBaseData* LDFBaseData::DataFromString(const std::string& format) {
// First, check the format // First, check the format
std::istringstream ssFormat(format); std::istringstream ssFormat(format);
@ -72,16 +72,11 @@ LDFBaseData * LDFBaseData::DataFromString(const std::string& format) {
{ {
uint32_t data; uint32_t data;
if (dataArray[1] == "true") if (dataArray[1] == "true") {
{
data = 1; data = 1;
} } else if (dataArray[1] == "false") {
else if (dataArray[1] == "false")
{
data = 0; data = 0;
} } else {
else
{
data = static_cast<uint32_t>(stoul(dataArray[1])); data = static_cast<uint32_t>(stoul(dataArray[1]));
} }
@ -91,16 +86,11 @@ LDFBaseData * LDFBaseData::DataFromString(const std::string& format) {
case LDF_TYPE_BOOLEAN: { case LDF_TYPE_BOOLEAN: {
bool data; bool data;
if (dataArray[1] == "true") if (dataArray[1] == "true") {
{
data = true; data = true;
} } else if (dataArray[1] == "false") {
else if (dataArray[1] == "false")
{
data = false; data = false;
} } else {
else
{
data = static_cast<bool>(stoi(dataArray[1])); data = static_cast<bool>(stoi(dataArray[1]));
} }

View File

@ -17,7 +17,7 @@
\brief A collection of LDF format classes \brief A collection of LDF format classes
*/ */
//! An enum for LDF Data Types //! An enum for LDF Data Types
enum eLDFType { enum eLDFType {
LDF_TYPE_UNKNOWN = -1, //!< Unknown data type LDF_TYPE_UNKNOWN = -1, //!< Unknown data type
LDF_TYPE_UTF_16 = 0, //!< UTF-16 wstring data type LDF_TYPE_UTF_16 = 0, //!< UTF-16 wstring data type
@ -36,13 +36,13 @@ class LDFBaseData {
public: public:
//! Destructor //! Destructor
virtual ~LDFBaseData(void) { } virtual ~LDFBaseData(void) {}
//! Writes the data to a packet //! Writes the data to a packet
/*! /*!
\param packet The packet \param packet The packet
*/ */
virtual void WriteToPacket(RakNet::BitStream * packet) = 0; virtual void WriteToPacket(RakNet::BitStream* packet) = 0;
//! Gets the key //! Gets the key
/*! /*!
@ -66,7 +66,7 @@ public:
virtual std::string GetValueAsString() = 0; virtual std::string GetValueAsString() = 0;
virtual LDFBaseData * Copy() = 0; virtual LDFBaseData* Copy() = 0;
// MARK: Functions // MARK: Functions
@ -74,7 +74,7 @@ public:
/*! /*!
\param format The format \param format The format
*/ */
static LDFBaseData * DataFromString(const std::string& format); static LDFBaseData* DataFromString(const std::string& format);
}; };
@ -86,7 +86,7 @@ private:
T value; T value;
//! 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(static_cast<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(static_cast<uint16_t>(this->key[i]));
@ -94,7 +94,7 @@ private:
} }
//! 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(static_cast<uint8_t>(this->GetValueType()));
packet->Write(this->value); packet->Write(this->value);
} }
@ -108,7 +108,7 @@ public:
} }
//! Destructor //! Destructor
~LDFData(void) override { } ~LDFData(void) override {}
//! Gets the value //! Gets the value
/*! /*!
@ -132,7 +132,7 @@ public:
/*! /*!
\param packet The packet \param packet The packet
*/ */
void WriteToPacket(RakNet::BitStream * packet) override { void WriteToPacket(RakNet::BitStream* packet) override {
this->WriteKey(packet); this->WriteKey(packet);
this->WriteValue(packet); this->WriteValue(packet);
} }
@ -186,7 +186,7 @@ public:
return this->GetValueString(); return this->GetValueString();
} }
LDFBaseData * Copy() override { LDFBaseData* Copy() override {
return new LDFData<T>(key, value); return new LDFData<T>(key, value);
} }
@ -206,7 +206,7 @@ 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(static_cast<uint8_t>(this->GetValueType()));
packet->Write(static_cast<uint32_t>(this->value.length())); packet->Write(static_cast<uint32_t>(this->value.length()));
@ -217,7 +217,7 @@ inline void LDFData<std::u16string>::WriteValue(RakNet::BitStream * packet) {
// 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(static_cast<uint8_t>(this->GetValueType()));
packet->Write(static_cast<uint8_t>(this->value)); packet->Write(static_cast<uint8_t>(this->value));
@ -225,7 +225,7 @@ inline void LDFData<bool>::WriteValue(RakNet::BitStream * packet) {
// 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(static_cast<uint8_t>(this->GetValueType()));
packet->Write(static_cast<uint32_t>(this->value.length())); packet->Write(static_cast<uint32_t>(this->value.length()));

View File

@ -30,7 +30,7 @@
*/ */
/* interface header */ /* interface header */
#include "MD5.h" #include "MD5.h"
/* system implementation headers */ /* system implementation headers */
@ -59,15 +59,15 @@
// F, G, H and I are basic MD5 functions. // F, G, H and I are basic MD5 functions.
inline MD5::uint4 MD5::F(uint4 x, uint4 y, uint4 z) { inline MD5::uint4 MD5::F(uint4 x, uint4 y, uint4 z) {
return x&y | ~x&z; return x & y | ~x & z;
} }
inline MD5::uint4 MD5::G(uint4 x, uint4 y, uint4 z) { inline MD5::uint4 MD5::G(uint4 x, uint4 y, uint4 z) {
return x&z | y&~z; return x & z | y & ~z;
} }
inline MD5::uint4 MD5::H(uint4 x, uint4 y, uint4 z) { inline MD5::uint4 MD5::H(uint4 x, uint4 y, uint4 z) {
return x^y^z; return x ^ y ^ z;
} }
inline MD5::uint4 MD5::I(uint4 x, uint4 y, uint4 z) { inline MD5::uint4 MD5::I(uint4 x, uint4 y, uint4 z) {
@ -81,35 +81,33 @@ inline MD5::uint4 MD5::rotate_left(uint4 x, int n) {
// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. // FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
// Rotation is separate from addition to prevent recomputation. // Rotation is separate from addition to prevent recomputation.
inline void MD5::FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) { inline void MD5::FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
a = rotate_left(a + F(b, c, d) + x + ac, s) + b; a = rotate_left(a + F(b, c, d) + x + ac, s) + b;
} }
inline void MD5::GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) { inline void MD5::GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
a = rotate_left(a + G(b, c, d) + x + ac, s) + b; a = rotate_left(a + G(b, c, d) + x + ac, s) + b;
} }
inline void MD5::HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) { inline void MD5::HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
a = rotate_left(a + H(b, c, d) + x + ac, s) + b; a = rotate_left(a + H(b, c, d) + x + ac, s) + b;
} }
inline void MD5::II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) { inline void MD5::II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac) {
a = rotate_left(a + I(b, c, d) + x + ac, s) + b; a = rotate_left(a + I(b, c, d) + x + ac, s) + b;
} }
////////////////////////////////////////////// //////////////////////////////////////////////
// default ctor, just initailize // default ctor, just initailize
MD5::MD5() MD5::MD5() {
{
init(); init();
} }
////////////////////////////////////////////// //////////////////////////////////////////////
// nifty shortcut ctor, compute MD5 for string and finalize it right away // nifty shortcut ctor, compute MD5 for string and finalize it right away
MD5::MD5(const std::string &text) MD5::MD5(const std::string& text) {
{
init(); init();
update(text.c_str(), text.length()); update(text.c_str(), text.length());
finalize(); finalize();
@ -117,8 +115,7 @@ MD5::MD5(const std::string &text)
////////////////////////////// //////////////////////////////
void MD5::init() void MD5::init() {
{
finalized = false; finalized = false;
count[0] = 0; count[0] = 0;
@ -134,8 +131,7 @@ void MD5::init()
////////////////////////////// //////////////////////////////
// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4. // decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4.
void MD5::decode(uint4 output[], const uint1 input[], size_type len) void MD5::decode(uint4 output[], const uint1 input[], size_type len) {
{
for (unsigned int i = 0, j = 0; j < len; i++, j += 4) for (unsigned int i = 0, j = 0; j < len; i++, j += 4)
output[i] = ((uint4)input[j]) | (((uint4)input[j + 1]) << 8) | output[i] = ((uint4)input[j]) | (((uint4)input[j + 1]) << 8) |
(((uint4)input[j + 2]) << 16) | (((uint4)input[j + 3]) << 24); (((uint4)input[j + 2]) << 16) | (((uint4)input[j + 3]) << 24);
@ -145,8 +141,7 @@ void MD5::decode(uint4 output[], const uint1 input[], size_type len)
// encodes input (uint4) into output (unsigned char). Assumes len is // encodes input (uint4) into output (unsigned char). Assumes len is
// a multiple of 4. // a multiple of 4.
void MD5::encode(uint1 output[], const uint4 input[], size_type len) void MD5::encode(uint1 output[], const uint4 input[], size_type len) {
{
for (size_type i = 0, j = 0; j < len; i++, j += 4) { for (size_type i = 0, j = 0; j < len; i++, j += 4) {
output[j] = input[i] & 0xff; output[j] = input[i] & 0xff;
output[j + 1] = (input[i] >> 8) & 0xff; output[j + 1] = (input[i] >> 8) & 0xff;
@ -158,8 +153,7 @@ void MD5::encode(uint1 output[], const uint4 input[], size_type len)
////////////////////////////// //////////////////////////////
// apply MD5 algo on a block // apply MD5 algo on a block
void MD5::transform(const uint1 block[blocksize]) void MD5::transform(const uint1 block[blocksize]) {
{
uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
decode(x, block, blocksize); decode(x, block, blocksize);
@ -248,8 +242,7 @@ void MD5::transform(const uint1 block[blocksize])
// MD5 block update operation. Continues an MD5 message-digest // MD5 block update operation. Continues an MD5 message-digest
// operation, processing another message block // operation, processing another message block
void MD5::update(const unsigned char input[], size_type length) void MD5::update(const unsigned char input[], size_type length) {
{
// compute number of bytes mod 64 // compute number of bytes mod 64
size_type index = count[0] / 8 % blocksize; size_type index = count[0] / 8 % blocksize;
@ -264,8 +257,7 @@ void MD5::update(const unsigned char input[], size_type length)
size_type i; size_type i;
// transform as many times as possible. // transform as many times as possible.
if (length >= firstpart) if (length >= firstpart) {
{
// fill buffer first, transform // fill buffer first, transform
memcpy(&buffer[index], input, firstpart); memcpy(&buffer[index], input, firstpart);
transform(buffer); transform(buffer);
@ -275,8 +267,7 @@ void MD5::update(const unsigned char input[], size_type length)
transform(&input[i]); transform(&input[i]);
index = 0; index = 0;
} } else
else
i = 0; i = 0;
// buffer remaining input // buffer remaining input
@ -286,8 +277,7 @@ void MD5::update(const unsigned char input[], size_type length)
////////////////////////////// //////////////////////////////
// for convenience provide a verson with signed char // for convenience provide a verson with signed char
void MD5::update(const char input[], size_type length) void MD5::update(const char input[], size_type length) {
{
update((const unsigned char*)input, length); update((const unsigned char*)input, length);
} }
@ -295,8 +285,7 @@ void MD5::update(const char input[], size_type length)
// MD5 finalization. Ends an MD5 message-digest operation, writing the // MD5 finalization. Ends an MD5 message-digest operation, writing the
// the message digest and zeroizing the context. // the message digest and zeroizing the context.
MD5& MD5::finalize() MD5& MD5::finalize() {
{
static unsigned char padding[64] = { static unsigned char padding[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -332,13 +321,12 @@ MD5& MD5::finalize()
////////////////////////////// //////////////////////////////
// return hex representation of digest as string // return hex representation of digest as string
std::string MD5::hexdigest() const std::string MD5::hexdigest() const {
{
if (!finalized) if (!finalized)
return ""; return "";
char buf[33]; char buf[33];
for (int i = 0; i<16; i++) for (int i = 0; i < 16; i++)
sprintf(buf + i * 2, "%02x", digest[i]); sprintf(buf + i * 2, "%02x", digest[i]);
buf[32] = 0; buf[32] = 0;
@ -347,15 +335,13 @@ std::string MD5::hexdigest() const
////////////////////////////// //////////////////////////////
std::ostream& operator<<(std::ostream& out, MD5 md5) std::ostream& operator<<(std::ostream& out, MD5 md5) {
{
return out << md5.hexdigest(); return out << md5.hexdigest();
} }
////////////////////////////// //////////////////////////////
std::string md5(const std::string str) std::string md5(const std::string str) {
{
MD5 md5 = MD5(str); MD5 md5 = MD5(str);
return md5.hexdigest(); return md5.hexdigest();

View File

@ -37,16 +37,16 @@
#include <iostream> #include <iostream>
// a small class for calculating MD5 hashes of strings or byte arrays // a small class for calculating MD5 hashes of strings or byte arrays
// it is not meant to be fast or secure // it is not meant to be fast or secure
// //
// usage: 1) feed it blocks of uchars with update() // usage: 1) feed it blocks of uchars with update()
// 2) finalize() // 2) finalize()
// 3) get hexdigest() string // 3) get hexdigest() string
// or // or
// MD5(std::string).hexdigest() // MD5(std::string).hexdigest()
// //
// assumes that char is 8 bit and int is 32 bit // assumes that char is 8 bit and int is 32 bit
class MD5 class MD5
{ {
public: public:
@ -54,8 +54,8 @@ public:
MD5(); MD5();
MD5(const std::string& text); MD5(const std::string& text);
void update(const unsigned char *buf, size_type length); void update(const unsigned char* buf, size_type length);
void update(const char *buf, size_type length); void update(const char* buf, size_type length);
MD5& finalize(); MD5& finalize();
std::string hexdigest() const; std::string hexdigest() const;
friend std::ostream& operator<<(std::ostream&, MD5 md5); friend std::ostream& operator<<(std::ostream&, MD5 md5);
@ -82,10 +82,10 @@ private:
static inline uint4 H(uint4 x, uint4 y, uint4 z); static inline uint4 H(uint4 x, uint4 y, uint4 z);
static inline uint4 I(uint4 x, uint4 y, uint4 z); static inline uint4 I(uint4 x, uint4 y, uint4 z);
static inline uint4 rotate_left(uint4 x, int n); static inline uint4 rotate_left(uint4 x, int n);
static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac);
}; };
std::string md5(const std::string str); std::string md5(const std::string str);

View File

@ -16,55 +16,44 @@ std::vector<MetricVariable> Metrics::m_Variables = {
MetricVariable::Frame, MetricVariable::Frame,
}; };
void Metrics::AddMeasurement(MetricVariable variable, int64_t value) void Metrics::AddMeasurement(MetricVariable variable, int64_t value) {
{
const auto& iter = m_Metrics.find(variable); const auto& iter = m_Metrics.find(variable);
Metric* metric; Metric* metric;
if (iter == m_Metrics.end()) if (iter == m_Metrics.end()) {
{
metric = new Metric(); metric = new Metric();
m_Metrics[variable] = metric; m_Metrics[variable] = metric;
} } else {
else
{
metric = iter->second; metric = iter->second;
} }
AddMeasurement(metric, value); AddMeasurement(metric, value);
} }
void Metrics::AddMeasurement(Metric* metric, int64_t value) void Metrics::AddMeasurement(Metric* metric, int64_t value) {
{
const auto index = metric->measurementIndex; const auto index = metric->measurementIndex;
metric->measurements[index] = value; metric->measurements[index] = value;
if (metric->max == -1 || value > metric->max) if (metric->max == -1 || value > metric->max) {
{
metric->max = value; metric->max = value;
} } else if (metric->min == -1 || metric->min > value) {
else if (metric->min == -1 || metric->min > value)
{
metric->min = value; metric->min = value;
} }
if (metric->measurementSize < MAX_MEASURMENT_POINTS) if (metric->measurementSize < MAX_MEASURMENT_POINTS) {
{
metric->measurementSize++; metric->measurementSize++;
} }
metric->measurementIndex = (index + 1) % MAX_MEASURMENT_POINTS; metric->measurementIndex = (index + 1) % MAX_MEASURMENT_POINTS;
} }
const Metric* Metrics::GetMetric(MetricVariable variable) const Metric* Metrics::GetMetric(MetricVariable variable) {
{
const auto& iter = m_Metrics.find(variable); const auto& iter = m_Metrics.find(variable);
if (iter == m_Metrics.end()) if (iter == m_Metrics.end()) {
{
return nullptr; return nullptr;
} }
@ -72,8 +61,7 @@ const Metric* Metrics::GetMetric(MetricVariable variable)
int64_t average = 0; int64_t average = 0;
for (size_t i = 0; i < metric->measurementSize; i++) for (size_t i = 0; i < metric->measurementSize; i++) {
{
average += metric->measurements[i]; average += metric->measurements[i];
} }
@ -84,34 +72,28 @@ const Metric* Metrics::GetMetric(MetricVariable variable)
return metric; return metric;
} }
void Metrics::StartMeasurement(MetricVariable variable) void Metrics::StartMeasurement(MetricVariable variable) {
{
const auto& iter = m_Metrics.find(variable); const auto& iter = m_Metrics.find(variable);
Metric* metric; Metric* metric;
if (iter == m_Metrics.end()) if (iter == m_Metrics.end()) {
{
metric = new Metric(); metric = new Metric();
m_Metrics[variable] = metric; m_Metrics[variable] = metric;
} } else {
else
{
metric = iter->second; metric = iter->second;
} }
metric->activeMeasurement = std::chrono::high_resolution_clock::now(); metric->activeMeasurement = std::chrono::high_resolution_clock::now();
} }
void Metrics::EndMeasurement(MetricVariable variable) void Metrics::EndMeasurement(MetricVariable variable) {
{
const auto end = std::chrono::high_resolution_clock::now(); const auto end = std::chrono::high_resolution_clock::now();
const auto& iter = m_Metrics.find(variable); const auto& iter = m_Metrics.find(variable);
if (iter == m_Metrics.end()) if (iter == m_Metrics.end()) {
{
return; return;
} }
@ -124,15 +106,12 @@ void Metrics::EndMeasurement(MetricVariable variable)
AddMeasurement(metric, nanoseconds); AddMeasurement(metric, nanoseconds);
} }
float Metrics::ToMiliseconds(int64_t nanoseconds) float Metrics::ToMiliseconds(int64_t nanoseconds) {
{ return (float)nanoseconds / 1e6;
return (float) nanoseconds / 1e6;
} }
std::string Metrics::MetricVariableToString(MetricVariable variable) std::string Metrics::MetricVariableToString(MetricVariable variable) {
{ switch (variable) {
switch (variable)
{
case MetricVariable::GameLoop: case MetricVariable::GameLoop:
return "GameLoop"; return "GameLoop";
case MetricVariable::PacketHandling: case MetricVariable::PacketHandling:
@ -159,15 +138,12 @@ std::string Metrics::MetricVariableToString(MetricVariable variable)
} }
} }
const std::vector<MetricVariable>& Metrics::GetAllMetrics() const std::vector<MetricVariable>& Metrics::GetAllMetrics() {
{
return m_Variables; return m_Variables;
} }
void Metrics::Clear() void Metrics::Clear() {
{ for (const auto& pair : m_Metrics) {
for (const auto& pair : m_Metrics)
{
delete pair.second; delete pair.second;
} }
@ -207,37 +183,35 @@ void Metrics::Clear()
#error "Cannot define getPeakRSS( ) or getCurrentRSS( ) for an unknown OS." #error "Cannot define getPeakRSS( ) or getCurrentRSS( ) for an unknown OS."
#endif #endif
/** /**
* Returns the peak (maximum so far) resident set size (physical * Returns the peak (maximum so far) resident set size (physical
* memory use) measured in bytes, or zero if the value cannot be * memory use) measured in bytes, or zero if the value cannot be
* determined on this OS. * determined on this OS.
*/ */
size_t Metrics::GetPeakRSS() size_t Metrics::GetPeakRSS() {
{
#if defined(_WIN32) #if defined(_WIN32)
/* 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 (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 (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 (size_t)0L; /* Can't read? */
} }
close( fd ); close(fd);
return (size_t)(psinfo.pr_rssize * 1024L); return (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 (size_t)rusage.ru_maxrss;
#else #else
@ -255,20 +229,19 @@ size_t Metrics::GetPeakRSS()
* Returns the current resident set size (physical memory use) measured * Returns the current resident set size (physical memory use) measured
* in bytes, or zero if the value cannot be determined on this OS. * in bytes, or zero if the value cannot be determined on this OS.
*/ */
size_t Metrics::GetCurrentRSS() size_t Metrics::GetCurrentRSS() {
{
#if defined(_WIN32) #if defined(_WIN32)
/* 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 (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 ) (task_info_t)&info, &infoCount) != KERN_SUCCESS)
return (size_t)0L; /* Can't access? */ return (size_t)0L; /* Can't access? */
return (size_t)info.resident_size; return (size_t)info.resident_size;
@ -276,15 +249,14 @@ size_t Metrics::GetCurrentRSS()
/* 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 (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 (size_t)0L; /* Can't read? */
} }
fclose( fp ); fclose(fp);
return (size_t)rss * (size_t)sysconf( _SC_PAGESIZE); return (size_t)rss * (size_t)sysconf(_SC_PAGESIZE);
#else #else
/* AIX, BSD, Solaris, and Unknown OS ------------------------ */ /* AIX, BSD, Solaris, and Unknown OS ------------------------ */
@ -293,8 +265,7 @@ size_t Metrics::GetCurrentRSS()
} }
size_t Metrics::GetProcessID() size_t Metrics::GetProcessID() {
{
#if defined(_WIN32) #if defined(_WIN32)
return GetCurrentProcessId(); return GetCurrentProcessId();
#else #else

View File

@ -71,12 +71,12 @@ void NiPoint3::SetZ(float z) {
//! Gets the length of the vector //! Gets the length of the vector
float NiPoint3::Length(void) const { float NiPoint3::Length(void) const {
return sqrt(x*x + y*y + z*z); return sqrt(x * x + y * y + z * z);
} }
//! Gets the squared length of a vector //! Gets the squared length of a vector
float NiPoint3::SquaredLength(void) const { float NiPoint3::SquaredLength(void) const {
return (x*x + y*y + z*z); return (x * x + y * y + z * z);
} }
//! Returns the dot product of the vector dotted with another vector //! Returns the dot product of the vector dotted with another vector
@ -113,13 +113,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 (float&)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 (float&)base[i];
} }
@ -166,7 +166,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
@ -175,8 +175,7 @@ bool NiPoint3::IsWithinSpehere(const NiPoint3& sphereCenter, float radius) {
return (diffVec.SquaredLength() <= (radius * radius)); return (diffVec.SquaredLength() <= (radius * radius));
} }
NiPoint3 NiPoint3::ClosestPointOnLine(const NiPoint3& a, const NiPoint3& b, const NiPoint3& p) NiPoint3 NiPoint3::ClosestPointOnLine(const NiPoint3& a, const NiPoint3& b, const NiPoint3& p) {
{
if (a == b) return a; if (a == b) return a;
const auto pa = p - a; const auto pa = p - a;
@ -191,16 +190,14 @@ NiPoint3 NiPoint3::ClosestPointOnLine(const NiPoint3& a, const NiPoint3& b, cons
return a + ab * t; return a + ab * t;
} }
float NiPoint3::Angle(const NiPoint3& a, const NiPoint3& b) float NiPoint3::Angle(const NiPoint3& a, const NiPoint3& b) {
{
const auto dot = a.DotProduct(b); const auto dot = a.DotProduct(b);
const auto lenA = a.SquaredLength(); const auto lenA = a.SquaredLength();
const auto lenB = a.SquaredLength(); const auto lenB = a.SquaredLength();
return acos(dot / sqrt(lenA * lenB)); return acos(dot / sqrt(lenA * lenB));
} }
float NiPoint3::Distance(const NiPoint3& a, const NiPoint3& b) float NiPoint3::Distance(const NiPoint3& a, const NiPoint3& b) {
{
const auto dx = a.x - b.x; const auto dx = a.x - b.x;
const auto dy = a.y - b.y; const auto dy = a.y - b.y;
const auto dz = a.z - b.z; const auto dz = a.z - b.z;
@ -208,8 +205,7 @@ float NiPoint3::Distance(const NiPoint3& a, const NiPoint3& b)
return std::sqrt(dx * dx + dy * dy + dz * dz); return std::sqrt(dx * dx + dy * dy + dz * dz);
} }
float NiPoint3::DistanceSquared(const NiPoint3& a, const NiPoint3& b) float NiPoint3::DistanceSquared(const NiPoint3& a, const NiPoint3& b) {
{
const auto dx = a.x - b.x; const auto dx = a.x - b.x;
const auto dy = a.y - b.y; const auto dy = a.y - b.y;
const auto dz = a.z - b.z; const auto dz = a.z - b.z;
@ -217,15 +213,14 @@ float NiPoint3::DistanceSquared(const NiPoint3& a, const NiPoint3& b)
return dx * dx + dy * dy + dz * dz; return dx * dx + dy * dy + dz * dz;
} }
NiPoint3 NiPoint3::MoveTowards(const NiPoint3& current, const NiPoint3& target, float maxDistanceDelta) NiPoint3 NiPoint3::MoveTowards(const NiPoint3& current, const NiPoint3& target, float maxDistanceDelta) {
{
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); 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) if ((double)lengthSquared == 0.0 || (double)maxDistanceDelta >= 0.0 && (double)lengthSquared <= (double)maxDistanceDelta * (double)maxDistanceDelta)
return target; return target;
float length = (float) std::sqrt((double) lengthSquared); float length = (float)std::sqrt((double)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

@ -99,8 +99,7 @@ Vector3 NiQuaternion::GetEulerAngles() const {
if (std::abs(sinp) >= 1) { if (std::abs(sinp) >= 1) {
angles.y = std::copysign(3.14 / 2, sinp); // use 90 degrees if out of range angles.y = std::copysign(3.14 / 2, sinp); // use 90 degrees if out of range
} } else {
else {
angles.y = std::asin(sinp); angles.y = std::asin(sinp);
} }
@ -149,8 +148,7 @@ NiQuaternion NiQuaternion::LookAt(const NiPoint3& sourcePoint, const NiPoint3& d
return NiQuaternion::CreateFromAxisAngle(vecA, rotAngle); return NiQuaternion::CreateFromAxisAngle(vecA, rotAngle);
} }
NiQuaternion NiQuaternion::LookAtUnlocked(const NiPoint3& sourcePoint, const NiPoint3& destPoint) NiQuaternion NiQuaternion::LookAtUnlocked(const NiPoint3& sourcePoint, const NiPoint3& destPoint) {
{
NiPoint3 forwardVector = NiPoint3(destPoint - sourcePoint).Unitize(); NiPoint3 forwardVector = NiPoint3(destPoint - sourcePoint).Unitize();
NiPoint3 posZ = NiPoint3::UNIT_Z; NiPoint3 posZ = NiPoint3::UNIT_Z;
@ -179,8 +177,7 @@ NiQuaternion NiQuaternion::CreateFromAxisAngle(const Vector3& axis, float angle)
return q; return q;
} }
NiQuaternion NiQuaternion::FromEulerAngles(const NiPoint3& eulerAngles) NiQuaternion NiQuaternion::FromEulerAngles(const NiPoint3& eulerAngles) {
{
// Abbreviations for the various angular functions // Abbreviations for the various angular functions
float cy = cos(eulerAngles.z * 0.5); float cy = cos(eulerAngles.z * 0.5);
float sy = sin(eulerAngles.z * 0.5); float sy = sin(eulerAngles.z * 0.5);

View File

@ -45,12 +45,11 @@ const unsigned long long SHA512::sha512_k[80] = //ULL = uint64
0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL }; 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL };
void SHA512::transform(const unsigned char *message, unsigned int block_nb) void SHA512::transform(const unsigned char* message, unsigned int block_nb) {
{
uint64 w[80]; uint64 w[80];
uint64 wv[8]; uint64 wv[8];
uint64 t1, t2; uint64 t1, t2;
const unsigned char *sub_block; const unsigned char* sub_block;
int i, j; int i, j;
for (i = 0; i < (int)block_nb; i++) { for (i = 0; i < (int)block_nb; i++) {
sub_block = message + (i << 7); sub_block = message + (i << 7);
@ -83,8 +82,7 @@ void SHA512::transform(const unsigned char *message, unsigned int block_nb)
} }
} }
void SHA512::init() void SHA512::init() {
{
m_h[0] = 0x6a09e667f3bcc908ULL; m_h[0] = 0x6a09e667f3bcc908ULL;
m_h[1] = 0xbb67ae8584caa73bULL; m_h[1] = 0xbb67ae8584caa73bULL;
m_h[2] = 0x3c6ef372fe94f82bULL; m_h[2] = 0x3c6ef372fe94f82bULL;
@ -97,11 +95,10 @@ void SHA512::init()
m_tot_len = 0; m_tot_len = 0;
} }
void SHA512::update(const unsigned char *message, unsigned int len) void SHA512::update(const unsigned char* message, unsigned int len) {
{
unsigned int block_nb; unsigned int block_nb;
unsigned int new_len, rem_len, tmp_len; unsigned int new_len, rem_len, tmp_len;
const unsigned char *shifted_message; const unsigned char* shifted_message;
tmp_len = SHA384_512_BLOCK_SIZE - m_len; tmp_len = SHA384_512_BLOCK_SIZE - m_len;
rem_len = len < tmp_len ? len : tmp_len; rem_len = len < tmp_len ? len : tmp_len;
memcpy(&m_block[m_len], message, rem_len); memcpy(&m_block[m_len], message, rem_len);
@ -120,8 +117,7 @@ void SHA512::update(const unsigned char *message, unsigned int len)
m_tot_len += (block_nb + 1) << 7; m_tot_len += (block_nb + 1) << 7;
} }
void SHA512::final(unsigned char *digest) void SHA512::final(unsigned char* digest) {
{
unsigned int block_nb; unsigned int block_nb;
unsigned int pm_len; unsigned int pm_len;
unsigned int len_b; unsigned int len_b;
@ -139,8 +135,7 @@ void SHA512::final(unsigned char *digest)
} }
} }
std::string sha512(std::string input) std::string sha512(std::string input) {
{
unsigned char digest[SHA512::DIGEST_SIZE]; unsigned char digest[SHA512::DIGEST_SIZE];
memset(digest, 0, SHA512::DIGEST_SIZE); memset(digest, 0, SHA512::DIGEST_SIZE);
class SHA512 ctx; class SHA512 ctx;

View File

@ -14,12 +14,12 @@ protected:
public: public:
void init(); void init();
void update(const unsigned char *message, unsigned int len); void update(const unsigned char* message, unsigned int len);
void final(unsigned char *digest); void final(unsigned char* digest);
static const unsigned int DIGEST_SIZE = (512 / 8); static const unsigned int DIGEST_SIZE = (512 / 8);
protected: protected:
void transform(const unsigned char *message, unsigned int block_nb); void transform(const unsigned char* message, unsigned int block_nb);
unsigned int m_tot_len; unsigned int m_tot_len;
unsigned int m_len; unsigned int m_len;
unsigned char m_block[2 * SHA384_512_BLOCK_SIZE]; unsigned char m_block[2 * SHA384_512_BLOCK_SIZE];

View File

@ -9,12 +9,12 @@ std::string demangle(const char* name) {
int status = -4; // some arbitrary value to eliminate the compiler warning int status = -4; // some arbitrary value to eliminate the compiler warning
// enable c++11 by passing the flag -std=c++11 to g++ // enable c++11 by passing the flag -std=c++11 to g++
std::unique_ptr<char, void(*)(void*)> res { std::unique_ptr<char, void(*)(void*)> res{
abi::__cxa_demangle(name, NULL, NULL, &status), abi::__cxa_demangle(name, NULL, NULL, &status),
std::free std::free
}; };
return (status==0) ? res.get() : name ; return (status == 0) ? res.get() : name;
} }
#else #else

View File

@ -4,16 +4,13 @@
#include <zlib.h> #include <zlib.h>
namespace ZCompression namespace ZCompression {
{ int32_t GetMaxCompressedLength(int32_t nLenSrc) {
int32_t GetMaxCompressedLength(int32_t nLenSrc)
{
int32_t n16kBlocks = (nLenSrc + 16383) / 16384; // round up any fraction of a block int32_t n16kBlocks = (nLenSrc + 16383) / 16384; // round up any fraction of a block
return (nLenSrc + 6 + (n16kBlocks * 5)); return (nLenSrc + 6 + (n16kBlocks * 5));
} }
int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst) int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst) {
{
z_stream zInfo = { 0 }; z_stream zInfo = { 0 };
zInfo.total_in = zInfo.avail_in = nLenSrc; zInfo.total_in = zInfo.avail_in = nLenSrc;
zInfo.total_out = zInfo.avail_out = nLenDst; zInfo.total_out = zInfo.avail_out = nLenDst;
@ -33,8 +30,7 @@ namespace ZCompression
} }
int32_t Decompress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst, int32_t& nErr) int32_t Decompress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst, int32_t& nErr) {
{
// Get the size of the decompressed data // Get the size of the decompressed data
z_stream zInfo = { 0 }; z_stream zInfo = { 0 };
zInfo.total_in = zInfo.avail_in = nLenSrc; zInfo.total_in = zInfo.avail_in = nLenSrc;

View File

@ -6,8 +6,7 @@
#ifndef DARKFLAME_PLATFORM_WIN32 #ifndef DARKFLAME_PLATFORM_WIN32
namespace ZCompression namespace ZCompression {
{
int32_t GetMaxCompressedLength(int32_t nLenSrc); int32_t GetMaxCompressedLength(int32_t nLenSrc);
int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst); int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst);

View File

@ -542,7 +542,7 @@ enum ePlayerFlags {
TOOLTIP_TALK_TO_SKYLAND_TO_GET_HAT = 52, TOOLTIP_TALK_TO_SKYLAND_TO_GET_HAT = 52,
MODULAR_BUILD_PLAYER_PLACES_FIRST_MODEL_IN_SCRATCH = 53, MODULAR_BUILD_PLAYER_PLACES_FIRST_MODEL_IN_SCRATCH = 53,
MODULAR_BUILD_FIRST_ARROW_DISPLAY_FOR_MODULE = 54, MODULAR_BUILD_FIRST_ARROW_DISPLAY_FOR_MODULE = 54,
AG_BEACON_QB,_SO_THE_PLAYER_CAN_ALWAYS_BUILD_THEM = 55, AG_BEACON_QB_SO_THE_PLAYER_CAN_ALWAYS_BUILD_THEM = 55,
GF_PET_DIG_FLAG_1 = 56, GF_PET_DIG_FLAG_1 = 56,
GF_PET_DIG_FLAG_2 = 57, GF_PET_DIG_FLAG_2 = 57,
GF_PET_DIG_FLAG_3 = 58, GF_PET_DIG_FLAG_3 = 58,

View File

@ -46,7 +46,7 @@ void dLogger::vLog(const char* format, va_list args) {
mFile << "[" << timeStr << "] " << message; mFile << "[" << timeStr << "] " << message;
#else #else
time_t t = time(NULL); time_t t = time(NULL);
struct tm * time = localtime(&t); struct tm* time = localtime(&t);
char timeStr[70]; char timeStr[70];
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", time); strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", time);
char message[2048]; char message[2048];
@ -70,18 +70,18 @@ void dLogger::vLog(const char* format, va_list args) {
#endif #endif
} }
void dLogger::LogBasic(const char * format, ...) { void dLogger::LogBasic(const char* format, ...) {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
vLog(format, args); vLog(format, args);
va_end(args); va_end(args);
} }
void dLogger::LogBasic(const std::string & message) { void dLogger::LogBasic(const std::string& message) {
LogBasic(message.c_str()); LogBasic(message.c_str());
} }
void dLogger::Log(const char * className, const char * format, ...) { void dLogger::Log(const char* className, const char* format, ...) {
va_list args; va_list args;
std::string log = "[" + std::string(className) + "] " + std::string(format) + "\n"; std::string log = "[" + std::string(className) + "] " + std::string(format) + "\n";
va_start(args, format); va_start(args, format);
@ -89,11 +89,11 @@ void dLogger::Log(const char * className, const char * format, ...) {
va_end(args); va_end(args);
} }
void dLogger::Log(const std::string & className, const std::string & message) { void dLogger::Log(const std::string& className, const std::string& message) {
Log(className.c_str(), message.c_str()); Log(className.c_str(), message.c_str());
} }
void dLogger::LogDebug(const char * className, const char * format, ...) { void dLogger::LogDebug(const char* className, const char* format, ...) {
if (!m_logDebugStatements) return; if (!m_logDebugStatements) return;
va_list args; va_list args;
std::string log = "[" + std::string(className) + "] " + std::string(format); std::string log = "[" + std::string(className) + "] " + std::string(format);
@ -102,7 +102,7 @@ void dLogger::LogDebug(const char * className, const char * format, ...) {
va_end(args); va_end(args);
} }
void dLogger::LogDebug(const std::string & className, const std::string & message) { void dLogger::LogDebug(const std::string& className, const std::string& message) {
LogDebug(className.c_str(), message.c_str()); LogDebug(className.c_str(), message.c_str());
} }

View File

@ -31,8 +31,8 @@ private:
std::string m_outpath; std::string m_outpath;
std::ofstream mFile; std::ofstream mFile;
#ifndef _WIN32 #ifndef _WIN32
//Glorious linux can run with SPEED: //Glorious linux can run with SPEED:
FILE* fp = nullptr; FILE* fp = nullptr;
#endif #endif
}; };

View File

@ -1,29 +1,29 @@
#pragma once #pragma once
#if defined(_WIN32) #if defined(_WIN32)
#define DARKFLAME_PLATFORM_WIN32 #define DARKFLAME_PLATFORM_WIN32
#elif defined(__APPLE__) && defined(__MACH__) #elif defined(__APPLE__) && defined(__MACH__)
#include <TargetConditionals.h> #include <TargetConditionals.h>
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#define DARKFLAME_PLATFORM_IOS #define DARKFLAME_PLATFORM_IOS
#elif TARGET_OS_MAC #elif TARGET_OS_MAC
#define DARKFLAME_PLATFORM_MACOS #define DARKFLAME_PLATFORM_MACOS
#else
#error unknown Apple operating system
#endif
#elif defined(__unix__)
#define DARKFLAME_PLATFORM_UNIX
#if defined(__ANDROID__)
#define DARKFLAME_PLATFORM_ANDROID
#elif defined(__linux__)
#define DARKFLAME_PLATFORM_LINUX
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#define DARKFLAME_PLATFORM_FREEBSD
#elif defined(__CYGWIN__)
#define DARKFLAME_PLATFORM_CYGWIN
#else
#error unknown unix operating system
#endif
#else #else
#error unknown operating system #error unknown Apple operating system
#endif
#elif defined(__unix__)
#define DARKFLAME_PLATFORM_UNIX
#if defined(__ANDROID__)
#define DARKFLAME_PLATFORM_ANDROID
#elif defined(__linux__)
#define DARKFLAME_PLATFORM_LINUX
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#define DARKFLAME_PLATFORM_FREEBSD
#elif defined(__CYGWIN__)
#define DARKFLAME_PLATFORM_CYGWIN
#else
#error unknown unix operating system
#endif
#else
#error unknown operating system
#endif #endif

View File

@ -2,7 +2,7 @@
#include "CDComponentsRegistryTable.h" #include "CDComponentsRegistryTable.h"
// Static Variables // Static Variables
static CppSQLite3DB * conn = new CppSQLite3DB(); static CppSQLite3DB* conn = new CppSQLite3DB();
//! Opens a connection with the CDClient //! Opens a connection with the CDClient
void CDClientDatabase::Connect(const std::string& filename) { void CDClientDatabase::Connect(const std::string& filename) {

View File

@ -13,10 +13,10 @@
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
// Enable this to cache all entries in each table for fast access, comes with more memory cost // Enable this to cache all entries in each table for fast access, comes with more memory cost
//#define CDCLIENT_CACHE_ALL //#define CDCLIENT_CACHE_ALL
// Enable this to skip some unused columns in some tables // Enable this to skip some unused columns in some tables
#define UNUSED(v) #define UNUSED(v)
/*! /*!
@ -24,7 +24,7 @@
\brief An interface between the CDClient.sqlite file and the server \brief An interface between the CDClient.sqlite file and the server
*/ */
//! The CDClient Database namespace //! The CDClient Database namespace
namespace CDClientDatabase { namespace CDClientDatabase {
//! Opens a connection with the CDClient //! Opens a connection with the CDClient

View File

@ -1,7 +1,7 @@
#include "CDClientManager.h" #include "CDClientManager.h"
// Static Variables // Static Variables
CDClientManager * CDClientManager::m_Address = nullptr; CDClientManager* CDClientManager::m_Address = nullptr;
//! Initializes the manager //! Initializes the manager
void CDClientManager::Initialize(void) { void CDClientManager::Initialize(void) {

View File

@ -52,17 +52,17 @@
\brief A manager for the CDClient tables \brief A manager for the CDClient tables
*/ */
//! Manages all data from the CDClient //! Manages all data from the CDClient
class CDClientManager { class CDClientManager {
private: private:
static CDClientManager * m_Address; //!< The singleton address static CDClientManager* m_Address; //!< The singleton address
std::unordered_map<std::string, CDTable*> tables; //!< The tables std::unordered_map<std::string, CDTable*> tables; //!< The tables
public: public:
//! The singleton method //! The singleton method
static CDClientManager * Instance() { static CDClientManager* Instance() {
if (m_Address == 0) { if (m_Address == 0) {
m_Address = new CDClientManager; m_Address = new CDClientManager;
} }
@ -82,7 +82,7 @@ public:
\return The class or nullptr \return The class or nullptr
*/ */
template<typename T> template<typename T>
T * GetTable(const std::string& tableName) { T* GetTable(const std::string& tableName) {
static_assert(std::is_base_of<CDTable, T>::value, "T should inherit from CDTable!"); static_assert(std::is_base_of<CDTable, T>::value, "T should inherit from CDTable!");
for (auto itr = this->tables.begin(); itr != this->tables.end(); ++itr) { for (auto itr = this->tables.begin(); itr != this->tables.end(); ++itr) {

View File

@ -6,8 +6,8 @@ using namespace std;
#pragma warning (disable:4251) //Disables SQL warnings #pragma warning (disable:4251) //Disables SQL warnings
sql::Driver * Database::driver; sql::Driver* Database::driver;
sql::Connection * Database::con; sql::Connection* Database::con;
sql::Properties Database::props; sql::Properties Database::props;
std::string Database::database; std::string Database::database;
@ -66,8 +66,7 @@ sql::PreparedStatement* Database::CreatePreppedStmt(const std::string& query) {
Game::logger->Log("Database", "Trying to reconnect to MySQL"); Game::logger->Log("Database", "Trying to reconnect to MySQL");
} }
if (!con->isValid() || con->isClosed()) if (!con->isValid() || con->isClosed()) {
{
delete con; delete con;
con = nullptr; con = nullptr;

View File

@ -11,8 +11,8 @@ public:
class Database { class Database {
private: private:
static sql::Driver *driver; static sql::Driver* driver;
static sql::Connection *con; static sql::Connection* con;
static sql::Properties props; static sql::Properties props;
static std::string database; static std::string database;
public: public:

View File

@ -47,8 +47,7 @@ void MigrationRunner::RunMigrations() {
auto simpleStatement = Database::CreateStmt(); auto simpleStatement = Database::CreateStmt();
simpleStatement->execute(finalSQL); simpleStatement->execute(finalSQL);
delete simpleStatement; delete simpleStatement;
} } catch (sql::SQLException e) {
catch (sql::SQLException e) {
Game::logger->Log("MigrationRunner", "Encountered error running migration: %s", e.what()); Game::logger->Log("MigrationRunner", "Encountered error running migration: %s", e.what());
} }
} }

View File

@ -49,7 +49,7 @@ CDActivitiesTable::CDActivitiesTable(void) {
} }
//! Destructor //! Destructor
CDActivitiesTable::~CDActivitiesTable(void) { } CDActivitiesTable::~CDActivitiesTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDActivitiesTable::GetName(void) const { std::string CDActivitiesTable::GetName(void) const {

View File

@ -37,7 +37,7 @@ CDActivityRewardsTable::CDActivityRewardsTable(void) {
} }
//! Destructor //! Destructor
CDActivityRewardsTable::~CDActivityRewardsTable(void) { } CDActivityRewardsTable::~CDActivityRewardsTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDActivityRewardsTable::GetName(void) const { std::string CDActivityRewardsTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the ActivityRewards table \brief Contains data for the ActivityRewards table
*/ */
//! ActivityRewards Entry Struct //! ActivityRewards Entry Struct
struct CDActivityRewards { struct CDActivityRewards {
unsigned int objectTemplate; //!< The object template (?) unsigned int objectTemplate; //!< The object template (?)
unsigned int ActivityRewardIndex; //!< The activity reward index unsigned int ActivityRewardIndex; //!< The activity reward index

View File

@ -43,7 +43,7 @@ CDAnimationsTable::CDAnimationsTable(void) {
} }
//! Destructor //! Destructor
CDAnimationsTable::~CDAnimationsTable(void) { } CDAnimationsTable::~CDAnimationsTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDAnimationsTable::GetName(void) const { std::string CDAnimationsTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the Animations table \brief Contains data for the Animations table
*/ */
//! Animations Entry Struct //! Animations Entry Struct
struct CDAnimations { struct CDAnimations {
unsigned int animationGroupID; //!< The animation group ID unsigned int animationGroupID; //!< The animation group ID
std::string animation_type; //!< The animation type std::string animation_type; //!< The animation type

View File

@ -31,15 +31,14 @@ CDBehaviorParameterTable::CDBehaviorParameterTable(void) {
} }
//! Destructor //! Destructor
CDBehaviorParameterTable::~CDBehaviorParameterTable(void) { } CDBehaviorParameterTable::~CDBehaviorParameterTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDBehaviorParameterTable::GetName(void) const { std::string CDBehaviorParameterTable::GetName(void) const {
return "BehaviorParameter"; return "BehaviorParameter";
} }
CDBehaviorParameter CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::string& name, const float defaultValue) CDBehaviorParameter CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::string& name, const float defaultValue) {
{
CDBehaviorParameter returnValue; CDBehaviorParameter returnValue;
returnValue.behaviorID = 0; returnValue.behaviorID = 0;
returnValue.parameterID = m_ParametersList.end(); returnValue.parameterID = m_ParametersList.end();

View File

@ -10,7 +10,7 @@
\brief Contains data for the BehaviorParameter table \brief Contains data for the BehaviorParameter table
*/ */
//! BehaviorParameter Entry Struct //! BehaviorParameter Entry Struct
struct CDBehaviorParameter { struct CDBehaviorParameter {
unsigned int behaviorID; //!< The Behavior ID unsigned int behaviorID; //!< The Behavior ID
std::unordered_set<std::string>::iterator parameterID; //!< The Parameter ID std::unordered_set<std::string>::iterator parameterID; //!< The Parameter ID

View File

@ -41,7 +41,7 @@ CDBehaviorTemplateTable::CDBehaviorTemplateTable(void) {
} }
//! Destructor //! Destructor
CDBehaviorTemplateTable::~CDBehaviorTemplateTable(void) { } CDBehaviorTemplateTable::~CDBehaviorTemplateTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDBehaviorTemplateTable::GetName(void) const { std::string CDBehaviorTemplateTable::GetName(void) const {

View File

@ -10,7 +10,7 @@
\brief Contains data for the BehaviorTemplate table \brief Contains data for the BehaviorTemplate table
*/ */
//! BehaviorTemplate Entry Struct //! BehaviorTemplate Entry Struct
struct CDBehaviorTemplate { struct CDBehaviorTemplate {
unsigned int behaviorID; //!< The Behavior ID unsigned int behaviorID; //!< The Behavior ID
unsigned int templateID; //!< The Template ID (LOT) unsigned int templateID; //!< The Template ID (LOT)

View File

@ -32,7 +32,7 @@ CDBrickIDTableTable::CDBrickIDTableTable(void) {
} }
//! Destructor //! Destructor
CDBrickIDTableTable::~CDBrickIDTableTable(void) { } CDBrickIDTableTable::~CDBrickIDTableTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDBrickIDTableTable::GetName(void) const { std::string CDBrickIDTableTable::GetName(void) const {

View File

@ -28,7 +28,7 @@ CDComponentsRegistryTable::CDComponentsRegistryTable(void) {
entry.component_type = tableData.getIntField(1, -1); entry.component_type = tableData.getIntField(1, -1);
entry.component_id = tableData.getIntField(2, -1); entry.component_id = tableData.getIntField(2, -1);
this->mappedEntries.insert_or_assign(((uint64_t) entry.component_type) << 32 | ((uint64_t) entry.id), entry.component_id); this->mappedEntries.insert_or_assign(((uint64_t)entry.component_type) << 32 | ((uint64_t)entry.id), entry.component_id);
//this->entries.push_back(entry); //this->entries.push_back(entry);
@ -56,19 +56,17 @@ CDComponentsRegistryTable::CDComponentsRegistryTable(void) {
} }
//! Destructor //! Destructor
CDComponentsRegistryTable::~CDComponentsRegistryTable(void) { } CDComponentsRegistryTable::~CDComponentsRegistryTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDComponentsRegistryTable::GetName(void) const { std::string CDComponentsRegistryTable::GetName(void) const {
return "ComponentsRegistry"; return "ComponentsRegistry";
} }
int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, uint32_t componentType, int32_t defaultValue) int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, uint32_t componentType, int32_t defaultValue) {
{ const auto& iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
const auto& iter = this->mappedEntries.find(((uint64_t) componentType) << 32 | ((uint64_t) id));
if (iter == this->mappedEntries.end()) if (iter == this->mappedEntries.end()) {
{
return defaultValue; return defaultValue;
} }
@ -106,8 +104,7 @@ int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, uint32_t componen
if (iter == it->second.end()) { if (iter == it->second.end()) {
it->second.insert(std::make_pair(entry.component_type, entry.component_id)); it->second.insert(std::make_pair(entry.component_type, entry.component_id));
} }
} } else {
else {
std::map<unsigned int, unsigned int> map; std::map<unsigned int, unsigned int> map;
map.insert(std::make_pair(entry.component_type, entry.component_id)); map.insert(std::make_pair(entry.component_type, entry.component_id));
this->mappedEntries.insert(std::make_pair(entry.id, map)); this->mappedEntries.insert(std::make_pair(entry.id, map));

View File

@ -8,7 +8,7 @@
\brief Contains data for the ComponentsRegistry table \brief Contains data for the ComponentsRegistry table
*/ */
//! ComponentsRegistry Entry Struct //! ComponentsRegistry Entry Struct
struct CDComponentsRegistry { struct CDComponentsRegistry {
unsigned int id; //!< The LOT is used as the ID unsigned int id; //!< The LOT is used as the ID
unsigned int component_type; //!< See ComponentTypes enum for values unsigned int component_type; //!< See ComponentTypes enum for values

View File

@ -35,7 +35,7 @@ CDCurrencyTableTable::CDCurrencyTableTable(void) {
} }
//! Destructor //! Destructor
CDCurrencyTableTable::~CDCurrencyTableTable(void) { } CDCurrencyTableTable::~CDCurrencyTableTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDCurrencyTableTable::GetName(void) const { std::string CDCurrencyTableTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the CurrencyTable table \brief Contains data for the CurrencyTable table
*/ */
//! CurrencyTable Struct //! CurrencyTable Struct
struct CDCurrencyTable { struct CDCurrencyTable {
unsigned int currencyIndex; //!< The Currency Index unsigned int currencyIndex; //!< The Currency Index
unsigned int npcminlevel; //!< The minimum level of the npc unsigned int npcminlevel; //!< The minimum level of the npc

View File

@ -44,7 +44,7 @@ CDDestructibleComponentTable::CDDestructibleComponentTable(void) {
} }
//! Destructor //! Destructor
CDDestructibleComponentTable::~CDDestructibleComponentTable(void) { } CDDestructibleComponentTable::~CDDestructibleComponentTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDDestructibleComponentTable::GetName(void) const { std::string CDDestructibleComponentTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the DestructibleComponent table \brief Contains data for the DestructibleComponent table
*/ */
//! ItemComponent Struct //! ItemComponent Struct
struct CDDestructibleComponent { struct CDDestructibleComponent {
unsigned int id; //!< The component ID from the ComponentsRegistry Table unsigned int id; //!< The component ID from the ComponentsRegistry Table
int faction; //!< The Faction ID of the object int faction; //!< The Faction ID of the object

View File

@ -35,7 +35,7 @@ std::string CDEmoteTableTable::GetName(void) const {
return "Emotes"; return "Emotes";
} }
CDEmoteTable * CDEmoteTableTable::GetEmote(int id) { CDEmoteTable* CDEmoteTableTable::GetEmote(int id) {
for (auto e : entries) { for (auto e : entries) {
if (e.first == id) return e.second; if (e.first == id) return e.second;
} }

View File

@ -9,7 +9,7 @@
\brief Contains data for the CDEmoteTable table \brief Contains data for the CDEmoteTable table
*/ */
//! CDEmoteEntry Struct //! CDEmoteEntry Struct
struct CDEmoteTable { struct CDEmoteTable {
CDEmoteTable() { CDEmoteTable() {
ID = -1; ID = -1;

View File

@ -35,7 +35,7 @@ CDFeatureGatingTable::CDFeatureGatingTable(void) {
} }
//! Destructor //! Destructor
CDFeatureGatingTable::~CDFeatureGatingTable(void) { } CDFeatureGatingTable::~CDFeatureGatingTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDFeatureGatingTable::GetName(void) const { std::string CDFeatureGatingTable::GetName(void) const {
@ -52,12 +52,9 @@ std::vector<CDFeatureGating> CDFeatureGatingTable::Query(std::function<bool(CDFe
return data; return data;
} }
bool CDFeatureGatingTable::FeatureUnlocked(const std::string& feature) const bool CDFeatureGatingTable::FeatureUnlocked(const std::string& feature) const {
{ for (const auto& entry : entries) {
for (const auto& entry : entries) if (entry.featureName == feature) {
{
if (entry.featureName == feature)
{
return true; return true;
} }
} }

View File

@ -7,7 +7,7 @@
\file CDFeatureGatingTable.hpp \file CDFeatureGatingTable.hpp
*/ */
//! ItemComponent Struct //! ItemComponent Struct
struct CDFeatureGating { struct CDFeatureGating {
std::string featureName; std::string featureName;
int32_t major; int32_t major;

View File

@ -34,7 +34,7 @@ CDInventoryComponentTable::CDInventoryComponentTable(void) {
} }
//! Destructor //! Destructor
CDInventoryComponentTable::~CDInventoryComponentTable(void) { } CDInventoryComponentTable::~CDInventoryComponentTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDInventoryComponentTable::GetName(void) const { std::string CDInventoryComponentTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the InventoryComponent table \brief Contains data for the InventoryComponent table
*/ */
//! ItemComponent Struct //! ItemComponent Struct
struct CDInventoryComponent { struct CDInventoryComponent {
unsigned int id; //!< The component ID for this object unsigned int id; //!< The component ID for this object
unsigned int itemid; //!< The LOT of the object unsigned int itemid; //!< The LOT of the object

View File

@ -75,14 +75,14 @@ CDItemComponentTable::CDItemComponentTable(void) {
} }
//! Destructor //! Destructor
CDItemComponentTable::~CDItemComponentTable(void) { } CDItemComponentTable::~CDItemComponentTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDItemComponentTable::GetName(void) const { std::string CDItemComponentTable::GetName(void) const {
return "ItemComponent"; return "ItemComponent";
} }
const CDItemComponent & CDItemComponentTable::GetItemComponentByID(unsigned int skillID) { const CDItemComponent& CDItemComponentTable::GetItemComponentByID(unsigned int skillID) {
const auto& it = this->entries.find(skillID); const auto& it = this->entries.find(skillID);
if (it != this->entries.end()) { if (it != this->entries.end()) {
return it->second; return it->second;

View File

@ -9,7 +9,7 @@
\brief Contains data for the ItemComponent table \brief Contains data for the ItemComponent table
*/ */
//! ItemComponent Struct //! ItemComponent Struct
struct CDItemComponent { struct CDItemComponent {
unsigned int id; //!< The Component ID unsigned int id; //!< The Component ID
std::string equipLocation; //!< The equip location std::string equipLocation; //!< The equip location

View File

@ -33,7 +33,7 @@ CDItemSetSkillsTable::CDItemSetSkillsTable(void) {
} }
//! Destructor //! Destructor
CDItemSetSkillsTable::~CDItemSetSkillsTable(void) { } CDItemSetSkillsTable::~CDItemSetSkillsTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDItemSetSkillsTable::GetName(void) const { std::string CDItemSetSkillsTable::GetName(void) const {
@ -55,8 +55,7 @@ std::vector<CDItemSetSkills> CDItemSetSkillsTable::GetEntries(void) const {
return this->entries; return this->entries;
} }
std::vector<CDItemSetSkills> CDItemSetSkillsTable::GetBySkillID(unsigned int SkillSetID) std::vector<CDItemSetSkills> CDItemSetSkillsTable::GetBySkillID(unsigned int SkillSetID) {
{
std::vector<CDItemSetSkills> toReturn; std::vector<CDItemSetSkills> toReturn;
for (CDItemSetSkills entry : this->entries) { for (CDItemSetSkills entry : this->entries) {

View File

@ -8,7 +8,7 @@
\brief Contains data for the ItemSetSkills table \brief Contains data for the ItemSetSkills table
*/ */
//! ZoneTable Struct //! ZoneTable Struct
struct CDItemSetSkills { struct CDItemSetSkills {
unsigned int SkillSetID; //!< The skill set ID unsigned int SkillSetID; //!< The skill set ID
unsigned int SkillID; //!< The skill ID unsigned int SkillID; //!< The skill ID

View File

@ -45,7 +45,7 @@ CDItemSetsTable::CDItemSetsTable(void) {
} }
//! Destructor //! Destructor
CDItemSetsTable::~CDItemSetsTable(void) { } CDItemSetsTable::~CDItemSetsTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDItemSetsTable::GetName(void) const { std::string CDItemSetsTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the ItemSets table \brief Contains data for the ItemSets table
*/ */
//! ZoneTable Struct //! ZoneTable Struct
struct CDItemSets { struct CDItemSets {
unsigned int setID; //!< The item set ID unsigned int setID; //!< The item set ID
unsigned int locStatus; //!< The loc status unsigned int locStatus; //!< The loc status

View File

@ -33,7 +33,7 @@ CDLevelProgressionLookupTable::CDLevelProgressionLookupTable(void) {
} }
//! Destructor //! Destructor
CDLevelProgressionLookupTable::~CDLevelProgressionLookupTable(void) { } CDLevelProgressionLookupTable::~CDLevelProgressionLookupTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDLevelProgressionLookupTable::GetName(void) const { std::string CDLevelProgressionLookupTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the LevelProgressionLookup table \brief Contains data for the LevelProgressionLookup table
*/ */
//! LevelProgressionLookup Entry Struct //! LevelProgressionLookup Entry Struct
struct CDLevelProgressionLookup { struct CDLevelProgressionLookup {
unsigned int id; //!< The Level ID unsigned int id; //!< The Level ID
unsigned int requiredUScore; //!< The required LEGO Score unsigned int requiredUScore; //!< The required LEGO Score

View File

@ -39,7 +39,7 @@ CDLootMatrixTable::CDLootMatrixTable(void) {
} }
//! Destructor //! Destructor
CDLootMatrixTable::~CDLootMatrixTable(void) { } CDLootMatrixTable::~CDLootMatrixTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDLootMatrixTable::GetName(void) const { std::string CDLootMatrixTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the ObjectSkills table \brief Contains data for the ObjectSkills table
*/ */
//! LootMatrix Struct //! LootMatrix Struct
struct CDLootMatrix { struct CDLootMatrix {
unsigned int LootMatrixIndex; //!< The Loot Matrix Index unsigned int LootMatrixIndex; //!< The Loot Matrix Index
unsigned int LootTableIndex; //!< The Loot Table Index unsigned int LootTableIndex; //!< The Loot Table Index

View File

@ -36,7 +36,7 @@ CDLootTableTable::CDLootTableTable(void) {
} }
//! Destructor //! Destructor
CDLootTableTable::~CDLootTableTable(void) { } CDLootTableTable::~CDLootTableTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDLootTableTable::GetName(void) const { std::string CDLootTableTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the LootTable table \brief Contains data for the LootTable table
*/ */
//! LootTable Struct //! LootTable Struct
struct CDLootTable { struct CDLootTable {
unsigned int itemid; //!< The LOT of the item unsigned int itemid; //!< The LOT of the item
unsigned int LootTableIndex; //!< The Loot Table Index unsigned int LootTableIndex; //!< The Loot Table Index

View File

@ -38,7 +38,7 @@ CDMissionEmailTable::CDMissionEmailTable(void) {
} }
//! Destructor //! Destructor
CDMissionEmailTable::~CDMissionEmailTable(void) { } CDMissionEmailTable::~CDMissionEmailTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDMissionEmailTable::GetName(void) const { std::string CDMissionEmailTable::GetName(void) const {

View File

@ -35,7 +35,7 @@ CDMissionNPCComponentTable::CDMissionNPCComponentTable(void) {
} }
//! Destructor //! Destructor
CDMissionNPCComponentTable::~CDMissionNPCComponentTable(void) { } CDMissionNPCComponentTable::~CDMissionNPCComponentTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDMissionNPCComponentTable::GetName(void) const { std::string CDMissionNPCComponentTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the ObjectSkills table \brief Contains data for the ObjectSkills table
*/ */
//! MissionNPCComponent Struct //! MissionNPCComponent Struct
struct CDMissionNPCComponent { struct CDMissionNPCComponent {
unsigned int id; //!< The ID unsigned int id; //!< The ID
unsigned int missionID; //!< The Mission ID unsigned int missionID; //!< The Mission ID

View File

@ -43,7 +43,7 @@ CDMissionTasksTable::CDMissionTasksTable(void) {
} }
//! Destructor //! Destructor
CDMissionTasksTable::~CDMissionTasksTable(void) { } CDMissionTasksTable::~CDMissionTasksTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDMissionTasksTable::GetName(void) const { std::string CDMissionTasksTable::GetName(void) const {
@ -60,14 +60,11 @@ std::vector<CDMissionTasks> CDMissionTasksTable::Query(std::function<bool(CDMiss
return data; return data;
} }
std::vector<CDMissionTasks*> CDMissionTasksTable::GetByMissionID(uint32_t missionID) std::vector<CDMissionTasks*> CDMissionTasksTable::GetByMissionID(uint32_t missionID) {
{
std::vector<CDMissionTasks*> tasks; std::vector<CDMissionTasks*> tasks;
for (auto& entry : this->entries) for (auto& entry : this->entries) {
{ if (entry.id == missionID) {
if (entry.id == missionID)
{
CDMissionTasks* task = const_cast<CDMissionTasks*>(&entry); CDMissionTasks* task = const_cast<CDMissionTasks*>(&entry);
tasks.push_back(task); tasks.push_back(task);

View File

@ -8,7 +8,7 @@
\brief Contains data for the MissionTasks table \brief Contains data for the MissionTasks table
*/ */
//! ObjectSkills Struct //! ObjectSkills Struct
struct CDMissionTasks { struct CDMissionTasks {
unsigned int id; //!< The Mission ID that the task belongs to unsigned int id; //!< The Mission ID that the task belongs to
UNUSED(unsigned int locStatus); //!< ??? UNUSED(unsigned int locStatus); //!< ???

View File

@ -86,7 +86,7 @@ CDMissionsTable::CDMissionsTable(void) {
} }
//! Destructor //! Destructor
CDMissionsTable::~CDMissionsTable(void) { } CDMissionsTable::~CDMissionsTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDMissionsTable::GetName(void) const { std::string CDMissionsTable::GetName(void) const {
@ -108,12 +108,9 @@ const std::vector<CDMissions>& CDMissionsTable::GetEntries(void) const {
return this->entries; return this->entries;
} }
const CDMissions* CDMissionsTable::GetPtrByMissionID(uint32_t missionID) const const CDMissions* CDMissionsTable::GetPtrByMissionID(uint32_t missionID) const {
{ for (const auto& entry : entries) {
for (const auto& entry : entries) if (entry.id == missionID) {
{
if (entry.id == missionID)
{
return const_cast<CDMissions*>(&entry); return const_cast<CDMissions*>(&entry);
} }
} }
@ -121,12 +118,9 @@ const CDMissions* CDMissionsTable::GetPtrByMissionID(uint32_t missionID) const
return &Default; return &Default;
} }
const CDMissions& CDMissionsTable::GetByMissionID(uint32_t missionID, bool& found) const const CDMissions& CDMissionsTable::GetByMissionID(uint32_t missionID, bool& found) const {
{ for (const auto& entry : entries) {
for (const auto& entry : entries) if (entry.id == missionID) {
{
if (entry.id == missionID)
{
found = true; found = true;
return entry; return entry;

View File

@ -10,7 +10,7 @@
\brief Contains data for the Missions table \brief Contains data for the Missions table
*/ */
//! Missions Struct //! Missions Struct
struct CDMissions { struct CDMissions {
int id; //!< The Mission ID int id; //!< The Mission ID
std::string defined_type; //!< The type of mission std::string defined_type; //!< The type of mission

View File

@ -38,7 +38,7 @@ CDMovementAIComponentTable::CDMovementAIComponentTable(void) {
} }
//! Destructor //! Destructor
CDMovementAIComponentTable::~CDMovementAIComponentTable(void) { } CDMovementAIComponentTable::~CDMovementAIComponentTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDMovementAIComponentTable::GetName(void) const { std::string CDMovementAIComponentTable::GetName(void) const {

View File

@ -34,7 +34,7 @@ CDObjectSkillsTable::CDObjectSkillsTable(void) {
} }
//! Destructor //! Destructor
CDObjectSkillsTable::~CDObjectSkillsTable(void) { } CDObjectSkillsTable::~CDObjectSkillsTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDObjectSkillsTable::GetName(void) const { std::string CDObjectSkillsTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the ObjectSkills table \brief Contains data for the ObjectSkills table
*/ */
//! ObjectSkills Struct //! ObjectSkills Struct
struct CDObjectSkills { struct CDObjectSkills {
unsigned int objectTemplate; //!< The LOT of the item unsigned int objectTemplate; //!< The LOT of the item
unsigned int skillID; //!< The Skill ID of the object unsigned int skillID; //!< The Skill ID of the object

View File

@ -44,14 +44,14 @@ CDObjectsTable::CDObjectsTable(void) {
} }
//! Destructor //! Destructor
CDObjectsTable::~CDObjectsTable(void) { } CDObjectsTable::~CDObjectsTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDObjectsTable::GetName(void) const { std::string CDObjectsTable::GetName(void) const {
return "Objects"; return "Objects";
} }
const CDObjects & CDObjectsTable::GetByID(unsigned int LOT) { const CDObjects& CDObjectsTable::GetByID(unsigned int LOT) {
const auto& it = this->entries.find(LOT); const auto& it = this->entries.find(LOT);
if (it != this->entries.end()) { if (it != this->entries.end()) {
return it->second; return it->second;

View File

@ -8,7 +8,7 @@
\brief Contains data for the Objects table \brief Contains data for the Objects table
*/ */
//! RebuildComponent Struct //! RebuildComponent Struct
struct CDObjects { struct CDObjects {
unsigned int id; //!< The LOT of the object unsigned int id; //!< The LOT of the object
std::string name; //!< The internal name of the object std::string name; //!< The internal name of the object

View File

@ -33,7 +33,7 @@ CDPackageComponentTable::CDPackageComponentTable(void) {
} }
//! Destructor //! Destructor
CDPackageComponentTable::~CDPackageComponentTable(void) { } CDPackageComponentTable::~CDPackageComponentTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDPackageComponentTable::GetName(void) const { std::string CDPackageComponentTable::GetName(void) const {

View File

@ -17,7 +17,7 @@ CDPropertyEntranceComponentTable::CDPropertyEntranceComponentTable() {
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PropertyEntranceComponent;"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PropertyEntranceComponent;");
while (!tableData.eof()) { while (!tableData.eof()) {
auto entry = CDPropertyEntranceComponent { auto entry = CDPropertyEntranceComponent{
static_cast<uint32_t>(tableData.getIntField(0, -1)), static_cast<uint32_t>(tableData.getIntField(0, -1)),
static_cast<uint32_t>(tableData.getIntField(1, -1)), static_cast<uint32_t>(tableData.getIntField(1, -1)),
tableData.getStringField(2, ""), tableData.getStringField(2, ""),

View File

@ -36,6 +36,6 @@ public:
*/ */
[[nodiscard]] std::vector<CDPropertyEntranceComponent> GetEntries() const { return entries; } [[nodiscard]] std::vector<CDPropertyEntranceComponent> GetEntries() const { return entries; }
private: private:
std::vector<CDPropertyEntranceComponent> entries {}; std::vector<CDPropertyEntranceComponent> entries{};
CDPropertyEntranceComponent defaultEntry {}; CDPropertyEntranceComponent defaultEntry{};
}; };

View File

@ -16,7 +16,7 @@ CDPropertyTemplateTable::CDPropertyTemplateTable() {
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PropertyTemplate;"); auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PropertyTemplate;");
while (!tableData.eof()) { while (!tableData.eof()) {
auto entry = CDPropertyTemplate { auto entry = CDPropertyTemplate{
static_cast<uint32_t>(tableData.getIntField(0, -1)), static_cast<uint32_t>(tableData.getIntField(0, -1)),
static_cast<uint32_t>(tableData.getIntField(1, -1)), static_cast<uint32_t>(tableData.getIntField(1, -1)),
static_cast<uint32_t>(tableData.getIntField(2, -1)), static_cast<uint32_t>(tableData.getIntField(2, -1)),

View File

@ -16,6 +16,6 @@ public:
[[nodiscard]] std::string GetName() const override; [[nodiscard]] std::string GetName() const override;
CDPropertyTemplate GetByMapID(uint32_t mapID); CDPropertyTemplate GetByMapID(uint32_t mapID);
private: private:
std::vector<CDPropertyTemplate> entries {}; std::vector<CDPropertyTemplate> entries{};
CDPropertyTemplate defaultEntry {}; CDPropertyTemplate defaultEntry{};
}; };

View File

@ -34,7 +34,7 @@ CDProximityMonitorComponentTable::CDProximityMonitorComponentTable(void) {
} }
//! Destructor //! Destructor
CDProximityMonitorComponentTable::~CDProximityMonitorComponentTable(void) { } CDProximityMonitorComponentTable::~CDProximityMonitorComponentTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDProximityMonitorComponentTable::GetName(void) const { std::string CDProximityMonitorComponentTable::GetName(void) const {

View File

@ -73,7 +73,7 @@ std::vector<CDRailActivatorComponent> CDRailActivatorComponentTable::GetEntries(
return m_Entries; return m_Entries;
} }
std::pair<uint32_t, std::u16string> CDRailActivatorComponentTable::EffectPairFromString(std::string &str) { std::pair<uint32_t, std::u16string> CDRailActivatorComponentTable::EffectPairFromString(std::string& str) {
const auto split = GeneralUtils::SplitString(str, ':'); const auto split = GeneralUtils::SplitString(str, ':');
if (split.size() == 2) { if (split.size() == 2) {
return { std::stoi(split.at(0)), GeneralUtils::ASCIIToUTF16(split.at(1)) }; return { std::stoi(split.at(0)), GeneralUtils::ASCIIToUTF16(split.at(1)) };

View File

@ -29,6 +29,6 @@ public:
[[nodiscard]] CDRailActivatorComponent GetEntryByID(int32_t id) const; [[nodiscard]] CDRailActivatorComponent GetEntryByID(int32_t id) const;
[[nodiscard]] std::vector<CDRailActivatorComponent> GetEntries() const; [[nodiscard]] std::vector<CDRailActivatorComponent> GetEntries() const;
private: private:
static std::pair<uint32_t , std::u16string> EffectPairFromString(std::string& str); static std::pair<uint32_t, std::u16string> EffectPairFromString(std::string& str);
std::vector<CDRailActivatorComponent> m_Entries {}; std::vector<CDRailActivatorComponent> m_Entries{};
}; };

View File

@ -34,7 +34,7 @@ CDRarityTableTable::CDRarityTableTable(void) {
} }
//! Destructor //! Destructor
CDRarityTableTable::~CDRarityTableTable(void) { } CDRarityTableTable::~CDRarityTableTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDRarityTableTable::GetName(void) const { std::string CDRarityTableTable::GetName(void) const {

View File

@ -15,23 +15,19 @@ struct CDRarityTable {
unsigned int rarity; unsigned int rarity;
unsigned int RarityTableIndex; unsigned int RarityTableIndex;
friend bool operator> (const CDRarityTable& c1, const CDRarityTable& c2) friend bool operator> (const CDRarityTable& c1, const CDRarityTable& c2) {
{
return c1.rarity > c2.rarity; return c1.rarity > c2.rarity;
} }
friend bool operator>= (const CDRarityTable& c1, const CDRarityTable& c2) friend bool operator>= (const CDRarityTable& c1, const CDRarityTable& c2) {
{
return c1.rarity >= c2.rarity; return c1.rarity >= c2.rarity;
} }
friend bool operator< (const CDRarityTable& c1, const CDRarityTable& c2) friend bool operator< (const CDRarityTable& c1, const CDRarityTable& c2) {
{
return c1.rarity < c2.rarity; return c1.rarity < c2.rarity;
} }
friend bool operator<= (const CDRarityTable& c1, const CDRarityTable& c2) friend bool operator<= (const CDRarityTable& c1, const CDRarityTable& c2) {
{
return c1.rarity <= c2.rarity; return c1.rarity <= c2.rarity;
} }
}; };

View File

@ -40,7 +40,7 @@ CDRebuildComponentTable::CDRebuildComponentTable(void) {
} }
//! Destructor //! Destructor
CDRebuildComponentTable::~CDRebuildComponentTable(void) { } CDRebuildComponentTable::~CDRebuildComponentTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDRebuildComponentTable::GetName(void) const { std::string CDRebuildComponentTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the RebuildComponent table \brief Contains data for the RebuildComponent table
*/ */
//! RebuildComponent Struct //! RebuildComponent Struct
struct CDRebuildComponent { struct CDRebuildComponent {
unsigned int id; //!< The component Id unsigned int id; //!< The component Id
float reset_time; //!< The reset time float reset_time; //!< The reset time

View File

@ -31,7 +31,7 @@ std::string CDRewardsTable::GetName(void) const {
} }
std::vector<CDRewards*> CDRewardsTable::GetByLevelID(uint32_t levelID) { std::vector<CDRewards*> CDRewardsTable::GetByLevelID(uint32_t levelID) {
std::vector<CDRewards*> result {}; std::vector<CDRewards*> result{};
for (const auto& e : m_entries) { for (const auto& e : m_entries) {
if (e.second->levelID == levelID) result.push_back(e.second); if (e.second->levelID == levelID) result.push_back(e.second);
} }

View File

@ -30,7 +30,7 @@ CDScriptComponentTable::CDScriptComponentTable(void) {
} }
//! Destructor //! Destructor
CDScriptComponentTable::~CDScriptComponentTable(void) { } CDScriptComponentTable::~CDScriptComponentTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDScriptComponentTable::GetName(void) const { std::string CDScriptComponentTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the ScriptComponent table \brief Contains data for the ScriptComponent table
*/ */
//! ScriptComponent Struct //! ScriptComponent Struct
struct CDScriptComponent { struct CDScriptComponent {
unsigned int id; //!< The component ID unsigned int id; //!< The component ID
std::string script_name; //!< The script name std::string script_name; //!< The script name

View File

@ -52,7 +52,7 @@ CDSkillBehaviorTable::CDSkillBehaviorTable(void) {
} }
//! Destructor //! Destructor
CDSkillBehaviorTable::~CDSkillBehaviorTable(void) { } CDSkillBehaviorTable::~CDSkillBehaviorTable(void) {}
//! Returns the table's name //! Returns the table's name
std::string CDSkillBehaviorTable::GetName(void) const { std::string CDSkillBehaviorTable::GetName(void) const {

View File

@ -8,7 +8,7 @@
\brief Contains data for the SkillBehavior table \brief Contains data for the SkillBehavior table
*/ */
//! ZoneTable Struct //! ZoneTable Struct
struct CDSkillBehavior { struct CDSkillBehavior {
unsigned int skillID; //!< The Skill ID of the skill unsigned int skillID; //!< The Skill ID of the skill
UNUSED(unsigned int locStatus); //!< ?? UNUSED(unsigned int locStatus); //!< ??

Some files were not shown because too many files have changed in this diff Show More