Make logger automatically put a newline (#675)

at the end of the line
remove all the newlines in log calls
This commit is contained in:
Aaron Kimbrell 2022-07-24 21:26:51 -05:00 committed by GitHub
parent a7fb6eb3f3
commit e97ae92624
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
86 changed files with 1249 additions and 1252 deletions

View File

@ -37,9 +37,9 @@ int main(int argc, char** argv) {
//Create all the objects we need to run our service:
Game::logger = SetupLogger();
if (!Game::logger) return 0;
Game::logger->Log("AuthServer", "Starting Auth server...\n");
Game::logger->Log("AuthServer", "Version: %i.%i\n", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR);
Game::logger->Log("AuthServer", "Compiled on: %s\n", __TIMESTAMP__);
Game::logger->Log("AuthServer", "Starting Auth server...");
Game::logger->Log("AuthServer", "Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR);
Game::logger->Log("AuthServer", "Compiled on: %s", __TIMESTAMP__);
//Read our config:
dConfig config("authconfig.ini");
@ -56,7 +56,7 @@ int main(int argc, char** argv) {
try {
Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password);
} catch (sql::SQLException& ex) {
Game::logger->Log("AuthServer", "Got an error while connecting to the database: %s\n", ex.what());
Game::logger->Log("AuthServer", "Got an error while connecting to the database: %s", ex.what());
Database::Destroy("AuthServer");
delete Game::server;
delete Game::logger;
@ -78,10 +78,10 @@ int main(int argc, char** argv) {
//It's safe to pass 'localhost' here, as the IP is only used as the external IP.
int maxClients = 50;
int ourPort = 1001; //LU client is hardcoded to use this for auth port, so I'm making it the default.
int ourPort = 1001; //LU client is hardcoded to use this for auth port, so I'm making it the default.
if (config.GetValue("max_clients") != "") maxClients = std::stoi(config.GetValue("max_clients"));
if (config.GetValue("port") != "") ourPort = std::atoi(config.GetValue("port").c_str());
Game::server = new dServer(config.GetValue("external_ip"), ourPort, 0, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::Auth);
//Run it until server gets a kill message from Master:

View File

@ -79,7 +79,7 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
bitStream.Write<uint8_t>(0);
bitStream.Write<uint16_t>(1); //Length of packet -- just writing one as it doesn't matter, client skips it.
bitStream.Write((uint16_t)friends.size());
for (auto& data : friends) {
data.Serialize(bitStream);
}
@ -139,7 +139,7 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
}
}
// If at this point we dont have a target, then they arent online and we cant send the request.
// If at this point we dont have a target, then they arent online and we cant send the request.
// Send the response code that corresponds to what the error is.
if (!requestee) {
std::unique_ptr<sql::PreparedStatement> nameQuery(Database::CreatePreppedStmt("SELECT name from charinfo where name = ?;"));
@ -232,7 +232,7 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
// Do not send this if we are requesting to be a best friend.
SendFriendRequest(requestee.get(), requestor);
}
// If the player is actually a player and not a ghost one defined above, release it from being deleted.
if (requestee->sysAddr != UNASSIGNED_SYSTEM_ADDRESS) requestee.release();
}
@ -301,7 +301,7 @@ void ChatPacketHandler::HandleFriendResponse(Packet* packet) {
requesteeData.isFTP = false;
requesteeData.isOnline = true;
requestor->friends.push_back(requesteeData);
std::unique_ptr<sql::PreparedStatement> statement(Database::CreatePreppedStmt("INSERT IGNORE INTO `friends` (`player_id`, `friend_id`, `best_friend`) VALUES (?,?,?);"));
statement->setUInt(1, static_cast<uint32_t>(requestor->playerID));
statement->setUInt(2, static_cast<uint32_t>(requestee->playerID));
@ -371,7 +371,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;
@ -390,10 +390,10 @@ void ChatPacketHandler::HandleChatMessage(Packet* packet)
uint8_t channel = 0;
inStream.Read(channel);
std::string message = PacketUtils::ReadString(0x66, packet, true);
Game::logger->Log("ChatPacketHandler", "Got a message from (%s) [%d]: %s\n", senderName.c_str(), channel, message.c_str());
Game::logger->Log("ChatPacketHandler", "Got a message from (%s) [%d]: %s", senderName.c_str(), channel, message.c_str());
if (channel != 8) return;
@ -530,16 +530,16 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet)
if (team->memberIDs.size() > 3) {
// no more teams greater than 4
Game::logger->Log("ChatPacketHandler", "Someone tried to invite a 5th player to a team\n");
Game::logger->Log("ChatPacketHandler", "Someone tried to invite a 5th player to a team");
return;
}
SendTeamInvite(other, player);
Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s\n", playerID, invitedPlayer.c_str());
Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s", playerID, invitedPlayer.c_str());
}
void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet)
void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet)
{
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
@ -552,7 +552,7 @@ void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet)
LWOOBJID leaderID = LWOOBJID_EMPTY;
inStream.Read(leaderID);
Game::logger->Log("ChatPacketHandler", "Accepted invite: %llu -> %llu (%d)\n", playerID, leaderID, declined);
Game::logger->Log("ChatPacketHandler", "Accepted invite: %llu -> %llu (%d)", playerID, leaderID, declined);
if (declined)
{
@ -563,21 +563,21 @@ void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet)
if (team == nullptr)
{
Game::logger->Log("ChatPacketHandler", "Failed to find team for leader (%llu)\n", leaderID);
Game::logger->Log("ChatPacketHandler", "Failed to find team for leader (%llu)", leaderID);
team = playerContainer.GetTeam(playerID);
}
if (team == nullptr)
{
Game::logger->Log("ChatPacketHandler", "Failed to find team for player (%llu)\n", playerID);
Game::logger->Log("ChatPacketHandler", "Failed to find team for player (%llu)", playerID);
return;
}
playerContainer.AddMember(team, playerID);
}
void ChatPacketHandler::HandleTeamLeave(Packet* packet)
void ChatPacketHandler::HandleTeamLeave(Packet* packet)
{
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
@ -588,7 +588,7 @@ void ChatPacketHandler::HandleTeamLeave(Packet* packet)
auto* team = playerContainer.GetTeam(playerID);
Game::logger->Log("ChatPacketHandler", "(%llu) leaving team\n", playerID);
Game::logger->Log("ChatPacketHandler", "(%llu) leaving team", playerID);
if (team != nullptr)
{
@ -596,16 +596,16 @@ void ChatPacketHandler::HandleTeamLeave(Packet* packet)
}
}
void ChatPacketHandler::HandleTeamKick(Packet* packet)
void ChatPacketHandler::HandleTeamKick(Packet* packet)
{
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID);
inStream.Read(playerID);
std::string kickedPlayer = PacketUtils::ReadString(0x14, packet, true);
Game::logger->Log("ChatPacketHandler", "(%llu) kicking (%s) from team\n", playerID, kickedPlayer.c_str());
Game::logger->Log("ChatPacketHandler", "(%llu) kicking (%s) from team", playerID, kickedPlayer.c_str());
auto* kicked = playerContainer.GetPlayerData(kickedPlayer);
@ -632,16 +632,16 @@ void ChatPacketHandler::HandleTeamKick(Packet* packet)
}
}
void ChatPacketHandler::HandleTeamPromote(Packet* packet)
void ChatPacketHandler::HandleTeamPromote(Packet* packet)
{
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
inStream.Read(playerID);
inStream.Read(playerID);
std::string promotedPlayer = PacketUtils::ReadString(0x14, packet, true);
Game::logger->Log("ChatPacketHandler", "(%llu) promoting (%s) to team leader\n", playerID, promotedPlayer.c_str());
Game::logger->Log("ChatPacketHandler", "(%llu) promoting (%s) to team leader", playerID, promotedPlayer.c_str());
auto* promoted = playerContainer.GetPlayerData(promotedPlayer);
@ -657,7 +657,7 @@ void ChatPacketHandler::HandleTeamPromote(Packet* packet)
}
}
void ChatPacketHandler::HandleTeamLootOption(Packet* packet)
void ChatPacketHandler::HandleTeamLootOption(Packet* packet)
{
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
@ -665,7 +665,7 @@ void ChatPacketHandler::HandleTeamLootOption(Packet* packet)
inStream.Read(playerID);
uint32_t size = 0;
inStream.Read(size);
char option;
inStream.Read(option);
@ -678,12 +678,12 @@ void ChatPacketHandler::HandleTeamLootOption(Packet* packet)
team->lootFlag = option;
playerContainer.TeamStatusUpdate(team);
playerContainer.UpdateTeamsOnWorld(team, false);
}
}
void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet)
void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet)
{
CINSTREAM;
LWOOBJID playerID = LWOOBJID_EMPTY;
@ -729,7 +729,7 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet)
if (memberId == playerID) continue;
const auto memberName = playerContainer.GetName(memberId);
if (otherMember != nullptr)
{
ChatPacketHandler::SendTeamSetOffWorldFlag(otherMember, data->playerID, data->zoneID);
@ -741,7 +741,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);
@ -757,7 +757,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);
@ -813,7 +813,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);
@ -831,7 +831,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);
@ -863,7 +863,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);
@ -891,7 +891,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);

View File

@ -40,9 +40,9 @@ int main(int argc, char** argv) {
//Create all the objects we need to run our service:
Game::logger = SetupLogger();
if (!Game::logger) return 0;
Game::logger->Log("ChatServer", "Starting Chat server...\n");
Game::logger->Log("ChatServer", "Version: %i.%i\n", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR);
Game::logger->Log("ChatServer", "Compiled on: %s\n", __TIMESTAMP__);
Game::logger->Log("ChatServer", "Starting Chat server...");
Game::logger->Log("ChatServer", "Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR);
Game::logger->Log("ChatServer", "Compiled on: %s", __TIMESTAMP__);
//Read our config:
dConfig config("chatconfig.ini");
@ -60,7 +60,7 @@ int main(int argc, char** argv) {
Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password);
}
catch (sql::SQLException& ex) {
Game::logger->Log("ChatServer", "Got an error while connecting to the database: %s\n", ex.what());
Game::logger->Log("ChatServer", "Got an error while connecting to the database: %s", ex.what());
Database::Destroy("ChatServer");
delete Game::server;
delete Game::logger;
@ -172,11 +172,11 @@ dLogger * SetupLogger() {
void HandlePacket(Packet* packet) {
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {
Game::logger->Log("ChatServer", "A server has disconnected, erasing their connected players from the list.\n");
Game::logger->Log("ChatServer", "A server has disconnected, erasing their connected players from the list.");
}
if (packet->data[0] == ID_NEW_INCOMING_CONNECTION) {
Game::logger->Log("ChatServer", "A server is connecting, awaiting user list.\n");
Game::logger->Log("ChatServer", "A server is connecting, awaiting user list.");
}
if (packet->data[1] == CHAT_INTERNAL) {
@ -205,7 +205,7 @@ void HandlePacket(Packet* packet) {
}
default:
Game::logger->Log("ChatServer", "Unknown CHAT_INTERNAL id: %i\n", int(packet->data[3]));
Game::logger->Log("ChatServer", "Unknown CHAT_INTERNAL id: %i", int(packet->data[3]));
}
}
@ -216,7 +216,7 @@ void HandlePacket(Packet* packet) {
break;
case MSG_CHAT_GET_IGNORE_LIST:
Game::logger->Log("ChatServer", "Asked for ignore list, but is unimplemented right now.\n");
Game::logger->Log("ChatServer", "Asked for ignore list, but is unimplemented right now.");
break;
case MSG_CHAT_TEAM_GET_STATUS:
@ -272,21 +272,21 @@ void HandlePacket(Packet* packet) {
case MSG_CHAT_TEAM_SET_LOOT:
ChatPacketHandler::HandleTeamLootOption(packet);
break;
default:
Game::logger->Log("ChatServer", "Unknown CHAT id: %i\n", int(packet->data[3]));
Game::logger->Log("ChatServer", "Unknown CHAT id: %i", int(packet->data[3]));
}
}
if (packet->data[1] == WORLD) {
switch (packet->data[3]) {
case MSG_WORLD_CLIENT_ROUTE_PACKET: {
printf("routing packet from world\n");
Game::logger->Log("ChatServer", "Routing packet from world");
break;
}
default:
Game::logger->Log("ChatServer", "Unknown World id: %i\n", int(packet->data[3]));
Game::logger->Log("ChatServer", "Unknown World id: %i", int(packet->data[3]));
}
}
}

View File

@ -28,7 +28,7 @@ void PlayerContainer::InsertPlayer(Packet* packet) {
for (int i = 0; i < len; i++) {
char character; inStream.Read<char>(character);
data->playerName += character;
data->playerName += character;
}
inStream.Read(data->zoneID);
@ -38,7 +38,7 @@ void PlayerContainer::InsertPlayer(Packet* packet) {
mNames[data->playerID] = GeneralUtils::ASCIIToUTF16(std::string(data->playerName.c_str()));
mPlayers.insert(std::make_pair(data->playerID, data));
Game::logger->Log("PlayerContainer", "Added user: %s (%llu), zone: %i\n", data->playerName.c_str(), data->playerID, data->zoneID.GetMapID());
Game::logger->Log("PlayerContainer", "Added user: %s (%llu), zone: %i", data->playerName.c_str(), data->playerID, data->zoneID.GetMapID());
auto* insertLog = Database::CreatePreppedStmt("INSERT INTO activity_log (character_id, activity, time, map_id) VALUES (?, ?, ?, ?);");
@ -73,7 +73,7 @@ void PlayerContainer::RemovePlayer(Packet* packet) {
if (team != nullptr)
{
const auto memberName = GeneralUtils::ASCIIToUTF16(std::string(player->playerName.c_str()));
for (const auto memberId : team->memberIDs)
{
auto* otherMember = GetPlayerData(memberId);
@ -84,7 +84,7 @@ void PlayerContainer::RemovePlayer(Packet* packet) {
}
}
Game::logger->Log("PlayerContainer", "Removed user: %llu\n", playerID);
Game::logger->Log("PlayerContainer", "Removed user: %llu", playerID);
mPlayers.erase(playerID);
auto* insertLog = Database::CreatePreppedStmt("INSERT INTO activity_log (character_id, activity, time, map_id) VALUES (?, ?, ?, ?);");
@ -97,7 +97,7 @@ void PlayerContainer::RemovePlayer(Packet* packet) {
insertLog->executeUpdate();
}
void PlayerContainer::MuteUpdate(Packet* packet)
void PlayerContainer::MuteUpdate(Packet* packet)
{
CINSTREAM;
LWOOBJID playerID;
@ -110,7 +110,7 @@ void PlayerContainer::MuteUpdate(Packet* packet)
if (player == nullptr)
{
Game::logger->Log("PlayerContainer", "Failed to find user: %llu\n", playerID);
Game::logger->Log("PlayerContainer", "Failed to find user: %llu", playerID);
return;
}
@ -120,7 +120,7 @@ void PlayerContainer::MuteUpdate(Packet* packet)
BroadcastMuteUpdate(playerID, expire);
}
void PlayerContainer::CreateTeamServer(Packet* packet)
void PlayerContainer::CreateTeamServer(Packet* packet)
{
CINSTREAM;
LWOOBJID playerID;
@ -143,7 +143,7 @@ void PlayerContainer::CreateTeamServer(Packet* packet)
LWOZONEID zoneId;
inStream.Read(zoneId);
auto* team = CreateLocalTeam(members);
if (team != nullptr)
@ -154,7 +154,7 @@ void PlayerContainer::CreateTeamServer(Packet* packet)
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,7 +165,7 @@ void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time)
Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true);
}
TeamData* PlayerContainer::CreateLocalTeam(std::vector<LWOOBJID> members)
TeamData* PlayerContainer::CreateLocalTeam(std::vector<LWOOBJID> members)
{
if (members.empty())
{
@ -200,14 +200,14 @@ 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;
team->leaderID = leader;
team->local = local;
mTeams.push_back(team);
AddMember(team, leader);
@ -215,7 +215,7 @@ TeamData* PlayerContainer::CreateTeam(LWOOBJID leader, bool local)
return team;
}
TeamData* PlayerContainer::GetTeam(LWOOBJID playerID)
TeamData* PlayerContainer::GetTeam(LWOOBJID playerID)
{
for (auto* team : mTeams)
{
@ -223,11 +223,11 @@ TeamData* PlayerContainer::GetTeam(LWOOBJID playerID)
return team;
}
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);
@ -263,7 +263,7 @@ void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID)
if (otherMember == member) continue;
const auto otherMemberName = GetName(memberId);
ChatPacketHandler::SendTeamAddPlayer(member, false, team->local, false, memberId, otherMemberName, otherMember != nullptr ? otherMember->zoneID : LWOZONEID(0, 0, 0));
if (otherMember != nullptr)
@ -273,14 +273,14 @@ void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID)
}
}
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)
{
ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY);
@ -319,7 +319,7 @@ void PlayerContainer::RemoveMember(TeamData* team, LWOOBJID playerID, bool disba
}
}
void PlayerContainer::PromoteMember(TeamData* team, LWOOBJID newLeader)
void PlayerContainer::PromoteMember(TeamData* team, LWOOBJID newLeader)
{
team->leaderID = newLeader;
@ -333,7 +333,7 @@ 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);
@ -350,7 +350,7 @@ void PlayerContainer::DisbandTeam(TeamData* team)
ChatPacketHandler::SendTeamSetLeader(otherMember, LWOOBJID_EMPTY);
ChatPacketHandler::SendTeamRemovePlayer(otherMember, true, false, false, team->local, team->leaderID, otherMember->playerID, memberName);
}
UpdateTeamsOnWorld(team, true);
mTeams.erase(index);
@ -358,7 +358,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);
@ -385,7 +385,7 @@ 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);
@ -406,7 +406,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);
@ -415,7 +415,7 @@ std::u16string PlayerContainer::GetName(LWOOBJID playerID)
return pair->second;
}
LWOOBJID PlayerContainer::GetId(const std::u16string& playerName)
LWOOBJID PlayerContainer::GetId(const std::u16string& playerName)
{
for (const auto& pair : mNames)
{
@ -424,11 +424,11 @@ LWOOBJID PlayerContainer::GetId(const std::u16string& playerName)
return pair.first;
}
}
return LWOOBJID_EMPTY;
}
bool PlayerContainer::GetIsMuted(PlayerData* data)
bool PlayerContainer::GetIsMuted(PlayerData* data)
{
return data->muteExpire == 1 || data->muteExpire > time(NULL);
}

View File

@ -44,14 +44,14 @@ void dLogger::vLog(const char* format, va_list args) {
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", time);
char message[2048];
vsprintf(message, format, args);
if (m_logToConsole) {
fputs("[", stdout);
fputs(timeStr, stdout);
fputs("] ", stdout);
fputs(message, stdout);
}
if (fp != nullptr) {
fputs("[", fp);
fputs(timeStr, fp);
@ -76,7 +76,7 @@ void dLogger::LogBasic(const std::string & message) {
void dLogger::Log(const char * className, const char * format, ...) {
va_list args;
std::string log = "[" + std::string(className) + "] " + std::string(format);
std::string log = "[" + std::string(className) + "] " + std::string(format) + "\n";
va_start(args, format);
vLog(log.c_str(), args);
va_end(args);

View File

@ -41,10 +41,10 @@ void Database::Connect() {
void Database::Destroy(std::string source, bool log) {
if (!con) return;
if (log) {
if (source != "") Game::logger->Log("Database", "Destroying MySQL connection from %s!\n", source.c_str());
else Game::logger->Log("Database", "Destroying MySQL connection!\n");
if (source != "") Game::logger->Log("Database", "Destroying MySQL connection from %s!", source.c_str());
else Game::logger->Log("Database", "Destroying MySQL connection!");
}
con->close();
@ -63,7 +63,7 @@ sql::PreparedStatement* Database::CreatePreppedStmt(const std::string& query) {
if (!con) {
Connect();
Game::logger->Log("Database", "Trying to reconnect to MySQL\n");
Game::logger->Log("Database", "Trying to reconnect to MySQL");
}
if (!con->isValid() || con->isClosed())
@ -73,9 +73,9 @@ sql::PreparedStatement* Database::CreatePreppedStmt(const std::string& query) {
con = nullptr;
Connect();
Game::logger->Log("Database", "Trying to reconnect to MySQL from invalid or closed connection\n");
Game::logger->Log("Database", "Trying to reconnect to MySQL from invalid or closed connection");
}
auto* stmt = con->prepareStatement(str);
return stmt;

View File

@ -31,7 +31,7 @@ void MigrationRunner::RunMigrations() {
delete stmt;
if (doExit) continue;
Game::logger->Log("MigrationRunner", "Running migration: " + migration.name + "\n");
Game::logger->Log("MigrationRunner", "Running migration: " + migration.name + "");
finalSQL.append(migration.data);
finalSQL.append('\n');
@ -49,7 +49,7 @@ void MigrationRunner::RunMigrations() {
delete simpleStatement;
}
catch (sql::SQLException e) {
Game::logger->Log("MigrationRunner", std::string("Encountered error running migration: ") + e.what() + "\n");
Game::logger->Log("MigrationRunner", std::string("Encountered error running migration: ") + e.what() + "");
}
}
}
@ -60,7 +60,7 @@ Migration MigrationRunner::LoadMigration(std::string path) {
if (file.is_open()) {
std::hash<std::string> hash;
std::string line;
std::string total = "";
@ -73,6 +73,6 @@ Migration MigrationRunner::LoadMigration(std::string path) {
migration.name = path;
migration.data = total;
}
return migration;
}

View File

@ -13,9 +13,9 @@ CDSkillBehaviorTable::CDSkillBehaviorTable(void) {
tableSize.nextRow();
}
tableSize.finalize();
// Reserve the size
//this->entries.reserve(size);
@ -68,7 +68,7 @@ std::vector<CDSkillBehavior> CDSkillBehaviorTable::Query(std::function<bool(CDSk
return data;*/
//Logger::LogDebug("CDSkillBehaviorTable", "The 'Query' function is no longer working! Please use GetSkillByID instead!\n");
//Logger::LogDebug("CDSkillBehaviorTable", "The 'Query' function is no longer working! Please use GetSkillByID instead!");
std::vector<CDSkillBehavior> data; //So MSVC shuts up
return data;
}

View File

@ -25,9 +25,9 @@ Character::Character(uint32_t id, User* parentUser) {
);
stmt->setInt64(1, id);
sql::ResultSet* res = stmt->executeQuery();
while (res->next()) {
m_Name = res->getString(1).c_str();
m_UnapprovedName = res->getString(2).c_str();
@ -35,25 +35,25 @@ Character::Character(uint32_t id, User* parentUser) {
m_PropertyCloneID = res->getUInt(4);
m_PermissionMap = static_cast<PermissionMap>(res->getUInt64(5));
}
delete res;
delete stmt;
//Load the xmlData now:
sql::PreparedStatement* xmlStmt = Database::CreatePreppedStmt(
"SELECT xml_data FROM charxml WHERE id=? LIMIT 1;"
);
xmlStmt->setInt64(1, id);
sql::ResultSet* xmlRes = xmlStmt->executeQuery();
while (xmlRes->next()) {
m_XMLData = xmlRes->getString(1).c_str();
}
delete xmlRes;
delete xmlStmt;
m_ZoneID = 0; //TEMP! Set back to 0 when done. This is so we can see loading screen progress for testing.
m_ZoneInstanceID = 0; //These values don't really matter, these are only used on the char select screen and seem unused.
m_ZoneCloneID = 0;
@ -62,12 +62,12 @@ Character::Character(uint32_t id, User* parentUser) {
//Quickly and dirtly parse the xmlData to get the info we need:
DoQuickXMLDataParse();
//Set our objectID:
m_ObjectID = m_ID;
m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_CHARACTER);
m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_PERSISTENT);
m_ParentUser = parentUser;
m_OurEntity = nullptr;
m_BuildMode = false;
@ -78,16 +78,16 @@ Character::~Character() {
m_Doc = nullptr;
}
void Character::UpdateFromDatabase()
void Character::UpdateFromDatabase()
{
sql::PreparedStatement* stmt = Database::CreatePreppedStmt(
"SELECT name, pending_name, needs_rename, prop_clone_id, permission_map FROM charinfo WHERE id=? LIMIT 1;"
);
stmt->setInt64(1, m_ID);
sql::ResultSet* res = stmt->executeQuery();
while (res->next()) {
m_Name = res->getString(1).c_str();
m_UnapprovedName = res->getString(2).c_str();
@ -95,24 +95,24 @@ void Character::UpdateFromDatabase()
m_PropertyCloneID = res->getUInt(4);
m_PermissionMap = static_cast<PermissionMap>(res->getUInt64(5));
}
delete res;
delete stmt;
//Load the xmlData now:
sql::PreparedStatement* xmlStmt = Database::CreatePreppedStmt(
"SELECT xml_data FROM charxml WHERE id=? LIMIT 1;"
);
xmlStmt->setInt64(1, m_ID);
sql::ResultSet* xmlRes = xmlStmt->executeQuery();
while (xmlRes->next()) {
m_XMLData = xmlRes->getString(1).c_str();
}
delete xmlRes;
delete xmlStmt;
m_ZoneID = 0; //TEMP! Set back to 0 when done. This is so we can see loading screen progress for testing.
m_ZoneInstanceID = 0; //These values don't really matter, these are only used on the char select screen and seem unused.
m_ZoneCloneID = 0;
@ -122,67 +122,67 @@ void Character::UpdateFromDatabase()
//Quickly and dirtly parse the xmlData to get the info we need:
DoQuickXMLDataParse();
//Set our objectID:
m_ObjectID = m_ID;
m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_CHARACTER);
m_ObjectID = GeneralUtils::SetBit(m_ObjectID, OBJECT_BIT_PERSISTENT);
m_OurEntity = nullptr;
m_BuildMode = false;
}
void Character::DoQuickXMLDataParse() {
if (m_XMLData.size() == 0) return;
delete m_Doc;
m_Doc = new tinyxml2::XMLDocument();
if (!m_Doc) return;
if (m_Doc->Parse(m_XMLData.c_str(), m_XMLData.size()) == 0) {
Game::logger->Log("Character", "Loaded xmlData for character %s (%i)!\n", m_Name.c_str(), m_ID);
Game::logger->Log("Character", "Loaded xmlData for character %s (%i)!", m_Name.c_str(), m_ID);
} else {
Game::logger->Log("Character", "Failed to load xmlData!\n");
Game::logger->Log("Character", "Failed to load xmlData!");
//Server::rakServer->CloseConnection(m_ParentUser->GetSystemAddress(), true);
return;
}
tinyxml2::XMLElement* mf = m_Doc->FirstChildElement("obj")->FirstChildElement("mf");
if (!mf) {
Game::logger->Log("Character", "Failed to find mf tag!\n");
Game::logger->Log("Character", "Failed to find mf tag!");
return;
}
mf->QueryAttribute("hc", &m_HairColor);
mf->QueryAttribute("hs", &m_HairStyle);
mf->QueryAttribute("t", &m_ShirtColor);
mf->QueryAttribute("l", &m_PantsColor);
mf->QueryAttribute("lh", &m_LeftHand);
mf->QueryAttribute("rh", &m_RightHand);
mf->QueryAttribute("es", &m_Eyebrows);
mf->QueryAttribute("ess", &m_Eyes);
mf->QueryAttribute("ms", &m_Mouth);
tinyxml2::XMLElement* inv = m_Doc->FirstChildElement("obj")->FirstChildElement("inv");
if (!inv) {
Game::logger->Log("Character", "Char has no inv!\n");
Game::logger->Log("Character", "Char has no inv!");
return;
}
tinyxml2::XMLElement* bag = inv->FirstChildElement("items")->FirstChildElement("in");
if (!bag) {
Game::logger->Log("Character", "Couldn't find bag0!\n");
Game::logger->Log("Character", "Couldn't find bag0!");
return;
}
while (bag != nullptr)
{
auto* sib = bag->FirstChildElement();
while (sib != nullptr) {
bool eq = false;
sib->QueryAttribute("eq", &eq);
@ -198,8 +198,8 @@ void Character::DoQuickXMLDataParse() {
bag = bag->NextSiblingElement();
}
tinyxml2::XMLElement* character = m_Doc->FirstChildElement("obj")->FirstChildElement("char");
if (character) {
character->QueryAttribute("cc", &m_Coins);
@ -261,7 +261,7 @@ void Character::DoQuickXMLDataParse() {
character->QueryAttribute("lzrz", &m_OriginalRotation.z);
character->QueryAttribute("lzrw", &m_OriginalRotation.w);
}
auto* flags = m_Doc->FirstChildElement("obj")->FirstChildElement("flag");
if (flags) {
auto* currentChild = flags->FirstChildElement();
@ -269,10 +269,10 @@ void Character::DoQuickXMLDataParse() {
uint32_t index = 0;
uint64_t value = 0;
const auto* temp = currentChild->Attribute("v");
index = std::stoul(currentChild->Attribute("id"));
value = std::stoull(temp);
m_PlayerFlags.insert(std::make_pair(index, value));
currentChild = currentChild->NextSiblingElement();
}
@ -296,10 +296,10 @@ void Character::SetBuildMode(bool buildMode)
void Character::SaveXMLToDatabase() {
if (!m_Doc) return;
//For metrics, we'll record the time it took to save:
auto start = std::chrono::system_clock::now();
tinyxml2::XMLElement* character = m_Doc->FirstChildElement("obj")->FirstChildElement("char");
if (character) {
character->SetAttribute("gm", m_GMLevel);
@ -323,7 +323,7 @@ void Character::SaveXMLToDatabase() {
auto emotes = character->FirstChildElement("ue");
if (!emotes) emotes = m_Doc->NewElement("ue");
emotes->DeleteChildren();
for (int emoteID : m_UnlockedEmotes) {
auto emote = m_Doc->NewElement("e");
@ -334,53 +334,53 @@ void Character::SaveXMLToDatabase() {
character->LinkEndChild(emotes);
}
//Export our flags:
auto* flags = m_Doc->FirstChildElement("obj")->FirstChildElement("flag");
if (!flags) {
flags = m_Doc->NewElement("flag"); //Create a flags tag if we don't have one
m_Doc->FirstChildElement("obj")->LinkEndChild(flags); //Link it to the obj tag so we can find next time
}
flags->DeleteChildren(); //Clear it if we have anything, so that we can fill it up again without dupes
for (std::pair<uint32_t, uint64_t> flag : m_PlayerFlags) {
auto* f = m_Doc->NewElement("f");
f->SetAttribute("id", flag.first);
//Because of the joy that is tinyxml2, it doesn't offer a function to set a uint64 as an attribute.
//Only signed 64-bits ints would work.
std::string v = std::to_string(flag.second);
f->SetAttribute("v", v.c_str());
flags->LinkEndChild(f);
}
SaveXmlRespawnCheckpoints();
//Call upon the entity to update our xmlDoc:
//Call upon the entity to update our xmlDoc:
if (!m_OurEntity) {
Game::logger->Log("Character", "We didn't have an entity set while saving! CHARACTER WILL NOT BE SAVED!\n");
Game::logger->Log("Character", "We didn't have an entity set while saving! CHARACTER WILL NOT BE SAVED!");
return;
}
m_OurEntity->UpdateXMLDoc(m_Doc);
//Dump our xml into m_XMLData:
auto* printer = new tinyxml2::XMLPrinter(0, true, 0);
m_Doc->Print(printer);
m_XMLData = printer->CStr();
//Finally, save to db:
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("UPDATE charxml SET xml_data=? WHERE id=?");
stmt->setString(1, m_XMLData.c_str());
stmt->setUInt(2, m_ID);
stmt->execute();
delete stmt;
//For metrics, log the time it took to save:
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed = end - start;
Game::logger->Log("Character", "Saved character to Database in: %fs\n", elapsed.count());
Game::logger->Log("Character", "Saved character to Database in: %fs", elapsed.count());
delete printer;
}
@ -404,7 +404,7 @@ void Character::SetPlayerFlag(const uint32_t flagId, const bool value) {
}
}
}
// Calculate the index first
auto flagIndex = uint32_t(std::floor(flagId / 64));
@ -425,9 +425,9 @@ void Character::SetPlayerFlag(const uint32_t flagId, const bool value) {
if (value) {
// Otherwise, insert the value
uint64_t flagValue = 0;
flagValue |= shiftedValue;
m_PlayerFlags.insert(std::make_pair(flagIndex, flagValue));
}
}
@ -458,7 +458,7 @@ void Character::SetRetroactiveFlags() {
}
}
void Character::SaveXmlRespawnCheckpoints()
void Character::SaveXmlRespawnCheckpoints()
{
//Export our respawn points:
auto* points = m_Doc->FirstChildElement("obj")->FirstChildElement("res");
@ -466,21 +466,21 @@ void Character::SaveXmlRespawnCheckpoints()
points = m_Doc->NewElement("res");
m_Doc->FirstChildElement("obj")->LinkEndChild(points);
}
points->DeleteChildren();
for (const auto& point : m_WorldRespawnCheckpoints) {
auto* r = m_Doc->NewElement("r");
r->SetAttribute("w", point.first);
r->SetAttribute("x", point.second.x);
r->SetAttribute("y", point.second.y);
r->SetAttribute("z", point.second.z);
points->LinkEndChild(r);
}
}
void Character::LoadXmlRespawnCheckpoints()
void Character::LoadXmlRespawnCheckpoints()
{
m_WorldRespawnCheckpoints.clear();
@ -504,10 +504,10 @@ void Character::LoadXmlRespawnCheckpoints()
m_WorldRespawnCheckpoints[map] = point;
}
}
void Character::OnZoneLoad()
void Character::OnZoneLoad()
{
if (m_OurEntity == nullptr) {
return;
@ -530,8 +530,8 @@ void Character::OnZoneLoad()
}
/**
* Restrict old character to 1 million coins
*/
* Restrict old character to 1 million coins
*/
if (HasPermission(PermissionMap::Old)) {
if (GetCoins() > 1000000) {
SetCoins(1000000, eLootSourceType::LOOT_SOURCE_NONE);
@ -560,7 +560,7 @@ bool Character::HasPermission(PermissionMap permission) const
return (static_cast<uint64_t>(m_PermissionMap) & static_cast<uint64_t>(permission)) != 0;
}
void Character::SetRespawnPoint(LWOMAPID map, const NiPoint3& point)
void Character::SetRespawnPoint(LWOMAPID map, const NiPoint3& point)
{
m_WorldRespawnCheckpoints[map] = point;
}
@ -604,7 +604,7 @@ void Character::SendMuteNotice() const
// Format: Mo, 15.06.2009 20:20:00
std::strftime(buffer, 32, "%a, %d.%m.%Y %H:%M:%S", ptm);
}
const auto timeStr = GeneralUtils::ASCIIToUTF16(std::string(buffer));
ChatPackets::SendSystemMessage(GetEntity()->GetSystemAddress(), u"You are muted until " + timeStr);

View File

@ -26,7 +26,7 @@ Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Enti
m_SystemAddress = m_ParentUser->GetSystemAddress();
m_DroppedLoot = {};
m_DroppedCoins = 0;
m_GhostReferencePoint = NiPoint3::ZERO;
m_GhostOverridePoint = NiPoint3::ZERO;
m_GhostOverride = false;
@ -121,7 +121,7 @@ void Player::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId)
});
}
void Player::AddLimboConstruction(LWOOBJID objectId)
void Player::AddLimboConstruction(LWOOBJID objectId)
{
const auto& iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
@ -133,7 +133,7 @@ void Player::AddLimboConstruction(LWOOBJID objectId)
m_LimboConstructions.push_back(objectId);
}
void Player::RemoveLimboConstruction(LWOOBJID objectId)
void Player::RemoveLimboConstruction(LWOOBJID objectId)
{
const auto& iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
@ -158,7 +158,7 @@ void Player::ConstructLimboEntities()
EntityManager::Instance()->ConstructEntity(entity, m_SystemAddress);
}
m_LimboConstructions.clear();
}
@ -177,12 +177,12 @@ const NiPoint3& Player::GetOriginGhostReferencePoint() const
return m_GhostReferencePoint;
}
void Player::SetGhostReferencePoint(const NiPoint3& value)
void Player::SetGhostReferencePoint(const NiPoint3& value)
{
m_GhostReferencePoint = value;
}
void Player::SetGhostOverridePoint(const NiPoint3& value)
void Player::SetGhostOverridePoint(const NiPoint3& value)
{
m_GhostOverridePoint = value;
}
@ -192,7 +192,7 @@ const NiPoint3& Player::GetGhostOverridePoint() const
return m_GhostOverridePoint;
}
void Player::SetGhostOverride(bool value)
void Player::SetGhostOverride(bool value)
{
m_GhostOverride = value;
}
@ -202,7 +202,7 @@ bool Player::GetGhostOverride() const
return m_GhostOverride;
}
void Player::ObserveEntity(int32_t id)
void Player::ObserveEntity(int32_t id)
{
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++)
{
@ -226,7 +226,7 @@ void Player::ObserveEntity(int32_t id)
m_ObservedEntities[index] = id;
}
bool Player::IsObserved(int32_t id)
bool Player::IsObserved(int32_t id)
{
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++)
{
@ -239,7 +239,7 @@ bool Player::IsObserved(int32_t id)
return false;
}
void Player::GhostEntity(int32_t id)
void Player::GhostEntity(int32_t id)
{
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++)
{
@ -257,7 +257,7 @@ Player* Player::GetPlayer(const SystemAddress& sysAddr)
return static_cast<Player*>(entity);
}
Player* Player::GetPlayer(const std::string& name)
Player* Player::GetPlayer(const std::string& name)
{
const auto characters = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_CHARACTER);
@ -274,7 +274,7 @@ Player* Player::GetPlayer(const std::string& name)
return nullptr;
}
Player* Player::GetPlayer(LWOOBJID playerID)
Player* Player::GetPlayer(LWOOBJID playerID)
{
for (auto* player : m_Players)
{
@ -283,11 +283,11 @@ Player* Player::GetPlayer(LWOOBJID playerID)
return player;
}
}
return nullptr;
}
const std::vector<Player*>& Player::GetAllPlayers()
const std::vector<Player*>& Player::GetAllPlayers()
{
return m_Players;
}
@ -302,7 +302,7 @@ void Player::SetDroppedCoins(uint64_t value) {
Player::~Player()
{
Game::logger->Log("Player", "Deleted player\n");
Game::logger->Log("Player", "Deleted player");
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++)
{

View File

@ -12,16 +12,16 @@
TradingManager* TradingManager::m_Address = nullptr;
Trade::Trade(LWOOBJID tradeId, LWOOBJID participantA, LWOOBJID participantB)
Trade::Trade(LWOOBJID tradeId, LWOOBJID participantA, LWOOBJID participantB)
{
m_TradeId = tradeId;
m_ParticipantA = participantA;
m_ParticipantB = participantB;
}
Trade::~Trade()
Trade::~Trade()
{
}
LWOOBJID Trade::GetTradeId() const
@ -54,7 +54,7 @@ Entity* Trade::GetParticipantBEntity() const
return EntityManager::Instance()->GetEntity(m_ParticipantB);
}
void Trade::SetCoins(LWOOBJID participant, uint64_t coins)
void Trade::SetCoins(LWOOBJID participant, uint64_t coins)
{
if (participant == m_ParticipantA)
{
@ -66,7 +66,7 @@ void Trade::SetCoins(LWOOBJID participant, uint64_t coins)
}
}
void Trade::SetItems(LWOOBJID participant, std::vector<TradeItem> items)
void Trade::SetItems(LWOOBJID participant, std::vector<TradeItem> items)
{
if (participant == m_ParticipantA)
{
@ -78,13 +78,13 @@ void Trade::SetItems(LWOOBJID participant, std::vector<TradeItem> items)
}
}
void Trade::SetAccepted(LWOOBJID participant, bool value)
void Trade::SetAccepted(LWOOBJID participant, bool value)
{
if (participant == m_ParticipantA)
{
m_AcceptedA = !value;
Game::logger->Log("Trade", "Accepted from A (%d), B: (%d)\n", value, m_AcceptedB);
Game::logger->Log("Trade", "Accepted from A (%d), B: (%d)", value, m_AcceptedB);
auto* entityB = GetParticipantBEntity();
@ -97,7 +97,7 @@ void Trade::SetAccepted(LWOOBJID participant, bool value)
{
m_AcceptedB = !value;
Game::logger->Log("Trade", "Accepted from B (%d), A: (%d)\n", value, m_AcceptedA);
Game::logger->Log("Trade", "Accepted from B (%d), A: (%d)", value, m_AcceptedA);
auto* entityA = GetParticipantAEntity();
@ -106,7 +106,7 @@ void Trade::SetAccepted(LWOOBJID participant, bool value)
GameMessages::SendServerTradeAccept(m_ParticipantA, value, entityA->GetSystemAddress());
}
}
if (m_AcceptedA && m_AcceptedB)
{
auto* entityB = GetParticipantBEntity();
@ -119,7 +119,7 @@ void Trade::SetAccepted(LWOOBJID participant, bool value)
{
return;
}
auto* entityA = GetParticipantAEntity();
if (entityA != nullptr)
@ -130,16 +130,16 @@ void Trade::SetAccepted(LWOOBJID participant, bool value)
{
return;
}
Complete();
}
}
void Trade::Complete()
void Trade::Complete()
{
auto* entityA = GetParticipantAEntity();
auto* entityB = GetParticipantBEntity();
if (entityA == nullptr || entityB == nullptr) return;
auto* inventoryA = entityA->GetComponent<InventoryComponent>();
@ -160,7 +160,7 @@ void Trade::Complete()
missionsA->Progress(MissionTaskType::MISSION_TASK_TYPE_ITEM_COLLECTION, tradeItem.itemLot, LWOOBJID_EMPTY, "", -tradeItem.itemCount);
}
for (const auto& tradeItem : m_ItemsB)
{
inventoryB->RemoveItem(tradeItem.itemLot, tradeItem.itemCount, INVALID, true);
@ -184,26 +184,26 @@ void Trade::Complete()
characterB->SaveXMLToDatabase();
}
void Trade::Cancel()
void Trade::Cancel()
{
auto* entityA = GetParticipantAEntity();
auto* entityB = GetParticipantBEntity();
if (entityA == nullptr || entityB == nullptr) return;
GameMessages::SendServerTradeCancel(entityA->GetObjectID(), entityA->GetSystemAddress());
GameMessages::SendServerTradeCancel(entityB->GetObjectID(), entityB->GetSystemAddress());
}
void Trade::SendUpdateToOther(LWOOBJID participant)
void Trade::SendUpdateToOther(LWOOBJID participant)
{
Entity* other = nullptr;
Entity* self = nullptr;
uint64_t coins;
std::vector<TradeItem> itemIds;
Game::logger->Log("Trade", "Attempting to send trade update\n");
Game::logger->Log("Trade", "Attempting to send trade update");
if (participant == m_ParticipantA)
{
other = GetParticipantBEntity();
@ -222,11 +222,11 @@ void Trade::SendUpdateToOther(LWOOBJID participant)
{
return;
}
if (other == nullptr || self == nullptr) return;
std::vector<TradeItem> items {};
auto* inventoryComponent = self->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) return;
@ -242,8 +242,8 @@ void Trade::SendUpdateToOther(LWOOBJID participant)
items.push_back(tradeItem);
}
Game::logger->Log("Trade", "Sending trade update\n");
Game::logger->Log("Trade", "Sending trade update");
GameMessages::SendServerTradeUpdate(other->GetObjectID(), coins, items, other->GetSystemAddress());
}
@ -257,7 +257,7 @@ TradingManager::~TradingManager()
{
delete pair.second;
}
trades.clear();
}
@ -279,30 +279,30 @@ Trade* TradingManager::GetPlayerTrade(LWOOBJID playerId) const
return pair.second;
}
}
return nullptr;
}
void TradingManager::CancelTrade(LWOOBJID tradeId)
void TradingManager::CancelTrade(LWOOBJID tradeId)
{
auto* trade = GetTrade(tradeId);
if (trade == nullptr) return;
delete trade;
trades.erase(tradeId);
}
Trade* TradingManager::NewTrade(LWOOBJID participantA, LWOOBJID participantB)
Trade* TradingManager::NewTrade(LWOOBJID participantA, LWOOBJID participantB)
{
const LWOOBJID tradeId = ObjectIDManager::Instance()->GenerateObjectID();
auto* trade = new Trade(tradeId, participantA, participantB);
trades[tradeId] = trade;
Game::logger->Log("TradingManager", "Created new trade between (%llu) <-> (%llu)\n", participantA, participantB);
Game::logger->Log("TradingManager", "Created new trade between (%llu) <-> (%llu)", participantA, participantB);
return trade;
}

View File

@ -20,40 +20,40 @@ User::User(const SystemAddress& sysAddr, const std::string& username, const std:
m_LoggedInCharID = 0;
m_IsBestFriendMap = std::unordered_map<std::string, bool>();
//HACK HACK HACK
//This needs to be re-enabled / updated whenever the mute stuff is moved to another table.
//This was only done because otherwise the website's account page dies and the website is waiting on a migration to wordpress.
//sql::PreparedStatement* stmt = Database::CreatePreppedStmt("SELECT id, gmlevel, mute_expire FROM accounts WHERE name=? LIMIT 1;");
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("SELECT id, gm_level FROM accounts WHERE name=? LIMIT 1;");
stmt->setString(1, username.c_str());
sql::ResultSet* res = stmt->executeQuery();
while (res->next()) {
m_AccountID = res->getUInt(1);
m_MaxGMLevel = res->getInt(2);
m_MuteExpire = 0; //res->getUInt64(3);
}
delete res;
delete stmt;
//If we're loading a zone, we'll load the last used (aka current) character:
if (Game::server->GetZoneID() != 0) {
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("SELECT id FROM charinfo WHERE account_id=? ORDER BY last_login DESC LIMIT 1;");
stmt->setUInt(1, m_AccountID);
sql::ResultSet* res = stmt->executeQuery();
if (res->rowsCount() > 0) {
while (res->next()) {
LWOOBJID objID = res->getUInt64(1);
Character* character = new Character(uint32_t(objID), this);
m_Characters.push_back(character);
Game::logger->Log("User", "Loaded %llu as it is the last used char\n", objID);
Game::logger->Log("User", "Loaded %llu as it is the last used char", objID);
}
}
delete res;
delete stmt;
}
@ -92,7 +92,7 @@ User& User::operator= ( const User& other ) {
bool User::operator== ( const User& other ) const {
if (m_Username == other.m_Username || m_SessionKey == other.m_SessionKey || m_SystemAddress == other.m_SystemAddress)
return true;
return false;
}
@ -104,7 +104,7 @@ Character * User::GetLastUsedChar() {
for (size_t i = 0; i < m_Characters.size(); ++i) {
if (m_Characters[i]->GetLastLogin() > toReturn->GetLastLogin()) toReturn = m_Characters[i];
}
return toReturn;
}
}
@ -119,7 +119,7 @@ time_t User::GetMuteExpire() const
return m_MuteExpire;
}
void User::SetMuteExpire(time_t value)
void User::SetMuteExpire(time_t value)
{
m_MuteExpire = value;
}
@ -128,7 +128,7 @@ void User::UserOutOfSync() {
m_AmountOfTimesOutOfSync++;
if (m_AmountOfTimesOutOfSync > m_MaxDesyncAllowed) {
//YEET
Game::logger->Log("User", "User %s was out of sync %i times out of %i, disconnecting for suspected speedhacking.\n", m_Username.c_str(), m_AmountOfTimesOutOfSync, m_MaxDesyncAllowed);
Game::logger->Log("User", "User %s was out of sync %i times out of %i, disconnecting for suspected speedhacking.", m_Username.c_str(), m_AmountOfTimesOutOfSync, m_MaxDesyncAllowed);
Game::server->Disconnect(this->m_SystemAddress, SERVER_DISCON_KICK);
}
}

View File

@ -62,7 +62,7 @@ void UserManager::Initialize() {
fnFile.close();
mnFile.close();
lnFile.close();
//Load our pre-approved names:
std::fstream chatList("./res/chatplus_en_us.txt", std::ios::in);
while (std::getline(chatList, line, '\n')) {
@ -72,7 +72,7 @@ void UserManager::Initialize() {
}
UserManager::~UserManager() {
}
User* UserManager::CreateUser ( const SystemAddress& sysAddr, const std::string& username, const std::string& sessionKey ) {
@ -114,20 +114,20 @@ bool UserManager::DeleteUser ( const SystemAddress& sysAddr ) {
if (std::count(m_UsersToDelete.begin(), m_UsersToDelete.end(), it->second)) return false;
m_UsersToDelete.push_back(it->second);
m_Users.erase(it);
return true;
}
return false;
}
void UserManager::DeletePendingRemovals()
void UserManager::DeletePendingRemovals()
{
for (auto* user : m_UsersToDelete)
{
Game::logger->Log("UserManager", "Deleted user %i\n", user->GetAccountID());
Game::logger->Log("UserManager", "Deleted user %i", user->GetAccountID());
delete user;
}
@ -140,10 +140,10 @@ bool UserManager::IsNameAvailable ( const std::string& requestedName ) {
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("SELECT id FROM charinfo WHERE name=? OR pending_name=? LIMIT 1;");
stmt->setString(1, requestedName.c_str());
stmt->setString(2, requestedName.c_str());
sql::ResultSet* res = stmt->executeQuery();
if (res->rowsCount() == 0) toReturn = true;
delete stmt;
delete res;
return toReturn;
@ -158,33 +158,33 @@ bool UserManager::IsNamePreapproved ( const std::string& requestedName ) {
for (std::string& s : m_PreapprovedNames) {
if (s == requestedName) return true;
}
for (std::string& s : m_FirstNames) {
if (s == requestedName) return true;
}
for (std::string& s : m_MiddleNames) {
if (s == requestedName) return true;
}
for (std::string& s : m_LastNames) {
if (s == requestedName) return true;
}
return false;
}
void UserManager::RequestCharacterList ( const SystemAddress& sysAddr ) {
User* u = GetUser(sysAddr);
if (!u) return;
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("SELECT id FROM charinfo WHERE account_id=? ORDER BY last_login DESC LIMIT 4;");
stmt->setUInt(1, u->GetAccountID());
sql::ResultSet* res = stmt->executeQuery();
if (res->rowsCount() > 0) {
std::vector<Character*>& chars = u->GetCharacters();
for (size_t i = 0; i < chars.size(); ++i)
{
if (chars[i]->GetEntity() == nullptr) // We don't have entity data to save
@ -209,9 +209,9 @@ void UserManager::RequestCharacterList ( const SystemAddress& sysAddr ) {
delete chars[i];
}
chars.clear();
while (res->next()) {
LWOOBJID objID = res->getUInt64(1);
Character* character = new Character(uint32_t(objID), u);
@ -221,14 +221,14 @@ void UserManager::RequestCharacterList ( const SystemAddress& sysAddr ) {
delete res;
delete stmt;
WorldPackets::SendCharacterList(sysAddr, u);
}
void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet) {
User* u = GetUser(sysAddr);
if (!u) return;
std::string name = PacketUtils::ReadString(8, packet, true);
uint32_t firstNameIndex = PacketUtils::ReadPacketU32(74, packet);
@ -246,29 +246,29 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
uint32_t eyebrows = PacketUtils::ReadPacketU32(123, packet);
uint32_t eyes = PacketUtils::ReadPacketU32(127, packet);
uint32_t mouth = PacketUtils::ReadPacketU32(131, packet);
LOT shirtLOT = FindCharShirtID(shirtColor, shirtStyle);
LOT pantsLOT = FindCharPantsID(pantsColor);
if (name != "" && !UserManager::IsNameAvailable(name)) {
Game::logger->Log("UserManager", "AccountID: %i chose unavailable name: %s\n", u->GetAccountID(), name.c_str());
Game::logger->Log("UserManager", "AccountID: %i chose unavailable name: %s", u->GetAccountID(), name.c_str());
WorldPackets::SendCharacterCreationResponse(sysAddr, CREATION_RESPONSE_CUSTOM_NAME_IN_USE);
return;
}
if (!IsNameAvailable(predefinedName)) {
Game::logger->Log("UserManager", "AccountID: %i chose unavailable predefined name: %s\n", u->GetAccountID(), predefinedName.c_str());
Game::logger->Log("UserManager", "AccountID: %i chose unavailable predefined name: %s", u->GetAccountID(), predefinedName.c_str());
WorldPackets::SendCharacterCreationResponse(sysAddr, CREATION_RESPONSE_PREDEFINED_NAME_IN_USE);
return;
}
if (name == "") {
Game::logger->Log("UserManager", "AccountID: %i is creating a character with predefined name: %s\n", u->GetAccountID(), predefinedName.c_str());
Game::logger->Log("UserManager", "AccountID: %i is creating a character with predefined name: %s", u->GetAccountID(), predefinedName.c_str());
}
else {
Game::logger->Log("UserManager", "AccountID: %i is creating a character with name: %s (temporary: %s)\n", u->GetAccountID(), name.c_str(), predefinedName.c_str());
Game::logger->Log("UserManager", "AccountID: %i is creating a character with name: %s (temporary: %s)", u->GetAccountID(), name.c_str(), predefinedName.c_str());
}
//Now that the name is ok, we can get an objectID from Master:
ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t objectID) {
sql::PreparedStatement* overlapStmt = Database::CreatePreppedStmt("SELECT id FROM charinfo WHERE id = ?");
@ -277,47 +277,47 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
auto* overlapResult = overlapStmt->executeQuery();
if (overlapResult->next()) {
Game::logger->Log("UserManager", "Character object id unavailable, check objectidtracker!\n");
Game::logger->Log("UserManager", "Character object id unavailable, check objectidtracker!");
WorldPackets::SendCharacterCreationResponse(sysAddr, CREATION_RESPONSE_OBJECT_ID_UNAVAILABLE);
return;
}
std::stringstream xml;
xml << "<obj v=\"1\"><mf hc=\"" << hairColor << "\" hs=\"" << hairStyle << "\" hd=\"0\" t=\"" << shirtColor << "\" l=\"" << pantsColor;
xml << "\" hdc=\"0\" cd=\"" << shirtStyle << "\" lh=\"" << lh << "\" rh=\"" << rh << "\" es=\"" << eyebrows << "\" ";
xml << "ess=\"" << eyes << "\" ms=\"" << mouth << "\"/>";
xml << "<char acct=\"" << u->GetAccountID() << "\" cc=\"0\" gm=\"0\" ft=\"0\" llog=\"" << time(NULL) << "\" ";
xml << "ls=\"0\" lzx=\"-626.5847\" lzy=\"613.3515\" lzz=\"-28.6374\" lzrx=\"0.0\" lzry=\"0.7015\" lzrz=\"0.0\" lzrw=\"0.7126\" ";
xml << "stt=\"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;\"></char>";
xml << "<dest hm=\"4\" hc=\"4\" im=\"0\" ic=\"0\" am=\"0\" ac=\"0\" d=\"0\"/>";
xml << "<inv><bag><b t=\"0\" m=\"20\"/><b t=\"1\" m=\"40\"/><b t=\"2\" m=\"240\"/><b t=\"3\" m=\"240\"/><b t=\"14\" m=\"40\"/></bag><items><in t=\"0\">";
std::string xmlSave1 = xml.str();
ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t idforshirt) {
std::stringstream xml2;
LWOOBJID lwoidforshirt = idforshirt;
lwoidforshirt = GeneralUtils::SetBit(lwoidforshirt, OBJECT_BIT_CHARACTER);
lwoidforshirt = GeneralUtils::SetBit(lwoidforshirt, OBJECT_BIT_PERSISTENT);
xml2 << xmlSave1 << "<i l=\"" << shirtLOT << "\" id=\"" << lwoidforshirt << "\" s=\"0\" c=\"1\" eq=\"1\" b=\"1\"/>";
std::string xmlSave2 = xml2.str();
ObjectIDManager::Instance()->RequestPersistentID([=](uint32_t idforpants) {
LWOOBJID lwoidforpants = idforpants;
lwoidforpants = GeneralUtils::SetBit(lwoidforpants, OBJECT_BIT_CHARACTER);
lwoidforpants = GeneralUtils::SetBit(lwoidforpants, OBJECT_BIT_PERSISTENT);
std::stringstream xml3;
xml3 << xmlSave2 << "<i l=\"" << pantsLOT << "\" id=\"" << lwoidforpants << "\" s=\"1\" c=\"1\" eq=\"1\" b=\"1\"/>";
xml3 << "</in></items></inv><lvl l=\"1\" cv=\"1\" sb=\"500\"/><flag></flag></obj>";
//Check to see if our name was pre-approved:
bool nameOk = IsNamePreapproved(name);
if (!nameOk && u->GetMaxGMLevel() > 1) nameOk = true;
if (name != "") {
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("INSERT INTO `charinfo`(`id`, `account_id`, `name`, `pending_name`, `needs_rename`, `last_login`) VALUES (?,?,?,?,?,?)");
stmt->setUInt(1, objectID);
@ -326,12 +326,12 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
stmt->setString(4, name.c_str());
stmt->setBoolean(5, false);
stmt->setUInt64(6, time(NULL));
if (nameOk) {
stmt->setString(3, name.c_str());
stmt->setString(4, "");
}
stmt->execute();
delete stmt;
} else {
@ -342,18 +342,18 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
stmt->setString(4, "");
stmt->setBoolean(5, false);
stmt->setUInt64(6, time(NULL));
stmt->execute();
delete stmt;
}
//Now finally insert our character xml:
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("INSERT INTO `charxml`(`id`, `xml_data`) VALUES (?,?)");
stmt->setUInt(1, objectID);
stmt->setString(2, xml3.str().c_str());
stmt->execute();
delete stmt;
WorldPackets::SendCharacterCreationResponse(sysAddr, CREATION_RESPONSE_SUCCESS);
UserManager::RequestCharacterList(sysAddr);
});
@ -364,28 +364,28 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet) {
User* u = GetUser(sysAddr);
if (!u) {
Game::logger->Log("UserManager", "Couldn't get user to delete character\n");
Game::logger->Log("UserManager", "Couldn't get user to delete character");
return;
}
LWOOBJID objectID = PacketUtils::ReadPacketS64(8, packet);
uint32_t charID = static_cast<uint32_t>(objectID);
Game::logger->Log("UserManager", "Received char delete req for ID: %llu (%u)\n", objectID, charID);
Game::logger->Log("UserManager", "Received char delete req for ID: %llu (%u)", objectID, charID);
//Check if this user has this character:
bool hasCharacter = false;
std::vector<Character*>& characters = u->GetCharacters();
for (size_t i = 0; i < characters.size(); ++i) {
if (characters[i]->GetID() == charID) { hasCharacter = true; }
}
if (!hasCharacter) {
Game::logger->Log("UserManager", "User %i tried to delete a character that it does not own!\n", u->GetAccountID());
Game::logger->Log("UserManager", "User %i tried to delete a character that it does not own!", u->GetAccountID());
WorldPackets::SendCharacterDeleteResponse(sysAddr, false);
}
else {
Game::logger->Log("UserManager", "Deleting character %i\n", charID);
Game::logger->Log("UserManager", "Deleting character %i", charID);
{
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("DELETE FROM charxml WHERE id=? LIMIT 1;");
stmt->setUInt64(1, charID);
@ -453,7 +453,7 @@ void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet)
stmt->execute();
delete stmt;
}
WorldPackets::SendCharacterDeleteResponse(sysAddr, true);
}
}
@ -461,37 +461,37 @@ void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet)
void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet) {
User* u = GetUser(sysAddr);
if (!u) {
Game::logger->Log("UserManager", "Couldn't get user to delete character\n");
Game::logger->Log("UserManager", "Couldn't get user to delete character");
return;
}
LWOOBJID objectID = PacketUtils::ReadPacketS64(8, packet);
objectID = GeneralUtils::ClearBit(objectID, OBJECT_BIT_CHARACTER);
objectID = GeneralUtils::ClearBit(objectID, OBJECT_BIT_PERSISTENT);
uint32_t charID = static_cast<uint32_t>(objectID);
Game::logger->Log("UserManager", "Received char rename request for ID: %llu (%u)\n", objectID, charID);
Game::logger->Log("UserManager", "Received char rename request for ID: %llu (%u)", objectID, charID);
std::string newName = PacketUtils::ReadString(16, packet, true);
Character* character = nullptr;
//Check if this user has this character:
bool hasCharacter = false;
std::vector<Character*>& characters = u->GetCharacters();
for (size_t i = 0; i < characters.size(); ++i) {
if (characters[i]->GetID() == charID) { hasCharacter = true; character = characters[i]; }
}
if (!hasCharacter || !character) {
Game::logger->Log("UserManager", "User %i tried to rename a character that it does not own!\n", u->GetAccountID());
Game::logger->Log("UserManager", "User %i tried to rename a character that it does not own!", u->GetAccountID());
WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_UNKNOWN_ERROR);
} else if (hasCharacter && character) {
if (newName == character->GetName()) {
WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_NAME_UNAVAILABLE);
return;
}
if (IsNameAvailable(newName)) {
if (IsNamePreapproved(newName)) {
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("UPDATE charinfo SET name=?, pending_name='', needs_rename=0, last_login=? WHERE id=? LIMIT 1");
@ -500,8 +500,8 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
stmt->setUInt(3, character->GetID());
stmt->execute();
delete stmt;
Game::logger->Log("UserManager", "Character %s now known as %s\n", character->GetName().c_str(), newName.c_str());
Game::logger->Log("UserManager", "Character %s now known as %s", character->GetName().c_str(), newName.c_str());
WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_SUCCESS);
UserManager::RequestCharacterList(sysAddr);
} else {
@ -511,8 +511,8 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
stmt->setUInt(3, character->GetID());
stmt->execute();
delete stmt;
Game::logger->Log("UserManager", "Character %s has been renamed to %s and is pending approval by a moderator.\n", character->GetName().c_str(), newName.c_str());
Game::logger->Log("UserManager", "Character %s has been renamed to %s and is pending approval by a moderator.", character->GetName().c_str(), newName.c_str());
WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_SUCCESS);
UserManager::RequestCharacterList(sysAddr);
}
@ -520,7 +520,7 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_NAME_IN_USE);
}
} else {
Game::logger->Log("UserManager", "Unknown error occurred when renaming character, either hasCharacter or character variable != true.\n");
Game::logger->Log("UserManager", "Unknown error occurred when renaming character, either hasCharacter or character variable != true.");
WorldPackets::SendCharacterRenameResponse(sysAddr, RENAME_RESPONSE_UNKNOWN_ERROR);
}
}
@ -528,30 +528,30 @@ void UserManager::RenameCharacter(const SystemAddress& sysAddr, Packet* packet)
void UserManager::LoginCharacter(const SystemAddress& sysAddr, uint32_t playerID) {
User* u = GetUser(sysAddr);
if (!u) {
Game::logger->Log("UserManager", "Couldn't get user to log in character\n");
Game::logger->Log("UserManager", "Couldn't get user to log in character");
return;
}
Character* character = nullptr;
bool hasCharacter = false;
std::vector<Character*>& characters = u->GetCharacters();
for (size_t i = 0; i < characters.size(); ++i) {
if (characters[i]->GetID() == playerID) { hasCharacter = true; character = characters[i]; }
}
if (hasCharacter && character) {
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("UPDATE charinfo SET last_login=? WHERE id=? LIMIT 1");
stmt->setUInt64(1, time(NULL));
stmt->setUInt(2, playerID);
stmt->execute();
delete stmt;
uint32_t zoneID = character->GetZoneID();
if (zoneID == LWOZONEID_INVALID) zoneID = 1000; //Send char to VE
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, zoneID, character->GetZoneClone(), false, [=](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i\n", character->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", character->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
if (character) {
character->SetZoneID(zoneID);
character->SetZoneInstance(zoneInstance);
@ -561,7 +561,7 @@ void UserManager::LoginCharacter(const SystemAddress& sysAddr, uint32_t playerID
return;
});
} else {
Game::logger->Log("UserManager", "Unknown error occurred when logging in a character, either hasCharacter or character variable != true.\n");
Game::logger->Log("UserManager", "Unknown error occurred when logging in a character, either hasCharacter or character variable != true.");
}
}

View File

@ -37,7 +37,7 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b
for (auto target : targets)
{
branch.target = target;
this->m_action->Handle(context, bitStream, branch);
}
}
@ -48,7 +48,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
if (self == nullptr)
{
Game::logger->Log("TacArcBehavior", "Invalid self for (%llu)!\n", context->originator);
Game::logger->Log("TacArcBehavior", "Invalid self for (%llu)!", context->originator);
return;
}
@ -81,7 +81,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
if (entity == nullptr)
{
Game::logger->Log("TacArcBehavior", "Invalid target (%llu) for (%llu)!\n", validTarget, context->originator);
Game::logger->Log("TacArcBehavior", "Invalid target (%llu) for (%llu)!", validTarget, context->originator);
continue;
}
@ -90,7 +90,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
{
continue;
}
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
if (destroyableComponent == nullptr)
@ -120,7 +120,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
});
const uint32_t size = targets.size();
bitStream->Write(size);
if (size == 0)
@ -133,10 +133,10 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
for (auto* target : targets)
{
bitStream->Write(target->GetObjectID());
PlayFx(u"cast", context->originator, target->GetObjectID());
}
for (auto* target : targets)
{
branch.target = target->GetObjectID();

View File

@ -21,7 +21,7 @@ void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
return;
}
bitStream->AlignReadToByteBoundary();
uint16_t allocatedBits;
@ -69,7 +69,7 @@ void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
this->m_onSuccess->Handle(context, bitStream, branch);
break;
default:
Game::logger->Log("BasicAttackBehavior", "Unknown success state (%i)!\n", successState);
Game::logger->Log("BasicAttackBehavior", "Unknown success state (%i)!", successState);
break;
}
@ -79,10 +79,10 @@ void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
void BasicAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
auto* self = EntityManager::Instance()->GetEntity(context->originator);
if (self == nullptr) {
Game::logger->Log("BasicAttackBehavior", "Invalid self entity (%llu)!\n", context->originator);
Game::logger->Log("BasicAttackBehavior", "Invalid self entity (%llu)!", context->originator);
return;
}
bitStream->AlignWriteToByteBoundary();
const auto allocatedAddress = bitStream->GetWriteOffset();
@ -127,7 +127,7 @@ void BasicAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream*
this->m_onSuccess->Calculate(context, bitStream, branch);
break;
default:
Game::logger->Log("BasicAttackBehavior", "Unknown success state (%i)!\n", successState);
Game::logger->Log("BasicAttackBehavior", "Unknown success state (%i)!", successState);
break;
}

View File

@ -175,7 +175,7 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId)
behavior = new SpeedBehavior(behaviorId);
break;
case BehaviorTemplates::BEHAVIOR_DARK_INSPIRATION: break;
case BehaviorTemplates::BEHAVIOR_LOOT_BUFF:
case BehaviorTemplates::BEHAVIOR_LOOT_BUFF:
behavior = new LootBuffBehavior(behaviorId);
break;
case BehaviorTemplates::BEHAVIOR_VENTURE_VISION:
@ -269,13 +269,13 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId)
case BehaviorTemplates::BEHAVIOR_MOUNT: break;
case BehaviorTemplates::BEHAVIOR_SKILL_SET: break;
default:
//Game::logger->Log("Behavior", "Failed to load behavior with invalid template id (%i)!\n", templateId);
//Game::logger->Log("Behavior", "Failed to load behavior with invalid template id (%i)!", templateId);
break;
}
if (behavior == nullptr)
{
//Game::logger->Log("Behavior", "Failed to load unimplemented template id (%i)!\n", templateId);
//Game::logger->Log("Behavior", "Failed to load unimplemented template id (%i)!", templateId);
behavior = new EmptyBehavior(behaviorId);
}
@ -298,7 +298,7 @@ BehaviorTemplates Behavior::GetBehaviorTemplate(const uint32_t behaviorId) {
}
if (templateID == BehaviorTemplates::BEHAVIOR_EMPTY && behaviorId != 0) {
Game::logger->Log("Behavior", "Failed to load behavior template with id (%i)!\n", behaviorId);
Game::logger->Log("Behavior", "Failed to load behavior template with id (%i)!", behaviorId);
}
return templateID;
@ -432,7 +432,7 @@ Behavior::Behavior(const uint32_t behaviorId)
// Make sure we do not proceed if we are trying to load an invalid behavior
if (templateInDatabase.behaviorID == 0)
{
Game::logger->Log("Behavior", "Failed to load behavior with id (%i)!\n", behaviorId);
Game::logger->Log("Behavior", "Failed to load behavior with id (%i)!", behaviorId);
this->m_effectId = 0;
this->m_effectHandle = nullptr;

View File

@ -33,7 +33,7 @@ uint32_t BehaviorContext::GetUniqueSkillId() const
if (entity == nullptr)
{
Game::logger->Log("BehaviorContext", "Invalid entity for (%llu)!\n", this->originator);
Game::logger->Log("BehaviorContext", "Invalid entity for (%llu)!", this->originator);
return 0;
}
@ -42,7 +42,7 @@ uint32_t BehaviorContext::GetUniqueSkillId() const
if (component == nullptr)
{
Game::logger->Log("BehaviorContext", "No skill component attached to (%llu)!\n", this->originator);;
Game::logger->Log("BehaviorContext", "No skill component attached to (%llu)!", this->originator);;
return 0;
}
@ -65,7 +65,7 @@ void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* beha
void BehaviorContext::RegisterTimerBehavior(Behavior* behavior, const BehaviorBranchContext& branchContext, const LWOOBJID second)
{
BehaviorTimerEntry entry;
entry.time = branchContext.duration;
entry.behavior = behavior;
entry.branchContext = branchContext;
@ -103,7 +103,7 @@ void BehaviorContext::ExecuteUpdates()
auto* entity = EntityManager::Instance()->GetEntity(id);
if (entity == nullptr) continue;
EntityManager::Instance()->SerializeEntity(entity);
}
@ -111,7 +111,7 @@ void BehaviorContext::ExecuteUpdates()
}
void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bitStream)
{
{
BehaviorSyncEntry entry;
auto found = false;
@ -121,7 +121,7 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bit
for (auto i = 0u; i < this->syncEntries.size(); ++i)
{
const auto syncEntry = this->syncEntries.at(i);
if (syncEntry.handle == syncId)
{
found = true;
@ -135,7 +135,7 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bit
if (!found)
{
Game::logger->Log("BehaviorContext", "Failed to find behavior sync entry with sync id (%i)!\n", syncId);
Game::logger->Log("BehaviorContext", "Failed to find behavior sync entry with sync id (%i)!", syncId);
return;
}
@ -145,8 +145,8 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bit
if (behavior == nullptr)
{
Game::logger->Log("BehaviorContext", "Invalid behavior for sync id (%i)!\n", syncId);
Game::logger->Log("BehaviorContext", "Invalid behavior for sync id (%i)!", syncId);
return;
}
@ -166,7 +166,7 @@ void BehaviorContext::Update(const float deltaTime)
this->timerEntries[i] = entry;
}
if (entry.time > 0)
{
continue;
@ -174,7 +174,7 @@ void BehaviorContext::Update(const float deltaTime)
entry.behavior->Timer(this, entry.branchContext, entry.second);
}
std::vector<BehaviorTimerEntry> valid;
for (const auto& entry : this->timerEntries)
@ -226,7 +226,7 @@ void BehaviorContext::InvokeEnd(const uint32_t id)
bool BehaviorContext::CalculateUpdate(const float deltaTime)
{
auto any = false;
for (auto i = 0u; i < this->syncEntries.size(); ++i)
{
auto entry = this->syncEntries.at(i);
@ -241,7 +241,7 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime)
if (entry.time > 0)
{
any = true;
continue;
}
@ -267,7 +267,7 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime)
PacketUtils::WriteHeader(message, CLIENT, MSG_CLIENT_GAME_MSG);
message.Write(this->originator);
echo.Serialize(&message);
Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true);
}
@ -293,7 +293,7 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime)
return any;
}
void BehaviorContext::Interrupt()
void BehaviorContext::Interrupt()
{
std::vector<BehaviorSyncEntry> keptSync {};
@ -303,7 +303,7 @@ void BehaviorContext::Interrupt()
keptSync.push_back(entry);
}
this->syncEntries = keptSync;
}
@ -330,10 +330,10 @@ std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, in
auto* entity = EntityManager::Instance()->GetEntity(this->caster);
std::vector<LWOOBJID> targets;
if (entity == nullptr)
{
Game::logger->Log("BehaviorContext", "Invalid entity for (%llu)!\n", this->originator);
Game::logger->Log("BehaviorContext", "Invalid entity for (%llu)!", this->originator);
return targets;
}
@ -360,12 +360,12 @@ std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, in
{
return targets;
}
auto entities = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_CONTROLLABLE_PHYSICS);
for (auto* candidate : entities)
{
const auto id = candidate->GetObjectID();
if ((id != entity->GetObjectID() || targetSelf) && destroyableComponent->CheckValidity(id, ignoreFaction || includeFaction, targetEnemy, targetFriend))
{
targets.push_back(id);

View File

@ -15,7 +15,7 @@ void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
if (entity == nullptr)
{
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!\n", branch.target);
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
return;
}
@ -52,7 +52,7 @@ void BlockBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branc
if (entity == nullptr)
{
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!\n", branch.target);
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
return;
}

View File

@ -10,12 +10,12 @@
void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
{
const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator;
auto* entity = EntityManager::Instance()->GetEntity(target);
if (entity == nullptr)
{
Game::logger->Log("BuffBehavior", "Invalid target (%llu)!\n", target);
Game::logger->Log("BuffBehavior", "Invalid target (%llu)!", target);
return;
}
@ -24,7 +24,7 @@ void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream
if (component == nullptr)
{
Game::logger->Log("BuffBehavior", "Invalid target, no destroyable component (%llu)!\n", target);
Game::logger->Log("BuffBehavior", "Invalid target, no destroyable component (%llu)!", target);
return;
}
@ -51,12 +51,12 @@ void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream
void BuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch)
{
const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator;
auto* entity = EntityManager::Instance()->GetEntity(target);
if (entity == nullptr)
{
Game::logger->Log("BuffBehavior", "Invalid target (%llu)!\n", target);
Game::logger->Log("BuffBehavior", "Invalid target (%llu)!", target);
return;
}
@ -65,7 +65,7 @@ void BuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch
if (component == nullptr)
{
Game::logger->Log("BuffBehavior", "Invalid target, no destroyable component (%llu)!\n", target);
Game::logger->Log("BuffBehavior", "Invalid target, no destroyable component (%llu)!", target);
return;
}
@ -73,7 +73,7 @@ void BuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch
component->SetMaxHealth(component->GetMaxHealth() - this->m_health);
component->SetMaxArmor(component->GetMaxArmor() - this->m_armor);
component->SetMaxImagination(component->GetMaxImagination() - this->m_imagination);
EntityManager::Instance()->SerializeEntity(entity);
}

View File

@ -8,7 +8,7 @@
#include "dLogger.h"
#include "PossessableComponent.h"
void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
{
GameMessages::SendVehicleAddPassiveBoostAction(branch.target, UNASSIGNED_SYSTEM_ADDRESS);
@ -19,7 +19,7 @@ void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
return;
}
Game::logger->Log("Car boost", "Activating car boost!\n");
Game::logger->Log("Car boost", "Activating car boost!");
auto* possessableComponent = entity->GetComponent<PossessableComponent>();
if (possessableComponent != nullptr) {
@ -29,7 +29,7 @@ void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
auto* characterComponent = possessor->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) {
Game::logger->Log("Car boost", "Tracking car boost!\n");
Game::logger->Log("Car boost", "Tracking car boost!");
characterComponent->UpdatePlayerStatistic(RacingCarBoostsActivated);
}
}
@ -43,7 +43,7 @@ void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
});
}
void CarBoostBehavior::Load()
void CarBoostBehavior::Load()
{
m_Action = GetAction("action");

View File

@ -13,7 +13,7 @@ void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
if (target == nullptr)
{
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!\n", branch.target);
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
return;
}
@ -32,7 +32,7 @@ void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
context->RegisterTimerBehavior(this, branch, target->GetObjectID());
}
void DamageAbsorptionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
void DamageAbsorptionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
{
Handle(context, bitStream, branch);
}
@ -43,11 +43,11 @@ void DamageAbsorptionBehavior::Timer(BehaviorContext* context, BehaviorBranchCon
if (target == nullptr)
{
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!\n", second);
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", second);
return;
}
auto* destroyable = target->GetComponent<DestroyableComponent>();
if (destroyable == nullptr)
@ -56,7 +56,7 @@ void DamageAbsorptionBehavior::Timer(BehaviorContext* context, BehaviorBranchCon
}
const auto present = static_cast<uint32_t>(destroyable->GetDamageToAbsorb());
const auto toRemove = std::min(present, this->m_absorbAmount);
destroyable->SetDamageToAbsorb(present - toRemove);

View File

@ -13,7 +13,7 @@ void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream
if (target == nullptr)
{
Game::logger->Log("DamageReductionBehavior", "Failed to find target (%llu)!\n", branch.target);
Game::logger->Log("DamageReductionBehavior", "Failed to find target (%llu)!", branch.target);
return;
}
@ -26,11 +26,11 @@ void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream
}
destroyable->SetDamageReduction(m_ReductionAmount);
context->RegisterTimerBehavior(this, branch, target->GetObjectID());
}
void DamageReductionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
void DamageReductionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
{
Handle(context, bitStream, branch);
}
@ -41,11 +41,11 @@ void DamageReductionBehavior::Timer(BehaviorContext* context, BehaviorBranchCont
if (target == nullptr)
{
Game::logger->Log("DamageReductionBehavior", "Failed to find target (%llu)!\n", second);
Game::logger->Log("DamageReductionBehavior", "Failed to find target (%llu)!", second);
return;
}
auto* destroyable = target->GetComponent<DestroyableComponent>();
if (destroyable == nullptr)

View File

@ -12,7 +12,7 @@ void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_strea
if (entity == nullptr)
{
Game::logger->Log("HealBehavior", "Failed to find entity for (%llu)!\n", branch.target);
Game::logger->Log("HealBehavior", "Failed to find entity for (%llu)!", branch.target);
return;
}
@ -21,11 +21,11 @@ void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_strea
if (destroyable == nullptr)
{
Game::logger->Log("HealBehavior", "Failed to find destroyable component for %(llu)!\n", branch.target);
Game::logger->Log("HealBehavior", "Failed to find destroyable component for %(llu)!", branch.target);
return;
}
destroyable->Heal(this->m_health);
}

View File

@ -13,7 +13,7 @@ void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
if (target == nullptr)
{
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!\n", branch.target);
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
return;
}
@ -31,11 +31,11 @@ void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
}
destroyable->PushImmunity();
context->RegisterTimerBehavior(this, branch, target->GetObjectID());
}
void ImmunityBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
void ImmunityBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
{
Handle(context, bitStream, branch);
}
@ -46,7 +46,7 @@ void ImmunityBehavior::Timer(BehaviorContext* context, BehaviorBranchContext bra
if (target == nullptr)
{
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!\n", second);
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", second);
return;
}

View File

@ -8,13 +8,13 @@ void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream*
if (this->m_groundAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
this->m_jumpAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
this->m_fallingAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
this->m_doubleJumpAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
this->m_doubleJumpAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
this->m_airAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
this->m_jetpackAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY)
{
return;
}
uint32_t movementType;
bitStream->Read(movementType);
@ -40,13 +40,13 @@ void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream*
this->m_jetpackAction->Handle(context, bitStream, branch);
break;
default:
Game::logger->Log("MovementSwitchBehavior", "Invalid movement behavior type (%i)!\n", movementType);
Game::logger->Log("MovementSwitchBehavior", "Invalid movement behavior type (%i)!", movementType);
break;
}
}
void MovementSwitchBehavior::Load()
{
{
this->m_airAction = GetAction("air_action");
this->m_doubleJumpAction = GetAction("double_jump_action");

View File

@ -12,12 +12,12 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
LWOOBJID target;
bitStream->Read(target);
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
if (entity == nullptr)
{
Game::logger->Log("ProjectileAttackBehavior", "Failed to find originator (%llu)!\n", context->originator);
Game::logger->Log("ProjectileAttackBehavior", "Failed to find originator (%llu)!", context->originator);
return;
}
@ -26,7 +26,7 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
if (skillComponent == nullptr)
{
Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!\n", -context->originator);
Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", -context->originator);
return;
}
@ -44,7 +44,7 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
LWOOBJID projectileId;
bitStream->Read(projectileId);
branch.target = target;
branch.isProjectile = true;
branch.referencePosition = targetEntity == nullptr ? entity->GetPosition() : targetEntity->GetPosition();
@ -61,7 +61,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
if (entity == nullptr)
{
Game::logger->Log("ProjectileAttackBehavior", "Failed to find originator (%llu)!\n", context->originator);
Game::logger->Log("ProjectileAttackBehavior", "Failed to find originator (%llu)!", context->originator);
return;
}
@ -70,7 +70,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
if (skillComponent == nullptr)
{
Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!\n", context->originator);
Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", context->originator);
return;
@ -80,8 +80,8 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
if (other == nullptr)
{
Game::logger->Log("ProjectileAttackBehavior", "Invalid projectile target (%llu)!\n", branch.target);
Game::logger->Log("ProjectileAttackBehavior", "Invalid projectile target (%llu)!", branch.target);
return;
}

View File

@ -12,7 +12,7 @@ void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_str
if (entity == nullptr)
{
Game::logger->Log("RepairBehavior", "Failed to find entity for (%llu)!\n", branch.target);
Game::logger->Log("RepairBehavior", "Failed to find entity for (%llu)!", branch.target);
return;
}
@ -21,11 +21,11 @@ void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_str
if (destroyable == nullptr)
{
Game::logger->Log("RepairBehavior", "Failed to find destroyable component for %(llu)!\n", branch.target);
Game::logger->Log("RepairBehavior", "Failed to find destroyable component for %(llu)!", branch.target);
return;
}
destroyable->Repair(this->m_armor);
}

View File

@ -14,7 +14,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
if (origin == nullptr)
{
Game::logger->Log("SpawnBehavior", "Failed to find self entity (%llu)!\n", context->originator);
Game::logger->Log("SpawnBehavior", "Failed to find self entity (%llu)!", context->originator);
return;
}
@ -28,7 +28,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
origin = target;
}
}
EntityInfo info;
info.lot = this->m_lot;
info.pos = origin->GetPosition();
@ -47,7 +47,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
if (entity == nullptr)
{
Game::logger->Log("SpawnBehavior", "Failed to spawn entity (%i)!\n", this->m_lot);
Game::logger->Log("SpawnBehavior", "Failed to spawn entity (%i)!", this->m_lot);
return;
}
@ -61,7 +61,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
{
rebuildComponent->SetRepositionPlayer(false);
}
EntityManager::Instance()->ConstructEntity(entity);
if (branch.duration > 0)
@ -79,7 +79,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
});
}
void SpawnBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
void SpawnBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
{
Handle(context, bitStream, branch);
}
@ -90,7 +90,7 @@ void SpawnBehavior::Timer(BehaviorContext* context, const BehaviorBranchContext
if (entity == nullptr)
{
Game::logger->Log("SpawnBehavior", "Failed to find spawned entity (%llu)!\n", second);
Game::logger->Log("SpawnBehavior", "Failed to find spawned entity (%llu)!", second);
return;
}
@ -100,7 +100,7 @@ void SpawnBehavior::Timer(BehaviorContext* context, const BehaviorBranchContext
if (destroyable == nullptr)
{
entity->Smash(context->originator);
return;
}

View File

@ -22,7 +22,7 @@ void StunBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream
if (target == nullptr)
{
Game::logger->Log("StunBehavior", "Failed to find target (%llu)!\n", branch.target);
Game::logger->Log("StunBehavior", "Failed to find target (%llu)!", branch.target);
return;
}
@ -30,7 +30,7 @@ void StunBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream
/*
* If our target is an enemy we can go ahead and stun it.
*/
auto* combatAiComponent = static_cast<BaseCombatAIComponent*>(target->GetComponent(COMPONENT_TYPE_BASE_COMBAT_AI));
if (combatAiComponent == nullptr)
@ -49,7 +49,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr
if (self == nullptr)
{
Game::logger->Log("StunBehavior", "Invalid self entity (%llu)!\n", context->originator);
Game::logger->Log("StunBehavior", "Invalid self entity (%llu)!", context->originator);
return;
}
@ -57,7 +57,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr
/*
* See if we can stun ourselves
*/
auto* combatAiComponent = static_cast<BaseCombatAIComponent*>(self->GetComponent(COMPONENT_TYPE_BASE_COMBAT_AI));
if (combatAiComponent == nullptr)
@ -66,7 +66,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr
}
combatAiComponent->Stun(branch.duration);
return;
}
@ -88,7 +88,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr
if (target == nullptr)
{
Game::logger->Log("StunBehavior", "Failed to find target (%llu)!\n", branch.target);
Game::logger->Log("StunBehavior", "Failed to find target (%llu)!", branch.target);
return;
}

View File

@ -23,13 +23,13 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
}
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
if (destroyableComponent == nullptr)
{
return;
}
Game::logger->Log("SwitchBehavior", "[%i] State: (%d), imagination: (%i) / (%f)\n", entity->GetLOT(), state, destroyableComponent->GetImagination(), destroyableComponent->GetMaxImagination());
Game::logger->Log("SwitchBehavior", "[%i] State: (%d), imagination: (%i) / (%f)", entity->GetLOT(), state, destroyableComponent->GetImagination(), destroyableComponent->GetMaxImagination());
if (state || (entity->GetLOT() == 8092 && destroyableComponent->GetImagination() >= m_imagination))
{
@ -44,7 +44,7 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
{
auto state = true;
if (this->m_imagination > 0 || !this->m_isEnemyFaction)
{
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
@ -77,11 +77,11 @@ void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
void SwitchBehavior::Load()
{
this->m_actionTrue = GetAction("action_true");
this->m_actionFalse = GetAction("action_false");
this->m_imagination = GetInt("imagination");
this->m_isEnemyFaction = GetBoolean("isEnemyFaction");
this->m_targetHasBuff = GetInt("target_has_buff");

View File

@ -27,7 +27,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
if (this->m_checkEnv)
{
bool blocked = false;
bitStream->Read(blocked);
if (blocked)
@ -63,7 +63,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre
for (auto target : targets)
{
branch.target = target;
this->m_action->Handle(context, bitStream, branch);
}
}
@ -77,7 +77,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
{
auto* self = EntityManager::Instance()->GetEntity(context->originator);
if (self == nullptr) {
Game::logger->Log("TacArcBehavior", "Invalid self for (%llu)!\n", context->originator);
Game::logger->Log("TacArcBehavior", "Invalid self for (%llu)!", context->originator);
return;
}
@ -102,7 +102,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
}
auto* combatAi = self->GetComponent<BaseCombatAIComponent>();
const auto casterPosition = self->GetPosition();
auto reference = self->GetPosition(); //+ m_offset;
@ -144,7 +144,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
if (entity == nullptr)
{
Game::logger->Log("TacArcBehavior", "Invalid target (%llu) for (%llu)!\n", validTarget, context->originator);
Game::logger->Log("TacArcBehavior", "Invalid target (%llu) for (%llu)!", validTarget, context->originator);
continue;
}
@ -171,7 +171,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
// otherPosition is the position of the target.
// reference is the position of the caster.
// If we cast a ray forward from the caster, does it come within m_farWidth of the target?
const auto distance = Vector3::Distance(reference, otherPosition);
if (m_method == 2)
@ -185,7 +185,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
}
auto normalized = (reference - otherPosition) / distance;
const float degreeAngle = std::abs(Vector3::Angle(forward, normalized) * (180 / 3.14) - 180);
if (distance >= this->m_minDistance && this->m_maxDistance >= distance && degreeAngle <= 2 * this->m_angle)
@ -221,7 +221,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
}
context->foundTarget = true; // We want to continue with this behavior
const auto count = static_cast<uint32_t>(targets.size());
bitStream->Write(count);

View File

@ -12,13 +12,13 @@ void TauntBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
if (target == nullptr)
{
Game::logger->Log("TauntBehavior", "Failed to find target (%llu)!\n", branch.target);
Game::logger->Log("TauntBehavior", "Failed to find target (%llu)!", branch.target);
return;
}
auto* combatComponent = target->GetComponent<BaseCombatAIComponent>();
if (combatComponent != nullptr)
{
combatComponent->Taunt(context->originator, m_threatToAdd);
@ -31,13 +31,13 @@ void TauntBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitSt
if (target == nullptr)
{
Game::logger->Log("TauntBehavior", "Failed to find target (%llu)!\n", branch.target);
Game::logger->Log("TauntBehavior", "Failed to find target (%llu)!", branch.target);
return;
}
auto* combatComponent = target->GetComponent<BaseCombatAIComponent>();
if (combatComponent != nullptr)
{
combatComponent->Taunt(context->originator, m_threatToAdd);

View File

@ -23,11 +23,11 @@ void VerifyBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
if (self == nullptr)
{
Game::logger->Log("VerifyBehavior", "Invalid self for (%llu)\n", context->originator);
Game::logger->Log("VerifyBehavior", "Invalid self for (%llu)", context->originator);
return;
}
const auto distance = Vector3::DistanceSquared(self->GetPosition(), entity->GetPosition());
if (distance > this->m_range * this->m_range)

View File

@ -38,7 +38,7 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id)
auto componentQuery = CDClientDatabase::CreatePreppedStmt(
"SELECT aggroRadius, tetherSpeed, pursuitSpeed, softTetherRadius, hardTetherRadius FROM BaseCombatAIComponent WHERE id = ?;");
componentQuery.bind(1, (int) id);
auto componentResult = componentQuery.execQuery();
if (!componentResult.eof())
@ -76,7 +76,7 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id)
auto skillQuery = CDClientDatabase::CreatePreppedStmt(
"SELECT skillID, cooldown, behaviorID FROM SkillBehavior WHERE skillID IN (SELECT skillID FROM ObjectSkills WHERE objectTemplate = ?);");
skillQuery.bind(1, (int) parent->GetLOT());
auto result = skillQuery.execQuery();
while (!result.eof()) {
@ -254,7 +254,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
}
skillComponent->CalculateUpdate(deltaTime);
if (m_Disabled) return;
if (m_StunTime > 0.0f)
@ -362,19 +362,19 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
if (m_Target == LWOOBJID_EMPTY)
{
m_State = AiState::idle;
return;
}
m_Downtime = 0.5f;
auto* target = GetTargetEntity();
if (target != nullptr)
{
LookAt(target->GetPosition());
}
for (auto i = 0; i < m_SkillEntries.size(); ++i)
{
auto entry = m_SkillEntries.at(i);
@ -413,11 +413,11 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
if (m_MovementAI) reference = m_MovementAI->ApproximateLocation();
auto* target = GetTargetEntity();
if (target != nullptr && !m_DirtyThreat)
{
const auto targetPosition = target->GetPosition();
if (Vector3::DistanceSquared(targetPosition, m_StartPosition) < m_HardTetherRadius * m_HardTetherRadius)
{
return m_Target;
@ -492,7 +492,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
}
std::vector<LWOOBJID> deadThreats {};
for (const auto& threatTarget : m_ThreatEntries)
{
auto* entity = EntityManager::Instance()->GetEntity(threatTarget.first);
@ -526,7 +526,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
}
m_DirtyThreat = false;
if (optimalTarget == nullptr)
{
return LWOOBJID_EMPTY;
@ -577,7 +577,7 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
auto* entity = EntityManager::Instance()->GetEntity(target);
if (entity == nullptr) {
Game::logger->Log("BaseCombatAIComponent", "Invalid entity for checking validity (%llu)!\n", target);
Game::logger->Log("BaseCombatAIComponent", "Invalid entity for checking validity (%llu)!", target);
return false;
}
@ -591,7 +591,7 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
auto* referenceDestroyable = m_Parent->GetComponent<DestroyableComponent>();
if (referenceDestroyable == nullptr) {
Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!\n", m_Parent->GetObjectID());
Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_Parent->GetObjectID());
return false;
}
@ -601,7 +601,7 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
if (quickbuild != nullptr)
{
const auto state = quickbuild->GetState();
if (state != REBUILD_COMPLETED)
{
return false;
@ -662,7 +662,7 @@ const NiPoint3& BaseCombatAIComponent::GetStartPosition() const
return m_StartPosition;
}
void BaseCombatAIComponent::ClearThreat()
void BaseCombatAIComponent::ClearThreat()
{
m_ThreatEntries.clear();
@ -675,12 +675,12 @@ void BaseCombatAIComponent::Wander() {
}
m_MovementAI->SetHaltDistance(0);
const auto& info = m_MovementAI->GetInfo();
const auto div = static_cast<int>(info.wanderDelayMax);
m_Timer = (div == 0 ? 0 : GeneralUtils::GenerateRandomNumber<int>(0, div)) + info.wanderDelayMin; //set a random timer to stay put.
const float radius = info.wanderRadius * sqrt(static_cast<double>(GeneralUtils::GenerateRandomNumber<float>(0, 1))); //our wander radius + a bit of random range
const float theta = ((static_cast<double>(GeneralUtils::GenerateRandomNumber<float>(0, 1)) * 2 * PI));
@ -720,7 +720,7 @@ void BaseCombatAIComponent::OnAggro() {
}
m_MovementAI->SetHaltDistance(m_AttackRadius);
NiPoint3 targetPos = target->GetPosition();
NiPoint3 currentPos = m_MovementAI->GetCurrentPosition();
@ -731,7 +731,7 @@ void BaseCombatAIComponent::OnAggro() {
else if (Vector3::DistanceSquared(m_StartPosition, targetPos) > m_HardTetherRadius * m_HardTetherRadius) //Return to spawn if we're too far
{
m_MovementAI->SetSpeed(m_PursuitSpeed);
m_MovementAI->SetDestination(m_StartPosition);
}
else //Chase the player's new position
@ -768,7 +768,7 @@ void BaseCombatAIComponent::OnTether() {
m_MovementAI->SetSpeed(m_PursuitSpeed);
m_MovementAI->SetDestination(m_StartPosition);
m_State = AiState::aggro;
}
else {
@ -795,7 +795,7 @@ bool BaseCombatAIComponent::GetStunImmune() const
return m_StunImmune;
}
void BaseCombatAIComponent::SetStunImmune(bool value)
void BaseCombatAIComponent::SetStunImmune(bool value)
{
m_StunImmune = value;
}
@ -805,7 +805,7 @@ float BaseCombatAIComponent::GetTetherSpeed() const
return m_TetherSpeed;
}
void BaseCombatAIComponent::SetTetherSpeed(float value)
void BaseCombatAIComponent::SetTetherSpeed(float value)
{
m_TetherSpeed = value;
}
@ -816,7 +816,7 @@ void BaseCombatAIComponent::Stun(const float time) {
}
m_StunTime = time;
m_Stunned = true;
}
@ -848,13 +848,13 @@ bool BaseCombatAIComponent::GetDistabled() const
return m_Disabled;
}
void BaseCombatAIComponent::Sleep()
void BaseCombatAIComponent::Sleep()
{
m_dpEntity->SetSleeping(true);
m_dpEntityEnemy->SetSleeping(true);
}
void BaseCombatAIComponent::Wake()
void BaseCombatAIComponent::Wake()
{
m_dpEntity->SetSleeping(false);
m_dpEntityEnemy->SetSleeping(false);

View File

@ -12,7 +12,7 @@ BouncerComponent::BouncerComponent(Entity* parent) : Component(parent) {
m_PetEnabled = false;
m_PetBouncerEnabled = false;
m_PetSwitchLoaded = false;
if (parent->GetLOT() == 7625)
{
LookupPetSwitch();
@ -34,14 +34,14 @@ Entity* BouncerComponent::GetParentEntity() const
return m_Parent;
}
void BouncerComponent::SetPetEnabled(bool value)
void BouncerComponent::SetPetEnabled(bool value)
{
m_PetEnabled = value;
EntityManager::Instance()->SerializeEntity(m_Parent);
}
void BouncerComponent::SetPetBouncerEnabled(bool value)
void BouncerComponent::SetPetBouncerEnabled(bool value)
{
m_PetBouncerEnabled = value;
@ -57,7 +57,7 @@ void BouncerComponent::SetPetBouncerEnabled(bool value)
{
GameMessages::SendStopFXEffect(m_Parent, true, "PetOnSwitch");
}
}
bool BouncerComponent::GetPetEnabled() const
@ -70,7 +70,7 @@ bool BouncerComponent::GetPetBouncerEnabled() const
return m_PetBouncerEnabled;
}
void BouncerComponent::LookupPetSwitch()
void BouncerComponent::LookupPetSwitch()
{
const auto& groups = m_Parent->GetGroups();
@ -85,21 +85,21 @@ void BouncerComponent::LookupPetSwitch()
if (switchComponent != nullptr)
{
switchComponent->SetPetBouncer(this);
m_PetSwitchLoaded = true;
m_PetEnabled = true;
EntityManager::Instance()->SerializeEntity(m_Parent);
Game::logger->Log("BouncerComponent", "Loaded pet bouncer\n");
Game::logger->Log("BouncerComponent", "Loaded pet bouncer");
}
}
}
if (!m_PetSwitchLoaded)
{
Game::logger->Log("BouncerComponent", "Failed to load pet bouncer\n");
Game::logger->Log("BouncerComponent", "Failed to load pet bouncer");
m_Parent->AddCallbackTimer(0.5f, [this]() {
LookupPetSwitch();
});

View File

@ -49,11 +49,11 @@ void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUp
outBitStream->Write<uint32_t>(0);
}
}
outBitStream->Write0();
}
void BuffComponent::Update(float deltaTime)
void BuffComponent::Update(float deltaTime)
{
/**
* Loop through all buffs and apply deltaTime to ther time.
@ -138,7 +138,7 @@ void BuffComponent::ApplyBuff(const int32_t id, const float duration, const LWOO
m_Buffs.emplace(id, buff);
}
void BuffComponent::RemoveBuff(int32_t id)
void BuffComponent::RemoveBuff(int32_t id)
{
const auto& iter = m_Buffs.find(id);
@ -146,18 +146,18 @@ void BuffComponent::RemoveBuff(int32_t id)
{
return;
}
m_Buffs.erase(iter);
RemoveBuffEffect(id);
}
bool BuffComponent::HasBuff(int32_t id)
bool BuffComponent::HasBuff(int32_t id)
{
return m_Buffs.find(id) != m_Buffs.end();
}
void BuffComponent::ApplyBuffEffect(int32_t id)
void BuffComponent::ApplyBuffEffect(int32_t id)
{
const auto& parameters = GetBuffParameters(id);
for (const auto& parameter : parameters)
@ -209,7 +209,7 @@ void BuffComponent::ApplyBuffEffect(int32_t id)
}
}
void BuffComponent::RemoveBuffEffect(int32_t id)
void BuffComponent::RemoveBuffEffect(int32_t id)
{
const auto& parameters = GetBuffParameters(id);
for (const auto& parameter : parameters)
@ -261,7 +261,7 @@ void BuffComponent::RemoveBuffEffect(int32_t id)
}
}
void BuffComponent::RemoveAllBuffs()
void BuffComponent::RemoveAllBuffs()
{
for (const auto& buff : m_Buffs)
{
@ -271,12 +271,12 @@ void BuffComponent::RemoveAllBuffs()
m_Buffs.clear();
}
void BuffComponent::Reset()
void BuffComponent::Reset()
{
RemoveAllBuffs();
}
void BuffComponent::ReApplyBuffs()
void BuffComponent::ReApplyBuffs()
{
for (const auto& buff : m_Buffs)
{
@ -293,10 +293,10 @@ void BuffComponent::LoadFromXml(tinyxml2::XMLDocument* doc)
{
// Load buffs
auto* dest = doc->FirstChildElement("obj")->FirstChildElement("dest");
// Make sure we have a clean buff element.
auto* buffElement = dest->FirstChildElement("buff");
// Old character, no buffs to load
if (buffElement == nullptr)
{
@ -328,14 +328,14 @@ void BuffComponent::LoadFromXml(tinyxml2::XMLDocument* doc)
}
}
void BuffComponent::UpdateXml(tinyxml2::XMLDocument* doc)
void BuffComponent::UpdateXml(tinyxml2::XMLDocument* doc)
{
// Save buffs
auto* dest = doc->FirstChildElement("obj")->FirstChildElement("dest");
// Make sure we have a clean buff element.
auto* buffElement = dest->FirstChildElement("buff");
if (buffElement == nullptr)
{
buffElement = doc->NewElement("buff");
@ -357,12 +357,12 @@ void BuffComponent::UpdateXml(tinyxml2::XMLDocument* doc)
buffEntry->SetAttribute("s", buff.second.stacks);
buffEntry->SetAttribute("sr", buff.second.source);
buffEntry->SetAttribute("b", buff.second.behaviorID);
buffElement->LinkEndChild(buffEntry);
}
}
const std::vector<BuffParameter>& BuffComponent::GetBuffParameters(int32_t buffId)
const std::vector<BuffParameter>& BuffComponent::GetBuffParameters(int32_t buffId)
{
const auto& pair = m_Cache.find(buffId);
@ -376,7 +376,7 @@ const std::vector<BuffParameter>& BuffComponent::GetBuffParameters(int32_t buffI
query.bind(1, (int) buffId);
auto result = query.execQuery();
std::vector<BuffParameter> parameters {};
while (!result.eof())
@ -402,7 +402,7 @@ const std::vector<BuffParameter>& BuffComponent::GetBuffParameters(int32_t buffI
}
catch (std::invalid_argument& exception)
{
Game::logger->Log("BuffComponent", "Failed to parse value (%s): (%s)!\n", token.c_str(), exception.what());
Game::logger->Log("BuffComponent", "Failed to parse value (%s): (%s)!", token.c_str(), exception.what());
}
}
}
@ -411,7 +411,7 @@ const std::vector<BuffParameter>& BuffComponent::GetBuffParameters(int32_t buffI
result.nextRow();
}
m_Cache.insert_or_assign(buffId, parameters);
return m_Cache.find(buffId)->second;

View File

@ -26,8 +26,8 @@ void BuildBorderComponent::OnUse(Entity* originator) {
if (!entities.empty())
{
buildArea = entities[0]->GetObjectID();
Game::logger->Log("BuildBorderComponent", "Using PropertyPlaque\n");
Game::logger->Log("BuildBorderComponent", "Using PropertyPlaque");
}
auto* inventoryComponent = originator->GetComponent<InventoryComponent>();
@ -44,7 +44,7 @@ void BuildBorderComponent::OnUse(Entity* originator) {
inventoryComponent->PushEquippedItems();
Game::logger->Log("BuildBorderComponent", "Starting with %llu\n", buildArea);
Game::logger->Log("BuildBorderComponent", "Starting with %llu", buildArea);
if (PropertyManagementComponent::Instance() != nullptr) {
GameMessages::SendStartArrangingWithItem(

View File

@ -41,7 +41,7 @@ CharacterComponent::CharacterComponent(Entity* parent, Character* character) : C
if (character->GetZoneID() != Game::server->GetZoneID()) {
m_IsLanding = true;
}
if (LandingAnimDisabled(character->GetZoneID()) || LandingAnimDisabled(Game::server->GetZoneID()) || m_LastRocketConfig.empty()) {
m_IsLanding = false; //Don't make us land on VE/minigames lol
}
@ -77,13 +77,13 @@ CharacterComponent::~CharacterComponent() {
}
void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
if (bIsInitialUpdate) {
outBitStream->Write0();
outBitStream->Write0();
outBitStream->Write0();
outBitStream->Write0();
outBitStream->Write(m_Character->GetHairColor());
outBitStream->Write(m_Character->GetHairStyle());
outBitStream->Write<uint32_t>(0); //Default "head"
@ -128,7 +128,7 @@ void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInit
outBitStream->Write(m_RacingSmashablesSmashed);
outBitStream->Write(m_RacesFinished);
outBitStream->Write(m_FirstPlaceRaceFinishes);
outBitStream->Write0();
outBitStream->Write(m_IsLanding);
if (m_IsLanding) {
@ -147,17 +147,17 @@ void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInit
outBitStream->Write(m_EditorEnabled);
outBitStream->Write(m_EditorLevel);
}
outBitStream->Write(m_DirtyCurrentActivity);
if (m_DirtyCurrentActivity) outBitStream->Write(m_CurrentActivity);
outBitStream->Write(m_DirtySocialInfo);
if (m_DirtySocialInfo) {
outBitStream->Write(m_GuildID);
outBitStream->Write<unsigned char>(static_cast<unsigned char>(m_GuildName.size()));
if (!m_GuildName.empty())
outBitStream->WriteBits(reinterpret_cast<const unsigned char*>(m_GuildName.c_str()), static_cast<unsigned char>(m_GuildName.size()) * sizeof(wchar_t) * 8);
outBitStream->Write(m_IsLEGOClubMember);
outBitStream->Write(m_CountryCode);
}
@ -171,7 +171,7 @@ bool CharacterComponent::GetPvpEnabled() const
void CharacterComponent::SetPvpEnabled(const bool value)
{
m_DirtyGMInfo = true;
m_PvpEnabled = value;
}
@ -183,15 +183,16 @@ void CharacterComponent::SetGMLevel(int gmlevel) {
}
void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
if (!character) {
Game::logger->Log("CharacterComponent", "Failed to find char tag while loading XML!\n");
Game::logger->Log("CharacterComponent", "Failed to find char tag while loading XML!");
return;
}
if (character->QueryAttribute("rpt", &m_Reputation) == tinyxml2::XML_NO_ATTRIBUTE) {
SetReputation(0);
}
character->QueryInt64Attribute("ls", &m_Uscore);
// Load the statistics
@ -280,11 +281,11 @@ void CharacterComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
tinyxml2::XMLElement* minifig = doc->FirstChildElement("obj")->FirstChildElement("mf");
if (!minifig) {
Game::logger->Log("CharacterComponent", "Failed to find mf tag while updating XML!\n");
Game::logger->Log("CharacterComponent", "Failed to find mf tag while updating XML!");
return;
}
// write minifig information that might have been changed by commands
// write minifig information that might have been changed by commands
minifig->SetAttribute("es", m_Character->GetEyebrows());
minifig->SetAttribute("ess", m_Character->GetEyes());
@ -300,7 +301,7 @@ void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
if (!character) {
Game::logger->Log("CharacterComponent", "Failed to find char tag while updating XML!\n");
Game::logger->Log("CharacterComponent", "Failed to find char tag while updating XML!");
return;
}
@ -350,7 +351,7 @@ void CharacterComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
//
auto newUpdateTimestamp = std::time(nullptr);
Game::logger->Log("TotalTimePlayed", "Time since last save: %d\n", newUpdateTimestamp - m_LastUpdateTimestamp);
Game::logger->Log("TotalTimePlayed", "Time since last save: %d", newUpdateTimestamp - m_LastUpdateTimestamp);
m_TotalTimePlayed += newUpdateTimestamp - m_LastUpdateTimestamp;
character->SetAttribute("time", m_TotalTimePlayed);
@ -380,7 +381,7 @@ Item* CharacterComponent::GetRocket(Entity* player) {
}
if (!rocket) {
Game::logger->Log("CharacterComponent", "Unable to find rocket to equip!\n");
Game::logger->Log("CharacterComponent", "Unable to find rocket to equip!");
return rocket;
}
return rocket;

View File

@ -36,7 +36,7 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Com
return;
if (entity->GetLOT() == 1) {
Game::logger->Log("ControllablePhysicsComponent", "Using patch to load minifig physics\n");
Game::logger->Log("ControllablePhysicsComponent", "Using patch to load minifig physics");
float radius = 1.5f;
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), radius, false);
@ -133,10 +133,10 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
if (!character) {
Game::logger->Log("ControllablePhysicsComponent", "Failed to find char tag!\n");
Game::logger->Log("ControllablePhysicsComponent", "Failed to find char tag!");
return;
}
m_Parent->GetCharacter()->LoadXmlRespawnCheckpoints();
character->QueryAttribute("lzx", &m_Position.x);
@ -159,7 +159,7 @@ void ControllablePhysicsComponent::ResetFlags() {
void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
if (!character) {
Game::logger->Log("ControllablePhysicsComponent", "Failed to find char tag while updating XML!\n");
Game::logger->Log("ControllablePhysicsComponent", "Failed to find char tag while updating XML!");
return;
}
@ -254,7 +254,7 @@ void ControllablePhysicsComponent::RemovePickupRadiusScale(float value) {
if (pos != m_ActivePickupRadiusScales.end()) {
m_ActivePickupRadiusScales.erase(pos);
} else {
Game::logger->Log("ControllablePhysicsComponent", "Warning: Could not find pickup radius %f in list of active radii. List has %i active radii.\n", value, m_ActivePickupRadiusScales.size());
Game::logger->Log("ControllablePhysicsComponent", "Warning: Could not find pickup radius %f in list of active radii. List has %i active radii.", value, m_ActivePickupRadiusScales.size());
return;
}

View File

@ -162,7 +162,7 @@ void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn
void DestroyableComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
tinyxml2::XMLElement* dest = doc->FirstChildElement("obj")->FirstChildElement("dest");
if (!dest) {
Game::logger->Log("DestroyableComponent", "Failed to find dest tag!\n");
Game::logger->Log("DestroyableComponent", "Failed to find dest tag!");
return;
}
@ -184,7 +184,7 @@ void DestroyableComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
void DestroyableComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
tinyxml2::XMLElement* dest = doc->FirstChildElement("obj")->FirstChildElement("dest");
if (!dest) {
Game::logger->Log("DestroyableComponent", "Failed to find dest tag!\n");
Game::logger->Log("DestroyableComponent", "Failed to find dest tag!");
return;
}
@ -246,7 +246,7 @@ void DestroyableComponent::SetArmor(int32_t value) {
// If Destroyable Component already has zero armor do not trigger the passive ability again.
bool hadArmor = m_iArmor > 0;
auto* characterComponent = m_Parent->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) {
characterComponent->TrackArmorDelta(value - m_iArmor);
@ -499,7 +499,7 @@ bool DestroyableComponent::CheckValidity(const LWOOBJID target, const bool ignor
if (targetEntity == nullptr)
{
Game::logger->Log("DestroyableComponent", "Invalid entity for checking validity (%llu)!\n", target);
Game::logger->Log("DestroyableComponent", "Invalid entity for checking validity (%llu)!", target);
return false;
}
@ -777,22 +777,22 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
else
{
//Check if this zone allows coin drops
if (dZoneManager::Instance()->GetPlayerLoseCoinOnDeath())
if (dZoneManager::Instance()->GetPlayerLoseCoinOnDeath())
{
auto* character = m_Parent->GetCharacter();
uint64_t coinsTotal = character->GetCoins();
if (coinsTotal > 0)
if (coinsTotal > 0)
{
uint64_t coinsToLoose = 1;
if (coinsTotal >= 200)
if (coinsTotal >= 200)
{
float hundreth = (coinsTotal / 100.0f);
coinsToLoose = static_cast<int>(hundreth);
}
if (coinsToLoose > 10000)
if (coinsToLoose > 10000)
{
coinsToLoose = 10000;
}

View File

@ -157,7 +157,7 @@ void InventoryComponent::AddItem(
{
if (count == 0)
{
Game::logger->Log("InventoryComponent", "Attempted to add 0 of item (%i) to the inventory!\n", lot);
Game::logger->Log("InventoryComponent", "Attempted to add 0 of item (%i) to the inventory!", lot);
return;
}
@ -166,7 +166,7 @@ void InventoryComponent::AddItem(
{
if (lot > 0)
{
Game::logger->Log("InventoryComponent", "Attempted to add invalid item (%i) to the inventory!\n", lot);
Game::logger->Log("InventoryComponent", "Attempted to add invalid item (%i) to the inventory!", lot);
}
return;
@ -187,7 +187,7 @@ void InventoryComponent::AddItem(
if (slot == -1)
{
Game::logger->Log("InventoryComponent", "Failed to find empty slot for inventory (%i)!\n", inventoryType);
Game::logger->Log("InventoryComponent", "Failed to find empty slot for inventory (%i)!", inventoryType);
return;
}
@ -303,7 +303,7 @@ void InventoryComponent::RemoveItem(const LOT lot, const uint32_t count, eInvent
{
if (count == 0)
{
Game::logger->Log("InventoryComponent", "Attempted to remove 0 of item (%i) from the inventory!\n", lot);
Game::logger->Log("InventoryComponent", "Attempted to remove 0 of item (%i) from the inventory!", lot);
return;
}
@ -532,7 +532,7 @@ void InventoryComponent::LoadXml(tinyxml2::XMLDocument* document)
if (inventoryElement == nullptr)
{
Game::logger->Log("InventoryComponent", "Failed to find 'inv' xml element!\n");
Game::logger->Log("InventoryComponent", "Failed to find 'inv' xml element!");
return;
}
@ -541,7 +541,7 @@ void InventoryComponent::LoadXml(tinyxml2::XMLDocument* document)
if (bags == nullptr)
{
Game::logger->Log("InventoryComponent", "Failed to find 'bags' xml element!\n");
Game::logger->Log("InventoryComponent", "Failed to find 'bags' xml element!");
return;
}
@ -569,7 +569,7 @@ void InventoryComponent::LoadXml(tinyxml2::XMLDocument* document)
if (items == nullptr)
{
Game::logger->Log("InventoryComponent", "Failed to find 'items' xml element!\n");
Game::logger->Log("InventoryComponent", "Failed to find 'items' xml element!");
return;
}
@ -586,7 +586,7 @@ void InventoryComponent::LoadXml(tinyxml2::XMLDocument* document)
if (inventory == nullptr)
{
Game::logger->Log("InventoryComponent", "Failed to find inventory (%i)!\n", type);
Game::logger->Log("InventoryComponent", "Failed to find inventory (%i)!", type);
return;
}
@ -666,7 +666,7 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document)
if (inventoryElement == nullptr)
{
Game::logger->Log("InventoryComponent", "Failed to find 'inv' xml element!\n");
Game::logger->Log("InventoryComponent", "Failed to find 'inv' xml element!");
return;
}
@ -691,7 +691,7 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document)
if (bags == nullptr)
{
Game::logger->Log("InventoryComponent", "Failed to find 'bags' xml element!\n");
Game::logger->Log("InventoryComponent", "Failed to find 'bags' xml element!");
return;
}
@ -712,7 +712,7 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document)
if (items == nullptr)
{
Game::logger->Log("InventoryComponent", "Failed to find 'items' xml element!\n");
Game::logger->Log("InventoryComponent", "Failed to find 'items' xml element!");
return;
}
@ -819,7 +819,7 @@ void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool b
outBitStream->Write<uint8_t>(0); // Don't compress
outBitStream->Write(ldfStream);
}
outBitStream->Write1();
}
@ -932,9 +932,9 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks)
const auto building = character->GetBuildMode();
const auto type = static_cast<eItemType>(item->GetInfo().itemType);
if (item->GetLot() == 8092 && m_Parent->GetGMLevel() >= GAME_MASTER_LEVEL_OPERATOR && hasCarEquipped == false)
{
{
auto startPosition = m_Parent->GetPosition();
auto startRotation = NiQuaternion::LookAt(startPosition, startPosition + NiPoint3::UNIT_X);
@ -1055,11 +1055,11 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks)
}
GenerateProxies(item);
UpdateSlot(item->GetInfo().equipLocation, { item->GetId(), item->GetLot(), item->GetCount(), item->GetSlot(), item->GetConfig() });
ApplyBuff(item);
AddItemSkills(item->GetLot());
EntityManager::Instance()->SerializeEntity(m_Parent);
@ -1087,7 +1087,7 @@ void InventoryComponent::UnEquipItem(Item* item)
}
RemoveBuff(item);
RemoveItemSkills(item->GetLot());
RemoveSlot(item->GetInfo().equipLocation);
@ -1162,7 +1162,7 @@ void InventoryComponent::PopEquippedItems()
m_Pushed.clear();
auto destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
// Reset stats to full
if (destroyableComponent) {
destroyableComponent->SetHealth(static_cast<int32_t>(destroyableComponent->GetMaxHealth()));
@ -1265,10 +1265,10 @@ void InventoryComponent::AddItemSkills(const LOT lot)
if (index != m_Skills.end())
{
const auto old = index->second;
GameMessages::SendRemoveSkill(m_Parent, old);
}
GameMessages::SendAddSkill(m_Parent, skill, static_cast<int>(slot));
m_Skills.insert_or_assign(slot, skill);
@ -1474,7 +1474,7 @@ std::vector<uint32_t> InventoryComponent::FindBuffs(Item* item, bool castOnEquip
if (entry.skillID == 0)
{
Game::logger->Log("InventoryComponent", "Failed to find buff behavior for skill (%i)!\n", result.skillID);
Game::logger->Log("InventoryComponent", "Failed to find buff behavior for skill (%i)!", result.skillID);
continue;
}
@ -1483,7 +1483,7 @@ std::vector<uint32_t> InventoryComponent::FindBuffs(Item* item, bool castOnEquip
{
missions->Progress(MissionTaskType::MISSION_TASK_TYPE_SKILL, result.skillID);
}
// If item is not a proxy, add its buff to the added buffs.
if (item->GetParent() == LWOOBJID_EMPTY) buffs.push_back(static_cast<uint32_t>(entry.behaviorID));
}
@ -1553,7 +1553,7 @@ std::vector<Item*> InventoryComponent::GenerateProxies(Item* parent)
}
catch (std::invalid_argument& exception)
{
Game::logger->Log("InventoryComponent", "Failed to parse proxy (%s): (%s)!\n", segment.c_str(), exception.what());
Game::logger->Log("InventoryComponent", "Failed to parse proxy (%s): (%s)!", segment.c_str(), exception.what());
}
}

View File

@ -12,7 +12,7 @@ LevelProgressionComponent::LevelProgressionComponent(Entity* parent) : Component
void LevelProgressionComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
tinyxml2::XMLElement* level = doc->FirstChildElement("obj")->FirstChildElement("lvl");
if (!level) {
Game::logger->Log("LevelProgressionComponent", "Failed to find lvl tag while updating XML!\n");
Game::logger->Log("LevelProgressionComponent", "Failed to find lvl tag while updating XML!");
return;
}
level->SetAttribute("l", m_Level);
@ -22,7 +22,7 @@ void LevelProgressionComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
void LevelProgressionComponent::LoadFromXml(tinyxml2::XMLDocument* doc){
tinyxml2::XMLElement* level = doc->FirstChildElement("obj")->FirstChildElement("lvl");
if (!level) {
Game::logger->Log("LevelProgressionComponent", "Failed to find lvl tag while loading XML!\n");
Game::logger->Log("LevelProgressionComponent", "Failed to find lvl tag while loading XML!");
return;
}
level->QueryAttribute("l", &m_Level);

View File

@ -220,7 +220,7 @@ void MissionComponent::ForceProgressTaskType(const uint32_t missionId, const uin
}
}
void MissionComponent::ForceProgressValue(uint32_t missionId, uint32_t taskType, int32_t value, bool acceptMission)
void MissionComponent::ForceProgressValue(uint32_t missionId, uint32_t taskType, int32_t value, bool acceptMission)
{
auto* mission = GetMission(missionId);
@ -357,7 +357,7 @@ bool MissionComponent::LookForAchievements(MissionTaskType type, int32_t value,
}
}
catch (std::invalid_argument& exception) {
Game::logger->Log("MissionComponent", "Failed to parse target (%s): (%s)!\n", token.c_str(), exception.what());
Game::logger->Log("MissionComponent", "Failed to parse target (%s): (%s)!", token.c_str(), exception.what());
}
}
@ -383,7 +383,7 @@ bool MissionComponent::LookForAchievements(MissionTaskType type, int32_t value,
#endif
}
const std::vector<uint32_t>& MissionComponent::QueryAchievements(MissionTaskType type, int32_t value, const std::string targets) {
const std::vector<uint32_t>& MissionComponent::QueryAchievements(MissionTaskType type, int32_t value, const std::string targets) {
// Create a hash which represent this query for achievements
size_t hash = 0;
GeneralUtils::hash_combine(hash, type);
@ -471,7 +471,7 @@ bool MissionComponent::RequiresItem(const LOT lot) {
}
result.finalize();
for (const auto& pair : m_Missions) {
auto* mission = pair.second;
@ -594,7 +594,7 @@ void MissionComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
}
}
void MissionComponent::AddCollectible(int32_t collectibleID)
void MissionComponent::AddCollectible(int32_t collectibleID)
{
// Check if this collectible is already in the list
if (HasCollectible(collectibleID)) {
@ -604,12 +604,12 @@ void MissionComponent::AddCollectible(int32_t collectibleID)
m_Collectibles.push_back(collectibleID);
}
bool MissionComponent::HasCollectible(int32_t collectibleID)
bool MissionComponent::HasCollectible(int32_t collectibleID)
{
return std::find(m_Collectibles.begin(), m_Collectibles.end(), collectibleID) != m_Collectibles.end();
}
bool MissionComponent::HasMission(uint32_t missionId)
bool MissionComponent::HasMission(uint32_t missionId)
{
return GetMission(missionId) != nullptr;
}

View File

@ -50,7 +50,7 @@ MissionOfferComponent::MissionOfferComponent(Entity* parent, const LOT parentLot
// Now lookup the missions in the MissionNPCComponent table
auto* missionNpcComponentTable = CDClientManager::Instance()->GetTable<CDMissionNPCComponentTable>("MissionNPCComponent");
auto missions = missionNpcComponentTable->Query([=](const CDMissionNPCComponent& entry)
{
return entry.id == static_cast<unsigned>(componentId);
@ -73,11 +73,11 @@ MissionOfferComponent::~MissionOfferComponent()
mission = nullptr;
}
}
offeredMissions.clear();
}
void MissionOfferComponent::OnUse(Entity* originator)
void MissionOfferComponent::OnUse(Entity* originator)
{
OfferMissions(originator);
}
@ -86,9 +86,9 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
{
// First, get the entity's MissionComponent. If there is not one, then we cannot offer missions to this entity.
auto* missionComponent = static_cast<MissionComponent*>(entity->GetComponent(COMPONENT_TYPE_MISSION));
if (!missionComponent) {
Game::logger->Log("MissionOfferComponent", "Unable to get mission component for Entity %llu\n", entity->GetObjectID());
Game::logger->Log("MissionOfferComponent", "Unable to get mission component for Entity %llu", entity->GetObjectID());
return;
}
@ -137,7 +137,7 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
continue;
}
}
const auto canAccept = MissionPrerequisites::CanAccept(missionId, missionComponent->GetMissions());
// Mission has not yet been accepted - check the prereqs
@ -148,10 +148,10 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
{
continue;
}
const auto& randomPool = info.randomPool;
const auto isRandom = info.isRandom;
if (isRandom && randomPool.empty()) // This means the mission is part of a random pool of missions.
{
continue;
@ -163,7 +163,7 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
std::string token;
std::vector<uint32_t> randomMissionPool;
while (std::getline(stream, token, ','))
{
try
@ -174,7 +174,7 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
}
catch (std::invalid_argument& exception)
{
Game::logger->Log("MissionOfferComponent", "Failed to parse value (%s): (%s)!\n", token.c_str(), exception.what());
Game::logger->Log("MissionOfferComponent", "Failed to parse value (%s): (%s)!", token.c_str(), exception.what());
}
}
@ -195,7 +195,7 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
for (const auto sample : randomMissionPool)
{
const auto state = missionComponent->GetMissionState(sample);
if (state == MissionState::MISSION_STATE_ACTIVE ||
state == MissionState::MISSION_STATE_COMPLETE_ACTIVE ||
state == MissionState::MISSION_STATE_READY_TO_COMPLETE ||
@ -212,10 +212,10 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), sample, m_Parent->GetObjectID());
canAcceptPool.clear();
break;
}
if (std::find(offered.begin(), offered.end(), sample) == offered.end() && MissionPrerequisites::CanAccept(sample, missionComponent->GetMissions()))
{
canAcceptPool.push_back(sample);

View File

@ -20,12 +20,12 @@ MoverSubComponent::MoverSubComponent(const NiPoint3& startPos) {
mDesiredWaypointIndex = 0; // -1;
mInReverse = false;
mShouldStopAtDesiredWaypoint = false;
mPercentBetweenPoints = 0.0f;
mCurrentWaypointIndex = 0;
mNextWaypointIndex = 0; //mCurrentWaypointIndex + 1;
mIdleTimeElapsed = 0.0f;
}
@ -38,16 +38,16 @@ void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIniti
outBitStream->Write<int32_t>(mDesiredWaypointIndex);
outBitStream->Write(mShouldStopAtDesiredWaypoint);
outBitStream->Write(mInReverse);
outBitStream->Write<float_t>(mPercentBetweenPoints);
outBitStream->Write<float_t>(mPosition.x);
outBitStream->Write<float_t>(mPosition.y);
outBitStream->Write<float_t>(mPosition.z);
outBitStream->Write<uint32_t>(mCurrentWaypointIndex);
outBitStream->Write<uint32_t>(mNextWaypointIndex);
outBitStream->Write<float_t>(mIdleTimeElapsed);
outBitStream->Write<float_t>(0.0f); // Move time elapsed
}
@ -62,7 +62,7 @@ MovingPlatformComponent::MovingPlatformComponent(Entity* parent, const std::stri
m_NoAutoStart = false;
if (m_Path == nullptr) {
Game::logger->Log("MovingPlatformComponent", "Path not found: %s\n", pathName.c_str());
Game::logger->Log("MovingPlatformComponent", "Path not found: %s", pathName.c_str());
}
}
@ -72,7 +72,7 @@ MovingPlatformComponent::~MovingPlatformComponent() {
void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
// Here we don't serialize the moving platform to let the client simulate the movement
if (!m_Serialize)
{
outBitStream->Write<bool>(false);
@ -89,7 +89,7 @@ void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
if (hasPath) {
// Is on rail
outBitStream->Write1();
outBitStream->Write(static_cast<uint16_t>(m_PathName.size()));
for (const auto& c : m_PathName) {
outBitStream->Write(static_cast<uint16_t>(c));
@ -128,7 +128,7 @@ void MovingPlatformComponent::OnCompleteRebuild() {
StartPathing();
}
void MovingPlatformComponent::SetMovementState(MovementPlatformState value)
void MovingPlatformComponent::SetMovementState(MovementPlatformState value)
{
auto* subComponent = static_cast<MoverSubComponent*>(m_MoverSubComponent);
@ -137,10 +137,10 @@ void MovingPlatformComponent::SetMovementState(MovementPlatformState value)
EntityManager::Instance()->SerializeEntity(m_Parent);
}
void MovingPlatformComponent::GotoWaypoint(uint32_t index, bool stopAtWaypoint)
void MovingPlatformComponent::GotoWaypoint(uint32_t index, bool stopAtWaypoint)
{
auto* subComponent = static_cast<MoverSubComponent*>(m_MoverSubComponent);
subComponent->mDesiredWaypointIndex = index;
subComponent->mNextWaypointIndex = index;
subComponent->mShouldStopAtDesiredWaypoint = stopAtWaypoint;
@ -148,13 +148,13 @@ void MovingPlatformComponent::GotoWaypoint(uint32_t index, bool stopAtWaypoint)
StartPathing();
}
void MovingPlatformComponent::StartPathing()
void MovingPlatformComponent::StartPathing()
{
//GameMessages::SendStartPathing(m_Parent);
m_PathingStopped = false;
auto* subComponent = static_cast<MoverSubComponent*>(m_MoverSubComponent);
subComponent->mShouldStopAtDesiredWaypoint = true;
subComponent->mState = MovementPlatformState::Stationary;
@ -206,7 +206,7 @@ void MovingPlatformComponent::StartPathing()
void MovingPlatformComponent::ContinuePathing()
{
auto* subComponent = static_cast<MoverSubComponent*>(m_MoverSubComponent);
subComponent->mState = MovementPlatformState::Stationary;
subComponent->mCurrentWaypointIndex = subComponent->mNextWaypointIndex;
@ -258,7 +258,7 @@ void MovingPlatformComponent::ContinuePathing()
case PathBehavior::Once:
EntityManager::Instance()->SerializeEntity(m_Parent);
return;
case PathBehavior::Bounce:
subComponent->mInReverse = true;
break;
@ -266,7 +266,7 @@ void MovingPlatformComponent::ContinuePathing()
case PathBehavior::Loop:
subComponent->mNextWaypointIndex = 0;
break;
default:
break;
}
@ -347,7 +347,7 @@ void MovingPlatformComponent::StopPathing()
//GameMessages::SendPlatformResync(m_Parent, UNASSIGNED_SYSTEM_ADDRESS);
}
void MovingPlatformComponent::SetSerialized(bool value)
void MovingPlatformComponent::SetSerialized(bool value)
{
m_Serialize = value;
}
@ -357,7 +357,7 @@ bool MovingPlatformComponent::GetNoAutoStart() const
return m_NoAutoStart;
}
void MovingPlatformComponent::SetNoAutoStart(const bool value)
void MovingPlatformComponent::SetNoAutoStart(const bool value)
{
m_NoAutoStart = value;
}

View File

@ -98,7 +98,7 @@ PetComponent::PetComponent(Entity* parent, uint32_t componentId) : Component(par
result.finalize();
}
void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags)
void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags)
{
const bool tamed = m_Owner != LWOOBJID_EMPTY;
@ -114,7 +114,7 @@ void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpd
{
outBitStream->Write(m_Interaction);
}
outBitStream->Write(tamed);
if (tamed)
{
@ -143,7 +143,7 @@ void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpd
}
}
void PetComponent::OnUse(Entity* originator)
void PetComponent::OnUse(Entity* originator)
{
if (m_Owner != LWOOBJID_EMPTY)
{
@ -158,7 +158,7 @@ void PetComponent::OnUse(Entity* originator)
{
return;
}
m_Tamer = LWOOBJID_EMPTY;
}
@ -179,7 +179,7 @@ void PetComponent::OnUse(Entity* originator)
{
movementAIComponent->Stop();
}
inventoryComponent->DespawnPet();
const auto& cached = buildCache.find(m_Parent->GetLOT());
@ -245,7 +245,7 @@ void PetComponent::OnUse(Entity* originator)
}
auto* destroyableComponent = originator->GetComponent<DestroyableComponent>();
if (destroyableComponent == nullptr)
{
return;
@ -263,7 +263,7 @@ void PetComponent::OnUse(Entity* originator)
if (bricks.empty())
{
ChatPackets::SendSystemMessage(originator->GetSystemAddress(), u"Failed to load the puzzle minigame for this pet.");
Game::logger->Log("PetComponent", "Couldn't find %s for minigame!\n", buildFile.c_str());
Game::logger->Log("PetComponent", "Couldn't find %s for minigame!", buildFile.c_str());
return;
}
@ -282,7 +282,7 @@ void PetComponent::OnUse(Entity* originator)
}
auto position = originatorPosition;
NiPoint3 forward = NiQuaternion::LookAt(m_Parent->GetPosition(), originator->GetPosition()).GetForwardVector();
forward.y = 0;
@ -297,7 +297,7 @@ void PetComponent::OnUse(Entity* originator)
const NiPoint3 forward = m_Parent->GetRotation().GetForwardVector();
attempt = originatorPosition + forward * interactionDistance;
y = dpWorld::Instance().GetHeightAtPoint(attempt);
interactionDistance -= 0.5f;
@ -309,10 +309,10 @@ void PetComponent::OnUse(Entity* originator)
{
position = petPosition + forward * interactionDistance;
}
auto rotation = NiQuaternion::LookAt(position, petPosition);
GameMessages::SendNotifyPetTamingMinigame(
originator->GetObjectID(),
m_Parent->GetObjectID(),
@ -350,7 +350,7 @@ void PetComponent::OnUse(Entity* originator)
}
}
void PetComponent::Update(float deltaTime)
void PetComponent::Update(float deltaTime)
{
if (m_StartPosition == NiPoint3::ZERO)
{
@ -422,7 +422,7 @@ void PetComponent::Update(float deltaTime)
}
m_TresureTime -= deltaTime;
m_MovementAI->Stop();
if (m_TresureTime <= 0)
@ -466,7 +466,7 @@ void PetComponent::Update(float deltaTime)
if (m_Timer > 0)
{
m_Timer -= deltaTime;
return;
}
@ -509,7 +509,7 @@ void PetComponent::Update(float deltaTime)
if (distance < 3 * 3)
{
m_Interaction = closestTresure->GetObjectID();
Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 1, 202, true);
m_TresureTime = 2;
@ -525,7 +525,7 @@ void PetComponent::Update(float deltaTime)
skipTresure:
m_MovementAI->SetHaltDistance(haltDistance);
m_MovementAI->SetSpeed(2.5f);
m_MovementAI->SetDestination(destination);
@ -573,7 +573,7 @@ void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) {
GameMessages::SendPetTamingTryBuildResult(m_Tamer, !clientFailed, numBricks, tamer->GetSystemAddress());
}
void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position)
void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position)
{
if (m_Tamer == LWOOBJID_EMPTY) return;
@ -603,7 +603,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position)
info.spawnerID = tamer->GetObjectID();
auto* modelEntity = EntityManager::Instance()->CreateEntity(info);
m_ModelId = modelEntity->GetObjectID();
EntityManager::Instance()->ConstructEntity(modelEntity);
@ -625,26 +625,26 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position)
petSubKey = GeneralUtils::SetBit(petSubKey, OBJECT_BIT_PERSISTENT);
m_DatabaseId = petSubKey;
std::string petName = tamer->GetCharacter()->GetName();
petName += "'s Pet";
GameMessages::SendAddPetToPlayer(m_Tamer, 0, GeneralUtils::ASCIIToUTF16(petName), petSubKey, m_Parent->GetLOT(), tamer->GetSystemAddress());
GameMessages::SendRegisterPetID(m_Tamer, m_Parent->GetObjectID(), tamer->GetSystemAddress());
GameMessages::SendRegisterPetDBID(m_Tamer, petSubKey, tamer->GetSystemAddress());
inventoryComponent->AddItem(m_Parent->GetLOT(), 1, eLootSourceType::LOOT_SOURCE_ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey);
auto* item = inventoryComponent->FindItemBySubKey(petSubKey, MODELS);
if (item == nullptr)
{
return;
}
DatabasePet databasePet {};
databasePet.lot = m_Parent->GetLOT();
databasePet.moderationState = 1;
databasePet.name = petName;
@ -687,7 +687,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position)
}
}
void PetComponent::RequestSetPetName(std::u16string name)
void PetComponent::RequestSetPetName(std::u16string name)
{
if (m_Tamer == LWOOBJID_EMPTY)
{
@ -717,7 +717,7 @@ void PetComponent::RequestSetPetName(std::u16string name)
return;
}
Game::logger->Log("PetComponent", "Got set pet name (%s)\n", GeneralUtils::UTF16ToWTF8(name).c_str());
Game::logger->Log("PetComponent", "Got set pet name (%s)", GeneralUtils::UTF16ToWTF8(name).c_str());
auto* inventoryComponent = tamer->GetComponent<InventoryComponent>();
@ -770,7 +770,7 @@ void PetComponent::RequestSetPetName(std::u16string name)
}
}
void PetComponent::ClientExitTamingMinigame(bool voluntaryExit)
void PetComponent::ClientExitTamingMinigame(bool voluntaryExit)
{
if (m_Tamer == LWOOBJID_EMPTY) return;
@ -804,7 +804,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit)
SetStatus(67108866);
m_Tamer = LWOOBJID_EMPTY;
m_Timer = 0;
EntityManager::Instance()->SerializeEntity(m_Parent);
// Notify the end of a pet taming minigame
@ -813,7 +813,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit)
}
}
void PetComponent::StartTimer()
void PetComponent::StartTimer()
{
const auto& cached = buildCache.find(m_Parent->GetLOT());
@ -825,8 +825,8 @@ void PetComponent::StartTimer()
m_Timer = cached->second.timeLimit;
}
void PetComponent::ClientFailTamingMinigame()
{
void PetComponent::ClientFailTamingMinigame()
{
if (m_Tamer == LWOOBJID_EMPTY) return;
auto* tamer = EntityManager::Instance()->GetEntity(m_Tamer);
@ -859,7 +859,7 @@ void PetComponent::ClientFailTamingMinigame()
SetStatus(67108866);
m_Tamer = LWOOBJID_EMPTY;
m_Timer = 0;
EntityManager::Instance()->SerializeEntity(m_Parent);
// Notify the end of a pet taming minigame
@ -868,7 +868,7 @@ void PetComponent::ClientFailTamingMinigame()
}
}
void PetComponent::Wander()
void PetComponent::Wander()
{
m_MovementAI = m_Parent->GetComponent<MovementAIComponent>();
@ -877,12 +877,12 @@ void PetComponent::Wander()
}
m_MovementAI->SetHaltDistance(0);
const auto& info = m_MovementAI->GetInfo();
const auto div = static_cast<int>(info.wanderDelayMax);
m_Timer = (div == 0 ? 0 : GeneralUtils::GenerateRandomNumber<int>(0, div)) + info.wanderDelayMin; //set a random timer to stay put.
const float radius = info.wanderRadius * sqrt(static_cast<double>(GeneralUtils::GenerateRandomNumber<float>(0, 1))); //our wander radius + a bit of random range
const float theta = ((static_cast<double>(GeneralUtils::GenerateRandomNumber<float>(0, 1)) * 2 * PI));
@ -912,13 +912,13 @@ void PetComponent::Wander()
m_Timer += (m_MovementAI->GetCurrentPosition().x - destination.x) / info.wanderSpeed;
}
void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming)
void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming)
{
AddDrainImaginationTimer(item, fromTaming);
m_ItemId = item->GetId();
m_DatabaseId = item->GetSubKey();
auto* inventoryComponent = item->GetInventory()->GetComponent();
if (inventoryComponent == nullptr) return;
@ -1006,10 +1006,10 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
// Set this to a variable so when this is called back from the player the timer doesn't fire off.
m_Parent->AddCallbackTimer(imaginationDrainRate, [playerDestroyableComponent, this, item](){
if (!playerDestroyableComponent) {
Game::logger->Log("PetComponent", "No petComponent and/or no playerDestroyableComponent\n");
Game::logger->Log("PetComponent", "No petComponent and/or no playerDestroyableComponent");
return;
}
// If we are out of imagination despawn the pet.
if (playerDestroyableComponent->GetImagination() == 0) {
this->Deactivate();
@ -1023,7 +1023,7 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
});
}
void PetComponent::Deactivate()
void PetComponent::Deactivate()
{
GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), -1, u"despawn", "", LWOOBJID_EMPTY, 1, 1, true);
@ -1036,7 +1036,7 @@ void PetComponent::Deactivate()
auto* owner = GetOwner();
if (owner == nullptr) return;
GameMessages::SendAddPetToPlayer(m_Owner, 0, u"", LWOOBJID_EMPTY, LOT_NULL, owner->GetSystemAddress());
GameMessages::SendRegisterPetID(m_Owner, LWOOBJID_EMPTY, owner->GetSystemAddress());
@ -1046,7 +1046,7 @@ void PetComponent::Deactivate()
GameMessages::SendShowPetActionButton(m_Owner, 0, false, owner->GetSystemAddress());
}
void PetComponent::Release()
void PetComponent::Release()
{
auto* inventoryComponent = GetOwner()->GetComponent<InventoryComponent>();
@ -1054,7 +1054,7 @@ void PetComponent::Release()
{
return;
}
Deactivate();
inventoryComponent->RemoveDatabasePet(m_DatabaseId);
@ -1064,7 +1064,7 @@ void PetComponent::Release()
item->SetCount(0, false, false);
}
void PetComponent::Command(NiPoint3 position, LWOOBJID source, int32_t commandType, int32_t typeId, bool overrideObey)
void PetComponent::Command(NiPoint3 position, LWOOBJID source, int32_t commandType, int32_t typeId, bool overrideObey)
{
auto* owner = GetOwner();
@ -1133,12 +1133,12 @@ void PetComponent::SetStatus(uint32_t value)
m_Status = value;
}
void PetComponent::SetAbility(PetAbilityType value)
void PetComponent::SetAbility(PetAbilityType value)
{
m_Ability = value;
}
PetComponent* PetComponent::GetTamingPet(LWOOBJID tamer)
PetComponent* PetComponent::GetTamingPet(LWOOBJID tamer)
{
const auto& pair = currentActivities.find(tamer);
@ -1159,7 +1159,7 @@ PetComponent* PetComponent::GetTamingPet(LWOOBJID tamer)
return entity->GetComponent<PetComponent>();
}
PetComponent* PetComponent::GetActivePet(LWOOBJID owner)
PetComponent* PetComponent::GetActivePet(LWOOBJID owner)
{
const auto& pair = activePets.find(owner);
@ -1173,7 +1173,7 @@ PetComponent* PetComponent::GetActivePet(LWOOBJID owner)
if (entity == nullptr)
{
activePets.erase(owner);
return nullptr;
}

View File

@ -30,18 +30,18 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
m_Rotation = m_Parent->GetDefaultRotation();
m_Scale = m_Parent->GetDefaultScale();
m_dpEntity = nullptr;
m_EffectInfoDirty = false;
m_PositionInfoDirty = false;
m_IsPhysicsEffectActive = false;
m_EffectType = 0;
m_DirectionalMultiplier = 0.0f;
m_MinMax = false;
m_Min = 0;
m_Max = 1;
m_IsDirectional = false;
m_Direction = NiPoint3(); // * m_DirectionalMultiplier
@ -82,7 +82,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
}
// HF - RespawnPoints. Legacy respawn entity.
if (m_Parent->GetLOT() == 4945)
if (m_Parent->GetLOT() == 4945)
{
m_IsRespawnVolume = true;
m_RespawnPos = m_Position;
@ -218,7 +218,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
dpWorld::Instance().AddEntity(m_dpEntity);
}
else {
//Game::logger->Log("PhantomPhysicsComponent", "This one is supposed to have %s\n", info->physicsAsset.c_str());
//Game::logger->Log("PhantomPhysicsComponent", "This one is supposed to have %s", info->physicsAsset.c_str());
//add fallback cube:
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 2.0f, 2.0f, 2.0f);
@ -262,7 +262,7 @@ void PhantomPhysicsComponent::CreatePhysics() {
CDPhysicsComponentTable* physComp = CDClientManager::Instance()->GetTable<CDPhysicsComponentTable>("PhysicsComponent");
if (physComp == nullptr) return;
auto info = physComp->GetByID(componentID);
if (info == nullptr) return;
@ -315,15 +315,15 @@ void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
m_PositionInfoDirty = false;
}
outBitStream->Write(m_EffectInfoDirty || bIsInitialUpdate);
if (m_EffectInfoDirty || bIsInitialUpdate) {
outBitStream->Write(m_IsPhysicsEffectActive);
if (m_IsPhysicsEffectActive) {
outBitStream->Write(m_EffectType);
outBitStream->Write(m_DirectionalMultiplier);
// forgive me father for i have sinned
outBitStream->Write0();
//outBitStream->Write(m_MinMax);
@ -331,7 +331,7 @@ void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
//outBitStream->Write(m_Min);
//outBitStream->Write(m_Max);
//}
outBitStream->Write(m_IsDirectional);
if (m_IsDirectional) {
outBitStream->Write(m_Direction.x);
@ -379,7 +379,7 @@ void PhantomPhysicsComponent::SetDirection(const NiPoint3& pos) {
m_Direction.x *= m_DirectionalMultiplier;
m_Direction.y *= m_DirectionalMultiplier;
m_Direction.z *= m_DirectionalMultiplier;
m_EffectInfoDirty = true;
m_IsDirectional = true;
}

View File

@ -192,7 +192,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
const auto query = BuildQuery(entity, sortMethod, character);
auto propertyLookup = Database::CreatePreppedStmt(query);
const auto searchString = "%" + filterText + "%";
propertyLookup->setUInt(1, this->m_MapID);
propertyLookup->setString(2, searchString.c_str());
@ -230,7 +230,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
delete nameLookup;
nameLookup = nullptr;
Game::logger->Log("PropertyEntranceComponent", "Failed to find property owner name for %llu!\n", cloneId);
Game::logger->Log("PropertyEntranceComponent", "Failed to find property owner name for %llu!", cloneId);
continue;
} else {
@ -318,7 +318,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
propertyLookup = nullptr;
propertyQueries[entity->GetObjectID()] = entries;
// Query here is to figure out whether or not to display the button to go to the next page or not.
int32_t numberOfProperties = 0;
@ -337,7 +337,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
delete result;
result = nullptr;
delete propertiesLeft;
propertiesLeft = nullptr;

View File

@ -37,7 +37,7 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo
instance = this;
const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID();
const auto zoneId = worldId.GetMapID();
const auto cloneId = worldId.GetCloneID();
@ -51,7 +51,7 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo
{
return;
}
templateId = result.getIntField(0);
result.finalize();
@ -80,7 +80,7 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo
this->reputation = propertyEntry->getUInt(14);
Load();
}
}
delete propertyLookup;
}
@ -111,14 +111,14 @@ std::vector<NiPoint3> PropertyManagementComponent::GetPaths() const
auto result = query.execQuery();
std::vector<NiPoint3> paths {};
if (result.eof())
{
return paths;
}
std::vector<float> points;
std::istringstream stream(result.getStringField(0));
std::string token;
@ -132,7 +132,7 @@ std::vector<NiPoint3> PropertyManagementComponent::GetPaths() const
}
catch (std::invalid_argument& exception)
{
Game::logger->Log("PropertyManagementComponent", "Failed to parse value (%s): (%s)!\n", token.c_str(), exception.what());
Game::logger->Log("PropertyManagementComponent", "Failed to parse value (%s): (%s)!", token.c_str(), exception.what());
}
}
@ -149,7 +149,7 @@ PropertyPrivacyOption PropertyManagementComponent::GetPrivacyOption() const
return privacyOption;
}
void PropertyManagementComponent::SetPrivacyOption(PropertyPrivacyOption value)
void PropertyManagementComponent::SetPrivacyOption(PropertyPrivacyOption value)
{
if (owner == LWOOBJID_EMPTY) return;
@ -241,7 +241,7 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId)
}
catch (sql::SQLException& exception)
{
Game::logger->Log("PropertyManagementComponent", "Failed to execute query: (%s)!\n", exception.what());
Game::logger->Log("PropertyManagementComponent", "Failed to execute query: (%s)!", exception.what());
throw exception;
return false;
@ -254,7 +254,7 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId)
return true;
}
void PropertyManagementComponent::OnStartBuilding()
void PropertyManagementComponent::OnStartBuilding()
{
auto* ownerEntity = GetOwner();
@ -307,7 +307,7 @@ void PropertyManagementComponent::OnFinishBuilding()
void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const NiPoint3 position, NiQuaternion rotation)
{
Game::logger->Log("PropertyManagementComponent", "Placing model <%f, %f, %f>\n", position.x, position.y, position.z);
Game::logger->Log("PropertyManagementComponent", "Placing model <%f, %f, %f>", position.x, position.y, position.z);
auto* entity = GetOwner();
@ -327,7 +327,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
if (item == nullptr)
{
Game::logger->Log("PropertyManagementComponent", "Failed to find item with id %d\n", id);
Game::logger->Log("PropertyManagementComponent", "Failed to find item with id %d", id);
return;
}
@ -369,7 +369,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
item->SetCount(item->GetCount() - 1);
return;
}
item->SetCount(item->GetCount() - 1);
auto* node = new SpawnerNode();
@ -394,7 +394,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
LWOOBJID id = static_cast<LWOOBJID>(persistentId) | 1ull << OBJECT_BIT_CLIENT;
info.spawnerID = id;
const auto spawnerId = dZoneManager::Instance()->MakeSpawner(info);
auto* spawner = dZoneManager::Instance()->GetSpawner(spawnerId);
@ -429,7 +429,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int deleteReason)
{
Game::logger->Log("PropertyManagementComponent", "Delete model: (%llu) (%i)\n", id, deleteReason);
Game::logger->Log("PropertyManagementComponent", "Delete model: (%llu) (%i)", id, deleteReason);
auto* entity = GetOwner();
@ -449,34 +449,34 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
if (index == models.end())
{
Game::logger->Log("PropertyManagementComponent", "Failed to find model\n");
Game::logger->Log("PropertyManagementComponent", "Failed to find model");
return;
}
const auto spawnerId = index->second;
auto* spawner = dZoneManager::Instance()->GetSpawner(spawnerId);
models.erase(id);
if (spawner == nullptr)
{
Game::logger->Log("PropertyManagementComponent", "Failed to find spawner\n");
Game::logger->Log("PropertyManagementComponent", "Failed to find spawner");
}
auto* model = EntityManager::Instance()->GetEntity(id);
if (model == nullptr)
{
Game::logger->Log("PropertyManagementComponent", "Failed to find model entity\n");
Game::logger->Log("PropertyManagementComponent", "Failed to find model entity");
return;
}
EntityManager::Instance()->DestructEntity(model);
Game::logger->Log("PropertyManagementComponent", "Deleting model LOT %i\n", model->GetLOT());
Game::logger->Log("PropertyManagementComponent", "Deleting model LOT %i", model->GetLOT());
if (model->GetLOT() == 14)
{
@ -536,7 +536,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
return;
}
inventoryComponent->AddItem(model->GetLOT(), 1, eLootSourceType::LOOT_SOURCE_DELETION, INVALID, {}, LWOOBJID_EMPTY, false);
auto* item = inventoryComponent->FindItemByLot(model->GetLOT());
@ -572,10 +572,10 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
}
default:
{
Game::logger->Log("PropertyManagementComponent", "Invalid delete reason\n");
Game::logger->Log("PropertyManagementComponent", "Invalid delete reason");
}
}
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3::ZERO, LWOOBJID_EMPTY, 16, NiQuaternion::IDENTITY);
@ -593,7 +593,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
void PropertyManagementComponent::UpdateApprovedStatus(const bool value)
{
if (owner == LWOOBJID_EMPTY) return;
auto* update = Database::CreatePreppedStmt("UPDATE properties SET mod_approved = ? WHERE id = ?;");
update->setBoolean(1, value);
@ -610,11 +610,11 @@ void PropertyManagementComponent::Load()
{
return;
}
auto* lookup = Database::CreatePreppedStmt("SELECT id, lot, x, y, z, rx, ry, rz, rw, ugc_id FROM properties_contents WHERE property_id = ?;");
lookup->setUInt64(1, propertyId);
auto* lookupResult = lookup->executeQuery();
while (lookupResult->next())
@ -622,7 +622,7 @@ void PropertyManagementComponent::Load()
const LWOOBJID id = lookupResult->getUInt64(1);
const LOT lot = lookupResult->getInt(2);
const NiPoint3 position =
const NiPoint3 position =
{
static_cast<float>(lookupResult->getDouble(3)),
static_cast<float>(lookupResult->getDouble(4)),
@ -641,7 +641,7 @@ void PropertyManagementComponent::Load()
node->position = position;
node->rotation = rotation;
SpawnerInfo info{};
info.templateID = lot;
@ -720,7 +720,7 @@ void PropertyManagementComponent::Save()
try {
lookupResult = lookup->executeQuery();
} catch (sql::SQLException& ex) {
Game::logger->Log("PropertyManagementComponent", "lookup error %s\n", ex.what());
Game::logger->Log("PropertyManagementComponent", "lookup error %s", ex.what());
}
std::vector<LWOOBJID> present;
@ -734,7 +734,7 @@ void PropertyManagementComponent::Save()
delete lookupResult;
std::vector<LWOOBJID> modelIds;
for (const auto& pair : models)
{
const auto id = pair.second;
@ -767,7 +767,7 @@ void PropertyManagementComponent::Save()
try {
insertion->execute();
} catch (sql::SQLException& ex) {
Game::logger->Log("PropertyManagementComponent", "Error inserting into properties_contents. Error %s\n", ex.what());
Game::logger->Log("PropertyManagementComponent", "Error inserting into properties_contents. Error %s", ex.what());
}
}
else
@ -784,7 +784,7 @@ void PropertyManagementComponent::Save()
try {
update->executeUpdate();
} catch (sql::SQLException& ex) {
Game::logger->Log("PropertyManagementComponent", "Error updating properties_contents. Error: %s\n", ex.what());
Game::logger->Log("PropertyManagementComponent", "Error updating properties_contents. Error: %s", ex.what());
}
}
}
@ -800,7 +800,7 @@ void PropertyManagementComponent::Save()
try {
remove->execute();
} catch (sql::SQLException& ex) {
Game::logger->Log("PropertyManagementComponent", "Error removing from properties_contents. Error %s\n", ex.what());
Game::logger->Log("PropertyManagementComponent", "Error removing from properties_contents. Error %s", ex.what());
}
}
@ -815,7 +815,7 @@ void PropertyManagementComponent::Save()
delete remove;
}
void PropertyManagementComponent::AddModel(LWOOBJID modelId, LWOOBJID spawnerId)
void PropertyManagementComponent::AddModel(LWOOBJID modelId, LWOOBJID spawnerId)
{
models[modelId] = spawnerId;
}
@ -834,7 +834,7 @@ void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const
const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID();
const auto zoneId = worldId.GetMapID();
Game::logger->Log("Properties", "Getting property info for %d\n", zoneId);
Game::logger->Log("Properties", "Getting property info for %d", zoneId);
GameMessages::PropertyDataMessage message = GameMessages::PropertyDataMessage(zoneId);
const auto isClaimed = GetOwnerId() != LWOOBJID_EMPTY;
@ -845,7 +845,7 @@ void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const
std::string description = "";
uint64_t claimed = 0;
char privacy = 0;
if (isClaimed) {
const auto cloneId = worldId.GetCloneID();
@ -904,7 +904,7 @@ void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const
// send rejection here?
}
void PropertyManagementComponent::OnUse(Entity* originator)
void PropertyManagementComponent::OnUse(Entity* originator)
{
OnQueryPropertyData(originator, UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::SendOpenPropertyManagment(m_Parent->GetObjectID(), originator->GetSystemAddress());

View File

@ -22,7 +22,7 @@ void PropertyVendorComponent::OnUse(Entity* originator)
if (PropertyManagementComponent::Instance()->GetOwnerId() == LWOOBJID_EMPTY)
{
Game::logger->Log("PropertyVendorComponent", "Property vendor opening!\n");
Game::logger->Log("PropertyVendorComponent", "Property vendor opening!");
GameMessages::SendOpenPropertyVendor(m_Parent->GetObjectID(), originator->GetSystemAddress());
@ -42,7 +42,7 @@ void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool con
if (PropertyManagementComponent::Instance() == nullptr) return;
if (PropertyManagementComponent::Instance()->Claim(originator->GetObjectID()) == false) {
Game::logger->Log("PropertyVendorComponent", "FAILED TO CLAIM PROPERTY. PLAYER ID IS %llu\n", originator->GetObjectID());
Game::logger->Log("PropertyVendorComponent", "FAILED TO CLAIM PROPERTY. PLAYER ID IS %llu", originator->GetObjectID());
return;
}
@ -51,11 +51,11 @@ void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool con
auto* controller = dZoneManager::Instance()->GetZoneControlObject();
controller->OnFireEventServerSide(m_Parent, "propertyRented");
PropertyManagementComponent::Instance()->SetOwner(originator);
PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, originator->GetSystemAddress());
Game::logger->Log("PropertyVendorComponent", "Fired event; (%d) (%i) (%i)\n", confirmed, lot, count);
Game::logger->Log("PropertyVendorComponent", "Fired event; (%d) (%i) (%i)", confirmed, lot, count);
}

View File

@ -91,7 +91,7 @@ void RacingControlComponent::OnPlayerLoaded(Entity *player) {
m_LoadedPlayers++;
Game::logger->Log("RacingControlComponent", "Loading player %i\n",
Game::logger->Log("RacingControlComponent", "Loading player %i",
m_LoadedPlayers);
m_LobbyPlayers.push_back(objectID);
@ -116,7 +116,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity *player,
auto *item = inventoryComponent->FindItemByLot(8092);
if (item == nullptr) {
Game::logger->Log("RacingControlComponent", "Failed to find item\n");
Game::logger->Log("RacingControlComponent", "Failed to find item");
return;
}
@ -149,7 +149,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity *player,
startRotation = NiQuaternion::FromEulerAngles(angles);
Game::logger->Log("RacingControlComponent",
"Start position <%f, %f, %f>, <%f, %f, %f>\n",
"Start position <%f, %f, %f>, <%f, %f, %f>",
startPosition.x, startPosition.y, startPosition.z,
angles.x * (180.0f / M_PI), angles.y * (180.0f / M_PI),
angles.z * (180.0f / M_PI));
@ -565,11 +565,11 @@ void RacingControlComponent::Update(float deltaTime) {
// to load in, can raise this if it's too low
if (m_LoadTimer >= 15) {
Game::logger->Log("RacingControlComponent",
"Loading all players...\n");
"Loading all players...");
for (size_t i = 0; i < m_LobbyPlayers.size(); i++) {
Game::logger->Log("RacingControlComponent",
"Loading player now!\n");
"Loading player now!");
auto *player =
EntityManager::Instance()->GetEntity(m_LobbyPlayers[i]);
@ -579,7 +579,7 @@ void RacingControlComponent::Update(float deltaTime) {
}
Game::logger->Log("RacingControlComponent",
"Loading player now NOW!\n");
"Loading player now NOW!");
LoadPlayerVehicle(player, true);
@ -729,7 +729,7 @@ void RacingControlComponent::Update(float deltaTime) {
m_Started = true;
Game::logger->Log("RacingControlComponent", "Starting race\n");
Game::logger->Log("RacingControlComponent", "Starting race");
EntityManager::Instance()->SerializeEntity(m_Parent);
@ -833,7 +833,7 @@ void RacingControlComponent::Update(float deltaTime) {
player.bestLapTime = lapTime;
Game::logger->Log("RacingControlComponent",
"Best lap time (%llu)\n", lapTime);
"Best lap time (%llu)", lapTime);
}
auto *missionComponent =
@ -854,7 +854,7 @@ void RacingControlComponent::Update(float deltaTime) {
player.raceTime = raceTime;
Game::logger->Log("RacingControlComponent",
"Completed time %llu, %llu\n",
"Completed time %llu, %llu",
raceTime, raceTime * 1000);
// Entire race time
@ -870,12 +870,12 @@ void RacingControlComponent::Update(float deltaTime) {
}
Game::logger->Log("RacingControlComponent",
"Lapped (%i) in (%llu)\n", player.lap,
"Lapped (%i) in (%llu)", player.lap,
lapTime);
}
Game::logger->Log("RacingControlComponent",
"Reached point (%i)/(%i)\n", player.respawnIndex,
"Reached point (%i)/(%i)", player.respawnIndex,
path->pathWaypoints.size());
break;

View File

@ -28,12 +28,12 @@ RebuildComponent::RebuildComponent(Entity* entity) : Component(entity) {
// Should a setting that has the build activator position exist, fetch that setting here and parse it for position.
// It is assumed that the user who sets this setting uses the correct character delimiter (character 31 or in hex 0x1F)
auto positionAsVector = GeneralUtils::SplitString(m_Parent->GetVarAsString(u"rebuild_activators"), 0x1F);
if (positionAsVector.size() == 3 &&
if (positionAsVector.size() == 3 &&
GeneralUtils::TryParse(positionAsVector[0], m_ActivatorPosition.x) &&
GeneralUtils::TryParse(positionAsVector[1], m_ActivatorPosition.y) &&
GeneralUtils::TryParse(positionAsVector[1], m_ActivatorPosition.y) &&
GeneralUtils::TryParse(positionAsVector[2], m_ActivatorPosition.z)) {
} else {
Game::logger->Log("RebuildComponent", "Failed to find activator position for lot %i. Defaulting to parents position.\n", m_Parent->GetLOT());
Game::logger->Log("RebuildComponent", "Failed to find activator position for lot %i. Defaulting to parents position.", m_Parent->GetLOT());
m_ActivatorPosition = m_Parent->GetPosition();
}
@ -47,7 +47,7 @@ RebuildComponent::~RebuildComponent() {
if (builder) {
CancelRebuild(builder, eFailReason::REASON_BUILD_ENDED, true);
}
DespawnActivator();
}
@ -61,7 +61,7 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia
outBitStream->Write(false);
}
// If build state is completed and we've already serialized once in the completed state,
// If build state is completed and we've already serialized once in the completed state,
// don't serializing this component anymore as this will cause the build to jump again.
// If state changes, serialization will begin again.
if (!m_StateDirty && m_State == REBUILD_COMPLETED) {
@ -93,7 +93,7 @@ void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia
outBitStream->Write(m_ShowResetEffect);
outBitStream->Write(m_Activator != nullptr);
outBitStream->Write(m_Timer);
outBitStream->Write(m_TimerIncomplete);
@ -146,7 +146,7 @@ void RebuildComponent::Update(float deltaTime) {
}
}
}
break;
}
case REBUILD_COMPLETED: {
@ -272,7 +272,7 @@ void RebuildComponent::SpawnActivator() {
void RebuildComponent::DespawnActivator() {
if (m_Activator) {
EntityManager::Instance()->DestructEntity(m_Activator);
m_Activator->ScheduleKillAfterUpdate();
m_Activator = nullptr;
@ -281,7 +281,7 @@ void RebuildComponent::DespawnActivator() {
}
}
Entity* RebuildComponent::GetActivator()
Entity* RebuildComponent::GetActivator()
{
return EntityManager::Instance()->GetEntity(m_ActivatorId);
}
@ -431,13 +431,13 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
if (user == nullptr) {
return;
}
auto* characterComponent = user->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) {
characterComponent->SetCurrentActivity(eGameActivities::ACTIVITY_NONE);
characterComponent->TrackRebuildComplete();
} else {
Game::logger->Log("RebuildComponent", "Some user tried to finish the rebuild but they didn't have a character somehow.\n");
Game::logger->Log("RebuildComponent", "Some user tried to finish the rebuild but they didn't have a character somehow.");
return;
}
@ -447,7 +447,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
GameMessages::SendPlayFXEffect(m_Parent, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true);
GameMessages::SendEnableRebuild(m_Parent, false, false, true, eFailReason::REASON_NOT_GIVEN, m_ResetTime, user->GetObjectID());
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID());
m_State = eRebuildState::REBUILD_COMPLETED;
m_StateDirty = true;
@ -528,7 +528,7 @@ void RebuildComponent::ResetRebuild(bool failed) {
m_TimerIncomplete = 0.0f;
m_ShowResetEffect = false;
m_DrainedImagination = 0;
EntityManager::Instance()->SerializeEntity(m_Parent);
// Notify scripts and possible subscribers

View File

@ -57,7 +57,7 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId,
auto* rocket = characterComponent->GetRocket(originator);
if (!rocket) {
Game::logger->Log("RocketLaunchpadControlComponent", "Unable to find rocket!\n");
Game::logger->Log("RocketLaunchpadControlComponent", "Unable to find rocket!");
return;
}
@ -79,7 +79,7 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId,
SetSelectedMapId(originator->GetObjectID(), zone);
GameMessages::SendFireEventClientSide(m_Parent->GetObjectID(), originator->GetSystemAddress(), u"RocketEquipped", rocket->GetId(), cloneId, -1, originator->GetObjectID());
GameMessages::SendChangeObjectWorldState(rocket->GetId(), WORLDSTATE_ATTACHED, UNASSIGNED_SYSTEM_ADDRESS);
EntityManager::Instance()->SerializeEntity(originator);

View File

@ -185,7 +185,7 @@ void ScriptedActivityComponent::PlayerLeave(LWOOBJID playerID) {
delete lobby->players[i];
lobby->players[i] = nullptr;
lobby->players.erase(lobby->players.begin() + i);
return;
}
}
@ -246,7 +246,7 @@ void ScriptedActivityComponent::Update(float deltaTime) {
// The timer has elapsed, start the instance
if (lobby->timer <= 0.0f) {
Game::logger->Log("ScriptedActivityComponent", "Setting up instance.\n");
Game::logger->Log("ScriptedActivityComponent", "Setting up instance.");
ActivityInstance* instance = NewInstance();
LoadPlayersIntoInstance(instance, lobby->players);
@ -397,7 +397,7 @@ void ScriptedActivityComponent::ClearInstances() {
m_Instances.clear();
}
ActivityPlayer* ScriptedActivityComponent::GetActivityPlayerData(LWOOBJID playerID)
ActivityPlayer* ScriptedActivityComponent::GetActivityPlayerData(LWOOBJID playerID)
{
for (auto* activityData : m_ActivityPlayers)
{
@ -410,7 +410,7 @@ ActivityPlayer* ScriptedActivityComponent::GetActivityPlayerData(LWOOBJID player
return nullptr;
}
void ScriptedActivityComponent::RemoveActivityPlayerData(LWOOBJID playerID)
void ScriptedActivityComponent::RemoveActivityPlayerData(LWOOBJID playerID)
{
for (size_t i = 0; i < m_ActivityPlayers.size(); i++)
{
@ -427,7 +427,7 @@ void ScriptedActivityComponent::RemoveActivityPlayerData(LWOOBJID playerID)
}
}
ActivityPlayer* ScriptedActivityComponent::AddActivityPlayerData(LWOOBJID playerID)
ActivityPlayer* ScriptedActivityComponent::AddActivityPlayerData(LWOOBJID playerID)
{
auto* data = GetActivityPlayerData(playerID);
if (data != nullptr)
@ -515,7 +515,7 @@ void ActivityInstance::StartZone() {
if (player == nullptr)
return;
Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i\n", player->GetCharacter()->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", player->GetCharacter()->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
if (player->GetCharacter()) {
player->GetCharacter()->SetZoneID(zoneID);
player->GetCharacter()->SetZoneInstance(zoneInstance);
@ -526,7 +526,7 @@ void ActivityInstance::StartZone() {
return;
});
}
m_NextZoneCloneID++;
}
@ -565,7 +565,7 @@ std::vector<Entity*> ActivityInstance::GetParticipants() const {
if (entity != nullptr)
entities.push_back(entity);
}
return entities;
}

View File

@ -52,7 +52,7 @@ void SkillComponent::SyncPlayerSkill(const uint32_t skillUid, const uint32_t syn
if (index == this->m_managedBehaviors.end())
{
Game::logger->Log("SkillComponent", "Failed to find skill with uid (%i)!\n", skillUid, syncId);
Game::logger->Log("SkillComponent", "Failed to find skill with uid (%i)!", skillUid, syncId);
return;
}
@ -81,7 +81,7 @@ void SkillComponent::SyncPlayerProjectile(const LWOOBJID projectileId, RakNet::B
if (index == -1)
{
Game::logger->Log("SkillComponent", "Failed to find projectile id (%llu)!\n", projectileId);
Game::logger->Log("SkillComponent", "Failed to find projectile id (%llu)!", projectileId);
return;
}
@ -95,7 +95,7 @@ void SkillComponent::SyncPlayerProjectile(const LWOOBJID projectileId, RakNet::B
auto result = query.execQuery();
if (result.eof()) {
Game::logger->Log("SkillComponent", "Failed to find skill id for (%i)!\n", sync_entry.lot);
Game::logger->Log("SkillComponent", "Failed to find skill id for (%i)!", sync_entry.lot);
return;
}
@ -432,7 +432,7 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry)
if (other == nullptr) {
if (entry.branchContext.target != LWOOBJID_EMPTY)
{
Game::logger->Log("SkillComponent", "Invalid projectile target (%llu)!\n", entry.branchContext.target);
Game::logger->Log("SkillComponent", "Invalid projectile target (%llu)!", entry.branchContext.target);
}
return;
@ -444,7 +444,7 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry)
auto result = query.execQuery();
if (result.eof()) {
Game::logger->Log("SkillComponent", "Failed to find skill id for (%i)!\n", entry.lot);
Game::logger->Log("SkillComponent", "Failed to find skill id for (%i)!", entry.lot);
return;
}

View File

@ -30,7 +30,7 @@
using namespace std;
void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, GAME_MSG messageID) {
CBITSTREAM
// Get the entity
@ -40,7 +40,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
if (!entity)
{
Game::logger->Log("GameMessageHandler", "Failed to find associated entity (%llu), aborting GM (%X)!\n", objectID, messageID);
Game::logger->Log("GameMessageHandler", "Failed to find associated entity (%llu), aborting GM (%X)!", objectID, messageID);
return;
}
@ -69,31 +69,31 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
case GAME_MSG_UN_EQUIP_ITEM:
GameMessages::HandleUnequipItem(inStream, entity);
break;
case GAME_MSG_RESPOND_TO_MISSION: {
GameMessages::HandleRespondToMission(inStream, entity);
break;
}
case GAME_MSG_REQUEST_USE: {
GameMessages::HandleRequestUse(inStream, entity, sysAddr);
break;
}
case GAME_MSG_SET_FLAG: {
GameMessages::HandleSetFlag(inStream, entity);
break;
}
case GAME_MSG_HAS_BEEN_COLLECTED: {
GameMessages::HandleHasBeenCollected(inStream, entity);
break;
}
case GAME_MSG_PLAYER_LOADED: {
GameMessages::SendRestoreToPostLoadStats(entity, sysAddr);
entity->SetPlayerReadyForUpdates();
auto* player = dynamic_cast<Player*>(entity);
if (player != nullptr)
{
@ -157,20 +157,20 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
character->OnZoneLoad();
}
Game::logger->Log("GameMessageHandler", "Player %s (%llu) loaded.\n", entity->GetCharacter()->GetName().c_str(), entity->GetObjectID());
Game::logger->Log("GameMessageHandler", "Player %s (%llu) loaded.", entity->GetCharacter()->GetName().c_str(), entity->GetObjectID());
// After we've done our thing, tell the client they're ready
GameMessages::SendPlayerReady(dZoneManager::Instance()->GetZoneControlObject(), sysAddr);
GameMessages::SendPlayerReady(entity, sysAddr);
break;
}
case GAME_MSG_REQUEST_LINKED_MISSION: {
GameMessages::HandleRequestLinkedMission(inStream, entity);
break;
}
case GAME_MSG_MISSION_DIALOGUE_OK: {
GameMessages::HandleMissionDialogOK(inStream, entity);
break;
@ -181,12 +181,12 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
//rejecting a mission offer. We dont need to do anything. This is just here to remove a warning in our logs :)
break;
}
case GAME_MSG_REQUEST_PLATFORM_RESYNC: {
GameMessages::HandleRequestPlatformResync(inStream, entity, sysAddr);
break;
}
case GAME_MSG_FIRE_EVENT_SERVER_SIDE: {
GameMessages::HandleFireEventServerSide(inStream, entity, sysAddr);
break;
@ -206,7 +206,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
GameMessages::HandleActivityStateChangeRequest(inStream, entity);
break;
}
case GAME_MSG_PARSE_CHAT_MESSAGE: {
GameMessages::HandleParseChatMessage(inStream, entity, sysAddr);
break;
@ -259,31 +259,31 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
if (skill_component != nullptr)
{
auto* bs = new RakNet::BitStream((unsigned char*) message.sBitStream.c_str(), message.sBitStream.size(), false);
skill_component->SyncPlayerProjectile(message.i64LocalID, bs, message.i64TargetID);
delete bs;
}
break;
}
case GAME_MSG_START_SKILL: {
GameMessages::StartSkill startSkill = GameMessages::StartSkill();
startSkill.Deserialize(inStream); // inStream replaces &bitStream
if (startSkill.skillID == 1561 || startSkill.skillID == 1562 || startSkill.skillID == 1541) return;
MissionComponent* comp = entity->GetComponent<MissionComponent>();
if (comp) {
comp->Progress(MissionTaskType::MISSION_TASK_TYPE_SKILL, startSkill.skillID);
}
CDSkillBehaviorTable* skillTable = CDClientManager::Instance()->GetTable<CDSkillBehaviorTable>("SkillBehavior");
unsigned int behaviorId = skillTable->GetSkillByID(startSkill.skillID).behaviorID;
bool success = false;
if (behaviorId > 0) {
RakNet::BitStream * bs = new RakNet::BitStream((unsigned char *)startSkill.sBitStream.c_str(), startSkill.sBitStream.size(), false);
@ -295,10 +295,10 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
DestroyableComponent* destComp = entity->GetComponent<DestroyableComponent>();
destComp->SetImagination(destComp->GetImagination() - skillTable->GetSkillByID(startSkill.skillID).imaginationcost);
}
delete bs;
}
if (Game::server->GetZoneID() == 1302) {
break;
}
@ -345,7 +345,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
}
//cout << buffer.str() << endl;
if(usr != nullptr) {
RakNet::BitStream * bs = new RakNet::BitStream((unsigned char *)sync.sBitStream.c_str(), sync.sBitStream.size(), false);
@ -378,7 +378,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
case GAME_MSG_MODULAR_BUILD_FINISH:
GameMessages::HandleModularBuildFinish(inStream, entity, sysAddr);
break;
case GAME_MSG_PUSH_EQUIPPED_ITEMS_STATE:
GameMessages::HandlePushEquippedItemsState(inStream, entity);
break;
@ -386,7 +386,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
case GAME_MSG_POP_EQUIPPED_ITEMS_STATE:
GameMessages::HandlePopEquippedItemsState(inStream, entity);
break;
case GAME_MSG_BUY_FROM_VENDOR:
GameMessages::HandleBuyFromVendor(inStream, entity, sysAddr);
break;
@ -477,7 +477,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
case GAME_MSG_COMMAND_PET:
GameMessages::HandleCommandPet(inStream, entity, sysAddr);
break;
case GAME_MSG_DESPAWN_PET:
GameMessages::HandleDespawnPet(inStream, entity, sysAddr);
break;
@ -558,7 +558,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
case GAME_MSG_UPDATE_PROPERTY_OR_MODEL_FOR_FILTER_CHECK:
GameMessages::HandleUpdatePropertyOrModelForFilterCheck(inStream, entity, sysAddr);
break;
case GAME_MSG_SET_PROPERTY_ACCESS:
GameMessages::HandleSetPropertyAccess(inStream, entity, sysAddr);
break;
@ -657,8 +657,8 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
GameMessages::HandleUpdatePlayerStatistic(inStream, entity);
break;
default:
//Game::logger->Log("GameMessageHandler", "Unknown game message ID: %X\n", messageID);
default:
//Game::logger->Log("GameMessageHandler", "Unknown game message ID: %X", messageID);
break;
}
}

View File

@ -126,7 +126,7 @@ void GameMessages::SendTeleport(const LWOOBJID& objectID, const NiPoint3& pos, c
void GameMessages::SendPlayAnimation(Entity* entity, const std::u16string& animationName, float fPriority, float fScale) {
if (!entity) {
Game::logger->Log("SendPlayAnimation", "Trying to play animation, but entity var is nullptr!\n");
Game::logger->Log("SendPlayAnimation", "Trying to play animation, but entity var is nullptr!");
return;
}
@ -1613,7 +1613,7 @@ void GameMessages::HandleUpdateShootingGalleryRotation(RakNet::BitStream* inStre
void GameMessages::HandleActivitySummaryLeaderboardData(RakNet::BitStream* instream, Entity* entity,
const SystemAddress& sysAddr) {
Game::logger->Log("AGS", "We got mail!\n");
Game::logger->Log("AGS", "We got mail!");
}
void GameMessages::SendActivitySummaryLeaderboardData(const LWOOBJID& objectID, const Leaderboard* leaderboard, const SystemAddress& sysAddr) {
@ -1685,7 +1685,7 @@ void GameMessages::HandleActivityStateChangeRequest(RakNet::BitStream *inStream,
auto* assosiate = EntityManager::Instance()->GetEntity(objectID);
Game::logger->Log("Activity State Change", "%s [%i, %i] from %i to %i\n", GeneralUtils::UTF16ToWTF8(stringValue).c_str(), value1, value2, entity->GetLOT(), assosiate != nullptr ? assosiate->GetLOT() : 0);
Game::logger->Log("Activity State Change", "%s [%i, %i] from %i to %i", GeneralUtils::UTF16ToWTF8(stringValue).c_str(), value1, value2, entity->GetLOT(), assosiate != nullptr ? assosiate->GetLOT() : 0);
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_SHOOTING_GALLERY);
for (Entity* scriptEntity : scriptedActs) {
@ -1985,7 +1985,7 @@ void GameMessages::SendDownloadPropertyData(const LWOOBJID objectId, const Prope
data.Serialize(bitStream);
Game::logger->Log("SendDownloadPropertyData", "(%llu) sending property data (%d)\n", objectId, sysAddr == UNASSIGNED_SYSTEM_ADDRESS);
Game::logger->Log("SendDownloadPropertyData", "(%llu) sending property data (%d)", objectId, sysAddr == UNASSIGNED_SYSTEM_ADDRESS);
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST;
SEND_PACKET;
@ -2060,7 +2060,7 @@ void GameMessages::SendGetModelsOnProperty(LWOOBJID objectId, std::map<LWOOBJID,
bitStream.Write(pair.second);
}
Game::logger->Log("SendGetModelsOnProperty", "Sending property models to (%llu) (%d)\n", objectId, sysAddr == UNASSIGNED_SYSTEM_ADDRESS);
Game::logger->Log("SendGetModelsOnProperty", "Sending property models to (%llu) (%d)", objectId, sysAddr == UNASSIGNED_SYSTEM_ADDRESS);
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST;
SEND_PACKET;
@ -2167,7 +2167,7 @@ void GameMessages::HandleSetPropertyAccess(RakNet::BitStream* inStream, Entity*
inStream->Read(renewIsDefault);
if (renewIsDefault != 0) inStream->Read(renew);
Game::logger->Log("GameMessages", "Set privacy option to: %i\n", accessType);
Game::logger->Log("GameMessages", "Set privacy option to: %i", accessType);
if (PropertyManagementComponent::Instance() == nullptr) return;
@ -2211,7 +2211,7 @@ void GameMessages::HandleUpdatePropertyOrModelForFilterCheck(RakNet::BitStream*
void GameMessages::HandleQueryPropertyData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr)
{
Game::logger->Log("HandleQueryPropertyData", "Entity (%i) requesting data\n", entity->GetLOT());
Game::logger->Log("HandleQueryPropertyData", "Entity (%i) requesting data", entity->GetLOT());
/*
auto entites = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_PROPERTY_VENDOR);
@ -2270,7 +2270,7 @@ void GameMessages::HandleSetBuildMode(RakNet::BitStream* inStream, Entity* entit
player->GetCharacter()->SetBuildMode(start);
Game::logger->Log("GameMessages", "Sending build mode confirm (%i): (%d) (%i) (%d) (%i) (%llu)\n", entity->GetLOT(), start, distanceType, modePaused, modeValue, playerId);
Game::logger->Log("GameMessages", "Sending build mode confirm (%i): (%d) (%i) (%d) (%i) (%llu)", entity->GetLOT(), start, distanceType, modePaused, modeValue, playerId);
SendSetBuildModeConfirmed(entity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS, start, false, modePaused, modeValue, playerId, startPosition);
}
@ -2308,7 +2308,7 @@ void GameMessages::HandleStartBuildingWithItem(RakNet::BitStream* inStream, Enti
sourceType = 4;
}
Game::logger->Log("GameMessages", "Handling start building with item (%i): (%d) (%d) (%i) (%llu) (%i) (%i) (%llu) (%i) (%i)\n", entity->GetLOT(), firstTime, success, sourceBag, sourceId, sourceLot, sourceType, targetId, targetLot, targetType);
Game::logger->Log("GameMessages", "Handling start building with item (%i): (%d) (%d) (%i) (%llu) (%i) (%i) (%llu) (%i) (%i)", entity->GetLOT(), firstTime, success, sourceBag, sourceId, sourceLot, sourceType, targetId, targetLot, targetType);
auto* user = UserManager::Instance()->GetUser(sysAddr);
@ -2408,7 +2408,7 @@ void GameMessages::HandleBBBLoadItemRequest(RakNet::BitStream* inStream, Entity*
LWOOBJID itemID = LWOOBJID_EMPTY;
inStream->Read(itemID);
Game::logger->Log("BBB", "Load item request for: " + std::to_string(itemID) + "\n");
Game::logger->Log("BBB", "Load item request for: " + std::to_string(itemID) + "");
CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_BLUEPRINT_LOAD_RESPONSE_ITEMID);
@ -2451,7 +2451,7 @@ void GameMessages::SendUnSmash(Entity* entity, LWOOBJID builderID, float duratio
void GameMessages::HandleControlBehaviors(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
// TODO
Game::logger->Log("GameMessages", "Recieved Control Behavior GameMessage, but property behaviors are unimplemented.\n");
Game::logger->Log("GameMessages", "Recieved Control Behavior GameMessage, but property behaviors are unimplemented.");
}
void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
@ -2531,7 +2531,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
//int32_t size = ZCompression::Decompress(inData, lxfmlSize, outData, 327680, error);
//if (size == -1) {
// Game::logger->Log("GameMessages", "Failed to decompress LXFML: (%i)\n", error);
// Game::logger->Log("GameMessages", "Failed to decompress LXFML: (%i)", error);
// return;
//}
//
@ -3259,7 +3259,7 @@ void GameMessages::HandleClientTradeRequest(RakNet::BitStream* inStream, Entity*
return;
}
Game::logger->Log("GameMessages", "Trade request to (%llu)\n", i64Invitee);
Game::logger->Log("GameMessages", "Trade request to (%llu)", i64Invitee);
auto* trade = TradingManager::Instance()->GetPlayerTrade(entity->GetObjectID());
@ -3293,7 +3293,7 @@ void GameMessages::HandleClientTradeCancel(RakNet::BitStream* inStream, Entity*
if (trade == nullptr) return;
Game::logger->Log("GameMessages", "Trade canceled from (%llu)\n", entity->GetObjectID());
Game::logger->Log("GameMessages", "Trade canceled from (%llu)", entity->GetObjectID());
TradingManager::Instance()->CancelTrade(trade->GetTradeId());
}
@ -3302,7 +3302,7 @@ void GameMessages::HandleClientTradeAccept(RakNet::BitStream* inStream, Entity*
{
bool bFirst = inStream->ReadBit();
Game::logger->Log("GameMessages", "Trade accepted from (%llu) -> (%d)\n", entity->GetObjectID(), bFirst);
Game::logger->Log("GameMessages", "Trade accepted from (%llu) -> (%d)", entity->GetObjectID(), bFirst);
auto* trade = TradingManager::Instance()->GetPlayerTrade(entity->GetObjectID());
@ -3319,7 +3319,7 @@ void GameMessages::HandleClientTradeUpdate(RakNet::BitStream* inStream, Entity*
inStream->Read(currency);
inStream->Read(itemCount);
Game::logger->Log("GameMessages", "Trade update from (%llu) -> (%llu), (%i)\n", entity->GetObjectID(), currency, itemCount);
Game::logger->Log("GameMessages", "Trade update from (%llu) -> (%llu), (%i)", entity->GetObjectID(), currency, itemCount);
std::vector<TradeItem> items {};
@ -3375,7 +3375,7 @@ void GameMessages::HandleClientTradeUpdate(RakNet::BitStream* inStream, Entity*
items.push_back({itemId, lot, unknown2});
Game::logger->Log("GameMessages", "Trade item from (%llu) -> (%llu)/(%llu), (%i), (%llu), (%i), (%i)\n", entity->GetObjectID(), itemId, itemId2, lot, unknown1, unknown2, unknown3);
Game::logger->Log("GameMessages", "Trade item from (%llu) -> (%llu)/(%llu), (%i), (%llu), (%i), (%i)", entity->GetObjectID(), itemId, itemId2, lot, unknown1, unknown2, unknown3);
}
auto* trade = TradingManager::Instance()->GetPlayerTrade(entity->GetObjectID());
@ -3848,7 +3848,7 @@ void GameMessages::HandleMessageBoxResponse(RakNet::BitStream* inStream, Entity*
userData.push_back(character);
}
Game::logger->Log("HandleMessageBoxResponse", "Button: " + std::to_string(iButton) + "; LOT: " + std::to_string(entity->GetLOT()) + " identifier: " + GeneralUtils::UTF16ToWTF8(identifier) + "; userData: " + GeneralUtils::UTF16ToWTF8(userData) + "\n");
Game::logger->Log("HandleMessageBoxResponse", "Button: " + std::to_string(iButton) + "; LOT: " + std::to_string(entity->GetLOT()) + " identifier: " + GeneralUtils::UTF16ToWTF8(identifier) + "; userData: " + GeneralUtils::UTF16ToWTF8(userData));
auto* user = UserManager::Instance()->GetUser(sysAddr);
@ -3912,7 +3912,7 @@ void GameMessages::HandleChoiceBoxRespond(RakNet::BitStream* inStream, Entity* e
identifier.push_back(character);
}
Game::logger->Log("HandleChoiceBoxRespond", "Button: " + std::to_string(iButton) + "; LOT: " + std::to_string(entity->GetLOT()) + " buttonIdentifier: " + GeneralUtils::UTF16ToWTF8(buttonIdentifier) + "; userData: " + GeneralUtils::UTF16ToWTF8(identifier) + "\n");
Game::logger->Log("HandleChoiceBoxRespond", "Button: " + std::to_string(iButton) + "; LOT: " + std::to_string(entity->GetLOT()) + " buttonIdentifier: " + GeneralUtils::UTF16ToWTF8(buttonIdentifier) + "; userData: " + GeneralUtils::UTF16ToWTF8(identifier));
auto* user = UserManager::Instance()->GetUser(sysAddr);
@ -4057,7 +4057,7 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e
void GameMessages::HandleAcknowledgePossession(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
Game::logger->Log("HandleAcknowledgePossession", "Got AcknowledgePossession from %i\n", entity->GetLOT());
Game::logger->Log("HandleAcknowledgePossession", "Got AcknowledgePossession from %i", entity->GetLOT());
EntityManager::Instance()->SerializeEntity(entity);
}
@ -4067,11 +4067,11 @@ void GameMessages::HandleModuleAssemblyQueryData(RakNet::BitStream* inStream, En
{
auto* moduleAssemblyComponent = entity->GetComponent<ModuleAssemblyComponent>();
Game::logger->Log("HandleModuleAssemblyQueryData", "Got Query from %i\n", entity->GetLOT());
Game::logger->Log("HandleModuleAssemblyQueryData", "Got Query from %i", entity->GetLOT());
if (moduleAssemblyComponent != nullptr)
{
Game::logger->Log("HandleModuleAssemblyQueryData", "Returning assembly %s\n", GeneralUtils::UTF16ToWTF8(moduleAssemblyComponent->GetAssemblyPartsLOTs()).c_str());
Game::logger->Log("HandleModuleAssemblyQueryData", "Returning assembly %s", GeneralUtils::UTF16ToWTF8(moduleAssemblyComponent->GetAssemblyPartsLOTs()).c_str());
SendModuleAssemblyDBDataForClient(entity->GetObjectID(), moduleAssemblyComponent->GetSubKey(), moduleAssemblyComponent->GetAssemblyPartsLOTs(), UNASSIGNED_SYSTEM_ADDRESS);
}
@ -4163,7 +4163,7 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity,
auto* racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
Game::logger->Log("HandleRequestDie", "Got die request: %i\n", entity->GetLOT());
Game::logger->Log("HandleRequestDie", "Got die request: %i", entity->GetLOT());
if (racingControlComponent != nullptr)
{
@ -4213,7 +4213,7 @@ void GameMessages::HandleRacingPlayerInfoResetFinished(RakNet::BitStream* inStre
auto* racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
Game::logger->Log("HandleRacingPlayerInfoResetFinished", "Got finished: %i\n", entity->GetLOT());
Game::logger->Log("HandleRacingPlayerInfoResetFinished", "Got finished: %i", entity->GetLOT());
if (racingControlComponent != nullptr)
{
@ -5011,7 +5011,7 @@ void GameMessages::HandleFireEventServerSide(RakNet::BitStream* inStream, Entity
mapId = dZoneManager::Instance()->GetZoneID().GetMapID(); // Fallback to sending the player back to the same zone.
}
Game::logger->Log("FireEventServerSide", "Player %llu has requested zone transfer to (%i, %i).\n", sender->GetObjectID(), (int) mapId, (int) cloneId);
Game::logger->Log("FireEventServerSide", "Player %llu has requested zone transfer to (%i, %i).", sender->GetObjectID(), (int) mapId, (int) cloneId);
auto* character = player->GetCharacter();
@ -5020,7 +5020,7 @@ void GameMessages::HandleFireEventServerSide(RakNet::BitStream* inStream, Entity
}
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, mapId, cloneId, false, [=](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i\n", character->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", character->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
if (character) {
character->SetZoneID(zoneID);
@ -5071,7 +5071,7 @@ void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity,
if (interactedObject == nullptr)
{
Game::logger->Log("GameMessages", "Object %llu tried to interact, but doesn't exist!\n", objectID);
Game::logger->Log("GameMessages", "Object %llu tried to interact, but doesn't exist!", objectID);
return;
}
@ -5117,7 +5117,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity)
inStream->Read(emoteID);
inStream->Read(targetID);
Game::logger->Log("GameMessages", "Emote (%i) (%llu)\n", emoteID, targetID);
Game::logger->Log("GameMessages", "Emote (%i) (%llu)", emoteID, targetID);
//TODO: If targetID != 0, and we have one of the "perform emote" missions, complete them.
@ -5133,7 +5133,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity)
{
auto* targetEntity = EntityManager::Instance()->GetEntity(targetID);
Game::logger->Log("GameMessages", "Emote target found (%d)\n", targetEntity != nullptr);
Game::logger->Log("GameMessages", "Emote target found (%d)", targetEntity != nullptr);
if (targetEntity != nullptr)
{
@ -5218,7 +5218,7 @@ void GameMessages::HandleRespondToMission(RakNet::BitStream* inStream, Entity* e
MissionComponent* missionComponent = static_cast<MissionComponent*>(entity->GetComponent(COMPONENT_TYPE_MISSION));
if (!missionComponent) {
Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle RespondToMission\n", playerID);
Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle RespondToMission", playerID);
return;
}
@ -5227,13 +5227,13 @@ void GameMessages::HandleRespondToMission(RakNet::BitStream* inStream, Entity* e
mission->SetReward(reward);
}
else {
Game::logger->Log("GameMessages", "Unable to get mission %i for entity %llu to update reward in RespondToMission\n", missionID, playerID);
Game::logger->Log("GameMessages", "Unable to get mission %i for entity %llu to update reward in RespondToMission", missionID, playerID);
}
Entity* offerer = EntityManager::Instance()->GetEntity(receiverID);
if (offerer == nullptr) {
Game::logger->Log("GameMessages", "Unable to get receiver entity %llu for RespondToMission\n", receiverID);
Game::logger->Log("GameMessages", "Unable to get receiver entity %llu for RespondToMission", receiverID);
return;
}
@ -5262,7 +5262,7 @@ void GameMessages::HandleMissionDialogOK(RakNet::BitStream* inStream, Entity* en
// Get the player's mission component
MissionComponent* missionComponent = static_cast<MissionComponent*>(player->GetComponent(COMPONENT_TYPE_MISSION));
if (!missionComponent) {
Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle MissionDialogueOK\n", player->GetObjectID());
Game::logger->Log("GameMessages", "Unable to get mission component for entity %llu to handle MissionDialogueOK", player->GetObjectID());
return;
}
@ -5608,7 +5608,7 @@ void GameMessages::HandleBuildModeSet(RakNet::BitStream* inStream, Entity* entit
inStream->Read(bStart);
// there's more here but we don't need it (for now?)
Game::logger->Log("GameMessages", "Set build mode to (%d) for (%llu)\n", bStart, entity->GetObjectID());
Game::logger->Log("GameMessages", "Set build mode to (%d) for (%llu)", bStart, entity->GetObjectID());
if (entity->GetCharacter()) {
entity->GetCharacter()->SetBuildMode(bStart);
@ -5623,7 +5623,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(COMPONENT_TYPE_INVENTORY));
if (!inv) return;
Game::logger->Log("GameMessages", "Build finished\n");
Game::logger->Log("GameMessages", "Build finished");
GameMessages::SendFinishArrangingWithItem(character, entity->GetObjectID()); // kick them from modular build
GameMessages::SendModularBuildEnd(character); // i dont know if this does anything but DLUv2 did it
@ -5753,7 +5753,7 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti
/*
Game::logger->Log("GameMessages",
"\nnewSourceBAG: %d\nnewSourceID: %llu\nnewSourceLOT: %d\nnewSourceTYPE: %d\nnewTargetID: %llu\nnewTargetLOT: %d\nnewTargetTYPE: %d\nnewTargetPOS: %f, %f, %f\noldItemBAG: %d\noldItemID: %llu\noldItemLOT: %d\noldItemTYPE: %d\n",
"\nnewSourceBAG: %d\nnewSourceID: %llu\nnewSourceLOT: %d\nnewSourceTYPE: %d\nnewTargetID: %llu\nnewTargetLOT: %d\nnewTargetTYPE: %d\nnewTargetPOS: %f, %f, %f\noldItemBAG: %d\noldItemID: %llu\noldItemLOT: %d\noldItemTYPE: %d",
newSourceBAG, newSourceID, newSourceLOT, newSourceTYPE, newTargetID, newTargetLOT, newTargetTYPE, newTargetPOS.x, newTargetPOS.y, newTargetPOS.z, oldItemBAG, oldItemID, oldItemLOT, oldItemTYPE
);
*/
@ -5771,15 +5771,15 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti
else if (!entities.empty()) {
buildArea = entities[0];
Game::logger->Log("BuildBorderComponent", "Using PropertyPlaque\n");
Game::logger->Log("BuildBorderComponent", "Using PropertyPlaque");
}
else {
Game::logger->Log("BuildBorderComponent", "No build area found\n");
Game::logger->Log("BuildBorderComponent", "No build area found");
return;
}
Game::logger->Log("GameMessages", "Build area found: %llu\n", buildArea->GetObjectID());
Game::logger->Log("GameMessages", "Build area found: %llu", buildArea->GetObjectID());
GameMessages::SendStartArrangingWithItem(
character,
@ -5798,7 +5798,7 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti
);
}
Game::logger->Log("GameMessages", "Done Arranging\n");
Game::logger->Log("GameMessages", "Done Arranging");
//GenericInventory* models = inv->GetGenericInventory(MODELS);
//GenericInventory* tempModels = inv->GetGenericInventory(TEMP_MODELS);
@ -5824,7 +5824,7 @@ void GameMessages::HandleModularBuildMoveAndEquip(RakNet::BitStream* inStream, E
Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
if (!character) return;
Game::logger->Log("GameMessages", "Build and move\n");
Game::logger->Log("GameMessages", "Build and move");
LOT templateID;
@ -6014,7 +6014,7 @@ void GameMessages::SendGetHotPropertyData(RakNet::BitStream* inStream, Entity* e
* [float] - performance cost
* [timestamp] - time last published
* [cloneid] - clone id
*
*
*/
// TODO This needs to be implemented when reputation is implemented for getting hot properties.
/**
@ -6099,7 +6099,7 @@ void GameMessages::HandleReportBug(RakNet::BitStream* inStream, Entity* entity)
delete insertBug;
}
catch (sql::SQLException& e) {
Game::logger->Log("HandleReportBug", "Couldn't save bug report! (%s)\n", e.what());
Game::logger->Log("HandleReportBug", "Couldn't save bug report! (%s)", e.what());
}
}

View File

@ -81,7 +81,7 @@ uint32_t Inventory::GetLotCount(const LOT lot) const
void Inventory::SetSize(const uint32_t value)
{
free += static_cast<int32_t>(value) - static_cast<int32_t>(size);
size = value;
GameMessages::SendSetInventorySize(component->GetParent(), type, static_cast<int>(size));
@ -107,7 +107,7 @@ int32_t Inventory::FindEmptySlot()
{
newSize += 10u;
}
if (newSize > GetSize())
{
SetSize(newSize);
@ -121,7 +121,7 @@ int32_t Inventory::FindEmptySlot()
}
const auto slots = GetSlots();
for (auto i = 0u; i < size; ++i)
{
if (slots.find(i) == slots.end())
@ -133,15 +133,15 @@ int32_t Inventory::FindEmptySlot()
return -1;
}
int32_t Inventory::GetEmptySlots()
int32_t Inventory::GetEmptySlots()
{
return free;
}
bool Inventory::IsSlotEmpty(int32_t slot)
bool Inventory::IsSlotEmpty(int32_t slot)
{
const auto slots = GetSlots();
const auto& index = slots.find(slot);
return index == slots.end();
@ -201,7 +201,7 @@ Item* Inventory::FindItemByLot(const LOT lot, const bool ignoreEquipped, const b
Item* Inventory::FindItemBySlot(const uint32_t slot) const
{
const auto slots = GetSlots();
const auto index = slots.find(slot);
if (index == slots.end())
@ -228,21 +228,21 @@ Item* Inventory::FindItemBySubKey(LWOOBJID id) const
void Inventory::AddManagedItem(Item* item)
{
const auto id = item->GetId();
if (items.find(id) != items.end())
{
Game::logger->Log("Inventory", "Attempting to add an item with an already present id (%llu)!\n", id);
Game::logger->Log("Inventory", "Attempting to add an item with an already present id (%llu)!", id);
return;
}
const auto slots = GetSlots();
const auto slot = item->GetSlot();
if (slots.find(slot) != slots.end())
{
Game::logger->Log("Inventory", "Attempting to add an item with an already present slot (%i)!\n", slot);
Game::logger->Log("Inventory", "Attempting to add an item with an already present slot (%i)!", slot);
return;
}
@ -258,7 +258,7 @@ void Inventory::RemoveManagedItem(Item* item)
if (items.find(id) == items.end())
{
Game::logger->Log("Inventory", "Attempting to remove an item with an invalid id (%llu), lot (%i)!\n", id, item->GetLot());
Game::logger->Log("Inventory", "Attempting to remove an item with an invalid id (%llu), lot (%i)!", id, item->GetLot());
return;
}
@ -277,7 +277,7 @@ eInventoryType Inventory::FindInventoryTypeForLot(const LOT lot)
switch (itemType) {
case eItemType::ITEM_TYPE_BRICK:
return BRICKS;
case eItemType::ITEM_TYPE_BEHAVIOR:
return BEHAVIORS;
@ -289,7 +289,7 @@ eInventoryType Inventory::FindInventoryTypeForLot(const LOT lot)
case eItemType::ITEM_TYPE_LOOT_MODEL:
case eItemType::ITEM_TYPE_MOUNT:
return MODELS;
case eItemType::ITEM_TYPE_HAT:
case eItemType::ITEM_TYPE_HAIR:
case eItemType::ITEM_TYPE_NECK:
@ -307,7 +307,7 @@ eInventoryType Inventory::FindInventoryTypeForLot(const LOT lot)
case eItemType::ITEM_TYPE_PACKAGE:
case eItemType::ITEM_TYPE_CURRENCY:
return ITEMS;
case eItemType::ITEM_TYPE_QUEST_OBJECT:
case eItemType::ITEM_TYPE_UNKNOWN:
default:
@ -325,11 +325,11 @@ const CDItemComponent& Inventory::FindItemComponent(const LOT lot)
if (componentId == 0)
{
Game::logger->Log("Inventory", "Failed to find item component for (%i)!\n", lot);
Game::logger->Log("Inventory", "Failed to find item component for (%i)!", lot);
return CDItemComponentTable::Default;
}
const auto& itemComponent = itemComponents->GetItemComponentByID(componentId);
return itemComponent;
@ -344,7 +344,7 @@ bool Inventory::IsValidItem(const LOT lot)
return componentId != 0;
}
const std::vector<LOT>& Inventory::GetAllGMItems()
const std::vector<LOT>& Inventory::GetAllGMItems()
{
return m_GameMasterRestrictedItems;
}

View File

@ -20,7 +20,7 @@ Item::Item(const LWOOBJID id, const LOT lot, Inventory* inventory, const uint32_
{
return;
}
this->id = id;
this->lot = lot;
this->inventory = inventory;
@ -32,7 +32,7 @@ Item::Item(const LWOOBJID id, const LOT lot, Inventory* inventory, const uint32_
this->info = &Inventory::FindItemComponent(lot);
this->preconditions = new PreconditionExpression(this->info->reqPrecondition);
this->subKey = subKey;
inventory->AddManagedItem(this);
}
@ -48,7 +48,7 @@ Item::Item(
LWOOBJID subKey,
bool bound,
eLootSourceType lootSourceType)
{
{
if (!Inventory::IsValidItem(lot))
{
return;
@ -87,7 +87,7 @@ Item::Item(
{
Equip();
Game::logger->Log("Item", "Move and equipped (%i) from (%i)\n", this->lot, this->inventory->GetType());
Game::logger->Log("Item", "Move and equipped (%i) from (%i)", this->lot, this->inventory->GetType());
EntityManager::Instance()->SerializeEntity(inventory->GetComponent()->GetParent());
}
@ -154,7 +154,7 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem
{
return;
}
const auto delta = std::abs(static_cast<int32_t>(value) - static_cast<int32_t>(count));
const auto type = static_cast<eItemType>(info->itemType);
@ -169,11 +169,11 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem
}
}
}
if (!silent)
{
auto* entity = inventory->GetComponent()->GetParent();
if (value > count)
{
GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta, LWOOBJID_EMPTY, lootSourceType);
@ -217,7 +217,7 @@ void Item::SetBound(const bool value)
bound = value;
}
void Item::SetSubKey(LWOOBJID value)
void Item::SetSubKey(LWOOBJID value)
{
subKey = value;
}
@ -271,14 +271,14 @@ bool Item::IsEquipped() const
bool Item::Consume()
{
auto* skillsTable = CDClientManager::Instance()->GetTable<CDObjectSkillsTable>("ObjectSkills");
auto skills = skillsTable->Query([=](const CDObjectSkills entry)
{
return entry.objectTemplate == static_cast<uint32_t>(lot);
});
auto success = false;
for (auto& skill : skills)
{
if (skill.castOnType == 3) // Consumable type
@ -287,7 +287,7 @@ bool Item::Consume()
}
}
Game::logger->Log("Item", "Consumed (%i) / (%llu) with (%d)\n", lot, id, success);
Game::logger->Log("Item", "Consumed (%i) / (%llu) with (%d)", lot, id, success);
GameMessages::SendUseItemResult(inventory->GetComponent()->GetParent(), lot, success);
@ -343,7 +343,7 @@ bool Item::UseNonEquip()
LootGenerator::Instance().GiveLoot(inventory->GetComponent()->GetParent(), result, eLootSourceType::LOOT_SOURCE_CONSUMPTION);
}
Game::logger->Log("Item", "Used (%i)\n", lot);
Game::logger->Log("Item", "Used (%i)", lot);
inventory->GetComponent()->RemoveItem(lot, 1);
}
@ -357,11 +357,11 @@ void Item::Disassemble(const eInventoryType inventoryType)
if (data->GetKey() == u"assemblyPartLOTs")
{
auto modStr = data->GetValueAsString();
std::vector<LOT> modArray;
std::stringstream ssData(modStr);
std::string token;
const auto deliminator = '+';
@ -369,7 +369,7 @@ void Item::Disassemble(const eInventoryType inventoryType)
while (std::getline(ssData, token, deliminator))
{
const auto modLot = std::stoi(token.substr(2, token.size() - 1));
modArray.push_back(modLot);
}
@ -397,7 +397,7 @@ void Item::DisassembleModel()
{
return;
}
std::string renderAsset = result.fieldIsNull(0) ? "" : std::string(result.getStringField(0));
std::vector<std::string> renderAssetSplit = GeneralUtils::SplitString(renderAsset, '\\');
@ -410,7 +410,7 @@ void Item::DisassembleModel()
{
return;
}
std::stringstream data;
data << file.rdbuf();
@ -420,7 +420,7 @@ void Item::DisassembleModel()
}
auto* doc = new tinyxml2::XMLDocument();
if (!doc)
{
return;
@ -436,26 +436,26 @@ void Item::DisassembleModel()
auto* lxfml = doc->FirstChildElement("LXFML");
auto* bricks = lxfml->FirstChildElement("Bricks");
std::string searchTerm = "Brick";
if (!bricks)
{
searchTerm = "Part";
bricks = lxfml->FirstChildElement("Scene")->FirstChildElement("Model")->FirstChildElement("Group");
if (!bricks)
{
return;
}
}
auto* currentBrick = bricks->FirstChildElement(searchTerm.c_str());
while (currentBrick)
{
if (currentBrick->Attribute("designID") != nullptr)
if (currentBrick->Attribute("designID") != nullptr)
{
parts.push_back(std::stoi(currentBrick->Attribute("designID")));
}
currentBrick = currentBrick->NextSiblingElement(searchTerm.c_str());
}
@ -472,7 +472,7 @@ void Item::DisassembleModel()
{
continue;
}
GetInventory()->GetComponent()->AddItem(brickID[0].NDObjectID, 1, eLootSourceType::LOOT_SOURCE_DELETION);
}
}
@ -480,7 +480,7 @@ void Item::DisassembleModel()
void Item::RemoveFromInventory()
{
UnEquip();
count = 0;
inventory->RemoveManagedItem(this);

View File

@ -35,7 +35,7 @@ Mission::Mission(MissionComponent* missionComponent, const uint32_t missionId) {
info = missionsTable->GetPtrByMissionID(missionId);
if (info == &CDMissionsTable::Default) {
Game::logger->Log("Missions", "Failed to find mission (%i)!\n", missionId);
Game::logger->Log("Missions", "Failed to find mission (%i)!", missionId);
return;
}
@ -491,7 +491,7 @@ void Mission::YieldRewards() {
if (pair.second < 0 || (m_Reward > 0 && pair.first != m_Reward)) {
continue;
}
// If a mission rewards zero of an item, make it reward 1.
auto count = pair.second > 0 ? pair.second : 1;

View File

@ -31,7 +31,7 @@ MissionTask::MissionTask(Mission* mission, CDMissionTasks* info, uint32_t mask)
parameters.push_back(parameter);
}
}
stream = std::istringstream(info->targetGroup);
while (std::getline(stream, token, ',')) {
@ -61,14 +61,14 @@ void MissionTask::SetProgress(const uint32_t value, const bool echo)
{
return;
}
progress = value;
if (!echo)
{
return;
}
auto* entity = mission->GetAssociate();
if (entity == nullptr)
@ -101,7 +101,7 @@ void MissionTask::AddProgress(int32_t value)
{
value = 0;
}
SetProgress(value);
}
@ -211,7 +211,7 @@ void MissionTask::CheckCompletion() const
void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string& targets, int32_t count)
{
if (IsComplete() && count > 0) return;
const auto type = GetType();
if (count < 0)
@ -250,11 +250,11 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
uint32_t lot;
uint32_t collectionId;
std::vector<LDFBaseData*> settings;
switch (type) {
case MissionTaskType::MISSION_TASK_TYPE_UNKNOWN:
break;
case MissionTaskType::MISSION_TASK_TYPE_ACTIVITY:
{
if (InAllTargets(value)) {
@ -265,7 +265,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
entity = EntityManager::Instance()->GetEntity(associate);
if (entity == nullptr) {
if (associate != LWOOBJID_EMPTY) {
Game::logger->Log("MissionTask", "Failed to find associated entity (%llu)!\n", associate);
Game::logger->Log("MissionTask", "Failed to find associated entity (%llu)!", associate);
}
break;
}
@ -305,12 +305,12 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
case MissionTaskType::MISSION_TASK_TYPE_EMOTE:
{
if (!InParameters(value)) break;
entity = EntityManager::Instance()->GetEntity(associate);
if (entity == nullptr)
{
Game::logger->Log("MissionTask", "Failed to find associated entity (%llu)!\n", associate);
Game::logger->Log("MissionTask", "Failed to find associated entity (%llu)!", associate);
break;
}
@ -320,10 +320,10 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
if (GetTarget() != lot) break;
AddProgress(count);
break;
}
case MissionTaskType::MISSION_TASK_TYPE_SKILL:
{
// This is a complicated check because for some missions we need to check for the associate being in the parameters instead of the value being in the parameters.
@ -331,7 +331,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
if (InParameters(value)) AddProgress(count);
} else {
if (InParameters(associate) && InAllTargets(value)) AddProgress(count);
}
}
break;
}
@ -373,19 +373,19 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
AddProgress(count);
unique.push_back(associate);
break;
}
case MissionTaskType::MISSION_TASK_TYPE_ENVIRONMENT:
{
if (!InAllTargets(value)) break;
entity = EntityManager::Instance()->GetEntity(associate);
if (entity == nullptr)
{
Game::logger->Log("MissionTask", "Failed to find associated entity (%llu)!\n", associate);
Game::logger->Log("MissionTask", "Failed to find associated entity (%llu)!", associate);
break;
}
@ -397,7 +397,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
if (std::find(unique.begin(), unique.end(), collectionId) != unique.end()) break;
unique.push_back(collectionId);
SetProgress(unique.size());
auto* entity = mission->GetAssociate();
@ -409,7 +409,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
if (missionComponent == nullptr) break;
missionComponent->AddCollectible(collectionId);
break;
}
@ -418,10 +418,10 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
if (info->targetGroup != targets) break;
AddProgress(count);
break;
}
case MissionTaskType::MISSION_TASK_TYPE_RACING:
{
// The meaning of associate can be found in RacingTaskParam.h
@ -452,7 +452,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
{
// If the player did not crash during the race, progress this task by count.
if (value != 0) break;
AddProgress(count);
}
else if (associate == 4 || associate == 5 || associate == 14)
@ -495,7 +495,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
break;
}
default:
Game::logger->Log("MissionTask", "Invalid mission task type (%i)!\n", static_cast<int>(type));
Game::logger->Log("MissionTask", "Invalid mission task type (%i)!", static_cast<int>(type));
return;
}

View File

@ -93,7 +93,7 @@ void Mail::SendMail(const LWOOBJID sender, const std::string& senderName, LWOOBJ
delete ins;
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) return; // TODO: Echo to chat server
SendNotification(sysAddr, 1); //Show the "one new mail" message
}
@ -152,7 +152,7 @@ void Mail::HandleMailStuff(RakNet::BitStream* packet, const SystemAddress& sysAd
Mail::HandleSendMail(packet, sysAddr, entity);
break;
default:
Game::logger->Log("Mail", "Unhandled and possibly undefined MailStuffID: %i\n", int(stuffID));
Game::logger->Log("Mail", "Unhandled and possibly undefined MailStuffID: %i", int(stuffID));
}
});
}
@ -264,10 +264,10 @@ void Mail::HandleSendMail(RakNet::BitStream* packet, const SystemAddress& sysAdd
Mail::SendSendResponse(sysAddr, Mail::MailSendResponse::Success);
entity->GetCharacter()->SetCoins(entity->GetCharacter()->GetCoins() - mailCost, eLootSourceType::LOOT_SOURCE_MAIL);
Game::logger->Log("Mail", "Seeing if we need to remove item with ID/count/LOT: %i %i %i\n", itemID, attachmentCount, itemLOT);
Game::logger->Log("Mail", "Seeing if we need to remove item with ID/count/LOT: %i %i %i", itemID, attachmentCount, itemLOT);
if (inv && itemLOT != 0 && attachmentCount > 0 && item) {
Game::logger->Log("Mail", "Trying to remove item with ID/count/LOT: %i %i %i\n", itemID, attachmentCount, itemLOT);
Game::logger->Log("Mail", "Trying to remove item with ID/count/LOT: %i %i %i", itemID, attachmentCount, itemLOT);
inv->RemoveItem(itemLOT, attachmentCount, INVALID, true);
auto* missionCompoent = entity->GetComponent<MissionComponent>();

View File

@ -29,7 +29,7 @@ Precondition::Precondition(const uint32_t condition) {
this->count = 1;
this->values = { 0 };
Game::logger->Log("Precondition", "Failed to find precondition of id (%i)!\n", condition);
Game::logger->Log("Precondition", "Failed to find precondition of id (%i)!", condition);
return;
}

View File

@ -102,7 +102,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
break;
}
//Game::logger->Log("SlashCommandHandler", "Received chat command \"%s\"\n", GeneralUtils::UTF16ToWTF8(command).c_str());
//Game::logger->Log("SlashCommandHandler", "Received chat command \"%s\"", GeneralUtils::UTF16ToWTF8(command).c_str());
User* user = UserManager::Instance()->GetUser(sysAddr);
if ((chatCommand == "setgmlevel" || chatCommand == "makegm" || chatCommand == "gmlevel") && user->GetMaxGMLevel() > GAME_MASTER_LEVEL_CIVILIAN) {
@ -145,7 +145,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
WorldPackets::SendGMLevelChange(sysAddr, success, user->GetMaxGMLevel(), entity->GetGMLevel(), level);
GameMessages::SendChatModeUpdate(entity->GetObjectID(), level);
entity->SetGMLevel(level);
Game::logger->Log("SlashCommandHandler", "User %s (%i) has changed their GM level to %i for charID %llu\n", user->GetUsername().c_str(), user->GetAccountID(), level, entity->GetObjectID());
Game::logger->Log("SlashCommandHandler", "User %s (%i) has changed their GM level to %i for charID %llu", user->GetUsername().c_str(), user->GetAccountID(), level, entity->GetObjectID());
}
}
@ -170,7 +170,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
auto* character = entity->GetComponent<CharacterComponent>();
if (character == nullptr) {
Game::logger->Log("SlashCommandHandler", "Failed to find character component!\n");
Game::logger->Log("SlashCommandHandler", "Failed to find character component!");
return;
}
@ -289,7 +289,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
args.InsertValue("visible", new AMFTrueValue());
args.InsertValue("text", text);
Game::logger->Log("SlashCommandHandler", "Sending \n%s\n", customText.c_str());
Game::logger->Log("SlashCommandHandler", "Sending %s", customText.c_str());
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "ToggleStoryBox", &args);
});
@ -324,7 +324,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
const auto sysAddr = entity->GetSystemAddress();
Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i\n", entity->GetCharacter()->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", entity->GetCharacter()->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
if (entity->GetCharacter()) {
entity->GetCharacter()->SetZoneID(zoneID);
@ -344,7 +344,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
ZoneInstanceManager::Instance()->RequestPrivateZone(Game::server, false, password, [=](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort)
{
Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i\n", sysAddr.ToString(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", sysAddr.ToString(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
if (entity->GetCharacter()) {
entity->GetCharacter()->SetZoneID(zoneID);
@ -920,7 +920,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
pos.SetY(y);
pos.SetZ(z);
Game::logger->Log("SlashCommandHandler", "Teleporting objectID: %llu to %f, %f, %f\n", entity->GetObjectID(), pos.x, pos.y, pos.z);
Game::logger->Log("SlashCommandHandler", "Teleporting objectID: %llu to %f, %f, %f", entity->GetObjectID(), pos.x, pos.y, pos.z);
GameMessages::SendTeleport(entity->GetObjectID(), pos, NiQuaternion(), sysAddr);
} else if (args.size() == 2) {
@ -942,7 +942,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
pos.SetY(0.0f);
pos.SetZ(z);
Game::logger->Log("SlashCommandHandler", "Teleporting objectID: %llu to X: %f, Z: %f\n", entity->GetObjectID(), pos.x, pos.z);
Game::logger->Log("SlashCommandHandler", "Teleporting objectID: %llu to X: %f, Z: %f", entity->GetObjectID(), pos.x, pos.z);
GameMessages::SendTeleport(entity->GetObjectID(), pos, NiQuaternion(), sysAddr);
} else {
ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /teleport <x> (<y>) <z> - if no Y given, will teleport to the height of the terrain (or any physics object).");
@ -964,7 +964,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
EntityManager::Instance()->SerializeEntity(possassableEntity);
Game::logger->Log("ClientPackets", "Forced updated vehicle position\n");
Game::logger->Log("ClientPackets", "Forced updated vehicle position");
}
}
}
@ -1522,7 +1522,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
ChatPackets::SendSystemMessage(sysAddr, u"Transfering map...");
Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i\n", sysAddr.ToString(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
Game::logger->Log("UserManager", "Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", sysAddr.ToString(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
if (entity->GetCharacter()) {
entity->GetCharacter()->SetZoneID(zoneID);
entity->GetCharacter()->SetZoneInstance(zoneInstance);

View File

@ -48,7 +48,7 @@ void VanityUtilities::SpawnVanity()
std::vector<VanityNPC> npcList = m_NPCs;
std::vector<uint32_t> taken = {};
Game::logger->Log("VanityUtilities", "Spawning party with %i locations\n", party.m_Locations.size());
Game::logger->Log("VanityUtilities", "Spawning party with %i locations", party.m_Locations.size());
// Loop through all locations
for (const auto& location : party.m_Locations) {
@ -187,7 +187,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* npcs = doc.FirstChildElement("npcs");
if (npcs == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse NPCs\n");
Game::logger->Log("VanityUtilities", "Failed to parse NPCs");
return;
}
@ -211,7 +211,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* locations = party->FirstChildElement("locations");
if (locations == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse party locations\n");
Game::logger->Log("VanityUtilities", "Failed to parse party locations");
continue;
}
@ -228,7 +228,7 @@ void VanityUtilities::ParseXML(const std::string& file)
if (x == nullptr || y == nullptr || z == nullptr || rw == nullptr || rx == nullptr || ry == nullptr
|| rz == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse party location data\n");
Game::logger->Log("VanityUtilities", "Failed to parse party location data");
continue;
}
@ -246,7 +246,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* partyPhrases = npcs->FirstChildElement("partyphrases");
if (partyPhrases == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse party phrases\n");
Game::logger->Log("VanityUtilities", "Failed to parse party phrases");
return;
}
@ -256,7 +256,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* text = phrase->GetText();
if (text == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse party phrase\n");
Game::logger->Log("VanityUtilities", "Failed to parse party phrase");
continue;
}
@ -268,7 +268,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* name = npc->Attribute("name");
if (name == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse NPC name\n");
Game::logger->Log("VanityUtilities", "Failed to parse NPC name");
continue;
}
@ -276,7 +276,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* lot = npc->Attribute("lot");
if (lot == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse NPC lot\n");
Game::logger->Log("VanityUtilities", "Failed to parse NPC lot");
continue;
}
@ -284,7 +284,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* equipment = npc->FirstChildElement("equipment");
if (equipment == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse NPC equipment\n");
Game::logger->Log("VanityUtilities", "Failed to parse NPC equipment");
continue;
}
@ -306,7 +306,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* phrases = npc->FirstChildElement("phrases");
if (phrases == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse NPC phrases\n");
Game::logger->Log("VanityUtilities", "Failed to parse NPC phrases");
continue;
}
@ -318,7 +318,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* text = phrase->GetText();
if (text == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse NPC phrase\n");
Game::logger->Log("VanityUtilities", "Failed to parse NPC phrase");
continue;
}
@ -334,7 +334,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* scriptNameAttribute = scriptElement->Attribute("name");
if (scriptNameAttribute == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse NPC script name\n");
Game::logger->Log("VanityUtilities", "Failed to parse NPC script name");
continue;
}
@ -358,7 +358,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* name = flag->Attribute("name");
if (name == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse NPC flag name\n");
Game::logger->Log("VanityUtilities", "Failed to parse NPC flag name");
continue;
}
@ -366,7 +366,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* value = flag->Attribute("value");
if (value == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse NPC flag value\n");
Game::logger->Log("VanityUtilities", "Failed to parse NPC flag value");
continue;
}
@ -380,7 +380,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* zoneID = zone->Attribute("id");
if (zoneID == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse NPC zone ID\n");
Game::logger->Log("VanityUtilities", "Failed to parse NPC zone ID");
continue;
}
@ -388,7 +388,7 @@ void VanityUtilities::ParseXML(const std::string& file)
auto* locations = zone->FirstChildElement("locations");
if (locations == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse NPC locations\n");
Game::logger->Log("VanityUtilities", "Failed to parse NPC locations");
continue;
}
@ -405,7 +405,7 @@ void VanityUtilities::ParseXML(const std::string& file)
if (x == nullptr || y == nullptr || z == nullptr || rw == nullptr || rx == nullptr || ry == nullptr
|| rz == nullptr) {
Game::logger->Log("VanityUtilities", "Failed to parse NPC location data\n");
Game::logger->Log("VanityUtilities", "Failed to parse NPC location data");
continue;
}

View File

@ -26,7 +26,7 @@ InstanceManager::~InstanceManager() {
}
Instance * InstanceManager::GetInstance(LWOMAPID mapID, bool isFriendTransfer, LWOCLONEID cloneID) {
mLogger->Log("InstanceManager", "Searching for an instance for mapID %i/%i\n", mapID, cloneID);
mLogger->Log("InstanceManager", "Searching for an instance for mapID %i/%i", mapID, cloneID);
Instance* instance = FindInstance(mapID, isFriendTransfer, cloneID);
if (instance) return instance;
@ -78,10 +78,10 @@ Instance * InstanceManager::GetInstance(LWOMAPID mapID, bool isFriendTransfer, L
m_Instances.push_back(instance);
if (instance) {
mLogger->Log("InstanceManager", "Created new instance: %i/%i/%i with min/max %i/%i\n", mapID, m_LastInstanceID, cloneID, softCap, maxPlayers);
mLogger->Log("InstanceManager", "Created new instance: %i/%i/%i with min/max %i/%i", mapID, m_LastInstanceID, cloneID, softCap, maxPlayers);
return instance;
}
else mLogger->Log("InstanceManager", "Failed to create a new instance!\n");
else mLogger->Log("InstanceManager", "Failed to create a new instance!");
return nullptr;
}
@ -92,7 +92,7 @@ bool InstanceManager::IsPortInUse(uint32_t port) {
return true;
}
}
return false;
}
@ -102,7 +102,7 @@ uint32_t InstanceManager::GetFreePort() {
for (Instance* i : m_Instances) {
usedPorts.push_back(i->GetPort());
}
std::sort(usedPorts.begin(), usedPorts.end());
int portIdx = 0;
@ -142,7 +142,7 @@ std::vector<Instance*> InstanceManager::GetInstances() const
void InstanceManager::AddInstance(Instance* instance) {
if (instance == nullptr) return;
m_Instances.push_back(instance);
}
@ -152,9 +152,9 @@ void InstanceManager::RemoveInstance(Instance* instance) {
if (m_Instances[i] == instance)
{
instance->SetShutdownComplete(true);
RedirectPendingRequests(instance);
delete m_Instances[i];
m_Instances.erase(m_Instances.begin() + i);
@ -174,7 +174,7 @@ void InstanceManager::ReadyInstance(Instance* instance)
{
const auto& zoneId = instance->GetZoneID();
Game::logger->Log("InstanceManager", "Responding to pending request %llu -> %i (%i)\n", request, zoneId.GetMapID(), zoneId.GetCloneID());
Game::logger->Log("InstanceManager", "Responding to pending request %llu -> %i (%i)", request, zoneId.GetMapID(), zoneId.GetCloneID());
MasterPackets::SendZoneTransferResponse(
Game::server,
@ -188,7 +188,7 @@ void InstanceManager::ReadyInstance(Instance* instance)
instance->GetPort()
);
}
pending.clear();
}
@ -201,10 +201,10 @@ void InstanceManager::RequestAffirmation(Instance* instance, const PendingInstan
PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_AFFIRM_TRANSFER_REQUEST);
bitStream.Write(request.id);
Game::server->Send(&bitStream, instance->GetSysAddr(), false);
Game::logger->Log("MasterServer", "Sent affirmation request %llu to %i/%i\n", request.id,
Game::logger->Log("MasterServer", "Sent affirmation request %llu to %i/%i", request.id,
static_cast<int>(instance->GetZoneID().GetMapID()),
static_cast<int>(instance->GetZoneID().GetCloneID())
);
@ -217,7 +217,7 @@ void InstanceManager::AffirmTransfer(Instance* instance, const uint64_t transfer
for (auto i = 0u; i < pending.size(); ++i)
{
const auto& request = pending[i];
if (request.id != transferID) continue;
const auto& zoneId = instance->GetZoneID();
@ -233,7 +233,7 @@ void InstanceManager::AffirmTransfer(Instance* instance, const uint64_t transfer
instance->GetIP(),
instance->GetPort()
);
pending.erase(pending.begin() + i);
break;
@ -243,7 +243,7 @@ void InstanceManager::AffirmTransfer(Instance* instance, const uint64_t transfer
void InstanceManager::RedirectPendingRequests(Instance* instance)
{
const auto& zoneId = instance->GetZoneID();
for (const auto& request : instance->GetPendingAffirmations())
{
auto* in = Game::im->GetInstance(zoneId.GetMapID(), false, zoneId.GetCloneID());
@ -270,11 +270,11 @@ Instance* InstanceManager::GetInstanceBySysAddr(SystemAddress& sysAddr) {
}
bool InstanceManager::IsInstanceFull(Instance* instance, bool isFriendTransfer) {
if (!isFriendTransfer && instance->GetSoftCap() > instance->GetCurrentClientCount())
if (!isFriendTransfer && instance->GetSoftCap() > instance->GetCurrentClientCount())
return false;
else if (isFriendTransfer && instance->GetHardCap() > instance->GetCurrentClientCount())
else if (isFriendTransfer && instance->GetHardCap() > instance->GetCurrentClientCount())
return false;
return true;
}
@ -308,7 +308,7 @@ Instance* InstanceManager::CreatePrivateInstance(LWOMAPID mapID, LWOCLONEID clon
}
int maxPlayers = 999;
uint32_t port = GetFreePort();
instance = new Instance(mExternalIP, port, mapID, ++m_LastInstanceID, cloneID, maxPlayers, maxPlayers, true, password);
@ -339,7 +339,7 @@ Instance* InstanceManager::CreatePrivateInstance(LWOMAPID mapID, LWOCLONEID clon
m_Instances.push_back(instance);
if (instance) return instance;
else mLogger->Log("InstanceManager", "Failed to create a new instance!\n");
else mLogger->Log("InstanceManager", "Failed to create a new instance!");
return instance;
}
@ -355,7 +355,7 @@ Instance* InstanceManager::FindPrivateInstance(const std::string& password)
continue;
}
mLogger->Log("InstanceManager", "Password: %s == %s => %d\n", password.c_str(), instance->GetPassword().c_str(), password == instance->GetPassword());
mLogger->Log("InstanceManager", "Password: %s == %s => %d", password.c_str(), instance->GetPassword().c_str(), password == instance->GetPassword());
if (instance->GetPassword() == password)
{
@ -375,7 +375,7 @@ int InstanceManager::GetSoftCap(LWOMAPID mapID) {
return zone->population_soft_cap;
}
}
return 8;
}
@ -405,10 +405,10 @@ bool Instance::GetShutdownComplete() const
void Instance::Shutdown()
{
CBITSTREAM;
PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_SHUTDOWN);
Game::server->Send(&bitStream, this->m_SysAddr, false);
Game::logger->Log("Instance", "Triggered world shutdown\n");
Game::logger->Log("Instance", "Triggered world shutdown");
}

View File

@ -75,16 +75,16 @@ int main(int argc, char** argv) {
Game::logger = SetupLogger();
if (!Game::logger) return EXIT_FAILURE;
Game::logger->Log("MasterServer", "Starting Master server...\n");
Game::logger->Log("MasterServer", "Version: %i.%i\n", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR);
Game::logger->Log("MasterServer", "Compiled on: %s\n", __TIMESTAMP__);
Game::logger->Log("MasterServer", "Starting Master server...");
Game::logger->Log("MasterServer", "Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR);
Game::logger->Log("MasterServer", "Compiled on: %s", __TIMESTAMP__);
//Read our config:
dConfig config("masterconfig.ini");
Game::config = &config;
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
if (argc > 1 && (strcmp(argv[1], "-m") == 0 || strcmp(argv[1], "--migrations") == 0)) {
//Connect to the MySQL Database
std::string mysql_host = config.GetValue("mysql_host");
@ -95,23 +95,23 @@ int main(int argc, char** argv) {
try {
Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password);
} catch (sql::SQLException& ex) {
Game::logger->Log("MasterServer", "Got an error while connecting to the database: %s\n", ex.what());
Game::logger->Log("MigrationRunner", "Migrations not run\n");
Game::logger->Log("MasterServer", "Got an error while connecting to the database: %s", ex.what());
Game::logger->Log("MigrationRunner", "Migrations not run");
return EXIT_FAILURE;
}
MigrationRunner::RunMigrations();
Game::logger->Log("MigrationRunner", "Finished running migrations\n");
Game::logger->Log("MigrationRunner", "Finished running migrations");
return EXIT_SUCCESS;
}
}
else {
//Check CDClient exists
const std::string cdclient_path = "./res/CDServer.sqlite";
std::ifstream cdclient_fd(cdclient_path);
if (!cdclient_fd.good()) {
Game::logger->Log("WorldServer", "%s could not be opened\n", cdclient_path.c_str());
Game::logger->Log("WorldServer", "%s could not be opened", cdclient_path.c_str());
return EXIT_FAILURE;
}
cdclient_fd.close();
@ -120,9 +120,9 @@ int main(int argc, char** argv) {
try {
CDClientDatabase::Connect(cdclient_path);
} catch (CppSQLite3Exception& e) {
Game::logger->Log("WorldServer", "Unable to connect to CDServer SQLite Database\n");
Game::logger->Log("WorldServer", "Error: %s\n", e.errorMessage());
Game::logger->Log("WorldServer", "Error Code: %i\n", e.errorCode());
Game::logger->Log("WorldServer", "Unable to connect to CDServer SQLite Database");
Game::logger->Log("WorldServer", "Error: %s", e.errorMessage());
Game::logger->Log("WorldServer", "Error Code: %i", e.errorCode());
return EXIT_FAILURE;
}
@ -130,10 +130,10 @@ int main(int argc, char** argv) {
try {
CDClientManager::Instance()->Initialize();
} catch (CppSQLite3Exception& e) {
Game::logger->Log("WorldServer", "Failed to initialize CDServer SQLite Database\n");
Game::logger->Log("WorldServer", "May be caused by corrupted file: %s\n", cdclient_path.c_str());
Game::logger->Log("WorldServer", "Error: %s\n", e.errorMessage());
Game::logger->Log("WorldServer", "Error Code: %i\n", e.errorCode());
Game::logger->Log("WorldServer", "Failed to initialize CDServer SQLite Database");
Game::logger->Log("WorldServer", "May be caused by corrupted file: %s", cdclient_path.c_str());
Game::logger->Log("WorldServer", "Error: %s", e.errorMessage());
Game::logger->Log("WorldServer", "Error Code: %i", e.errorCode());
return EXIT_FAILURE;
}
@ -146,7 +146,7 @@ int main(int argc, char** argv) {
try {
Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password);
} catch (sql::SQLException& ex) {
Game::logger->Log("MasterServer", "Got an error while connecting to the database: %s\n", ex.what());
Game::logger->Log("MasterServer", "Got an error while connecting to the database: %s", ex.what());
return EXIT_FAILURE;
}
}
@ -368,14 +368,14 @@ dLogger* SetupLogger() {
void HandlePacket(Packet* packet) {
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION) {
Game::logger->Log("MasterServer", "A server has disconnected\n");
Game::logger->Log("MasterServer", "A server has disconnected");
//Since this disconnection is intentional, we'll just delete it as
//we'll start a new one anyway if needed:
Instance* instance =
Game::im->GetInstanceBySysAddr(packet->systemAddress);
if (instance) {
Game::logger->Log("MasterServer", "Actually disconnected from zone %i clone %i instance %i port %i\n", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance->GetPort());
Game::logger->Log("MasterServer", "Actually disconnected from zone %i clone %i instance %i port %i", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance->GetPort());
Game::im->RemoveInstance(instance); //Delete the old
}
@ -385,7 +385,7 @@ void HandlePacket(Packet* packet) {
}
if (packet->data[0] == ID_CONNECTION_LOST) {
Game::logger->Log("MasterServer", "A server has lost the connection\n");
Game::logger->Log("MasterServer", "A server has lost the connection");
Instance* instance =
Game::im->GetInstanceBySysAddr(packet->systemAddress);
@ -403,7 +403,7 @@ void HandlePacket(Packet* packet) {
if (packet->data[1] == MASTER) {
switch (packet->data[3]) {
case MSG_MASTER_REQUEST_PERSISTENT_ID: {
Game::logger->Log("MasterServer", "A persistent ID req\n");
Game::logger->Log("MasterServer", "A persistent ID req");
RakNet::BitStream inStream(packet->data, packet->length, false);
uint64_t header = inStream.Read(header);
uint64_t requestID = 0;
@ -415,7 +415,7 @@ void HandlePacket(Packet* packet) {
}
case MSG_MASTER_REQUEST_ZONE_TRANSFER: {
Game::logger->Log("MasterServer","Received zone transfer req\n");
Game::logger->Log("MasterServer","Received zone transfer req");
RakNet::BitStream inStream(packet->data, packet->length, false);
uint64_t header = inStream.Read(header);
uint64_t requestID = 0;
@ -431,18 +431,18 @@ void HandlePacket(Packet* packet) {
Instance* in = Game::im->GetInstance(zoneID, false, zoneClone);
for (auto* instance : Game::im->GetInstances()) {
Game::logger->Log("MasterServer", "Instance: %i/%i/%i -> %i\n",instance->GetMapID(), instance->GetCloneID(),instance->GetInstanceID(), instance == in);
Game::logger->Log("MasterServer", "Instance: %i/%i/%i -> %i",instance->GetMapID(), instance->GetCloneID(),instance->GetInstanceID(), instance == in);
}
if (!in->GetIsReady()) //Instance not ready, make a pending request
{
in->GetPendingRequests().push_back({ requestID, static_cast<bool>(mythranShift), packet->systemAddress });
Game::logger->Log("MasterServer", "Server not ready, adding pending request %llu %i %i\n", requestID, zoneID, zoneClone);
Game::logger->Log("MasterServer", "Server not ready, adding pending request %llu %i %i", requestID, zoneID, zoneClone);
break;
}
//Instance is ready, transfer
Game::logger->Log("MasterServer", "Responding to transfer request %llu for zone %i %i\n", requestID, zoneID, zoneClone);
Game::logger->Log("MasterServer", "Responding to transfer request %llu for zone %i %i", requestID, zoneID, zoneClone);
Game::im->RequestAffirmation(in, { requestID, static_cast<bool>(mythranShift), packet->systemAddress });
break;
}
@ -494,7 +494,7 @@ void HandlePacket(Packet* packet) {
chatServerMasterPeerSysAddr = copy;
}
Game::logger->Log("MasterServer", "Received server info, instance: %i port: %i\n", theirInstanceID, theirPort);
Game::logger->Log("MasterServer", "Received server info, instance: %i port: %i", theirInstanceID, theirPort);
break;
}
@ -526,7 +526,7 @@ void HandlePacket(Packet* packet) {
}
activeSessions.insert(std::make_pair(sessionKey, username));
Game::logger->Log("MasterServer", "Got sessionKey %i for user %s\n", sessionKey, username.c_str());
Game::logger->Log("MasterServer", "Got sessionKey %i for user %s", sessionKey, username.c_str());
break;
}
@ -564,7 +564,7 @@ void HandlePacket(Packet* packet) {
instance->AddPlayer(Player());
}
else {
printf("Instance missing? What?\n");
printf("Instance missing? What?");
}
break;
}
@ -622,7 +622,7 @@ void HandlePacket(Packet* packet) {
inStream.Read(requestID);
inStream.Read(mythranShift);
uint32_t len;
inStream.Read<uint32_t>(len);
@ -633,7 +633,7 @@ void HandlePacket(Packet* packet) {
auto* instance = Game::im->FindPrivateInstance(password.c_str());
Game::logger->Log( "MasterServer", "Join private zone: %llu %d %s %p\n", requestID, mythranShift, password.c_str(), instance);
Game::logger->Log( "MasterServer", "Join private zone: %llu %d %s %p", requestID, mythranShift, password.c_str(), instance);
if (instance == nullptr) {
return;
@ -656,16 +656,16 @@ void HandlePacket(Packet* packet) {
inStream.Read(zoneID);
inStream.Read(instanceID);
Game::logger->Log("MasterServer", "Got world ready %i %i\n",zoneID, instanceID);
Game::logger->Log("MasterServer", "Got world ready %i %i",zoneID, instanceID);
auto* instance = Game::im->FindInstance(zoneID, instanceID);
if (instance == nullptr) {
Game::logger->Log("MasterServer","Failed to find zone to ready\n");
Game::logger->Log("MasterServer","Failed to find zone to ready");
return;
}
Game::logger->Log("MasterServer", "Ready zone %i\n", zoneID);
Game::logger->Log("MasterServer", "Ready zone %i", zoneID);
Game::im->ReadyInstance(instance);
break;
}
@ -677,7 +677,7 @@ void HandlePacket(Packet* packet) {
int zoneID;
inStream.Read(zoneID);
Game::logger->Log("MasterServer", "Prepping zone %i\n", zoneID);
Game::logger->Log("MasterServer", "Prepping zone %i", zoneID);
Game::im->GetInstance(zoneID, false, 0);
break;
}
@ -690,7 +690,7 @@ void HandlePacket(Packet* packet) {
inStream.Read(requestID);
Game::logger->Log("MasterServer","Got affirmation of transfer %llu\n",requestID);
Game::logger->Log("MasterServer","Got affirmation of transfer %llu",requestID);
auto* instance =Game::im->GetInstanceBySysAddr(packet->systemAddress);
@ -698,7 +698,7 @@ void HandlePacket(Packet* packet) {
return;
Game::im->AffirmTransfer(instance, requestID);
Game::logger->Log("MasterServer", "Affirmation complete %llu\n",requestID);
Game::logger->Log("MasterServer", "Affirmation complete %llu",requestID);
break;
}
@ -712,19 +712,19 @@ void HandlePacket(Packet* packet) {
return;
}
Game::logger->Log("MasterServer", "Got shutdown response from zone %i clone %i instance %i port %i\n", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance->GetPort());
Game::logger->Log("MasterServer", "Got shutdown response from zone %i clone %i instance %i port %i", instance->GetMapID(), instance->GetCloneID(), instance->GetInstanceID(), instance->GetPort());
instance->SetIsShuttingDown(true);
break;
}
case MSG_MASTER_SHUTDOWN_UNIVERSE: {
Game::logger->Log("MasterServer","Received shutdown universe command, shutting down in 10 minutes.\n");
Game::logger->Log("MasterServer","Received shutdown universe command, shutting down in 10 minutes.");
shouldShutdown = true;
break;
}
default:
Game::logger->Log("MasterServer","Unknown master packet ID from server: %i\n",packet->data[3]);
Game::logger->Log("MasterServer","Unknown master packet ID from server: %i",packet->data[3]);
}
}
}
@ -780,7 +780,7 @@ void ShutdownSequence() {
auto* objIdManager = ObjectIDManager::TryInstance();
if (objIdManager != nullptr) {
objIdManager->SaveToDatabase();
Game::logger->Log("MasterServer", "Saved ObjectIDTracker to DB\n");
Game::logger->Log("MasterServer", "Saved ObjectIDTracker to DB");
}
auto t = std::chrono::high_resolution_clock::now();
@ -790,7 +790,7 @@ void ShutdownSequence() {
exit(EXIT_SUCCESS);
}
Game::logger->Log("MasterServer", "Attempting to shutdown instances, max 60 seconds...\n");
Game::logger->Log("MasterServer", "Attempting to shutdown instances, max 60 seconds...");
while (true) {
@ -800,7 +800,7 @@ void ShutdownSequence() {
Game::server->DeallocatePacket(packet);
packet = nullptr;
}
auto done = true;
for (auto* instance : Game::im->GetInstances()) {
@ -814,7 +814,7 @@ void ShutdownSequence() {
}
if (done) {
Game::logger->Log("MasterServer", "Finished shutting down MasterServer!\n");
Game::logger->Log("MasterServer", "Finished shutting down MasterServer!");
break;
}
@ -824,7 +824,7 @@ void ShutdownSequence() {
ticks++;
if (ticks == 600 * 6) {
Game::logger->Log("MasterServer", "Finished shutting down by timeout!\n");
Game::logger->Log("MasterServer", "Finished shutting down by timeout!");
break;
}
}

View File

@ -40,8 +40,8 @@ void ObjectIDManager::Initialize(dLogger *logger) {
delete stmt;
} catch (sql::SQLException &e) {
mLogger->Log("ObjectIDManager", "Unable to fetch max persistent object "
"ID in use. Defaulting to 1.\n");
mLogger->Log("ObjectIDManager", "SQL error: %s\n", e.what());
"ID in use. Defaulting to 1.");
mLogger->Log("ObjectIDManager", "SQL error: %s", e.what());
this->currentPersistentID = 1;
}
}

View File

@ -27,23 +27,23 @@ void AuthPackets::HandleHandshake(dServer* server, Packet* packet) {
uint64_t header = inStream.Read(header);
uint32_t clientVersion = 0;
inStream.Read(clientVersion);
server->GetLogger()->Log("AuthPackets", "Received client version: %i\n", clientVersion);
server->GetLogger()->Log("AuthPackets", "Received client version: %i", clientVersion);
SendHandshake(server, packet->systemAddress, server->GetIP(), server->GetPort());
}
void AuthPackets::SendHandshake(dServer* server, const SystemAddress& sysAddr, const std::string& nextServerIP, uint16_t nextServerPort) {
RakNet::BitStream bitStream;
PacketUtils::WriteHeader(bitStream, SERVER, MSG_SERVER_VERSION_CONFIRM);
bitStream.Write<unsigned int>(NET_VERSION);
bitStream.Write<unsigned int>(NET_VERSION);
bitStream.Write(uint32_t(0x93));
if (nextServerPort == 1001) bitStream.Write(uint32_t(1)); //Conn: auth
else bitStream.Write(uint32_t(4)); //Conn: world
bitStream.Write(uint32_t(0)); //Server process ID
bitStream.Write(nextServerPort);
server->Send(&bitStream, sysAddr, false);
}
@ -55,15 +55,15 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
// Fetch account details
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("SELECT password, banned, locked, play_key_id, gm_level FROM accounts WHERE name=? LIMIT 1;");
stmt->setString(1, szUsername);
sql::ResultSet* res = stmt->executeQuery();
if (res->rowsCount() == 0) {
server->GetLogger()->Log("AuthPackets", "No user found!\n");
server->GetLogger()->Log("AuthPackets", "No user found!");
AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_WRONG_PASS_OR_USER, "", "", 2001, username);
return;
}
std::string sqlPass = "";
bool sqlBanned = false;
bool sqlLocked = false;
@ -77,7 +77,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
sqlPlayKey = res->getInt(4);
sqlGmLevel = res->getInt(5);
}
delete stmt;
delete res;
@ -92,7 +92,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
//Check to see if we have a play key:
if (sqlPlayKey == 0 && sqlGmLevel == 0) {
AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username);
server->GetLogger()->Log("AuthPackets", "User %s tried to log in, but they don't have a play key.\n", username.c_str());
server->GetLogger()->Log("AuthPackets", "User %s tried to log in, but they don't have a play key.", username.c_str());
return;
}
@ -101,7 +101,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
keyCheckStmt->setInt(1, sqlPlayKey);
auto keyRes = keyCheckStmt->executeQuery();
bool isKeyActive = false;
if (keyRes->rowsCount() == 0 && sqlGmLevel == 0) {
AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username);
return;
@ -113,13 +113,13 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
if (!isKeyActive && sqlGmLevel == 0) {
AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username);
server->GetLogger()->Log("AuthPackets", "User %s tried to log in, but their play key was disabled\n", username.c_str());
server->GetLogger()->Log("AuthPackets", "User %s tried to log in, but their play key was disabled", username.c_str());
return;
}
}
if (sqlBanned) {
AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_BANNED, "", "", 2001, username); return;
if (sqlBanned) {
AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_BANNED, "", "", 2001, username); return;
}
if (sqlLocked) {
@ -131,7 +131,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
* First attempt bcrypt.
* If that fails, fallback to old method and setup bcrypt for new login.
*/
bool loginSuccess = true;
int32_t bcryptState = ::bcrypt_checkpw(password.c_str(), sqlPass.c_str());
@ -162,7 +162,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
assert(bcryptState == 0);
sql::PreparedStatement* accountUpdate = Database::CreatePreppedStmt("UPDATE accounts SET password = ? WHERE name = ? LIMIT 1;");
accountUpdate->setString(1, std::string(hash, BCRYPT_HASHSIZE).c_str());
accountUpdate->setString(2, szUsername);
@ -176,7 +176,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
if (!loginSuccess) {
AuthPackets::SendLoginResponse(server, packet->systemAddress, LOGIN_RESPONSE_WRONG_PASS_OR_USER, "", "", 2001, username);
server->GetLogger()->Log("AuthPackets", "Wrong password used\n");
server->GetLogger()->Log("AuthPackets", "Wrong password used");
}
else {
SystemAddress system = packet->systemAddress; //Copy the sysAddr before the Packet gets destroyed from main
@ -185,7 +185,7 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
AuthPackets::SendLoginResponse(server, system, LOGIN_RESPONSE_GENERAL_FAILED, "", "", 0, username);
return;
}
ZoneInstanceManager::Instance()->RequestZoneTransfer(server, 0, 0, false, [system, server, username](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string zoneIP, uint16_t zonePort) {
AuthPackets::SendLoginResponse(server, system, LOGIN_RESPONSE_SUCCESS, "", zoneIP, zonePort, username);
});
@ -195,11 +195,11 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAddr, eLoginResponse responseCode, const std::string& errorMsg, const std::string& wServerIP, uint16_t wServerPort, std::string username) {
RakNet::BitStream packet;
PacketUtils::WriteHeader(packet, CLIENT, MSG_CLIENT_LOGIN_RESPONSE);
packet.Write(static_cast<uint8_t>(responseCode));
PacketUtils::WritePacketString("Talk_Like_A_Pirate", 33, &packet);
// 7 unknown strings - perhaps other IP addresses?
PacketUtils::WritePacketString("", 33, &packet);
PacketUtils::WritePacketString("", 33, &packet);
@ -208,44 +208,44 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
PacketUtils::WritePacketString("", 33, &packet);
PacketUtils::WritePacketString("", 33, &packet);
PacketUtils::WritePacketString("", 33, &packet);
packet.Write(static_cast<uint16_t>(1)); // Version Major
packet.Write(static_cast<uint16_t>(10)); // Version Current
packet.Write(static_cast<uint16_t>(64)); // Version Minor
// Writes the user key
uint32_t sessionKey = rand(); // not mt but whatever
std::string userHash = std::to_string(sessionKey);
userHash = md5(userHash);
PacketUtils::WritePacketWString(userHash, 33, &packet);
// Write the Character and Chat IPs
PacketUtils::WritePacketString(wServerIP, 33, &packet);
PacketUtils::WritePacketString("", 33, &packet);
// Write the Character and Chat Ports
packet.Write(static_cast<uint16_t>(wServerPort));
packet.Write(static_cast<uint16_t>(0));
// Write another IP
PacketUtils::WritePacketString("", 33, &packet);
// Write a GUID or something...
PacketUtils::WritePacketString("00000000-0000-0000-0000-000000000000", 37, &packet);
packet.Write(static_cast<uint32_t>(0)); // ???
// Write the localization
PacketUtils::WritePacketString("US", 3, &packet);
packet.Write(static_cast<uint8_t>(false)); // User first logged in?
packet.Write(static_cast<uint8_t>(false)); // User is F2P?
packet.Write(static_cast<uint64_t>(0)); // ???
// Write custom error message
packet.Write(static_cast<uint16_t>(errorMsg.length()));
PacketUtils::WritePacketWString(errorMsg, static_cast<uint32_t>(errorMsg.length()), &packet);
// Here write auth logs
packet.Write(static_cast<uint32_t>(20));
for (uint32_t i = 0; i < 20; ++i) {
@ -254,7 +254,7 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
packet.Write(static_cast<uint32_t>(14000));
packet.Write(static_cast<uint32_t>(0));
}
server->Send(&packet, sysAddr, false);
//Inform the master server that we've created a session for this user:
@ -265,6 +265,6 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
PacketUtils::WriteString(bitStream, username, 66);
server->SendToMaster(&bitStream);
server->GetLogger()->Log("AuthPackets", "Set sessionKey: %i for user %s\n", sessionKey, username.c_str());
server->GetLogger()->Log("AuthPackets", "Set sessionKey: %i for user %s", sessionKey, username.c_str());
}
}

View File

@ -37,7 +37,7 @@
void ClientPackets::HandleChatMessage(const SystemAddress& sysAddr, Packet* packet) {
User* user = UserManager::Instance()->GetUser(sysAddr);
if (!user) {
Game::logger->Log("ClientPackets", "Unable to get user to parse chat message\n");
Game::logger->Log("ClientPackets", "Unable to get user to parse chat message");
return;
}
@ -71,14 +71,14 @@ void ClientPackets::HandleChatMessage(const SystemAddress& sysAddr, Packet* pack
if (!user->GetLastChatMessageApproved() && !isMythran) return;
std::string sMessage = GeneralUtils::UTF16ToWTF8(message);
Game::logger->Log("Chat", "%s: %s\n", playerName.c_str(), sMessage.c_str());
Game::logger->Log("Chat", "%s: %s", playerName.c_str(), sMessage.c_str());
ChatPackets::SendChatMessage(sysAddr, chatChannel, playerName, user->GetLoggedInChar(), isMythran, message);
}
void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Packet* packet) {
User* user = UserManager::Instance()->GetUser(sysAddr);
if (!user) {
Game::logger->Log("ClientPackets", "Unable to get user to parse position update\n");
Game::logger->Log("ClientPackets", "Unable to get user to parse position update");
return;
}
@ -240,14 +240,14 @@ void ClientPackets::HandleClientPositionUpdate(const SystemAddress& sysAddr, Pac
void ClientPackets::HandleChatModerationRequest(const SystemAddress& sysAddr, Packet* packet) {
User* user = UserManager::Instance()->GetUser(sysAddr);
if (!user) {
Game::logger->Log("ClientPackets", "Unable to get user to parse chat moderation request\n");
Game::logger->Log("ClientPackets", "Unable to get user to parse chat moderation request");
return;
}
auto* entity = Player::GetPlayer(sysAddr);
if (entity == nullptr) {
Game::logger->Log("ClientPackets", "Unable to get player to parse chat moderation request\n");
Game::logger->Log("ClientPackets", "Unable to get player to parse chat moderation request");
return;
}

View File

@ -18,7 +18,7 @@
void WorldPackets::SendLoadStaticZone(const SystemAddress& sysAddr, float x, float y, float z, uint32_t checksum) {
RakNet::BitStream bitStream;
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_LOAD_STATIC_ZONE);
auto zone = dZoneManager::Instance()->GetZone()->GetZoneID();
bitStream.Write(static_cast<uint16_t>(zone.GetMapID()));
bitStream.Write(static_cast<uint16_t>(zone.GetInstanceID()));
@ -33,7 +33,7 @@ void WorldPackets::SendLoadStaticZone(const SystemAddress& sysAddr, float x, flo
bitStream.Write(z);
bitStream.Write(static_cast<uint32_t>(0)); // Change this to eventually use 4 on activity worlds
SEND_PACKET
}
@ -42,23 +42,23 @@ void WorldPackets::SendCharacterList ( const SystemAddress& sysAddr, User* user
RakNet::BitStream bitStream;
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHARACTER_LIST_RESPONSE);
std::vector<Character*> characters = user->GetCharacters();
bitStream.Write(static_cast<uint8_t>(characters.size()));
bitStream.Write(static_cast<uint8_t>(0)); //character index in front, just picking 0
for (uint32_t i = 0; i < characters.size(); ++i) {
bitStream.Write(characters[i]->GetObjectID());
bitStream.Write(static_cast<uint32_t>(0));
PacketUtils::WriteWString(bitStream, characters[i]->GetName(), 33);
PacketUtils::WriteWString(bitStream, characters[i]->GetUnapprovedName(), 33);
bitStream.Write(static_cast<uint8_t>(characters[i]->GetNameRejected()));
bitStream.Write(static_cast<uint8_t>(false));
PacketUtils::WriteString(bitStream, "", 10);
bitStream.Write(characters[i]->GetShirtColor());
bitStream.Write(characters[i]->GetShirtStyle());
bitStream.Write(characters[i]->GetPantsColor());
@ -79,12 +79,12 @@ void WorldPackets::SendCharacterList ( const SystemAddress& sysAddr, User* user
const auto& equippedItems = characters[i]->GetEquippedItems();
bitStream.Write(static_cast<uint16_t>(equippedItems.size()));
for (uint32_t j = 0; j < equippedItems.size(); ++j) {
bitStream.Write(equippedItems[j]);
}
}
SEND_PACKET
}
@ -112,11 +112,11 @@ void WorldPackets::SendCharacterDeleteResponse(const SystemAddress& sysAddr, boo
void WorldPackets::SendTransferToWorld ( const SystemAddress& sysAddr, const std::string& serverIP, uint32_t serverPort, bool mythranShift ) {
RakNet::BitStream bitStream;
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_TRANSFER_TO_WORLD);
PacketUtils::WriteString(bitStream, serverIP, 33);
bitStream.Write(static_cast<uint16_t>(serverPort));
bitStream.Write(static_cast<uint8_t>(mythranShift));
SEND_PACKET
}
@ -130,7 +130,7 @@ void WorldPackets::SendServerState ( const SystemAddress& sysAddr ) {
void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* entity, const std::string& xmlData, const std::u16string& username, int32_t gm) {
RakNet::BitStream bitStream;
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CREATE_CHARACTER);
RakNet::BitStream data;
data.Write<uint32_t>(7); //LDF key count
@ -155,7 +155,7 @@ void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* ent
chatmode->WriteToPacket(&data);
xmlConfigData->WriteToPacket(&data);
reputation->WriteToPacket(&data);
delete objid;
delete lot;
delete xmlConfigData;
@ -168,7 +168,7 @@ void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* ent
bitStream.Write<uint32_t>(data.GetNumberOfBytesUsed() + 1);
bitStream.Write<uint8_t>(0);
bitStream.Write((char*)data.GetData(), data.GetNumberOfBytesUsed());
#else
#else
//Compress the data before sending:
const int reservedSize = 5 * 1024 * 1024;
uint8_t compressedData[reservedSize];
@ -185,7 +185,7 @@ void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* ent
PacketUtils::SavePacket("chardata.bin", (const char *)bitStream.GetData(), static_cast<uint32_t>(bitStream.GetNumberOfBytesUsed()));
SEND_PACKET
Game::logger->Log("WorldPackets", "Sent CreateCharacter for ID: %llu\n", entity->GetObjectID());
Game::logger->Log("WorldPackets", "Sent CreateCharacter for ID: %llu", entity->GetObjectID());
}
void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::vector<std::pair<uint8_t, uint8_t>> unacceptedItems) {
@ -215,11 +215,11 @@ void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool
void WorldPackets::SendGMLevelChange(const SystemAddress& sysAddr, bool success, uint8_t highestLevel, uint8_t prevLevel, uint8_t newLevel) {
CBITSTREAM
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAKE_GM_RESPONSE);
bitStream.Write<uint8_t>(success);
bitStream.Write<uint16_t>(highestLevel);
bitStream.Write<uint16_t>(prevLevel);
bitStream.Write<uint16_t>(newLevel);
SEND_PACKET
}

View File

@ -13,7 +13,7 @@
//! Replica Constructor class
class ReplicaConstructor : public ReceiveConstructionInterface {
public:
public:
ReplicaReturnResult ReceiveConstruction(RakNet::BitStream *inBitStream, RakNetTime timestamp, NetworkID networkID, NetworkIDObject *existingObject, SystemAddress senderId, ReplicaManager *caller) {
return REPLICA_PROCESSING_DONE;
}
@ -60,11 +60,11 @@ dServer::dServer(const std::string& ip, int port, int instanceID, int maxConnect
if (mIsOkay) {
if (zoneID == 0)
mLogger->Log("dServer", "Server is listening on %s:%i with encryption: %i\n", ip.c_str(), port, int(useEncryption));
mLogger->Log("dServer", "Server is listening on %s:%i with encryption: %i", ip.c_str(), port, int(useEncryption));
else
mLogger->Log("dServer", "Server is listening on %s:%i with encryption: %i, running zone %i / %i\n", ip.c_str(), port, int(useEncryption), zoneID, instanceID);
mLogger->Log("dServer", "Server is listening on %s:%i with encryption: %i, running zone %i / %i", ip.c_str(), port, int(useEncryption), zoneID, instanceID);
}
else { mLogger->Log("dServer", "FAILED TO START SERVER ON IP/PORT: %s:%i\n", ip.c_str(), port); return; }
else { mLogger->Log("dServer", "FAILED TO START SERVER ON IP/PORT: %s:%i", ip.c_str(), port); return; }
mLogger->SetLogToConsole(prevLogSetting);
@ -104,13 +104,13 @@ Packet* dServer::ReceiveFromMaster() {
if (packet->length < 1) { mMasterPeer->DeallocatePacket(packet); return nullptr; }
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {
mLogger->Log("dServer", "Lost our connection to master, shutting DOWN!\n");
mLogger->Log("dServer", "Lost our connection to master, shutting DOWN!");
mMasterConnectionActive = false;
//ConnectToMaster(); //We'll just shut down now
}
if (packet->data[0] == ID_CONNECTION_REQUEST_ACCEPTED) {
mLogger->Log("dServer", "Established connection to master, zone (%i), instance (%i)\n",this->GetZoneID(), this->GetInstanceID());
mLogger->Log("dServer", "Established connection to master, zone (%i), instance (%i)",this->GetZoneID(), this->GetInstanceID());
mMasterConnectionActive = true;
mMasterSystemAddress = packet->systemAddress;
MasterPackets::SendServerInfo(this, packet);

View File

@ -13,7 +13,7 @@ void dpWorld::Initialize(unsigned int zoneID) {
phys_sp_tilecount = std::atoi(Game::config->GetValue("phys_sp_tilecount").c_str());
phys_sp_tilesize = std::atoi(Game::config->GetValue("phys_sp_tilesize").c_str());
//If spatial partitioning is enabled, then we need to create the m_Grid.
//If spatial partitioning is enabled, then we need to create the m_Grid.
//if m_Grid exists, then the old method will be used.
//SP will NOT be used unless it is added to ShouldUseSP();
if (std::atoi(Game::config->GetValue("phys_spatial_partitioning").c_str()) == 1
@ -21,11 +21,11 @@ void dpWorld::Initialize(unsigned int zoneID) {
m_Grid = new dpGrid(phys_sp_tilecount, phys_sp_tilesize);
}
Game::logger->Log("dpWorld", "Physics world initialized!\n");
Game::logger->Log("dpWorld", "Physics world initialized!");
if (ShouldLoadNavmesh(zoneID)) {
if (LoadNavmeshByZoneID(zoneID)) Game::logger->Log("dpWorld", "Loaded navmesh!\n");
else Game::logger->Log("dpWorld", "Error(s) occurred during navmesh load.\n");
if (LoadNavmeshByZoneID(zoneID)) Game::logger->Log("dpWorld", "Loaded navmesh!");
else Game::logger->Log("dpWorld", "Error(s) occurred during navmesh load.");
}
}
@ -39,9 +39,9 @@ dpWorld::~dpWorld() {
}
void dpWorld::StepWorld(float deltaTime) {
if (m_Grid) {
m_Grid->Update(deltaTime);
return;
if (m_Grid) {
m_Grid->Update(deltaTime);
return;
}
//Pre update:
@ -53,7 +53,7 @@ void dpWorld::StepWorld(float deltaTime) {
//Do actual update:
for (auto entity : m_DynamicEntites) {
if (!entity || entity->GetSleeping()) continue;
entity->Update(deltaTime);
for (auto other : m_StaticEntities) {
@ -135,7 +135,7 @@ bool dpWorld::LoadNavmeshByZoneID(unsigned int zoneID) {
dtNavMesh* dpWorld::LoadNavmesh(const char* path) {
FILE* fp;
#ifdef _WIN32
fopen_s(&fp, path, "rb");
#elif __APPLE__
@ -144,7 +144,7 @@ dtNavMesh* dpWorld::LoadNavmesh(const char* path) {
#else
fp = fopen64(path, "rb");
#endif
if (!fp) {
return 0;
}
@ -272,7 +272,7 @@ std::vector<NiPoint3> dpWorld::GetPath(const NiPoint3& startPos, const NiPoint3&
//how many points to generate between start/end?
//note: not actually 100% accurate due to rounding, but worst case it causes them to go a tiny bit faster
//than their speed value would normally allow at the end.
int numPoints = startPos.Distance(startPos, endPos) / speed;
int numPoints = startPos.Distance(startPos, endPos) / speed;
path.push_back(startPos); //insert the start pos

View File

@ -51,7 +51,7 @@ float_t ActivityManager::GetActivityValue(Entity *self, const LWOOBJID playerID,
void ActivityManager::StopActivity(Entity *self, const LWOOBJID playerID, const uint32_t score,
const uint32_t value1, const uint32_t value2, bool quit) {
int32_t gameID = 0;
auto* sac = self->GetComponent<ScriptedActivityComponent>();
if (sac == nullptr) {
gameID = self->GetLOT();
@ -125,7 +125,7 @@ void ActivityManager::ActivityTimerStart(Entity *self, const std::string& timerN
auto* timer = new ActivityTimer { timerName, updateInterval, stopTime };
activeTimers.push_back(timer);
Game::logger->Log("ActivityManager", "Starting timer '%s', %f, %f\n", timerName.c_str(), updateInterval, stopTime);
Game::logger->Log("ActivityManager", "Starting timer '%s', %f, %f", timerName.c_str(), updateInterval, stopTime);
self->AddTimer(GetPrefixedName(timer->name), timer->updateInterval);
}
@ -147,7 +147,7 @@ float_t ActivityManager::ActivityTimerGetCurrentTime(Entity *self, const std::st
int32_t ActivityManager::GetGameID(Entity *self) const
{
int32_t gameID = 0;
auto* sac = self->GetComponent<ScriptedActivityComponent>();
if (sac == nullptr) {
gameID = self->GetLOT();
@ -208,10 +208,10 @@ void ActivityManager::OnTimerDone(Entity *self, std::string timerName) {
activeTimers.erase(std::remove(activeTimers.begin(), activeTimers.end(), timer),
activeTimers.end());
delete timer;
Game::logger->Log("ActivityManager", "Executing timer '%s'\n", activityTimerName.c_str());
Game::logger->Log("ActivityManager", "Executing timer '%s'", activityTimerName.c_str());
OnActivityTimerDone(self, activityTimerName);
} else {
Game::logger->Log("ActivityManager", "Updating timer '%s'\n", activityTimerName.c_str());
Game::logger->Log("ActivityManager", "Updating timer '%s'", activityTimerName.c_str());
OnActivityTimerUpdate(self, timer->name, timer->stopTime - timer->runTime, timer->runTime);
self->AddTimer(GetPrefixedName(timer->name), timer->updateInterval);
}

View File

@ -49,20 +49,20 @@ void AgJetEffectServer::OnRebuildComplete(Entity* self, Entity* target)
auto* effect = entities[0];
auto groups = self->GetGroups();
if (groups.empty())
{
return;
}
builder = target->GetObjectID();
const auto group = groups[0];
GameMessages::SendPlayAnimation(effect, u"jetFX");
self->AddTimer("PlayEffect", 2.5f);
if (group == "Base_Radar")
{
self->AddTimer("CineDone", 5);
@ -88,7 +88,7 @@ void AgJetEffectServer::OnTimerDone(Entity* self, std::string timerName)
}
const auto size = entities.size();
if (size == 0)
{
return;
@ -98,7 +98,7 @@ void AgJetEffectServer::OnTimerDone(Entity* self, std::string timerName)
auto* mortar = entities[selected];
Game::logger->Log("AgJetEffectServer", "Mortar (%i) (&d)\n", mortar->GetLOT(), mortar->HasComponent(COMPONENT_TYPE_SKILL));
Game::logger->Log("AgJetEffectServer", "Mortar (%i) (&d)", mortar->GetLOT(), mortar->HasComponent(COMPONENT_TYPE_SKILL));
mortar->SetOwnerOverride(builder);

View File

@ -4,7 +4,7 @@
#include "dLogger.h"
#include "Entity.h"
void BaseRandomServer::BaseStartup(Entity* self)
void BaseRandomServer::BaseStartup(Entity* self)
{
self->SetVar<std::string>(u"SpawnState", "min");
self->SetVar<bool>(u"JustChanged", false);
@ -13,12 +13,12 @@ void BaseRandomServer::BaseStartup(Entity* self)
SpawnMapZones(self);
}
void BaseRandomServer::CheckEvents(Entity* self)
void BaseRandomServer::CheckEvents(Entity* self)
{
// TODO: Add events?
}
void BaseRandomServer::SpawnMapZones(Entity* self)
void BaseRandomServer::SpawnMapZones(Entity* self)
{
for (const auto& pair : sectionMultipliers)
{
@ -35,13 +35,13 @@ void BaseRandomServer::SpawnMapZones(Entity* self)
self->SetVar(u"bInit", true);
}
void BaseRandomServer::SpawnSection(Entity* self, const std::string& sectionName, float iMultiplier)
void BaseRandomServer::SpawnSection(Entity* self, const std::string& sectionName, float iMultiplier)
{
Zone* spawnLoad = GetRandomLoad(self, sectionName);
if (spawnLoad == nullptr)
{
Game::logger->Log("BaseRandomServer", "Failed to find section: %s\n", sectionName.c_str());
Game::logger->Log("BaseRandomServer", "Failed to find section: %s", sectionName.c_str());
return;
}
@ -60,7 +60,7 @@ void BaseRandomServer::SpawnSection(Entity* self, const std::string& sectionName
}
}
void BaseRandomServer::SetSpawnerNetwork(Entity* self, const std::string& spawnerName, int32_t spawnNum, LOT spawnLOT)
void BaseRandomServer::SetSpawnerNetwork(Entity* self, const std::string& spawnerName, int32_t spawnNum, LOT spawnLOT)
{
const auto& spawners = dZoneManager::Instance()->GetSpawnersByName(spawnerName);
@ -71,7 +71,7 @@ void BaseRandomServer::SetSpawnerNetwork(Entity* self, const std::string& spawne
if (spawners.empty())
{
Game::logger->Log("BaseRandomServer", "Failed to find spawner: %s\n", spawnerName.c_str());
Game::logger->Log("BaseRandomServer", "Failed to find spawner: %s", spawnerName.c_str());
return;
}
@ -108,7 +108,7 @@ void BaseRandomServer::SetSpawnerNetwork(Entity* self, const std::string& spawne
spawnersWatched.push_back(spawner);
}
BaseRandomServer::Zone* BaseRandomServer::GetRandomLoad(Entity* self, const std::string& sectionName)
BaseRandomServer::Zone* BaseRandomServer::GetRandomLoad(Entity* self, const std::string& sectionName)
{
const auto zoneInfo = GeneralUtils::SplitString(sectionName, '_');
@ -135,7 +135,7 @@ BaseRandomServer::Zone* BaseRandomServer::GetRandomLoad(Entity* self, const std:
return nullptr;
}
void BaseRandomServer::NotifySpawnerOfDeath(Entity* self, Spawner* spawner)
void BaseRandomServer::NotifySpawnerOfDeath(Entity* self, Spawner* spawner)
{
const auto& spawnerName = spawner->GetName();
@ -164,29 +164,29 @@ void BaseRandomServer::NotifySpawnerOfDeath(Entity* self, Spawner* spawner)
self->SetVar(variableName, mobDeathCount);
}
void BaseRandomServer::NamedEnemyDeath(Entity* self, Spawner* spawner)
void BaseRandomServer::NamedEnemyDeath(Entity* self, Spawner* spawner)
{
const auto spawnDelay = GeneralUtils::GenerateRandomNumber<float>(1, 2) * 450;
self->AddTimer("SpawnNewEnemy", spawnDelay);
}
void BaseRandomServer::SpawnersUp(Entity* self)
void BaseRandomServer::SpawnersUp(Entity* self)
{
}
void BaseRandomServer::SpawnersDown(Entity* self)
void BaseRandomServer::SpawnersDown(Entity* self)
{
}
void BaseRandomServer::BaseOnTimerDone(Entity* self, const std::string& timerName)
void BaseRandomServer::BaseOnTimerDone(Entity* self, const std::string& timerName)
{
NamedTimerDone(self, timerName);
}
void BaseRandomServer::SpawnNamedEnemy(Entity* self)
void BaseRandomServer::SpawnNamedEnemy(Entity* self)
{
const auto enemy = namedMobs[GeneralUtils::GenerateRandomNumber<int32_t>(0, namedMobs.size() - 1)];

View File

@ -22,7 +22,7 @@
void BossSpiderQueenEnemyServer::OnStartup(Entity* self) {
// Make immune to stuns
//self:SetStunImmunity{ StateChangeType = "PUSH", bImmuneToStunAttack = true, bImmuneToStunMove = true, bImmuneToStunTurn = true, bImmuneToStunUseItem = true, bImmuneToStunEquip = true, bImmuneToStunInteract = true, bImmuneToStunJump = true }
// Make immune to knockbacks and pulls
//self:SetStatusImmunity{ StateChangeType = "PUSH", bImmuneToPullToPoint = true, bImmuneToKnockback = true, bImmuneToInterrupt = true }
@ -60,7 +60,7 @@ void BossSpiderQueenEnemyServer::OnDie(Entity* self, Entity* killer) {
missionComponent->CompleteMission(instanceMissionID);
}
Game::logger->Log("BossSpiderQueenEnemyServer", "Starting timer...\n");
Game::logger->Log("BossSpiderQueenEnemyServer", "Starting timer...");
// There is suppose to be a 0.1 second delay here but that may be admitted?
auto* controller = EntityManager::Instance()->GetZoneControlEntity();
@ -88,15 +88,15 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra
//First rotate for anim
NiQuaternion rot = NiQuaternion::IDENTITY;
controllable->SetStatic(false);
controllable->SetRotation(rot);
controllable->SetStatic(true);
controllable->SetDirtyPosition(true);
rot = controllable->GetRotation();
EntityManager::Instance()->SerializeEntity(self);
@ -122,10 +122,10 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra
}
else {
controllable->SetStatic(false);
//Cancel all remaining timers for say idle anims:
self->CancelAllTimers();
auto* baseCombatAi = self->GetComponent<BaseCombatAIComponent>();
baseCombatAi->SetDisabled(false);
@ -133,7 +133,7 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra
// Move the Spider to its ground location
// preparing its stage attacks, and removing invulnerability
//destroyable->SetIsImmune(false);
// Run the advance animation and prepare a timer for resuming AI
float animTime = PlayAnimAndReturnTime(self, spiderAdvanceAnim);
animTime += 1.f;
@ -142,19 +142,19 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra
destroyable->SetFaction(4);
destroyable->SetIsImmune(false);
//Advance stage
m_CurrentBossStage++;
//Reset the current wave death counter
m_DeathCounter = 0;
EntityManager::Instance()->SerializeEntity(self);
// Prepare a timer for post leap attack
self->AddTimer("AdvanceAttack", attackPause);
// Prepare a timer for post leap
// Prepare a timer for post leap
self->AddTimer("AdvanceComplete", animTime);
}
@ -162,7 +162,7 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra
}
void BossSpiderQueenEnemyServer::SpawnSpiderWave(Entity* self, int spiderCount) {
// The Spider Queen Boss is withdrawing and requesting the spawn
// The Spider Queen Boss is withdrawing and requesting the spawn
// of a hatchling wave
/*auto SpiderEggNetworkID = self->GetI64(u"SpiderEggNetworkID");
@ -176,7 +176,7 @@ void BossSpiderQueenEnemyServer::SpawnSpiderWave(Entity* self, int spiderCount)
hatchCounter = spiderCount;
hatchList = {};
Game::logger->Log("SpiderQueen", "Trying to spawn %i spiders\n", hatchCounter);
Game::logger->Log("SpiderQueen", "Trying to spawn %i spiders", hatchCounter);
// Run the wave manager
@ -189,19 +189,19 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
// Reset the spider egg spawner network to ensure a maximum number of eggs
//SpiderEggNetworkID:SpawnerReset()
// Obtain a list of all the eggs on the egg spawner network
//auto spiderEggList = SpiderEggNetworkID:SpawnerGetAllObjectIDsSpawned().objects;
//if (table.maxn(spiderEggList) <= 0) {
//if (table.maxn(spiderEggList) <= 0) {
// self->AddTimer("PollSpiderWaveManager", 1.0f);
// return;
//}
//
//// A check for (wave mangement across multiple spawn iterations
//if(hatchCounter < spiderWaveCnt) {
// // We have already prepped some objects for (hatching,
// // We have already prepped some objects for (hatching,
// // remove them from our list for (random egg pulls
// for (i, sVal in ipairs(spiderEggList) {
// if(hatchList[sVal:GetID()]) {
@ -220,8 +220,8 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
for (auto spodder : spooders) {
spiderEggs.push_back(spodder->GetObjectID());
}
// Select a number of random spider eggs from the list equal to the
// Select a number of random spider eggs from the list equal to the
// current number needed to complete the current wave
for (int i = 0; i < hatchCounter; i++) {
// Select a random spider egg
@ -235,7 +235,7 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
randomEgg = spiderEggs[randomEggLoc];
}
}
if (randomEgg) {
auto* eggEntity = EntityManager::Instance()->GetEntity(randomEgg);
@ -246,24 +246,24 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
// Prep the selected spider egg
//randomEgg:FireEvent{s}erID=self, args="prepEgg"}
eggEntity->OnFireEventServerSide(self, "prepEgg");
Game::logger->Log("SpiderQueen", "Prepping egg %llu\n", eggEntity->GetObjectID());
Game::logger->Log("SpiderQueen", "Prepping egg %llu", eggEntity->GetObjectID());
// Add the prepped egg to our hatchList
hatchList.push_back(eggEntity->GetObjectID());
// Decrement the hatchCounter
hatchCounter = hatchCounter - 1;
}
// Remove it from our spider egg list
//table.remove(spiderEggList, randomEggLoc);
spiderEggs[randomEggLoc] = LWOOBJID_EMPTY;
if (spiderEggs.size() <= 0 || (hatchCounter <= 0)) {
if (spiderEggs.size() <= 0 || (hatchCounter <= 0)) {
break;
}
}
if (hatchCounter > 0) {
// We still have more eggs to hatch, poll the SpiderWaveManager again
self->AddTimer("PollSpiderWaveManager", 1.0f);
@ -280,20 +280,20 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
}
eggEntity->OnFireEventServerSide(self, "hatchEgg");
Game::logger->Log("SpiderQueen", "hatching egg %llu\n", eggEntity->GetObjectID());
Game::logger->Log("SpiderQueen", "hatching egg %llu", eggEntity->GetObjectID());
auto time = PlayAnimAndReturnTime(self, spiderWithdrawIdle);
combat->SetStunImmune(false);
combat->Stun(time += 6.0f);
combat->SetStunImmune(true);
//self->AddTimer("disableWaitForIdle", defaultAnimPause);
self->AddTimer("checkForSpiders", 6.0f);
}
hatchList.clear();
}
}
@ -322,7 +322,7 @@ void BossSpiderQueenEnemyServer::RunRainOfFire(Entity* self)
for (const auto& rofGroup : ROFTargetGroupIDTable)
{
const auto spawners = dZoneManager::Instance()->GetSpawnersInGroup(rofGroup);
std::vector<LWOOBJID> spawned;
for (auto* spawner : spawners)
@ -352,7 +352,7 @@ void BossSpiderQueenEnemyServer::RunRainOfFire(Entity* self)
self->AddTimer("StartROF", animTime);
}
void BossSpiderQueenEnemyServer::RainOfFireManager(Entity* self)
void BossSpiderQueenEnemyServer::RainOfFireManager(Entity* self)
{
if (!impactList.empty())
{
@ -362,7 +362,7 @@ void BossSpiderQueenEnemyServer::RainOfFireManager(Entity* self)
if (entity == nullptr)
{
Game::logger->Log("BossSpiderQueenEnemyServer", "Failed to find impact!\n");
Game::logger->Log("BossSpiderQueenEnemyServer", "Failed to find impact!");
return;
}
@ -371,8 +371,8 @@ void BossSpiderQueenEnemyServer::RainOfFireManager(Entity* self)
if (skillComponent == nullptr)
{
Game::logger->Log("BossSpiderQueenEnemyServer", "Failed to find impact skill component!\n");
Game::logger->Log("BossSpiderQueenEnemyServer", "Failed to find impact skill component!");
return;
}
@ -384,7 +384,7 @@ void BossSpiderQueenEnemyServer::RainOfFireManager(Entity* self)
}
ToggleForSpecial(self, false);
self->AddTimer("ROF", GeneralUtils::GenerateRandomNumber<float>(20, 40));
}
@ -402,7 +402,7 @@ void BossSpiderQueenEnemyServer::RapidFireShooterManager(Entity* self)
}
const auto target = attackTargetTable[0];
auto* skillComponent = self->GetComponent<SkillComponent>();
skillComponent->CalculateBehavior(1394, 32612, target, true);
@ -412,7 +412,7 @@ void BossSpiderQueenEnemyServer::RapidFireShooterManager(Entity* self)
self->AddTimer("PollRFSManager", 0.3f);
}
void BossSpiderQueenEnemyServer::RunRapidFireShooter(Entity* self)
void BossSpiderQueenEnemyServer::RunRapidFireShooter(Entity* self)
{
/*
const auto targets = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_CHARACTER);
@ -429,7 +429,7 @@ void BossSpiderQueenEnemyServer::RunRapidFireShooter(Entity* self)
if (targets.empty())
{
Game::logger->Log("BossSpiderQueenEnemyServer", "Failed to find RFS targets\n");
Game::logger->Log("BossSpiderQueenEnemyServer", "Failed to find RFS targets");
self->AddTimer("RFS", GeneralUtils::GenerateRandomNumber<float>(5, 10));
@ -452,7 +452,7 @@ void BossSpiderQueenEnemyServer::RunRapidFireShooter(Entity* self)
PlayAnimAndReturnTime(self, spiderSingleShot);
Game::logger->Log("BossSpiderQueenEnemyServer", "Ran RFS\n");
Game::logger->Log("BossSpiderQueenEnemyServer", "Ran RFS");
self->AddTimer("RFS", GeneralUtils::GenerateRandomNumber<float>(10, 15));
}
@ -487,7 +487,7 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
//If there are still baby spiders, don't do anyhting either
const auto spiders = EntityManager::Instance()->GetEntitiesInGroup("BabySpider");
if (spiders.size() > 0)
if (spiders.size() > 0)
self->AddTimer("checkForSpiders", time);
else
WithdrawSpider(self, false);
@ -496,30 +496,30 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
//Call the manager again to attempt to initiate an impact on another random location
//Run the ROF Manager
RainOfFireManager(self);
} else if ( timerName == "PollRFSManager") {
//Call the manager again to attempt to initiate a rapid fire shot at the next sequential target
//Run the ROF Manager
RapidFireShooterManager(self);
} else if ( timerName == "StartROF") {
//Re-enable Spider Boss
//ToggleForSpecial(self, false);
RainOfFireManager(self);
} else if ( timerName == "PollSpiderSkillManager") {
//Call the skill manager again to attempt to run the current Spider Boss
//stage's special attack again
//SpiderSkillManager(self, true);
PlayAnimAndReturnTime(self, spiderJeerAnim);
} else if ( timerName == "RFS") {
RunRapidFireShooter(self);
} else if ( timerName == "ROF") {
RunRainOfFire(self);
} else if ( timerName == "RFSTauntComplete") {
//Determine an appropriate random time to check our manager again
} else if ( timerName == "RFSTauntComplete") {
//Determine an appropriate random time to check our manager again
// local spiderCooldownDelay = math.random(s1DelayMin, s1DelayMax)
//Set a timer based on our random cooldown determination
@ -529,7 +529,7 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
//Re-enable Spider Boss
//ToggleForSpecial(self, false);
} else if ( timerName == "WithdrawComplete") {
//Play the Spider Boss' mountain idle anim
PlayAnimAndReturnTime(self, spiderWithdrawIdle);
@ -545,19 +545,19 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
if (currentStage > 1) hatchCounter++;
SpawnSpiderWave(self, spiderWaveCntTable[currentStage - 1]);
} else if ( timerName == "AdvanceAttack") {
} else if ( timerName == "AdvanceAttack") {
//TODO: Can we even do knockbacks yet? @Wincent01
// Yes ^
//Fire the melee smash skill to throw players back
/*local landingTarget = self:GetVar("LandingTarget") or false
if((landingTarget) and (landingTarget:Exists())) {
local advSmashFlag = landingTarget:CastSkill{skillID = bossLandingSkill}
landingTarget:PlayEmbeddedEffectOnAllClientsNearObject{radius = 100, fromObjectID = landingTarget, effectName = "camshake-bridge"}
}*/
auto landingTarget = self->GetI64(u"LandingTarget");
auto landingEntity = EntityManager::Instance()->GetEntity(landingTarget);
@ -567,7 +567,7 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
{
skillComponent->CalculateBehavior(bossLandingSkill, 37739, LWOOBJID_EMPTY);
}
if (landingEntity) {
auto* landingSkill = landingEntity->GetComponent<SkillComponent>();
@ -578,12 +578,12 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
}
GameMessages::SendPlayEmbeddedEffectOnAllClientsNearObject(self, u"camshake-bridge", self->GetObjectID(), 100.0f);
} else if ( timerName == "AdvanceComplete") {
} else if ( timerName == "AdvanceComplete") {
//Reset faction and collision
/*local SBFactionList = self:GetVar("SBFactionList")
local SBCollisionGroup = self:GetVar("SBCollisionGroup")
for i, fVal in ipairs(SBFactionList) {
if(i == 1) {
//Our first faction - flush and add
@ -596,18 +596,18 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
/*
auto SBCollisionGroup = self->GetI32(u"SBCollisionGroup");
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SetColGroup", SBCollisionGroup, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS);
*/
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SetColGroup", 11, 0, 0, "", UNASSIGNED_SYSTEM_ADDRESS);
//Wind up, telegraphing next round
float animTime = PlayAnimAndReturnTime(self, spiderJeerAnim);
self->AddTimer("AdvanceTauntComplete", animTime);
} else if ( timerName == "AdvanceTauntComplete") {
//Declare a default special Spider Boss skill cooldown
int spiderCooldownDelay = 10;
@ -620,11 +620,11 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
//Set a timer based on our random cooldown determination
//to pulse the SpiderSkillManager
self->AddTimer("PollSpiderSkillManager", spiderCooldownDelay);
//Remove current status immunity
/*self:SetStatusImmunity{ StateChangeType = "POP", bImmuneToSpeed = true, bImmuneToBasicAttack = true, bImmuneToDOT = true}
self:SetStunned{StateChangeType = "POP",
self:SetStunned{StateChangeType = "POP",
bCantMove = true,
bCantJump = true,
bCantTurn = true,
@ -638,14 +638,14 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
destroyable->SetFaction(4);
EntityManager::Instance()->SerializeEntity(self);
} else if ( timerName == "Clear") {
EntityManager::Instance()->FireEventServerSide(self, "ClearProperty");
self->CancelAllTimers();
} else if ( timerName == "UnlockSpecials") {
//We no longer need to lock specials
self->SetBoolean(u"bSpecialLock", false);
//Did we queue a spcial attack?
if(self->GetBoolean(u"bSpecialQueued")) {
self->SetBoolean(u"bSpecialQueued", false);
@ -723,17 +723,17 @@ float BossSpiderQueenEnemyServer::PlayAnimAndReturnTime(Entity* self, const std:
//TODO: Get the actual animation time
// Get the anim time
float animTimer = defaultAnimPause; //self:GetAnimationTime{animationID = animID}.time
float animTimer = defaultAnimPause; //self:GetAnimationTime{animationID = animID}.time
// If we have an animation play it
if (animTimer > 0) {
GameMessages::SendPlayAnimation(self, animID);
}
// If the anim time is less than the the default time use default
if (animTimer < defaultAnimPause) {
animTimer = defaultAnimPause;
}
return animTimer;
}

View File

@ -818,7 +818,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
script = invalidToReturn;
else if (script == invalidToReturn) {
if (scriptName.length() > 0)
Game::logger->LogDebug("CppScripts", "Attempted to load CppScript for '" + scriptName + "', but returned InvalidScript.\n");
Game::logger->LogDebug("CppScripts", "Attempted to load CppScript for '" + scriptName + "', but returned InvalidScript.");
// information not really needed for sys admins but is for developers
script = invalidToReturn;

View File

@ -2,7 +2,7 @@
#include "SkillComponent.h"
#include "GameMessages.h"
void FlameJetServer::OnStartup(Entity* self)
void FlameJetServer::OnStartup(Entity* self)
{
if (self->GetVar<bool>(u"NotActive"))
{
@ -12,7 +12,7 @@ void FlameJetServer::OnStartup(Entity* self)
self->SetNetworkVar<bool>(u"FlameOn", true);
}
void FlameJetServer::OnCollisionPhantom(Entity* self, Entity* target)
void FlameJetServer::OnCollisionPhantom(Entity* self, Entity* target)
{
if (!target->IsPlayer())
{
@ -42,9 +42,9 @@ void FlameJetServer::OnCollisionPhantom(Entity* self, Entity* target)
GameMessages::SendKnockback(target->GetObjectID(), self->GetObjectID(), self->GetObjectID(), 1000, dir);
}
void FlameJetServer::OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, int32_t param3)
void FlameJetServer::OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, int32_t param3)
{
Game::logger->Log("FlameJetServer::OnFireEventServerSide", "Event: %s\n", args.c_str());
Game::logger->Log("FlameJetServer::OnFireEventServerSide", "Event: %s", args.c_str());
if (args == "OnActivated")
{

View File

@ -4,7 +4,7 @@
#include "BaseCombatAIComponent.h"
#include "DestroyableComponent.h"
void FvMaelstromDragon::OnStartup(Entity* self)
void FvMaelstromDragon::OnStartup(Entity* self)
{
self->SetVar<int32_t>(u"weakspot", 0);
@ -16,7 +16,7 @@ void FvMaelstromDragon::OnStartup(Entity* self)
}
}
void FvMaelstromDragon::OnDie(Entity* self, Entity* killer)
void FvMaelstromDragon::OnDie(Entity* self, Entity* killer)
{
if (self->GetVar<bool>(u"bDied"))
{
@ -68,7 +68,7 @@ void FvMaelstromDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_
if (destroyableComponent != nullptr)
{
Game::logger->Log("FvMaelstromDragon", "Hit %i\n", destroyableComponent->GetArmor());
Game::logger->Log("FvMaelstromDragon", "Hit %i", destroyableComponent->GetArmor());
if (destroyableComponent->GetArmor() > 0) return;
@ -76,7 +76,7 @@ void FvMaelstromDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_
if (weakpoint == 0)
{
Game::logger->Log("FvMaelstromDragon", "Activating weakpoint\n");
Game::logger->Log("FvMaelstromDragon", "Activating weakpoint");
self->AddTimer("ReviveTimer", 12);
@ -141,7 +141,7 @@ void FvMaelstromDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_
}
}
void FvMaelstromDragon::OnTimerDone(Entity* self, std::string timerName)
void FvMaelstromDragon::OnTimerDone(Entity* self, std::string timerName)
{
if (timerName == "ReviveHeldTimer")
{
@ -187,7 +187,7 @@ FvMaelstromDragon::OnFireEventServerSide(Entity *self, Entity *sender, std::stri
int32_t param3)
{
if (args != "rebuildDone") return;
self->AddTimer("ExposeWeakSpotTimer", 3.8f);
self->CancelTimer("ReviveTimer");

View File

@ -92,7 +92,7 @@ void NjMonastryBossInstance::OnPlayerExit(Entity *self, Entity *player) {
UpdatePlayer(self, player->GetObjectID(), true);
// Fetch the total players loaded from the vars
auto totalPlayersLoaded = self->GetVar<std::vector<LWOOBJID> >(TotalPlayersLoadedVariable);
// Find the player to remove
auto playerToRemove = std::find(totalPlayersLoaded.begin(), totalPlayersLoaded.end(), player->GetObjectID());
@ -100,7 +100,7 @@ void NjMonastryBossInstance::OnPlayerExit(Entity *self, Entity *player) {
if (playerToRemove != totalPlayersLoaded.end()) {
totalPlayersLoaded.erase(playerToRemove);
} else {
Game::logger->Log("NjMonastryBossInstance", "Failed to remove player at exit.\n");
Game::logger->Log("NjMonastryBossInstance", "Failed to remove player at exit.");
}
// Set the players loaded var back

View File

@ -13,7 +13,7 @@
#include "MissionComponent.h"
void SGCannon::OnStartup(Entity *self) {
Game::logger->Log("SGCannon", "OnStartup\n");
Game::logger->Log("SGCannon", "OnStartup");
m_Waves = GetWaves();
constants = GetConstants();
@ -59,7 +59,7 @@ void SGCannon::OnStartup(Entity *self) {
}
void SGCannon::OnPlayerLoaded(Entity *self, Entity *player) {
Game::logger->Log("SGCannon", "Player loaded\n");
Game::logger->Log("SGCannon", "Player loaded");
self->SetVar<LWOOBJID>(PlayerIDVariable, player->GetObjectID());
}
@ -70,15 +70,15 @@ void SGCannon::OnFireEventServerSide(Entity *self, Entity *sender, std::string a
void SGCannon::OnActivityStateChangeRequest(Entity *self, LWOOBJID senderID, int32_t value1, int32_t value2,
const std::u16string &stringValue) {
Game::logger->Log("SGCannon", "Got activity state change request: %s\n", GeneralUtils::UTF16ToWTF8(stringValue).c_str());
Game::logger->Log("SGCannon", "Got activity state change request: %s", GeneralUtils::UTF16ToWTF8(stringValue).c_str());
if (stringValue == u"clientready") {
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player != nullptr) {
Game::logger->Log("SGCannon", "Player is ready\n");
Game::logger->Log("SGCannon", "Player is ready");
/*GameMessages::SendSetStunned(player->GetObjectID(), PUSH, player->GetSystemAddress(), LWOOBJID_EMPTY,
true, true, true, true, true, true, true);*/
Game::logger->Log("SGCannon", "Sending ActivityEnter\n");
Game::logger->Log("SGCannon", "Sending ActivityEnter");
GameMessages::SendActivityEnter(self->GetObjectID(), player->GetSystemAddress());
@ -87,14 +87,14 @@ void SGCannon::OnActivityStateChangeRequest(Entity *self, LWOOBJID senderID, int
if (shootingGalleryComponent != nullptr) {
shootingGalleryComponent->SetCurrentPlayerID(player->GetObjectID());
Game::logger->Log("SGCannon", "Setting player ID\n");
Game::logger->Log("SGCannon", "Setting player ID");
EntityManager::Instance()->SerializeEntity(self);
}
else {
Game::logger->Log("SGCannon", "Shooting gallery component is null\n");
Game::logger->Log("SGCannon", "Shooting gallery component is null");
}
auto* characterComponent = player->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) {
@ -112,11 +112,11 @@ void SGCannon::OnActivityStateChangeRequest(Entity *self, LWOOBJID senderID, int
self->SetNetworkVar<bool>(HideScoreBoardVariable, true);
self->SetNetworkVar<bool>(ReSetSuperChargeVariable, true);
self->SetNetworkVar<bool>(ShowLoadingUI, true);
/*
GameMessages::SendTeleport(
player->GetObjectID(),
{-292.6415710449219, 230.20237731933594, -3.9090466499328613},
player->GetObjectID(),
{-292.6415710449219, 230.20237731933594, -3.9090466499328613},
{0.7067984342575073, -6.527870573336259e-05, 0.707414984703064, 0.00021762956748716533},
player->GetSystemAddress(), true
);
@ -125,7 +125,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity *self, LWOOBJID senderID, int
//GameMessages::SendRequestActivityEnter(self->GetObjectID(), player->GetSystemAddress(), false, player->GetObjectID());
}
else {
Game::logger->Log("SGCannon", "Player not found\n");
Game::logger->Log("SGCannon", "Player not found");
}
}
else if (value1 == 1200) {
@ -193,7 +193,7 @@ void SGCannon::OnActivityTimerDone(Entity *self, const std::string &name) {
SpawnObject(self, enemyToSpawn, true);
}
Game::logger->Log("SGCannon", "Current wave spawn: %i/%i\n", wave, m_Waves.size());
Game::logger->Log("SGCannon", "Current wave spawn: %i/%i", wave, m_Waves.size());
// All waves completed
const auto timeLimit = (float_t) self->GetVar<uint32_t>(TimeLimitVariable);
@ -208,7 +208,7 @@ void SGCannon::OnActivityTimerDone(Entity *self, const std::string &name) {
GameMessages::SendPlayFXEffect(player->GetObjectID(), -1, u"SG-start", "");
GameMessages::SendStartActivityTime(self->GetObjectID(), timeLimit, player->GetSystemAddress());
Game::logger->Log("SGCannon", "Sending ActivityPause false\n");
Game::logger->Log("SGCannon", "Sending ActivityPause false");
GameMessages::SendActivityPause(self->GetObjectID(), false, player->GetSystemAddress());
}
@ -229,7 +229,7 @@ void SGCannon::OnActivityTimerDone(Entity *self, const std::string &name) {
self->SetNetworkVar<uint32_t>(WaveNumVariable, self->GetVar<uint32_t>(ThisWaveVariable) + 1);
self->SetNetworkVar<uint32_t>(WaveStrVariable, self->GetVar<uint32_t>(TimeLimitVariable));
Game::logger->Log("SGCannon", "Current wave: %i/%i\n", self->GetVar<uint32_t>(ThisWaveVariable), m_Waves.size());
Game::logger->Log("SGCannon", "Current wave: %i/%i", self->GetVar<uint32_t>(ThisWaveVariable), m_Waves.size());
if (self->GetVar<uint32_t>(ThisWaveVariable) >= m_Waves.size()) {
ActivityTimerStart(self, GameOverTimer, 0.1, 0.1);
@ -237,7 +237,7 @@ void SGCannon::OnActivityTimerDone(Entity *self, const std::string &name) {
ActivityTimerStart(self, SpawnWaveTimer, constants.inBetweenWavePause, constants.inBetweenWavePause);
}
Game::logger->Log("SGCannon", "Sending ActivityPause true\n");
Game::logger->Log("SGCannon", "Sending ActivityPause true");
GameMessages::SendActivityPause(self->GetObjectID(), true);
if (self->GetVar<bool>(SuperChargeActiveVariable) && !self->GetVar<bool>(SuperChargePausedVariable)) {
@ -246,7 +246,7 @@ void SGCannon::OnActivityTimerDone(Entity *self, const std::string &name) {
} else if (name == GameOverTimer) {
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player != nullptr) {
Game::logger->Log("SGCannon", "Sending ActivityPause true\n");
Game::logger->Log("SGCannon", "Sending ActivityPause true");
GameMessages::SendActivityPause(self->GetObjectID(), true, player->GetSystemAddress());
@ -288,7 +288,7 @@ void SGCannon::OnActivityTimerDone(Entity *self, const std::string &name) {
new LDFData<std::u16string>(u"groupID", u"SGEnemy")
};
Game::logger->Log("SGCannon", "Spawning enemy %i on path %s\n", toSpawn.lot, path->pathName.c_str());
Game::logger->Log("SGCannon", "Spawning enemy %i on path %s", toSpawn.lot, path->pathName.c_str());
auto* enemy = EntityManager::Instance()->CreateEntity(info, nullptr, self);
EntityManager::Instance()->ConstructEntity(enemy);
@ -297,7 +297,7 @@ void SGCannon::OnActivityTimerDone(Entity *self, const std::string &name) {
auto* movementAI = new MovementAIComponent(enemy, {});
enemy->AddComponent(COMPONENT_TYPE_MOVEMENT_AI, movementAI);
movementAI->SetSpeed(toSpawn.initialSpeed);
movementAI->SetCurrentSpeed(toSpawn.initialSpeed);
movementAI->SetHaltDistance(0.0f);
@ -349,7 +349,7 @@ void SGCannon::StartGame(Entity *self) {
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player != nullptr) {
GetLeaderboardData(self, player->GetObjectID(), GetActivityID(self));
Game::logger->Log("SGCannon", "Sending ActivityStart\n");
Game::logger->Log("SGCannon", "Sending ActivityStart");
GameMessages::SendActivityStart(self->GetObjectID(), player->GetSystemAddress());
GameMessages::SendPlayFXEffect(self->GetObjectID(), -1, u"start", "");
@ -554,7 +554,7 @@ void SGCannon::StopGame(Entity *self, bool cancel) {
}
auto* missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent != nullptr) {
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_MINIGAME, self->GetVar<uint32_t>(TotalScoreVariable), self->GetObjectID(), "performact_score");
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_MINIGAME, self->GetVar<uint32_t>(MaxStreakVariable), self->GetObjectID(), "performact_streak");
@ -602,7 +602,7 @@ void SGCannon::StopGame(Entity *self, bool cancel) {
ResetVars(self);
}
void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& timerName)
void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& timerName)
{
const auto& spawnInfo = target->GetVar<SGEnemy>(u"SpawnData");
@ -634,7 +634,7 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time
auto scScore = self->GetVar<uint32_t>(TotalScoreVariable) - lastSuperTotal;
Game::logger->Log("SGCannon", "LastSuperTotal: %i, scScore: %i, constants.chargedPoints: %i\n",
Game::logger->Log("SGCannon", "LastSuperTotal: %i, scScore: %i, constants.chargedPoints: %i",
lastSuperTotal, scScore, constants.chargedPoints
);
@ -674,7 +674,7 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_SMASH, spawnInfo.lot, self->GetObjectID());
}
void SGCannon::UpdateStreak(Entity* self)
void SGCannon::UpdateStreak(Entity* self)
{
const auto streakBonus = GetCurrentBonus(self);
@ -705,7 +705,7 @@ void SGCannon::UpdateStreak(Entity* self)
if (maxStreak < curStreak) self->SetVar<uint32_t>(MaxStreakVariable, curStreak);
}
float_t SGCannon::GetCurrentBonus(Entity* self)
float_t SGCannon::GetCurrentBonus(Entity* self)
{
auto streak = self->GetVar<uint32_t>(u"m_curStreak");
@ -723,7 +723,7 @@ void SGCannon::ToggleSuperCharge(Entity *self, bool enable) {
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player == nullptr) {
Game::logger->Log("SGCannon", "Player not found in toggle super charge\n");
Game::logger->Log("SGCannon", "Player not found in toggle super charge");
return;
}
@ -731,7 +731,7 @@ void SGCannon::ToggleSuperCharge(Entity *self, bool enable) {
auto equippedItems = inventoryComponent->GetEquippedItems();
Game::logger->Log("SGCannon", "Player has %d equipped items\n", equippedItems.size());
Game::logger->Log("SGCannon", "Player has %d equipped items", equippedItems.size());
auto skillID = constants.cannonSkill;
auto coolDown = constants.cannonRefireRate;
@ -739,12 +739,12 @@ void SGCannon::ToggleSuperCharge(Entity *self, bool enable) {
auto* selfInventoryComponent = self->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) {
Game::logger->Log("SGCannon", "Inventory component not found\n");
Game::logger->Log("SGCannon", "Inventory component not found");
return;
}
if (enable) {
Game::logger->Log("SGCannon", "Player is activating super charge\n");
Game::logger->Log("SGCannon", "Player is activating super charge");
selfInventoryComponent->UpdateSlot("greeble_r", { ObjectIDManager::GenerateRandomObjectID(), 6505, 1, 0 });
selfInventoryComponent->UpdateSlot("greeble_l", { ObjectIDManager::GenerateRandomObjectID(), 6506, 1, 0 });
@ -754,15 +754,15 @@ void SGCannon::ToggleSuperCharge(Entity *self, bool enable) {
} else {
selfInventoryComponent->UpdateSlot("greeble_r", { ObjectIDManager::GenerateRandomObjectID(), 0, 0, 0 });
selfInventoryComponent->UpdateSlot("greeble_l", { ObjectIDManager::GenerateRandomObjectID(), 0, 0, 0 });
self->SetNetworkVar<float>(u"SuperChargeBar", 0);
Game::logger->Log("SGCannon", "Player disables super charge\n");
Game::logger->Log("SGCannon", "Player disables super charge");
// TODO: Unequip items
for (const auto& equipped : equippedItems) {
if (equipped.first == "special_r" || equipped.first == "special_l") {
Game::logger->Log("SGCannon", "Trying to unequip a weapon, %i\n", equipped.second.lot);
Game::logger->Log("SGCannon", "Trying to unequip a weapon, %i", equipped.second.lot);
auto* item = inventoryComponent->FindItemById(equipped.second.id);
@ -770,7 +770,7 @@ void SGCannon::ToggleSuperCharge(Entity *self, bool enable) {
inventoryComponent->UnEquipItem(item);
}
else {
Game::logger->Log("SGCannon", "Item not found, %i\n", equipped.second.lot);
Game::logger->Log("SGCannon", "Item not found, %i", equipped.second.lot);
}
}
}
@ -787,7 +787,7 @@ void SGCannon::ToggleSuperCharge(Entity *self, bool enable) {
}
DynamicShootingGalleryParams properties = shootingGalleryComponent->GetDynamicParams();
properties.cannonFOV = 58.6f;
properties.cannonVelocity = 129.0;
properties.cannonRefireRate = 800;

View File

@ -127,9 +127,9 @@ int main(int argc, char** argv) {
if (!Game::logger) return 0;
Game::logger->SetLogToConsole(true); //We want this info to always be logged.
Game::logger->Log("WorldServer", "Starting World server...\n");
Game::logger->Log("WorldServer", "Version: %i.%i\n", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR);
Game::logger->Log("WorldServer", "Compiled on: %s\n", __TIMESTAMP__);
Game::logger->Log("WorldServer", "Starting World server...");
Game::logger->Log("WorldServer", "Version: %i.%i", PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR);
Game::logger->Log("WorldServer", "Compiled on: %s", __TIMESTAMP__);
#ifndef _DEBUG
Game::logger->SetLogToConsole(false); //By default, turn it back off if not in debug.
@ -146,9 +146,9 @@ int main(int argc, char** argv) {
try {
CDClientDatabase::Connect("./res/CDServer.sqlite");
} catch (CppSQLite3Exception& e) {
Game::logger->Log("WorldServer", "Unable to connect to CDServer SQLite Database\n");
Game::logger->Log("WorldServer", "Error: %s\n", e.errorMessage());
Game::logger->Log("WorldServer", "Error Code: %i\n", e.errorCode());
Game::logger->Log("WorldServer", "Unable to connect to CDServer SQLite Database");
Game::logger->Log("WorldServer", "Error: %s", e.errorMessage());
Game::logger->Log("WorldServer", "Error Code: %i", e.errorCode());
return -1;
}
@ -170,7 +170,7 @@ int main(int argc, char** argv) {
try {
Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password);
} catch (sql::SQLException& ex) {
Game::logger->Log("WorldServer", "Got an error while connecting to the database: %s\n", ex.what());
Game::logger->Log("WorldServer", "Got an error while connecting to the database: %s", ex.what());
return 0;
}
@ -277,7 +277,7 @@ int main(int argc, char** argv) {
delete md5;
Game::logger->Log("WorldServer", "FDB Checksum calculated as: %s\n", databaseChecksum.c_str());
Game::logger->Log("WorldServer", "FDB Checksum calculated as: %s", databaseChecksum.c_str());
}
}
@ -304,7 +304,7 @@ int main(int argc, char** argv) {
//Warning if we ran slow
if (deltaTime > currentFramerate) {
Game::logger->Log("WorldServer", "We're running behind, dT: %f > %f (framerate)\n", deltaTime, currentFramerate);
Game::logger->Log("WorldServer", "We're running behind, dT: %f > %f (framerate)", deltaTime, currentFramerate);
}
//Check if we're still connected to master:
@ -313,7 +313,7 @@ int main(int argc, char** argv) {
int framesToWaitForMaster = ready ? 10 : 200;
if (framesSinceMasterDisconnect >= framesToWaitForMaster && !worldShutdownSequenceStarted) {
Game::logger->Log("WorldServer", "Game loop running but no connection to master for %d frames, shutting down\n", framesToWaitForMaster);
Game::logger->Log("WorldServer", "Game loop running but no connection to master for %d frames, shutting down", framesToWaitForMaster);
worldShutdownSequenceStarted = true;
}
}
@ -470,7 +470,7 @@ int main(int argc, char** argv) {
if (framesSinceMasterStatus >= 200)
{
Game::logger->Log("WorldServer", "Finished loading world with zone (%i), ready up!\n", Game::server->GetZoneID());
Game::logger->Log("WorldServer", "Finished loading world with zone (%i), ready up!", Game::server->GetZoneID());
MasterPackets::SendWorldReady(Game::server, Game::server->GetZoneID(), Game::server->GetInstanceID());
@ -504,13 +504,13 @@ dLogger * SetupLogger(int zoneID, int instanceID) {
void HandlePacketChat(Packet* packet) {
if (packet->data[0] == ID_DISCONNECTION_NOTIFICATION || packet->data[0] == ID_CONNECTION_LOST) {
Game::logger->Log("WorldServer", "Lost our connection to chat, zone(%i), instance(%i)\n", Game::server->GetZoneID(), Game::server->GetInstanceID());
Game::logger->Log("WorldServer", "Lost our connection to chat, zone(%i), instance(%i)", Game::server->GetZoneID(), Game::server->GetInstanceID());
chatConnected = false;
}
if (packet->data[0] == ID_CONNECTION_REQUEST_ACCEPTED) {
Game::logger->Log("WorldServer", "Established connection to chat, zone(%i), instance (%i)\n",Game::server -> GetZoneID(), Game::server -> GetInstanceID());
Game::logger->Log("WorldServer", "Established connection to chat, zone(%i), instance (%i)",Game::server -> GetZoneID(), Game::server -> GetInstanceID());
Game::chatSysAddr = packet->systemAddress;
chatConnected = true;
@ -556,7 +556,7 @@ void HandlePacketChat(Packet* packet) {
inStream.Read<char>(character);
title += character;
}
len = 0;
inStream.Read<uint32_t>(len);
for (int i = 0; len > i; i++) {
@ -617,21 +617,21 @@ void HandlePacketChat(Packet* packet) {
{
TeamManager::Instance()->DeleteTeam(teamID);
Game::logger->Log("WorldServer", "Deleting team (%llu)\n", teamID);
Game::logger->Log("WorldServer", "Deleting team (%llu)", teamID);
break;
}
inStream.Read(lootOption);
inStream.Read(memberCount);
Game::logger->Log("WorldServer", "Updating team (%llu), (%i), (%i)\n", teamID, lootOption, memberCount);
Game::logger->Log("WorldServer", "Updating team (%llu), (%i), (%i)", teamID, lootOption, memberCount);
for (char i = 0; i < memberCount; i++)
{
LWOOBJID member = LWOOBJID_EMPTY;
inStream.Read(member);
members.push_back(member);
Game::logger->Log("WorldServer", "Updating team member (%llu)\n", member);
Game::logger->Log("WorldServer", "Updating team member (%llu)", member);
}
TeamManager::Instance()->UpdateTeam(teamID, lootOption, members);
@ -640,7 +640,7 @@ void HandlePacketChat(Packet* packet) {
}
default:
Game::logger->Log("WorldServer", "Received an unknown chat internal: %i\n", int(packet->data[3]));
Game::logger->Log("WorldServer", "Received an unknown chat internal: %i", int(packet->data[3]));
}
}
}
@ -674,7 +674,7 @@ void HandlePacket(Packet* packet) {
entity->GetCharacter()->SaveXMLToDatabase();
Game::logger->Log("WorldServer", "Deleting player %llu\n", entity->GetObjectID());
Game::logger->Log("WorldServer", "Deleting player %llu", entity->GetObjectID());
EntityManager::Instance()->DestroyEntity(entity);
}
@ -741,12 +741,12 @@ void HandlePacket(Packet* packet) {
//Verify it:
if (userHash != it->second.hash) {
Game::logger->Log("WorldServer", "SOMEONE IS TRYING TO HACK? SESSION KEY MISMATCH: ours: %s != master: %s\n", userHash.c_str(), it->second.hash.c_str());
Game::logger->Log("WorldServer", "SOMEONE IS TRYING TO HACK? SESSION KEY MISMATCH: ours: %s != master: %s", userHash.c_str(), it->second.hash.c_str());
Game::server->Disconnect(it->second.sysAddr, SERVER_DISCON_INVALID_SESSION_KEY);
return;
}
else {
Game::logger->Log("WorldServer", "User %s authenticated with correct key.\n", username.c_str());
Game::logger->Log("WorldServer", "User %s authenticated with correct key.", username.c_str());
UserManager::Instance()->DeleteUser(packet->systemAddress);
@ -791,7 +791,7 @@ void HandlePacket(Packet* packet) {
case MSG_MASTER_AFFIRM_TRANSFER_REQUEST: {
const uint64_t requestID = PacketUtils::ReadPacketU64(8, packet);
Game::logger->Log("MasterServer", "Got affirmation request of transfer %llu\n", requestID);
Game::logger->Log("MasterServer", "Got affirmation request of transfer %llu", requestID);
CBITSTREAM
@ -804,7 +804,7 @@ void HandlePacket(Packet* packet) {
case MSG_MASTER_SHUTDOWN: {
worldShutdownSequenceStarted = true;
Game::logger->Log("WorldServer", "Got shutdown request from master, zone (%i), instance (%i)\n", Game::server->GetZoneID(), Game::server->GetInstanceID());
Game::logger->Log("WorldServer", "Got shutdown request from master, zone (%i), instance (%i)", Game::server->GetZoneID(), Game::server->GetInstanceID());
break;
}
@ -814,10 +814,10 @@ void HandlePacket(Packet* packet) {
uint32_t sessionKey = inStream.Read(sessionKey);
std::string username;
uint32_t len;
inStream.Read(len);
for (int i = 0; i < len; i++) {
char character; inStream.Read<char>(character);
username += character;
@ -826,13 +826,13 @@ void HandlePacket(Packet* packet) {
//Find them:
User* user = UserManager::Instance()->GetUser(username.c_str());
if (!user) {
Game::logger->Log("WorldServer", "Got new session alert for user %s, but they're not logged in.\n", username.c_str());
Game::logger->Log("WorldServer", "Got new session alert for user %s, but they're not logged in.", username.c_str());
return;
}
//Check the key:
if (sessionKey != std::atoi(user->GetSessionKey().c_str())) {
Game::logger->Log("WorldServer", "Got new session alert for user %s, but the session key is invalid.\n", username.c_str());
Game::logger->Log("WorldServer", "Got new session alert for user %s, but the session key is invalid.", username.c_str());
Game::server->Disconnect(user->GetSystemAddress(), SERVER_DISCON_INVALID_SESSION_KEY);
return;
}
@ -840,7 +840,7 @@ void HandlePacket(Packet* packet) {
}
default:
Game::logger->Log("WorldServer", "Unknown packet ID from master %i\n", int(packet->data[3]));
Game::logger->Log("WorldServer", "Unknown packet ID from master %i", int(packet->data[3]));
}
return;
@ -873,7 +873,7 @@ void HandlePacket(Packet* packet) {
// Developers may skip this check
if (gmLevel < 8 && clientDatabaseChecksum != databaseChecksum) {
Game::logger->Log("WorldServer", "Client's database checksum does not match the server's, aborting connection.\n");
Game::logger->Log("WorldServer", "Client's database checksum does not match the server's, aborting connection.");
Game::server->Disconnect(packet->systemAddress, SERVER_DISCON_KICK);
return;
}
@ -949,7 +949,7 @@ void HandlePacket(Packet* packet) {
playerID = GeneralUtils::ClearBit(playerID, OBJECT_BIT_PERSISTENT);
auto user = UserManager::Instance()->GetUser(packet->systemAddress);
if (user) {
auto lastCharacter = user->GetLoggedInChar();
// This means we swapped characters and we need to remove the previous player from the container.
@ -977,7 +977,7 @@ void HandlePacket(Packet* packet) {
}
case MSG_WORLD_CLIENT_LEVEL_LOAD_COMPLETE: {
Game::logger->Log("WorldServer", "Received level load complete from user.\n");
Game::logger->Log("WorldServer", "Received level load complete from user.");
User* user = UserManager::Instance()->GetUser(packet->systemAddress);
if (user) {
Character* c = user->GetLastUsedChar();
@ -1036,7 +1036,7 @@ void HandlePacket(Packet* packet) {
auto result = query.execQuery();
if (result.eof() || result.fieldIsNull(0)) {
Game::logger->Log("WorldServer", "No property templates found for zone %d, not sending BBB\n", zoneId);
Game::logger->Log("WorldServer", "No property templates found for zone %d, not sending BBB", zoneId);
goto noBBB;
}
@ -1064,7 +1064,7 @@ void HandlePacket(Packet* packet) {
stmt->setUInt64(1, propertyId);
auto res = stmt->executeQuery();
while (res->next()) {
Game::logger->Log("UGC", "Getting lxfml ugcID: " + std::to_string(res->getUInt(1)) + "\n");
Game::logger->Log("UGC", "Getting lxfml ugcID: " + std::to_string(res->getUInt(1)));
//Get lxfml:
auto stmtL = Database::CreatePreppedStmt("SELECT lxfml from ugc where id=?");
@ -1154,11 +1154,11 @@ void HandlePacket(Packet* packet) {
}
}
else {
Game::logger->Log("WorldServer", "Couldn't find character to log in with for user %s (%i)!\n", user->GetUsername().c_str(), user->GetAccountID());
Game::logger->Log("WorldServer", "Couldn't find character to log in with for user %s (%i)!", user->GetUsername().c_str(), user->GetAccountID());
Game::server->Disconnect(packet->systemAddress, SERVER_DISCON_CHARACTER_NOT_FOUND);
}
} else {
Game::logger->Log("WorldServer", "Couldn't get user for level load complete!\n");
Game::logger->Log("WorldServer", "Couldn't get user for level load complete!");
}
break;
}
@ -1185,7 +1185,7 @@ void HandlePacket(Packet* packet) {
inStream.Read(size);
if (size > 20000) {
Game::logger->Log("WorldServer", "Tried to route a packet with a read size > 20000, so likely a false packet.\n");
Game::logger->Log("WorldServer", "Tried to route a packet with a read size > 20000, so likely a false packet.");
return;
}
@ -1248,38 +1248,36 @@ void HandlePacket(Packet* packet) {
}
default:
Game::server->GetLogger()->Log("HandlePacket", "Unknown world packet received: %i\n", int(packet->data[3]));
Game::server->GetLogger()->Log("HandlePacket", "Unknown world packet received: %i", int(packet->data[3]));
}
}
void WorldShutdownProcess(uint32_t zoneId) {
Game::logger->Log("WorldServer", "Saving map %i instance %i\n", zoneId, instanceID);
Game::logger->Log("WorldServer", "Saving map %i instance %i", zoneId, instanceID);
for (auto i = 0; i < Game::server->GetReplicaManager()->GetParticipantCount(); ++i) {
const auto& player = Game::server->GetReplicaManager()->GetParticipantAtIndex(i);
auto* entity = Player::GetPlayer(player);
Game::logger->Log("WorldServer", "Saving data!\n");
Game::logger->Log("WorldServer", "Saving data!");
if (entity != nullptr && entity->GetCharacter() != nullptr) {
auto* skillComponent = entity->GetComponent<SkillComponent>();
if (skillComponent != nullptr) {
skillComponent->Reset();
}
std::string message = "Saving character " + entity->GetCharacter()->GetName() + "...\n";
Game::logger->Log("WorldServer", message);
Game::logger->Log("WorldServer", "Saving character %s...", entity->GetCharacter()->GetName().c_str());
entity->GetCharacter()->SaveXMLToDatabase();
message = "Character data for " + entity->GetCharacter()->GetName() + " was saved!\n";
Game::logger->Log("WorldServer", message);
Game::logger->Log("WorldServer", "Character data for %s was saved!", entity->GetCharacter()->GetName().c_str());
}
}
if (PropertyManagementComponent::Instance() != nullptr) {
Game::logger->Log("WorldServer", "Saving ALL property data for zone %i clone %i!\n", zoneId, PropertyManagementComponent::Instance()->GetCloneId());
Game::logger->Log("WorldServer", "Saving ALL property data for zone %i clone %i!", zoneId, PropertyManagementComponent::Instance()->GetCloneId());
PropertyManagementComponent::Instance()->Save();
Game::logger->Log("WorldServer", "ALL property data saved for zone %i clone %i!\n", zoneId, PropertyManagementComponent::Instance()->GetCloneId());
Game::logger->Log("WorldServer", "ALL property data saved for zone %i clone %i!", zoneId, PropertyManagementComponent::Instance()->GetCloneId());
}
Game::logger->Log("WorldServer", "ALL DATA HAS BEEN SAVED FOR ZONE %i INSTANCE %i!\n", zoneId, instanceID);
Game::logger->Log("WorldServer", "ALL DATA HAS BEEN SAVED FOR ZONE %i INSTANCE %i!", zoneId, instanceID);
while (Game::server->GetReplicaManager()->GetParticipantCount() > 0) {
const auto& player = Game::server->GetReplicaManager()->GetParticipantAtIndex(0);
@ -1296,7 +1294,7 @@ void WorldShutdownSequence() {
worldShutdownSequenceStarted = true;
Game::logger->Log("WorldServer", "Zone (%i) instance (%i) shutting down outside of main loop!\n", Game::server->GetZoneID(), instanceID);
Game::logger->Log("WorldServer", "Zone (%i) instance (%i) shutting down outside of main loop!", Game::server->GetZoneID(), instanceID);
WorldShutdownProcess(Game::server->GetZoneID());
FinalizeShutdown();
}
@ -1306,7 +1304,7 @@ void FinalizeShutdown() {
if (Game::physicsWorld) Game::physicsWorld = nullptr;
if (Game::zoneManager) delete Game::zoneManager;
Game::logger->Log("WorldServer", "Shutdown complete, zone (%i), instance (%i)\n", Game::server->GetZoneID(), instanceID);
Game::logger->Log("WorldServer", "Shutdown complete, zone (%i), instance (%i)", Game::server->GetZoneID(), instanceID);
Metrics::Clear();
Database::Destroy("WorldServer");

View File

@ -18,11 +18,10 @@ Level::Level(Zone* parentZone, const std::string& filepath) {
m_ParentZone = parentZone;
std::ifstream file(filepath, std::ios_base::in | std::ios_base::binary);
if (file) {
//printf("Opened %s\n", filepath.c_str());
ReadChunks(file);
}
else {
Game::logger->Log("Level", "Failed to load %s\n", filepath.c_str());
Game::logger->Log("Level", "Failed to load %s", filepath.c_str());
}
file.close();
@ -96,7 +95,7 @@ void Level::ReadChunks(std::ifstream & file) {
for (uint32_t i = 0; i < s; ++i) {
file.ignore(4); //a uint
file.ignore(4); //two floats
file.ignore(4);
file.ignore(4);
}
}
}
@ -110,7 +109,7 @@ void Level::ReadChunks(std::ifstream & file) {
if (header.chunkVersion >= 36) {
file.ignore(3 * 4);
}
if (header.chunkVersion < 42) {
file.ignore(3 * 4);
@ -176,7 +175,7 @@ void Level::ReadSceneObjectDataChunk(std::ifstream & file, Header & header) {
BinaryIO::BinaryRead(file, obj.rotation);
BinaryIO::BinaryRead(file, obj.scale);
//This is a little bit of a bodge, but because the alpha client (HF) doesn't store the
//This is a little bit of a bodge, but because the alpha client (HF) doesn't store the
//spawn position / rotation like the later versions do, we need to check the LOT for the spawn pos & set it.
if (obj.lot == LOT_MARKER_PLAYER_START) {
dZoneManager::Instance()->GetZone()->SetSpawnPos(obj.position);
@ -186,18 +185,18 @@ void Level::ReadSceneObjectDataChunk(std::ifstream & file, Header & header) {
std::u16string ldfString = u"";
uint32_t length = 0;
BinaryIO::BinaryRead(file, length);
for (uint32_t i = 0; i < length; ++i) {
uint16_t data;
BinaryIO::BinaryRead(file, data);
ldfString.push_back(data);
}
std::string sData = GeneralUtils::UTF16ToWTF8(ldfString);
std::stringstream ssData(sData);
std::string token;
char deliminator = '\n';
while (std::getline(ssData, token, deliminator)) {
LDFBaseData * ldfData = LDFBaseData::DataFromString(token);
obj.settings.push_back(ldfData);
@ -260,11 +259,11 @@ void Level::ReadSceneObjectDataChunk(std::ifstream & file, Header & header) {
if (data->GetKey() == u"spawner_active_on_load") {
spawnInfo.activeOnLoad = std::stoi(data->GetValueAsString());
}
if (data->GetKey() == u"active_on_load") {
spawnInfo.activeOnLoad = std::stoi(data->GetValueAsString());
}
if (data->GetKey() == u"respawn") {
if (data->GetValueType() == eLDFType::LDF_TYPE_FLOAT) // Floats are in seconds
{
@ -350,6 +349,5 @@ void Level::ReadSceneObjectDataChunk(std::ifstream & file, Header & header) {
}
}
//printf("Loaded %u objects!\n", objectsCount);
header.sceneObjects = chunk;
}

View File

@ -24,7 +24,7 @@ Zone::Zone(const LWOMAPID & mapID, const LWOINSTANCEID & instanceID, const LWOCL
}
Zone::~Zone() {
Game::logger->Log("Zone", "Destroying zone %i\n", m_ZoneID.GetMapID());
Game::logger->Log("Zone", "Destroying zone %i", m_ZoneID.GetMapID());
for (std::map<LWOSCENEID, SceneRef>::iterator it = m_Scenes.begin(); it != m_Scenes.end(); ++it) {
if (it->second.level != nullptr) delete it->second.level;
}
@ -45,12 +45,12 @@ void Zone::LoadZoneIntoMemory() {
std::ifstream file(m_ZoneFilePath, std::ios::binary);
if (file) {
BinaryIO::BinaryRead(file, m_ZoneFileFormatVersion);
uint32_t mapRevision = 0;
if (m_ZoneFileFormatVersion >= Zone::ZoneFileFormatVersion::Alpha) BinaryIO::BinaryRead(file, mapRevision);
BinaryIO::BinaryRead(file, m_WorldID);
if ((uint16_t)m_WorldID != m_ZoneID.GetMapID()) Game::logger->Log("Zone", "WorldID: %i doesn't match MapID %i! Is this intended?\n", m_WorldID, m_ZoneID.GetMapID());
if ((uint16_t)m_WorldID != m_ZoneID.GetMapID()) Game::logger->Log("Zone", "WorldID: %i doesn't match MapID %i! Is this intended?", m_WorldID, m_ZoneID.GetMapID());
AddRevision(LWOSCENEID_INVALID, mapRevision);
@ -58,7 +58,7 @@ void Zone::LoadZoneIntoMemory() {
BinaryIO::BinaryRead(file, m_Spawnpoint);
BinaryIO::BinaryRead(file, m_SpawnpointRotation);
}
if (m_ZoneFileFormatVersion <= Zone::ZoneFileFormatVersion::LateAlpha) {
uint8_t sceneCount;
BinaryIO::BinaryRead(file, sceneCount);
@ -102,7 +102,7 @@ void Zone::LoadZoneIntoMemory() {
for (uint32_t i = 0; i < pathCount; ++i) {
LoadPath(file);
}
for (Path path : m_Paths) {
if (path.pathType == PathType::Spawner) {
SpawnerInfo info = SpawnerInfo();
@ -150,16 +150,16 @@ void Zone::LoadZoneIntoMemory() {
Spawner* spawner = new Spawner(info);
dZoneManager::Instance()->AddSpawner(info.spawnerID, spawner);
}
}
//m_PathData.resize(m_PathDataLength);
//file.read((char*)&m_PathData[0], m_PathDataLength);
}
}
else {
Game::logger->Log("Zone", "Failed to open: %s\n", m_ZoneFilePath.c_str());
Game::logger->Log("Zone", "Failed to open: %s", m_ZoneFilePath.c_str());
}
m_ZonePath = m_ZoneFilePath.substr(0, m_ZoneFilePath.rfind('/') + 1);
@ -226,7 +226,7 @@ void Zone::AddRevision(LWOSCENEID sceneID, uint32_t revision) {
const void Zone::PrintAllGameObjects() {
for (std::pair<LWOSCENEID, SceneRef> scene : m_Scenes) {
Game::logger->Log("Zone", "\nIn sceneID: %i\n\n", scene.first.GetSceneID());
Game::logger->Log("Zone", "In sceneID: %i", scene.first.GetSceneID());
scene.second.level->PrintAllObjects();
}
}
@ -242,7 +242,7 @@ void Zone::LoadScene(std::ifstream & file) {
std::string luTriggersPath = scene.filename.substr(0, scene.filename.size() - 4) + ".lutriggers";
std::vector<LUTriggers::Trigger*> triggers = LoadLUTriggers(luTriggersPath, scene.id);
for (LUTriggers::Trigger* trigger : triggers) {
scene.triggers.insert({ trigger->id, trigger });
}
@ -283,13 +283,13 @@ std::vector<LUTriggers::Trigger*> Zone::LoadLUTriggers(std::string triggerFile,
if (!doc) return lvlTriggers;
if (doc->Parse(data.str().c_str(), data.str().size()) == 0) {
//Game::logger->Log("Zone", "Loaded LUTriggers from file %s!\n", triggerFile.c_str());
//Game::logger->Log("Zone", "Loaded LUTriggers from file %s!", triggerFile.c_str());
}
else {
Game::logger->Log("Zone", "Failed to load LUTriggers from file %s\n", triggerFile.c_str());
Game::logger->Log("Zone", "Failed to load LUTriggers from file %s", triggerFile.c_str());
return lvlTriggers;
}
tinyxml2::XMLElement* triggers = doc->FirstChildElement("triggers");
if (!triggers) return lvlTriggers;
@ -323,7 +323,7 @@ std::vector<LUTriggers::Trigger*> Zone::LoadLUTriggers(std::string triggerFile,
currentTrigger = currentTrigger->NextSiblingElement("trigger");
lvlTriggers.push_back(newTrigger);
}
delete doc;
return lvlTriggers;
@ -474,8 +474,8 @@ void Zone::LoadPath(std::ifstream & file) {
BinaryIO::BinaryRead(file, waypoint.position.x);
BinaryIO::BinaryRead(file, waypoint.position.y);
BinaryIO::BinaryRead(file, waypoint.position.z);
if (path.pathType == PathType::Spawner || path.pathType == PathType::MovingPlatform || path.pathType == PathType::Race) {
BinaryIO::BinaryRead(file, waypoint.rotation.w);
BinaryIO::BinaryRead(file, waypoint.rotation.x);
@ -565,7 +565,7 @@ void Zone::LoadPath(std::ifstream & file) {
path.pathWaypoints.push_back(waypoint);
}
m_Paths.push_back(path);
}

View File

@ -15,7 +15,7 @@
dZoneManager* dZoneManager::m_Address = nullptr;
void dZoneManager::Initialize(const LWOZONEID& zoneID) {
Game::logger->Log("dZoneManager", "Preparing zone: %i/%i/%i\n", zoneID.GetMapID(), zoneID.GetInstanceID(), zoneID.GetCloneID());
Game::logger->Log("dZoneManager", "Preparing zone: %i/%i/%i", zoneID.GetMapID(), zoneID.GetInstanceID(), zoneID.GetCloneID());
int64_t startTime = 0;
int64_t endTime = 0;
@ -40,7 +40,7 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) {
}
}
Game::logger->Log("dZoneManager", "Creating zone control object %i\n", zoneControlTemplate);
Game::logger->Log("dZoneManager", "Creating zone control object %i", zoneControlTemplate);
// Create ZoneControl object
EntityInfo info;
@ -53,7 +53,7 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) {
endTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
Game::logger->Log("dZoneManager", "Zone prepared in: %llu ms\n", (endTime - startTime));
Game::logger->Log("dZoneManager", "Zone prepared in: %llu ms", (endTime - startTime));
VanityUtilities::SpawnVanity();
}
@ -89,7 +89,7 @@ void dZoneManager::NotifyZone(const dZoneNotifier & notifier, const LWOOBJID& ob
case dZoneNotifier::SpawnedChildObjectDestroyed:
break;
case dZoneNotifier::ReloadZone:
Game::logger->Log("dZoneManager", "Forcing reload of zone %i\n", m_ZoneID.GetMapID());
Game::logger->Log("dZoneManager", "Forcing reload of zone %i", m_ZoneID.GetMapID());
LoadZone(m_ZoneID);
m_pZone->Initalize();
@ -102,10 +102,10 @@ void dZoneManager::NotifyZone(const dZoneNotifier & notifier, const LWOOBJID& ob
m_pZone->PrintAllGameObjects();
break;
case dZoneNotifier::InvalidNotifier:
Game::logger->Log("dZoneManager", "Got an invalid zone notifier.\n");
Game::logger->Log("dZoneManager", "Got an invalid zone notifier.");
break;
default:
Game::logger->Log("dZoneManager", "Unknown zone notifier: %i\n", int(notifier));
Game::logger->Log("dZoneManager", "Unknown zone notifier: %i", int(notifier));
}
}
@ -188,7 +188,7 @@ void dZoneManager::RemoveSpawner(const LWOOBJID id)
auto* spawner = GetSpawner(id);
if (spawner == nullptr) {
Game::logger->Log("dZoneManager", "Failed to find spawner (%llu)\n", id);
Game::logger->Log("dZoneManager", "Failed to find spawner (%llu)", id);
return;
}
@ -199,7 +199,7 @@ void dZoneManager::RemoveSpawner(const LWOOBJID id)
}
else {
Game::logger->Log("dZoneManager", "Failed to find spawner entity (%llu)\n", id);
Game::logger->Log("dZoneManager", "Failed to find spawner entity (%llu)", id);
}
for (auto* node : spawner->m_Info.nodes)
@ -218,7 +218,7 @@ void dZoneManager::RemoveSpawner(const LWOOBJID id)
spawner->Deactivate();
Game::logger->Log("dZoneManager", "Destroying spawner (%llu)\n", id);
Game::logger->Log("dZoneManager", "Destroying spawner (%llu)", id);
m_Spawners.erase(id);