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)
break; //Exit our loop, shut down.
}
else framesSinceMasterDisconnect = 0;
} else framesSinceMasterDisconnect = 0;
//In world we'd update our other systems here.
@@ -134,8 +133,7 @@ int main(int argc, char** argv) {
delete stmt;
framesSinceLastSQLPing = 0;
}
else framesSinceLastSQLPing++;
} else framesSinceLastSQLPing++;
//Sleep our thread since auth can afford to.
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;
}
dLogger * SetupLogger() {
dLogger* SetupLogger() {
std::string logPath = "./logs/AuthServer_" + std::to_string(time(nullptr)) + ".log";
bool logToConsole = 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) {
ReadWordlistPlaintext(filepath + ".txt", true);
if (!m_DontGenerateDCF) ExportWordlistToDCF(filepath + ".dcf", true);
}
else if (!ReadWordlistDCF(filepath + ".dcf", true)) {
} else if (!ReadWordlistDCF(filepath + ".dcf", true)) {
ReadWordlistPlaintext(filepath + ".txt", true);
ExportWordlistToDCF(filepath + ".dcf", true);
}
@@ -85,8 +84,7 @@ bool dChatFilter::ReadWordlistDCF(const std::string& filepath, bool whiteList) {
}
return true;
}
else {
} else {
file.close();
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));
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);
//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:
SendFriendUpdate(fr, player, 1, fd.isBestFriend);
}
else {
} else {
fd.isOnline = false;
fd.zoneID = LWOZONEID();
}
@@ -209,8 +208,8 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
updateQuery->executeUpdate();
// Sent the best friend update here if the value is 3
if (bestFriendStatus == 3U) {
requestee->countOfBestFriends+=1;
requestor->countOfBestFriends+=1;
requestee->countOfBestFriends += 1;
requestor->countOfBestFriends += 1;
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);
for (auto& friendData : requestor->friends) {
@@ -371,8 +370,7 @@ void ChatPacketHandler::HandleRemoveFriend(Packet* packet) {
SendRemoveFriend(goonB, goonAName, true);
}
void ChatPacketHandler::HandleChatMessage(Packet* packet)
{
void ChatPacketHandler::HandleChatMessage(Packet* packet) {
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID);
@@ -401,8 +399,7 @@ void ChatPacketHandler::HandleChatMessage(Packet* packet)
if (team == nullptr) return;
for (const auto memberId : team->memberIDs)
{
for (const auto memberId : team->memberIDs) {
auto* otherMember = playerContainer.GetPlayerData(memberId);
if (otherMember == nullptr) return;
@@ -493,8 +490,7 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) {
}
}
void ChatPacketHandler::HandleTeamInvite(Packet* packet)
{
void ChatPacketHandler::HandleTeamInvite(Packet* packet) {
CINSTREAM;
LWOOBJID playerID;
inStream.Read(playerID);
@@ -503,27 +499,23 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet)
auto* player = playerContainer.GetPlayerData(playerID);
if (player == nullptr)
{
if (player == nullptr) {
return;
}
auto* team = playerContainer.GetTeam(playerID);
if (team == nullptr)
{
if (team == nullptr) {
team = playerContainer.CreateTeam(playerID);
}
auto* other = playerContainer.GetPlayerData(invitedPlayer);
if (other == nullptr)
{
if (other == nullptr) {
return;
}
if (playerContainer.GetTeam(other->playerID) != nullptr)
{
if (playerContainer.GetTeam(other->playerID) != nullptr) {
return;
}
@@ -539,8 +531,7 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet)
Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s", playerID, invitedPlayer.c_str());
}
void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet)
{
void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet) {
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID);
@@ -554,22 +545,19 @@ void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet)
Game::logger->Log("ChatPacketHandler", "Accepted invite: %llu -> %llu (%d)", playerID, leaderID, declined);
if (declined)
{
if (declined) {
return;
}
auto* team = playerContainer.GetTeam(leaderID);
if (team == nullptr)
{
if (team == nullptr) {
Game::logger->Log("ChatPacketHandler", "Failed to find team for leader (%llu)", leaderID);
team = playerContainer.GetTeam(playerID);
}
if (team == nullptr)
{
if (team == nullptr) {
Game::logger->Log("ChatPacketHandler", "Failed to find team for player (%llu)", playerID);
return;
}
@@ -577,8 +565,7 @@ void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet)
playerContainer.AddMember(team, playerID);
}
void ChatPacketHandler::HandleTeamLeave(Packet* packet)
{
void ChatPacketHandler::HandleTeamLeave(Packet* packet) {
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID);
@@ -590,14 +577,12 @@ void ChatPacketHandler::HandleTeamLeave(Packet* packet)
Game::logger->Log("ChatPacketHandler", "(%llu) leaving team", playerID);
if (team != nullptr)
{
if (team != nullptr) {
playerContainer.RemoveMember(team, playerID, false, false, true);
}
}
void ChatPacketHandler::HandleTeamKick(Packet* packet)
{
void ChatPacketHandler::HandleTeamKick(Packet* packet) {
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID);
@@ -611,12 +596,9 @@ void ChatPacketHandler::HandleTeamKick(Packet* packet)
LWOOBJID kickedId = LWOOBJID_EMPTY;
if (kicked != nullptr)
{
if (kicked != nullptr) {
kickedId = kicked->playerID;
}
else
{
} else {
kickedId = playerContainer.GetId(GeneralUtils::ASCIIToUTF16(kickedPlayer));
}
@@ -624,16 +606,14 @@ void ChatPacketHandler::HandleTeamKick(Packet* packet)
auto* team = playerContainer.GetTeam(playerID);
if (team != nullptr)
{
if (team != nullptr) {
if (team->leaderID != playerID || team->leaderID == kickedId) return;
playerContainer.RemoveMember(team, kickedId, false, true, false);
}
}
void ChatPacketHandler::HandleTeamPromote(Packet* packet)
{
void ChatPacketHandler::HandleTeamPromote(Packet* packet) {
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID);
@@ -649,16 +629,14 @@ void ChatPacketHandler::HandleTeamPromote(Packet* packet)
auto* team = playerContainer.GetTeam(playerID);
if (team != nullptr)
{
if (team != nullptr) {
if (team->leaderID != playerID) return;
playerContainer.PromoteMember(team, promoted->playerID);
}
}
void ChatPacketHandler::HandleTeamLootOption(Packet* packet)
{
void ChatPacketHandler::HandleTeamLootOption(Packet* packet) {
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID);
@@ -671,8 +649,7 @@ void ChatPacketHandler::HandleTeamLootOption(Packet* packet)
auto* team = playerContainer.GetTeam(playerID);
if (team != nullptr)
{
if (team != nullptr) {
if (team->leaderID != playerID) return;
team->lootFlag = option;
@@ -683,8 +660,7 @@ void ChatPacketHandler::HandleTeamLootOption(Packet* packet)
}
}
void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet)
{
void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet) {
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID);
@@ -693,28 +669,22 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet)
auto* team = playerContainer.GetTeam(playerID);
auto* data = playerContainer.GetPlayerData(playerID);
if (team != nullptr && data != nullptr)
{
if (team->local && data->zoneID.GetMapID() != team->zoneId.GetMapID() && data->zoneID.GetCloneID() != team->zoneId.GetCloneID())
{
if (team != nullptr && data != nullptr) {
if (team->local && data->zoneID.GetMapID() != team->zoneId.GetMapID() && data->zoneID.GetCloneID() != team->zoneId.GetCloneID()) {
playerContainer.RemoveMember(team, playerID, false, false, true, true);
return;
}
if (team->memberIDs.size() <= 1 && !team->local)
{
if (team->memberIDs.size() <= 1 && !team->local) {
playerContainer.DisbandTeam(team);
return;
}
if (!team->local)
{
if (!team->local) {
ChatPacketHandler::SendTeamSetLeader(data, team->leaderID);
}
else
{
} else {
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()));
for (const auto memberId : team->memberIDs)
{
for (const auto memberId : team->memberIDs) {
auto* otherMember = playerContainer.GetPlayerData(memberId);
if (memberId == playerID) continue;
const auto memberName = playerContainer.GetName(memberId);
if (otherMember != nullptr)
{
if (otherMember != nullptr) {
ChatPacketHandler::SendTeamSetOffWorldFlag(otherMember, data->playerID, data->zoneID);
}
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;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID);
@@ -757,8 +724,7 @@ void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender)
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;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID);
@@ -777,8 +743,7 @@ void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeader
bitStream.Write(ucNumOfOtherPlayers);
bitStream.Write(ucResponseCode);
bitStream.Write(static_cast<uint32_t>(wsLeaderName.size()));
for (const auto character : wsLeaderName)
{
for (const auto character : wsLeaderName) {
bitStream.Write(character);
}
@@ -786,8 +751,7 @@ void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeader
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;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID);
@@ -804,8 +768,7 @@ void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderI
bitStream.Write(ucLootFlag);
bitStream.Write(ucNumOfOtherPlayers);
bitStream.Write(static_cast<uint32_t>(wsLeaderName.size()));
for (const auto character : wsLeaderName)
{
for (const auto character : wsLeaderName) {
bitStream.Write(character);
}
@@ -813,8 +776,7 @@ void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderI
SEND_PACKET;
}
void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64PlayerID)
{
void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64PlayerID) {
CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID);
@@ -831,8 +793,7 @@ void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64Play
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;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID);
@@ -848,13 +809,11 @@ void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTria
bitStream.Write(bNoLootOnDeath);
bitStream.Write(i64PlayerID);
bitStream.Write(static_cast<uint32_t>(wsPlayerName.size()));
for (const auto character : wsPlayerName)
{
for (const auto character : wsPlayerName) {
bitStream.Write(character);
}
bitStream.Write1();
if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID())
{
if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID()) {
zoneID = LWOZONEID(zoneID.GetMapID(), zoneID.GetInstanceID(), 0);
}
bitStream.Write(zoneID);
@@ -863,8 +822,7 @@ void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTria
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;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
bitStream.Write(receiver->playerID);
@@ -882,8 +840,7 @@ void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband
bitStream.Write(i64LeaderID);
bitStream.Write(i64PlayerID);
bitStream.Write(static_cast<uint32_t>(wsPlayerName.size()));
for (const auto character : wsPlayerName)
{
for (const auto character : wsPlayerName) {
bitStream.Write(character);
}
@@ -891,8 +848,7 @@ void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband
SEND_PACKET;
}
void ChatPacketHandler::SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID)
{
void ChatPacketHandler::SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID) {
CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
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(i64PlayerID);
if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID())
{
if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID()) {
zoneID = LWOZONEID(zoneID.GetMapID(), zoneID.GetInstanceID(), 0);
}
bitStream.Write(zoneID);
@@ -943,12 +898,9 @@ void ChatPacketHandler::SendFriendUpdate(PlayerData* friendData, PlayerData* pla
bitStream.Write(playerData->zoneID.GetMapID());
bitStream.Write(playerData->zoneID.GetInstanceID());
if (playerData->zoneID.GetCloneID() == friendData->zoneID.GetCloneID())
{
if (playerData->zoneID.GetCloneID() == friendData->zoneID.GetCloneID()) {
bitStream.Write(0);
}
else
{
} else {
bitStream.Write(playerData->zoneID.GetCloneID());
}

View File

@@ -58,8 +58,7 @@ int main(int argc, char** argv) {
try {
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());
Database::Destroy("ChatServer");
delete Game::server;
@@ -104,8 +103,7 @@ int main(int argc, char** argv) {
if (framesSinceMasterDisconnect >= 30)
break; //Exit our loop, shut down.
}
else framesSinceMasterDisconnect = 0;
} else framesSinceMasterDisconnect = 0;
//In world we'd update our other systems here.
@@ -122,8 +120,7 @@ int main(int argc, char** argv) {
if (framesSinceLastFlush >= 900) {
Game::logger->Flush();
framesSinceLastFlush = 0;
}
else framesSinceLastFlush++;
} else framesSinceLastFlush++;
//Every 10 min we ping our sql server to keep it alive hopefully:
if (framesSinceLastSQLPing >= 40000) {
@@ -141,8 +138,7 @@ int main(int argc, char** argv) {
delete stmt;
framesSinceLastSQLPing = 0;
}
else framesSinceLastSQLPing++;
} else framesSinceLastSQLPing++;
//Sleep our thread since auth can afford to.
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;
}
dLogger * SetupLogger() {
dLogger* SetupLogger() {
std::string logPath = "./logs/ChatServer_" + std::to_string(time(nullptr)) + ".log";
bool logToConsole = false;
bool logDebugStatements = false;

View File

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

View File

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

View File

@@ -7,7 +7,7 @@
class AMFValue;
class AMFDeserialize {
public:
public:
/**
* 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.
*/
AMFValue* Read(RakNet::BitStream* inStream);
private:
private:
/**
* @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) {
this->Write(AMFDouble);
double d = value.GetDoubleValue();
WriteAMFU64(this, *((unsigned long long*)&d));
WriteAMFU64(this, *((unsigned long long*) & d));
}
// Writes an AMFStringValue to BitStream

View File

@@ -11,7 +11,7 @@
\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 {
//! 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
std::string BinaryIO::ReadString(std::ifstream & instream) {
std::string BinaryIO::ReadString(std::ifstream& instream) {
std::string toReturn;
char buffer;
@@ -37,7 +37,7 @@ std::string BinaryIO::ReadString(std::ifstream& instream, size_t size) {
return toReturn;
}
std::string BinaryIO::ReadWString(std::ifstream & instream) {
std::string BinaryIO::ReadWString(std::ifstream& instream) {
size_t size;
BinaryRead(instream, size);
//toReturn.resize(size);

View File

@@ -9,7 +9,7 @@ namespace BinaryIO {
}
template<typename T>
std::istream & BinaryRead(std::istream& stream, T& value) {
std::istream& BinaryRead(std::istream& stream, T& value) {
if (!stream.good())
printf("bla");
@@ -17,7 +17,7 @@ namespace BinaryIO {
}
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 ReadWString(std::ifstream& instream);

View File

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

View File

@@ -50,7 +50,7 @@ bool _IsSuffixChar(uint8_t c) {
bool GeneralUtils::_NextUTF8Char(std::string_view& slice, uint32_t& out) {
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) {
uint8_t first = bytes[0];
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) {
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
@@ -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) {
size_t start_pos = str.find(from);
if(start_pos == std::string::npos)
if (start_pos == std::string::npos)
return false;
str.replace(start_pos, from.length(), to);
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::wstring current;
@@ -239,8 +238,7 @@ std::vector<std::wstring> GeneralUtils::SplitString(std::wstring& str, wchar_t d
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::u16string current;
@@ -257,22 +255,17 @@ std::vector<std::u16string> GeneralUtils::SplitString(std::u16string& str, char1
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::string current = "";
for (size_t i = 0; i < str.length(); i++)
{
for (size_t i = 0; i < str.length(); i++) {
char c = str[i];
if (c == delimiter)
{
if (c == delimiter) {
vector.push_back(current);
current = "";
}
else
{
} else {
current += c;
}
}
@@ -282,7 +275,7 @@ std::vector<std::string> GeneralUtils::SplitString(const std::string& str, char
return vector;
}
std::u16string GeneralUtils::ReadWString(RakNet::BitStream *inStream) {
std::u16string GeneralUtils::ReadWString(RakNet::BitStream* inStream) {
uint32_t length;
inStream->Read<uint32_t>(length);
@@ -300,8 +293,7 @@ std::u16string GeneralUtils::ReadWString(RakNet::BitStream *inStream) {
#define WIN32_LEAN_AND_MEAN
#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::string search_path = folder + "/*.*";
WIN32_FIND_DATA fd;

View File

@@ -18,7 +18,7 @@
\brief A namespace containing general utility functions
*/
//! The general utils namespace
//! The general utils namespace
namespace GeneralUtils {
//! 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
std::uniform_int_distribution<T> distribution(min, max);
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);
return distribution(Game::randomEngine);
}
@@ -131,7 +130,7 @@ namespace GeneralUtils {
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);
@@ -145,78 +144,64 @@ namespace GeneralUtils {
T Parse(const char* value);
template <>
inline int32_t Parse(const char* value)
{
inline int32_t Parse(const char* value) {
return std::stoi(value);
}
template <>
inline int64_t Parse(const char* value)
{
inline int64_t Parse(const char* value) {
return std::stoll(value);
}
template <>
inline float Parse(const char* value)
{
inline float Parse(const char* value) {
return std::stof(value);
}
template <>
inline double Parse(const char* value)
{
inline double Parse(const char* value) {
return std::stod(value);
}
template <>
inline uint32_t Parse(const char* value)
{
inline uint32_t Parse(const char* value) {
return std::stoul(value);
}
template <>
inline uint64_t Parse(const char* value)
{
inline uint64_t Parse(const char* value) {
return std::stoull(value);
}
template <typename T>
bool TryParse(const char* value, T& dst)
{
try
{
bool TryParse(const char* value, T& dst) {
try {
dst = Parse<T>(value);
return true;
}
catch (...)
{
} catch (...) {
return false;
}
}
template <typename T>
T Parse(const std::string& value)
{
T Parse(const std::string& value) {
return Parse<T>(value.c_str());
}
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);
}
template<typename T>
std::u16string to_u16string(T value)
{
std::u16string to_u16string(T value) {
return GeneralUtils::ASCIIToUTF16(std::to_string(value));
}
// From boost::hash_combine
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;
s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2);
}

View File

@@ -8,7 +8,7 @@
#include <vector>
//! 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
std::istringstream ssFormat(format);
@@ -72,16 +72,11 @@ LDFBaseData * LDFBaseData::DataFromString(const std::string& format) {
{
uint32_t data;
if (dataArray[1] == "true")
{
if (dataArray[1] == "true") {
data = 1;
}
else if (dataArray[1] == "false")
{
} else if (dataArray[1] == "false") {
data = 0;
}
else
{
} else {
data = static_cast<uint32_t>(stoul(dataArray[1]));
}
@@ -91,16 +86,11 @@ LDFBaseData * LDFBaseData::DataFromString(const std::string& format) {
case LDF_TYPE_BOOLEAN: {
bool data;
if (dataArray[1] == "true")
{
if (dataArray[1] == "true") {
data = true;
}
else if (dataArray[1] == "false")
{
} else if (dataArray[1] == "false") {
data = false;
}
else
{
} else {
data = static_cast<bool>(stoi(dataArray[1]));
}

View File

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

View File

@@ -30,7 +30,7 @@
*/
/* interface header */
/* interface header */
#include "MD5.h"
/* system implementation headers */
@@ -59,15 +59,15 @@
// F, G, H and I are basic MD5 functions.
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) {
return x&z | y&~z;
return x & z | y & ~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) {
@@ -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.
// 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;
}
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;
}
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;
}
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;
}
//////////////////////////////////////////////
// default ctor, just initailize
MD5::MD5()
{
MD5::MD5() {
init();
}
//////////////////////////////////////////////
// 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();
update(text.c_str(), text.length());
finalize();
@@ -117,8 +115,7 @@ MD5::MD5(const std::string &text)
//////////////////////////////
void MD5::init()
{
void MD5::init() {
finalized = false;
count[0] = 0;
@@ -134,8 +131,7 @@ void MD5::init()
//////////////////////////////
// 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)
output[i] = ((uint4)input[j]) | (((uint4)input[j + 1]) << 8) |
(((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
// 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) {
output[j] = input[i] & 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
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];
decode(x, block, blocksize);
@@ -248,8 +242,7 @@ void MD5::transform(const uint1 block[blocksize])
// MD5 block update operation. Continues an MD5 message-digest
// 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
size_type index = count[0] / 8 % blocksize;
@@ -264,8 +257,7 @@ void MD5::update(const unsigned char input[], size_type length)
size_type i;
// transform as many times as possible.
if (length >= firstpart)
{
if (length >= firstpart) {
// fill buffer first, transform
memcpy(&buffer[index], input, firstpart);
transform(buffer);
@@ -275,8 +267,7 @@ void MD5::update(const unsigned char input[], size_type length)
transform(&input[i]);
index = 0;
}
else
} else
i = 0;
// 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
void MD5::update(const char input[], size_type length)
{
void MD5::update(const char input[], size_type 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
// the message digest and zeroizing the context.
MD5& MD5::finalize()
{
MD5& MD5::finalize() {
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,
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
std::string MD5::hexdigest() const
{
std::string MD5::hexdigest() const {
if (!finalized)
return "";
char buf[33];
for (int i = 0; i<16; i++)
for (int i = 0; i < 16; i++)
sprintf(buf + i * 2, "%02x", digest[i]);
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();
}
//////////////////////////////
std::string md5(const std::string str)
{
std::string md5(const std::string str) {
MD5 md5 = MD5(str);
return md5.hexdigest();

View File

@@ -37,16 +37,16 @@
#include <iostream>
// a small class for calculating MD5 hashes of strings or byte arrays
// it is not meant to be fast or secure
//
// usage: 1) feed it blocks of uchars with update()
// 2) finalize()
// 3) get hexdigest() string
// or
// MD5(std::string).hexdigest()
//
// assumes that char is 8 bit and int is 32 bit
// a small class for calculating MD5 hashes of strings or byte arrays
// it is not meant to be fast or secure
//
// usage: 1) feed it blocks of uchars with update()
// 2) finalize()
// 3) get hexdigest() string
// or
// MD5(std::string).hexdigest()
//
// assumes that char is 8 bit and int is 32 bit
class MD5
{
public:
@@ -54,8 +54,8 @@ public:
MD5();
MD5(const std::string& text);
void update(const unsigned char *buf, size_type length);
void update(const char *buf, size_type length);
void update(const unsigned char* buf, size_type length);
void update(const char* buf, size_type length);
MD5& finalize();
std::string hexdigest() const;
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 I(uint4 x, uint4 y, uint4 z);
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 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 II(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 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);
};
std::string md5(const std::string str);

View File

@@ -16,55 +16,44 @@ std::vector<MetricVariable> Metrics::m_Variables = {
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);
Metric* metric;
if (iter == m_Metrics.end())
{
if (iter == m_Metrics.end()) {
metric = new Metric();
m_Metrics[variable] = metric;
}
else
{
} else {
metric = iter->second;
}
AddMeasurement(metric, value);
}
void Metrics::AddMeasurement(Metric* metric, int64_t value)
{
void Metrics::AddMeasurement(Metric* metric, int64_t value) {
const auto index = metric->measurementIndex;
metric->measurements[index] = value;
if (metric->max == -1 || value > metric->max)
{
if (metric->max == -1 || value > metric->max) {
metric->max = value;
}
else if (metric->min == -1 || metric->min > value)
{
} else if (metric->min == -1 || metric->min > value) {
metric->min = value;
}
if (metric->measurementSize < MAX_MEASURMENT_POINTS)
{
if (metric->measurementSize < MAX_MEASURMENT_POINTS) {
metric->measurementSize++;
}
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);
if (iter == m_Metrics.end())
{
if (iter == m_Metrics.end()) {
return nullptr;
}
@@ -72,8 +61,7 @@ const Metric* Metrics::GetMetric(MetricVariable variable)
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];
}
@@ -84,34 +72,28 @@ const Metric* Metrics::GetMetric(MetricVariable variable)
return metric;
}
void Metrics::StartMeasurement(MetricVariable variable)
{
void Metrics::StartMeasurement(MetricVariable variable) {
const auto& iter = m_Metrics.find(variable);
Metric* metric;
if (iter == m_Metrics.end())
{
if (iter == m_Metrics.end()) {
metric = new Metric();
m_Metrics[variable] = metric;
}
else
{
} else {
metric = iter->second;
}
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& iter = m_Metrics.find(variable);
if (iter == m_Metrics.end())
{
if (iter == m_Metrics.end()) {
return;
}
@@ -124,15 +106,12 @@ void Metrics::EndMeasurement(MetricVariable variable)
AddMeasurement(metric, nanoseconds);
}
float Metrics::ToMiliseconds(int64_t nanoseconds)
{
return (float) nanoseconds / 1e6;
float Metrics::ToMiliseconds(int64_t nanoseconds) {
return (float)nanoseconds / 1e6;
}
std::string Metrics::MetricVariableToString(MetricVariable variable)
{
switch (variable)
{
std::string Metrics::MetricVariableToString(MetricVariable variable) {
switch (variable) {
case MetricVariable::GameLoop:
return "GameLoop";
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;
}
void Metrics::Clear()
{
for (const auto& pair : m_Metrics)
{
void Metrics::Clear() {
for (const auto& pair : m_Metrics) {
delete pair.second;
}
@@ -207,37 +183,35 @@ void Metrics::Clear()
#error "Cannot define getPeakRSS( ) or getCurrentRSS( ) for an unknown OS."
#endif
/**
/**
* Returns the peak (maximum so far) resident set size (physical
* memory use) measured in bytes, or zero if the value cannot be
* determined on this OS.
*/
size_t Metrics::GetPeakRSS()
{
size_t Metrics::GetPeakRSS() {
#if defined(_WIN32)
/* Windows -------------------------------------------------- */
PROCESS_MEMORY_COUNTERS info;
GetProcessMemoryInfo( GetCurrentProcess( ), &info, sizeof(info) );
GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info));
return (size_t)info.PeakWorkingSetSize;
#elif (defined(_AIX) || defined(__TOS__AIX__)) || (defined(__sun__) || defined(__sun) || defined(sun) && (defined(__SVR4) || defined(__svr4__)))
/* AIX and Solaris ------------------------------------------ */
struct psinfo psinfo;
int fd = -1;
if ( (fd = open( "/proc/self/psinfo", O_RDONLY )) == -1 )
if ((fd = open("/proc/self/psinfo", O_RDONLY)) == -1)
return (size_t)0L; /* Can't open? */
if ( read( fd, &psinfo, sizeof(psinfo) ) != sizeof(psinfo) )
{
close( fd );
if (read(fd, &psinfo, sizeof(psinfo)) != sizeof(psinfo)) {
close(fd);
return (size_t)0L; /* Can't read? */
}
close( fd );
close(fd);
return (size_t)(psinfo.pr_rssize * 1024L);
#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__))
/* BSD, Linux, and OSX -------------------------------------- */
struct rusage rusage;
getrusage( RUSAGE_SELF, &rusage );
getrusage(RUSAGE_SELF, &rusage);
#if defined(__APPLE__) && defined(__MACH__)
return (size_t)rusage.ru_maxrss;
#else
@@ -255,20 +229,19 @@ size_t Metrics::GetPeakRSS()
* Returns the current resident set size (physical memory use) measured
* in bytes, or zero if the value cannot be determined on this OS.
*/
size_t Metrics::GetCurrentRSS()
{
size_t Metrics::GetCurrentRSS() {
#if defined(_WIN32)
/* Windows -------------------------------------------------- */
PROCESS_MEMORY_COUNTERS info;
GetProcessMemoryInfo( GetCurrentProcess( ), &info, sizeof(info) );
GetProcessMemoryInfo(GetCurrentProcess(), &info, sizeof(info));
return (size_t)info.WorkingSetSize;
#elif defined(__APPLE__) && defined(__MACH__)
/* OSX ------------------------------------------------------ */
struct mach_task_basic_info info;
mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
if ( task_info( mach_task_self( ), MACH_TASK_BASIC_INFO,
(task_info_t)&info, &infoCount ) != KERN_SUCCESS )
if (task_info(mach_task_self(), MACH_TASK_BASIC_INFO,
(task_info_t)&info, &infoCount) != KERN_SUCCESS)
return (size_t)0L; /* Can't access? */
return (size_t)info.resident_size;
@@ -276,15 +249,14 @@ size_t Metrics::GetCurrentRSS()
/* Linux ---------------------------------------------------- */
long rss = 0L;
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? */
if ( fscanf( fp, "%*s%ld", &rss ) != 1 )
{
fclose( fp );
if (fscanf(fp, "%*s%ld", &rss) != 1) {
fclose(fp);
return (size_t)0L; /* Can't read? */
}
fclose( fp );
return (size_t)rss * (size_t)sysconf( _SC_PAGESIZE);
fclose(fp);
return (size_t)rss * (size_t)sysconf(_SC_PAGESIZE);
#else
/* 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)
return GetCurrentProcessId();
#else

View File

@@ -71,12 +71,12 @@ void NiPoint3::SetZ(float z) {
//! Gets the length of the vector
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
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
@@ -113,13 +113,13 @@ bool NiPoint3::operator!=(const NiPoint3& point) const {
//! Operator for subscripting
float& NiPoint3::operator[](int i) {
float * base = &x;
float* base = &x;
return (float&)base[i];
}
//! Operator for subscripting
const float& NiPoint3::operator[](int i) const {
const float * base = &x;
const float* base = &x;
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 > 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
@@ -175,8 +175,7 @@ bool NiPoint3::IsWithinSpehere(const NiPoint3& sphereCenter, float 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;
const auto pa = p - a;
@@ -191,16 +190,14 @@ NiPoint3 NiPoint3::ClosestPointOnLine(const NiPoint3& a, const NiPoint3& b, cons
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 lenA = a.SquaredLength();
const auto lenB = a.SquaredLength();
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 dy = a.y - b.y;
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);
}
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 dy = a.y - b.y;
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;
}
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 dy = target.y - current.y;
float dz = target.z - current.z;
float lengthSquared = (float) ((double) dx * (double) dx + (double) dy * (double) dy + (double) dz * (double) dz);
if ((double) lengthSquared == 0.0 || (double) maxDistanceDelta >= 0.0 && (double) lengthSquared <= (double) maxDistanceDelta * (double) maxDistanceDelta)
float lengthSquared = (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)
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);
}

View File

@@ -99,8 +99,7 @@ Vector3 NiQuaternion::GetEulerAngles() const {
if (std::abs(sinp) >= 1) {
angles.y = std::copysign(3.14 / 2, sinp); // use 90 degrees if out of range
}
else {
} else {
angles.y = std::asin(sinp);
}
@@ -149,8 +148,7 @@ NiQuaternion NiQuaternion::LookAt(const NiPoint3& sourcePoint, const NiPoint3& d
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 posZ = NiPoint3::UNIT_Z;
@@ -179,8 +177,7 @@ NiQuaternion NiQuaternion::CreateFromAxisAngle(const Vector3& axis, float angle)
return q;
}
NiQuaternion NiQuaternion::FromEulerAngles(const NiPoint3& eulerAngles)
{
NiQuaternion NiQuaternion::FromEulerAngles(const NiPoint3& eulerAngles) {
// Abbreviations for the various angular functions
float cy = cos(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,
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 wv[8];
uint64 t1, t2;
const unsigned char *sub_block;
const unsigned char* sub_block;
int i, j;
for (i = 0; i < (int)block_nb; i++) {
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[1] = 0xbb67ae8584caa73bULL;
m_h[2] = 0x3c6ef372fe94f82bULL;
@@ -97,11 +95,10 @@ void SHA512::init()
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 new_len, rem_len, tmp_len;
const unsigned char *shifted_message;
const unsigned char* shifted_message;
tmp_len = SHA384_512_BLOCK_SIZE - m_len;
rem_len = len < tmp_len ? len : tmp_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;
}
void SHA512::final(unsigned char *digest)
{
void SHA512::final(unsigned char* digest) {
unsigned int block_nb;
unsigned int pm_len;
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];
memset(digest, 0, SHA512::DIGEST_SIZE);
class SHA512 ctx;

View File

@@ -14,12 +14,12 @@ protected:
public:
void init();
void update(const unsigned char *message, unsigned int len);
void final(unsigned char *digest);
void update(const unsigned char* message, unsigned int len);
void final(unsigned char* digest);
static const unsigned int DIGEST_SIZE = (512 / 8);
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_len;
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
// 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),
std::free
};
return (status==0) ? res.get() : name ;
return (status == 0) ? res.get() : name;
}
#else

View File

@@ -4,16 +4,13 @@
#include <zlib.h>
namespace ZCompression
{
int32_t GetMaxCompressedLength(int32_t nLenSrc)
{
namespace ZCompression {
int32_t GetMaxCompressedLength(int32_t nLenSrc) {
int32_t n16kBlocks = (nLenSrc + 16383) / 16384; // round up any fraction of a block
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 };
zInfo.total_in = zInfo.avail_in = nLenSrc;
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
z_stream zInfo = { 0 };
zInfo.total_in = zInfo.avail_in = nLenSrc;

View File

@@ -6,8 +6,7 @@
#ifndef DARKFLAME_PLATFORM_WIN32
namespace ZCompression
{
namespace ZCompression {
int32_t GetMaxCompressedLength(int32_t nLenSrc);
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,
MODULAR_BUILD_PLAYER_PLACES_FIRST_MODEL_IN_SCRATCH = 53,
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_2 = 57,
GF_PET_DIG_FLAG_3 = 58,

View File

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

View File

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

View File

@@ -1,29 +1,29 @@
#pragma once
#if defined(_WIN32)
#define DARKFLAME_PLATFORM_WIN32
#define DARKFLAME_PLATFORM_WIN32
#elif defined(__APPLE__) && defined(__MACH__)
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#define DARKFLAME_PLATFORM_IOS
#elif TARGET_OS_MAC
#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
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#define DARKFLAME_PLATFORM_IOS
#elif TARGET_OS_MAC
#define DARKFLAME_PLATFORM_MACOS
#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

View File

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

View File

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

View File

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

View File

@@ -52,17 +52,17 @@
\brief A manager for the CDClient tables
*/
//! Manages all data from the CDClient
//! Manages all data from the CDClient
class CDClientManager {
private:
static CDClientManager * m_Address; //!< The singleton address
static CDClientManager* m_Address; //!< The singleton address
std::unordered_map<std::string, CDTable*> tables; //!< The tables
public:
//! The singleton method
static CDClientManager * Instance() {
static CDClientManager* Instance() {
if (m_Address == 0) {
m_Address = new CDClientManager;
}
@@ -82,7 +82,7 @@ public:
\return The class or nullptr
*/
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!");
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
sql::Driver * Database::driver;
sql::Connection * Database::con;
sql::Driver* Database::driver;
sql::Connection* Database::con;
sql::Properties Database::props;
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");
}
if (!con->isValid() || con->isClosed())
{
if (!con->isValid() || con->isClosed()) {
delete con;
con = nullptr;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -31,15 +31,14 @@ CDBehaviorParameterTable::CDBehaviorParameterTable(void) {
}
//! Destructor
CDBehaviorParameterTable::~CDBehaviorParameterTable(void) { }
CDBehaviorParameterTable::~CDBehaviorParameterTable(void) {}
//! Returns the table's name
std::string CDBehaviorParameterTable::GetName(void) const {
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;
returnValue.behaviorID = 0;
returnValue.parameterID = m_ParametersList.end();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -73,7 +73,7 @@ std::vector<CDRailActivatorComponent> CDRailActivatorComponentTable::GetEntries(
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, ':');
if (split.size() == 2) {
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]] std::vector<CDRailActivatorComponent> GetEntries() const;
private:
static std::pair<uint32_t , std::u16string> EffectPairFromString(std::string& str);
std::vector<CDRailActivatorComponent> m_Entries {};
static std::pair<uint32_t, std::u16string> EffectPairFromString(std::string& str);
std::vector<CDRailActivatorComponent> m_Entries{};
};

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,7 @@
\brief Contains data for the RebuildComponent table
*/
//! RebuildComponent Struct
//! RebuildComponent Struct
struct CDRebuildComponent {
unsigned int id; //!< The component Id
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*> result {};
std::vector<CDRewards*> result{};
for (const auto& e : m_entries) {
if (e.second->levelID == levelID) result.push_back(e.second);
}

View File

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

View File

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

View File

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

View File

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

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