diff --git a/changelog.txt b/changelog.txt index b2c71a440..18d35029e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,13 +1,59 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 4/1/2017 == +Akkadius: [Performance] Reworked how all log calls are made in the source + - Before we used Log.Out, we will now use a macro Log( + - Before: Log.Out(Logs::General, Logs::Status, "Importing Spells..."); + - After: Log(Logs::General, Logs::Status, "Importing Spells..."); + - The difference is + 1) It's 200-300x faster especially when log statements are inside very hot code paths. We already + had most hot paths checked before we logged them, but this blankets all existing logging calls now and not just the + select few we had picked out in the source. + 2) Strings don't get copied to the stack, popped and pushed constantly even when we hit a log statement that + actually isn't going to log anything. + - We do an 'if (LogSys.log_settings[log_category].is_category_enabled == 1)' before we call a log function + in the log macro so the log function doesn't get called at all if we're not logging the category + - This has increased binary executables roughly 15KB + - The old extern for EQEmuLogSys is now named LogSys appropriately instead of Log (Ex: LogSys.StartFileLogs()) + - The result keeps logging footprint non-existent for when we're not logging that category + +== 03/30/2017 == +Akkadius: [Performance] Fixed an overhead issue where many hot paths would trigger quest subroutines and beneath that the code would + try to see if a quest existed perpetually (checking if file exists) even though it should have determined the quest + didn't exist the first time. + - This caused a lot of overhead in an instance where an entire zone of NPC's is pathing, triggering EVENT_WAYPOINT_ARRIVE + and EVENT_WAYPOINT_DEPART when there is no global_npc.pl/lua, or all NPC's pathing don't have a quest assigned, similar + behavior would occur. This goes for any other type of quests: spells, items, encounters etc. + +== 03/28/2017 == +Akkadius: [Performance] Fixed a large overhead issue where every single NPC in a zone was checking to depop themselves + as a swarm pet every 3ms regardless of being a swarm pet or not. Swarm pets now check to depop only when their timer is up +Akkadius: [Performance] Removed a timer where clients would constantly calculate light amount on equipment every 600ms, instead + clients will update light when changing equipment or entering a zone +Akkadius: [Performance] Disabled enraged timer checks for NPC's that do not actually have enrage as a special attack +Akkadius: [Performance] Don't process ProjectileAttack checks for NPC's that are not engaged in any combat + +== 03/27/2017 == +Akkadius: [Performance] Reworked how client to NPC aggro checks are made + - Before when reverse aggro checks were done (client to NPC), checks would happen every 750 millseconds where a client would + check an entire entity list with distance calcs and other checks for aggro, with many clients in a zone and many NPC's this would + add a lot of unecessary overhead. A temporary adjustment on 3/25 was made and upped the check to 6 seconds. + - Now, there is a new methodology to scanning. The client will build a cache list of NPC's within close range as defined in new rule: + RULE_INT(Range, ClientNPCScan, 300) and will also get any NPC that has an aggro range beyond that defined range to use in + the frequent checks for aggro, the result is far less overhead + - Client scanning changes when moving versus not moving, the client will scan aggro every 500 milliseconds while moving, and + 3000 millseconds aggro check when not moving, with a 6000ms re-fetch for close NPC's + - A demo of these changes can be found here: + https://youtu.be/aGroiwLSTVU + == 03/25/2017 == -Akkadius: Reduced CPU footprint in non-combat zones doing constant checks for combat related activities -Akkadius: Reduced CPU footprint in cases where a client is checking for aggro excessively every 750 millseconds. This has +Akkadius: [Performance] Reduced CPU footprint in non-combat zones doing constant checks for combat related activities +Akkadius: [Performance] Reduced CPU footprint in cases where a client is checking for aggro excessively every 750 millseconds. This has been adjusted to 6 seconds per new rule RULE_INT(Aggro, ClientAggroCheckInterval) - When zones have many players, with many NPC's, this adds up quickly == 03/12/2017 == -Akkadius: +Akkadius: [Performance] - Implemented range rules for packets and other functions RULE_INT ( Range, Say, 135 ) RULE_INT ( Range, Emote, 135 ) diff --git a/client_files/export/main.cpp b/client_files/export/main.cpp index 2eda87411..8009e81b4 100644 --- a/client_files/export/main.cpp +++ b/client_files/export/main.cpp @@ -27,7 +27,7 @@ #include "../../common/rulesys.h" #include "../../common/string_util.h" -EQEmuLogSys Log; +EQEmuLogSys LogSys; void ExportSpells(SharedDatabase *db); void ExportSkillCaps(SharedDatabase *db); @@ -36,46 +36,46 @@ void ExportDBStrings(SharedDatabase *db); int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformClientExport); - Log.LoadLogSettingsDefaults(); + LogSys.LoadLogSettingsDefaults(); set_exception_handler(); - Log.Out(Logs::General, Logs::Status, "Client Files Export Utility"); + Log(Logs::General, Logs::Status, "Client Files Export Utility"); if(!EQEmuConfig::LoadConfig()) { - Log.Out(Logs::General, Logs::Error, "Unable to load configuration file."); + Log(Logs::General, Logs::Error, "Unable to load configuration file."); return 1; } auto Config = EQEmuConfig::get(); SharedDatabase database; - Log.Out(Logs::General, Logs::Status, "Connecting to database..."); + Log(Logs::General, Logs::Status, "Connecting to database..."); if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(), Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) { - Log.Out(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a " + Log(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a " "database connection"); return 1; } /* Register Log System and Settings */ - database.LoadLogSettings(Log.log_settings); - Log.StartFileLogs(); + database.LoadLogSettings(LogSys.log_settings); + LogSys.StartFileLogs(); ExportSpells(&database); ExportSkillCaps(&database); ExportBaseData(&database); ExportDBStrings(&database); - Log.CloseFileLogs(); + LogSys.CloseFileLogs(); return 0; } void ExportSpells(SharedDatabase *db) { - Log.Out(Logs::General, Logs::Status, "Exporting Spells..."); + Log(Logs::General, Logs::Status, "Exporting Spells..."); FILE *f = fopen("export/spells_us.txt", "w"); if(!f) { - Log.Out(Logs::General, Logs::Error, "Unable to open export/spells_us.txt to write, skipping."); + Log(Logs::General, Logs::Error, "Unable to open export/spells_us.txt to write, skipping."); return; } @@ -142,11 +142,11 @@ int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) { } void ExportSkillCaps(SharedDatabase *db) { - Log.Out(Logs::General, Logs::Status, "Exporting Skill Caps..."); + Log(Logs::General, Logs::Status, "Exporting Skill Caps..."); FILE *f = fopen("export/SkillCaps.txt", "w"); if(!f) { - Log.Out(Logs::General, Logs::Error, "Unable to open export/SkillCaps.txt to write, skipping."); + Log(Logs::General, Logs::Error, "Unable to open export/SkillCaps.txt to write, skipping."); return; } @@ -171,11 +171,11 @@ void ExportSkillCaps(SharedDatabase *db) { } void ExportBaseData(SharedDatabase *db) { - Log.Out(Logs::General, Logs::Status, "Exporting Base Data..."); + Log(Logs::General, Logs::Status, "Exporting Base Data..."); FILE *f = fopen("export/BaseData.txt", "w"); if(!f) { - Log.Out(Logs::General, Logs::Error, "Unable to open export/BaseData.txt to write, skipping."); + Log(Logs::General, Logs::Error, "Unable to open export/BaseData.txt to write, skipping."); return; } @@ -202,11 +202,11 @@ void ExportBaseData(SharedDatabase *db) { } void ExportDBStrings(SharedDatabase *db) { - Log.Out(Logs::General, Logs::Status, "Exporting DB Strings..."); + Log(Logs::General, Logs::Status, "Exporting DB Strings..."); FILE *f = fopen("export/dbstr_us.txt", "w"); if(!f) { - Log.Out(Logs::General, Logs::Error, "Unable to open export/dbstr_us.txt to write, skipping."); + Log(Logs::General, Logs::Error, "Unable to open export/dbstr_us.txt to write, skipping."); return; } diff --git a/client_files/import/main.cpp b/client_files/import/main.cpp index defd64f98..a8e2ad0fe 100644 --- a/client_files/import/main.cpp +++ b/client_files/import/main.cpp @@ -25,7 +25,7 @@ #include "../../common/rulesys.h" #include "../../common/string_util.h" -EQEmuLogSys Log; +EQEmuLogSys LogSys; void ImportSpells(SharedDatabase *db); void ImportSkillCaps(SharedDatabase *db); @@ -34,35 +34,35 @@ void ImportDBStrings(SharedDatabase *db); int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformClientImport); - Log.LoadLogSettingsDefaults(); + LogSys.LoadLogSettingsDefaults(); set_exception_handler(); - Log.Out(Logs::General, Logs::Status, "Client Files Import Utility"); + Log(Logs::General, Logs::Status, "Client Files Import Utility"); if(!EQEmuConfig::LoadConfig()) { - Log.Out(Logs::General, Logs::Error, "Unable to load configuration file."); + Log(Logs::General, Logs::Error, "Unable to load configuration file."); return 1; } auto Config = EQEmuConfig::get(); SharedDatabase database; - Log.Out(Logs::General, Logs::Status, "Connecting to database..."); + Log(Logs::General, Logs::Status, "Connecting to database..."); if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(), Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) { - Log.Out(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a " + Log(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a " "database connection"); return 1; } - database.LoadLogSettings(Log.log_settings); - Log.StartFileLogs(); + database.LoadLogSettings(LogSys.log_settings); + LogSys.StartFileLogs(); ImportSpells(&database); ImportSkillCaps(&database); ImportBaseData(&database); ImportDBStrings(&database); - Log.CloseFileLogs(); + LogSys.CloseFileLogs(); return 0; } @@ -97,10 +97,10 @@ bool IsStringField(int i) { } void ImportSpells(SharedDatabase *db) { - Log.Out(Logs::General, Logs::Status, "Importing Spells..."); + Log(Logs::General, Logs::Status, "Importing Spells..."); FILE *f = fopen("import/spells_us.txt", "r"); if(!f) { - Log.Out(Logs::General, Logs::Error, "Unable to open import/spells_us.txt to read, skipping."); + Log(Logs::General, Logs::Error, "Unable to open import/spells_us.txt to read, skipping."); return; } @@ -173,23 +173,23 @@ void ImportSpells(SharedDatabase *db) { spells_imported++; if(spells_imported % 1000 == 0) { - Log.Out(Logs::General, Logs::Status, "%d spells imported.", spells_imported); + Log(Logs::General, Logs::Status, "%d spells imported.", spells_imported); } } if(spells_imported % 1000 != 0) { - Log.Out(Logs::General, Logs::Status, "%d spells imported.", spells_imported); + Log(Logs::General, Logs::Status, "%d spells imported.", spells_imported); } fclose(f); } void ImportSkillCaps(SharedDatabase *db) { - Log.Out(Logs::General, Logs::Status, "Importing Skill Caps..."); + Log(Logs::General, Logs::Status, "Importing Skill Caps..."); FILE *f = fopen("import/SkillCaps.txt", "r"); if(!f) { - Log.Out(Logs::General, Logs::Error, "Unable to open import/SkillCaps.txt to read, skipping."); + Log(Logs::General, Logs::Error, "Unable to open import/SkillCaps.txt to read, skipping."); return; } @@ -220,11 +220,11 @@ void ImportSkillCaps(SharedDatabase *db) { } void ImportBaseData(SharedDatabase *db) { - Log.Out(Logs::General, Logs::Status, "Importing Base Data..."); + Log(Logs::General, Logs::Status, "Importing Base Data..."); FILE *f = fopen("import/BaseData.txt", "r"); if(!f) { - Log.Out(Logs::General, Logs::Error, "Unable to open import/BaseData.txt to read, skipping."); + Log(Logs::General, Logs::Error, "Unable to open import/BaseData.txt to read, skipping."); return; } @@ -265,11 +265,11 @@ void ImportBaseData(SharedDatabase *db) { } void ImportDBStrings(SharedDatabase *db) { - Log.Out(Logs::General, Logs::Status, "Importing DB Strings..."); + Log(Logs::General, Logs::Status, "Importing DB Strings..."); FILE *f = fopen("import/dbstr_us.txt", "r"); if(!f) { - Log.Out(Logs::General, Logs::Error, "Unable to open import/dbstr_us.txt to read, skipping."); + Log(Logs::General, Logs::Error, "Unable to open import/dbstr_us.txt to read, skipping."); return; } diff --git a/common/crash.cpp b/common/crash.cpp index 1f700f151..522d5f171 100644 --- a/common/crash.cpp +++ b/common/crash.cpp @@ -25,7 +25,7 @@ public: } } - Log.Out(Logs::General, Logs::Crash, buffer); + Log(Logs::General, Logs::Crash, buffer); StackWalker::OnOutput(szText); } }; @@ -35,67 +35,67 @@ LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo) switch(ExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_ACCESS_VIOLATION"); + Log(Logs::General, Logs::Crash, "EXCEPTION_ACCESS_VIOLATION"); break; case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED"); + Log(Logs::General, Logs::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED"); break; case EXCEPTION_BREAKPOINT: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_BREAKPOINT"); + Log(Logs::General, Logs::Crash, "EXCEPTION_BREAKPOINT"); break; case EXCEPTION_DATATYPE_MISALIGNMENT: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT"); + Log(Logs::General, Logs::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT"); break; case EXCEPTION_FLT_DENORMAL_OPERAND: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND"); + Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND"); break; case EXCEPTION_FLT_DIVIDE_BY_ZERO: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO"); + Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO"); break; case EXCEPTION_FLT_INEXACT_RESULT: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_INEXACT_RESULT"); + Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_INEXACT_RESULT"); break; case EXCEPTION_FLT_INVALID_OPERATION: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_INVALID_OPERATION"); + Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_INVALID_OPERATION"); break; case EXCEPTION_FLT_OVERFLOW: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_OVERFLOW"); + Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_OVERFLOW"); break; case EXCEPTION_FLT_STACK_CHECK: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_STACK_CHECK"); + Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_STACK_CHECK"); break; case EXCEPTION_FLT_UNDERFLOW: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_UNDERFLOW"); + Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_UNDERFLOW"); break; case EXCEPTION_ILLEGAL_INSTRUCTION: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION"); + Log(Logs::General, Logs::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION"); break; case EXCEPTION_IN_PAGE_ERROR: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_IN_PAGE_ERROR"); + Log(Logs::General, Logs::Crash, "EXCEPTION_IN_PAGE_ERROR"); break; case EXCEPTION_INT_DIVIDE_BY_ZERO: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO"); + Log(Logs::General, Logs::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO"); break; case EXCEPTION_INT_OVERFLOW: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_INT_OVERFLOW"); + Log(Logs::General, Logs::Crash, "EXCEPTION_INT_OVERFLOW"); break; case EXCEPTION_INVALID_DISPOSITION: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_INVALID_DISPOSITION"); + Log(Logs::General, Logs::Crash, "EXCEPTION_INVALID_DISPOSITION"); break; case EXCEPTION_NONCONTINUABLE_EXCEPTION: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION"); + Log(Logs::General, Logs::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION"); break; case EXCEPTION_PRIV_INSTRUCTION: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_PRIV_INSTRUCTION"); + Log(Logs::General, Logs::Crash, "EXCEPTION_PRIV_INSTRUCTION"); break; case EXCEPTION_SINGLE_STEP: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_SINGLE_STEP"); + Log(Logs::General, Logs::Crash, "EXCEPTION_SINGLE_STEP"); break; case EXCEPTION_STACK_OVERFLOW: - Log.Out(Logs::General, Logs::Crash, "EXCEPTION_STACK_OVERFLOW"); + Log(Logs::General, Logs::Crash, "EXCEPTION_STACK_OVERFLOW"); break; default: - Log.Out(Logs::General, Logs::Crash, "Unknown Exception"); + Log(Logs::General, Logs::Crash, "Unknown Exception"); break; } diff --git a/common/database.cpp b/common/database.cpp index ec4049862..62a8453d1 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -64,11 +64,11 @@ bool Database::Connect(const char* host, const char* user, const char* passwd, c uint32 errnum= 0; char errbuf[MYSQL_ERRMSG_SIZE]; if (!Open(host, user, passwd, database, port, &errnum, errbuf)) { - Log.Out(Logs::General, Logs::Error, "Failed to connect to database: Error: %s", errbuf); + Log(Logs::General, Logs::Error, "Failed to connect to database: Error: %s", errbuf); return false; } else { - Log.Out(Logs::General, Logs::Status, "Using database '%s' at %s:%d", database, host,port); + Log(Logs::General, Logs::Status, "Using database '%s' at %s:%d", database, host,port); return true; } } @@ -208,7 +208,7 @@ uint32 Database::CreateAccount(const char* name, const char* password, int16 sta else query = StringFormat("INSERT INTO account SET name='%s', status=%i, lsaccount_id=%i, time_creation=UNIX_TIMESTAMP();",name, status, lsaccount_id); - Log.Out(Logs::General, Logs::World_Server, "Account Attempting to be created: '%s' status: %i", name, status); + Log(Logs::General, Logs::World_Server, "Account Attempting to be created: '%s' status: %i", name, status); auto results = QueryDatabase(query); if (!results.Success()) { @@ -225,7 +225,7 @@ uint32 Database::CreateAccount(const char* name, const char* password, int16 sta bool Database::DeleteAccount(const char* name) { std::string query = StringFormat("DELETE FROM account WHERE name='%s';",name); - Log.Out(Logs::General, Logs::World_Server, "Account Attempting to be deleted:'%s'", name); + Log(Logs::General, Logs::World_Server, "Account Attempting to be deleted:'%s'", name); auto results = QueryDatabase(query); if (!results.Success()) { @@ -272,7 +272,7 @@ bool Database::ReserveName(uint32 account_id, char* name) { auto results = QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { if (row[0] && atoi(row[0]) > 0){ - Log.Out(Logs::General, Logs::World_Server, "Account: %i tried to request name: %s, but it is already taken...", account_id, name); + Log(Logs::General, Logs::World_Server, "Account: %i tried to request name: %s, but it is already taken...", account_id, name); return false; } } @@ -290,17 +290,17 @@ bool Database::ReserveName(uint32 account_id, char* name) { bool Database::DeleteCharacter(char *name) { uint32 charid = 0; if(!name || !strlen(name)) { - Log.Out(Logs::General, Logs::World_Server, "DeleteCharacter: request to delete without a name (empty char slot)"); + Log(Logs::General, Logs::World_Server, "DeleteCharacter: request to delete without a name (empty char slot)"); return false; } - Log.Out(Logs::General, Logs::World_Server, "Database::DeleteCharacter name : '%s'", name); + Log(Logs::General, Logs::World_Server, "Database::DeleteCharacter name : '%s'", name); /* Get id from character_data before deleting record so we can clean up the rest of the tables */ std::string query = StringFormat("SELECT `id` from `character_data` WHERE `name` = '%s'", name); auto results = QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { charid = atoi(row[0]); } if (charid <= 0){ - Log.Out(Logs::General, Logs::Error, "Database::DeleteCharacter :: Character (%s) not found, stopping delete...", name); + Log(Logs::General, Logs::Error, "Database::DeleteCharacter :: Character (%s) not found, stopping delete...", name); return false; } @@ -687,7 +687,7 @@ bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, EQEmu charid = GetCharacterID(pp->name); if(!charid) { - Log.Out(Logs::General, Logs::Error, "StoreCharacter: no character id"); + Log(Logs::General, Logs::Error, "StoreCharacter: no character id"); return false; } @@ -1500,7 +1500,7 @@ void Database::SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ism auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Error deleting character from group id: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error deleting character from group id: %s", results.ErrorMessage().c_str()); return; } @@ -1542,6 +1542,8 @@ uint32 Database::GetGroupID(const char* name){ if (results.RowCount() == 0) { + // Commenting this out until logging levels can prevent this from going to console + //Log(Logs::General, Logs::None,, "Character not in a group: %s", name); return 0; } @@ -1588,7 +1590,7 @@ void Database::SetGroupLeaderName(uint32 gid, const char* name) { result = QueryDatabase(query); if(!result.Success()) { - Log.Out(Logs::General, Logs::None, "Error in Database::SetGroupLeaderName: %s", result.ErrorMessage().c_str()); + Log(Logs::General, Logs::None, "Error in Database::SetGroupLeaderName: %s", result.ErrorMessage().c_str()); } } @@ -1785,7 +1787,7 @@ const char* Database::GetRaidLeaderName(uint32 raid_id) auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Debug, "Unable to get Raid Leader Name for Raid ID: %u", raid_id); + Log(Logs::General, Logs::Debug, "Unable to get Raid Leader Name for Raid ID: %u", raid_id); return "UNKNOWN"; } @@ -2069,7 +2071,7 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings) auto results = QueryDatabase(query); int log_category = 0; - Log.file_logs_enabled = false; + LogSys.file_logs_enabled = false; for (auto row = results.begin(); row != results.end(); ++row) { log_category = atoi(row[0]); @@ -2095,7 +2097,7 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings) If we go through this whole loop and nothing is set to any debug level, there is no point to create a file or keep anything open */ if (log_settings[log_category].log_to_file > 0){ - Log.file_logs_enabled = true; + LogSys.file_logs_enabled = true; } } } @@ -2117,7 +2119,7 @@ struct TimeOfDay_Struct Database::LoadTime(time_t &realtime) auto results = QueryDatabase(query); if (!results.Success() || results.RowCount() == 0){ - Log.Out(Logs::Detail, Logs::World_Server, "Loading EQ time of day failed. Using defaults."); + Log(Logs::Detail, Logs::World_Server, "Loading EQ time of day failed. Using defaults."); eqTime.minute = 0; eqTime.hour = 9; eqTime.day = 1; diff --git a/common/dbcore.cpp b/common/dbcore.cpp index 0fcaa7678..0468bdc77 100644 --- a/common/dbcore.cpp +++ b/common/dbcore.cpp @@ -110,8 +110,8 @@ MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, boo /* Implement Logging at the Root */ if (mysql_errno(&mysql) > 0 && strlen(query) > 0){ - if (Log.log_settings[Logs::MySQLError].is_category_enabled == 1) - Log.Out(Logs::General, Logs::MySQLError, "%i: %s \n %s", mysql_errno(&mysql), mysql_error(&mysql), query); + if (LogSys.log_settings[Logs::MySQLError].is_category_enabled == 1) + Log(Logs::General, Logs::MySQLError, "%i: %s \n %s", mysql_errno(&mysql), mysql_error(&mysql), query); } return MySQLRequestResult(nullptr, 0, 0, 0, 0, mysql_errno(&mysql),errorBuffer); @@ -127,12 +127,14 @@ MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, boo MySQLRequestResult requestResult(res, (uint32)mysql_affected_rows(&mysql), rowCount, (uint32)mysql_field_count(&mysql), (uint32)mysql_insert_id(&mysql)); - if (Log.log_settings[Logs::MySQLQuery].is_category_enabled == 1) + if (LogSys.log_settings[Logs::MySQLQuery].is_category_enabled == 1) { - if ((strncasecmp(query, "select", 6) == 0)) - Log.Out(Logs::General, Logs::MySQLQuery, "%s (%u row%s returned)", query, requestResult.RowCount(), requestResult.RowCount() == 1 ? "" : "s"); - else - Log.Out(Logs::General, Logs::MySQLQuery, "%s (%u row%s affected)", query, requestResult.RowsAffected(), requestResult.RowsAffected() == 1 ? "" : "s"); + if ((strncasecmp(query, "select", 6) == 0)) { + Log(Logs::General, Logs::MySQLQuery, "%s (%u row%s returned)", query, requestResult.RowCount(), requestResult.RowCount() == 1 ? "" : "s"); + } + else { + Log(Logs::General, Logs::MySQLQuery, "%s (%u row%s affected)", query, requestResult.RowsAffected(), requestResult.RowsAffected() == 1 ? "" : "s"); + } } return requestResult; diff --git a/common/eq_stream.cpp b/common/eq_stream.cpp index dee4e4d65..96b816b1f 100644 --- a/common/eq_stream.cpp +++ b/common/eq_stream.cpp @@ -84,14 +84,14 @@ void EQStream::init(bool resetSession) { OpMgr = nullptr; if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { - Log.Out(Logs::Detail, Logs::Netcode, _L "init Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); + Log(Logs::Detail, Logs::Netcode, _L "init Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); } } EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p) { EQRawApplicationPacket *ap=nullptr; - Log.Out(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, p->size); + Log(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, p->size); // _raw(NET__APP_CREATE_HEX, 0xFFFF, p); ap = p->MakeAppPacket(); return ap; @@ -100,7 +100,7 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p) EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf, uint32 len) { EQRawApplicationPacket *ap=nullptr; - Log.Out(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, len); + Log(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, len); ap = new EQRawApplicationPacket(buf, len); return ap; } @@ -130,7 +130,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) } if (!Session && p->opcode!=OP_SessionRequest && p->opcode!=OP_SessionResponse) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Session not initialized, packet ignored" __L); + Log(Logs::Detail, Logs::Netcode, _L "Session not initialized, packet ignored" __L); // _raw(NET__DEBUG, 0xFFFF, p); return; } @@ -141,7 +141,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) while(processed < p->size) { subpacket_length=*(p->pBuffer+processed); EQProtocolPacket *subp=MakeProtocolPacket(p->pBuffer+processed+1,subpacket_length); - Log.Out(Logs::Detail, Logs::Netcode, _L "Extracting combined packet of length %d" __L, subpacket_length); + Log(Logs::Detail, Logs::Netcode, _L "Extracting combined packet of length %d" __L, subpacket_length); // _raw(NET__NET_CREATE_HEX, 0xFFFF, subp); subp->copyInfo(p); ProcessPacket(subp); @@ -156,12 +156,12 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) while(processedsize) { EQRawApplicationPacket *ap=nullptr; if ((subpacket_length=(unsigned char)*(p->pBuffer+processed))!=0xff) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Extracting combined app packet of length %d, short len" __L, subpacket_length); + Log(Logs::Detail, Logs::Netcode, _L "Extracting combined app packet of length %d, short len" __L, subpacket_length); ap=MakeApplicationPacket(p->pBuffer+processed+1,subpacket_length); processed+=subpacket_length+1; } else { subpacket_length=ntohs(*(uint16 *)(p->pBuffer+processed+1)); - Log.Out(Logs::Detail, Logs::Netcode, _L "Extracting combined app packet of length %d, short len" __L, subpacket_length); + Log(Logs::Detail, Logs::Netcode, _L "Extracting combined app packet of length %d, short len" __L, subpacket_length); ap=MakeApplicationPacket(p->pBuffer+processed+3,subpacket_length); processed+=subpacket_length+3; } @@ -176,29 +176,29 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) case OP_Packet: { if(!p->pBuffer || (p->Size() < 4)) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_Packet that was of malformed size" __L); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_Packet that was of malformed size" __L); break; } uint16 seq=ntohs(*(uint16 *)(p->pBuffer)); SeqOrder check=CompareSequence(NextInSeq,seq); if (check == SeqFuture) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Future OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq); + Log(Logs::Detail, Logs::Netcode, _L "Future OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq); // _raw(NET__DEBUG, seq, p); PacketQueue[seq]=p->Copy(); - Log.Out(Logs::Detail, Logs::Netcode, _L "OP_Packet Queue size=%d" __L, PacketQueue.size()); + Log(Logs::Detail, Logs::Netcode, _L "OP_Packet Queue size=%d" __L, PacketQueue.size()); //SendOutOfOrderAck(seq); } else if (check == SeqPast) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Duplicate OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq); + Log(Logs::Detail, Logs::Netcode, _L "Duplicate OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq); // _raw(NET__DEBUG, seq, p); SendOutOfOrderAck(seq); //we already got this packet but it was out of order } else { // In case we did queue one before as well. EQProtocolPacket *qp=RemoveQueue(seq); if (qp) { - Log.Out(Logs::General, Logs::Netcode, "[NET_TRACE] OP_Packet: Removing older queued packet with sequence %d", seq); + Log(Logs::General, Logs::Netcode, "[NET_TRACE] OP_Packet: Removing older queued packet with sequence %d", seq); delete qp; } @@ -207,7 +207,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) // Check for an embedded OP_AppCombinded (protocol level 0x19) if (*(p->pBuffer+2)==0x00 && *(p->pBuffer+3)==0x19) { EQProtocolPacket *subp=MakeProtocolPacket(p->pBuffer+2,p->size-2); - Log.Out(Logs::Detail, Logs::Netcode, _L "seq %d, Extracting combined packet of length %d" __L, seq, subp->size); + Log(Logs::Detail, Logs::Netcode, _L "seq %d, Extracting combined packet of length %d" __L, seq, subp->size); // _raw(NET__NET_CREATE_HEX, seq, subp); subp->copyInfo(p); ProcessPacket(subp); @@ -226,29 +226,29 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) case OP_Fragment: { if(!p->pBuffer || (p->Size() < 4)) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_Fragment that was of malformed size" __L); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_Fragment that was of malformed size" __L); break; } uint16 seq=ntohs(*(uint16 *)(p->pBuffer)); SeqOrder check=CompareSequence(NextInSeq,seq); if (check == SeqFuture) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Future OP_Fragment: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq); + Log(Logs::Detail, Logs::Netcode, _L "Future OP_Fragment: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq); // _raw(NET__DEBUG, seq, p); PacketQueue[seq]=p->Copy(); - Log.Out(Logs::Detail, Logs::Netcode, _L "OP_Fragment Queue size=%d" __L, PacketQueue.size()); + Log(Logs::Detail, Logs::Netcode, _L "OP_Fragment Queue size=%d" __L, PacketQueue.size()); //SendOutOfOrderAck(seq); } else if (check == SeqPast) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Duplicate OP_Fragment: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq); + Log(Logs::Detail, Logs::Netcode, _L "Duplicate OP_Fragment: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq); // _raw(NET__DEBUG, seq, p); SendOutOfOrderAck(seq); } else { // In case we did queue one before as well. EQProtocolPacket *qp=RemoveQueue(seq); if (qp) { - Log.Out(Logs::General, Logs::Netcode, "[NET_TRACE] OP_Fragment: Removing older queued packet with sequence %d", seq); + Log(Logs::General, Logs::Netcode, "[NET_TRACE] OP_Fragment: Removing older queued packet with sequence %d", seq); delete qp; } SetNextAckToSend(seq); @@ -256,18 +256,18 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) if (oversize_buffer) { memcpy(oversize_buffer+oversize_offset,p->pBuffer+2,p->size-2); oversize_offset+=p->size-2; - Log.Out(Logs::Detail, Logs::Netcode, _L "Fragment of oversized of length %d, seq %d: now at %d/%d" __L, p->size-2, seq, oversize_offset, oversize_length); + Log(Logs::Detail, Logs::Netcode, _L "Fragment of oversized of length %d, seq %d: now at %d/%d" __L, p->size-2, seq, oversize_offset, oversize_length); if (oversize_offset==oversize_length) { if (*(p->pBuffer+2)==0x00 && *(p->pBuffer+3)==0x19) { EQProtocolPacket *subp=MakeProtocolPacket(oversize_buffer,oversize_offset); - Log.Out(Logs::Detail, Logs::Netcode, _L "seq %d, Extracting combined oversize packet of length %d" __L, seq, subp->size); + Log(Logs::Detail, Logs::Netcode, _L "seq %d, Extracting combined oversize packet of length %d" __L, seq, subp->size); //// _raw(NET__NET_CREATE_HEX, subp); subp->copyInfo(p); ProcessPacket(subp); delete subp; } else { EQRawApplicationPacket *ap=MakeApplicationPacket(oversize_buffer,oversize_offset); - Log.Out(Logs::Detail, Logs::Netcode, _L "seq %d, completed combined oversize packet of length %d" __L, seq, ap->size); + Log(Logs::Detail, Logs::Netcode, _L "seq %d, completed combined oversize packet of length %d" __L, seq, ap->size); if (ap) { ap->copyInfo(p); InboundQueuePush(ap); @@ -282,20 +282,20 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) oversize_buffer=new unsigned char[oversize_length]; memcpy(oversize_buffer,p->pBuffer+6,p->size-6); oversize_offset=p->size-6; - Log.Out(Logs::Detail, Logs::Netcode, _L "First fragment of oversized of seq %d: now at %d/%d" __L, seq, oversize_offset, oversize_length); + Log(Logs::Detail, Logs::Netcode, _L "First fragment of oversized of seq %d: now at %d/%d" __L, seq, oversize_offset, oversize_length); } } } break; case OP_KeepAlive: { NonSequencedPush(new EQProtocolPacket(p->opcode,p->pBuffer,p->size)); - Log.Out(Logs::Detail, Logs::Netcode, _L "Received and queued reply to keep alive" __L); + Log(Logs::Detail, Logs::Netcode, _L "Received and queued reply to keep alive" __L); } break; case OP_Ack: { if(!p->pBuffer || (p->Size() < 4)) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_Ack that was of malformed size" __L); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_Ack that was of malformed size" __L); break; } uint16 seq=ntohs(*(uint16 *)(p->pBuffer)); @@ -309,11 +309,11 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) case OP_SessionRequest: { if(p->Size() < sizeof(SessionRequest)) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionRequest that was of malformed size" __L); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionRequest that was of malformed size" __L); break; } if (GetState()==ESTABLISHED) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionRequest in ESTABLISHED state (%d) streamactive (%i) attempt (%i)" __L, GetState(),streamactive,sessionAttempts); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionRequest in ESTABLISHED state (%d) streamactive (%i) attempt (%i)" __L, GetState(),streamactive,sessionAttempts); // client seems to try a max of 30 times (initial+3 retries) then gives up, giving it a few more attempts just in case // streamactive means we identified the opcode for the stream, we cannot re-establish this connection @@ -331,7 +331,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) SessionRequest *Request=(SessionRequest *)p->pBuffer; Session=ntohl(Request->Session); SetMaxLen(ntohl(Request->MaxLength)); - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionRequest: session %lu, maxlen %d" __L, (unsigned long)Session, MaxLen); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionRequest: session %lu, maxlen %d" __L, (unsigned long)Session, MaxLen); SetState(ESTABLISHED); Key=0x11223344; SendSessionResponse(); @@ -340,7 +340,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) case OP_SessionResponse: { if(p->Size() < sizeof(SessionResponse)) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionResponse that was of malformed size" __L); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionResponse that was of malformed size" __L); break; } @@ -356,7 +356,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) compressed=(Response->Format&FLAG_COMPRESSED); encoded=(Response->Format&FLAG_ENCODED); - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionResponse: session %lu, maxlen %d, key %lu, compressed? %s, encoded? %s" __L, (unsigned long)Session, MaxLen, (unsigned long)Key, compressed?"yes":"no", encoded?"yes":"no"); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionResponse: session %lu, maxlen %d, key %lu, compressed? %s, encoded? %s" __L, (unsigned long)Session, MaxLen, (unsigned long)Key, compressed?"yes":"no", encoded?"yes":"no"); // Kinda kludgy, but trie for now if (StreamType==UnknownStream) { @@ -379,17 +379,17 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) EQStreamState state = GetState(); if(state == ESTABLISHED) { //client initiated disconnect? - Log.Out(Logs::Detail, Logs::Netcode, _L "Received unsolicited OP_SessionDisconnect. Treating like a client-initiated disconnect." __L); + Log(Logs::Detail, Logs::Netcode, _L "Received unsolicited OP_SessionDisconnect. Treating like a client-initiated disconnect." __L); _SendDisconnect(); SetState(CLOSED); } else if(state == CLOSING) { //we were waiting for this anyways, ignore pending messages, send the reply and be closed. - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionDisconnect when we have a pending close, they beat us to it. Were happy though." __L); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionDisconnect when we have a pending close, they beat us to it. Were happy though." __L); _SendDisconnect(); SetState(CLOSED); } else { //we are expecting this (or have already gotten it, but dont care either way) - Log.Out(Logs::Detail, Logs::Netcode, _L "Received expected OP_SessionDisconnect. Moving to closed state." __L); + Log(Logs::Detail, Logs::Netcode, _L "Received expected OP_SessionDisconnect. Moving to closed state." __L); SetState(CLOSED); } } @@ -397,24 +397,24 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) case OP_OutOfOrderAck: { if(!p->pBuffer || (p->Size() < 4)) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfOrderAck that was of malformed size" __L); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfOrderAck that was of malformed size" __L); break; } uint16 seq=ntohs(*(uint16 *)(p->pBuffer)); MOutboundQueue.lock(); if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-OOA Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); + Log(Logs::Detail, Logs::Netcode, _L "Pre-OOA Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); } //if the packet they got out of order is between our last acked packet and the last sent packet, then its valid. if (CompareSequence(SequencedBase,seq) != SeqPast && CompareSequence(NextOutSeq,seq) == SeqPast) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfOrderAck for sequence %d, starting retransmit at the start of our unacked buffer (seq %d, was %d)." __L, + Log(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfOrderAck for sequence %d, starting retransmit at the start of our unacked buffer (seq %d, was %d)." __L, seq, SequencedBase, SequencedBase+SequencedQueue.size()); uint16 sqsize = SequencedQueue.size(); uint16 index = seq - SequencedBase; - Log.Out(Logs::Detail, Logs::Netcode, _L "OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize); + Log(Logs::Detail, Logs::Netcode, _L "OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize); if (index < sqsize) { SequencedQueue[index]->acked = true; // flag packets for a resend @@ -423,7 +423,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) for (auto sitr = SequencedQueue.begin(); sitr != SequencedQueue.end() && count < index; ++sitr, ++count) { if (!(*sitr)->acked && (*sitr)->sent_time > 0 && (((*sitr)->sent_time + timeout) < Timer::GetCurrentTime())) { (*sitr)->sent_time = 0; - Log.Out(Logs::Detail, Logs::Netcode, _L "OP_OutOfOrderAck Flagging packet %d for retransmission" __L, SequencedBase + count); + Log(Logs::Detail, Logs::Netcode, _L "OP_OutOfOrderAck Flagging packet %d for retransmission" __L, SequencedBase + count); } } } @@ -432,11 +432,11 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) retransmittimer = Timer::GetCurrentTime(); } } else { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfOrderAck for out-of-window %d. Window (%d->%d)." __L, seq, SequencedBase, NextOutSeq); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfOrderAck for out-of-window %d. Window (%d->%d)." __L, seq, SequencedBase, NextOutSeq); } if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Post-OOA Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); + Log(Logs::Detail, Logs::Netcode, _L "Post-OOA Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); } MOutboundQueue.unlock(); @@ -445,11 +445,11 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) case OP_SessionStatRequest: { if(p->Size() < sizeof(ClientSessionStats)) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionStatRequest that was of malformed size" __L); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionStatRequest that was of malformed size" __L); break; } ClientSessionStats *ClientStats=(ClientSessionStats *)p->pBuffer; - Log.Out(Logs::Detail, Logs::Netcode, _L "Received Stats: %lu packets received, %lu packets sent, Deltas: local %lu, (%lu <- %lu -> %lu) remote %lu" __L, + Log(Logs::Detail, Logs::Netcode, _L "Received Stats: %lu packets received, %lu packets sent, Deltas: local %lu, (%lu <- %lu -> %lu) remote %lu" __L, (unsigned long)ntohl(ClientStats->packets_received), (unsigned long)ntohl(ClientStats->packets_sent), (unsigned long)ntohl(ClientStats->last_local_delta), (unsigned long)ntohl(ClientStats->low_delta), (unsigned long)ntohl(ClientStats->average_delta), (unsigned long)ntohl(ClientStats->high_delta), (unsigned long)ntohl(ClientStats->last_remote_delta)); @@ -468,7 +468,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) retransmittimeout += 300; if(retransmittimeout > RETRANSMIT_TIMEOUT_MAX) retransmittimeout = RETRANSMIT_TIMEOUT_MAX; - Log.Out(Logs::Detail, Logs::Netcode, _L "Retransmit timeout recalculated to %dms" __L, retransmittimeout); + Log(Logs::Detail, Logs::Netcode, _L "Retransmit timeout recalculated to %dms" __L, retransmittimeout); } } @@ -485,11 +485,11 @@ void EQStream::ProcessPacket(EQProtocolPacket *p) } break; case OP_SessionStatResponse: { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionStatResponse. Ignoring." __L); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_SessionStatResponse. Ignoring." __L); } break; case OP_OutOfSession: { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfSession. Ignoring." __L); + Log(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfSession. Ignoring." __L); } break; default: @@ -520,7 +520,7 @@ void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req) return; if(OpMgr == nullptr || *OpMgr == nullptr) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Packet enqueued into a stream with no opcode manager, dropping." __L); + Log(Logs::Detail, Logs::Netcode, _L "Packet enqueued into a stream with no opcode manager, dropping." __L); delete pack; return; } @@ -545,32 +545,32 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p) uint32 chunksize, used; uint32 length; - if (Log.log_settings[Logs::Server_Client_Packet].is_category_enabled == 1){ + if (LogSys.log_settings[Logs::Server_Client_Packet].is_category_enabled == 1){ if (p->GetOpcode() != OP_SpecialMesg){ - Log.Out(Logs::General, Logs::Server_Client_Packet, "[%s - 0x%04x] [Size: %u]", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size()); + Log(Logs::General, Logs::Server_Client_Packet, "[%s - 0x%04x] [Size: %u]", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size()); } } - if (Log.log_settings[Logs::Server_Client_Packet_With_Dump].is_category_enabled == 1){ + if (LogSys.log_settings[Logs::Server_Client_Packet_With_Dump].is_category_enabled == 1){ if (p->GetOpcode() != OP_SpecialMesg){ - Log.Out(Logs::General, Logs::Server_Client_Packet_With_Dump, "[%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size(), DumpPacketToString(p).c_str()); + Log(Logs::General, Logs::Server_Client_Packet_With_Dump, "[%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(p->GetOpcode()), p->GetOpcode(), p->Size(), DumpPacketToString(p).c_str()); } } // Convert the EQApplicationPacket to 1 or more EQProtocolPackets if (p->size>(MaxLen-8)) { // proto-op(2), seq(2), app-op(2) ... data ... crc(2) - Log.Out(Logs::Detail, Logs::Netcode, _L "Making oversized packet, len %d" __L, p->Size()); + Log(Logs::Detail, Logs::Netcode, _L "Making oversized packet, len %d" __L, p->Size()); auto tmpbuff = new unsigned char[p->size + 3]; length=p->serialize(opcode, tmpbuff); if (length != p->Size()) - Log.Out(Logs::Detail, Logs::Netcode, _L "Packet adjustment, len %d to %d" __L, p->Size(), length); + Log(Logs::Detail, Logs::Netcode, _L "Packet adjustment, len %d to %d" __L, p->Size(), length); auto out = new EQProtocolPacket(OP_Fragment, nullptr, MaxLen - 4); *(uint32 *)(out->pBuffer+2)=htonl(length); used=MaxLen-10; memcpy(out->pBuffer+6,tmpbuff,used); - Log.Out(Logs::Detail, Logs::Netcode, _L "First fragment: used %d/%d. Payload size %d in the packet" __L, used, length, p->size); + Log(Logs::Detail, Logs::Netcode, _L "First fragment: used %d/%d. Payload size %d in the packet" __L, used, length, p->size); SequencedPush(out); @@ -581,7 +581,7 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p) out->size=chunksize+2; SequencedPush(out); used+=chunksize; - Log.Out(Logs::Detail, Logs::Netcode, _L "Subsequent fragment: len %d, used %d/%d." __L, chunksize, used, length); + Log(Logs::Detail, Logs::Netcode, _L "Subsequent fragment: len %d, used %d/%d." __L, chunksize, used, length); } delete p; delete[] tmpbuff; @@ -602,18 +602,18 @@ void EQStream::SequencedPush(EQProtocolPacket *p) { MOutboundQueue.lock(); if (uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, + Log(Logs::Detail, Logs::Netcode, _L "Pre-Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); } - Log.Out(Logs::Detail, Logs::Netcode, _L "Pushing sequenced packet %d of length %d. Base Seq is %d." __L, + Log(Logs::Detail, Logs::Netcode, _L "Pushing sequenced packet %d of length %d. Base Seq is %d." __L, NextOutSeq, p->size, SequencedBase); *(uint16 *)(p->pBuffer) = htons(NextOutSeq); SequencedQueue.push_back(p); NextOutSeq++; if (uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, + Log(Logs::Detail, Logs::Netcode, _L "Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); } @@ -623,7 +623,7 @@ void EQStream::SequencedPush(EQProtocolPacket *p) void EQStream::NonSequencedPush(EQProtocolPacket *p) { MOutboundQueue.lock(); - Log.Out(Logs::Detail, Logs::Netcode, _L "Pushing non-sequenced packet of length %d" __L, p->size); + Log(Logs::Detail, Logs::Netcode, _L "Pushing non-sequenced packet of length %d" __L, p->size); NonSequencedQueue.push(p); MOutboundQueue.unlock(); } @@ -631,14 +631,14 @@ void EQStream::NonSequencedPush(EQProtocolPacket *p) void EQStream::SendAck(uint16 seq) { uint16 Seq=htons(seq); - Log.Out(Logs::Detail, Logs::Netcode, _L "Sending ack with sequence %d" __L, seq); + Log(Logs::Detail, Logs::Netcode, _L "Sending ack with sequence %d" __L, seq); SetLastAckSent(seq); NonSequencedPush(new EQProtocolPacket(OP_Ack,(unsigned char *)&Seq,sizeof(uint16))); } void EQStream::SendOutOfOrderAck(uint16 seq) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Sending out of order ack with sequence %d" __L, seq); + Log(Logs::Detail, Logs::Netcode, _L "Sending out of order ack with sequence %d" __L, seq); uint16 Seq=htons(seq); NonSequencedPush(new EQProtocolPacket(OP_OutOfOrderAck,(unsigned char *)&Seq,sizeof(uint16))); } @@ -688,24 +688,24 @@ void EQStream::Write(int eq_fd) // If we don't have a packet to try to combine into, use this one as the base // And remove it form the queue p = NonSequencedQueue.front(); - Log.Out(Logs::Detail, Logs::Netcode, _L "Starting combined packet with non-seq packet of len %d" __L, p->size); + Log(Logs::Detail, Logs::Netcode, _L "Starting combined packet with non-seq packet of len %d" __L, p->size); NonSequencedQueue.pop(); } else if (!p->combine(NonSequencedQueue.front())) { // Trying to combine this packet with the base didn't work (too big maybe) // So just send the base packet (we'll try this packet again later) - Log.Out(Logs::Detail, Logs::Netcode, _L "Combined packet full at len %d, next non-seq packet is len %d" __L, p->size, (NonSequencedQueue.front())->size); + Log(Logs::Detail, Logs::Netcode, _L "Combined packet full at len %d, next non-seq packet is len %d" __L, p->size, (NonSequencedQueue.front())->size); ReadyToSend.push(p); BytesWritten+=p->size; p=nullptr; if (BytesWritten > threshold) { // Sent enough this round, lets stop to be fair - Log.Out(Logs::Detail, Logs::Netcode, _L "Exceeded write threshold in nonseq (%d > %d)" __L, BytesWritten, threshold); + Log(Logs::Detail, Logs::Netcode, _L "Exceeded write threshold in nonseq (%d > %d)" __L, BytesWritten, threshold); break; } } else { // Combine worked, so just remove this packet and it's spot in the queue - Log.Out(Logs::Detail, Logs::Netcode, _L "Combined non-seq packet of len %d, yeilding %d combined." __L, (NonSequencedQueue.front())->size, p->size); + Log(Logs::Detail, Logs::Netcode, _L "Combined non-seq packet of len %d, yeilding %d combined." __L, (NonSequencedQueue.front())->size, p->size); delete NonSequencedQueue.front(); NonSequencedQueue.pop(); } @@ -718,7 +718,7 @@ void EQStream::Write(int eq_fd) uint16 seq_send = SequencedBase + count; //just for logging... if(SequencedQueue.empty()) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Tried to write a packet with an empty queue (%d is past next out %d)" __L, seq_send, NextOutSeq); + Log(Logs::Detail, Logs::Netcode, _L "Tried to write a packet with an empty queue (%d is past next out %d)" __L, seq_send, NextOutSeq); SeqEmpty=true; continue; } @@ -728,35 +728,35 @@ void EQStream::Write(int eq_fd) ++sitr; ++count; if (p) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Final combined packet not full, len %d" __L, p->size); + Log(Logs::Detail, Logs::Netcode, _L "Final combined packet not full, len %d" __L, p->size); ReadyToSend.push(p); BytesWritten += p->size; p = nullptr; } - Log.Out(Logs::Detail, Logs::Netcode, _L "Not retransmitting seq packet %d because already marked as acked" __L, seq_send); + Log(Logs::Detail, Logs::Netcode, _L "Not retransmitting seq packet %d because already marked as acked" __L, seq_send); } else if (!p) { // If we don't have a packet to try to combine into, use this one as the base // Copy it first as it will still live until it is acked p=(*sitr)->Copy(); - Log.Out(Logs::Detail, Logs::Netcode, _L "Starting combined packet with seq packet %d of len %d" __L, seq_send, p->size); + Log(Logs::Detail, Logs::Netcode, _L "Starting combined packet with seq packet %d of len %d" __L, seq_send, p->size); (*sitr)->sent_time = Timer::GetCurrentTime(); ++sitr; ++count; } else if (!p->combine(*sitr)) { // Trying to combine this packet with the base didn't work (too big maybe) // So just send the base packet (we'll try this packet again later) - Log.Out(Logs::Detail, Logs::Netcode, _L "Combined packet full at len %d, next seq packet %d is len %d" __L, p->size, seq_send + 1, (*sitr)->size); + Log(Logs::Detail, Logs::Netcode, _L "Combined packet full at len %d, next seq packet %d is len %d" __L, p->size, seq_send + 1, (*sitr)->size); ReadyToSend.push(p); BytesWritten+=p->size; p=nullptr; if ((*sitr)->opcode != OP_Fragment && BytesWritten > threshold) { // Sent enough this round, lets stop to be fair - Log.Out(Logs::Detail, Logs::Netcode, _L "Exceeded write threshold in seq (%d > %d)" __L, BytesWritten, threshold); + Log(Logs::Detail, Logs::Netcode, _L "Exceeded write threshold in seq (%d > %d)" __L, BytesWritten, threshold); break; } } else { // Combine worked - Log.Out(Logs::Detail, Logs::Netcode, _L "Combined seq packet %d of len %d, yeilding %d combined." __L, seq_send, (*sitr)->size, p->size); + Log(Logs::Detail, Logs::Netcode, _L "Combined seq packet %d of len %d, yeilding %d combined." __L, seq_send, (*sitr)->size, p->size); (*sitr)->sent_time = Timer::GetCurrentTime(); ++sitr; ++count; @@ -766,7 +766,7 @@ void EQStream::Write(int eq_fd) ++sitr; ++count; if (p) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Final combined packet not full, len %d" __L, p->size); + Log(Logs::Detail, Logs::Netcode, _L "Final combined packet not full, len %d" __L, p->size); ReadyToSend.push(p); BytesWritten += p->size; p = nullptr; @@ -776,25 +776,25 @@ void EQStream::Write(int eq_fd) // Copy it first as it will still live until it is acked p=(*sitr)->Copy(); (*sitr)->sent_time = Timer::GetCurrentTime(); - Log.Out(Logs::Detail, Logs::Netcode, _L "Starting combined packet with seq packet %d of len %d" __L, seq_send, p->size); + Log(Logs::Detail, Logs::Netcode, _L "Starting combined packet with seq packet %d of len %d" __L, seq_send, p->size); ++sitr; ++count; } else if (!p->combine(*sitr)) { // Trying to combine this packet with the base didn't work (too big maybe) // So just send the base packet (we'll try this packet again later) - Log.Out(Logs::Detail, Logs::Netcode, _L "Combined packet full at len %d, next seq packet %d is len %d" __L, p->size, seq_send, (*sitr)->size); + Log(Logs::Detail, Logs::Netcode, _L "Combined packet full at len %d, next seq packet %d is len %d" __L, p->size, seq_send, (*sitr)->size); ReadyToSend.push(p); BytesWritten+=p->size; p=nullptr; if (BytesWritten > threshold) { // Sent enough this round, lets stop to be fair - Log.Out(Logs::Detail, Logs::Netcode, _L "Exceeded write threshold in seq (%d > %d)" __L, BytesWritten, threshold); + Log(Logs::Detail, Logs::Netcode, _L "Exceeded write threshold in seq (%d > %d)" __L, BytesWritten, threshold); break; } } else { // Combine worked - Log.Out(Logs::Detail, Logs::Netcode, _L "Combined seq packet %d of len %d, yielding %d combined." __L, seq_send, (*sitr)->size, p->size); + Log(Logs::Detail, Logs::Netcode, _L "Combined seq packet %d of len %d, yielding %d combined." __L, seq_send, (*sitr)->size, p->size); (*sitr)->sent_time = Timer::GetCurrentTime(); ++sitr; ++count; @@ -802,7 +802,7 @@ void EQStream::Write(int eq_fd) } if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Post send Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); + Log(Logs::Detail, Logs::Netcode, _L "Post send Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq); } } else { // No more sequenced packets @@ -814,7 +814,7 @@ void EQStream::Write(int eq_fd) // We have a packet still, must have run out of both seq and non-seq, so send it if (p) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Final combined packet not full, len %d" __L, p->size); + Log(Logs::Detail, Logs::Netcode, _L "Final combined packet not full, len %d" __L, p->size); ReadyToSend.push(p); BytesWritten+=p->size; } @@ -831,7 +831,7 @@ void EQStream::Write(int eq_fd) if(SeqEmpty && NonSeqEmpty) { //no more data to send if(CheckState(CLOSING)) { - Log.Out(Logs::Detail, Logs::Netcode, _L "All outgoing data flushed, closing stream." __L ); + Log(Logs::Detail, Logs::Netcode, _L "All outgoing data flushed, closing stream." __L ); //we are waiting for the queues to empty, now we can do our disconnect. //this packet will not actually go out until the next call to Write(). _SendDisconnect(); @@ -896,7 +896,7 @@ void EQStream::SendSessionResponse() out->size=sizeof(SessionResponse); - Log.Out(Logs::Detail, Logs::Netcode, _L "Sending OP_SessionResponse: session %lu, maxlen=%d, key=0x%x, compressed? %s, encoded? %s" __L, + Log(Logs::Detail, Logs::Netcode, _L "Sending OP_SessionResponse: session %lu, maxlen=%d, key=0x%x, compressed? %s, encoded? %s" __L, (unsigned long)Session, MaxLen, Key, compressed?"yes":"no", encoded?"yes":"no"); NonSequencedPush(out); @@ -910,7 +910,7 @@ void EQStream::SendSessionRequest() Request->Session=htonl(time(nullptr)); Request->MaxLength=htonl(512); - Log.Out(Logs::Detail, Logs::Netcode, _L "Sending OP_SessionRequest: session %lu, maxlen=%d" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength)); + Log(Logs::Detail, Logs::Netcode, _L "Sending OP_SessionRequest: session %lu, maxlen=%d" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength)); NonSequencedPush(out); } @@ -924,7 +924,7 @@ void EQStream::_SendDisconnect() *(uint32 *)out->pBuffer=htonl(Session); NonSequencedPush(out); - Log.Out(Logs::Detail, Logs::Netcode, _L "Sending OP_SessionDisconnect: session %lu" __L, (unsigned long)Session); + Log(Logs::Detail, Logs::Netcode, _L "Sending OP_SessionDisconnect: session %lu" __L, (unsigned long)Session); } void EQStream::InboundQueuePush(EQRawApplicationPacket *p) @@ -950,7 +950,7 @@ EQRawApplicationPacket *p=nullptr; if (OpMgr != nullptr && *OpMgr != nullptr) { EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode); if (emu_op == OP_Unknown) { - // Log.Out(Logs::General, Logs::Client_Server_Packet_Unhandled, "Unknown :: [%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(p->GetOpcode()), p->opcode, p->Size(), DumpPacketToString(p).c_str()); + // Log(Logs::General, Logs::Client_Server_Packet_Unhandled, "Unknown :: [%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(p->GetOpcode()), p->opcode, p->Size(), DumpPacketToString(p).c_str()); } p->SetOpcode(emu_op); } @@ -976,7 +976,7 @@ EQRawApplicationPacket *p=nullptr; if(OpMgr != nullptr && *OpMgr != nullptr) { EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode); if(emu_op == OP_Unknown) { - Log.Out(Logs::General, Logs::Netcode, "Unable to convert EQ opcode 0x%.4x to an Application opcode.", p->opcode); + Log(Logs::General, Logs::Netcode, "Unable to convert EQ opcode 0x%.4x to an Application opcode.", p->opcode); } p->SetOpcode(emu_op); @@ -1004,7 +1004,7 @@ void EQStream::InboundQueueClear() { EQApplicationPacket *p=nullptr; - Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing inbound queue" __L); + Log(Logs::Detail, Logs::Netcode, _L "Clearing inbound queue" __L); MInboundQueue.lock(); if (!InboundQueue.empty()) { @@ -1047,7 +1047,7 @@ void EQStream::OutboundQueueClear() { EQProtocolPacket *p=nullptr; - Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing outbound queue" __L); + Log(Logs::Detail, Logs::Netcode, _L "Clearing outbound queue" __L); MOutboundQueue.lock(); while(!NonSequencedQueue.empty()) { @@ -1069,7 +1069,7 @@ void EQStream::PacketQueueClear() { EQProtocolPacket *p=nullptr; - Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing future packet queue" __L); + Log(Logs::Detail, Logs::Netcode, _L "Clearing future packet queue" __L); if(!PacketQueue.empty()) { std::map::iterator itr; @@ -1101,7 +1101,7 @@ void EQStream::Process(const unsigned char *buffer, const uint32 length) delete p; ProcessQueue(); } else { - Log.Out(Logs::Detail, Logs::Netcode, _L "Incoming packet failed checksum" __L); + Log(Logs::Detail, Logs::Netcode, _L "Incoming packet failed checksum" __L); } } @@ -1132,23 +1132,23 @@ std::deque::iterator itr, tmp; SeqOrder ord = CompareSequence(SequencedBase, seq); if(ord == SeqInOrder) { //they are not acking anything new... - Log.Out(Logs::Detail, Logs::Netcode, _L "Received an ack with no window advancement (seq %d)." __L, seq); + Log(Logs::Detail, Logs::Netcode, _L "Received an ack with no window advancement (seq %d)." __L, seq); } else if(ord == SeqPast) { //they are nacking blocks going back before our buffer, wtf? - Log.Out(Logs::Detail, Logs::Netcode, _L "Received an ack with backward window advancement (they gave %d, our window starts at %d). This is bad." __L, seq, SequencedBase); + Log(Logs::Detail, Logs::Netcode, _L "Received an ack with backward window advancement (they gave %d, our window starts at %d). This is bad." __L, seq, SequencedBase); } else { - Log.Out(Logs::Detail, Logs::Netcode, _L "Received an ack up through sequence %d. Our base is %d." __L, seq, SequencedBase); + Log(Logs::Detail, Logs::Netcode, _L "Received an ack up through sequence %d. Our base is %d." __L, seq, SequencedBase); //this is a good ack, we get to ack some blocks. seq++; //we stop at the block right after their ack, counting on the wrap of both numbers. while(SequencedBase != seq) { if(SequencedQueue.empty()) { - Log.Out(Logs::Detail, Logs::Netcode, _L "OUT OF PACKETS acked packet with sequence %lu. Next send is %d before this." __L, (unsigned long)SequencedBase, SequencedQueue.size()); + Log(Logs::Detail, Logs::Netcode, _L "OUT OF PACKETS acked packet with sequence %lu. Next send is %d before this." __L, (unsigned long)SequencedBase, SequencedQueue.size()); SequencedBase = NextOutSeq; break; } - Log.Out(Logs::Detail, Logs::Netcode, _L "Removing acked packet with sequence %lu." __L, (unsigned long)SequencedBase); + Log(Logs::Detail, Logs::Netcode, _L "Removing acked packet with sequence %lu." __L, (unsigned long)SequencedBase); //clean out the acked packet delete SequencedQueue.front(); SequencedQueue.pop_front(); @@ -1156,7 +1156,7 @@ std::deque::iterator itr, tmp; SequencedBase++; } if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Post-Ack on %d Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, seq, SequencedBase, SequencedQueue.size(), NextOutSeq); + Log(Logs::Detail, Logs::Netcode, _L "Post-Ack on %d Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, seq, SequencedBase, SequencedQueue.size(), NextOutSeq); } } @@ -1166,7 +1166,7 @@ std::deque::iterator itr, tmp; void EQStream::SetNextAckToSend(uint32 seq) { MAcks.lock(); - Log.Out(Logs::Detail, Logs::Netcode, _L "Set Next Ack To Send to %lu" __L, (unsigned long)seq); + Log(Logs::Detail, Logs::Netcode, _L "Set Next Ack To Send to %lu" __L, (unsigned long)seq); NextAckToSend=seq; MAcks.unlock(); } @@ -1174,7 +1174,7 @@ void EQStream::SetNextAckToSend(uint32 seq) void EQStream::SetLastAckSent(uint32 seq) { MAcks.lock(); - Log.Out(Logs::Detail, Logs::Netcode, _L "Set Last Ack Sent to %lu" __L, (unsigned long)seq); + Log(Logs::Detail, Logs::Netcode, _L "Set Last Ack Sent to %lu" __L, (unsigned long)seq); LastAckSent=seq; MAcks.unlock(); } @@ -1187,10 +1187,10 @@ void EQStream::ProcessQueue() EQProtocolPacket *qp=nullptr; while((qp=RemoveQueue(NextInSeq))!=nullptr) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Processing Queued Packet: Seq=%d" __L, NextInSeq); + Log(Logs::Detail, Logs::Netcode, _L "Processing Queued Packet: Seq=%d" __L, NextInSeq); ProcessPacket(qp); delete qp; - Log.Out(Logs::Detail, Logs::Netcode, _L "OP_Packet Queue size=%d" __L, PacketQueue.size()); + Log(Logs::Detail, Logs::Netcode, _L "OP_Packet Queue size=%d" __L, PacketQueue.size()); } } @@ -1201,21 +1201,21 @@ EQProtocolPacket *qp=nullptr; if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) { qp=itr->second; PacketQueue.erase(itr); - Log.Out(Logs::Detail, Logs::Netcode, _L "OP_Packet Queue size=%d" __L, PacketQueue.size()); + Log(Logs::Detail, Logs::Netcode, _L "OP_Packet Queue size=%d" __L, PacketQueue.size()); } return qp; } void EQStream::SetStreamType(EQStreamType type) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Changing stream type from %s to %s" __L, StreamTypeString(StreamType), StreamTypeString(type)); + Log(Logs::Detail, Logs::Netcode, _L "Changing stream type from %s to %s" __L, StreamTypeString(StreamType), StreamTypeString(type)); StreamType=type; switch (StreamType) { case LoginStream: app_opcode_size=1; compressed=false; encoded=false; - Log.Out(Logs::Detail, Logs::Netcode, _L "Login stream has app opcode size %d, is not compressed or encoded." __L, app_opcode_size); + Log(Logs::Detail, Logs::Netcode, _L "Login stream has app opcode size %d, is not compressed or encoded." __L, app_opcode_size); break; case ChatOrMailStream: case ChatStream: @@ -1223,7 +1223,7 @@ void EQStream::SetStreamType(EQStreamType type) app_opcode_size=1; compressed=false; encoded=true; - Log.Out(Logs::Detail, Logs::Netcode, _L "Chat/Mail stream has app opcode size %d, is not compressed, and is encoded." __L, app_opcode_size); + Log(Logs::Detail, Logs::Netcode, _L "Chat/Mail stream has app opcode size %d, is not compressed, and is encoded." __L, app_opcode_size); break; case ZoneStream: case WorldStream: @@ -1231,7 +1231,7 @@ void EQStream::SetStreamType(EQStreamType type) app_opcode_size=2; compressed=true; encoded=false; - Log.Out(Logs::Detail, Logs::Netcode, _L "World/Zone stream has app opcode size %d, is compressed, and is not encoded." __L, app_opcode_size); + Log(Logs::Detail, Logs::Netcode, _L "World/Zone stream has app opcode size %d, is compressed, and is not encoded." __L, app_opcode_size); break; } } @@ -1281,7 +1281,7 @@ EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq) void EQStream::SetState(EQStreamState state) { MState.lock(); - Log.Out(Logs::Detail, Logs::Netcode, _L "Changing state from %d to %d" __L, State, state); + Log(Logs::Detail, Logs::Netcode, _L "Changing state from %d to %d" __L, State, state); State=state; MState.unlock(); } @@ -1293,29 +1293,29 @@ void EQStream::CheckTimeout(uint32 now, uint32 timeout) { EQStreamState orig_state = GetState(); if (orig_state == CLOSING && !outgoing_data) { - Log.Out(Logs::Detail, Logs::Netcode, _L "Out of data in closing state, disconnecting." __L); + Log(Logs::Detail, Logs::Netcode, _L "Out of data in closing state, disconnecting." __L); _SendDisconnect(); SetState(DISCONNECTING); } else if (LastPacket && (now-LastPacket) > timeout) { switch(orig_state) { case CLOSING: //if we time out in the closing state, they are not acking us, just give up - Log.Out(Logs::Detail, Logs::Netcode, _L "Timeout expired in closing state. Moving to closed state." __L); + Log(Logs::Detail, Logs::Netcode, _L "Timeout expired in closing state. Moving to closed state." __L); _SendDisconnect(); SetState(CLOSED); break; case DISCONNECTING: //we timed out waiting for them to send us the disconnect reply, just give up. - Log.Out(Logs::Detail, Logs::Netcode, _L "Timeout expired in disconnecting state. Moving to closed state." __L); + Log(Logs::Detail, Logs::Netcode, _L "Timeout expired in disconnecting state. Moving to closed state." __L); SetState(CLOSED); break; case CLOSED: - Log.Out(Logs::Detail, Logs::Netcode, _L "Timeout expired in closed state??" __L); + Log(Logs::Detail, Logs::Netcode, _L "Timeout expired in closed state??" __L); break; case ESTABLISHED: //we timed out during normal operation. Try to be nice about it. //we will almost certainly time out again waiting for the disconnect reply, but oh well. - Log.Out(Logs::Detail, Logs::Netcode, _L "Timeout expired in established state. Closing connection." __L); + Log(Logs::Detail, Logs::Netcode, _L "Timeout expired in established state. Closing connection." __L); _SendDisconnect(); SetState(DISCONNECTING); break; @@ -1342,7 +1342,7 @@ void EQStream::Decay() for (auto sitr = SequencedQueue.begin(); sitr != SequencedQueue.end(); ++sitr, count++) { if (!(*sitr)->acked && (*sitr)->sent_time > 0 && ((*sitr)->sent_time + retransmittimeout) < Timer::GetCurrentTime()) { (*sitr)->sent_time = 0; - Log.Out(Logs::Detail, Logs::Netcode, _L "Timeout exceeded for seq %d. Flagging packet for retransmission" __L, SequencedBase + count); + Log(Logs::Detail, Logs::Netcode, _L "Timeout exceeded for seq %d. Flagging packet for retransmission" __L, SequencedBase + count); } } MOutboundQueue.unlock(); @@ -1359,11 +1359,11 @@ void EQStream::AdjustRates(uint32 average_delta) DecayRate=DECAYBASE/average_delta; if (BytesWritten > RateThreshold) BytesWritten = RateThreshold + DecayRate; - Log.Out(Logs::Detail, Logs::Netcode, _L "Adjusting data rate to thresh %d, decay %d based on avg delta %d" __L, + Log(Logs::Detail, Logs::Netcode, _L "Adjusting data rate to thresh %d, decay %d based on avg delta %d" __L, RateThreshold, DecayRate, average_delta); MRate.unlock(); } else { - Log.Out(Logs::Detail, Logs::Netcode, _L "Not adjusting data rate because avg delta over max (%d > %d)" __L, + Log(Logs::Detail, Logs::Netcode, _L "Not adjusting data rate because avg delta over max (%d > %d)" __L, average_delta, AVERAGE_DELTA_MAX); AverageDelta = AVERAGE_DELTA_MAX; } @@ -1374,7 +1374,7 @@ void EQStream::AdjustRates(uint32 average_delta) BytesWritten = 0; RateThreshold=RATEBASE/average_delta; DecayRate=DECAYBASE/average_delta; - Log.Out(Logs::Detail, Logs::Netcode, _L "Adjusting data rate to thresh %d, decay %d based on avg delta %d" __L, + Log(Logs::Detail, Logs::Netcode, _L "Adjusting data rate to thresh %d, decay %d based on avg delta %d" __L, RateThreshold, DecayRate, average_delta); MRate.unlock(); } @@ -1384,12 +1384,12 @@ void EQStream::AdjustRates(uint32 average_delta) void EQStream::Close() { if(HasOutgoingData()) { //there is pending data, wait for it to go out. - Log.Out(Logs::Detail, Logs::Netcode, _L "Stream requested to Close(), but there is pending data, waiting for it." __L); + Log(Logs::Detail, Logs::Netcode, _L "Stream requested to Close(), but there is pending data, waiting for it." __L); SetState(CLOSING); } else { //otherwise, we are done, we can drop immediately. _SendDisconnect(); - Log.Out(Logs::Detail, Logs::Netcode, _L "Stream closing immediate due to Close()" __L); + Log(Logs::Detail, Logs::Netcode, _L "Stream closing immediate due to Close()" __L); SetState(DISCONNECTING); } } @@ -1417,19 +1417,19 @@ EQStream::MatchState EQStream::CheckSignature(const Signature *sig) { } else if(p->opcode == sig->first_eq_opcode) { //opcode matches, check length.. if(p->size == sig->first_length) { - Log.Out(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: First opcode matched 0x%x and length matched %d", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), sig->first_eq_opcode, p->size); + Log(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: First opcode matched 0x%x and length matched %d", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), sig->first_eq_opcode, p->size); res = MatchSuccessful; } else if(sig->first_length == 0) { - Log.Out(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: First opcode matched 0x%x and length (%d) is ignored", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), sig->first_eq_opcode, p->size); + Log(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: First opcode matched 0x%x and length (%d) is ignored", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), sig->first_eq_opcode, p->size); res = MatchSuccessful; } else { //opcode matched but length did not. - Log.Out(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: First opcode matched 0x%x, but length %d did not match expected %d", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), sig->first_eq_opcode, p->size, sig->first_length); + Log(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: First opcode matched 0x%x, but length %d did not match expected %d", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), sig->first_eq_opcode, p->size, sig->first_length); res = MatchFailed; } } else { //first opcode did not match.. - Log.Out(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: First opcode 0x%x did not match expected 0x%x", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), p->opcode, sig->first_eq_opcode); + Log(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: First opcode 0x%x did not match expected 0x%x", long2ip(GetRemoteIP()).c_str(), ntohs(GetRemotePort()), p->opcode, sig->first_eq_opcode); res = MatchFailed; } } diff --git a/common/eq_stream_factory.cpp b/common/eq_stream_factory.cpp index d58995623..429f258f6 100644 --- a/common/eq_stream_factory.cpp +++ b/common/eq_stream_factory.cpp @@ -23,18 +23,10 @@ ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs) { -EQStreamFactory *fs=(EQStreamFactory *)eqfs; - -#ifndef WIN32 - Log.Out(Logs::Detail, Logs::None, "Starting EQStreamFactoryReaderLoop with thread ID %d", pthread_self()); -#endif + EQStreamFactory *fs=(EQStreamFactory *)eqfs; fs->ReaderLoop(); -#ifndef WIN32 - Log.Out(Logs::Detail, Logs::None, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self()); -#endif - THREAD_RETURN(nullptr); } @@ -42,16 +34,8 @@ ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs) { EQStreamFactory *fs=(EQStreamFactory *)eqfs; -#ifndef WIN32 - Log.Out(Logs::Detail, Logs::None, "Starting EQStreamFactoryWriterLoop with thread ID %d", pthread_self()); -#endif - fs->WriterLoop(); -#ifndef WIN32 - Log.Out(Logs::Detail, Logs::None, "Ending EQStreamFactoryWriterLoop with thread ID %d", pthread_self()); -#endif - THREAD_RETURN(nullptr); } diff --git a/common/eq_stream_ident.cpp b/common/eq_stream_ident.cpp index 7a7ed71dc..5706bbced 100644 --- a/common/eq_stream_ident.cpp +++ b/common/eq_stream_ident.cpp @@ -46,8 +46,9 @@ void EQStreamIdentifier::Process() { //first see if this stream has expired if(r.expire.Check(false)) { - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Unable to identify stream from %s:%d before timeout.", r.stream->GetRemoteAddr().c_str(), ntohs(r.stream->GetRemotePort())); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Unable to identify stream from %s:%d before timeout.", r.stream->GetRemoteAddr().c_str(), ntohs(r.stream->GetRemotePort())); r.stream->Close(); + cur = m_streams.erase(cur); continue; } @@ -61,23 +62,23 @@ void EQStreamIdentifier::Process() { } if(r.stream->GetState() != ESTABLISHED) { //the stream closed before it was identified. - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Unable to identify stream from %s:%d before it closed.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort())); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Unable to identify stream from %s:%d before it closed.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort())); switch(r.stream->GetState()) { case ESTABLISHED: - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Established"); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Established"); break; case CLOSING: - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Closing"); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Closing"); break; case DISCONNECTING: - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Disconnecting"); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Disconnecting"); break; case CLOSED: - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Closed"); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Closed"); break; default: - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Unestablished or unknown"); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Unestablished or unknown"); break; } r.stream->ReleaseFromUse(); @@ -107,7 +108,7 @@ void EQStreamIdentifier::Process() { case EQStreamInterface::MatchSuccessful: { //yay, a match. - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Identified stream %s:%d with signature %s", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str()); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Identified stream %s:%d with signature %s", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str()); // before we assign the eqstream to an interface, let the stream recognize it is in use and the session should not be reset any further r.stream->SetActive(true); @@ -121,7 +122,7 @@ void EQStreamIdentifier::Process() { } case EQStreamInterface::MatchFailed: //do nothing... - Log.Out(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: Tried patch %s, and it did not match.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str()); + Log(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: Tried patch %s, and it did not match.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort()), p->name.c_str()); break; } } @@ -129,7 +130,7 @@ void EQStreamIdentifier::Process() { //if we checked all patches and did not find a match. if(all_ready && !found_one) { //the stream cannot be identified. - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Unable to identify stream from %s:%d, no match found.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort())); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Unable to identify stream from %s:%d, no match found.", long2ip(r.stream->GetRemoteIP()).c_str(), ntohs(r.stream->GetRemotePort())); r.stream->ReleaseFromUse(); } diff --git a/common/eqemu_logsys.h b/common/eqemu_logsys.h index b3309a877..ed821831a 100644 --- a/common/eqemu_logsys.h +++ b/common/eqemu_logsys.h @@ -1,3 +1,4 @@ + /* EQEMu: Everquest Server Emulator Copyright (C) 2001-2015 EQEMu Development Team (http://eqemulator.net) @@ -38,106 +39,116 @@ namespace Logs { NOTE: Only add to the bottom of the enum because that is the type ID assignment */ - enum LogCategory { - None = 0, - AA, - AI, - Aggro, - Attack, - Client_Server_Packet, - Combat, - Commands, - Crash, - Debug, - Doors, - Error, - Guilds, - Inventory, - Launcher, - Netcode, - Normal, - Object, - Pathing, - QS_Server, - Quests, - Rules, - Skills, - Spawns, - Spells, - Status, - TCP_Connection, - Tasks, - Tradeskills, - Trading, - Tribute, - UCS_Server, - WebInterface_Server, - World_Server, - Zone_Server, - MySQLError, - MySQLQuery, - Mercenaries, - QuestDebug, - Server_Client_Packet, - Client_Server_Packet_Unhandled, - Server_Client_Packet_With_Dump, - Client_Server_Packet_With_Dump, - Login_Server, - Client_Login, - Headless_Client, - MaxCategoryID /* Don't Remove this*/ - }; +enum LogCategory { + None = 0, + AA, + AI, + Aggro, + Attack, + Client_Server_Packet, + Combat, + Commands, + Crash, + Debug, + Doors, + Error, + Guilds, + Inventory, + Launcher, + Netcode, + Normal, + Object, + Pathing, + QS_Server, + Quests, + Rules, + Skills, + Spawns, + Spells, + Status, + TCP_Connection, + Tasks, + Tradeskills, + Trading, + Tribute, + UCS_Server, + WebInterface_Server, + World_Server, + Zone_Server, + MySQLError, + MySQLQuery, + Mercenaries, + QuestDebug, + Server_Client_Packet, + Client_Server_Packet_Unhandled, + Server_Client_Packet_With_Dump, + Client_Server_Packet_With_Dump, + Login_Server, + Client_Login, + Headless_Client, + MaxCategoryID /* Don't Remove this*/ +}; - /* If you add to this, make sure you update LogCategory */ - static const char* LogCategoryName[LogCategory::MaxCategoryID] = { - "", - "AA", - "AI", - "Aggro", - "Attack", - "Packet :: Client -> Server", - "Combat", - "Commands", - "Crash", - "Debug", - "Doors", - "Error", - "Guilds", - "Inventory", - "Launcher", - "Netcode", - "Normal", - "Object", - "Pathing", - "QS Server", - "Quests", - "Rules", - "Skills", - "Spawns", - "Spells", - "Status", - "TCP Connection", - "Tasks", - "Tradeskills", - "Trading", - "Tribute", - "UCS Server", - "WebInterface Server", - "World Server", - "Zone Server", - "MySQL Error", - "MySQL Query", - "Mercenaries", - "Quest Debug", - "Packet :: Server -> Client", - "Packet :: Client -> Server Unhandled", - "Packet :: Server -> Client (Dump)", - "Packet :: Client -> Server (Dump)", - "Login Server", - "Client Login" - }; +/* If you add to this, make sure you update LogCategory */ +static const char* LogCategoryName[LogCategory::MaxCategoryID] = { + "", + "AA", + "AI", + "Aggro", + "Attack", + "Packet :: Client -> Server", + "Combat", + "Commands", + "Crash", + "Debug", + "Doors", + "Error", + "Guilds", + "Inventory", + "Launcher", + "Netcode", + "Normal", + "Object", + "Pathing", + "QS Server", + "Quests", + "Rules", + "Skills", + "Spawns", + "Spells", + "Status", + "TCP Connection", + "Tasks", + "Tradeskills", + "Trading", + "Tribute", + "UCS Server", + "WebInterface Server", + "World Server", + "Zone Server", + "MySQL Error", + "MySQL Query", + "Mercenaries", + "Quest Debug", + "Packet :: Server -> Client", + "Packet :: Client -> Server Unhandled", + "Packet :: Server -> Client (Dump)", + "Packet :: Client -> Server (Dump)", + "Login Server", + "Client Login" +}; } +#define Log(debug_level, log_category, message, ...) do {\ + if (LogSys.log_settings[log_category].is_category_enabled == 1)\ + LogSys.Out(debug_level, log_category, message, ##__VA_ARGS__);\ +} while (0) + +#define LogF(debug_level, log_category, message, ...) do {\ + if (LogSys.log_settings[log_category].is_category_enabled == 1)\ + LogSys.OutF(debug_level, log_category, message, ##__VA_ARGS__);\ +} while (0) + class EQEmuLogSys { public: EQEmuLogSys(); @@ -206,11 +217,11 @@ private: uint16 GetWindowsConsoleColorFromCategory(uint16 log_category); /* Windows console color messages mapped by category */ - void ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message); /* ProcessConsoleMessage called via Log.Out */ - void ProcessGMSay(uint16 debug_level, uint16 log_category, const std::string &message); /* ProcessGMSay called via Log.Out */ - void ProcessLogWrite(uint16 debug_level, uint16 log_category, const std::string &message); /* ProcessLogWrite called via Log.Out */ + void ProcessConsoleMessage(uint16 debug_level, uint16 log_category, const std::string &message); /* ProcessConsoleMessage called via Log */ + void ProcessGMSay(uint16 debug_level, uint16 log_category, const std::string &message); /* ProcessGMSay called via Log */ + void ProcessLogWrite(uint16 debug_level, uint16 log_category, const std::string &message); /* ProcessLogWrite called via Log */ }; -extern EQEmuLogSys Log; +extern EQEmuLogSys LogSys; #endif diff --git a/common/guild_base.cpp b/common/guild_base.cpp index ed4b508bc..8cf1b0fa8 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -46,7 +46,7 @@ bool BaseGuildManager::LoadGuilds() { ClearGuilds(); if(m_db == nullptr) { - Log.Out(Logs::Detail, Logs::Guilds, "Requested to load guilds when we have no database object."); + Log(Logs::Detail, Logs::Guilds, "Requested to load guilds when we have no database object."); return(false); } @@ -77,13 +77,13 @@ bool BaseGuildManager::LoadGuilds() { uint8 rankn = atoi(row[1]); if(rankn > GUILD_MAX_RANK) { - Log.Out(Logs::Detail, Logs::Guilds, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id); + Log(Logs::Detail, Logs::Guilds, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id); continue; } res = m_guilds.find(guild_id); if(res == m_guilds.end()) { - Log.Out(Logs::Detail, Logs::Guilds, "Found rank %d for non-existent guild %d, skipping.", rankn, guild_id); + Log(Logs::Detail, Logs::Guilds, "Found rank %d for non-existent guild %d, skipping.", rankn, guild_id); continue; } @@ -105,7 +105,7 @@ bool BaseGuildManager::LoadGuilds() { bool BaseGuildManager::RefreshGuild(uint32 guild_id) { if(m_db == nullptr) { - Log.Out(Logs::Detail, Logs::Guilds, "Requested to refresh guild %d when we have no database object.", guild_id); + Log(Logs::Detail, Logs::Guilds, "Requested to refresh guild %d when we have no database object.", guild_id); return(false); } @@ -123,7 +123,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) { if (results.RowCount() == 0) { - Log.Out(Logs::Detail, Logs::Guilds, "Unable to find guild %d in the database.", guild_id); + Log(Logs::Detail, Logs::Guilds, "Unable to find guild %d in the database.", guild_id); return false; } @@ -145,7 +145,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) { uint8 rankn = atoi(row[1]); if(rankn > GUILD_MAX_RANK) { - Log.Out(Logs::Detail, Logs::Guilds, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id); + Log(Logs::Detail, Logs::Guilds, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id); continue; } @@ -162,7 +162,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) { rank.permissions[GUILD_WARPEACE] = (row[10][0] == '1') ? true: false; } - Log.Out(Logs::Detail, Logs::Guilds, "Successfully refreshed guild %d from the database.", guild_id); + Log(Logs::Detail, Logs::Guilds, "Successfully refreshed guild %d from the database.", guild_id); return true; } @@ -214,14 +214,14 @@ BaseGuildManager::GuildInfo *BaseGuildManager::_CreateGuild(uint32 guild_id, con bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) { if(m_db == nullptr) { - Log.Out(Logs::Detail, Logs::Guilds, "Requested to store guild %d when we have no database object.", guild_id); + Log(Logs::Detail, Logs::Guilds, "Requested to store guild %d when we have no database object.", guild_id); return(false); } std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) { - Log.Out(Logs::Detail, Logs::Guilds, "Requested to store non-existent guild %d", guild_id); + Log(Logs::Detail, Logs::Guilds, "Requested to store non-existent guild %d", guild_id); return(false); } GuildInfo *info = res->second; @@ -289,14 +289,14 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) { safe_delete_array(title_esc); } - Log.Out(Logs::Detail, Logs::Guilds, "Stored guild %d in the database", guild_id); + Log(Logs::Detail, Logs::Guilds, "Stored guild %d in the database", guild_id); return true; } uint32 BaseGuildManager::_GetFreeGuildID() { if(m_db == nullptr) { - Log.Out(Logs::Detail, Logs::Guilds, "Requested find a free guild ID when we have no database object."); + Log(Logs::Detail, Logs::Guilds, "Requested find a free guild ID when we have no database object."); return(GUILD_NONE); } @@ -330,12 +330,12 @@ uint32 BaseGuildManager::_GetFreeGuildID() { if (results.RowCount() == 0) { - Log.Out(Logs::Detail, Logs::Guilds, "Located free guild ID %d in the database", index); + Log(Logs::Detail, Logs::Guilds, "Located free guild ID %d in the database", index); return index; } } - Log.Out(Logs::Detail, Logs::Guilds, "Unable to find a free guild ID when requested."); + Log(Logs::Detail, Logs::Guilds, "Unable to find a free guild ID when requested."); return GUILD_NONE; } @@ -505,11 +505,11 @@ uint32 BaseGuildManager::DBCreateGuild(const char* name, uint32 leader) { //now store the resulting guild setup into the DB. if(!_StoreGuildDB(new_id)) { - Log.Out(Logs::Detail, Logs::Guilds, "Error storing new guild. It may have been partially created which may need manual removal."); + Log(Logs::Detail, Logs::Guilds, "Error storing new guild. It may have been partially created which may need manual removal."); return(GUILD_NONE); } - Log.Out(Logs::Detail, Logs::Guilds, "Created guild %d in the database.", new_id); + Log(Logs::Detail, Logs::Guilds, "Created guild %d in the database.", new_id); return(new_id); } @@ -525,7 +525,7 @@ bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) { } if(m_db == nullptr) { - Log.Out(Logs::Detail, Logs::Guilds, "Requested to delete guild %d when we have no database object.", guild_id); + Log(Logs::Detail, Logs::Guilds, "Requested to delete guild %d when we have no database object.", guild_id); return(false); } @@ -545,14 +545,14 @@ bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) { query = StringFormat("DELETE FROM guild_bank WHERE guildid=%lu", (unsigned long)guild_id); QueryWithLogging(query, "deleting guild bank"); - Log.Out(Logs::Detail, Logs::Guilds, "Deleted guild %d from the database.", guild_id); + Log(Logs::Detail, Logs::Guilds, "Deleted guild %d from the database.", guild_id); return(true); } bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) { if(m_db == nullptr) { - Log.Out(Logs::Detail, Logs::Guilds, "Requested to rename guild %d when we have no database object.", guild_id); + Log(Logs::Detail, Logs::Guilds, "Requested to rename guild %d when we have no database object.", guild_id); return false; } @@ -573,13 +573,13 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) { if (!results.Success()) { - Log.Out(Logs::Detail, Logs::Guilds, "Error renaming guild %d '%s': %s", guild_id, query.c_str(), results.Success()); + Log(Logs::Detail, Logs::Guilds, "Error renaming guild %d '%s': %s", guild_id, query.c_str(), results.Success()); safe_delete_array(esc); return false; } safe_delete_array(esc); - Log.Out(Logs::Detail, Logs::Guilds, "Renamed guild %s (%d) to %s in database.", info->name.c_str(), guild_id, name); + Log(Logs::Detail, Logs::Guilds, "Renamed guild %s (%d) to %s in database.", info->name.c_str(), guild_id, name); info->name = name; //update our local record. @@ -588,7 +588,7 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) { bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) { if(m_db == nullptr) { - Log.Out(Logs::Detail, Logs::Guilds, "Requested to set the leader for guild %d when we have no database object.", guild_id); + Log(Logs::Detail, Logs::Guilds, "Requested to set the leader for guild %d when we have no database object.", guild_id); return false; } @@ -614,7 +614,7 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) { if(!DBSetGuildRank(leader, GUILD_LEADER)) return false; - Log.Out(Logs::Detail, Logs::Guilds, "Set guild leader for guild %d to %d in the database", guild_id, leader); + Log(Logs::Detail, Logs::Guilds, "Set guild leader for guild %d to %d in the database", guild_id, leader); info->leader_char_id = leader; //update our local record. @@ -623,7 +623,7 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) { bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const char *setter) { if(m_db == nullptr) { - Log.Out(Logs::Detail, Logs::Guilds, "Requested to set the MOTD for guild %d when we have no database object.", guild_id); + Log(Logs::Detail, Logs::Guilds, "Requested to set the MOTD for guild %d when we have no database object.", guild_id); return(false); } @@ -654,7 +654,7 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c safe_delete_array(esc); safe_delete_array(esc_set); - Log.Out(Logs::Detail, Logs::Guilds, "Set MOTD for guild %d in the database", guild_id); + Log(Logs::Detail, Logs::Guilds, "Set MOTD for guild %d in the database", guild_id); info->motd = motd; //update our local record. info->motd_setter = setter; //update our local record. @@ -688,7 +688,7 @@ bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL) } safe_delete_array(esc); - Log.Out(Logs::Detail, Logs::Guilds, "Set URL for guild %d in the database", GuildID); + Log(Logs::Detail, Logs::Guilds, "Set URL for guild %d in the database", GuildID); info->url = URL; //update our local record. @@ -722,7 +722,7 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel) } safe_delete_array(esc); - Log.Out(Logs::Detail, Logs::Guilds, "Set Channel for guild %d in the database", GuildID); + Log(Logs::Detail, Logs::Guilds, "Set Channel for guild %d in the database", GuildID); info->channel = Channel; //update our local record. @@ -731,7 +731,7 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel) bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) { if(m_db == nullptr) { - Log.Out(Logs::Detail, Logs::Guilds, "Requested to set char to guild %d when we have no database object.", guild_id); + Log(Logs::Detail, Logs::Guilds, "Requested to set char to guild %d when we have no database object.", guild_id); return(false); } @@ -753,7 +753,7 @@ bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) { return false; } } - Log.Out(Logs::Detail, Logs::Guilds, "Set char %d to guild %d and rank %d in the database.", charid, guild_id, rank); + Log(Logs::Detail, Logs::Guilds, "Set char %d to guild %d and rank %d in the database.", charid, guild_id, rank); return true; } @@ -845,7 +845,7 @@ bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) { return false; } - Log.Out(Logs::Detail, Logs::Guilds, "Set public not for char %d", charid); + Log(Logs::Detail, Logs::Guilds, "Set public not for char %d", charid); return true; } @@ -924,14 +924,14 @@ bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) { - Log.Out(Logs::Detail, Logs::Guilds, "Check leader for char %d: invalid guild.", char_id); + Log(Logs::Detail, Logs::Guilds, "Check leader for char %d: invalid guild.", char_id); return(false); //invalid guild } - Log.Out(Logs::Detail, Logs::Guilds, "Check leader for guild %d, char %d: leader id=%d", guild_id, char_id, res->second->leader_char_id); + Log(Logs::Detail, Logs::Guilds, "Check leader for guild %d, char %d: leader id=%d", guild_id, char_id, res->second->leader_char_id); return(char_id == res->second->leader_char_id); } @@ -1137,20 +1137,20 @@ uint8 BaseGuildManager::GetDisplayedRank(uint32 guild_id, uint8 rank, uint32 cha bool BaseGuildManager::CheckGMStatus(uint32 guild_id, uint8 status) const { if(status >= 250) { - Log.Out(Logs::Detail, Logs::Guilds, "Check permission on guild %d with user status %d > 250, granted.", guild_id, status); + Log(Logs::Detail, Logs::Guilds, "Check permission on guild %d with user status %d > 250, granted.", guild_id, status); return(true); //250+ as allowed anything } std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) { - Log.Out(Logs::Detail, Logs::Guilds, "Check permission on guild %d with user status %d, no such guild, denied.", guild_id, status); + Log(Logs::Detail, Logs::Guilds, "Check permission on guild %d with user status %d, no such guild, denied.", guild_id, status); return(false); //invalid guild } bool granted = (res->second->minstatus <= status); - Log.Out(Logs::Detail, Logs::Guilds, "Check permission on guild %s (%d) with user status %d. Min status %d: %s", + Log(Logs::Detail, Logs::Guilds, "Check permission on guild %s (%d) with user status %d. Min status %d: %s", res->second->name.c_str(), guild_id, status, res->second->minstatus, granted?"granted":"denied"); return(granted); @@ -1158,21 +1158,21 @@ bool BaseGuildManager::CheckGMStatus(uint32 guild_id, uint8 status) const { bool BaseGuildManager::CheckPermission(uint32 guild_id, uint8 rank, GuildAction act) const { if(rank > GUILD_MAX_RANK) { - Log.Out(Logs::Detail, Logs::Guilds, "Check permission on guild %d and rank %d for action %s (%d): Invalid rank, denied.", + Log(Logs::Detail, Logs::Guilds, "Check permission on guild %d and rank %d for action %s (%d): Invalid rank, denied.", guild_id, rank, GuildActionNames[act], act); return(false); //invalid rank } std::map::const_iterator res; res = m_guilds.find(guild_id); if(res == m_guilds.end()) { - Log.Out(Logs::Detail, Logs::Guilds, "Check permission on guild %d and rank %d for action %s (%d): Invalid guild, denied.", + Log(Logs::Detail, Logs::Guilds, "Check permission on guild %d and rank %d for action %s (%d): Invalid guild, denied.", guild_id, rank, GuildActionNames[act], act); return(false); //invalid guild } bool granted = res->second->ranks[rank].permissions[act]; - Log.Out(Logs::Detail, Logs::Guilds, "Check permission on guild %s (%d) and rank %s (%d) for action %s (%d): %s", + Log(Logs::Detail, Logs::Guilds, "Check permission on guild %s (%d) and rank %s (%d) for action %s (%d): %s", res->second->name.c_str(), guild_id, res->second->ranks[rank].name.c_str(), rank, GuildActionNames[act], act, diff --git a/common/inventory_profile.cpp b/common/inventory_profile.cpp index 480f4e98f..4f245ee58 100644 --- a/common/inventory_profile.cpp +++ b/common/inventory_profile.cpp @@ -241,14 +241,45 @@ EQEmu::ItemInstance* EQEmu::InventoryProfile::GetCursorItem() } // Swap items in inventory -bool EQEmu::InventoryProfile::SwapItem(int16 slot_a, int16 slot_b) +bool EQEmu::InventoryProfile::SwapItem(int16 slot_a, int16 slot_b, uint16 race_id, uint8 class_id, uint16 deity_id, uint8 level) { // Temp holding areas for a and b ItemInstance* inst_a = GetItem(slot_a); ItemInstance* inst_b = GetItem(slot_b); - if (inst_a) { if (!inst_a->IsSlotAllowed(slot_b)) { return false; } } - if (inst_b) { if (!inst_b->IsSlotAllowed(slot_a)) { return false; } } + if (inst_a) { + if (!inst_a->IsSlotAllowed(slot_b)) + return false; + + if ((slot_b >= legacy::EQUIPMENT_BEGIN && slot_b <= legacy::EQUIPMENT_END) || slot_b == inventory::slotPowerSource) { + auto item_a = inst_a->GetItem(); + if (!item_a) + return false; + if (race_id && class_id && !item_a->IsEquipable(race_id, class_id)) + return false; + if (deity_id && item_a->Deity && !(deity::ConvertDeityTypeToDeityTypeBit((deity::DeityType)deity_id) & item_a->Deity)) + return false; + if (level && item_a->ReqLevel && level < item_a->ReqLevel) + return false; + } + } + + if (inst_b) { + if (!inst_b->IsSlotAllowed(slot_a)) + return false; + + if ((slot_a >= legacy::EQUIPMENT_BEGIN && slot_a <= legacy::EQUIPMENT_END) || slot_a == inventory::slotPowerSource) { + auto item_b = inst_b->GetItem(); + if (!item_b) + return false; + if (race_id && class_id && !item_b->IsEquipable(race_id, class_id)) + return false; + if (deity_id && item_b->Deity && !(deity::ConvertDeityTypeToDeityTypeBit((deity::DeityType)deity_id) & item_b->Deity)) + return false; + if (level && item_b->ReqLevel && level < item_b->ReqLevel) + return false; + } + } _PutItem(slot_a, inst_b); // Copy b->a _PutItem(slot_b, inst_a); // Copy a->b @@ -1173,7 +1204,7 @@ int16 EQEmu::InventoryProfile::_PutItem(int16 slot_id, ItemInstance* inst) } if (result == INVALID_INDEX) { - Log.Out(Logs::General, Logs::Error, "InventoryProfile::_PutItem: Invalid slot_id specified (%i) with parent slot id (%i)", slot_id, parentSlot); + Log(Logs::General, Logs::Error, "InventoryProfile::_PutItem: Invalid slot_id specified (%i) with parent slot id (%i)", slot_id, parentSlot); InventoryProfile::MarkDirty(inst); // Slot not found, clean up } diff --git a/common/inventory_profile.h b/common/inventory_profile.h index d8cf6cf7f..d6d166337 100644 --- a/common/inventory_profile.h +++ b/common/inventory_profile.h @@ -127,7 +127,7 @@ namespace EQEmu ItemInstance* GetCursorItem(); // Swap items in inventory - bool SwapItem(int16 slot_a, int16 slot_b); + bool SwapItem(int16 slot_a, int16 slot_b, uint16 race_id = 0, uint8 class_id = 0, uint16 deity_id = 0, uint8 level = 0); // Remove item from inventory bool DeleteItem(int16 slot_id, uint8 quantity = 0); diff --git a/common/misc_functions.h b/common/misc_functions.h index 27ed6db86..501244fda 100644 --- a/common/misc_functions.h +++ b/common/misc_functions.h @@ -40,7 +40,7 @@ #define VERIFY_PACKET_LENGTH(OPCode, Packet, StructName) \ if(Packet->size != sizeof(StructName)) \ { \ - Log.Out(Logs::Detail, Logs::Netcode, "Size mismatch in " #OPCode " expected %i got %i", sizeof(StructName), Packet->size); \ + Log(Logs::Detail, Logs::Netcode, "Size mismatch in " #OPCode " expected %i got %i", sizeof(StructName), Packet->size); \ DumpPacket(Packet); \ return; \ } diff --git a/common/net/daybreak_connection.cpp b/common/net/daybreak_connection.cpp index 2b86bb301..28e9951e2 100644 --- a/common/net/daybreak_connection.cpp +++ b/common/net/daybreak_connection.cpp @@ -188,7 +188,7 @@ void EQ::Net::DaybreakConnectionManager::ProcessPacket(const std::string &endpoi } if (size < DaybreakHeader::size()) { - Log.OutF(Logs::Detail, Logs::Netcode, "Packet of size {0} which is less than {1}", size, DaybreakHeader::size()); + LogF(Logs::Detail, Logs::Netcode, "Packet of size {0} which is less than {1}", size, DaybreakHeader::size()); return; } @@ -218,7 +218,7 @@ void EQ::Net::DaybreakConnectionManager::ProcessPacket(const std::string &endpoi } } catch (std::exception &ex) { - Log.OutF(Logs::Detail, Logs::Netcode, "Error processing packet: {0}", ex.what()); + LogF(Logs::Detail, Logs::Netcode, "Error processing packet: {0}", ex.what()); } } @@ -364,7 +364,7 @@ void EQ::Net::DaybreakConnection::Process() ProcessQueue(); } catch (std::exception ex) { - Log.OutF(Logs::Detail, Logs::Netcode, "Error processing connection: {0}", ex.what()); + LogF(Logs::Detail, Logs::Netcode, "Error processing connection: {0}", ex.what()); } } @@ -379,7 +379,7 @@ void EQ::Net::DaybreakConnection::ProcessPacket(Packet &p) } if (p.GetInt8(0) != 0) { - Log.OutF(Logs::Detail, Logs::Netcode, "Error parsing packet, did not start with a 0 frame, not a valid protocol packet."); + LogF(Logs::Detail, Logs::Netcode, "Error parsing packet, did not start with a 0 frame, not a valid protocol packet."); return; } @@ -390,7 +390,7 @@ void EQ::Net::DaybreakConnection::ProcessPacket(Packet &p) if (PacketCanBeEncoded(p)) { if (!ValidateCRC(p)) { - Log.OutF(Logs::Detail, Logs::Netcode, "Tossed packet that failed CRC of type {0:#x}", p.Length() >= 2 ? p.GetInt8(1) : 0); + LogF(Logs::Detail, Logs::Netcode, "Tossed packet that failed CRC of type {0:#x}", p.Length() >= 2 ? p.GetInt8(1) : 0); return; } @@ -756,7 +756,7 @@ void EQ::Net::DaybreakConnection::ProcessDecodedPacket(const Packet &p) case OP_SessionStatResponse: break; default: - Log.OutF(Logs::Detail, Logs::Netcode, "Unhandled opcode {0:#x}", p.GetInt8(1)); + LogF(Logs::Detail, Logs::Netcode, "Unhandled opcode {0:#x}", p.GetInt8(1)); break; } } diff --git a/common/net/eqstream.cpp b/common/net/eqstream.cpp index a366fe1a2..26fdf1d8e 100644 --- a/common/net/eqstream.cpp +++ b/common/net/eqstream.cpp @@ -171,23 +171,23 @@ EQStreamInterface::MatchState EQ::Net::EQStream::CheckSignature(const Signature if (opcode == sig->first_eq_opcode) { if (length == sig->first_length) { - Log.OutF(Logs::General, Logs::Netcode, "[IDENT_TRACE] {0}:{1}: First opcode matched {2:#x} and length matched {3}", + LogF(Logs::General, Logs::Netcode, "[IDENT_TRACE] {0}:{1}: First opcode matched {2:#x} and length matched {3}", RemoteEndpoint(), m_connection->RemotePort(), sig->first_eq_opcode, length); return MatchSuccessful; } else if (length == 0) { - Log.OutF(Logs::General, Logs::Netcode, "[IDENT_TRACE] {0}:{1}: First opcode matched {2:#x} and length is ignored.", + LogF(Logs::General, Logs::Netcode, "[IDENT_TRACE] {0}:{1}: First opcode matched {2:#x} and length is ignored.", RemoteEndpoint(), m_connection->RemotePort(), sig->first_eq_opcode); return MatchSuccessful; } else { - Log.OutF(Logs::General, Logs::Netcode, "[IDENT_TRACE] {0}:{1}: First opcode matched {2:#x} but length {3} did not match expected {4}", + LogF(Logs::General, Logs::Netcode, "[IDENT_TRACE] {0}:{1}: First opcode matched {2:#x} but length {3} did not match expected {4}", RemoteEndpoint(), m_connection->RemotePort(), sig->first_eq_opcode, length, sig->first_length); return MatchFailed; } } else { - Log.OutF(Logs::General, Logs::Netcode, "[IDENT_TRACE] {0}:{1}: First opcode {1:#x} did not match expected {2:#x}", + LogF(Logs::General, Logs::Netcode, "[IDENT_TRACE] {0}:{1}: First opcode {1:#x} did not match expected {2:#x}", RemoteEndpoint(), m_connection->RemotePort(), opcode, sig->first_eq_opcode); return MatchFailed; } diff --git a/common/net/servertalk_client_connection.cpp b/common/net/servertalk_client_connection.cpp index 181b75c42..676d9d024 100644 --- a/common/net/servertalk_client_connection.cpp +++ b/common/net/servertalk_client_connection.cpp @@ -78,15 +78,15 @@ void EQ::Net::ServertalkClient::Connect() m_connecting = true; EQ::Net::TCPConnection::Connect(m_addr, m_port, false, [this](std::shared_ptr connection) { if (connection == nullptr) { - Log.OutF(Logs::General, Logs::TCP_Connection, "Error connecting to {0}:{1}, attempting to reconnect...", m_addr, m_port); + LogF(Logs::General, Logs::TCP_Connection, "Error connecting to {0}:{1}, attempting to reconnect...", m_addr, m_port); m_connecting = false; return; } - Log.OutF(Logs::General, Logs::TCP_Connection, "Connected to {0}:{1}", m_addr, m_port); + LogF(Logs::General, Logs::TCP_Connection, "Connected to {0}:{1}", m_addr, m_port); m_connection = connection; m_connection->OnDisconnect([this](EQ::Net::TCPConnection *c) { - Log.OutF(Logs::General, Logs::TCP_Connection, "Connection lost to {0}:{1}, attempting to reconnect...", m_addr, m_port); + LogF(Logs::General, Logs::TCP_Connection, "Connection lost to {0}:{1}, attempting to reconnect...", m_addr, m_port); m_encrypted = false; m_connection.reset(); }); @@ -213,7 +213,7 @@ void EQ::Net::ServertalkClient::ProcessHello(EQ::Net::Packet &p) } } else { - Log.OutF(Logs::General, Logs::Error, "Could not process hello, size != {0}", 1 + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES); + LogF(Logs::General, Logs::Error, "Could not process hello, size != {0}", 1 + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES); } } else { @@ -225,7 +225,7 @@ void EQ::Net::ServertalkClient::ProcessHello(EQ::Net::Packet &p) } } catch (std::exception &ex) { - Log.OutF(Logs::General, Logs::Error, "Error parsing hello from server: {0}", ex.what()); + LogF(Logs::General, Logs::Error, "Error parsing hello from server: {0}", ex.what()); m_connection->Disconnect(); if (m_on_connect_cb) { @@ -252,7 +252,7 @@ void EQ::Net::ServertalkClient::ProcessHello(EQ::Net::Packet &p) } } catch (std::exception &ex) { - Log.OutF(Logs::General, Logs::Error, "Error parsing hello from server: {0}", ex.what()); + LogF(Logs::General, Logs::Error, "Error parsing hello from server: {0}", ex.what()); m_connection->Disconnect(); if (m_on_connect_cb) { @@ -275,7 +275,7 @@ void EQ::Net::ServertalkClient::ProcessMessage(EQ::Net::Packet &p) std::unique_ptr decrypted_text(new unsigned char[message_len]); if (crypto_box_open_easy_afternm(&decrypted_text[0], (unsigned char*)&data[0], length, m_nonce_theirs, m_shared_key)) { - Log.OutF(Logs::General, Logs::Error, "Error decrypting message from server"); + LogF(Logs::General, Logs::Error, "Error decrypting message from server"); (*(uint64_t*)&m_nonce_theirs[0])++; return; } @@ -323,7 +323,7 @@ void EQ::Net::ServertalkClient::ProcessMessage(EQ::Net::Packet &p) } } catch (std::exception &ex) { - Log.OutF(Logs::General, Logs::Error, "Error parsing message from server: {0}", ex.what()); + LogF(Logs::General, Logs::Error, "Error parsing message from server: {0}", ex.what()); } } diff --git a/common/net/servertalk_legacy_client_connection.cpp b/common/net/servertalk_legacy_client_connection.cpp index fad5a27b4..1e31f406f 100644 --- a/common/net/servertalk_legacy_client_connection.cpp +++ b/common/net/servertalk_legacy_client_connection.cpp @@ -58,15 +58,15 @@ void EQ::Net::ServertalkLegacyClient::Connect() m_connecting = true; EQ::Net::TCPConnection::Connect(m_addr, m_port, false, [this](std::shared_ptr connection) { if (connection == nullptr) { - Log.OutF(Logs::General, Logs::TCP_Connection, "Error connecting to {0}:{1}, attempting to reconnect...", m_addr, m_port); + LogF(Logs::General, Logs::TCP_Connection, "Error connecting to {0}:{1}, attempting to reconnect...", m_addr, m_port); m_connecting = false; return; } - Log.OutF(Logs::General, Logs::TCP_Connection, "Connected to {0}:{1}", m_addr, m_port); + LogF(Logs::General, Logs::TCP_Connection, "Connected to {0}:{1}", m_addr, m_port); m_connection = connection; m_connection->OnDisconnect([this](EQ::Net::TCPConnection *c) { - Log.OutF(Logs::General, Logs::TCP_Connection, "Connection lost to {0}:{1}, attempting to reconnect...", m_addr, m_port); + LogF(Logs::General, Logs::TCP_Connection, "Connection lost to {0}:{1}, attempting to reconnect...", m_addr, m_port); m_connection.reset(); }); diff --git a/common/net/servertalk_server_connection.cpp b/common/net/servertalk_server_connection.cpp index 98589773b..c211545f0 100644 --- a/common/net/servertalk_server_connection.cpp +++ b/common/net/servertalk_server_connection.cpp @@ -201,7 +201,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b { #ifdef ENABLE_SECURITY if (downgrade_security && m_allow_downgrade && m_encrypted) { - Log.OutF(Logs::General, Logs::TCP_Connection, "Downgraded encrypted connection to plaintext because otherside didn't support encryption {0}:{1}", + LogF(Logs::General, Logs::TCP_Connection, "Downgraded encrypted connection to plaintext because otherside didn't support encryption {0}:{1}", m_connection->RemoteIP(), m_connection->RemotePort()); m_encrypted = false; } @@ -220,7 +220,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b if (crypto_box_open_easy_afternm(&decrypted_text[0], (unsigned char*)p.Data() + crypto_box_PUBLICKEYBYTES + crypto_box_NONCEBYTES, cipher_len, m_nonce_theirs, m_shared_key)) { - Log.OutF(Logs::General, Logs::Error, "Error decrypting handshake from client, dropping connection."); + LogF(Logs::General, Logs::Error, "Error decrypting handshake from client, dropping connection."); m_connection->Disconnect(); return; } @@ -229,7 +229,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b std::string credentials = (const char*)&decrypted_text[0] + (m_identifier.length() + 1); if (!m_parent->CheckCredentials(credentials)) { - Log.OutF(Logs::General, Logs::Error, "Got incoming connection with invalid credentials during handshake, dropping connection."); + LogF(Logs::General, Logs::Error, "Got incoming connection with invalid credentials during handshake, dropping connection."); m_connection->Disconnect(); return; } @@ -239,7 +239,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b } } catch (std::exception &ex) { - Log.OutF(Logs::General, Logs::Error, "Error parsing handshake from client: {0}", ex.what()); + LogF(Logs::General, Logs::Error, "Error parsing handshake from client: {0}", ex.what()); m_connection->Disconnect(); } } @@ -249,7 +249,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b auto credentials = p.GetCString(m_identifier.length() + 1); if (!m_parent->CheckCredentials(credentials)) { - Log.OutF(Logs::General, Logs::Error, "Got incoming connection with invalid credentials during handshake, dropping connection."); + LogF(Logs::General, Logs::Error, "Got incoming connection with invalid credentials during handshake, dropping connection."); m_connection->Disconnect(); return; } @@ -257,7 +257,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b m_parent->ConnectionIdentified(this); } catch (std::exception &ex) { - Log.OutF(Logs::General, Logs::Error, "Error parsing handshake from client: {0}", ex.what()); + LogF(Logs::General, Logs::Error, "Error parsing handshake from client: {0}", ex.what()); m_connection->Disconnect(); } } @@ -267,7 +267,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b auto credentials = p.GetCString(m_identifier.length() + 1); if (!m_parent->CheckCredentials(credentials)) { - Log.OutF(Logs::General, Logs::Error, "Got incoming connection with invalid credentials during handshake, dropping connection."); + LogF(Logs::General, Logs::Error, "Got incoming connection with invalid credentials during handshake, dropping connection."); m_connection->Disconnect(); return; } @@ -275,7 +275,7 @@ void EQ::Net::ServertalkServerConnection::ProcessHandshake(EQ::Net::Packet &p, b m_parent->ConnectionIdentified(this); } catch (std::exception &ex) { - Log.OutF(Logs::General, Logs::Error, "Error parsing handshake from client: {0}", ex.what()); + LogF(Logs::General, Logs::Error, "Error parsing handshake from client: {0}", ex.what()); m_connection->Disconnect(); } #endif @@ -295,7 +295,7 @@ void EQ::Net::ServertalkServerConnection::ProcessMessage(EQ::Net::Packet &p) if (crypto_box_open_easy_afternm(&decrypted_text[0], (unsigned char*)&data[0], length, m_nonce_theirs, m_shared_key)) { - Log.OutF(Logs::General, Logs::Error, "Error decrypting message from client"); + LogF(Logs::General, Logs::Error, "Error decrypting message from client"); (*(uint64_t*)&m_nonce_theirs[0])++; return; } @@ -343,6 +343,6 @@ void EQ::Net::ServertalkServerConnection::ProcessMessage(EQ::Net::Packet &p) } } catch (std::exception &ex) { - Log.OutF(Logs::General, Logs::Error, "Error parsing message from client: {0}", ex.what()); + LogF(Logs::General, Logs::Error, "Error parsing message from client: {0}", ex.what()); } } diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index ead2ce49a..e342c5410 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -83,7 +83,7 @@ namespace RoF //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); if (!opcodes->LoadOpcodes(opfile.c_str())) { - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name); return; } } @@ -106,7 +106,7 @@ namespace RoF signature.first_length = sizeof(structs::ClientZoneEntry_Struct); signature.first_eq_opcode = opcodes->EmuToEQ(OP_ZoneEntry); into.RegisterPatch(signature, pname.c_str(), &opcodes, &struct_strategy); - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name); } void Reload() @@ -123,10 +123,10 @@ namespace RoF opfile += name; opfile += ".conf"; if (!opcodes->ReloadOpcodes(opfile.c_str())) { - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name); return; } - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name); } } @@ -347,7 +347,7 @@ namespace RoF if (EntryCount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct)); delete in; return; } @@ -569,7 +569,7 @@ namespace RoF int item_count = in->size / sizeof(EQEmu::InternalSerializedItem_Struct); if (!item_count || (in->size % sizeof(EQEmu::InternalSerializedItem_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(EQEmu::InternalSerializedItem_Struct)); delete in; @@ -586,7 +586,7 @@ namespace RoF for (int index = 0; index < item_count; ++index, ++eq) { SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0); if (ob.tellp() == last_pos) - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id); last_pos = ob.tellp(); } @@ -1512,7 +1512,7 @@ namespace RoF SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0); if (ob.tellp() == last_pos) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id); delete in; return; } @@ -2690,7 +2690,7 @@ namespace RoF outapp->WriteUInt8(0); // Unknown - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Player Profile Packet is %i bytes", outapp->GetWritePosition()); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Player Profile Packet is %i bytes", outapp->GetWritePosition()); auto NewBuffer = new unsigned char[outapp->GetWritePosition()]; memcpy(NewBuffer, outapp->pBuffer, outapp->GetWritePosition()); @@ -3550,7 +3550,7 @@ namespace RoF if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct)); delete in; return; } @@ -3898,7 +3898,7 @@ namespace RoF //determine and verify length int entrycount = in->size / sizeof(Spawn_Struct); if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct)); delete in; return; } @@ -4146,7 +4146,7 @@ namespace RoF Buffer += 29; if (Buffer != (BufferStart + PacketSize)) { - Log.Out(Logs::General, Logs::Netcode, "[ERROR] SPAWN ENCODE LOGIC PROBLEM: Buffer pointer is now %i from end", Buffer - (BufferStart + PacketSize)); + Log(Logs::General, Logs::Netcode, "[ERROR] SPAWN ENCODE LOGIC PROBLEM: Buffer pointer is now %i from end", Buffer - (BufferStart + PacketSize)); } //Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Sending zone spawn for %s packet is %i bytes", emu->name, outapp->size); //Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size); @@ -4715,7 +4715,7 @@ namespace RoF return; } default: - Log.Out(Logs::Detail, Logs::Netcode, "Unhandled OP_GuildBank action"); + Log(Logs::Detail, Logs::Netcode, "Unhandled OP_GuildBank action"); __packet->SetOpcode(OP_Unknown); /* invalidate the packet */ return; } @@ -4861,7 +4861,7 @@ namespace RoF SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct); //Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Moved item from %u to %u", eq->from_slot.MainSlot, eq->to_slot.MainSlot); - Log.Out(Logs::General, Logs::Netcode, "[RoF] MoveItem SlotType from %i to %i, MainSlot from %i to %i, SubSlot from %i to %i, AugSlot from %i to %i, Unknown01 from %i to %i, Number %u", eq->from_slot.Type, eq->to_slot.Type, eq->from_slot.Slot, eq->to_slot.Slot, eq->from_slot.SubIndex, eq->to_slot.SubIndex, eq->from_slot.AugIndex, eq->to_slot.AugIndex, eq->from_slot.Unknown01, eq->to_slot.Unknown01, eq->number_in_stack); + Log(Logs::General, Logs::Netcode, "[RoF] MoveItem SlotType from %i to %i, MainSlot from %i to %i, SubSlot from %i to %i, AugSlot from %i to %i, Unknown01 from %i to %i, Number %u", eq->from_slot.Type, eq->to_slot.Type, eq->from_slot.Slot, eq->to_slot.Slot, eq->from_slot.SubIndex, eq->to_slot.SubIndex, eq->from_slot.AugIndex, eq->to_slot.AugIndex, eq->from_slot.Unknown01, eq->to_slot.Unknown01, eq->number_in_stack); emu->from_slot = RoFToServerSlot(eq->from_slot); emu->to_slot = RoFToServerSlot(eq->to_slot); IN(number_in_stack); @@ -5721,7 +5721,7 @@ namespace RoF RoFSlot.Slot = TempSlot; } - Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoFSlot.Type, RoFSlot.Unknown02, RoFSlot.Slot, RoFSlot.SubIndex, RoFSlot.AugIndex, RoFSlot.Unknown01); + Log(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoFSlot.Type, RoFSlot.Unknown02, RoFSlot.Slot, RoFSlot.SubIndex, RoFSlot.AugIndex, RoFSlot.Unknown01); return RoFSlot; } @@ -5762,7 +5762,7 @@ namespace RoF RoFSlot.SubIndex = TempSlot - ((RoFSlot.Slot + 2) * EQEmu::inventory::ContainerCount); } - Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF Slots: Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoFSlot.Slot, RoFSlot.SubIndex, RoFSlot.AugIndex, RoFSlot.Unknown01); + Log(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF Slots: Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoFSlot.Slot, RoFSlot.SubIndex, RoFSlot.AugIndex, RoFSlot.Unknown01); return RoFSlot; } @@ -5867,7 +5867,7 @@ namespace RoF ServerSlot = INVALID_INDEX; } - Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert RoF Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", rofSlot.Type, rofSlot.Unknown02, rofSlot.Slot, rofSlot.SubIndex, rofSlot.AugIndex, rofSlot.Unknown01, ServerSlot); + Log(Logs::General, Logs::Netcode, "[ERROR] Convert RoF Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", rofSlot.Type, rofSlot.Unknown02, rofSlot.Slot, rofSlot.SubIndex, rofSlot.AugIndex, rofSlot.Unknown01, ServerSlot); return ServerSlot; } @@ -5902,7 +5902,7 @@ namespace RoF ServerSlot = TempSlot; } - Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert RoF Slots: Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", rofSlot.Slot, rofSlot.SubIndex, rofSlot.AugIndex, rofSlot.Unknown01, ServerSlot); + Log(Logs::General, Logs::Netcode, "[ERROR] Convert RoF Slots: Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", rofSlot.Slot, rofSlot.SubIndex, rofSlot.AugIndex, rofSlot.Unknown01, ServerSlot); return ServerSlot; } diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index 8c40a1263..e38fde6f1 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -83,7 +83,7 @@ namespace RoF2 //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); if (!opcodes->LoadOpcodes(opfile.c_str())) { - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name); return; } } @@ -109,7 +109,7 @@ namespace RoF2 - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name); } void Reload() @@ -126,10 +126,10 @@ namespace RoF2 opfile += name; opfile += ".conf"; if (!opcodes->ReloadOpcodes(opfile.c_str())) { - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name); return; } - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name); } } @@ -416,7 +416,7 @@ namespace RoF2 if (EntryCount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct)); delete in; return; } @@ -637,7 +637,7 @@ namespace RoF2 int item_count = in->size / sizeof(EQEmu::InternalSerializedItem_Struct); if (!item_count || (in->size % sizeof(EQEmu::InternalSerializedItem_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(EQEmu::InternalSerializedItem_Struct)); delete in; @@ -654,7 +654,7 @@ namespace RoF2 for (int index = 0; index < item_count; ++index, ++eq) { SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0, ItemPacketCharInventory); if (ob.tellp() == last_pos) - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id); last_pos = ob.tellp(); } @@ -1581,7 +1581,7 @@ namespace RoF2 SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0, old_item_pkt->PacketType); if (ob.tellp() == last_pos) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id); delete in; return; } @@ -2779,7 +2779,7 @@ namespace RoF2 // Think we need 1 byte of padding at the end outapp->WriteUInt8(0); // Unknown - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Player Profile Packet is %i bytes", outapp->GetWritePosition()); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Player Profile Packet is %i bytes", outapp->GetWritePosition()); auto NewBuffer = new unsigned char[outapp->GetWritePosition()]; memcpy(NewBuffer, outapp->pBuffer, outapp->GetWritePosition()); @@ -3620,7 +3620,7 @@ namespace RoF2 if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct)); delete in; return; } @@ -3730,7 +3730,7 @@ namespace RoF2 OUT(TraderID); snprintf(eq->SerialNumber, sizeof(eq->SerialNumber), "%016d", emu->ItemID); - Log.Out(Logs::Detail, Logs::Trading, "ENCODE(OP_TraderDelItem): TraderID %d, SerialNumber: %d", emu->TraderID, emu->ItemID); + Log(Logs::Detail, Logs::Trading, "ENCODE(OP_TraderDelItem): TraderID %d, SerialNumber: %d", emu->TraderID, emu->ItemID); FINISH_ENCODE(); } @@ -3761,7 +3761,7 @@ namespace RoF2 eq->Traders2 = emu->Traders; eq->Items2 = emu->Items; - Log.Out(Logs::Detail, Logs::Trading, "ENCODE(OP_TraderShop): BazaarWelcome_Struct Code %d, Traders %d, Items %d", + Log(Logs::Detail, Logs::Trading, "ENCODE(OP_TraderShop): BazaarWelcome_Struct Code %d, Traders %d, Items %d", eq->Code, eq->Traders, eq->Items); FINISH_ENCODE(); @@ -3784,14 +3784,14 @@ namespace RoF2 OUT(Quantity); snprintf(eq->SerialNumber, sizeof(eq->SerialNumber), "%016d", emu->ItemID); - Log.Out(Logs::Detail, Logs::Trading, "ENCODE(OP_TraderShop): Buy Action %d, Price %d, Trader %d, ItemID %d, Quantity %d, ItemName, %s", + Log(Logs::Detail, Logs::Trading, "ENCODE(OP_TraderShop): Buy Action %d, Price %d, Trader %d, ItemID %d, Quantity %d, ItemName, %s", eq->Action, eq->Price, eq->TraderID, eq->ItemID, eq->Quantity, emu->ItemName); FINISH_ENCODE(); } else { - Log.Out(Logs::Detail, Logs::Trading, "ENCODE(OP_TraderShop): Encode Size Unknown (%d)", psize); + Log(Logs::Detail, Logs::Trading, "ENCODE(OP_TraderShop): Encode Size Unknown (%d)", psize); } } @@ -4043,7 +4043,7 @@ namespace RoF2 //determine and verify length int entrycount = in->size / sizeof(Spawn_Struct); if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct)); delete in; return; } @@ -4364,7 +4364,7 @@ namespace RoF2 Buffer += 29; if (Buffer != (BufferStart + PacketSize)) { - Log.Out(Logs::General, Logs::Netcode, "[ERROR] SPAWN ENCODE LOGIC PROBLEM: Buffer pointer is now %i from end", Buffer - (BufferStart + PacketSize)); + Log(Logs::General, Logs::Netcode, "[ERROR] SPAWN ENCODE LOGIC PROBLEM: Buffer pointer is now %i from end", Buffer - (BufferStart + PacketSize)); } //Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Sending zone spawn for %s packet is %i bytes", emu->name, outapp->size); //Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size); @@ -4945,7 +4945,7 @@ namespace RoF2 return; } default: - Log.Out(Logs::Detail, Logs::Netcode, "Unhandled OP_GuildBank action"); + Log(Logs::Detail, Logs::Netcode, "Unhandled OP_GuildBank action"); __packet->SetOpcode(OP_Unknown); /* invalidate the packet */ return; } @@ -5090,7 +5090,7 @@ namespace RoF2 DECODE_LENGTH_EXACT(structs::MoveItem_Struct); SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct); - Log.Out(Logs::General, Logs::Netcode, "[RoF2] MoveItem SlotType from %i to %i, MainSlot from %i to %i, SubSlot from %i to %i, AugSlot from %i to %i, Unknown01 from %i to %i, Number %u", eq->from_slot.Type, eq->to_slot.Type, eq->from_slot.Slot, eq->to_slot.Slot, eq->from_slot.SubIndex, eq->to_slot.SubIndex, eq->from_slot.AugIndex, eq->to_slot.AugIndex, eq->from_slot.Unknown01, eq->to_slot.Unknown01, eq->number_in_stack); + Log(Logs::General, Logs::Netcode, "[RoF2] MoveItem SlotType from %i to %i, MainSlot from %i to %i, SubSlot from %i to %i, AugSlot from %i to %i, Unknown01 from %i to %i, Number %u", eq->from_slot.Type, eq->to_slot.Type, eq->from_slot.Slot, eq->to_slot.Slot, eq->from_slot.SubIndex, eq->to_slot.SubIndex, eq->from_slot.AugIndex, eq->to_slot.AugIndex, eq->from_slot.Unknown01, eq->to_slot.Unknown01, eq->number_in_stack); emu->from_slot = RoF2ToServerSlot(eq->from_slot); emu->to_slot = RoF2ToServerSlot(eq->to_slot); IN(number_in_stack); @@ -5326,7 +5326,7 @@ namespace RoF2 IN(Code); IN(TraderID); IN(Approval); - Log.Out(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): TraderClick_Struct Code %d, TraderID %d, Approval %d", + Log(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): TraderClick_Struct Code %d, TraderID %d, Approval %d", eq->Code, eq->TraderID, eq->Approval); FINISH_DIRECT_DECODE(); @@ -5340,7 +5340,7 @@ namespace RoF2 emu->Beginning.Action = eq->Code; IN(Traders); IN(Items); - Log.Out(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): BazaarWelcome_Struct Code %d, Traders %d, Items %d", + Log(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): BazaarWelcome_Struct Code %d, Traders %d, Items %d", eq->Code, eq->Traders, eq->Items); FINISH_DIRECT_DECODE(); @@ -5357,20 +5357,20 @@ namespace RoF2 memcpy(emu->ItemName, eq->ItemName, sizeof(emu->ItemName)); IN(ItemID); IN(Quantity); - Log.Out(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): TraderBuy_Struct (Unknowns) Unknown004 %d, Unknown008 %d, Unknown012 %d, Unknown076 %d, Unknown276 %d", + Log(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): TraderBuy_Struct (Unknowns) Unknown004 %d, Unknown008 %d, Unknown012 %d, Unknown076 %d, Unknown276 %d", eq->Unknown004, eq->Unknown008, eq->Unknown012, eq->Unknown076, eq->Unknown276); - Log.Out(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): TraderBuy_Struct Buy Action %d, Price %d, Trader %d, ItemID %d, Quantity %d, ItemName, %s", + Log(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): TraderBuy_Struct Buy Action %d, Price %d, Trader %d, ItemID %d, Quantity %d, ItemName, %s", eq->Action, eq->Price, eq->TraderID, eq->ItemID, eq->Quantity, eq->ItemName); FINISH_DIRECT_DECODE(); } else if (psize == 4) { - Log.Out(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): Forwarding packet as-is with size 4"); + Log(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): Forwarding packet as-is with size 4"); } else { - Log.Out(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): Decode Size Unknown (%d)", psize); + Log(Logs::Detail, Logs::Trading, "DECODE(OP_TraderShop): Decode Size Unknown (%d)", psize); } } @@ -6024,7 +6024,7 @@ namespace RoF2 RoF2Slot.Slot = TempSlot; } - Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF2 Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoF2Slot.Type, RoF2Slot.Unknown02, RoF2Slot.Slot, RoF2Slot.SubIndex, RoF2Slot.AugIndex, RoF2Slot.Unknown01); + Log(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF2 Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoF2Slot.Type, RoF2Slot.Unknown02, RoF2Slot.Slot, RoF2Slot.SubIndex, RoF2Slot.AugIndex, RoF2Slot.Unknown01); return RoF2Slot; } @@ -6065,7 +6065,7 @@ namespace RoF2 RoF2Slot.SubIndex = TempSlot - ((RoF2Slot.Slot + 2) * EQEmu::inventory::ContainerCount); } - Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF2 Slots: Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoF2Slot.Slot, RoF2Slot.SubIndex, RoF2Slot.AugIndex, RoF2Slot.Unknown01); + Log(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF2 Slots: Main %i, Sub %i, Aug %i, Unk1 %i", serverSlot, RoF2Slot.Slot, RoF2Slot.SubIndex, RoF2Slot.AugIndex, RoF2Slot.Unknown01); return RoF2Slot; } @@ -6174,7 +6174,7 @@ namespace RoF2 ServerSlot = rof2Slot.Slot + EQEmu::legacy::CORPSE_BEGIN; } - Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert RoF2 Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", rof2Slot.Type, rof2Slot.Unknown02, rof2Slot.Slot, rof2Slot.SubIndex, rof2Slot.AugIndex, rof2Slot.Unknown01, ServerSlot); + Log(Logs::General, Logs::Netcode, "[ERROR] Convert RoF2 Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", rof2Slot.Type, rof2Slot.Unknown02, rof2Slot.Slot, rof2Slot.SubIndex, rof2Slot.AugIndex, rof2Slot.Unknown01, ServerSlot); return ServerSlot; } @@ -6209,7 +6209,7 @@ namespace RoF2 ServerSlot = TempSlot; } - Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert RoF2 Slots: Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", rof2Slot.Slot, rof2Slot.SubIndex, rof2Slot.AugIndex, rof2Slot.Unknown01, ServerSlot); + Log(Logs::General, Logs::Netcode, "[ERROR] Convert RoF2 Slots: Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", rof2Slot.Slot, rof2Slot.SubIndex, rof2Slot.AugIndex, rof2Slot.Unknown01, ServerSlot); return ServerSlot; } diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index a0f5fcea1..9d4db7737 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -79,7 +79,7 @@ namespace SoD //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); if (!opcodes->LoadOpcodes(opfile.c_str())) { - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name); return; } } @@ -105,7 +105,7 @@ namespace SoD - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name); } void Reload() @@ -122,10 +122,10 @@ namespace SoD opfile += name; opfile += ".conf"; if (!opcodes->ReloadOpcodes(opfile.c_str())) { - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name); return; } - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name); } } @@ -278,7 +278,7 @@ namespace SoD if (EntryCount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct)); delete in; return; } @@ -384,7 +384,7 @@ namespace SoD int item_count = in->size / sizeof(EQEmu::InternalSerializedItem_Struct); if (!item_count || (in->size % sizeof(EQEmu::InternalSerializedItem_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(EQEmu::InternalSerializedItem_Struct)); delete in; @@ -401,7 +401,7 @@ namespace SoD for (int index = 0; index < item_count; ++index, ++eq) { SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0); if (ob.tellp() == last_pos) - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id); last_pos = ob.tellp(); } @@ -1065,7 +1065,7 @@ namespace SoD SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0); if (ob.tellp() == last_pos) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id); delete in; return; } @@ -2285,7 +2285,7 @@ namespace SoD if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct)); delete in; return; } @@ -2522,7 +2522,7 @@ namespace SoD //determine and verify length int entrycount = in->size / sizeof(Spawn_Struct); if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct)); delete in; return; } @@ -3275,7 +3275,7 @@ namespace SoD DECODE_LENGTH_EXACT(structs::MoveItem_Struct); SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct); - Log.Out(Logs::General, Logs::Netcode, "[SoD] Moved item from %u to %u", eq->from_slot, eq->to_slot); + Log(Logs::General, Logs::Netcode, "[SoD] Moved item from %u to %u", eq->from_slot, eq->to_slot); emu->from_slot = SoDToServerSlot(eq->from_slot); emu->to_slot = SoDToServerSlot(eq->to_slot); diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index b74955e34..456bc7339 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -79,7 +79,7 @@ namespace SoF //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); if (!opcodes->LoadOpcodes(opfile.c_str())) { - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name); return; } } @@ -105,7 +105,7 @@ namespace SoF - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name); } void Reload() @@ -122,10 +122,10 @@ namespace SoF opfile += name; opfile += ".conf"; if (!opcodes->ReloadOpcodes(opfile.c_str())) { - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name); return; } - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name); } } @@ -245,7 +245,7 @@ namespace SoF //determine and verify length int entrycount = in->size / sizeof(BazaarSearchResults_Struct); if (entrycount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct)); delete in; return; @@ -366,7 +366,7 @@ namespace SoF int item_count = in->size / sizeof(EQEmu::InternalSerializedItem_Struct); if (!item_count || (in->size % sizeof(EQEmu::InternalSerializedItem_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(EQEmu::InternalSerializedItem_Struct)); delete in; @@ -383,7 +383,7 @@ namespace SoF for (int index = 0; index < item_count; ++index, ++eq) { SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0); if (ob.tellp() == last_pos) - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id); last_pos = ob.tellp(); } @@ -862,7 +862,7 @@ namespace SoF SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0); if (ob.tellp() == last_pos) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id); delete in; return; } @@ -1916,7 +1916,7 @@ namespace SoF if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct)); delete in; return; } @@ -2078,7 +2078,7 @@ namespace SoF //determine and verify length int entrycount = in->size / sizeof(Spawn_Struct); if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct)); delete in; return; } @@ -2659,7 +2659,7 @@ namespace SoF DECODE_LENGTH_EXACT(structs::MoveItem_Struct); SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct); - Log.Out(Logs::General, Logs::Netcode, "[SoF] Moved item from %u to %u", eq->from_slot, eq->to_slot); + Log(Logs::General, Logs::Netcode, "[SoF] Moved item from %u to %u", eq->from_slot, eq->to_slot); emu->from_slot = SoFToServerSlot(eq->from_slot); emu->to_slot = SoFToServerSlot(eq->to_slot); diff --git a/common/patches/ss_define.h b/common/patches/ss_define.h index f5c6ab361..bd5c065c5 100644 --- a/common/patches/ss_define.h +++ b/common/patches/ss_define.h @@ -87,14 +87,14 @@ //check length of packet before decoding. Call before setup. #define ENCODE_LENGTH_EXACT(struct_) \ if((*p)->size != sizeof(struct_)) { \ - Log.Out(Logs::Detail, Logs::Netcode, "Wrong size on outbound %s (" #struct_ "): Got %d, expected %d", opcodes->EmuToName((*p)->GetOpcode()), (*p)->size, sizeof(struct_)); \ + Log(Logs::Detail, Logs::Netcode, "Wrong size on outbound %s (" #struct_ "): Got %d, expected %d", opcodes->EmuToName((*p)->GetOpcode()), (*p)->size, sizeof(struct_)); \ delete *p; \ *p = nullptr; \ return; \ } #define ENCODE_LENGTH_ATLEAST(struct_) \ if((*p)->size < sizeof(struct_)) { \ - Log.Out(Logs::Detail, Logs::Netcode, "Wrong size on outbound %s (" #struct_ "): Got %d, expected at least %d", opcodes->EmuToName((*p)->GetOpcode()), (*p)->size, sizeof(struct_)); \ + Log(Logs::Detail, Logs::Netcode, "Wrong size on outbound %s (" #struct_ "): Got %d, expected at least %d", opcodes->EmuToName((*p)->GetOpcode()), (*p)->size, sizeof(struct_)); \ delete *p; \ *p = nullptr; \ return; \ @@ -153,13 +153,13 @@ //check length of packet before decoding. Call before setup. #define DECODE_LENGTH_EXACT(struct_) \ if(__packet->size != sizeof(struct_)) { \ - Log.Out(Logs::Detail, Logs::Netcode, "Wrong size on incoming %s (" #struct_ "): Got %d, expected %d", opcodes->EmuToName(__packet->GetOpcode()), __packet->size, sizeof(struct_)); \ + Log(Logs::Detail, Logs::Netcode, "Wrong size on incoming %s (" #struct_ "): Got %d, expected %d", opcodes->EmuToName(__packet->GetOpcode()), __packet->size, sizeof(struct_)); \ __packet->SetOpcode(OP_Unknown); /* invalidate the packet */ \ return; \ } #define DECODE_LENGTH_ATLEAST(struct_) \ if(__packet->size < sizeof(struct_)) { \ - Log.Out(Logs::Detail, Logs::Netcode, "Wrong size on incoming %s (" #struct_ "): Got %d, expected at least %d", opcodes->EmuToName(__packet->GetOpcode()), __packet->size, sizeof(struct_)); \ + Log(Logs::Detail, Logs::Netcode, "Wrong size on incoming %s (" #struct_ "): Got %d, expected at least %d", opcodes->EmuToName(__packet->GetOpcode()), __packet->size, sizeof(struct_)); \ __packet->SetOpcode(OP_Unknown); /* invalidate the packet */ \ return; \ } diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index 1e51568a7..302befb6a 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -78,7 +78,7 @@ namespace Titanium //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); if (!opcodes->LoadOpcodes(opfile.c_str())) { - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name); return; } } @@ -104,7 +104,7 @@ namespace Titanium - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name); } void Reload() @@ -121,10 +121,10 @@ namespace Titanium opfile += name; opfile += ".conf"; if (!opcodes->ReloadOpcodes(opfile.c_str())) { - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name); return; } - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name); } } @@ -219,7 +219,7 @@ namespace Titanium //determine and verify length int entrycount = in->size / sizeof(BazaarSearchResults_Struct); if (entrycount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct)); delete in; return; @@ -319,7 +319,7 @@ namespace Titanium int itemcount = in->size / sizeof(EQEmu::InternalSerializedItem_Struct); if (itemcount == 0 || (in->size % sizeof(EQEmu::InternalSerializedItem_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(EQEmu::InternalSerializedItem_Struct)); delete in; return; @@ -334,7 +334,7 @@ namespace Titanium for (int r = 0; r < itemcount; r++, eq++) { SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0); if (ob.tellp() == last_pos) - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id); last_pos = ob.tellp(); } @@ -820,7 +820,7 @@ namespace Titanium SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0); if (ob.tellp() == last_pos) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id); delete in; return; } @@ -1492,7 +1492,7 @@ namespace Titanium if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct)); delete in; return; } @@ -1610,7 +1610,7 @@ namespace Titanium //determine and verify length int entrycount = in->size / sizeof(Spawn_Struct); if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct)); delete in; return; } @@ -2014,7 +2014,7 @@ namespace Titanium DECODE_LENGTH_EXACT(structs::MoveItem_Struct); SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct); - Log.Out(Logs::General, Logs::Netcode, "[Titanium] Moved item from %u to %u", eq->from_slot, eq->to_slot); + Log(Logs::General, Logs::Netcode, "[Titanium] Moved item from %u to %u", eq->from_slot, eq->to_slot); emu->from_slot = TitaniumToServerSlot(eq->from_slot); emu->to_slot = TitaniumToServerSlot(eq->to_slot); diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index 92bf67146..e2093aef0 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -79,7 +79,7 @@ namespace UF //TODO: figure out how to support shared memory with multiple patches... opcodes = new RegularOpcodeManager(); if (!opcodes->LoadOpcodes(opfile.c_str())) { - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name); return; } } @@ -105,7 +105,7 @@ namespace UF - Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name); + Log(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name); } void Reload() @@ -122,10 +122,10 @@ namespace UF opfile += name; opfile += ".conf"; if (!opcodes->ReloadOpcodes(opfile.c_str())) { - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name); return; } - Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name); + Log(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name); } } @@ -339,7 +339,7 @@ namespace UF if (EntryCount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct)); delete in; return; } @@ -512,7 +512,7 @@ namespace UF int item_count = in->size / sizeof(EQEmu::InternalSerializedItem_Struct); if (!item_count || (in->size % sizeof(EQEmu::InternalSerializedItem_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(EQEmu::InternalSerializedItem_Struct)); delete in; @@ -529,7 +529,7 @@ namespace UF for (int index = 0; index < item_count; ++index, ++eq) { SerializeItem(ob, (const EQEmu::ItemInstance*)eq->inst, eq->slot_id, 0); if (ob.tellp() == last_pos) - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id); last_pos = ob.tellp(); } @@ -1281,7 +1281,7 @@ namespace UF SerializeItem(ob, (const EQEmu::ItemInstance*)int_struct->inst, int_struct->slot_id, 0); if (ob.tellp() == last_pos) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id); delete in; return; } @@ -2572,7 +2572,7 @@ namespace UF if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct)); delete in; return; } @@ -2804,7 +2804,7 @@ namespace UF //determine and verify length int entrycount = in->size / sizeof(Spawn_Struct); if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct)); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct)); delete in; return; } @@ -3624,7 +3624,7 @@ namespace UF DECODE_LENGTH_EXACT(structs::MoveItem_Struct); SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct); - Log.Out(Logs::General, Logs::Netcode, "[UF] Moved item from %u to %u", eq->from_slot, eq->to_slot); + Log(Logs::General, Logs::Netcode, "[UF] Moved item from %u to %u", eq->from_slot, eq->to_slot); emu->from_slot = UFToServerSlot(eq->from_slot); emu->to_slot = UFToServerSlot(eq->to_slot); diff --git a/common/ptimer.cpp b/common/ptimer.cpp index 273ac54d0..5a3d9617f 100644 --- a/common/ptimer.cpp +++ b/common/ptimer.cpp @@ -134,7 +134,7 @@ bool PersistentTimer::Load(Database *db) { (unsigned long)_char_id, _type); auto results = db->QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str()); return false; } @@ -166,7 +166,7 @@ bool PersistentTimer::Store(Database *db) { auto results = db->QueryDatabase(query); if (!results.Success()) { #if EQDEBUG > 5 - Log.Out(Logs::General, Logs::Error, "Error in PersistentTimer::Store, error: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in PersistentTimer::Store, error: %s", results.ErrorMessage().c_str()); #endif return false; } @@ -186,7 +186,7 @@ bool PersistentTimer::Clear(Database *db) { auto results = db->QueryDatabase(query); if (!results.Success()) { #if EQDEBUG > 5 - Log.Out(Logs::General, Logs::Error, "Error in PersistentTimer::Clear, error: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in PersistentTimer::Clear, error: %s", results.ErrorMessage().c_str()); #endif return false; } @@ -198,7 +198,7 @@ bool PersistentTimer::Clear(Database *db) { /* This function checks if the timer triggered */ bool PersistentTimer::Expired(Database *db, bool iReset) { if (this == nullptr) { - Log.Out(Logs::General, Logs::Error, "Null timer during ->Check()!?\n"); + Log(Logs::General, Logs::Error, "Null timer during ->Check()!?\n"); return(true); } uint32 current_time = get_current_time(); @@ -290,7 +290,7 @@ bool PTimerList::Load(Database *db) { auto results = db->QueryDatabase(query); if (!results.Success()) { #if EQDEBUG > 5 - Log.Out(Logs::General, Logs::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str()); #endif return false; } @@ -349,7 +349,7 @@ bool PTimerList::Clear(Database *db) { auto results = db->QueryDatabase(query); if (!results.Success()) { #if EQDEBUG > 5 - Log.Out(Logs::General, Logs::Error, "Error in PersistentTimer::Clear, error: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in PersistentTimer::Clear, error: %s", results.ErrorMessage().c_str()); #endif return false; } @@ -441,7 +441,7 @@ bool PTimerList::ClearOffline(Database *db, uint32 char_id, pTimerType type) { auto results = db->QueryDatabase(query); if (!results.Success()) { #if EQDEBUG > 5 - Log.Out(Logs::General, Logs::Error, "Error in PTimerList::ClearOffline, error: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in PTimerList::ClearOffline, error: %s", results.ErrorMessage().c_str()); #endif return false; } diff --git a/common/rulesys.cpp b/common/rulesys.cpp index 770a1ab97..82d471745 100644 --- a/common/rulesys.cpp +++ b/common/rulesys.cpp @@ -78,7 +78,7 @@ bool RuleManager::ListRules(const char *catname, std::vector &into if (catname != nullptr) { cat = FindCategory(catname); if (cat == InvalidCategory) { - Log.Out(Logs::Detail, Logs::Rules, "Unable to find category '%s'", catname); + Log(Logs::Detail, Logs::Rules, "Unable to find category '%s'", catname); return(false); } } @@ -138,11 +138,11 @@ bool RuleManager::SetRule(const char *rule_name, const char *rule_value, Databas switch(type) { case IntRule: m_RuleIntValues[index] = atoi(rule_value); - Log.Out(Logs::Detail, Logs::Rules, "Set rule %s to value %d", rule_name, m_RuleIntValues[index]); + Log(Logs::Detail, Logs::Rules, "Set rule %s to value %d", rule_name, m_RuleIntValues[index]); break; case RealRule: m_RuleRealValues[index] = atof(rule_value); - Log.Out(Logs::Detail, Logs::Rules, "Set rule %s to value %.13f", rule_name, m_RuleRealValues[index]); + Log(Logs::Detail, Logs::Rules, "Set rule %s to value %.13f", rule_name, m_RuleRealValues[index]); break; case BoolRule: uint32 val = 0; @@ -150,7 +150,7 @@ bool RuleManager::SetRule(const char *rule_name, const char *rule_value, Databas val = 1; m_RuleBoolValues[index] = val; - Log.Out(Logs::Detail, Logs::Rules, "Set rule %s to value %s", rule_name, m_RuleBoolValues[index] == 1 ? "true" : "false"); + Log(Logs::Detail, Logs::Rules, "Set rule %s to value %s", rule_name, m_RuleBoolValues[index] == 1 ? "true" : "false"); break; } @@ -161,7 +161,7 @@ bool RuleManager::SetRule(const char *rule_name, const char *rule_value, Databas } void RuleManager::ResetRules() { - Log.Out(Logs::Detail, Logs::Rules, "Resetting running rules to default values"); + Log(Logs::Detail, Logs::Rules, "Resetting running rules to default values"); #define RULE_INT(cat, rule, default_value) \ m_RuleIntValues[ Int__##rule ] = default_value; #define RULE_REAL(cat, rule, default_value) \ @@ -185,7 +185,7 @@ bool RuleManager::_FindRule(const char *rule_name, RuleType &type_into, uint16 & return(true); } } - Log.Out(Logs::Detail, Logs::Rules, "Unable to find rule '%s'", rule_name); + Log(Logs::Detail, Logs::Rules, "Unable to find rule '%s'", rule_name); return(false); } @@ -212,15 +212,15 @@ void RuleManager::SaveRules(Database *database, const char *ruleset_name) { m_activeRuleset = _FindOrCreateRuleset(database, ruleset_name); if (m_activeRuleset == -1) { - Log.Out(Logs::Detail, Logs::Rules, "Unable to find or create rule set %s", ruleset_name); + Log(Logs::Detail, Logs::Rules, "Unable to find or create rule set %s", ruleset_name); return; } m_activeName = ruleset_name; } - Log.Out(Logs::Detail, Logs::Rules, "Saving running rules into rule set %s (%d)", ruleset_name, m_activeRuleset); + Log(Logs::Detail, Logs::Rules, "Saving running rules into rule set %s (%d)", ruleset_name, m_activeRuleset); } else { - Log.Out(Logs::Detail, Logs::Rules, "Saving running rules into running rule set %s", m_activeName.c_str(), m_activeRuleset); + Log(Logs::Detail, Logs::Rules, "Saving running rules into running rule set %s", m_activeName.c_str(), m_activeRuleset); } int i; @@ -239,11 +239,11 @@ bool RuleManager::LoadRules(Database *database, const char *ruleset_name) { int ruleset_id = GetRulesetID(database, ruleset_name); if (ruleset_id < 0) { - Log.Out(Logs::Detail, Logs::Rules, "Failed to find ruleset '%s' for load operation. Canceling.", ruleset_name); + Log(Logs::Detail, Logs::Rules, "Failed to find ruleset '%s' for load operation. Canceling.", ruleset_name); return(false); } - Log.Out(Logs::Detail, Logs::Rules, "Loading rule set '%s' (%d)", ruleset_name, ruleset_id); + Log(Logs::Detail, Logs::Rules, "Loading rule set '%s' (%d)", ruleset_name, ruleset_id); m_activeRuleset = ruleset_id; m_activeName = ruleset_name; @@ -253,10 +253,10 @@ bool RuleManager::LoadRules(Database *database, const char *ruleset_name) { std::string default_ruleset_name = "default"; int default_ruleset_id = GetRulesetID(database, default_ruleset_name.c_str()); if (default_ruleset_id < 0) { - Log.Out(Logs::Detail, Logs::Rules, "Failed to find default ruleset '%s' for load operation. Canceling.", default_ruleset_name.c_str()); + Log(Logs::Detail, Logs::Rules, "Failed to find default ruleset '%s' for load operation. Canceling.", default_ruleset_name.c_str()); return(false); } - Log.Out(Logs::Detail, Logs::Rules, "Loading rule set '%s' (%d)", default_ruleset_name.c_str(), default_ruleset_id); + Log(Logs::Detail, Logs::Rules, "Loading rule set '%s' (%d)", default_ruleset_name.c_str(), default_ruleset_id); std::string query = StringFormat("SELECT rule_name, rule_value FROM rule_values WHERE ruleset_id = %d", default_ruleset_id); auto results = database->QueryDatabase(query); @@ -265,7 +265,7 @@ bool RuleManager::LoadRules(Database *database, const char *ruleset_name) { for (auto row = results.begin(); row != results.end(); ++row) if (!SetRule(row[0], row[1], nullptr, false)) - Log.Out(Logs::Detail, Logs::Rules, "Unable to interpret rule record for %s", row[0]); + Log(Logs::Detail, Logs::Rules, "Unable to interpret rule record for %s", row[0]); } std::string query = StringFormat("SELECT rule_name, rule_value FROM rule_values WHERE ruleset_id=%d", ruleset_id); @@ -275,7 +275,7 @@ bool RuleManager::LoadRules(Database *database, const char *ruleset_name) { for (auto row = results.begin(); row != results.end(); ++row) if (!SetRule(row[0], row[1], nullptr, false)) - Log.Out(Logs::Detail, Logs::Rules, "Unable to interpret rule record for %s", row[0]); + Log(Logs::Detail, Logs::Rules, "Unable to interpret rule record for %s", row[0]); return true; } diff --git a/common/ruletypes.h b/common/ruletypes.h index a6653da8e..a902109c3 100644 --- a/common/ruletypes.h +++ b/common/ruletypes.h @@ -345,7 +345,7 @@ RULE_INT(Spells, MaxDiscSlotsNPC, 0) // NPCs don't have discs ... RULE_INT(Spells, MaxTotalSlotsNPC, 60) // default to Tit's limit RULE_INT(Spells, MaxTotalSlotsPET, 30) // default to Tit's limit RULE_BOOL (Spells, EnableBlockedBuffs, true) -RULE_INT(Spells, ReflectType, 1) //0 = disabled, 1 = single target player spells only, 2 = all player spells, 3 = all single target spells, 4 = all spells +RULE_INT(Spells, ReflectType, 3) //0 = disabled, 1 = single target player spells only, 2 = all player spells, 3 = all single target spells, 4 = all spells RULE_INT(Spells, VirusSpreadDistance, 30) // The distance a viral spell will jump to its next victim RULE_BOOL(Spells, LiveLikeFocusEffects, true) // Determines whether specific healing, dmg and mana reduction focuses are randomized RULE_INT(Spells, BaseImmunityLevel, 55) // The level that targets start to be immune to stun, fear and mez spells with a max level of 0. @@ -559,6 +559,7 @@ RULE_INT(Range, SpellMessages, 75) RULE_INT(Range, SongMessages, 75) RULE_INT(Range, MobPositionUpdates, 600) RULE_INT(Range, CriticalDamage, 80) +RULE_INT(Range, ClientNPCScan, 300) RULE_CATEGORY_END() diff --git a/common/say_link.cpp b/common/say_link.cpp index 42c0f46a1..923e53407 100644 --- a/common/say_link.cpp +++ b/common/say_link.cpp @@ -98,10 +98,10 @@ std::string EQEmu::SayLinkEngine::GenerateLink() if ((m_Link.length() == 0) || (m_Link.length() > 250)) { m_Error = true; m_Link = ""; - Log.Out(Logs::General, Logs::Error, "TextLink::GenerateLink() failed to generate a useable text link (LinkType: %i, Lengths: {link: %u, body: %u, text: %u})", + Log(Logs::General, Logs::Error, "TextLink::GenerateLink() failed to generate a useable text link (LinkType: %i, Lengths: {link: %u, body: %u, text: %u})", m_LinkType, m_Link.length(), m_LinkBody.length(), m_LinkText.length()); - Log.Out(Logs::General, Logs::Error, ">> LinkBody: %s", m_LinkBody.c_str()); - Log.Out(Logs::General, Logs::Error, ">> LinkText: %s", m_LinkText.c_str()); + Log(Logs::General, Logs::Error, ">> LinkBody: %s", m_LinkBody.c_str()); + Log(Logs::General, Logs::Error, ">> LinkText: %s", m_LinkText.c_str()); } return m_Link; diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 0ef5c5dad..2efb06913 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -429,7 +429,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, EQEmu::InventoryProfile *inv, bool id); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Database::GetSharedBank(uint32 account_id): %s", + Log(Logs::General, Logs::Error, "Database::GetSharedBank(uint32 account_id): %s", results.ErrorMessage().c_str()); return false; } @@ -450,7 +450,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, EQEmu::InventoryProfile *inv, bool const EQEmu::ItemData *item = GetItem(item_id); if (!item) { - Log.Out(Logs::General, Logs::Error, + Log(Logs::General, Logs::Error, "Warning: %s %i has an invalid item_id %i in inventory slot %i", ((is_charid == true) ? "charid" : "acctid"), id, item_id, slot_id); continue; @@ -499,7 +499,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, EQEmu::InventoryProfile *inv, bool if (put_slot_id != INVALID_INDEX) continue; - Log.Out(Logs::General, Logs::Error, + Log(Logs::General, Logs::Error, "Warning: Invalid slot_id for item in shared bank inventory: %s=%i, item_id=%i, slot_id=%i", ((is_charid == true) ? "charid" : "acctid"), id, item_id, slot_id); @@ -521,7 +521,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::InventoryProfile *inv) char_id); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "If you got an error related to the 'instnodrop' field, run the " + Log(Logs::General, Logs::Error, "If you got an error related to the 'instnodrop' field, run the " "following SQL Queries:\nalter table inventory add instnodrop " "tinyint(1) unsigned default 0 not null;\n"); return false; @@ -553,7 +553,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::InventoryProfile *inv) const EQEmu::ItemData *item = GetItem(item_id); if (!item) { - Log.Out(Logs::General, Logs::Error, + Log(Logs::General, Logs::Error, "Warning: charid %i has an invalid item_id %i in inventory slot %i", char_id, item_id, slot_id); continue; @@ -630,7 +630,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::InventoryProfile *inv) put_slot_id = inv->PushCursor(*inst); } else if (slot_id >= 3111 && slot_id <= 3179) { // Admins: please report any occurrences of this error - Log.Out(Logs::General, Logs::Error, "Warning: Defunct location for item in inventory: " + Log(Logs::General, Logs::Error, "Warning: Defunct location for item in inventory: " "charid=%i, item_id=%i, slot_id=%i .. pushing to cursor...", char_id, item_id, slot_id); put_slot_id = inv->PushCursor(*inst); @@ -642,7 +642,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQEmu::InventoryProfile *inv) // Save ptr to item in inventory if (put_slot_id == INVALID_INDEX) { - Log.Out(Logs::General, Logs::Error, + Log(Logs::General, Logs::Error, "Warning: Invalid slot_id for item in inventory: charid=%i, item_id=%i, slot_id=%i", char_id, item_id, slot_id); } @@ -665,7 +665,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char *name, EQEmu::Inventor name, account_id); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "If you got an error related to the 'instnodrop' field, run the " + Log(Logs::General, Logs::Error, "If you got an error related to the 'instnodrop' field, run the " "following SQL Queries:\nalter table inventory add instnodrop " "tinyint(1) unsigned default 0 not null;\n"); return false; @@ -753,7 +753,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char *name, EQEmu::Inventor // Save ptr to item in inventory if (put_slot_id == INVALID_INDEX) - Log.Out(Logs::General, Logs::Error, "Warning: Invalid slot_id for item in inventory: name=%s, " + Log(Logs::General, Logs::Error, "Warning: Invalid slot_id for item in inventory: name=%s, " "acctid=%i, item_id=%i, slot_id=%i", name, account_id, item_id, slot_id); } @@ -830,7 +830,7 @@ bool SharedDatabase::LoadItems(const std::string &prefix) { items_hash = std::unique_ptr>(new EQEmu::FixedMemoryHashSet(reinterpret_cast(items_mmf->Get()), items_mmf->Size())); mutex.Unlock(); } catch(std::exception& ex) { - Log.Out(Logs::General, Logs::Error, "Error Loading Items: %s", ex.what()); + Log(Logs::General, Logs::Error, "Error Loading Items: %s", ex.what()); return false; } @@ -1091,7 +1091,7 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_ try { hash.insert(item.ID, item); } catch (std::exception &ex) { - Log.Out(Logs::General, Logs::Error, "Database::LoadItems: %s", ex.what()); + Log(Logs::General, Logs::Error, "Database::LoadItems: %s", ex.what()); break; } } @@ -1150,7 +1150,7 @@ std::string SharedDatabase::GetBook(const char *txtfile, int16 *language) } if (results.RowCount() == 0) { - Log.Out(Logs::General, Logs::Error, "No book to send, (%s)", txtfile); + Log(Logs::General, Logs::Error, "No book to send, (%s)", txtfile); txtout.assign(" ",1); return txtout; } @@ -1255,7 +1255,7 @@ bool SharedDatabase::LoadNPCFactionLists(const std::string &prefix) { faction_hash = std::unique_ptr>(new EQEmu::FixedMemoryHashSet(reinterpret_cast(faction_mmf->Get()), faction_mmf->Size())); mutex.Unlock(); } catch(std::exception& ex) { - Log.Out(Logs::General, Logs::Error, "Error Loading npc factions: %s", ex.what()); + Log(Logs::General, Logs::Error, "Error Loading npc factions: %s", ex.what()); return false; } @@ -1273,8 +1273,8 @@ EQEmu::ItemInstance* SharedDatabase::CreateItem(uint32 item_id, int16 charges, u inst = CreateBaseItem(item, charges); if (inst == nullptr) { - Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateItem()"); - Log.Out(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges); + Log(Logs::General, Logs::Error, "Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateItem()"); + Log(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges); return nullptr; } @@ -1299,8 +1299,8 @@ EQEmu::ItemInstance* SharedDatabase::CreateItem(const EQEmu::ItemData* item, int inst = CreateBaseItem(item, charges); if (inst == nullptr) { - Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateItem()"); - Log.Out(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges); + Log(Logs::General, Logs::Error, "Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateItem()"); + Log(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges); return nullptr; } @@ -1330,8 +1330,8 @@ EQEmu::ItemInstance* SharedDatabase::CreateBaseItem(const EQEmu::ItemData* item, inst = new EQEmu::ItemInstance(item, charges); if (inst == nullptr) { - Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateBaseItem()"); - Log.Out(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges); + Log(Logs::General, Logs::Error, "Error: valid item data returned a null reference for EQEmu::ItemInstance creation in SharedDatabase::CreateBaseItem()"); + Log(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges); return nullptr; } @@ -1406,7 +1406,7 @@ bool SharedDatabase::LoadSkillCaps(const std::string &prefix) { skill_caps_mmf = std::unique_ptr(new EQEmu::MemoryMappedFile(file_name)); mutex.Unlock(); } catch(std::exception &ex) { - Log.Out(Logs::General, Logs::Error, "Error loading skill caps: %s", ex.what()); + Log(Logs::General, Logs::Error, "Error loading skill caps: %s", ex.what()); return false; } @@ -1422,7 +1422,7 @@ void SharedDatabase::LoadSkillCaps(void *data) { const std::string query = "SELECT skillID, class, level, cap FROM skill_caps ORDER BY skillID, class, level"; auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error loading skill caps from database: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error loading skill caps from database: %s", results.ErrorMessage().c_str()); return; } @@ -1566,7 +1566,7 @@ bool SharedDatabase::LoadSpells(const std::string &prefix, int32 *records, const mutex.Unlock(); } catch(std::exception& ex) { - Log.Out(Logs::General, Logs::Error, "Error Loading Spells: %s", ex.what()); + Log(Logs::General, Logs::Error, "Error Loading Spells: %s", ex.what()); return false; } return true; @@ -1583,7 +1583,7 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) { } if(results.ColumnCount() <= SPELL_LOAD_FIELD_COUNT) { - Log.Out(Logs::Detail, Logs::Spells, "Fatal error loading spells: Spell field count < SPELL_LOAD_FIELD_COUNT(%u)", SPELL_LOAD_FIELD_COUNT); + Log(Logs::Detail, Logs::Spells, "Fatal error loading spells: Spell field count < SPELL_LOAD_FIELD_COUNT(%u)", SPELL_LOAD_FIELD_COUNT); return; } @@ -1593,7 +1593,7 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) { for (auto row = results.begin(); row != results.end(); ++row) { tempid = atoi(row[0]); if(tempid >= max_spells) { - Log.Out(Logs::Detail, Logs::Spells, "Non fatal error: spell.id >= max_spells, ignoring."); + Log(Logs::Detail, Logs::Spells, "Non fatal error: spell.id >= max_spells, ignoring."); continue; } @@ -1769,7 +1769,7 @@ bool SharedDatabase::LoadBaseData(const std::string &prefix) { base_data_mmf = std::unique_ptr(new EQEmu::MemoryMappedFile(file_name)); mutex.Unlock(); } catch(std::exception& ex) { - Log.Out(Logs::General, Logs::Error, "Error Loading Base Data: %s", ex.what()); + Log(Logs::General, Logs::Error, "Error Loading Base Data: %s", ex.what()); return false; } @@ -1793,22 +1793,22 @@ void SharedDatabase::LoadBaseData(void *data, int max_level) { cl = atoi(row[1]); if(lvl <= 0) { - Log.Out(Logs::General, Logs::Error, "Non fatal error: base_data.level <= 0, ignoring."); + Log(Logs::General, Logs::Error, "Non fatal error: base_data.level <= 0, ignoring."); continue; } if(lvl >= max_level) { - Log.Out(Logs::General, Logs::Error, "Non fatal error: base_data.level >= max_level, ignoring."); + Log(Logs::General, Logs::Error, "Non fatal error: base_data.level >= max_level, ignoring."); continue; } if(cl <= 0) { - Log.Out(Logs::General, Logs::Error, "Non fatal error: base_data.cl <= 0, ignoring."); + Log(Logs::General, Logs::Error, "Non fatal error: base_data.cl <= 0, ignoring."); continue; } if(cl > 16) { - Log.Out(Logs::General, Logs::Error, "Non fatal error: base_data.class > 16, ignoring."); + Log(Logs::General, Logs::Error, "Non fatal error: base_data.class > 16, ignoring."); continue; } @@ -2016,7 +2016,7 @@ bool SharedDatabase::LoadLoot(const std::string &prefix) { loot_drop_mmf->Size())); mutex.Unlock(); } catch(std::exception &ex) { - Log.Out(Logs::General, Logs::Error, "Error loading loot: %s", ex.what()); + Log(Logs::General, Logs::Error, "Error loading loot: %s", ex.what()); return false; } @@ -2032,7 +2032,7 @@ const LootTable_Struct* SharedDatabase::GetLootTable(uint32 loottable_id) { return &loot_table_hash->at(loottable_id); } } catch(std::exception &ex) { - Log.Out(Logs::General, Logs::Error, "Could not get loot table: %s", ex.what()); + Log(Logs::General, Logs::Error, "Could not get loot table: %s", ex.what()); } return nullptr; } @@ -2046,7 +2046,7 @@ const LootDrop_Struct* SharedDatabase::GetLootDrop(uint32 lootdrop_id) { return &loot_drop_hash->at(lootdrop_id); } } catch(std::exception &ex) { - Log.Out(Logs::General, Logs::Error, "Could not get loot drop: %s", ex.what()); + Log(Logs::General, Logs::Error, "Could not get loot drop: %s", ex.what()); } return nullptr; } diff --git a/common/spdat.cpp b/common/spdat.cpp index e88240ef9..064b8fb61 100644 --- a/common/spdat.cpp +++ b/common/spdat.cpp @@ -851,7 +851,7 @@ DmgShieldType GetDamageShieldType(uint16 spell_id, int32 DSType) // If we have a DamageShieldType for this spell from the damageshieldtypes table, return that, // else, make a guess, based on the resist type. Default return value is DS_THORNS if (IsValidSpell(spell_id)) { - Log.Out(Logs::Detail, Logs::Spells, "DamageShieldType for spell %i (%s) is %X\n", spell_id, + Log(Logs::Detail, Logs::Spells, "DamageShieldType for spell %i (%s) is %X\n", spell_id, spells[spell_id].name, spells[spell_id].DamageShieldType); if (spells[spell_id].DamageShieldType) diff --git a/common/struct_strategy.cpp b/common/struct_strategy.cpp index e1561de18..58a7f9e76 100644 --- a/common/struct_strategy.cpp +++ b/common/struct_strategy.cpp @@ -41,13 +41,13 @@ void StructStrategy::ErrorEncoder(EQApplicationPacket **in_p, std::shared_ptrGetOpcode())); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Error encoding opcode %s: no encoder provided. Dropping.", OpcodeManager::EmuToName(p->GetOpcode())); delete p; } void StructStrategy::ErrorDecoder(EQApplicationPacket *p) { - Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Error decoding opcode %s: no decoder provided. Invalidating.", OpcodeManager::EmuToName(p->GetOpcode())); + Log(Logs::General, Logs::Netcode, "[STRUCTS] Error decoding opcode %s: no decoder provided. Invalidating.", OpcodeManager::EmuToName(p->GetOpcode())); p->SetOpcode(OP_Unknown); } diff --git a/common/tcp_connection.cpp b/common/tcp_connection.cpp new file mode 100644 index 000000000..3a4439911 --- /dev/null +++ b/common/tcp_connection.cpp @@ -0,0 +1,942 @@ +/* EQEMu: Everquest Server Emulator + Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "../common/global_define.h" +#include "../common/eqemu_logsys.h" + +#include +#include +#include + +#include "tcp_connection.h" + +#ifdef FREEBSD //Timothy Whitman - January 7, 2003 + #define MSG_NOSIGNAL 0 +#endif +#ifdef DARWIN + #define MSG_NOSIGNAL SO_NOSIGPIPE // Corysia Taware - Sept. 27, 2013 + // See http://lists.apple.com/archives/macnetworkprog/2002/Dec/msg00091.html +#endif // DARWIN + +#ifdef _WINDOWS +InitWinsock winsock; +#endif + +#define LOOP_GRANULARITY 3 //# of ms between checking our socket/queues + +#define TCPN_DEBUG 0 +#define TCPN_DEBUG_Console 0 +#define TCPN_DEBUG_Memory 0 +#define TCPN_LOG_RAW_DATA_OUT 0 //1 = info, 2 = length limited dump, 3 = full dump +#define TCPN_LOG_RAW_DATA_IN 0 //1 = info, 2 = length limited dump, 3 = full dump + +//client version +TCPConnection::TCPConnection() +: ConnectionType(Outgoing), + connection_socket(0), + id(0), + rIP(0), + rPort(0) +{ + pState = TCPS_Ready; + pFree = false; + pEcho = false; + recvbuf = nullptr; + sendbuf = nullptr; + pRunLoop = false; + charAsyncConnect = 0; + pAsyncConnect = false; + m_previousLineEnd = false; +#if TCPN_DEBUG_Memory >= 7 + std::cout << "Constructor #2 on outgoing TCP# " << GetID() << std::endl; +#endif +} + +//server version +TCPConnection::TCPConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) +: ConnectionType(Incoming), + connection_socket(in_socket), + id(ID), + rIP(irIP), + rPort(irPort) +{ + pState = TCPS_Connected; + pFree = false; + pEcho = false; + recvbuf = nullptr; + sendbuf = nullptr; + pRunLoop = false; + charAsyncConnect = 0; + pAsyncConnect = false; + m_previousLineEnd = false; +#if TCPN_DEBUG_Memory >= 7 + std::cout << "Constructor #2 on incoming TCP# " << GetID() << std::endl; +#endif +} + +TCPConnection::~TCPConnection() { + FinishDisconnect(); + ClearBuffers(); + if (ConnectionType == Outgoing) { + MRunLoop.lock(); + pRunLoop = false; + MRunLoop.unlock(); + MLoopRunning.lock(); + MLoopRunning.unlock(); +#if TCPN_DEBUG_Memory >= 6 + std::cout << "Deconstructor on outgoing TCP# " << GetID() << std::endl; +#endif + } +#if TCPN_DEBUG_Memory >= 5 + else { + std::cout << "Deconstructor on incoming TCP# " << GetID() << std::endl; + } +#endif + safe_delete_array(recvbuf); + safe_delete_array(sendbuf); + safe_delete_array(charAsyncConnect); +} + +void TCPConnection::SetState(State_t in_state) { + MState.lock(); + pState = in_state; + MState.unlock(); +} + +TCPConnection::State_t TCPConnection::GetState() const { + State_t ret; + MState.lock(); + ret = pState; + MState.unlock(); + return ret; +} + +bool TCPConnection::GetSockName(char *host, uint16 *port) +{ + bool result=false; + LockMutex lock(&MState); + if (!Connected()) + return false; + + struct sockaddr_in local; + +#ifdef _WINDOWS + int addrlen; +#else +#ifdef FREEBSD + socklen_t addrlen; +#else + size_t addrlen; +#endif +#endif + addrlen=sizeof(struct sockaddr_in); +#ifdef _WINDOWS + if (!getsockname(connection_socket,(struct sockaddr *)&local,&addrlen)) { +#else + if (!getsockname(connection_socket,(struct sockaddr *)&local,(socklen_t *)&addrlen)) { +#endif + unsigned long ip=local.sin_addr.s_addr; + sprintf(host,"%d.%d.%d.%d", + *(unsigned char *)&ip, + *((unsigned char *)&ip+1), + *((unsigned char *)&ip+2), + *((unsigned char *)&ip+3)); + *port=ntohs(local.sin_port); + + result=true; + } + + return result; +} + +void TCPConnection::Free() { + Disconnect(); + pFree = true; +} + +bool TCPConnection::Send(const uchar* data, int32 size) { + if (!Connected()) + return false; + if (!size) + return true; + ServerSendQueuePushEnd(data, size); + return true; +} + +void TCPConnection::ServerSendQueuePushEnd(const uchar* data, int32 size) { + MSendQueue.lock(); + if (sendbuf == nullptr) { + sendbuf = new uchar[size]; + sendbuf_size = size; + sendbuf_used = 0; + } + else if (size > (sendbuf_size - sendbuf_used)) { + sendbuf_size += size + 1024; + auto tmp = new uchar[sendbuf_size]; + memcpy(tmp, sendbuf, sendbuf_used); + safe_delete_array(sendbuf); + sendbuf = tmp; + } + memcpy(&sendbuf[sendbuf_used], data, size); + sendbuf_used += size; + MSendQueue.unlock(); +} + +void TCPConnection::ServerSendQueuePushEnd(uchar** data, int32 size) { + MSendQueue.lock(); + if (sendbuf == 0) { + sendbuf = *data; + sendbuf_size = size; + sendbuf_used = size; + MSendQueue.unlock(); + *data = 0; + return; + } + if (size > (sendbuf_size - sendbuf_used)) { + sendbuf_size += size; + auto tmp = new uchar[sendbuf_size]; + memcpy(tmp, sendbuf, sendbuf_used); + safe_delete_array(sendbuf); + sendbuf = tmp; + } + memcpy(&sendbuf[sendbuf_used], *data, size); + sendbuf_used += size; + MSendQueue.unlock(); + safe_delete_array(*data); +} + +void TCPConnection::ServerSendQueuePushFront(uchar* data, int32 size) { + MSendQueue.lock(); + if (sendbuf == 0) { + sendbuf = new uchar[size]; + sendbuf_size = size; + sendbuf_used = 0; + } + else if (size > (sendbuf_size - sendbuf_used)) { + sendbuf_size += size; + auto tmp = new uchar[sendbuf_size]; + memcpy(&tmp[size], sendbuf, sendbuf_used); + safe_delete_array(sendbuf); + sendbuf = tmp; + } + memcpy(sendbuf, data, size); + sendbuf_used += size; + MSendQueue.unlock(); +} + +bool TCPConnection::ServerSendQueuePop(uchar** data, int32* size) { + bool ret; + if (!MSendQueue.trylock()) + return false; + if (sendbuf) { + *data = sendbuf; + *size = sendbuf_used; + sendbuf = 0; + ret = true; + } + else { + ret = false; + } + MSendQueue.unlock(); + return ret; +} + +bool TCPConnection::ServerSendQueuePopForce(uchar** data, int32* size) { + bool ret; + MSendQueue.lock(); + if (sendbuf) { + *data = sendbuf; + *size = sendbuf_used; + sendbuf = 0; + ret = true; + } + else { + ret = false; + } + MSendQueue.unlock(); + return ret; +} + +char* TCPConnection::PopLine() { + char* ret; + if (!MLineOutQueue.trylock()) + return 0; + ret = (char*) LineOutQueue.pop(); + MLineOutQueue.unlock(); + return ret; +} + +bool TCPConnection::LineOutQueuePush(char* line) { + MLineOutQueue.lock(); + LineOutQueue.push(line); + MLineOutQueue.unlock(); + return(false); +} + + +void TCPConnection::FinishDisconnect() { + MState.lock(); + if (connection_socket != INVALID_SOCKET && connection_socket != 0) { + if (pState == TCPS_Connected || pState == TCPS_Disconnecting || pState == TCPS_Disconnected) { + bool sent_something = false; + SendData(sent_something); + } + pState = TCPS_Closing; + shutdown(connection_socket, 0x01); + shutdown(connection_socket, 0x00); +#ifdef _WINDOWS + closesocket(connection_socket); +#else + close(connection_socket); +#endif + connection_socket = 0; + rIP = 0; + rPort = 0; + ClearBuffers(); + } + pState = TCPS_Disconnected; + MState.unlock(); +} + +void TCPConnection::Disconnect() { + MState.lock(); + if(pState == TCPS_Connected || pState == TCPS_Connecting) { + pState = TCPS_Disconnecting; + } + MState.unlock(); +} + +bool TCPConnection::GetAsyncConnect() { + bool ret; + MAsyncConnect.lock(); + ret = pAsyncConnect; + MAsyncConnect.unlock(); + return ret; +} + +bool TCPConnection::SetAsyncConnect(bool iValue) { + bool ret; + MAsyncConnect.lock(); + ret = pAsyncConnect; + pAsyncConnect = iValue; + MAsyncConnect.unlock(); + return ret; +} + +bool TCPConnection::ConnectReady() const { + State_t s = GetState(); + if (s != TCPS_Ready && s != TCPS_Disconnected) + return(false); + return(ConnectionType == Outgoing); +} + +void TCPConnection::AsyncConnect(const char* irAddress, uint16 irPort) { + safe_delete_array(charAsyncConnect); + charAsyncConnect = new char[strlen(irAddress) + 1]; + strcpy(charAsyncConnect, irAddress); + AsyncConnect((uint32) 0, irPort); +} + +void TCPConnection::AsyncConnect(uint32 irIP, uint16 irPort) { + if (ConnectionType != Outgoing) { + // If this code runs, we got serious problems + // Crash and burn. + return; + } + if(!ConnectReady()) { +#if TCPN_DEBUG > 0 + printf("Trying to do async connect in invalid state %s\n", GetState()); +#endif + return; + } + MAsyncConnect.lock(); + if (pAsyncConnect) { + MAsyncConnect.unlock(); +#if TCPN_DEBUG > 0 + printf("Trying to do async connect when already doing one.\n"); +#endif + return; + } +#if TCPN_DEBUG > 0 + printf("Start async connect.\n"); +#endif + pAsyncConnect = true; + if(irIP != 0) + safe_delete_array(charAsyncConnect); + rIP = irIP; + rPort = irPort; + MAsyncConnect.unlock(); + if (!pRunLoop) { + pRunLoop = true; +#ifdef _WINDOWS + _beginthread(TCPConnectionLoop, 0, this); +#else + pthread_t thread; + pthread_create(&thread, nullptr, TCPConnectionLoop, this); +#endif + } + return; +} + +bool TCPConnection::Connect(const char* irAddress, uint16 irPort, char* errbuf) { + if (errbuf) + errbuf[0] = 0; + uint32 tmpIP = ResolveIP(irAddress); + if (!tmpIP) { + if (errbuf) { +#ifdef _WINDOWS + snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::Connect(): Couldnt resolve hostname. Error: %i", WSAGetLastError()); +#else + snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::Connect(): Couldnt resolve hostname. Error #%i: %s", errno, strerror(errno)); +#endif + } + return false; + } + return ConnectIP(tmpIP, irPort, errbuf); +} + +bool TCPConnection::ConnectIP(uint32 in_ip, uint16 in_port, char* errbuf) { + if (errbuf) + errbuf[0] = 0; + if (ConnectionType != Outgoing) { + // If this code runs, we got serious problems + // Crash and burn. + return false; + } + MState.lock(); + if (ConnectReady()) { + pState = TCPS_Connecting; + } else { + MState.unlock(); + SetAsyncConnect(false); + return false; + } + MState.unlock(); + if (!pRunLoop) { + pRunLoop = true; +#ifdef _WINDOWS + _beginthread(TCPConnectionLoop, 0, this); +#else + pthread_t thread; + pthread_create(&thread, nullptr, TCPConnectionLoop, this); +#endif + } + + connection_socket = INVALID_SOCKET; + struct sockaddr_in server_sin; + //struct in_addr in; + + if ((connection_socket = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET || connection_socket == 0) { +#ifdef _WINDOWS + if (errbuf) + snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::Connect(): Allocating socket failed. Error: %i", WSAGetLastError()); +#else + if (errbuf) + snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::Connect(): Allocating socket failed. Error: %s", strerror(errno)); +#endif + SetState(TCPS_Ready); + SetAsyncConnect(false); + return false; + } + server_sin.sin_family = AF_INET; + server_sin.sin_addr.s_addr = in_ip; + server_sin.sin_port = htons(in_port); + + // Establish a connection to the server socket. +#ifdef _WINDOWS + if (connect(connection_socket, (PSOCKADDR) &server_sin, sizeof (server_sin)) == SOCKET_ERROR) { + if (errbuf) + snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::Connect(): connect() failed. Error: %i", WSAGetLastError()); + closesocket(connection_socket); + connection_socket = 0; + SetState(TCPS_Ready); + SetAsyncConnect(false); + return false; + } +#else + if (connect(connection_socket, (struct sockaddr *) &server_sin, sizeof (server_sin)) == SOCKET_ERROR) { + if (errbuf) + snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::Connect(): connect() failed. Error: %s", strerror(errno)); + close(connection_socket); + connection_socket = 0; + SetState(TCPS_Ready); + SetAsyncConnect(false); + return false; + } +#endif + int bufsize = 64 * 1024; // 64kbyte recieve buffer, up from default of 8k + setsockopt(connection_socket, SOL_SOCKET, SO_RCVBUF, (char*) &bufsize, sizeof(bufsize)); +#ifdef _WINDOWS + unsigned long nonblocking = 1; + ioctlsocket(connection_socket, FIONBIO, &nonblocking); +#else + fcntl(connection_socket, F_SETFL, O_NONBLOCK); +#endif + + SetEcho(false); + ClearBuffers(); + + rIP = in_ip; + rPort = in_port; + SetState(TCPS_Connected); + SetAsyncConnect(false); + return true; +} + +void TCPConnection::ClearBuffers() { + LockMutex lock1(&MSendQueue); + LockMutex lock3(&MRunLoop); + LockMutex lock4(&MState); + safe_delete_array(recvbuf); + safe_delete_array(sendbuf); + + char* line = 0; + while ((line = LineOutQueue.pop())) + safe_delete_array(line); +} + +bool TCPConnection::CheckNetActive() { + MState.lock(); + if (pState == TCPS_Connected || pState == TCPS_Disconnecting) { + MState.unlock(); + return true; + } + MState.unlock(); + return false; +} + +/* This is always called from an IO thread. Either the server socket's thread, or a + * special thread we create when we make an outbound connection. */ +bool TCPConnection::Process() { + char errbuf[TCPConnection_ErrorBufferSize]; + switch(GetState()) { + case TCPS_Ready: + case TCPS_Connecting: + if (ConnectionType == Outgoing) { + if (GetAsyncConnect()) { + if (charAsyncConnect) + rIP = ResolveIP(charAsyncConnect); + ConnectIP(rIP, rPort); + } + } + return(true); + + case TCPS_Connected: + // only receive data in the connected state, no others... + if (!RecvData(errbuf)) { + struct in_addr in; + in.s_addr = GetrIP(); + return false; + } + /* we break to do the send */ + break; + + case TCPS_Disconnecting: { + //waiting for any sending data to go out... + MSendQueue.lock(); + if(sendbuf) { + if(sendbuf_used > 0) { + //something left to send, keep processing... + MSendQueue.unlock(); + break; + } + //else, send buffer is empty. + safe_delete_array(sendbuf); + } //else, no send buffer, we are done. + MSendQueue.unlock(); + } + /* Fallthrough */ + + case TCPS_Disconnected: + FinishDisconnect(); + MRunLoop.lock(); + pRunLoop = false; + MRunLoop.unlock(); +// SetState(TCPS_Ready); //reset the state in case they want to use it again... + return(false); + + case TCPS_Closing: + //I dont understand this state... + + case TCPS_Error: + MRunLoop.lock(); + pRunLoop = false; + MRunLoop.unlock(); + return(false); + } + + /* we get here in connected or disconnecting with more data to send */ + + bool sent_something = false; + if (!SendData(sent_something, errbuf)) { + struct in_addr in; + in.s_addr = GetrIP(); + std::cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << std::endl; + return false; + } + + return true; +} + +bool TCPConnection::RecvData(char* errbuf) { + if (errbuf) + errbuf[0] = 0; + if (!Connected()) { + return false; + } + + int status = 0; + if (recvbuf == 0) { + recvbuf = new uchar[5120]; + recvbuf_size = 5120; + recvbuf_used = 0; + recvbuf_echo = 0; + } + else if ((recvbuf_size - recvbuf_used) < 2048) { + auto tmpbuf = new uchar[recvbuf_size + 5120]; + memcpy(tmpbuf, recvbuf, recvbuf_used); + recvbuf_size += 5120; + safe_delete_array(recvbuf); + recvbuf = tmpbuf; + if (recvbuf_size >= MaxTCPReceiveBuffferSize) { + if (errbuf) + snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::RecvData(): recvbuf_size >= MaxTCPReceiveBuffferSize"); + return false; + } + } + + status = recv(connection_socket, (char *) &recvbuf[recvbuf_used], (recvbuf_size - recvbuf_used), 0); + + if (status >= 1) { +#if TCPN_LOG_RAW_DATA_IN >= 1 + struct in_addr in; + in.s_addr = GetrIP(); + CoutTimestamp(true); + std::cout << ": Read " << status << " bytes from network. (recvbuf_used = " << recvbuf_used << ") " << inet_ntoa(in) << ":" << GetrPort(); + std::cout << std::endl; + #if TCPN_LOG_RAW_DATA_IN == 2 + int32 tmp = status; + if (tmp > 32) + tmp = 32; + DumpPacket(&recvbuf[recvbuf_used], status); + #elif TCPN_LOG_RAW_DATA_IN >= 3 + DumpPacket(&recvbuf[recvbuf_used], status); + #endif +#endif + recvbuf_used += status; + if (!ProcessReceivedData(errbuf)) + return false; + } + else if (status == SOCKET_ERROR) { +#ifdef _WINDOWS + if (!(WSAGetLastError() == WSAEWOULDBLOCK)) { + if (errbuf) + snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::RecvData(): Error: %i", WSAGetLastError()); + return false; + } +#else + if (!(errno == EWOULDBLOCK)) { + if (errbuf) + snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::RecvData(): Error: %s", strerror(errno)); + return false; + } +#endif + } else if (status == 0) { + snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::RecvData(): Connection closed"); + return false; + } + + return true; +} + + +bool TCPConnection::GetEcho() { + bool ret; + ret = pEcho; + return ret; +} + +void TCPConnection::SetEcho(bool iValue) { + pEcho = iValue; +} + +bool TCPConnection::ProcessReceivedData(char* errbuf) { + if (errbuf) + errbuf[0] = 0; + if (!recvbuf) + return true; +#if TCPN_DEBUG_Console >= 4 + if (recvbuf_used) { + std::cout << "Starting Processing: recvbuf=" << recvbuf_used << std::endl; + DumpPacket(recvbuf, recvbuf_used); + } +#endif + for (int i=0; i < recvbuf_used; i++) { + if (GetEcho() && i >= recvbuf_echo) { + Send(&recvbuf[i], 1); + recvbuf_echo = i + 1; + } + switch(recvbuf[i]) { + case 0: { // 0 is the code for clear buffer + if (i==0) { + recvbuf_used--; + recvbuf_echo--; + memmove(recvbuf, &recvbuf[1], recvbuf_used); + i = -1; + } else { + if (i == recvbuf_used) { + safe_delete_array(recvbuf); + i = -1; + } + else { + uchar* tmpdel = recvbuf; + recvbuf = new uchar[recvbuf_size]; + memcpy(recvbuf, &tmpdel[i+1], recvbuf_used-i); + recvbuf_used -= i + 1; + recvbuf_echo -= i + 1; + safe_delete_array(tmpdel); + i = -1; + } + } +#if TCPN_DEBUG_Console >= 5 + std::cout << "Removed 0x00" << std::endl; + if (recvbuf_used) { + std::cout << "recvbuf left: " << recvbuf_used << std::endl; + DumpPacket(recvbuf, recvbuf_used); + } + else + std::cout << "recbuf left: None" << std::endl; +#endif + m_previousLineEnd = false; + break; + } + case 10: + case 13: // newline marker + { + char *line = nullptr; + if (i==0) { // empty line + if(!m_previousLineEnd) { + //char right before this was NOT a CR, report the empty line. + line = new char[1]; + line[0] = '\0'; + m_previousLineEnd = true; + } else { + m_previousLineEnd = false; + } + recvbuf_used--; + recvbuf_echo--; + memcpy(recvbuf, &recvbuf[1], recvbuf_used); + i = -1; + } else { + line = new char[i+1]; + memset(line, 0, i+1); + memcpy(line, recvbuf, i); +#if TCPN_DEBUG_Console >= 3 + std::cout << "Line Out: " << std::endl; + DumpPacket((uchar*) line, i); +#endif + //line[i] = 0; + uchar* tmpdel = recvbuf; + recvbuf = new uchar[recvbuf_size]; + recvbuf_used -= i+1; + recvbuf_echo -= i+1; + memcpy(recvbuf, &tmpdel[i+1], recvbuf_used); +#if TCPN_DEBUG_Console >= 5 + std::cout << "i+1=" << i+1 << std::endl; + if (recvbuf_used) { + std::cout << "recvbuf left: " << recvbuf_used << std::endl; + DumpPacket(recvbuf, recvbuf_used); + } + else + std::cout << "recbuf left: None" << std::endl; +#endif + safe_delete_array(tmpdel); + i = -1; + m_previousLineEnd = true; + } + + + if(line != nullptr) { + bool finish_proc = false; + finish_proc = LineOutQueuePush(line); + if(finish_proc) + return(true); //break early as requested by LineOutQueuePush + } + + break; + } + case 8: // backspace + { + if (i==0) { // nothin to backspace + recvbuf_used--; + recvbuf_echo--; + memmove(recvbuf, &recvbuf[1], recvbuf_used); + i = -1; + } else { + uchar* tmpdel = recvbuf; + recvbuf = new uchar[recvbuf_size]; + memcpy(recvbuf, tmpdel, i-1); + memcpy(&recvbuf[i-1], &tmpdel[i+1], recvbuf_used-i); + recvbuf_used -= 2; + recvbuf_echo -= 2; + safe_delete_array(tmpdel); + i -= 2; + } + break; + m_previousLineEnd = false; + } + default: + m_previousLineEnd = false; + } + } + if (recvbuf_used < 0) + safe_delete_array(recvbuf); + return true; +} + +bool TCPConnection::SendData(bool &sent_something, char* errbuf) { + if (errbuf) + errbuf[0] = 0; + /************ Get first send packet on queue and send it! ************/ + uchar* data = 0; + int32 size = 0; + int status = 0; + if (ServerSendQueuePop(&data, &size)) { +#ifdef _WINDOWS + status = send(connection_socket, (const char *) data, size, 0); +#else + status = send(connection_socket, data, size, MSG_NOSIGNAL); + if(errno==EPIPE) status = SOCKET_ERROR; +#endif + if (status >= 1) { +#if TCPN_LOG_RAW_DATA_OUT >= 1 + struct in_addr in; + in.s_addr = GetrIP(); + CoutTimestamp(true); + std::cout << ": Wrote " << status << " bytes to network. " << inet_ntoa(in) << ":" << GetrPort(); + std::cout << std::endl; + #if TCPN_LOG_RAW_DATA_OUT == 2 + int32 tmp = status; + if (tmp > 32) + tmp = 32; + DumpPacket(data, status); + #elif TCPN_LOG_RAW_DATA_OUT >= 3 + DumpPacket(data, status); + #endif +#endif + sent_something = true; + if (status < (signed)size) { +#if TCPN_LOG_RAW_DATA_OUT >= 1 + struct in_addr in; + in.s_addr = GetrIP(); + CoutTimestamp(true); + std::cout << ": Pushed " << (size - status) << " bytes back onto the send queue. " << inet_ntoa(in) << ":" << GetrPort(); + std::cout << std::endl; +#endif + // If there's network congestion, the number of bytes sent can be less than + // what we tried to give it... Push the extra back on the queue for later + ServerSendQueuePushFront(&data[status], size - status); + } + else if (status > (signed)size) { + return false; + } + // else if (status == size) {} + } + else { + ServerSendQueuePushFront(data, size); + } + + safe_delete_array(data); + if (status == SOCKET_ERROR) { +#ifdef _WINDOWS + if (WSAGetLastError() != WSAEWOULDBLOCK) +#else + if (errno != EWOULDBLOCK) +#endif + { + if (errbuf) { +#ifdef _WINDOWS + snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::SendData(): send(): Errorcode: %i", WSAGetLastError()); +#else + snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::SendData(): send(): Errorcode: %s", strerror(errno)); +#endif + } + + //if we get an error while disconnecting, just jump to disconnected + MState.lock(); + if(pState == TCPS_Disconnecting) + pState = TCPS_Disconnected; + MState.unlock(); + + return false; + } + } + } + return true; +} + +ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) { +#ifdef _WINDOWS + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); +#endif + if (tmp == 0) { + THREAD_RETURN(nullptr); + } + TCPConnection* tcpc = (TCPConnection*) tmp; +#ifndef WIN32 + Log(Logs::Detail, Logs::TCP_Connection, "%s Starting TCPConnectionLoop with thread ID %d", __FUNCTION__, pthread_self()); +#endif + tcpc->MLoopRunning.lock(); + while (tcpc->RunLoop()) { + Sleep(LOOP_GRANULARITY); + if (!tcpc->ConnectReady()) { + if (!tcpc->Process()) { + //the processing loop has detecting an error.. + //we want to drop the link immediately, so we clear buffers too. + tcpc->ClearBuffers(); + tcpc->Disconnect(); + } + Sleep(1); + } + else if (tcpc->GetAsyncConnect()) { + if (tcpc->charAsyncConnect) + tcpc->Connect(tcpc->charAsyncConnect, tcpc->GetrPort()); + else + tcpc->ConnectIP(tcpc->GetrIP(), tcpc->GetrPort()); + tcpc->SetAsyncConnect(false); + } + else + Sleep(10); //nothing to do. + } + tcpc->MLoopRunning.unlock(); + +#ifndef WIN32 + Log(Logs::Detail, Logs::TCP_Connection, "%s Ending TCPConnectionLoop with thread ID %d", __FUNCTION__, pthread_self()); +#endif + + THREAD_RETURN(nullptr); +} + +bool TCPConnection::RunLoop() { + bool ret; + MRunLoop.lock(); + ret = pRunLoop; + MRunLoop.unlock(); + return ret; +} + diff --git a/common/tcp_server.cpp b/common/tcp_server.cpp new file mode 100644 index 000000000..d036e7626 --- /dev/null +++ b/common/tcp_server.cpp @@ -0,0 +1,231 @@ +#include "global_define.h" +#include "tcp_server.h" +#include "../common/eqemu_logsys.h" + +#include +#include +#include + +#ifdef _WINDOWS + #include +#else + #include + #include + #include + #include + #include + #define INVALID_SOCKET -1 + #define SOCKET_ERROR -1 +#endif + +#define SERVER_LOOP_GRANULARITY 3 //# of ms between checking our socket/queues + +BaseTCPServer::BaseTCPServer(uint16 in_port) { + NextID = 1; + pPort = in_port; + sock = 0; + pRunLoop = true; +#ifdef _WINDOWS + _beginthread(BaseTCPServer::TCPServerLoop, 0, this); +#else + pthread_t thread; + pthread_create(&thread, nullptr, &BaseTCPServer::TCPServerLoop, this); +#endif +} + +BaseTCPServer::~BaseTCPServer() { + StopLoopAndWait(); +} + +void BaseTCPServer::StopLoopAndWait() { + MRunLoop.lock(); + if(pRunLoop) { + pRunLoop = false; + MRunLoop.unlock(); + //wait for loop to stop. + MLoopRunning.lock(); + MLoopRunning.unlock(); + } else { + MRunLoop.unlock(); + } +} + +bool BaseTCPServer::RunLoop() { + bool ret; + MRunLoop.lock(); + ret = pRunLoop; + MRunLoop.unlock(); + return ret; +} + +ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) { +#ifdef _WINDOWS + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); +#endif + if (tmp == 0) { + THREAD_RETURN(nullptr); + } + BaseTCPServer* tcps = (BaseTCPServer*) tmp; + +#ifndef WIN32 + Log(Logs::Detail, Logs::None, "Starting TCPServerLoop with thread ID %d", pthread_self()); +#endif + + tcps->MLoopRunning.lock(); + while (tcps->RunLoop()) { + Sleep(SERVER_LOOP_GRANULARITY); + tcps->Process(); + } + tcps->MLoopRunning.unlock(); + +#ifndef WIN32 + Log(Logs::Detail, Logs::None, "Ending TCPServerLoop with thread ID %d", pthread_self()); +#endif + + THREAD_RETURN(nullptr); +} + +void BaseTCPServer::Process() { + ListenNewConnections(); +} + +void BaseTCPServer::ListenNewConnections() { + SOCKET tmpsock; + struct sockaddr_in from; + struct in_addr in; + unsigned int fromlen; + unsigned short port; + + from.sin_family = AF_INET; + fromlen = sizeof(from); + LockMutex lock(&MSock); +#ifndef DARWIN // Corysia - On OSX, 0 is a valid fd. + if (!sock) + return; +#else + if (sock == -1) return; +#endif + + // Check for pending connects +#ifdef _WINDOWS + unsigned long nonblocking = 1; + while ((tmpsock = accept(sock, (struct sockaddr*) &from, (int *) &fromlen)) != INVALID_SOCKET) { + ioctlsocket (tmpsock, FIONBIO, &nonblocking); +#else +#ifdef __CYGWIN__ + while ((tmpsock = accept(sock, (struct sockaddr *) &from, (int *) &fromlen)) != INVALID_SOCKET) { +#else + while ((tmpsock = accept(sock, (struct sockaddr*) &from, &fromlen)) != INVALID_SOCKET) { +#endif + fcntl(tmpsock, F_SETFL, O_NONBLOCK); +#endif + int bufsize = 64 * 1024; // 64kbyte recieve buffer, up from default of 8k + setsockopt(tmpsock, SOL_SOCKET, SO_RCVBUF, (char*) &bufsize, sizeof(bufsize)); + port = from.sin_port; + in.s_addr = from.sin_addr.s_addr; + + // New TCP connection, this must consume the socket. + CreateNewConnection(GetNextID(), tmpsock, in.s_addr, ntohs(from.sin_port)); + } +} + +bool BaseTCPServer::Open(uint16 in_port, char* errbuf) { + if (errbuf) + errbuf[0] = 0; + LockMutex lock(&MSock); + if (sock != 0) { + if (errbuf) + snprintf(errbuf, TCPServer_ErrorBufferSize, "Listening socket already open"); + return false; + } + if (in_port != 0) { + pPort = in_port; + } + +#ifdef _WINDOWS + SOCKADDR_IN address; + unsigned long nonblocking = 1; +#else + struct sockaddr_in address; +#endif + int reuse_addr = 1; + +// Setup internet address information. +// This is used with the bind() call + memset((char *) &address, 0, sizeof(address)); + address.sin_family = AF_INET; + address.sin_port = htons(pPort); + address.sin_addr.s_addr = htonl(INADDR_ANY); + +// Setting up TCP port for new TCP connections + sock = socket(AF_INET, SOCK_STREAM, 0); + if (sock == INVALID_SOCKET) { + if (errbuf) + snprintf(errbuf, TCPServer_ErrorBufferSize, "socket(): INVALID_SOCKET"); + return false; + } + +// Quag: dont think following is good stuff for TCP, good for UDP +// Mis: SO_REUSEADDR shouldn't be a problem for tcp--allows you to restart +// without waiting for conns in TIME_WAIT to die + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &reuse_addr, sizeof(reuse_addr)); + + + if (bind(sock, (struct sockaddr *) &address, sizeof(address)) < 0) { +#ifdef _WINDOWS + closesocket(sock); +#else + close(sock); +#endif + sock = 0; + if (errbuf) + sprintf(errbuf, "bind(): <0"); + return false; + } + + int bufsize = 64 * 1024; // 64kbyte recieve buffer, up from default of 8k + setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char*) &bufsize, sizeof(bufsize)); +#ifdef _WINDOWS + ioctlsocket (sock, FIONBIO, &nonblocking); +#else + fcntl(sock, F_SETFL, O_NONBLOCK); +#endif + + if (listen(sock, SOMAXCONN) == SOCKET_ERROR) { +#ifdef _WINDOWS + closesocket(sock); + if (errbuf) + snprintf(errbuf, TCPServer_ErrorBufferSize, "listen() failed, Error: %d", WSAGetLastError()); +#else + close(sock); + if (errbuf) + snprintf(errbuf, TCPServer_ErrorBufferSize, "listen() failed, Error: %s", strerror(errno)); +#endif + sock = 0; + return false; + } + + return true; +} + +void BaseTCPServer::Close() { + StopLoopAndWait(); + + LockMutex lock(&MSock); + if (sock) { +#ifdef _WINDOWS + closesocket(sock); +#else + close(sock); +#endif + } + sock = 0; +} + +bool BaseTCPServer::IsOpen() { + MSock.lock(); + bool ret = (bool) (sock != 0); + MSock.unlock(); + return ret; +} + diff --git a/common/timeoutmgr.cpp b/common/timeoutmgr.cpp index 998195cb3..71e639f31 100644 --- a/common/timeoutmgr.cpp +++ b/common/timeoutmgr.cpp @@ -43,7 +43,7 @@ void TimeoutManager::CheckTimeouts() { Timeoutable *it = *cur; if(it->next_check.Check()) { #ifdef TIMEOUT_DEBUG - Log.Out(Logs::General, Logs::None,, "Checking timeout on 0x%x\n", it); + Log(Logs::General, Logs::None,, "Checking timeout on 0x%x\n", it); #endif it->CheckTimeout(); } @@ -58,13 +58,13 @@ void TimeoutManager::AddMember(Timeoutable *who) { DeleteMember(who); //just in case... prolly not needed. members.push_back(who); #ifdef TIMEOUT_DEBUG - Log.Out(Logs::General, Logs::None,, "Adding timeoutable 0x%x\n", who); + Log(Logs::General, Logs::None,, "Adding timeoutable 0x%x\n", who); #endif } void TimeoutManager::DeleteMember(Timeoutable *who) { #ifdef TIMEOUT_DEBUG - Log.Out(Logs::General, Logs::None,, "Removing timeoutable 0x%x\n", who); + Log(Logs::General, Logs::None,, "Removing timeoutable 0x%x\n", who); #endif std::vector::iterator cur,end; cur = members.begin(); diff --git a/common/worldconn.cpp b/common/worldconn.cpp new file mode 100644 index 000000000..22a34a3ba --- /dev/null +++ b/common/worldconn.cpp @@ -0,0 +1,87 @@ +/* EQEMu: Everquest Server Emulator + Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "../common/global_define.h" +#include "../common/eqemu_logsys.h" +#include + +#include "worldconn.h" +#include "eqemu_config.h" +#include "md5.h" +#include "servertalk.h" + +WorldConnection::WorldConnection(EmuTCPConnection::ePacketMode mode, const char *password) +: m_password(password) +{ + tcpc.SetPacketMode(mode); + pTryReconnect = true; + pConnected = false; +} + +WorldConnection::~WorldConnection() { +} + +bool WorldConnection::SendPacket(ServerPacket* pack) { + if (!Connected()) + return false; + return tcpc.SendPacket(pack); +} + +void WorldConnection::OnConnected() { + const EQEmuConfig *Config=EQEmuConfig::get(); + Log(Logs::General, Logs::Netcode, "[WORLD] Connected to World: %s:%d", Config->WorldIP.c_str(), Config->WorldTCPPort); + + auto pack = new ServerPacket(ServerOP_ZAAuth, 16); + MD5::Generate((const uchar*) m_password.c_str(), m_password.length(), pack->pBuffer); + SendPacket(pack); + safe_delete(pack); +} + +void WorldConnection::Process() { + //persistent connection.... + if (!Connected()) { + pConnected = tcpc.Connected(); + if (pConnected) { + OnConnected(); + } + else + return; + } + +} + +void WorldConnection::AsyncConnect() { + const EQEmuConfig *Config=EQEmuConfig::get(); + tcpc.AsyncConnect(Config->WorldIP.c_str(), Config->WorldTCPPort); +} + +bool WorldConnection::Connect() { + const EQEmuConfig *Config=EQEmuConfig::get(); + char errbuf[TCPConnection_ErrorBufferSize]; + if (tcpc.Connect(Config->WorldIP.c_str(), Config->WorldTCPPort, errbuf)) { + return true; + } else { + Log(Logs::General, Logs::Netcode, "[WORLD] WorldConnection connect: Connecting to the server %s:%d failed: %s", Config->WorldIP.c_str(), Config->WorldTCPPort, errbuf); + } + return false; +} + +void WorldConnection::Disconnect() { + tcpc.Disconnect(); +} + diff --git a/eqlaunch/eqlaunch.cpp b/eqlaunch/eqlaunch.cpp index f6b41738c..a15ee6bdb 100644 --- a/eqlaunch/eqlaunch.cpp +++ b/eqlaunch/eqlaunch.cpp @@ -31,11 +31,7 @@ #include #include -#ifndef _WINDOWS -#include "../common/unix.h" -#endif - -EQEmuLogSys Log; +EQEmuLogSys LogSys; bool RunLoops = false; @@ -43,7 +39,7 @@ void CatchSignal(int sig_num); int main(int argc, char *argv[]) { RegisterExecutablePlatform(ExePlatformLaunch); - Log.LoadLogSettingsDefaults(); + LogSys.LoadLogSettingsDefaults(); set_exception_handler(); std::string launcher_name; @@ -51,13 +47,13 @@ int main(int argc, char *argv[]) { launcher_name = argv[1]; } if(launcher_name.length() < 1) { - Log.Out(Logs::Detail, Logs::Launcher, "You must specfify a launcher name as the first argument to this program."); + Log(Logs::Detail, Logs::Launcher, "You must specfify a launcher name as the first argument to this program."); return 1; } - Log.Out(Logs::Detail, Logs::Launcher, "Loading server configuration.."); + Log(Logs::Detail, Logs::Launcher, "Loading server configuration.."); if (!EQEmuConfig::LoadConfig()) { - Log.Out(Logs::Detail, Logs::Launcher, "Loading server configuration failed."); + Log(Logs::Detail, Logs::Launcher, "Loading server configuration failed."); return 1; } auto Config = EQEmuConfig::get(); @@ -66,16 +62,16 @@ int main(int argc, char *argv[]) { * Setup nice signal handlers */ if (signal(SIGINT, CatchSignal) == SIG_ERR) { - Log.Out(Logs::Detail, Logs::Launcher, "Could not set signal handler"); + Log(Logs::Detail, Logs::Launcher, "Could not set signal handler"); return 1; } if (signal(SIGTERM, CatchSignal) == SIG_ERR) { - Log.Out(Logs::Detail, Logs::Launcher, "Could not set signal handler"); + Log(Logs::Detail, Logs::Launcher, "Could not set signal handler"); return 1; } #ifndef WIN32 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { - Log.Out(Logs::Detail, Logs::Launcher, "Could not set signal handler"); + Log(Logs::Detail, Logs::Launcher, "Could not set signal handler"); return 1; } @@ -101,7 +97,7 @@ int main(int argc, char *argv[]) { Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect - Log.Out(Logs::Detail, Logs::Launcher, "Starting main loop..."); + Log(Logs::Detail, Logs::Launcher, "Starting main loop..."); ProcLauncher *launch = ProcLauncher::get(); RunLoops = true; @@ -160,14 +156,14 @@ int main(int argc, char *argv[]) { delete zone->second; } - Log.CloseFileLogs(); + LogSys.CloseFileLogs(); return 0; } void CatchSignal(int sig_num) { - Log.Out(Logs::Detail, Logs::Launcher, "Caught signal %d", sig_num); + Log(Logs::Detail, Logs::Launcher, "Caught signal %d", sig_num); RunLoops = false; } diff --git a/eqlaunch/worldserver.cpp b/eqlaunch/worldserver.cpp index 1dd39dedc..ea0eee4ac 100644 --- a/eqlaunch/worldserver.cpp +++ b/eqlaunch/worldserver.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" @@ -25,7 +25,7 @@ #include "zone_launch.h" WorldServer::WorldServer(std::map &zones, const char *name, const EQEmuConfig *config) -: m_name(name), + : m_name(name), m_config(config), m_zones(zones) { @@ -43,7 +43,7 @@ WorldServer::~WorldServer() { void WorldServer::OnConnected() { auto pack = new ServerPacket(ServerOP_LauncherConnectInfo, sizeof(LauncherConnectInfo)); - LauncherConnectInfo* sci = (LauncherConnectInfo*) pack->pBuffer; + LauncherConnectInfo* sci = (LauncherConnectInfo*)pack->pBuffer; strn0cpy(sci->name, m_name, sizeof(sci->name)); m_connection->SendPacket(pack); safe_delete(pack); @@ -52,7 +52,7 @@ void WorldServer::OnConnected() { std::map::iterator cur, end; cur = m_zones.begin(); end = m_zones.end(); - for(; cur != end; ++cur) { + for (; cur != end; ++cur) { cur->second->SendStatus(); } } @@ -61,7 +61,7 @@ void WorldServer::HandleMessage(uint16 opcode, EQ::Net::Packet &p) { ServerPacket tpack(opcode, p); ServerPacket *pack = &tpack; - switch(opcode) { + switch (opcode) { case 0: { break; } @@ -71,18 +71,19 @@ void WorldServer::HandleMessage(uint16 opcode, EQ::Net::Packet &p) { break; } case ServerOP_LauncherZoneRequest: { - if(pack->size != sizeof(LauncherZoneRequest)) { - Log.Out(Logs::Detail, Logs::Launcher, "Invalid size of LauncherZoneRequest: %d", pack->size); + if (pack->size != sizeof(LauncherZoneRequest)) { + Log(Logs::Detail, Logs::Launcher, "Invalid size of LauncherZoneRequest: %d", pack->size); break; } - const LauncherZoneRequest *lzr = (const LauncherZoneRequest *) pack->pBuffer; - - switch(ZoneRequestCommands(lzr->command)) { + const LauncherZoneRequest *lzr = (const LauncherZoneRequest *)pack->pBuffer; + + switch (ZoneRequestCommands(lzr->command)) { case ZR_Start: { - if(m_zones.find(lzr->short_name) != m_zones.end()) { - Log.Out(Logs::Detail, Logs::Launcher, "World told us to start zone %s, but it is already running.", lzr->short_name); - } else { - Log.Out(Logs::Detail, Logs::Launcher, "World told us to start zone %s.", lzr->short_name); + if (m_zones.find(lzr->short_name) != m_zones.end()) { + Log(Logs::Detail, Logs::Launcher, "World told us to start zone %s, but it is already running.", lzr->short_name); + } + else { + Log(Logs::Detail, Logs::Launcher, "World told us to start zone %s.", lzr->short_name); auto l = new ZoneLaunch(this, m_name, lzr->short_name, lzr->port, m_config); m_zones[lzr->short_name] = l; } @@ -90,20 +91,22 @@ void WorldServer::HandleMessage(uint16 opcode, EQ::Net::Packet &p) { } case ZR_Restart: { auto res = m_zones.find(lzr->short_name); - if(res == m_zones.end()) { - Log.Out(Logs::Detail, Logs::Launcher, "World told us to restart zone %s, but it is not running.", lzr->short_name); - } else { - Log.Out(Logs::Detail, Logs::Launcher, "World told us to restart zone %s.", lzr->short_name); + if (res == m_zones.end()) { + Log(Logs::Detail, Logs::Launcher, "World told us to restart zone %s, but it is not running.", lzr->short_name); + } + else { + Log(Logs::Detail, Logs::Launcher, "World told us to restart zone %s.", lzr->short_name); res->second->Restart(); } break; } case ZR_Stop: { auto res = m_zones.find(lzr->short_name); - if(res == m_zones.end()) { - Log.Out(Logs::Detail, Logs::Launcher, "World told us to stop zone %s, but it is not running.", lzr->short_name); - } else { - Log.Out(Logs::Detail, Logs::Launcher, "World told us to stop zone %s.", lzr->short_name); + if (res == m_zones.end()) { + Log(Logs::Detail, Logs::Launcher, "World told us to stop zone %s, but it is not running.", lzr->short_name); + } + else { + Log(Logs::Detail, Logs::Launcher, "World told us to stop zone %s.", lzr->short_name); res->second->Stop(); } break; @@ -115,9 +118,9 @@ void WorldServer::HandleMessage(uint16 opcode, EQ::Net::Packet &p) { //ignore this, world is still being dumb break; } - + default: { - Log.Out(Logs::Detail, Logs::Launcher, "Unknown opcode 0x%x from World of len %d", pack->opcode, pack->size); + Log(Logs::Detail, Logs::Launcher, "Unknown opcode 0x%x from World of len %d", pack->opcode, pack->size); break; } } @@ -127,12 +130,12 @@ void WorldServer::HandleMessage(uint16 opcode, EQ::Net::Packet &p) { void WorldServer::SendStatus(const char *short_name, uint32 start_count, bool running) { auto pack = new ServerPacket(ServerOP_LauncherZoneStatus, sizeof(LauncherZoneStatus)); - LauncherZoneStatus* it =(LauncherZoneStatus*) pack->pBuffer; + LauncherZoneStatus* it = (LauncherZoneStatus*)pack->pBuffer; strn0cpy(it->short_name, short_name, 32); it->start_count = start_count; - it->running = running?1:0; + it->running = running ? 1 : 0; m_connection->SendPacket(pack); safe_delete(pack); -} +} \ No newline at end of file diff --git a/eqlaunch/zone_launch.cpp b/eqlaunch/zone_launch.cpp index 7af96c59f..4e0a9a8ff 100644 --- a/eqlaunch/zone_launch.cpp +++ b/eqlaunch/zone_launch.cpp @@ -77,7 +77,7 @@ void ZoneLaunch::Start() { //spec is consumed, even on failure m_ref = ProcLauncher::get()->Launch(spec); if(m_ref == ProcLauncher::ProcError) { - Log.Out(Logs::Detail, Logs::Launcher, "Failure to launch '%s %s %s'. ", m_config->ZoneExe.c_str(), m_zone.c_str(), m_launcherName); + Log(Logs::Detail, Logs::Launcher, "Failure to launch '%s %s %s'. ", m_config->ZoneExe.c_str(), m_zone.c_str(), m_launcherName); m_timer.Start(m_config->RestartWait); return; } @@ -89,17 +89,17 @@ void ZoneLaunch::Start() { SendStatus(); - Log.Out(Logs::Detail, Logs::Launcher, "Zone %s has been started.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Zone %s has been started.", m_zone.c_str()); } void ZoneLaunch::Restart() { switch(m_state) { case StateRestartPending: - Log.Out(Logs::Detail, Logs::Launcher, "Restart of zone %s requested when a restart is already pending.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Restart of zone %s requested when a restart is already pending.", m_zone.c_str()); break; case StateStartPending: //we havent started yet, do nothing - Log.Out(Logs::Detail, Logs::Launcher, "Restart of %s before it has started. Ignoring.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Restart of %s before it has started. Ignoring.", m_zone.c_str()); break; case StateStarted: //process is running along, kill it off.. @@ -107,20 +107,20 @@ void ZoneLaunch::Restart() { break; //we have no proc ref... cannot stop.. if(!ProcLauncher::get()->Terminate(m_ref, true)) { //failed to terminate the process, its not likely that it will work if we try again, so give up. - Log.Out(Logs::Detail, Logs::Launcher, "Failed to terminate zone %s. Giving up and moving to stopped.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Failed to terminate zone %s. Giving up and moving to stopped.", m_zone.c_str()); m_state = StateStopped; break; } - Log.Out(Logs::Detail, Logs::Launcher, "Termination signal sent to zone %s.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Termination signal sent to zone %s.", m_zone.c_str()); m_timer.Start(m_config->TerminateWait); m_state = StateRestartPending; break; case StateStopPending: - Log.Out(Logs::Detail, Logs::Launcher, "Restart of zone %s requested when a stop is pending. Ignoring.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Restart of zone %s requested when a stop is pending. Ignoring.", m_zone.c_str()); break; case StateStopped: //process is already stopped... nothing to do.. - Log.Out(Logs::Detail, Logs::Launcher, "Restart requested when zone %s is already stopped.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Restart requested when zone %s is already stopped.", m_zone.c_str()); break; } } @@ -129,7 +129,7 @@ void ZoneLaunch::Stop(bool graceful) { switch(m_state) { case StateStartPending: //we havent started yet, transition directly to stopped. - Log.Out(Logs::Detail, Logs::Launcher, "Stopping zone %s before it has started.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Stopping zone %s before it has started.", m_zone.c_str()); m_state = StateStopped; break; case StateStarted: @@ -139,17 +139,17 @@ void ZoneLaunch::Stop(bool graceful) { break; //we have no proc ref... cannot stop.. if(!ProcLauncher::get()->Terminate(m_ref, graceful)) { //failed to terminate the process, its not likely that it will work if we try again, so give up. - Log.Out(Logs::Detail, Logs::Launcher, "Failed to terminate zone %s. Giving up and moving to stopped.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Failed to terminate zone %s. Giving up and moving to stopped.", m_zone.c_str()); m_state = StateStopped; break; } - Log.Out(Logs::Detail, Logs::Launcher, "Termination signal sent to zone %s.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Termination signal sent to zone %s.", m_zone.c_str()); m_timer.Start(m_config->TerminateWait); m_state = StateStopPending; break; case StateStopped: //process is already stopped... nothing to do.. - Log.Out(Logs::Detail, Logs::Launcher, "Stop requested when zone %s is already stopped.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Stop requested when zone %s is already stopped.", m_zone.c_str()); break; } } @@ -169,17 +169,17 @@ bool ZoneLaunch::Process() { m_timer.Disable(); //actually start up the program - Log.Out(Logs::Detail, Logs::Launcher, "Starting zone %s", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Starting zone %s", m_zone.c_str()); Start(); //now update the shared timer to reflect the proper start interval. if(s_running == 1) { //we are the first zone started. wait that interval. - Log.Out(Logs::Detail, Logs::Launcher, "Waiting %d milliseconds before booting the second zone.", m_config->InitialBootWait); + Log(Logs::Detail, Logs::Launcher, "Waiting %d milliseconds before booting the second zone.", m_config->InitialBootWait); s_startTimer.Start(m_config->InitialBootWait); } else { //just some follow on zone, use that interval. - Log.Out(Logs::Detail, Logs::Launcher, "Waiting %d milliseconds before booting the next zone.", m_config->ZoneBootInterval); + Log(Logs::Detail, Logs::Launcher, "Waiting %d milliseconds before booting the next zone.", m_config->ZoneBootInterval); s_startTimer.Start(m_config->ZoneBootInterval); } @@ -192,7 +192,7 @@ bool ZoneLaunch::Process() { //waiting for notification that our child has died.. if(m_timer.Check()) { //we have timed out, try to kill the child again - Log.Out(Logs::Detail, Logs::Launcher, "Zone %s refused to die, killing again.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Zone %s refused to die, killing again.", m_zone.c_str()); Restart(); } break; @@ -202,12 +202,12 @@ bool ZoneLaunch::Process() { //we have timed out, try to kill the child again m_killFails++; if(m_killFails > 5) { //should get this number from somewhere.. - Log.Out(Logs::Detail, Logs::Launcher, "Zone %s refused to die, giving up and acting like its dead.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Zone %s refused to die, giving up and acting like its dead.", m_zone.c_str()); m_state = StateStopped; s_running--; SendStatus(); } else { - Log.Out(Logs::Detail, Logs::Launcher, "Zone %s refused to die, killing again.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Zone %s refused to die, killing again.", m_zone.c_str()); Stop(false); } } @@ -226,29 +226,29 @@ void ZoneLaunch::OnTerminate(const ProcLauncher::ProcRef &ref, const ProcLaunche switch(m_state) { case StateStartPending: - Log.Out(Logs::Detail, Logs::Launcher, "Zone %s has gone down before we started it..?? Restart timer started.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Zone %s has gone down before we started it..?? Restart timer started.", m_zone.c_str()); m_state = StateStartPending; m_timer.Start(m_config->RestartWait); break; case StateStarted: //something happened to our happy process... - Log.Out(Logs::Detail, Logs::Launcher, "Zone %s has gone down. Restart timer started.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Zone %s has gone down. Restart timer started.", m_zone.c_str()); m_state = StateStartPending; m_timer.Start(m_config->RestartWait); break; case StateRestartPending: //it finally died, start it on up again - Log.Out(Logs::Detail, Logs::Launcher, "Zone %s has terminated. Transitioning to starting state.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Zone %s has terminated. Transitioning to starting state.", m_zone.c_str()); m_state = StateStartPending; break; case StateStopPending: //it finally died, transition to close. - Log.Out(Logs::Detail, Logs::Launcher, "Zone %s has terminated. Transitioning to stopped state.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Zone %s has terminated. Transitioning to stopped state.", m_zone.c_str()); m_state = StateStopped; break; case StateStopped: //we already thought it was stopped... dont care... - Log.Out(Logs::Detail, Logs::Launcher, "Notified of zone %s terminating when we thought it was stopped.", m_zone.c_str()); + Log(Logs::Detail, Logs::Launcher, "Notified of zone %s terminating when we thought it was stopped.", m_zone.c_str()); break; } diff --git a/loginserver/client.cpp b/loginserver/client.cpp index 97a55c41e..602967e38 100644 --- a/loginserver/client.cpp +++ b/loginserver/client.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "client.h" #include "login_server.h" @@ -21,7 +21,6 @@ #include "../common/misc_functions.h" #include "../common/eqemu_logsys.h" -extern EQEmuLogSys Log; extern LoginServer server; Client::Client(std::shared_ptr c, LSClientVersion v) @@ -37,14 +36,14 @@ Client::Client(std::shared_ptr c, LSClientVersion v) bool Client::Process() { EQApplicationPacket *app = connection->PopPacket(); - while(app) + while (app) { - if(server.options.IsTraceOn()) + if (server.options.IsTraceOn()) { - Log.Out(Logs::General, Logs::Login_Server, "Application packet received from client (size %u)", app->Size()); + Log(Logs::General, Logs::Login_Server, "Application packet received from client (size %u)", app->Size()); } - if(server.options.IsDumpInPacketsOn()) + if (server.options.IsDumpInPacketsOn()) { DumpPacket(app); } @@ -55,68 +54,68 @@ bool Client::Process() continue; } - switch(app->GetOpcode()) + switch (app->GetOpcode()) { case OP_SessionReady: + { + if (server.options.IsTraceOn()) { - if(server.options.IsTraceOn()) - { - Log.Out(Logs::General, Logs::Login_Server, "Session ready received from client."); - } - Handle_SessionReady((const char*)app->pBuffer, app->Size()); - break; + Log(Logs::General, Logs::Login_Server, "Session ready received from client."); } + Handle_SessionReady((const char*)app->pBuffer, app->Size()); + break; + } case OP_Login: + { + if (app->Size() < 20) { - if(app->Size() < 20) - { - Log.Out(Logs::General, Logs::Error, "Login received but it is too small, discarding."); - break; - } - - if(server.options.IsTraceOn()) - { - Log.Out(Logs::General, Logs::Login_Server, "Login received from client."); - } - - Handle_Login((const char*)app->pBuffer, app->Size()); + Log(Logs::General, Logs::Error, "Login received but it is too small, discarding."); break; } + + if (server.options.IsTraceOn()) + { + Log(Logs::General, Logs::Login_Server, "Login received from client."); + } + + Handle_Login((const char*)app->pBuffer, app->Size()); + break; + } case OP_ServerListRequest: - { - if (app->Size() < 4) { - Log.Out(Logs::General, Logs::Error, "Server List Request received but it is too small, discarding."); - break; - } - - if(server.options.IsTraceOn()) - { - Log.Out(Logs::General, Logs::Login_Server, "Server list request received from client."); - } - - SendServerListPacket(*(uint32_t*)app->pBuffer); + { + if (app->Size() < 4) { + Log(Logs::General, Logs::Error, "Server List Request received but it is too small, discarding."); break; } + + if (server.options.IsTraceOn()) + { + Log(Logs::General, Logs::Login_Server, "Server list request received from client."); + } + + SendServerListPacket(*(uint32_t*)app->pBuffer); + break; + } case OP_PlayEverquestRequest: + { + if (app->Size() < sizeof(PlayEverquestRequest_Struct)) { - if(app->Size() < sizeof(PlayEverquestRequest_Struct)) - { - Log.Out(Logs::General, Logs::Error, "Play received but it is too small, discarding."); - break; - } - - Handle_Play((const char*)app->pBuffer); + Log(Logs::General, Logs::Error, "Play received but it is too small, discarding."); break; } + + Handle_Play((const char*)app->pBuffer); + break; + } default: - { - if (Log.log_settings[Logs::Client_Server_Packet_Unhandled].is_category_enabled == 1) { - char dump[64]; - app->build_header_dump(dump); - Log.Out(Logs::General, Logs::Error, "Recieved unhandled application packet from the client: %s.", dump); - } + { + if (LogSys.log_settings[Logs::Client_Server_Packet_Unhandled].is_category_enabled == 1) { + char dump[64]; + app->build_header_dump(dump); + Log(Logs::General, Logs::Error, "Recieved unhandled application packet from the client: %s.", dump); } } + } delete app; app = connection->PopPacket(); @@ -127,15 +126,15 @@ bool Client::Process() void Client::Handle_SessionReady(const char* data, unsigned int size) { - if(status != cs_not_sent_session_ready) + if (status != cs_not_sent_session_ready) { - Log.Out(Logs::General, Logs::Error, "Session ready received again after already being received."); + Log(Logs::General, Logs::Error, "Session ready received again after already being received."); return; } - if(size < sizeof(unsigned int)) + if (size < sizeof(unsigned int)) { - Log.Out(Logs::General, Logs::Error, "Session ready was too small."); + Log(Logs::General, Logs::Error, "Session ready was too small."); return; } @@ -144,14 +143,14 @@ void Client::Handle_SessionReady(const char* data, unsigned int size) /** * The packets are mostly the same but slightly different between the two versions. */ - if(version == cv_sod) + if (version == cv_sod) { EQApplicationPacket *outapp = new EQApplicationPacket(OP_ChatMessage, 17); outapp->pBuffer[0] = 0x02; outapp->pBuffer[10] = 0x01; outapp->pBuffer[11] = 0x65; - if(server.options.IsDumpOutPacketsOn()) + if (server.options.IsDumpOutPacketsOn()) { DumpPacket(outapp); } @@ -168,7 +167,7 @@ void Client::Handle_SessionReady(const char* data, unsigned int size) outapp->pBuffer[11] = 0x65; strcpy((char*)(outapp->pBuffer + 15), msg); - if(server.options.IsDumpOutPacketsOn()) + if (server.options.IsDumpOutPacketsOn()) { DumpPacket(outapp); } @@ -182,13 +181,13 @@ void Client::Handle_Login(const char* data, unsigned int size) { auto mode = server.options.GetEncryptionMode(); - if(status != cs_waiting_for_login) { - Log.Out(Logs::General, Logs::Error, "Login received after already having logged in."); + if (status != cs_waiting_for_login) { + Log(Logs::General, Logs::Error, "Login received after already having logged in."); return; } - if((size - 12) % 8 != 0) { - Log.Out(Logs::General, Logs::Error, "Login received packet of size: %u, this would cause a block corruption, discarding.", size); + if ((size - 12) % 8 != 0) { + Log(Logs::General, Logs::Error, "Login received packet of size: %u, this would cause a block corruption, discarding.", size); return; } @@ -200,13 +199,13 @@ void Client::Handle_Login(const char* data, unsigned int size) std::string outbuffer; outbuffer.resize(size - 12); if (outbuffer.length() == 0) { - Log.OutF(Logs::General, Logs::Debug, "Corrupt buffer sent to server, no length."); + LogF(Logs::General, Logs::Debug, "Corrupt buffer sent to server, no length."); return; } auto r = eqcrypt_block(data + 10, size - 12, &outbuffer[0], 0); if (r == nullptr) { - Log.OutF(Logs::General, Logs::Debug, "Failed to decrypt eqcrypt block"); + LogF(Logs::General, Logs::Debug, "Failed to decrypt eqcrypt block"); return; } @@ -214,12 +213,12 @@ void Client::Handle_Login(const char* data, unsigned int size) std::string user(&outbuffer[0]); if (user.length() >= outbuffer.length()) { - Log.OutF(Logs::General, Logs::Debug, "Corrupt buffer sent to server, preventing buffer overflow."); + LogF(Logs::General, Logs::Debug, "Corrupt buffer sent to server, preventing buffer overflow."); return; } bool result = false; - if(outbuffer[0] == 0 && outbuffer[1] == 0) { + if (outbuffer[0] == 0 && outbuffer[1] == 0) { if (server.options.IsTokenLoginAllowed()) { cred = (&outbuffer[2 + user.length()]); result = server.db->GetLoginTokenDataFromToken(cred, connection->GetRemoteAddr(), db_account_id, user); @@ -234,11 +233,11 @@ void Client::Handle_Login(const char* data, unsigned int size) server.options.CanAutoCreateAccounts() && server.db->CreateLoginData(user, eqcrypt_hash(user, cred, mode), db_account_id) == true ) { - Log.OutF(Logs::General, Logs::Error, "User {0} does not exist in the database, so we created it...", user); + LogF(Logs::General, Logs::Error, "User {0} does not exist in the database, so we created it...", user); result = true; } else { - Log.OutF(Logs::General, Logs::Error, "Error logging in, user {0} does not exist in the database.", user); + LogF(Logs::General, Logs::Error, "Error logging in, user {0} does not exist in the database.", user); result = false; } } @@ -302,7 +301,7 @@ void Client::Handle_Login(const char* data, unsigned int size) char encrypted_buffer[80] = { 0 }; auto rc = eqcrypt_block((const char*)login_failed_attempts, 75, encrypted_buffer, 1); if (rc == nullptr) { - Log.OutF(Logs::General, Logs::Debug, "Failed to encrypt eqcrypt block"); + LogF(Logs::General, Logs::Debug, "Failed to encrypt eqcrypt block"); } memcpy(login_accepted->encrypt, encrypted_buffer, 80); @@ -340,9 +339,9 @@ void Client::Handle_Login(const char* data, unsigned int size) void Client::Handle_Play(const char* data) { - if(status != cs_logged_in) + if (status != cs_logged_in) { - Log.Out(Logs::General, Logs::Error, "Client sent a play request when they were not logged in, discarding."); + Log(Logs::General, Logs::Error, "Client sent a play request when they were not logged in, discarding."); return; } @@ -350,9 +349,9 @@ void Client::Handle_Play(const char* data) unsigned int server_id_in = (unsigned int)play->ServerNumber; unsigned int sequence_in = (unsigned int)play->Sequence; - if(server.options.IsTraceOn()) + if (server.options.IsTraceOn()) { - Log.Out(Logs::General, Logs::Login_Server, "Play received from client, server number %u sequence %u.", server_id_in, sequence_in); + Log(Logs::General, Logs::Login_Server, "Play received from client, server number %u sequence %u.", server_id_in, sequence_in); } this->play_server_id = (unsigned int)play->ServerNumber; @@ -365,7 +364,7 @@ void Client::SendServerListPacket(uint32 seq) { EQApplicationPacket *outapp = server.server_manager->CreateServerListPacket(this, seq); - if(server.options.IsDumpOutPacketsOn()) + if (server.options.IsDumpOutPacketsOn()) { DumpPacket(outapp); } @@ -376,9 +375,9 @@ void Client::SendServerListPacket(uint32 seq) void Client::SendPlayResponse(EQApplicationPacket *outapp) { - if(server.options.IsTraceOn()) + if (server.options.IsTraceOn()) { - Log.Out(Logs::General, Logs::Netcode, "Sending play response for %s.", GetAccountName().c_str()); + Log(Logs::General, Logs::Netcode, "Sending play response for %s.", GetAccountName().c_str()); // server_log->LogPacket(log_network_trace, (const char*)outapp->pBuffer, outapp->size); } connection->QueuePacket(outapp); @@ -403,4 +402,3 @@ void Client::GenerateKey() count++; } } - diff --git a/loginserver/client_manager.cpp b/loginserver/client_manager.cpp index 1cabc1b74..04de69e53 100644 --- a/loginserver/client_manager.cpp +++ b/loginserver/client_manager.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "client_manager.h" #include "login_server.h" @@ -22,7 +22,6 @@ extern LoginServer server; extern bool run_server; #include "../common/eqemu_logsys.h" -extern EQEmuLogSys Log; ClientManager::ClientManager() { @@ -30,15 +29,15 @@ ClientManager::ClientManager() EQ::Net::EQStreamManagerOptions titanium_opts(titanium_port, false, false); titanium_stream = new EQ::Net::EQStreamManager(titanium_opts); titanium_ops = new RegularOpcodeManager; - if(!titanium_ops->LoadOpcodes(server.config->GetVariable("Titanium", "opcodes").c_str())) + if (!titanium_ops->LoadOpcodes(server.config->GetVariable("Titanium", "opcodes").c_str())) { - Log.Out(Logs::General, Logs::Error, "ClientManager fatal error: couldn't load opcodes for Titanium file %s.", + Log(Logs::General, Logs::Error, "ClientManager fatal error: couldn't load opcodes for Titanium file %s.", server.config->GetVariable("Titanium", "opcodes").c_str()); run_server = false; } titanium_stream->OnNewConnection([this](std::shared_ptr stream) { - Log.OutF(Logs::General, Logs::Login_Server, "New Titanium client connection from {0}:{1}", stream->RemoteEndpoint(), stream->GetRemotePort()); + LogF(Logs::General, Logs::Login_Server, "New Titanium client connection from {0}:{1}", stream->RemoteEndpoint(), stream->GetRemotePort()); stream->SetOpcodeManager(&titanium_ops); Client *c = new Client(stream, cv_titanium); clients.push_back(c); @@ -48,15 +47,15 @@ ClientManager::ClientManager() EQ::Net::EQStreamManagerOptions sod_opts(sod_port, false, false); sod_stream = new EQ::Net::EQStreamManager(sod_opts); sod_ops = new RegularOpcodeManager; - if(!sod_ops->LoadOpcodes(server.config->GetVariable("SoD", "opcodes").c_str())) + if (!sod_ops->LoadOpcodes(server.config->GetVariable("SoD", "opcodes").c_str())) { - Log.Out(Logs::General, Logs::Error, "ClientManager fatal error: couldn't load opcodes for SoD file %s.", + Log(Logs::General, Logs::Error, "ClientManager fatal error: couldn't load opcodes for SoD file %s.", server.config->GetVariable("SoD", "opcodes").c_str()); run_server = false; } sod_stream->OnNewConnection([this](std::shared_ptr stream) { - Log.OutF(Logs::General, Logs::Login_Server, "New SoD client connection from {0}:{1}", stream->RemoteEndpoint(), stream->GetRemotePort()); + LogF(Logs::General, Logs::Login_Server, "New SoD client connection from {0}:{1}", stream->RemoteEndpoint(), stream->GetRemotePort()); stream->SetOpcodeManager(&sod_ops); Client *c = new Client(stream, cv_sod); clients.push_back(c); @@ -65,22 +64,22 @@ ClientManager::ClientManager() ClientManager::~ClientManager() { - if(titanium_stream) + if (titanium_stream) { delete titanium_stream; } - if(titanium_ops) + if (titanium_ops) { delete titanium_ops; } - if(sod_stream) + if (sod_stream) { delete sod_stream; } - if(sod_ops) + if (sod_ops) { delete sod_ops; } @@ -91,11 +90,11 @@ void ClientManager::Process() ProcessDisconnect(); auto iter = clients.begin(); - while(iter != clients.end()) + while (iter != clients.end()) { - if((*iter)->Process() == false) + if ((*iter)->Process() == false) { - Log.Out(Logs::General, Logs::Debug, "Client had a fatal error and had to be removed from the login."); + Log(Logs::General, Logs::Debug, "Client had a fatal error and had to be removed from the login."); delete (*iter); iter = clients.erase(iter); } @@ -109,12 +108,12 @@ void ClientManager::Process() void ClientManager::ProcessDisconnect() { auto iter = clients.begin(); - while(iter != clients.end()) + while (iter != clients.end()) { std::shared_ptr c = (*iter)->GetConnection(); - if(c->CheckState(CLOSED)) + if (c->CheckState(CLOSED)) { - Log.Out(Logs::General, Logs::Login_Server, "Client disconnected from the server, removing client."); + Log(Logs::General, Logs::Login_Server, "Client disconnected from the server, removing client."); delete (*iter); iter = clients.erase(iter); } @@ -128,11 +127,11 @@ void ClientManager::ProcessDisconnect() void ClientManager::RemoveExistingClient(unsigned int account_id) { auto iter = clients.begin(); - while(iter != clients.end()) + while (iter != clients.end()) { - if((*iter)->GetAccountID() == account_id) + if ((*iter)->GetAccountID() == account_id) { - Log.Out(Logs::General, Logs::Login_Server, "Client attempting to log in and existing client already logged in, removing existing client."); + Log(Logs::General, Logs::Login_Server, "Client attempting to log in and existing client already logged in, removing existing client."); delete (*iter); iter = clients.erase(iter); } @@ -148,9 +147,9 @@ Client *ClientManager::GetClient(unsigned int account_id) Client *cur = nullptr; int count = 0; auto iter = clients.begin(); - while(iter != clients.end()) + while (iter != clients.end()) { - if((*iter)->GetAccountID() == account_id) + if ((*iter)->GetAccountID() == account_id) { cur = (*iter); count++; @@ -158,10 +157,9 @@ Client *ClientManager::GetClient(unsigned int account_id) ++iter; } - if(count > 1) + if (count > 1) { - Log.Out(Logs::General, Logs::Error, "More than one client with a given account_id existed in the client list."); + Log(Logs::General, Logs::Error, "More than one client with a given account_id existed in the client list."); } return cur; } - diff --git a/loginserver/config.cpp b/loginserver/config.cpp index 5582e9754..72d44efa0 100644 --- a/loginserver/config.cpp +++ b/loginserver/config.cpp @@ -19,7 +19,6 @@ #include "../common/eqemu_logsys.h" #include "config.h" -extern EQEmuLogSys Log; /** * Retrieves the variable we want from our title or theme * First gets the map from the title @@ -48,7 +47,7 @@ void Config::Parse(const char *file_name) { if(file_name == nullptr) { - Log.Out(Logs::General, Logs::Error, "Config::Parse(), file_name passed was null."); + Log(Logs::General, Logs::Error, "Config::Parse(), file_name passed was null."); return; } @@ -71,7 +70,7 @@ void Config::Parse(const char *file_name) ++iter; if(iter == tokens.end()) { - Log.Out(Logs::General, Logs::Error, "Config::Parse(), EOF before title done parsing."); + Log(Logs::General, Logs::Error, "Config::Parse(), EOF before title done parsing."); fclose(input); vars.clear(); return; @@ -104,7 +103,7 @@ void Config::Parse(const char *file_name) mode++; if((*iter).compare("=") != 0) { - Log.Out(Logs::General, Logs::Error, "Config::Parse(), invalid parse token where = should be."); + Log(Logs::General, Logs::Error, "Config::Parse(), invalid parse token where = should be."); fclose(input); vars.clear(); return; @@ -133,7 +132,7 @@ void Config::Parse(const char *file_name) } else { - Log.Out(Logs::General, Logs::Error, "Config::Parse(), file was unable to be opened for parsing."); + Log(Logs::General, Logs::Error, "Config::Parse(), file was unable to be opened for parsing."); } } diff --git a/loginserver/database_mysql.cpp b/loginserver/database_mysql.cpp index ed392b9f7..b40c77a0f 100644 --- a/loginserver/database_mysql.cpp +++ b/loginserver/database_mysql.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" #include "database.h" @@ -24,7 +24,6 @@ #include "../common/eqemu_logsys.h" #include "../common/string_util.h" -extern EQEmuLogSys Log; extern LoginServer server; DatabaseMySQL::DatabaseMySQL(std::string user, std::string pass, std::string host, std::string port, std::string name) @@ -35,26 +34,26 @@ DatabaseMySQL::DatabaseMySQL(std::string user, std::string pass, std::string hos this->name = name; database = mysql_init(nullptr); - if(database) + if (database) { my_bool r = 1; mysql_options(database, MYSQL_OPT_RECONNECT, &r); - if(!mysql_real_connect(database, host.c_str(), user.c_str(), pass.c_str(), name.c_str(), atoi(port.c_str()), nullptr, 0)) + if (!mysql_real_connect(database, host.c_str(), user.c_str(), pass.c_str(), name.c_str(), atoi(port.c_str()), nullptr, 0)) { mysql_close(database); - Log.Out(Logs::General, Logs::Error, "Failed to connect to MySQL database. Error: %s", mysql_error(database)); + Log(Logs::General, Logs::Error, "Failed to connect to MySQL database. Error: %s", mysql_error(database)); exit(1); } } else { - Log.Out(Logs::General, Logs::Error, "Failed to create db object in MySQL database."); + Log(Logs::General, Logs::Error, "Failed to create db object in MySQL database."); } } DatabaseMySQL::~DatabaseMySQL() { - if(database) + if (database) { mysql_close(database); } @@ -76,7 +75,7 @@ bool DatabaseMySQL::GetLoginDataFromAccountName(std::string name, std::string &p if (mysql_query(database, query.str().c_str()) != 0) { - Log.OutF(Logs::General, Logs::Error, "Mysql query failed: {0}", query.str()); + LogF(Logs::General, Logs::Error, "Mysql query failed: {0}", query.str()); return false; } @@ -93,7 +92,7 @@ bool DatabaseMySQL::GetLoginDataFromAccountName(std::string name, std::string &p } } - Log.Out(Logs::General, Logs::Error, "Mysql query returned no result: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query returned no result: %s", query.str().c_str()); return false; } @@ -113,7 +112,7 @@ bool DatabaseMySQL::GetLoginTokenDataFromToken(const std::string &token, const s if (mysql_query(database, query.str().c_str()) != 0) { - Log.Out(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); return false; } @@ -158,15 +157,15 @@ bool DatabaseMySQL::CreateLoginData(const std::string &name, const std::string & query << " VALUES('" << name << "', '" << password << "', 'local_creation', NOW(), '127.0.0.1'); "; if (mysql_query(database, query.str().c_str()) != 0) { - Log.Out(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); return false; } - else{ + else { id = mysql_insert_id(database); return true; } - Log.Out(Logs::General, Logs::Error, "Mysql query returned no result: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query returned no result: %s", query.str().c_str()); return false; } @@ -194,7 +193,7 @@ bool DatabaseMySQL::GetWorldRegistration(std::string long_name, std::string shor if (mysql_query(database, query.str().c_str()) != 0) { - Log.Out(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); return false; } @@ -219,7 +218,7 @@ bool DatabaseMySQL::GetWorldRegistration(std::string long_name, std::string shor if (mysql_query(database, query.str().c_str()) != 0) { - Log.Out(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); return false; } @@ -235,14 +234,14 @@ bool DatabaseMySQL::GetWorldRegistration(std::string long_name, std::string shor } } - Log.Out(Logs::General, Logs::Error, "Mysql query returned no result: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query returned no result: %s", query.str().c_str()); return false; } return true; } } - Log.Out(Logs::General, Logs::Error, "Mysql query returned no result: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query returned no result: %s", query.str().c_str()); return false; } @@ -261,7 +260,7 @@ void DatabaseMySQL::UpdateLSAccountData(unsigned int id, std::string ip_address) if (mysql_query(database, query.str().c_str()) != 0) { - Log.Out(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); } } @@ -280,7 +279,7 @@ void DatabaseMySQL::UpdateLSAccountInfo(unsigned int id, std::string name, std:: if (mysql_query(database, query.str().c_str()) != 0) { - Log.Out(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); } } @@ -305,7 +304,7 @@ void DatabaseMySQL::UpdateWorldRegistration(unsigned int id, std::string long_na if (mysql_query(database, query.str().c_str()) != 0) { - Log.Out(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); } } @@ -330,7 +329,7 @@ bool DatabaseMySQL::CreateWorldRegistration(std::string long_name, std::string s if (mysql_query(database, query.str().c_str()) != 0) { - Log.Out(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); return false; } @@ -349,15 +348,14 @@ bool DatabaseMySQL::CreateWorldRegistration(std::string long_name, std::string s if (mysql_query(database, query.str().c_str()) != 0) { - Log.Out(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); + Log(Logs::General, Logs::Error, "Mysql query failed: %s", query.str().c_str()); return false; } return true; } } - Log.Out(Logs::General, Logs::Error, "World registration did not exist in the database for %s %s", long_name.c_str(), short_name.c_str()); + Log(Logs::General, Logs::Error, "World registration did not exist in the database for %s %s", long_name.c_str(), short_name.c_str()); return false; } #endif - diff --git a/loginserver/database_postgresql.cpp b/loginserver/database_postgresql.cpp index fba9aa8ec..4b6242e63 100644 --- a/loginserver/database_postgresql.cpp +++ b/loginserver/database_postgresql.cpp @@ -34,12 +34,12 @@ DatabasePostgreSQL::DatabasePostgreSQL(string user, string pass, string host, st db = PQsetdbLogin(host.c_str(), port.c_str(), nullptr, nullptr, name.c_str(), user.c_str(), pass.c_str()); if(!db) { - Log.Out(Logs::General, Logs::Error, "Failed to connect to PostgreSQL Database."); + Log(Logs::General, Logs::Error, "Failed to connect to PostgreSQL Database."); } if(PQstatus(db) != CONNECTION_OK) { - Log.Out(Logs::General, Logs::Error, "Failed to connect to PostgreSQL Database."); + Log(Logs::General, Logs::Error, "Failed to connect to PostgreSQL Database."); PQfinish(db); db = nullptr; } @@ -83,7 +83,7 @@ bool DatabasePostgreSQL::GetLoginDataFromAccountName(string name, string &passwo char *error = PQresultErrorMessage(res); if(strlen(error) > 0) { - Log.Out(Logs::General, Logs::Error, "Database error in DatabasePostgreSQL::GetLoginDataFromAccountName(): %s", error); + Log(Logs::General, Logs::Error, "Database error in DatabasePostgreSQL::GetLoginDataFromAccountName(): %s", error); PQclear(res); return false; } @@ -135,7 +135,7 @@ bool DatabasePostgreSQL::GetWorldRegistration(string long_name, string short_nam char *error = PQresultErrorMessage(res); if(strlen(error) > 0) { - Log.Out(Logs::General, Logs::Error, "Database error in DatabasePostgreSQL::GetWorldRegistration(): %s", error); + Log(Logs::General, Logs::Error, "Database error in DatabasePostgreSQL::GetWorldRegistration(): %s", error); PQclear(res); return false; } @@ -188,7 +188,7 @@ void DatabasePostgreSQL::UpdateLSAccountData(unsigned int id, string ip_address) char *error = PQresultErrorMessage(res); if(strlen(error) > 0) { - Log.Out(Logs::General, Logs::Error, "Database error in DatabasePostgreSQL::GetLoginDataFromAccountName(): %s", error); + Log(Logs::General, Logs::Error, "Database error in DatabasePostgreSQL::GetLoginDataFromAccountName(): %s", error); } PQclear(res); } @@ -225,7 +225,7 @@ void DatabasePostgreSQL::UpdateWorldRegistration(unsigned int id, string long_na char *error = PQresultErrorMessage(res); if(strlen(error) > 0) { - Log.Out(Logs::General, Logs::Error, "Database error in DatabasePostgreSQL::GetLoginDataFromAccountName(): %s", error); + Log(Logs::General, Logs::Error, "Database error in DatabasePostgreSQL::GetLoginDataFromAccountName(): %s", error); } PQclear(res); } diff --git a/loginserver/encryption.cpp b/loginserver/encryption.cpp index 33eedaef6..c8e688e5f 100644 --- a/loginserver/encryption.cpp +++ b/loginserver/encryption.cpp @@ -89,7 +89,7 @@ std::string eqcrypt_scrypt(const std::string &msg) std::string ret; ret.resize(crypto_pwhash_scryptsalsa208sha256_STRBYTES); - if (crypto_pwhash_scryptsalsa208sha256_str(&ret[0], &msg[0], msg.length(), + if (crypto_pwhash_scryptsalsa208sha256_str(&ret[0], &msg[0], msg.length(), crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE, crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE) != 0) { return ""; } diff --git a/loginserver/main.cpp b/loginserver/main.cpp index 5d7633799..9d8b3ef22 100644 --- a/loginserver/main.cpp +++ b/loginserver/main.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" #include "../common/types.h" @@ -30,7 +30,7 @@ #include LoginServer server; -EQEmuLogSys Log; +EQEmuLogSys LogSys; bool run_server = true; void CatchSignal(int sig_num) @@ -41,15 +41,15 @@ int main() { RegisterExecutablePlatform(ExePlatformLogin); set_exception_handler(); - Log.LoadLogSettingsDefaults(); + LogSys.LoadLogSettingsDefaults(); - Log.log_settings[Logs::Error].log_to_console = Logs::General; + LogSys.log_settings[Logs::Error].log_to_console = Logs::General; - Log.Out(Logs::General, Logs::Login_Server, "Logging System Init."); + Log(Logs::General, Logs::Login_Server, "Logging System Init."); /* Parse out login.ini */ server.config = new Config(); - Log.Out(Logs::General, Logs::Login_Server, "Config System Init."); + Log(Logs::General, Logs::Login_Server, "Config System Init."); server.config->Parse("login.ini"); if (server.config->GetVariable("options", "unregistered_allowed").compare("FALSE") == 0) @@ -106,7 +106,7 @@ int main() /* Create database connection */ if (server.config->GetVariable("database", "subsystem").compare("MySQL") == 0) { #ifdef EQEMU_MYSQL_ENABLED - Log.Out(Logs::General, Logs::Login_Server, "MySQL Database Init."); + Log(Logs::General, Logs::Login_Server, "MySQL Database Init."); server.db = (Database*)new DatabaseMySQL( server.config->GetVariable("database", "user"), server.config->GetVariable("database", "password"), @@ -117,7 +117,7 @@ int main() } else if (server.config->GetVariable("database", "subsystem").compare("PostgreSQL") == 0) { #ifdef EQEMU_POSTGRESQL_ENABLED - Log.Out(Logs::General, Logs::Login_Server, "PostgreSQL Database Init."); + Log(Logs::General, Logs::Login_Server, "PostgreSQL Database Init."); server.db = (Database*)new DatabasePostgreSQL( server.config->GetVariable("database", "user"), server.config->GetVariable("database", "password"), @@ -129,39 +129,39 @@ int main() /* Make sure our database got created okay, otherwise cleanup and exit. */ if (!server.db) { - Log.Out(Logs::General, Logs::Error, "Database Initialization Failure."); - Log.Out(Logs::General, Logs::Login_Server, "Config System Shutdown."); + Log(Logs::General, Logs::Error, "Database Initialization Failure."); + Log(Logs::General, Logs::Login_Server, "Config System Shutdown."); delete server.config; - Log.Out(Logs::General, Logs::Login_Server, "Log System Shutdown."); + Log(Logs::General, Logs::Login_Server, "Log System Shutdown."); return 1; } //create our server manager. - Log.Out(Logs::General, Logs::Login_Server, "Server Manager Initialize."); + Log(Logs::General, Logs::Login_Server, "Server Manager Initialize."); server.server_manager = new ServerManager(); if (!server.server_manager) { //We can't run without a server manager, cleanup and exit. - Log.Out(Logs::General, Logs::Error, "Server Manager Failed to Start."); + Log(Logs::General, Logs::Error, "Server Manager Failed to Start."); - Log.Out(Logs::General, Logs::Login_Server, "Database System Shutdown."); + Log(Logs::General, Logs::Login_Server, "Database System Shutdown."); delete server.db; - Log.Out(Logs::General, Logs::Login_Server, "Config System Shutdown."); + Log(Logs::General, Logs::Login_Server, "Config System Shutdown."); delete server.config; return 1; } //create our client manager. - Log.Out(Logs::General, Logs::Login_Server, "Client Manager Initialize."); + Log(Logs::General, Logs::Login_Server, "Client Manager Initialize."); server.client_manager = new ClientManager(); if (!server.client_manager) { //We can't run without a client manager, cleanup and exit. - Log.Out(Logs::General, Logs::Error, "Client Manager Failed to Start."); - Log.Out(Logs::General, Logs::Login_Server, "Server Manager Shutdown."); + Log(Logs::General, Logs::Error, "Client Manager Failed to Start."); + Log(Logs::General, Logs::Login_Server, "Server Manager Shutdown."); delete server.server_manager; - Log.Out(Logs::General, Logs::Login_Server, "Database System Shutdown."); + Log(Logs::General, Logs::Login_Server, "Database System Shutdown."); delete server.db; - Log.Out(Logs::General, Logs::Login_Server, "Config System Shutdown."); + Log(Logs::General, Logs::Login_Server, "Config System Shutdown."); delete server.config; return 1; } @@ -174,7 +174,7 @@ int main() #endif #endif - Log.Out(Logs::General, Logs::Login_Server, "Server Started."); + Log(Logs::General, Logs::Login_Server, "Server Started."); while (run_server) { Timer::SetCurrentTime(); server.client_manager->Process(); @@ -182,16 +182,15 @@ int main() Sleep(5); } - Log.Out(Logs::General, Logs::Login_Server, "Server Shutdown."); - Log.Out(Logs::General, Logs::Login_Server, "Client Manager Shutdown."); + Log(Logs::General, Logs::Login_Server, "Server Shutdown."); + Log(Logs::General, Logs::Login_Server, "Client Manager Shutdown."); delete server.client_manager; - Log.Out(Logs::General, Logs::Login_Server, "Server Manager Shutdown."); + Log(Logs::General, Logs::Login_Server, "Server Manager Shutdown."); delete server.server_manager; - Log.Out(Logs::General, Logs::Login_Server, "Database System Shutdown."); + Log(Logs::General, Logs::Login_Server, "Database System Shutdown."); delete server.db; - Log.Out(Logs::General, Logs::Login_Server, "Config System Shutdown."); + Log(Logs::General, Logs::Login_Server, "Config System Shutdown."); delete server.config; return 0; } - diff --git a/loginserver/server_manager.cpp b/loginserver/server_manager.cpp index 95a839341..550dba806 100644 --- a/loginserver/server_manager.cpp +++ b/loginserver/server_manager.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "server_manager.h" #include "login_server.h" @@ -22,14 +22,13 @@ #include "../common/eqemu_logsys.h" -extern EQEmuLogSys Log; extern LoginServer server; extern bool run_server; ServerManager::ServerManager() { int listen_port = atoi(server.config->GetVariable("options", "listen_port").c_str()); - + server_connection.reset(new EQ::Net::ServertalkServer()); EQ::Net::ServertalkServerOptions opts; opts.port = listen_port; @@ -37,15 +36,15 @@ ServerManager::ServerManager() server_connection->Listen(opts); server_connection->OnConnectionIdentified("World", [this](std::shared_ptr c) { - Log.OutF(Logs::General, Logs::Login_Server, "New world server connection from {0}:{1}", c->Handle()->RemoteIP(), c->Handle()->RemotePort()); - + LogF(Logs::General, Logs::Login_Server, "New world server connection from {0}:{1}", c->Handle()->RemoteIP(), c->Handle()->RemotePort()); + auto iter = world_servers.begin(); while (iter != world_servers.end()) { - if ((*iter)->GetConnection()->Handle()->RemoteIP().compare(c->Handle()->RemoteIP()) == 0 && + if ((*iter)->GetConnection()->Handle()->RemoteIP().compare(c->Handle()->RemoteIP()) == 0 && (*iter)->GetConnection()->Handle()->RemotePort() == c->Handle()->RemotePort()) { - Log.OutF(Logs::General, Logs::Login_Server, "World server already existed for {0}:{1}, removing existing connection.", + LogF(Logs::General, Logs::Login_Server, "World server already existed for {0}:{1}, removing existing connection.", c->Handle()->RemoteIP(), c->Handle()->RemotePort()); - + world_servers.erase(iter); break; } @@ -60,7 +59,7 @@ ServerManager::ServerManager() auto iter = world_servers.begin(); while (iter != world_servers.end()) { if ((*iter)->GetConnection()->GetUUID() == c->GetUUID()) { - Log.OutF(Logs::General, Logs::World_Server, "World server {0} has been disconnected, removing.", (*iter)->GetLongName().c_str()); + LogF(Logs::General, Logs::World_Server, "World server {0} has been disconnected, removing.", (*iter)->GetLongName().c_str()); world_servers.erase(iter); return; } @@ -72,7 +71,7 @@ ServerManager::ServerManager() ServerManager::~ServerManager() { - + } WorldServer* ServerManager::GetServerByAddress(const std::string &addr, int port) @@ -84,7 +83,7 @@ WorldServer* ServerManager::GetServerByAddress(const std::string &addr, int port } ++iter; } - + return nullptr; } @@ -126,8 +125,8 @@ EQApplicationPacket *ServerManager::CreateServerListPacket(Client *c, uint32 seq server_list->Unknown3 = 0x01650000; /** - * Not sure what this is but it should be noted setting it to - * 0xFFFFFFFF crashes the client so: don't do that. + * Not sure what this is but it should be noted setting it to + * 0xFFFFFFFF crashes the client so: don't do that. */ server_list->Unknown4 = 0x00000000; server_list->NumberOfServers = server_count; @@ -157,17 +156,17 @@ EQApplicationPacket *ServerManager::CreateServerListPacket(Client *c, uint32 seq } switch ((*iter)->GetServerListID()) { - case 1: { - *(unsigned int*)data_pointer = 0x00000030; - break; - } - case 2: { - *(unsigned int*)data_pointer = 0x00000009; - break; - } - default: { - *(unsigned int*)data_pointer = 0x00000001; - } + case 1: { + *(unsigned int*)data_pointer = 0x00000030; + break; + } + case 2: { + *(unsigned int*)data_pointer = 0x00000009; + break; + } + default: { + *(unsigned int*)data_pointer = 0x00000001; + } } data_pointer += 4; @@ -215,21 +214,21 @@ void ServerManager::SendUserToWorldRequest(unsigned int server_id, unsigned int if ((*iter)->GetRuntimeID() == server_id) { EQ::Net::DynamicPacket outapp; outapp.Resize(sizeof(UsertoWorldRequest_Struct)); - UsertoWorldRequest_Struct *utwr = (UsertoWorldRequest_Struct*)outapp.Data(); + UsertoWorldRequest_Struct *utwr = (UsertoWorldRequest_Struct*)outapp.Data(); utwr->worldid = server_id; utwr->lsaccountid = client_account_id; (*iter)->GetConnection()->Send(ServerOP_UsertoWorldReq, outapp); found = true; if (server.options.IsDumpInPacketsOn()) { - Log.OutF(Logs::General, Logs::Login_Server, "{0}", outapp.ToString()); + LogF(Logs::General, Logs::Login_Server, "{0}", outapp.ToString()); } } ++iter; } if (!found && server.options.IsTraceOn()) { - Log.Out(Logs::General, Logs::Error, "Client requested a user to world but supplied an invalid id of %u.", server_id); + Log(Logs::General, Logs::Error, "Client requested a user to world but supplied an invalid id of %u.", server_id); } } @@ -266,4 +265,4 @@ void ServerManager::DestroyServerByName(std::string l_name, std::string s_name, ++iter; } -} +} \ No newline at end of file diff --git a/loginserver/world_server.cpp b/loginserver/world_server.cpp index fb171bea3..55fc03b7b 100644 --- a/loginserver/world_server.cpp +++ b/loginserver/world_server.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2010 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "world_server.h" #include "login_server.h" @@ -22,7 +22,6 @@ #include "../common/eqemu_logsys.h" -extern EQEmuLogSys Log; extern LoginServer server; WorldServer::WorldServer(std::shared_ptr c) @@ -46,7 +45,7 @@ WorldServer::WorldServer(std::shared_ptr c) WorldServer::~WorldServer() { - + } void WorldServer::Reset() @@ -65,7 +64,7 @@ void WorldServer::ProcessNewLSInfo(uint16_t opcode, const EQ::Net::Packet &p) { if (server.options.IsWorldTraceOn()) { - Log.Out(Logs::General, Logs::Netcode, "Application packet received from server: 0x%.4X, (size %u)", opcode, p.Length()); + Log(Logs::General, Logs::Netcode, "Application packet received from server: 0x%.4X, (size %u)", opcode, p.Length()); } if (server.options.IsDumpInPacketsOn()) @@ -75,14 +74,14 @@ void WorldServer::ProcessNewLSInfo(uint16_t opcode, const EQ::Net::Packet &p) if (p.Length() < sizeof(ServerNewLSInfo_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received application packet from server that had opcode ServerOP_NewLSInfo, " + Log(Logs::General, Logs::Error, "Received application packet from server that had opcode ServerOP_NewLSInfo, " "but was too small. Discarded to avoid buffer overrun."); return; } if (server.options.IsWorldTraceOn()) { - Log.Out(Logs::General, Logs::Netcode, "New Login Info Recieved."); + Log(Logs::General, Logs::Netcode, "New Login Info Recieved."); } ServerNewLSInfo_Struct *info = (ServerNewLSInfo_Struct*)p.Data(); @@ -93,7 +92,7 @@ void WorldServer::ProcessLSStatus(uint16_t opcode, const EQ::Net::Packet &p) { if (server.options.IsWorldTraceOn()) { - Log.Out(Logs::General, Logs::Netcode, "Application packet received from server: 0x%.4X, (size %u)", opcode, p.Length()); + Log(Logs::General, Logs::Netcode, "Application packet received from server: 0x%.4X, (size %u)", opcode, p.Length()); } if (server.options.IsDumpInPacketsOn()) @@ -103,14 +102,14 @@ void WorldServer::ProcessLSStatus(uint16_t opcode, const EQ::Net::Packet &p) if (p.Length() < sizeof(ServerLSStatus_Struct)) { - Log.Out(Logs::General, Logs::Error, "Recieved application packet from server that had opcode ServerOP_LSStatus, " + Log(Logs::General, Logs::Error, "Recieved application packet from server that had opcode ServerOP_LSStatus, " "but was too small. Discarded to avoid buffer overrun."); return; } if (server.options.IsWorldTraceOn()) { - Log.Out(Logs::General, Logs::Netcode, "World Server Status Recieved."); + Log(Logs::General, Logs::Netcode, "World Server Status Recieved."); } ServerLSStatus_Struct *ls_status = (ServerLSStatus_Struct*)p.Data(); @@ -121,7 +120,7 @@ void WorldServer::ProcessUsertoWorldResp(uint16_t opcode, const EQ::Net::Packet { if (server.options.IsWorldTraceOn()) { - Log.Out(Logs::General, Logs::Netcode, "Application packet received from server: 0x%.4X, (size %u)", opcode, p.Length()); + Log(Logs::General, Logs::Netcode, "Application packet received from server: 0x%.4X, (size %u)", opcode, p.Length()); } if (server.options.IsDumpInPacketsOn()) @@ -131,7 +130,7 @@ void WorldServer::ProcessUsertoWorldResp(uint16_t opcode, const EQ::Net::Packet if (p.Length() < sizeof(UsertoWorldResponse_Struct)) { - Log.Out(Logs::General, Logs::Error, "Recieved application packet from server that had opcode ServerOP_UsertoWorldResp, " + Log(Logs::General, Logs::Error, "Recieved application packet from server that had opcode ServerOP_UsertoWorldResp, " "but was too small. Discarded to avoid buffer overrun."); return; } @@ -141,22 +140,22 @@ void WorldServer::ProcessUsertoWorldResp(uint16_t opcode, const EQ::Net::Packet //While keeping world server spam with multiple servers connected almost impossible. if (server.options.IsTraceOn()) { - Log.Out(Logs::General, Logs::Netcode, "User-To-World Response received."); + Log(Logs::General, Logs::Netcode, "User-To-World Response received."); } UsertoWorldResponse_Struct *utwr = (UsertoWorldResponse_Struct*)p.Data(); - Log.Out(Logs::General, Logs::Debug, "Trying to find client with user id of %u.", utwr->lsaccountid); + Log(Logs::General, Logs::Debug, "Trying to find client with user id of %u.", utwr->lsaccountid); Client *c = server.client_manager->GetClient(utwr->lsaccountid); if (c) { - Log.Out(Logs::General, Logs::Debug, "Found client with user id of %u and account name of %s.", utwr->lsaccountid, c->GetAccountName().c_str()); + Log(Logs::General, Logs::Debug, "Found client with user id of %u and account name of %s.", utwr->lsaccountid, c->GetAccountName().c_str()); EQApplicationPacket *outapp = new EQApplicationPacket(OP_PlayEverquestResponse, sizeof(PlayEverquestResponse_Struct)); PlayEverquestResponse_Struct *per = (PlayEverquestResponse_Struct*)outapp->pBuffer; per->Sequence = c->GetPlaySequence(); per->ServerNumber = c->GetPlayServerID(); - Log.Out(Logs::General, Logs::Debug, "Found sequence and play of %u %u", c->GetPlaySequence(), c->GetPlayServerID()); + Log(Logs::General, Logs::Debug, "Found sequence and play of %u %u", c->GetPlaySequence(), c->GetPlayServerID()); - Log.Out(Logs::General, Logs::Netcode, "[Size: %u] %s", outapp->size, DumpPacketToString(outapp).c_str()); + Log(Logs::General, Logs::Netcode, "[Size: %u] %s", outapp->size, DumpPacketToString(outapp).c_str()); if (utwr->response > 0) { @@ -185,9 +184,9 @@ void WorldServer::ProcessUsertoWorldResp(uint16_t opcode, const EQ::Net::Packet if (server.options.IsTraceOn()) { - Log.Out(Logs::General, Logs::Netcode, "Sending play response with following data, allowed %u, sequence %u, server number %u, message %u", + Log(Logs::General, Logs::Netcode, "Sending play response with following data, allowed %u, sequence %u, server number %u, message %u", per->Allowed, per->Sequence, per->ServerNumber, per->Message); - Log.Out(Logs::General, Logs::Netcode, "[Size: %u] %s", outapp->size, DumpPacketToString(outapp).c_str()); + Log(Logs::General, Logs::Netcode, "[Size: %u] %s", outapp->size, DumpPacketToString(outapp).c_str()); } if (server.options.IsDumpOutPacketsOn()) @@ -200,7 +199,7 @@ void WorldServer::ProcessUsertoWorldResp(uint16_t opcode, const EQ::Net::Packet } else { - Log.Out(Logs::General, Logs::Error, "Recieved User-To-World Response for %u but could not find the client referenced!.", utwr->lsaccountid); + Log(Logs::General, Logs::Error, "Recieved User-To-World Response for %u but could not find the client referenced!.", utwr->lsaccountid); } } @@ -208,7 +207,7 @@ void WorldServer::ProcessLSAccountUpdate(uint16_t opcode, const EQ::Net::Packet { if (server.options.IsWorldTraceOn()) { - Log.Out(Logs::General, Logs::Netcode, "Application packet received from server: 0x%.4X, (size %u)", opcode, p.Length()); + Log(Logs::General, Logs::Netcode, "Application packet received from server: 0x%.4X, (size %u)", opcode, p.Length()); } if (server.options.IsDumpInPacketsOn()) @@ -218,16 +217,16 @@ void WorldServer::ProcessLSAccountUpdate(uint16_t opcode, const EQ::Net::Packet if (p.Length() < sizeof(ServerLSAccountUpdate_Struct)) { - Log.Out(Logs::General, Logs::Error, "Recieved application packet from server that had opcode ServerLSAccountUpdate_Struct, " + Log(Logs::General, Logs::Error, "Recieved application packet from server that had opcode ServerLSAccountUpdate_Struct, " "but was too small. Discarded to avoid buffer overrun."); return; } - Log.Out(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate packet received from: %s", short_name.c_str()); + Log(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate packet received from: %s", short_name.c_str()); ServerLSAccountUpdate_Struct *lsau = (ServerLSAccountUpdate_Struct*)p.Data(); if (is_server_trusted) { - Log.Out(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate update processed for: %s", lsau->useraccount); + Log(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate update processed for: %s", lsau->useraccount); std::string name; std::string password; std::string email; @@ -240,57 +239,57 @@ void WorldServer::ProcessLSAccountUpdate(uint16_t opcode, const EQ::Net::Packet void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) { - if(is_server_logged_in) + if (is_server_logged_in) { - Log.Out(Logs::General, Logs::Error, "WorldServer::Handle_NewLSInfo called but the login server was already marked as logged in, aborting."); + Log(Logs::General, Logs::Error, "WorldServer::Handle_NewLSInfo called but the login server was already marked as logged in, aborting."); return; } - if(strlen(i->account) <= 30) + if (strlen(i->account) <= 30) { account_name = i->account; } else { - Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, account name was too long."); + Log(Logs::General, Logs::Error, "Handle_NewLSInfo error, account name was too long."); return; } - if(strlen(i->password) <= 30) + if (strlen(i->password) <= 30) { account_password = i->password; } else { - Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, account password was too long."); + Log(Logs::General, Logs::Error, "Handle_NewLSInfo error, account password was too long."); return; } - if(strlen(i->name) <= 200) + if (strlen(i->name) <= 200) { long_name = i->name; } else { - Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, long name was too long."); + Log(Logs::General, Logs::Error, "Handle_NewLSInfo error, long name was too long."); return; } - if(strlen(i->shortname) <= 50) + if (strlen(i->shortname) <= 50) { short_name = i->shortname; } else { - Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, short name was too long."); + Log(Logs::General, Logs::Error, "Handle_NewLSInfo error, short name was too long."); return; } - if(strlen(i->local_address) <= 125) + if (strlen(i->local_address) <= 125) { - if(strlen(i->local_address) == 0) + if (strlen(i->local_address) == 0) { - Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, local address was null, defaulting to localhost"); + Log(Logs::General, Logs::Error, "Handle_NewLSInfo error, local address was null, defaulting to localhost"); local_ip = "127.0.0.1"; } else @@ -300,16 +299,16 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else { - Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, local address was too long."); + Log(Logs::General, Logs::Error, "Handle_NewLSInfo error, local address was too long."); return; } - if(strlen(i->remote_address) <= 125) + if (strlen(i->remote_address) <= 125) { - if(strlen(i->remote_address) == 0) + if (strlen(i->remote_address) == 0) { remote_ip = GetConnection()->Handle()->RemoteIP(); - Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, remote address was null, defaulting to stream address %s.", remote_ip.c_str()); + Log(Logs::General, Logs::Error, "Handle_NewLSInfo error, remote address was null, defaulting to stream address %s.", remote_ip.c_str()); } else { @@ -319,52 +318,52 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) else { remote_ip = GetConnection()->Handle()->RemoteIP(); - Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, remote address was too long, defaulting to stream address %s.", remote_ip.c_str()); + Log(Logs::General, Logs::Error, "Handle_NewLSInfo error, remote address was too long, defaulting to stream address %s.", remote_ip.c_str()); } - if(strlen(i->serverversion) <= 64) + if (strlen(i->serverversion) <= 64) { version = i->serverversion; } else { - Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, server version was too long."); + Log(Logs::General, Logs::Error, "Handle_NewLSInfo error, server version was too long."); return; } - if(strlen(i->protocolversion) <= 25) + if (strlen(i->protocolversion) <= 25) { protocol = i->protocolversion; } else { - Log.Out(Logs::General, Logs::Error, "Handle_NewLSInfo error, protocol version was too long."); + Log(Logs::General, Logs::Error, "Handle_NewLSInfo error, protocol version was too long."); return; } server_type = i->servertype; is_server_logged_in = true; - if(server.options.IsRejectingDuplicateServers()) + if (server.options.IsRejectingDuplicateServers()) { - if(server.server_manager->ServerExists(long_name, short_name, this)) + if (server.server_manager->ServerExists(long_name, short_name, this)) { - Log.Out(Logs::General, Logs::Error, "World tried to login but there already exists a server that has that name."); + Log(Logs::General, Logs::Error, "World tried to login but there already exists a server that has that name."); return; } } else { - if(server.server_manager->ServerExists(long_name, short_name, this)) + if (server.server_manager->ServerExists(long_name, short_name, this)) { - Log.Out(Logs::General, Logs::Error, "World tried to login but there already exists a server that has that name."); + Log(Logs::General, Logs::Error, "World tried to login but there already exists a server that has that name."); server.server_manager->DestroyServerByName(long_name, short_name, this); } } - if(!server.options.IsUnregisteredAllowed()) + if (!server.options.IsUnregisteredAllowed()) { - if(account_name.size() > 0 && account_password.size() > 0) + if (account_name.size() > 0 && account_password.size() > 0) { unsigned int s_id = 0; unsigned int s_list_type = 0; @@ -373,27 +372,27 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) std::string s_list_desc; std::string s_acct_name; std::string s_acct_pass; - if(server.db->GetWorldRegistration(long_name, short_name, s_id, s_desc, s_list_type, s_trusted, s_list_desc, s_acct_name, s_acct_pass)) + if (server.db->GetWorldRegistration(long_name, short_name, s_id, s_desc, s_list_type, s_trusted, s_list_desc, s_acct_name, s_acct_pass)) { - if(s_acct_name.size() == 0 || s_acct_pass.size() == 0) + if (s_acct_name.size() == 0 || s_acct_pass.size() == 0) { - Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) successfully logged into account that had no user/password requirement.", + Log(Logs::General, Logs::World_Server, "Server %s(%s) successfully logged into account that had no user/password requirement.", long_name.c_str(), short_name.c_str()); is_server_authorized = true; SetRuntimeID(s_id); server_list_id = s_list_type; desc = s_desc; } - else if(s_acct_name.compare(account_name) == 0 && s_acct_pass.compare(account_password) == 0) + else if (s_acct_name.compare(account_name) == 0 && s_acct_pass.compare(account_password) == 0) { - Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) successfully logged in.", + Log(Logs::General, Logs::World_Server, "Server %s(%s) successfully logged in.", long_name.c_str(), short_name.c_str()); is_server_authorized = true; SetRuntimeID(s_id); server_list_id = s_list_type; desc = s_desc; - if(s_trusted) { - Log.Out(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate sent to world"); + if (s_trusted) { + Log(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate sent to world"); is_server_trusted = true; EQ::Net::DynamicPacket outapp; @@ -401,19 +400,19 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } } else { - Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but account and password did not match the entry in the database, and only" + Log(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but account and password did not match the entry in the database, and only" " registered servers are allowed.", long_name.c_str(), short_name.c_str()); return; } } else { - Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but database couldn't find an entry and only registered servers are allowed.", + Log(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but database couldn't find an entry and only registered servers are allowed.", long_name.c_str(), short_name.c_str()); return; } } else { - Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) did not attempt to log in but only registered servers are allowed.", + Log(Logs::General, Logs::World_Server, "Server %s(%s) did not attempt to log in but only registered servers are allowed.", long_name.c_str(), short_name.c_str()); return; } @@ -428,29 +427,29 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) std::string server_account_password; - if(server.db->GetWorldRegistration( - long_name, - short_name, - server_id, - server_description, - server_list_type, - is_server_trusted, - server_list_description, - server_account_name, - server_account_password)) + if (server.db->GetWorldRegistration( + long_name, + short_name, + server_id, + server_description, + server_list_type, + is_server_trusted, + server_list_description, + server_account_name, + server_account_password)) { - - if(account_name.size() > 0 && account_password.size() > 0) { - if(server_account_name.compare(account_name) == 0 && server_account_password.compare(account_password) == 0) { - Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) successfully logged in.", + + if (account_name.size() > 0 && account_password.size() > 0) { + if (server_account_name.compare(account_name) == 0 && server_account_password.compare(account_password) == 0) { + Log(Logs::General, Logs::World_Server, "Server %s(%s) successfully logged in.", long_name.c_str(), short_name.c_str()); is_server_authorized = true; SetRuntimeID(server_id); server_list_id = server_list_type; desc = server_description; - if(is_server_trusted) { - Log.Out(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate sent to world"); + if (is_server_trusted) { + Log(Logs::General, Logs::Netcode, "ServerOP_LSAccountUpdate sent to world"); is_server_trusted = true; EQ::Net::DynamicPacket outapp; connection->Send(ServerOP_LSAccountUpdate, outapp); @@ -458,18 +457,18 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else { // this is the first of two cases where we should deny access even if unregistered is allowed - Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but account and password did not match the entry in the database.", + Log(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but account and password did not match the entry in the database.", long_name.c_str(), short_name.c_str()); } } else { - if(server_account_name.size() > 0 || server_account_password.size() > 0) { + if (server_account_name.size() > 0 || server_account_password.size() > 0) { // this is the second of two cases where we should deny access even if unregistered is allowed - Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) did not attempt to log in but this server requires a password.", + Log(Logs::General, Logs::World_Server, "Server %s(%s) did not attempt to log in but this server requires a password.", long_name.c_str(), short_name.c_str()); } else { - Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) did not attempt to log in but unregistered servers are allowed.", + Log(Logs::General, Logs::World_Server, "Server %s(%s) did not attempt to log in but unregistered servers are allowed.", long_name.c_str(), short_name.c_str()); is_server_authorized = true; SetRuntimeID(server_id); @@ -479,9 +478,9 @@ void WorldServer::Handle_NewLSInfo(ServerNewLSInfo_Struct* i) } else { - Log.Out(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but database couldn't find an entry but unregistered servers are allowed.", + Log(Logs::General, Logs::World_Server, "Server %s(%s) attempted to log in but database couldn't find an entry but unregistered servers are allowed.", long_name.c_str(), short_name.c_str()); - if(server.db->CreateWorldRegistration(long_name, short_name, server_id)) { + if (server.db->CreateWorldRegistration(long_name, short_name, server_id)) { is_server_authorized = true; SetRuntimeID(server_id); server_list_id = 3; @@ -509,10 +508,10 @@ void WorldServer::SendClientAuth(std::string ip, std::string account, std::strin client_auth.lsadmin = 0; client_auth.worldadmin = 0; client_auth.ip = inet_addr(ip.c_str()); - + std::string client_address(ip); std::string world_address(connection->Handle()->RemoteIP()); - + if (client_address.compare(world_address) == 0) { client_auth.local = 1; } @@ -522,13 +521,12 @@ void WorldServer::SendClientAuth(std::string ip, std::string account, std::strin else { client_auth.local = 0; } - + outapp.PutSerialize(0, client_auth); connection->Send(ServerOP_LSClientAuth, outapp); - + if (server.options.IsDumpInPacketsOn()) { DumpPacket(ServerOP_LSClientAuth, outapp); } } - diff --git a/queryserv/database.cpp b/queryserv/database.cpp index 6216e112d..c4e185360 100644 --- a/queryserv/database.cpp +++ b/queryserv/database.cpp @@ -69,14 +69,14 @@ bool Database::Connect(const char* host, const char* user, const char* passwd, c char errbuf[MYSQL_ERRMSG_SIZE]; if (!Open(host, user, passwd, database, port, &errnum, errbuf)) { - Log.Out(Logs::General, Logs::Error, "Failed to connect to database: Error: %s", errbuf); + Log(Logs::General, Logs::Error, "Failed to connect to database: Error: %s", errbuf); HandleMysqlError(errnum); return false; } else { - Log.Out(Logs::General, Logs::Status, "Using database '%s' at %s:%d",database,host,port); + Log(Logs::General, Logs::Status, "Using database '%s' at %s:%d",database,host,port); return true; } } @@ -116,8 +116,8 @@ void Database::AddSpeech(const char* from, const char* to, const char* message, safe_delete_array(escapedMessage); auto results = QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed Speech Entry Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed Speech Entry Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } @@ -136,8 +136,8 @@ void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 detailCount) { QS->char2_money.silver, QS->char2_money.copper, QS->char2_count); auto results = QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed Trade Log Record Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed Trade Log Record Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } if(detailCount == 0) @@ -156,8 +156,8 @@ void Database::LogPlayerTrade(QSPlayerLogTrade_Struct* QS, uint32 detailCount) { QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5); results = QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed Trade Log Record Entry Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed Trade Log Record Entry Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } } @@ -179,8 +179,8 @@ void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 detailCount) QS->npc_count); auto results = QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed Handin Log Record Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed Handin Log Record Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } if(detailCount == 0) @@ -198,8 +198,8 @@ void Database::LogPlayerHandin(QSPlayerLogHandin_Struct* QS, uint32 detailCount) QS->items[i].aug_2, QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed Handin Log Record Entry Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed Handin Log Record Entry Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } } @@ -213,8 +213,8 @@ void Database::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct* QS, uint32 members){ QS->s1.NPCID, QS->s1.Type, QS->s1.ZoneID); auto results = QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed NPC Kill Log Record Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed NPC Kill Log Record Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } if(members == 0) @@ -228,8 +228,8 @@ void Database::LogPlayerNPCKill(QSPlayerLogNPCKill_Struct* QS, uint32 members){ lastIndex, QS->Chars[i].char_id); auto results = QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed NPC Kill Log Entry Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed NPC Kill Log Entry Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } } @@ -243,8 +243,8 @@ void Database::LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 items) { QS->char_id, QS->stack_size, QS->char_count, QS->char_count); auto results = QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed Delete Log Record Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed Delete Log Record Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } if(items == 0) @@ -261,8 +261,8 @@ void Database::LogPlayerDelete(QSPlayerLogDelete_Struct* QS, uint32 items) { QS->items[i].aug_5); results = QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed Delete Log Record Entry Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed Delete Log Record Entry Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } } @@ -279,8 +279,8 @@ void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 items) { QS->char_count, QS->postaction); auto results = QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed Move Log Record Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed Move Log Record Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } if(items == 0) @@ -297,8 +297,8 @@ void Database::LogPlayerMove(QSPlayerLogMove_Struct* QS, uint32 items) { QS->items[i].aug_3, QS->items[i].aug_4, QS->items[i].aug_5); results = QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed Move Log Record Entry Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed Move Log Record Entry Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } } @@ -320,8 +320,8 @@ void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint3 QS->char_money.copper, QS->char_count); auto results = QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed Transaction Log Record Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed Transaction Log Record Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } if(items == 0) @@ -338,8 +338,8 @@ void Database::LogMerchantTransaction(QSMerchantLogTransaction_Struct* QS, uint3 QS->items[i].aug_5); results = QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed Transaction Log Record Entry Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed Transaction Log Record Entry Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } } @@ -356,8 +356,8 @@ void Database::GeneralQueryReceive(ServerPacket *pack) { std::string query(queryBuffer); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::Detail, Logs::QS_Server, "Failed Delete Log Record Insert: %s", results.ErrorMessage().c_str()); - Log.Out(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); + Log(Logs::Detail, Logs::QS_Server, "Failed Delete Log Record Insert: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::QS_Server, "%s", query.c_str()); } safe_delete(pack); @@ -378,7 +378,7 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings){ auto results = QueryDatabase(query); int log_category = 0; - Log.file_logs_enabled = false; + LogSys.file_logs_enabled = false; for (auto row = results.begin(); row != results.end(); ++row) { log_category = atoi(row[0]); @@ -401,7 +401,7 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings){ If we go through this whole loop and nothing is set to any debug level, there is no point to create a file or keep anything open */ if (log_settings[log_category].log_to_file > 0){ - Log.file_logs_enabled = true; + LogSys.file_logs_enabled = true; } } } diff --git a/queryserv/queryserv.cpp b/queryserv/queryserv.cpp index 893462afe..cef6e40e3 100644 --- a/queryserv/queryserv.cpp +++ b/queryserv/queryserv.cpp @@ -40,7 +40,7 @@ LFGuildManager lfguildmanager; std::string WorldShortName; const queryservconfig *Config; WorldServer *worldserver = 0; -EQEmuLogSys Log; +EQEmuLogSys LogSys; void CatchSignal(int sig_num) { RunLoops = false; @@ -48,20 +48,20 @@ void CatchSignal(int sig_num) { int main() { RegisterExecutablePlatform(ExePlatformQueryServ); - Log.LoadLogSettingsDefaults(); + LogSys.LoadLogSettingsDefaults(); set_exception_handler(); Timer LFGuildExpireTimer(60000); - Log.Out(Logs::General, Logs::QS_Server, "Starting EQEmu QueryServ."); + Log(Logs::General, Logs::QS_Server, "Starting EQEmu QueryServ."); if (!queryservconfig::LoadConfig()) { - Log.Out(Logs::General, Logs::QS_Server, "Loading server configuration failed."); + Log(Logs::General, Logs::QS_Server, "Loading server configuration failed."); return 1; } Config = queryservconfig::get(); WorldShortName = Config->ShortName; - Log.Out(Logs::General, Logs::QS_Server, "Connecting to MySQL..."); + Log(Logs::General, Logs::QS_Server, "Connecting to MySQL..."); /* MySQL Connection */ if (!database.Connect( @@ -70,20 +70,20 @@ int main() { Config->QSDatabasePassword.c_str(), Config->QSDatabaseDB.c_str(), Config->QSDatabasePort)) { - Log.Out(Logs::General, Logs::QS_Server, "Cannot continue without a database connection."); + Log(Logs::General, Logs::QS_Server, "Cannot continue without a database connection."); return 1; } /* Register Log System and Settings */ - database.LoadLogSettings(Log.log_settings); - Log.StartFileLogs(); + database.LoadLogSettings(LogSys.log_settings); + LogSys.StartFileLogs(); if (signal(SIGINT, CatchSignal) == SIG_ERR) { - Log.Out(Logs::General, Logs::QS_Server, "Could not set signal handler"); + Log(Logs::General, Logs::QS_Server, "Could not set signal handler"); return 1; } if (signal(SIGTERM, CatchSignal) == SIG_ERR) { - Log.Out(Logs::General, Logs::QS_Server, "Could not set signal handler"); + Log(Logs::General, Logs::QS_Server, "Could not set signal handler"); return 1; } @@ -102,7 +102,7 @@ int main() { EQ::EventLoop::Get().Process(); Sleep(5); } - Log.CloseFileLogs(); + LogSys.CloseFileLogs(); } void UpdateWindowTitle(char* iNewTitle) { diff --git a/queryserv/worldserver.cpp b/queryserv/worldserver.cpp index a63685d20..686c92326 100644 --- a/queryserv/worldserver.cpp +++ b/queryserv/worldserver.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) +Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -79,107 +79,105 @@ bool WorldServer::Connected() const void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { - Log.OutF(Logs::General, Logs::Debug, "Received Opcode: {0}\n{1}", opcode, p.ToString()); + switch (opcode) { + case 0: { + break; + } + case ServerOP_KeepAlive: { + break; + } + case ServerOP_Speech: { + Server_Speech_Struct *SSS = (Server_Speech_Struct*)p.Data(); + std::string tmp1 = SSS->from; + std::string tmp2 = SSS->to; + database.AddSpeech(tmp1.c_str(), tmp2.c_str(), SSS->message, SSS->minstatus, SSS->guilddbid, SSS->type); + break; + } + case ServerOP_QSPlayerLogTrades: { + QSPlayerLogTrade_Struct *QS = (QSPlayerLogTrade_Struct*)p.Data(); + database.LogPlayerTrade(QS, QS->_detail_count); + break; + } + case ServerOP_QSPlayerLogHandins: { + QSPlayerLogHandin_Struct *QS = (QSPlayerLogHandin_Struct*)p.Data(); + database.LogPlayerHandin(QS, QS->_detail_count); + break; + } + case ServerOP_QSPlayerLogNPCKills: { + QSPlayerLogNPCKill_Struct *QS = (QSPlayerLogNPCKill_Struct*)p.Data(); + uint32 Members = (uint32)(p.Length() - sizeof(QSPlayerLogNPCKill_Struct)); + if (Members > 0) Members = Members / sizeof(QSPlayerLogNPCKillsPlayers_Struct); + database.LogPlayerNPCKill(QS, Members); + break; + } + case ServerOP_QSPlayerLogDeletes: { + QSPlayerLogDelete_Struct *QS = (QSPlayerLogDelete_Struct*)p.Data(); + uint32 Items = QS->char_count; + database.LogPlayerDelete(QS, Items); + break; + } + case ServerOP_QSPlayerLogMoves: { + QSPlayerLogMove_Struct *QS = (QSPlayerLogMove_Struct*)p.Data(); + uint32 Items = QS->char_count; + database.LogPlayerMove(QS, Items); + break; + } + case ServerOP_QSPlayerLogMerchantTransactions: { + QSMerchantLogTransaction_Struct *QS = (QSMerchantLogTransaction_Struct*)p.Data(); + uint32 Items = QS->char_count + QS->merchant_count; + database.LogMerchantTransaction(QS, Items); + break; + } + case ServerOP_QueryServGeneric: { + /* + The purpose of ServerOP_QueryServerGeneric is so that we don't have to add code to world just to relay packets + each time we add functionality to queryserv. - switch(opcode) { - case 0: { - break; - } - case ServerOP_KeepAlive: { - break; - } - case ServerOP_Speech: { - Server_Speech_Struct *SSS = (Server_Speech_Struct*)p.Data(); - std::string tmp1 = SSS->from; - std::string tmp2 = SSS->to; - database.AddSpeech(tmp1.c_str(), tmp2.c_str(), SSS->message, SSS->minstatus, SSS->guilddbid, SSS->type); - break; - } - case ServerOP_QSPlayerLogTrades: { - QSPlayerLogTrade_Struct *QS = (QSPlayerLogTrade_Struct*)p.Data(); - database.LogPlayerTrade(QS, QS->_detail_count); - break; - } - case ServerOP_QSPlayerLogHandins: { - QSPlayerLogHandin_Struct *QS = (QSPlayerLogHandin_Struct*)p.Data(); - database.LogPlayerHandin(QS, QS->_detail_count); - break; - } - case ServerOP_QSPlayerLogNPCKills: { - QSPlayerLogNPCKill_Struct *QS = (QSPlayerLogNPCKill_Struct*)p.Data(); - uint32 Members = (uint32)(p.Length() - sizeof(QSPlayerLogNPCKill_Struct)); - if (Members > 0) Members = Members / sizeof(QSPlayerLogNPCKillsPlayers_Struct); - database.LogPlayerNPCKill(QS, Members); - break; - } - case ServerOP_QSPlayerLogDeletes: { - QSPlayerLogDelete_Struct *QS = (QSPlayerLogDelete_Struct*)p.Data(); - uint32 Items = QS->char_count; - database.LogPlayerDelete(QS, Items); - break; - } - case ServerOP_QSPlayerLogMoves: { - QSPlayerLogMove_Struct *QS = (QSPlayerLogMove_Struct*)p.Data(); - uint32 Items = QS->char_count; - database.LogPlayerMove(QS, Items); - break; - } - case ServerOP_QSPlayerLogMerchantTransactions: { - QSMerchantLogTransaction_Struct *QS = (QSMerchantLogTransaction_Struct*)p.Data(); - uint32 Items = QS->char_count + QS->merchant_count; - database.LogMerchantTransaction(QS, Items); - break; - } - case ServerOP_QueryServGeneric: { - /* - The purpose of ServerOP_QueryServerGeneric is so that we don't have to add code to world just to relay packets - each time we add functionality to queryserv. - - A ServerOP_QueryServGeneric packet has the following format: - - uint32 SourceZoneID - uint32 SourceInstanceID - char OriginatingCharacterName[0] - - Null terminated name of the character this packet came from. This could be just - - an empty string if it has no meaning in the context of a particular packet. - uint32 Type - - The 'Type' field is a 'sub-opcode'. A value of 0 is used for the LFGuild packets. The next feature to be added - to queryserv would use 1, etc. - - Obviously, any fields in the packet following the 'Type' will be unique to the particular type of packet. The - 'Generic' in the name of this ServerOP code relates to the four header fields. - */ - - auto from = p.GetCString(8); - uint32 Type = p.GetUInt32(8 + from.length() + 1); - - switch(Type) { - case QSG_LFGuild:{ - ServerPacket pack; - pack.pBuffer = (uchar*)p.Data(); - pack.opcode = opcode; - pack.size = (uint32)p.Length(); - lfguildmanager.HandlePacket(&pack); - pack.pBuffer = nullptr; - break; - } - default: - Log.Out(Logs::Detail, Logs::QS_Server, "Received unhandled ServerOP_QueryServGeneric", Type); - break; - } - break; - } - case ServerOP_QSSendQuery: { - /* Process all packets here */ + A ServerOP_QueryServGeneric packet has the following format: + + uint32 SourceZoneID + uint32 SourceInstanceID + char OriginatingCharacterName[0] + - Null terminated name of the character this packet came from. This could be just + - an empty string if it has no meaning in the context of a particular packet. + uint32 Type + + The 'Type' field is a 'sub-opcode'. A value of 0 is used for the LFGuild packets. The next feature to be added + to queryserv would use 1, etc. + + Obviously, any fields in the packet following the 'Type' will be unique to the particular type of packet. The + 'Generic' in the name of this ServerOP code relates to the four header fields. + */ + + auto from = p.GetCString(8); + uint32 Type = p.GetUInt32(8 + from.length() + 1); + + switch (Type) { + case QSG_LFGuild: { ServerPacket pack; pack.pBuffer = (uchar*)p.Data(); pack.opcode = opcode; pack.size = (uint32)p.Length(); - - database.GeneralQueryReceive(&pack); + lfguildmanager.HandlePacket(&pack); pack.pBuffer = nullptr; break; } + default: + Log(Logs::Detail, Logs::QS_Server, "Received unhandled ServerOP_QueryServGeneric", Type); + break; + } + break; } -} + case ServerOP_QSSendQuery: { + /* Process all packets here */ + ServerPacket pack; + pack.pBuffer = (uchar*)p.Data(); + pack.opcode = opcode; + pack.size = (uint32)p.Length(); + + database.GeneralQueryReceive(&pack); + pack.pBuffer = nullptr; + break; + } + } +} \ No newline at end of file diff --git a/shared_memory/main.cpp b/shared_memory/main.cpp index d80c22156..63280adc0 100644 --- a/shared_memory/main.cpp +++ b/shared_memory/main.cpp @@ -34,7 +34,7 @@ #include "spells.h" #include "base_data.h" -EQEmuLogSys Log; +EQEmuLogSys LogSys; #ifdef _WINDOWS #include @@ -71,33 +71,33 @@ inline bool MakeDirectory(const std::string &directory_name) int main(int argc, char **argv) { RegisterExecutablePlatform(ExePlatformSharedMemory); - Log.LoadLogSettingsDefaults(); + LogSys.LoadLogSettingsDefaults(); set_exception_handler(); - Log.Out(Logs::General, Logs::Status, "Shared Memory Loader Program"); + Log(Logs::General, Logs::Status, "Shared Memory Loader Program"); if(!EQEmuConfig::LoadConfig()) { - Log.Out(Logs::General, Logs::Error, "Unable to load configuration file."); + Log(Logs::General, Logs::Error, "Unable to load configuration file."); return 1; } auto Config = EQEmuConfig::get(); SharedDatabase database; - Log.Out(Logs::General, Logs::Status, "Connecting to database..."); + Log(Logs::General, Logs::Status, "Connecting to database..."); if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(), Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) { - Log.Out(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a " + Log(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a " "database connection"); return 1; } /* Register Log System and Settings */ - database.LoadLogSettings(Log.log_settings); - Log.StartFileLogs(); + database.LoadLogSettings(LogSys.log_settings); + LogSys.StartFileLogs(); std::string shared_mem_directory = Config->SharedMemDir; if (MakeDirectory(shared_mem_directory)) { - Log.Out(Logs::General, Logs::Status, "Shared Memory folder doesn't exist, so we created it... '%s'", shared_mem_directory.c_str()); + Log(Logs::General, Logs::Status, "Shared Memory folder doesn't exist, so we created it... '%s'", shared_mem_directory.c_str()); } database.LoadVariables(); @@ -106,7 +106,7 @@ int main(int argc, char **argv) { std::string db_hotfix_name; if (database.GetVariable("hotfix_name", db_hotfix_name)) { if (!db_hotfix_name.empty() && strcasecmp("hotfix_", db_hotfix_name.c_str()) == 0) { - Log.Out(Logs::General, Logs::Status, "Current hotfix in variables is the default %s, clearing out variable", db_hotfix_name.c_str()); + Log(Logs::General, Logs::Status, "Current hotfix in variables is the default %s, clearing out variable", db_hotfix_name.c_str()); std::string query = StringFormat("UPDATE `variables` SET `value`='' WHERE (`varname`='hotfix_name')"); database.QueryDatabase(query); } @@ -177,69 +177,69 @@ int main(int argc, char **argv) { } if(hotfix_name.length() > 0) { - Log.Out(Logs::General, Logs::Status, "Writing data for hotfix '%s'", hotfix_name.c_str()); + Log(Logs::General, Logs::Status, "Writing data for hotfix '%s'", hotfix_name.c_str()); } if(load_all || load_items) { - Log.Out(Logs::General, Logs::Status, "Loading items..."); + Log(Logs::General, Logs::Status, "Loading items..."); try { LoadItems(&database, hotfix_name); } catch(std::exception &ex) { - Log.Out(Logs::General, Logs::Error, "%s", ex.what()); + Log(Logs::General, Logs::Error, "%s", ex.what()); return 1; } } if(load_all || load_factions) { - Log.Out(Logs::General, Logs::Status, "Loading factions..."); + Log(Logs::General, Logs::Status, "Loading factions..."); try { LoadFactions(&database, hotfix_name); } catch(std::exception &ex) { - Log.Out(Logs::General, Logs::Error, "%s", ex.what()); + Log(Logs::General, Logs::Error, "%s", ex.what()); return 1; } } if(load_all || load_loot) { - Log.Out(Logs::General, Logs::Status, "Loading loot..."); + Log(Logs::General, Logs::Status, "Loading loot..."); try { LoadLoot(&database, hotfix_name); } catch(std::exception &ex) { - Log.Out(Logs::General, Logs::Error, "%s", ex.what()); + Log(Logs::General, Logs::Error, "%s", ex.what()); return 1; } } if(load_all || load_skill_caps) { - Log.Out(Logs::General, Logs::Status, "Loading skill caps..."); + Log(Logs::General, Logs::Status, "Loading skill caps..."); try { LoadSkillCaps(&database, hotfix_name); } catch(std::exception &ex) { - Log.Out(Logs::General, Logs::Error, "%s", ex.what()); + Log(Logs::General, Logs::Error, "%s", ex.what()); return 1; } } if(load_all || load_spells) { - Log.Out(Logs::General, Logs::Status, "Loading spells..."); + Log(Logs::General, Logs::Status, "Loading spells..."); try { LoadSpells(&database, hotfix_name); } catch(std::exception &ex) { - Log.Out(Logs::General, Logs::Error, "%s", ex.what()); + Log(Logs::General, Logs::Error, "%s", ex.what()); return 1; } } if(load_all || load_bd) { - Log.Out(Logs::General, Logs::Status, "Loading base data..."); + Log(Logs::General, Logs::Status, "Loading base data..."); try { LoadBaseData(&database, hotfix_name); } catch(std::exception &ex) { - Log.Out(Logs::General, Logs::Error, "%s", ex.what()); + Log(Logs::General, Logs::Error, "%s", ex.what()); return 1; } } - Log.CloseFileLogs(); + LogSys.CloseFileLogs(); return 0; } diff --git a/ucs/chatchannel.cpp b/ucs/chatchannel.cpp index 9ab9db216..16403c295 100644 --- a/ucs/chatchannel.cpp +++ b/ucs/chatchannel.cpp @@ -43,7 +43,7 @@ ChatChannel::ChatChannel(std::string inName, std::string inOwner, std::string in Moderated = false; - Log.Out(Logs::Detail, Logs::UCS_Server, "New ChatChannel created: Name: [%s], Owner: [%s], Password: [%s], MinStatus: %i", + Log(Logs::Detail, Logs::UCS_Server, "New ChatChannel created: Name: [%s], Owner: [%s], Password: [%s], MinStatus: %i", Name.c_str(), Owner.c_str(), Password.c_str(), MinimumStatus); } @@ -150,7 +150,7 @@ void ChatChannelList::SendAllChannels(Client *c) { void ChatChannelList::RemoveChannel(ChatChannel *Channel) { - Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveChannel(%s)", Channel->GetName().c_str()); + Log(Logs::Detail, Logs::UCS_Server, "RemoveChannel(%s)", Channel->GetName().c_str()); LinkedListIterator iterator(ChatChannels); @@ -171,7 +171,7 @@ void ChatChannelList::RemoveChannel(ChatChannel *Channel) { void ChatChannelList::RemoveAllChannels() { - Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveAllChannels"); + Log(Logs::Detail, Logs::UCS_Server, "RemoveAllChannels"); LinkedListIterator iterator(ChatChannels); @@ -229,7 +229,7 @@ void ChatChannel::AddClient(Client *c) { if(IsClientInChannel(c)) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Client %s already in channel %s", c->GetName().c_str(), GetName().c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Client %s already in channel %s", c->GetName().c_str(), GetName().c_str()); return; } @@ -238,7 +238,7 @@ void ChatChannel::AddClient(Client *c) { int AccountStatus = c->GetAccountStatus(); - Log.Out(Logs::Detail, Logs::UCS_Server, "Adding %s to channel %s", c->GetName().c_str(), Name.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Adding %s to channel %s", c->GetName().c_str(), Name.c_str()); LinkedListIterator iterator(ClientsInChannel); @@ -263,7 +263,7 @@ bool ChatChannel::RemoveClient(Client *c) { if(!c) return false; - Log.Out(Logs::Detail, Logs::UCS_Server, "RemoveClient %s from channel %s", c->GetName().c_str(), GetName().c_str()); + Log(Logs::Detail, Logs::UCS_Server, "RemoveClient %s from channel %s", c->GetName().c_str(), GetName().c_str()); bool HideMe = c->GetHideMe(); @@ -300,7 +300,7 @@ bool ChatChannel::RemoveClient(Client *c) { if((Password.length() == 0) || (RuleI(Channels, DeleteTimer) == 0)) return false; - Log.Out(Logs::Detail, Logs::UCS_Server, "Starting delete timer for empty password protected channel %s", Name.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Starting delete timer for empty password protected channel %s", Name.c_str()); DeleteTimer.Start(RuleI(Channels, DeleteTimer) * 60000); } @@ -396,7 +396,7 @@ void ChatChannel::SendMessageToChannel(std::string Message, Client* Sender) { if(ChannelClient) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Sending message to %s from %s", + Log(Logs::Detail, Logs::UCS_Server, "Sending message to %s from %s", ChannelClient->GetName().c_str(), Sender->GetName().c_str()); ChannelClient->SendChannelMessage(Name, Message, Sender); } @@ -478,7 +478,7 @@ ChatChannel *ChatChannelList::AddClientToChannel(std::string ChannelName, Client return nullptr; } - Log.Out(Logs::Detail, Logs::UCS_Server, "AddClient to channel [%s] with password [%s]", NormalisedName.c_str(), Password.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "AddClient to channel [%s] with password [%s]", NormalisedName.c_str(), Password.c_str()); ChatChannel *RequiredChannel = FindChannel(NormalisedName); @@ -554,7 +554,7 @@ void ChatChannelList::Process() { if(CurrentChannel && CurrentChannel->ReadyToDelete()) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Empty temporary password protected channel %s being destroyed.", + Log(Logs::Detail, Logs::UCS_Server, "Empty temporary password protected channel %s being destroyed.", CurrentChannel->GetName().c_str()); RemoveChannel(CurrentChannel); @@ -570,7 +570,7 @@ void ChatChannel::AddInvitee(const std::string &Invitee) if (!IsInvitee(Invitee)) { Invitees.push_back(Invitee); - Log.Out(Logs::Detail, Logs::UCS_Server, "Added %s as invitee to channel %s", Invitee.c_str(), Name.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Added %s as invitee to channel %s", Invitee.c_str(), Name.c_str()); } } @@ -581,7 +581,7 @@ void ChatChannel::RemoveInvitee(std::string Invitee) if(it != std::end(Invitees)) { Invitees.erase(it); - Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as invitee to channel %s", Invitee.c_str(), Name.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Removed %s as invitee to channel %s", Invitee.c_str(), Name.c_str()); } } @@ -595,7 +595,7 @@ void ChatChannel::AddModerator(const std::string &Moderator) if (!IsModerator(Moderator)) { Moderators.push_back(Moderator); - Log.Out(Logs::Detail, Logs::UCS_Server, "Added %s as moderator to channel %s", Moderator.c_str(), Name.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Added %s as moderator to channel %s", Moderator.c_str(), Name.c_str()); } } @@ -606,7 +606,7 @@ void ChatChannel::RemoveModerator(const std::string &Moderator) if (it != std::end(Moderators)) { Moderators.erase(it); - Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as moderator to channel %s", Moderator.c_str(), Name.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Removed %s as moderator to channel %s", Moderator.c_str(), Name.c_str()); } } @@ -620,7 +620,7 @@ void ChatChannel::AddVoice(const std::string &inVoiced) if (!HasVoice(inVoiced)) { Voiced.push_back(inVoiced); - Log.Out(Logs::Detail, Logs::UCS_Server, "Added %s as voiced to channel %s", inVoiced.c_str(), Name.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Added %s as voiced to channel %s", inVoiced.c_str(), Name.c_str()); } } @@ -631,7 +631,7 @@ void ChatChannel::RemoveVoice(const std::string &inVoiced) if (it != std::end(Voiced)) { Voiced.erase(it); - Log.Out(Logs::Detail, Logs::UCS_Server, "Removed %s as voiced to channel %s", inVoiced.c_str(), Name.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Removed %s as voiced to channel %s", inVoiced.c_str(), Name.c_str()); } } diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index 21893740f..998410ec1 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2008 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -42,11 +42,11 @@ extern uint32 MailMessagesSent; int LookupCommand(const char *ChatCommand) { - if(!ChatCommand) return -1; + if (!ChatCommand) return -1; - for(int i = 0; i < CommandEndOfList; i++) { + for (int i = 0; i < CommandEndOfList; i++) { - if(!strcasecmp(Commands[i].CommandString, ChatCommand)) + if (!strcasecmp(Commands[i].CommandString, ChatCommand)) return Commands[i].CommandCode; } @@ -116,11 +116,11 @@ std::vector ParseRecipients(std::string RecipientString) { CurrentPos = 0; - while(CurrentPos != std::string::npos) { + while (CurrentPos != std::string::npos) { Comma = RecipientString.find_first_of(",", CurrentPos); - if(Comma == std::string::npos) { + if (Comma == std::string::npos) { RecipientList.push_back(RecipientString.substr(CurrentPos)); @@ -135,13 +135,13 @@ std::vector ParseRecipients(std::string RecipientString) { Iterator = RecipientList.begin(); - while(Iterator != RecipientList.end()) { + while (Iterator != RecipientList.end()) { - if((*Iterator)[0] == '-') { + if ((*Iterator)[0] == '-') { Secret = "-"; - while((*Iterator)[0] == '-') + while ((*Iterator)[0] == '-') (*Iterator) = (*Iterator).substr(1); } else @@ -149,15 +149,15 @@ std::vector ParseRecipients(std::string RecipientString) { FirstLT = (*Iterator).find_first_of("<"); - if(FirstLT != std::string::npos) { + if (FirstLT != std::string::npos) { LastGT = (*Iterator).find_last_of(">"); - if(LastGT != std::string::npos) { + if (LastGT != std::string::npos) { (*Iterator) = (*Iterator).substr(FirstLT + 1, LastGT - FirstLT - 1); - if((*Iterator).find_first_of(" ") != std::string::npos) { + if ((*Iterator).find_first_of(" ") != std::string::npos) { std::string Recips = (*Iterator); @@ -165,18 +165,18 @@ std::vector ParseRecipients(std::string RecipientString) { CurrentPos = 0; - while(CurrentPos != std::string::npos) { + while (CurrentPos != std::string::npos) { Space = Recips.find_first_of(" ", CurrentPos); - if(Space == std::string::npos) { + if (Space == std::string::npos) { RecipientList.push_back(Secret + Recips.substr(CurrentPos)); break; } RecipientList.push_back(Secret + Recips.substr(CurrentPos, - Space - CurrentPos)); + Space - CurrentPos)); CurrentPos = Space + 1; } Iterator = RecipientList.begin(); @@ -193,24 +193,24 @@ std::vector ParseRecipients(std::string RecipientString) { } - for(Iterator = RecipientList.begin(); Iterator != RecipientList.end(); ++Iterator) { + for (Iterator = RecipientList.begin(); Iterator != RecipientList.end(); ++Iterator) { - if((*Iterator).length() > 0) { + if ((*Iterator).length() > 0) { - if((*Iterator)[0] == '-') + if ((*Iterator)[0] == '-') Secret = "-"; else Secret = ""; LastPeriod = (*Iterator).find_last_of("."); - if(LastPeriod != std::string::npos) { + if (LastPeriod != std::string::npos) { (*Iterator) = (*Iterator).substr(LastPeriod + 1); - for(unsigned int i = 0; i < (*Iterator).length(); i++) { + for (unsigned int i = 0; i < (*Iterator).length(); i++) { - if(i == 0) + if (i == 0) (*Iterator)[i] = toupper((*Iterator)[i]); else (*Iterator)[i] = tolower((*Iterator)[i]); @@ -234,7 +234,7 @@ std::vector ParseRecipients(std::string RecipientString) { static void ProcessMailTo(Client *c, std::string MailMessage) { - Log.Out(Logs::Detail, Logs::UCS_Server, "MAILTO: From %s, %s", c->MailBoxName().c_str(), MailMessage.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "MAILTO: From %s, %s", c->MailBoxName().c_str(), MailMessage.c_str()); std::vector Recipients; @@ -242,7 +242,7 @@ static void ProcessMailTo(Client *c, std::string MailMessage) { std::string::size_type NextQuote = MailMessage.find_first_of("\"", FirstQuote + 1); - std::string RecipientsString = MailMessage.substr(FirstQuote+1, NextQuote-FirstQuote - 1); + std::string RecipientsString = MailMessage.substr(FirstQuote + 1, NextQuote - FirstQuote - 1); Recipients = ParseRecipients(RecipientsString); @@ -254,7 +254,7 @@ static void ProcessMailTo(Client *c, std::string MailMessage) { std::string::size_type SubjectEnd; - if(MailMessage.substr(SubjectStart, 1) == "\"") { + if (MailMessage.substr(SubjectStart, 1) == "\"") { SubjectEnd = MailMessage.find_first_of("\"", SubjectStart + 1); @@ -287,7 +287,7 @@ static void ProcessMailTo(Client *c, std::string MailMessage) { } else { - if(VisibleRecipients > 0) + if (VisibleRecipients > 0) RecipientsString += ", "; @@ -296,15 +296,15 @@ static void ProcessMailTo(Client *c, std::string MailMessage) { RecipientsString = RecipientsString + GetMailPrefix() + Recipient; } } - if(VisibleRecipients == 0) + if (VisibleRecipients == 0) RecipientsString = ""; for (auto &Recipient : Recipients) { if (!database.SendMail(Recipient, c->MailBoxName(), Subject, Body, RecipientsString)) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Failed in SendMail(%s, %s, %s, %s)", Recipient.c_str(), - c->MailBoxName().c_str(), Subject.c_str(), RecipientsString.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Failed in SendMail(%s, %s, %s, %s)", Recipient.c_str(), + c->MailBoxName().c_str(), Subject.c_str(), RecipientsString.c_str()); int PacketLength = 10 + Recipient.length() + Subject.length(); @@ -330,7 +330,7 @@ static void ProcessMailTo(Client *c, std::string MailMessage) { } } - if(Success) { + if (Success) { // Success auto outapp = new EQApplicationPacket(OP_MailDeliveryStatus, 10); @@ -357,27 +357,27 @@ static void ProcessSetMessageStatus(std::string SetMessageCommand) { int Status; - switch(SetMessageCommand[0]) { + switch (SetMessageCommand[0]) { - case 'R': // READ - Status = 3; - break; + case 'R': // READ + Status = 3; + break; - case 'T': // TRASH - Status = 4; - break; + case 'T': // TRASH + Status = 4; + break; - default: // DELETE - Status = 0; + default: // DELETE + Status = 0; } std::string::size_type NumStart = SetMessageCommand.find_first_of("123456789"); - while(NumStart != std::string::npos) { + while (NumStart != std::string::npos) { std::string::size_type NumEnd = SetMessageCommand.find_first_of(" ", NumStart); - if(NumEnd == std::string::npos) { + if (NumEnd == std::string::npos) { MessageNumber = atoi(SetMessageCommand.substr(NumStart).c_str()); @@ -386,7 +386,7 @@ static void ProcessSetMessageStatus(std::string SetMessageCommand) { break; } - MessageNumber = atoi(SetMessageCommand.substr(NumStart, NumEnd-NumStart).c_str()); + MessageNumber = atoi(SetMessageCommand.substr(NumStart, NumEnd - NumStart).c_str()); database.SetMessageStatus(MessageNumber, Status); @@ -396,19 +396,19 @@ static void ProcessSetMessageStatus(std::string SetMessageCommand) { static void ProcessCommandBuddy(Client *c, std::string Buddy) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Received buddy command with parameters %s", Buddy.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Received buddy command with parameters %s", Buddy.c_str()); c->GeneralChannelMessage("Buddy list modified"); uint8 SubAction = 1; - if(Buddy.substr(0, 1) == "-") + if (Buddy.substr(0, 1) == "-") SubAction = 0; auto outapp = new EQApplicationPacket(OP_Buddy, Buddy.length() + 2); char *PacketBuffer = (char *)outapp->pBuffer; VARSTRUCT_ENCODE_TYPE(uint8, PacketBuffer, SubAction); - if(SubAction == 1) { + if (SubAction == 1) { VARSTRUCT_ENCODE_STRING(PacketBuffer, Buddy.c_str()); database.AddFriendOrIgnore(c->GetCharID(), 1, Buddy); } @@ -425,12 +425,12 @@ static void ProcessCommandBuddy(Client *c, std::string Buddy) { static void ProcessCommandIgnore(Client *c, std::string Ignoree) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Received ignore command with parameters %s", Ignoree.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Received ignore command with parameters %s", Ignoree.c_str()); c->GeneralChannelMessage("Ignore list modified"); uint8 SubAction = 0; - if(Ignoree.substr(0, 1) == "-") { + if (Ignoree.substr(0, 1) == "-") { SubAction = 1; Ignoree = Ignoree.substr(1); @@ -440,7 +440,7 @@ static void ProcessCommandIgnore(Client *c, std::string Ignoree) { std::string::size_type LastPeriod = Ignoree.find_last_of("."); - if(LastPeriod == std::string::npos) + if (LastPeriod == std::string::npos) CharacterName = Ignoree; else CharacterName = Ignoree.substr(LastPeriod + 1); @@ -473,11 +473,11 @@ Clientlist::Clientlist(int ChatPort) { ChatOpMgr = new RegularOpcodeManager; - if(!ChatOpMgr->LoadOpcodes("mail_opcodes.conf")) + if (!ChatOpMgr->LoadOpcodes("mail_opcodes.conf")) exit(1); chatsf->OnNewConnection([this](std::shared_ptr stream) { - Log.OutF(Logs::General, Logs::Login_Server, "New Client UDP connection from {0}:{1}", stream->RemoteEndpoint(), stream->GetRemotePort()); + LogF(Logs::General, Logs::Login_Server, "New Client UDP connection from {0}:{1}", stream->RemoteEndpoint(), stream->GetRemotePort()); stream->SetOpcodeManager(&ChatOpMgr); auto c = new Client(stream); @@ -523,13 +523,13 @@ Client::~Client() { LeaveAllChannels(false); - if(AccountGrabUpdateTimer) + if (AccountGrabUpdateTimer) { delete AccountGrabUpdateTimer; AccountGrabUpdateTimer = nullptr; } - if(GlobalChatLimiterTimer) + if (GlobalChatLimiterTimer) { delete GlobalChatLimiterTimer; GlobalChatLimiterTimer = nullptr; @@ -547,23 +547,23 @@ void Client::CloseConnection() { void Clientlist::CheckForStaleConnections(Client *c) { - if(!c) return; + if (!c) return; std::list::iterator Iterator; - for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); ++Iterator) { + for (Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); ++Iterator) { - if(((*Iterator) != c) && ((c->GetName() == (*Iterator)->GetName()) - && (c->GetConnectionType() == (*Iterator)->GetConnectionType()))) { + if (((*Iterator) != c) && ((c->GetName() == (*Iterator)->GetName()) + && (c->GetConnectionType() == (*Iterator)->GetConnectionType()))) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Removing old connection for %s", c->GetName().c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Removing old connection for %s", c->GetName().c_str()); struct in_addr in; in.s_addr = (*Iterator)->ClientStream->GetRemoteIP(); - Log.Out(Logs::Detail, Logs::UCS_Server, "Client connection from %s:%d closed.", inet_ntoa(in), - ntohs((*Iterator)->ClientStream->GetRemotePort())); + Log(Logs::Detail, Logs::UCS_Server, "Client connection from %s:%d closed.", inet_ntoa(in), + ntohs((*Iterator)->ClientStream->GetRemotePort())); safe_delete((*Iterator)); @@ -581,7 +581,7 @@ void Clientlist::Process() struct in_addr in; in.s_addr = (*it)->ClientStream->GetRemoteIP(); - Log.Out(Logs::Detail, Logs::UCS_Server, "Client connection from %s:%d closed.", inet_ntoa(in), + Log(Logs::Detail, Logs::UCS_Server, "Client connection from %s:%d closed.", inet_ntoa(in), ntohs((*it)->ClientStream->GetRemotePort())); safe_delete((*it)); @@ -607,7 +607,7 @@ void Clientlist::Process() VARSTRUCT_DECODE_STRING(MailBox, PacketBuffer); if (strlen(PacketBuffer) != 9) { - Log.Out(Logs::Detail, Logs::UCS_Server, + Log(Logs::Detail, Logs::UCS_Server, "Mail key is the wrong size. Version of world incompatible with UCS."); KeyValid = false; break; @@ -629,11 +629,11 @@ void Clientlist::Process() else CharacterName = MailBoxString.substr(LastPeriod + 1); - Log.Out(Logs::Detail, Logs::UCS_Server, "Received login for user %s with key %s", + Log(Logs::Detail, Logs::UCS_Server, "Received login for user %s with key %s", MailBox, Key); if (!database.VerifyMailKey(CharacterName, (*it)->ClientStream->GetRemoteIP(), Key)) { - Log.Out(Logs::Detail, Logs::UCS_Server, + Log(Logs::Detail, Logs::UCS_Server, "Chat Key for %s does not match, closing connection.", MailBox); KeyValid = false; break; @@ -659,7 +659,7 @@ void Clientlist::Process() } default: { - Log.Out(Logs::Detail, Logs::UCS_Server, "Unhandled chat opcode %8X", opcode); + Log(Logs::Detail, Logs::UCS_Server, "Unhandled chat opcode %8X", opcode); break; } } @@ -669,7 +669,7 @@ void Clientlist::Process() struct in_addr in; in.s_addr = (*it)->ClientStream->GetRemoteIP(); - Log.Out(Logs::Detail, Logs::UCS_Server, + Log(Logs::Detail, Logs::UCS_Server, "Force disconnecting client: %s:%d, KeyValid=%i, GetForceDisconnect()=%i", inet_ntoa(in), ntohs((*it)->ClientStream->GetRemotePort()), KeyValid, (*it)->GetForceDisconnect()); @@ -688,10 +688,10 @@ void Clientlist::Process() void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString) { - if(CommandString.length() == 0) + if (CommandString.length() == 0) return; - if(isdigit(CommandString[0])) + if (isdigit(CommandString[0])) { c->SendChannelMessageByNumber(CommandString); @@ -699,7 +699,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString) return; } - if(CommandString[0] == '#') { + if (CommandString[0] == '#') { c->SendChannelMessage(CommandString); @@ -710,13 +710,13 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString) std::string::size_type Space = CommandString.find_first_of(" "); - if(Space != std::string::npos) { + if (Space != std::string::npos) { Command = CommandString.substr(0, Space); std::string::size_type ParametersStart = CommandString.find_first_not_of(" ", Space); - if(ParametersStart != std::string::npos) + if (ParametersStart != std::string::npos) Parameters = CommandString.substr(ParametersStart); } else @@ -724,119 +724,119 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string CommandString) int CommandCode = LookupCommand(Command.c_str()); - switch(CommandCode) { + switch (CommandCode) { - case CommandJoin: - c->JoinChannels(Parameters); - break; + case CommandJoin: + c->JoinChannels(Parameters); + break; - case CommandLeaveAll: - c->LeaveAllChannels(); - break; + case CommandLeaveAll: + c->LeaveAllChannels(); + break; - case CommandLeave: - c->LeaveChannels(Parameters); - break; + case CommandLeave: + c->LeaveChannels(Parameters); + break; - case CommandListAll: - ChannelList->SendAllChannels(c); - break; + case CommandListAll: + ChannelList->SendAllChannels(c); + break; - case CommandList: - c->ProcessChannelList(Parameters); - break; + case CommandList: + c->ProcessChannelList(Parameters); + break; - case CommandSet: - c->LeaveAllChannels(false); - c->JoinChannels(Parameters); - break; + case CommandSet: + c->LeaveAllChannels(false); + c->JoinChannels(Parameters); + break; - case CommandAnnounce: - c->ToggleAnnounce(Parameters); - break; + case CommandAnnounce: + c->ToggleAnnounce(Parameters); + break; - case CommandSetOwner: - c->SetChannelOwner(Parameters); - break; + case CommandSetOwner: + c->SetChannelOwner(Parameters); + break; - case CommandOPList: - c->OPList(Parameters); - break; + case CommandOPList: + c->OPList(Parameters); + break; - case CommandInvite: - c->ChannelInvite(Parameters); - break; + case CommandInvite: + c->ChannelInvite(Parameters); + break; - case CommandGrant: - c->ChannelGrantModerator(Parameters); - break; + case CommandGrant: + c->ChannelGrantModerator(Parameters); + break; - case CommandModerate: - c->ChannelModerate(Parameters); - break; + case CommandModerate: + c->ChannelModerate(Parameters); + break; - case CommandVoice: - c->ChannelGrantVoice(Parameters); - break; + case CommandVoice: + c->ChannelGrantVoice(Parameters); + break; - case CommandKick: - c->ChannelKick(Parameters); - break; + case CommandKick: + c->ChannelKick(Parameters); + break; - case CommandPassword: - c->SetChannelPassword(Parameters); - break; + case CommandPassword: + c->SetChannelPassword(Parameters); + break; - case CommandToggleInvites: - c->ToggleInvites(); - break; + case CommandToggleInvites: + c->ToggleInvites(); + break; - case CommandAFK: - break; + case CommandAFK: + break; - case CommandUptime: - c->SendUptime(); - break; + case CommandUptime: + c->SendUptime(); + break; - case CommandGetHeaders: - database.SendHeaders(c); - break; + case CommandGetHeaders: + database.SendHeaders(c); + break; - case CommandGetBody: - database.SendBody(c, atoi(Parameters.c_str())); - break; + case CommandGetBody: + database.SendBody(c, atoi(Parameters.c_str())); + break; - case CommandMailTo: - ProcessMailTo(c, Parameters); - break; + case CommandMailTo: + ProcessMailTo(c, Parameters); + break; - case CommandSetMessageStatus: - Log.Out(Logs::Detail, Logs::UCS_Server, "Set Message Status, Params: %s", Parameters.c_str()); - ProcessSetMessageStatus(Parameters); - break; + case CommandSetMessageStatus: + Log(Logs::Detail, Logs::UCS_Server, "Set Message Status, Params: %s", Parameters.c_str()); + ProcessSetMessageStatus(Parameters); + break; - case CommandSelectMailBox: - { - std::string::size_type NumStart = Parameters.find_first_of("0123456789"); - c->ChangeMailBox(atoi(Parameters.substr(NumStart).c_str())); - break; - } - case CommandSetMailForwarding: - break; + case CommandSelectMailBox: + { + std::string::size_type NumStart = Parameters.find_first_of("0123456789"); + c->ChangeMailBox(atoi(Parameters.substr(NumStart).c_str())); + break; + } + case CommandSetMailForwarding: + break; - case CommandBuddy: - RemoveApostrophes(Parameters); - ProcessCommandBuddy(c, Parameters); - break; + case CommandBuddy: + RemoveApostrophes(Parameters); + ProcessCommandBuddy(c, Parameters); + break; - case CommandIgnorePlayer: - RemoveApostrophes(Parameters); - ProcessCommandIgnore(c, Parameters); - break; + case CommandIgnorePlayer: + RemoveApostrophes(Parameters); + ProcessCommandIgnore(c, Parameters); + break; - default: - c->SendHelp(); - Log.Out(Logs::Detail, Logs::UCS_Server, "Unhandled OP_Mail command: %s", CommandString.c_str()); + default: + c->SendHelp(); + Log(Logs::Detail, Logs::UCS_Server, "Unhandled OP_Mail command: %s", CommandString.c_str()); } } @@ -845,9 +845,9 @@ void Clientlist::CloseAllConnections() { std::list::iterator Iterator; - for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); ++Iterator) { + for (Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); ++Iterator) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Removing client %s", (*Iterator)->GetName().c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Removing client %s", (*Iterator)->GetName().c_str()); (*Iterator)->CloseConnection(); } @@ -855,8 +855,8 @@ void Clientlist::CloseAllConnections() { void Client::AddCharacter(int CharID, const char *CharacterName, int Level) { - if(!CharacterName) return; - Log.Out(Logs::Detail, Logs::UCS_Server, "Adding character %s with ID %i for %s", CharacterName, CharID, GetName().c_str()); + if (!CharacterName) return; + Log(Logs::Detail, Logs::UCS_Server, "Adding character %s with ID %i for %s", CharacterName, CharID, GetName().c_str()); CharacterEntry NewCharacter; NewCharacter.CharID = CharID; NewCharacter.Name = CharacterName; @@ -873,11 +873,11 @@ void Client::SendMailBoxes() { std::string s; - for(int i = 0; i < Count; i++) { + for (int i = 0; i < Count; i++) { s += GetMailPrefix() + Characters[i].Name; - if(i != (Count - 1)) + if (i != (Count - 1)) s = s + ","; } @@ -904,9 +904,9 @@ Client *Clientlist::FindCharacter(std::string CharacterName) { std::list::iterator Iterator; - for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); ++Iterator) { + for (Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); ++Iterator) { - if((*Iterator)->GetName() == CharacterName) + if ((*Iterator)->GetName() == CharacterName) return ((*Iterator)); } @@ -916,24 +916,24 @@ Client *Clientlist::FindCharacter(std::string CharacterName) { void Client::AddToChannelList(ChatChannel *JoinedChannel) { - if(!JoinedChannel) return; + if (!JoinedChannel) return; - for(int i = 0; i < MAX_JOINED_CHANNELS; i++) - if(JoinedChannels[i] == nullptr) { + for (int i = 0; i < MAX_JOINED_CHANNELS; i++) + if (JoinedChannels[i] == nullptr) { JoinedChannels[i] = JoinedChannel; - Log.Out(Logs::Detail, Logs::UCS_Server, "Added Channel %s to slot %i for %s", JoinedChannel->GetName().c_str(), i + 1, GetName().c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Added Channel %s to slot %i for %s", JoinedChannel->GetName().c_str(), i + 1, GetName().c_str()); return; } } void Client::RemoveFromChannelList(ChatChannel *JoinedChannel) { - for(int i = 0; i < MAX_JOINED_CHANNELS; i++) - if(JoinedChannels[i] == JoinedChannel) { + for (int i = 0; i < MAX_JOINED_CHANNELS; i++) + if (JoinedChannels[i] == JoinedChannel) { // Shuffle all the channels down. Client likes them all nice and consecutive. // - for(int j = i; j < (MAX_JOINED_CHANNELS - 1); j++) + for (int j = i; j < (MAX_JOINED_CHANNELS - 1); j++) JoinedChannels[j] = JoinedChannels[j + 1]; JoinedChannels[MAX_JOINED_CHANNELS - 1] = nullptr; @@ -962,15 +962,15 @@ void Client::JoinChannels(std::string ChannelNameList) { } } - Log.Out(Logs::Detail, Logs::UCS_Server, "Client: %s joining channels %s", GetName().c_str(), ChannelNameList.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Client: %s joining channels %s", GetName().c_str(), ChannelNameList.c_str()); int NumberOfChannels = ChannelCount(); std::string::size_type CurrentPos = ChannelNameList.find_first_not_of(" "); - while(CurrentPos != std::string::npos) { + while (CurrentPos != std::string::npos) { - if(NumberOfChannels == MAX_JOINED_CHANNELS) { + if (NumberOfChannels == MAX_JOINED_CHANNELS) { GeneralChannelMessage("You have joined the maximum number of channels. /leave one before trying to join another."); @@ -979,19 +979,19 @@ void Client::JoinChannels(std::string ChannelNameList) { std::string::size_type Comma = ChannelNameList.find_first_of(", ", CurrentPos); - if(Comma == std::string::npos) { + if (Comma == std::string::npos) { ChatChannel* JoinedChannel = ChannelList->AddClientToChannel(ChannelNameList.substr(CurrentPos), this); - if(JoinedChannel) + if (JoinedChannel) AddToChannelList(JoinedChannel); break; } - ChatChannel* JoinedChannel = ChannelList->AddClientToChannel(ChannelNameList.substr(CurrentPos, Comma-CurrentPos), this); + ChatChannel* JoinedChannel = ChannelList->AddClientToChannel(ChannelNameList.substr(CurrentPos, Comma - CurrentPos), this); - if(JoinedChannel) { + if (JoinedChannel) { AddToChannelList(JoinedChannel); @@ -1009,11 +1009,11 @@ void Client::JoinChannels(std::string ChannelNameList) { int ChannelCount = 0; - for(int i = 0; i < MAX_JOINED_CHANNELS ; i++) { + for (int i = 0; i < MAX_JOINED_CHANNELS; i++) { - if(JoinedChannels[i] != nullptr) { + if (JoinedChannels[i] != nullptr) { - if(ChannelCount) { + if (ChannelCount) { JoinedChannelsList = JoinedChannelsList + ","; @@ -1042,7 +1042,7 @@ void Client::JoinChannels(std::string ChannelNameList) { safe_delete(outapp); - if(ChannelCount == 0) + if (ChannelCount == 0) ChannelMessage = "You are not on any channels."; outapp = new EQApplicationPacket(OP_ChannelMessage, ChannelMessage.length() + 3); @@ -1061,27 +1061,27 @@ void Client::JoinChannels(std::string ChannelNameList) { void Client::LeaveChannels(std::string ChannelNameList) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Client: %s leaving channels %s", GetName().c_str(), ChannelNameList.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Client: %s leaving channels %s", GetName().c_str(), ChannelNameList.c_str()); std::string::size_type CurrentPos = 0; - while(CurrentPos != std::string::npos) { + while (CurrentPos != std::string::npos) { std::string::size_type Comma = ChannelNameList.find_first_of(", ", CurrentPos); - if(Comma == std::string::npos) { + if (Comma == std::string::npos) { ChatChannel* JoinedChannel = ChannelList->RemoveClientFromChannel(ChannelNameList.substr(CurrentPos), this); - if(JoinedChannel) + if (JoinedChannel) RemoveFromChannelList(JoinedChannel); break; } - ChatChannel* JoinedChannel = ChannelList->RemoveClientFromChannel(ChannelNameList.substr(CurrentPos, Comma-CurrentPos), this); + ChatChannel* JoinedChannel = ChannelList->RemoveClientFromChannel(ChannelNameList.substr(CurrentPos, Comma - CurrentPos), this); - if(JoinedChannel) + if (JoinedChannel) RemoveFromChannelList(JoinedChannel); CurrentPos = ChannelNameList.find_first_not_of(", ", Comma); @@ -1095,11 +1095,11 @@ void Client::LeaveChannels(std::string ChannelNameList) { int ChannelCount = 0; - for(int i = 0; i < MAX_JOINED_CHANNELS ; i++) { + for (int i = 0; i < MAX_JOINED_CHANNELS; i++) { - if(JoinedChannels[i] != nullptr) { + if (JoinedChannels[i] != nullptr) { - if(ChannelCount) { + if (ChannelCount) { JoinedChannelsList = JoinedChannelsList + ","; @@ -1127,7 +1127,7 @@ void Client::LeaveChannels(std::string ChannelNameList) { safe_delete(outapp); - if(ChannelCount == 0) + if (ChannelCount == 0) ChannelMessage = "You are not on any channels."; outapp = new EQApplicationPacket(OP_ChannelMessage, ChannelMessage.length() + 3); @@ -1156,14 +1156,14 @@ void Client::LeaveAllChannels(bool SendUpdatedChannelList) { } } - if(SendUpdatedChannelList) + if (SendUpdatedChannelList) SendChannelList(); } void Client::ProcessChannelList(std::string Input) { - if(Input.length() == 0) { + if (Input.length() == 0) { SendChannelList(); @@ -1172,12 +1172,12 @@ void Client::ProcessChannelList(std::string Input) { std::string ChannelName = Input; - if(isdigit(ChannelName[0])) + if (isdigit(ChannelName[0])) ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); - if(RequiredChannel) + if (RequiredChannel) RequiredChannel->SendChannelMembers(this); else GeneralChannelMessage("Channel " + Input + " not found."); @@ -1195,11 +1195,11 @@ void Client::SendChannelList() { int ChannelCount = 0; - for(int i = 0; i < MAX_JOINED_CHANNELS ; i++) { + for (int i = 0; i < MAX_JOINED_CHANNELS; i++) { - if(JoinedChannels[i] != nullptr) { + if (JoinedChannels[i] != nullptr) { - if(ChannelCount) + if (ChannelCount) ChannelMessage = ChannelMessage + ","; sprintf(tmp, "%i=%s(%i)", i + 1, JoinedChannels[i]->GetName().c_str(), JoinedChannels[i]->MemberCount(Status)); @@ -1210,7 +1210,7 @@ void Client::SendChannelList() { } } - if(ChannelCount == 0) + if (ChannelCount == 0) ChannelMessage = "You are not on any channels."; auto outapp = new EQApplicationPacket(OP_ChannelMessage, ChannelMessage.length() + 3); @@ -1232,24 +1232,24 @@ void Client::SendChannelMessage(std::string Message) std::string::size_type MessageStart = Message.find_first_of(" "); - if(MessageStart == std::string::npos) + if (MessageStart == std::string::npos) return; - std::string ChannelName = Message.substr(1, MessageStart-1); + std::string ChannelName = Message.substr(1, MessageStart - 1); - Log.Out(Logs::Detail, Logs::UCS_Server, "%s tells %s, [%s]", GetName().c_str(), ChannelName.c_str(), Message.substr(MessageStart + 1).c_str()); + Log(Logs::Detail, Logs::UCS_Server, "%s tells %s, [%s]", GetName().c_str(), ChannelName.c_str(), Message.substr(MessageStart + 1).c_str()); ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); - if(IsRevoked()) + if (IsRevoked()) { GeneralChannelMessage("You are Revoked, you cannot chat in global channels."); return; } - if(ChannelName.compare("Newplayers") != 0) + if (ChannelName.compare("Newplayers") != 0) { - if(GetKarma() < RuleI(Chat, KarmaGlobalChatLimit)) + if (GetKarma() < RuleI(Chat, KarmaGlobalChatLimit)) { CharacterEntry *char_ent = nullptr; for (auto &elem : Characters) { @@ -1258,9 +1258,9 @@ void Client::SendChannelMessage(std::string Message) break; } } - if(char_ent) + if (char_ent) { - if(char_ent->Level < RuleI(Chat, GlobalChatLevelLimit)) + if (char_ent->Level < RuleI(Chat, GlobalChatLevelLimit)) { GeneralChannelMessage("You are either not high enough level or high enough karma to talk in this channel right now."); return; @@ -1269,15 +1269,15 @@ void Client::SendChannelMessage(std::string Message) } } - if(RequiredChannel) { - if(RuleB(Chat, EnableAntiSpam)) + if (RequiredChannel) { + if (RuleB(Chat, EnableAntiSpam)) { - if(!RequiredChannel->IsModerated() || RequiredChannel->HasVoice(GetName()) || RequiredChannel->IsOwner(GetName()) || + if (!RequiredChannel->IsModerated() || RequiredChannel->HasVoice(GetName()) || RequiredChannel->IsOwner(GetName()) || RequiredChannel->IsModerator(GetName()) || IsChannelAdmin()) { - if(GlobalChatLimiterTimer) + if (GlobalChatLimiterTimer) { - if(GlobalChatLimiterTimer->Check(false)) + if (GlobalChatLimiterTimer->Check(false)) { GlobalChatLimiterTimer->Start(RuleI(Chat, IntervalDurationMS)); AttemptedMessages = 0; @@ -1286,17 +1286,17 @@ void Client::SendChannelMessage(std::string Message) int AllowedMessages = RuleI(Chat, MinimumMessagesPerInterval) + GetKarma(); AllowedMessages = AllowedMessages > RuleI(Chat, MaximumMessagesPerInterval) ? RuleI(Chat, MaximumMessagesPerInterval) : AllowedMessages; - if(RuleI(Chat, MinStatusToBypassAntiSpam) <= Status) + if (RuleI(Chat, MinStatusToBypassAntiSpam) <= Status) AllowedMessages = 10000; AttemptedMessages++; - if(AttemptedMessages > AllowedMessages) + if (AttemptedMessages > AllowedMessages) { - if(AttemptedMessages > RuleI(Chat, MaxMessagesBeforeKick)) + if (AttemptedMessages > RuleI(Chat, MaxMessagesBeforeKick)) { ForceDisconnect = true; } - if(GlobalChatLimiterTimer) + if (GlobalChatLimiterTimer) { char TimeLeft[256]; sprintf(TimeLeft, "You are currently rate limited, you cannot send more messages for %i seconds.", @@ -1310,7 +1310,7 @@ void Client::SendChannelMessage(std::string Message) } else { - RequiredChannel->SendMessageToChannel(Message.substr(MessageStart+1), this); + RequiredChannel->SendMessageToChannel(Message.substr(MessageStart + 1), this); } } else @@ -1318,9 +1318,9 @@ void Client::SendChannelMessage(std::string Message) } else { - if(!RequiredChannel->IsModerated() || RequiredChannel->HasVoice(GetName()) || RequiredChannel->IsOwner(GetName()) || + if (!RequiredChannel->IsModerated() || RequiredChannel->HasVoice(GetName()) || RequiredChannel->IsOwner(GetName()) || RequiredChannel->IsModerator(GetName()) || IsChannelAdmin()) - RequiredChannel->SendMessageToChannel(Message.substr(MessageStart+1), this); + RequiredChannel->SendMessageToChannel(Message.substr(MessageStart + 1), this); else GeneralChannelMessage("Channel " + ChannelName + " is moderated and you have not been granted a voice."); } @@ -1331,36 +1331,36 @@ void Client::SendChannelMessageByNumber(std::string Message) { std::string::size_type MessageStart = Message.find_first_of(" "); - if(MessageStart == std::string::npos) + if (MessageStart == std::string::npos) return; int ChannelNumber = atoi(Message.substr(0, MessageStart).c_str()); - if((ChannelNumber < 1) || (ChannelNumber > MAX_JOINED_CHANNELS)) { + if ((ChannelNumber < 1) || (ChannelNumber > MAX_JOINED_CHANNELS)) { GeneralChannelMessage("Invalid channel name/number specified."); return; } - ChatChannel *RequiredChannel = JoinedChannels[ChannelNumber-1]; + ChatChannel *RequiredChannel = JoinedChannels[ChannelNumber - 1]; - if(!RequiredChannel) { + if (!RequiredChannel) { GeneralChannelMessage("Invalid channel name/number specified."); return; } - if(IsRevoked()) + if (IsRevoked()) { GeneralChannelMessage("You are Revoked, you cannot chat in global channels."); return; } - if(RequiredChannel->GetName().compare("Newplayers") != 0) + if (RequiredChannel->GetName().compare("Newplayers") != 0) { - if(GetKarma() < RuleI(Chat, KarmaGlobalChatLimit)) + if (GetKarma() < RuleI(Chat, KarmaGlobalChatLimit)) { CharacterEntry *char_ent = nullptr; for (auto &elem : Characters) { @@ -1369,9 +1369,9 @@ void Client::SendChannelMessageByNumber(std::string Message) { break; } } - if(char_ent) + if (char_ent) { - if(char_ent->Level < RuleI(Chat, GlobalChatLevelLimit)) + if (char_ent->Level < RuleI(Chat, GlobalChatLevelLimit)) { GeneralChannelMessage("You are either not high enough level or high enough karma to talk in this channel right now."); return; @@ -1380,59 +1380,59 @@ void Client::SendChannelMessageByNumber(std::string Message) { } } - Log.Out(Logs::Detail, Logs::UCS_Server, "%s tells %s, [%s]", GetName().c_str(), RequiredChannel->GetName().c_str(), - Message.substr(MessageStart + 1).c_str()); + Log(Logs::Detail, Logs::UCS_Server, "%s tells %s, [%s]", GetName().c_str(), RequiredChannel->GetName().c_str(), + Message.substr(MessageStart + 1).c_str()); - if(RuleB(Chat, EnableAntiSpam)) + if (RuleB(Chat, EnableAntiSpam)) { - if(!RequiredChannel->IsModerated() || RequiredChannel->HasVoice(GetName()) || RequiredChannel->IsOwner(GetName()) || + if (!RequiredChannel->IsModerated() || RequiredChannel->HasVoice(GetName()) || RequiredChannel->IsOwner(GetName()) || RequiredChannel->IsModerator(GetName())) { - if(GlobalChatLimiterTimer) + if (GlobalChatLimiterTimer) + { + if (GlobalChatLimiterTimer->Check(false)) { - if(GlobalChatLimiterTimer->Check(false)) - { - GlobalChatLimiterTimer->Start(RuleI(Chat, IntervalDurationMS)); - AttemptedMessages = 0; - } + GlobalChatLimiterTimer->Start(RuleI(Chat, IntervalDurationMS)); + AttemptedMessages = 0; } - int AllowedMessages = RuleI(Chat, MinimumMessagesPerInterval) + GetKarma(); - AllowedMessages = AllowedMessages > RuleI(Chat, MaximumMessagesPerInterval) ? RuleI(Chat, MaximumMessagesPerInterval) : AllowedMessages; - if(RuleI(Chat, MinStatusToBypassAntiSpam) <= Status) - AllowedMessages = 10000; + } + int AllowedMessages = RuleI(Chat, MinimumMessagesPerInterval) + GetKarma(); + AllowedMessages = AllowedMessages > RuleI(Chat, MaximumMessagesPerInterval) ? RuleI(Chat, MaximumMessagesPerInterval) : AllowedMessages; + if (RuleI(Chat, MinStatusToBypassAntiSpam) <= Status) + AllowedMessages = 10000; - AttemptedMessages++; - if(AttemptedMessages > AllowedMessages) + AttemptedMessages++; + if (AttemptedMessages > AllowedMessages) + { + if (AttemptedMessages > RuleI(Chat, MaxMessagesBeforeKick)) { - if(AttemptedMessages > RuleI(Chat, MaxMessagesBeforeKick)) - { - ForceDisconnect = true; - } - if(GlobalChatLimiterTimer) - { - char TimeLeft[256]; - sprintf(TimeLeft, "You are currently rate limited, you cannot send more messages for %i seconds.", - (GlobalChatLimiterTimer->GetRemainingTime() / 1000)); - GeneralChannelMessage(TimeLeft); - } - else - { - GeneralChannelMessage("You are currently rate limited, you cannot send more messages for up to 60 seconds."); - } + ForceDisconnect = true; + } + if (GlobalChatLimiterTimer) + { + char TimeLeft[256]; + sprintf(TimeLeft, "You are currently rate limited, you cannot send more messages for %i seconds.", + (GlobalChatLimiterTimer->GetRemainingTime() / 1000)); + GeneralChannelMessage(TimeLeft); } else { - RequiredChannel->SendMessageToChannel(Message.substr(MessageStart+1), this); + GeneralChannelMessage("You are currently rate limited, you cannot send more messages for up to 60 seconds."); } + } + else + { + RequiredChannel->SendMessageToChannel(Message.substr(MessageStart + 1), this); + } } else GeneralChannelMessage("Channel " + RequiredChannel->GetName() + " is moderated and you have not been granted a voice."); } else { - if(!RequiredChannel->IsModerated() || RequiredChannel->HasVoice(GetName()) || RequiredChannel->IsOwner(GetName()) || + if (!RequiredChannel->IsModerated() || RequiredChannel->HasVoice(GetName()) || RequiredChannel->IsOwner(GetName()) || RequiredChannel->IsModerator(GetName())) - RequiredChannel->SendMessageToChannel(Message.substr(MessageStart+1), this); + RequiredChannel->SendMessageToChannel(Message.substr(MessageStart + 1), this); else GeneralChannelMessage("Channel " + RequiredChannel->GetName() + " is moderated and you have not been granted a voice."); } @@ -1441,13 +1441,13 @@ void Client::SendChannelMessageByNumber(std::string Message) { void Client::SendChannelMessage(std::string ChannelName, std::string Message, Client *Sender) { - if(!Sender) return; + if (!Sender) return; std::string FQSenderName = WorldShortName + "." + Sender->GetName(); int PacketLength = ChannelName.length() + Message.length() + FQSenderName.length() + 3; - if(UnderfootOrLater) + if (UnderfootOrLater) PacketLength += 8; auto outapp = new EQApplicationPacket(OP_ChannelMessage, PacketLength); @@ -1458,7 +1458,7 @@ void Client::SendChannelMessage(std::string ChannelName, std::string Message, Cl VARSTRUCT_ENCODE_STRING(PacketBuffer, FQSenderName.c_str()); VARSTRUCT_ENCODE_STRING(PacketBuffer, Message.c_str()); - if(UnderfootOrLater) + if (UnderfootOrLater) VARSTRUCT_ENCODE_STRING(PacketBuffer, "SPAM:0:"); QueuePacket(outapp); @@ -1468,16 +1468,16 @@ void Client::SendChannelMessage(std::string ChannelName, std::string Message, Cl void Client::ToggleAnnounce(std::string State) { - if(State == "") + if (State == "") Announce = !Announce; - else if(State == "on") + else if (State == "on") Announce = true; else Announce = false; std::string Message = "Announcing now "; - if(Announce) + if (Announce) Message += "on"; else Message += "off"; @@ -1487,7 +1487,7 @@ void Client::ToggleAnnounce(std::string State) void Client::AnnounceJoin(ChatChannel *Channel, Client *c) { - if(!Channel || !c) return; + if (!Channel || !c) return; int PacketLength = Channel->GetName().length() + c->GetName().length() + 2; @@ -1506,7 +1506,7 @@ void Client::AnnounceJoin(ChatChannel *Channel, Client *c) { void Client::AnnounceLeave(ChatChannel *Channel, Client *c) { - if(!Channel || !c) return; + if (!Channel || !c) return; int PacketLength = Channel->GetName().length() + c->GetName().length() + 2; @@ -1525,7 +1525,7 @@ void Client::AnnounceLeave(ChatChannel *Channel, Client *c) { void Client::GeneralChannelMessage(const char *Characters) { - if(!Characters) return; + if (!Characters) return; std::string Message = Characters; @@ -1550,7 +1550,7 @@ void Client::SetChannelPassword(std::string ChannelPassword) { std::string::size_type PasswordStart = ChannelPassword.find_first_not_of(" "); - if(PasswordStart == std::string::npos) { + if (PasswordStart == std::string::npos) { std::string Message = "Incorrect syntax: /chat password "; GeneralChannelMessage(Message); return; @@ -1558,7 +1558,7 @@ void Client::SetChannelPassword(std::string ChannelPassword) { std::string::size_type Space = ChannelPassword.find_first_of(" ", PasswordStart); - if(Space == std::string::npos) { + if (Space == std::string::npos) { std::string Message = "Incorrect syntax: /chat password "; GeneralChannelMessage(Message); return; @@ -1568,7 +1568,7 @@ void Client::SetChannelPassword(std::string ChannelPassword) { std::string::size_type ChannelStart = ChannelPassword.find_first_not_of(" ", Space); - if(ChannelStart == std::string::npos) { + if (ChannelStart == std::string::npos) { std::string Message = "Incorrect syntax: /chat password "; GeneralChannelMessage(Message); return; @@ -1576,29 +1576,29 @@ void Client::SetChannelPassword(std::string ChannelPassword) { std::string ChannelName = ChannelPassword.substr(ChannelStart); - if((ChannelName.length() > 0) && isdigit(ChannelName[0])) + if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); std::string Message; - if(!strcasecmp(Password.c_str(), "remove")) { + if (!strcasecmp(Password.c_str(), "remove")) { Password.clear(); Message = "Password REMOVED on channel " + ChannelName; } else Message = "Password change on channel " + ChannelName; - Log.Out(Logs::Detail, Logs::UCS_Server, "Set password of channel [%s] to [%s] by %s", ChannelName.c_str(), Password.c_str(), GetName().c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Set password of channel [%s] to [%s] by %s", ChannelName.c_str(), Password.c_str(), GetName().c_str()); ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); - if(!RequiredChannel) { + if (!RequiredChannel) { std::string Message = "Channel not found."; GeneralChannelMessage(Message); return; } - if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName()) && !IsChannelAdmin()) { + if (!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName()) && !IsChannelAdmin()) { std::string Message = "You do not own or have moderator rights on channel " + ChannelName; GeneralChannelMessage(Message); return; @@ -1614,7 +1614,7 @@ void Client::SetChannelOwner(std::string CommandString) { std::string::size_type PlayerStart = CommandString.find_first_not_of(" "); - if(PlayerStart == std::string::npos) { + if (PlayerStart == std::string::npos) { std::string Message = "Incorrect syntax: /chat setowner "; GeneralChannelMessage(Message); return; @@ -1622,7 +1622,7 @@ void Client::SetChannelOwner(std::string CommandString) { std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart); - if(Space == std::string::npos) { + if (Space == std::string::npos) { std::string Message = "Incorrect syntax: /chat setowner "; GeneralChannelMessage(Message); return; @@ -1632,7 +1632,7 @@ void Client::SetChannelOwner(std::string CommandString) { std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space); - if(ChannelStart == std::string::npos) { + if (ChannelStart == std::string::npos) { std::string Message = "Incorrect syntax: /chat setowner "; GeneralChannelMessage(Message); return; @@ -1640,25 +1640,25 @@ void Client::SetChannelOwner(std::string CommandString) { std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); - if((ChannelName.length() > 0) && isdigit(ChannelName[0])) + if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); - Log.Out(Logs::Detail, Logs::UCS_Server, "Set owner of channel [%s] to [%s]", ChannelName.c_str(), NewOwner.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Set owner of channel [%s] to [%s]", ChannelName.c_str(), NewOwner.c_str()); ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); - if(!RequiredChannel) { + if (!RequiredChannel) { GeneralChannelMessage("Channel " + ChannelName + " not found."); return; } - if(!RequiredChannel->IsOwner(GetName()) && !IsChannelAdmin()) { + if (!RequiredChannel->IsOwner(GetName()) && !IsChannelAdmin()) { std::string Message = "You do not own channel " + ChannelName; GeneralChannelMessage(Message); return; } - if(database.FindCharacter(NewOwner.c_str()) < 0) { + if (database.FindCharacter(NewOwner.c_str()) < 0) { GeneralChannelMessage("Player " + NewOwner + " does not exist."); return; @@ -1666,7 +1666,7 @@ void Client::SetChannelOwner(std::string CommandString) { RequiredChannel->SetOwner(NewOwner); - if(RequiredChannel->IsModerator(NewOwner)) + if (RequiredChannel->IsModerator(NewOwner)) RequiredChannel->RemoveModerator(NewOwner); GeneralChannelMessage("Channel owner changed."); @@ -1677,7 +1677,7 @@ void Client::OPList(std::string CommandString) { std::string::size_type ChannelStart = CommandString.find_first_not_of(" "); - if(ChannelStart == std::string::npos) { + if (ChannelStart == std::string::npos) { std::string Message = "Incorrect syntax: /chat oplist "; GeneralChannelMessage(Message); return; @@ -1685,12 +1685,12 @@ void Client::OPList(std::string CommandString) { std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); - if((ChannelName.length() > 0) && isdigit(ChannelName[0])) + if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); - if(!RequiredChannel) { + if (!RequiredChannel) { GeneralChannelMessage("Channel " + ChannelName + " not found."); return; } @@ -1702,7 +1702,7 @@ void Client::ChannelInvite(std::string CommandString) { std::string::size_type PlayerStart = CommandString.find_first_not_of(" "); - if(PlayerStart == std::string::npos) { + if (PlayerStart == std::string::npos) { std::string Message = "Incorrect syntax: /chat invite "; GeneralChannelMessage(Message); return; @@ -1710,7 +1710,7 @@ void Client::ChannelInvite(std::string CommandString) { std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart); - if(Space == std::string::npos) { + if (Space == std::string::npos) { std::string Message = "Incorrect syntax: /chat invite "; GeneralChannelMessage(Message); return; @@ -1720,7 +1720,7 @@ void Client::ChannelInvite(std::string CommandString) { std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space); - if(ChannelStart == std::string::npos) { + if (ChannelStart == std::string::npos) { std::string Message = "Incorrect syntax: /chat invite "; GeneralChannelMessage(Message); return; @@ -1728,26 +1728,26 @@ void Client::ChannelInvite(std::string CommandString) { std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); - if((ChannelName.length() > 0) && isdigit(ChannelName[0])) + if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); - Log.Out(Logs::Detail, Logs::UCS_Server, "[%s] invites [%s] to channel [%s]", GetName().c_str(), Invitee.c_str(), ChannelName.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "[%s] invites [%s] to channel [%s]", GetName().c_str(), Invitee.c_str(), ChannelName.c_str()); Client *RequiredClient = g_Clientlist->FindCharacter(Invitee); - if(!RequiredClient) { + if (!RequiredClient) { GeneralChannelMessage(Invitee + " is not online."); return; } - if(RequiredClient == this) { + if (RequiredClient == this) { GeneralChannelMessage("You cannot invite yourself to a channel."); return; } - if(!RequiredClient->InvitesAllowed()) { + if (!RequiredClient->InvitesAllowed()) { GeneralChannelMessage("That player is not currently accepting channel invitations."); return; @@ -1755,13 +1755,13 @@ void Client::ChannelInvite(std::string CommandString) { ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); - if(!RequiredChannel) { + if (!RequiredChannel) { GeneralChannelMessage("Channel " + ChannelName + " not found."); return; } - if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName())) { + if (!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName())) { std::string Message = "You do not own or have moderator rights to channel " + ChannelName; @@ -1769,7 +1769,7 @@ void Client::ChannelInvite(std::string CommandString) { return; } - if(RequiredChannel->IsClientInChannel(RequiredClient)) { + if (RequiredChannel->IsClientInChannel(RequiredClient)) { GeneralChannelMessage(Invitee + " is already in that channel"); @@ -1788,7 +1788,7 @@ void Client::ChannelModerate(std::string CommandString) { std::string::size_type ChannelStart = CommandString.find_first_not_of(" "); - if(ChannelStart == std::string::npos) { + if (ChannelStart == std::string::npos) { std::string Message = "Incorrect syntax: /chat moderate "; @@ -1798,18 +1798,18 @@ void Client::ChannelModerate(std::string CommandString) { std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); - if((ChannelName.length() > 0) && isdigit(ChannelName[0])) + if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); - if(!RequiredChannel) { + if (!RequiredChannel) { GeneralChannelMessage("Channel " + ChannelName + " not found."); return; } - if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName()) && !IsChannelAdmin()) { + if (!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName()) && !IsChannelAdmin()) { GeneralChannelMessage("You do not own or have moderator rights to channel " + ChannelName); return; @@ -1830,7 +1830,7 @@ void Client::ChannelGrantModerator(std::string CommandString) { std::string::size_type PlayerStart = CommandString.find_first_not_of(" "); - if(PlayerStart == std::string::npos) { + if (PlayerStart == std::string::npos) { GeneralChannelMessage("Incorrect syntax: /chat grant "); return; @@ -1838,7 +1838,7 @@ void Client::ChannelGrantModerator(std::string CommandString) { std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart); - if(Space == std::string::npos) { + if (Space == std::string::npos) { GeneralChannelMessage("Incorrect syntax: /chat grant "); return; @@ -1848,7 +1848,7 @@ void Client::ChannelGrantModerator(std::string CommandString) { std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space); - if(ChannelStart == std::string::npos) { + if (ChannelStart == std::string::npos) { GeneralChannelMessage("Incorrect syntax: /chat grant "); return; @@ -1856,20 +1856,20 @@ void Client::ChannelGrantModerator(std::string CommandString) { std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); - if((ChannelName.length() > 0) && isdigit(ChannelName[0])) + if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); - Log.Out(Logs::Detail, Logs::UCS_Server, "[%s] gives [%s] moderator rights to channel [%s]", GetName().c_str(), Moderator.c_str(), ChannelName.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "[%s] gives [%s] moderator rights to channel [%s]", GetName().c_str(), Moderator.c_str(), ChannelName.c_str()); Client *RequiredClient = g_Clientlist->FindCharacter(Moderator); - if(!RequiredClient && (database.FindCharacter(Moderator.c_str()) < 0)) { + if (!RequiredClient && (database.FindCharacter(Moderator.c_str()) < 0)) { GeneralChannelMessage("Player " + Moderator + " does not exist."); return; } - if(RequiredClient == this) { + if (RequiredClient == this) { GeneralChannelMessage("You cannot grant yourself moderator rights to a channel."); return; @@ -1877,23 +1877,23 @@ void Client::ChannelGrantModerator(std::string CommandString) { ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); - if(!RequiredChannel) { + if (!RequiredChannel) { GeneralChannelMessage("Channel " + ChannelName + " not found."); return; } - if(!RequiredChannel->IsOwner(GetName()) && !IsChannelAdmin()) { + if (!RequiredChannel->IsOwner(GetName()) && !IsChannelAdmin()) { GeneralChannelMessage("You do not own channel " + ChannelName); return; } - if(RequiredChannel->IsModerator(Moderator)) { + if (RequiredChannel->IsModerator(Moderator)) { RequiredChannel->RemoveModerator(Moderator); - if(RequiredClient) + if (RequiredClient) RequiredClient->GeneralChannelMessage(GetName() + " has removed your moderator rights to channel " + ChannelName); GeneralChannelMessage("Removing moderator rights from " + Moderator + " to channel " + ChannelName); @@ -1901,7 +1901,7 @@ void Client::ChannelGrantModerator(std::string CommandString) { else { RequiredChannel->AddModerator(Moderator); - if(RequiredClient) + if (RequiredClient) RequiredClient->GeneralChannelMessage(GetName() + " has made you a moderator of channel " + ChannelName); GeneralChannelMessage(Moderator + " is now a moderator on channel " + ChannelName); @@ -1913,7 +1913,7 @@ void Client::ChannelGrantVoice(std::string CommandString) { std::string::size_type PlayerStart = CommandString.find_first_not_of(" "); - if(PlayerStart == std::string::npos) { + if (PlayerStart == std::string::npos) { GeneralChannelMessage("Incorrect syntax: /chat voice "); return; @@ -1921,7 +1921,7 @@ void Client::ChannelGrantVoice(std::string CommandString) { std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart); - if(Space == std::string::npos) { + if (Space == std::string::npos) { GeneralChannelMessage("Incorrect syntax: /chat voice "); return; } @@ -1930,27 +1930,27 @@ void Client::ChannelGrantVoice(std::string CommandString) { std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space); - if(ChannelStart == std::string::npos) { + if (ChannelStart == std::string::npos) { GeneralChannelMessage("Incorrect syntax: /chat voice "); return; } std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); - if((ChannelName.length() > 0) && isdigit(ChannelName[0])) + if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); - Log.Out(Logs::Detail, Logs::UCS_Server, "[%s] gives [%s] voice to channel [%s]", GetName().c_str(), Voicee.c_str(), ChannelName.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "[%s] gives [%s] voice to channel [%s]", GetName().c_str(), Voicee.c_str(), ChannelName.c_str()); Client *RequiredClient = g_Clientlist->FindCharacter(Voicee); - if(!RequiredClient && (database.FindCharacter(Voicee.c_str()) < 0)) { + if (!RequiredClient && (database.FindCharacter(Voicee.c_str()) < 0)) { GeneralChannelMessage("Player " + Voicee + " does not exist."); return; } - if(RequiredClient == this) { + if (RequiredClient == this) { GeneralChannelMessage("You cannot grant yourself voice to a channel."); return; @@ -1958,29 +1958,29 @@ void Client::ChannelGrantVoice(std::string CommandString) { ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); - if(!RequiredChannel) { + if (!RequiredChannel) { GeneralChannelMessage("Channel " + ChannelName + " not found."); return; } - if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName()) && !IsChannelAdmin()) { + if (!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName()) && !IsChannelAdmin()) { GeneralChannelMessage("You do not own or have moderator rights to channel " + ChannelName); return; } - if(RequiredClient && (RequiredChannel->IsOwner(RequiredClient->GetName()) || RequiredChannel->IsModerator(RequiredClient->GetName()))) { + if (RequiredClient && (RequiredChannel->IsOwner(RequiredClient->GetName()) || RequiredChannel->IsModerator(RequiredClient->GetName()))) { GeneralChannelMessage("The channel owner and moderators automatically have voice."); return; } - if(RequiredChannel->HasVoice(Voicee)) { + if (RequiredChannel->HasVoice(Voicee)) { RequiredChannel->RemoveVoice(Voicee); - if(RequiredClient) + if (RequiredClient) RequiredClient->GeneralChannelMessage(GetName() + " has removed your voice rights to channel " + ChannelName); GeneralChannelMessage("Removing voice from " + Voicee + " in channel " + ChannelName); @@ -1988,7 +1988,7 @@ void Client::ChannelGrantVoice(std::string CommandString) { else { RequiredChannel->AddVoice(Voicee); - if(RequiredClient) + if (RequiredClient) RequiredClient->GeneralChannelMessage(GetName() + " has given you voice in channel " + ChannelName); GeneralChannelMessage(Voicee + " now has voice in channel " + ChannelName); @@ -2000,7 +2000,7 @@ void Client::ChannelKick(std::string CommandString) { std::string::size_type PlayerStart = CommandString.find_first_not_of(" "); - if(PlayerStart == std::string::npos) { + if (PlayerStart == std::string::npos) { GeneralChannelMessage("Incorrect syntax: /chat kick "); return; @@ -2008,7 +2008,7 @@ void Client::ChannelKick(std::string CommandString) { std::string::size_type Space = CommandString.find_first_of(" ", PlayerStart); - if(Space == std::string::npos) { + if (Space == std::string::npos) { GeneralChannelMessage("Incorrect syntax: /chat kick "); return; @@ -2018,27 +2018,27 @@ void Client::ChannelKick(std::string CommandString) { std::string::size_type ChannelStart = CommandString.find_first_not_of(" ", Space); - if(ChannelStart == std::string::npos) { + if (ChannelStart == std::string::npos) { GeneralChannelMessage("Incorrect syntax: /chat kick "); return; } std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); - if((ChannelName.length() > 0) && isdigit(ChannelName[0])) + if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); - Log.Out(Logs::Detail, Logs::UCS_Server, "[%s] kicks [%s] from channel [%s]", GetName().c_str(), Kickee.c_str(), ChannelName.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "[%s] kicks [%s] from channel [%s]", GetName().c_str(), Kickee.c_str(), ChannelName.c_str()); Client *RequiredClient = g_Clientlist->FindCharacter(Kickee); - if(!RequiredClient) { + if (!RequiredClient) { GeneralChannelMessage("Player " + Kickee + " is not online."); return; } - if(RequiredClient == this) { + if (RequiredClient == this) { GeneralChannelMessage("You cannot kick yourself out of a channel."); return; @@ -2046,31 +2046,31 @@ void Client::ChannelKick(std::string CommandString) { ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); - if(!RequiredChannel) { + if (!RequiredChannel) { GeneralChannelMessage("Channel " + ChannelName + " not found."); return; } - if(!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName()) && !IsChannelAdmin()) { + if (!RequiredChannel->IsOwner(GetName()) && !RequiredChannel->IsModerator(GetName()) && !IsChannelAdmin()) { GeneralChannelMessage("You do not own or have moderator rights to channel " + ChannelName); return; } - if(RequiredChannel->IsOwner(RequiredClient->GetName())) { + if (RequiredChannel->IsOwner(RequiredClient->GetName())) { GeneralChannelMessage("You cannot kick the owner out of the channel."); return; } - if(RequiredChannel->IsModerator(Kickee) && !RequiredChannel->IsOwner(GetName())) { + if (RequiredChannel->IsModerator(Kickee) && !RequiredChannel->IsOwner(GetName())) { GeneralChannelMessage("Only the channel owner can kick a moderator out of the channel."); return; } - if(RequiredChannel->IsModerator(Kickee)) { + if (RequiredChannel->IsModerator(Kickee)) { RequiredChannel->RemoveModerator(Kickee); @@ -2090,7 +2090,7 @@ void Client::ToggleInvites() { AllowInvites = !AllowInvites; - if(AllowInvites) + if (AllowInvites) GeneralChannelMessage("You will now receive channel invitations."); else GeneralChannelMessage("You will no longer receive channel invitations."); @@ -2099,10 +2099,10 @@ void Client::ToggleInvites() { std::string Client::ChannelSlotName(int SlotNumber) { - if((SlotNumber < 1 ) || (SlotNumber > MAX_JOINED_CHANNELS)) + if ((SlotNumber < 1) || (SlotNumber > MAX_JOINED_CHANNELS)) return ""; - if(JoinedChannels[SlotNumber - 1] == nullptr) + if (JoinedChannels[SlotNumber - 1] == nullptr) return ""; return JoinedChannels[SlotNumber - 1]->GetName(); @@ -2120,9 +2120,9 @@ void Client::SendHelp() { void Client::AccountUpdate() { - if(AccountGrabUpdateTimer) + if (AccountGrabUpdateTimer) { - if(AccountGrabUpdateTimer->Check(false)) + if (AccountGrabUpdateTimer->Check(false)) { AccountGrabUpdateTimer->Start(60000); database.GetAccountStatus(this); @@ -2132,38 +2132,38 @@ void Client::AccountUpdate() void Client::SetConnectionType(char c) { - switch(c) + switch (c) { - case 'S': - { - TypeOfConnection = ConnectionTypeCombined; - Log.Out(Logs::Detail, Logs::UCS_Server, "Connection type is Combined (SoF/SoD)"); - break; - } - case 'U': - { - TypeOfConnection = ConnectionTypeCombined; - UnderfootOrLater = true; - Log.Out(Logs::Detail, Logs::UCS_Server, "Connection type is Combined (Underfoot+)"); - break; - } - case 'M': - { - TypeOfConnection = ConnectionTypeMail; - Log.Out(Logs::Detail, Logs::UCS_Server, "Connection type is Mail (6.2 or Titanium client)"); - break; - } - case 'C': - { - TypeOfConnection = ConnectionTypeChat; - Log.Out(Logs::Detail, Logs::UCS_Server, "Connection type is Chat (6.2 or Titanium client)"); - break; - } - default: - { - TypeOfConnection = ConnectionTypeUnknown; - Log.Out(Logs::Detail, Logs::UCS_Server, "Connection type is unknown."); - } + case 'S': + { + TypeOfConnection = ConnectionTypeCombined; + Log(Logs::Detail, Logs::UCS_Server, "Connection type is Combined (SoF/SoD)"); + break; + } + case 'U': + { + TypeOfConnection = ConnectionTypeCombined; + UnderfootOrLater = true; + Log(Logs::Detail, Logs::UCS_Server, "Connection type is Combined (Underfoot+)"); + break; + } + case 'M': + { + TypeOfConnection = ConnectionTypeMail; + Log(Logs::Detail, Logs::UCS_Server, "Connection type is Mail (6.2 or Titanium client)"); + break; + } + case 'C': + { + TypeOfConnection = ConnectionTypeChat; + Log(Logs::Detail, Logs::UCS_Server, "Connection type is Chat (6.2 or Titanium client)"); + break; + } + default: + { + TypeOfConnection = ConnectionTypeUnknown; + Log(Logs::Detail, Logs::UCS_Server, "Connection type is unknown."); + } } } @@ -2178,17 +2178,17 @@ Client *Clientlist::IsCharacterOnline(std::string CharacterName) { // std::list::iterator Iterator; - for(Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); ++Iterator) { + for (Iterator = ClientChatConnections.begin(); Iterator != ClientChatConnections.end(); ++Iterator) { - if(!(*Iterator)->IsMailConnection()) + if (!(*Iterator)->IsMailConnection()) continue; int MailBoxNumber = (*Iterator)->GetMailBoxNumber(CharacterName); // If the mail is destined for the primary mailbox for this character, or the one they have selected // - if((MailBoxNumber == 0) || (MailBoxNumber == (*Iterator)->GetMailBoxNumber())) - return (*Iterator); + if ((MailBoxNumber == 0) || (MailBoxNumber == (*Iterator)->GetMailBoxNumber())) + return (*Iterator); } @@ -2197,8 +2197,8 @@ Client *Clientlist::IsCharacterOnline(std::string CharacterName) { int Client::GetMailBoxNumber(std::string CharacterName) { - for(unsigned int i = 0; i < Characters.size(); i++) - if(Characters[i].Name == CharacterName) + for (unsigned int i = 0; i < Characters.size(); i++) + if (Characters[i].Name == CharacterName) return i; return -1; @@ -2218,7 +2218,7 @@ void Client::SendNotification(int MailBoxNumber, std::string Subject, std::strin sprintf(Sequence, "%i", 1); - int PacketLength = 8 + strlen(sMessageID) + strlen(TimeStamp)+ From.length() + Subject.length(); + int PacketLength = 8 + strlen(sMessageID) + strlen(TimeStamp) + From.length() + Subject.length(); auto outapp = new EQApplicationPacket(OP_MailNew, PacketLength); @@ -2239,12 +2239,12 @@ void Client::SendNotification(int MailBoxNumber, std::string Subject, std::strin void Client::ChangeMailBox(int NewMailBox) { - Log.Out(Logs::Detail, Logs::UCS_Server, "%s Change to mailbox %i", MailBoxName().c_str(), NewMailBox); + Log(Logs::Detail, Logs::UCS_Server, "%s Change to mailbox %i", MailBoxName().c_str(), NewMailBox); SetMailBox(NewMailBox); auto id = std::to_string(NewMailBox); - Log.Out(Logs::Detail, Logs::UCS_Server, "New mailbox is %s", MailBoxName().c_str()); + Log(Logs::Detail, Logs::UCS_Server, "New mailbox is %s", MailBoxName().c_str()); auto outapp = new EQApplicationPacket(OP_MailboxChange, id.length() + 1); @@ -2268,7 +2268,7 @@ void Client::SendFriends() { Iterator = Friends.begin(); - while(Iterator != Friends.end()) { + while (Iterator != Friends.end()) { outapp = new EQApplicationPacket(OP_Buddy, (*Iterator).length() + 2); @@ -2288,7 +2288,7 @@ void Client::SendFriends() { Iterator = Ignorees.begin(); - while(Iterator != Ignorees.end()) { + while (Iterator != Ignorees.end()) { std::string Ignoree = "SOE.EQ." + WorldShortName + "." + (*Iterator); @@ -2311,16 +2311,16 @@ void Client::SendFriends() { std::string Client::MailBoxName() { - if((Characters.empty()) || (CurrentMailBox > (Characters.size() - 1))) + if ((Characters.empty()) || (CurrentMailBox > (Characters.size() - 1))) { - Log.Out(Logs::Detail, Logs::UCS_Server, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i", - CurrentMailBox, Characters.size()); + Log(Logs::Detail, Logs::UCS_Server, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i", + CurrentMailBox, Characters.size()); return ""; } - Log.Out(Logs::Detail, Logs::UCS_Server, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i", - CurrentMailBox, Characters.size()); + Log(Logs::Detail, Logs::UCS_Server, "MailBoxName() called with CurrentMailBox set to %i and Characters.size() is %i", + CurrentMailBox, Characters.size()); return Characters[CurrentMailBox].Name; @@ -2328,9 +2328,8 @@ std::string Client::MailBoxName() { int Client::GetCharID() { - if(Characters.empty()) + if (Characters.empty()) return 0; return Characters[0].CharID; } - diff --git a/ucs/database.cpp b/ucs/database.cpp index dbd0af504..5104c851d 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -74,14 +74,14 @@ bool Database::Connect(const char* host, const char* user, const char* passwd, c char errbuf[MYSQL_ERRMSG_SIZE]; if (!Open(host, user, passwd, database, port, &errnum, errbuf)) { - Log.Out(Logs::General, Logs::Error, "Failed to connect to database: Error: %s", errbuf); + Log(Logs::General, Logs::Error, "Failed to connect to database: Error: %s", errbuf); HandleMysqlError(errnum); return false; } else { - Log.Out(Logs::General, Logs::Status, "Using database '%s' at %s:%d",database,host,port); + Log(Logs::General, Logs::Status, "Using database '%s' at %s:%d",database,host,port); return true; } } @@ -110,15 +110,15 @@ void Database::GetAccountStatus(Client *client) { client->GetAccountID()); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Unable to get account status for character %s, error %s", client->GetName().c_str(), results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Unable to get account status for character %s, error %s", client->GetName().c_str(), results.ErrorMessage().c_str()); return; } - Log.Out(Logs::Detail, Logs::UCS_Server, "GetAccountStatus Query: %s", query.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "GetAccountStatus Query: %s", query.c_str()); if(results.RowCount() != 1) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Error in GetAccountStatus"); + Log(Logs::Detail, Logs::UCS_Server, "Error in GetAccountStatus"); return; } @@ -129,13 +129,13 @@ void Database::GetAccountStatus(Client *client) { client->SetKarma(atoi(row[2])); client->SetRevoked((atoi(row[3])==1?true:false)); - Log.Out(Logs::Detail, Logs::UCS_Server, "Set account status to %i, hideme to %i and karma to %i for %s", client->GetAccountStatus(), client->GetHideMe(), client->GetKarma(), client->GetName().c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Set account status to %i, hideme to %i and karma to %i for %s", client->GetAccountStatus(), client->GetHideMe(), client->GetKarma(), client->GetName().c_str()); } int Database::FindAccount(const char *characterName, Client *client) { - Log.Out(Logs::Detail, Logs::UCS_Server, "FindAccount for character %s", characterName); + Log(Logs::Detail, Logs::UCS_Server, "FindAccount for character %s", characterName); client->ClearCharacters(); @@ -144,12 +144,12 @@ int Database::FindAccount(const char *characterName, Client *client) { characterName); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::Detail, Logs::UCS_Server, "FindAccount query failed: %s", query.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "FindAccount query failed: %s", query.c_str()); return -1; } if (results.RowCount() != 1) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Bad result from query"); + Log(Logs::Detail, Logs::UCS_Server, "Bad result from query"); return -1; } @@ -158,7 +158,7 @@ int Database::FindAccount(const char *characterName, Client *client) { int accountID = atoi(row[1]); - Log.Out(Logs::Detail, Logs::UCS_Server, "Account ID for %s is %i", characterName, accountID); + Log(Logs::Detail, Logs::UCS_Server, "Account ID for %s is %i", characterName, accountID); query = StringFormat("SELECT `id`, `name`, `level` FROM `character_data` " "WHERE `account_id` = %i AND `name` != '%s'", @@ -179,7 +179,7 @@ bool Database::VerifyMailKey(std::string characterName, int IPAddress, std::stri characterName.c_str()); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Error retrieving mailkey from database: %s", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Error retrieving mailkey from database: %s", results.ErrorMessage().c_str()); return false; } @@ -195,7 +195,7 @@ bool Database::VerifyMailKey(std::string characterName, int IPAddress, std::stri else sprintf(combinedKey, "%s", MailKey.c_str()); - Log.Out(Logs::Detail, Logs::UCS_Server, "DB key is [%s], Client key is [%s]", (row[0] ? row[0] : ""), combinedKey); + Log(Logs::Detail, Logs::UCS_Server, "DB key is [%s], Client key is [%s]", (row[0] ? row[0] : ""), combinedKey); return !strcmp(row[0], combinedKey); } @@ -213,7 +213,7 @@ int Database::FindCharacter(const char *characterName) safe_delete_array(safeCharName); if (results.RowCount() != 1) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Bad result from FindCharacter query for character %s", + Log(Logs::Detail, Logs::UCS_Server, "Bad result from FindCharacter query for character %s", characterName); return -1; } @@ -245,7 +245,7 @@ bool Database::GetVariable(const char* varname, char* varvalue, uint16 varvalue_ bool Database::LoadChatChannels() { - Log.Out(Logs::Detail, Logs::UCS_Server, "Loading chat channels from the database."); + Log(Logs::Detail, Logs::UCS_Server, "Loading chat channels from the database."); const std::string query = "SELECT `name`, `owner`, `password`, `minstatus` FROM `chatchannels`"; auto results = QueryDatabase(query); @@ -266,7 +266,7 @@ bool Database::LoadChatChannels() { void Database::SetChannelPassword(std::string channelName, std::string password) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Database::SetChannelPassword(%s, %s)", channelName.c_str(), password.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Database::SetChannelPassword(%s, %s)", channelName.c_str(), password.c_str()); std::string query = StringFormat("UPDATE `chatchannels` SET `password` = '%s' WHERE `name` = '%s'", password.c_str(), channelName.c_str()); @@ -275,7 +275,7 @@ void Database::SetChannelPassword(std::string channelName, std::string password) void Database::SetChannelOwner(std::string channelName, std::string owner) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Database::SetChannelOwner(%s, %s)", channelName.c_str(), owner.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Database::SetChannelOwner(%s, %s)", channelName.c_str(), owner.c_str()); std::string query = StringFormat("UPDATE `chatchannels` SET `owner` = '%s' WHERE `name` = '%s'", owner.c_str(), channelName.c_str()); @@ -288,7 +288,7 @@ void Database::SendHeaders(Client *client) { int unknownField3 = 1; int characterID = FindCharacter(client->MailBoxName().c_str()); - Log.Out(Logs::Detail, Logs::UCS_Server, "Sendheaders for %s, CharID is %i", client->MailBoxName().c_str(), characterID); + Log(Logs::Detail, Logs::UCS_Server, "Sendheaders for %s, CharID is %i", client->MailBoxName().c_str(), characterID); if(characterID <= 0) return; @@ -373,7 +373,7 @@ void Database::SendBody(Client *client, int messageNumber) { int characterID = FindCharacter(client->MailBoxName().c_str()); - Log.Out(Logs::Detail, Logs::UCS_Server, "SendBody: MsgID %i, to %s, CharID is %i", messageNumber, client->MailBoxName().c_str(), characterID); + Log(Logs::Detail, Logs::UCS_Server, "SendBody: MsgID %i, to %s, CharID is %i", messageNumber, client->MailBoxName().c_str(), characterID); if(characterID <= 0) return; @@ -390,7 +390,7 @@ void Database::SendBody(Client *client, int messageNumber) { auto row = results.begin(); - Log.Out(Logs::Detail, Logs::UCS_Server, "Message: %i body (%i bytes)", messageNumber, strlen(row[1])); + Log(Logs::Detail, Logs::UCS_Server, "Message: %i body (%i bytes)", messageNumber, strlen(row[1])); int packetLength = 12 + strlen(row[0]) + strlen(row[1]) + strlen(row[2]); @@ -435,7 +435,7 @@ bool Database::SendMail(std::string recipient, std::string from, std::string sub characterID = FindCharacter(characterName.c_str()); - Log.Out(Logs::Detail, Logs::UCS_Server, "SendMail: CharacterID for recipient %s is %i", characterName.c_str(), characterID); + Log(Logs::Detail, Logs::UCS_Server, "SendMail: CharacterID for recipient %s is %i", characterName.c_str(), characterID); if(characterID <= 0) return false; @@ -460,7 +460,7 @@ bool Database::SendMail(std::string recipient, std::string from, std::string sub return false; } - Log.Out(Logs::Detail, Logs::UCS_Server, "MessageID %i generated, from %s, to %s", results.LastInsertedID(), from.c_str(), recipient.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "MessageID %i generated, from %s, to %s", results.LastInsertedID(), from.c_str(), recipient.c_str()); Client *client = g_Clientlist->IsCharacterOnline(characterName); @@ -477,7 +477,7 @@ bool Database::SendMail(std::string recipient, std::string from, std::string sub void Database::SetMessageStatus(int messageNumber, int status) { - Log.Out(Logs::Detail, Logs::UCS_Server, "SetMessageStatus %i %i", messageNumber, status); + Log(Logs::Detail, Logs::UCS_Server, "SetMessageStatus %i %i", messageNumber, status); if(status == 0) { std::string query = StringFormat("DELETE FROM `mail` WHERE `msgid` = %i", messageNumber); @@ -491,7 +491,7 @@ void Database::SetMessageStatus(int messageNumber, int status) { void Database::ExpireMail() { - Log.Out(Logs::Detail, Logs::UCS_Server, "Expiring mail..."); + Log(Logs::Detail, Logs::UCS_Server, "Expiring mail..."); std::string query = "SELECT COUNT(*) FROM `mail`"; auto results = QueryDatabase(query); @@ -501,7 +501,7 @@ void Database::ExpireMail() { auto row = results.begin(); - Log.Out(Logs::Detail, Logs::UCS_Server, "There are %s messages in the database.", row[0]); + Log(Logs::Detail, Logs::UCS_Server, "There are %s messages in the database.", row[0]); // Expire Trash if(RuleI(Mail, ExpireTrash) >= 0) { @@ -509,7 +509,7 @@ void Database::ExpireMail() { time(nullptr) - RuleI(Mail, ExpireTrash)); results = QueryDatabase(query); if(results.Success()) - Log.Out(Logs::Detail, Logs::UCS_Server, "Expired %i trash messages.", results.RowsAffected()); + Log(Logs::Detail, Logs::UCS_Server, "Expired %i trash messages.", results.RowsAffected()); } // Expire Read @@ -518,7 +518,7 @@ void Database::ExpireMail() { time(nullptr) - RuleI(Mail, ExpireRead)); results = QueryDatabase(query); if(results.Success()) - Log.Out(Logs::Detail, Logs::UCS_Server, "Expired %i read messages.", results.RowsAffected()); + Log(Logs::Detail, Logs::UCS_Server, "Expired %i read messages.", results.RowsAffected()); } // Expire Unread @@ -527,7 +527,7 @@ void Database::ExpireMail() { time(nullptr) - RuleI(Mail, ExpireUnread)); results = QueryDatabase(query); if(results.Success()) - Log.Out(Logs::Detail, Logs::UCS_Server, "Expired %i unread messages.", results.RowsAffected()); + Log(Logs::Detail, Logs::UCS_Server, "Expired %i unread messages.", results.RowsAffected()); } } @@ -538,7 +538,7 @@ void Database::AddFriendOrIgnore(int charID, int type, std::string name) { charID, type, CapitaliseName(name).c_str()); auto results = QueryDatabase(query); if(results.Success()) - Log.Out(Logs::Detail, Logs::UCS_Server, "Wrote Friend/Ignore entry for charid %i, type %i, name %s to database.", charID, type, name.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Wrote Friend/Ignore entry for charid %i, type %i, name %s to database.", charID, type, name.c_str()); } @@ -548,11 +548,12 @@ void Database::RemoveFriendOrIgnore(int charID, int type, std::string name) { "AND `type` = %i AND `name` = '%s'", charID, type, CapitaliseName(name).c_str()); auto results = QueryDatabase(query); - if(!results.Success()) - Log.Out(Logs::Detail, Logs::UCS_Server, "Error removing friend/ignore, query was %s", query.c_str()); - else - Log.Out(Logs::Detail, Logs::UCS_Server, "Removed Friend/Ignore entry for charid %i, type %i, name %s from database.", charID, type, name.c_str()); - + if (!results.Success()) { + Log(Logs::Detail, Logs::UCS_Server, "Error removing friend/ignore, query was %s", query.c_str()); + } + else { + Log(Logs::Detail, Logs::UCS_Server, "Removed Friend/Ignore entry for charid %i, type %i, name %s from database.", charID, type, name.c_str()); + } } void Database::GetFriendsAndIgnore(int charID, std::vector &friends, std::vector &ignorees) { @@ -570,12 +571,12 @@ void Database::GetFriendsAndIgnore(int charID, std::vector &friends if(atoi(row[0]) == 0) { ignorees.push_back(name); - Log.Out(Logs::Detail, Logs::UCS_Server, "Added Ignoree from DB %s", name.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Added Ignoree from DB %s", name.c_str()); continue; } friends.push_back(name); - Log.Out(Logs::Detail, Logs::UCS_Server, "Added Friend from DB %s", name.c_str()); + Log(Logs::Detail, Logs::UCS_Server, "Added Friend from DB %s", name.c_str()); } } @@ -594,7 +595,7 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings){ auto results = QueryDatabase(query); int log_category = 0; - Log.file_logs_enabled = false; + LogSys.file_logs_enabled = false; for (auto row = results.begin(); row != results.end(); ++row) { log_category = atoi(row[0]); @@ -617,7 +618,7 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings){ If we go through this whole loop and nothing is set to any debug level, there is no point to create a file or keep anything open */ if (log_settings[log_category].log_to_file > 0){ - Log.file_logs_enabled = true; + LogSys.file_logs_enabled = true; } } } diff --git a/ucs/ucs.cpp b/ucs/ucs.cpp index 62e2f7e99..b9e7f41b4 100644 --- a/ucs/ucs.cpp +++ b/ucs/ucs.cpp @@ -38,7 +38,7 @@ ChatChannelList *ChannelList; Clientlist *g_Clientlist; -EQEmuLogSys Log; +EQEmuLogSys LogSys; Database database; WorldServer *worldserver = nullptr; @@ -64,7 +64,7 @@ std::string GetMailPrefix() { int main() { RegisterExecutablePlatform(ExePlatformUCS); - Log.LoadLogSettingsDefaults(); + LogSys.LoadLogSettingsDefaults(); set_exception_handler(); // Check every minute for unused channels we can delete @@ -73,10 +73,10 @@ int main() { Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect - Log.Out(Logs::General, Logs::UCS_Server, "Starting EQEmu Universal Chat Server."); + Log(Logs::General, Logs::UCS_Server, "Starting EQEmu Universal Chat Server."); if (!ucsconfig::LoadConfig()) { - Log.Out(Logs::General, Logs::UCS_Server, "Loading server configuration failed."); + Log(Logs::General, Logs::UCS_Server, "Loading server configuration failed."); return 1; } @@ -84,7 +84,7 @@ int main() { WorldShortName = Config->ShortName; - Log.Out(Logs::General, Logs::UCS_Server, "Connecting to MySQL..."); + Log(Logs::General, Logs::UCS_Server, "Connecting to MySQL..."); if (!database.Connect( Config->DatabaseHost.c_str(), @@ -92,26 +92,26 @@ int main() { Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) { - Log.Out(Logs::General, Logs::UCS_Server, "Cannot continue without a database connection."); + Log(Logs::General, Logs::UCS_Server, "Cannot continue without a database connection."); return 1; } /* Register Log System and Settings */ - database.LoadLogSettings(Log.log_settings); - Log.StartFileLogs(); + database.LoadLogSettings(LogSys.log_settings); + LogSys.StartFileLogs(); char tmp[64]; if (database.GetVariable("RuleSet", tmp, sizeof(tmp)-1)) { - Log.Out(Logs::General, Logs::UCS_Server, "Loading rule set '%s'", tmp); + Log(Logs::General, Logs::UCS_Server, "Loading rule set '%s'", tmp); if(!RuleManager::Instance()->LoadRules(&database, tmp)) { - Log.Out(Logs::General, Logs::UCS_Server, "Failed to load ruleset '%s', falling back to defaults.", tmp); + Log(Logs::General, Logs::UCS_Server, "Failed to load ruleset '%s', falling back to defaults.", tmp); } } else { if(!RuleManager::Instance()->LoadRules(&database, "default")) { - Log.Out(Logs::General, Logs::UCS_Server, "No rule set configured, using default rules"); + Log(Logs::General, Logs::UCS_Server, "No rule set configured, using default rules"); } else { - Log.Out(Logs::General, Logs::UCS_Server, "Loaded default rule set 'default'", tmp); + Log(Logs::General, Logs::UCS_Server, "Loaded default rule set 'default'", tmp); } } @@ -119,7 +119,7 @@ int main() { if(Config->ChatPort != Config->MailPort) { - Log.Out(Logs::General, Logs::UCS_Server, "MailPort and CharPort must be the same in eqemu_config.xml for UCS."); + Log(Logs::General, Logs::UCS_Server, "MailPort and CharPort must be the same in eqemu_config.xml for UCS."); exit(1); } @@ -130,11 +130,11 @@ int main() { database.LoadChatChannels(); if (signal(SIGINT, CatchSignal) == SIG_ERR) { - Log.Out(Logs::General, Logs::UCS_Server, "Could not set signal handler"); + Log(Logs::General, Logs::UCS_Server, "Could not set signal handler"); return 1; } if (signal(SIGTERM, CatchSignal) == SIG_ERR) { - Log.Out(Logs::General, Logs::UCS_Server, "Could not set signal handler"); + Log(Logs::General, Logs::UCS_Server, "Could not set signal handler"); return 1; } @@ -158,7 +158,7 @@ int main() { g_Clientlist->CloseAllConnections(); - Log.CloseFileLogs(); + LogSys.CloseFileLogs(); } diff --git a/ucs/worldserver.cpp b/ucs/worldserver.cpp index fb9176c22..141211032 100644 --- a/ucs/worldserver.cpp +++ b/ucs/worldserver.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) +Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" #include "../common/eqemu_logsys.h" @@ -56,64 +56,63 @@ void WorldServer::ProcessMessage(uint16 opcode, EQ::Net::Packet &p) ServerPacket tpack(opcode, p); ServerPacket *pack = &tpack; - Log.Out(Logs::Detail, Logs::UCS_Server, "Received Opcode: %4X", opcode); + Log(Logs::Detail, Logs::UCS_Server, "Received Opcode: %4X", opcode); - switch(opcode) + switch (opcode) { - case 0: { + case 0: { + break; + } + case ServerOP_KeepAlive: + { + break; + } + case ServerOP_UCSMessage: + { + char *Buffer = (char *)pack->pBuffer; + + auto From = new char[strlen(Buffer) + 1]; + + VARSTRUCT_DECODE_STRING(From, Buffer); + + std::string Message = Buffer; + + Log(Logs::Detail, Logs::UCS_Server, "Player: %s, Sent Message: %s", From, Message.c_str()); + + Client *c = g_Clientlist->FindCharacter(From); + + safe_delete_array(From); + + if (Message.length() < 2) break; - } - case ServerOP_KeepAlive: + + if (!c) { + Log(Logs::Detail, Logs::UCS_Server, "Client not found."); break; } - case ServerOP_UCSMessage: + + if (Message[0] == ';') { - char *Buffer = (char *)pack->pBuffer; - - auto From = new char[strlen(Buffer) + 1]; - - VARSTRUCT_DECODE_STRING(From, Buffer); - - std::string Message = Buffer; - - Log.Out(Logs::Detail, Logs::UCS_Server, "Player: %s, Sent Message: %s", From, Message.c_str()); - - Client *c = g_Clientlist->FindCharacter(From); - - safe_delete_array(From); - - if(Message.length() < 2) - break; - - if(!c) - { - Log.Out(Logs::Detail, Logs::UCS_Server, "Client not found."); - break; - } - - if(Message[0] == ';') - { - c->SendChannelMessageByNumber(Message.substr(1, std::string::npos)); - } - else if(Message[0] == '[') - { - g_Clientlist->ProcessOPMailCommand(c, Message.substr(1, std::string::npos)); - } - - break; + c->SendChannelMessageByNumber(Message.substr(1, std::string::npos)); } - - case ServerOP_UCSMailMessage: + else if (Message[0] == '[') { - ServerMailMessageHeader_Struct *mail = (ServerMailMessageHeader_Struct*)pack->pBuffer; - database.SendMail(std::string("SOE.EQ.") + Config->ShortName + std::string(".") + std::string(mail->to), - std::string(mail->from), - mail->subject, - mail->message, - std::string()); - break; + g_Clientlist->ProcessOPMailCommand(c, Message.substr(1, std::string::npos)); } + + break; + } + + case ServerOP_UCSMailMessage: + { + ServerMailMessageHeader_Struct *mail = (ServerMailMessageHeader_Struct*)pack->pBuffer; + database.SendMail(std::string("SOE.EQ.") + Config->ShortName + std::string(".") + std::string(mail->to), + std::string(mail->from), + mail->subject, + mail->message, + std::string()); + break; + } } } - diff --git a/utils/sql/git/bots/bots_db_update_manifest.txt b/utils/sql/git/bots/bots_db_update_manifest.txt index 9fdb07b41..5806cfa3e 100644 --- a/utils/sql/git/bots/bots_db_update_manifest.txt +++ b/utils/sql/git/bots/bots_db_update_manifest.txt @@ -8,7 +8,7 @@ 9007|2016_06_23_bots_camel_case_name_rule.sql|SELECT * FROM `rule_values` WHERE `rule_name` LIKE 'Bots:AllowCamelCaseNames'|empty| 9008|2016_06_28_bots_inventory_charges_update.sql|SELECT * FROM `information_schema`.`COLUMNS` isc WHERE isc.`TABLE_SCHEMA` = DATABASE() AND isc.`TABLE_NAME` = 'bot_inventories' AND isc.`COLUMN_NAME` = 'inst_charges' AND isc.`DATA_TYPE` = 'tinyint'|not_empty| 9009|2017_02_15_bots_bot_spells_entries.sql|SELECT `id` FROM `npc_spells_entries` WHERE `npc_spells_id` >= 701 AND `npc_spells_id` <= 712|not_empty| -9010|2017_02_20_bots_bard_spell_update.sql|SELECT * FROM `bot_spells_entries` WHERE `npc_spells_id` = 711 AND (`type` & 0xFFFF0000) = 0xFFFF0000|empty| +9010|2017_02_20_bots_bard_spell_update.sql|SELECT * FROM `bot_spells_entries` WHERE (`npc_spells_id` = 711 OR `npc_spells_id` = 3008) AND `type` >= 0xFFFF0000|empty| 9011|2017_02_23_bots_spell_casting_chances.sql|SHOW TABLES LIKE 'bot_spell_casting_chances'|empty| 9012|2017_02_26_bots_npc_spells_update_for_bots.sql|SELECT * FROM `npc_spells` WHERE `id` = '701' AND `name` = 'Cleric Bot'|not_empty| 9013|2017_02_26_bots_spells_id_update_for_saved_bots.sql|SELECT * FROM `bot_data` WHERE `spells_id` >= '701' AND `spells_id` <= '712'|not_empty| diff --git a/world/client.cpp b/world/client.cpp index 1971fc9cb..0c1cd9e2a 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -157,7 +157,7 @@ void Client::SendEnterWorld(std::string name) eqs->Close(); return; } else { - Log.Out(Logs::Detail, Logs::World_Server,"Telling client to continue session."); + Log(Logs::Detail, Logs::World_Server,"Telling client to continue session."); } } @@ -201,7 +201,7 @@ void Client::SendCharInfo() { QueuePacket(outapp); } else { - Log.Out(Logs::General, Logs::World_Server, "[Error] Database did not return an OP_SendCharInfo packet for account %u", GetAccountID()); + Log(Logs::General, Logs::World_Server, "[Error] Database did not return an OP_SendCharInfo packet for account %u", GetAccountID()); } safe_delete(outapp); } @@ -406,7 +406,7 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) { if (strlen(password) <= 1) { // TODO: Find out how to tell the client wrong username/password - Log.Out(Logs::Detail, Logs::World_Server,"Login without a password"); + Log(Logs::Detail, Logs::World_Server,"Login without a password"); return false; } @@ -433,17 +433,19 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) { else id=atoi(name); if (loginserverlist.Connected() == false && !is_player_zoning) { - Log.Out(Logs::General, Logs::World_Server,"Error: Login server login while not connected to login server."); + Log(Logs::General, Logs::World_Server,"Error: Login server login while not connected to login server."); return false; } if (((cle = client_list.CheckAuth(name, password)) || (cle = client_list.CheckAuth(id, password)))) { if (cle->AccountID() == 0 || (!minilogin && cle->LSID()==0)) { - Log.Out(Logs::General, Logs::World_Server,"ID is 0. Is this server connected to minilogin?"); - if(!minilogin) - Log.Out(Logs::General, Logs::World_Server,"If so you forget the minilogin variable..."); - else - Log.Out(Logs::General, Logs::World_Server,"Could not find a minilogin account, verify ip address logging into minilogin is the same that is in your account table."); + Log(Logs::General, Logs::World_Server,"ID is 0. Is this server connected to minilogin?"); + if (!minilogin) { + Log(Logs::General, Logs::World_Server, "If so you forget the minilogin variable..."); + } + else { + Log(Logs::General, Logs::World_Server, "Could not find a minilogin account, verify ip address logging into minilogin is the same that is in your account table."); + } return false; } @@ -451,11 +453,11 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) { if(minilogin){ WorldConfig::DisableStats(); - Log.Out(Logs::General, Logs::World_Server, "MiniLogin Account #%d",cle->AccountID()); + Log(Logs::General, Logs::World_Server, "MiniLogin Account #%d",cle->AccountID()); } else { if (!is_player_zoning) { - Log.Out(Logs::General, Logs::World_Server, + Log(Logs::General, Logs::World_Server, "Account (%s) Logging in :: LSID: %d ", cle->AccountName(), cle->LSID()); } } @@ -491,7 +493,7 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) { } else { // TODO: Find out how to tell the client wrong username/password - Log.Out(Logs::Detail, Logs::World_Server,"Bad/Expired session key '%s'",name); + Log(Logs::Detail, Logs::World_Server,"Bad/Expired session key '%s'",name); return false; } @@ -505,7 +507,7 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) { bool Client::HandleNameApprovalPacket(const EQApplicationPacket *app) { if (GetAccountID() == 0) { - Log.Out(Logs::Detail, Logs::World_Server,"Name approval request with no logged in account"); + Log(Logs::Detail, Logs::World_Server,"Name approval request with no logged in account"); return false; } @@ -513,7 +515,7 @@ bool Client::HandleNameApprovalPacket(const EQApplicationPacket *app) uchar race = app->pBuffer[64]; uchar clas = app->pBuffer[68]; - Log.Out(Logs::Detail, Logs::World_Server, "Name approval request. Name=%s, race=%s, class=%s", char_name, GetRaceIDName(race), GetClassIDName(clas)); + Log(Logs::Detail, Logs::World_Server, "Name approval request. Name=%s, race=%s, class=%s", char_name, GetRaceIDName(race), GetClassIDName(clas)); EQApplicationPacket *outapp; outapp = new EQApplicationPacket; @@ -674,11 +676,11 @@ bool Client::HandleCharacterCreateRequestPacket(const EQApplicationPacket *app) bool Client::HandleCharacterCreatePacket(const EQApplicationPacket *app) { if (GetAccountID() == 0) { - Log.Out(Logs::Detail, Logs::World_Server,"Account ID not set; unable to create character."); + Log(Logs::Detail, Logs::World_Server,"Account ID not set; unable to create character."); return false; } else if (app->size != sizeof(CharCreate_Struct)) { - Log.Out(Logs::Detail, Logs::World_Server,"Wrong size on OP_CharacterCreate. Got: %d, Expected: %d",app->size,sizeof(CharCreate_Struct)); + Log(Logs::Detail, Logs::World_Server,"Wrong size on OP_CharacterCreate. Got: %d, Expected: %d",app->size,sizeof(CharCreate_Struct)); DumpPacket(app); // the previous behavior was essentially returning true here // but that seems a bit odd to me. @@ -705,14 +707,14 @@ bool Client::HandleCharacterCreatePacket(const EQApplicationPacket *app) { bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) { if (GetAccountID() == 0) { - Log.Out(Logs::Detail, Logs::World_Server,"Enter world with no logged in account"); + Log(Logs::Detail, Logs::World_Server,"Enter world with no logged in account"); eqs->Close(); return true; } if(GetAdmin() < 0) { - Log.Out(Logs::Detail, Logs::World_Server,"Account banned or suspended."); + Log(Logs::Detail, Logs::World_Server,"Account banned or suspended."); eqs->Close(); return true; } @@ -728,14 +730,14 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) { uint32 tmpaccid = 0; charid = database.GetCharacterInfo(char_name, &tmpaccid, &zone_id, &instance_id); if (charid == 0 || tmpaccid != GetAccountID()) { - Log.Out(Logs::Detail, Logs::World_Server,"Could not get CharInfo for '%s'",char_name); + Log(Logs::Detail, Logs::World_Server,"Could not get CharInfo for '%s'",char_name); eqs->Close(); return true; } // Make sure this account owns this character if (tmpaccid != GetAccountID()) { - Log.Out(Logs::Detail, Logs::World_Server,"This account does not own the character named '%s'",char_name); + Log(Logs::Detail, Logs::World_Server,"This account does not own the character named '%s'",char_name); eqs->Close(); return true; } @@ -777,7 +779,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) { zone_id = database.MoveCharacterToBind(charid, 4); } else { - Log.Out(Logs::Detail, Logs::World_Server, "'%s' is trying to go home before they're able...", char_name); + Log(Logs::Detail, Logs::World_Server, "'%s' is trying to go home before they're able...", char_name); database.SetHackerFlag(GetAccountName(), char_name, "MQGoHome: player tried to go home before they were able."); eqs->Close(); return true; @@ -801,7 +803,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) { database.MoveCharacterToZone(charid, database.GetZoneName(zone_id)); } else { - Log.Out(Logs::Detail, Logs::World_Server, "'%s' is trying to go to tutorial but are not allowed...", char_name); + Log(Logs::Detail, Logs::World_Server, "'%s' is trying to go to tutorial but are not allowed...", char_name); database.SetHackerFlag(GetAccountName(), char_name, "MQTutorial: player tried to enter the tutorial without having tutorial enabled for this character."); eqs->Close(); return true; @@ -812,7 +814,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) { if (zone_id == 0 || !database.GetZoneName(zone_id)) { // This is to save people in an invalid zone, once it's removed from the DB database.MoveCharacterToZone(charid, "arena"); - Log.Out(Logs::Detail, Logs::World_Server, "Zone not found in database zone_id=%i, moveing char to arena character:%s", zone_id, char_name); + Log(Logs::Detail, Logs::World_Server, "Zone not found in database zone_id=%i, moveing char to arena character:%s", zone_id, char_name); } if(instance_id > 0) @@ -926,7 +928,7 @@ bool Client::HandleDeleteCharacterPacket(const EQApplicationPacket *app) { uint32 char_acct_id = database.GetAccountIDByChar((char*)app->pBuffer); if(char_acct_id == GetAccountID()) { - Log.Out(Logs::Detail, Logs::World_Server,"Delete character: %s",app->pBuffer); + Log(Logs::Detail, Logs::World_Server,"Delete character: %s",app->pBuffer); database.DeleteCharacter((char *)app->pBuffer); SendCharInfo(); } @@ -947,24 +949,24 @@ bool Client::HandlePacket(const EQApplicationPacket *app) { EmuOpcode opcode = app->GetOpcode(); - Log.Out(Logs::Detail, Logs::World_Server,"Recevied EQApplicationPacket"); + Log(Logs::Detail, Logs::World_Server,"Recevied EQApplicationPacket"); if (!eqs->CheckState(ESTABLISHED)) { - Log.Out(Logs::Detail, Logs::World_Server,"Client disconnected (net inactive on send)"); + Log(Logs::Detail, Logs::World_Server,"Client disconnected (net inactive on send)"); return false; } // Voidd: Anti-GM Account hack, Checks source ip against valid GM Account IP Addresses if (RuleB(World, GMAccountIPList) && this->GetAdmin() >= (RuleI(World, MinGMAntiHackStatus))) { if(!database.CheckGMIPs(long2ip(this->GetIP()).c_str(), this->GetAccountID())) { - Log.Out(Logs::Detail, Logs::World_Server,"GM Account not permited from source address %s and accountid %i", long2ip(this->GetIP()).c_str(), this->GetAccountID()); + Log(Logs::Detail, Logs::World_Server,"GM Account not permited from source address %s and accountid %i", long2ip(this->GetIP()).c_str(), this->GetAccountID()); eqs->Close(); } } if (GetAccountID() == 0 && opcode != OP_SendLoginInfo) { // Got a packet other than OP_SendLoginInfo when not logged in - Log.Out(Logs::Detail, Logs::World_Server,"Expecting OP_SendLoginInfo, got %s", OpcodeNames[opcode]); + Log(Logs::Detail, Logs::World_Server,"Expecting OP_SendLoginInfo, got %s", OpcodeNames[opcode]); return false; } else if (opcode == OP_AckPacket) { @@ -1042,7 +1044,7 @@ bool Client::HandlePacket(const EQApplicationPacket *app) { } default: { - Log.Out(Logs::Detail, Logs::World_Server,"Received unknown EQApplicationPacket"); + Log(Logs::Detail, Logs::World_Server,"Received unknown EQApplicationPacket"); return true; } } @@ -1060,7 +1062,7 @@ bool Client::Process() { to.sin_addr.s_addr = ip; if (autobootup_timeout.Check()) { - Log.Out(Logs::General, Logs::World_Server, "Zone bootup timer expired, bootup failed or too slow."); + Log(Logs::General, Logs::World_Server, "Zone bootup timer expired, bootup failed or too slow."); TellClientZoneUnavailable(); } if(connect.Check()){ @@ -1094,7 +1096,7 @@ bool Client::Process() { loginserverlist.SendPacket(pack); safe_delete(pack); } - Log.Out(Logs::Detail, Logs::World_Server,"Client disconnected (not active in process)"); + Log(Logs::Detail, Logs::World_Server,"Client disconnected (not active in process)"); return false; } @@ -1143,17 +1145,17 @@ void Client::EnterWorld(bool TryBootup) { } else { if (TryBootup) { - Log.Out(Logs::General, Logs::World_Server, "Attempting autobootup of %s (%d:%d)", zone_name, zone_id, instance_id); + Log(Logs::General, Logs::World_Server, "Attempting autobootup of %s (%d:%d)", zone_name, zone_id, instance_id); autobootup_timeout.Start(); zone_waiting_for_bootup = zoneserver_list.TriggerBootup(zone_id, instance_id); if (zone_waiting_for_bootup == 0) { - Log.Out(Logs::General, Logs::World_Server, "No zoneserver available to boot up."); + Log(Logs::General, Logs::World_Server, "No zoneserver available to boot up."); TellClientZoneUnavailable(); } return; } else { - Log.Out(Logs::General, Logs::World_Server, "Requested zone %s is not running.", zone_name); + Log(Logs::General, Logs::World_Server, "Requested zone %s is not running.", zone_name); TellClientZoneUnavailable(); return; } @@ -1167,7 +1169,7 @@ void Client::EnterWorld(bool TryBootup) { cle->SetChar(charid, char_name); database.UpdateLiveChar(char_name, GetAccountID()); - Log.Out(Logs::General, Logs::World_Server, + Log(Logs::General, Logs::World_Server, "(%s) %s %s (Zone ID %d: Instance ID: %d) ", char_name, (seen_character_select ? "Zoning from character select" : "Zoning to"), @@ -1178,7 +1180,7 @@ void Client::EnterWorld(bool TryBootup) { if (seen_character_select) { if (GetAdmin() < 80 && zoneserver_list.IsZoneLocked(zone_id)) { - Log.Out(Logs::General, Logs::World_Server, "Enter world failed. Zone is locked."); + Log(Logs::General, Logs::World_Server, "Enter world failed. Zone is locked."); TellClientZoneUnavailable(); return; } @@ -1216,9 +1218,9 @@ void Client::Clearance(int8 response) { if (zs == 0) { - Log.Out(Logs::Detail, Logs::World_Server,"Unable to find zoneserver in Client::Clearance!!"); + Log(Logs::Detail, Logs::World_Server,"Unable to find zoneserver in Client::Clearance!!"); } else { - Log.Out(Logs::Detail, Logs::World_Server, "Invalid response %d in Client::Clearance", response); + Log(Logs::Detail, Logs::World_Server, "Invalid response %d in Client::Clearance", response); } TellClientZoneUnavailable(); @@ -1228,20 +1230,20 @@ void Client::Clearance(int8 response) EQApplicationPacket* outapp; if (zs->GetCAddress() == nullptr) { - Log.Out(Logs::Detail, Logs::World_Server, "Unable to do zs->GetCAddress() in Client::Clearance!!"); + Log(Logs::Detail, Logs::World_Server, "Unable to do zs->GetCAddress() in Client::Clearance!!"); TellClientZoneUnavailable(); return; } if (zone_id == 0) { - Log.Out(Logs::Detail, Logs::World_Server, "zoneID is nullptr in Client::Clearance!!"); + Log(Logs::Detail, Logs::World_Server, "zoneID is nullptr in Client::Clearance!!"); TellClientZoneUnavailable(); return; } const char* zonename = database.GetZoneName(zone_id); if (zonename == 0) { - Log.Out(Logs::Detail, Logs::World_Server, "zonename is nullptr in Client::Clearance!!"); + Log(Logs::Detail, Logs::World_Server, "zonename is nullptr in Client::Clearance!!"); TellClientZoneUnavailable(); return; } @@ -1259,10 +1261,10 @@ void Client::Clearance(int8 response) } else { if(strcmp(zs->GetIP().c_str(), "127.0.0.1") == 0) { - Log.Out(Logs::Detail, Logs::World_Server, "Local zone address was %s, setting local address to: %s", zs_addr, WorldConfig::get()->LocalAddress.c_str()); + Log(Logs::Detail, Logs::World_Server, "Local zone address was %s, setting local address to: %s", zs_addr, WorldConfig::get()->LocalAddress.c_str()); zs_addr = WorldConfig::get()->LocalAddress.c_str(); } else { - Log.Out(Logs::Detail, Logs::World_Server, "Local zone address %s", zs_addr); + Log(Logs::Detail, Logs::World_Server, "Local zone address %s", zs_addr); } } @@ -1277,7 +1279,7 @@ void Client::Clearance(int8 response) strcpy(zsi->ip, zs_addr); zsi->port =zs->GetCPort(); - Log.Out(Logs::Detail, Logs::World_Server,"Sending client to zone %s (%d:%d) at %s:%d",zonename,zone_id,instance_id,zsi->ip,zsi->port); + Log(Logs::Detail, Logs::World_Server,"Sending client to zone %s (%d:%d) at %s:%d",zonename,zone_id,instance_id,zsi->ip,zsi->port); QueuePacket(outapp); safe_delete(outapp); @@ -1308,7 +1310,7 @@ bool Client::GenPassKey(char* key) { } void Client::QueuePacket(const EQApplicationPacket* app, bool ack_req) { - Log.Out(Logs::Detail, Logs::World_Server, "Sending EQApplicationPacket OpCode 0x%04x",app->GetOpcode()); + Log(Logs::Detail, Logs::World_Server, "Sending EQApplicationPacket OpCode 0x%04x",app->GetOpcode()); ack_req = true; // It's broke right now, dont delete this line till fix it. =P eqs->QueuePacket(app, ack_req); @@ -1391,27 +1393,27 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) in.s_addr = GetIP(); - Log.Out(Logs::Detail, Logs::World_Server, "Character creation request from %s LS#%d (%s:%d) : ", GetCLE()->LSName(), GetCLE()->LSID(), inet_ntoa(in), GetPort()); - Log.Out(Logs::Detail, Logs::World_Server, "Name: %s", name); - Log.Out(Logs::Detail, Logs::World_Server, "Race: %d Class: %d Gender: %d Deity: %d Start zone: %d Tutorial: %s", + Log(Logs::Detail, Logs::World_Server, "Character creation request from %s LS#%d (%s:%d) : ", GetCLE()->LSName(), GetCLE()->LSID(), inet_ntoa(in), GetPort()); + Log(Logs::Detail, Logs::World_Server, "Name: %s", name); + Log(Logs::Detail, Logs::World_Server, "Race: %d Class: %d Gender: %d Deity: %d Start zone: %d Tutorial: %s", cc->race, cc->class_, cc->gender, cc->deity, cc->start_zone, cc->tutorial ? "true" : "false"); - Log.Out(Logs::Detail, Logs::World_Server, "STR STA AGI DEX WIS INT CHA Total"); - Log.Out(Logs::Detail, Logs::World_Server, "%3d %3d %3d %3d %3d %3d %3d %3d", + Log(Logs::Detail, Logs::World_Server, "STR STA AGI DEX WIS INT CHA Total"); + Log(Logs::Detail, Logs::World_Server, "%3d %3d %3d %3d %3d %3d %3d %3d", cc->STR, cc->STA, cc->AGI, cc->DEX, cc->WIS, cc->INT, cc->CHA, stats_sum); - Log.Out(Logs::Detail, Logs::World_Server, "Face: %d Eye colors: %d %d", cc->face, cc->eyecolor1, cc->eyecolor2); - Log.Out(Logs::Detail, Logs::World_Server, "Hairstyle: %d Haircolor: %d", cc->hairstyle, cc->haircolor); - Log.Out(Logs::Detail, Logs::World_Server, "Beard: %d Beardcolor: %d", cc->beard, cc->beardcolor); + Log(Logs::Detail, Logs::World_Server, "Face: %d Eye colors: %d %d", cc->face, cc->eyecolor1, cc->eyecolor2); + Log(Logs::Detail, Logs::World_Server, "Hairstyle: %d Haircolor: %d", cc->hairstyle, cc->haircolor); + Log(Logs::Detail, Logs::World_Server, "Beard: %d Beardcolor: %d", cc->beard, cc->beardcolor); /* Validate the char creation struct */ if (m_ClientVersionBit & EQEmu::versions::bit_SoFAndLater) { if (!CheckCharCreateInfoSoF(cc)) { - Log.Out(Logs::Detail, Logs::World_Server,"CheckCharCreateInfo did not validate the request (bad race/class/stats)"); + Log(Logs::Detail, Logs::World_Server,"CheckCharCreateInfo did not validate the request (bad race/class/stats)"); return false; } } else { if (!CheckCharCreateInfoTitanium(cc)) { - Log.Out(Logs::Detail, Logs::World_Server,"CheckCharCreateInfo did not validate the request (bad race/class/stats)"); + Log(Logs::Detail, Logs::World_Server,"CheckCharCreateInfo did not validate the request (bad race/class/stats)"); return false; } } @@ -1476,14 +1478,14 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) /* If it is an SoF Client and the SoF Start Zone rule is set, send new chars there */ if (m_ClientVersionBit & EQEmu::versions::bit_SoFAndLater) { - Log.Out(Logs::Detail, Logs::World_Server,"Found 'SoFStartZoneID' rule setting: %i", RuleI(World, SoFStartZoneID)); + Log(Logs::Detail, Logs::World_Server,"Found 'SoFStartZoneID' rule setting: %i", RuleI(World, SoFStartZoneID)); if (RuleI(World, SoFStartZoneID) > 0) { pp.zone_id = RuleI(World, SoFStartZoneID); cc->start_zone = pp.zone_id; } } else { - Log.Out(Logs::General, Logs::World_Server, "Found 'TitaniumStartZoneID' rule setting: %i", RuleI(World, TitaniumStartZoneID)); + Log(Logs::General, Logs::World_Server, "Found 'TitaniumStartZoneID' rule setting: %i", RuleI(World, TitaniumStartZoneID)); if (RuleI(World, TitaniumStartZoneID) > 0) { /* if there's a startzone variable put them in there */ pp.zone_id = RuleI(World, TitaniumStartZoneID); @@ -1543,11 +1545,11 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) pp.binds[0].heading = pp.heading; } - Log.Out(Logs::Detail, Logs::World_Server,"Current location: %s (%d) %0.2f, %0.2f, %0.2f, %0.2f", + Log(Logs::Detail, Logs::World_Server,"Current location: %s (%d) %0.2f, %0.2f, %0.2f, %0.2f", database.GetZoneName(pp.zone_id), pp.zone_id, pp.x, pp.y, pp.z, pp.heading); - Log.Out(Logs::Detail, Logs::World_Server,"Bind location: %s (%d) %0.2f, %0.2f, %0.2f", + Log(Logs::Detail, Logs::World_Server,"Bind location: %s (%d) %0.2f, %0.2f, %0.2f", database.GetZoneName(pp.binds[0].zoneId), pp.binds[0].zoneId, pp.binds[0].x, pp.binds[0].y, pp.binds[0].z); - Log.Out(Logs::Detail, Logs::World_Server,"Home location: %s (%d) %0.2f, %0.2f, %0.2f", + Log(Logs::Detail, Logs::World_Server,"Home location: %s (%d) %0.2f, %0.2f, %0.2f", database.GetZoneName(pp.binds[4].zoneId), pp.binds[4].zoneId, pp.binds[4].x, pp.binds[4].y, pp.binds[4].z); /* Starting Items inventory */ @@ -1556,10 +1558,10 @@ bool Client::OPCharCreate(char *name, CharCreate_Struct *cc) // now we give the pp and the inv we made to StoreCharacter // to see if we can store it if (!database.StoreCharacter(GetAccountID(), &pp, &inv)) { - Log.Out(Logs::Detail, Logs::World_Server,"Character creation failed: %s", pp.name); + Log(Logs::Detail, Logs::World_Server,"Character creation failed: %s", pp.name); return false; } - Log.Out(Logs::Detail, Logs::World_Server,"Character creation successful: %s", pp.name); + Log(Logs::Detail, Logs::World_Server,"Character creation successful: %s", pp.name); return true; } @@ -1569,7 +1571,7 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct *cc) if (!cc) return false; - Log.Out(Logs::Detail, Logs::World_Server, "Validating char creation info..."); + Log(Logs::Detail, Logs::World_Server, "Validating char creation info..."); RaceClassCombos class_combo; bool found = false; @@ -1586,7 +1588,7 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct *cc) } if (!found) { - Log.Out(Logs::Detail, Logs::World_Server, "Could not find class/race/deity/start_zone combination"); + Log(Logs::Detail, Logs::World_Server, "Could not find class/race/deity/start_zone combination"); return false; } @@ -1603,7 +1605,7 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct *cc) } if (!found) { - Log.Out(Logs::Detail, Logs::World_Server, "Could not find starting stats for selected character combo, cannot verify stats"); + Log(Logs::Detail, Logs::World_Server, "Could not find starting stats for selected character combo, cannot verify stats"); return false; } @@ -1616,37 +1618,37 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct *cc) allocation.DefaultPointAllocation[6]; if (cc->STR > allocation.BaseStats[0] + max_stats || cc->STR < allocation.BaseStats[0]) { - Log.Out(Logs::Detail, Logs::World_Server, "Strength out of range"); + Log(Logs::Detail, Logs::World_Server, "Strength out of range"); return false; } if (cc->DEX > allocation.BaseStats[1] + max_stats || cc->DEX < allocation.BaseStats[1]) { - Log.Out(Logs::Detail, Logs::World_Server, "Dexterity out of range"); + Log(Logs::Detail, Logs::World_Server, "Dexterity out of range"); return false; } if (cc->AGI > allocation.BaseStats[2] + max_stats || cc->AGI < allocation.BaseStats[2]) { - Log.Out(Logs::Detail, Logs::World_Server, "Agility out of range"); + Log(Logs::Detail, Logs::World_Server, "Agility out of range"); return false; } if (cc->STA > allocation.BaseStats[3] + max_stats || cc->STA < allocation.BaseStats[3]) { - Log.Out(Logs::Detail, Logs::World_Server, "Stamina out of range"); + Log(Logs::Detail, Logs::World_Server, "Stamina out of range"); return false; } if (cc->INT > allocation.BaseStats[4] + max_stats || cc->INT < allocation.BaseStats[4]) { - Log.Out(Logs::Detail, Logs::World_Server, "Intelligence out of range"); + Log(Logs::Detail, Logs::World_Server, "Intelligence out of range"); return false; } if (cc->WIS > allocation.BaseStats[5] + max_stats || cc->WIS < allocation.BaseStats[5]) { - Log.Out(Logs::Detail, Logs::World_Server, "Wisdom out of range"); + Log(Logs::Detail, Logs::World_Server, "Wisdom out of range"); return false; } if (cc->CHA > allocation.BaseStats[6] + max_stats || cc->CHA < allocation.BaseStats[6]) { - Log.Out(Logs::Detail, Logs::World_Server, "Charisma out of range"); + Log(Logs::Detail, Logs::World_Server, "Charisma out of range"); return false; } @@ -1659,7 +1661,7 @@ bool CheckCharCreateInfoSoF(CharCreate_Struct *cc) current_stats += cc->WIS - allocation.BaseStats[5]; current_stats += cc->CHA - allocation.BaseStats[6]; if (current_stats > max_stats) { - Log.Out(Logs::Detail, Logs::World_Server, "Current Stats > Maximum Stats"); + Log(Logs::Detail, Logs::World_Server, "Current Stats > Maximum Stats"); return false; } @@ -1740,7 +1742,7 @@ bool CheckCharCreateInfoTitanium(CharCreate_Struct *cc) if (!cc) return false; - Log.Out(Logs::Detail, Logs::World_Server,"Validating char creation info..."); + Log(Logs::Detail, Logs::World_Server,"Validating char creation info..."); classtemp = cc->class_ - 1; racetemp = cc->race - 1; @@ -1753,16 +1755,16 @@ bool CheckCharCreateInfoTitanium(CharCreate_Struct *cc) // if out of range looking it up in the table would crash stuff // so we return from these if (classtemp >= PLAYER_CLASS_COUNT) { - Log.Out(Logs::Detail, Logs::World_Server," class is out of range"); + Log(Logs::Detail, Logs::World_Server," class is out of range"); return false; } if (racetemp >= _TABLE_RACES) { - Log.Out(Logs::Detail, Logs::World_Server," race is out of range"); + Log(Logs::Detail, Logs::World_Server," race is out of range"); return false; } if (!ClassRaceLookupTable[classtemp][racetemp]) { //Lookup table better than a bunch of ifs? - Log.Out(Logs::Detail, Logs::World_Server," invalid race/class combination"); + Log(Logs::Detail, Logs::World_Server," invalid race/class combination"); // we return from this one, since if it's an invalid combination our table // doesn't have meaningful values for the stats return false; @@ -1790,43 +1792,43 @@ bool CheckCharCreateInfoTitanium(CharCreate_Struct *cc) // that are messed up not just the first hit if (bTOTAL + stat_points != cTOTAL) { - Log.Out(Logs::Detail, Logs::World_Server," stat points total doesn't match expected value: expecting %d got %d", bTOTAL + stat_points, cTOTAL); + Log(Logs::Detail, Logs::World_Server," stat points total doesn't match expected value: expecting %d got %d", bTOTAL + stat_points, cTOTAL); Charerrors++; } if (cc->STR > bSTR + stat_points || cc->STR < bSTR) { - Log.Out(Logs::Detail, Logs::World_Server," stat STR is out of range"); + Log(Logs::Detail, Logs::World_Server," stat STR is out of range"); Charerrors++; } if (cc->STA > bSTA + stat_points || cc->STA < bSTA) { - Log.Out(Logs::Detail, Logs::World_Server," stat STA is out of range"); + Log(Logs::Detail, Logs::World_Server," stat STA is out of range"); Charerrors++; } if (cc->AGI > bAGI + stat_points || cc->AGI < bAGI) { - Log.Out(Logs::Detail, Logs::World_Server," stat AGI is out of range"); + Log(Logs::Detail, Logs::World_Server," stat AGI is out of range"); Charerrors++; } if (cc->DEX > bDEX + stat_points || cc->DEX < bDEX) { - Log.Out(Logs::Detail, Logs::World_Server," stat DEX is out of range"); + Log(Logs::Detail, Logs::World_Server," stat DEX is out of range"); Charerrors++; } if (cc->WIS > bWIS + stat_points || cc->WIS < bWIS) { - Log.Out(Logs::Detail, Logs::World_Server," stat WIS is out of range"); + Log(Logs::Detail, Logs::World_Server," stat WIS is out of range"); Charerrors++; } if (cc->INT > bINT + stat_points || cc->INT < bINT) { - Log.Out(Logs::Detail, Logs::World_Server," stat INT is out of range"); + Log(Logs::Detail, Logs::World_Server," stat INT is out of range"); Charerrors++; } if (cc->CHA > bCHA + stat_points || cc->CHA < bCHA) { - Log.Out(Logs::Detail, Logs::World_Server," stat CHA is out of range"); + Log(Logs::Detail, Logs::World_Server," stat CHA is out of range"); Charerrors++; } /*TODO: Check for deity/class/race.. it'd be nice, but probably of any real use to hack(faction, deity based items are all I can think of) I am NOT writing those tables - kathgar*/ - Log.Out(Logs::Detail, Logs::World_Server,"Found %d errors in character creation request", Charerrors); + Log(Logs::Detail, Logs::World_Server,"Found %d errors in character creation request", Charerrors); return Charerrors == 0; } diff --git a/world/cliententry.cpp b/world/cliententry.cpp index 3caa08ad7..be8916676 100644 --- a/world/cliententry.cpp +++ b/world/cliententry.cpp @@ -283,7 +283,7 @@ bool ClientListEntry::CheckAuth(uint32 iLSID, const char* iKey) { int16 tmpStatus = WorldConfig::get()->DefaultStatus; paccountid = database.CreateAccount(plsname, 0, tmpStatus, LSID()); if (!paccountid) { - Log.Out(Logs::Detail, Logs::World_Server,"Error adding local account for LS login: '%s', duplicate name?" ,plsname); + Log(Logs::Detail, Logs::World_Server,"Error adding local account for LS login: '%s', duplicate name?" ,plsname); return false; } strn0cpy(paccountname, plsname, sizeof(paccountname)); diff --git a/world/clientlist.cpp b/world/clientlist.cpp index 926e1de36..e7a3918f0 100644 --- a/world/clientlist.cpp +++ b/world/clientlist.cpp @@ -63,7 +63,7 @@ void ClientList::Process() { if (!iterator.GetData()->Process()) { struct in_addr in; in.s_addr = iterator.GetData()->GetIP(); - Log.Out(Logs::Detail, Logs::World_Server,"Removing client from %s:%d", inet_ntoa(in), iterator.GetData()->GetPort()); + Log(Logs::Detail, Logs::World_Server,"Removing client from %s:%d", inet_ntoa(in), iterator.GetData()->GetPort()); //the client destructor should take care of this. // iterator.GetData()->Free(); iterator.RemoveCurrent(); @@ -158,16 +158,16 @@ void ClientList::GetCLEIP(uint32 iIP) { countCLEIPs = iterator.GetData(); if ((countCLEIPs->GetIP() == iIP) && ((countCLEIPs->Admin() < (RuleI(World, ExemptMaxClientsStatus))) || (RuleI(World, ExemptMaxClientsStatus) < 0))) { // If the IP matches, and the connection admin status is below the exempt status, or exempt status is less than 0 (no-one is exempt) IPInstances++; // Increment the occurences of this IP address - Log.Out(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s.", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); + Log(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s.", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); if (RuleB(World, EnableIPExemptions)) { - Log.Out(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s IP Instances: %i Max IP Instances: %i", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, database.GetIPExemption(long2ip(countCLEIPs->GetIP()).c_str())); + Log(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s IP Instances: %i Max IP Instances: %i", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, database.GetIPExemption(long2ip(countCLEIPs->GetIP()).c_str())); if (IPInstances > database.GetIPExemption(long2ip(countCLEIPs->GetIP()).c_str())) { if(RuleB(World, IPLimitDisconnectAll)) { - Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str()); + Log(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str()); DisconnectByIP(iIP); return; } else { - Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); + Log(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); countCLEIPs->SetOnline(CLE_Status_Offline); iterator.RemoveCurrent(); continue; @@ -176,14 +176,14 @@ void ClientList::GetCLEIP(uint32 iIP) { } else { if (IPInstances > (RuleI(World, MaxClientsPerIP))) { // If the number of connections exceeds the lower limit if (RuleB(World, MaxClientsSetByStatus)) { // If MaxClientsSetByStatus is set to True, override other IP Limit Rules - Log.Out(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s IP Instances: %i Max IP Instances: %i", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, countCLEIPs->Admin()); + Log(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s IP Instances: %i Max IP Instances: %i", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, countCLEIPs->Admin()); if (IPInstances > countCLEIPs->Admin()) { // The IP Limit is set by the status of the account if status > MaxClientsPerIP if(RuleB(World, IPLimitDisconnectAll)) { - Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str()); + Log(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str()); DisconnectByIP(iIP); return; } else { - Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); + Log(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); countCLEIPs->SetOnline(CLE_Status_Offline); // Remove the connection iterator.RemoveCurrent(); continue; @@ -191,22 +191,22 @@ void ClientList::GetCLEIP(uint32 iIP) { } } else if ((countCLEIPs->Admin() < RuleI(World, AddMaxClientsStatus)) || (RuleI(World, AddMaxClientsStatus) < 0)) { // Else if the Admin status of the connection is not eligible for the higher limit, or there is no higher limit (AddMaxClientStatus < 0) if(RuleB(World, IPLimitDisconnectAll)) { - Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str()); + Log(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str()); DisconnectByIP(iIP); return; } else { - Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); + Log(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); countCLEIPs->SetOnline(CLE_Status_Offline); // Remove the connection iterator.RemoveCurrent(); continue; } } else if (IPInstances > RuleI(World, AddMaxClientsPerIP)) { // else they are eligible for the higher limit, but if they exceed that if(RuleB(World, IPLimitDisconnectAll)) { - Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str()); + Log(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str()); DisconnectByIP(iIP); return; } else { - Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); + Log(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str()); countCLEIPs->SetOnline(CLE_Status_Offline); // Remove the connection iterator.RemoveCurrent(); continue; @@ -468,7 +468,7 @@ void ClientList::SendOnlineGuildMembers(uint32 FromID, uint32 GuildID) if(!from) { - Log.Out(Logs::Detail, Logs::World_Server,"Invalid client. FromID=%i GuildID=%i", FromID, GuildID); + Log(Logs::Detail, Logs::World_Server,"Invalid client. FromID=%i GuildID=%i", FromID, GuildID); return; } @@ -771,7 +771,7 @@ void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_S safe_delete_array(output); } catch(...){ - Log.Out(Logs::Detail, Logs::World_Server,"Unknown error in world's SendWhoAll (probably mem error), ignoring..."); + Log(Logs::Detail, Logs::World_Server,"Unknown error in world's SendWhoAll (probably mem error), ignoring..."); return; } } @@ -914,7 +914,7 @@ void ClientList::SendFriendsWho(ServerFriendsWho_Struct *FriendsWho, WorldTCPCon safe_delete(pack2); } catch(...){ - Log.Out(Logs::Detail, Logs::World_Server,"Unknown error in world's SendFriendsWho (probably mem error), ignoring..."); + Log(Logs::Detail, Logs::World_Server,"Unknown error in world's SendFriendsWho (probably mem error), ignoring..."); return; } } @@ -1147,7 +1147,7 @@ Client* ClientList::FindByAccountID(uint32 account_id) { iterator.Reset(); while(iterator.MoreElements()) { - Log.Out(Logs::Detail, Logs::World_Server, "ClientList[0x%08x]::FindByAccountID(%p) iterator.GetData()[%p]", this, account_id, iterator.GetData()); + Log(Logs::Detail, Logs::World_Server, "ClientList[0x%08x]::FindByAccountID(%p) iterator.GetData()[%p]", this, account_id, iterator.GetData()); if (iterator.GetData()->GetAccountID() == account_id) { Client* tmp = iterator.GetData(); return tmp; @@ -1162,7 +1162,7 @@ Client* ClientList::FindByName(char* charname) { iterator.Reset(); while(iterator.MoreElements()) { - Log.Out(Logs::Detail, Logs::World_Server, "ClientList[0x%08x]::FindByName(\"%s\") iterator.GetData()[%p]", this, charname, iterator.GetData()); + Log(Logs::Detail, Logs::World_Server, "ClientList[0x%08x]::FindByName(\"%s\") iterator.GetData()[%p]", this, charname, iterator.GetData()); if (iterator.GetData()->GetCharName() == charname) { Client* tmp = iterator.GetData(); return tmp; diff --git a/world/console.cpp b/world/console.cpp new file mode 100644 index 000000000..fa5ca0ffe --- /dev/null +++ b/world/console.cpp @@ -0,0 +1,890 @@ +/* EQEMu: Everquest Server Emulator + Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#include "../common/global_define.h" +#include +#include +#include +#include +#include + + +#include "../common/version.h" +#include "console.h" +#include "zoneserver.h" +#include "worlddb.h" +#include "../common/packet_dump.h" +#include "../common/seperator.h" +#include "../common/eq_packet_structs.h" +#include "../common/eq_packet.h" +#include "login_server.h" +#include "login_server_list.h" +#include "../common/serverinfo.h" +#include "../common/md5.h" +#include "../common/opcodemgr.h" +#include "../common/rulesys.h" +#include "../common/ruletypes.h" +#include "../common/string_util.h" +#include "world_config.h" +#include "zoneserver.h" +#include "zonelist.h" +#include "clientlist.h" +#include "launcher_list.h" +#include "ucs.h" +#include "queryserv.h" + +#ifdef _WINDOWS + #define snprintf _snprintf + #define strncasecmp _strnicmp + #define strcasecmp _stricmp +#endif + +extern ZSList zoneserver_list; +extern uint32 numzones; +extern LoginServerList loginserverlist; +extern ClientList client_list; +extern LauncherList launcher_list; +extern UCSConnection UCSLink; +extern QueryServConnection QSLink; +extern volatile bool RunLoops; + +ConsoleList console_list; +void CatchSignal(int sig_num); + +Console::Console(EmuTCPConnection* itcpc) +: WorldTCPConnection(), + timeout_timer(RuleI(Console, SessionTimeOut)), + prompt_timer(1) +{ + tcpc = itcpc; + tcpc->SetEcho(true); + state = 0; + paccountid = 0; + memset(paccountname, 0, sizeof(paccountname)); + admin = 0; + pAcceptMessages = false; +} + +Console::~Console() { + if (tcpc) + tcpc->Free(); +} + +void Console::Die() { + state = CONSOLE_STATE_CLOSED; + struct in_addr in; + in.s_addr = GetIP(); + Log(Logs::Detail, Logs::World_Server,"Removing console from %s:%d",inet_ntoa(in),GetPort()); + tcpc->Disconnect(); +} + +bool Console::SendChannelMessage(const ServerChannelMessage_Struct* scm) { + if (!pAcceptMessages) + return false; + switch (scm->chan_num) { + if(RuleB(Chat, ServerWideAuction)){ + case 4: { + SendMessage(1, "%s auctions, '%s'", scm->from, scm->message); + break; + } + } + if(RuleB(Chat, ServerWideOOC)){ + case 5: { + SendMessage(1, "%s says ooc, '%s'", scm->from, scm->message); + break; + } + } + case 6: { + SendMessage(1, "%s BROADCASTS, '%s'", scm->from, scm->message); + break; + } + case 7: { + SendMessage(1, "[%s] tells you, '%s'", scm->from, scm->message); + auto pack = new ServerPacket(ServerOP_ChannelMessage, + sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1); + memcpy(pack->pBuffer, scm, pack->size); + ServerChannelMessage_Struct* scm2 = (ServerChannelMessage_Struct*) pack->pBuffer; + strcpy(scm2->deliverto, scm2->from); + scm2->noreply = true; + client_list.SendPacket(scm->from, pack); + safe_delete(pack); + break; + } + case 11: { + SendMessage(1, "%s GMSAYS, '%s'", scm->from, scm->message); + break; + } + default: { + return false; + } + } + return true; +} + +bool Console::SendEmoteMessage(uint32 type, const char* message, ...) { + if (!message) + return false; + if (!pAcceptMessages) + return false; + va_list argptr; + char buffer[1024]; + + va_start(argptr, message); + vsnprintf(buffer, sizeof(buffer), message, argptr); + va_end(argptr); + + SendMessage(1, message); + return true; +} + +bool Console::SendEmoteMessageRaw(uint32 type, const char* message) { + if (!message) + return false; + if (!pAcceptMessages) + return false; + SendMessage(1, message); + return true; +} + +void Console::SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message, ...) { + if (!message) + return; + if (to_guilddbid != 0 || to_minstatus > Admin()) + return; + va_list argptr; + char buffer[1024]; + + va_start(argptr, message); + vsnprintf(buffer, sizeof(buffer), message, argptr); + va_end(argptr); + + SendEmoteMessageRaw(to, to_guilddbid, to_minstatus, type, buffer); +} + +void Console::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message) { + if (!message) + return; + if (to_guilddbid != 0 || to_minstatus > Admin()) + return; + SendMessage(1, message); +} + +void Console::SendMessage(uint8 newline, const char* message, ...) { + if (!message) + return; + char* buffer = 0; + uint32 bufsize = 1500; + if (message) + bufsize += strlen(message); + buffer = new char[bufsize]; + memset(buffer, 0, bufsize); + if (message != 0) { + va_list argptr; + + va_start(argptr, message); + vsnprintf(buffer, bufsize - 512, message, argptr); + va_end(argptr); + } + + if (newline) { + char outbuf[3]; + outbuf[0] = 13; + outbuf[1] = 10; + outbuf[2] = 0; + for (int i=0; i < newline; i++) + strcat(buffer, outbuf); + } + tcpc->Send((uchar*) buffer, strlen(buffer)); + safe_delete_array(buffer); +} + +bool Console::Process() { + if (state == CONSOLE_STATE_CLOSED) + return false; + + if (!tcpc->Connected()) { + struct in_addr in; + in.s_addr = GetIP(); + Log(Logs::Detail, Logs::World_Server,"Removing console (!tcpc->Connected) from %s:%d",inet_ntoa(in),GetPort()); + return false; + } + //if we have not gotten the special markers after this timer, send login prompt + if(prompt_timer.Check()) { + struct in_addr in; + in.s_addr = GetIP(); + + std::string connecting_ip = inet_ntoa(in); + + SendMessage(2, StringFormat("Establishing connection from IP: %s Port: %d", inet_ntoa(in), GetPort()).c_str()); + + if (connecting_ip.find("127.0.0.1") != std::string::npos) { + SendMessage(2, StringFormat("Connecting established from local host, auto assuming admin").c_str()); + state = CONSOLE_STATE_CONNECTED; + tcpc->SetEcho(false); + admin = 255; + SendPrompt(); + } + else { + if (tcpc->GetMode() == EmuTCPConnection::modeConsole) + tcpc->Send((const uchar*) "Username: ", strlen("Username: ")); + } + + prompt_timer.Disable(); + + } + + if (timeout_timer.Check()) { + SendMessage(1, 0); + SendMessage(1, "Timeout, disconnecting..."); + struct in_addr in; + in.s_addr = GetIP(); + Log(Logs::Detail, Logs::World_Server,"TCP connection timeout from %s:%d",inet_ntoa(in),GetPort()); + return false; + } + + if (tcpc->GetMode() == EmuTCPConnection::modePacket) { + struct in_addr in; + in.s_addr = GetIP(); + if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeZone) { + auto zs = new ZoneServer(tcpc); + Log(Logs::Detail, Logs::World_Server,"New zoneserver #%d from %s:%d", zs->GetID(), inet_ntoa(in), GetPort()); + zoneserver_list.Add(zs); + numzones++; + tcpc = 0; + } else if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeLauncher) { + Log(Logs::Detail, Logs::World_Server,"New launcher from %s:%d", inet_ntoa(in), GetPort()); + launcher_list.Add(tcpc); + tcpc = 0; + } + else if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeUCS) + { + Log(Logs::Detail, Logs::World_Server,"New UCS Connection from %s:%d", inet_ntoa(in), GetPort()); + UCSLink.SetConnection(tcpc); + tcpc = 0; + } + else if(tcpc->GetPacketMode() == EmuTCPConnection::packetModeQueryServ) + { + Log(Logs::Detail, Logs::World_Server,"New QS Connection from %s:%d", inet_ntoa(in), GetPort()); + QSLink.SetConnection(tcpc); + tcpc = 0; + } + else { + Log(Logs::Detail, Logs::World_Server,"Unsupported packet mode from %s:%d", inet_ntoa(in), GetPort()); + } + return false; + } + char* command = 0; + while ((command = tcpc->PopLine())) { + timeout_timer.Start(); + ProcessCommand(command); + delete command; + } + return true; +} + +void ConsoleList::Add(Console* con) { + list.Insert(con); +} + +void ConsoleList::Process() { + LinkedListIterator iterator(list); + iterator.Reset(); + + while(iterator.MoreElements()) { + if (!iterator.GetData()->Process()) + iterator.RemoveCurrent(); + else + iterator.Advance(); + } +} + +void ConsoleList::KillAll() { + LinkedListIterator iterator(list); + iterator.Reset(); + + while(iterator.MoreElements()) { + iterator.GetData()->Die(); + iterator.RemoveCurrent(); + } +} + +void ConsoleList::SendConsoleWho(WorldTCPConnection* connection, const char* to, int16 admin, char** output, uint32* outsize, uint32* outlen) { + LinkedListIterator iterator(list); + iterator.Reset(); + struct in_addr in; + int x = 0; + + while(iterator.MoreElements()) { + in.s_addr = iterator.GetData()->GetIP(); + if (admin >= iterator.GetData()->Admin()) + AppendAnyLenString(output, outsize, outlen, " Console: %s:%i AccID: %i AccName: %s", inet_ntoa(in), iterator.GetData()->GetPort(), iterator.GetData()->AccountID(), iterator.GetData()->AccountName()); + else + AppendAnyLenString(output, outsize, outlen, " Console: AccID: %i AccName: %s", iterator.GetData()->AccountID(), iterator.GetData()->AccountName()); + if (*outlen >= 3584) { + connection->SendEmoteMessageRaw(to, 0, 0, 10, *output); + safe_delete(*output); + *outsize = 0; + *outlen = 0; + } + else { + if (connection->IsConsole()) + AppendAnyLenString(output, outsize, outlen, "\r\n"); + else + AppendAnyLenString(output, outsize, outlen, "\n"); + } + x++; + iterator.Advance(); + } + AppendAnyLenString(output, outsize, outlen, "%i consoles connected", x); +} + +void ConsoleList::SendChannelMessage(const ServerChannelMessage_Struct* scm) { + LinkedListIterator iterator(list); + iterator.Reset(); + + while(iterator.MoreElements()) { + iterator.GetData()->SendChannelMessage(scm); + iterator.Advance(); + } +} + +void ConsoleList::SendEmoteMessage(uint32 type, const char* message, ...) { + va_list argptr; + char buffer[1024]; + + va_start(argptr, message); + vsnprintf(buffer, sizeof(buffer), message, argptr); + va_end(argptr); + + SendEmoteMessageRaw(type, buffer); +} + +void ConsoleList::SendEmoteMessageRaw(uint32 type, const char* message) { + LinkedListIterator iterator(list); + iterator.Reset(); + + while(iterator.MoreElements()) { + iterator.GetData()->SendEmoteMessageRaw(type, message); + iterator.Advance(); + } +} + +Console* ConsoleList::FindByAccountName(const char* accname) { + LinkedListIterator iterator(list); + iterator.Reset(); + + while(iterator.MoreElements()) { + if (strcasecmp(iterator.GetData()->AccountName(), accname) == 0) + return iterator.GetData(); + + iterator.Advance(); + } + return 0; +} + +void Console::ProcessCommand(const char* command) { + switch(state) + { + case CONSOLE_STATE_USERNAME: + { + if (strlen(command) >= 16) { + SendMessage(1, 0); + SendMessage(2, "Username buffer overflow."); + SendMessage(1, "Bye Bye."); + state = CONSOLE_STATE_CLOSED; + return; + } + strcpy(paccountname, command); + state = CONSOLE_STATE_PASSWORD; + SendMessage(0, "Password: "); + tcpc->SetEcho(false); + break; + } + case CONSOLE_STATE_PASSWORD: + { + if (strlen(command) >= 16) { + SendMessage(1, 0); + SendMessage(2, "Password buffer overflow."); + SendMessage(1, "Bye Bye."); + state = CONSOLE_STATE_CLOSED; + return; + } + paccountid = database.CheckLogin(paccountname ,command); + if (paccountid == 0) { + SendMessage(1, 0); + SendMessage(2, "Login failed."); + SendMessage(1, "Bye Bye."); + state = CONSOLE_STATE_CLOSED; + return; + } + database.GetAccountName(paccountid, paccountname); // fixes case and stuff + admin = database.CheckStatus(paccountid); + if (!(admin >= consoleLoginStatus)) { + SendMessage(1, 0); + SendMessage(2, "Access denied."); + SendMessage(1, "Bye Bye."); + state = CONSOLE_STATE_CLOSED; + return; + } + Log(Logs::Detail, Logs::World_Server,"TCP console authenticated: Username=%s, Admin=%d",paccountname,admin); + SendMessage(1, 0); + SendMessage(2, "Login accepted."); + state = CONSOLE_STATE_CONNECTED; + tcpc->SetEcho(true); + SendPrompt(); + break; + } + case CONSOLE_STATE_CONNECTED: { + Log(Logs::Detail, Logs::World_Server,"TCP command: %s: \"%s\"",paccountname ,command); + Seperator sep(command); + if (strcasecmp(sep.arg[0], "help") == 0 || strcmp(sep.arg[0], "?") == 0) { + SendMessage(1, " whoami"); + SendMessage(1, " who"); + SendMessage(1, " zonestatus"); + SendMessage(1, " uptime [zoneID#]"); + SendMessage(1, " emote [zonename or charname or world] [type] [message]"); + SendMessage(1, " echo [on/off]"); + SendMessage(1, " acceptmessages [on/off]"); + SendMessage(1, " tell [name] [message]"); + SendMessage(1, " broadcast [message]"); + SendMessage(1, " gmsay [message]"); + SendMessage(1, " ooc [message]"); + SendMessage(1, " auction [message]"); + if (admin >= consoleKickStatus) + SendMessage(1, " kick [charname]"); + if (admin >= consoleLockStatus) + SendMessage(1, " lock/unlock"); + if (admin >= consoleZoneStatus) { + SendMessage(1, " zoneshutdown [zonename or ZoneServerID]"); + SendMessage(1, " zonebootup [ZoneServerID] [zonename]"); + SendMessage(1, " zonelock [list|lock|unlock] [zonename]"); + } + if (admin >= consoleFlagStatus) + SendMessage(1, " flag [status] [accountname]"); + if (admin >= consolePassStatus) + SendMessage(1, " setpass [accountname] [newpass]"); + if (admin >= consoleWorldStatus) { + SendMessage(1, " version"); + SendMessage(1, " worldshutdown"); + } + if (admin >= 201) { + SendMessage(1, " IPLookup [name]"); + } + if (admin >= 100) { + SendMessage(1, " LSReconnect"); + SendMessage(1, " signalcharbyname charname ID"); + SendMessage(1, " reloadworld"); + } + } + else if (strcasecmp(sep.arg[0], "ping") == 0) { + // do nothing + } + else if (strcasecmp(sep.arg[0], "signalcharbyname") == 0) { + SendMessage(1, "Signal Sent to %s with ID %i", (char*) sep.arg[1], atoi(sep.arg[2])); + uint32 message_len = strlen((char*) sep.arg[1]) + 1; + auto pack = new ServerPacket(ServerOP_CZSignalClientByName, + sizeof(CZClientSignalByName_Struct) + message_len); + CZClientSignalByName_Struct* CZSC = (CZClientSignalByName_Struct*) pack->pBuffer; + strn0cpy(CZSC->Name, (char*) sep.arg[1], 64); + CZSC->data = atoi(sep.arg[2]); + zoneserver_list.SendPacket(pack); + safe_delete(pack); + } + else if (strcasecmp(sep.arg[0], "setpass") == 0 && admin >= consolePassStatus) { + if (sep.argnum != 2) + SendMessage(1, "Format: setpass accountname password"); + else { + + int16 tmpstatus = 0; + uint32 tmpid = database.GetAccountIDByName(sep.arg[1], &tmpstatus); + if (!tmpid) + SendMessage(1, "Error: Account not found"); + else if (tmpstatus > admin) + SendMessage(1, "Cannot change password: Account's status is higher than yours"); + else if (database.SetLocalPassword(tmpid, sep.arg[2])) + SendMessage(1, "Password changed."); + else + SendMessage(1, "Error changing password."); + } + } + else if (strcasecmp(sep.arg[0], "uptime") == 0) { + if (sep.IsNumber(1) && atoi(sep.arg[1]) > 0) { + auto pack = new ServerPacket(ServerOP_Uptime, sizeof(ServerUptime_Struct)); + ServerUptime_Struct* sus = (ServerUptime_Struct*) pack->pBuffer; + snprintf(sus->adminname, sizeof(sus->adminname), "*%s", this->GetName()); + sus->zoneserverid = atoi(sep.arg[1]); + ZoneServer* zs = zoneserver_list.FindByID(sus->zoneserverid); + if (zs) + zs->SendPacket(pack); + else + SendMessage(1, "Zoneserver not found."); + delete pack; + } + else { + ZSList::ShowUpTime(this); + } + } + else if (strcasecmp(sep.arg[0], "md5") == 0) { + uint8 md5[16]; + MD5::Generate((const uchar*) sep.argplus[1], strlen(sep.argplus[1]), md5); + SendMessage(1, "MD5: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", md5[0], md5[1], md5[2], md5[3], md5[4], md5[5], md5[6], md5[7], md5[8], md5[9], md5[10], md5[11], md5[12], md5[13], md5[14], md5[15]); + } + else if (strcasecmp(sep.arg[0], "whoami") == 0) { + SendMessage(1, "You are logged in as '%s'", this->AccountName()); + SendMessage(1, "You are known as '*%s'", this->AccountName()); + SendMessage(1, "AccessLevel: %d", this->Admin()); + } + else if (strcasecmp(sep.arg[0], "echo") == 0) { + if (strcasecmp(sep.arg[1], "on") == 0) + tcpc->SetEcho(true); + else if (strcasecmp(sep.arg[1], "off") == 0) { + if (pAcceptMessages) + SendMessage(1, "Echo can not be turned off while acceptmessages is on"); + else + tcpc->SetEcho(false); + } + else + SendMessage(1, "Usage: echo [on/off]"); + } + else if (strcasecmp(sep.arg[0], "acceptmessages") == 0) { + if (strcasecmp(sep.arg[1], "on") == 0) + if (tcpc->GetEcho()) + SendMessage(1, "AcceptMessages can not be turned on while echo is on"); + else + pAcceptMessages = true; + else if (strcasecmp(sep.arg[1], "off") == 0) + pAcceptMessages = false; + else + SendMessage(1, "Usage: acceptmessages [on/off]"); + } + else if (strcasecmp(sep.arg[0], "tell") == 0) { + char tmpname[64]; + tmpname[0] = '*'; + strcpy(&tmpname[1], paccountname); + zoneserver_list.SendChannelMessage(tmpname, sep.arg[1], 7, 0, sep.argplus[2]); + } + else if (strcasecmp(sep.arg[0], "broadcast") == 0) { + char tmpname[64]; + tmpname[0] = '*'; + strcpy(&tmpname[1], paccountname); + zoneserver_list.SendChannelMessage(tmpname, 0, 6, 0, sep.argplus[1]); + } + else if (strcasecmp(sep.arg[0], "ooc") == 0) { + char tmpname[64]; + tmpname[0] = '*'; + strcpy(&tmpname[1], paccountname); + zoneserver_list.SendChannelMessage(tmpname, 0, 5, 0, sep.argplus[1]); + } + else if (strcasecmp(sep.arg[0], "auction") == 0) { + char tmpname[64]; + tmpname[0] = '*'; + strcpy(&tmpname[1], paccountname); + zoneserver_list.SendChannelMessage(tmpname, 0, 4, 0, sep.argplus[1]); + } + else if (strcasecmp(sep.arg[0], "gmsay") == 0 || strcasecmp(sep.arg[0], "pr") == 0) { + char tmpname[64]; + tmpname[0] = '*'; + strcpy(&tmpname[1], paccountname); + zoneserver_list.SendChannelMessage(tmpname, 0, 11, 0, sep.argplus[1]); + } + else if (strcasecmp(sep.arg[0], "emote") == 0) { + if (strcasecmp(sep.arg[1], "world") == 0) + zoneserver_list.SendEmoteMessageRaw(0, 0, 0, atoi(sep.arg[2]), sep.argplus[3]); + else { + ZoneServer* zs = zoneserver_list.FindByName(sep.arg[1]); + if (zs != 0) + zs->SendEmoteMessageRaw(0, 0, 0, atoi(sep.arg[2]), sep.argplus[3]); + else + zoneserver_list.SendEmoteMessageRaw(sep.arg[1], 0, 0, atoi(sep.arg[2]), sep.argplus[3]); + } + } + else if (strcasecmp(sep.arg[0], "movechar") == 0) { + if(sep.arg[1][0]==0 || sep.arg[2][0] == 0) + SendMessage(1, "Usage: movechar [charactername] [zonename]"); + else { + if (!database.GetZoneID(sep.arg[2])) + SendMessage(1, "Error: Zone '%s' not found", sep.arg[2]); + else if (!database.CheckUsedName((char*) sep.arg[1])) { + if (!database.MoveCharacterToZone((char*) sep.arg[1], (char*) sep.arg[2])) + SendMessage(1, "Character Move Failed!"); + else + SendMessage(1, "Character has been moved."); + } + else + SendMessage(1, "Character Does Not Exist"); + } + } + else if (strcasecmp(sep.arg[0], "flag") == 0 && this->Admin() >= consoleFlagStatus) { +// SCORPIOUS2K - reversed parameter order for flag + if(sep.arg[2][0]==0 || !sep.IsNumber(1)) + SendMessage(1, "Usage: flag [status] [accountname]"); + else + { + if (atoi(sep.arg[1]) > this->Admin()) + SendMessage(1, "You cannot set people's status to higher than your own"); + else if (atoi(sep.arg[1]) < 0 && this->Admin() < consoleFlagStatus) + SendMessage(1, "You have too low of status to change flags"); + else if (!database.SetAccountStatus(sep.arg[2], atoi(sep.arg[1]))) + SendMessage(1, "Unable to flag account!"); + else + SendMessage(1, "Account Flaged"); + } + } + else if (strcasecmp(sep.arg[0], "kick") == 0 && admin >= consoleKickStatus) { + char tmpname[64]; + tmpname[0] = '*'; + strcpy(&tmpname[1], paccountname); + auto pack = new ServerPacket; + pack->opcode = ServerOP_KickPlayer; + pack->size = sizeof(ServerKickPlayer_Struct); + pack->pBuffer = new uchar[pack->size]; + ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*) pack->pBuffer; + strcpy(skp->adminname, tmpname); + strcpy(skp->name, sep.arg[1]); + skp->adminrank = this->Admin(); + zoneserver_list.SendPacket(pack); + delete pack; + } + else if (strcasecmp(sep.arg[0], "who") == 0) { + auto whom = new Who_All_Struct; + memset(whom, 0, sizeof(Who_All_Struct)); + whom->lvllow = 0xFFFF; + whom->lvlhigh = 0xFFFF; + whom->wclass = 0xFFFF; + whom->wrace = 0xFFFF; + whom->gmlookup = 0xFFFF; + for (int i=1; i<=sep.argnum; i++) { + if (strcasecmp(sep.arg[i], "gm") == 0) + whom->gmlookup = 1; + else if (sep.IsNumber(i)) { + if (whom->lvllow == 0xFFFF) { + whom->lvllow = atoi(sep.arg[i]); + whom->lvlhigh = whom->lvllow; + } + else if (atoi(sep.arg[i]) > int(whom->lvllow)) + whom->lvlhigh = atoi(sep.arg[i]); + else + whom->lvllow = atoi(sep.arg[i]); + } + else + strn0cpy(whom->whom, sep.arg[i], sizeof(whom->whom)); + } + client_list.ConsoleSendWhoAll(0, admin, whom, this); + delete whom; + } + else if (strcasecmp(sep.arg[0], "zonestatus") == 0) { + zoneserver_list.SendZoneStatus(0, admin, this); + } + else if (strcasecmp(sep.arg[0], "exit") == 0 || strcasecmp(sep.arg[0], "quit") == 0) { + SendMessage(1, "Bye Bye."); + state = CONSOLE_STATE_CLOSED; + } + else if (strcasecmp(sep.arg[0], "zoneshutdown") == 0 && admin >= consoleZoneStatus) { + if (sep.arg[1][0] == 0) { + SendMessage(1, "Usage: zoneshutdown zoneshortname"); + } else { + char tmpname[64]; + tmpname[0] = '*'; + strcpy(&tmpname[1], paccountname); + + auto pack = new ServerPacket; + pack->size = sizeof(ServerZoneStateChange_struct); + pack->pBuffer = new uchar[pack->size]; + memset(pack->pBuffer, 0, sizeof(ServerZoneStateChange_struct)); + ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *) pack->pBuffer; + pack->opcode = ServerOP_ZoneShutdown; + strcpy(s->adminname, tmpname); + if (sep.arg[1][0] >= '0' && sep.arg[1][0] <= '9') + s->ZoneServerID = atoi(sep.arg[1]); + else + s->zoneid = database.GetZoneID(sep.arg[1]); + + ZoneServer* zs = 0; + if (s->ZoneServerID != 0) + zs = zoneserver_list.FindByID(s->ZoneServerID); + else if (s->zoneid != 0) + zs = zoneserver_list.FindByName(database.GetZoneName(s->zoneid)); + else + SendMessage(1, "Error: ZoneShutdown: neither ID nor name specified"); + + if (zs == 0) + SendMessage(1, "Error: ZoneShutdown: zoneserver not found"); + else + zs->SendPacket(pack); + + delete pack; + } + } + else if (strcasecmp(sep.arg[0], "zonebootup") == 0 && admin >= consoleZoneStatus) { + if (sep.arg[2][0] == 0 || !sep.IsNumber(1)) { + SendMessage(1, "Usage: zonebootup ZoneServerID# zoneshortname"); + } else { + char tmpname[64]; + tmpname[0] = '*'; + strcpy(&tmpname[1], paccountname); + + Log(Logs::Detail, Logs::World_Server,"Console ZoneBootup: %s, %s, %s",tmpname,sep.arg[2],sep.arg[1]); + zoneserver_list.SOPZoneBootup(tmpname, atoi(sep.arg[1]), sep.arg[2], (bool) (strcasecmp(sep.arg[3], "static") == 0)); + } + } + else if (strcasecmp(sep.arg[0], "worldshutdown") == 0 && admin >= consoleWorldStatus) { + int32 time, interval; + if(sep.IsNumber(1) && sep.IsNumber(2) && ((time=atoi(sep.arg[1]))>0) && ((interval=atoi(sep.arg[2]))>0)) { + zoneserver_list.WorldShutDown(time, interval); + } + else if(strcasecmp(sep.arg[1], "now") == 0) { + zoneserver_list.WorldShutDown(0, 0); + } + else if(strcasecmp(sep.arg[1], "disable") == 0) { + SendEmoteMessage(0,0,0,15,":SYSTEM MSG:World shutdown aborted."); + zoneserver_list.SendEmoteMessage(0,0,0,15,":SYSTEM MSG:World shutdown aborted."); + zoneserver_list.shutdowntimer->Disable(); + zoneserver_list.reminder->Disable(); + } + else { + SendMessage(1, "Usage: worldshutdown [now] [disable] ([time] [interval])"); + //Go ahead and shut down since that's what this used to do when invoked this way. + zoneserver_list.WorldShutDown(0, 0); + } + } + else if (strcasecmp(sep.arg[0], "lock") == 0 && admin >= consoleLockStatus) { + WorldConfig::LockWorld(); + if (loginserverlist.Connected()) { + loginserverlist.SendStatus(); + SendMessage(1, "World locked."); + } + else { + SendMessage(1, "World locked, but login server not connected."); + } + } + else if (strcasecmp(sep.arg[0], "unlock") == 0 && admin >= consoleLockStatus) { + WorldConfig::UnlockWorld(); + if (loginserverlist.Connected()) { + loginserverlist.SendStatus(); + SendMessage(1, "World unlocked."); + } + else { + SendMessage(1, "World unlocked, but login server not connected."); + } + } + else if (strcasecmp(sep.arg[0], "version") == 0 && admin >= consoleWorldStatus) { + SendMessage(1, "Current version information."); + SendMessage(1, " %s", CURRENT_VERSION); + SendMessage(1, " Compiled on: %s at %s", COMPILE_DATE, COMPILE_TIME); + SendMessage(1, " Last modified on: %s", LAST_MODIFIED); + } + else if (strcasecmp(sep.arg[0], "serverinfo") == 0 && admin >= 200) { + if (strcasecmp(sep.arg[1], "os") == 0) { + #ifdef _WINDOWS + GetOS(); + char intbuffer [sizeof(unsigned long)]; + SendMessage(1, "Operating system information."); + SendMessage(1, " %s", Ver_name); + SendMessage(1, " Build number: %s", ultoa(Ver_build, intbuffer, 10)); + SendMessage(1, " Minor version: %s", ultoa(Ver_min, intbuffer, 10)); + SendMessage(1, " Major version: %s", ultoa(Ver_maj, intbuffer, 10)); + SendMessage(1, " Platform Id: %s", ultoa(Ver_pid, intbuffer, 10)); + #else + char os_string[100]; + SendMessage(1, "Operating system information."); + SendMessage(1, " %s", GetOS(os_string)); + #endif + } + else { + SendMessage(1, "Usage: Serverinfo [type]"); + SendMessage(1, " OS - Operating system version information."); + } + } + else if (strcasecmp(sep.arg[0], "IPLookup") == 0 && admin >= 201) { + client_list.SendCLEList(admin, 0, this, sep.argplus[1]); + } + else if (strcasecmp(sep.arg[0], "LSReconnect") == 0 && admin >= 100) { + #ifdef _WINDOWS + _beginthread(AutoInitLoginServer, 0, nullptr); + #else + pthread_t thread; + pthread_create(&thread, nullptr, &AutoInitLoginServer, nullptr); + #endif + RunLoops = true; + SendMessage(1, " Login Server Reconnect manually restarted by Console"); + Log(Logs::Detail, Logs::World_Server,"Login Server Reconnect manually restarted by Console"); + } + else if (strcasecmp(sep.arg[0], "zonelock") == 0 && admin >= consoleZoneStatus) { + if (strcasecmp(sep.arg[1], "list") == 0) { + zoneserver_list.ListLockedZones(0, this); + } + else if (strcasecmp(sep.arg[1], "lock") == 0 && admin >= 101) { + uint16 tmp = database.GetZoneID(sep.arg[2]); + if (tmp) { + if (zoneserver_list.SetLockedZone(tmp, true)) + zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", database.GetZoneName(tmp)); + else + SendMessage(1, "Failed to change lock"); + } + else + SendMessage(1, "Usage: #zonelock lock [zonename]"); + } + else if (strcasecmp(sep.arg[1], "unlock") == 0 && admin >= 101) { + uint16 tmp = database.GetZoneID(sep.arg[2]); + if (tmp) { + if (zoneserver_list.SetLockedZone(tmp, false)) + zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", database.GetZoneName(tmp)); + else + SendMessage(1, "Failed to change lock"); + } + else + SendMessage(1, "Usage: #zonelock unlock [zonename]"); + } + else { + SendMessage(1, "#zonelock sub-commands"); + SendMessage(1, " list"); + if (admin >= 101) { + SendMessage(1, " lock [zonename]"); + SendMessage(1, " unlock [zonename]"); + } + } + } + else if (strcasecmp(sep.arg[0], "reloadworld") == 0 && admin > 101) + { + SendEmoteMessage(0,0,0,15,"Reloading World..."); + auto pack = new ServerPacket(ServerOP_ReloadWorld, sizeof(ReloadWorld_Struct)); + ReloadWorld_Struct* RW = (ReloadWorld_Struct*) pack->pBuffer; + RW->Option = 1; + zoneserver_list.SendPacket(pack); + safe_delete(pack); + } + else if (strcasecmp(sep.arg[0], "") == 0){ + /* Hit Enter with no command */ + } + else { + SendMessage(1, "Command unknown."); + } + if (state == CONSOLE_STATE_CONNECTED) + SendPrompt(); + break; + } + default: { + break; + } + } +} + +void Console::SendPrompt() { + if (tcpc->GetEcho()) + SendMessage(0, "%s> ", paccountname); +} + diff --git a/world/eql_config.cpp b/world/eql_config.cpp index 255f6d3a0..1a1536591 100644 --- a/world/eql_config.cpp +++ b/world/eql_config.cpp @@ -41,8 +41,9 @@ void EQLConfig::LoadSettings() { std::string query = StringFormat("SELECT dynamics FROM launcher WHERE name = '%s'", namebuf); auto results = database.QueryDatabase(query); - if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "EQLConfig::LoadSettings: %s", results.ErrorMessage().c_str()); + if (!results.Success()) { + Log(Logs::General, Logs::Error, "EQLConfig::LoadSettings: %s", results.ErrorMessage().c_str()); + } else { auto row = results.begin(); m_dynamics = atoi(row[0]); @@ -51,7 +52,7 @@ void EQLConfig::LoadSettings() { query = StringFormat("SELECT zone, port FROM launcher_zones WHERE launcher = '%s'", namebuf); results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "EQLConfig::LoadSettings: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "EQLConfig::LoadSettings: %s", results.ErrorMessage().c_str()); return; } @@ -198,7 +199,7 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) { res = m_zones.find(short_name); if(res == m_zones.end()) { //not found. - Log.Out(Logs::General, Logs::Error, "Update for unknown zone %s", short_name); + Log(Logs::General, Logs::Error, "Update for unknown zone %s", short_name); return false; } @@ -234,7 +235,7 @@ bool EQLConfig::DeleteStaticZone(Const_char *short_name) { res = m_zones.find(short_name); if(res == m_zones.end()) { //not found. - Log.Out(Logs::General, Logs::Error, "Update for unknown zone %s", short_name); + Log(Logs::General, Logs::Error, "Update for unknown zone %s", short_name); return false; } diff --git a/world/eqw_http_handler.cpp b/world/eqw_http_handler.cpp new file mode 100644 index 000000000..9e0effb1e --- /dev/null +++ b/world/eqw_http_handler.cpp @@ -0,0 +1,335 @@ +/* EQEMu: Everquest Server Emulator + Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#include "../common/global_define.h" +#include "eqw_http_handler.h" +#include "../common/SocketLib/Base64.h" +#include "eqw_parser.h" +#include "eqw.h" +#include "http_request.h" + +#include "worlddb.h" +#include "console.h" + +Mime EQWHTTPHandler::s_mime; +#ifdef EMBPERL +EQWParser *EQWHTTPHandler::s_parser = nullptr; +#endif +const int EQWHTTPHandler::READ_BUFFER_LEN = 1024; //for page IO, was a static const member, but VC6 got mad. + +EQWHTTPHandler::EQWHTTPHandler(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) +: HttpdSocket(ID,in_socket,irIP,irPort), + m_closeOnFinish(false) +{ +} + +EQWHTTPHandler::~EQWHTTPHandler() { + +} + +#ifdef EMBPERL +EQWParser *EQWHTTPHandler::GetParser() { + if(s_parser == nullptr) { + EQW::Singleton()->ClearOutput(); + s_parser = new EQWParser(); + const std::string &res = EQW::Singleton()->GetOutput(); + if(!res.empty()) { + printf("EQWParser Init output:\n%s\n\n", res.c_str()); + EQW::Singleton()->ClearOutput(); + } + } + return(s_parser); +} +#endif + +/*void EQWHTTPHandler::OnWrite() { + HttpdSocket::OnWrite(); + if(m_closeOnFinish && GetOutputLength() == 0) { +// printf("CLOSING\n"); + Close(); + } +}*/ + + +void EQWHTTPHandler::Exec() { + m_sentHeaders = false; + m_responseCode = "200"; +// printf("Request: %s, %s, %s, %s.\n", GetMethod().c_str(), GetUrl().c_str(), GetUri().c_str(), GetQueryString().c_str()); + + SetHttpVersion("HTTP/1.0"); + AddResponseHeader("Connection", "close"); + + if(GetUri().find("..") != std::string::npos) { + SendResponse("403", "Forbidden"); + printf("%s is forbidden.\n", GetUri().c_str()); + return; + } + + if(!CheckAuth()) { + AddResponseHeader("Content-type", "text/plain"); + AddResponseHeader("WWW-Authenticate", "Basic realm=\"EQEmulator\""); + SendResponse("401", "Authorization Required"); + SendString("Gotta Authenticate."); + } else { + std::string::size_type start = GetUri().find_first_not_of('/'); + std::string page; + if(start != std::string::npos) + page = GetUri().substr(start); + else + page = "index.html"; + SendPage(page); + } +/* if (!Detach()) { + printf("Unable to detach...\n"); + } + if(GetOutputLength() > 0) { + //we cannot close yet + m_closeOnFinish = true; + } else { + Close(); + }*/ + Free(); //the "app" side (us) is done with this connection too... + Disconnect(); +} + +void EQWHTTPHandler::OnHeader(const std::string& key,const std::string& value) { + HttpdSocket::OnHeader(key, value); + + if (!strcasecmp(key.c_str(),"Authorization")) { + if(strncasecmp(value.c_str(), "Basic ", 6)) { + printf("Invalid auth type. Expected Basic: %s\n", value.c_str()); + return; + } + + std::string dec; + Base64::decode(value.c_str() + 6, dec); + + std::string::size_type cpos; + cpos = dec.find_first_of(':'); + if(cpos == std::string::npos) { + printf("Invalid auth string: %s\n", dec.c_str()); + return; + } + + m_username = dec.substr(0, cpos); + m_password = dec.substr(cpos+1); + } +} + +//we should prolly cache login info here... if we load a fresh page, we could be checking +//their auth dozens of times rather quickly... +bool EQWHTTPHandler::CheckAuth() const { + if(m_username.length() < 1) + return(false); + + int16 status = 0; + uint32 acctid = database.CheckLogin(m_username.c_str(), m_password.c_str(), &status); + if(acctid == 0) { + Log(Logs::Detail, Logs::World_Server, "Login autentication failed for %s with '%s'", m_username.c_str(), m_password.c_str()); + return(false); + } + if(status < httpLoginStatus) { + Log(Logs::Detail, Logs::World_Server, "Login of %s failed: status too low.", m_username.c_str()); + return(false); + } + + return(true); +} + +void EQWHTTPHandler::SendPage(const std::string &file) { + + std::string path = "templates/"; + path += file; + + FILE *f = fopen(path.c_str(), "rb"); + if(f == nullptr) { + SendResponse("404", "Not Found"); + SendString("Not found."); + printf("%s not found.\n", file.c_str()); + return; + } + + std::string type = s_mime.GetMimeFromFilename(file); + AddResponseHeader("Content-type", type); + + bool process = false; +#ifdef EMBPERL + if(type == "text/html") + process = true; + else { + //not processing, send headers right away +#endif + SendResponse("200", "OK"); +#ifdef EMBPERL + } +#endif + + auto buffer = new char[READ_BUFFER_LEN + 1]; + size_t len; + std::string to_process; + while((len = fread(buffer, 1, READ_BUFFER_LEN, f)) > 0) { + buffer[len] = '\0'; + if(process) + to_process += buffer; + else + SendBuf(buffer, len); + } + delete[] buffer; + fclose(f); +#ifdef EMBPERL + if(process) { + //convert the base form into a useful perl exportable form + HTTPRequest req(this, GetHttpForm()); + GetParser()->SetHTTPRequest("testing", &req); + + //parse out the page and potentially pass some stuff on to perl. + ProcessAndSend(to_process); + + //clear out the form, just in case (since it gets destroyed next) + GetParser()->SetHTTPRequest("testing", nullptr); + } +#endif +} + +bool EQWHTTPHandler::LoadMimeTypes(const char *filename) { + return(s_mime.LoadMimeFile(filename)); +} + +#ifdef EMBPERL +void EQWHTTPHandler::ProcessAndSend(const std::string &str) { + std::string::size_type len = str.length(); + std::string::size_type start = 0; + std::string::size_type pos, end; + + while((pos = str.find("", pos+2); + if(end == std::string::npos) { + //terminal ?> not found... should issue a warning or something... + std::string scriptBody = str.substr(pos+2); + ProcessScript(scriptBody); + start = len; + break; + } else { + //script only consumes some of this buffer... + std::string scriptBody = str.substr(pos+2, end-pos-2); + ProcessScript(scriptBody); + start = end + 2; + } + } + + //send whatever is left over + if(start != len) + ProcessText(str.c_str() + start, len-start); +} + +void EQWHTTPHandler::ProcessScript(const std::string &script_body) { + const char *script = script_body.c_str(); + if(strcmp("perl", script) == 0) + script += 4; //allow EQW_eval("testing", script_body.c_str()); + const std::string &res = EQW::Singleton()->GetOutput(); + if(!res.empty()) { + ProcessText(res.c_str(), res.length()); + EQW::Singleton()->ClearOutput(); + } +} + +void EQWHTTPHandler::ProcessText(const char *txt, int len) { + if(!m_sentHeaders) { + SendResponse(m_responseCode, "OK"); + m_sentHeaders = true; + } + SendBuf(txt, len); +} +#endif + + +EQWHTTPServer::EQWHTTPServer() +: m_port(0) +{ +} + +void EQWHTTPServer::CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort) { + auto conn = new EQWHTTPHandler(ID, in_socket, irIP, irPort); + AddConnection(conn); +} + +void EQWHTTPServer::Stop() { + Log(Logs::Detail, Logs::World_Server, "Requesting that HTTP Service stop."); + m_running = false; + Close(); +} + +bool EQWHTTPServer::Start(uint16 port, const char *mime_file) { + if(m_running) { + Log(Logs::Detail, Logs::World_Server, "HTTP Service is already running on port %d", m_port); + return(false); + } + + //load up our nice mime types + if(!EQWHTTPHandler::LoadMimeTypes(mime_file)) { + Log(Logs::Detail, Logs::World_Server, "Failed to load mime types from '%s'", mime_file); + return(false); + } else { + Log(Logs::Detail, Logs::World_Server, "Loaded mime types from %s", mime_file); + } + + //fire up the server thread + char errbuf[TCPServer_ErrorBufferSize]; + if(!Open(port, errbuf)) { + Log(Logs::Detail, Logs::World_Server, "Unable to bind to port %d for HTTP service: %s", port, errbuf); + return(false); + } + + m_running = true; + m_port = port; + + /* + +#ifdef _WINDOWS + _beginthread(ThreadProc, 0, this); +#else + pthread_create(&m_thread, nullptr, ThreadProc, this); +#endif*/ + + return(true); +} + +/* +void EQWHTTPServer::Run() { + Log.LogDebugType(Logs::Detail, Logs::World_Server, "HTTP Processing thread started on port %d", m_port); + do { +#warning DELETE THIS IF YOU DONT USE IT + Sleep(10); + } while(m_running); + Log.LogDebugType(Logs::Detail, Logs::World_Server, "HTTP Processing thread terminating on port %d", m_port); +} + +ThreadReturnType EQWHTTPServer::ThreadProc(void *data) { + ((EQWHTTPServer *) data)->Run(); + THREAD_RETURN(nullptr); +}*/ + diff --git a/world/eqw_parser.cpp b/world/eqw_parser.cpp new file mode 100644 index 000000000..b0604924e --- /dev/null +++ b/world/eqw_parser.cpp @@ -0,0 +1,348 @@ +/* EQEMu: Everquest Server Emulator + Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY except by those people which sell it, which + are required to give you total support for your newly bought product; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +//a lot of this is copied from embperl.cpp, but I didnt feel like factoring the common stuff out + +#ifdef EMBPERL + +#include "../common/global_define.h" +#include "eqw_parser.h" +#include "eqw.h" +#include "../common/eqdb.h" + +#include "worlddb.h" + +#ifndef GvCV_set +#define GvCV_set(gv,cv) (GvCV(gv) = (cv)) +#endif + +XS(XS_EQWIO_PRINT); + +//so embedded scripts can use xs extensions (ala 'use socket;') +EXTERN_C void boot_DynaLoader(pTHX_ CV* cv); +EXTERN_C XS(boot_EQW); +EXTERN_C XS(boot_EQDB); +EXTERN_C XS(boot_EQDBRes); +EXTERN_C XS(boot_HTTPRequest); +EXTERN_C XS(boot_EQLConfig); + +EXTERN_C void xs_init(pTHX) +{ + char file[256]; + strncpy(file, __FILE__, 256); + file[255] = '\0'; + + char buf[128]; //shouldent have any function names longer than this. + + //add the strcpy stuff to get rid of const warnings.... + + newXS(strcpy(buf, "DynaLoader::boot_DynaLoader"), boot_DynaLoader, file); + newXS(strcpy(buf, "EQW::boot_EQW"), boot_EQW, file); + newXS(strcpy(buf, "EQDB::boot_EQDB"), boot_EQDB, file); + newXS(strcpy(buf, "EQDBRes::boot_EQDBRes"), boot_EQDBRes, file); + newXS(strcpy(buf, "HTTPRequest::boot_HTTPRequest"), boot_HTTPRequest, file); + newXS(strcpy(buf, "EQLConfig::boot_EQLConfig"), boot_EQLConfig, file); + newXS(strcpy(buf, "EQWIO::PRINT"), XS_EQWIO_PRINT, file); +} + +EQWParser::EQWParser() { + //setup perl... + my_perl = perl_alloc(); + _empty_sv = newSV(0); + if (!my_perl) { + Log(Logs::Detail, Logs::World_Server, "Error: perl_alloc failed!"); + } + else { + DoInit(); + } +} + +void EQWParser::DoInit() { + const char *argv_eqemu[] = { "", + "-w", "-W", + "-e", "0;", nullptr }; + + int argc = 5; + + char **argv = (char **)argv_eqemu; + char **env = { nullptr }; + + PL_perl_destruct_level = 1; + + perl_construct(my_perl); + + PERL_SYS_INIT3(&argc, &argv, &env); + + perl_parse(my_perl, xs_init, argc, argv, env); + + perl_run(my_perl); + + //a little routine we use a lot. + eval_pv("sub my_eval {eval $_[0];}", TRUE); //dies on error + + //ruin the perl exit and command: + eval_pv("sub my_exit {}",TRUE); + eval_pv("sub my_sleep {}",TRUE); + if(gv_stashpv("CORE::GLOBAL", FALSE)) { + GV *exitgp = gv_fetchpv("CORE::GLOBAL::exit", TRUE, SVt_PVCV); + GvCV_set(exitgp, perl_get_cv("my_exit", TRUE)); //dies on error + GvIMPORTED_CV_on(exitgp); + GV *sleepgp = gv_fetchpv("CORE::GLOBAL::sleep", TRUE, SVt_PVCV); + GvCV_set(sleepgp, perl_get_cv("my_sleep", TRUE)); //dies on error + GvIMPORTED_CV_on(sleepgp); + } + + //setup eval_file + eval_pv( + "our %Cache;" + "use Symbol qw(delete_package);" + "sub eval_file {" + "my($package, $filename) = @_;" + "$filename=~s/\'//g;" + "if(! -r $filename) { print \"Unable to read perl file '$filename'\\n\"; return; }" + "my $mtime = -M $filename;" + "if(defined $Cache{$package}{mtime}&&$Cache{$package}{mtime} <= $mtime && !($package eq 'plugin')){" + " return;" + "} else {" + //we 'my' $filename,$mtime,$package,$sub to prevent them from changing our state up here. + " eval(\"package $package; my(\\$filename,\\$mtime,\\$package,\\$sub); \\$isloaded = 1; require '$filename'; \");" + "}" + "}" + ,FALSE); + + //make a tie-able class to capture IO and get it where it needs to go + eval_pv( + "package EQWIO; " +// "&boot_EQEmuIO;" + "sub TIEHANDLE { my $me = bless {}, $_[0]; $me->PRINT('Creating '.$me); return($me); } " + "sub WRITE { } " + "sub PRINTF { my $me = shift; my $fmt = shift; $me->PRINT(sprintf($fmt, @_)); } " + "sub CLOSE { my $me = shift; $me->PRINT('Closing '.$me); } " + "sub DESTROY { my $me = shift; $me->PRINT('Destroying '.$me); } " +//this ties us for all packages + "package MAIN;" + " if(tied *STDOUT) { untie(*STDOUT); }" + " if(tied *STDERR) { untie(*STDERR); }" + " tie *STDOUT, 'EQWIO';" + " tie *STDERR, 'EQWIO';" + ,FALSE); + + eval_pv( + "package world; " + ,FALSE + ); + + //make sure the EQW pointer is set up in this package + EQW *curc = EQW::Singleton(); + SV *l = get_sv("world::EQW", true); + if(curc != nullptr) { + sv_setref_pv(l, "EQW", curc); + } else { + //clear out the value, mainly to get rid of blessedness + sv_setsv(l, _empty_sv); + } + + //make sure the EQDB pointer is set up in this package + EQDB::SetMySQL(database.getMySQL()); + EQDB *curc_db = EQDB::Singleton(); + SV *l_db = get_sv("world::EQDB", true); + if(curc_db != nullptr) { + sv_setref_pv(l_db, "EQDB", curc_db); + } else { + //clear out the value, mainly to get rid of blessedness + sv_setsv(l_db, _empty_sv); + } + + //load up EQW + eval_pv( + "package EQW;" + "&boot_EQW;" //load our EQW XS + "package EQDB;" + "&boot_EQDB;" //load our EQW XS + "package EQDBRes;" + "&boot_EQDBRes;" //load our EQW XS + "package HTTPRequest;" + "&boot_HTTPRequest;" //load our HTTPRequest XS + "package EQLConfig;" + "&boot_EQLConfig;" //load our EQLConfig XS + , FALSE ); + + +#ifdef EMBPERL_PLUGIN + Log(Logs::Detail, Logs::World_Server, "Loading worldui perl plugins."); + std::string err; + if(!eval_file("world", "worldui.pl", err)) { + Log(Logs::Detail, Logs::World_Server, "Warning - world.pl: %s", err.c_str()); + } + + eval_pv( + "package world; " + "if(opendir(D,'worldui')) { " + " my @d = readdir(D);" + " closedir(D);" + " foreach(@d){ " + " next unless(/\\.pl$); " + " require 'templates/'.$_;" + " }" + "}" + ,FALSE); +#endif //EMBPERL_PLUGIN +} + +EQWParser::~EQWParser() { + //removed to try to stop perl from exploding on reload, we'll see +/* eval_pv( + "package quest;" + " untie *STDOUT;" + " untie *STDERR;" + ,FALSE); +*/ + perl_free(my_perl); +} + +bool EQWParser::eval_file(const char * packagename, const char * filename, std::string &error) +{ + std::vector args; + args.push_back(packagename); + args.push_back(filename); + return(dosub("eval_file", args, error)); +} + +bool EQWParser::dosub(const char * subname, const std::vector &args, std::string &error, int mode) { + bool err = false; + dSP; // initialize stack pointer + ENTER; // everything created after here + SAVETMPS; // ...is a temporary variable + PUSHMARK(SP); // remember the stack pointer + if(!args.empty()) + { + for (auto i = args.begin(); i != args.end(); ++i) { /* push the arguments onto the perl stack */ + XPUSHs(sv_2mortal(newSVpv(i->c_str(), i->length()))); + } + } + PUTBACK; // make local stack pointer global + call_pv(subname, mode); /*eval our code*/ + SPAGAIN; // refresh stack pointer + if(SvTRUE(ERRSV)) { + err = true; + } + FREETMPS; // free temp values + LEAVE; // ...and the XPUSHed "mortal" args. + + if(err) { + error = "Perl runtime error: "; + error += SvPVX(ERRSV); + return(false); + } + return(true); +} + +bool EQWParser::eval(const char * code, std::string &error) { + std::vector arg; + arg.push_back(code); + return(dosub("my_eval", arg, error, G_SCALAR|G_DISCARD|G_EVAL|G_KEEPERR)); +} + +void EQWParser::EQW_eval(const char *pkg, const char *code) { + char namebuf[64]; + + snprintf(namebuf, 64, "package %s;", pkg); + eval_pv(namebuf, FALSE); + + //make sure the EQW pointer is set up + EQW *curc = EQW::Singleton(); + snprintf(namebuf, 64, "EQW"); +// snprintf(namebuf, 64, "%s::EQW", pkg); + SV *l = get_sv(namebuf, true); + if(curc != nullptr) { + sv_setref_pv(l, "EQW", curc); + } else { + //clear out the value, mainly to get rid of blessedness + sv_setsv(l, _empty_sv); + } + //make sure the EQDB pointer is set up + EQDB *curc_db = EQDB::Singleton(); + snprintf(namebuf, 64, "EQDB"); +// snprintf(namebuf, 64, "%s::EQW", pkg); + SV *l_db = get_sv(namebuf, true); + if(curc_db != nullptr) { + sv_setref_pv(l_db, "EQDB", curc_db); + } else { + //clear out the value, mainly to get rid of blessedness + sv_setsv(l_db, _empty_sv); + } + + std::string err; + if(!eval(code, err)) { + EQW::Singleton()->AppendOutput(err.c_str()); + } +} + +void EQWParser::SetHTTPRequest(const char *pkg, HTTPRequest *it) { + char namebuf[64]; + + snprintf(namebuf, 64, "package %s;", pkg); + eval_pv(namebuf, FALSE); + + snprintf(namebuf, 64, "request"); +// snprintf(namebuf, 64, "%s::EQW", pkg); + SV *l = get_sv(namebuf, true); + if(it != nullptr) { + sv_setref_pv(l, "HTTPRequest", it); + } else { + //clear out the value, mainly to get rid of blessedness + sv_setsv(l, _empty_sv); + } + +} +/* +$editors = array(); +$editors["merchant"] = new MerchantEditor(); +#... for other editors + +if(defined($editors[$editor])) { + $edit = $editors[$editor]; + $edit->dispatch($action); +} + +class MerchantEditor extends BaseEditor { + MerchantEditor() { + $this->RegisterAction(0, "get_merchantlist", "merchant/merchant.tmpl.php", "no"); + $this->RegisterAction(1, "get_merchantlist", "merchant/merchant.edit.tmpl.php", "no"); + } +} + +function dispatch() { + my $dispatcher = $this->_dispatchers[$action]; + $body = new Template($dispatcher["template"]); + my $proc = $dispatcher["proc"]; + $vars = $this->$proc(); + if($dispatcher["guestmode"] == "no") { + check_authorization(); + } + if ($vars) { + foreach ($vars as $key=>$value) { + $body->set($key, $value); + } + } +} + +*/ + +#endif //EMBPERL + diff --git a/world/launcher_link.cpp b/world/launcher_link.cpp index 8b1e94446..83c51947b 100644 --- a/world/launcher_link.cpp +++ b/world/launcher_link.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" @@ -35,7 +35,7 @@ extern LauncherList launcher_list; LauncherLink::LauncherLink(int id, std::shared_ptr c) -: ID(id), + : ID(id), tcpc(c), authenticated(false), m_name(""), @@ -71,7 +71,7 @@ void LauncherLink::ProcessMessage(uint16 opcode, EQ::Net::Packet &p) ServerPacket tpack(opcode, p); ServerPacket *pack = &tpack; - switch(opcode) { + switch (opcode) { case 0: break; case ServerOP_KeepAlive: { @@ -79,65 +79,65 @@ void LauncherLink::ProcessMessage(uint16 opcode, EQ::Net::Packet &p) break; } case ServerOP_ZAAuth: { - Log.Out(Logs::Detail, Logs::World_Server, "Got authentication from %s when they are already authenticated.", m_name.c_str()); + Log(Logs::Detail, Logs::World_Server, "Got authentication from %s when they are already authenticated.", m_name.c_str()); break; } case ServerOP_LauncherConnectInfo: { - const LauncherConnectInfo *it = (const LauncherConnectInfo *) pack->pBuffer; - if(HasName()) { - Log.Out(Logs::Detail, Logs::World_Server, "Launcher '%s' received an additional connect packet with name '%s'. Ignoring.", m_name.c_str(), it->name); + const LauncherConnectInfo *it = (const LauncherConnectInfo *)pack->pBuffer; + if (HasName()) { + Log(Logs::Detail, Logs::World_Server, "Launcher '%s' received an additional connect packet with name '%s'. Ignoring.", m_name.c_str(), it->name); break; } m_name = it->name; - + EQLConfig *config = launcher_list.GetConfig(m_name.c_str()); - if(config == nullptr) { - Log.Out(Logs::Detail, Logs::World_Server, "Unknown launcher '%s' connected. Disconnecting.", it->name); + if (config == nullptr) { + Log(Logs::Detail, Logs::World_Server, "Unknown launcher '%s' connected. Disconnecting.", it->name); Disconnect(); break; } - - Log.Out(Logs::Detail, Logs::World_Server, "Launcher Identified itself as '%s'. Loading zone list.", it->name); - + + Log(Logs::Detail, Logs::World_Server, "Launcher Identified itself as '%s'. Loading zone list.", it->name); + std::vector result; //database.GetLauncherZones(it->name, result); config->GetZones(result); - + std::vector::iterator cur, end; cur = result.begin(); end = result.end(); ZoneState zs; - for(; cur != end; cur++) { + for (; cur != end; cur++) { zs.port = cur->port; zs.up = false; zs.starts = 0; - Log.Out(Logs::Detail, Logs::World_Server, "%s: Loaded zone '%s' on port %d", m_name.c_str(), cur->name.c_str(), zs.port); + Log(Logs::Detail, Logs::World_Server, "%s: Loaded zone '%s' on port %d", m_name.c_str(), cur->name.c_str(), zs.port); m_states[cur->name] = zs; } - + //now we add all the dynamics. BootDynamics(config->GetDynamicCount()); - + m_bootTimer.Start(); - + break; } case ServerOP_LauncherZoneStatus: { - const LauncherZoneStatus *it = (const LauncherZoneStatus *) pack->pBuffer; + const LauncherZoneStatus *it = (const LauncherZoneStatus *)pack->pBuffer; std::map::iterator res; res = m_states.find(it->short_name); - if(res == m_states.end()) { - Log.Out(Logs::Detail, Logs::World_Server, "%s: reported state for zone %s which it does not have.", m_name.c_str(), it->short_name); + if (res == m_states.end()) { + Log(Logs::Detail, Logs::World_Server, "%s: reported state for zone %s which it does not have.", m_name.c_str(), it->short_name); break; } - Log.Out(Logs::Detail, Logs::World_Server, "%s: %s reported state %s (%d starts)", m_name.c_str(), it->short_name, it->running?"STARTED":"STOPPED", it->start_count); + Log(Logs::Detail, Logs::World_Server, "%s: %s reported state %s (%d starts)", m_name.c_str(), it->short_name, it->running ? "STARTED" : "STOPPED", it->start_count); res->second.up = it->running; res->second.starts = it->start_count; break; } default: { - Log.Out(Logs::Detail, Logs::World_Server, "Unknown ServerOPcode from launcher 0x%04x, size %d",pack->opcode,pack->size); + Log(Logs::Detail, Logs::World_Server, "Unknown ServerOPcode from launcher 0x%04x, size %d", pack->opcode, pack->size); DumpPacket(pack->pBuffer, pack->size); break; } @@ -153,7 +153,7 @@ void LauncherLink::BootZone(const char *short_name, uint16 port) { zs.port = port; zs.up = false; zs.starts = 0; - Log.Out(Logs::Detail, Logs::World_Server, "%s: Loaded zone '%s' on port %d", m_name.c_str(), short_name, zs.port); + Log(Logs::Detail, Logs::World_Server, "%s: Loaded zone '%s' on port %d", m_name.c_str(), short_name, zs.port); m_states[short_name] = zs; StartZone(short_name, port); @@ -165,7 +165,7 @@ void LauncherLink::StartZone(const char *short_name) { void LauncherLink::StartZone(const char *short_name, uint16 port) { auto pack = new ServerPacket(ServerOP_LauncherZoneRequest, sizeof(LauncherZoneRequest)); - LauncherZoneRequest* s = (LauncherZoneRequest *) pack->pBuffer; + LauncherZoneRequest* s = (LauncherZoneRequest *)pack->pBuffer; strn0cpy(s->short_name, short_name, 32); s->command = ZR_Start; @@ -177,7 +177,7 @@ void LauncherLink::StartZone(const char *short_name, uint16 port) { void LauncherLink::RestartZone(const char *short_name) { auto pack = new ServerPacket(ServerOP_LauncherZoneRequest, sizeof(LauncherZoneRequest)); - LauncherZoneRequest* s = (LauncherZoneRequest *) pack->pBuffer; + LauncherZoneRequest* s = (LauncherZoneRequest *)pack->pBuffer; strn0cpy(s->short_name, short_name, 32); s->command = ZR_Restart; @@ -189,7 +189,7 @@ void LauncherLink::RestartZone(const char *short_name) { void LauncherLink::StopZone(const char *short_name) { auto pack = new ServerPacket(ServerOP_LauncherZoneRequest, sizeof(LauncherZoneRequest)); - LauncherZoneRequest* s = (LauncherZoneRequest *) pack->pBuffer; + LauncherZoneRequest* s = (LauncherZoneRequest *)pack->pBuffer; strn0cpy(s->short_name, short_name, 32); s->command = ZR_Stop; @@ -200,11 +200,11 @@ void LauncherLink::StopZone(const char *short_name) { } void LauncherLink::BootDynamics(uint8 new_count) { - if(m_dynamicCount == new_count) + if (m_dynamicCount == new_count) return; ZoneState zs; - if(m_dynamicCount < new_count) { + if (m_dynamicCount < new_count) { //we are booting more dynamics. zs.port = 0; @@ -215,11 +215,11 @@ void LauncherLink::BootDynamics(uint8 new_count) { char nbuf[20]; uint8 index; //"for each zone we need to boot" - for(r = m_dynamicCount; r < new_count; r++) { + for (r = m_dynamicCount; r < new_count; r++) { //find an idle ID - for(index = m_dynamicCount+1; index < 255; index++) { + for (index = m_dynamicCount + 1; index < 255; index++) { sprintf(nbuf, "dynamic_%02d", index); - if(m_states.find(nbuf) != m_states.end()) + if (m_states.find(nbuf) != m_states.end()) continue; m_states[nbuf] = zs; StartZone(nbuf); @@ -227,15 +227,17 @@ void LauncherLink::BootDynamics(uint8 new_count) { } } m_dynamicCount = new_count; - } else if(new_count == 0) { + } + else if (new_count == 0) { //kill all zones... std::map::iterator cur, end; cur = m_states.begin(); end = m_states.end(); - for(; cur != end; cur++) { + for (; cur != end; cur++) { StopZone(cur->first.c_str()); } - } else { + } + else { //need to get rid of some zones... //quick and dirty way to do this.. should do better (like looking for idle zones) @@ -243,12 +245,13 @@ void LauncherLink::BootDynamics(uint8 new_count) { std::map::iterator cur, end; cur = m_states.begin(); end = m_states.end(); - for(; cur != end; cur++) { - if(cur->first.find("dynamic_") == 0) { - if(found >= new_count) { + for (; cur != end; cur++) { + if (cur->first.find("dynamic_") == 0) { + if (found >= new_count) { //this zone exceeds the number of allowed booted zones. StopZone(cur->first.c_str()); - } else { + } + else { found++; } } @@ -264,25 +267,26 @@ void LauncherLink::GetZoneList(std::vector &l) { std::map::iterator cur, end; cur = m_states.begin(); end = m_states.end(); - for(; cur != end; cur++) { + for (; cur != end; cur++) { l.push_back(cur->first.c_str()); } } -void LauncherLink::GetZoneDetails(const char *short_name, std::map &res) { +void LauncherLink::GetZoneDetails(const char *short_name, std::map &res) { res.clear(); std::map::iterator r; r = m_states.find(short_name); - if(r == m_states.end()) { + if (r == m_states.end()) { res["error"] = "Zone Not Found"; res["name"] = short_name; res["up"] = "0"; res["starts"] = "0"; res["port"] = "0"; - } else { + } + else { res["name"] = r->first; - res["up"] = r->second.up?"1":"0"; + res["up"] = r->second.up ? "1" : "0"; res["starts"] = itoa(r->second.starts); res["port"] = itoa(r->second.port); } @@ -292,4 +296,4 @@ void LauncherLink::Shutdown() { auto pack = new ServerPacket(ServerOP_ShutdownAll); SendPacket(pack); delete pack; -} +} \ No newline at end of file diff --git a/world/launcher_list.cpp b/world/launcher_list.cpp index df5597f5a..c13276384 100644 --- a/world/launcher_list.cpp +++ b/world/launcher_list.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ @@ -24,7 +24,7 @@ #include "eql_config.h" LauncherList::LauncherList() -: nextID(1) + : nextID(1) { } @@ -32,21 +32,21 @@ LauncherList::~LauncherList() { std::vector::iterator cur, end; cur = m_pendingLaunchers.begin(); end = m_pendingLaunchers.end(); - for(; cur != end; ++cur) { + for (; cur != end; ++cur) { delete *cur; } std::map::iterator curc, endc; curc = m_configs.begin(); endc = m_configs.end(); - for(; curc != endc; ++curc) { + for (; curc != endc; ++curc) { delete curc->second; } std::map::iterator curl, endl; curl = m_launchers.begin(); endl = m_launchers.end(); - for(; curl != endl; ++curl) { + for (; curl != endl; ++curl) { delete curl->second; } } @@ -54,9 +54,9 @@ LauncherList::~LauncherList() { void LauncherList::Process() { std::vector::iterator cur; cur = m_pendingLaunchers.begin(); - while(cur != m_pendingLaunchers.end()) { + while (cur != m_pendingLaunchers.end()) { LauncherLink *l = *cur; - if(l->HasName()) { + if (l->HasName()) { //launcher has identified itself now. //remove ourself from the pending list cur = m_pendingLaunchers.erase(cur); @@ -64,14 +64,15 @@ void LauncherList::Process() { //kill off anybody else using our name. std::map::iterator res; res = m_launchers.find(name); - if(res != m_launchers.end()) { - Log.Out(Logs::Detail, Logs::World_Server, "Ghosting launcher %s", name.c_str()); + if (res != m_launchers.end()) { + Log(Logs::Detail, Logs::World_Server, "Ghosting launcher %s", name.c_str()); delete res->second; } - Log.Out(Logs::Detail, Logs::World_Server, "Removing pending launcher %d. Adding %s to active list.", l->GetID(), name.c_str()); + Log(Logs::Detail, Logs::World_Server, "Removing pending launcher %d. Adding %s to active list.", l->GetID(), name.c_str()); //put the launcher in the list. m_launchers[name] = l; - } else { + } + else { ++cur; } } @@ -80,7 +81,7 @@ void LauncherList::Process() { LauncherLink *LauncherList::Get(const char *name) { std::map::iterator res; res = m_launchers.find(name); - if(res == m_launchers.end()) + if (res == m_launchers.end()) return(nullptr); return(res->second); } @@ -89,8 +90,8 @@ LauncherLink *LauncherList::FindByZone(const char *short_name) { std::map::iterator cur, end; cur = m_launchers.begin(); end = m_launchers.end(); - for(; cur != end; ++cur) { - if(cur->second->ContainsZone(short_name)) + for (; cur != end; ++cur) { + if (cur->second->ContainsZone(short_name)) return(cur->second); } return(nullptr); @@ -98,7 +99,7 @@ LauncherLink *LauncherList::FindByZone(const char *short_name) { void LauncherList::Add(std::shared_ptr conn) { auto it = new LauncherLink(nextID++, conn); - Log.Out(Logs::Detail, Logs::World_Server, "Adding pending launcher %d", it->GetID()); + Log(Logs::Detail, Logs::World_Server, "Adding pending launcher %d", it->GetID()); m_pendingLaunchers.push_back(it); } @@ -132,7 +133,7 @@ void LauncherList::GetLauncherNameList(std::vector &res) { std::map::iterator cur, end; cur = m_configs.begin(); end = m_configs.end(); - for(; cur != end; ++cur) { + for (; cur != end; ++cur) { res.push_back(cur->first); } } @@ -145,7 +146,7 @@ void LauncherList::LoadList() { std::vector::iterator cur, end; cur = launchers.begin(); end = launchers.end(); - for(; cur != end; ++cur) { + for (; cur != end; ++cur) { m_configs[*cur] = new EQLConfig(cur->c_str()); } } @@ -153,7 +154,7 @@ void LauncherList::LoadList() { EQLConfig *LauncherList::GetConfig(const char *name) { std::map::iterator res; res = m_configs.find(name); - if(res == m_configs.end()) { + if (res == m_configs.end()) { return(nullptr); } return(res->second); @@ -166,15 +167,14 @@ void LauncherList::CreateLauncher(const char *name, uint8 dynamic_count) { void LauncherList::Remove(const char *name) { std::map::iterator resc; resc = m_configs.find(name); - if(resc != m_configs.end()) { + if (resc != m_configs.end()) { delete resc->second; m_configs.erase(resc); } std::map::iterator resl; resl = m_launchers.find(name); - if(resl != m_launchers.end()) { + if (resl != m_launchers.end()) { resl->second->Disconnect(); } } - diff --git a/world/login_server.cpp b/world/login_server.cpp index 9ffc28ec8..97c9f5214 100644 --- a/world/login_server.cpp +++ b/world/login_server.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) +Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" #include @@ -43,10 +43,10 @@ extern volatile bool RunLoops; LoginServer::LoginServer(const char* iAddress, uint16 iPort, const char* Account, const char* Password, bool legacy) { - strn0cpy(LoginServerAddress,iAddress,256); + strn0cpy(LoginServerAddress, iAddress, 256); LoginServerPort = iPort; - strn0cpy(LoginAccount,Account,31); - strn0cpy(LoginPassword,Password,31); + strn0cpy(LoginAccount, Account, 31); + strn0cpy(LoginPassword, Password, 31); CanAccountUpdate = false; IsLegacy = legacy; Connect(); @@ -57,7 +57,7 @@ LoginServer::~LoginServer() { void LoginServer::ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p) { const WorldConfig *Config = WorldConfig::get(); - Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode); + Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode); UsertoWorldRequest_Struct* utwr = (UsertoWorldRequest_Struct*)p.Data(); uint32 id = database.GetAccountIDFromLSID(utwr->lsaccountid); @@ -99,8 +99,8 @@ void LoginServer::ProcessUsertoWorldReq(uint16_t opcode, EQ::Net::Packet &p) { void LoginServer::ProcessLSClientAuth(uint16_t opcode, EQ::Net::Packet &p) { const WorldConfig *Config = WorldConfig::get(); - Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode); - + Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode); + try { auto slsca = p.GetSerialize(0); @@ -109,27 +109,27 @@ void LoginServer::ProcessLSClientAuth(uint16_t opcode, EQ::Net::Packet &p) { // online at the same time. client_list.EnforceSessionLimit(slsca.lsaccount_id); } - + client_list.CLEAdd(slsca.lsaccount_id, slsca.name, slsca.key, slsca.worldadmin, slsca.ip, slsca.local); } catch (std::exception &ex) { - Log.OutF(Logs::General, Logs::Error, "Error parsing LSClientAuth packet from world.\n{0}", ex.what()); + LogF(Logs::General, Logs::Error, "Error parsing LSClientAuth packet from world.\n{0}", ex.what()); } } void LoginServer::ProcessLSFatalError(uint16_t opcode, EQ::Net::Packet &p) { const WorldConfig *Config = WorldConfig::get(); - Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode); + Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode); - Log.Out(Logs::Detail, Logs::World_Server, "Login server responded with FatalError."); + Log(Logs::Detail, Logs::World_Server, "Login server responded with FatalError."); if (p.Length() > 1) { - Log.Out(Logs::Detail, Logs::World_Server, " %s", (const char*)p.Data()); + Log(Logs::Detail, Logs::World_Server, " %s", (const char*)p.Data()); } } void LoginServer::ProcessSystemwideMessage(uint16_t opcode, EQ::Net::Packet &p) { const WorldConfig *Config = WorldConfig::get(); - Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode); + Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode); ServerSystemwideMessage* swm = (ServerSystemwideMessage*)p.Data(); zoneserver_list.SendEmoteMessageRaw(0, 0, 0, swm->type, swm->message); @@ -137,44 +137,44 @@ void LoginServer::ProcessSystemwideMessage(uint16_t opcode, EQ::Net::Packet &p) void LoginServer::ProcessLSRemoteAddr(uint16_t opcode, EQ::Net::Packet &p) { const WorldConfig *Config = WorldConfig::get(); - Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode); + Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode); if (!Config->WorldAddress.length()) { WorldConfig::SetWorldAddress((char *)p.Data()); - Log.Out(Logs::Detail, Logs::World_Server, "Loginserver provided %s as world address", (const char*)p.Data()); + Log(Logs::Detail, Logs::World_Server, "Loginserver provided %s as world address", (const char*)p.Data()); } } void LoginServer::ProcessLSAccountUpdate(uint16_t opcode, EQ::Net::Packet &p) { const WorldConfig *Config = WorldConfig::get(); - Log.Out(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode); + Log(Logs::Detail, Logs::World_Server, "Recevied ServerPacket from LS OpCode 0x04x", opcode); - Log.Out(Logs::Detail, Logs::World_Server, "Received ServerOP_LSAccountUpdate packet from loginserver"); + Log(Logs::Detail, Logs::World_Server, "Received ServerOP_LSAccountUpdate packet from loginserver"); CanAccountUpdate = true; } bool LoginServer::Connect() { std::string tmp; - if(database.GetVariable("loginType", tmp) && strcasecmp(tmp.c_str(), "MinILogin") == 0) { + if (database.GetVariable("loginType", tmp) && strcasecmp(tmp.c_str(), "MinILogin") == 0) { minilogin = true; - Log.Out(Logs::Detail, Logs::World_Server, "Setting World to MiniLogin Server type"); + Log(Logs::Detail, Logs::World_Server, "Setting World to MiniLogin Server type"); } else minilogin = false; - if (minilogin && WorldConfig::get()->WorldAddress.length()==0) { - Log.Out(Logs::Detail, Logs::World_Server, "**** For minilogin to work, you need to set the
element in the section."); + if (minilogin && WorldConfig::get()->WorldAddress.length() == 0) { + Log(Logs::Detail, Logs::World_Server, "**** For minilogin to work, you need to set the
element in the section."); return false; } char errbuf[1024]; if ((LoginServerIP = ResolveIP(LoginServerAddress, errbuf)) == 0) { - Log.Out(Logs::Detail, Logs::World_Server, "Unable to resolve '%s' to an IP.",LoginServerAddress); + Log(Logs::Detail, Logs::World_Server, "Unable to resolve '%s' to an IP.", LoginServerAddress); return false; } if (LoginServerIP == 0 || LoginServerPort == 0) { - Log.Out(Logs::Detail, Logs::World_Server, "Connect info incomplete, cannot connect: %s:%d",LoginServerAddress,LoginServerPort); + Log(Logs::Detail, Logs::World_Server, "Connect info incomplete, cannot connect: %s:%d", LoginServerAddress, LoginServerPort); return false; } @@ -182,7 +182,7 @@ bool LoginServer::Connect() { legacy_client.reset(new EQ::Net::ServertalkLegacyClient(LoginServerAddress, LoginServerPort, false)); legacy_client->OnConnect([this](EQ::Net::ServertalkLegacyClient *client) { if (client) { - Log.Out(Logs::Detail, Logs::World_Server, "Connected to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort); + Log(Logs::Detail, Logs::World_Server, "Connected to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort); if (minilogin) SendInfo(); else @@ -195,7 +195,7 @@ bool LoginServer::Connect() { })); } else { - Log.Out(Logs::Detail, Logs::World_Server, "Could not connect to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort); + Log(Logs::Detail, Logs::World_Server, "Could not connect to Legacy Loginserver: %s:%d", LoginServerAddress, LoginServerPort); } }); @@ -211,7 +211,7 @@ bool LoginServer::Connect() { client.reset(new EQ::Net::ServertalkClient(LoginServerAddress, LoginServerPort, false, "World", "")); client->OnConnect([this](EQ::Net::ServertalkClient *client) { if (client) { - Log.Out(Logs::Detail, Logs::World_Server, "Connected to Loginserver: %s:%d", LoginServerAddress, LoginServerPort); + Log(Logs::Detail, Logs::World_Server, "Connected to Loginserver: %s:%d", LoginServerAddress, LoginServerPort); if (minilogin) SendInfo(); else @@ -224,7 +224,7 @@ bool LoginServer::Connect() { })); } else { - Log.Out(Logs::Detail, Logs::World_Server, "Could not connect to Loginserver: %s:%d", LoginServerAddress, LoginServerPort); + Log(Logs::Detail, Logs::World_Server, "Could not connect to Loginserver: %s:%d", LoginServerAddress, LoginServerPort); } }); @@ -239,14 +239,14 @@ bool LoginServer::Connect() { return true; } void LoginServer::SendInfo() { - const WorldConfig *Config=WorldConfig::get(); + const WorldConfig *Config = WorldConfig::get(); auto pack = new ServerPacket; pack->opcode = ServerOP_LSInfo; pack->size = sizeof(ServerLSInfo_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer, 0, pack->size); - ServerLSInfo_Struct* lsi = (ServerLSInfo_Struct*) pack->pBuffer; + ServerLSInfo_Struct* lsi = (ServerLSInfo_Struct*)pack->pBuffer; strcpy(lsi->protocolversion, EQEMU_PROTOCOL_VERSION); strcpy(lsi->serverversion, LOGIN_VERSION); strcpy(lsi->name, Config->LongName.c_str()); @@ -258,14 +258,14 @@ void LoginServer::SendInfo() { } void LoginServer::SendNewInfo() { - const WorldConfig *Config=WorldConfig::get(); + const WorldConfig *Config = WorldConfig::get(); auto pack = new ServerPacket; pack->opcode = ServerOP_NewLSInfo; pack->size = sizeof(ServerNewLSInfo_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer, 0, pack->size); - ServerNewLSInfo_Struct* lsi = (ServerNewLSInfo_Struct*) pack->pBuffer; + ServerNewLSInfo_Struct* lsi = (ServerNewLSInfo_Struct*)pack->pBuffer; strcpy(lsi->protocolversion, EQEMU_PROTOCOL_VERSION); strcpy(lsi->serverversion, LOGIN_VERSION); strcpy(lsi->name, Config->LongName.c_str()); @@ -291,7 +291,7 @@ void LoginServer::SendStatus() { pack->size = sizeof(ServerLSStatus_Struct); pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer, 0, pack->size); - ServerLSStatus_Struct* lss = (ServerLSStatus_Struct*) pack->pBuffer; + ServerLSStatus_Struct* lss = (ServerLSStatus_Struct*)pack->pBuffer; if (WorldConfig::get()->Locked) lss->status = -2; @@ -307,12 +307,11 @@ void LoginServer::SendStatus() { } void LoginServer::SendAccountUpdate(ServerPacket* pack) { - ServerLSAccountUpdate_Struct* s = (ServerLSAccountUpdate_Struct *) pack->pBuffer; - if(CanUpdate()) { - Log.Out(Logs::Detail, Logs::World_Server, "Sending ServerOP_LSAccountUpdate packet to loginserver: %s:%d",LoginServerAddress,LoginServerPort); + ServerLSAccountUpdate_Struct* s = (ServerLSAccountUpdate_Struct *)pack->pBuffer; + if (CanUpdate()) { + Log(Logs::Detail, Logs::World_Server, "Sending ServerOP_LSAccountUpdate packet to loginserver: %s:%d", LoginServerAddress, LoginServerPort); strn0cpy(s->worldaccount, LoginAccount, 30); strn0cpy(s->worldpassword, LoginPassword, 30); SendPacket(pack); } } - diff --git a/world/login_server_list.cpp b/world/login_server_list.cpp index d8951847a..92d67fb82 100644 --- a/world/login_server_list.cpp +++ b/world/login_server_list.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) +Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" #include @@ -88,7 +88,7 @@ bool LoginServerList::SendPacket(ServerPacket* pack) { } bool LoginServerList::SendAccountUpdate(ServerPacket* pack) { - Log.Out(Logs::Detail, Logs::World_Server, "Requested to send ServerOP_LSAccountUpdate packet to all loginservers"); + Log(Logs::Detail, Logs::World_Server, "Requested to send ServerOP_LSAccountUpdate packet to all loginservers"); for (auto &iter : m_list) { if ((*iter).CanUpdate()) { (*iter).SendAccountUpdate(pack); @@ -137,4 +137,3 @@ bool LoginServerList::CanUpdate() { return false; } - diff --git a/world/net.cpp b/world/net.cpp index a3bb71adc..788ffcaad 100644 --- a/world/net.cpp +++ b/world/net.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) +Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" @@ -41,27 +41,27 @@ #include "client.h" #include "worlddb.h" #ifdef _WINDOWS - #include - #define snprintf _snprintf - #define strncasecmp _strnicmp - #define strcasecmp _stricmp - #include +#include +#define snprintf _snprintf +#define strncasecmp _strnicmp +#define strcasecmp _stricmp +#include #else - #include - #include "../common/unix.h" - #include - #include - #include - #include - #if not defined (FREEBSD) && not defined (DARWIN) - union semun { - int val; - struct semid_ds *buf; - ushort *array; - struct seminfo *__buf; - void *__pad; - }; - #endif +#include +#include "../common/unix.h" +#include +#include +#include +#include +#if not defined (FREEBSD) && not defined (DARWIN) +union semun { + int val; + struct semid_ds *buf; + ushort *array; + struct seminfo *__buf; + void *__pad; +}; +#endif #endif @@ -91,7 +91,7 @@ ZSList zoneserver_list; LoginServerList loginserverlist; UCSConnection UCSLink; QueryServConnection QSLink; -LauncherList launcher_list; +LauncherList launcher_list; AdventureManager adventure_manager; EQEmu::Random emu_random; volatile bool RunLoops = true; @@ -99,20 +99,20 @@ uint32 numclients = 0; uint32 numzones = 0; bool holdzones = false; const WorldConfig *Config; -EQEmuLogSys Log; +EQEmuLogSys LogSys; WebInterfaceList web_interface; void CatchSignal(int sig_num); int main(int argc, char** argv) { RegisterExecutablePlatform(ExePlatformWorld); - Log.LoadLogSettingsDefaults(); + LogSys.LoadLogSettingsDefaults(); set_exception_handler(); /* Database Version Check */ uint32 Database_Version = CURRENT_BINARY_DATABASE_VERSION; uint32 Bots_Database_Version = CURRENT_BINARY_BOTS_DATABASE_VERSION; - if (argc >= 2) { + if (argc >= 2) { if (strcasecmp(argv[1], "db_version") == 0) { std::cout << "Binary Database Version: " << Database_Version << " : " << Bots_Database_Version << std::endl; return 0; @@ -120,66 +120,67 @@ int main(int argc, char** argv) { } // Load server configuration - Log.Out(Logs::General, Logs::World_Server, "Loading server configuration.."); + Log(Logs::General, Logs::World_Server, "Loading server configuration.."); if (!WorldConfig::LoadConfig()) { - Log.Out(Logs::General, Logs::World_Server, "Loading server configuration failed."); + Log(Logs::General, Logs::World_Server, "Loading server configuration failed."); return 1; } Config = WorldConfig::get(); - Log.Out(Logs::General, Logs::World_Server, "CURRENT_VERSION: %s", CURRENT_VERSION); + Log(Logs::General, Logs::World_Server, "CURRENT_VERSION: %s", CURRENT_VERSION); - if (signal(SIGINT, CatchSignal) == SIG_ERR) { - Log.Out(Logs::General, Logs::World_Server, "Could not set signal handler"); + if (signal(SIGINT, CatchSignal) == SIG_ERR) { + Log(Logs::General, Logs::World_Server, "Could not set signal handler"); return 1; } - if (signal(SIGTERM, CatchSignal) == SIG_ERR) { - Log.Out(Logs::General, Logs::World_Server, "Could not set signal handler"); + if (signal(SIGTERM, CatchSignal) == SIG_ERR) { + Log(Logs::General, Logs::World_Server, "Could not set signal handler"); return 1; } - #ifndef WIN32 - if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { - Log.Out(Logs::General, Logs::World_Server, "Could not set signal handler"); +#ifndef WIN32 + if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { + Log(Logs::General, Logs::World_Server, "Could not set signal handler"); return 1; } - #endif +#endif // add login server config to list if (Config->LoginCount == 0) { if (Config->LoginHost.length()) { loginserverlist.Add(Config->LoginHost.c_str(), Config->LoginPort, Config->LoginAccount.c_str(), Config->LoginPassword.c_str(), Config->LoginLegacy); - Log.Out(Logs::General, Logs::World_Server, "Added loginserver %s:%i", Config->LoginHost.c_str(), Config->LoginPort); + Log(Logs::General, Logs::World_Server, "Added loginserver %s:%i", Config->LoginHost.c_str(), Config->LoginPort); } - } else { - LinkedList loginlist=Config->loginlist; + } + else { + LinkedList loginlist = Config->loginlist; LinkedListIterator iterator(loginlist); iterator.Reset(); - while(iterator.MoreElements()) { + while (iterator.MoreElements()) { loginserverlist.Add(iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort, iterator.GetData()->LoginAccount.c_str(), iterator.GetData()->LoginPassword.c_str(), iterator.GetData()->LoginLegacy); - Log.Out(Logs::General, Logs::World_Server, "Added loginserver %s:%i", iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort); + Log(Logs::General, Logs::World_Server, "Added loginserver %s:%i", iterator.GetData()->LoginHost.c_str(), iterator.GetData()->LoginPort); iterator.Advance(); } } - Log.Out(Logs::General, Logs::World_Server, "Connecting to MySQL..."); + Log(Logs::General, Logs::World_Server, "Connecting to MySQL..."); if (!database.Connect( Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(), Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) { - Log.Out(Logs::General, Logs::World_Server, "Cannot continue without a database connection."); + Log(Logs::General, Logs::World_Server, "Cannot continue without a database connection."); return 1; } guild_mgr.SetDatabase(&database); /* Register Log System and Settings */ - database.LoadLogSettings(Log.log_settings); - Log.StartFileLogs(); + database.LoadLogSettings(LogSys.log_settings); + LogSys.StartFileLogs(); bool ignore_db = false; if (argc >= 2) { @@ -227,7 +228,7 @@ int main(int argc, char** argv) { if (argc == 4) { if (Seperator::IsNumber(argv[3])) { if (atoi(argv[3]) >= 0 && atoi(argv[3]) <= 255) { - if (database.SetAccountStatus(argv[2], atoi(argv[3]))){ + if (database.SetAccountStatus(argv[2], atoi(argv[3]))) { std::cout << "Account flagged: Username='" << argv[2] << "', status=" << argv[3] << std::endl; return 0; } @@ -266,7 +267,7 @@ int main(int argc, char** argv) { std::cout << "Usage: world startzone zoneshortname" << std::endl; return 0; } - else if(strcasecmp(argv[1], "ignore_db") == 0) { + else if (strcasecmp(argv[1], "ignore_db") == 0) { ignore_db = true; } else { @@ -275,100 +276,102 @@ int main(int argc, char** argv) { } } - if(!ignore_db) { - Log.Out(Logs::General, Logs::World_Server, "Checking Database Conversions.."); + if (!ignore_db) { + Log(Logs::General, Logs::World_Server, "Checking Database Conversions.."); database.CheckDatabaseConversions(); } - Log.Out(Logs::General, Logs::World_Server, "Loading variables.."); + Log(Logs::General, Logs::World_Server, "Loading variables.."); database.LoadVariables(); std::string hotfix_name; - if(database.GetVariable("hotfix_name", hotfix_name)) { + if (database.GetVariable("hotfix_name", hotfix_name)) { if (!hotfix_name.empty()) { - Log.Out(Logs::General, Logs::Zone_Server, "Current hotfix in use: '%s'", hotfix_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Current hotfix in use: '%s'", hotfix_name.c_str()); } } - Log.Out(Logs::General, Logs::World_Server, "Loading zones.."); + Log(Logs::General, Logs::World_Server, "Loading zones.."); database.LoadZoneNames(); - Log.Out(Logs::General, Logs::World_Server, "Clearing groups.."); + Log(Logs::General, Logs::World_Server, "Clearing groups.."); database.ClearGroup(); - Log.Out(Logs::General, Logs::World_Server, "Clearing raids.."); + Log(Logs::General, Logs::World_Server, "Clearing raids.."); database.ClearRaid(); database.ClearRaidDetails(); database.ClearRaidLeader(); - Log.Out(Logs::General, Logs::World_Server, "Clearing inventory snapshots.."); + Log(Logs::General, Logs::World_Server, "Clearing inventory snapshots.."); database.ClearInvSnapshots(); - Log.Out(Logs::General, Logs::World_Server, "Loading items.."); - if(!database.LoadItems(hotfix_name)) - Log.Out(Logs::General, Logs::World_Server, "Error: Could not load item data. But ignoring"); - Log.Out(Logs::General, Logs::World_Server, "Loading skill caps.."); - if(!database.LoadSkillCaps(std::string(hotfix_name))) - Log.Out(Logs::General, Logs::World_Server, "Error: Could not load skill cap data. But ignoring"); - Log.Out(Logs::General, Logs::World_Server, "Loading guilds.."); + Log(Logs::General, Logs::World_Server, "Loading items.."); + if (!database.LoadItems(hotfix_name)) + Log(Logs::General, Logs::World_Server, "Error: Could not load item data. But ignoring"); + Log(Logs::General, Logs::World_Server, "Loading skill caps.."); + if (!database.LoadSkillCaps(std::string(hotfix_name))) + Log(Logs::General, Logs::World_Server, "Error: Could not load skill cap data. But ignoring"); + Log(Logs::General, Logs::World_Server, "Loading guilds.."); guild_mgr.LoadGuilds(); //rules: { std::string tmp; if (database.GetVariable("RuleSet", tmp)) { - Log.Out(Logs::General, Logs::World_Server, "Loading rule set '%s'", tmp.c_str()); - if(!RuleManager::Instance()->LoadRules(&database, tmp.c_str())) { - Log.Out(Logs::General, Logs::World_Server, "Failed to load ruleset '%s', falling back to defaults.", tmp.c_str()); + Log(Logs::General, Logs::World_Server, "Loading rule set '%s'", tmp.c_str()); + if (!RuleManager::Instance()->LoadRules(&database, tmp.c_str())) { + Log(Logs::General, Logs::World_Server, "Failed to load ruleset '%s', falling back to defaults.", tmp.c_str()); } - } else { - if(!RuleManager::Instance()->LoadRules(&database, "default")) { - Log.Out(Logs::General, Logs::World_Server, "No rule set configured, using default rules"); - } else { - Log.Out(Logs::General, Logs::World_Server, "Loaded default rule set 'default'", tmp.c_str()); + } + else { + if (!RuleManager::Instance()->LoadRules(&database, "default")) { + Log(Logs::General, Logs::World_Server, "No rule set configured, using default rules"); + } + else { + Log(Logs::General, Logs::World_Server, "Loaded default rule set 'default'", tmp.c_str()); } } } - if(RuleB(World, ClearTempMerchantlist)){ - Log.Out(Logs::General, Logs::World_Server, "Clearing temporary merchant lists.."); + if (RuleB(World, ClearTempMerchantlist)) { + Log(Logs::General, Logs::World_Server, "Clearing temporary merchant lists.."); database.ClearMerchantTemp(); } - Log.Out(Logs::General, Logs::World_Server, "Loading EQ time of day.."); + Log(Logs::General, Logs::World_Server, "Loading EQ time of day.."); TimeOfDay_Struct eqTime; time_t realtime; eqTime = database.LoadTime(realtime); zoneserver_list.worldclock.SetCurrentEQTimeOfDay(eqTime, realtime); Timer EQTimeTimer(600000); EQTimeTimer.Start(600000); - - Log.Out(Logs::General, Logs::World_Server, "Loading launcher list.."); + + Log(Logs::General, Logs::World_Server, "Loading launcher list.."); launcher_list.LoadList(); std::string tmp; - database.GetVariable("holdzones",tmp); + database.GetVariable("holdzones", tmp); if (tmp.length() == 1 && tmp[0] == '1') { holdzones = true; } - Log.Out(Logs::General, Logs::World_Server, "Reboot zone modes %s",holdzones ? "ON" : "OFF"); + Log(Logs::General, Logs::World_Server, "Reboot zone modes %s", holdzones ? "ON" : "OFF"); - Log.Out(Logs::General, Logs::World_Server, "Deleted %i stale player corpses from database", database.DeleteStalePlayerCorpses()); + Log(Logs::General, Logs::World_Server, "Deleted %i stale player corpses from database", database.DeleteStalePlayerCorpses()); - Log.Out(Logs::General, Logs::World_Server, "Loading adventures..."); - if(!adventure_manager.LoadAdventureTemplates()) + Log(Logs::General, Logs::World_Server, "Loading adventures..."); + if (!adventure_manager.LoadAdventureTemplates()) { - Log.Out(Logs::General, Logs::World_Server, "Unable to load adventure templates."); + Log(Logs::General, Logs::World_Server, "Unable to load adventure templates."); } - if(!adventure_manager.LoadAdventureEntries()) + if (!adventure_manager.LoadAdventureEntries()) { - Log.Out(Logs::General, Logs::World_Server, "Unable to load adventure templates."); + Log(Logs::General, Logs::World_Server, "Unable to load adventure templates."); } adventure_manager.Load(); adventure_manager.LoadLeaderboardInfo(); - Log.Out(Logs::General, Logs::World_Server, "Purging expired instances"); + Log(Logs::General, Logs::World_Server, "Purging expired instances"); database.PurgeExpiredInstances(); Timer PurgeInstanceTimer(450000); PurgeInstanceTimer.Start(450000); - Log.Out(Logs::General, Logs::World_Server, "Loading char create info..."); + Log(Logs::General, Logs::World_Server, "Loading char create info..."); database.LoadCharacterCreateAllocations(); database.LoadCharacterCreateCombos(); @@ -380,10 +383,10 @@ int main(int argc, char** argv) { server_opts.ipv6 = false; server_opts.credentials = Config->SharedKey; server_connection->Listen(server_opts); - Log.Out(Logs::General, Logs::World_Server, "Server (TCP) listener started."); + Log(Logs::General, Logs::World_Server, "Server (TCP) listener started."); server_connection->OnConnectionIdentified("Zone", [](std::shared_ptr connection) { - Log.OutF(Logs::General, Logs::World_Server, "New Zone Server connection from {2} at {0}:{1}", + LogF(Logs::General, Logs::World_Server, "New Zone Server connection from {2} at {0}:{1}", connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID()); numzones++; @@ -391,7 +394,7 @@ int main(int argc, char** argv) { }); server_connection->OnConnectionRemoved("Zone", [](std::shared_ptr connection) { - Log.OutF(Logs::General, Logs::World_Server, "Removed Zone Server connection from {0}", + LogF(Logs::General, Logs::World_Server, "Removed Zone Server connection from {0}", connection->GetUUID()); numzones--; @@ -399,56 +402,56 @@ int main(int argc, char** argv) { }); server_connection->OnConnectionIdentified("Launcher", [](std::shared_ptr connection) { - Log.OutF(Logs::General, Logs::World_Server, "New Launcher connection from {2} at {0}:{1}", + LogF(Logs::General, Logs::World_Server, "New Launcher connection from {2} at {0}:{1}", connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID()); launcher_list.Add(connection); }); server_connection->OnConnectionRemoved("Launcher", [](std::shared_ptr connection) { - Log.OutF(Logs::General, Logs::World_Server, "Removed Launcher connection from {0}", + LogF(Logs::General, Logs::World_Server, "Removed Launcher connection from {0}", connection->GetUUID()); launcher_list.Remove(connection); }); server_connection->OnConnectionIdentified("QueryServ", [](std::shared_ptr connection) { - Log.OutF(Logs::General, Logs::World_Server, "New Query Server connection from {2} at {0}:{1}", + LogF(Logs::General, Logs::World_Server, "New Query Server connection from {2} at {0}:{1}", connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID()); QSLink.AddConnection(connection); }); server_connection->OnConnectionRemoved("QueryServ", [](std::shared_ptr connection) { - Log.OutF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}", + LogF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}", connection->GetUUID()); QSLink.RemoveConnection(connection); }); server_connection->OnConnectionIdentified("UCS", [](std::shared_ptr connection) { - Log.OutF(Logs::General, Logs::World_Server, "New UCS Server connection from {2} at {0}:{1}", + LogF(Logs::General, Logs::World_Server, "New UCS Server connection from {2} at {0}:{1}", connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID()); UCSLink.SetConnection(connection); }); server_connection->OnConnectionRemoved("UCS", [](std::shared_ptr connection) { - Log.OutF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}", + LogF(Logs::General, Logs::World_Server, "Removed Query Server connection from {0}", connection->GetUUID()); UCSLink.SetConnection(nullptr); }); server_connection->OnConnectionIdentified("WebInterface", [](std::shared_ptr connection) { - Log.OutF(Logs::General, Logs::World_Server, "New WebInterface Server connection from {2} at {0}:{1}", + LogF(Logs::General, Logs::World_Server, "New WebInterface Server connection from {2} at {0}:{1}", connection->Handle()->RemoteIP(), connection->Handle()->RemotePort(), connection->GetUUID()); web_interface.AddConnection(connection); }); server_connection->OnConnectionRemoved("WebInterface", [](std::shared_ptr connection) { - Log.OutF(Logs::General, Logs::World_Server, "Removed WebInterface Server connection from {0}", + LogF(Logs::General, Logs::World_Server, "Removed WebInterface Server connection from {0}", connection->GetUUID()); web_interface.RemoveConnection(connection); @@ -472,10 +475,10 @@ int main(int argc, char** argv) { eqsm.OnNewConnection([&stream_identifier](std::shared_ptr stream) { stream_identifier.AddStream(stream); - Log.OutF(Logs::Detail, Logs::World_Server, "New connection from IP {0}:{1}", stream->RemoteEndpoint(), ntohs(stream->GetRemotePort())); + LogF(Logs::Detail, Logs::World_Server, "New connection from IP {0}:{1}", stream->RemoteEndpoint(), ntohs(stream->GetRemotePort())); }); - while(RunLoops) { + while (RunLoops) { Timer::SetCurrentTime(); eqs = nullptr; @@ -483,33 +486,34 @@ int main(int argc, char** argv) { stream_identifier.Process(); //check the stream identifier for any now-identified streams - while((eqsi = stream_identifier.PopIdentified())) { + while ((eqsi = stream_identifier.PopIdentified())) { //now that we know what patch they are running, start up their client object struct in_addr in; in.s_addr = eqsi->GetRemoteIP(); - if (RuleB(World, UseBannedIPsTable)){ //Lieka: Check to see if we have the responsibility for blocking IPs. - Log.Out(Logs::Detail, Logs::World_Server, "Checking inbound connection %s against BannedIPs table", inet_ntoa(in)); - if (!database.CheckBannedIPs(inet_ntoa(in))){ //Lieka: Check inbound IP against banned IP table. - Log.Out(Logs::Detail, Logs::World_Server, "Connection %s PASSED banned IPs check. Processing connection.", inet_ntoa(in)); + if (RuleB(World, UseBannedIPsTable)) { //Lieka: Check to see if we have the responsibility for blocking IPs. + Log(Logs::Detail, Logs::World_Server, "Checking inbound connection %s against BannedIPs table", inet_ntoa(in)); + if (!database.CheckBannedIPs(inet_ntoa(in))) { //Lieka: Check inbound IP against banned IP table. + Log(Logs::Detail, Logs::World_Server, "Connection %s PASSED banned IPs check. Processing connection.", inet_ntoa(in)); auto client = new Client(eqsi); // @merth: client->zoneattempt=0; client_list.Add(client); - } else { - Log.Out(Logs::General, Logs::World_Server, "Connection from %s FAILED banned IPs check. Closing connection.", inet_ntoa(in)); + } + else { + Log(Logs::General, Logs::World_Server, "Connection from %s FAILED banned IPs check. Closing connection.", inet_ntoa(in)); eqsi->Close(); //Lieka: If the inbound IP is on the banned table, close the EQStream. } } - if (!RuleB(World, UseBannedIPsTable)){ - Log.Out(Logs::Detail, Logs::World_Server, "New connection from %s:%d, processing connection", inet_ntoa(in), ntohs(eqsi->GetRemotePort())); - auto client = new Client(eqsi); - // @merth: client->zoneattempt=0; - client_list.Add(client); + if (!RuleB(World, UseBannedIPsTable)) { + Log(Logs::Detail, Logs::World_Server, "New connection from %s:%d, processing connection", inet_ntoa(in), ntohs(eqsi->GetRemotePort())); + auto client = new Client(eqsi); + // @merth: client->zoneattempt=0; + client_list.Add(client); } } client_list.Process(); - if(PurgeInstanceTimer.Check()) + if (PurgeInstanceTimer.Check()) { database.PurgeExpiredInstances(); } @@ -519,36 +523,36 @@ int main(int argc, char** argv) { TimeOfDay_Struct tod; zoneserver_list.worldclock.GetCurrentEQTimeOfDay(time(0), &tod); if (!database.SaveTime(tod.minute, tod.hour, tod.day, tod.month, tod.year)) - Log.Out(Logs::General, Logs::World_Server, "Failed to save eqtime."); + Log(Logs::General, Logs::World_Server, "Failed to save eqtime."); else - Log.Out(Logs::Detail, Logs::World_Server, "EQTime successfully saved."); + Log(Logs::Detail, Logs::World_Server, "EQTime successfully saved."); } - + zoneserver_list.Process(); launcher_list.Process(); - LFPGroupList.Process(); + LFPGroupList.Process(); adventure_manager.Process(); if (InterserverTimer.Check()) { InterserverTimer.Start(); - database.ping(); + database.ping(); } - + EQ::EventLoop::Get().Process(); Sleep(5); } - Log.Out(Logs::General, Logs::World_Server, "World main loop completed."); - Log.Out(Logs::General, Logs::World_Server, "Shutting down zone connections (if any)."); + Log(Logs::General, Logs::World_Server, "World main loop completed."); + Log(Logs::General, Logs::World_Server, "Shutting down zone connections (if any)."); zoneserver_list.KillAll(); - Log.Out(Logs::General, Logs::World_Server, "Zone (TCP) listener stopped."); - Log.Out(Logs::General, Logs::World_Server, "Signaling HTTP service to stop..."); - Log.CloseFileLogs(); + Log(Logs::General, Logs::World_Server, "Zone (TCP) listener stopped."); + Log(Logs::General, Logs::World_Server, "Signaling HTTP service to stop..."); + LogSys.CloseFileLogs(); return 0; } void CatchSignal(int sig_num) { - Log.Out(Logs::General, Logs::World_Server,"Caught signal %d",sig_num); + Log(Logs::General, Logs::World_Server, "Caught signal %d", sig_num); RunLoops = false; } @@ -564,4 +568,3 @@ void UpdateWindowTitle(char* iNewTitle) { SetConsoleTitle(tmp); #endif } - diff --git a/world/queryserv.cpp b/world/queryserv.cpp index b943ca57f..e3cf2a51f 100644 --- a/world/queryserv.cpp +++ b/world/queryserv.cpp @@ -51,4 +51,4 @@ bool QueryServConnection::SendPacket(ServerPacket* pack) } return true; -} +} \ No newline at end of file diff --git a/world/ucs.cpp b/world/ucs.cpp index 4208bc24a..de642fe0d 100644 --- a/world/ucs.cpp +++ b/world/ucs.cpp @@ -14,9 +14,9 @@ UCSConnection::UCSConnection() void UCSConnection::SetConnection(std::shared_ptr inStream) { - if(Stream && Stream->Handle()) + if (Stream && Stream->Handle()) { - Log.Out(Logs::Detail, Logs::UCS_Server, "Incoming UCS Connection while we were already connected to a UCS."); + Log(Logs::Detail, Logs::UCS_Server, "Incoming UCS Connection while we were already connected to a UCS."); Stream->Handle()->Disconnect(); } @@ -34,33 +34,33 @@ void UCSConnection::ProcessPacket(uint16 opcode, EQ::Net::Packet &p) ServerPacket tpack(opcode, p); ServerPacket *pack = &tpack; - switch(opcode) + switch (opcode) { - case 0: - break; + case 0: + break; - case ServerOP_KeepAlive: - { - // ignore this - break; - } - case ServerOP_ZAAuth: - { - Log.Out(Logs::Detail, Logs::UCS_Server, "Got authentication from UCS when they are already authenticated."); - break; - } - default: - { - Log.Out(Logs::Detail, Logs::UCS_Server, "Unknown ServerOPcode from UCS 0x%04x, size %d", opcode, pack->size); - DumpPacket(pack->pBuffer, pack->size); - break; - } + case ServerOP_KeepAlive: + { + // ignore this + break; + } + case ServerOP_ZAAuth: + { + Log(Logs::Detail, Logs::UCS_Server, "Got authentication from UCS when they are already authenticated."); + break; + } + default: + { + Log(Logs::Detail, Logs::UCS_Server, "Unknown ServerOPcode from UCS 0x%04x, size %d", opcode, pack->size); + DumpPacket(pack->pBuffer, pack->size); + break; + } } } void UCSConnection::SendPacket(ServerPacket* pack) { - if(!Stream) + if (!Stream) return; Stream->SendPacket(pack); @@ -78,4 +78,3 @@ void UCSConnection::SendMessage(const char *From, const char *Message) SendPacket(pack); safe_delete(pack); } - diff --git a/world/wguild_mgr.cpp b/world/wguild_mgr.cpp index b2750ded2..dbc20fba6 100644 --- a/world/wguild_mgr.cpp +++ b/world/wguild_mgr.cpp @@ -34,7 +34,7 @@ WorldGuildManager guild_mgr; void WorldGuildManager::SendGuildRefresh(uint32 guild_id, bool name, bool motd, bool rank, bool relation) { - Log.Out(Logs::Detail, Logs::Guilds, "Broadcasting guild refresh for %d, changes: name=%d, motd=%d, rank=d, relation=%d", guild_id, name, motd, rank, relation); + Log(Logs::Detail, Logs::Guilds, "Broadcasting guild refresh for %d, changes: name=%d, motd=%d, rank=d, relation=%d", guild_id, name, motd, rank, relation); auto pack = new ServerPacket(ServerOP_RefreshGuild, sizeof(ServerGuildRefresh_Struct)); ServerGuildRefresh_Struct *s = (ServerGuildRefresh_Struct *) pack->pBuffer; s->guild_id = guild_id; @@ -47,7 +47,7 @@ void WorldGuildManager::SendGuildRefresh(uint32 guild_id, bool name, bool motd, } void WorldGuildManager::SendCharRefresh(uint32 old_guild_id, uint32 guild_id, uint32 charid) { - Log.Out(Logs::Detail, Logs::Guilds, "Broadcasting char refresh for %d from guild %d to world", charid, guild_id); + Log(Logs::Detail, Logs::Guilds, "Broadcasting char refresh for %d from guild %d to world", charid, guild_id); auto pack = new ServerPacket(ServerOP_GuildCharRefresh, sizeof(ServerGuildCharRefresh_Struct)); ServerGuildCharRefresh_Struct *s = (ServerGuildCharRefresh_Struct *) pack->pBuffer; s->guild_id = guild_id; @@ -58,7 +58,7 @@ void WorldGuildManager::SendCharRefresh(uint32 old_guild_id, uint32 guild_id, ui } void WorldGuildManager::SendGuildDelete(uint32 guild_id) { - Log.Out(Logs::Detail, Logs::Guilds, "Broadcasting guild delete for guild %d to world", guild_id); + Log(Logs::Detail, Logs::Guilds, "Broadcasting guild delete for guild %d to world", guild_id); auto pack = new ServerPacket(ServerOP_DeleteGuild, sizeof(ServerGuildID_Struct)); ServerGuildID_Struct *s = (ServerGuildID_Struct *) pack->pBuffer; s->guild_id = guild_id; @@ -71,18 +71,18 @@ void WorldGuildManager::ProcessZonePacket(ServerPacket *pack) { case ServerOP_RefreshGuild: { if(pack->size != sizeof(ServerGuildRefresh_Struct)) { - Log.Out(Logs::Detail, Logs::Guilds, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildRefresh_Struct)); + Log(Logs::Detail, Logs::Guilds, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildRefresh_Struct)); return; } ServerGuildRefresh_Struct *s = (ServerGuildRefresh_Struct *) pack->pBuffer; - Log.Out(Logs::Detail, Logs::Guilds, "Received and broadcasting guild refresh for %d, changes: name=%d, motd=%d, rank=d, relation=%d", s->guild_id, s->name_change, s->motd_change, s->rank_change, s->relation_change); + Log(Logs::Detail, Logs::Guilds, "Received and broadcasting guild refresh for %d, changes: name=%d, motd=%d, rank=d, relation=%d", s->guild_id, s->name_change, s->motd_change, s->rank_change, s->relation_change); //broadcast this packet to all zones. zoneserver_list.SendPacket(pack); //preform a local refresh. if(!RefreshGuild(s->guild_id)) { - Log.Out(Logs::Detail, Logs::Guilds, "Unable to preform local refresh on guild %d", s->guild_id); + Log(Logs::Detail, Logs::Guilds, "Unable to preform local refresh on guild %d", s->guild_id); //can we do anything? } @@ -91,11 +91,11 @@ void WorldGuildManager::ProcessZonePacket(ServerPacket *pack) { case ServerOP_GuildCharRefresh: { if(pack->size != sizeof(ServerGuildCharRefresh_Struct)) { - Log.Out(Logs::Detail, Logs::Guilds, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildCharRefresh_Struct)); + Log(Logs::Detail, Logs::Guilds, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildCharRefresh_Struct)); return; } ServerGuildCharRefresh_Struct *s = (ServerGuildCharRefresh_Struct *) pack->pBuffer; - Log.Out(Logs::Detail, Logs::Guilds, "Received and broadcasting guild member refresh for char %d to all zones with members of guild %d", s->char_id, s->guild_id); + Log(Logs::Detail, Logs::Guilds, "Received and broadcasting guild member refresh for char %d to all zones with members of guild %d", s->char_id, s->guild_id); //preform the local update client_list.UpdateClientGuild(s->char_id, s->guild_id); @@ -110,18 +110,18 @@ void WorldGuildManager::ProcessZonePacket(ServerPacket *pack) { case ServerOP_DeleteGuild: { if(pack->size != sizeof(ServerGuildID_Struct)) { - Log.Out(Logs::Detail, Logs::Guilds, "Received ServerOP_DeleteGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildID_Struct)); + Log(Logs::Detail, Logs::Guilds, "Received ServerOP_DeleteGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildID_Struct)); return; } ServerGuildID_Struct *s = (ServerGuildID_Struct *) pack->pBuffer; - Log.Out(Logs::Detail, Logs::Guilds, "Received and broadcasting guild delete for guild %d", s->guild_id); + Log(Logs::Detail, Logs::Guilds, "Received and broadcasting guild delete for guild %d", s->guild_id); //broadcast this packet to all zones. zoneserver_list.SendPacket(pack); //preform a local refresh. if(!LocalDeleteGuild(s->guild_id)) { - Log.Out(Logs::Detail, Logs::Guilds, "Unable to preform local delete on guild %d", s->guild_id); + Log(Logs::Detail, Logs::Guilds, "Unable to preform local delete on guild %d", s->guild_id); //can we do anything? } @@ -131,7 +131,7 @@ void WorldGuildManager::ProcessZonePacket(ServerPacket *pack) { case ServerOP_GuildMemberUpdate: { if(pack->size != sizeof(ServerGuildMemberUpdate_Struct)) { - Log.Out(Logs::Detail, Logs::Guilds, "Received ServerOP_GuildMemberUpdate of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildMemberUpdate_Struct)); + Log(Logs::Detail, Logs::Guilds, "Received ServerOP_GuildMemberUpdate of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildMemberUpdate_Struct)); return; } @@ -141,7 +141,7 @@ void WorldGuildManager::ProcessZonePacket(ServerPacket *pack) { } default: - Log.Out(Logs::Detail, Logs::Guilds, "Unknown packet 0x%x received from zone??", pack->opcode); + Log(Logs::Detail, Logs::Guilds, "Unknown packet 0x%x received from zone??", pack->opcode); break; } } diff --git a/world/worlddb.cpp b/world/worlddb.cpp index cd6733770..0b118ff2e 100644 --- a/world/worlddb.cpp +++ b/world/worlddb.cpp @@ -361,14 +361,14 @@ bool WorldDatabase::GetStartZone(PlayerProfile_Struct* in_pp, CharCreate_Struct* return false; } - Log.Out(Logs::General, Logs::Status, "SoF Start zone query: %s\n", query.c_str()); + Log(Logs::General, Logs::Status, "SoF Start zone query: %s\n", query.c_str()); if (results.RowCount() == 0) { printf("No start_zones entry in database, using defaults\n"); isTitanium ? SetTitaniumDefaultStartZone(in_pp, in_cc) : SetSoFDefaultStartZone(in_pp, in_cc); } else { - Log.Out(Logs::General, Logs::Status, "Found starting location in start_zones"); + Log(Logs::General, Logs::Status, "Found starting location in start_zones"); auto row = results.begin(); in_pp->x = atof(row[0]); in_pp->y = atof(row[1]); @@ -507,7 +507,7 @@ void WorldDatabase::GetLauncherList(std::vector &rl) { const std::string query = "SELECT name FROM launcher"; auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "WorldDatabase::GetLauncherList: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "WorldDatabase::GetLauncherList: %s", results.ErrorMessage().c_str()); return; } @@ -529,7 +529,7 @@ void WorldDatabase::SetMailKey(int CharID, int IPAddress, int MailKey) MailKeyString, CharID); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "WorldDatabase::SetMailKey(%i, %s) : %s", CharID, MailKeyString, results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "WorldDatabase::SetMailKey(%i, %s) : %s", CharID, MailKeyString, results.ErrorMessage().c_str()); } @@ -538,7 +538,7 @@ bool WorldDatabase::GetCharacterLevel(const char *name, int &level) std::string query = StringFormat("SELECT level FROM character_data WHERE name = '%s'", name); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "WorldDatabase::GetCharacterLevel: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "WorldDatabase::GetCharacterLevel: %s", results.ErrorMessage().c_str()); return false; } diff --git a/world/zonelist.cpp b/world/zonelist.cpp index c0b2f6348..a1f0a60ff 100644 --- a/world/zonelist.cpp +++ b/world/zonelist.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" #include "zonelist.h" @@ -38,7 +38,7 @@ ZSList::ZSList() { NextID = 1; CurGroupID = 1; - LastAllocatedPort=0; + LastAllocatedPort = 0; memset(pLockedZones, 0, sizeof(pLockedZones)); m_tick.reset(new EQ::Timer(5000, true, std::bind(&ZSList::OnTick, this, std::placeholders::_1))); @@ -83,7 +83,7 @@ void ZSList::Remove(const std::string &uuid) void ZSList::KillAll() { auto iterator = list.begin(); - while(iterator != list.end()) { + while (iterator != list.end()) { (*iterator)->Disconnect(); iterator = list.erase(iterator); } @@ -91,19 +91,19 @@ void ZSList::KillAll() { void ZSList::Process() { - if(shutdowntimer && shutdowntimer->Check()){ - Log.Out(Logs::Detail, Logs::World_Server, "Shutdown timer has expired. Telling all zones to shut down and exiting. (fake sigint)"); + if (shutdowntimer && shutdowntimer->Check()) { + Log(Logs::Detail, Logs::World_Server, "Shutdown timer has expired. Telling all zones to shut down and exiting. (fake sigint)"); auto pack2 = new ServerPacket; pack2->opcode = ServerOP_ShutdownAll; - pack2->size=0; + pack2->size = 0; SendPacket(pack2); safe_delete(pack2); Process(); CatchSignal(2); } - if(reminder && reminder->Check() && shutdowntimer){ - SendEmoteMessage(0,0,0,15,":SYSTEM MSG:World coming down, everyone log out now. World will shut down in %i minutes...", ((shutdowntimer->GetRemainingTime()/1000) / 60)); + if (reminder && reminder->Check() && shutdowntimer) { + SendEmoteMessage(0, 0, 0, 15, ":SYSTEM MSG:World coming down, everyone log out now. World will shut down in %i minutes...", ((shutdowntimer->GetRemainingTime() / 1000) / 60)); } } @@ -130,11 +130,11 @@ bool ZSList::SendPacket(uint32 ZoneID, ServerPacket* pack) { } bool ZSList::SendPacket(uint32 ZoneID, uint16 instanceID, ServerPacket* pack) { - if(instanceID != 0) + if (instanceID != 0) { auto iterator = list.begin(); while (iterator != list.end()) { - if((*iterator)->GetInstanceID() == instanceID) { + if ((*iterator)->GetInstanceID() == instanceID) { ZoneServer* tmp = (*iterator).get(); tmp->SendPacket(pack); return true; @@ -258,7 +258,7 @@ void ZSList::ListLockedZones(const char* to, WorldTCPConnection* connection) { void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* connection) { char locked[4]; - if (WorldConfig::get()->Locked == true){ + if (WorldConfig::get()->Locked == true) { strcpy(locked, "Yes"); } else { @@ -268,16 +268,16 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con char* output = 0; uint32 outsize = 0, outlen = 0; - if (connection->IsConsole()){ + if (connection->IsConsole()) { AppendAnyLenString(&output, &outsize, &outlen, "World Locked: %s\r\n", locked); } - else{ + else { AppendAnyLenString(&output, &outsize, &outlen, "World Locked: %s^", locked); } - if (connection->IsConsole()){ + if (connection->IsConsole()) { AppendAnyLenString(&output, &outsize, &outlen, "Zoneservers online:\r\n"); } - else{ + else { AppendAnyLenString(&output, &outsize, &outlen, "Zoneservers online:^"); } @@ -292,13 +292,13 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con zone_server_data = (*iterator).get(); auto addr = zone_server_data->GetIP(); - if (zone_server_data->IsStaticZone()){ + if (zone_server_data->IsStaticZone()) { z++; } - else if (zone_server_data->GetZoneID() != 0){ + else if (zone_server_data->GetZoneID() != 0) { w++; } - else if (zone_server_data->GetZoneID() == 0 && !zone_server_data->IsBootingUp()){ + else if (zone_server_data->GetZoneID() == 0 && !zone_server_data->IsBootingUp()) { v++; } @@ -308,29 +308,29 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con is_static_string[0] = 'D'; if (admin >= 150) { - if (zone_server_data->GetZoneID()){ + if (zone_server_data->GetZoneID()) { snprintf(zone_data_string, sizeof(zone_data_string), "%s (%i)", zone_server_data->GetZoneName(), zone_server_data->GetZoneID()); } - else if (zone_server_data->IsBootingUp()){ + else if (zone_server_data->IsBootingUp()) { strcpy(zone_data_string, "..."); } - else{ + else { zone_data_string[0] = 0; } - AppendAnyLenString(&output, &outsize, &outlen, - "#%-3i :: %s :: %15s:%-5i :: %2i :: %s:%i :: %s :: (%u)", - zone_server_data->GetID(), - is_static_string, + AppendAnyLenString(&output, &outsize, &outlen, + "#%-3i :: %s :: %15s:%-5i :: %2i :: %s:%i :: %s :: (%u)", + zone_server_data->GetID(), + is_static_string, addr.c_str(), - zone_server_data->GetPort(), - zone_server_data->NumPlayers(), - zone_server_data->GetCAddress(), - zone_server_data->GetCPort(), + zone_server_data->GetPort(), + zone_server_data->NumPlayers(), + zone_server_data->GetCAddress(), + zone_server_data->GetCPort(), zone_data_string, zone_server_data->GetZoneOSProcessID() - ); - + ); + if (outlen >= 3584) { connection->SendEmoteMessageRaw(to, 0, 0, 10, output); safe_delete(output); @@ -358,10 +358,10 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con outlen = 0; } else { - if (connection->IsConsole()){ + if (connection->IsConsole()) { AppendAnyLenString(&output, &outsize, &outlen, "\r\n"); } - else{ + else { AppendAnyLenString(&output, &outsize, &outlen, "^"); } } @@ -371,7 +371,7 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con iterator++; } - if (connection->IsConsole()){ + if (connection->IsConsole()) { AppendAnyLenString(&output, &outsize, &outlen, "%i servers listed. %i servers online.\r\n", x, y); } else { @@ -380,7 +380,7 @@ void ZSList::SendZoneStatus(const char* to, int16 admin, WorldTCPConnection* con AppendAnyLenString(&output, &outsize, &outlen, "%i zones are static zones, %i zones are booted zones, %i zones available.", z, w, v); - if (output){ + if (output) { connection->SendEmoteMessageRaw(to, 0, 0, 10, output); } @@ -406,10 +406,10 @@ void ZSList::SendChannelMessageRaw(const char* from, const char* to, uint8 chan_ auto pack = new ServerPacket; pack->opcode = ServerOP_ChannelMessage; - pack->size = sizeof(ServerChannelMessage_Struct)+strlen(message)+1; + pack->size = sizeof(ServerChannelMessage_Struct) + strlen(message) + 1; pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer, 0, pack->size); - ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*) pack->pBuffer; + ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*)pack->pBuffer; if (from == 0) { strcpy(scm->from, "WServer"); scm->noreply = true; @@ -421,8 +421,8 @@ void ZSList::SendChannelMessageRaw(const char* from, const char* to, uint8 chan_ else strcpy(scm->from, from); if (to != 0) { - strcpy((char *) scm->to, to); - strcpy((char *) scm->deliverto, to); + strcpy((char *)scm->to, to); + strcpy((char *)scm->deliverto, to); } else { scm->to[0] = 0; @@ -457,13 +457,13 @@ void ZSList::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_m auto pack = new ServerPacket; pack->opcode = ServerOP_EmoteMessage; - pack->size = sizeof(ServerEmoteMessage_Struct)+strlen(message)+1; + pack->size = sizeof(ServerEmoteMessage_Struct) + strlen(message) + 1; pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer, 0, pack->size); - ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*) pack->pBuffer; + ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer; if (to) { - strcpy((char *) sem->to, to); + strcpy((char *)sem->to, to); } else { sem->to[0] = 0; @@ -473,9 +473,9 @@ void ZSList::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_m sem->minstatus = to_minstatus; sem->type = type; strcpy(&sem->message[0], message); - char tempto[64]={0}; - if(to) - strn0cpy(tempto,to,64); + char tempto[64] = { 0 }; + if (to) + strn0cpy(tempto, to, 64); if (tempto[0] == 0) { SendPacket(pack); @@ -493,9 +493,9 @@ void ZSList::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_m void ZSList::SendTimeSync() { auto pack = new ServerPacket(ServerOP_SyncWorldTime, sizeof(eqTimeOfDay)); - eqTimeOfDay* tod = (eqTimeOfDay*) pack->pBuffer; - tod->start_eqtime=worldclock.getStartEQTime(); - tod->start_realtime=worldclock.getStartRealTime(); + eqTimeOfDay* tod = (eqTimeOfDay*)pack->pBuffer; + tod->start_eqtime = worldclock.getStartEQTime(); + tod->start_realtime = worldclock.getStartRealTime(); SendPacket(pack); delete pack; } @@ -503,7 +503,7 @@ void ZSList::SendTimeSync() { void ZSList::NextGroupIDs(uint32 &start, uint32 &end) { start = CurGroupID; CurGroupID += 1000; //hand them out 1000 at a time... - if(CurGroupID < start) { //handle overflow + if (CurGroupID < start) { //handle overflow start = 1; CurGroupID = 1001; } @@ -535,7 +535,7 @@ void ZSList::SOPZoneBootup(const char* adminname, uint32 ZoneServerID, const cha } } -void ZSList::RebootZone(const char* ip1,uint16 port,const char* ip2, uint32 skipid, uint32 zoneid){ +void ZSList::RebootZone(const char* ip1, uint16 port, const char* ip2, uint32 skipid, uint32 zoneid) { // get random zone uint32 x = 0; auto iterator = list.begin(); @@ -547,10 +547,10 @@ void ZSList::RebootZone(const char* ip1,uint16 port,const char* ip2, uint32 skip return; auto tmp = new ZoneServer *[x]; uint32 y = 0; - + iterator = list.begin(); while (iterator != list.end()) { - if (!strcmp((*iterator)->GetCAddress(),ip2) && !(*iterator)->IsBootingUp() && (*iterator)->GetID() != skipid) { + if (!strcmp((*iterator)->GetCAddress(), ip2) && !(*iterator)->IsBootingUp() && (*iterator)->GetID() != skipid) { tmp[y++] = (*iterator).get(); } iterator++; @@ -559,16 +559,16 @@ void ZSList::RebootZone(const char* ip1,uint16 port,const char* ip2, uint32 skip safe_delete_array(tmp); return; } - uint32 z = emu_random.Int(0, y-1); + uint32 z = emu_random.Int(0, y - 1); auto pack = new ServerPacket(ServerOP_ZoneReboot, sizeof(ServerZoneReboot_Struct)); - ServerZoneReboot_Struct* s = (ServerZoneReboot_Struct*) pack->pBuffer; -// strcpy(s->ip1,ip1); - strcpy(s->ip2,ip2); + ServerZoneReboot_Struct* s = (ServerZoneReboot_Struct*)pack->pBuffer; + // strcpy(s->ip1,ip1); + strcpy(s->ip2, ip2); s->port = port; s->zoneid = zoneid; - if(zoneid != 0) - Log.Out(Logs::Detail, Logs::World_Server,"Rebooting static zone with the ID of: %i",zoneid); + if (zoneid != 0) + Log(Logs::Detail, Logs::World_Server, "Rebooting static zone with the ID of: %i", zoneid); tmp[z]->SendPacket(pack); delete pack; safe_delete_array(tmp); @@ -576,36 +576,36 @@ void ZSList::RebootZone(const char* ip1,uint16 port,const char* ip2, uint32 skip uint16 ZSList::GetAvailableZonePort() { - const WorldConfig *Config=WorldConfig::get(); + const WorldConfig *Config = WorldConfig::get(); int i; - uint16 port=0; + uint16 port = 0; - if (LastAllocatedPort==0) - i=Config->ZonePortLow; + if (LastAllocatedPort == 0) + i = Config->ZonePortLow; else - i=LastAllocatedPort+1; + i = LastAllocatedPort + 1; - while(i!=LastAllocatedPort && port==0) { + while (i != LastAllocatedPort && port == 0) { if (i>Config->ZonePortHigh) - i=Config->ZonePortLow; + i = Config->ZonePortLow; if (!FindByPort(i)) { - port=i; + port = i; break; } i++; } - LastAllocatedPort=port; + LastAllocatedPort = port; return port; } uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) { - if(iInstanceID > 0) + if (iInstanceID > 0) { auto iterator = list.begin(); while (iterator != list.end()) { - if((*iterator)->GetInstanceID() == iInstanceID) + if ((*iterator)->GetInstanceID() == iInstanceID) { return (*iterator)->GetID(); } @@ -615,7 +615,7 @@ uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) { iterator = list.begin(); while (iterator != list.end()) { if ((*iterator)->GetZoneID() == 0 && !(*iterator)->IsBootingUp()) { - ZoneServer* zone=(*iterator).get(); + ZoneServer* zone = (*iterator).get(); zone->TriggerBootup(iZoneID, iInstanceID); return zone->GetID(); } @@ -627,7 +627,7 @@ uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) { { auto iterator = list.begin(); while (iterator != list.end()) { - if((*iterator)->GetZoneID() == iZoneID && (*iterator)->GetInstanceID() == 0) + if ((*iterator)->GetZoneID() == iZoneID && (*iterator)->GetInstanceID() == 0) { return (*iterator)->GetID(); } @@ -647,11 +647,11 @@ uint32 ZSList::TriggerBootup(uint32 iZoneID, uint32 iInstanceID) { } } -void ZSList::SendLSZones(){ +void ZSList::SendLSZones() { auto iterator = list.begin(); - while(iterator != list.end()) { + while (iterator != list.end()) { ZoneServer* zs = (*iterator).get(); - zs->LSBootUpdate(zs->GetZoneID(),true); + zs->LSBootUpdate(zs->GetZoneID(), true); iterator++; } } @@ -671,24 +671,24 @@ void ZSList::GetZoneIDList(std::vector &zones) { void ZSList::WorldShutDown(uint32 time, uint32 interval) { - if( time > 0 ) { - SendEmoteMessage(0,0,0,15,":SYSTEM MSG:World coming down in %i minutes, everyone log out before this time.", (time / 60)); + if (time > 0) { + SendEmoteMessage(0, 0, 0, 15, ":SYSTEM MSG:World coming down in %i minutes, everyone log out before this time.", (time / 60)); time *= 1000; interval *= 1000; - if(interval < 5000) { interval = 5000; } + if (interval < 5000) { interval = 5000; } shutdowntimer->SetTimer(time); - reminder->SetTimer(interval-1000); + reminder->SetTimer(interval - 1000); reminder->SetAtTrigger(interval); shutdowntimer->Start(); reminder->Start(); } else { - SendEmoteMessage(0,0,0,15,":SYSTEM MSG:World coming down, everyone log out now."); + SendEmoteMessage(0, 0, 0, 15, ":SYSTEM MSG:World coming down, everyone log out now."); auto pack = new ServerPacket; pack->opcode = ServerOP_ShutdownAll; - pack->size=0; + pack->size = 0; SendPacket(pack); safe_delete(pack); Process(); @@ -709,7 +709,7 @@ void ZSList::OnTick(EQ::Timer *t) for (auto &zone : list) { Json::Value outzone; - + outzone["CAddress"] = zone->GetCAddress(); outzone["CLocalAddress"] = zone->GetCLocalAddress(); outzone["CompileTime"] = zone->GetCompileTime(); @@ -734,4 +734,4 @@ void ZSList::OnTick(EQ::Timer *t) } web_interface.SendEvent(out); -} +} \ No newline at end of file diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index d4fe4eae5..a3fc7da7f 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" #include "zoneserver.h" @@ -47,7 +47,7 @@ extern QueryServConnection QSLink; void CatchSignal(int sig_num); ZoneServer::ZoneServer(std::shared_ptr connection) -: tcpc(connection), zone_boot_timer(5000) { + : tcpc(connection), zone_boot_timer(5000) { /* Set Process tracking variable defaults */ memset(zone_name, 0, sizeof(zone_name)); @@ -87,12 +87,12 @@ bool ZoneServer::SetZone(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { char* longname; if (iZoneID) - Log.Out(Logs::Detail, Logs::World_Server,"Setting to '%s' (%d:%d)%s",(zn) ? zn : "",iZoneID, iInstanceID, + Log(Logs::Detail, Logs::World_Server, "Setting to '%s' (%d:%d)%s", (zn) ? zn : "", iZoneID, iInstanceID, iStaticZone ? " (Static)" : ""); zone_server_zone_id = iZoneID; instance_id = iInstanceID; - if(iZoneID!=0) + if (iZoneID != 0) zone_server_previous_zone_id = iZoneID; if (zone_server_zone_id == 0) { client_list.CLERemoveZSRef(this); @@ -105,10 +105,10 @@ bool ZoneServer::SetZone(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { if (zn) { strn0cpy(zone_name, zn, sizeof(zone_name)); - if( database.GetZoneLongName( (char*)zone_name, &longname, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr ) ) + if (database.GetZoneLongName((char*)zone_name, &longname, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr)) { strn0cpy(long_name, longname, sizeof(long_name)); - safe_delete_array( longname ); + safe_delete_array(longname); } else strcpy(long_name, ""); @@ -125,15 +125,15 @@ bool ZoneServer::SetZone(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { return true; } -void ZoneServer::LSShutDownUpdate(uint32 zoneid){ - if(WorldConfig::get()->UpdateStats){ +void ZoneServer::LSShutDownUpdate(uint32 zoneid) { + if (WorldConfig::get()->UpdateStats) { auto pack = new ServerPacket; pack->opcode = ServerOP_LSZoneShutdown; pack->size = sizeof(ZoneShutdown_Struct); pack->pBuffer = new uchar[pack->size]; - memset(pack->pBuffer,0,pack->size); - ZoneShutdown_Struct* zsd =(ZoneShutdown_Struct*)pack->pBuffer; - if(zoneid==0) + memset(pack->pBuffer, 0, pack->size); + ZoneShutdown_Struct* zsd = (ZoneShutdown_Struct*)pack->pBuffer; + if (zoneid == 0) zsd->zone = GetPrevZoneID(); else zsd->zone = zoneid; @@ -142,19 +142,19 @@ void ZoneServer::LSShutDownUpdate(uint32 zoneid){ safe_delete(pack); } } -void ZoneServer::LSBootUpdate(uint32 zoneid, uint32 instanceid, bool startup){ - if(WorldConfig::get()->UpdateStats){ +void ZoneServer::LSBootUpdate(uint32 zoneid, uint32 instanceid, bool startup) { + if (WorldConfig::get()->UpdateStats) { auto pack = new ServerPacket; - if(startup) + if (startup) pack->opcode = ServerOP_LSZoneStart; else pack->opcode = ServerOP_LSZoneBoot; pack->size = sizeof(ZoneBoot_Struct); pack->pBuffer = new uchar[pack->size]; - memset(pack->pBuffer,0,pack->size); - ZoneBoot_Struct* bootup =(ZoneBoot_Struct*)pack->pBuffer; - if(startup) - strcpy(bootup->compile_time,GetCompileTime()); + memset(pack->pBuffer, 0, pack->size); + ZoneBoot_Struct* bootup = (ZoneBoot_Struct*)pack->pBuffer; + if (startup) + strcpy(bootup->compile_time, GetCompileTime()); bootup->zone = zoneid; bootup->zone_wid = GetID(); bootup->instance = instanceid; @@ -163,14 +163,14 @@ void ZoneServer::LSBootUpdate(uint32 zoneid, uint32 instanceid, bool startup){ } } -void ZoneServer::LSSleepUpdate(uint32 zoneid){ - if(WorldConfig::get()->UpdateStats){ +void ZoneServer::LSSleepUpdate(uint32 zoneid) { + if (WorldConfig::get()->UpdateStats) { auto pack = new ServerPacket; pack->opcode = ServerOP_LSZoneSleep; pack->size = sizeof(ServerLSZoneSleep_Struct); pack->pBuffer = new uchar[pack->size]; - memset(pack->pBuffer,0,pack->size); - ServerLSZoneSleep_Struct* sleep =(ServerLSZoneSleep_Struct*)pack->pBuffer; + memset(pack->pBuffer, 0, pack->size); + ServerLSZoneSleep_Struct* sleep = (ServerLSZoneSleep_Struct*)pack->pBuffer; sleep->zone = zoneid; sleep->zone_wid = GetID(); loginserverlist.SendPacket(pack); @@ -182,1114 +182,1117 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { ServerPacket tpack(opcode, p); ServerPacket *pack = &tpack; - switch(opcode) { - case 0: + switch (opcode) { + case 0: + break; + case ServerOP_KeepAlive: { + // ignore this + break; + } + case ServerOP_ZAAuth: { + break; + } + case ServerOP_LSZoneBoot: { + if (pack->size == sizeof(ZoneBoot_Struct)) { + ZoneBoot_Struct* zbs = (ZoneBoot_Struct*)pack->pBuffer; + SetCompile(zbs->compile_time); + } + break; + } + case ServerOP_GroupInvite: { + if (pack->size != sizeof(GroupInvite_Struct)) break; - case ServerOP_KeepAlive: { - // ignore this + + GroupInvite_Struct* gis = (GroupInvite_Struct*)pack->pBuffer; + + client_list.SendPacket(gis->invitee_name, pack); + break; + } + case ServerOP_GroupFollow: { + if (pack->size != sizeof(ServerGroupFollow_Struct)) + break; + + ServerGroupFollow_Struct *sgfs = (ServerGroupFollow_Struct *)pack->pBuffer; + + client_list.SendPacket(sgfs->gf.name1, pack); + break; + } + case ServerOP_GroupFollowAck: { + if (pack->size != sizeof(ServerGroupFollowAck_Struct)) + break; + + ServerGroupFollowAck_Struct *sgfas = (ServerGroupFollowAck_Struct *)pack->pBuffer; + + client_list.SendPacket(sgfas->Name, pack); + break; + } + case ServerOP_GroupCancelInvite: { + if (pack->size != sizeof(GroupCancel_Struct)) + break; + + GroupCancel_Struct *gcs = (GroupCancel_Struct *)pack->pBuffer; + + client_list.SendPacket(gcs->name1, pack); + break; + } + case ServerOP_GroupIDReq: { + SendGroupIDs(); + break; + } + case ServerOP_GroupLeave: { + if (pack->size != sizeof(ServerGroupLeave_Struct)) + break; + zoneserver_list.SendPacket(pack); //bounce it to all zones + break; + } + + case ServerOP_GroupJoin: { + if (pack->size != sizeof(ServerGroupJoin_Struct)) + break; + zoneserver_list.SendPacket(pack); //bounce it to all zones + break; + } + + case ServerOP_ForceGroupUpdate: { + if (pack->size != sizeof(ServerForceGroupUpdate_Struct)) + break; + zoneserver_list.SendPacket(pack); //bounce it to all zones + break; + } + + case ServerOP_OOZGroupMessage: { + zoneserver_list.SendPacket(pack); //bounce it to all zones + break; + } + + case ServerOP_DisbandGroup: { + if (pack->size != sizeof(ServerDisbandGroup_Struct)) + break; + zoneserver_list.SendPacket(pack); //bounce it to all zones + break; + } + + case ServerOP_RaidAdd: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_RaidRemove: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_RaidDisband: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_RaidLockFlag: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_RaidChangeGroup: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_UpdateGroup: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_RaidGroupDisband: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_RaidGroupAdd: { + if (pack->size != sizeof(ServerRaidGroupAction_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_RaidGroupRemove: { + if (pack->size != sizeof(ServerRaidGroupAction_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_RaidGroupSay: { + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_RaidSay: { + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_RaidGroupLeader: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_RaidLeader: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_DetailsChange: { + if (pack->size != sizeof(ServerRaidGeneralAction_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_RaidMOTD: { + if (pack->size < sizeof(ServerRaidMOTD_Struct)) + break; + + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_SpawnCondition: { + if (pack->size != sizeof(ServerSpawnCondition_Struct)) + break; + //bounce the packet to the correct zone server, if its up + ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*)pack->pBuffer; + zoneserver_list.SendPacket(ssc->zoneID, ssc->instanceID, pack); + break; + } + case ServerOP_SpawnEvent: { + if (pack->size != sizeof(ServerSpawnEvent_Struct)) + break; + //bounce the packet to the correct zone server, if its up + ServerSpawnEvent_Struct* sse = (ServerSpawnEvent_Struct*)pack->pBuffer; + zoneserver_list.SendPacket(sse->zoneID, 0, pack); + break; + } + case ServerOP_ChannelMessage: { + if (pack->size < sizeof(ServerChannelMessage_Struct)) + break; + ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*)pack->pBuffer; + if (scm->chan_num == 20) + { + UCSLink.SendMessage(scm->from, scm->message); break; } - case ServerOP_ZAAuth: { - break; - } - case ServerOP_LSZoneBoot:{ - if(pack->size==sizeof(ZoneBoot_Struct)){ - ZoneBoot_Struct* zbs= (ZoneBoot_Struct*)pack->pBuffer; - SetCompile(zbs->compile_time); + if (scm->chan_num == 7 || scm->chan_num == 14) { + ClientListEntry* cle = client_list.FindCharacter(scm->deliverto); + if (cle == 0 || cle->Online() < CLE_Status_Zoning || + (cle->TellsOff() && ((cle->Anon() == 1 && scm->fromadmin < cle->Admin()) || scm->fromadmin < 80))) { + if (!scm->noreply) { + ClientListEntry* sender = client_list.FindCharacter(scm->from); + if (!sender || !sender->Server()) + break; + scm->noreply = true; + scm->queued = 3; // offline + strcpy(scm->deliverto, scm->from); + // ideally this would be trimming off the message too, oh well + sender->Server()->SendPacket(pack); + } } - break; - } - case ServerOP_GroupInvite: { - if(pack->size != sizeof(GroupInvite_Struct)) - break; - - GroupInvite_Struct* gis = (GroupInvite_Struct*) pack->pBuffer; - - client_list.SendPacket(gis->invitee_name, pack); - break; - } - case ServerOP_GroupFollow: { - if(pack->size != sizeof(ServerGroupFollow_Struct)) - break; - - ServerGroupFollow_Struct *sgfs = (ServerGroupFollow_Struct *) pack->pBuffer; - - client_list.SendPacket(sgfs->gf.name1, pack); - break; - } - case ServerOP_GroupFollowAck: { - if(pack->size != sizeof(ServerGroupFollowAck_Struct)) - break; - - ServerGroupFollowAck_Struct *sgfas = (ServerGroupFollowAck_Struct *) pack->pBuffer; - - client_list.SendPacket(sgfas->Name, pack); - break; - } - case ServerOP_GroupCancelInvite: { - if(pack->size != sizeof(GroupCancel_Struct)) - break; - - GroupCancel_Struct *gcs = (GroupCancel_Struct *) pack->pBuffer; - - client_list.SendPacket(gcs->name1, pack); - break; - } - case ServerOP_GroupIDReq: { - SendGroupIDs(); - break; - } - case ServerOP_GroupLeave: { - if(pack->size != sizeof(ServerGroupLeave_Struct)) - break; - zoneserver_list.SendPacket(pack); //bounce it to all zones - break; - } - - case ServerOP_GroupJoin: { - if(pack->size != sizeof(ServerGroupJoin_Struct)) - break; - zoneserver_list.SendPacket(pack); //bounce it to all zones - break; - } - - case ServerOP_ForceGroupUpdate: { - if(pack->size != sizeof(ServerForceGroupUpdate_Struct)) - break; - zoneserver_list.SendPacket(pack); //bounce it to all zones - break; - } - - case ServerOP_OOZGroupMessage: { - zoneserver_list.SendPacket(pack); //bounce it to all zones - break; - } - - case ServerOP_DisbandGroup: { - if(pack->size != sizeof(ServerDisbandGroup_Struct)) - break; - zoneserver_list.SendPacket(pack); //bounce it to all zones - break; - } - - case ServerOP_RaidAdd:{ - if(pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidRemove: { - if(pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidDisband: { - if(pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidLockFlag: { - if(pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidChangeGroup: { - if(pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_UpdateGroup: { - if(pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidGroupDisband: { - if(pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidGroupAdd: { - if(pack->size != sizeof(ServerRaidGroupAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidGroupRemove: { - if(pack->size != sizeof(ServerRaidGroupAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidGroupSay: { - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidSay: { - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidGroupLeader: { - if(pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidLeader: { - if(pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_DetailsChange: { - if(pack->size != sizeof(ServerRaidGeneralAction_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RaidMOTD: { - if (pack->size < sizeof(ServerRaidMOTD_Struct)) - break; - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_SpawnCondition: { - if(pack->size != sizeof(ServerSpawnCondition_Struct)) - break; - //bounce the packet to the correct zone server, if its up - ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*)pack->pBuffer; - zoneserver_list.SendPacket(ssc->zoneID, ssc->instanceID, pack); - break; - } - case ServerOP_SpawnEvent: { - if(pack->size != sizeof(ServerSpawnEvent_Struct)) - break; - //bounce the packet to the correct zone server, if its up - ServerSpawnEvent_Struct* sse = (ServerSpawnEvent_Struct*)pack->pBuffer; - zoneserver_list.SendPacket(sse->zoneID, 0, pack); - break; - } - case ServerOP_ChannelMessage: { - if (pack->size < sizeof(ServerChannelMessage_Struct)) - break; - ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*) pack->pBuffer; - if(scm->chan_num == 20) - { - UCSLink.SendMessage(scm->from, scm->message); - break; - } - if (scm->chan_num == 7 || scm->chan_num == 14) { - ClientListEntry* cle = client_list.FindCharacter(scm->deliverto); - if (cle == 0 || cle->Online() < CLE_Status_Zoning || - (cle->TellsOff() && ((cle->Anon() == 1 && scm->fromadmin < cle->Admin()) || scm->fromadmin < 80))) { - if (!scm->noreply) { - ClientListEntry* sender = client_list.FindCharacter(scm->from); + else if (cle->Online() == CLE_Status_Zoning) { + if (!scm->noreply) { + ClientListEntry* sender = client_list.FindCharacter(scm->from); + if (cle->TellQueueFull()) { if (!sender || !sender->Server()) break; scm->noreply = true; - scm->queued = 3; // offline + scm->queued = 2; // queue full strcpy(scm->deliverto, scm->from); - // ideally this would be trimming off the message too, oh well sender->Server()->SendPacket(pack); } - } else if (cle->Online() == CLE_Status_Zoning) { - if (!scm->noreply) { - ClientListEntry* sender = client_list.FindCharacter(scm->from); - if (cle->TellQueueFull()) { - if (!sender || !sender->Server()) - break; - scm->noreply = true; - scm->queued = 2; // queue full - strcpy(scm->deliverto, scm->from); - sender->Server()->SendPacket(pack); - } else { - size_t struct_size = sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1; - ServerChannelMessage_Struct *temp = (ServerChannelMessage_Struct *) new uchar[struct_size]; - memset(temp, 0, struct_size); // just in case, was seeing some corrupt messages, but it shouldn't happen - memcpy(temp, scm, struct_size); - temp->noreply = true; - cle->PushToTellQueue(temp); // deallocation is handled in processing or deconstructor + else { + size_t struct_size = sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1; + ServerChannelMessage_Struct *temp = (ServerChannelMessage_Struct *) new uchar[struct_size]; + memset(temp, 0, struct_size); // just in case, was seeing some corrupt messages, but it shouldn't happen + memcpy(temp, scm, struct_size); + temp->noreply = true; + cle->PushToTellQueue(temp); // deallocation is handled in processing or deconstructor - if (!sender || !sender->Server()) - break; - scm->noreply = true; - scm->queued = 1; // queued - strcpy(scm->deliverto, scm->from); - sender->Server()->SendPacket(pack); - } + if (!sender || !sender->Server()) + break; + scm->noreply = true; + scm->queued = 1; // queued + strcpy(scm->deliverto, scm->from); + sender->Server()->SendPacket(pack); } } - else if (cle->Server() == 0) { - if (!scm->noreply) - zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not contactable at this time'", scm->to, scm->to); - } - else - cle->Server()->SendPacket(pack); } - else { - zoneserver_list.SendPacket(pack); - } - break; - } - case ServerOP_EmoteMessage: { - ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*) pack->pBuffer; - zoneserver_list.SendEmoteMessageRaw(sem->to, sem->guilddbid, sem->minstatus, sem->type, sem->message); - break; - } - case ServerOP_VoiceMacro: { - - ServerVoiceMacro_Struct* svm = (ServerVoiceMacro_Struct*) pack->pBuffer; - - if(svm->Type == VoiceMacroTell) { - - ClientListEntry* cle = client_list.FindCharacter(svm->To); - - if (!cle || (cle->Online() < CLE_Status_Zoning) || !cle->Server()) { - - zoneserver_list.SendEmoteMessage(svm->From, 0, 0, 0, "'%s is not online at this time'", svm->To); - - break; - } - - cle->Server()->SendPacket(pack); + else if (cle->Server() == 0) { + if (!scm->noreply) + zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not contactable at this time'", scm->to, scm->to); } else - zoneserver_list.SendPacket(pack); - - break; + cle->Server()->SendPacket(pack); } - - case ServerOP_RezzPlayerAccept: { + else { zoneserver_list.SendPacket(pack); - break; } - case ServerOP_RezzPlayer: { + break; + } + case ServerOP_EmoteMessage: { + ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer; + zoneserver_list.SendEmoteMessageRaw(sem->to, sem->guilddbid, sem->minstatus, sem->type, sem->message); + break; + } + case ServerOP_VoiceMacro: { - RezzPlayer_Struct* sRezz = (RezzPlayer_Struct*) pack->pBuffer; - if (zoneserver_list.SendPacket(pack)){ - Log.Out(Logs::Detail, Logs::World_Server,"Sent Rez packet for %s",sRezz->rez.your_name); - } - else { - Log.Out(Logs::Detail, Logs::World_Server,"Could not send Rez packet for %s",sRezz->rez.your_name); - } - break; - } - case ServerOP_RezzPlayerReject: - { - char *Recipient = (char *)pack->pBuffer; - client_list.SendPacket(Recipient, pack); - break; - } + ServerVoiceMacro_Struct* svm = (ServerVoiceMacro_Struct*)pack->pBuffer; + + if (svm->Type == VoiceMacroTell) { + + ClientListEntry* cle = client_list.FindCharacter(svm->To); + + if (!cle || (cle->Online() < CLE_Status_Zoning) || !cle->Server()) { + + zoneserver_list.SendEmoteMessage(svm->From, 0, 0, 0, "'%s is not online at this time'", svm->To); - case ServerOP_MultiLineMsg: { - ServerMultiLineMsg_Struct* mlm = (ServerMultiLineMsg_Struct*) pack->pBuffer; - client_list.SendPacket(mlm->to, pack); - break; - } - case ServerOP_SetZone: { - if(pack->size != sizeof(SetZone_Struct)) break; - - SetZone_Struct* szs = (SetZone_Struct*) pack->pBuffer; - if (szs->zoneid != 0) { - if(database.GetZoneName(szs->zoneid)) - SetZone(szs->zoneid, szs->instanceid, szs->staticzone); - else - SetZone(0); } + + cle->Server()->SendPacket(pack); + } + else + zoneserver_list.SendPacket(pack); + + break; + } + + case ServerOP_RezzPlayerAccept: { + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_RezzPlayer: { + + RezzPlayer_Struct* sRezz = (RezzPlayer_Struct*)pack->pBuffer; + if (zoneserver_list.SendPacket(pack)) { + Log(Logs::Detail, Logs::World_Server, "Sent Rez packet for %s", sRezz->rez.your_name); + } + else { + Log(Logs::Detail, Logs::World_Server, "Could not send Rez packet for %s", sRezz->rez.your_name); + } + break; + } + case ServerOP_RezzPlayerReject: + { + char *Recipient = (char *)pack->pBuffer; + client_list.SendPacket(Recipient, pack); + break; + } + + case ServerOP_MultiLineMsg: { + ServerMultiLineMsg_Struct* mlm = (ServerMultiLineMsg_Struct*)pack->pBuffer; + client_list.SendPacket(mlm->to, pack); + break; + } + case ServerOP_SetZone: { + if (pack->size != sizeof(SetZone_Struct)) + break; + + SetZone_Struct* szs = (SetZone_Struct*)pack->pBuffer; + if (szs->zoneid != 0) { + if (database.GetZoneName(szs->zoneid)) + SetZone(szs->zoneid, szs->instanceid, szs->staticzone); else SetZone(0); + } + else + SetZone(0); + break; + } + case ServerOP_SetConnectInfo: { + if (pack->size != sizeof(ServerConnectInfo)) break; + ServerConnectInfo* sci = (ServerConnectInfo*)pack->pBuffer; + + if (!sci->port) { + client_port = zoneserver_list.GetAvailableZonePort(); + + ServerPacket p(ServerOP_SetConnectInfo, sizeof(ServerConnectInfo)); + memset(p.pBuffer, 0, sizeof(ServerConnectInfo)); + ServerConnectInfo* sci = (ServerConnectInfo*)p.pBuffer; + sci->port = client_port; + SendPacket(&p); + Log(Logs::Detail, Logs::World_Server, "Auto zone port configuration. Telling zone to use port %d", client_port); } - case ServerOP_SetConnectInfo: { - if (pack->size != sizeof(ServerConnectInfo)) - break; - ServerConnectInfo* sci = (ServerConnectInfo*) pack->pBuffer; - - if (!sci->port) { - client_port = zoneserver_list.GetAvailableZonePort(); - - ServerPacket p(ServerOP_SetConnectInfo, sizeof(ServerConnectInfo)); - memset(p.pBuffer,0,sizeof(ServerConnectInfo)); - ServerConnectInfo* sci = (ServerConnectInfo*) p.pBuffer; - sci->port = client_port; - SendPacket(&p); - Log.Out(Logs::Detail, Logs::World_Server,"Auto zone port configuration. Telling zone to use port %d",client_port); - } else { - client_port = sci->port; - Log.Out(Logs::Detail, Logs::World_Server,"Zone specified port %d.",client_port); - } - - if(sci->address[0]) { - strn0cpy(client_address, sci->address, 250); - Log.Out(Logs::Detail, Logs::World_Server, "Zone specified address %s.", sci->address); - } - - if(sci->local_address[0]) { - strn0cpy(client_local_address, sci->local_address, 250); - Log.Out(Logs::Detail, Logs::World_Server, "Zone specified local address %s.", sci->address); - } - - if (sci->process_id){ - zone_os_process_id = sci->process_id; - } - + else { + client_port = sci->port; + Log(Logs::Detail, Logs::World_Server, "Zone specified port %d.", client_port); } - case ServerOP_SetLaunchName: { - if(pack->size != sizeof(LaunchName_Struct)) + + if (sci->address[0]) { + strn0cpy(client_address, sci->address, 250); + Log(Logs::Detail, Logs::World_Server, "Zone specified address %s.", sci->address); + } + + if (sci->local_address[0]) { + strn0cpy(client_local_address, sci->local_address, 250); + Log(Logs::Detail, Logs::World_Server, "Zone specified local address %s.", sci->address); + } + + if (sci->process_id) { + zone_os_process_id = sci->process_id; + } + + } + case ServerOP_SetLaunchName: { + if (pack->size != sizeof(LaunchName_Struct)) + break; + const LaunchName_Struct* ln = (const LaunchName_Struct*)pack->pBuffer; + launcher_name = ln->launcher_name; + launched_name = ln->zone_name; + Log(Logs::Detail, Logs::World_Server, "Zone started with name %s by launcher %s", launched_name.c_str(), launcher_name.c_str()); + break; + } + case ServerOP_ShutdownAll: { + if (pack->size == 0) { + zoneserver_list.SendPacket(pack); + zoneserver_list.Process(); + CatchSignal(2); + } + else { + WorldShutDown_Struct* wsd = (WorldShutDown_Struct*)pack->pBuffer; + if (wsd->time == 0 && wsd->interval == 0 && zoneserver_list.shutdowntimer->Enabled()) { + zoneserver_list.shutdowntimer->Disable(); + zoneserver_list.reminder->Disable(); + } + else { + zoneserver_list.shutdowntimer->SetTimer(wsd->time); + zoneserver_list.reminder->SetTimer(wsd->interval - 1000); + zoneserver_list.reminder->SetAtTrigger(wsd->interval); + zoneserver_list.shutdowntimer->Start(); + zoneserver_list.reminder->Start(); + } + } + break; + } + case ServerOP_ZoneShutdown: { + ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *)pack->pBuffer; + ZoneServer* zs = 0; + if (s->ZoneServerID != 0) + zs = zoneserver_list.FindByID(s->ZoneServerID); + else if (s->zoneid != 0) + zs = zoneserver_list.FindByName(database.GetZoneName(s->zoneid)); + else + zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, 0, "Error: SOP_ZoneShutdown: neither ID nor name specified"); + + if (zs == 0) + zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, 0, "Error: SOP_ZoneShutdown: zoneserver not found"); + else + zs->SendPacket(pack); + break; + } + case ServerOP_ZoneBootup: { + ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *)pack->pBuffer; + zoneserver_list.SOPZoneBootup(s->adminname, s->ZoneServerID, database.GetZoneName(s->zoneid), s->makestatic); + break; + } + case ServerOP_ZoneStatus: { + if (pack->size >= 1) + zoneserver_list.SendZoneStatus((char *)&pack->pBuffer[1], (uint8)pack->pBuffer[0], this); + break; + + } + case ServerOP_AcceptWorldEntrance: { + if (pack->size != sizeof(WorldToZone_Struct)) + break; + + WorldToZone_Struct* wtz = (WorldToZone_Struct*)pack->pBuffer; + Client* client = 0; + client = client_list.FindByAccountID(wtz->account_id); + if (client != 0) + client->Clearance(wtz->response); + } + case ServerOP_ZoneToZoneRequest: { + // + // ZoneChange is received by the zone the player is in, then the + // zone sends a ZTZ which ends up here. This code then find the target + // (ingress point) and boots it if needed, then sends the ZTZ to it. + // The ingress server will decide wether the player can enter, then will + // send back the ZTZ to here. This packet is passed back to the egress + // server, which will send a ZoneChange response back to the client + // which can be an error, or a success, in which case the client will + // disconnect, and their zone location will be saved when ~Client is + // called, so it will be available when they ask to zone. + // + + + if (pack->size != sizeof(ZoneToZone_Struct)) + break; + ZoneToZone_Struct* ztz = (ZoneToZone_Struct*)pack->pBuffer; + ClientListEntry* client = nullptr; + if (WorldConfig::get()->UpdateStats) + client = client_list.FindCharacter(ztz->name); + + Log(Logs::Detail, Logs::World_Server, "ZoneToZone request for %s current zone %d req zone %d\n", + ztz->name, ztz->current_zone_id, ztz->requested_zone_id); + + /* This is a request from the egress zone */ + if (GetZoneID() == ztz->current_zone_id && GetInstanceID() == ztz->current_instance_id) { + Log(Logs::Detail, Logs::World_Server, "Processing ZTZ for egress from zone for client %s\n", ztz->name); + + if (ztz->admin < 80 && ztz->ignorerestrictions < 2 && zoneserver_list.IsZoneLocked(ztz->requested_zone_id)) { + ztz->response = 0; + SendPacket(pack); break; - const LaunchName_Struct* ln = (const LaunchName_Struct*)pack->pBuffer; - launcher_name = ln->launcher_name; - launched_name = ln->zone_name; - Log.Out(Logs::Detail, Logs::World_Server, "Zone started with name %s by launcher %s", launched_name.c_str(), launcher_name.c_str()); - break; - } - case ServerOP_ShutdownAll: { - if(pack->size==0){ - zoneserver_list.SendPacket(pack); - zoneserver_list.Process(); - CatchSignal(2); } - else{ - WorldShutDown_Struct* wsd=(WorldShutDown_Struct*)pack->pBuffer; - if(wsd->time==0 && wsd->interval==0 && zoneserver_list.shutdowntimer->Enabled()){ - zoneserver_list.shutdowntimer->Disable(); - zoneserver_list.reminder->Disable(); - } - else{ - zoneserver_list.shutdowntimer->SetTimer(wsd->time); - zoneserver_list.reminder->SetTimer(wsd->interval-1000); - zoneserver_list.reminder->SetAtTrigger(wsd->interval); - zoneserver_list.shutdowntimer->Start(); - zoneserver_list.reminder->Start(); - } + + ZoneServer *ingress_server = nullptr; + if (ztz->requested_instance_id > 0) { + ingress_server = zoneserver_list.FindByInstanceID(ztz->requested_instance_id); + } + else { + ingress_server = zoneserver_list.FindByZoneID(ztz->requested_zone_id); } - break; - } - case ServerOP_ZoneShutdown: { - ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *) pack->pBuffer; - ZoneServer* zs = 0; - if (s->ZoneServerID != 0) - zs = zoneserver_list.FindByID(s->ZoneServerID); - else if (s->zoneid != 0) - zs = zoneserver_list.FindByName(database.GetZoneName(s->zoneid)); - else - zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, 0, "Error: SOP_ZoneShutdown: neither ID nor name specified"); - if (zs == 0) - zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, 0, "Error: SOP_ZoneShutdown: zoneserver not found"); - else - zs->SendPacket(pack); - break; - } - case ServerOP_ZoneBootup: { - ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *) pack->pBuffer; - zoneserver_list.SOPZoneBootup(s->adminname, s->ZoneServerID, database.GetZoneName(s->zoneid), s->makestatic); - break; - } - case ServerOP_ZoneStatus: { - if (pack->size >= 1) - zoneserver_list.SendZoneStatus((char *) &pack->pBuffer[1], (uint8) pack->pBuffer[0], this); - break; - - } - case ServerOP_AcceptWorldEntrance: { - if(pack->size != sizeof(WorldToZone_Struct)) - break; - - WorldToZone_Struct* wtz = (WorldToZone_Struct*) pack->pBuffer; - Client* client = 0; - client = client_list.FindByAccountID(wtz->account_id); - if(client != 0) - client->Clearance(wtz->response); - } - case ServerOP_ZoneToZoneRequest: { - // - // ZoneChange is received by the zone the player is in, then the - // zone sends a ZTZ which ends up here. This code then find the target - // (ingress point) and boots it if needed, then sends the ZTZ to it. - // The ingress server will decide wether the player can enter, then will - // send back the ZTZ to here. This packet is passed back to the egress - // server, which will send a ZoneChange response back to the client - // which can be an error, or a success, in which case the client will - // disconnect, and their zone location will be saved when ~Client is - // called, so it will be available when they ask to zone. - // - - - if(pack->size != sizeof(ZoneToZone_Struct)) - break; - ZoneToZone_Struct* ztz = (ZoneToZone_Struct*) pack->pBuffer; - ClientListEntry* client = nullptr; - if(WorldConfig::get()->UpdateStats) - client = client_list.FindCharacter(ztz->name); - - Log.Out(Logs::Detail, Logs::World_Server,"ZoneToZone request for %s current zone %d req zone %d\n", - ztz->name, ztz->current_zone_id, ztz->requested_zone_id); - - /* This is a request from the egress zone */ - if(GetZoneID() == ztz->current_zone_id && GetInstanceID() == ztz->current_instance_id) { - Log.Out(Logs::Detail, Logs::World_Server,"Processing ZTZ for egress from zone for client %s\n", ztz->name); - - if (ztz->admin < 80 && ztz->ignorerestrictions < 2 && zoneserver_list.IsZoneLocked(ztz->requested_zone_id)) { - ztz->response = 0; - SendPacket(pack); - break; - } - - ZoneServer *ingress_server = nullptr; - if(ztz->requested_instance_id > 0) { - ingress_server = zoneserver_list.FindByInstanceID(ztz->requested_instance_id); - } - else { - ingress_server = zoneserver_list.FindByZoneID(ztz->requested_zone_id); - } - - /* Zone was already running*/ - if(ingress_server) { - Log.Out(Logs::Detail, Logs::World_Server,"Found a zone already booted for %s\n", ztz->name); + /* Zone was already running*/ + if (ingress_server) { + Log(Logs::Detail, Logs::World_Server, "Found a zone already booted for %s\n", ztz->name); + ztz->response = 1; + } + /* Boot the Zone*/ + else { + int server_id; + if ((server_id = zoneserver_list.TriggerBootup(ztz->requested_zone_id, ztz->requested_instance_id))) { + Log(Logs::Detail, Logs::World_Server, "Successfully booted a zone for %s\n", ztz->name); + // bootup successful, ready to rock ztz->response = 1; + ingress_server = zoneserver_list.FindByID(server_id); } - /* Boot the Zone*/ else { - int server_id; - if ((server_id = zoneserver_list.TriggerBootup(ztz->requested_zone_id, ztz->requested_instance_id))){ - Log.Out(Logs::Detail, Logs::World_Server,"Successfully booted a zone for %s\n", ztz->name); - // bootup successful, ready to rock - ztz->response = 1; - ingress_server = zoneserver_list.FindByID(server_id); + Log(Logs::Detail, Logs::World_Server, "FAILED to boot a zone for %s\n", ztz->name); + // bootup failed, send back error code 0 + ztz->response = 0; + } + } + if (ztz->response != 0 && client) + client->LSZoneChange(ztz); + SendPacket(pack); // send back to egress server + if (ingress_server) { + ingress_server->SendPacket(pack); // inform target server + } + } + /* Response from Ingress server, route back to egress */ + else { + + Log(Logs::Detail, Logs::World_Server, "Processing ZTZ for ingress to zone for client %s\n", ztz->name); + ZoneServer *egress_server = nullptr; + if (ztz->current_instance_id > 0) { + egress_server = zoneserver_list.FindByInstanceID(ztz->current_instance_id); + } + else { + egress_server = zoneserver_list.FindByZoneID(ztz->current_zone_id); + } + + if (egress_server) { + egress_server->SendPacket(pack); + } + } + + break; + } + case ServerOP_ClientList: { + if (pack->size != sizeof(ServerClientList_Struct)) { + Log(Logs::Detail, Logs::World_Server, "Wrong size on ServerOP_ClientList. Got: %d, Expected: %d", pack->size, sizeof(ServerClientList_Struct)); + break; + } + client_list.ClientUpdate(this, (ServerClientList_Struct*)pack->pBuffer); + break; + } + case ServerOP_ClientListKA: { + ServerClientListKeepAlive_Struct* sclka = (ServerClientListKeepAlive_Struct*)pack->pBuffer; + if (pack->size < 4 || pack->size != 4 + (4 * sclka->numupdates)) { + Log(Logs::Detail, Logs::World_Server, "Wrong size on ServerOP_ClientListKA. Got: %d, Expected: %d", pack->size, (4 + (4 * sclka->numupdates))); + break; + } + client_list.CLEKeepAlive(sclka->numupdates, sclka->wid); + break; + } + case ServerOP_Who: { + ServerWhoAll_Struct* whoall = (ServerWhoAll_Struct*)pack->pBuffer; + auto whom = new Who_All_Struct; + memset(whom, 0, sizeof(Who_All_Struct)); + whom->gmlookup = whoall->gmlookup; + whom->lvllow = whoall->lvllow; + whom->lvlhigh = whoall->lvlhigh; + whom->wclass = whoall->wclass; + whom->wrace = whoall->wrace; + strcpy(whom->whom, whoall->whom); + client_list.SendWhoAll(whoall->fromid, whoall->from, whoall->admin, whom, this); + safe_delete(whom); + break; + } + case ServerOP_RequestOnlineGuildMembers: { + ServerRequestOnlineGuildMembers_Struct *srogms = (ServerRequestOnlineGuildMembers_Struct*)pack->pBuffer; + client_list.SendOnlineGuildMembers(srogms->FromID, srogms->GuildID); + break; + } + case ServerOP_ClientVersionSummary: { + ServerRequestClientVersionSummary_Struct *srcvss = (ServerRequestClientVersionSummary_Struct*)pack->pBuffer; + client_list.SendClientVersionSummary(srcvss->Name); + break; + } + case ServerOP_ReloadLogs: { + zoneserver_list.SendPacket(pack); + database.LoadLogSettings(LogSys.log_settings); + break; + } + case ServerOP_ReloadRules: { + zoneserver_list.SendPacket(pack); + RuleManager::Instance()->LoadRules(&database, "default"); + break; + } + case ServerOP_ReloadRulesWorld: + { + RuleManager::Instance()->LoadRules(&database, "default"); + break; + } + case ServerOP_ReloadPerlExportSettings: + { + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_CameraShake: + { + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_FriendsWho: { + ServerFriendsWho_Struct* FriendsWho = (ServerFriendsWho_Struct*)pack->pBuffer; + client_list.SendFriendsWho(FriendsWho, this); + break; + } + case ServerOP_LFGMatches: { + ServerLFGMatchesRequest_Struct* smrs = (ServerLFGMatchesRequest_Struct*)pack->pBuffer; + client_list.SendLFGMatches(smrs); + break; + } + case ServerOP_LFPMatches: { + ServerLFPMatchesRequest_Struct* smrs = (ServerLFPMatchesRequest_Struct*)pack->pBuffer; + LFPGroupList.SendLFPMatches(smrs); + break; + } + case ServerOP_LFPUpdate: { + ServerLFPUpdate_Struct* sus = (ServerLFPUpdate_Struct*)pack->pBuffer; + if (sus->Action) + LFPGroupList.UpdateGroup(sus); + else + LFPGroupList.RemoveGroup(sus); + break; + } + case ServerOP_ZonePlayer: { + //ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*) pack->pBuffer; + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_KickPlayer: { + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_KillPlayer: { + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_GuildRankUpdate: + { + zoneserver_list.SendPacket(pack); + break; + } + //these opcodes get processed by the guild manager. + case ServerOP_RefreshGuild: + case ServerOP_DeleteGuild: + case ServerOP_GuildCharRefresh: + case ServerOP_GuildMemberUpdate: { + guild_mgr.ProcessZonePacket(pack); + break; + } + + case ServerOP_FlagUpdate: { + ClientListEntry* cle = client_list.FindCLEByAccountID(*((uint32*)pack->pBuffer)); + if (cle) + cle->SetAdmin(*((int16*)&pack->pBuffer[4])); + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_GMGoto: { + if (pack->size != sizeof(ServerGMGoto_Struct)) { + Log(Logs::Detail, Logs::World_Server, "Wrong size on ServerOP_GMGoto. Got: %d, Expected: %d", pack->size, sizeof(ServerGMGoto_Struct)); + break; + } + ServerGMGoto_Struct* gmg = (ServerGMGoto_Struct*)pack->pBuffer; + ClientListEntry* cle = client_list.FindCharacter(gmg->gotoname); + if (cle != 0) { + if (cle->Server() == 0) + this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: Cannot identify %s's zoneserver.", gmg->gotoname); + else if (cle->Anon() == 1 && cle->Admin() > gmg->admin) // no snooping for anon GMs + this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: %s not found", gmg->gotoname); + else + cle->Server()->SendPacket(pack); + } + else { + this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: %s not found", gmg->gotoname); + } + break; + } + case ServerOP_Lock: { + if (pack->size != sizeof(ServerLock_Struct)) { + Log(Logs::Detail, Logs::World_Server, "Wrong size on ServerOP_Lock. Got: %d, Expected: %d", pack->size, sizeof(ServerLock_Struct)); + break; + } + ServerLock_Struct* slock = (ServerLock_Struct*)pack->pBuffer; + if (slock->mode >= 1) + WorldConfig::LockWorld(); + else + WorldConfig::UnlockWorld(); + if (loginserverlist.Connected()) { + loginserverlist.SendStatus(); + if (slock->mode >= 1) + this->SendEmoteMessage(slock->myname, 0, 0, 13, "World locked"); + else + this->SendEmoteMessage(slock->myname, 0, 0, 13, "World unlocked"); + } + else { + if (slock->mode >= 1) + this->SendEmoteMessage(slock->myname, 0, 0, 13, "World locked, but login server not connected."); + else + this->SendEmoteMessage(slock->myname, 0, 0, 13, "World unlocked, but login server not conencted."); + } + break; + } + case ServerOP_Motd: { + if (pack->size != sizeof(ServerMotd_Struct)) { + Log(Logs::Detail, Logs::World_Server, "Wrong size on ServerOP_Motd. Got: %d, Expected: %d", pack->size, sizeof(ServerMotd_Struct)); + break; + } + ServerMotd_Struct* smotd = (ServerMotd_Struct*)pack->pBuffer; + database.SetVariable("MOTD", smotd->motd); + //this->SendEmoteMessage(smotd->myname, 0, 0, 13, "Updated Motd."); + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_Uptime: { + if (pack->size != sizeof(ServerUptime_Struct)) { + Log(Logs::Detail, Logs::World_Server, "Wrong size on ServerOP_Uptime. Got: %d, Expected: %d", pack->size, sizeof(ServerUptime_Struct)); + break; + } + ServerUptime_Struct* sus = (ServerUptime_Struct*)pack->pBuffer; + if (sus->zoneserverid == 0) { + ZSList::ShowUpTime(this, sus->adminname); + } + else { + ZoneServer* zs = zoneserver_list.FindByID(sus->zoneserverid); + if (zs) + zs->SendPacket(pack); + } + break; + } + case ServerOP_Petition: { + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_GetWorldTime: { + Log(Logs::Detail, Logs::World_Server, "Broadcasting a world time update"); + auto pack = new ServerPacket; + + pack->opcode = ServerOP_SyncWorldTime; + pack->size = sizeof(eqTimeOfDay); + pack->pBuffer = new uchar[pack->size]; + memset(pack->pBuffer, 0, pack->size); + eqTimeOfDay* tod = (eqTimeOfDay*)pack->pBuffer; + tod->start_eqtime = zoneserver_list.worldclock.getStartEQTime(); + tod->start_realtime = zoneserver_list.worldclock.getStartRealTime(); + SendPacket(pack); + safe_delete(pack); + break; + } + case ServerOP_SetWorldTime: { + Log(Logs::Detail, Logs::World_Server, "Received SetWorldTime"); + eqTimeOfDay* newtime = (eqTimeOfDay*)pack->pBuffer; + zoneserver_list.worldclock.SetCurrentEQTimeOfDay(newtime->start_eqtime, newtime->start_realtime); + Log(Logs::Detail, Logs::World_Server, "New time = %d-%d-%d %d:%d (%d)\n", newtime->start_eqtime.year, newtime->start_eqtime.month, (int)newtime->start_eqtime.day, (int)newtime->start_eqtime.hour, (int)newtime->start_eqtime.minute, (int)newtime->start_realtime); + database.SaveTime((int)newtime->start_eqtime.minute, (int)newtime->start_eqtime.hour, (int)newtime->start_eqtime.day, newtime->start_eqtime.month, newtime->start_eqtime.year); + zoneserver_list.SendTimeSync(); + break; + } + case ServerOP_IPLookup: { + if (pack->size < sizeof(ServerGenericWorldQuery_Struct)) { + Log(Logs::Detail, Logs::World_Server, "Wrong size on ServerOP_IPLookup. Got: %d, Expected (at least): %d", pack->size, sizeof(ServerGenericWorldQuery_Struct)); + break; + } + ServerGenericWorldQuery_Struct* sgwq = (ServerGenericWorldQuery_Struct*)pack->pBuffer; + if (pack->size == sizeof(ServerGenericWorldQuery_Struct)) + client_list.SendCLEList(sgwq->admin, sgwq->from, this); + else + client_list.SendCLEList(sgwq->admin, sgwq->from, this, sgwq->query); + break; + } + case ServerOP_LockZone: { + if (pack->size < sizeof(ServerLockZone_Struct)) { + Log(Logs::Detail, Logs::World_Server, "Wrong size on ServerOP_LockZone. Got: %d, Expected: %d", pack->size, sizeof(ServerLockZone_Struct)); + break; + } + ServerLockZone_Struct* s = (ServerLockZone_Struct*)pack->pBuffer; + switch (s->op) { + case 0: + zoneserver_list.ListLockedZones(s->adminname, this); + break; + case 1: + if (zoneserver_list.SetLockedZone(s->zoneID, true)) + zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", database.GetZoneName(s->zoneID)); + else + this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock"); + break; + case 2: + if (zoneserver_list.SetLockedZone(s->zoneID, false)) + zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", database.GetZoneName(s->zoneID)); + else + this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock"); + break; + } + break; + } + case ServerOP_ItemStatus: { + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_OOCMute: { + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_Revoke: { + RevokeStruct* rev = (RevokeStruct*)pack->pBuffer; + ClientListEntry* cle = client_list.FindCharacter(rev->name); + if (cle != 0 && cle->Server() != 0) + { + cle->Server()->SendPacket(pack); + } + break; + } + case ServerOP_SpawnPlayerCorpse: { + SpawnPlayerCorpse_Struct* s = (SpawnPlayerCorpse_Struct*)pack->pBuffer; + ZoneServer* zs = zoneserver_list.FindByZoneID(s->zone_id); + if (zs) { + zs->SendPacket(pack); + } + break; + } + case ServerOP_Consent: { + // Message string id's likely to be used here are: + // CONSENT_YOURSELF = 399 + // CONSENT_INVALID_NAME = 397 + // TARGET_NOT_FOUND = 101 + ZoneServer* zs; + ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer; + ClientListEntry* cle = client_list.FindCharacter(s->grantname); + if (cle) { + if (cle->instance() != 0) + { + zs = zoneserver_list.FindByInstanceID(cle->instance()); + if (zs) { + zs->SendPacket(pack); + } + else + { + auto pack = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct)); + ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer; + strcpy(scs->grantname, s->grantname); + strcpy(scs->ownername, s->ownername); + scs->permission = s->permission; + scs->zone_id = s->zone_id; + scs->instance_id = s->instance_id; + scs->message_string_id = 101; + zs = zoneserver_list.FindByInstanceID(s->instance_id); + if (zs) { + zs->SendPacket(pack); } else { - Log.Out(Logs::Detail, Logs::World_Server,"FAILED to boot a zone for %s\n", ztz->name); - // bootup failed, send back error code 0 - ztz->response = 0; + Log(Logs::Detail, Logs::World_Server, "Unable to locate zone record for instance id %u in zoneserver list for ServerOP_Consent_Response operation.", s->instance_id); } + safe_delete(pack); } - if(ztz->response!=0 && client) - client->LSZoneChange(ztz); - SendPacket(pack); // send back to egress server - if(ingress_server) { - ingress_server->SendPacket(pack); // inform target server - } } - /* Response from Ingress server, route back to egress */ - else{ - - Log.Out(Logs::Detail, Logs::World_Server,"Processing ZTZ for ingress to zone for client %s\n", ztz->name); - ZoneServer *egress_server = nullptr; - if(ztz->current_instance_id > 0) { - egress_server = zoneserver_list.FindByInstanceID(ztz->current_instance_id); + else + { + zs = zoneserver_list.FindByZoneID(cle->zone()); + if (zs) { + zs->SendPacket(pack); } else { - egress_server = zoneserver_list.FindByZoneID(ztz->current_zone_id); - } - - if(egress_server) { - egress_server->SendPacket(pack); + // send target not found back to requester + auto pack = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct)); + ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer; + strcpy(scs->grantname, s->grantname); + strcpy(scs->ownername, s->ownername); + scs->permission = s->permission; + scs->zone_id = s->zone_id; + scs->message_string_id = 101; + zs = zoneserver_list.FindByZoneID(s->zone_id); + if (zs) { + zs->SendPacket(pack); + } + else { + Log(Logs::Detail, Logs::World_Server, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent_Response operation.", s->zone_id); + } + safe_delete(pack); } } - - break; } - case ServerOP_ClientList: { - if (pack->size != sizeof(ServerClientList_Struct)) { - Log.Out(Logs::Detail, Logs::World_Server,"Wrong size on ServerOP_ClientList. Got: %d, Expected: %d",pack->size,sizeof(ServerClientList_Struct)); - break; - } - client_list.ClientUpdate(this, (ServerClientList_Struct*) pack->pBuffer); - break; - } - case ServerOP_ClientListKA: { - ServerClientListKeepAlive_Struct* sclka = (ServerClientListKeepAlive_Struct*) pack->pBuffer; - if (pack->size < 4 || pack->size != 4 + (4 * sclka->numupdates)) { - Log.Out(Logs::Detail, Logs::World_Server,"Wrong size on ServerOP_ClientListKA. Got: %d, Expected: %d",pack->size, (4 + (4 * sclka->numupdates))); - break; - } - client_list.CLEKeepAlive(sclka->numupdates, sclka->wid); - break; - } - case ServerOP_Who: { - ServerWhoAll_Struct* whoall = (ServerWhoAll_Struct*) pack->pBuffer; - auto whom = new Who_All_Struct; - memset(whom,0,sizeof(Who_All_Struct)); - whom->gmlookup = whoall->gmlookup; - whom->lvllow = whoall->lvllow; - whom->lvlhigh = whoall->lvlhigh; - whom->wclass = whoall->wclass; - whom->wrace = whoall->wrace; - strcpy(whom->whom,whoall->whom); - client_list.SendWhoAll(whoall->fromid,whoall->from, whoall->admin, whom, this); - safe_delete(whom); - break; - } - case ServerOP_RequestOnlineGuildMembers: { - ServerRequestOnlineGuildMembers_Struct *srogms = (ServerRequestOnlineGuildMembers_Struct*) pack->pBuffer; - client_list.SendOnlineGuildMembers(srogms->FromID, srogms->GuildID); - break; - } - case ServerOP_ClientVersionSummary: { - ServerRequestClientVersionSummary_Struct *srcvss = (ServerRequestClientVersionSummary_Struct*) pack->pBuffer; - client_list.SendClientVersionSummary(srcvss->Name); - break; - } - case ServerOP_ReloadLogs: { - zoneserver_list.SendPacket(pack); - database.LoadLogSettings(Log.log_settings); - break; - } - case ServerOP_ReloadRules: { - zoneserver_list.SendPacket(pack); - RuleManager::Instance()->LoadRules(&database, "default"); - break; - } - case ServerOP_ReloadRulesWorld: - { - RuleManager::Instance()->LoadRules(&database, "default"); - break; - } - case ServerOP_ReloadPerlExportSettings: - { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_CameraShake: - { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_FriendsWho: { - ServerFriendsWho_Struct* FriendsWho = (ServerFriendsWho_Struct*) pack->pBuffer; - client_list.SendFriendsWho(FriendsWho, this); - break; - } - case ServerOP_LFGMatches: { - ServerLFGMatchesRequest_Struct* smrs = (ServerLFGMatchesRequest_Struct*) pack->pBuffer; - client_list.SendLFGMatches(smrs); - break; - } - case ServerOP_LFPMatches: { - ServerLFPMatchesRequest_Struct* smrs = (ServerLFPMatchesRequest_Struct*) pack->pBuffer; - LFPGroupList.SendLFPMatches(smrs); - break; - } - case ServerOP_LFPUpdate: { - ServerLFPUpdate_Struct* sus = (ServerLFPUpdate_Struct*) pack->pBuffer; - if(sus->Action) - LFPGroupList.UpdateGroup(sus); - else - LFPGroupList.RemoveGroup(sus); - break; - } - case ServerOP_ZonePlayer: { - //ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*) pack->pBuffer; - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_KickPlayer: { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_KillPlayer: { - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_GuildRankUpdate: - { - zoneserver_list.SendPacket(pack); - break; - } - //these opcodes get processed by the guild manager. - case ServerOP_RefreshGuild: - case ServerOP_DeleteGuild: - case ServerOP_GuildCharRefresh: - case ServerOP_GuildMemberUpdate: { - guild_mgr.ProcessZonePacket(pack); - break; - } - - case ServerOP_FlagUpdate: { - ClientListEntry* cle = client_list.FindCLEByAccountID(*((uint32*) pack->pBuffer)); - if (cle) - cle->SetAdmin(*((int16*) &pack->pBuffer[4])); - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_GMGoto: { - if (pack->size != sizeof(ServerGMGoto_Struct)) { - Log.Out(Logs::Detail, Logs::World_Server,"Wrong size on ServerOP_GMGoto. Got: %d, Expected: %d",pack->size,sizeof(ServerGMGoto_Struct)); - break; - } - ServerGMGoto_Struct* gmg = (ServerGMGoto_Struct*) pack->pBuffer; - ClientListEntry* cle = client_list.FindCharacter(gmg->gotoname); - if (cle != 0) { - if (cle->Server() == 0) - this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: Cannot identify %s's zoneserver.", gmg->gotoname); - else if (cle->Anon() == 1 && cle->Admin() > gmg->admin) // no snooping for anon GMs - this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: %s not found", gmg->gotoname); - else - cle->Server()->SendPacket(pack); - } - else { - this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: %s not found", gmg->gotoname); - } - break; - } - case ServerOP_Lock: { - if (pack->size != sizeof(ServerLock_Struct)) { - Log.Out(Logs::Detail, Logs::World_Server,"Wrong size on ServerOP_Lock. Got: %d, Expected: %d",pack->size,sizeof(ServerLock_Struct)); - break; - } - ServerLock_Struct* slock = (ServerLock_Struct*) pack->pBuffer; - if (slock->mode >= 1) - WorldConfig::LockWorld(); - else - WorldConfig::UnlockWorld(); - if (loginserverlist.Connected()) { - loginserverlist.SendStatus(); - if (slock->mode >= 1) - this->SendEmoteMessage(slock->myname, 0, 0, 13, "World locked"); - else - this->SendEmoteMessage(slock->myname, 0, 0, 13, "World unlocked"); - } - else { - if (slock->mode >= 1) - this->SendEmoteMessage(slock->myname, 0, 0, 13, "World locked, but login server not connected."); - else - this->SendEmoteMessage(slock->myname, 0, 0, 13, "World unlocked, but login server not conencted."); - } - break; - } - case ServerOP_Motd: { - if (pack->size != sizeof(ServerMotd_Struct)) { - Log.Out(Logs::Detail, Logs::World_Server,"Wrong size on ServerOP_Motd. Got: %d, Expected: %d",pack->size,sizeof(ServerMotd_Struct)); - break; - } - ServerMotd_Struct* smotd = (ServerMotd_Struct*) pack->pBuffer; - database.SetVariable("MOTD",smotd->motd); - //this->SendEmoteMessage(smotd->myname, 0, 0, 13, "Updated Motd."); - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_Uptime: { - if (pack->size != sizeof(ServerUptime_Struct)) { - Log.Out(Logs::Detail, Logs::World_Server,"Wrong size on ServerOP_Uptime. Got: %d, Expected: %d",pack->size,sizeof(ServerUptime_Struct)); - break; - } - ServerUptime_Struct* sus = (ServerUptime_Struct*) pack->pBuffer; - if (sus->zoneserverid == 0) { - ZSList::ShowUpTime(this, sus->adminname); - } - else { - ZoneServer* zs = zoneserver_list.FindByID(sus->zoneserverid); - if (zs) - zs->SendPacket(pack); - } - break; - } - case ServerOP_Petition: { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_GetWorldTime: { - Log.Out(Logs::Detail, Logs::World_Server,"Broadcasting a world time update"); - auto pack = new ServerPacket; - - pack->opcode = ServerOP_SyncWorldTime; - pack->size = sizeof(eqTimeOfDay); - pack->pBuffer = new uchar[pack->size]; - memset(pack->pBuffer, 0, pack->size); - eqTimeOfDay* tod = (eqTimeOfDay*) pack->pBuffer; - tod->start_eqtime=zoneserver_list.worldclock.getStartEQTime(); - tod->start_realtime=zoneserver_list.worldclock.getStartRealTime(); - SendPacket(pack); - safe_delete(pack); - break; - } - case ServerOP_SetWorldTime: { - Log.Out(Logs::Detail, Logs::World_Server,"Received SetWorldTime"); - eqTimeOfDay* newtime = (eqTimeOfDay*) pack->pBuffer; - zoneserver_list.worldclock.SetCurrentEQTimeOfDay(newtime->start_eqtime, newtime->start_realtime); - Log.Out(Logs::Detail, Logs::World_Server, "New time = %d-%d-%d %d:%d (%d)\n", newtime->start_eqtime.year, newtime->start_eqtime.month, (int)newtime->start_eqtime.day, (int)newtime->start_eqtime.hour, (int)newtime->start_eqtime.minute, (int)newtime->start_realtime); - database.SaveTime((int)newtime->start_eqtime.minute, (int)newtime->start_eqtime.hour, (int)newtime->start_eqtime.day, newtime->start_eqtime.month, newtime->start_eqtime.year); - zoneserver_list.SendTimeSync(); - break; - } - case ServerOP_IPLookup: { - if (pack->size < sizeof(ServerGenericWorldQuery_Struct)) { - Log.Out(Logs::Detail, Logs::World_Server,"Wrong size on ServerOP_IPLookup. Got: %d, Expected (at least): %d",pack->size,sizeof(ServerGenericWorldQuery_Struct)); - break; - } - ServerGenericWorldQuery_Struct* sgwq = (ServerGenericWorldQuery_Struct*) pack->pBuffer; - if (pack->size == sizeof(ServerGenericWorldQuery_Struct)) - client_list.SendCLEList(sgwq->admin, sgwq->from, this); - else - client_list.SendCLEList(sgwq->admin, sgwq->from, this, sgwq->query); - break; - } - case ServerOP_LockZone: { - if (pack->size < sizeof(ServerLockZone_Struct)) { - Log.Out(Logs::Detail, Logs::World_Server,"Wrong size on ServerOP_LockZone. Got: %d, Expected: %d",pack->size,sizeof(ServerLockZone_Struct)); - break; - } - ServerLockZone_Struct* s = (ServerLockZone_Struct*) pack->pBuffer; - switch (s->op) { - case 0: - zoneserver_list.ListLockedZones(s->adminname, this); - break; - case 1: - if (zoneserver_list.SetLockedZone(s->zoneID, true)) - zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", database.GetZoneName(s->zoneID)); - else - this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock"); - break; - case 2: - if (zoneserver_list.SetLockedZone(s->zoneID, false)) - zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", database.GetZoneName(s->zoneID)); - else - this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock"); - break; - } - break; - } - case ServerOP_ItemStatus: { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_OOCMute: { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_Revoke: { - RevokeStruct* rev = (RevokeStruct*)pack->pBuffer; - ClientListEntry* cle = client_list.FindCharacter(rev->name); - if (cle != 0 && cle->Server() != 0) - { - cle->Server()->SendPacket(pack); - } - break; - } - case ServerOP_SpawnPlayerCorpse: { - SpawnPlayerCorpse_Struct* s = (SpawnPlayerCorpse_Struct*)pack->pBuffer; - ZoneServer* zs = zoneserver_list.FindByZoneID(s->zone_id); - if(zs) { + else { + // send target not found back to requester + auto pack = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct)); + ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer; + strcpy(scs->grantname, s->grantname); + strcpy(scs->ownername, s->ownername); + scs->permission = s->permission; + scs->zone_id = s->zone_id; + scs->message_string_id = 397; + zs = zoneserver_list.FindByZoneID(s->zone_id); + if (zs) { zs->SendPacket(pack); } - break; + else { + Log(Logs::Detail, Logs::World_Server, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent_Response operation.", s->zone_id); + } + safe_delete(pack); } - case ServerOP_Consent: { - // Message string id's likely to be used here are: - // CONSENT_YOURSELF = 399 - // CONSENT_INVALID_NAME = 397 - // TARGET_NOT_FOUND = 101 - ZoneServer* zs; - ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer; - ClientListEntry* cle = client_list.FindCharacter(s->grantname); - if(cle) { - if(cle->instance() != 0) - { - zs = zoneserver_list.FindByInstanceID(cle->instance()); - if(zs) { - zs->SendPacket(pack); - } - else - { - auto pack = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct)); - ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer; - strcpy(scs->grantname, s->grantname); - strcpy(scs->ownername, s->ownername); - scs->permission = s->permission; - scs->zone_id = s->zone_id; - scs->instance_id = s->instance_id; - scs->message_string_id = 101; - zs = zoneserver_list.FindByInstanceID(s->instance_id); - if(zs) { - zs->SendPacket(pack); - } - else { - Log.Out(Logs::Detail, Logs::World_Server, "Unable to locate zone record for instance id %u in zoneserver list for ServerOP_Consent_Response operation.", s->instance_id); - } - safe_delete(pack); - } - } - else - { - zs = zoneserver_list.FindByZoneID(cle->zone()); - if(zs) { - zs->SendPacket(pack); - } - else { - // send target not found back to requester - auto pack = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct)); - ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer; - strcpy(scs->grantname, s->grantname); - strcpy(scs->ownername, s->ownername); - scs->permission = s->permission; - scs->zone_id = s->zone_id; - scs->message_string_id = 101; - zs = zoneserver_list.FindByZoneID(s->zone_id); - if(zs) { - zs->SendPacket(pack); - } - else { - Log.Out(Logs::Detail, Logs::World_Server, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent_Response operation.", s->zone_id); - } - safe_delete(pack); - } - } + break; + } + case ServerOP_Consent_Response: { + // Message string id's likely to be used here are: + // CONSENT_YOURSELF = 399 + // CONSENT_INVALID_NAME = 397 + // TARGET_NOT_FOUND = 101 + ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer; + if (s->instance_id != 0) + { + ZoneServer* zs = zoneserver_list.FindByInstanceID(s->instance_id); + if (zs) { + zs->SendPacket(pack); } else { - // send target not found back to requester - auto pack = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct)); - ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer; - strcpy(scs->grantname, s->grantname); - strcpy(scs->ownername, s->ownername); - scs->permission = s->permission; - scs->zone_id = s->zone_id; - scs->message_string_id = 397; - zs = zoneserver_list.FindByZoneID(s->zone_id); - if(zs) { - zs->SendPacket(pack); - } - else { - Log.Out(Logs::Detail, Logs::World_Server, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent_Response operation.", s->zone_id); - } - safe_delete(pack); + Log(Logs::Detail, Logs::World_Server, "Unable to locate zone record for instance id %u in zoneserver list for ServerOP_Consent_Response operation.", s->instance_id); } - break; } - case ServerOP_Consent_Response: { - // Message string id's likely to be used here are: - // CONSENT_YOURSELF = 399 - // CONSENT_INVALID_NAME = 397 - // TARGET_NOT_FOUND = 101 - ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer; - if(s->instance_id != 0) - { - ZoneServer* zs = zoneserver_list.FindByInstanceID(s->instance_id); - if(zs) { - zs->SendPacket(pack); - } - else { - Log.Out(Logs::Detail, Logs::World_Server, "Unable to locate zone record for instance id %u in zoneserver list for ServerOP_Consent_Response operation.", s->instance_id); - } + else + { + ZoneServer* zs = zoneserver_list.FindByZoneID(s->zone_id); + if (zs) { + zs->SendPacket(pack); } - else - { - ZoneServer* zs = zoneserver_list.FindByZoneID(s->zone_id); - if(zs) { - zs->SendPacket(pack); - } - else { - Log.Out(Logs::Detail, Logs::World_Server, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent_Response operation.", s->zone_id); - } + else { + Log(Logs::Detail, Logs::World_Server, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent_Response operation.", s->zone_id); } - break; } + break; + } - case ServerOP_InstanceUpdateTime : + case ServerOP_InstanceUpdateTime: + { + ServerInstanceUpdateTime_Struct *iut = (ServerInstanceUpdateTime_Struct*)pack->pBuffer; + ZoneServer *zm = zoneserver_list.FindByInstanceID(iut->instance_id); + if (zm) { - ServerInstanceUpdateTime_Struct *iut = (ServerInstanceUpdateTime_Struct*)pack->pBuffer; - ZoneServer *zm = zoneserver_list.FindByInstanceID(iut->instance_id); - if(zm) - { - zm->SendPacket(pack); - } - break; + zm->SendPacket(pack); } - case ServerOP_QGlobalUpdate: + break; + } + case ServerOP_QGlobalUpdate: + { + if (pack->size != sizeof(ServerQGlobalUpdate_Struct)) { - if(pack->size != sizeof(ServerQGlobalUpdate_Struct)) - { - break; - } - - zoneserver_list.SendPacket(pack); break; } - case ServerOP_QGlobalDelete: + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_QGlobalDelete: + { + if (pack->size != sizeof(ServerQGlobalDelete_Struct)) { - if(pack->size != sizeof(ServerQGlobalDelete_Struct)) - { - break; - } - - zoneserver_list.SendPacket(pack); break; } - case ServerOP_AdventureRequest: + zoneserver_list.SendPacket(pack); + break; + } + + case ServerOP_AdventureRequest: + { + adventure_manager.CalculateAdventureRequestReply((const char*)pack->pBuffer); + break; + } + + case ServerOP_AdventureRequestCreate: + { + adventure_manager.TryAdventureCreate((const char*)pack->pBuffer); + break; + } + + case ServerOP_AdventureDataRequest: + { + AdventureFinishEvent fe; + while (adventure_manager.PopFinishedEvent((const char*)pack->pBuffer, fe)) { - adventure_manager.CalculateAdventureRequestReply((const char*)pack->pBuffer); - break; + adventure_manager.SendAdventureFinish(fe); + } + adventure_manager.GetAdventureData((const char*)pack->pBuffer); + break; + } + + case ServerOP_AdventureClickDoor: + { + ServerPlayerClickedAdventureDoor_Struct *pcad = (ServerPlayerClickedAdventureDoor_Struct*)pack->pBuffer; + adventure_manager.PlayerClickedDoor(pcad->player, pcad->zone_id, pcad->id); + break; + } + + case ServerOP_AdventureLeave: + { + adventure_manager.LeaveAdventure((const char*)pack->pBuffer); + break; + } + + case ServerOP_AdventureCountUpdate: + { + ServerAdventureCount_Struct *sc = (ServerAdventureCount_Struct*)pack->pBuffer; + adventure_manager.IncrementCount(sc->instance_id); + break; + } + + case ServerOP_AdventureAssaCountUpdate: + { + adventure_manager.IncrementAssassinationCount(*((uint16*)pack->pBuffer)); + break; + } + + case ServerOP_AdventureZoneData: + { + adventure_manager.GetZoneData(*((uint16*)pack->pBuffer)); + break; + } + + case ServerOP_AdventureLeaderboard: + { + ServerLeaderboardRequest_Struct *lr = (ServerLeaderboardRequest_Struct*)pack->pBuffer; + adventure_manager.DoLeaderboardRequest(lr->player, lr->type); + break; + } + + case ServerOP_LSAccountUpdate: + { + Log(Logs::Detail, Logs::World_Server, "Received ServerOP_LSAccountUpdate packet from zone"); + loginserverlist.SendAccountUpdate(pack); + break; + } + + case ServerOP_UCSMailMessage: + { + UCSLink.SendPacket(pack); + break; + } + case ServerOP_QSSendQuery: + case ServerOP_QueryServGeneric: + case ServerOP_Speech: + case ServerOP_QSPlayerLogTrades: + case ServerOP_QSPlayerLogHandins: + case ServerOP_QSPlayerLogNPCKills: + case ServerOP_QSPlayerLogDeletes: + case ServerOP_QSPlayerLogMoves: + case ServerOP_QSPlayerLogMerchantTransactions: + { + QSLink.SendPacket(pack); + break; + } + case ServerOP_CZSignalClientByName: + case ServerOP_CZMessagePlayer: + case ServerOP_CZSignalNPC: + case ServerOP_CZSetEntityVariableByNPCTypeID: + case ServerOP_CZSignalClient: + case ServerOP_WWMarquee: + case ServerOP_DepopAllPlayersCorpses: + case ServerOP_DepopPlayerCorpse: + case ServerOP_ReloadTitles: + case ServerOP_SpawnStatusChange: + case ServerOP_ReloadTasks: + case ServerOP_ReloadWorld: + case ServerOP_UpdateSpawn: + { + zoneserver_list.SendPacket(pack); + break; + } + case ServerOP_ChangeSharedMem: { + std::string hotfix_name = std::string((char*)pack->pBuffer); + + Log(Logs::General, Logs::World_Server, "Loading items..."); + if (!database.LoadItems(hotfix_name)) { + Log(Logs::General, Logs::World_Server, "Error: Could not load item data. But ignoring"); } - case ServerOP_AdventureRequestCreate: - { - adventure_manager.TryAdventureCreate((const char*)pack->pBuffer); - break; + Log(Logs::General, Logs::World_Server, "Loading skill caps..."); + if (!database.LoadSkillCaps(hotfix_name)) { + Log(Logs::General, Logs::World_Server, "Error: Could not load skill cap data. But ignoring"); } - case ServerOP_AdventureDataRequest: - { - AdventureFinishEvent fe; - while(adventure_manager.PopFinishedEvent((const char*)pack->pBuffer, fe)) - { - adventure_manager.SendAdventureFinish(fe); - } - adventure_manager.GetAdventureData((const char*)pack->pBuffer); - break; - } + zoneserver_list.SendPacket(pack); + break; + } - case ServerOP_AdventureClickDoor: - { - ServerPlayerClickedAdventureDoor_Struct *pcad = (ServerPlayerClickedAdventureDoor_Struct*)pack->pBuffer; - adventure_manager.PlayerClickedDoor(pcad->player, pcad->zone_id, pcad->id); + case ServerOP_RequestTellQueue: + { + ServerRequestTellQueue_Struct* rtq = (ServerRequestTellQueue_Struct*)pack->pBuffer; + ClientListEntry *cle = client_list.FindCharacter(rtq->name); + if (!cle || cle->TellQueueEmpty()) break; - } - case ServerOP_AdventureLeave: - { - adventure_manager.LeaveAdventure((const char*)pack->pBuffer); - break; - } - - case ServerOP_AdventureCountUpdate: - { - ServerAdventureCount_Struct *sc = (ServerAdventureCount_Struct*)pack->pBuffer; - adventure_manager.IncrementCount(sc->instance_id); - break; - } - - case ServerOP_AdventureAssaCountUpdate: - { - adventure_manager.IncrementAssassinationCount(*((uint16*)pack->pBuffer)); - break; - } - - case ServerOP_AdventureZoneData: - { - adventure_manager.GetZoneData(*((uint16*)pack->pBuffer)); - break; - } - - case ServerOP_AdventureLeaderboard: - { - ServerLeaderboardRequest_Struct *lr = (ServerLeaderboardRequest_Struct*)pack->pBuffer; - adventure_manager.DoLeaderboardRequest(lr->player, lr->type); - break; - } - - case ServerOP_LSAccountUpdate: - { - Log.Out(Logs::Detail, Logs::World_Server, "Received ServerOP_LSAccountUpdate packet from zone"); - loginserverlist.SendAccountUpdate(pack); - break; - } - - case ServerOP_UCSMailMessage: - { - UCSLink.SendPacket(pack); - break; - } - case ServerOP_QSSendQuery: - case ServerOP_QueryServGeneric: - case ServerOP_Speech: - case ServerOP_QSPlayerLogTrades: - case ServerOP_QSPlayerLogHandins: - case ServerOP_QSPlayerLogNPCKills: - case ServerOP_QSPlayerLogDeletes: - case ServerOP_QSPlayerLogMoves: - case ServerOP_QSPlayerLogMerchantTransactions: - { - QSLink.SendPacket(pack); - break; - } - case ServerOP_CZSignalClientByName: - case ServerOP_CZMessagePlayer: - case ServerOP_CZSignalNPC: - case ServerOP_CZSetEntityVariableByNPCTypeID: - case ServerOP_CZSignalClient: - case ServerOP_WWMarquee: - case ServerOP_DepopAllPlayersCorpses: - case ServerOP_DepopPlayerCorpse: - case ServerOP_ReloadTitles: - case ServerOP_SpawnStatusChange: - case ServerOP_ReloadTasks: - case ServerOP_ReloadWorld: - case ServerOP_UpdateSpawn: - { - zoneserver_list.SendPacket(pack); - break; - } - case ServerOP_ChangeSharedMem: { - std::string hotfix_name = std::string((char*)pack->pBuffer); - - Log.Out(Logs::General, Logs::World_Server, "Loading items..."); - if(!database.LoadItems(hotfix_name)) { - Log.Out(Logs::General, Logs::World_Server, "Error: Could not load item data. But ignoring"); - } - - Log.Out(Logs::General, Logs::World_Server, "Loading skill caps..."); - if(!database.LoadSkillCaps(hotfix_name)) { - Log.Out(Logs::General, Logs::World_Server, "Error: Could not load skill cap data. But ignoring"); - } - - zoneserver_list.SendPacket(pack); - break; - } - - case ServerOP_RequestTellQueue: - { - ServerRequestTellQueue_Struct* rtq = (ServerRequestTellQueue_Struct*) pack->pBuffer; - ClientListEntry *cle = client_list.FindCharacter(rtq->name); - if (!cle || cle->TellQueueEmpty()) - break; - - cle->ProcessTellQueue(); - break; - } - default: - { - Log.Out(Logs::Detail, Logs::World_Server, "Unknown ServerOPcode from zone 0x%04x, size %d", pack->opcode, pack->size); - DumpPacket(pack->pBuffer, pack->size); - break; - } + cle->ProcessTellQueue(); + break; + } + default: + { + Log(Logs::Detail, Logs::World_Server, "Unknown ServerOPcode from zone 0x%04x, size %d", pack->opcode, pack->size); + DumpPacket(pack->pBuffer, pack->size); + break; + } } } @@ -1311,13 +1314,13 @@ void ZoneServer::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 auto pack = new ServerPacket; pack->opcode = ServerOP_EmoteMessage; - pack->size = sizeof(ServerEmoteMessage_Struct)+strlen(message)+1; + pack->size = sizeof(ServerEmoteMessage_Struct) + strlen(message) + 1; pack->pBuffer = new uchar[pack->size]; memset(pack->pBuffer, 0, pack->size); - ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*) pack->pBuffer; + ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer; if (to != 0) { - strcpy((char *) sem->to, to); + strcpy((char *)sem->to, to); } else { sem->to[0] = 0; @@ -1342,7 +1345,7 @@ void ZoneServer::SendGroupIDs() { void ZoneServer::ChangeWID(uint32 iCharID, uint32 iWID) { auto pack = new ServerPacket(ServerOP_ChangeWID, sizeof(ServerChangeWID_Struct)); - ServerChangeWID_Struct* scw = (ServerChangeWID_Struct*) pack->pBuffer; + ServerChangeWID_Struct* scw = (ServerChangeWID_Struct*)pack->pBuffer; scw->charid = iCharID; scw->newwid = iWID; zoneserver_list.SendPacket(pack); @@ -1356,7 +1359,7 @@ void ZoneServer::TriggerBootup(uint32 iZoneID, uint32 iInstanceID, const char* a instance_id = iInstanceID; auto pack = new ServerPacket(ServerOP_ZoneBootup, sizeof(ServerZoneStateChange_struct)); - ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *) pack->pBuffer; + ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *)pack->pBuffer; s->ZoneServerID = zone_server_id; if (adminname != 0) strcpy(s->adminname, adminname); @@ -1376,7 +1379,7 @@ void ZoneServer::TriggerBootup(uint32 iZoneID, uint32 iInstanceID, const char* a void ZoneServer::IncomingClient(Client* client) { is_booting_up = true; auto pack = new ServerPacket(ServerOP_ZoneIncClient, sizeof(ServerZoneIncomingClient_Struct)); - ServerZoneIncomingClient_Struct* s = (ServerZoneIncomingClient_Struct*) pack->pBuffer; + ServerZoneIncomingClient_Struct* s = (ServerZoneIncomingClient_Struct*)pack->pBuffer; s->zoneid = GetZoneID(); s->instanceid = GetInstanceID(); s->wid = client->GetWID(); @@ -1391,4 +1394,3 @@ void ZoneServer::IncomingClient(Client* client) { SendPacket(pack); delete pack; } - diff --git a/zone/aa.cpp b/zone/aa.cpp index 3c6f11f6e..2fb99a6fb 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -47,20 +47,20 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u return; PetRecord record; - if(!database.GetPetEntry(spells[spell_id].teleport_zone, &record)) + if (!database.GetPetEntry(spells[spell_id].teleport_zone, &record)) { - Log.Out(Logs::General, Logs::Error, "Unknown swarm pet spell id: %d, check pets table", spell_id); + Log(Logs::General, Logs::Error, "Unknown swarm pet spell id: %d, check pets table", spell_id); Message(13, "Unable to find data for pet %s", spells[spell_id].teleport_zone); return; } - AA_SwarmPet pet; + SwarmPet_Struct pet; pet.count = 1; pet.duration = 1; - for(int x = 0; x < MAX_SWARM_PETS; x++) + for (int x = 0; x < MAX_SWARM_PETS; x++) { - if(spells[spell_id].effectid[x] == SE_TemporaryPets) + if (spells[spell_id].effectid[x] == SE_TemporaryPets) { pet.count = spells[spell_id].base[x]; pet.duration = spells[spell_id].max[x]; @@ -74,14 +74,14 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u NPCType *made_npc = nullptr; const NPCType *npc_type = database.LoadNPCTypesData(pet.npc_id); - if(npc_type == nullptr) { + if (npc_type == nullptr) { //log write - Log.Out(Logs::General, Logs::Error, "Unknown npc type for swarm pet spell id: %d", spell_id); - Message(0,"Unable to find pet!"); + Log(Logs::General, Logs::Error, "Unknown npc type for swarm pet spell id: %d", spell_id); + Message(0, "Unable to find pet!"); return; } - if(name_override != nullptr) { + if (name_override != nullptr) { //we have to make a custom NPC type for this name change made_npc = new NPCType; memcpy(made_npc, npc_type, sizeof(NPCType)); @@ -92,7 +92,7 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u int summon_count = 0; summon_count = pet.count; - if(summon_count > MAX_SWARM_PETS) + if (summon_count > MAX_SWARM_PETS) summon_count = MAX_SWARM_PETS; static const glm::vec2 swarmPetLocations[MAX_SWARM_PETS] = { @@ -101,59 +101,61 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u glm::vec2(8, 8), glm::vec2(-8, 8), glm::vec2(8, -8), glm::vec2(-8, -8) }; - while(summon_count > 0) { + while (summon_count > 0) { int pet_duration = pet.duration; - if(duration_override > 0) + if (duration_override > 0) pet_duration = duration_override; //this is a little messy, but the only way to do it right //it would be possible to optimize out this copy for the last pet, but oh well NPCType *npc_dup = nullptr; - if(made_npc != nullptr) { + if (made_npc != nullptr) { npc_dup = new NPCType; memcpy(npc_dup, made_npc, sizeof(NPCType)); } - NPC* npca = new NPC( - (npc_dup!=nullptr)?npc_dup:npc_type, //make sure we give the NPC the correct data pointer - 0, - GetPosition() + glm::vec4(swarmPetLocations[summon_count], 0.0f, 0.0f), - FlyMode3); + NPC* swarm_pet_npc = new NPC( + (npc_dup != nullptr) ? npc_dup : npc_type, //make sure we give the NPC the correct data pointer + 0, + GetPosition() + glm::vec4(swarmPetLocations[summon_count], 0.0f, 0.0f), + FlyMode3); if (followme) - npca->SetFollowID(GetID()); + swarm_pet_npc->SetFollowID(GetID()); - if(!npca->GetSwarmInfo()){ - auto nSI = new AA_SwarmPetInfo; - npca->SetSwarmInfo(nSI); - npca->GetSwarmInfo()->duration = new Timer(pet_duration*1000); + if (!swarm_pet_npc->GetSwarmInfo()) { + auto nSI = new SwarmPet; + swarm_pet_npc->SetSwarmInfo(nSI); + swarm_pet_npc->GetSwarmInfo()->duration = new Timer(pet_duration * 1000); } - else{ - npca->GetSwarmInfo()->duration->Start(pet_duration*1000); + else { + swarm_pet_npc->GetSwarmInfo()->duration->Start(pet_duration * 1000); } + swarm_pet_npc->StartSwarmTimer(pet_duration * 1000); + //removing this prevents the pet from attacking - npca->GetSwarmInfo()->owner_id = GetID(); + swarm_pet_npc->GetSwarmInfo()->owner_id = GetID(); //give the pets somebody to "love" - if(targ != nullptr){ - npca->AddToHateList(targ, 1000, 1000); + if (targ != nullptr) { + swarm_pet_npc->AddToHateList(targ, 1000, 1000); if (RuleB(Spells, SwarmPetTargetLock) || sticktarg) - npca->GetSwarmInfo()->target = targ->GetID(); + swarm_pet_npc->GetSwarmInfo()->target = targ->GetID(); else - npca->GetSwarmInfo()->target = 0; + swarm_pet_npc->GetSwarmInfo()->target = 0; } //we allocated a new NPC type object, give the NPC ownership of that memory - if(npc_dup != nullptr) - npca->GiveNPCTypeData(npc_dup); + if (npc_dup != nullptr) + swarm_pet_npc->GiveNPCTypeData(npc_dup); - entity_list.AddNPC(npca, true, true); + entity_list.AddNPC(swarm_pet_npc, true, true); summon_count--; } //the target of these swarm pets will take offense to being cast on... - if(targ != nullptr) + if (targ != nullptr) targ->AddToHateList(this, 1, 0); // The other pointers we make are handled elsewhere. @@ -162,7 +164,7 @@ void Mob::TemporaryPets(uint16 spell_id, Mob *targ, const char *name_override, u void Mob::TypesTemporaryPets(uint32 typesid, Mob *targ, const char *name_override, uint32 duration_override, bool followme, bool sticktarg) { - AA_SwarmPet pet; + SwarmPet_Struct pet; pet.count = 1; pet.duration = 1; @@ -173,7 +175,7 @@ void Mob::TypesTemporaryPets(uint32 typesid, Mob *targ, const char *name_overrid const NPCType *npc_type = database.LoadNPCTypesData(typesid); if(npc_type == nullptr) { //log write - Log.Out(Logs::General, Logs::Error, "Unknown npc type for swarm pet type id: %d", typesid); + Log(Logs::General, Logs::Error, "Unknown npc type for swarm pet type id: %d", typesid); Message(0,"Unable to find pet!"); return; } @@ -211,42 +213,44 @@ void Mob::TypesTemporaryPets(uint32 typesid, Mob *targ, const char *name_overrid memcpy(npc_dup, made_npc, sizeof(NPCType)); } - NPC* npca = new NPC( + NPC* swarm_pet_npc = new NPC( (npc_dup!=nullptr)?npc_dup:npc_type, //make sure we give the NPC the correct data pointer 0, GetPosition() + glm::vec4(swarmPetLocations[summon_count], 0.0f, 0.0f), FlyMode3); if (followme) - npca->SetFollowID(GetID()); + swarm_pet_npc->SetFollowID(GetID()); - if(!npca->GetSwarmInfo()){ - auto nSI = new AA_SwarmPetInfo; - npca->SetSwarmInfo(nSI); - npca->GetSwarmInfo()->duration = new Timer(pet_duration*1000); + if(!swarm_pet_npc->GetSwarmInfo()){ + auto nSI = new SwarmPet; + swarm_pet_npc->SetSwarmInfo(nSI); + swarm_pet_npc->GetSwarmInfo()->duration = new Timer(pet_duration*1000); } - else{ - npca->GetSwarmInfo()->duration->Start(pet_duration*1000); + else { + swarm_pet_npc->GetSwarmInfo()->duration->Start(pet_duration*1000); } + swarm_pet_npc->StartSwarmTimer(pet_duration * 1000); + //removing this prevents the pet from attacking - npca->GetSwarmInfo()->owner_id = GetID(); + swarm_pet_npc->GetSwarmInfo()->owner_id = GetID(); //give the pets somebody to "love" if(targ != nullptr){ - npca->AddToHateList(targ, 1000, 1000); + swarm_pet_npc->AddToHateList(targ, 1000, 1000); if (RuleB(Spells, SwarmPetTargetLock) || sticktarg) - npca->GetSwarmInfo()->target = targ->GetID(); + swarm_pet_npc->GetSwarmInfo()->target = targ->GetID(); else - npca->GetSwarmInfo()->target = 0; + swarm_pet_npc->GetSwarmInfo()->target = 0; } //we allocated a new NPC type object, give the NPC ownership of that memory if(npc_dup != nullptr) - npca->GiveNPCTypeData(npc_dup); + swarm_pet_npc->GiveNPCTypeData(npc_dup); - entity_list.AddNPC(npca, true, true); + entity_list.AddNPC(swarm_pet_npc, true, true); summon_count--; } @@ -404,7 +408,7 @@ void Mob::WakeTheDead(uint16 spell_id, Mob *target, uint32 duration) auto npca = new NPC(make_npc, 0, GetPosition(), FlyMode3); if(!npca->GetSwarmInfo()){ - auto nSI = new AA_SwarmPetInfo; + auto nSI = new SwarmPet; npca->SetSwarmInfo(nSI); npca->GetSwarmInfo()->duration = new Timer(duration*1000); } @@ -793,21 +797,21 @@ void Client::RefundAA() { SendAlternateAdvancementStats(); } -AA_SwarmPetInfo::AA_SwarmPetInfo() +SwarmPet::SwarmPet() { target = 0; owner_id = 0; duration = nullptr; } -AA_SwarmPetInfo::~AA_SwarmPetInfo() +SwarmPet::~SwarmPet() { target = 0; owner_id = 0; safe_delete(duration); } -Mob *AA_SwarmPetInfo::GetOwner() +Mob *SwarmPet::GetOwner() { return entity_list.GetMobID(owner_id); } @@ -1533,17 +1537,17 @@ bool Mob::CanPurchaseAlternateAdvancementRank(AA::Rank *rank, bool check_price, } void Zone::LoadAlternateAdvancement() { - Log.Out(Logs::General, Logs::Status, "Loading Alternate Advancement Data..."); + Log(Logs::General, Logs::Status, "Loading Alternate Advancement Data..."); if(!database.LoadAlternateAdvancementAbilities(aa_abilities, aa_ranks)) { aa_abilities.clear(); aa_ranks.clear(); - Log.Out(Logs::General, Logs::Status, "Failed to load Alternate Advancement Data"); + Log(Logs::General, Logs::Status, "Failed to load Alternate Advancement Data"); return; } - Log.Out(Logs::General, Logs::Status, "Processing Alternate Advancement Data..."); + Log(Logs::General, Logs::Status, "Processing Alternate Advancement Data..."); for(const auto &ability : aa_abilities) { ability.second->first = GetAlternateAdvancementRank(ability.second->first_rank_id); @@ -1594,13 +1598,13 @@ void Zone::LoadAlternateAdvancement() { } } - Log.Out(Logs::General, Logs::Status, "Loaded Alternate Advancement Data"); + Log(Logs::General, Logs::Status, "Loaded Alternate Advancement Data"); } bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map> &abilities, std::unordered_map> &ranks) { - Log.Out(Logs::General, Logs::Status, "Loading Alternate Advancement Abilities..."); + Log(Logs::General, Logs::Status, "Loading Alternate Advancement Abilities..."); abilities.clear(); std::string query = "SELECT id, name, category, classes, races, deities, drakkin_heritage, status, type, charges, " "grant_only, first_rank_id FROM aa_ability WHERE enabled = 1"; @@ -1626,13 +1630,13 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_mapid] = std::unique_ptr(ability); } } else { - Log.Out(Logs::General, Logs::Error, "Failed to load Alternate Advancement Abilities"); + Log(Logs::General, Logs::Error, "Failed to load Alternate Advancement Abilities"); return false; } - Log.Out(Logs::General, Logs::Status, "Loaded %d Alternate Advancement Abilities", (int)abilities.size()); + Log(Logs::General, Logs::Status, "Loaded %d Alternate Advancement Abilities", (int)abilities.size()); - Log.Out(Logs::General, Logs::Status, "Loading Alternate Advancement Ability Ranks..."); + Log(Logs::General, Logs::Status, "Loading Alternate Advancement Ability Ranks..."); ranks.clear(); query = "SELECT id, upper_hotkey_sid, lower_hotkey_sid, title_sid, desc_sid, cost, level_req, spell, spell_type, recast_time, " "next_id, expansion FROM aa_ranks"; @@ -1661,13 +1665,13 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_mapid] = std::unique_ptr(rank); } } else { - Log.Out(Logs::General, Logs::Error, "Failed to load Alternate Advancement Ability Ranks"); + Log(Logs::General, Logs::Error, "Failed to load Alternate Advancement Ability Ranks"); return false; } - Log.Out(Logs::General, Logs::Status, "Loaded %d Alternate Advancement Ability Ranks", (int)ranks.size()); + Log(Logs::General, Logs::Status, "Loaded %d Alternate Advancement Ability Ranks", (int)ranks.size()); - Log.Out(Logs::General, Logs::Status, "Loading Alternate Advancement Ability Rank Effects..."); + Log(Logs::General, Logs::Status, "Loading Alternate Advancement Ability Rank Effects..."); query = "SELECT rank_id, slot, effect_id, base1, base2 FROM aa_rank_effects"; results = QueryDatabase(query); if(results.Success()) { @@ -1688,13 +1692,13 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map iAggroRange) || ( t2 > iAggroRange) || ( t3 > iAggroRange) - ||(mob->IsInvisible(this)) + || (mob->IsInvisible(this)) || (mob->IsClient() && (!mob->CastToClient()->Connected() || mob->CastToClient()->IsLD() @@ -298,7 +298,7 @@ bool Mob::CheckWillAggro(Mob *mob) { // Don't aggro new clients if we are already engaged unless PROX_AGGRO is set if (IsEngaged() && (!GetSpecialAbility(PROX_AGGRO) || (GetSpecialAbility(PROX_AGGRO) && !CombatRange(mob)))) { - Log.Out(Logs::Moderate, Logs::Aggro, + Log(Logs::Moderate, Logs::Aggro, "%s is in combat, and does not have prox_aggro, or does and is out of combat range with %s", GetName(), mob->GetName()); return false; @@ -360,7 +360,7 @@ bool Mob::CheckWillAggro(Mob *mob) { { //FatherNiwtit: make sure we can see them. last since it is very expensive if(CheckLosFN(mob)) { - Log.Out(Logs::Detail, Logs::Aggro, "Check aggro for %s target %s.", GetName(), mob->GetName()); + Log(Logs::Detail, Logs::Aggro, "Check aggro for %s target %s.", GetName(), mob->GetName()); return( mod_will_aggro(mob, this) ); } } @@ -392,18 +392,18 @@ bool Mob::CheckWillAggro(Mob *mob) { { //FatherNiwtit: make sure we can see them. last since it is very expensive if(CheckLosFN(mob)) { - Log.Out(Logs::Detail, Logs::Aggro, "Check aggro for %s target %s.", GetName(), mob->GetName()); + Log(Logs::Detail, Logs::Aggro, "Check aggro for %s target %s.", GetName(), mob->GetName()); return( mod_will_aggro(mob, this) ); } } } - Log.Out(Logs::Detail, Logs::Aggro, "Is In zone?:%d\n", mob->InZone()); - Log.Out(Logs::Detail, Logs::Aggro, "Dist^2: %f\n", dist2); - Log.Out(Logs::Detail, Logs::Aggro, "Range^2: %f\n", iAggroRange2); - Log.Out(Logs::Detail, Logs::Aggro, "Faction: %d\n", fv); - Log.Out(Logs::Detail, Logs::Aggro, "Int: %d\n", GetINT()); - Log.Out(Logs::Detail, Logs::Aggro, "Con: %d\n", GetLevelCon(mob->GetLevel())); + Log(Logs::Detail, Logs::Aggro, "Is In zone?:%d\n", mob->InZone()); + Log(Logs::Detail, Logs::Aggro, "Dist^2: %f\n", dist2); + Log(Logs::Detail, Logs::Aggro, "Range^2: %f\n", iAggroRange2); + Log(Logs::Detail, Logs::Aggro, "Faction: %d\n", fv); + Log(Logs::Detail, Logs::Aggro, "Int: %d\n", GetINT()); + Log(Logs::Detail, Logs::Aggro, "Con: %d\n", GetLevelCon(mob->GetLevel())); return(false); } @@ -526,7 +526,7 @@ void EntityList::AIYellForHelp(Mob* sender, Mob* attacker) { //Father Nitwit: make sure we can see them. if(mob->CheckLosFN(sender)) { #if (EQDEBUG>=5) - Log.Out(Logs::General, Logs::None, "AIYellForHelp(\"%s\",\"%s\") %s attacking %s Dist %f Z %f", + Log(Logs::General, Logs::None, "AIYellForHelp(\"%s\",\"%s\") %s attacking %s Dist %f Z %f", sender->GetName(), attacker->GetName(), mob->GetName(), attacker->GetName(), DistanceSquared(mob->GetPosition(), sender->GetPosition()), fabs(sender->GetZ()+mob->GetZ())); @@ -756,7 +756,7 @@ type', in which case, the answer is yes. } while( reverse++ == 0 ); - Log.Out(Logs::General, Logs::None, "Mob::IsAttackAllowed: don't have a rule for this - %s vs %s\n", this->GetName(), target->GetName()); + Log(Logs::General, Logs::None, "Mob::IsAttackAllowed: don't have a rule for this - %s vs %s\n", this->GetName(), target->GetName()); return false; } @@ -896,7 +896,7 @@ bool Mob::IsBeneficialAllowed(Mob *target) } while( reverse++ == 0 ); - Log.Out(Logs::General, Logs::None, "Mob::IsBeneficialAllowed: don't have a rule for this - %s to %s\n", this->GetName(), target->GetName()); + Log(Logs::General, Logs::None, "Mob::IsBeneficialAllowed: don't have a rule for this - %s to %s\n", this->GetName(), target->GetName()); return false; } @@ -1008,7 +1008,7 @@ bool Mob::CheckLosFN(float posX, float posY, float posZ, float mobSize) { oloc.z = posZ + (mobSize==0.0?LOS_DEFAULT_HEIGHT:mobSize)/2 * SEE_POSITION; #if LOSDEBUG>=5 - Log.Out(Logs::General, Logs::None, "LOS from (%.2f, %.2f, %.2f) to (%.2f, %.2f, %.2f) sizes: (%.2f, %.2f)", myloc.x, myloc.y, myloc.z, oloc.x, oloc.y, oloc.z, GetSize(), mobSize); + Log(Logs::General, Logs::None, "LOS from (%.2f, %.2f, %.2f) to (%.2f, %.2f, %.2f) sizes: (%.2f, %.2f)", myloc.x, myloc.y, myloc.z, oloc.x, oloc.y, oloc.z, GetSize(), mobSize); #endif return zone->zonemap->CheckLoS(myloc, oloc); } diff --git a/zone/attack.cpp b/zone/attack.cpp index ed1b0352d..c925555a1 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2002 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2002 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" @@ -59,7 +59,7 @@ bool Mob::AttackAnimation(EQEmu::skills::SkillType &skillinuse, int Hand, const if (weapon && weapon->IsClassCommon()) { const EQEmu::ItemData* item = weapon->GetItem(); - Log.Out(Logs::Detail, Logs::Attack, "Weapon skill : %i", item->ItemType); + Log(Logs::Detail, Logs::Attack, "Weapon skill : %i", item->ItemType); switch (item->ItemType) { case EQEmu::item::ItemType1HSlash: // 1H Slashing @@ -99,7 +99,7 @@ bool Mob::AttackAnimation(EQEmu::skills::SkillType &skillinuse, int Hand, const break; }// switch } - else if(IsNPC()) { + else if (IsNPC()) { switch (skillinuse) { case EQEmu::skills::Skill1HSlashing: // 1H Slashing type = anim1HWeapon; @@ -151,7 +151,8 @@ int Mob::compute_tohit(EQEmu::skills::SkillType skillinuse) if (reduction > 20.0) { reduction = std::min((110 - reduction) / 100.0, 1.0); tohit = reduction * static_cast(tohit); - } else if (IsBerserk()) { + } + else if (IsBerserk()) { tohit += (GetLevel() * 2) / 5; } } @@ -181,11 +182,11 @@ int Mob::GetTotalToHit(EQEmu::skills::SkillType skill, int chance_mod) // 216 Melee Accuracy Amt aka SE_Accuracy -- flat bonus accuracy += itembonuses.Accuracy[EQEmu::skills::HIGHEST_SKILL + 1] + - aabonuses.Accuracy[EQEmu::skills::HIGHEST_SKILL + 1] + - spellbonuses.Accuracy[EQEmu::skills::HIGHEST_SKILL + 1] + - itembonuses.Accuracy[skill] + - aabonuses.Accuracy[skill] + - spellbonuses.Accuracy[skill]; + aabonuses.Accuracy[EQEmu::skills::HIGHEST_SKILL + 1] + + spellbonuses.Accuracy[EQEmu::skills::HIGHEST_SKILL + 1] + + itembonuses.Accuracy[skill] + + aabonuses.Accuracy[skill] + + spellbonuses.Accuracy[skill]; // auto hit discs (and looks like there are some autohit AAs) if (spellbonuses.HitChanceEffect[skill] >= 10000 || aabonuses.HitChanceEffect[skill] >= 10000) @@ -196,11 +197,11 @@ int Mob::GetTotalToHit(EQEmu::skills::SkillType skill, int chance_mod) // 184 Accuracy % aka SE_HitChance -- percentage increase auto hit_bonus = itembonuses.HitChanceEffect[EQEmu::skills::HIGHEST_SKILL + 1] + - aabonuses.HitChanceEffect[EQEmu::skills::HIGHEST_SKILL + 1] + - spellbonuses.HitChanceEffect[EQEmu::skills::HIGHEST_SKILL + 1] + - itembonuses.HitChanceEffect[skill] + - aabonuses.HitChanceEffect[skill] + - spellbonuses.HitChanceEffect[skill]; + aabonuses.HitChanceEffect[EQEmu::skills::HIGHEST_SKILL + 1] + + spellbonuses.HitChanceEffect[EQEmu::skills::HIGHEST_SKILL + 1] + + itembonuses.HitChanceEffect[skill] + + aabonuses.HitChanceEffect[skill] + + spellbonuses.HitChanceEffect[skill]; accuracy = (accuracy * (100 + hit_bonus)) / 100; @@ -272,7 +273,7 @@ bool Mob::CheckHitChance(Mob* other, DamageHitInfo &hit) { Mob *attacker = other; Mob *defender = this; - Log.Out(Logs::Detail, Logs::Attack, "CheckHitChance(%s) attacked by %s", defender->GetName(), attacker->GetName()); + Log(Logs::Detail, Logs::Attack, "CheckHitChance(%s) attacked by %s", defender->GetName(), attacker->GetName()); if (defender->IsClient() && defender->CastToClient()->IsSitting()) return true; @@ -290,7 +291,7 @@ bool Mob::CheckHitChance(Mob* other, DamageHitInfo &hit) // Then your chance to simply avoid the attack is checked (defender's avoidance roll beat the attacker's accuracy roll.) int tohit_roll = zone->random.Roll0(accuracy); int avoid_roll = zone->random.Roll0(avoidance); - Log.Out(Logs::Detail, Logs::Attack, "CheckHitChance accuracy(%d => %d) avoidance(%d => %d)", accuracy, tohit_roll, avoidance, avoid_roll); + Log(Logs::Detail, Logs::Attack, "CheckHitChance accuracy(%d => %d) avoidance(%d => %d)", accuracy, tohit_roll, avoidance, avoid_roll); // tie breaker? Don't want to be biased any one way if (tohit_roll == avoid_roll) @@ -312,26 +313,26 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit) */ /* Order according to current (SoF+?) dev quotes: - * https://forums.daybreakgames.com/eq/index.php?threads/test-update-06-10-15.223510/page-2#post-3261772 - * https://forums.daybreakgames.com/eq/index.php?threads/test-update-06-10-15.223510/page-2#post-3268227 - * Riposte 50, hDEX, must have weapon/fists, doesn't work on archery/throwing - * Block 25, hDEX, works on archery/throwing, behind block done here if back to attacker base1 is chance - * Parry 45, hDEX, doesn't work on throwing/archery, must be facing target - * Dodge 45, hAGI, works on archery/throwing, monks can dodge attacks from behind - * Shield Block, rand base1 - * Staff Block, rand base1 - * regular strike through - * avoiding the attack (CheckHitChance) - * As soon as one succeeds, none of the rest are checked - * - * Formula (all int math) - * (posted for parry, assume rest at the same) - * Chance = (((SKILL + 100) + [((SKILL+100) * SPA(175).Base1) / 100]) / 45) + [(hDex / 25) - min([hDex / 25], hStrikethrough)]. - * hStrikethrough is a mob stat that was added to counter the bonuses of heroic stats - * Number rolled against 100, if the chance is greater than 100 it happens 100% of time - * - * Things with 10k accuracy mods can be avoided with these skills qq - */ + * https://forums.daybreakgames.com/eq/index.php?threads/test-update-06-10-15.223510/page-2#post-3261772 + * https://forums.daybreakgames.com/eq/index.php?threads/test-update-06-10-15.223510/page-2#post-3268227 + * Riposte 50, hDEX, must have weapon/fists, doesn't work on archery/throwing + * Block 25, hDEX, works on archery/throwing, behind block done here if back to attacker base1 is chance + * Parry 45, hDEX, doesn't work on throwing/archery, must be facing target + * Dodge 45, hAGI, works on archery/throwing, monks can dodge attacks from behind + * Shield Block, rand base1 + * Staff Block, rand base1 + * regular strike through + * avoiding the attack (CheckHitChance) + * As soon as one succeeds, none of the rest are checked + * + * Formula (all int math) + * (posted for parry, assume rest at the same) + * Chance = (((SKILL + 100) + [((SKILL+100) * SPA(175).Base1) / 100]) / 45) + [(hDex / 25) - min([hDex / 25], hStrikethrough)]. + * hStrikethrough is a mob stat that was added to counter the bonuses of heroic stats + * Number rolled against 100, if the chance is greater than 100 it happens 100% of time + * + * Things with 10k accuracy mods can be avoided with these skills qq + */ Mob *attacker = other; Mob *defender = this; @@ -364,7 +365,7 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit) if (hit.hand != EQEmu::inventory::slotRange && (CanThisClassRiposte() || IsEnraged()) && InFront && !ImmuneRipo) { if (IsEnraged()) { hit.damage_done = DMG_RIPOSTED; - Log.Out(Logs::Detail, Logs::Combat, "I am enraged, riposting frontal attack."); + Log(Logs::Detail, Logs::Combat, "I am enraged, riposting frontal attack."); return true; } if (IsClient()) @@ -409,7 +410,7 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit) CastToClient()->CheckIncreaseSkill(EQEmu::skills::SkillBlock, other, -10); // check auto discs ... I guess aa/items too :P if (spellbonuses.IncreaseBlockChance == 10000 || aabonuses.IncreaseBlockChance == 10000 || - itembonuses.IncreaseBlockChance == 10000) { + itembonuses.IncreaseBlockChance == 10000) { hit.damage_done = DMG_BLOCKED; return true; } @@ -451,7 +452,7 @@ bool Mob::AvoidDamage(Mob *other, DamageHitInfo &hit) } // dodge - if (CanThisClassDodge() && (InFront || GetClass() == MONK) ) { + if (CanThisClassDodge() && (InFront || GetClass() == MONK)) { if (IsClient()) CastToClient()->CheckIncreaseSkill(EQEmu::skills::SkillDodge, other, -10); // check auto discs ... I guess aa/items too :P @@ -505,59 +506,59 @@ int Mob::GetACSoftcap() { // from test server Resources/ACMitigation.txt static int war_softcaps[] = { - 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, - 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, - 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, - 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, - 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520 + 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, + 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, + 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, + 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, + 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520 }; static int clrbrdmnk_softcaps[] = { - 274, 276, 278, 278, 280, 282, 284, 286, 288, 290, 292, 292, 294, 296, 298, 300, 302, 304, 306, 308, 308, - 310, 312, 314, 316, 318, 320, 322, 322, 324, 326, 328, 330, 332, 334, 336, 336, 338, 340, 342, 344, 346, - 348, 350, 352, 352, 354, 356, 358, 360, 362, 364, 366, 366, 368, 370, 372, 374, 376, 378, 380, 380, 382, - 384, 386, 388, 390, 392, 394, 396, 396, 398, 400, 402, 404, 406, 408, 410, 410, 412, 414, 416, 418, 420, - 422, 424, 424, 426, 428, 430, 432, 434, 436, 438, 440, 440, 442, 444, 446, 448, 450, 452, 454, 454, 456 + 274, 276, 278, 278, 280, 282, 284, 286, 288, 290, 292, 292, 294, 296, 298, 300, 302, 304, 306, 308, 308, + 310, 312, 314, 316, 318, 320, 322, 322, 324, 326, 328, 330, 332, 334, 336, 336, 338, 340, 342, 344, 346, + 348, 350, 352, 352, 354, 356, 358, 360, 362, 364, 366, 366, 368, 370, 372, 374, 376, 378, 380, 380, 382, + 384, 386, 388, 390, 392, 394, 396, 396, 398, 400, 402, 404, 406, 408, 410, 410, 412, 414, 416, 418, 420, + 422, 424, 424, 426, 428, 430, 432, 434, 436, 438, 440, 440, 442, 444, 446, 448, 450, 452, 454, 454, 456 }; static int palshd_softcaps[] = { - 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 336, - 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, - 380, 382, 384, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, - 420, 422, 424, 426, 428, 430, 432, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, - 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498 + 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 336, + 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, + 380, 382, 384, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, + 420, 422, 424, 426, 428, 430, 432, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, + 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498 }; static int rng_softcaps[] = { - 286, 288, 290, 292, 294, 296, 298, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 322, - 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, - 364, 366, 368, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 390, 392, 394, 396, 398, 400, - 402, 404, 406, 408, 410, 412, 414, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 436, 438, - 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478 + 286, 288, 290, 292, 294, 296, 298, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 322, + 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, + 364, 366, 368, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 390, 392, 394, 396, 398, 400, + 402, 404, 406, 408, 410, 412, 414, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 436, 438, + 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478 }; static int dru_softcaps[] = { - 254, 256, 258, 260, 262, 264, 264, 266, 268, 270, 272, 272, 274, 276, 278, 280, 282, 282, 284, 286, 288, - 290, 290, 292, 294, 296, 298, 300, 300, 302, 304, 306, 308, 308, 310, 312, 314, 316, 318, 318, 320, 322, - 324, 326, 328, 328, 330, 332, 334, 336, 336, 338, 340, 342, 344, 346, 346, 348, 350, 352, 354, 354, 356, - 358, 360, 362, 364, 364, 366, 368, 370, 372, 372, 374, 376, 378, 380, 382, 382, 384, 386, 388, 390, 390, - 392, 394, 396, 398, 400, 400, 402, 404, 406, 408, 410, 410, 412, 414, 416, 418, 418, 420, 422, 424, 426 + 254, 256, 258, 260, 262, 264, 264, 266, 268, 270, 272, 272, 274, 276, 278, 280, 282, 282, 284, 286, 288, + 290, 290, 292, 294, 296, 298, 300, 300, 302, 304, 306, 308, 308, 310, 312, 314, 316, 318, 318, 320, 322, + 324, 326, 328, 328, 330, 332, 334, 336, 336, 338, 340, 342, 344, 346, 346, 348, 350, 352, 354, 354, 356, + 358, 360, 362, 364, 364, 366, 368, 370, 372, 372, 374, 376, 378, 380, 382, 382, 384, 386, 388, 390, 390, + 392, 394, 396, 398, 400, 400, 402, 404, 406, 408, 410, 410, 412, 414, 416, 418, 418, 420, 422, 424, 426 }; static int rogshmbstber_softcaps[] = { - 264, 266, 268, 270, 272, 272, 274, 276, 278, 280, 282, 282, 284, 286, 288, 290, 292, 294, 294, 296, 298, - 300, 302, 304, 306, 306, 308, 310, 312, 314, 316, 316, 318, 320, 322, 324, 326, 328, 328, 330, 332, 334, - 336, 338, 340, 340, 342, 344, 346, 348, 350, 350, 352, 354, 356, 358, 360, 362, 362, 364, 366, 368, 370, - 372, 374, 374, 376, 378, 380, 382, 384, 384, 386, 388, 390, 392, 394, 396, 396, 398, 400, 402, 404, 406, - 408, 408, 410, 412, 414, 416, 418, 418, 420, 422, 424, 426, 428, 430, 430, 432, 434, 436, 438, 440, 442 + 264, 266, 268, 270, 272, 272, 274, 276, 278, 280, 282, 282, 284, 286, 288, 290, 292, 294, 294, 296, 298, + 300, 302, 304, 306, 306, 308, 310, 312, 314, 316, 316, 318, 320, 322, 324, 326, 328, 328, 330, 332, 334, + 336, 338, 340, 340, 342, 344, 346, 348, 350, 350, 352, 354, 356, 358, 360, 362, 362, 364, 366, 368, 370, + 372, 374, 374, 376, 378, 380, 382, 384, 384, 386, 388, 390, 392, 394, 396, 396, 398, 400, 402, 404, 406, + 408, 408, 410, 412, 414, 416, 418, 418, 420, 422, 424, 426, 428, 430, 430, 432, 434, 436, 438, 440, 442 }; static int necwizmagenc_softcaps[] = { - 248, 250, 252, 254, 256, 256, 258, 260, 262, 264, 264, 266, 268, 270, 272, 272, 274, 276, 278, 280, 280, - 282, 284, 286, 288, 288, 290, 292, 294, 296, 296, 298, 300, 302, 304, 304, 306, 308, 310, 312, 312, 314, - 316, 318, 320, 320, 322, 324, 326, 328, 328, 330, 332, 334, 336, 336, 338, 340, 342, 344, 344, 346, 348, - 350, 352, 352, 354, 356, 358, 360, 360, 362, 364, 366, 368, 368, 370, 372, 374, 376, 376, 378, 380, 382, - 384, 384, 386, 388, 390, 392, 392, 394, 396, 398, 400, 400, 402, 404, 406, 408, 408, 410, 412, 414, 416 + 248, 250, 252, 254, 256, 256, 258, 260, 262, 264, 264, 266, 268, 270, 272, 272, 274, 276, 278, 280, 280, + 282, 284, 286, 288, 288, 290, 292, 294, 296, 296, 298, 300, 302, 304, 304, 306, 308, 310, 312, 312, 314, + 316, 318, 320, 320, 322, 324, 326, 328, 328, 330, 332, 334, 336, 336, 338, 340, 342, 344, 344, 346, 348, + 350, 352, 352, 354, 356, 358, 360, 360, 362, 364, 366, 368, 368, 370, 372, 374, 376, 376, 378, 380, 382, + 384, 384, 386, 388, 390, 392, 392, 394, 396, 398, 400, 400, 402, 404, 406, 408, 408, 410, 412, 414, 416 }; int level = std::min(105, static_cast(GetLevel())) - 1; @@ -634,49 +635,64 @@ int Mob::GetClassRaceACBonus() if (level > 99) { hardcap = 58; softcap = 35; - } else if (level > 94) { + } + else if (level > 94) { hardcap = 57; softcap = 34; - } else if (level > 89) { + } + else if (level > 89) { hardcap = 56; softcap = 33; - } else if (level > 84) { + } + else if (level > 84) { hardcap = 55; softcap = 32; - } else if (level > 79) { + } + else if (level > 79) { hardcap = 54; softcap = 31; - } else if (level > 74) { + } + else if (level > 74) { hardcap = 53; softcap = 30; - } else if (level > 69) { + } + else if (level > 69) { hardcap = 53; softcap = 28; - } else if (level > 64) { + } + else if (level > 64) { hardcap = 53; softcap = 26; - } else if (level > 63) { + } + else if (level > 63) { hardcap = 50; softcap = 24; - } else if (level > 61) { + } + else if (level > 61) { hardcap = 47; softcap = 24; - } else if (level > 59) { + } + else if (level > 59) { hardcap = 45; softcap = 24; - } else if (level > 54) { + } + else if (level > 54) { hardcap = 40; softcap = 20; - } else if (level > 50) { + } + else if (level > 50) { hardcap = 38; softcap = 18; - } else if (level > 44) { + } + else if (level > 44) { hardcap = 36; softcap = 17; - } else if (level > 29) { + } + else if (level > 29) { hardcap = 34; softcap = 16; - } else if (level > 14) { + } + else if (level > 14) { hardcap = 32; softcap = 15; } @@ -689,7 +705,8 @@ int Mob::GetClassRaceACBonus() temp = std::max(0, static_cast(temp * redux)); } ac_bonus = (4 * temp) / 3; - } else if (weight > hardcap + 1) { + } + else if (weight > hardcap + 1) { int temp = level + 5; double multiplier = std::min(1.0, (weight - (hardcap - 10.0)) / 100.0); temp = (4 * temp) / 3; @@ -776,7 +793,8 @@ int Mob::ACSum() ac += spell_aa_ac / 3; else ac += spell_aa_ac / 4; - } else { // TODO: so we can't set NPC skills ... so the skill bonus ends up being HUGE so lets nerf them a bit + } + else { // TODO: so we can't set NPC skills ... so the skill bonus ends up being HUGE so lets nerf them a bit auto spell_aa_ac = aabonuses.AC + spellbonuses.AC; if (EQEmu::ValueWithin(static_cast(GetClass()), NECROMANCER, ENCHANTER)) ac += GetSkill(EQEmu::skills::SkillDefense) / 2 + spell_aa_ac / 3; @@ -791,9 +809,9 @@ int Mob::ACSum() if (IsClient() #ifdef BOTS - || IsBot() + || IsBot() #endif - ) { + ) { auto softcap = GetACSoftcap(); auto returns = GetSoftcapReturns(); int total_aclimitmod = aabonuses.CombatStability + itembonuses.CombatStability + spellbonuses.CombatStability; @@ -804,9 +822,10 @@ int Mob::ACSum() auto over_cap = ac - softcap; ac = softcap + (over_cap * returns); } - Log.Out(Logs::Detail, Logs::Combat, "ACSum ac %d softcap %d returns %f", ac, softcap, returns); - } else { - Log.Out(Logs::Detail, Logs::Combat, "ACSum ac %d", ac); + Log(Logs::Detail, Logs::Combat, "ACSum ac %d softcap %d returns %f", ac, softcap, returns); + } + else { + Log(Logs::Detail, Logs::Combat, "ACSum ac %d", ac); } return ac; } @@ -870,7 +889,7 @@ void Mob::MeleeMitigation(Mob *attacker, DamageHitInfo &hit, ExtraAttackOptions // +0.5 for rounding, min to 1 dmg hit.damage_done = std::max(static_cast(roll * static_cast(hit.base_damage) + 0.5), 1); - Log.Out(Logs::Detail, Logs::Attack, "mitigation %d vs offense %d. base %d rolled %f damage %d", mitigation, hit.offense, hit.base_damage, roll, hit.damage_done); + Log(Logs::Detail, Logs::Attack, "mitigation %d vs offense %d. base %d rolled %f damage %d", mitigation, hit.offense, hit.base_damage, roll, hit.damage_done); } //Returns the weapon damage against the input mob @@ -883,14 +902,14 @@ int Mob::GetWeaponDamage(Mob *against, const EQEmu::ItemData *weapon_item) { int banedmg = 0; //can't hit invulnerable stuff with weapons. - if(against->GetInvul() || against->GetSpecialAbility(IMMUNE_MELEE)){ + if (against->GetInvul() || against->GetSpecialAbility(IMMUNE_MELEE)) { return 0; } //check to see if our weapons or fists are magical. - if(against->GetSpecialAbility(IMMUNE_MELEE_NONMAGICAL)){ - if(weapon_item){ - if(weapon_item->Magic){ + if (against->GetSpecialAbility(IMMUNE_MELEE_NONMAGICAL)) { + if (weapon_item) { + if (weapon_item->Magic) { dmg = weapon_item->Damage; //this is more for non weapon items, ex: boots for kick @@ -900,16 +919,16 @@ int Mob::GetWeaponDamage(Mob *against, const EQEmu::ItemData *weapon_item) { else return 0; } - else{ - if((GetClass() == MONK || GetClass() == BEASTLORD) && GetLevel() >= 30){ + else { + if ((GetClass() == MONK || GetClass() == BEASTLORD) && GetLevel() >= 30) { dmg = GetHandToHandDamage(); } - else if(GetOwner() && GetLevel() >= RuleI(Combat, PetAttackMagicLevel)){ + else if (GetOwner() && GetLevel() >= RuleI(Combat, PetAttackMagicLevel)) { //pets wouldn't actually use this but... //it gives us an idea if we can hit due to the dual nature of this function dmg = 1; } - else if(GetSpecialAbility(SPECATK_MAGICAL)) + else if (GetSpecialAbility(SPECATK_MAGICAL)) { dmg = 1; } @@ -917,39 +936,39 @@ int Mob::GetWeaponDamage(Mob *against, const EQEmu::ItemData *weapon_item) { return 0; } } - else{ - if(weapon_item){ + else { + if (weapon_item) { dmg = weapon_item->Damage; dmg = dmg <= 0 ? 1 : dmg; } - else{ + else { dmg = GetHandToHandDamage(); } } int eledmg = 0; - if(!against->GetSpecialAbility(IMMUNE_MAGIC)){ - if(weapon_item && weapon_item->ElemDmgAmt){ + if (!against->GetSpecialAbility(IMMUNE_MAGIC)) { + if (weapon_item && weapon_item->ElemDmgAmt) { //we don't check resist for npcs here eledmg = weapon_item->ElemDmgAmt; dmg += eledmg; } } - if(against->GetSpecialAbility(IMMUNE_MELEE_EXCEPT_BANE)){ - if(weapon_item){ - if(weapon_item->BaneDmgBody == against->GetBodyType()){ + if (against->GetSpecialAbility(IMMUNE_MELEE_EXCEPT_BANE)) { + if (weapon_item) { + if (weapon_item->BaneDmgBody == against->GetBodyType()) { banedmg += weapon_item->BaneDmgAmt; } - if(weapon_item->BaneDmgRace == against->GetRace()){ + if (weapon_item->BaneDmgRace == against->GetRace()) { banedmg += weapon_item->BaneDmgRaceAmt; } } - if(!banedmg){ - if(!GetSpecialAbility(SPECATK_BANE)) + if (!banedmg) { + if (!GetSpecialAbility(SPECATK_BANE)) return 0; else return 1; @@ -957,13 +976,13 @@ int Mob::GetWeaponDamage(Mob *against, const EQEmu::ItemData *weapon_item) { else dmg += banedmg; } - else{ - if(weapon_item){ - if(weapon_item->BaneDmgBody == against->GetBodyType()){ + else { + if (weapon_item) { + if (weapon_item->BaneDmgBody == against->GetBodyType()) { banedmg += weapon_item->BaneDmgAmt; } - if(weapon_item->BaneDmgRace == against->GetRace()){ + if (weapon_item->BaneDmgRace == against->GetRace()) { banedmg += weapon_item->BaneDmgRaceAmt; } } @@ -971,7 +990,7 @@ int Mob::GetWeaponDamage(Mob *against, const EQEmu::ItemData *weapon_item) { dmg += (banedmg + eledmg); } - if(dmg <= 0){ + if (dmg <= 0) { return 0; } else @@ -1007,14 +1026,16 @@ int Mob::GetWeaponDamage(Mob *against, const EQEmu::ItemInstance *weapon_item, u auto rec_level = weapon_item->GetItemRecommendedLevel(true); if (IsClient() && GetLevel() < rec_level) dmg = CastToClient()->CalcRecommendedLevelBonus( - GetLevel(), rec_level, weapon_item->GetItemWeaponDamage(true)); + GetLevel(), rec_level, weapon_item->GetItemWeaponDamage(true)); else dmg = weapon_item->GetItemWeaponDamage(true); dmg = dmg <= 0 ? 1 : dmg; - } else { + } + else { return 0; } - } else { + } + else { bool MagicGloves = false; if (IsClient()) { const EQEmu::ItemInstance *gloves = CastToClient()->GetInv().GetItem(EQEmu::inventory::slotHands); @@ -1028,29 +1049,35 @@ int Mob::GetWeaponDamage(Mob *against, const EQEmu::ItemInstance *weapon_item, u if (hate) *hate += dmg; } - } else if (GetOwner() && - GetLevel() >= - RuleI(Combat, PetAttackMagicLevel)) { // pets wouldn't actually use this but... + } + else if (GetOwner() && + GetLevel() >= + RuleI(Combat, PetAttackMagicLevel)) { // pets wouldn't actually use this but... dmg = 1; // it gives us an idea if we can hit - } else if (MagicGloves || GetSpecialAbility(SPECATK_MAGICAL)) { + } + else if (MagicGloves || GetSpecialAbility(SPECATK_MAGICAL)) { dmg = 1; - } else + } + else return 0; } - } else { + } + else { if (weapon_item) { if (weapon_item->GetItem()) { auto rec_level = weapon_item->GetItemRecommendedLevel(true); if (IsClient() && GetLevel() < rec_level) { dmg = CastToClient()->CalcRecommendedLevelBonus( - GetLevel(), rec_level, weapon_item->GetItemWeaponDamage(true)); - } else { + GetLevel(), rec_level, weapon_item->GetItemWeaponDamage(true)); + } + else { dmg = weapon_item->GetItemWeaponDamage(true); } dmg = dmg <= 0 ? 1 : dmg; } - } else { + } + else { dmg = GetHandToHandDamage(); if (hate) *hate += dmg; @@ -1065,7 +1092,7 @@ int Mob::GetWeaponDamage(Mob *against, const EQEmu::ItemInstance *weapon_item, u } if (weapon_item && weapon_item->GetItem() && - (weapon_item->GetItemBaneDamageBody(true) || weapon_item->GetItemBaneDamageRace(true))) + (weapon_item->GetItemBaneDamageBody(true) || weapon_item->GetItemBaneDamageRace(true))) banedmg = against->CheckBaneDamage(weapon_item); if (against->GetSpecialAbility(IMMUNE_MELEE_EXCEPT_BANE)) { @@ -1074,12 +1101,14 @@ int Mob::GetWeaponDamage(Mob *against, const EQEmu::ItemInstance *weapon_item, u return 0; else return 1; - } else { + } + else { dmg += (banedmg + eledmg); if (hate) *hate += banedmg; } - } else { + } + else { dmg += (banedmg + eledmg); if (hate) *hate += banedmg; @@ -1098,13 +1127,17 @@ int Client::DoDamageCaps(int base_damage) int cap = 0; if (level >= 125) { cap = 7 * level; - } else if (level >= 110) { + } + else if (level >= 110) { cap = 6 * level; - } else if (level >= 90) { + } + else if (level >= 90) { cap = 5 * level; - } else if (level >= 70) { + } + else if (level >= 70) { cap = 4 * level; - } else if (level >= 40) { + } + else if (level >= 40) { switch (GetClass()) { case CLERIC: case DRUID: @@ -1121,7 +1154,8 @@ int Client::DoDamageCaps(int base_damage) cap = 200; break; } - } else if (level >= 30) { + } + else if (level >= 30) { switch (GetClass()) { case CLERIC: case DRUID: @@ -1138,7 +1172,8 @@ int Client::DoDamageCaps(int base_damage) cap = 60; break; } - } else if (level >= 20) { + } + else if (level >= 20) { switch (GetClass()) { case CLERIC: case DRUID: @@ -1155,7 +1190,8 @@ int Client::DoDamageCaps(int base_damage) cap = 30; break; } - } else if (level >= 10) { + } + else if (level >= 10) { switch (GetClass()) { case CLERIC: case DRUID: @@ -1172,7 +1208,8 @@ int Client::DoDamageCaps(int base_damage) cap = 14; break; } - } else { + } + else { switch (GetClass()) { case CLERIC: case DRUID: @@ -1198,14 +1235,14 @@ void Mob::DoAttack(Mob *other, DamageHitInfo &hit, ExtraAttackOptions *opts) { if (!other) return; - Log.Out(Logs::Detail, Logs::Combat, "%s::DoAttack vs %s base %d min %d offense %d tohit %d skill %d", GetName(), + Log(Logs::Detail, Logs::Combat, "%s::DoAttack vs %s base %d min %d offense %d tohit %d skill %d", GetName(), other->GetName(), hit.base_damage, hit.min_damage, hit.offense, hit.tohit, hit.skill); // check to see if we hit.. if (other->AvoidDamage(this, hit)) { int strike_through = itembonuses.StrikeThrough + spellbonuses.StrikeThrough + aabonuses.StrikeThrough; if (strike_through && zone->random.Roll(strike_through)) { Message_StringID(MT_StrikeThrough, - STRIKETHROUGH_STRING); // You strike through your opponents defenses! + STRIKETHROUGH_STRING); // You strike through your opponents defenses! hit.damage_done = 1; // set to one, we will check this to continue } // I'm pretty sure you can riposte a riposte @@ -1214,7 +1251,7 @@ void Mob::DoAttack(Mob *other, DamageHitInfo &hit, ExtraAttackOptions *opts) //if (IsDead()) return; } - Log.Out(Logs::Detail, Logs::Combat, "Avoided/strikethrough damage with code %d", hit.damage_done); + Log(Logs::Detail, Logs::Combat, "Avoided/strikethrough damage with code %d", hit.damage_done); } if (hit.damage_done >= 0) { @@ -1224,9 +1261,10 @@ void Mob::DoAttack(Mob *other, DamageHitInfo &hit, ExtraAttackOptions *opts) ApplyDamageTable(hit); CommonOutgoingHitSuccess(other, hit, opts); } - Log.Out(Logs::Detail, Logs::Combat, "Final damage after all reductions: %d", hit.damage_done); - } else { - Log.Out(Logs::Detail, Logs::Combat, "Attack missed. Damage set to 0."); + Log(Logs::Detail, Logs::Combat, "Final damage after all reductions: %d", hit.damage_done); + } + else { + Log(Logs::Detail, Logs::Combat, "Attack missed. Damage set to 0."); hit.damage_done = 0; } } @@ -1239,14 +1277,14 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b { if (!other) { SetTarget(nullptr); - Log.Out(Logs::General, Logs::Error, "A null Mob object was passed to Client::Attack() for evaluation!"); + Log(Logs::General, Logs::Error, "A null Mob object was passed to Client::Attack() for evaluation!"); return false; } - if(!GetTarget()) + if (!GetTarget()) SetTarget(other); - Log.Out(Logs::Detail, Logs::Combat, "Attacking %s with hand %d %s", other?other->GetName():"(nullptr)", Hand, bRiposte?"(this is a riposte)":""); + Log(Logs::Detail, Logs::Combat, "Attacking %s with hand %d %s", other ? other->GetName() : "(nullptr)", Hand, bRiposte ? "(this is a riposte)" : ""); //SetAttackTimer(); if ( @@ -1256,12 +1294,12 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b || (GetHP() < 0) || (!IsAttackAllowed(other)) ) { - Log.Out(Logs::Detail, Logs::Combat, "Attack canceled, invalid circumstances."); + Log(Logs::Detail, Logs::Combat, "Attack canceled, invalid circumstances."); return false; // Only bards can attack while casting } - if(DivineAura() && !GetGM()) {//cant attack while invulnerable unless your a gm - Log.Out(Logs::Detail, Logs::Combat, "Attack canceled, Divine Aura is in effect."); + if (DivineAura() && !GetGM()) {//cant attack while invulnerable unless your a gm + Log(Logs::Detail, Logs::Combat, "Attack canceled, Divine Aura is in effect."); Message_StringID(MT_DefaultText, DIVINE_AURA_NO_ATK); //You can't attack while invulnerable! return false; } @@ -1270,30 +1308,31 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b return false; // Rogean: How can you attack while feigned? Moved up from Aggro Code. EQEmu::ItemInstance* weapon = nullptr; - if (Hand == EQEmu::inventory::slotSecondary){ // Kaiyodo - Pick weapon from the attacking hand + if (Hand == EQEmu::inventory::slotSecondary) { // Kaiyodo - Pick weapon from the attacking hand weapon = GetInv().GetItem(EQEmu::inventory::slotSecondary); OffHandAtk(true); } - else{ + else { weapon = GetInv().GetItem(EQEmu::inventory::slotPrimary); OffHandAtk(false); } - if(weapon != nullptr) { + if (weapon != nullptr) { if (!weapon->IsWeapon()) { - Log.Out(Logs::Detail, Logs::Combat, "Attack canceled, Item %s (%d) is not a weapon.", weapon->GetItem()->Name, weapon->GetID()); + Log(Logs::Detail, Logs::Combat, "Attack canceled, Item %s (%d) is not a weapon.", weapon->GetItem()->Name, weapon->GetID()); return(false); } - Log.Out(Logs::Detail, Logs::Combat, "Attacking with weapon: %s (%d)", weapon->GetItem()->Name, weapon->GetID()); - } else { - Log.Out(Logs::Detail, Logs::Combat, "Attacking without a weapon."); + Log(Logs::Detail, Logs::Combat, "Attacking with weapon: %s (%d)", weapon->GetItem()->Name, weapon->GetID()); + } + else { + Log(Logs::Detail, Logs::Combat, "Attacking without a weapon."); } DamageHitInfo my_hit; // calculate attack_skill and skillinuse depending on hand and weapon // also send Packet to near clients AttackAnimation(my_hit.skill, Hand, weapon); - Log.Out(Logs::Detail, Logs::Combat, "Attacking with %s in slot %d using skill %d", weapon?weapon->GetItem()->Name:"Fist", Hand, my_hit.skill); + Log(Logs::Detail, Logs::Combat, "Attacking with %s in slot %d using skill %d", weapon ? weapon->GetItem()->Name : "Fist", Hand, my_hit.skill); // Now figure out damage my_hit.damage_done = 1; @@ -1350,7 +1389,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b #endif //Live AA - Sinister Strikes *Adds weapon damage bonus to offhand weapon. if (Hand == EQEmu::inventory::slotSecondary) { - if (aabonuses.SecondaryDmgInc || itembonuses.SecondaryDmgInc || spellbonuses.SecondaryDmgInc){ + if (aabonuses.SecondaryDmgInc || itembonuses.SecondaryDmgInc || spellbonuses.SecondaryDmgInc) { ucDamageBonus = GetWeaponDamageBonus(weapon ? weapon->GetItem() : (const EQEmu::ItemData*) nullptr, true); @@ -1361,13 +1400,13 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b // damage = mod_client_damage(damage, skillinuse, Hand, weapon, other); - Log.Out(Logs::Detail, Logs::Combat, "Damage calculated: base %d min damage %d skill %d", my_hit.base_damage, my_hit.min_damage, my_hit.skill); + Log(Logs::Detail, Logs::Combat, "Damage calculated: base %d min damage %d skill %d", my_hit.base_damage, my_hit.min_damage, my_hit.skill); int hit_chance_bonus = 0; my_hit.offense = offense(my_hit.skill); // we need this a few times my_hit.hand = Hand; - if(opts) { + if (opts) { my_hit.base_damage *= opts->damage_percent; my_hit.base_damage += opts->damage_flat; hate *= opts->hate_percent; @@ -1378,7 +1417,8 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b my_hit.tohit = GetTotalToHit(my_hit.skill, hit_chance_bonus); DoAttack(other, my_hit, opts); - } else { + } + else { my_hit.damage_done = DMG_INVULNERABLE; } @@ -1391,11 +1431,11 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b ////// Send Attack Damage /////////////////////////////////////////////////////////// if (my_hit.damage_done > 0 && aabonuses.SkillAttackProc[0] && aabonuses.SkillAttackProc[1] == my_hit.skill && - IsValidSpell(aabonuses.SkillAttackProc[2])) { + IsValidSpell(aabonuses.SkillAttackProc[2])) { float chance = aabonuses.SkillAttackProc[0] / 1000.0f; if (zone->random.Roll(chance)) SpellFinished(aabonuses.SkillAttackProc[2], other, EQEmu::CastingSlot::Item, 0, -1, - spells[aabonuses.SkillAttackProc[2]].ResistDiff); + spells[aabonuses.SkillAttackProc[2]].ResistDiff); } other->Damage(this, my_hit.damage_done, SPELL_UNKNOWN, my_hit.skill, true, -1, false, m_specialattacks); @@ -1408,7 +1448,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b CommonBreakInvisibleFromCombat(); - if(GetTarget()) + if (GetTarget()) TriggerDefensiveProcs(other, Hand, true, my_hit.damage_done); if (my_hit.damage_done > 0) @@ -1427,10 +1467,10 @@ void Mob::Heal() void Client::Damage(Mob* other, int32 damage, uint16 spell_id, EQEmu::skills::SkillType attack_skill, bool avoidable, int8 buffslot, bool iBuffTic, eSpecialAttacks special) { - if(dead || IsCorpse()) + if (dead || IsCorpse()) return; - if(spell_id==0) + if (spell_id == 0) spell_id = SPELL_UNKNOWN; // cut all PVP spell damage to 2/3 @@ -1438,7 +1478,7 @@ void Client::Damage(Mob* other, int32 damage, uint16 spell_id, EQEmu::skills::Sk //Don't do PvP mitigation if the caster is damaging himself //should this be applied to all damage? comments sound like some is for spell DMG //patch notes on PVP reductions only mention archery/throwing ... not normal dmg - if(other && other->IsClient() && (other != this) && damage > 0) { + if (other && other->IsClient() && (other != this) && damage > 0) { int PvPMitigation = 100; if (attack_skill == EQEmu::skills::SkillArchery || attack_skill == EQEmu::skills::SkillThrowing) PvPMitigation = 80; @@ -1447,7 +1487,7 @@ void Client::Damage(Mob* other, int32 damage, uint16 spell_id, EQEmu::skills::Sk damage = std::max((damage * PvPMitigation) / 100, 1); } - if(!ClientFinishedLoading()) + if (!ClientFinishedLoading()) damage = -5; //do a majority of the work... @@ -1462,25 +1502,25 @@ void Client::Damage(Mob* other, int32 damage, uint16 spell_id, EQEmu::skills::Sk bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::SkillType attack_skill) { - if(!ClientFinishedLoading()) + if (!ClientFinishedLoading()) return false; - if(dead) + if (dead) return false; //cant die more than once... - if(!spell) + if (!spell) spell = SPELL_UNKNOWN; char buffer[48] = { 0 }; snprintf(buffer, 47, "%d %d %d %d", killerMob ? killerMob->GetID() : 0, damage, spell, static_cast(attack_skill)); - if(parse->EventPlayer(EVENT_DEATH, this, buffer, 0) != 0) { - if(GetHP() < 0) { + if (parse->EventPlayer(EVENT_DEATH, this, buffer, 0) != 0) { + if (GetHP() < 0) { SetHP(0); } return false; } - if(killerMob && killerMob->IsClient() && (spell != SPELL_UNKNOWN) && damage > 0) { + if (killerMob && killerMob->IsClient() && (spell != SPELL_UNKNOWN) && damage > 0) { char val1[20] = { 0 }; entity_list.MessageClose_StringID( @@ -1492,14 +1532,14 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk killerMob->GetCleanName(), /* Message1 */ GetCleanName(), /* Message2 */ ConvertArray(damage, val1)/* Message3 */ - ); + ); } int exploss = 0; - Log.Out(Logs::Detail, Logs::Combat, "Fatal blow dealt by %s with %d damage, spell %d, skill %d", killerMob ? killerMob->GetName() : "Unknown", damage, spell, attack_skill); + Log(Logs::Detail, Logs::Combat, "Fatal blow dealt by %s with %d damage, spell %d, skill %d", killerMob ? killerMob->GetName() : "Unknown", damage, spell, attack_skill); /* - #1: Send death packet to everyone + #1: Send death packet to everyone */ uint8 killed_level = GetLevel(); @@ -1519,7 +1559,7 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk Death_Struct* d = (Death_Struct*)app.pBuffer; d->spawn_id = GetID(); d->killer_id = killerMob ? killerMob->GetID() : 0; - d->corpseid=GetID(); + d->corpseid = GetID(); d->bindzoneid = m_pp.binds[0].zoneId; d->spell_id = spell == SPELL_UNKNOWN ? 0xffffffff : spell; d->attack_skill = spell != SPELL_UNKNOWN ? 0xe7 : attack_skill; @@ -1528,7 +1568,7 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk entity_list.QueueClients(this, &app); /* - #2: figure out things that affect the player dying and mark them dead + #2: figure out things that affect the player dying and mark them dead */ InterruptSpell(); @@ -1536,7 +1576,7 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk SetHorseId(0); dead = true; - if(GetMerc()) { + if (GetMerc()) { GetMerc()->Suspend(); } @@ -1548,12 +1588,12 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk mod_client_death_npc(killerMob); uint16 emoteid = killerMob->GetEmoteID(); - if(emoteid != 0) - killerMob->CastToNPC()->DoNPCEmote(KILLEDPC,emoteid); - killerMob->TrySpellOnKill(killed_level,spell); + if (emoteid != 0) + killerMob->CastToNPC()->DoNPCEmote(KILLEDPC, emoteid); + killerMob->TrySpellOnKill(killed_level, spell); } - if(killerMob->IsClient() && (IsDueling() || killerMob->CastToClient()->IsDueling())) { + if (killerMob->IsClient() && (IsDueling() || killerMob->CastToClient()->IsDueling())) { SetDueling(false); SetDuelTarget(0); if (killerMob->IsClient() && killerMob->CastToClient()->IsDueling() && killerMob->CastToClient()->GetDuelTarget() == GetID()) @@ -1561,14 +1601,15 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk //if duel opponent killed us... killerMob->CastToClient()->SetDueling(false); killerMob->CastToClient()->SetDuelTarget(0); - entity_list.DuelMessage(killerMob,this,false); + entity_list.DuelMessage(killerMob, this, false); mod_client_death_duel(killerMob); - } else { + } + else { //otherwise, we just died, end the duel. Mob* who = entity_list.GetMob(GetDuelTarget()); - if(who && who->IsClient()) { + if (who && who->IsClient()) { who->CastToClient()->SetDueling(false); who->CastToClient()->SetDuelTarget(0); } @@ -1584,45 +1625,45 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk ClearAllProximities(); /* - #3: exp loss and corpse generation + #3: exp loss and corpse generation */ // figure out if they should lose exp - if(RuleB(Character, UseDeathExpLossMult)){ - float GetNum [] = {0.005f,0.015f,0.025f,0.035f,0.045f,0.055f,0.065f,0.075f,0.085f,0.095f,0.110f }; + if (RuleB(Character, UseDeathExpLossMult)) { + float GetNum[] = { 0.005f,0.015f,0.025f,0.035f,0.045f,0.055f,0.065f,0.075f,0.085f,0.095f,0.110f }; int Num = RuleI(Character, DeathExpLossMultiplier); - if((Num < 0) || (Num > 10)) + if ((Num < 0) || (Num > 10)) Num = 3; float loss = GetNum[Num]; - exploss=(int)((float)GetEXP() * (loss)); //loose % of total XP pending rule (choose 0-10) + exploss = (int)((float)GetEXP() * (loss)); //loose % of total XP pending rule (choose 0-10) } - if(!RuleB(Character, UseDeathExpLossMult)){ + if (!RuleB(Character, UseDeathExpLossMult)) { exploss = (int)(GetLevel() * (GetLevel() / 18.0) * 12000); } - if( (GetLevel() < RuleI(Character, DeathExpLossLevel)) || (GetLevel() > RuleI(Character, DeathExpLossMaxLevel)) || IsBecomeNPC() ) + if ((GetLevel() < RuleI(Character, DeathExpLossLevel)) || (GetLevel() > RuleI(Character, DeathExpLossMaxLevel)) || IsBecomeNPC()) { exploss = 0; } - else if( killerMob ) + else if (killerMob) { - if( killerMob->IsClient() ) + if (killerMob->IsClient()) { exploss = 0; } - else if( killerMob->GetOwner() && killerMob->GetOwner()->IsClient() ) + else if (killerMob->GetOwner() && killerMob->GetOwner()->IsClient()) { exploss = 0; } } - if(spell != SPELL_UNKNOWN) + if (spell != SPELL_UNKNOWN) { uint32 buff_count = GetMaxTotalSlots(); - for(uint16 buffIt = 0; buffIt < buff_count; buffIt++) + for (uint16 buffIt = 0; buffIt < buff_count; buffIt++) { - if(buffs[buffIt].spellid == spell && buffs[buffIt].client) + if (buffs[buffIt].spellid == spell && buffs[buffIt].client) { exploss = 0; // no exp loss for pvp dot break; @@ -1634,14 +1675,15 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk // now we apply the exp loss, unmem their spells, and make a corpse // unless they're a GM (or less than lvl 10 - if(!GetGM()) + if (!GetGM()) { - if(exploss > 0) { + if (exploss > 0) { int32 newexp = GetEXP(); - if(exploss > newexp) { + if (exploss > newexp) { //lost more than we have... wtf.. newexp = 1; - } else { + } + else { newexp -= exploss; } SetEXP(newexp, GetAAXP()); @@ -1651,43 +1693,43 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk //this generates a lot of 'updates' to the client that the client does not need BuffFadeNonPersistDeath(); if (RuleB(Character, UnmemSpellsOnDeath)) { - if((ClientVersionBit() & EQEmu::versions::bit_SoFAndLater) && RuleB(Character, RespawnFromHover)) + if ((ClientVersionBit() & EQEmu::versions::bit_SoFAndLater) && RuleB(Character, RespawnFromHover)) UnmemSpellAll(true); else UnmemSpellAll(false); } - if((RuleB(Character, LeaveCorpses) && GetLevel() >= RuleI(Character, DeathItemLossLevel)) || RuleB(Character, LeaveNakedCorpses)) + if ((RuleB(Character, LeaveCorpses) && GetLevel() >= RuleI(Character, DeathItemLossLevel)) || RuleB(Character, LeaveNakedCorpses)) { // creating the corpse takes the cash/items off the player too auto new_corpse = new Corpse(this, exploss); std::string tmp; database.GetVariable("ServerType", tmp); - if(tmp[0] == '1' && tmp[1] == '\0' && killerMob != nullptr && killerMob->IsClient()){ + if (tmp[0] == '1' && tmp[1] == '\0' && killerMob != nullptr && killerMob->IsClient()) { database.GetVariable("PvPreward", tmp); int reward = atoi(tmp.c_str()); - if(reward==3){ + if (reward == 3) { database.GetVariable("PvPitem", tmp); int pvpitem = atoi(tmp.c_str()); - if(pvpitem>0 && pvpitem<200000) + if (pvpitem>0 && pvpitem<200000) new_corpse->SetPlayerKillItemID(pvpitem); } - else if(reward==2) + else if (reward == 2) new_corpse->SetPlayerKillItemID(-1); - else if(reward==1) + else if (reward == 1) new_corpse->SetPlayerKillItemID(1); else new_corpse->SetPlayerKillItemID(0); - if(killerMob->CastToClient()->isgrouped) { + if (killerMob->CastToClient()->isgrouped) { Group* group = entity_list.GetGroupByClient(killerMob->CastToClient()); - if(group != 0) + if (group != 0) { - for(int i=0;i<6;i++) + for (int i = 0; i<6; i++) { - if(group->members[i] != nullptr) + if (group->members[i] != nullptr) { - new_corpse->AllowPlayerLoot(group->members[i],i); + new_corpse->AllowPlayerLoot(group->members[i], i); } } } @@ -1702,18 +1744,19 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk LeftCorpse = true; } - } else { + } + else { BuffFadeDetrimental(); } /* - Finally, send em home + Finally, send em home - We change the mob variables, not pp directly, because Save() will copy - from these and overwrite what we set in pp anyway + We change the mob variables, not pp directly, because Save() will copy + from these and overwrite what we set in pp anyway */ - if(LeftCorpse && (ClientVersionBit() & EQEmu::versions::bit_SoFAndLater) && RuleB(Character, RespawnFromHover)) + if (LeftCorpse && (ClientVersionBit() & EQEmu::versions::bit_SoFAndLater) && RuleB(Character, RespawnFromHover)) { ClearDraggedCorpses(); RespawnFromHoverTimer.Start(RuleI(Character, RespawnFromHoverTimer) * 1000); @@ -1721,16 +1764,16 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk } else { - if(isgrouped) + if (isgrouped) { Group *g = GetGroup(); - if(g) + if (g) g->MemberZoned(this); } Raid* r = entity_list.GetRaidByClient(this); - if(r) + if (r) r->MemberZoned(this); dead_timer.Start(5000, true); @@ -1742,9 +1785,9 @@ bool Client::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Sk } /* QS: PlayerLogDeaths */ - if (RuleB(QueryServ, PlayerLogDeaths)){ + if (RuleB(QueryServ, PlayerLogDeaths)) { const char * killer_name = ""; - if (killerMob && killerMob->GetCleanName()){ killer_name = killerMob->GetCleanName(); } + if (killerMob && killerMob->GetCleanName()) { killer_name = killerMob->GetCleanName(); } std::string event_desc = StringFormat("Died in zoneid:%i instid:%i by '%s', spellid:%i, damage:%i", this->GetZoneID(), this->GetInstanceID(), killer_name, spell, damage); QServ->PlayerLogEvent(Player_Log_Deaths, this->CharacterID(), event_desc); } @@ -1757,25 +1800,25 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool { if (!other) { SetTarget(nullptr); - Log.Out(Logs::General, Logs::Error, "A null Mob object was passed to NPC::Attack() for evaluation!"); + Log(Logs::General, Logs::Error, "A null Mob object was passed to NPC::Attack() for evaluation!"); return false; } - if(DivineAura()) + if (DivineAura()) return(false); - if(!GetTarget()) + if (!GetTarget()) SetTarget(other); //Check that we can attack before we calc heading and face our target if (!IsAttackAllowed(other)) { if (this->GetOwnerID()) this->Say_StringID(NOT_LEGAL_TARGET); - if(other) { + if (other) { if (other->IsClient()) other->CastToClient()->RemoveXTarget(this, false); RemoveFromHateList(other); - Log.Out(Logs::Detail, Logs::Combat, "I am not allowed to attack %s", other->GetName()); + Log(Logs::Detail, Logs::Combat, "I am not allowed to attack %s", other->GetName()); } return false; } @@ -1804,15 +1847,15 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool //We dont factor much from the weapon into the attack. //Just the skill type so it doesn't look silly using punching animations and stuff while wielding weapons - if(weapon) { - Log.Out(Logs::Detail, Logs::Combat, "Attacking with weapon: %s (%d) (too bad im not using it for much)", weapon->Name, weapon->ID); + if (weapon) { + Log(Logs::Detail, Logs::Combat, "Attacking with weapon: %s (%d) (too bad im not using it for much)", weapon->Name, weapon->ID); - if (Hand == EQEmu::inventory::slotSecondary && weapon->ItemType == EQEmu::item::ItemTypeShield){ - Log.Out(Logs::Detail, Logs::Combat, "Attack with shield canceled."); + if (Hand == EQEmu::inventory::slotSecondary && weapon->ItemType == EQEmu::item::ItemTypeShield) { + Log(Logs::Detail, Logs::Combat, "Attack with shield canceled."); return false; } - switch(weapon->ItemType) { + switch (weapon->ItemType) { case EQEmu::item::ItemType1HSlash: my_hit.skill = EQEmu::skills::Skill1HSlashing; break; @@ -1852,28 +1895,28 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool AttackAnimation(my_hit.skill, Hand, &weapon_inst); //basically "if not immune" then do the attack - if(weapon_damage > 0) { + if (weapon_damage > 0) { //ele and bane dmg too //NPCs add this differently than PCs //if NPCs can't inheriently hit the target we don't add bane/magic dmg which isn't exactly the same as PCs int eleBane = 0; - if(weapon){ - if(weapon->BaneDmgBody == other->GetBodyType()){ + if (weapon) { + if (weapon->BaneDmgBody == other->GetBodyType()) { eleBane += weapon->BaneDmgAmt; } - if(weapon->BaneDmgRace == other->GetRace()){ + if (weapon->BaneDmgRace == other->GetRace()) { eleBane += weapon->BaneDmgRaceAmt; } - if(weapon->ElemDmgAmt){ + if (weapon->ElemDmgAmt) { eleBane += (weapon->ElemDmgAmt * other->ResistSpell(weapon->ElemDmgType, 0, this) / 100); } } - if(!RuleB(NPC, UseItemBonusesForNonPets)){ - if(!GetOwner()){ + if (!RuleB(NPC, UseItemBonusesForNonPets)) { + if (!GetOwner()) { eleBane = 0; } } @@ -1907,21 +1950,23 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool other->AddToHateList(this, hate); - Log.Out(Logs::Detail, Logs::Combat, "Final damage against %s: %d", other->GetName(), my_hit.damage_done); + Log(Logs::Detail, Logs::Combat, "Final damage against %s: %d", other->GetName(), my_hit.damage_done); - if(other->IsClient() && IsPet() && GetOwner()->IsClient()) { + if (other->IsClient() && IsPet() && GetOwner()->IsClient()) { //pets do half damage to clients in pvp my_hit.damage_done /= 2; if (my_hit.damage_done < 1) my_hit.damage_done = 1; } - } else { + } + else { my_hit.damage_done = DMG_INVULNERABLE; } - if(GetHP() > 0 && !other->HasDied()) { + if (GetHP() > 0 && !other->HasDied()) { other->Damage(this, my_hit.damage_done, SPELL_UNKNOWN, my_hit.skill, true, -1, false, m_specialattacks); // Not avoidable client already had thier chance to Avoid - } else + } + else return false; if (HasDied()) //killed by damage shield ect @@ -1935,7 +1980,7 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool if (!GetTarget()) return true; //We killed them - if(!bRiposte && !other->HasDied()) { + if (!bRiposte && !other->HasDied()) { TryWeaponProc(nullptr, weapon, other, Hand); //no weapon if (!other->HasDied()) @@ -1945,7 +1990,7 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool TrySkillProc(other, my_hit.skill, 0, true, Hand); } - if(GetHP() > 0 && !other->HasDied()) + if (GetHP() > 0 && !other->HasDied()) TriggerDefensiveProcs(other, Hand, true, my_hit.damage_done); if (my_hit.damage_done > 0) @@ -1956,13 +2001,13 @@ bool NPC::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, bool } void NPC::Damage(Mob* other, int32 damage, uint16 spell_id, EQEmu::skills::SkillType attack_skill, bool avoidable, int8 buffslot, bool iBuffTic, eSpecialAttacks special) { - if(spell_id==0) + if (spell_id == 0) spell_id = SPELL_UNKNOWN; //handle EVENT_ATTACK. Resets after we have not been attacked for 12 seconds - if(attacked_timer.Check()) + if (attacked_timer.Check()) { - Log.Out(Logs::Detail, Logs::Combat, "Triggering EVENT_ATTACK due to attack by %s", other ? other->GetName() : "nullptr"); + Log(Logs::Detail, Logs::Combat, "Triggering EVENT_ATTACK due to attack by %s", other ? other->GetName() : "nullptr"); parse->EventNPC(EVENT_ATTACK, this, other, "", 0); } attacked_timer.Start(CombatEventTimer_expire); @@ -1970,15 +2015,15 @@ void NPC::Damage(Mob* other, int32 damage, uint16 spell_id, EQEmu::skills::Skill if (!IsEngaged()) zone->AddAggroMob(); - if(GetClass() == LDON_TREASURE) + if (GetClass() == LDON_TREASURE) { - if(IsLDoNLocked() && GetLDoNLockedSkill() != LDoNTypeMechanical) + if (IsLDoNLocked() && GetLDoNLockedSkill() != LDoNTypeMechanical) { damage = -5; } else { - if(IsLDoNTrapped()) + if (IsLDoNTrapped()) { Message_StringID(13, LDON_ACCIDENT_SETOFF2); SpellFinished(GetLDoNTrapSpellID(), other, EQEmu::CastingSlot::Item, 0, -1, spells[GetLDoNTrapSpellID()].ResistDiff, false); @@ -1992,15 +2037,15 @@ void NPC::Damage(Mob* other, int32 damage, uint16 spell_id, EQEmu::skills::Skill //do a majority of the work... CommonDamage(other, damage, spell_id, attack_skill, avoidable, buffslot, iBuffTic, special); - if(damage > 0) { + if (damage > 0) { //see if we are gunna start fleeing - if(!IsPet()) CheckFlee(); + if (!IsPet()) CheckFlee(); } } bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQEmu::skills::SkillType attack_skill) { - Log.Out(Logs::Detail, Logs::Combat, "Fatal blow dealt by %s with %d damage, spell %d, skill %d", + Log(Logs::Detail, Logs::Combat, "Fatal blow dealt by %s with %d damage, spell %d, skill %d", ((killer_mob) ? (killer_mob->GetName()) : ("[nullptr]")), damage, spell, attack_skill); Mob *oos = nullptr; @@ -2029,7 +2074,7 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQEmu::skills::Skil killer_mob->GetCleanName(), /* Message1 */ GetCleanName(), /* Message2 */ ConvertArray(damage, val1) /* Message3 */ - ); + ); } } else { @@ -2046,7 +2091,7 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQEmu::skills::Skil if (IsEngaged()) { zone->DelAggroMob(); - Log.Out(Logs::Detail, Logs::Attack, "%s Mobs currently Aggro %i", __FUNCTION__, zone->MobsAggroCount()); + Log(Logs::Detail, Logs::Attack, "%s Mobs currently Aggro %i", __FUNCTION__, zone->MobsAggroCount()); } SetHP(0); @@ -2109,7 +2154,7 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQEmu::skills::Skil bool ownerInGroup = false; if ((give_exp->HasGroup() && give_exp->GetGroup()->IsGroupMember(give_exp->GetUltimateOwner())) || (give_exp->IsPet() && (give_exp->GetOwner()->IsClient() - || (give_exp->GetOwner()->HasGroup() && give_exp->GetOwner()->GetGroup()->IsGroupMember(give_exp->GetOwner()->GetUltimateOwner()))))) + || (give_exp->GetOwner()->HasGroup() && give_exp->GetOwner()->GetGroup()->IsGroupMember(give_exp->GetOwner()->GetUltimateOwner()))))) ownerInGroup = true; give_exp = give_exp->GetUltimateOwner(); @@ -2175,9 +2220,9 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQEmu::skills::Skil // QueryServ Logging - Raid Kills if (RuleB(QueryServ, PlayerLogNPCKills)) { auto pack = - new ServerPacket(ServerOP_QSPlayerLogNPCKills, - sizeof(QSPlayerLogNPCKill_Struct) + - (sizeof(QSPlayerLogNPCKillsPlayers_Struct) * PlayerCount)); + new ServerPacket(ServerOP_QSPlayerLogNPCKills, + sizeof(QSPlayerLogNPCKill_Struct) + + (sizeof(QSPlayerLogNPCKillsPlayers_Struct) * PlayerCount)); PlayerCount = 0; QSPlayerLogNPCKill_Struct* QS = (QSPlayerLogNPCKill_Struct*)pack->pBuffer; QS->s1.NPCID = this->GetNPCTypeID(); @@ -2225,9 +2270,9 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQEmu::skills::Skil // QueryServ Logging - Group Kills if (RuleB(QueryServ, PlayerLogNPCKills)) { auto pack = - new ServerPacket(ServerOP_QSPlayerLogNPCKills, - sizeof(QSPlayerLogNPCKill_Struct) + - (sizeof(QSPlayerLogNPCKillsPlayers_Struct) * PlayerCount)); + new ServerPacket(ServerOP_QSPlayerLogNPCKills, + sizeof(QSPlayerLogNPCKill_Struct) + + (sizeof(QSPlayerLogNPCKillsPlayers_Struct) * PlayerCount)); PlayerCount = 0; QSPlayerLogNPCKill_Struct* QS = (QSPlayerLogNPCKill_Struct*)pack->pBuffer; QS->s1.NPCID = this->GetNPCTypeID(); @@ -2262,7 +2307,7 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQEmu::skills::Skil if (RuleB(NPC, EnableMeritBasedFaction)) give_exp_client->SetFactionLevel(give_exp_client->CharacterID(), GetNPCFactionID(), give_exp_client->GetBaseClass(), - give_exp_client->GetBaseRace(), give_exp_client->GetDeity()); + give_exp_client->GetBaseRace(), give_exp_client->GetDeity()); mod_npc_killed_merit(give_exp_client); @@ -2272,8 +2317,8 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQEmu::skills::Skil // QueryServ Logging - Solo if (RuleB(QueryServ, PlayerLogNPCKills)) { auto pack = new ServerPacket(ServerOP_QSPlayerLogNPCKills, - sizeof(QSPlayerLogNPCKill_Struct) + - (sizeof(QSPlayerLogNPCKillsPlayers_Struct) * 1)); + sizeof(QSPlayerLogNPCKill_Struct) + + (sizeof(QSPlayerLogNPCKillsPlayers_Struct) * 1)); QSPlayerLogNPCKill_Struct* QS = (QSPlayerLogNPCKill_Struct*)pack->pBuffer; QS->s1.NPCID = this->GetNPCTypeID(); QS->s1.ZoneID = this->GetZoneID(); @@ -2290,8 +2335,8 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQEmu::skills::Skil if (!HasOwner() && !IsMerc() && class_ != MERCHANT && class_ != ADVENTUREMERCHANT && !GetSwarmInfo() && MerchantType == 0 && ((killer && (killer->IsClient() || (killer->HasOwner() && killer->GetUltimateOwner()->IsClient()) || - (killer->IsNPC() && killer->CastToNPC()->GetSwarmInfo() && killer->CastToNPC()->GetSwarmInfo()->GetOwner() && killer->CastToNPC()->GetSwarmInfo()->GetOwner()->IsClient()))) - || (killer_mob && IsLdonTreasure))) + (killer->IsNPC() && killer->CastToNPC()->GetSwarmInfo() && killer->CastToNPC()->GetSwarmInfo()->GetOwner() && killer->CastToNPC()->GetSwarmInfo()->GetOwner()->IsClient()))) + || (killer_mob && IsLdonTreasure))) { if (killer != 0) { if (killer->GetOwner() != 0 && killer->GetOwner()->IsClient()) @@ -2304,8 +2349,8 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQEmu::skills::Skil entity_list.RemoveFromAutoXTargets(this); uint16 emoteid = this->GetEmoteID(); auto corpse = new Corpse(this, &itemlist, GetNPCTypeID(), &NPCTypedata, - level > 54 ? RuleI(NPC, MajorNPCCorpseDecayTimeMS) - : RuleI(NPC, MinorNPCCorpseDecayTimeMS)); + level > 54 ? RuleI(NPC, MajorNPCCorpseDecayTimeMS) + : RuleI(NPC, MinorNPCCorpseDecayTimeMS)); entity_list.LimitRemoveNPC(this); entity_list.AddCorpse(corpse, GetID()); @@ -2434,13 +2479,13 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQEmu::skills::Skil void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, bool iYellForHelp /*= true*/, bool bFrenzy /*= false*/, bool iBuffTic /*= false*/, uint16 spell_id) { - if(!other) + if (!other) return; if (other == this) return; - if(damage < 0){ + if (damage < 0) { hate = 1; } @@ -2456,25 +2501,26 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b Mob* targetmob = this->GetTarget(); bool on_hatelist = CheckAggro(other); - if(other){ + if (other) { AddRampage(other); if (on_hatelist) { // odd reason, if you're not on the hate list, subtlety etc don't apply! - // Spell Casting Subtlety etc + // Spell Casting Subtlety etc int hatemod = 100 + other->spellbonuses.hatemod + other->itembonuses.hatemod + other->aabonuses.hatemod; - if(hatemod < 1) + if (hatemod < 1) hatemod = 1; - hate = ((hate * (hatemod))/100); - } else { + hate = ((hate * (hatemod)) / 100); + } + else { hate += 100; // 100 bonus initial aggro } } - if(IsPet() && GetOwner() && GetOwner()->GetAA(aaPetDiscipline) && IsHeld() && !IsFocused()) { //ignore aggro if hold and !focus + if (IsPet() && GetOwner() && GetOwner()->GetAA(aaPetDiscipline) && IsHeld() && !IsFocused()) { //ignore aggro if hold and !focus return; } - if(IsPet() && GetOwner() && GetOwner()->GetAA(aaPetDiscipline) && IsHeld() && GetOwner()->GetAA(aaAdvancedPetDiscipline) >= 1 && IsFocused()) { + if (IsPet() && GetOwner() && GetOwner()->GetAA(aaPetDiscipline) && IsHeld() && GetOwner()->GetAA(aaAdvancedPetDiscipline) >= 1 && IsFocused()) { if (!targetmob) return; } @@ -2482,10 +2528,10 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b if (other->IsNPC() && (other->IsPet() || other->CastToNPC()->GetSwarmOwner() > 0)) TryTriggerOnValueAmount(false, false, false, true); - if(IsClient() && !IsAIControlled()) + if (IsClient() && !IsAIControlled()) return; - if(IsFamiliar() || GetSpecialAbility(IMMUNE_AGGRO)) + if (IsFamiliar() || GetSpecialAbility(IMMUNE_AGGRO)) return; if (spell_id != SPELL_UNKNOWN && NoDetrimentalSpellAggro(spell_id)) @@ -2494,25 +2540,26 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b if (other == myowner) return; - if(other->GetSpecialAbility(IMMUNE_AGGRO_ON)) + if (other->GetSpecialAbility(IMMUNE_AGGRO_ON)) return; - if(GetSpecialAbility(NPC_TUNNELVISION)) { + if (GetSpecialAbility(NPC_TUNNELVISION)) { int tv_mod = GetSpecialAbilityParam(NPC_TUNNELVISION, 0); Mob *top = GetTarget(); - if(top && top != other) { - if(tv_mod) { + if (top && top != other) { + if (tv_mod) { float tv = tv_mod / 100.0f; hate *= tv; - } else { + } + else { hate *= RuleR(Aggro, TunnelVisionAggroMod); } } } - if(IsNPC() && CastToNPC()->IsUnderwaterOnly() && zone->HasWaterMap()) { - if(!zone->watermap->InLiquid(glm::vec3(other->GetPosition()))) { + if (IsNPC() && CastToNPC()->IsUnderwaterOnly() && zone->HasWaterMap()) { + if (!zone->watermap->InLiquid(glm::vec3(other->GetPosition()))) { return; } } @@ -2523,64 +2570,66 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b // If we add 10000 damage, Player B would get the kill credit, so we only award damage credit to player B of the // amount of HP the mob had left. // - if(damage > GetHP()) + if (damage > GetHP()) damage = GetHP(); if (spellbonuses.ImprovedTaunt[1] && (GetLevel() < spellbonuses.ImprovedTaunt[0]) - && other && (buffs[spellbonuses.ImprovedTaunt[2]].casterid != other->GetID())) - hate = (hate*spellbonuses.ImprovedTaunt[1])/100; + && other && (buffs[spellbonuses.ImprovedTaunt[2]].casterid != other->GetID())) + hate = (hate*spellbonuses.ImprovedTaunt[1]) / 100; hate_list.AddEntToHateList(other, hate, damage, bFrenzy, !iBuffTic); - if(other->IsClient() && !on_hatelist) + if (other->IsClient() && !on_hatelist) other->CastToClient()->AddAutoXTarget(this); #ifdef BOTS // if other is a bot, add the bots client to the hate list - if(other->IsBot()) { - if(other->CastToBot()->GetBotOwner() && other->CastToBot()->GetBotOwner()->CastToClient()->GetFeigned()) { + if (other->IsBot()) { + if (other->CastToBot()->GetBotOwner() && other->CastToBot()->GetBotOwner()->CastToClient()->GetFeigned()) { AddFeignMemory(other->CastToBot()->GetBotOwner()->CastToClient()); } else { - if(!hate_list.IsEntOnHateList(other->CastToBot()->GetBotOwner())) + if (!hate_list.IsEntOnHateList(other->CastToBot()->GetBotOwner())) hate_list.AddEntToHateList(other->CastToBot()->GetBotOwner(), 0, 0, false, true); } } #endif //BOTS // if other is a merc, add the merc client to the hate list - if(other->IsMerc()) { - if(other->CastToMerc()->GetMercOwner() && other->CastToMerc()->GetMercOwner()->CastToClient()->GetFeigned()) { + if (other->IsMerc()) { + if (other->CastToMerc()->GetMercOwner() && other->CastToMerc()->GetMercOwner()->CastToClient()->GetFeigned()) { AddFeignMemory(other->CastToMerc()->GetMercOwner()->CastToClient()); } else { - if(!hate_list.IsEntOnHateList(other->CastToMerc()->GetMercOwner())) + if (!hate_list.IsEntOnHateList(other->CastToMerc()->GetMercOwner())) hate_list.AddEntToHateList(other->CastToMerc()->GetMercOwner(), 0, 0, false, true); } } //MERC - // then add pet owner if there's one + // then add pet owner if there's one if (owner) { // Other is a pet, add him and it - // EverHood 6/12/06 - // Can't add a feigned owner to hate list - if(owner->IsClient() && owner->CastToClient()->GetFeigned()) { + // EverHood 6/12/06 + // Can't add a feigned owner to hate list + if (owner->IsClient() && owner->CastToClient()->GetFeigned()) { //they avoid hate due to feign death... - } else { + } + else { // cb:2007-08-17 // owner must get on list, but he's not actually gained any hate yet - if(!owner->GetSpecialAbility(IMMUNE_AGGRO)) + if (!owner->GetSpecialAbility(IMMUNE_AGGRO)) { hate_list.AddEntToHateList(owner, 0, 0, false, !iBuffTic); - if(owner->IsClient() && !CheckAggro(owner)) + if (owner->IsClient() && !CheckAggro(owner)) owner->CastToClient()->AddAutoXTarget(this); } } } if (mypet && (!(GetAA(aaPetDiscipline) && mypet->IsHeld()))) { // I have a pet, add other to it - if(!mypet->IsFamiliar() && !mypet->GetSpecialAbility(IMMUNE_AGGRO)) + if (!mypet->IsFamiliar() && !mypet->GetSpecialAbility(IMMUNE_AGGRO)) mypet->hate_list.AddEntToHateList(other, 0, 0, bFrenzy); - } else if (myowner) { // I am a pet, add other to owner if it's NPC/LD + } + else if (myowner) { // I am a pet, add other to owner if it's NPC/LD if (myowner->IsAIControlled() && !myowner->GetSpecialAbility(IMMUNE_AGGRO)) myowner->hate_list.AddEntToHateList(other, 0, 0, bFrenzy); } @@ -2589,7 +2638,7 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b entity_list.AddTempPetsToHateList(other, this, bFrenzy); if (!wasengaged) { - if(IsNPC() && other->IsClient() && other->CastToClient()) + if (IsNPC() && other->IsClient() && other->CastToClient()) parse->EventNPC(EVENT_AGGRO, this->CastToNPC(), other, "", 0); AI_Event_Engaged(other, iYellForHelp); } @@ -2605,19 +2654,19 @@ void Mob::AddToHateList(Mob* other, uint32 hate /*= 0*/, int32 damage /*= 0*/, b //a damage shield on a spell is a negative value but on an item it's a positive value so add the spell value and subtract the item value to get the end ds value void Mob::DamageShield(Mob* attacker, bool spell_ds) { - if(!attacker || this == attacker) + if (!attacker || this == attacker) return; int DS = 0; int rev_ds = 0; uint16 spellid = 0; - if(!spell_ds) + if (!spell_ds) { DS = spellbonuses.DamageShield; rev_ds = attacker->spellbonuses.ReverseDamageShield; - if(spellbonuses.DamageShieldSpellID != 0 && spellbonuses.DamageShieldSpellID != SPELL_UNKNOWN) + if (spellbonuses.DamageShieldSpellID != 0 && spellbonuses.DamageShieldSpellID != SPELL_UNKNOWN) spellid = spellbonuses.DamageShieldSpellID; } else { @@ -2627,25 +2676,25 @@ void Mob::DamageShield(Mob* attacker, bool spell_ds) { spellid = 2166; } - if(DS == 0 && rev_ds == 0) + if (DS == 0 && rev_ds == 0) return; - Log.Out(Logs::Detail, Logs::Combat, "Applying Damage Shield of value %d to %s", DS, attacker->GetName()); + Log(Logs::Detail, Logs::Combat, "Applying Damage Shield of value %d to %s", DS, attacker->GetName()); //invert DS... spells yield negative values for a true damage shield - if(DS < 0) { - if(!spell_ds) { + if (DS < 0) { + if (!spell_ds) { DS += aabonuses.DamageShield; //Live AA - coat of thistles. (negative value) DS -= itembonuses.DamageShield; //+Damage Shield should only work when you already have a DS spell - //Spell data for damage shield mitigation shows a negative value for spells for clients and positive - //value for spells that effect pets. Unclear as to why. For now will convert all positive to be consistent. - if (attacker->IsOffHandAtk()){ + //Spell data for damage shield mitigation shows a negative value for spells for clients and positive + //value for spells that effect pets. Unclear as to why. For now will convert all positive to be consistent. + if (attacker->IsOffHandAtk()) { int32 mitigation = attacker->itembonuses.DSMitigationOffHand + - attacker->spellbonuses.DSMitigationOffHand + - attacker->aabonuses.DSMitigationOffHand; - DS -= DS*mitigation/100; + attacker->spellbonuses.DSMitigationOffHand + + attacker->aabonuses.DSMitigationOffHand; + DS -= DS*mitigation / 100; } DS -= DS * attacker->itembonuses.DSMitigation / 100; } @@ -2660,7 +2709,8 @@ void Mob::DamageShield(Mob* attacker, bool spell_ds) { cds->damage = DS; entity_list.QueueCloseClients(this, outapp); safe_delete(outapp); - } else if (DS > 0 && !spell_ds) { + } + else if (DS > 0 && !spell_ds) { //we are healing the attacker... attacker->HealDamage(DS); //TODO: send a packet??? @@ -2671,13 +2721,13 @@ void Mob::DamageShield(Mob* attacker, bool spell_ds) { //if we've gotten to this point, we know we know "attacker" hit "this" (us) for damage & we aren't invulnerable uint16 rev_ds_spell_id = SPELL_UNKNOWN; - if(spellbonuses.ReverseDamageShieldSpellID != 0 && spellbonuses.ReverseDamageShieldSpellID != SPELL_UNKNOWN) + if (spellbonuses.ReverseDamageShieldSpellID != 0 && spellbonuses.ReverseDamageShieldSpellID != SPELL_UNKNOWN) rev_ds_spell_id = spellbonuses.ReverseDamageShieldSpellID; - if(rev_ds < 0) { - Log.Out(Logs::Detail, Logs::Combat, "Applying Reverse Damage Shield of value %d to %s", rev_ds, attacker->GetName()); + if (rev_ds < 0) { + Log(Logs::Detail, Logs::Combat, "Applying Reverse Damage Shield of value %d to %s", rev_ds, attacker->GetName()); attacker->Damage(this, -rev_ds, rev_ds_spell_id, EQEmu::skills::SkillAbjuration/*hackish*/, false); //"this" (us) will get the hate, etc. not sure how this works on Live, but it'll works for now, and tanks will love us for this - //do we need to send a damage packet here also? + //do we need to send a damage packet here also? } } @@ -2704,10 +2754,12 @@ uint8 Mob::GetWeaponDamageBonus(const EQEmu::ItemData *weapon, bool offhand) return 3 + ((level - 28) / 3) + ((delay - 40) / 3); else if (delay >= 45) return 4 + ((level - 28) / 3) + ((delay - 40) / 3); - } else { + } + else { return 1 + ((level - 40) / 3) * (delay / 30); // YOOO shit's useless waste of AAs } - } else { + } + else { // 2h damage bonus int damage_bonus = 1 + (level - 28) / 3; if (delay <= 27) @@ -2757,27 +2809,28 @@ int Mob::GetHandToHandDamage(void) return skill / 15 + 3; } - static uint8 mnk_dmg[] = {99, - 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, // 1-10 - 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, // 11-20 - 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, // 21-30 - 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, // 31-40 - 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, // 41-50 - 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, // 51-60 - 14, 14}; // 61-62 - static uint8 bst_dmg[] = {99, - 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, // 1-10 - 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, // 11-20 - 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, // 21-30 - 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, // 31-40 - 10, 11, 11, 11, 11, 11, 11, 12, 12}; // 41-49 + static uint8 mnk_dmg[] = { 99, + 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, // 1-10 + 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, // 11-20 + 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, // 21-30 + 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, // 31-40 + 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, // 41-50 + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, // 51-60 + 14, 14 }; // 61-62 + static uint8 bst_dmg[] = { 99, + 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, // 1-10 + 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, // 11-20 + 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, // 21-30 + 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, // 31-40 + 10, 11, 11, 11, 11, 11, 11, 12, 12 }; // 41-49 if (GetClass() == MONK) { if (IsClient() && CastToClient()->GetItemIDAt(12) == 10652 && GetLevel() > 50) return 9; if (level > 62) return 15; return mnk_dmg[level]; - } else if (GetClass() == BEASTLORD) { + } + else if (GetClass() == BEASTLORD) { if (level > 49) return 13; return bst_dmg[level]; @@ -2802,31 +2855,31 @@ int Mob::GetHandToHandDelay(void) } int delay = 35; - static uint8 mnk_hum_delay[] = {99, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, // 1-10 - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, // 11-20 - 35, 35, 35, 35, 35, 35, 35, 34, 34, 34, // 21-30 - 34, 33, 33, 33, 33, 32, 32, 32, 32, 31, // 31-40 - 31, 31, 31, 30, 30, 30, 30, 29, 29, 29, // 41-50 - 29, 28, 28, 28, 28, 27, 27, 27, 27, 26, // 51-60 - 24, 22}; // 61-62 - static uint8 mnk_iks_delay[] = {99, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, // 1-10 - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, // 11-20 - 35, 35, 35, 35, 35, 35, 35, 35, 35, 34, // 21-30 - 34, 34, 34, 34, 34, 33, 33, 33, 33, 33, // 31-40 - 33, 32, 32, 32, 32, 32, 32, 31, 31, 31, // 41-50 - 31, 31, 31, 30, 30, 30, 30, 30, 30, 29, // 51-60 - 25, 23}; // 61-62 - static uint8 bst_delay[] = {99, - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, // 1-10 - 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, // 11-20 - 35, 35, 35, 35, 35, 35, 35, 35, 34, 34, // 21-30 - 34, 34, 34, 33, 33, 33, 33, 33, 32, 32, // 31-40 - 32, 32, 32, 31, 31, 31, 31, 31, 30, 30, // 41-50 - 30, 30, 30, 29, 29, 29, 29, 29, 28, 28, // 51-60 - 28, 28, 28, 27, 27, 27, 27, 27, 26, 26, // 61-70 - 26, 26, 26}; // 71-73 + static uint8 mnk_hum_delay[] = { 99, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, // 1-10 + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, // 11-20 + 35, 35, 35, 35, 35, 35, 35, 34, 34, 34, // 21-30 + 34, 33, 33, 33, 33, 32, 32, 32, 32, 31, // 31-40 + 31, 31, 31, 30, 30, 30, 30, 29, 29, 29, // 41-50 + 29, 28, 28, 28, 28, 27, 27, 27, 27, 26, // 51-60 + 24, 22 }; // 61-62 + static uint8 mnk_iks_delay[] = { 99, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, // 1-10 + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, // 11-20 + 35, 35, 35, 35, 35, 35, 35, 35, 35, 34, // 21-30 + 34, 34, 34, 34, 34, 33, 33, 33, 33, 33, // 31-40 + 33, 32, 32, 32, 32, 32, 32, 31, 31, 31, // 41-50 + 31, 31, 31, 30, 30, 30, 30, 30, 30, 29, // 51-60 + 25, 23 }; // 61-62 + static uint8 bst_delay[] = { 99, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, // 1-10 + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, // 11-20 + 35, 35, 35, 35, 35, 35, 35, 35, 34, 34, // 21-30 + 34, 34, 34, 33, 33, 33, 33, 33, 32, 32, // 31-40 + 32, 32, 32, 31, 31, 31, 31, 31, 30, 30, // 41-50 + 30, 30, 30, 29, 29, 29, 29, 29, 28, 28, // 51-60 + 28, 28, 28, 27, 27, 27, 27, 27, 26, 26, // 61-70 + 26, 26, 26 }; // 71-73 if (GetClass() == MONK) { // Have a look to see if we have epic fists on @@ -2836,7 +2889,8 @@ int Mob::GetHandToHandDelay(void) if (level > 62) return GetRace() == IKSAR ? 21 : 20; return GetRace() == IKSAR ? mnk_iks_delay[level] : mnk_hum_delay[level]; - } else if (GetClass() == BEASTLORD) { + } + else if (GetClass() == BEASTLORD) { int level = GetLevel(); if (level > 73) return 25; @@ -2847,19 +2901,19 @@ int Mob::GetHandToHandDelay(void) int32 Mob::ReduceDamage(int32 damage) { - if(damage <= 0) + if (damage <= 0) return damage; int32 slot = -1; bool DisableMeleeRune = false; - if (spellbonuses.NegateAttacks[0]){ + if (spellbonuses.NegateAttacks[0]) { slot = spellbonuses.NegateAttacks[1]; - if(slot >= 0) { - if(--buffs[slot].numhits == 0) { + if (slot >= 0) { + if (--buffs[slot].numhits == 0) { - if(!TryFadeEffect(slot)) - BuffFadeBySlot(slot , true); + if (!TryFadeEffect(slot)) + BuffFadeBySlot(slot, true); } if (spellbonuses.NegateAttacks[2] && (damage > spellbonuses.NegateAttacks[2])) @@ -2870,24 +2924,24 @@ int32 Mob::ReduceDamage(int32 damage) } //Only mitigate if damage is above the minimium specified. - if (spellbonuses.MeleeThresholdGuard[0]){ + if (spellbonuses.MeleeThresholdGuard[0]) { slot = spellbonuses.MeleeThresholdGuard[1]; if (slot >= 0 && (damage > spellbonuses.MeleeThresholdGuard[2])) { DisableMeleeRune = true; int damage_to_reduce = damage * spellbonuses.MeleeThresholdGuard[0] / 100; - if(damage_to_reduce >= buffs[slot].melee_rune) + if (damage_to_reduce >= buffs[slot].melee_rune) { - Log.Out(Logs::Detail, Logs::Spells, "Mob::ReduceDamage SE_MeleeThresholdGuard %d damage negated, %d" + Log(Logs::Detail, Logs::Spells, "Mob::ReduceDamage SE_MeleeThresholdGuard %d damage negated, %d" " damage remaining, fading buff.", damage_to_reduce, buffs[slot].melee_rune); damage -= buffs[slot].melee_rune; - if(!TryFadeEffect(slot)) + if (!TryFadeEffect(slot)) BuffFadeBySlot(slot); } else { - Log.Out(Logs::Detail, Logs::Spells, "Mob::ReduceDamage SE_MeleeThresholdGuard %d damage negated, %d" + Log(Logs::Detail, Logs::Spells, "Mob::ReduceDamage SE_MeleeThresholdGuard %d damage negated, %d" " damage remaining.", damage_to_reduce, buffs[slot].melee_rune); buffs[slot].melee_rune = (buffs[slot].melee_rune - damage_to_reduce); damage -= damage_to_reduce; @@ -2895,26 +2949,26 @@ int32 Mob::ReduceDamage(int32 damage) } } - if (spellbonuses.MitigateMeleeRune[0] && !DisableMeleeRune){ + if (spellbonuses.MitigateMeleeRune[0] && !DisableMeleeRune) { slot = spellbonuses.MitigateMeleeRune[1]; - if(slot >= 0) + if (slot >= 0) { int damage_to_reduce = damage * spellbonuses.MitigateMeleeRune[0] / 100; if (spellbonuses.MitigateMeleeRune[2] && (damage_to_reduce > spellbonuses.MitigateMeleeRune[2])) - damage_to_reduce = spellbonuses.MitigateMeleeRune[2]; + damage_to_reduce = spellbonuses.MitigateMeleeRune[2]; - if(spellbonuses.MitigateMeleeRune[3] && (damage_to_reduce >= buffs[slot].melee_rune)) + if (spellbonuses.MitigateMeleeRune[3] && (damage_to_reduce >= buffs[slot].melee_rune)) { - Log.Out(Logs::Detail, Logs::Spells, "Mob::ReduceDamage SE_MitigateMeleeDamage %d damage negated, %d" + Log(Logs::Detail, Logs::Spells, "Mob::ReduceDamage SE_MitigateMeleeDamage %d damage negated, %d" " damage remaining, fading buff.", damage_to_reduce, buffs[slot].melee_rune); damage -= buffs[slot].melee_rune; - if(!TryFadeEffect(slot)) + if (!TryFadeEffect(slot)) BuffFadeBySlot(slot); } else { - Log.Out(Logs::Detail, Logs::Spells, "Mob::ReduceDamage SE_MitigateMeleeDamage %d damage negated, %d" + Log(Logs::Detail, Logs::Spells, "Mob::ReduceDamage SE_MitigateMeleeDamage %d damage negated, %d" " damage remaining.", damage_to_reduce, buffs[slot].melee_rune); if (spellbonuses.MitigateMeleeRune[3]) @@ -2925,13 +2979,13 @@ int32 Mob::ReduceDamage(int32 damage) } } - if(damage < 1) + if (damage < 1) return DMG_RUNE; if (spellbonuses.MeleeRune[0] && spellbonuses.MeleeRune[1] >= 0) damage = RuneAbsorb(damage, SE_Rune); - if(damage < 1) + if (damage < 1) return DMG_RUNE; return(damage); @@ -2939,20 +2993,20 @@ int32 Mob::ReduceDamage(int32 damage) int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTic, Mob* attacker) { - if(damage <= 0) + if (damage <= 0) return damage; bool DisableSpellRune = false; int32 slot = -1; // See if we block the spell outright first - if (!iBuffTic && spellbonuses.NegateAttacks[0]){ + if (!iBuffTic && spellbonuses.NegateAttacks[0]) { slot = spellbonuses.NegateAttacks[1]; - if(slot >= 0) { - if(--buffs[slot].numhits == 0) { + if (slot >= 0) { + if (--buffs[slot].numhits == 0) { - if(!TryFadeEffect(slot)) - BuffFadeBySlot(slot , true); + if (!TryFadeEffect(slot)) + BuffFadeBySlot(slot, true); } if (spellbonuses.NegateAttacks[2] && (damage > spellbonuses.NegateAttacks[2])) @@ -2963,22 +3017,22 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi } // If this is a DoT, use DoT Shielding... - if(iBuffTic) { + if (iBuffTic) { damage -= (damage * itembonuses.DoTShielding / 100); - if (spellbonuses.MitigateDotRune[0]){ + if (spellbonuses.MitigateDotRune[0]) { slot = spellbonuses.MitigateDotRune[1]; - if(slot >= 0) + if (slot >= 0) { int damage_to_reduce = damage * spellbonuses.MitigateDotRune[0] / 100; if (spellbonuses.MitigateDotRune[2] && (damage_to_reduce > spellbonuses.MitigateDotRune[2])) damage_to_reduce = spellbonuses.MitigateDotRune[2]; - if(spellbonuses.MitigateDotRune[3] && (damage_to_reduce >= buffs[slot].dot_rune)) + if (spellbonuses.MitigateDotRune[3] && (damage_to_reduce >= buffs[slot].dot_rune)) { damage -= buffs[slot].dot_rune; - if(!TryFadeEffect(slot)) + if (!TryFadeEffect(slot)) BuffFadeBySlot(slot); } else @@ -2999,17 +3053,17 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi damage -= (damage * itembonuses.SpellShield / 100); //Only mitigate if damage is above the minimium specified. - if (spellbonuses.SpellThresholdGuard[0]){ + if (spellbonuses.SpellThresholdGuard[0]) { slot = spellbonuses.SpellThresholdGuard[1]; if (slot >= 0 && (damage > spellbonuses.MeleeThresholdGuard[2])) { DisableSpellRune = true; int damage_to_reduce = damage * spellbonuses.SpellThresholdGuard[0] / 100; - if(damage_to_reduce >= buffs[slot].magic_rune) + if (damage_to_reduce >= buffs[slot].magic_rune) { damage -= buffs[slot].magic_rune; - if(!TryFadeEffect(slot)) + if (!TryFadeEffect(slot)) BuffFadeBySlot(slot); } else @@ -3021,26 +3075,26 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi } // Do runes now. - if (spellbonuses.MitigateSpellRune[0] && !DisableSpellRune){ + if (spellbonuses.MitigateSpellRune[0] && !DisableSpellRune) { slot = spellbonuses.MitigateSpellRune[1]; - if(slot >= 0) + if (slot >= 0) { int damage_to_reduce = damage * spellbonuses.MitigateSpellRune[0] / 100; if (spellbonuses.MitigateSpellRune[2] && (damage_to_reduce > spellbonuses.MitigateSpellRune[2])) damage_to_reduce = spellbonuses.MitigateSpellRune[2]; - if(spellbonuses.MitigateSpellRune[3] && (damage_to_reduce >= buffs[slot].magic_rune)) + if (spellbonuses.MitigateSpellRune[3] && (damage_to_reduce >= buffs[slot].magic_rune)) { - Log.Out(Logs::Detail, Logs::Spells, "Mob::ReduceDamage SE_MitigateSpellDamage %d damage negated, %d" + Log(Logs::Detail, Logs::Spells, "Mob::ReduceDamage SE_MitigateSpellDamage %d damage negated, %d" " damage remaining, fading buff.", damage_to_reduce, buffs[slot].magic_rune); damage -= buffs[slot].magic_rune; - if(!TryFadeEffect(slot)) + if (!TryFadeEffect(slot)) BuffFadeBySlot(slot); } else { - Log.Out(Logs::Detail, Logs::Spells, "Mob::ReduceDamage SE_MitigateMeleeDamage %d damage negated, %d" + Log(Logs::Detail, Logs::Spells, "Mob::ReduceDamage SE_MitigateMeleeDamage %d damage negated, %d" " damage remaining.", damage_to_reduce, buffs[slot].magic_rune); if (spellbonuses.MitigateSpellRune[3]) @@ -3051,7 +3105,7 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi } } - if(damage < 1) + if (damage < 1) return 0; //Regular runes absorb spell damage (except dots) - Confirmed on live. @@ -3061,7 +3115,7 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi if (spellbonuses.AbsorbMagicAtt[0] && spellbonuses.AbsorbMagicAtt[1] >= 0) damage = RuneAbsorb(damage, SE_AbsorbMagicAtt); - if(damage < 1) + if (damage < 1) return 0; } return damage; @@ -3069,12 +3123,12 @@ int32 Mob::AffectMagicalDamage(int32 damage, uint16 spell_id, const bool iBuffTi int32 Mob::ReduceAllDamage(int32 damage) { - if(damage <= 0) + if (damage <= 0) return damage; - if(spellbonuses.ManaAbsorbPercentDamage[0]) { - int32 mana_reduced = damage * spellbonuses.ManaAbsorbPercentDamage[0] / 100; - if (GetMana() >= mana_reduced){ + if (spellbonuses.ManaAbsorbPercentDamage[0]) { + int32 mana_reduced = damage * spellbonuses.ManaAbsorbPercentDamage[0] / 100; + if (GetMana() >= mana_reduced) { damage -= mana_reduced; SetMana(GetMana() - mana_reduced); TryTriggerOnValueAmount(false, true); @@ -3105,7 +3159,7 @@ bool Mob::HasDefensiveProcs() const bool Mob::HasSkillProcs() const { - for(int i = 0; i < MAX_SKILL_PROCS; i++){ + for (int i = 0; i < MAX_SKILL_PROCS; i++) { if (spellbonuses.SkillProc[i] || itembonuses.SkillProc[i] || aabonuses.SkillProc[i]) return true; } @@ -3114,7 +3168,7 @@ bool Mob::HasSkillProcs() const bool Mob::HasSkillProcSuccess() const { - for(int i = 0; i < MAX_SKILL_PROCS; i++){ + for (int i = 0; i < MAX_SKILL_PROCS; i++) { if (spellbonuses.SkillProcSuccess[i] || itembonuses.SkillProcSuccess[i] || aabonuses.SkillProcSuccess[i]) return true; } @@ -3167,7 +3221,7 @@ bool Client::CheckTripleAttack() bool Client::CheckDoubleRangedAttack() { int32 chance = spellbonuses.DoubleRangedAttack + itembonuses.DoubleRangedAttack + aabonuses.DoubleRangedAttack; - if(chance && zone->random.Roll(chance)) + if (chance && zone->random.Roll(chance)) return true; return false; @@ -3196,11 +3250,11 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const ignore_invul = spell_id == 982 || spells[spell_id].cast_not_standing; // cazic touch if (!ignore_invul && (GetInvul() || DivineAura())) { - Log.Out(Logs::Detail, Logs::Combat, "Avoiding %d damage due to invulnerability.", damage); + Log(Logs::Detail, Logs::Combat, "Avoiding %d damage due to invulnerability.", damage); damage = DMG_INVULNERABLE; } - if( spell_id != SPELL_UNKNOWN || attacker == nullptr ) + if (spell_id != SPELL_UNKNOWN || attacker == nullptr) avoidable = false; // only apply DS if physical damage (no spell damage) @@ -3216,15 +3270,15 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const attacker->CheckNumHitsRemaining(NumHit::OutgoingHitAttempts); } - if(attacker){ - if(attacker->IsClient()){ - if(!RuleB(Combat, EXPFromDmgShield)) { - // Damage shield damage shouldn't count towards who gets EXP - if(!attacker->CastToClient()->GetFeigned() && !FromDamageShield) + if (attacker) { + if (attacker->IsClient()) { + if (!RuleB(Combat, EXPFromDmgShield)) { + // Damage shield damage shouldn't count towards who gets EXP + if (!attacker->CastToClient()->GetFeigned() && !FromDamageShield) AddToHateList(attacker, 0, damage, true, false, iBuffTic, spell_id); } else { - if(!attacker->CastToClient()->GetFeigned()) + if (!attacker->CastToClient()->GetFeigned()) AddToHateList(attacker, 0, damage, true, false, iBuffTic, spell_id); } } @@ -3232,20 +3286,20 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const AddToHateList(attacker, 0, damage, true, false, iBuffTic, spell_id); } - if(damage > 0) { + if (damage > 0) { //if there is some damage being done and theres an attacker involved - if(attacker) { + if (attacker) { // if spell is lifetap add hp to the caster - if (spell_id != SPELL_UNKNOWN && IsLifetapSpell( spell_id )) { + if (spell_id != SPELL_UNKNOWN && IsLifetapSpell(spell_id)) { int healed = damage; healed = attacker->GetActSpellHealing(spell_id, healed); - Log.Out(Logs::Detail, Logs::Combat, "Applying lifetap heal of %d to %s", healed, attacker->GetName()); + Log(Logs::Detail, Logs::Combat, "Applying lifetap heal of %d to %s", healed, attacker->GetName()); attacker->HealDamage(healed); //we used to do a message to the client, but its gone now. // emote goes with every one ... even npcs - entity_list.MessageClose(this, true, RuleI(Range, SpellMessages), MT_Emote, "%s beams a smile at %s", attacker->GetCleanName(), this->GetCleanName() ); + entity_list.MessageClose(this, true, RuleI(Range, SpellMessages), MT_Emote, "%s beams a smile at %s", attacker->GetCleanName(), this->GetCleanName()); } } //end `if there is some damage being done and theres anattacker person involved` @@ -3253,43 +3307,44 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const if (pet && !pet->IsFamiliar() && !pet->GetSpecialAbility(IMMUNE_AGGRO) && !pet->IsEngaged() && attacker && attacker != this && !attacker->IsCorpse()) { if (!pet->IsHeld()) { - Log.Out(Logs::Detail, Logs::Aggro, "Sending pet %s into battle due to attack.", pet->GetName()); - pet->AddToHateList(attacker, 1,0, true, false, false, spell_id); + Log(Logs::Detail, Logs::Aggro, "Sending pet %s into battle due to attack.", pet->GetName()); + pet->AddToHateList(attacker, 1, 0, true, false, false, spell_id); pet->SetTarget(attacker); Message_StringID(10, PET_ATTACKING, pet->GetCleanName(), attacker->GetCleanName()); } } //see if any runes want to reduce this damage - if(spell_id == SPELL_UNKNOWN) { + if (spell_id == SPELL_UNKNOWN) { damage = ReduceDamage(damage); - Log.Out(Logs::Detail, Logs::Combat, "Melee Damage reduced to %d", damage); + Log(Logs::Detail, Logs::Combat, "Melee Damage reduced to %d", damage); damage = ReduceAllDamage(damage); TryTriggerThreshHold(damage, SE_TriggerMeleeThreshold, attacker); if (skill_used) CheckNumHitsRemaining(NumHit::IncomingHitSuccess); - } else { + } + else { int32 origdmg = damage; damage = AffectMagicalDamage(damage, spell_id, iBuffTic, attacker); if (origdmg != damage && attacker && attacker->IsClient()) { - if(attacker->CastToClient()->GetFilter(FilterDamageShields) != FilterHide) + if (attacker->CastToClient()->GetFilter(FilterDamageShields) != FilterHide) attacker->Message(15, "The Spellshield absorbed %d of %d points of damage", origdmg - damage, origdmg); } if (damage == 0 && attacker && origdmg != damage && IsClient()) { //Kayen: Probably need to add a filter for this - Not sure if this msg is correct but there should be a message for spell negate/runes. - Message(263, "%s tries to cast on YOU, but YOUR magical skin absorbs the spell.",attacker->GetCleanName()); + Message(263, "%s tries to cast on YOU, but YOUR magical skin absorbs the spell.", attacker->GetCleanName()); } damage = ReduceAllDamage(damage); TryTriggerThreshHold(damage, SE_TriggerSpellThreshold, attacker); } - if(IsClient() && CastToClient()->sneaking){ + if (IsClient() && CastToClient()->sneaking) { CastToClient()->sneaking = false; SendAppearancePacket(AT_Sneak, 0); } - if(attacker && attacker->IsClient() && attacker->CastToClient()->sneaking){ + if (attacker && attacker->IsClient() && attacker->CastToClient()->sneaking) { attacker->CastToClient()->sneaking = false; attacker->SendAppearancePacket(AT_Sneak, 0); } @@ -3301,22 +3356,22 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const if (IsClient()) this->CastToClient()->SendHPUpdateMarquee(); - if(HasDied()) { + if (HasDied()) { bool IsSaved = false; - if(TryDivineSave()) + if (TryDivineSave()) IsSaved = true; - if(!IsSaved && !TrySpellOnDeath()) { + if (!IsSaved && !TrySpellOnDeath()) { SetHP(-500); - if(Death(attacker, damage, spell_id, skill_used)) { + if (Death(attacker, damage, spell_id, skill_used)) { return; } } } - else{ - if(GetHPRatio() < 16) + else { + if (GetHPRatio() < 16) TryDeathSave(); } @@ -3324,16 +3379,16 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const //fade mez if we are mezzed if (IsMezzed() && attacker) { - Log.Out(Logs::Detail, Logs::Combat, "Breaking mez due to attack."); + Log(Logs::Detail, Logs::Combat, "Breaking mez due to attack."); entity_list.MessageClose_StringID( this, /* Sender */ true, /* Skip Sender */ - RuleI(Range, SpellMessages), + RuleI(Range, SpellMessages), MT_WornOff, /* 284 */ HAS_BEEN_AWAKENED, // %1 has been awakened by %2. GetCleanName(), /* Message1 */ attacker->GetCleanName() /* Message2 */ - ); + ); BuffFadeByEffect(SE_Mez); } @@ -3348,15 +3403,16 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const can_stun = true; if (attacker->IsClient()) stunbash_chance = attacker->spellbonuses.StunBashChance + - attacker->itembonuses.StunBashChance + - attacker->aabonuses.StunBashChance; - } else if (skill_used == EQEmu::skills::SkillKick && - (attacker->GetLevel() > 55 || attacker->IsNPC()) && GetClass() == WARRIOR) { + attacker->itembonuses.StunBashChance + + attacker->aabonuses.StunBashChance; + } + else if (skill_used == EQEmu::skills::SkillKick && + (attacker->GetLevel() > 55 || attacker->IsNPC()) && GetClass() == WARRIOR) { can_stun = true; } if ((GetBaseRace() == OGRE || GetBaseRace() == OGGOK_CITIZEN) && - !attacker->BehindMob(this, attacker->GetX(), attacker->GetY())) + !attacker->BehindMob(this, attacker->GetX(), attacker->GetY())) can_stun = false; if (GetSpecialAbility(UNSTUNABLE)) can_stun = false; @@ -3367,57 +3423,60 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const // did stun -- roll other resists // SE_FrontalStunResist description says any angle now a days int stun_resist2 = spellbonuses.FrontalStunResist + itembonuses.FrontalStunResist + - aabonuses.FrontalStunResist; + aabonuses.FrontalStunResist; if (zone->random.Int(1, 100) > stun_resist2) { // stun resist 2 failed // time to check SE_StunResist and mod2 stun resist int stun_resist = - spellbonuses.StunResist + itembonuses.StunResist + aabonuses.StunResist; + spellbonuses.StunResist + itembonuses.StunResist + aabonuses.StunResist; if (zone->random.Int(0, 100) >= stun_resist) { // did stun // nothing else to check! Stun(2000); // straight 2 seconds every time - } else { + } + else { // stun resist passed! if (IsClient()) Message_StringID(MT_Stun, SHAKE_OFF_STUN); } - } else { + } + else { // stun resist 2 passed! if (IsClient()) Message_StringID(MT_Stun, AVOID_STUNNING_BLOW); } - } else { + } + else { // main stun failed -- extra interrupt roll if (IsCasting() && - !EQEmu::ValueWithin(casting_spell_id, 859, 1023)) // these spells are excluded - // 90% chance >< -- stun immune won't reach this branch though :( + !EQEmu::ValueWithin(casting_spell_id, 859, 1023)) // these spells are excluded + // 90% chance >< -- stun immune won't reach this branch though :( if (zone->random.Int(0, 9) > 1) InterruptSpell(); } } - if(spell_id != SPELL_UNKNOWN && !iBuffTic) { + if (spell_id != SPELL_UNKNOWN && !iBuffTic) { //see if root will break if (IsRooted() && !FromDamageShield) // neotoyko: only spells cancel root TryRootFadeByDamage(buffslot, attacker); } - else if(spell_id == SPELL_UNKNOWN) + else if (spell_id == SPELL_UNKNOWN) { //increment chances of interrupting - if(IsCasting()) { //shouldnt interrupt on regular spell damage + if (IsCasting()) { //shouldnt interrupt on regular spell damage attacked_count++; - Log.Out(Logs::Detail, Logs::Combat, "Melee attack while casting. Attack count %d", attacked_count); + Log(Logs::Detail, Logs::Combat, "Melee attack while casting. Attack count %d", attacked_count); } } //send an HP update if we are hurt - if(GetHP() < GetMaxHP()) + if (GetHP() < GetMaxHP()) SendHPUpdate(!iBuffTic); // the OP_Damage actually updates the client in these cases, so we skip the HP update for them } //end `if damage was done` - //send damage packet... - if(!iBuffTic) { //buff ticks do not send damage, instead they just call SendHPUpdate(), which is done above + //send damage packet... + if (!iBuffTic) { //buff ticks do not send damage, instead they just call SendHPUpdate(), which is done above auto outapp = new EQApplicationPacket(OP_Damage, sizeof(CombatDamage_Struct)); CombatDamage_Struct* a = (CombatDamage_Struct*)outapp->pBuffer; a->target = GetID(); @@ -3438,18 +3497,19 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const a->special = 0; a->meleepush_xy = attacker ? attacker->GetHeading() * 2.0f : 0.0f; if (RuleB(Combat, MeleePush) && damage > 0 && !IsRooted() && - (IsClient() || zone->random.Roll(RuleI(Combat, MeleePushChance)))) { + (IsClient() || zone->random.Roll(RuleI(Combat, MeleePushChance)))) { a->force = EQEmu::skills::GetSkillMeleePushForce(skill_used); // update NPC stuff auto new_pos = glm::vec3(m_Position.x + (a->force * std::sin(a->meleepush_xy) + m_Delta.x), - m_Position.y + (a->force * std::cos(a->meleepush_xy) + m_Delta.y), m_Position.z); + m_Position.y + (a->force * std::cos(a->meleepush_xy) + m_Delta.y), m_Position.z); if (zone->zonemap && zone->zonemap->CheckLoS(glm::vec3(m_Position), new_pos)) { // If we have LoS on the new loc it should be reachable. if (IsNPC()) { // Is this adequate? Teleport(new_pos); SendPosUpdate(); } - } else { + } + else { a->force = 0.0f; // we couldn't move there, so lets not } } @@ -3458,21 +3518,23 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const //this was done to simplify the code here (since we can only effectively skip one mob on queue) eqFilterType filter; Mob *skip = attacker; - if(attacker && attacker->GetOwnerID()) { + if (attacker && attacker->GetOwnerID()) { //attacker is a pet, let pet owners see their pet's damage Mob* owner = attacker->GetOwner(); if (owner && owner->IsClient()) { if (((spell_id != SPELL_UNKNOWN) || (FromDamageShield)) && damage>0) { //special crap for spell damage, looks hackish to me - char val1[20]={0}; - owner->Message_StringID(MT_NonMelee,OTHER_HIT_NONMELEE,GetCleanName(),ConvertArray(damage,val1)); - } else { - if(damage > 0) { - if(spell_id != SPELL_UNKNOWN) + char val1[20] = { 0 }; + owner->Message_StringID(MT_NonMelee, OTHER_HIT_NONMELEE, GetCleanName(), ConvertArray(damage, val1)); + } + else { + if (damage > 0) { + if (spell_id != SPELL_UNKNOWN) filter = iBuffTic ? FilterDOT : FilterSpellDamage; else filter = FilterPetHits; - } else if(damage == -5) + } + else if (damage == -5) filter = FilterNone; //cant filter invulnerable else filter = FilterPetMisses; @@ -3482,18 +3544,20 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const } } skip = owner; - } else { + } + else { //attacker is not a pet, send to the attacker //if the attacker is a client, try them with the correct filter - if(attacker && attacker->IsClient()) { + if (attacker && attacker->IsClient()) { if ((spell_id != SPELL_UNKNOWN || FromDamageShield) && damage > 0) { //special crap for spell damage, looks hackish to me - char val1[20] = {0}; + char val1[20] = { 0 }; if (FromDamageShield) { if (attacker->CastToClient()->GetFilter(FilterDamageShields) != FilterHide) attacker->Message_StringID(MT_DS, OTHER_HIT_NONMELEE, GetCleanName(), ConvertArray(damage, val1)); - } else { + } + else { entity_list.MessageClose_StringID( this, /* Sender */ true, /* Skip Sender */ @@ -3503,15 +3567,17 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const attacker->GetCleanName(), /* Message1 */ GetCleanName(), /* Message2 */ ConvertArray(damage, val1) /* Message3 */ - ); + ); } - } else { - if(damage > 0) { - if(spell_id != SPELL_UNKNOWN) + } + else { + if (damage > 0) { + if (spell_id != SPELL_UNKNOWN) filter = iBuffTic ? FilterDOT : FilterSpellDamage; else filter = FilterNone; //cant filter our own hits - } else if(damage == -5) + } + else if (damage == -5) filter = FilterNone; //cant filter invulnerable else filter = FilterMyMisses; @@ -3523,12 +3589,13 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const } //send damage to all clients around except the specified skip mob (attacker or the attacker's owner) and ourself - if(damage > 0) { - if(spell_id != SPELL_UNKNOWN) + if (damage > 0) { + if (spell_id != SPELL_UNKNOWN) filter = iBuffTic ? FilterDOT : FilterSpellDamage; else filter = FilterOthersHit; - } else if(damage == -5) + } + else if (damage == -5) filter = FilterNone; //cant filter invulnerable else filter = FilterOthersMiss; @@ -3536,33 +3603,34 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const //this call will send the packet to `this` as well (using the wrong filter) (will not happen until PC charm works) // If this is Damage Shield damage, the correct OP_Damage packets will be sent from Mob::DamageShield, so // we don't send them here. - if(!FromDamageShield) { + if (!FromDamageShield) { entity_list.QueueCloseClients( this, /* Sender */ outapp, /* packet */ true, /* Skip Sender */ - RuleI(Range, SpellMessages), + RuleI(Range, SpellMessages), skip, /* Skip this mob */ true, /* Packet ACK */ filter /* eqFilterType filter */ - ); + ); //send the damage to ourself if we are a client - if(IsClient()) { + if (IsClient()) { //I dont think any filters apply to damage affecting us CastToClient()->QueuePacket(outapp); } } safe_delete(outapp); - } else { + } + else { //else, it is a buff tic... // So we can see our dot dmg like live shows it. - if(spell_id != SPELL_UNKNOWN && damage > 0 && attacker && attacker != this && attacker->IsClient()) { + if (spell_id != SPELL_UNKNOWN && damage > 0 && attacker && attacker != this && attacker->IsClient()) { //might filter on (attack_skill>200 && attack_skill<250), but I dont think we need it attacker->FilteredMessage_StringID(attacker, MT_DoTDamage, FilterDOT, - YOUR_HIT_DOT, GetCleanName(), itoa(damage), spells[spell_id].name); + YOUR_HIT_DOT, GetCleanName(), itoa(damage), spells[spell_id].name); /* older clients don't have the below String ID, but it will be filtered */ entity_list.FilteredMessageClose_StringID( @@ -3576,7 +3644,7 @@ void Mob::CommonDamage(Mob* attacker, int &damage, const uint16 spell_id, const itoa(damage), /* Message2 */ attacker->GetCleanName(), /* Message3 */ spells[spell_id].name /* Message4 */ - ); + ); } } //end packet sending @@ -3596,41 +3664,44 @@ void Mob::HealDamage(uint32 amount, Mob *caster, uint16 spell_id) if (acthealed > 100) { if (caster) { if (IsBuffSpell(spell_id)) { // hots - // message to caster + // message to caster if (caster->IsClient() && caster == this) { if (caster->CastToClient()->ClientVersionBit() & EQEmu::versions::bit_SoFAndLater) FilteredMessage_StringID(caster, MT_NonMelee, FilterHealOverTime, - HOT_HEAL_SELF, itoa(acthealed), spells[spell_id].name); + HOT_HEAL_SELF, itoa(acthealed), spells[spell_id].name); else FilteredMessage_StringID(caster, MT_NonMelee, FilterHealOverTime, - YOU_HEALED, GetCleanName(), itoa(acthealed)); - } else if (caster->IsClient() && caster != this) { + YOU_HEALED, GetCleanName(), itoa(acthealed)); + } + else if (caster->IsClient() && caster != this) { if (caster->CastToClient()->ClientVersionBit() & EQEmu::versions::bit_SoFAndLater) caster->FilteredMessage_StringID(caster, MT_NonMelee, FilterHealOverTime, - HOT_HEAL_OTHER, GetCleanName(), itoa(acthealed), - spells[spell_id].name); + HOT_HEAL_OTHER, GetCleanName(), itoa(acthealed), + spells[spell_id].name); else caster->FilteredMessage_StringID(caster, MT_NonMelee, FilterHealOverTime, - YOU_HEAL, GetCleanName(), itoa(acthealed)); + YOU_HEAL, GetCleanName(), itoa(acthealed)); } // message to target if (IsClient() && caster != this) { if (CastToClient()->ClientVersionBit() & EQEmu::versions::bit_SoFAndLater) FilteredMessage_StringID(this, MT_NonMelee, FilterHealOverTime, - HOT_HEALED_OTHER, caster->GetCleanName(), - itoa(acthealed), spells[spell_id].name); + HOT_HEALED_OTHER, caster->GetCleanName(), + itoa(acthealed), spells[spell_id].name); else FilteredMessage_StringID(this, MT_NonMelee, FilterHealOverTime, - YOU_HEALED, caster->GetCleanName(), itoa(acthealed)); + YOU_HEALED, caster->GetCleanName(), itoa(acthealed)); } - } else { // normal heals + } + else { // normal heals FilteredMessage_StringID(caster, MT_NonMelee, FilterSpellDamage, - YOU_HEALED, caster->GetCleanName(), itoa(acthealed)); + YOU_HEALED, caster->GetCleanName(), itoa(acthealed)); if (caster != this) caster->FilteredMessage_StringID(caster, MT_NonMelee, FilterSpellDamage, - YOU_HEAL, GetCleanName(), itoa(acthealed)); + YOU_HEAL, GetCleanName(), itoa(acthealed)); } - } else { + } + else { Message(MT_NonMelee, "You have been healed for %d points of damage.", acthealed); } } @@ -3656,16 +3727,17 @@ float Mob::GetProcChances(float ProcBonus, uint16 hand) if (RuleB(Combat, AdjustProcPerMinute)) { ProcChance = (static_cast(weapon_speed) * - RuleR(Combat, AvgProcsPerMinute) / 60000.0f); // compensate for weapon_speed being in ms + RuleR(Combat, AvgProcsPerMinute) / 60000.0f); // compensate for weapon_speed being in ms ProcBonus += static_cast(mydex) * RuleR(Combat, ProcPerMinDexContrib); ProcChance += ProcChance * ProcBonus / 100.0f; - } else { + } + else { ProcChance = RuleR(Combat, BaseProcChance) + static_cast(mydex) / RuleR(Combat, ProcDexDivideBy); ProcChance += ProcChance * ProcBonus / 100.0f; } - Log.Out(Logs::Detail, Logs::Combat, "Proc chance %.2f (%.2f from bonuses)", ProcChance, ProcBonus); + Log(Logs::Detail, Logs::Combat, "Proc chance %.2f (%.2f from bonuses)", ProcChance, ProcBonus); return ProcChance; } @@ -3684,7 +3756,7 @@ float Mob::GetDefensiveProcChances(float &ProcBonus, float &ProcChance, uint16 h ProcBonus += static_cast(myagi) * RuleR(Combat, DefProcPerMinAgiContrib) / 100.0f; ProcChance = ProcChance + (ProcChance * ProcBonus); - Log.Out(Logs::Detail, Logs::Combat, "Defensive Proc chance %.2f (%.2f from bonuses)", ProcChance, ProcBonus); + Log(Logs::Detail, Logs::Combat, "Defensive Proc chance %.2f (%.2f from bonuses)", ProcChance, ProcBonus); return ProcChance; } @@ -3693,17 +3765,17 @@ void Mob::TryDefensiveProc(Mob *on, uint16 hand) { if (!on) { SetTarget(nullptr); - Log.Out(Logs::General, Logs::Error, "A null Mob object was passed to Mob::TryDefensiveProc for evaluation!"); + Log(Logs::General, Logs::Error, "A null Mob object was passed to Mob::TryDefensiveProc for evaluation!"); return; } if (!HasDefensiveProcs()) return; - if (!on->HasDied() && on->GetHP() > 0){ + if (!on->HasDied() && on->GetHP() > 0) { float ProcChance, ProcBonus; - on->GetDefensiveProcChances(ProcBonus, ProcChance, hand , this); + on->GetDefensiveProcChances(ProcBonus, ProcChance, hand, this); if (hand != EQEmu::inventory::slotPrimary) ProcChance /= 2; @@ -3713,17 +3785,17 @@ void Mob::TryDefensiveProc(Mob *on, uint16 hand) { if (level_diff > 6)//10% penalty per level if > 6 levels over target. level_penalty = (level_diff - 6) * 10; - ProcChance -= ProcChance*level_penalty/100; + ProcChance -= ProcChance*level_penalty / 100; if (ProcChance < 0) return; for (int i = 0; i < MAX_PROCS; i++) { if (IsValidSpell(DefensiveProcs[i].spellID)) { - float chance = ProcChance * (static_cast(DefensiveProcs[i].chance)/100.0f); + float chance = ProcChance * (static_cast(DefensiveProcs[i].chance) / 100.0f); if (zone->random.Roll(chance)) { ExecWeaponProc(nullptr, DefensiveProcs[i].spellID, on); - CheckNumHitsRemaining(NumHit::DefensiveSpellProcs, 0,DefensiveProcs[i].base_spellID); + CheckNumHitsRemaining(NumHit::DefensiveSpellProcs, 0, DefensiveProcs[i].base_spellID); } } } @@ -3731,23 +3803,23 @@ void Mob::TryDefensiveProc(Mob *on, uint16 hand) { } void Mob::TryWeaponProc(const EQEmu::ItemInstance* weapon_g, Mob *on, uint16 hand) { - if(!on) { + if (!on) { SetTarget(nullptr); - Log.Out(Logs::General, Logs::Error, "A null Mob object was passed to Mob::TryWeaponProc for evaluation!"); + Log(Logs::General, Logs::Error, "A null Mob object was passed to Mob::TryWeaponProc for evaluation!"); return; } if (!IsAttackAllowed(on)) { - Log.Out(Logs::Detail, Logs::Combat, "Preventing procing off of unattackable things."); + Log(Logs::Detail, Logs::Combat, "Preventing procing off of unattackable things."); return; } if (DivineAura()) { - Log.Out(Logs::Detail, Logs::Combat, "Procs canceled, Divine Aura is in effect."); + Log(Logs::Detail, Logs::Combat, "Procs canceled, Divine Aura is in effect."); return; } - if(!weapon_g) { + if (!weapon_g) { TrySpellProc(nullptr, (const EQEmu::ItemData*)nullptr, on); return; } @@ -3774,7 +3846,7 @@ void Mob::TryWeaponProc(const EQEmu::ItemInstance *inst, const EQEmu::ItemData * uint16 skillinuse = 28; int ourlevel = GetLevel(); float ProcBonus = static_cast(aabonuses.ProcChanceSPA + - spellbonuses.ProcChanceSPA + itembonuses.ProcChanceSPA); + spellbonuses.ProcChanceSPA + itembonuses.ProcChanceSPA); ProcBonus += static_cast(itembonuses.ProcChance) / 10.0f; // Combat Effects float ProcChance = GetProcChances(ProcBonus, hand); @@ -3787,23 +3859,25 @@ void Mob::TryWeaponProc(const EQEmu::ItemInstance *inst, const EQEmu::ItemData * skillinuse = GetSkillByItemType(weapon->ItemType); if (weapon->Proc.Type == EQEmu::item::ItemEffectCombatProc && IsValidSpell(weapon->Proc.Effect)) { float WPC = ProcChance * (100.0f + // Proc chance for this weapon - static_cast(weapon->ProcRate)) / 100.0f; + static_cast(weapon->ProcRate)) / 100.0f; if (zone->random.Roll(WPC)) { // 255 dex = 0.084 chance of proc. No idea what this number should be really. if (weapon->Proc.Level > ourlevel) { - Log.Out(Logs::Detail, Logs::Combat, - "Tried to proc (%s), but our level (%d) is lower than required (%d)", - weapon->Name, ourlevel, weapon->Proc.Level); + Log(Logs::Detail, Logs::Combat, + "Tried to proc (%s), but our level (%d) is lower than required (%d)", + weapon->Name, ourlevel, weapon->Proc.Level); if (IsPet()) { Mob *own = GetOwner(); if (own) own->Message_StringID(13, PROC_PETTOOLOW); - } else { + } + else { Message_StringID(13, PROC_TOOLOW); } - } else { - Log.Out(Logs::Detail, Logs::Combat, - "Attacking weapon (%s) successfully procing spell %d (%.2f percent chance)", - weapon->Name, weapon->Proc.Effect, WPC * 100); + } + else { + Log(Logs::Detail, Logs::Combat, + "Attacking weapon (%s) successfully procing spell %d (%.2f percent chance)", + weapon->Name, weapon->Proc.Effect, WPC * 100); ExecWeaponProc(inst, weapon->Proc.Effect, on); proced = true; } @@ -3811,7 +3885,7 @@ void Mob::TryWeaponProc(const EQEmu::ItemInstance *inst, const EQEmu::ItemData * } //If OneProcPerWeapon is not enabled, we reset the try for that weapon regardless of if we procced or not. //This is for some servers that may want to have as many procs triggering from weapons as possible in a single round. - if(!RuleB(Combat, OneProcPerWeapon)) + if (!RuleB(Combat, OneProcPerWeapon)) proced = false; if (!proced && inst) { @@ -3832,10 +3906,12 @@ void Mob::TryWeaponProc(const EQEmu::ItemInstance *inst, const EQEmu::ItemData * Mob *own = GetOwner(); if (own) own->Message_StringID(13, PROC_PETTOOLOW); - } else { + } + else { Message_StringID(13, PROC_TOOLOW); } - } else { + } + else { ExecWeaponProc(aug_i, aug->Proc.Effect, on); if (RuleB(Combat, OneProcPerWeapon)) break; @@ -3852,7 +3928,7 @@ void Mob::TryWeaponProc(const EQEmu::ItemInstance *inst, const EQEmu::ItemData * void Mob::TrySpellProc(const EQEmu::ItemInstance *inst, const EQEmu::ItemData *weapon, Mob *on, uint16 hand) { float ProcBonus = static_cast(spellbonuses.SpellProcChance + - itembonuses.SpellProcChance + aabonuses.SpellProcChance); + itembonuses.SpellProcChance + aabonuses.SpellProcChance); float ProcChance = 0.0f; ProcChance = GetProcChances(ProcBonus, hand); @@ -3876,19 +3952,20 @@ void Mob::TrySpellProc(const EQEmu::ItemInstance *inst, const EQEmu::ItemData *w if (IsPet() && hand != EQEmu::inventory::slotPrimary) //Pets can only proc spell procs from their primay hand (ie; beastlord pets) continue; // If pets ever can proc from off hand, this will need to change - // Not ranged + // Not ranged if (!rangedattk) { // Perma procs (AAs) if (PermaProcs[i].spellID != SPELL_UNKNOWN) { if (zone->random.Roll(PermaProcs[i].chance)) { // TODO: Do these get spell bonus? - Log.Out(Logs::Detail, Logs::Combat, - "Permanent proc %d procing spell %d (%d percent chance)", - i, PermaProcs[i].spellID, PermaProcs[i].chance); + Log(Logs::Detail, Logs::Combat, + "Permanent proc %d procing spell %d (%d percent chance)", + i, PermaProcs[i].spellID, PermaProcs[i].chance); ExecWeaponProc(nullptr, PermaProcs[i].spellID, on); - } else { - Log.Out(Logs::Detail, Logs::Combat, - "Permanent proc %d failed to proc %d (%d percent chance)", - i, PermaProcs[i].spellID, PermaProcs[i].chance); + } + else { + Log(Logs::Detail, Logs::Combat, + "Permanent proc %d failed to proc %d (%d percent chance)", + i, PermaProcs[i].spellID, PermaProcs[i].chance); } } @@ -3896,10 +3973,10 @@ void Mob::TrySpellProc(const EQEmu::ItemInstance *inst, const EQEmu::ItemData *w if (SpellProcs[i].spellID != SPELL_UNKNOWN) { float chance = ProcChance * (static_cast(SpellProcs[i].chance) / 100.0f); if (zone->random.Roll(chance)) { - Log.Out(Logs::Detail, Logs::Combat, - "Spell proc %d procing spell %d (%.2f percent chance)", - i, SpellProcs[i].spellID, chance); - auto outapp = new EQApplicationPacket(OP_BeginCast,sizeof(BeginCast_Struct)); + Log(Logs::Detail, Logs::Combat, + "Spell proc %d procing spell %d (%.2f percent chance)", + i, SpellProcs[i].spellID, chance); + auto outapp = new EQApplicationPacket(OP_BeginCast, sizeof(BeginCast_Struct)); BeginCast_Struct* begincast = (BeginCast_Struct*)outapp->pBuffer; begincast->caster_id = GetID(); begincast->spell_id = SpellProcs[i].spellID; @@ -3909,34 +3986,37 @@ void Mob::TrySpellProc(const EQEmu::ItemInstance *inst, const EQEmu::ItemData *w safe_delete(outapp); ExecWeaponProc(nullptr, SpellProcs[i].spellID, on, SpellProcs[i].level_override); CheckNumHitsRemaining(NumHit::OffensiveSpellProcs, 0, - SpellProcs[i].base_spellID); - } else { - Log.Out(Logs::Detail, Logs::Combat, - "Spell proc %d failed to proc %d (%.2f percent chance)", - i, SpellProcs[i].spellID, chance); + SpellProcs[i].base_spellID); + } + else { + Log(Logs::Detail, Logs::Combat, + "Spell proc %d failed to proc %d (%.2f percent chance)", + i, SpellProcs[i].spellID, chance); } } - } else if (rangedattk) { // ranged only - // ranged spell procs (buffs) + } + else if (rangedattk) { // ranged only + // ranged spell procs (buffs) if (RangedProcs[i].spellID != SPELL_UNKNOWN) { float chance = ProcChance * (static_cast(RangedProcs[i].chance) / 100.0f); - if (zone->random.Roll(chance)) { - Log.Out(Logs::Detail, Logs::Combat, - "Ranged proc %d procing spell %d (%.2f percent chance)", - i, RangedProcs[i].spellID, chance); + if (zone->random.Roll(chance)) { + Log(Logs::Detail, Logs::Combat, + "Ranged proc %d procing spell %d (%.2f percent chance)", + i, RangedProcs[i].spellID, chance); ExecWeaponProc(nullptr, RangedProcs[i].spellID, on); CheckNumHitsRemaining(NumHit::OffensiveSpellProcs, 0, - RangedProcs[i].base_spellID); - } else { - Log.Out(Logs::Detail, Logs::Combat, - "Ranged proc %d failed to proc %d (%.2f percent chance)", - i, RangedProcs[i].spellID, chance); + RangedProcs[i].base_spellID); + } + else { + Log(Logs::Detail, Logs::Combat, + "Ranged proc %d failed to proc %d (%.2f percent chance)", + i, RangedProcs[i].spellID, chance); } } } } - if (HasSkillProcs() && hand != EQEmu::inventory::slotRange){ //We check ranged skill procs within the attack functions. + if (HasSkillProcs() && hand != EQEmu::inventory::slotRange) { //We check ranged skill procs within the attack functions. uint16 skillinuse = 28; if (weapon) skillinuse = GetSkillByItemType(weapon->ItemType); @@ -3973,7 +4053,7 @@ void Mob::TryPetCriticalHit(Mob *defender, DamageHitInfo &hit) return; int CritPetChance = - owner->aabonuses.PetCriticalHit + owner->itembonuses.PetCriticalHit + owner->spellbonuses.PetCriticalHit; + owner->aabonuses.PetCriticalHit + owner->itembonuses.PetCriticalHit + owner->spellbonuses.PetCriticalHit; if (CritPetChance || critChance) // For pets use PetCriticalHit for base chance, pets do not innately critical with without it @@ -3994,7 +4074,7 @@ void Mob::TryPetCriticalHit(Mob *defender, DamageHitInfo &hit) CRITICAL_HIT, /* MessageFormat: %1 scores a critical hit! (%2) */ GetCleanName(), /* Message1 */ itoa(hit.damage_done + hit.min_damage) /* Message2 */ - ); + ); } } @@ -4024,13 +4104,13 @@ void Mob::TryCriticalHit(Mob *defender, DamageHitInfo &hit, ExtraAttackOptions * // 1: Try Slay Undead if (defender->GetBodyType() == BT_Undead || defender->GetBodyType() == BT_SummonedUndead || - defender->GetBodyType() == BT_Vampire) { + defender->GetBodyType() == BT_Vampire) { int SlayRateBonus = aabonuses.SlayUndead[0] + itembonuses.SlayUndead[0] + spellbonuses.SlayUndead[0]; if (SlayRateBonus) { float slayChance = static_cast(SlayRateBonus) / 10000.0f; if (zone->random.Roll(slayChance)) { int SlayDmgBonus = std::max( - {aabonuses.SlayUndead[1], itembonuses.SlayUndead[1], spellbonuses.SlayUndead[1]}); + { aabonuses.SlayUndead[1], itembonuses.SlayUndead[1], spellbonuses.SlayUndead[1] }); hit.damage_done = std::max(hit.damage_done, hit.base_damage) + 5; hit.damage_done = (hit.damage_done * SlayDmgBonus) / 100; @@ -4038,14 +4118,14 @@ void Mob::TryCriticalHit(Mob *defender, DamageHitInfo &hit, ExtraAttackOptions * if (GetGender() == 1) { entity_list.FilteredMessageClose_StringID( this, /* Sender */ - false, /* Skip Sender */ + false, /* Skip Sender */ RuleI(Range, CriticalDamage), MT_CritMelee, /* Type: 301 */ FilterMeleeCrits, /* FilterType: 12 */ FEMALE_SLAYUNDEAD, /* MessageFormat: %1's holy blade cleanses her target!(%2) */ GetCleanName(), /* Message1 */ itoa(hit.damage_done + hit.min_damage) /* Message2 */ - ); + ); } /* Males and Neuter */ else { @@ -4058,7 +4138,7 @@ void Mob::TryCriticalHit(Mob *defender, DamageHitInfo &hit, ExtraAttackOptions * MALE_SLAYUNDEAD, /* MessageFormat: %1's holy blade cleanses his target!(%2) */ GetCleanName(), /* Message1 */ itoa(hit.damage_done + hit.min_damage) /* Message2 */ - ); + ); } return; } @@ -4094,7 +4174,7 @@ void Mob::TryCriticalHit(Mob *defender, DamageHitInfo &hit, ExtraAttackOptions * dex_bonus = 255 + ((dex_bonus - 255) / 5); dex_bonus += 45; // chances did not match live without a small boost - // so if we have an innate crit we have a better chance, except for ber throwing + // so if we have an innate crit we have a better chance, except for ber throwing if (!innate_crit || (GetClass() == BERSERKER && hit.skill == EQEmu::skills::SkillThrowing)) dex_bonus = dex_bonus * 3 / 5; @@ -4112,7 +4192,7 @@ void Mob::TryCriticalHit(Mob *defender, DamageHitInfo &hit, ExtraAttackOptions * int og_damage = hit.damage_done; int crit_mod = 170 + GetCritDmgMob(hit.skill); hit.damage_done = hit.damage_done * crit_mod / 100; - Log.Out(Logs::Detail, Logs::Combat, + Log(Logs::Detail, Logs::Combat, "Crit success roll %d dex chance %d og dmg %d crit_mod %d new dmg %d", roll, dex_bonus, og_damage, crit_mod, hit.damage_done); @@ -4138,7 +4218,7 @@ void Mob::TryCriticalHit(Mob *defender, DamageHitInfo &hit, ExtraAttackOptions * DEADLY_STRIKE, /* MessageFormat: %1 scores a Deadly Strike!(%2) */ GetCleanName(), /* Message1 */ itoa(hit.damage_done + hit.min_damage) /* Message2 */ - ); + ); return; } } @@ -4155,7 +4235,7 @@ void Mob::TryCriticalHit(Mob *defender, DamageHitInfo &hit, ExtraAttackOptions * if (IsBerserk() || berserk) { hit.damage_done += og_damage * 119 / 100; - Log.Out(Logs::Detail, Logs::Combat, "Crip damage %d", hit.damage_done); + Log(Logs::Detail, Logs::Combat, "Crip damage %d", hit.damage_done); entity_list.FilteredMessageClose_StringID( this, /* Sender */ @@ -4166,7 +4246,7 @@ void Mob::TryCriticalHit(Mob *defender, DamageHitInfo &hit, ExtraAttackOptions * CRIPPLING_BLOW, /* MessageFormat: %1 lands a Crippling Blow!(%2) */ GetCleanName(), /* Message1 */ itoa(hit.damage_done + hit.min_damage) /* Message2 */ - ); + ); // Crippling blows also have a chance to stun // Kayen: Crippling Blow would cause a chance to interrupt for npcs < 55, with a @@ -4177,18 +4257,18 @@ void Mob::TryCriticalHit(Mob *defender, DamageHitInfo &hit, ExtraAttackOptions * } return; } - + /* Normal Critical hit message */ entity_list.FilteredMessageClose_StringID( this, /* Sender */ false, /* Skip Sender */ - RuleI(Range, CriticalDamage), + RuleI(Range, CriticalDamage), MT_CritMelee, /* Type: 301 */ FilterMeleeCrits, /* FilterType: 12 */ CRITICAL_HIT, /* MessageFormat: %1 scores a critical hit! (%2) */ GetCleanName(), /* Message1 */ itoa(hit.damage_done + hit.min_damage) /* Message2 */ - ); + ); } } } @@ -4199,7 +4279,7 @@ bool Mob::TryFinishingBlow(Mob *defender, int &damage) if (defender && !defender->IsClient() && defender->GetHPRatio() < 10) { uint32 FB_Dmg = - aabonuses.FinishingBlow[1] + spellbonuses.FinishingBlow[1] + itembonuses.FinishingBlow[1]; + aabonuses.FinishingBlow[1] + spellbonuses.FinishingBlow[1] + itembonuses.FinishingBlow[1]; uint32 FB_Level = 0; FB_Level = aabonuses.FinishingBlowLvl[0]; @@ -4210,10 +4290,10 @@ bool Mob::TryFinishingBlow(Mob *defender, int &damage) // modern AA description says rank 1 (500) is 50% chance int ProcChance = - aabonuses.FinishingBlow[0] + spellbonuses.FinishingBlow[0] + spellbonuses.FinishingBlow[0]; + aabonuses.FinishingBlow[0] + spellbonuses.FinishingBlow[0] + spellbonuses.FinishingBlow[0]; if (FB_Level && FB_Dmg && (defender->GetLevel() <= FB_Level) && - (ProcChance >= zone->random.Int(1, 1000))) { + (ProcChance >= zone->random.Int(1, 1000))) { /* Finishing Blow Critical Message */ entity_list.FilteredMessageClose_StringID( @@ -4224,7 +4304,7 @@ bool Mob::TryFinishingBlow(Mob *defender, int &damage) FilterMeleeCrits, /* FilterType: 12 */ FINISHING_BLOW, /* MessageFormat: %1 scores a Finishing Blow!!) */ GetCleanName() /* Message1 */ - ); + ); damage = FB_Dmg; return true; @@ -4235,7 +4315,7 @@ bool Mob::TryFinishingBlow(Mob *defender, int &damage) void Mob::DoRiposte(Mob *defender) { - Log.Out(Logs::Detail, Logs::Combat, "Preforming a riposte"); + Log(Logs::Detail, Logs::Combat, "Preforming a riposte"); if (!defender) return; @@ -4246,10 +4326,10 @@ void Mob::DoRiposte(Mob *defender) // this effect isn't used on live? See no AAs or spells int32 DoubleRipChance = defender->aabonuses.DoubleRiposte + defender->spellbonuses.DoubleRiposte + - defender->itembonuses.DoubleRiposte; + defender->itembonuses.DoubleRiposte; if (DoubleRipChance && zone->random.Roll(DoubleRipChance)) { - Log.Out(Logs::Detail, Logs::Combat, + Log(Logs::Detail, Logs::Combat, "Preforming a double riposted from SE_DoubleRiposte (%d percent chance)", DoubleRipChance); defender->Attack(this, EQEmu::inventory::slotPrimary, true); if (HasDied()) @@ -4257,11 +4337,11 @@ void Mob::DoRiposte(Mob *defender) } DoubleRipChance = defender->aabonuses.GiveDoubleRiposte[0] + defender->spellbonuses.GiveDoubleRiposte[0] + - defender->itembonuses.GiveDoubleRiposte[0]; + defender->itembonuses.GiveDoubleRiposte[0]; // Live AA - Double Riposte if (DoubleRipChance && zone->random.Roll(DoubleRipChance)) { - Log.Out(Logs::Detail, Logs::Combat, + Log(Logs::Detail, Logs::Combat, "Preforming a double riposted from SE_GiveDoubleRiposte base1 == 0 (%d percent chance)", DoubleRipChance); defender->Attack(this, EQEmu::inventory::slotPrimary, true); @@ -4275,7 +4355,7 @@ void Mob::DoRiposte(Mob *defender) DoubleRipChance = defender->aabonuses.GiveDoubleRiposte[1]; if (DoubleRipChance && zone->random.Roll(DoubleRipChance)) { - Log.Out(Logs::Detail, Logs::Combat, "Preforming a return SPECIAL ATTACK (%d percent chance)", + Log(Logs::Detail, Logs::Combat, "Preforming a return SPECIAL ATTACK (%d percent chance)", DoubleRipChance); if (defender->GetClass() == MONK) @@ -4309,7 +4389,7 @@ bool Mob::HasDied() { hp_below = (GetDelayDeath() * -1); - if((GetHP()) <= (hp_below)) + if ((GetHP()) <= (hp_below)) Result = true; return Result; @@ -4318,121 +4398,121 @@ bool Mob::HasDied() { const DamageTable &Mob::GetDamageTable() const { static const DamageTable dmg_table[] = { - {210, 49, 105}, // 1-50 - {245, 35, 80}, // 51 - {245, 35, 80}, // 52 - {245, 35, 80}, // 53 - {245, 35, 80}, // 54 - {245, 35, 80}, // 55 - {265, 28, 70}, // 56 - {265, 28, 70}, // 57 - {265, 28, 70}, // 58 - {265, 28, 70}, // 59 - {285, 23, 65}, // 60 - {285, 23, 65}, // 61 - {285, 23, 65}, // 62 - {290, 21, 60}, // 63 - {290, 21, 60}, // 64 - {295, 19, 55}, // 65 - {295, 19, 55}, // 66 - {300, 19, 55}, // 67 - {300, 19, 55}, // 68 - {300, 19, 55}, // 69 - {305, 19, 55}, // 70 - {305, 19, 55}, // 71 - {310, 17, 50}, // 72 - {310, 17, 50}, // 73 - {310, 17, 50}, // 74 - {315, 17, 50}, // 75 - {315, 17, 50}, // 76 - {325, 17, 45}, // 77 - {325, 17, 45}, // 78 - {325, 17, 45}, // 79 - {335, 17, 45}, // 80 - {335, 17, 45}, // 81 - {345, 17, 45}, // 82 - {345, 17, 45}, // 83 - {345, 17, 45}, // 84 - {355, 17, 45}, // 85 - {355, 17, 45}, // 86 - {365, 17, 45}, // 87 - {365, 17, 45}, // 88 - {365, 17, 45}, // 89 - {375, 17, 45}, // 90 - {375, 17, 45}, // 91 - {380, 17, 45}, // 92 - {380, 17, 45}, // 93 - {380, 17, 45}, // 94 - {385, 17, 45}, // 95 - {385, 17, 45}, // 96 - {390, 17, 45}, // 97 - {390, 17, 45}, // 98 - {390, 17, 45}, // 99 - {395, 17, 45}, // 100 - {395, 17, 45}, // 101 - {400, 17, 45}, // 102 - {400, 17, 45}, // 103 - {400, 17, 45}, // 104 - {405, 17, 45} // 105 + { 210, 49, 105 }, // 1-50 + { 245, 35, 80 }, // 51 + { 245, 35, 80 }, // 52 + { 245, 35, 80 }, // 53 + { 245, 35, 80 }, // 54 + { 245, 35, 80 }, // 55 + { 265, 28, 70 }, // 56 + { 265, 28, 70 }, // 57 + { 265, 28, 70 }, // 58 + { 265, 28, 70 }, // 59 + { 285, 23, 65 }, // 60 + { 285, 23, 65 }, // 61 + { 285, 23, 65 }, // 62 + { 290, 21, 60 }, // 63 + { 290, 21, 60 }, // 64 + { 295, 19, 55 }, // 65 + { 295, 19, 55 }, // 66 + { 300, 19, 55 }, // 67 + { 300, 19, 55 }, // 68 + { 300, 19, 55 }, // 69 + { 305, 19, 55 }, // 70 + { 305, 19, 55 }, // 71 + { 310, 17, 50 }, // 72 + { 310, 17, 50 }, // 73 + { 310, 17, 50 }, // 74 + { 315, 17, 50 }, // 75 + { 315, 17, 50 }, // 76 + { 325, 17, 45 }, // 77 + { 325, 17, 45 }, // 78 + { 325, 17, 45 }, // 79 + { 335, 17, 45 }, // 80 + { 335, 17, 45 }, // 81 + { 345, 17, 45 }, // 82 + { 345, 17, 45 }, // 83 + { 345, 17, 45 }, // 84 + { 355, 17, 45 }, // 85 + { 355, 17, 45 }, // 86 + { 365, 17, 45 }, // 87 + { 365, 17, 45 }, // 88 + { 365, 17, 45 }, // 89 + { 375, 17, 45 }, // 90 + { 375, 17, 45 }, // 91 + { 380, 17, 45 }, // 92 + { 380, 17, 45 }, // 93 + { 380, 17, 45 }, // 94 + { 385, 17, 45 }, // 95 + { 385, 17, 45 }, // 96 + { 390, 17, 45 }, // 97 + { 390, 17, 45 }, // 98 + { 390, 17, 45 }, // 99 + { 395, 17, 45 }, // 100 + { 395, 17, 45 }, // 101 + { 400, 17, 45 }, // 102 + { 400, 17, 45 }, // 103 + { 400, 17, 45 }, // 104 + { 405, 17, 45 } // 105 }; static const DamageTable mnk_table[] = { - {220, 45, 100}, // 1-50 - {245, 35, 80}, // 51 - {245, 35, 80}, // 52 - {245, 35, 80}, // 53 - {245, 35, 80}, // 54 - {245, 35, 80}, // 55 - {285, 23, 65}, // 56 - {285, 23, 65}, // 57 - {285, 23, 65}, // 58 - {285, 23, 65}, // 59 - {290, 21, 60}, // 60 - {290, 21, 60}, // 61 - {290, 21, 60}, // 62 - {295, 19, 55}, // 63 - {295, 19, 55}, // 64 - {300, 17, 50}, // 65 - {300, 17, 50}, // 66 - {310, 17, 50}, // 67 - {310, 17, 50}, // 68 - {310, 17, 50}, // 69 - {320, 17, 50}, // 70 - {320, 17, 50}, // 71 - {325, 15, 45}, // 72 - {325, 15, 45}, // 73 - {325, 15, 45}, // 74 - {330, 15, 45}, // 75 - {330, 15, 45}, // 76 - {335, 15, 40}, // 77 - {335, 15, 40}, // 78 - {335, 15, 40}, // 79 - {345, 15, 40}, // 80 - {345, 15, 40}, // 81 - {355, 15, 40}, // 82 - {355, 15, 40}, // 83 - {355, 15, 40}, // 84 - {365, 15, 40}, // 85 - {365, 15, 40}, // 86 - {375, 15, 40}, // 87 - {375, 15, 40}, // 88 - {375, 15, 40}, // 89 - {385, 15, 40}, // 90 - {385, 15, 40}, // 91 - {390, 15, 40}, // 92 - {390, 15, 40}, // 93 - {390, 15, 40}, // 94 - {395, 15, 40}, // 95 - {395, 15, 40}, // 96 - {400, 15, 40}, // 97 - {400, 15, 40}, // 98 - {400, 15, 40}, // 99 - {405, 15, 40}, // 100 - {405, 15, 40}, // 101 - {410, 15, 40}, // 102 - {410, 15, 40}, // 103 - {410, 15, 40}, // 104 - {415, 15, 40}, // 105 + { 220, 45, 100 }, // 1-50 + { 245, 35, 80 }, // 51 + { 245, 35, 80 }, // 52 + { 245, 35, 80 }, // 53 + { 245, 35, 80 }, // 54 + { 245, 35, 80 }, // 55 + { 285, 23, 65 }, // 56 + { 285, 23, 65 }, // 57 + { 285, 23, 65 }, // 58 + { 285, 23, 65 }, // 59 + { 290, 21, 60 }, // 60 + { 290, 21, 60 }, // 61 + { 290, 21, 60 }, // 62 + { 295, 19, 55 }, // 63 + { 295, 19, 55 }, // 64 + { 300, 17, 50 }, // 65 + { 300, 17, 50 }, // 66 + { 310, 17, 50 }, // 67 + { 310, 17, 50 }, // 68 + { 310, 17, 50 }, // 69 + { 320, 17, 50 }, // 70 + { 320, 17, 50 }, // 71 + { 325, 15, 45 }, // 72 + { 325, 15, 45 }, // 73 + { 325, 15, 45 }, // 74 + { 330, 15, 45 }, // 75 + { 330, 15, 45 }, // 76 + { 335, 15, 40 }, // 77 + { 335, 15, 40 }, // 78 + { 335, 15, 40 }, // 79 + { 345, 15, 40 }, // 80 + { 345, 15, 40 }, // 81 + { 355, 15, 40 }, // 82 + { 355, 15, 40 }, // 83 + { 355, 15, 40 }, // 84 + { 365, 15, 40 }, // 85 + { 365, 15, 40 }, // 86 + { 375, 15, 40 }, // 87 + { 375, 15, 40 }, // 88 + { 375, 15, 40 }, // 89 + { 385, 15, 40 }, // 90 + { 385, 15, 40 }, // 91 + { 390, 15, 40 }, // 92 + { 390, 15, 40 }, // 93 + { 390, 15, 40 }, // 94 + { 395, 15, 40 }, // 95 + { 395, 15, 40 }, // 96 + { 400, 15, 40 }, // 97 + { 400, 15, 40 }, // 98 + { 400, 15, 40 }, // 99 + { 405, 15, 40 }, // 100 + { 405, 15, 40 }, // 101 + { 410, 15, 40 }, // 102 + { 410, 15, 40 }, // 103 + { 410, 15, 40 }, // 104 + { 415, 15, 40 }, // 105 }; bool monk = GetClass() == MONK; @@ -4455,9 +4535,9 @@ void Mob::ApplyDamageTable(DamageHitInfo &hit) // someone may want to add this to custom servers, can remove this if that's the case if (!IsClient() #ifdef BOTS - && !IsBot() + && !IsBot() #endif - ) + ) return; // this was parsed, but we do see the min of 10 and the normal minus factor is 105, so makes sense if (hit.offense < 115) @@ -4480,7 +4560,7 @@ void Mob::ApplyDamageTable(DamageHitInfo &hit) if (IsWarriorClass() && GetLevel() > 54) hit.damage_done++; - Log.Out(Logs::Detail, Logs::Attack, "Damage table applied %d (max %d)", percent, damage_table.max_extra); + Log(Logs::Detail, Logs::Attack, "Damage table applied %d (max %d)", percent, damage_table.max_extra); } void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, uint16 hand, bool IsDefensive) @@ -4488,7 +4568,7 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui if (!on) { SetTarget(nullptr); - Log.Out(Logs::General, Logs::Error, "A null Mob object was passed to Mob::TrySkillProc for evaluation!"); + Log(Logs::General, Logs::Error, "A null Mob object was passed to Mob::TrySkillProc for evaluation!"); return; } @@ -4510,12 +4590,12 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui else chance = GetSkillProcChances(ReuseTime, hand); - if (spellbonuses.LimitToSkill[skill]){ + if (spellbonuses.LimitToSkill[skill]) { - for(int e = 0; e < MAX_SKILL_PROCS; e++){ + for (int e = 0; e < MAX_SKILL_PROCS; e++) { if (CanProc && ((!Success && spellbonuses.SkillProc[e] && IsValidSpell(spellbonuses.SkillProc[e])) - || (Success && spellbonuses.SkillProcSuccess[e] && IsValidSpell(spellbonuses.SkillProcSuccess[e])))) { + || (Success && spellbonuses.SkillProcSuccess[e] && IsValidSpell(spellbonuses.SkillProcSuccess[e])))) { if (Success) base_spell_id = spellbonuses.SkillProcSuccess[e]; @@ -4539,7 +4619,7 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui if (zone->random.Roll(final_chance)) { ExecWeaponProc(nullptr, proc_spell_id, on); CheckNumHitsRemaining(NumHit::OffensiveSpellProcs, 0, - base_spell_id); + base_spell_id); CanProc = false; break; } @@ -4555,12 +4635,12 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui } } - if (itembonuses.LimitToSkill[skill]){ + if (itembonuses.LimitToSkill[skill]) { CanProc = true; - for(int e = 0; e < MAX_SKILL_PROCS; e++){ + for (int e = 0; e < MAX_SKILL_PROCS; e++) { if (CanProc && ((!Success && itembonuses.SkillProc[e] && IsValidSpell(itembonuses.SkillProc[e])) - || (Success && itembonuses.SkillProcSuccess[e] && IsValidSpell(itembonuses.SkillProcSuccess[e])))) { + || (Success && itembonuses.SkillProcSuccess[e] && IsValidSpell(itembonuses.SkillProcSuccess[e])))) { if (Success) base_spell_id = itembonuses.SkillProcSuccess[e]; @@ -4596,7 +4676,7 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui } } - if (IsClient() && aabonuses.LimitToSkill[skill]){ + if (IsClient() && aabonuses.LimitToSkill[skill]) { CanProc = true; uint32 effect_id = 0; @@ -4604,10 +4684,10 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui int32 base2 = 0; uint32 slot = 0; - for(int e = 0; e < MAX_SKILL_PROCS; e++){ + for (int e = 0; e < MAX_SKILL_PROCS; e++) { if (CanProc && ((!Success && aabonuses.SkillProc[e]) - || (Success && aabonuses.SkillProcSuccess[e]))) { + || (Success && aabonuses.SkillProcSuccess[e]))) { int aaid = 0; if (Success) @@ -4618,22 +4698,22 @@ void Mob::TrySkillProc(Mob *on, uint16 skill, uint16 ReuseTime, bool Success, ui proc_spell_id = 0; ProcMod = 0; - for(auto &rank_info : aa_ranks) { + for (auto &rank_info : aa_ranks) { auto ability_rank = zone->GetAlternateAdvancementAbilityAndRank(rank_info.first, rank_info.second.first); auto ability = ability_rank.first; auto rank = ability_rank.second; - if(!ability) { + if (!ability) { continue; } - for(auto &effect : rank->effects) { + for (auto &effect : rank->effects) { effect_id = effect.effect_id; base1 = effect.base1; base2 = effect.base2; slot = effect.slot; - if(effect_id == SE_SkillProc || effect_id == SE_SkillProcSuccess) { + if (effect_id == SE_SkillProc || effect_id == SE_SkillProcSuccess) { proc_spell_id = base1; ProcMod = static_cast(base2); } @@ -4695,22 +4775,22 @@ bool Mob::TryRootFadeByDamage(int buffslot, Mob* attacker) { if (!attacker || !spellbonuses.Root[0] || spellbonuses.Root[1] < 0) return false; - if (IsDetrimentalSpell(spellbonuses.Root[1]) && spellbonuses.Root[1] != buffslot){ + if (IsDetrimentalSpell(spellbonuses.Root[1]) && spellbonuses.Root[1] != buffslot) { int BreakChance = RuleI(Spells, RootBreakFromSpells); - BreakChance -= BreakChance*buffs[spellbonuses.Root[1]].RootBreakChance/100; + BreakChance -= BreakChance*buffs[spellbonuses.Root[1]].RootBreakChance / 100; int level_diff = attacker->GetLevel() - GetLevel(); //Use baseline if level difference <= 1 (ie. If target is (1) level less than you, or equal or greater level) if (level_diff == 2) - BreakChance = (BreakChance * 80) /100; //Decrease by 20%; + BreakChance = (BreakChance * 80) / 100; //Decrease by 20%; else if (level_diff >= 3 && level_diff <= 20) - BreakChance = (BreakChance * 60) /100; //Decrease by 40%; + BreakChance = (BreakChance * 60) / 100; //Decrease by 40%; else if (level_diff > 21) - BreakChance = (BreakChance * 20) /100; //Decrease by 80%; + BreakChance = (BreakChance * 20) / 100; //Decrease by 80%; if (BreakChance < 1) BreakChance = 1; @@ -4719,25 +4799,25 @@ bool Mob::TryRootFadeByDamage(int buffslot, Mob* attacker) { if (!TryFadeEffect(spellbonuses.Root[1])) { BuffFadeBySlot(spellbonuses.Root[1]); - Log.Out(Logs::Detail, Logs::Combat, "Spell broke root! BreakChance percent chance"); + Log(Logs::Detail, Logs::Combat, "Spell broke root! BreakChance percent chance"); return true; } } } - Log.Out(Logs::Detail, Logs::Combat, "Spell did not break root. BreakChance percent chance"); + Log(Logs::Detail, Logs::Combat, "Spell did not break root. BreakChance percent chance"); return false; } int32 Mob::RuneAbsorb(int32 damage, uint16 type) { uint32 buff_max = GetMaxTotalSlots(); - if (type == SE_Rune){ - for(uint32 slot = 0; slot < buff_max; slot++) { - if(slot == spellbonuses.MeleeRune[1] && spellbonuses.MeleeRune[0] && buffs[slot].melee_rune && IsValidSpell(buffs[slot].spellid)){ + if (type == SE_Rune) { + for (uint32 slot = 0; slot < buff_max; slot++) { + if (slot == spellbonuses.MeleeRune[1] && spellbonuses.MeleeRune[0] && buffs[slot].melee_rune && IsValidSpell(buffs[slot].spellid)) { int melee_rune_left = buffs[slot].melee_rune; - if(melee_rune_left > damage) + if (melee_rune_left > damage) { melee_rune_left -= damage; buffs[slot].melee_rune = melee_rune_left; @@ -4746,21 +4826,21 @@ int32 Mob::RuneAbsorb(int32 damage, uint16 type) else { - if(melee_rune_left > 0) + if (melee_rune_left > 0) damage -= melee_rune_left; - if(!TryFadeEffect(slot)) + if (!TryFadeEffect(slot)) BuffFadeBySlot(slot); } } } } - else{ - for(uint32 slot = 0; slot < buff_max; slot++) { - if(slot == spellbonuses.AbsorbMagicAtt[1] && spellbonuses.AbsorbMagicAtt[0] && buffs[slot].magic_rune && IsValidSpell(buffs[slot].spellid)){ + else { + for (uint32 slot = 0; slot < buff_max; slot++) { + if (slot == spellbonuses.AbsorbMagicAtt[1] && spellbonuses.AbsorbMagicAtt[0] && buffs[slot].magic_rune && IsValidSpell(buffs[slot].spellid)) { int magic_rune_left = buffs[slot].magic_rune; - if(magic_rune_left > damage) + if (magic_rune_left > damage) { magic_rune_left -= damage; buffs[slot].magic_rune = magic_rune_left; @@ -4769,10 +4849,10 @@ int32 Mob::RuneAbsorb(int32 damage, uint16 type) else { - if(magic_rune_left > 0) + if (magic_rune_left > 0) damage -= magic_rune_left; - if(!TryFadeEffect(slot)) + if (!TryFadeEffect(slot)) BuffFadeBySlot(slot); } } @@ -4789,7 +4869,7 @@ void Mob::CommonOutgoingHitSuccess(Mob* defender, DamageHitInfo &hit, ExtraAttac // BER weren't parsing the halving if (hit.skill == EQEmu::skills::SkillArchery || - (hit.skill == EQEmu::skills::SkillThrowing && GetClass() != BERSERKER)) + (hit.skill == EQEmu::skills::SkillThrowing && GetClass() != BERSERKER)) hit.damage_done /= 2; if (hit.damage_done < 1) @@ -4801,7 +4881,8 @@ void Mob::CommonOutgoingHitSuccess(Mob* defender, DamageHitInfo &hit, ExtraAttac int headshot = TryHeadShot(defender, hit.skill); if (headshot > 0) { hit.damage_done = headshot; - } else if (GetClass() == RANGER && GetLevel() > 50) { // no double dmg on headshot + } + else if (GetClass() == RANGER && GetLevel() > 50) { // no double dmg on headshot if (defender->IsNPC() && !defender->IsMoving() && !defender->IsRooted()) { hit.damage_done *= 2; Message_StringID(MT_CritMelee, BOW_DOUBLE_DAMAGE); @@ -4819,12 +4900,14 @@ void Mob::CommonOutgoingHitSuccess(Mob* defender, DamageHitInfo &hit, ExtraAttac extra_mincap = GetLevel() * 3 / 2; if (IsSpecialAttack(eSpecialAttacks::ChaoticStab)) { hit.damage_done = extra_mincap; - } else { + } + else { int ass = TryAssassinate(defender, hit.skill); if (ass > 0) hit.damage_done = ass; } - } else if (hit.skill == EQEmu::skills::SkillFrenzy && GetClass() == BERSERKER && GetLevel() > 50) { + } + else if (hit.skill == EQEmu::skills::SkillFrenzy && GetClass() == BERSERKER && GetLevel() > 50) { extra_mincap = 4 * GetLevel() / 5; } @@ -4871,7 +4954,8 @@ void Mob::CommonOutgoingHitSuccess(Mob* defender, DamageHitInfo &hit, ExtraAttac if (spell > spec_mod) spec_mod = spell; } - } else if (IsSpecialAttack(eSpecialAttacks::AERampage)) { + } + else if (IsSpecialAttack(eSpecialAttacks::AERampage)) { int mod = GetSpecialAbilityParam(SPECATK_AREA_RAMPAGE, 2); if (mod > 0) spec_mod = mod; @@ -4887,20 +4971,20 @@ void Mob::CommonOutgoingHitSuccess(Mob* defender, DamageHitInfo &hit, ExtraAttac void Mob::CommonBreakInvisibleFromCombat() { //break invis when you attack - if(invisible) { - Log.Out(Logs::Detail, Logs::Combat, "Removing invisibility due to melee attack."); + if (invisible) { + Log(Logs::Detail, Logs::Combat, "Removing invisibility due to melee attack."); BuffFadeByEffect(SE_Invisibility); BuffFadeByEffect(SE_Invisibility2); invisible = false; } - if(invisible_undead) { - Log.Out(Logs::Detail, Logs::Combat, "Removing invisibility vs. undead due to melee attack."); + if (invisible_undead) { + Log(Logs::Detail, Logs::Combat, "Removing invisibility vs. undead due to melee attack."); BuffFadeByEffect(SE_InvisVsUndead); BuffFadeByEffect(SE_InvisVsUndead2); invisible_undead = false; } - if(invisible_animals){ - Log.Out(Logs::Detail, Logs::Combat, "Removing invisibility vs. animals due to melee attack."); + if (invisible_animals) { + Log(Logs::Detail, Logs::Combat, "Removing invisibility vs. animals due to melee attack."); BuffFadeByEffect(SE_InvisVsAnimals); invisible_animals = false; } @@ -4915,24 +4999,24 @@ void Mob::CommonBreakInvisibleFromCombat() } /* Dev quotes: - * Old formula - * Final delay = (Original Delay / (haste mod *.01f)) + ((Hundred Hands / 100) * Original Delay) - * New formula - * Final delay = (Original Delay / (haste mod *.01f)) + ((Hundred Hands / 1000) * (Original Delay / (haste mod *.01f)) - * Base Delay 20 25 30 37 - * Haste 2.25 2.25 2.25 2.25 - * HHE (old) -17 -17 -17 -17 - * Final Delay 5.488888889 6.861111111 8.233333333 10.15444444 - * - * Base Delay 20 25 30 37 - * Haste 2.25 2.25 2.25 2.25 - * HHE (new) -383 -383 -383 -383 - * Final Delay 5.484444444 6.855555556 8.226666667 10.14622222 - * - * Difference -0.004444444 -0.005555556 -0.006666667 -0.008222222 - * - * These times are in 10th of a second - */ +* Old formula +* Final delay = (Original Delay / (haste mod *.01f)) + ((Hundred Hands / 100) * Original Delay) +* New formula +* Final delay = (Original Delay / (haste mod *.01f)) + ((Hundred Hands / 1000) * (Original Delay / (haste mod *.01f)) +* Base Delay 20 25 30 37 +* Haste 2.25 2.25 2.25 2.25 +* HHE (old) -17 -17 -17 -17 +* Final Delay 5.488888889 6.861111111 8.233333333 10.15444444 +* +* Base Delay 20 25 30 37 +* Haste 2.25 2.25 2.25 2.25 +* HHE (new) -383 -383 -383 -383 +* Final Delay 5.484444444 6.855555556 8.226666667 10.14622222 +* +* Difference -0.004444444 -0.005555556 -0.006666667 -0.008222222 +* +* These times are in 10th of a second +*/ void Mob::SetAttackTimer() { @@ -5011,7 +5095,8 @@ void Client::SetAttackTimer() // Live actually had a bug here where they would return the non-modified attack speed // rather than the cap ... speed = std::max(speed - GetQuiverHaste(speed), RuleI(Combat, QuiverHasteCap)); - } else { + } + else { if (RuleB(Spells, Jun182014HundredHandsRevamp)) speed = static_cast(speed + ((hhe / 1000.0f) * speed)); else @@ -5056,7 +5141,7 @@ void NPC::SetAttackTimer() //special offhand stuff if (i == EQEmu::inventory::slotSecondary) { // SPECATK_QUAD is uncheesable - if(!CanThisClassDualWield() || (HasTwoHanderEquipped() && !GetSpecialAbility(SPECATK_QUAD))) { + if (!CanThisClassDualWield() || (HasTwoHanderEquipped() && !GetSpecialAbility(SPECATK_QUAD))) { attack_dw_timer.Disable(); continue; } @@ -5089,7 +5174,7 @@ void Client::DoAttackRounds(Mob *target, int hand, bool IsFromSpell) if (CheckTripleAttack()) { Attack(target, hand, false, false, IsFromSpell); auto flurrychance = aabonuses.FlurryChance + spellbonuses.FlurryChance + - itembonuses.FlurryChance; + itembonuses.FlurryChance; if (flurrychance && zone->random.Roll(flurrychance)) { Attack(target, hand, false, false, IsFromSpell); if (zone->random.Roll(flurrychance)) @@ -5145,9 +5230,9 @@ void Mob::DoMainHandAttackRounds(Mob *target, ExtraAttackOptions *opts) // A "quad" on live really is just a successful dual wield where both double attack // The mobs that could triple lost the ability to when the triple attack skill was added in Attack(target, EQEmu::inventory::slotPrimary, false, false, false, opts); - if (CanThisClassDoubleAttack() && CheckDoubleAttack()){ + if (CanThisClassDoubleAttack() && CheckDoubleAttack()) { Attack(target, EQEmu::inventory::slotPrimary, false, false, false, opts); - if ((IsPet() || IsTempPet()) && IsPetOwnerClient()){ + if ((IsPet() || IsTempPet()) && IsPetOwnerClient()) { int chance = spellbonuses.PC_Pet_Flurry + itembonuses.PC_Pet_Flurry + aabonuses.PC_Pet_Flurry; if (chance && zone->random.Roll(chance)) Flurry(nullptr); @@ -5160,12 +5245,14 @@ void Mob::DoMainHandAttackRounds(Mob *target, ExtraAttackOptions *opts) int16 n_atk = CastToNPC()->GetNumberOfAttacks(); if (n_atk <= 1) { Attack(target, EQEmu::inventory::slotPrimary, false, false, false, opts); - } else { + } + else { for (int i = 0; i < n_atk; ++i) { Attack(target, EQEmu::inventory::slotPrimary, false, false, false, opts); } } - } else { + } + else { Attack(target, EQEmu::inventory::slotPrimary, false, false, false, opts); } @@ -5174,14 +5261,14 @@ void Mob::DoMainHandAttackRounds(Mob *target, ExtraAttackOptions *opts) // out reasonably and will save us compute resources. int32 RandRoll = zone->random.Int(0, 99); if ((CanThisClassDoubleAttack() || GetSpecialAbility(SPECATK_TRIPLE) || GetSpecialAbility(SPECATK_QUAD)) - // check double attack, this is NOT the same rules that clients use... - && - RandRoll < (GetLevel() + NPCDualAttackModifier)) { + // check double attack, this is NOT the same rules that clients use... + && + RandRoll < (GetLevel() + NPCDualAttackModifier)) { Attack(target, EQEmu::inventory::slotPrimary, false, false, false, opts); // lets see if we can do a triple attack with the main hand // pets are excluded from triple and quads... if ((GetSpecialAbility(SPECATK_TRIPLE) || GetSpecialAbility(SPECATK_QUAD)) && !IsPet() && - RandRoll < (GetLevel() + NPCTripleAttackModifier)) { + RandRoll < (GetLevel() + NPCTripleAttackModifier)) { Attack(target, EQEmu::inventory::slotPrimary, false, false, false, opts); // now lets check the quad attack if (GetSpecialAbility(SPECATK_QUAD) && RandRoll < (GetLevel() + NPCQuadAttackModifier)) { @@ -5198,14 +5285,14 @@ void Mob::DoOffHandAttackRounds(Mob *target, ExtraAttackOptions *opts) // Mobs will only dual wield w/ the flag or have a secondary weapon // For now, SPECATK_QUAD means innate DW when Combat:UseLiveCombatRounds is true if ((GetSpecialAbility(SPECATK_INNATE_DW) || - (RuleB(Combat, UseLiveCombatRounds) && GetSpecialAbility(SPECATK_QUAD))) || - GetEquipment(EQEmu::textures::weaponSecondary) != 0) { + (RuleB(Combat, UseLiveCombatRounds) && GetSpecialAbility(SPECATK_QUAD))) || + GetEquipment(EQEmu::textures::weaponSecondary) != 0) { if (CheckDualWield()) { Attack(target, EQEmu::inventory::slotSecondary, false, false, false, opts); - if (CanThisClassDoubleAttack() && GetLevel() > 35 && CheckDoubleAttack()){ + if (CanThisClassDoubleAttack() && GetLevel() > 35 && CheckDoubleAttack()) { Attack(target, EQEmu::inventory::slotSecondary, false, false, false, opts); - if ((IsPet() || IsTempPet()) && IsPetOwnerClient()){ + if ((IsPet() || IsTempPet()) && IsPetOwnerClient()) { int chance = spellbonuses.PC_Pet_Flurry + itembonuses.PC_Pet_Flurry + aabonuses.PC_Pet_Flurry; if (chance && zone->random.Roll(chance)) Flurry(nullptr); @@ -5213,4 +5300,4 @@ void Mob::DoOffHandAttackRounds(Mob *target, ExtraAttackOptions *opts) } } } -} +} \ No newline at end of file diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index 1f94fb63b..e732d596b 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -660,7 +660,7 @@ void Mob::ApplyAABonuses(const AA::Rank &rank, StatBonuses *newbon) effect == SE_StackingCommand_Overwrite) continue; - Log.Out(Logs::Detail, Logs::AA, "Applying Effect %d from AA %u in slot %d (base1: %d, base2: %d) on %s", + Log(Logs::Detail, Logs::AA, "Applying Effect %d from AA %u in slot %d (base1: %d, base2: %d) on %s", effect, rank.id, slot, base1, base2, GetCleanName()); uint8 focus = IsFocusEffect(0, 0, true, effect); @@ -1498,7 +1498,7 @@ void Mob::ApplyAABonuses(const AA::Rank &rank, StatBonuses *newbon) break; default: - Log.Out(Logs::Detail, Logs::AA, "SPA %d not accounted for in AA %s (%d)", effect, rank.base_ability->name.c_str(), rank.id); + Log(Logs::Detail, Logs::AA, "SPA %d not accounted for in AA %s (%d)", effect, rank.base_ability->name.c_str(), rank.id); break; } diff --git a/zone/bot.cpp b/zone/bot.cpp index dae92f950..5678a62d0 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -1150,7 +1150,7 @@ int32 Bot::acmod() { else return (65 + ((agility - 300) / 21)); #if EQDEBUG >= 11 - Log.Out(Logs::General, Logs::Error, "Error in Bot::acmod(): Agility: %i, Level: %i",agility,level); + Log(Logs::General, Logs::Error, "Error in Bot::acmod(): Agility: %i, Level: %i",agility,level); #endif return 0; } @@ -1890,7 +1890,7 @@ void Bot::BotRangedAttack(Mob* other) { //make sure the attack and ranged timers are up //if the ranged timer is disabled, then they have no ranged weapon and shouldent be attacking anyhow if((attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check())) { - Log.Out(Logs::Detail, Logs::Combat, "Bot Archery attack canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); + Log(Logs::Detail, Logs::Combat, "Bot Archery attack canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); Message(0, "Error: Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); return; } @@ -1908,7 +1908,7 @@ void Bot::BotRangedAttack(Mob* other) { if(!RangeWeapon || !Ammo) return; - Log.Out(Logs::Detail, Logs::Combat, "Shooting %s with bow %s (%d) and arrow %s (%d)", other->GetCleanName(), RangeWeapon->Name, RangeWeapon->ID, Ammo->Name, Ammo->ID); + Log(Logs::Detail, Logs::Combat, "Shooting %s with bow %s (%d) and arrow %s (%d)", other->GetCleanName(), RangeWeapon->Name, RangeWeapon->ID, Ammo->Name, Ammo->ID); if(!IsAttackAllowed(other) || IsCasting() || DivineAura() || IsStunned() || IsMezzed() || (GetAppearance() == eaDead)) return; @@ -1918,21 +1918,21 @@ void Bot::BotRangedAttack(Mob* other) { //break invis when you attack if(invisible) { - Log.Out(Logs::Detail, Logs::Combat, "Removing invisibility due to melee attack."); + Log(Logs::Detail, Logs::Combat, "Removing invisibility due to melee attack."); BuffFadeByEffect(SE_Invisibility); BuffFadeByEffect(SE_Invisibility2); invisible = false; } if(invisible_undead) { - Log.Out(Logs::Detail, Logs::Combat, "Removing invisibility vs. undead due to melee attack."); + Log(Logs::Detail, Logs::Combat, "Removing invisibility vs. undead due to melee attack."); BuffFadeByEffect(SE_InvisVsUndead); BuffFadeByEffect(SE_InvisVsUndead2); invisible_undead = false; } if(invisible_animals) { - Log.Out(Logs::Detail, Logs::Combat, "Removing invisibility vs. animals due to melee attack."); + Log(Logs::Detail, Logs::Combat, "Removing invisibility vs. animals due to melee attack."); BuffFadeByEffect(SE_InvisVsAnimals); invisible_animals = false; } @@ -2138,7 +2138,7 @@ void Bot::AI_Process() { Mob* delete_me = HealRotationTarget(); if (AIHealRotation(HealRotationTarget(), UseHealRotationFastHeals())) { #if (EQDEBUG >= 12) - Log.Out(Logs::General, Logs::Error, "Bot::AI_Process() - Casting succeeded (m: %s, t: %s) : AdvHR(true)", GetCleanName(), ((delete_me) ? (delete_me->GetCleanName()) : ("nullptr"))); + Log(Logs::General, Logs::Error, "Bot::AI_Process() - Casting succeeded (m: %s, t: %s) : AdvHR(true)", GetCleanName(), ((delete_me) ? (delete_me->GetCleanName()) : ("nullptr"))); #endif m_member_of_heal_rotation->SetMemberIsCasting(this); m_member_of_heal_rotation->UpdateTargetHealingStats(HealRotationTarget()); @@ -2146,7 +2146,7 @@ void Bot::AI_Process() { } else { #if (EQDEBUG >= 12) - Log.Out(Logs::General, Logs::Error, "Bot::AI_Process() - Casting failed (m: %s, t: %s) : AdvHR(false)", GetCleanName(), ((delete_me) ? (delete_me->GetCleanName()) : ("nullptr"))); + Log(Logs::General, Logs::Error, "Bot::AI_Process() - Casting failed (m: %s, t: %s) : AdvHR(false)", GetCleanName(), ((delete_me) ? (delete_me->GetCleanName()) : ("nullptr"))); #endif m_member_of_heal_rotation->SetMemberIsCasting(this, false); AdvanceHealRotation(false); @@ -2163,7 +2163,7 @@ void Bot::AI_Process() { SetHasBeenSummoned(false); } else if(!IsRooted()) { if(GetTarget() && GetTarget()->GetHateTop() && GetTarget()->GetHateTop() != this) { - Log.Out(Logs::Detail, Logs::AI, "Returning to location prior to being summoned."); + Log(Logs::Detail, Logs::AI, "Returning to location prior to being summoned."); CalculateNewPosition2(m_PreSummonLocation.x, m_PreSummonLocation.y, m_PreSummonLocation.z, GetBotRunspeed()); SetHeading(CalculateHeadingToTarget(m_PreSummonLocation.x, m_PreSummonLocation.y)); return; @@ -2498,7 +2498,7 @@ void Bot::AI_Process() { if (AI_movement_timer->Check()) { if(!IsRooted()) { - Log.Out(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", GetTarget()->GetCleanName()); + Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", GetTarget()->GetCleanName()); CalculateNewPosition2(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), GetBotRunspeed()); return; } @@ -2746,7 +2746,7 @@ void Bot::PetAIProcess() { else if (botPet->GetTarget() && botPet->GetAIMovementTimer()->Check()) { botPet->SetRunAnimSpeed(0); if(!botPet->IsRooted()) { - Log.Out(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", botPet->GetTarget()->GetCleanName()); + Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", botPet->GetTarget()->GetCleanName()); botPet->CalculateNewPosition2(botPet->GetTarget()->GetX(), botPet->GetTarget()->GetY(), botPet->GetTarget()->GetZ(), botPet->GetOwner()->GetRunspeed()); return; } else { @@ -3813,7 +3813,7 @@ void Bot::Damage(Mob *from, int32 damage, uint16 spell_id, EQEmu::skills::SkillT //handle EVENT_ATTACK. Resets after we have not been attacked for 12 seconds if(attacked_timer.Check()) { - Log.Out(Logs::Detail, Logs::Combat, "Triggering EVENT_ATTACK due to attack by %s", from->GetName()); + Log(Logs::Detail, Logs::Combat, "Triggering EVENT_ATTACK due to attack by %s", from->GetName()); parse->EventNPC(EVENT_ATTACK, this, from, "", 0); } @@ -3821,7 +3821,7 @@ void Bot::Damage(Mob *from, int32 damage, uint16 spell_id, EQEmu::skills::SkillT // if spell is lifetap add hp to the caster if (spell_id != SPELL_UNKNOWN && IsLifetapSpell(spell_id)) { int healed = GetActSpellHealing(spell_id, damage); - Log.Out(Logs::Detail, Logs::Combat, "Applying lifetap heal of %d to %s", healed, GetCleanName()); + Log(Logs::Detail, Logs::Combat, "Applying lifetap heal of %d to %s", healed, GetCleanName()); HealDamage(healed); entity_list.MessageClose(this, true, 300, MT_Spells, "%s beams a smile at %s", GetCleanName(), from->GetCleanName() ); } @@ -3857,13 +3857,13 @@ void Bot::AddToHateList(Mob* other, uint32 hate, int32 damage, bool iYellForHelp bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, bool IsFromSpell, ExtraAttackOptions *opts) { if (!other) { SetTarget(nullptr); - Log.Out(Logs::General, Logs::Error, "A null Mob object was passed to Bot::Attack for evaluation!"); + Log(Logs::General, Logs::Error, "A null Mob object was passed to Bot::Attack for evaluation!"); return false; } if ((GetHP() <= 0) || (GetAppearance() == eaDead)) { SetTarget(nullptr); - Log.Out(Logs::Detail, Logs::Combat, "Attempted to attack %s while unconscious or, otherwise, appearing dead", other->GetCleanName()); + Log(Logs::Detail, Logs::Combat, "Attempted to attack %s while unconscious or, otherwise, appearing dead", other->GetCleanName()); return false; } @@ -3875,20 +3875,20 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b // takes more to compare a call result, load for a call, load a compare to address and compare, and finally // push a value to an address than to just load for a call and push a value to an address. - Log.Out(Logs::Detail, Logs::Combat, "Attacking %s with hand %d %s", other->GetCleanName(), Hand, (FromRiposte ? "(this is a riposte)" : "")); + Log(Logs::Detail, Logs::Combat, "Attacking %s with hand %d %s", other->GetCleanName(), Hand, (FromRiposte ? "(this is a riposte)" : "")); if ((IsCasting() && (GetClass() != BARD) && !IsFromSpell) || (!IsAttackAllowed(other))) { if(this->GetOwnerID()) entity_list.MessageClose(this, 1, 200, 10, "%s says, '%s is not a legal target master.'", this->GetCleanName(), this->GetTarget()->GetCleanName()); if(other) { RemoveFromHateList(other); - Log.Out(Logs::Detail, Logs::Combat, "I am not allowed to attack %s", other->GetCleanName()); + Log(Logs::Detail, Logs::Combat, "I am not allowed to attack %s", other->GetCleanName()); } return false; } if(DivineAura()) {//cant attack while invulnerable - Log.Out(Logs::Detail, Logs::Combat, "Attack canceled, Divine Aura is in effect."); + Log(Logs::Detail, Logs::Combat, "Attack canceled, Divine Aura is in effect."); return false; } @@ -3906,19 +3906,19 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b if(weapon != nullptr) { if (!weapon->IsWeapon()) { - Log.Out(Logs::Detail, Logs::Combat, "Attack canceled, Item %s (%d) is not a weapon.", weapon->GetItem()->Name, weapon->GetID()); + Log(Logs::Detail, Logs::Combat, "Attack canceled, Item %s (%d) is not a weapon.", weapon->GetItem()->Name, weapon->GetID()); return false; } - Log.Out(Logs::Detail, Logs::Combat, "Attacking with weapon: %s (%d)", weapon->GetItem()->Name, weapon->GetID()); + Log(Logs::Detail, Logs::Combat, "Attacking with weapon: %s (%d)", weapon->GetItem()->Name, weapon->GetID()); } else - Log.Out(Logs::Detail, Logs::Combat, "Attacking without a weapon."); + Log(Logs::Detail, Logs::Combat, "Attacking without a weapon."); // calculate attack_skill and skillinuse depending on hand and weapon // also send Packet to near clients DamageHitInfo my_hit; AttackAnimation(my_hit.skill, Hand, weapon); - Log.Out(Logs::Detail, Logs::Combat, "Attacking with %s in slot %d using skill %d", weapon?weapon->GetItem()->Name:"Fist", Hand, my_hit.skill); + Log(Logs::Detail, Logs::Combat, "Attacking with %s in slot %d using skill %d", weapon?weapon->GetItem()->Name:"Fist", Hand, my_hit.skill); // Now figure out damage my_hit.damage_done = 1; @@ -3966,7 +3966,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b } } - Log.Out(Logs::Detail, Logs::Combat, "Damage calculated: base %d min damage %d skill %d", my_hit.base_damage, my_hit.min_damage, my_hit.skill); + Log(Logs::Detail, Logs::Combat, "Damage calculated: base %d min damage %d skill %d", my_hit.base_damage, my_hit.min_damage, my_hit.skill); int hit_chance_bonus = 0; my_hit.offense = offense(my_hit.skill); @@ -3984,7 +3984,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b DoAttack(other, my_hit, opts); - Log.Out(Logs::Detail, Logs::Combat, "Final damage after all reductions: %d", my_hit.damage_done); + Log(Logs::Detail, Logs::Combat, "Final damage after all reductions: %d", my_hit.damage_done); } else { my_hit.damage_done = DMG_INVULNERABLE; } @@ -4595,7 +4595,7 @@ int32 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel return 0; break; default: - Log.Out(Logs::General, Logs::Normal, "CalcFocusEffect: unknown limit spelltype %d", focus_spell.base[i]); + Log(Logs::General, Logs::Normal, "CalcFocusEffect: unknown limit spelltype %d", focus_spell.base[i]); } break; @@ -4809,7 +4809,7 @@ int32 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel break; } default: - Log.Out(Logs::General, Logs::Spells, "CalcFocusEffect: unknown effectid %d", focus_spell.effectid[i]); + Log(Logs::General, Logs::Spells, "CalcFocusEffect: unknown effectid %d", focus_spell.effectid[i]); break; } } @@ -4849,7 +4849,7 @@ float Bot::GetProcChances(float ProcBonus, uint16 hand) { ProcChance += (ProcChance * ProcBonus / 100.0f); } - Log.Out(Logs::Detail, Logs::Combat, "Proc chance %.2f (%.2f from bonuses)", ProcChance, ProcBonus); + Log(Logs::Detail, Logs::Combat, "Proc chance %.2f (%.2f from bonuses)", ProcChance, ProcBonus); return ProcChance; } @@ -4903,13 +4903,13 @@ bool Bot::TryFinishingBlow(Mob *defender, int &damage) int fb_damage = aabonuses.FinishingBlow[1]; int levelreq = aabonuses.FinishingBlowLvl[0]; if (defender->GetLevel() <= levelreq && (chance >= zone->random.Int(1, 1000))) { - Log.Out(Logs::Detail, Logs::Combat, "Landed a finishing blow: levelreq at %d, other level %d", + Log(Logs::Detail, Logs::Combat, "Landed a finishing blow: levelreq at %d, other level %d", levelreq, defender->GetLevel()); entity_list.MessageClose_StringID(this, false, 200, MT_CritMelee, FINISHING_BLOW, GetName()); damage = fb_damage; return true; } else { - Log.Out(Logs::Detail, Logs::Combat, "FAILED a finishing blow: levelreq at %d, other level %d", + Log(Logs::Detail, Logs::Combat, "FAILED a finishing blow: levelreq at %d, other level %d", levelreq, defender->GetLevel()); return false; } @@ -4918,14 +4918,14 @@ bool Bot::TryFinishingBlow(Mob *defender, int &damage) } void Bot::DoRiposte(Mob* defender) { - Log.Out(Logs::Detail, Logs::Combat, "Preforming a riposte"); + Log(Logs::Detail, Logs::Combat, "Preforming a riposte"); if (!defender) return; defender->Attack(this, EQEmu::inventory::slotPrimary, true); int32 DoubleRipChance = (defender->GetAABonuses().GiveDoubleRiposte[0] + defender->GetSpellBonuses().GiveDoubleRiposte[0] + defender->GetItemBonuses().GiveDoubleRiposte[0]); if(DoubleRipChance && (DoubleRipChance >= zone->random.Int(0, 100))) { - Log.Out(Logs::Detail, Logs::Combat, "Preforming a double riposte (%d percent chance)", DoubleRipChance); + Log(Logs::Detail, Logs::Combat, "Preforming a double riposte (%d percent chance)", DoubleRipChance); defender->Attack(this, EQEmu::inventory::slotPrimary, true); } @@ -5548,7 +5548,7 @@ int32 Bot::CalcMaxMana() { break; } default: { - Log.Out(Logs::General, Logs::None, "Invalid Class '%c' in CalcMaxMana", GetCasterClass()); + Log(Logs::General, Logs::None, "Invalid Class '%c' in CalcMaxMana", GetCasterClass()); max_mana = 0; break; } @@ -5976,14 +5976,14 @@ bool Bot::CastSpell(uint16 spell_id, uint16 target_id, EQEmu::CastingSlot slot, uint32* oSpellWillFinish, uint32 item_slot, int16 *resist_adjust, uint32 aa_id) { bool Result = false; if(zone && !zone->IsSpellBlocked(spell_id, glm::vec3(GetPosition()))) { - Log.Out(Logs::Detail, Logs::Spells, "CastSpell called for spell %s (%d) on entity %d, slot %d, time %d, mana %d, from item slot %d", spells[spell_id].name, spell_id, target_id, slot, cast_time, mana_cost, (item_slot==0xFFFFFFFF)?999:item_slot); + Log(Logs::Detail, Logs::Spells, "CastSpell called for spell %s (%d) on entity %d, slot %d, time %d, mana %d, from item slot %d", spells[spell_id].name, spell_id, target_id, slot, cast_time, mana_cost, (item_slot==0xFFFFFFFF)?999:item_slot); if(casting_spell_id == spell_id) ZeroCastingVars(); if(GetClass() != BARD) { if(!IsValidSpell(spell_id) || casting_spell_id || delaytimer || spellend_timer.Enabled() || IsStunned() || IsFeared() || IsMezzed() || (IsSilenced() && !IsDiscipline(spell_id)) || (IsAmnesiad() && IsDiscipline(spell_id))) { - Log.Out(Logs::Detail, Logs::Spells, "Spell casting canceled: not able to cast now. Valid? %d, casting %d, waiting? %d, spellend? %d, stunned? %d, feared? %d, mezed? %d, silenced? %d", IsValidSpell(spell_id), casting_spell_id, delaytimer, spellend_timer.Enabled(), IsStunned(), IsFeared(), IsMezzed(), IsSilenced() ); + Log(Logs::Detail, Logs::Spells, "Spell casting canceled: not able to cast now. Valid? %d, casting %d, waiting? %d, spellend? %d, stunned? %d, feared? %d, mezed? %d, silenced? %d", IsValidSpell(spell_id), casting_spell_id, delaytimer, spellend_timer.Enabled(), IsStunned(), IsFeared(), IsMezzed(), IsSilenced() ); if(IsSilenced() && !IsDiscipline(spell_id)) Message_StringID(13, SILENCED_STRING); @@ -6007,7 +6007,7 @@ bool Bot::CastSpell(uint16 spell_id, uint16 target_id, EQEmu::CastingSlot slot, } if(DivineAura()) { - Log.Out(Logs::Detail, Logs::Spells, "Spell casting canceled: cannot cast while Divine Aura is in effect."); + Log(Logs::Detail, Logs::Spells, "Spell casting canceled: cannot cast while Divine Aura is in effect."); InterruptSpell(173, 0x121, false); return false; } @@ -6017,13 +6017,13 @@ bool Bot::CastSpell(uint16 spell_id, uint16 target_id, EQEmu::CastingSlot slot, InterruptSpell(fizzle_msg, 0x121, spell_id); uint32 use_mana = ((spells[spell_id].mana) / 4); - Log.Out(Logs::Detail, Logs::Spells, "Spell casting canceled: fizzled. %d mana has been consumed", use_mana); + Log(Logs::Detail, Logs::Spells, "Spell casting canceled: fizzled. %d mana has been consumed", use_mana); SetMana(GetMana() - use_mana); return false; } if (HasActiveSong()) { - Log.Out(Logs::Detail, Logs::Spells, "Casting a new spell/song while singing a song. Killing old song %d.", bardsong); + Log(Logs::Detail, Logs::Spells, "Casting a new spell/song while singing a song. Killing old song %d.", bardsong); bardsong = 0; bardsong_target_id = 0; bardsong_slot = EQEmu::CastingSlot::Gem1; @@ -6137,19 +6137,19 @@ bool Bot::IsImmuneToSpell(uint16 spell_id, Mob *caster) { if(caster->IsBot()) { if(spells[spell_id].targettype == ST_Undead) { if((GetBodyType() != BT_SummonedUndead) && (GetBodyType() != BT_Undead) && (GetBodyType() != BT_Vampire)) { - Log.Out(Logs::Detail, Logs::Spells, "Bot's target is not an undead."); + Log(Logs::Detail, Logs::Spells, "Bot's target is not an undead."); return true; } } if(spells[spell_id].targettype == ST_Summoned) { if((GetBodyType() != BT_SummonedUndead) && (GetBodyType() != BT_Summoned) && (GetBodyType() != BT_Summoned2) && (GetBodyType() != BT_Summoned3)) { - Log.Out(Logs::Detail, Logs::Spells, "Bot's target is not a summoned creature."); + Log(Logs::Detail, Logs::Spells, "Bot's target is not a summoned creature."); return true; } } } - Log.Out(Logs::Detail, Logs::Spells, "No bot immunities to spell %d found.", spell_id); + Log(Logs::Detail, Logs::Spells, "No bot immunities to spell %d found.", spell_id); } } @@ -6300,7 +6300,7 @@ bool Bot::DoFinishedSpellSingleTarget(uint16 spell_id, Mob* spellTarget, EQEmu:: if((spelltypeequal || spelltypetargetequal) || spelltypeclassequal || slotequal) { if(((spells[thespell].effectid[0] == 0) && (spells[thespell].base[0] < 0)) && (spellTarget->GetHP() < ((spells[thespell].base[0] * (-1)) + 100))) { - Log.Out(Logs::General, Logs::Spells, "Bot::DoFinishedSpellSingleTarget - GroupBuffing failure"); + Log(Logs::General, Logs::Spells, "Bot::DoFinishedSpellSingleTarget - GroupBuffing failure"); return false; } @@ -7807,7 +7807,7 @@ bool Bot::CheckLoreConflict(const EQEmu::ItemData* item) { bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, float iRange, uint32 iSpellTypes) { if((iSpellTypes&SpellTypes_Detrimental) != 0) { - Log.Out(Logs::General, Logs::Error, "Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); + Log(Logs::General, Logs::Error, "Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); return false; } diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index 9a9c6a8e7..5ba73d068 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -454,7 +454,7 @@ public: if (target_type == BCEnum::TT_Self && (entry_prototype->BCST() != BCEnum::SpT_Stance && entry_prototype->BCST() != BCEnum::SpT_SummonCorpse)) { #ifdef BCSTSPELLDUMP - Log.Out(Logs::General, Logs::Error, "DELETING entry_prototype (primary clause) - name: %s, target_type: %s, BCST: %s", + Log(Logs::General, Logs::Error, "DELETING entry_prototype (primary clause) - name: %s, target_type: %s, BCST: %s", spells[spell_id].name, BCEnum::TargetTypeEnumToString(target_type).c_str(), BCEnum::SpellTypeEnumToString(entry_prototype->BCST()).c_str()); #endif safe_delete(entry_prototype); @@ -462,7 +462,7 @@ public: } if (entry_prototype->BCST() == BCEnum::SpT_Stance && target_type != BCEnum::TT_Self) { #ifdef BCSTSPELLDUMP - Log.Out(Logs::General, Logs::Error, "DELETING entry_prototype (secondary clause) - name: %s, BCST: %s, target_type: %s", + Log(Logs::General, Logs::Error, "DELETING entry_prototype (secondary clause) - name: %s, BCST: %s, target_type: %s", spells[spell_id].name, BCEnum::SpellTypeEnumToString(entry_prototype->BCST()).c_str(), BCEnum::TargetTypeEnumToString(target_type).c_str()); #endif safe_delete(entry_prototype); @@ -1061,7 +1061,7 @@ private: std::string query = "SELECT `short_name`, `long_name` FROM `zone` WHERE '' NOT IN (`short_name`, `long_name`)"; auto results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "load_teleport_zone_names() - Error in zone names query: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "load_teleport_zone_names() - Error in zone names query: %s", results.ErrorMessage().c_str()); return; } @@ -1088,14 +1088,14 @@ private: } static void status_report() { - Log.Out(Logs::General, Logs::Commands, "load_bot_command_spells(): - 'RuleI(Bots, CommandSpellRank)' set to %i.", RuleI(Bots, CommandSpellRank)); + Log(Logs::General, Logs::Commands, "load_bot_command_spells(): - 'RuleI(Bots, CommandSpellRank)' set to %i.", RuleI(Bots, CommandSpellRank)); if (bot_command_spells.empty()) { - Log.Out(Logs::General, Logs::Error, "load_bot_command_spells() - 'bot_command_spells' is empty."); + Log(Logs::General, Logs::Error, "load_bot_command_spells() - 'bot_command_spells' is empty."); return; } for (int i = BCEnum::SpellTypeFirst; i <= BCEnum::SpellTypeLast; ++i) - Log.Out(Logs::General, Logs::Commands, "load_bot_command_spells(): - '%s' returned %u spell entries.", + Log(Logs::General, Logs::Commands, "load_bot_command_spells(): - '%s' returned %u spell entries.", BCEnum::SpellTypeEnumToString(static_cast(i)).c_str(), bot_command_spells[static_cast(i)].size()); } @@ -1428,12 +1428,12 @@ int bot_command_init(void) auto bot_command_settings_iter = bot_command_settings.find(working_bcl_iter.first); if (bot_command_settings_iter == bot_command_settings.end()) { if (working_bcl_iter.second->access == 0) - Log.Out(Logs::General, Logs::Commands, "bot_command_init(): Warning: Bot Command '%s' defaulting to access level 0!", working_bcl_iter.first.c_str()); + Log(Logs::General, Logs::Commands, "bot_command_init(): Warning: Bot Command '%s' defaulting to access level 0!", working_bcl_iter.first.c_str()); continue; } working_bcl_iter.second->access = bot_command_settings_iter->second.first; - Log.Out(Logs::General, Logs::Commands, "bot_command_init(): - Bot Command '%s' set to access level %d.", working_bcl_iter.first.c_str(), bot_command_settings_iter->second.first); + Log(Logs::General, Logs::Commands, "bot_command_init(): - Bot Command '%s' set to access level %d.", working_bcl_iter.first.c_str(), bot_command_settings_iter->second.first); if (bot_command_settings_iter->second.second.empty()) continue; @@ -1441,14 +1441,14 @@ int bot_command_init(void) if (alias_iter.empty()) continue; if (bot_command_list.find(alias_iter) != bot_command_list.end()) { - Log.Out(Logs::General, Logs::Commands, "bot_command_init(): Warning: Alias '%s' already exists as a bot command - skipping!", alias_iter.c_str()); + Log(Logs::General, Logs::Commands, "bot_command_init(): Warning: Alias '%s' already exists as a bot command - skipping!", alias_iter.c_str()); continue; } bot_command_list[alias_iter] = working_bcl_iter.second; bot_command_aliases[alias_iter] = working_bcl_iter.first; - Log.Out(Logs::General, Logs::Commands, "bot_command_init(): - Alias '%s' added to bot command '%s'.", alias_iter.c_str(), bot_command_aliases[alias_iter].c_str()); + Log(Logs::General, Logs::Commands, "bot_command_init(): - Alias '%s' added to bot command '%s'.", alias_iter.c_str(), bot_command_aliases[alias_iter].c_str()); } } @@ -1494,21 +1494,21 @@ void bot_command_deinit(void) int bot_command_add(std::string bot_command_name, const char *desc, int access, BotCmdFuncPtr function) { if (bot_command_name.empty()) { - Log.Out(Logs::General, Logs::Error, "bot_command_add() - Bot command added with empty name string - check bot_command.cpp."); + Log(Logs::General, Logs::Error, "bot_command_add() - Bot command added with empty name string - check bot_command.cpp."); return -1; } if (function == nullptr) { - Log.Out(Logs::General, Logs::Error, "bot_command_add() - Bot command '%s' added without a valid function pointer - check bot_command.cpp.", bot_command_name.c_str()); + Log(Logs::General, Logs::Error, "bot_command_add() - Bot command '%s' added without a valid function pointer - check bot_command.cpp.", bot_command_name.c_str()); return -1; } if (bot_command_list.count(bot_command_name) != 0) { - Log.Out(Logs::General, Logs::Error, "bot_command_add() - Bot command '%s' is a duplicate bot command name - check bot_command.cpp.", bot_command_name.c_str()); + Log(Logs::General, Logs::Error, "bot_command_add() - Bot command '%s' is a duplicate bot command name - check bot_command.cpp.", bot_command_name.c_str()); return -1; } for (auto iter : bot_command_list) { if (iter.second->function != function) continue; - Log.Out(Logs::General, Logs::Error, "bot_command_add() - Bot command '%s' equates to an alias of '%s' - check bot_command.cpp.", bot_command_name.c_str(), iter.first.c_str()); + Log(Logs::General, Logs::Error, "bot_command_add() - Bot command '%s' equates to an alias of '%s' - check bot_command.cpp.", bot_command_name.c_str(), iter.first.c_str()); return -1; } @@ -1563,11 +1563,11 @@ int bot_command_real_dispatch(Client *c, const char *message) } if(cur->access >= COMMANDS_LOGGING_MIN_STATUS) { - Log.Out(Logs::General, Logs::Commands, "%s (%s) used bot command: %s (target=%s)", c->GetName(), c->AccountName(), message, c->GetTarget()?c->GetTarget()->GetName():"NONE"); + Log(Logs::General, Logs::Commands, "%s (%s) used bot command: %s (target=%s)", c->GetName(), c->AccountName(), message, c->GetTarget()?c->GetTarget()->GetName():"NONE"); } if(cur->function == nullptr) { - Log.Out(Logs::General, Logs::Error, "Bot command '%s' has a null function\n", cstr.c_str()); + Log(Logs::General, Logs::Error, "Bot command '%s' has a null function\n", cstr.c_str()); return(-1); } else { //dispatch C++ bot command @@ -3500,7 +3500,7 @@ void bot_command_pick_lock(Client *c, const Seperator *sep) float curelev = (diff.z * diff.z); #if (EQDEBUG >= 11) if (curdist <= 130 && curelev <= 65 && curelev >= 25) // 2D limit is '130' (x^2 + y^2), 1D theoretically should be '65' (z^2) - Log.Out(Logs::Detail, Logs::Doors, "bot_command_pick_lock(): DoorID: %i - Elevation difference failure within theoretical limit (%f <= 65.0)", door_iter->GetDoorID(), curelev); + Log(Logs::Detail, Logs::Doors, "bot_command_pick_lock(): DoorID: %i - Elevation difference failure within theoretical limit (%f <= 65.0)", door_iter->GetDoorID(), curelev); #endif if (curelev >= 25 || curdist > 130) // changed curelev from '10' to '25' - requiring diff.z to be less than '5' continue; @@ -4188,7 +4188,7 @@ void bot_subcommand_bot_clone(Client *c, const Seperator *sep) } if (!my_bot->GetBotID()) { c->Message(m_unknown, "An unknown error has occured - BotName: %s, BotID: %u", my_bot->GetCleanName(), my_bot->GetBotID()); - Log.Out(Logs::General, Logs::Commands, "bot_command_clone(): - Error: Active bot reported invalid ID (BotName: %s, BotID: %u, OwnerName: %s, OwnerID: %u, AcctName: %s, AcctID: %u)", + Log(Logs::General, Logs::Commands, "bot_command_clone(): - Error: Active bot reported invalid ID (BotName: %s, BotID: %u, OwnerName: %s, OwnerID: %u, AcctName: %s, AcctID: %u)", my_bot->GetCleanName(), my_bot->GetBotID(), c->GetCleanName(), c->CharacterID(), c->AccountName(), c->AccountID()); return; } diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index b45ef6a3b..033984a93 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -49,11 +49,11 @@ bool BotDatabase::Connect(const char* host, const char* user, const char* passwd uint32 errnum = 0; char errbuf[MYSQL_ERRMSG_SIZE]; if (!Open(host, user, passwd, database, port, &errnum, errbuf)) { - Log.Out(Logs::General, Logs::Error, "Failed to connect to bot database: Error: %s", errbuf); + Log(Logs::General, Logs::Error, "Failed to connect to bot database: Error: %s", errbuf); return false; } else { - Log.Out(Logs::General, Logs::Status, "Using bot database '%s' at %s:%d", database, host, port); + Log(Logs::General, Logs::Status, "Using bot database '%s' at %s:%d", database, host, port); return true; } } @@ -1143,7 +1143,7 @@ bool BotDatabase::LoadItems(const uint32 bot_id, EQEmu::InventoryProfile& invent (uint32)atoul(row[14]) ); if (!item_inst) { - Log.Out(Logs::General, Logs::Error, "Warning: bot_id '%i' has an invalid item_id '%i' in inventory slot '%i'", bot_id, item_id, slot_id); + Log(Logs::General, Logs::Error, "Warning: bot_id '%i' has an invalid item_id '%i' in inventory slot '%i'", bot_id, item_id, slot_id); continue; } @@ -1196,7 +1196,7 @@ bool BotDatabase::LoadItems(const uint32 bot_id, EQEmu::InventoryProfile& invent item_inst->SetOrnamentHeroModel((uint32)atoul(row[8])); if (inventory_inst.PutItem(slot_id, *item_inst) == INVALID_INDEX) - Log.Out(Logs::General, Logs::Error, "Warning: Invalid slot_id for item in inventory: bot_id = '%i', item_id = '%i', slot_id = '%i'", bot_id, item_id, slot_id); + Log(Logs::General, Logs::Error, "Warning: Invalid slot_id for item in inventory: bot_id = '%i', item_id = '%i', slot_id = '%i'", bot_id, item_id, slot_id); safe_delete(item_inst); } diff --git a/zone/botspellsai.cpp b/zone/botspellsai.cpp index 9967d2368..154574453 100644 --- a/zone/botspellsai.cpp +++ b/zone/botspellsai.cpp @@ -1137,7 +1137,7 @@ bool Bot::AI_PursueCastCheck() { AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. - Log.Out(Logs::Detail, Logs::AI, "Bot Engaged (pursuing) autocast check triggered. Trying to cast offensive spells."); + Log(Logs::Detail, Logs::AI, "Bot Engaged (pursuing) autocast check triggered. Trying to cast offensive spells."); if(!AICastSpell(GetTarget(), 100, SpellType_Snare)) { if(!AICastSpell(GetTarget(), 100, SpellType_Lifetap)) { @@ -1165,7 +1165,7 @@ bool Bot::AI_IdleCastCheck() { if (AIautocastspell_timer->Check(false)) { #if BotAI_DEBUG_Spells >= 25 - Log.Out(Logs::Detail, Logs::AI, "Bot Non-Engaged autocast check triggered: %s", this->GetCleanName()); + Log(Logs::Detail, Logs::AI, "Bot Non-Engaged autocast check triggered: %s", this->GetCleanName()); #endif AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. @@ -1313,7 +1313,7 @@ bool Bot::AI_EngagedCastCheck() { BotStanceType botStance = GetBotStance(); bool mayGetAggro = HasOrMayGetAggro(); - Log.Out(Logs::Detail, Logs::AI, "Engaged autocast check triggered (BOTS). Trying to cast healing spells then maybe offensive spells."); + Log(Logs::Detail, Logs::AI, "Engaged autocast check triggered (BOTS). Trying to cast healing spells then maybe offensive spells."); if(botClass == CLERIC) { if(!AICastSpell(GetTarget(), GetChanceToCastBySpellType(SpellType_Escape), SpellType_Escape)) { @@ -1563,11 +1563,11 @@ bool Bot::AIHealRotation(Mob* tar, bool useFastHeals) { } #if BotAI_DEBUG_Spells >= 10 - Log.Out(Logs::Detail, Logs::AI, "Bot::AIHealRotation: heal spellid = %u, fastheals = %c, casterlevel = %u", + Log(Logs::Detail, Logs::AI, "Bot::AIHealRotation: heal spellid = %u, fastheals = %c, casterlevel = %u", botSpell.SpellId, ((useFastHeals) ? ('T') : ('F')), GetLevel()); #endif #if BotAI_DEBUG_Spells >= 25 - Log.Out(Logs::Detail, Logs::AI, "Bot::AIHealRotation: target = %s, current_time = %u, donthealmebefore = %u", tar->GetCleanName(), Timer::GetCurrentTime(), tar->DontHealMeBefore()); + Log(Logs::Detail, Logs::AI, "Bot::AIHealRotation: target = %s, current_time = %u, donthealmebefore = %u", tar->GetCleanName(), Timer::GetCurrentTime(), tar->DontHealMeBefore()); #endif // If there is still no spell id, then there isn't going to be one so we are done diff --git a/zone/client.cpp b/zone/client.cpp index 0bfb826b0..615acdef4 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -135,7 +135,7 @@ Client::Client(EQStreamInterface* ieqs) forget_timer(0), autosave_timer(RuleI(Character, AutosaveIntervalS) * 1000), #ifdef REVERSE_AGGRO - scanarea_timer(RuleI(Aggro, ClientAggroCheckInterval) * 1000), + client_scan_npc_aggro_timer(RuleI(Aggro, ClientAggroCheckInterval) * 1000), #endif tribute_timer(Tribute_duration), proximity_timer(ClientProximity_interval), @@ -153,14 +153,14 @@ Client::Client(EQStreamInterface* ieqs) anon_toggle_timer(250), afk_toggle_timer(250), helm_toggle_timer(250), - light_update_timer(600), aggro_meter_timer(AGGRO_METER_UPDATE_MS), m_Proximity(FLT_MAX, FLT_MAX, FLT_MAX), //arbitrary large number m_ZoneSummonLocation(-2.0f,-2.0f,-2.0f), m_AutoAttackPosition(0.0f, 0.0f, 0.0f, 0.0f), m_AutoAttackTargetLocation(0.0f, 0.0f, 0.0f), last_region_type(RegionTypeUnsupported), - m_dirtyautohaters(false) + m_dirtyautohaters(false), + npc_close_scan_timer(6000) { for(int cf=0; cf < _FilterCount; cf++) ClientFilters[cf] = FilterShow; @@ -176,6 +176,7 @@ Client::Client(EQStreamInterface* ieqs) client_state = CLIENT_CONNECTING; Trader=false; Buyer = false; + Haste = 0; CustomerID = 0; TraderID = 0; TrackingID = 0; @@ -349,7 +350,7 @@ Client::~Client() { ToggleBuyerMode(false); if(conn_state != ClientConnectFinished) { - Log.Out(Logs::General, Logs::None, "Client '%s' was destroyed before reaching the connected state:", GetName()); + Log(Logs::General, Logs::None, "Client '%s' was destroyed before reaching the connected state:", GetName()); ReportConnectingState(); } @@ -358,6 +359,8 @@ Client::~Client() { m_tradeskill_object = nullptr; } + close_npcs.clear(); + if(IsDueling() && GetDuelTarget() != 0) { Entity* entity = entity_list.GetID(GetDuelTarget()); if(entity != nullptr && entity->IsClient()) { @@ -508,31 +511,31 @@ void Client::SendLogoutPackets() { void Client::ReportConnectingState() { switch(conn_state) { case NoPacketsReceived: //havent gotten anything - Log.Out(Logs::General, Logs::None, "Client has not sent us an initial zone entry packet."); + Log(Logs::General, Logs::None, "Client has not sent us an initial zone entry packet."); break; case ReceivedZoneEntry: //got the first packet, loading up PP - Log.Out(Logs::General, Logs::None, "Client sent initial zone packet, but we never got their player info from the database."); + Log(Logs::General, Logs::None, "Client sent initial zone packet, but we never got their player info from the database."); break; case PlayerProfileLoaded: //our DB work is done, sending it - Log.Out(Logs::General, Logs::None, "We were sending the player profile, tributes, tasks, spawns, time and weather, but never finished."); + Log(Logs::General, Logs::None, "We were sending the player profile, tributes, tasks, spawns, time and weather, but never finished."); break; case ZoneInfoSent: //includes PP, tributes, tasks, spawns, time and weather - Log.Out(Logs::General, Logs::None, "We successfully sent player info and spawns, waiting for client to request new zone."); + Log(Logs::General, Logs::None, "We successfully sent player info and spawns, waiting for client to request new zone."); break; case NewZoneRequested: //received and sent new zone request - Log.Out(Logs::General, Logs::None, "We received client's new zone request, waiting for client spawn request."); + Log(Logs::General, Logs::None, "We received client's new zone request, waiting for client spawn request."); break; case ClientSpawnRequested: //client sent ReqClientSpawn - Log.Out(Logs::General, Logs::None, "We received the client spawn request, and were sending objects, doors, zone points and some other stuff, but never finished."); + Log(Logs::General, Logs::None, "We received the client spawn request, and were sending objects, doors, zone points and some other stuff, but never finished."); break; case ZoneContentsSent: //objects, doors, zone points - Log.Out(Logs::General, Logs::None, "The rest of the zone contents were successfully sent, waiting for client ready notification."); + Log(Logs::General, Logs::None, "The rest of the zone contents were successfully sent, waiting for client ready notification."); break; case ClientReadyReceived: //client told us its ready, send them a bunch of crap like guild MOTD, etc - Log.Out(Logs::General, Logs::None, "We received client ready notification, but never finished Client::CompleteConnect"); + Log(Logs::General, Logs::None, "We received client ready notification, but never finished Client::CompleteConnect"); break; case ClientConnectFinished: //client finally moved to finished state, were done here - Log.Out(Logs::General, Logs::None, "Client is successfully connected."); + Log(Logs::General, Logs::None, "Client is successfully connected."); break; }; } @@ -733,7 +736,7 @@ bool Client::SendAllPackets() { if(eqs) eqs->FastQueuePacket((EQApplicationPacket **)&cp->app, cp->ack_req); iterator.RemoveCurrent(); - Log.Out(Logs::Moderate, Logs::Client_Server_Packet, "Transmitting a packet"); + Log(Logs::Moderate, Logs::Client_Server_Packet, "Transmitting a packet"); } return true; } @@ -781,7 +784,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s char message[4096]; strn0cpy(message, orig_message, sizeof(message)); - Log.Out(Logs::Detail, Logs::Zone_Server, "Client::ChannelMessageReceived() Channel:%i message:'%s'", chan_num, message); + Log(Logs::Detail, Logs::Zone_Server, "Client::ChannelMessageReceived() Channel:%i message:'%s'", chan_num, message); if (targetname == nullptr) { targetname = (!GetTarget()) ? "" : GetTarget()->GetName(); @@ -1216,7 +1219,7 @@ void Client::ChannelMessageSend(const char* from, const char* to, uint8 chan_num QueuePacket(&app); if ((chan_num == 2) && (ListenerSkill < 100)) { // group message in unmastered language, check for skill up - if ((m_pp.languages[language] <= lang_skill) && (from != this->GetName())) + if (m_pp.languages[language] <= lang_skill) CheckLanguageSkillIncrease(language, lang_skill); } } @@ -1607,7 +1610,7 @@ void Client::UpdateAdmin(bool iFromDB) { if(m_pp.gm) { - Log.Out(Logs::Moderate, Logs::Zone_Server, "%s - %s is a GM", __FUNCTION__ , GetName()); + Log(Logs::Moderate, Logs::Zone_Server, "%s - %s is a GM", __FUNCTION__ , GetName()); // no need for this, having it set in pp you already start as gm // and it's also set in your spawn packet so other people see it too // SendAppearancePacket(AT_GM, 1, false); @@ -2015,7 +2018,7 @@ void Client::ReadBook(BookRequest_Struct *book) { if (booktxt2[0] != '\0') { #if EQDEBUG >= 6 - Log.Out(Logs::General, Logs::Normal, "Client::ReadBook() textfile:%s Text:%s", txtfile, booktxt2.c_str()); + Log(Logs::General, Logs::Normal, "Client::ReadBook() textfile:%s Text:%s", txtfile, booktxt2.c_str()); #endif auto outapp = new EQApplicationPacket(OP_ReadBook, length + sizeof(BookText_Struct)); @@ -2235,7 +2238,7 @@ void Client::AddMoneyToPP(uint64 copper, bool updateclient){ SaveCurrency(); - Log.Out(Logs::General, Logs::None, "Client::AddMoneyToPP() %s should have: plat:%i gold:%i silver:%i copper:%i", GetName(), m_pp.platinum, m_pp.gold, m_pp.silver, m_pp.copper); + Log(Logs::General, Logs::None, "Client::AddMoneyToPP() %s should have: plat:%i gold:%i silver:%i copper:%i", GetName(), m_pp.platinum, m_pp.gold, m_pp.silver, m_pp.copper); } void Client::EVENT_ITEM_ScriptStopReturn(){ @@ -2275,7 +2278,7 @@ void Client::AddMoneyToPP(uint32 copper, uint32 silver, uint32 gold, uint32 plat SaveCurrency(); #if (EQDEBUG>=5) - Log.Out(Logs::General, Logs::None, "Client::AddMoneyToPP() %s should have: plat:%i gold:%i silver:%i copper:%i", + Log(Logs::General, Logs::None, "Client::AddMoneyToPP() %s should have: plat:%i gold:%i silver:%i copper:%i", GetName(), m_pp.platinum, m_pp.gold, m_pp.silver, m_pp.copper); #endif } @@ -2365,13 +2368,13 @@ bool Client::CheckIncreaseSkill(EQEmu::skills::SkillType skillid, Mob *against_w if(zone->random.Real(0, 99) < Chance) { SetSkill(skillid, GetRawSkill(skillid) + 1); - Log.Out(Logs::Detail, Logs::Skills, "Skill %d at value %d successfully gain with %d%%chance (mod %d)", skillid, skillval, Chance, chancemodi); + Log(Logs::Detail, Logs::Skills, "Skill %d at value %d successfully gain with %d%%chance (mod %d)", skillid, skillval, Chance, chancemodi); return true; } else { - Log.Out(Logs::Detail, Logs::Skills, "Skill %d at value %d failed to gain with %d%%chance (mod %d)", skillid, skillval, Chance, chancemodi); + Log(Logs::Detail, Logs::Skills, "Skill %d at value %d failed to gain with %d%%chance (mod %d)", skillid, skillval, Chance, chancemodi); } } else { - Log.Out(Logs::Detail, Logs::Skills, "Skill %d at value %d cannot increase due to maxmum %d", skillid, skillval, maxskill); + Log(Logs::Detail, Logs::Skills, "Skill %d at value %d cannot increase due to maxmum %d", skillid, skillval, maxskill); } return false; } @@ -2392,10 +2395,10 @@ void Client::CheckLanguageSkillIncrease(uint8 langid, uint8 TeacherSkill) { if(zone->random.Real(0,100) < Chance) { // if they make the roll IncreaseLanguageSkill(langid); // increase the language skill by 1 - Log.Out(Logs::Detail, Logs::Skills, "Language %d at value %d successfully gain with %.4f%%chance", langid, LangSkill, Chance); + Log(Logs::Detail, Logs::Skills, "Language %d at value %d successfully gain with %.4f%%chance", langid, LangSkill, Chance); } else - Log.Out(Logs::Detail, Logs::Skills, "Language %d at value %d failed to gain with %.4f%%chance", langid, LangSkill, Chance); + Log(Logs::Detail, Logs::Skills, "Language %d at value %d failed to gain with %.4f%%chance", langid, LangSkill, Chance); } } @@ -2504,7 +2507,7 @@ uint16 Client::GetMaxSkillAfterSpecializationRules(EQEmu::skills::SkillType skil Save(); - Log.Out(Logs::General, Logs::Normal, "Reset %s's caster specialization skills to 1. " + Log(Logs::General, Logs::Normal, "Reset %s's caster specialization skills to 1. " "Too many specializations skills were above 50.", GetCleanName()); } @@ -4702,14 +4705,14 @@ void Client::HandleLDoNOpen(NPC *target) { if(target->GetClass() != LDON_TREASURE) { - Log.Out(Logs::General, Logs::None, "%s tried to open %s but %s was not a treasure chest.", + Log(Logs::General, Logs::None, "%s tried to open %s but %s was not a treasure chest.", GetName(), target->GetName(), target->GetName()); return; } if(DistanceSquaredNoZ(m_Position, target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse)) { - Log.Out(Logs::General, Logs::None, "%s tried to open %s but %s was out of range", + Log(Logs::General, Logs::None, "%s tried to open %s but %s was out of range", GetName(), target->GetName(), target->GetName()); Message(13, "Treasure chest out of range."); return; @@ -6346,12 +6349,12 @@ void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_overrid PetRecord record; if(!database.GetPetEntry(spells[spell_id].teleport_zone, &record)) { - Log.Out(Logs::General, Logs::Error, "Unknown doppelganger spell id: %d, check pets table", spell_id); + Log(Logs::General, Logs::Error, "Unknown doppelganger spell id: %d, check pets table", spell_id); Message(13, "Unable to find data for pet %s", spells[spell_id].teleport_zone); return; } - AA_SwarmPet pet; + SwarmPet_Struct pet; pet.count = pet_count; pet.duration = pet_duration; pet.npc_id = record.npc_type; @@ -6360,7 +6363,7 @@ void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_overrid const NPCType *npc_type = database.LoadNPCTypesData(pet.npc_id); if(npc_type == nullptr) { - Log.Out(Logs::General, Logs::Error, "Unknown npc type for doppelganger spell id: %d", spell_id); + Log(Logs::General, Logs::Error, "Unknown npc type for doppelganger spell id: %d", spell_id); Message(0,"Unable to find pet!"); return; } @@ -6426,33 +6429,35 @@ void Client::Doppelganger(uint16 spell_id, Mob *target, const char *name_overrid memcpy(npc_dup, made_npc, sizeof(NPCType)); } - NPC* npca = new NPC( + NPC* swarm_pet_npc = new NPC( (npc_dup!=nullptr)?npc_dup:npc_type, //make sure we give the NPC the correct data pointer 0, GetPosition() + glm::vec4(swarmPetLocations[summon_count], 0.0f, 0.0f), FlyMode3); - if(!npca->GetSwarmInfo()){ - auto nSI = new AA_SwarmPetInfo; - npca->SetSwarmInfo(nSI); - npca->GetSwarmInfo()->duration = new Timer(pet_duration*1000); + if(!swarm_pet_npc->GetSwarmInfo()){ + auto nSI = new SwarmPet; + swarm_pet_npc->SetSwarmInfo(nSI); + swarm_pet_npc->GetSwarmInfo()->duration = new Timer(pet_duration*1000); } else{ - npca->GetSwarmInfo()->duration->Start(pet_duration*1000); + swarm_pet_npc->GetSwarmInfo()->duration->Start(pet_duration*1000); } - npca->GetSwarmInfo()->owner_id = GetID(); + swarm_pet_npc->StartSwarmTimer(pet_duration * 1000); + + swarm_pet_npc->GetSwarmInfo()->owner_id = GetID(); // Give the pets alittle more agro than the caster and then agro them on the target - target->AddToHateList(npca, (target->GetHateAmount(this) + 100), (target->GetDamageAmount(this) + 100)); - npca->AddToHateList(target, 1000, 1000); - npca->GetSwarmInfo()->target = target->GetID(); + target->AddToHateList(swarm_pet_npc, (target->GetHateAmount(this) + 100), (target->GetDamageAmount(this) + 100)); + swarm_pet_npc->AddToHateList(target, 1000, 1000); + swarm_pet_npc->GetSwarmInfo()->target = target->GetID(); //we allocated a new NPC type object, give the NPC ownership of that memory if(npc_dup != nullptr) - npca->GiveNPCTypeData(npc_dup); + swarm_pet_npc->GiveNPCTypeData(npc_dup); - entity_list.AddNPC(npca); + entity_list.AddNPC(swarm_pet_npc); summon_count--; } } @@ -7628,7 +7633,7 @@ void Client::SendMercPersonalInfo() stancecount += zone->merc_stance_list[GetMercInfo().MercTemplateID].size(); if(stancecount > MAX_MERC_STANCES || mercCount > MAX_MERC || mercTypeCount > MAX_MERC_GRADES) { - Log.Out(Logs::General, Logs::Mercenaries, "SendMercPersonalInfo canceled: (%i) (%i) (%i) for %s", stancecount, mercCount, mercTypeCount, GetName()); + Log(Logs::General, Logs::Mercenaries, "SendMercPersonalInfo canceled: (%i) (%i) (%i) for %s", stancecount, mercCount, mercTypeCount, GetName()); SendMercMerchantResponsePacket(0); return; } @@ -7724,13 +7729,13 @@ void Client::SendMercPersonalInfo() return; } } - Log.Out(Logs::General, Logs::Mercenaries, "SendMercPersonalInfo Send Successful for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SendMercPersonalInfo Send Successful for %s.", GetName()); SendMercMerchantResponsePacket(0); } else { - Log.Out(Logs::General, Logs::Mercenaries, "SendMercPersonalInfo Send Failed Due to no MercData (%i) for %s", GetMercInfo().MercTemplateID, GetName()); + Log(Logs::General, Logs::Mercenaries, "SendMercPersonalInfo Send Failed Due to no MercData (%i) for %s", GetMercInfo().MercTemplateID, GetName()); } } @@ -8498,7 +8503,7 @@ void Client::Consume(const EQEmu::ItemData *item, uint8 type, int16 slot, bool a entity_list.MessageClose_StringID(this, true, 50, 0, EATING_MESSAGE, GetName(), item->Name); #if EQDEBUG >= 5 - Log.Out(Logs::General, Logs::None, "Eating from slot:%i", (int)slot); + Log(Logs::General, Logs::None, "Eating from slot:%i", (int)slot); #endif } else @@ -8515,7 +8520,7 @@ void Client::Consume(const EQEmu::ItemData *item, uint8 type, int16 slot, bool a entity_list.MessageClose_StringID(this, true, 50, 0, DRINKING_MESSAGE, GetName(), item->Name); #if EQDEBUG >= 5 - Log.Out(Logs::General, Logs::None, "Drinking from slot:%i", (int)slot); + Log(Logs::General, Logs::None, "Drinking from slot:%i", (int)slot); #endif } } @@ -8653,9 +8658,6 @@ void Client::QuestReward(Mob* target, uint32 copper, uint32 silver, uint32 gold, } void Client::SendHPUpdateMarquee(){ - if (!RuleB(Character, MarqueeHPUpdates)) - return; - if (!this || !this->IsClient() || !this->cur_hp || !this->max_hp) return; diff --git a/zone/client.h b/zone/client.h index 61da18686..768746e67 100644 --- a/zone/client.h +++ b/zone/client.h @@ -221,6 +221,9 @@ public: Client(EQStreamInterface * ieqs); ~Client(); + std::unordered_map close_npcs; + bool is_client_moving; + //abstract virtual function implementations required by base abstract class virtual bool Death(Mob* killerMob, int32 damage, uint16 spell_id, EQEmu::skills::SkillType attack_skill); virtual void Damage(Mob* from, int32 damage, uint16 spell_id, EQEmu::skills::SkillType attack_skill, bool avoidable = true, int8 buffslot = -1, bool iBuffTic = false, eSpecialAttacks special = eSpecialAttacks::None); @@ -1458,7 +1461,7 @@ private: Timer forget_timer; // our 2 min everybody forgets you timer Timer autosave_timer; #ifdef REVERSE_AGGRO - Timer scanarea_timer; + Timer client_scan_npc_aggro_timer; #endif Timer tribute_timer; @@ -1475,8 +1478,8 @@ private: Timer anon_toggle_timer; Timer afk_toggle_timer; Timer helm_toggle_timer; - Timer light_update_timer; Timer aggro_meter_timer; + Timer npc_close_scan_timer; glm::vec3 m_Proximity; diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index e97aa026c..ad6a8e7a2 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -1021,7 +1021,7 @@ int32 Client::acmod() //seems about 21 agil per extra AC pt over 300... return (65 + ((agility - 300) / 21)); } - Log.Out(Logs::Detail, Logs::Error, "Error in Client::acmod(): Agility: %i, Level: %i", agility, level); + Log(Logs::Detail, Logs::Error, "Error in Client::acmod(): Agility: %i, Level: %i", agility, level); return 0; }; @@ -1038,7 +1038,7 @@ int32 Client::CalcMaxMana() break; } default: { - Log.Out(Logs::Detail, Logs::Spells, "Invalid Class '%c' in CalcMaxMana", GetCasterClass()); + Log(Logs::Detail, Logs::Spells, "Invalid Class '%c' in CalcMaxMana", GetCasterClass()); max_mana = 0; break; } @@ -1056,7 +1056,7 @@ int32 Client::CalcMaxMana() cur_mana = curMana_cap; } } - Log.Out(Logs::Detail, Logs::Spells, "Client::CalcMaxMana() called for %s - returning %d", GetName(), max_mana); + Log(Logs::Detail, Logs::Spells, "Client::CalcMaxMana() called for %s - returning %d", GetName(), max_mana); return max_mana; } @@ -1140,13 +1140,13 @@ int32 Client::CalcBaseMana() break; } default: { - Log.Out(Logs::General, Logs::None, "Invalid Class '%c' in CalcMaxMana", GetCasterClass()); + Log(Logs::General, Logs::None, "Invalid Class '%c' in CalcMaxMana", GetCasterClass()); max_m = 0; break; } } #if EQDEBUG >= 11 - Log.Out(Logs::General, Logs::None, "Client::CalcBaseMana() called for %s - returning %d", GetName(), max_m); + Log(Logs::General, Logs::None, "Client::CalcBaseMana() called for %s - returning %d", GetName(), max_m); #endif return max_m; } @@ -2023,7 +2023,7 @@ uint32 Mob::GetInstrumentMod(uint16 spell_id) const effectmod = 10; if (!nocap && effectmod > effectmodcap) // if the cap is calculated to be 0 using new rules, no cap. effectmod = effectmodcap; - Log.Out(Logs::Detail, Logs::Spells, "%s::GetInstrumentMod() spell=%d mod=%d modcap=%d\n", GetName(), spell_id, + Log(Logs::Detail, Logs::Spells, "%s::GetInstrumentMod() spell=%d mod=%d modcap=%d\n", GetName(), spell_id, effectmod, effectmodcap); return effectmod; } diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index ba0e553a9..66ffb8ed5 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1,18 +1,18 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net) +Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" @@ -27,14 +27,14 @@ #include #ifdef _WINDOWS - #define snprintf _snprintf - #define strncasecmp _strnicmp - #define strcasecmp _stricmp +#define snprintf _snprintf +#define strncasecmp _strnicmp +#define strcasecmp _stricmp #else - #include - #include - #include - #include +#include +#include +#include +#include #endif #include "../common/crc32.h" @@ -337,7 +337,7 @@ void MapOpcodes() ConnectedOpcodes[OP_SelectTribute] = &Client::Handle_OP_SelectTribute; // Use or Ignore sense heading based on rule. - bool train=RuleB(Skills, TrainSenseHeading); + bool train = RuleB(Skills, TrainSenseHeading); ConnectedOpcodes[OP_SenseHeading] = (train) ? &Client::Handle_OP_SenseHeading : &Client::Handle_OP_Ignore; @@ -396,12 +396,12 @@ void MapOpcodes() void ClearMappedOpcode(EmuOpcode op) { - if(op >= _maxEmuOpcode) + if (op >= _maxEmuOpcode) return; ConnectedOpcodes[op] = nullptr; auto iter = ConnectingOpcodes.find(op); - if(iter != ConnectingOpcodes.end()) { + if (iter != ConnectingOpcodes.end()) { ConnectingOpcodes.erase(iter); } } @@ -409,37 +409,37 @@ void ClearMappedOpcode(EmuOpcode op) // client methods int Client::HandlePacket(const EQApplicationPacket *app) { - if (Log.log_settings[Logs::LogCategory::Netcode].is_category_enabled == 1) { + if (LogSys.log_settings[Logs::LogCategory::Netcode].is_category_enabled == 1) { char buffer[64]; app->build_header_dump(buffer); - Log.Out(Logs::Detail, Logs::Client_Server_Packet, "Dispatch opcode: %s", buffer); + Log(Logs::Detail, Logs::Client_Server_Packet, "Dispatch opcode: %s", buffer); } - if (Log.log_settings[Logs::Client_Server_Packet].is_category_enabled == 1) - Log.Out(Logs::General, Logs::Client_Server_Packet, "[%s - 0x%04x] [Size: %u]", OpcodeManager::EmuToName(app->GetOpcode()), app->GetOpcode(), app->Size()); + if (LogSys.log_settings[Logs::Client_Server_Packet].is_category_enabled == 1) + Log(Logs::General, Logs::Client_Server_Packet, "[%s - 0x%04x] [Size: %u]", OpcodeManager::EmuToName(app->GetOpcode()), app->GetOpcode(), app->Size()); - if (Log.log_settings[Logs::Client_Server_Packet_With_Dump].is_category_enabled == 1) - Log.Out(Logs::General, Logs::Client_Server_Packet_With_Dump, "[%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(app->GetOpcode()), app->GetOpcode(), app->Size(), DumpPacketToString(app).c_str()); + if (LogSys.log_settings[Logs::Client_Server_Packet_With_Dump].is_category_enabled == 1) + Log(Logs::General, Logs::Client_Server_Packet_With_Dump, "[%s - 0x%04x] [Size: %u] %s", OpcodeManager::EmuToName(app->GetOpcode()), app->GetOpcode(), app->Size(), DumpPacketToString(app).c_str()); EmuOpcode opcode = app->GetOpcode(); if (opcode == OP_AckPacket) { return true; } - #if EQDEBUG >= 9 - std::cout << "Received 0x" << std::hex << std::setw(4) << std::setfill('0') << opcode << ", size=" << std::dec << app->size << std::endl; - #endif +#if EQDEBUG >= 9 + std::cout << "Received 0x" << std::hex << std::setw(4) << std::setfill('0') << opcode << ", size=" << std::dec << app->size << std::endl; +#endif - switch(client_state) { + switch (client_state) { case CLIENT_CONNECTING: { - if(ConnectingOpcodes.count(opcode) != 1) { + if (ConnectingOpcodes.count(opcode) != 1) { //Hate const cast but everything in lua needs to be non-const even if i make it non-mutable std::vector args; args.push_back(const_cast(app)); parse->EventPlayer(EVENT_UNHANDLED_OPCODE, this, "", 1, &args); #if EQDEBUG >= 10 - Log.Out(Logs::General, Logs::Error, "HandlePacket() Opcode error: Unexpected packet during CLIENT_CONNECTING: opcode:" + Log(Logs::General, Logs::Error, "HandlePacket() Opcode error: Unexpected packet during CLIENT_CONNECTING: opcode:" " %s (#%d eq=0x%04x), size: %i", OpcodeNames[opcode], opcode, 0, app->size); DumpPacket(app); #endif @@ -453,7 +453,7 @@ int Client::HandlePacket(const EQApplicationPacket *app) (this->*p)(app); //special case where connecting code needs to boot client... - if(client_state == CLIENT_KICKED) { + if (client_state == CLIENT_KICKED) { return(false); } @@ -462,15 +462,15 @@ int Client::HandlePacket(const EQApplicationPacket *app) case CLIENT_CONNECTED: { ClientPacketProc p; p = ConnectedOpcodes[opcode]; - if(p == nullptr) { + if (p == nullptr) { std::vector args; args.push_back(const_cast(app)); parse->EventPlayer(EVENT_UNHANDLED_OPCODE, this, "", 0, &args); - if (Log.log_settings[Logs::Client_Server_Packet_Unhandled].is_category_enabled == 1) { + if (LogSys.log_settings[Logs::Client_Server_Packet_Unhandled].is_category_enabled == 1) { char buffer[64]; app->build_header_dump(buffer); - Log.Out(Logs::General, Logs::Client_Server_Packet_Unhandled, "%s %s", buffer, DumpPacketToString(app).c_str()); + Log(Logs::General, Logs::Client_Server_Packet_Unhandled, "%s %s", buffer, DumpPacketToString(app).c_str()); } break; } @@ -484,7 +484,7 @@ int Client::HandlePacket(const EQApplicationPacket *app) case CLIENT_LINKDEAD: break; default: - Log.Out(Logs::General, Logs::None, "Unknown client_state: %d\n", client_state); + Log(Logs::General, Logs::None, "Unknown client_state: %d\n", client_state); break; } @@ -510,7 +510,7 @@ void Client::CompleteConnect() /* Sets GM Flag if needed & Sends Petition Queue */ UpdateAdmin(false); - if (IsInAGuild()){ + if (IsInAGuild()) { uint8 rank = GuildRank(); if (ClientVersion() >= EQEmu::versions::ClientVersion::RoF) { @@ -534,18 +534,18 @@ void Client::CompleteConnect() uint32 raidid = database.GetRaidID(GetName()); Raid *raid = nullptr; - if (raidid > 0){ + if (raidid > 0) { raid = entity_list.GetRaidByID(raidid); - if (!raid){ + if (!raid) { raid = new Raid(raidid); - if (raid->GetID() != 0){ + if (raid->GetID() != 0) { entity_list.AddRaid(raid, raidid); raid->LoadLeadership(); // Recreating raid in new zone, get leadership from DB } else raid = nullptr; } - if (raid){ + if (raid) { SetRaidGrouped(true); raid->LearnMembers(); raid->VerifyRaid(); @@ -566,7 +566,7 @@ void Client::CompleteConnect() raid->SendAllRaidLeadershipAA(); } uint32 grpID = raid->GetGroup(GetName()); - if (grpID < 12){ + if (grpID < 12) { raid->SendRaidGroupRemove(GetName(), grpID); raid->SendRaidGroupAdd(GetName(), grpID); raid->CheckGroupMentor(grpID, this); @@ -626,7 +626,7 @@ void Client::CompleteConnect() { SendIllusionPacket(spell.base[x1], 0xFF, 0xFF, 0xFF); } - switch (spell.base[x1]){ + switch (spell.base[x1]) { case OGRE: SendAppearancePacket(AT_Size, 9); break; @@ -694,7 +694,7 @@ void Client::CompleteConnect() Message(13, "You can't levitate in this zone."); } } - else{ + else { SendAppearancePacket(AT_Levitate, 2); } break; @@ -757,7 +757,7 @@ void Client::CompleteConnect() entity_list.SendTraders(this); - if (GetPet()){ + if (GetPet()) { GetPet()->SendPetBuffsToClient(); } @@ -773,7 +773,7 @@ void Client::CompleteConnect() //enforce some rules.. if (!CanBeInZone()) { - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Kicking char from zone, not allowed here"); + Log(Logs::Detail, Logs::None, "[CLIENT] Kicking char from zone, not allowed here"); GoToSafeCoords(database.GetZoneID("arena"), 0); return; } @@ -787,10 +787,10 @@ void Client::CompleteConnect() parse->EventPlayer(EVENT_ENTER_ZONE, this, "", 0); /* This sub event is for if a player logs in for the first time since entering world. */ - if (firstlogon == 1){ + if (firstlogon == 1) { parse->EventPlayer(EVENT_CONNECT, this, "", 0); /* QS: PlayerLogConnectDisconnect */ - if (RuleB(QueryServ, PlayerLogConnectDisconnect)){ + if (RuleB(QueryServ, PlayerLogConnectDisconnect)) { std::string event_desc = StringFormat("Connect :: Logged into zoneid:%i instid:%i", this->GetZoneID(), this->GetInstanceID()); QServ->PlayerLogEvent(Player_Log_Connect_State, this->CharacterID(), event_desc); } @@ -872,7 +872,7 @@ void Client::CheatDetected(CheatTypes CheatType, float x, float y, float z) case MQWarp: //Some zones may still have issues. Database updates will eliminate most if not all problems. if (RuleB(Zone, EnableMQWarpDetector) && ((this->Admin() < RuleI(Zone, MQWarpExemptStatus) - || (RuleI(Zone, MQWarpExemptStatus)) == -1))) + || (RuleI(Zone, MQWarpExemptStatus)) == -1))) { Message(13, "Large warp detected."); char hString[250]; @@ -883,7 +883,7 @@ void Client::CheatDetected(CheatTypes CheatType, float x, float y, float z) case MQWarpShadowStep: if (RuleB(Zone, EnableMQWarpDetector) && ((this->Admin() < RuleI(Zone, MQWarpExemptStatus) - || (RuleI(Zone, MQWarpExemptStatus)) == -1))) + || (RuleI(Zone, MQWarpExemptStatus)) == -1))) { char *hString = nullptr; MakeAnyLenString(&hString, "/MQWarp(SS) with location %.2f, %.2f, %.2f, the target was shadow step exempt but we still found this suspicious.", GetX(), GetY(), GetZ()); @@ -894,7 +894,7 @@ void Client::CheatDetected(CheatTypes CheatType, float x, float y, float z) case MQWarpKnockBack: if (RuleB(Zone, EnableMQWarpDetector) && ((this->Admin() < RuleI(Zone, MQWarpExemptStatus) - || (RuleI(Zone, MQWarpExemptStatus)) == -1))) + || (RuleI(Zone, MQWarpExemptStatus)) == -1))) { char *hString = nullptr; MakeAnyLenString(&hString, "/MQWarp(KB) with location %.2f, %.2f, %.2f, the target was Knock Back exempt but we still found this suspicious.", GetX(), GetY(), GetZ()); @@ -906,7 +906,7 @@ void Client::CheatDetected(CheatTypes CheatType, float x, float y, float z) case MQWarpLight: if (RuleB(Zone, EnableMQWarpDetector) && ((this->Admin() < RuleI(Zone, MQWarpExemptStatus) - || (RuleI(Zone, MQWarpExemptStatus)) == -1))) + || (RuleI(Zone, MQWarpExemptStatus)) == -1))) { if (RuleB(Zone, MarkMQWarpLT)) { @@ -980,7 +980,7 @@ return; void Client::Handle_Connect_OP_ApproveZone(const EQApplicationPacket *app) { if (app->size != sizeof(ApproveZone_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size on OP_ApproveZone: Expected %i, Got %i", + Log(Logs::General, Logs::Error, "Invalid size on OP_ApproveZone: Expected %i, Got %i", sizeof(ApproveZone_Struct), app->size); return; } @@ -993,14 +993,14 @@ void Client::Handle_Connect_OP_ApproveZone(const EQApplicationPacket *app) void Client::Handle_Connect_OP_ClientError(const EQApplicationPacket *app) { if (app->size != sizeof(ClientError_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size on OP_ClientError: Expected %i, Got %i", + Log(Logs::General, Logs::Error, "Invalid size on OP_ClientError: Expected %i, Got %i", sizeof(ClientError_Struct), app->size); return; } // Client reporting error to server ClientError_Struct* error = (ClientError_Struct*)app->pBuffer; - Log.Out(Logs::General, Logs::Error, "Client error: %s", error->character_name); - Log.Out(Logs::General, Logs::Error, "Error message: %s", error->message); + Log(Logs::General, Logs::Error, "Client error: %s", error->character_name); + Log(Logs::General, Logs::Error, "Error message: %s", error->message); Message(13, error->message); #if (EQDEBUG>=5) DumpPacket(app); @@ -1133,7 +1133,7 @@ void Client::Handle_Connect_OP_SendTributes(const EQApplicationPacket *app) void Client::Handle_Connect_OP_SetServerFilter(const EQApplicationPacket *app) { if (app->size != sizeof(SetServerFilter_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received invalid sized OP_SetServerFilter"); + Log(Logs::General, Logs::Error, "Received invalid sized OP_SetServerFilter"); DumpPacket(app); return; } @@ -1150,7 +1150,7 @@ void Client::Handle_Connect_OP_SpawnAppearance(const EQApplicationPacket *app) void Client::Handle_Connect_OP_TGB(const EQApplicationPacket *app) { if (app->size != sizeof(uint32)) { - Log.Out(Logs::General, Logs::Error, "Invalid size on OP_TGB: Expected %i, Got %i", + Log(Logs::General, Logs::Error, "Invalid size on OP_TGB: Expected %i, Got %i", sizeof(uint32), app->size); return; } @@ -1197,11 +1197,11 @@ void Client::Handle_Connect_OP_ZoneComplete(const EQApplicationPacket *app) void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) { - if(app->size != sizeof(ClientZoneEntry_Struct)) + if (app->size != sizeof(ClientZoneEntry_Struct)) return; - ClientZoneEntry_Struct *cze = (ClientZoneEntry_Struct *) app->pBuffer; + ClientZoneEntry_Struct *cze = (ClientZoneEntry_Struct *)app->pBuffer; - if(strlen(cze->char_name) > 63) + if (strlen(cze->char_name) > 63) return; conn_state = ReceivedZoneEntry; @@ -1210,14 +1210,14 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) m_ClientVersionBit = EQEmu::versions::ConvertClientVersionToClientVersionBit(Connection()->ClientVersion()); bool siv = m_inv.SetInventoryVersion(m_ClientVersion); - Log.Out(Logs::General, Logs::None, "%s inventory version to %s(%i)", (siv ? "Succeeded in setting" : "Failed to set"), ClientVersionName(m_ClientVersion), m_ClientVersion); + Log(Logs::General, Logs::None, "%s inventory version to %s(%i)", (siv ? "Succeeded in setting" : "Failed to set"), ClientVersionName(m_ClientVersion), m_ClientVersion); /* Antighost code - tmp var is so the search doesnt find this object + tmp var is so the search doesnt find this object */ Client* client = entity_list.GetClientByName(cze->char_name); if (!zone->GetAuth(ip, cze->char_name, &WID, &account_id, &character_id, &admin, lskey, &tellsoff)) { - Log.Out(Logs::General, Logs::Error, "GetAuth() returned false kicking client"); + Log(Logs::General, Logs::Error, "GetAuth() returned false kicking client"); if (client != 0) { client->Save(); client->Kick(); @@ -1233,8 +1233,8 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) struct in_addr ghost_addr; ghost_addr.s_addr = eqs->GetRemoteIP(); - Log.Out(Logs::General, Logs::Error, "Ghosting client: Account ID:%i Name:%s Character:%s IP:%s", - client->AccountID(), client->AccountName(), client->GetName(), inet_ntoa(ghost_addr)); + Log(Logs::General, Logs::Error, "Ghosting client: Account ID:%i Name:%s Character:%s IP:%s", + client->AccountID(), client->AccountName(), client->GetName(), inet_ntoa(ghost_addr)); client->Save(); client->Disconnect(); } @@ -1250,7 +1250,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) uint32 cid = CharacterID(); character_id = cid; /* Global character_id reference */ - /* Flush and reload factions */ + /* Flush and reload factions */ database.RemoveTempFactions(this); database.LoadCharacterFactionValues(cid, factionvalues); @@ -1271,14 +1271,14 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) query = StringFormat("SELECT `lfp`, `lfg`, `xtargets`, `firstlogon`, `guild_id`, `rank` FROM `character_data` LEFT JOIN `guild_members` ON `id` = `char_id` WHERE `id` = %i", cid); results = database.QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { - if (row[4] && atoi(row[4]) > 0){ + if (row[4] && atoi(row[4]) > 0) { guild_id = atoi(row[4]); - if (row[5] != nullptr){ guildrank = atoi(row[5]); } - else{ guildrank = GUILD_RANK_NONE; } + if (row[5] != nullptr) { guildrank = atoi(row[5]); } + else { guildrank = GUILD_RANK_NONE; } } - if (LFP){ LFP = atoi(row[0]); } - if (LFG){ LFG = atoi(row[1]); } + if (LFP) { LFP = atoi(row[0]); } + if (LFG) { LFG = atoi(row[1]); } if (row[3]) firstlogon = atoi(row[3]); } @@ -1303,9 +1303,9 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) database.LoadCharacterLeadershipAA(cid, &m_pp); /* Load Character Leadership AA's */ database.LoadCharacterTribute(cid, &m_pp); /* Load CharacterTribute */ - /* Load AdventureStats */ + /* Load AdventureStats */ AdventureStats_Struct as; - if(database.GetAdventureStats(cid, &as)) + if (database.GetAdventureStats(cid, &as)) { m_pp.ldon_wins_guk = as.success.guk; m_pp.ldon_wins_mir = as.success.mir; @@ -1324,11 +1324,11 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) { if (m_pp.item_tint.Slot[i].UseTint == 1 || m_pp.item_tint.Slot[i].UseTint == 255) { - m_pp.item_tint.Slot[i].UseTint = 0xFF; + m_pp.item_tint.Slot[i].UseTint = 0xFF; } } - if (level){ level = m_pp.level; } + if (level) { level = m_pp.level; } /* If GM, not trackable */ if (gmhideme) { trackable = false; } @@ -1350,7 +1350,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) strcpy(lastname, m_pp.last_name); /* If PP is set to weird coordinates */ if ((m_pp.x == -1 && m_pp.y == -1 && m_pp.z == -1) || (m_pp.x == -2 && m_pp.y == -2 && m_pp.z == -2)) { - auto safePoint = zone->GetSafePoint(); + auto safePoint = zone->GetSafePoint(); m_pp.x = safePoint.x; m_pp.y = safePoint.y; m_pp.z = safePoint.z; @@ -1390,7 +1390,8 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) /* Load Guild */ if (!IsInAGuild()) { m_pp.guild_id = GUILD_NONE; - } else { + } + else { m_pp.guild_id = GuildID(); uint8 rank = guild_mgr.GetDisplayedRank(GuildID(), GuildRank(), CharacterID()); // FIXME: RoF guild rank @@ -1417,45 +1418,45 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) switch (race) { - case OGRE: - size = 9; break; - case TROLL: - size = 8; break; - case VAHSHIR: case BARBARIAN: - size = 7; break; - case HUMAN: case HIGH_ELF: case ERUDITE: case IKSAR: case DRAKKIN: - size = 6; break; - case HALF_ELF: - size = 5.5; break; - case WOOD_ELF: case DARK_ELF: case FROGLOK: - size = 5; break; - case DWARF: - size = 4; break; - case HALFLING: - size = 3.5; break; - case GNOME: - size = 3; break; - default: - size = 0; + case OGRE: + size = 9; break; + case TROLL: + size = 8; break; + case VAHSHIR: case BARBARIAN: + size = 7; break; + case HUMAN: case HIGH_ELF: case ERUDITE: case IKSAR: case DRAKKIN: + size = 6; break; + case HALF_ELF: + size = 5.5; break; + case WOOD_ELF: case DARK_ELF: case FROGLOK: + size = 5; break; + case DWARF: + size = 4; break; + case HALFLING: + size = 3.5; break; + case GNOME: + size = 3; break; + default: + size = 0; } /* Check for Invalid points */ - if (m_pp.ldon_points_guk < 0 || m_pp.ldon_points_guk > 2000000000){ m_pp.ldon_points_guk = 0; } - if (m_pp.ldon_points_mir < 0 || m_pp.ldon_points_mir > 2000000000){ m_pp.ldon_points_mir = 0; } - if (m_pp.ldon_points_mmc < 0 || m_pp.ldon_points_mmc > 2000000000){ m_pp.ldon_points_mmc = 0; } - if (m_pp.ldon_points_ruj < 0 || m_pp.ldon_points_ruj > 2000000000){ m_pp.ldon_points_ruj = 0; } - if (m_pp.ldon_points_tak < 0 || m_pp.ldon_points_tak > 2000000000){ m_pp.ldon_points_tak = 0; } - if (m_pp.ldon_points_available < 0 || m_pp.ldon_points_available > 2000000000){ m_pp.ldon_points_available = 0; } + if (m_pp.ldon_points_guk < 0 || m_pp.ldon_points_guk > 2000000000) { m_pp.ldon_points_guk = 0; } + if (m_pp.ldon_points_mir < 0 || m_pp.ldon_points_mir > 2000000000) { m_pp.ldon_points_mir = 0; } + if (m_pp.ldon_points_mmc < 0 || m_pp.ldon_points_mmc > 2000000000) { m_pp.ldon_points_mmc = 0; } + if (m_pp.ldon_points_ruj < 0 || m_pp.ldon_points_ruj > 2000000000) { m_pp.ldon_points_ruj = 0; } + if (m_pp.ldon_points_tak < 0 || m_pp.ldon_points_tak > 2000000000) { m_pp.ldon_points_tak = 0; } + if (m_pp.ldon_points_available < 0 || m_pp.ldon_points_available > 2000000000) { m_pp.ldon_points_available = 0; } - if(RuleB(World, UseClientBasedExpansionSettings)) { + if (RuleB(World, UseClientBasedExpansionSettings)) { m_pp.expansions = EQEmu::versions::ConvertClientVersionToExpansion(ClientVersion()); } else { m_pp.expansions = RuleI(World, ExpansionSettings); } - if(!database.LoadAlternateAdvancement(this)) { - Log.Out(Logs::General, Logs::Error, "Error loading AA points for %s", GetName()); + if (!database.LoadAlternateAdvancement(this)) { + Log(Logs::General, Logs::Error, "Error loading AA points for %s", GetName()); } if (SPDAT_RECORDS > 0) { @@ -1498,7 +1499,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) /* Send Group Members via PP */ uint32 groupid = database.GetGroupID(GetName()); Group* group = nullptr; - if (groupid > 0){ + if (groupid > 0) { group = entity_list.GetGroupByID(groupid); if (!group) { //nobody from our is here... start a new group group = new Group(groupid); @@ -1516,15 +1517,15 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) } else { //no group id - //clear out the group junk in our PP + //clear out the group junk in our PP uint32 xy = 0; for (xy = 0; xy < MAX_GROUP_MEMBERS; xy++) memset(m_pp.groupMembers[xy], 0, 64); } - if (group){ + if (group) { // If the group leader is not set, pull the group leader infomrmation from the database. - if (!group->GetLeader()){ + if (!group->GetLeader()) { char ln[64]; char MainTankName[64]; char AssistName[64]; @@ -1566,7 +1567,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) CalcBonuses(); if (RuleB(Zone, EnableLoggedOffReplenishments) && - time(nullptr) - m_pp.lastlogin >= RuleI(Zone, MinOfflineTimeToReplenishments)) { + time(nullptr) - m_pp.lastlogin >= RuleI(Zone, MinOfflineTimeToReplenishments)) { m_pp.cur_hp = GetMaxHP(); m_pp.mana = GetMaxMana(); m_pp.endurance = GetMaxEndurance(); @@ -1584,19 +1585,19 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) p_timers.SetCharID(CharacterID()); if (!p_timers.Load(&database)) { - Log.Out(Logs::General, Logs::Error, "Unable to load ability timers from the database for %s (%i)!", GetCleanName(), CharacterID()); + Log(Logs::General, Logs::Error, "Unable to load ability timers from the database for %s (%i)!", GetCleanName(), CharacterID()); } /* Load Spell Slot Refresh from Currently Memoried Spells */ for (unsigned int i = 0; i < MAX_PP_MEMSPELL; ++i) - if (IsValidSpell(m_pp.mem_spells[i])) - m_pp.spellSlotRefresh[i] = p_timers.GetRemainingTime(pTimerSpellStart + m_pp.mem_spells[i]) * 1000; + if (IsValidSpell(m_pp.mem_spells[i])) + m_pp.spellSlotRefresh[i] = p_timers.GetRemainingTime(pTimerSpellStart + m_pp.mem_spells[i]) * 1000; /* Ability slot refresh send SK/PAL */ if (m_pp.class_ == SHADOWKNIGHT || m_pp.class_ == PALADIN) { uint32 abilitynum = 0; - if (m_pp.class_ == SHADOWKNIGHT){ abilitynum = pTimerHarmTouch; } - else{ abilitynum = pTimerLayHands; } + if (m_pp.class_ == SHADOWKNIGHT) { abilitynum = pTimerHarmTouch; } + else { abilitynum = pTimerLayHands; } uint32 remaining = p_timers.GetRemainingTime(abilitynum); if (remaining > 0 && remaining < 15300) @@ -1622,7 +1623,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) m_pp.RestTimer = 0; /* This checksum should disappear once dynamic structs are in... each struct strategy will do it */ - CRC32::SetEQChecksum((unsigned char*)&m_pp, sizeof(PlayerProfile_Struct)-4); + CRC32::SetEQChecksum((unsigned char*)&m_pp, sizeof(PlayerProfile_Struct) - 4); outapp = new EQApplicationPacket(OP_PlayerProfile, sizeof(PlayerProfile_Struct)); @@ -1668,7 +1669,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) entity_list.SendZoneCorpsesBulk(this); entity_list.SendZonePVPUpdates(this); //hack until spawn struct is fixed. - /* Time of Day packet */ + /* Time of Day packet */ outapp = new EQApplicationPacket(OP_TimeOfDay, sizeof(TimeOfDay_Struct)); TimeOfDay_Struct* tod = (TimeOfDay_Struct*)outapp->pBuffer; zone->zone_time.GetCurrentEQTimeOfDay(time(0), tod); @@ -1683,8 +1684,8 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) } /* - Character Inventory Packet - this is not quite where live sends inventory, they do it after tribute + Character Inventory Packet + this is not quite where live sends inventory, they do it after tribute */ if (loaditems) { /* Dont load if a length error occurs */ BulkSendInventoryItems(); @@ -1715,14 +1716,14 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) } /* - Weather Packet - This shouldent be moved, this seems to be what the client - uses to advance to the next state (sending ReqNewZone) + Weather Packet + This shouldent be moved, this seems to be what the client + uses to advance to the next state (sending ReqNewZone) */ outapp = new EQApplicationPacket(OP_Weather, 12); Weather_Struct *ws = (Weather_Struct *)outapp->pBuffer; ws->val1 = 0x000000FF; - if (zone->zone_weather == 1){ ws->type = 0x31; } // Rain + if (zone->zone_weather == 1) { ws->type = 0x31; } // Rain if (zone->zone_weather == 2) { outapp->pBuffer[8] = 0x01; ws->type = 0x02; @@ -1749,22 +1750,22 @@ void Client::Handle_0x0193(const EQApplicationPacket *app) void Client::Handle_OP_AAAction(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::AA, "Received OP_AAAction"); + Log(Logs::Detail, Logs::AA, "Received OP_AAAction"); - if (app->size != sizeof(AA_Action)){ - Log.Out(Logs::General, Logs::AA, "Error! OP_AAAction size didnt match!"); + if (app->size != sizeof(AA_Action)) { + Log(Logs::General, Logs::AA, "Error! OP_AAAction size didnt match!"); return; } AA_Action* action = (AA_Action*)app->pBuffer; if (action->action == aaActionActivate) {//AA Hotkey - Log.Out(Logs::Detail, Logs::AA, "Activating AA %d", action->ability); + Log(Logs::Detail, Logs::AA, "Activating AA %d", action->ability); ActivateAlternateAdvancementAbility(action->ability, action->target_id); } else if (action->action == aaActionBuy) { PurchaseAlternateAdvancementRank(action->ability); } - else if (action->action == aaActionDisableEXP){ //Turn Off AA Exp + else if (action->action == aaActionDisableEXP) { //Turn Off AA Exp if (m_epp.perAA > 0) Message_StringID(0, AA_OFF); @@ -1775,15 +1776,15 @@ void Client::Handle_OP_AAAction(const EQApplicationPacket *app) if (m_epp.perAA == 0) Message_StringID(0, AA_ON); m_epp.perAA = action->exp_value; - if (m_epp.perAA < 0 || m_epp.perAA > 100) + if (m_epp.perAA < 0 || m_epp.perAA > 100) m_epp.perAA = 0; // stop exploit with sanity check - // send an update + // send an update SendAlternateAdvancementStats(); SendAlternateAdvancementTable(); } else { - Log.Out(Logs::General, Logs::AA, "Unknown AA action : %u %u %u %d", action->action, action->ability, action->target_id, action->exp_value); + Log(Logs::General, Logs::AA, "Unknown AA action : %u %u %u %d", action->action, action->ability, action->target_id, action->exp_value); } } @@ -1791,7 +1792,7 @@ void Client::Handle_OP_AcceptNewTask(const EQApplicationPacket *app) { if (app->size != sizeof(AcceptNewTask_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_AcceptNewTask expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_AcceptNewTask expected %i got %i", sizeof(AcceptNewTask_Struct), app->size); DumpPacket(app); return; @@ -1806,7 +1807,7 @@ void Client::Handle_OP_AdventureInfoRequest(const EQApplicationPacket *app) { if (app->size < sizeof(EntityId_Struct)) { - Log.Out(Logs::General, Logs::Error, "Handle_OP_AdventureInfoRequest had a packet that was too small."); + Log(Logs::General, Logs::Error, "Handle_OP_AdventureInfoRequest had a packet that was too small."); return; } EntityId_Struct* ent = (EntityId_Struct*)app->pBuffer; @@ -1861,7 +1862,7 @@ void Client::Handle_OP_AdventureMerchantPurchase(const EQApplicationPacket *app) { if (app->size != sizeof(Adventure_Purchase_Struct)) { - Log.Out(Logs::General, Logs::Error, "OP size error: OP_AdventureMerchantPurchase expected:%i got:%i", sizeof(Adventure_Purchase_Struct), app->size); + Log(Logs::General, Logs::Error, "OP size error: OP_AdventureMerchantPurchase expected:%i got:%i", sizeof(Adventure_Purchase_Struct), app->size); return; } @@ -1891,7 +1892,7 @@ void Client::Handle_OP_AdventureMerchantPurchase(const EQApplicationPacket *app) std::list merlist = zone->merchanttable[merchantid]; std::list::const_iterator itr; - for (itr = merlist.begin(); itr != merlist.end(); ++itr){ + for (itr = merlist.begin(); itr != merlist.end(); ++itr) { MerchantList ml = *itr; if (GetLevel() < ml.level_required) { continue; @@ -2041,7 +2042,7 @@ void Client::Handle_OP_AdventureMerchantRequest(const EQApplicationPacket *app) { if (app->size != sizeof(AdventureMerchant_Struct)) { - Log.Out(Logs::General, Logs::Error, "OP size error: OP_AdventureMerchantRequest expected:%i got:%i", sizeof(AdventureMerchant_Struct), app->size); + Log(Logs::General, Logs::Error, "OP size error: OP_AdventureMerchantRequest expected:%i got:%i", sizeof(AdventureMerchant_Struct), app->size); return; } std::stringstream ss(std::stringstream::in | std::stringstream::out); @@ -2065,7 +2066,7 @@ void Client::Handle_OP_AdventureMerchantRequest(const EQApplicationPacket *app) const EQEmu::ItemData *item = nullptr; std::list merlist = zone->merchanttable[merchantid]; std::list::const_iterator itr; - for (itr = merlist.begin(); itr != merlist.end() && count<255; ++itr){ + for (itr = merlist.begin(); itr != merlist.end() && count<255; ++itr) { const MerchantList &ml = *itr; if (GetLevel() < ml.level_required) { continue; @@ -2131,7 +2132,7 @@ void Client::Handle_OP_AdventureMerchantSell(const EQApplicationPacket *app) { if (app->size != sizeof(Adventure_Sell_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch on OP_AdventureMerchantSell: got %u expected %u", + Log(Logs::General, Logs::None, "Size mismatch on OP_AdventureMerchantSell: got %u expected %u", app->size, sizeof(Adventure_Sell_Struct)); DumpPacket(app); return; @@ -2163,7 +2164,7 @@ void Client::Handle_OP_AdventureMerchantSell(const EQApplicationPacket *app) const EQEmu::ItemData* item = database.GetItem(itemid); EQEmu::ItemInstance* inst = GetInv().GetItem(ams_in->slot); - if (!item || !inst){ + if (!item || !inst) { Message(13, "You seemed to have misplaced that item..."); return; } @@ -2264,7 +2265,7 @@ void Client::Handle_OP_AdventureRequest(const EQApplicationPacket *app) { if (app->size < sizeof(AdventureRequest_Struct)) { - Log.Out(Logs::General, Logs::Error, "Handle_OP_AdventureRequest had a packet that was too small."); + Log(Logs::General, Logs::Error, "Handle_OP_AdventureRequest had a packet that was too small."); return; } @@ -2320,7 +2321,7 @@ void Client::Handle_OP_AdventureRequest(const EQApplicationPacket *app) } auto packet = - new ServerPacket(ServerOP_AdventureRequest, sizeof(ServerAdventureRequest_Struct) + (64 * group_members)); + new ServerPacket(ServerOP_AdventureRequest, sizeof(ServerAdventureRequest_Struct) + (64 * group_members)); ServerAdventureRequest_Struct *sar = (ServerAdventureRequest_Struct*)packet->pBuffer; sar->member_count = group_members; sar->risk = ars->risk; @@ -2342,7 +2343,7 @@ void Client::Handle_OP_AdventureRequest(const EQApplicationPacket *app) c_name = r->GetClientNameByIndex(x); if (c_name) { - memcpy((packet->pBuffer + sizeof(ServerAdventureRequest_Struct)+(64 * i)), c_name, strlen(c_name)); + memcpy((packet->pBuffer + sizeof(ServerAdventureRequest_Struct) + (64 * i)), c_name, strlen(c_name)); ++i; } } @@ -2361,7 +2362,7 @@ void Client::Handle_OP_AdventureRequest(const EQApplicationPacket *app) c_name = g->GetClientNameByIndex(x); if (c_name) { - memcpy((packet->pBuffer + sizeof(ServerAdventureRequest_Struct)+(64 * i)), c_name, strlen(c_name)); + memcpy((packet->pBuffer + sizeof(ServerAdventureRequest_Struct) + (64 * i)), c_name, strlen(c_name)); ++i; } } @@ -2403,7 +2404,7 @@ void Client::Handle_OP_AdventureStatsRequest(const EQApplicationPacket *app) void Client::Handle_OP_AggroMeterLockTarget(const EQApplicationPacket *app) { if (app->size < sizeof(uint32)) { - Log.Out(Logs::General, Logs::Error, "Handle_OP_AggroMeterLockTarget had a packet that was too small."); + Log(Logs::General, Logs::Error, "Handle_OP_AggroMeterLockTarget had a packet that was too small."); return; } @@ -2452,7 +2453,7 @@ void Client::Handle_OP_AltCurrencyMerchantRequest(const EQApplicationPacket *app std::list merlist = zone->merchanttable[merchant_id]; std::list::const_iterator itr; - for (itr = merlist.begin(); itr != merlist.end() && count < 255; ++itr){ + for (itr = merlist.begin(); itr != merlist.end() && count < 255; ++itr) { const MerchantList &ml = *itr; if (GetLevel() < ml.level_required) { continue; @@ -2554,7 +2555,7 @@ void Client::Handle_OP_AltCurrencyPurchase(const EQApplicationPacket *app) } /* QS: PlayerLogAlternateCurrencyTransactions :: Merchant Purchase */ - if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){ + if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)) { std::string event_desc = StringFormat("Merchant Purchase :: Spent alt_currency_id:%i cost:%i for itemid:%i in zoneid:%i instid:%i", alt_cur_id, cost, item->ID, this->GetZoneID(), this->GetInstanceID()); QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); } @@ -2598,7 +2599,7 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app) AddAlternateCurrencyValue(reclaim->currency_id, removed); /* QS: PlayerLogAlternateCurrencyTransactions :: Item to Currency */ - if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){ + if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)) { std::string event_desc = StringFormat("Reclaim :: Item to Currency :: alt_currency_id:%i amount:%i to currency tab in zoneid:%i instid:%i", reclaim->currency_id, removed, this->GetZoneID(), this->GetInstanceID()); QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); } @@ -2608,7 +2609,7 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app) else { uint32 max_currency = GetAlternateCurrencyValue(reclaim->currency_id); - if(max_currency == 0 || reclaim->count == 0) + if (max_currency == 0 || reclaim->count == 0) return; /* If you input more than you have currency wise, just give the max of the currency you currently have */ @@ -2621,7 +2622,7 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app) AddAlternateCurrencyValue(reclaim->currency_id, -((int32)reclaim->count)); } /* QS: PlayerLogAlternateCurrencyTransactions :: Cursor to Item Storage */ - if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){ + if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)) { std::string event_desc = StringFormat("Reclaim :: Cursor to Item :: alt_currency_id:%i amount:-%i in zoneid:%i instid:%i", reclaim->currency_id, reclaim->count, this->GetZoneID(), this->GetInstanceID()); QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); } @@ -2653,7 +2654,7 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app) return; } - if (!RuleB(Merchant, EnableAltCurrencySell)) { + if (!RuleB(Merchant, EnableAltCurrencySell)) { return; } @@ -2680,7 +2681,7 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app) if (!item) continue; - if (item->ID == inst->GetItem()->ID) { + if (item->ID == inst->GetItem()->ID) { cost = ml.alt_currency_cost; found = true; break; @@ -2715,7 +2716,7 @@ void Client::Handle_OP_AltCurrencySell(const EQApplicationPacket *app) sell->cost = cost; /* QS: PlayerLogAlternateCurrencyTransactions :: Sold to Merchant*/ - if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)){ + if (RuleB(QueryServ, PlayerLogAlternateCurrencyTransactions)) { std::string event_desc = StringFormat("Sold to Merchant :: itemid:%u npcid:%u alt_currency_id:%u cost:%u in zoneid:%u instid:%i", item->ID, npc_id, alt_cur_id, cost, this->GetZoneID(), this->GetInstanceID()); QServ->PlayerLogEvent(Player_Log_Alternate_Currency_Transactions, this->CharacterID(), event_desc); } @@ -2755,7 +2756,7 @@ void Client::Handle_OP_AltCurrencySellSelection(const EQApplicationPacket *app) uint32 current_currency = GetAlternateCurrencyValue(alt_cur_id); uint32 merchant_id = tar->MerchantType; - if (RuleB(Merchant, EnableAltCurrencySell)) { + if (RuleB(Merchant, EnableAltCurrencySell)) { bool found = false; std::list merlist = zone->merchanttable[merchant_id]; std::list::const_iterator itr; @@ -2790,7 +2791,7 @@ void Client::Handle_OP_AltCurrencySellSelection(const EQApplicationPacket *app) } auto outapp = - new EQApplicationPacket(OP_AltCurrencySellSelection, sizeof(AltCurrencySelectItemReply_Struct)); + new EQApplicationPacket(OP_AltCurrencySellSelection, sizeof(AltCurrencySelectItemReply_Struct)); AltCurrencySelectItemReply_Struct *reply = (AltCurrencySelectItemReply_Struct*)outapp->pBuffer; reply->unknown004 = 0xFF; reply->unknown005 = 0xFF; @@ -2805,7 +2806,7 @@ void Client::Handle_OP_AltCurrencySellSelection(const EQApplicationPacket *app) void Client::Handle_OP_Animation(const EQApplicationPacket *app) { if (app->size != sizeof(Animation_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received invalid sized " + Log(Logs::General, Logs::Error, "Received invalid sized " "OP_Animation: got %d, expected %d", app->size, sizeof(Animation_Struct)); DumpPacket(app); @@ -2823,7 +2824,7 @@ void Client::Handle_OP_Animation(const EQApplicationPacket *app) void Client::Handle_OP_ApplyPoison(const EQApplicationPacket *app) { if (app->size != sizeof(ApplyPoison_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_ApplyPoison, size=%i, expected %i", app->size, sizeof(ApplyPoison_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_ApplyPoison, size=%i, expected %i", app->size, sizeof(ApplyPoison_Struct)); DumpPacket(app); return; } @@ -2837,7 +2838,7 @@ void Client::Handle_OP_ApplyPoison(const EQApplicationPacket *app) if (!IsPoison) { - Log.Out(Logs::Detail, Logs::Spells, "Item used to cast spell effect from a poison item was missing from inventory slot %d " + Log(Logs::Detail, Logs::Spells, "Item used to cast spell effect from a poison item was missing from inventory slot %d " "after casting, or is not a poison!", ApplyPoisonData->inventorySlot); Message(0, "Error: item not found for inventory slot #%i or is not a poison", ApplyPoisonData->inventorySlot); @@ -2860,7 +2861,7 @@ void Client::Handle_OP_ApplyPoison(const EQApplicationPacket *app) DeleteItemInInventory(ApplyPoisonData->inventorySlot, 1, true); - Log.Out(Logs::General, Logs::None, "Chance to Apply Poison was %f. Roll was %f. Result is %u.", SuccessChance, ChanceRoll, ApplyPoisonSuccessResult); + Log(Logs::General, Logs::None, "Chance to Apply Poison was %f. Roll was %f. Result is %u.", SuccessChance, ChanceRoll, ApplyPoisonSuccessResult); } } @@ -2875,7 +2876,7 @@ void Client::Handle_OP_ApplyPoison(const EQApplicationPacket *app) void Client::Handle_OP_Assist(const EQApplicationPacket *app) { if (app->size != sizeof(EntityId_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_Assist expected %i got %i", sizeof(EntityId_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_Assist expected %i got %i", sizeof(EntityId_Struct), app->size); return; } @@ -2905,7 +2906,7 @@ void Client::Handle_OP_Assist(const EQApplicationPacket *app) void Client::Handle_OP_AssistGroup(const EQApplicationPacket *app) { if (app->size != sizeof(EntityId_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_AssistGroup expected %i got %i", sizeof(EntityId_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_AssistGroup expected %i got %i", sizeof(EntityId_Struct), app->size); return; } QueuePacket(app); @@ -2918,7 +2919,7 @@ void Client::Handle_OP_AugmentInfo(const EQApplicationPacket *app) // Some clients this seems to nuke the charm text (ex. Adventurer's Stone) if (app->size != sizeof(AugmentInfo_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_AugmentInfo expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_AugmentInfo expected %i got %i", sizeof(AugmentInfo_Struct), app->size); DumpPacket(app); return; @@ -2937,7 +2938,7 @@ void Client::Handle_OP_AugmentInfo(const EQApplicationPacket *app) void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) { if (app->size != sizeof(AugmentItem_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for AugmentItem_Struct: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for AugmentItem_Struct: Expected: %i, Got: %i", sizeof(AugmentItem_Struct), app->size); return; } @@ -2961,7 +2962,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) EQEmu::ItemInstance *itemOneToPush = nullptr, *itemTwoToPush = nullptr; - //Log.Out(Logs::DebugLevel::Moderate, Logs::Debug, "cslot: %i aslot: %i cidx: %i aidx: %i act: %i dest: %i", + //Log(Logs::DebugLevel::Moderate, Logs::Debug, "cslot: %i aslot: %i cidx: %i aidx: %i act: %i dest: %i", // in_augment->container_slot, in_augment->augment_slot, in_augment->container_index, in_augment->augment_index, in_augment->augment_action, in_augment->dest_inst_id); EQEmu::ItemInstance *tobe_auged = nullptr, *old_aug = nullptr, *new_aug = nullptr, *aug = nullptr, *solvent = nullptr; @@ -2992,7 +2993,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) if (!solvent) { - Log.Out(Logs::General, Logs::Error, "Player tried to safely remove an augment without a distiller."); + Log(Logs::General, Logs::Error, "Player tried to safely remove an augment without a distiller."); Message(13, "Error: Missing an augmentation distiller for safely removing this augment."); return; } @@ -3002,20 +3003,20 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) if (!old_aug) { - Log.Out(Logs::General, Logs::Error, "Player tried to safely remove a nonexistent augment."); + Log(Logs::General, Logs::Error, "Player tried to safely remove a nonexistent augment."); Message(13, "Error: No augment found in slot %i for safely removing.", in_augment->augment_index); return; } else if (solvent->GetItem()->ID != old_aug->GetItem()->AugDistiller) { - Log.Out(Logs::General, Logs::Error, "Player tried to safely remove an augment with the wrong distiller (item %u vs expected %u).", solvent->GetItem()->ID, old_aug->GetItem()->AugDistiller); + Log(Logs::General, Logs::Error, "Player tried to safely remove an augment with the wrong distiller (item %u vs expected %u).", solvent->GetItem()->ID, old_aug->GetItem()->AugDistiller); Message(13, "Error: Wrong augmentation distiller for safely removing this augment."); return; } } else if (solvent->GetItem()->ItemType != EQEmu::item::ItemTypePerfectedAugmentationDistiller) { - Log.Out(Logs::General, Logs::Error, "Player tried to safely remove an augment with a non-distiller item."); + Log(Logs::General, Logs::Error, "Player tried to safely remove an augment with a non-distiller item."); Message(13, "Error: Invalid augmentation distiller for safely removing this augment."); return; } @@ -3023,219 +3024,219 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) switch (in_augment->augment_action) { - case 0: // Adding an augment - case 2: // Swapping augment - new_aug = user_inv.GetItem(EQEmu::inventory::slotCursor); + case 0: // Adding an augment + case 2: // Swapping augment + new_aug = user_inv.GetItem(EQEmu::inventory::slotCursor); - if (!new_aug) // Shouldn't get the OP code without the augment on the user's cursor, but maybe it's h4x. + if (!new_aug) // Shouldn't get the OP code without the augment on the user's cursor, but maybe it's h4x. + { + Log(Logs::General, Logs::Error, "AugmentItem OpCode with 'Insert' or 'Swap' action received, but no augment on client's cursor."); + Message(13, "Error: No augment found on cursor for inserting."); + return; + } + else + { + if (((tobe_auged->IsAugmentSlotAvailable(new_aug->GetAugmentType(), in_augment->augment_index)) != -1) && + (tobe_auged->AvailableWearSlot(new_aug->GetItem()->Slots))) { - Log.Out(Logs::General, Logs::Error, "AugmentItem OpCode with 'Insert' or 'Swap' action received, but no augment on client's cursor."); - Message(13, "Error: No augment found on cursor for inserting."); - return; - } - else - { - if (((tobe_auged->IsAugmentSlotAvailable(new_aug->GetAugmentType(), in_augment->augment_index)) != -1) && - (tobe_auged->AvailableWearSlot(new_aug->GetItem()->Slots))) + old_aug = tobe_auged->RemoveAugment(in_augment->augment_index); + if (old_aug) { - old_aug = tobe_auged->RemoveAugment(in_augment->augment_index); - if (old_aug) + // An old augment was removed in order to be replaced with the new one (augment_action 2) + + CalcBonuses(); + + std::vector args; + args.push_back(old_aug); + parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args); + + args.assign(1, tobe_auged); + args.push_back(false); + parse->EventItem(EVENT_AUGMENT_REMOVE, this, old_aug, nullptr, "", in_augment->augment_index, &args); + } + + tobe_auged->PutAugment(in_augment->augment_index, *new_aug); + tobe_auged->UpdateOrnamentationInfo(); + + aug = tobe_auged->GetAugment(in_augment->augment_index); + if (aug) + { + std::vector args; + args.push_back(aug); + parse->EventItem(EVENT_AUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args); + + args.assign(1, tobe_auged); + parse->EventItem(EVENT_AUGMENT_INSERT, this, aug, nullptr, "", in_augment->augment_index, &args); + } + else + { + Message(13, "Error: Could not properly insert augmentation into augment slot %i. Aborting.", in_augment->augment_index); + return; + } + + itemOneToPush = tobe_auged->Clone(); + if (old_aug) + { + itemTwoToPush = old_aug->Clone(); + } + + // Must push items after the items in inventory are deleted - necessary due to lore items... + if (itemOneToPush) + { + DeleteItemInInventory(item_slot, 0, true); + DeleteItemInInventory(EQEmu::inventory::slotCursor, new_aug->IsStackable() ? 1 : 0, true); + + if (solvent) { - // An old augment was removed in order to be replaced with the new one (augment_action 2) + // Consume the augment distiller + DeleteItemInInventory(solvent_slot, solvent->IsStackable() ? 1 : 0, true); + } + + if (itemTwoToPush) + { + // This is a swap. Return the old aug to the player's cursor. + if (!PutItemInInventory(EQEmu::inventory::slotCursor, *itemTwoToPush, true)) + { + Log(Logs::General, Logs::Error, "Problem returning old augment to player's cursor after augmentation swap."); + Message(15, "Error: Failed to retrieve old augment after augmentation swap!"); + } + } + + if (PutItemInInventory(item_slot, *itemOneToPush, true)) + { + // Successfully added an augment to the item CalcBonuses(); - std::vector args; - args.push_back(old_aug); - parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args); - - args.assign(1, tobe_auged); - args.push_back(false); - parse->EventItem(EVENT_AUGMENT_REMOVE, this, old_aug, nullptr, "", in_augment->augment_index, &args); - } - - tobe_auged->PutAugment(in_augment->augment_index, *new_aug); - tobe_auged->UpdateOrnamentationInfo(); - - aug = tobe_auged->GetAugment(in_augment->augment_index); - if (aug) - { - std::vector args; - args.push_back(aug); - parse->EventItem(EVENT_AUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args); - - args.assign(1, tobe_auged); - parse->EventItem(EVENT_AUGMENT_INSERT, this, aug, nullptr, "", in_augment->augment_index, &args); - } - else - { - Message(13, "Error: Could not properly insert augmentation into augment slot %i. Aborting.", in_augment->augment_index); - return; - } - - itemOneToPush = tobe_auged->Clone(); - if (old_aug) - { - itemTwoToPush = old_aug->Clone(); - } - - // Must push items after the items in inventory are deleted - necessary due to lore items... - if (itemOneToPush) - { - DeleteItemInInventory(item_slot, 0, true); - DeleteItemInInventory(EQEmu::inventory::slotCursor, new_aug->IsStackable() ? 1 : 0, true); - - if (solvent) + if (mat != EQEmu::textures::materialInvalid) { - // Consume the augment distiller - DeleteItemInInventory(solvent_slot, solvent->IsStackable() ? 1 : 0, true); - } - - if (itemTwoToPush) - { - // This is a swap. Return the old aug to the player's cursor. - if (!PutItemInInventory(EQEmu::inventory::slotCursor, *itemTwoToPush, true)) - { - Log.Out(Logs::General, Logs::Error, "Problem returning old augment to player's cursor after augmentation swap."); - Message(15, "Error: Failed to retrieve old augment after augmentation swap!"); - } - } - - if (PutItemInInventory(item_slot, *itemOneToPush, true)) - { - // Successfully added an augment to the item - - CalcBonuses(); - - if (mat != EQEmu::textures::materialInvalid) - { - SendWearChange(mat); // Visible item augged while equipped. Send WC in case ornamentation changed. - } - } - else - { - Message(13, "Error: No available slot for end result. Please free up the augment slot."); + SendWearChange(mat); // Visible item augged while equipped. Send WC in case ornamentation changed. } } else { - Message(13, "Error in cloning item for augment. Aborted."); + Message(13, "Error: No available slot for end result. Please free up the augment slot."); } } else { - Message(13, "Error: No available slot for augment in that item."); + Message(13, "Error in cloning item for augment. Aborted."); } } - break; - case 1: // Removing augment safely (distiller) - aug = tobe_auged->GetAugment(in_augment->augment_index); - if (aug) - { - std::vector args; - args.push_back(aug); - parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args); - - args.assign(1, tobe_auged); - - args.push_back(false); - - parse->EventItem(EVENT_AUGMENT_REMOVE, this, aug, nullptr, "", in_augment->augment_index, &args); - } else { - Message(13, "Error: Could not find augmentation to remove at index %i. Aborting.", in_augment->augment_index); - return; + Message(13, "Error: No available slot for augment in that item."); } - - old_aug = tobe_auged->RemoveAugment(in_augment->augment_index); - tobe_auged->UpdateOrnamentationInfo(); + } + break; + case 1: // Removing augment safely (distiller) + aug = tobe_auged->GetAugment(in_augment->augment_index); + if (aug) + { + std::vector args; + args.push_back(aug); + parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args); - itemOneToPush = tobe_auged->Clone(); - if (old_aug) - itemTwoToPush = old_aug->Clone(); + args.assign(1, tobe_auged); - if (itemOneToPush && itemTwoToPush) + args.push_back(false); + + parse->EventItem(EVENT_AUGMENT_REMOVE, this, aug, nullptr, "", in_augment->augment_index, &args); + } + else + { + Message(13, "Error: Could not find augmentation to remove at index %i. Aborting.", in_augment->augment_index); + return; + } + + old_aug = tobe_auged->RemoveAugment(in_augment->augment_index); + tobe_auged->UpdateOrnamentationInfo(); + + itemOneToPush = tobe_auged->Clone(); + if (old_aug) + itemTwoToPush = old_aug->Clone(); + + if (itemOneToPush && itemTwoToPush) + { + // Consume the augment distiller + DeleteItemInInventory(solvent_slot, solvent->IsStackable() ? 1 : 0, true); + + // Remove the augmented item + DeleteItemInInventory(item_slot, 0, true); + + // Replace it with the unaugmented item + if (!PutItemInInventory(item_slot, *itemOneToPush, true)) { - // Consume the augment distiller - DeleteItemInInventory(solvent_slot, solvent->IsStackable() ? 1 : 0, true); - - // Remove the augmented item - DeleteItemInInventory(item_slot, 0, true); - - // Replace it with the unaugmented item - if (!PutItemInInventory(item_slot, *itemOneToPush, true)) - { - Log.Out(Logs::General, Logs::Error, "Problem returning equipment item to player's inventory after safe augment removal."); - Message(15, "Error: Failed to return item after de-augmentation!"); - } - - CalcBonuses(); - - if (mat != EQEmu::textures::materialInvalid) - { - SendWearChange(mat); // Visible item augged while equipped. Send WC in case ornamentation changed. - } - - // Drop the removed augment on the player's cursor - if (!PutItemInInventory(EQEmu::inventory::slotCursor, *itemTwoToPush, true)) - { - Log.Out(Logs::General, Logs::Error, "Problem returning augment to player's cursor after safe removal."); - Message(15, "Error: Failed to return augment after removal from item!"); - return; - } - } - break; - case 3: // Destroying augment (formerly done in birdbath/sealer with a solvent) - - // RoF client does not require an augmentation solvent for destroying an augmentation in an item. - // Augments can be destroyed with a right click -> Destroy at any time. - - aug = tobe_auged->GetAugment(in_augment->augment_index); - if (aug) - { - std::vector args; - args.push_back(aug); - parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args); - - args.assign(1, tobe_auged); - - args.push_back(true); - - parse->EventItem(EVENT_AUGMENT_REMOVE, this, aug, nullptr, "", in_augment->augment_index, &args); - } - else - { - Message(13, "Error: Could not find augmentation to remove at index %i. Aborting."); - return; - } - - tobe_auged->DeleteAugment(in_augment->augment_index); - tobe_auged->UpdateOrnamentationInfo(); - - itemOneToPush = tobe_auged->Clone(); - if (itemOneToPush) - { - DeleteItemInInventory(item_slot, 0, true); - - if (!PutItemInInventory(item_slot, *itemOneToPush, true)) - { - Log.Out(Logs::General, Logs::Error, "Problem returning equipment item to player's inventory after augment deletion."); - Message(15, "Error: Failed to return item after destroying augment!"); - } + Log(Logs::General, Logs::Error, "Problem returning equipment item to player's inventory after safe augment removal."); + Message(15, "Error: Failed to return item after de-augmentation!"); } CalcBonuses(); if (mat != EQEmu::textures::materialInvalid) { - SendWearChange(mat); + SendWearChange(mat); // Visible item augged while equipped. Send WC in case ornamentation changed. } - break; - default: // Unknown - Log.Out(Logs::General, Logs::Inventory, "Unrecognized augmentation action - cslot: %i aslot: %i cidx: %i aidx: %i act: %i dest: %i", - in_augment->container_slot, in_augment->augment_slot, in_augment->container_index, in_augment->augment_index, in_augment->augment_action, in_augment->dest_inst_id); - break; + + // Drop the removed augment on the player's cursor + if (!PutItemInInventory(EQEmu::inventory::slotCursor, *itemTwoToPush, true)) + { + Log(Logs::General, Logs::Error, "Problem returning augment to player's cursor after safe removal."); + Message(15, "Error: Failed to return augment after removal from item!"); + return; + } + } + break; + case 3: // Destroying augment (formerly done in birdbath/sealer with a solvent) + + // RoF client does not require an augmentation solvent for destroying an augmentation in an item. + // Augments can be destroyed with a right click -> Destroy at any time. + + aug = tobe_auged->GetAugment(in_augment->augment_index); + if (aug) + { + std::vector args; + args.push_back(aug); + parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args); + + args.assign(1, tobe_auged); + + args.push_back(true); + + parse->EventItem(EVENT_AUGMENT_REMOVE, this, aug, nullptr, "", in_augment->augment_index, &args); + } + else + { + Message(13, "Error: Could not find augmentation to remove at index %i. Aborting."); + return; + } + + tobe_auged->DeleteAugment(in_augment->augment_index); + tobe_auged->UpdateOrnamentationInfo(); + + itemOneToPush = tobe_auged->Clone(); + if (itemOneToPush) + { + DeleteItemInInventory(item_slot, 0, true); + + if (!PutItemInInventory(item_slot, *itemOneToPush, true)) + { + Log(Logs::General, Logs::Error, "Problem returning equipment item to player's inventory after augment deletion."); + Message(15, "Error: Failed to return item after destroying augment!"); + } + } + + CalcBonuses(); + + if (mat != EQEmu::textures::materialInvalid) + { + SendWearChange(mat); + } + break; + default: // Unknown + Log(Logs::General, Logs::Inventory, "Unrecognized augmentation action - cslot: %i aslot: %i cidx: %i aidx: %i act: %i dest: %i", + in_augment->container_slot, in_augment->augment_slot, in_augment->container_index, in_augment->augment_index, in_augment->augment_action, in_augment->dest_inst_id); + break; } } else @@ -3249,7 +3250,7 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app) void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app) { if (app->size != 4) { - Log.Out(Logs::General, Logs::Error, "OP size error: OP_AutoAttack expected:4 got:%i", app->size); + Log(Logs::General, Logs::Error, "OP size error: OP_AutoAttack expected:4 got:%i", app->size); return; } @@ -3262,8 +3263,8 @@ void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app) ranged_timer.Disable(); attack_dw_timer.Disable(); - m_AutoAttackPosition = glm::vec4(); - m_AutoAttackTargetLocation = glm::vec3(); + m_AutoAttackPosition = glm::vec4(); + m_AutoAttackTargetLocation = glm::vec3(); aa_los_them_mob = nullptr; } else if (app->pBuffer[0] == 1) @@ -3301,7 +3302,7 @@ void Client::Handle_OP_AutoAttack2(const EQApplicationPacket *app) void Client::Handle_OP_AutoFire(const EQApplicationPacket *app) { if (app->size != sizeof(bool)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_AutoFire expected %i got %i", sizeof(bool), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_AutoFire expected %i got %i", sizeof(bool), app->size); DumpPacket(app); return; } @@ -3316,7 +3317,7 @@ void Client::Handle_OP_Bandolier(const EQApplicationPacket *app) // Although there are three different structs for OP_Bandolier, they are all the same size. // if (app->size != sizeof(BandolierCreate_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_Bandolier expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_Bandolier expected %i got %i", sizeof(BandolierCreate_Struct), app->size); DumpPacket(app); return; @@ -3336,7 +3337,7 @@ void Client::Handle_OP_Bandolier(const EQApplicationPacket *app) SetBandolier(app); break; default: - Log.Out(Logs::General, Logs::None, "Unknown Bandolier action %i", bs->Action); + Log(Logs::General, Logs::None, "Unknown Bandolier action %i", bs->Action); break; } } @@ -3345,7 +3346,7 @@ void Client::Handle_OP_BankerChange(const EQApplicationPacket *app) { if (app->size != sizeof(BankerChange_Struct) && app->size != 4) //Titanium only sends 4 Bytes for this { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_BankerChange expected %i got %i", sizeof(BankerChange_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_BankerChange expected %i got %i", sizeof(BankerChange_Struct), app->size); DumpPacket(app); return; } @@ -3430,7 +3431,7 @@ void Client::Handle_OP_Barter(const EQApplicationPacket *app) if (app->size < 4) { - Log.Out(Logs::General, Logs::None, "OP_Barter packet below minimum expected size. The packet was %i bytes.", app->size); + Log(Logs::General, Logs::None, "OP_Barter packet below minimum expected size. The packet was %i bytes.", app->size); DumpPacket(app); return; } @@ -3577,7 +3578,7 @@ void Client::Handle_OP_Barter(const EQApplicationPacket *app) default: Message(13, "Unrecognised Barter action."); - Log.Out(Logs::Detail, Logs::Trading, "Unrecognised Barter Action %i", Action); + Log(Logs::Detail, Logs::Trading, "Unrecognised Barter Action %i", Action); } } @@ -3585,7 +3586,7 @@ void Client::Handle_OP_Barter(const EQApplicationPacket *app) void Client::Handle_OP_BazaarInspect(const EQApplicationPacket *app) { if (app->size != sizeof(BazaarInspect_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for BazaarInspect_Struct: Expected %i, Got %i", + Log(Logs::General, Logs::Error, "Invalid size for BazaarInspect_Struct: Expected %i, Got %i", sizeof(BazaarInspect_Struct), app->size); return; } @@ -3639,8 +3640,8 @@ void Client::Handle_OP_BazaarSearch(const EQApplicationPacket *app) return; } else { - Log.Out(Logs::Detail, Logs::Trading, "Malformed BazaarSearch_Struct packe, Action %it received, ignoring..."); - Log.Out(Logs::General, Logs::Error, "Malformed BazaarSearch_Struct packet received, ignoring...\n"); + Log(Logs::Detail, Logs::Trading, "Malformed BazaarSearch_Struct packe, Action %it received, ignoring..."); + Log(Logs::General, Logs::Error, "Malformed BazaarSearch_Struct packet received, ignoring...\n"); } return; @@ -3724,17 +3725,17 @@ void Client::Handle_OP_Begging(const EQApplicationPacket *app) void Client::Handle_OP_Bind_Wound(const EQApplicationPacket *app) { - if (app->size != sizeof(BindWound_Struct)){ - Log.Out(Logs::General, Logs::Error, "Size mismatch for Bind wound packet"); + if (app->size != sizeof(BindWound_Struct)) { + Log(Logs::General, Logs::Error, "Size mismatch for Bind wound packet"); DumpPacket(app); } BindWound_Struct* bind_in = (BindWound_Struct*)app->pBuffer; Mob* bindmob = entity_list.GetMob(bind_in->to); - if (!bindmob){ - Log.Out(Logs::General, Logs::Error, "Bindwound on non-exsistant mob from %s", this->GetName()); + if (!bindmob) { + Log(Logs::General, Logs::Error, "Bindwound on non-exsistant mob from %s", this->GetName()); } else { - Log.Out(Logs::General, Logs::None, "BindWound in: to:\'%s\' from=\'%s\'", bindmob->GetName(), GetName()); + Log(Logs::General, Logs::None, "BindWound in: to:\'%s\' from=\'%s\'", bindmob->GetName(), GetName()); BindWound(bindmob, true); } return; @@ -3747,7 +3748,7 @@ void Client::Handle_OP_BlockedBuffs(const EQApplicationPacket *app) if (app->size != sizeof(BlockedBuffs_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_BlockedBuffs expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_BlockedBuffs expected %i got %i", sizeof(BlockedBuffs_Struct), app->size); DumpPacket(app); @@ -3842,7 +3843,7 @@ void Client::Handle_OP_BoardBoat(const EQApplicationPacket *app) // this sends unclean mob name, so capped at 64 // a_boat006 if (app->size <= 5 || app->size > 64) { - Log.Out(Logs::General, Logs::Error, "Size mismatch in OP_BoardBoad. Expected greater than 5 less than 64, got %i", app->size); + Log(Logs::General, Logs::Error, "Size mismatch in OP_BoardBoad. Expected greater than 5 less than 64, got %i", app->size); DumpPacket(app); return; } @@ -3863,14 +3864,14 @@ void Client::Handle_OP_Buff(const EQApplicationPacket *app) { if (app->size != sizeof(SpellBuffPacket_Struct)) { - Log.Out(Logs::General, Logs::Error, "Size mismatch in OP_Buff. expected %i got %i", sizeof(SpellBuffPacket_Struct), app->size); + Log(Logs::General, Logs::Error, "Size mismatch in OP_Buff. expected %i got %i", sizeof(SpellBuffPacket_Struct), app->size); DumpPacket(app); return; } SpellBuffPacket_Struct* sbf = (SpellBuffPacket_Struct*)app->pBuffer; uint32 spid = sbf->buff.spellid; - Log.Out(Logs::Detail, Logs::Spells, "Client requested that buff with spell id %d be canceled.", spid); + Log(Logs::Detail, Logs::Spells, "Client requested that buff with spell id %d be canceled.", spid); //something about IsDetrimentalSpell() crashes this portion of code.. //tbh we shouldn't use it anyway since this is a simple red vs blue buff check and @@ -3924,7 +3925,7 @@ void Client::Handle_OP_Bug(const EQApplicationPacket *app) { if (app->size != sizeof(BugStruct)) printf("Wrong size of BugStruct got %d expected %zu!\n", app->size, sizeof(BugStruct)); - else{ + else { BugStruct* bug = (BugStruct*)app->pBuffer; database.UpdateBug(bug); } @@ -3953,7 +3954,7 @@ void Client::Handle_OP_CancelTask(const EQApplicationPacket *app) { if (app->size != sizeof(CancelTask_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_CancelTask expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_CancelTask expected %i got %i", sizeof(CancelTask_Struct), app->size); DumpPacket(app); return; @@ -3967,7 +3968,7 @@ void Client::Handle_OP_CancelTask(const EQApplicationPacket *app) void Client::Handle_OP_CancelTrade(const EQApplicationPacket *app) { if (app->size != sizeof(CancelTrade_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_CancelTrade, size=%i, expected %i", app->size, sizeof(CancelTrade_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_CancelTrade, size=%i, expected %i", app->size, sizeof(CancelTrade_Struct)); return; } Mob* with = trade->With(); @@ -3984,7 +3985,7 @@ void Client::Handle_OP_CancelTrade(const EQApplicationPacket *app) FinishTrade(this); trade->Reset(); } - else if (with){ + else if (with) { CancelTrade_Struct* msg = (CancelTrade_Struct*)app->pBuffer; msg->fromid = with->GetID(); QueuePacket(app); @@ -4016,7 +4017,7 @@ void Client::Handle_OP_CastSpell(const EQApplicationPacket *app) m_TargetRing = glm::vec3(castspell->x_pos, castspell->y_pos, castspell->z_pos); - Log.Out(Logs::General, Logs::Spells, "OP CastSpell: slot=%d, spell=%d, target=%d, inv=%lx", castspell->slot, castspell->spell_id, castspell->target_id, (unsigned long)castspell->inventoryslot); + Log(Logs::General, Logs::Spells, "OP CastSpell: slot=%d, spell=%d, target=%d, inv=%lx", castspell->slot, castspell->spell_id, castspell->target_id, (unsigned long)castspell->inventoryslot); CastingSlot slot = static_cast(castspell->slot); /* Memorized Spell */ @@ -4043,7 +4044,7 @@ void Client::Handle_OP_CastSpell(const EQApplicationPacket *app) { // packet field types will be reviewed as packet transistions occur const EQEmu::ItemInstance* inst = m_inv[castspell->inventoryslot]; //slot values are int16, need to check packet on this field - //bool cancast = true; + //bool cancast = true; if (inst && inst->IsClassCommon()) { const EQEmu::ItemData* item = inst->GetItem(); @@ -4112,7 +4113,7 @@ void Client::Handle_OP_CastSpell(const EQApplicationPacket *app) /* Discipline -- older clients use the same slot as items, but we translate to it's own */ else if (slot == CastingSlot::Discipline) { if (!UseDiscipline(castspell->spell_id, castspell->target_id)) { - Log.Out(Logs::General, Logs::Spells, "Unknown ability being used by %s, spell being cast is: %i\n", GetName(), castspell->spell_id); + Log(Logs::General, Logs::Spells, "Unknown ability being used by %s, spell being cast is: %i\n", GetName(), castspell->spell_id); InterruptSpell(castspell->spell_id); return; } @@ -4177,7 +4178,7 @@ void Client::Handle_OP_ClearBlockedBuffs(const EQApplicationPacket *app) if (app->size != 1) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_ClearBlockedBuffs expected 1 got %i", app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_ClearBlockedBuffs expected 1 got %i", app->size); DumpPacket(app); @@ -4199,7 +4200,7 @@ void Client::Handle_OP_ClearNPCMarks(const EQApplicationPacket *app) if (app->size != 0) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_ClearNPCMarks expected 0 got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_ClearNPCMarks expected 0 got %i", app->size); DumpPacket(app); @@ -4221,7 +4222,7 @@ void Client::Handle_OP_ClearSurname(const EQApplicationPacket *app) void Client::Handle_OP_ClickDoor(const EQApplicationPacket *app) { if (app->size != sizeof(ClickDoor_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_ClickDoor, size=%i, expected %i", app->size, sizeof(ClickDoor_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_ClickDoor, size=%i, expected %i", app->size, sizeof(ClickDoor_Struct)); return; } ClickDoor_Struct* cd = (ClickDoor_Struct*)app->pBuffer; @@ -4246,7 +4247,7 @@ void Client::Handle_OP_ClickDoor(const EQApplicationPacket *app) void Client::Handle_OP_ClickObject(const EQApplicationPacket *app) { if (app->size != sizeof(ClickObject_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size on ClickObject_Struct: Expected %i, Got %i", + Log(Logs::General, Logs::Error, "Invalid size on ClickObject_Struct: Expected %i, Got %i", sizeof(ClickObject_Struct), app->size); return; } @@ -4287,13 +4288,13 @@ void Client::Handle_OP_ClickObjectAction(const EQApplicationPacket *app) // RoF sends a 0 sized packet for closing objects if (GetTradeskillObject() && ClientVersion() >= EQEmu::versions::ClientVersion::RoF) GetTradeskillObject()->CastToObject()->Close(); - + return; } else { if (app->size != sizeof(ClickObjectAction_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size on OP_ClickObjectAction: Expected %i, Got %i", + Log(Logs::General, Logs::Error, "Invalid size on OP_ClickObjectAction: Expected %i, Got %i", sizeof(ClickObjectAction_Struct), app->size); return; } @@ -4306,11 +4307,11 @@ void Client::Handle_OP_ClickObjectAction(const EQApplicationPacket *app) object->Close(); } else { - Log.Out(Logs::General, Logs::Error, "Unsupported action %d in OP_ClickObjectAction", oos->open); + Log(Logs::General, Logs::Error, "Unsupported action %d in OP_ClickObjectAction", oos->open); } } else { - Log.Out(Logs::General, Logs::Error, "Invalid object %d in OP_ClickObjectAction", oos->drop_id); + Log(Logs::General, Logs::Error, "Invalid object %d in OP_ClickObjectAction", oos->drop_id); } } @@ -4327,8 +4328,8 @@ void Client::Handle_OP_ClickObjectAction(const EQApplicationPacket *app) void Client::Handle_OP_ClientError(const EQApplicationPacket *app) { ClientError_Struct* error = (ClientError_Struct*)app->pBuffer; - Log.Out(Logs::General, Logs::Error, "Client error: %s", error->character_name); - Log.Out(Logs::General, Logs::Error, "Error message:%s", error->message); + Log(Logs::General, Logs::Error, "Client error: %s", error->character_name); + Log(Logs::General, Logs::Error, "Error message:%s", error->message); return; } @@ -4342,19 +4343,19 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) if (IsAIControlled()) return; - if(dead) + if (dead) return; //currently accepting two sizes, one has an extra byte on the end if (app->size != sizeof(PlayerPositionUpdateClient_Struct) - && app->size != (sizeof(PlayerPositionUpdateClient_Struct)+1) - ) { - Log.Out(Logs::General, Logs::Error, "OP size error: OP_ClientUpdate expected:%i got:%i", sizeof(PlayerPositionUpdateClient_Struct), app->size); + && app->size != (sizeof(PlayerPositionUpdateClient_Struct) + 1) + ) { + Log(Logs::General, Logs::Error, "OP size error: OP_ClientUpdate expected:%i got:%i", sizeof(PlayerPositionUpdateClient_Struct), app->size); return; } PlayerPositionUpdateClient_Struct* ppu = (PlayerPositionUpdateClient_Struct*)app->pBuffer; - if(ppu->spawn_id != GetID()) { + if (ppu->spawn_id != GetID()) { // check if the id is for a boat the player is controlling if (ppu->spawn_id == BoatID) { Mob* boat = entity_list.GetMob(BoatID); @@ -4368,7 +4369,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) boat->SetDelta(boatDelta); // send an update to everyone nearby except the client controlling the boat auto outapp = - new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); + new EQApplicationPacket(OP_ClientUpdate, sizeof(PlayerPositionUpdateServer_Struct)); PlayerPositionUpdateServer_Struct* ppus = (PlayerPositionUpdateServer_Struct*)outapp->pBuffer; boat->MakeSpawnUpdate(ppus); entity_list.QueueCloseClients(boat, outapp, true, 300, this, false); @@ -4391,40 +4392,40 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) //the purpose of this first block may not be readily apparent //basically it's so people don't do a moderate warp every 2.5 seconds //letting it even out and basically getting the job done without triggering - if(dist == 0) + if (dist == 0) { - if(m_DistanceSinceLastPositionCheck > 0.0) + if (m_DistanceSinceLastPositionCheck > 0.0) { uint32 cur_time = Timer::GetCurrentTime(); - if((cur_time - m_TimeSinceLastPositionCheck) > 0) + if ((cur_time - m_TimeSinceLastPositionCheck) > 0) { float speed = (m_DistanceSinceLastPositionCheck * 100) / (float)(cur_time - m_TimeSinceLastPositionCheck); int runs = GetRunspeed(); - if(speed > (runs * RuleR(Zone, MQWarpDetectionDistanceFactor))) + if (speed > (runs * RuleR(Zone, MQWarpDetectionDistanceFactor))) { - if(!GetGMSpeed() && (runs >= GetBaseRunspeed() || (speed > (GetBaseRunspeed() * RuleR(Zone, MQWarpDetectionDistanceFactor))))) + if (!GetGMSpeed() && (runs >= GetBaseRunspeed() || (speed > (GetBaseRunspeed() * RuleR(Zone, MQWarpDetectionDistanceFactor))))) { - if(IsShadowStepExempted()) + if (IsShadowStepExempted()) { - if(m_DistanceSinceLastPositionCheck > 800) + if (m_DistanceSinceLastPositionCheck > 800) { CheatDetected(MQWarpShadowStep, ppu->x_pos, ppu->y_pos, ppu->z_pos); } } - else if(IsKnockBackExempted()) + else if (IsKnockBackExempted()) { //still potential to trigger this if you're knocked back off a //HUGE fall that takes > 2.5 seconds - if(speed > 30.0f) + if (speed > 30.0f) { CheatDetected(MQWarpKnockBack, ppu->x_pos, ppu->y_pos, ppu->z_pos); } } - else if(!IsPortExempted()) + else if (!IsPortExempted()) { - if(!IsMQExemptedArea(zone->GetZoneID(), ppu->x_pos, ppu->y_pos, ppu->z_pos)) + if (!IsMQExemptedArea(zone->GetZoneID(), ppu->x_pos, ppu->y_pos, ppu->z_pos)) { - if(speed > (runs * 2 * RuleR(Zone, MQWarpDetectionDistanceFactor))) + if (speed > (runs * 2 * RuleR(Zone, MQWarpDetectionDistanceFactor))) { m_TimeSinceLastPositionCheck = cur_time; m_DistanceSinceLastPositionCheck = 0.0f; @@ -4457,46 +4458,46 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) { m_DistanceSinceLastPositionCheck += dist; m_CheatDetectMoved = true; - if(m_TimeSinceLastPositionCheck == 0) + if (m_TimeSinceLastPositionCheck == 0) { m_TimeSinceLastPositionCheck = Timer::GetCurrentTime(); } else { uint32 cur_time = Timer::GetCurrentTime(); - if((cur_time - m_TimeSinceLastPositionCheck) > 2500) + if ((cur_time - m_TimeSinceLastPositionCheck) > 2500) { float speed = (m_DistanceSinceLastPositionCheck * 100) / (float)(cur_time - m_TimeSinceLastPositionCheck); int runs = GetRunspeed(); - if(speed > (runs * RuleR(Zone, MQWarpDetectionDistanceFactor))) + if (speed > (runs * RuleR(Zone, MQWarpDetectionDistanceFactor))) { - if(!GetGMSpeed() && (runs >= GetBaseRunspeed() || (speed > (GetBaseRunspeed() * RuleR(Zone, MQWarpDetectionDistanceFactor))))) + if (!GetGMSpeed() && (runs >= GetBaseRunspeed() || (speed > (GetBaseRunspeed() * RuleR(Zone, MQWarpDetectionDistanceFactor))))) { - if(IsShadowStepExempted()) + if (IsShadowStepExempted()) { - if(m_DistanceSinceLastPositionCheck > 800) + if (m_DistanceSinceLastPositionCheck > 800) { //if(!IsMQExemptedArea(zone->GetZoneID(), ppu->x_pos, ppu->y_pos, ppu->z_pos)) //{ - CheatDetected(MQWarpShadowStep, ppu->x_pos, ppu->y_pos, ppu->z_pos); - //Death(this, 10000000, SPELL_UNKNOWN, _1H_BLUNT); + CheatDetected(MQWarpShadowStep, ppu->x_pos, ppu->y_pos, ppu->z_pos); + //Death(this, 10000000, SPELL_UNKNOWN, _1H_BLUNT); //} } } - else if(IsKnockBackExempted()) + else if (IsKnockBackExempted()) { //still potential to trigger this if you're knocked back off a //HUGE fall that takes > 2.5 seconds - if(speed > 30.0f) + if (speed > 30.0f) { CheatDetected(MQWarpKnockBack, ppu->x_pos, ppu->y_pos, ppu->z_pos); } } - else if(!IsPortExempted()) + else if (!IsPortExempted()) { - if(!IsMQExemptedArea(zone->GetZoneID(), ppu->x_pos, ppu->y_pos, ppu->z_pos)) + if (!IsMQExemptedArea(zone->GetZoneID(), ppu->x_pos, ppu->y_pos, ppu->z_pos)) { - if(speed > (runs * 2 * RuleR(Zone, MQWarpDetectionDistanceFactor))) + if (speed > (runs * 2 * RuleR(Zone, MQWarpDetectionDistanceFactor))) { m_TimeSinceLastPositionCheck = cur_time; m_DistanceSinceLastPositionCheck = 0.0f; @@ -4519,7 +4520,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) } } - if(IsDraggingCorpse()) + if (IsDraggingCorpse()) DragCorpses(); } @@ -4542,11 +4543,11 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) //just update rewind coords to the new ppu coords. This will prevent exploitation. if ((rewind_x_diff > 5000) || (rewind_y_diff > 5000)) - m_RewindLocation = glm::vec3(ppu->x_pos, ppu->y_pos, ppu->z_pos); + m_RewindLocation = glm::vec3(ppu->x_pos, ppu->y_pos, ppu->z_pos); - if(proximity_timer.Check()) { + if (proximity_timer.Check()) { entity_list.ProcessMove(this, glm::vec3(ppu->x_pos, ppu->y_pos, ppu->z_pos)); - if(RuleB(TaskSystem, EnableTaskSystem) && RuleB(TaskSystem,EnableTaskProximity)) + if (RuleB(TaskSystem, EnableTaskSystem) && RuleB(TaskSystem, EnableTaskProximity)) ProcessTaskProximities(ppu->x_pos, ppu->y_pos, ppu->z_pos); m_Proximity = glm::vec3(ppu->x_pos, ppu->y_pos, ppu->z_pos); @@ -4555,19 +4556,19 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) // Update internal state m_Delta = glm::vec4(ppu->delta_x, ppu->delta_y, ppu->delta_z, ppu->delta_heading); - if(IsTracking() && ((m_Position.x!=ppu->x_pos) || (m_Position.y!=ppu->y_pos))){ - if(zone->random.Real(0, 100) < 70)//should be good + if (IsTracking() && ((m_Position.x != ppu->x_pos) || (m_Position.y != ppu->y_pos))) { + if (zone->random.Real(0, 100) < 70)//should be good CheckIncreaseSkill(EQEmu::skills::SkillTracking, nullptr, -20); } // Break Hide if moving without sneaking and set rewind timer if moved - if(ppu->y_pos != m_Position.y || ppu->x_pos != m_Position.x){ - if((hidden || improved_hidden) && !sneaking){ + if (ppu->y_pos != m_Position.y || ppu->x_pos != m_Position.x) { + if ((hidden || improved_hidden) && !sneaking) { hidden = false; improved_hidden = false; - if(!invisible) { + if (!invisible) { auto outapp = - new EQApplicationPacket(OP_SpawnAppearance, sizeof(SpawnAppearance_Struct)); + new EQApplicationPacket(OP_SpawnAppearance, sizeof(SpawnAppearance_Struct)); SpawnAppearance_Struct* sa_out = (SpawnAppearance_Struct*)outapp->pBuffer; sa_out->spawn_id = GetID(); sa_out->type = 0x03; @@ -4582,10 +4583,10 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) // Outgoing client packet float tmpheading = EQ19toFloat(ppu->heading); /* The clients send an update at best every 1.3 seconds - * We want to avoid reflecting these updates to other clients as much as possible - * The client also sends an update every 280 ms while turning, if we prevent - * sending these by checking if the location is the same too aggressively, clients end up spinning - * so keep a count of how many packets are the same within a tolerance and stop when we get there */ + * We want to avoid reflecting these updates to other clients as much as possible + * The client also sends an update every 280 ms while turning, if we prevent + * sending these by checking if the location is the same too aggressively, clients end up spinning + * so keep a count of how many packets are the same within a tolerance and stop when we get there */ bool pos_same = FCMP(ppu->y_pos, m_Position.y) && FCMP(ppu->x_pos, m_Position.x) && FCMP(tmpheading, m_Position.w) && ppu->animation == animation; if (!pos_same || (pos_same && position_update_same_count < 6)) @@ -4659,9 +4660,9 @@ void Client::Handle_OP_ConfirmDelete(const EQApplicationPacket* app) void Client::Handle_OP_Consent(const EQApplicationPacket *app) { - if(app->size<64){ + if (app->size<64) { Consent_Struct* c = (Consent_Struct*)app->pBuffer; - if(strcmp(c->name, GetName()) != 0) { + if (strcmp(c->name, GetName()) != 0) { auto pack = new ServerPacket(ServerOP_Consent, sizeof(ServerOP_Consent_Struct)); ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer; strcpy(scs->grantname, c->name); @@ -4683,7 +4684,7 @@ void Client::Handle_OP_Consent(const EQApplicationPacket *app) void Client::Handle_OP_ConsentDeny(const EQApplicationPacket *app) { - if(app->size<64){ + if (app->size<64) { Consent_Struct* c = (Consent_Struct*)app->pBuffer; auto pack = new ServerPacket(ServerOP_Consent, sizeof(ServerOP_Consent_Struct)); ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer; @@ -4704,7 +4705,7 @@ void Client::Handle_OP_Consider(const EQApplicationPacket *app) { if (app->size != sizeof(Consider_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in Consider expected %i got %i", sizeof(Consider_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in Consider expected %i got %i", sizeof(Consider_Struct), app->size); return; } Consider_Struct* conin = (Consider_Struct*)app->pBuffer; @@ -4798,7 +4799,7 @@ void Client::Handle_OP_ConsiderCorpse(const EQApplicationPacket *app) { if (app->size != sizeof(Consider_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in Consider corpse expected %i got %i", sizeof(Consider_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in Consider corpse expected %i got %i", sizeof(Consider_Struct), app->size); return; } Consider_Struct* conin = (Consider_Struct*)app->pBuffer; @@ -4858,7 +4859,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app) { if (app->size != sizeof(Consume_Struct)) { - Log.Out(Logs::General, Logs::Error, "OP size error: OP_Consume expected:%i got:%i", sizeof(Consume_Struct), app->size); + Log(Logs::General, Logs::Error, "OP size error: OP_Consume expected:%i got:%i", sizeof(Consume_Struct), app->size); return; } Consume_Struct* pcs = (Consume_Struct*)app->pBuffer; @@ -4895,7 +4896,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app) EQEmu::ItemInstance *myitem = GetInv().GetItem(pcs->slot); if (myitem == nullptr) { - Log.Out(Logs::General, Logs::Error, "Consuming from empty slot %d", pcs->slot); + Log(Logs::General, Logs::Error, "Consuming from empty slot %d", pcs->slot); return; } @@ -4907,7 +4908,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app) Consume(eat_item, EQEmu::item::ItemTypeDrink, pcs->slot, (pcs->auto_consumed == 0xffffffff)); } else { - Log.Out(Logs::General, Logs::Error, "OP_Consume: unknown type, type:%i", (int)pcs->type); + Log(Logs::General, Logs::Error, "OP_Consume: unknown type, type:%i", (int)pcs->type); return; } if (m_pp.hunger_level > 50000) @@ -4928,7 +4929,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app) void Client::Handle_OP_ControlBoat(const EQApplicationPacket *app) { if (app->size != sizeof(ControlBoat_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_ControlBoat, size=%i, expected %i", app->size, sizeof(ControlBoat_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_ControlBoat, size=%i, expected %i", app->size, sizeof(ControlBoat_Struct)); return; } ControlBoat_Struct* cbs = (ControlBoat_Struct*)app->pBuffer; @@ -5029,8 +5030,8 @@ void Client::Handle_OP_CrashDump(const EQApplicationPacket *app) void Client::Handle_OP_CreateObject(const EQApplicationPacket *app) { - if (Log.log_settings[Logs::Inventory].is_category_enabled) - Log.Out(Logs::Detail, Logs::Inventory, "Handle_OP_CreateObject() [psize: %u] %s", app->size, DumpPacketToString(app).c_str()); + if (LogSys.log_settings[Logs::Inventory].is_category_enabled) + Log(Logs::Detail, Logs::Inventory, "Handle_OP_CreateObject() [psize: %u] %s", app->size, DumpPacketToString(app).c_str()); DropItem(EQEmu::inventory::slotCursor); return; @@ -5098,7 +5099,7 @@ void Client::Handle_OP_CrystalReclaim(const EQApplicationPacket *app) void Client::Handle_OP_Damage(const EQApplicationPacket *app) { if (app->size != sizeof(CombatDamage_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received invalid sized OP_Damage: got %d, expected %d", app->size, + Log(Logs::General, Logs::Error, "Received invalid sized OP_Damage: got %d, expected %d", app->size, sizeof(CombatDamage_Struct)); DumpPacket(app); return; @@ -5136,7 +5137,7 @@ void Client::Handle_OP_DelegateAbility(const EQApplicationPacket *app) if (app->size != sizeof(DelegateAbility_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_DelegateAbility expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_DelegateAbility expected %i got %i", sizeof(DelegateAbility_Struct), app->size); DumpPacket(app); @@ -5286,11 +5287,11 @@ void Client::Handle_OP_DisarmTraps(const EQApplicationPacket *app) } else { - if (zone->random.Int(0, 99) < 25){ + if (zone->random.Int(0, 99) < 25) { Message(MT_Skills, "You set off the trap while trying to disarm it!"); trap->Trigger(this); } - else{ + else { Message(MT_Skills, "You failed to disarm a trap."); } } @@ -5306,7 +5307,7 @@ void Client::Handle_OP_DoGroupLeadershipAbility(const EQApplicationPacket *app) if (app->size != sizeof(DoGroupLeadershipAbility_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_DoGroupLeadershipAbility expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_DoGroupLeadershipAbility expected %i got %i", sizeof(DoGroupLeadershipAbility_Struct), app->size); DumpPacket(app); @@ -5358,8 +5359,8 @@ void Client::Handle_OP_DoGroupLeadershipAbility(const EQApplicationPacket *app) } default: - Log.Out(Logs::General, Logs::None, "Got unhandled OP_DoGroupLeadershipAbility Ability: %d Parameter: %d", - dglas->Ability, dglas->Parameter); + Log(Logs::General, Logs::None, "Got unhandled OP_DoGroupLeadershipAbility Ability: %d Parameter: %d", + dglas->Ability, dglas->Parameter); break; } } @@ -5430,7 +5431,7 @@ void Client::Handle_OP_Dye(const EQApplicationPacket *app) { if (app->size != sizeof(EQEmu::TintProfile)) printf("Wrong size of DyeStruct, Got: %i, Expected: %zu\n", app->size, sizeof(EQEmu::TintProfile)); - else{ + else { EQEmu::TintProfile* dye = (EQEmu::TintProfile*)app->pBuffer; DyeArmor(dye); } @@ -5440,7 +5441,7 @@ void Client::Handle_OP_Dye(const EQApplicationPacket *app) void Client::Handle_OP_Emote(const EQApplicationPacket *app) { if (app->size != sizeof(Emote_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received invalid sized " + Log(Logs::General, Logs::Error, "Received invalid sized " "OP_Emote: got %d, expected %d", app->size, sizeof(Emote_Struct)); DumpPacket(app); @@ -5531,7 +5532,7 @@ void Client::Handle_OP_EnvDamage(const EQApplicationPacket *app) } if (app->size != sizeof(EnvDamage2_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received invalid sized OP_EnvDamage: got %d, expected %d", app->size, + Log(Logs::General, Logs::Error, "Received invalid sized OP_EnvDamage: got %d, expected %d", app->size, sizeof(EnvDamage2_Struct)); DumpPacket(app); return; @@ -5585,7 +5586,7 @@ void Client::Handle_OP_EnvDamage(const EQApplicationPacket *app) void Client::Handle_OP_FaceChange(const EQApplicationPacket *app) { if (app->size != sizeof(FaceChange_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for OP_FaceChange: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for OP_FaceChange: Expected: %i, Got: %i", sizeof(FaceChange_Struct), app->size); return; } @@ -5618,7 +5619,7 @@ void Client::Handle_OP_FeignDeath(const EQApplicationPacket *app) Message(13, "Ability recovery time not yet met."); return; } - + int reuse = FeignDeathReuseTime; reuse -= GetSkillReuseTime(EQEmu::skills::SkillFeignDeath); @@ -5820,7 +5821,7 @@ void Client::Handle_OP_FriendsWho(const EQApplicationPacket *app) void Client::Handle_OP_GetGuildMOTD(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Received OP_GetGuildMOTD"); + Log(Logs::Detail, Logs::Guilds, "Received OP_GetGuildMOTD"); SendGuildMOTD(true); @@ -5833,7 +5834,7 @@ void Client::Handle_OP_GetGuildMOTD(const EQApplicationPacket *app) void Client::Handle_OP_GetGuildsList(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Received OP_GetGuildsList"); + Log(Logs::Detail, Logs::Guilds, "Received OP_GetGuildsList"); SendGuildList(); } @@ -5846,7 +5847,7 @@ void Client::Handle_OP_GMBecomeNPC(const EQApplicationPacket *app) return; } if (app->size != sizeof(BecomeNPC_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_GMBecomeNPC, size=%i, expected %i", app->size, sizeof(BecomeNPC_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_GMBecomeNPC, size=%i, expected %i", app->size, sizeof(BecomeNPC_Struct)); return; } //entity_list.QueueClients(this, app, false); @@ -5898,14 +5899,14 @@ void Client::Handle_OP_GMEmoteZone(const EQApplicationPacket *app) return; } if (app->size != sizeof(GMEmoteZone_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_GMEmoteZone, size=%i, expected %i", app->size, sizeof(GMEmoteZone_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_GMEmoteZone, size=%i, expected %i", app->size, sizeof(GMEmoteZone_Struct)); return; } GMEmoteZone_Struct* gmez = (GMEmoteZone_Struct*)app->pBuffer; char* newmessage = nullptr; if (strstr(gmez->text, "^") == 0) entity_list.Message(0, 15, gmez->text); - else{ + else { for (newmessage = strtok((char*)gmez->text, "^"); newmessage != nullptr; newmessage = strtok(nullptr, "^")) entity_list.Message(0, 15, newmessage); } @@ -5915,7 +5916,7 @@ void Client::Handle_OP_GMEmoteZone(const EQApplicationPacket *app) void Client::Handle_OP_GMEndTraining(const EQApplicationPacket *app) { if (app->size != sizeof(GMTrainEnd_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_GMEndTraining expected %i got %i", sizeof(GMTrainEnd_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_GMEndTraining expected %i got %i", sizeof(GMTrainEnd_Struct), app->size); DumpPacket(app); return; } @@ -5931,7 +5932,7 @@ void Client::Handle_OP_GMFind(const EQApplicationPacket *app) return; } if (app->size != sizeof(GMSummon_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_GMFind, size=%i, expected %i", app->size, sizeof(GMSummon_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_GMFind, size=%i, expected %i", app->size, sizeof(GMSummon_Struct)); return; } //Break down incoming @@ -5996,7 +5997,7 @@ void Client::Handle_OP_GMHideMe(const EQApplicationPacket *app) return; } if (app->size != sizeof(SpawnAppearance_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_GMHideMe, size=%i, expected %i", app->size, sizeof(SpawnAppearance_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_GMHideMe, size=%i, expected %i", app->size, sizeof(SpawnAppearance_Struct)); return; } SpawnAppearance_Struct* sa = (SpawnAppearance_Struct*)app->pBuffer; @@ -6046,7 +6047,7 @@ void Client::Handle_OP_GMKill(const EQApplicationPacket *app) return; } if (app->size != sizeof(GMKill_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_GMKill, size=%i, expected %i", app->size, sizeof(GMKill_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_GMKill, size=%i, expected %i", app->size, sizeof(GMKill_Struct)); return; } GMKill_Struct* gmk = (GMKill_Struct *)app->pBuffer; @@ -6113,17 +6114,17 @@ void Client::Handle_OP_GMLastName(const EQApplicationPacket *app) void Client::Handle_OP_GMNameChange(const EQApplicationPacket *app) { if (app->size != sizeof(GMName_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_GMNameChange, size=%i, expected %i", app->size, sizeof(GMName_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_GMNameChange, size=%i, expected %i", app->size, sizeof(GMName_Struct)); return; } const GMName_Struct* gmn = (const GMName_Struct *)app->pBuffer; - if (this->Admin() < minStatusToUseGMCommands){ + if (this->Admin() < minStatusToUseGMCommands) { Message(13, "Your account has been reported for hacking."); database.SetHackerFlag(this->account_name, this->name, "/name"); return; } Client* client = entity_list.GetClientByName(gmn->oldname); - Log.Out(Logs::General, Logs::Status, "GM(%s) changeing players name. Old:%s New:%s", GetName(), gmn->oldname, gmn->newname); + Log(Logs::General, Logs::Status, "GM(%s) changeing players name. Old:%s New:%s", GetName(), gmn->oldname, gmn->newname); bool usedname = database.CheckUsedName((const char*)gmn->newname); if (client == 0) { Message(13, "%s not found for name change. Operation failed!", gmn->oldname); @@ -6165,7 +6166,7 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app) if (app->size < sizeof(GMSearchCorpse_Struct)) { - Log.Out(Logs::General, Logs::None, "OP_GMSearchCorpse size lower than expected: got %u expected at least %u", + Log(Logs::General, Logs::None, "OP_GMSearchCorpse size lower than expected: got %u expected at least %u", app->size, sizeof(GMSearchCorpse_Struct)); DumpPacket(app); return; @@ -6287,7 +6288,7 @@ void Client::Handle_OP_GMToggle(const EQApplicationPacket *app) void Client::Handle_OP_GMTraining(const EQApplicationPacket *app) { if (app->size != sizeof(GMTrainee_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_GMTraining expected %i got %i", sizeof(GMTrainee_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_GMTraining expected %i got %i", sizeof(GMTrainee_Struct), app->size); DumpPacket(app); return; } @@ -6298,7 +6299,7 @@ void Client::Handle_OP_GMTraining(const EQApplicationPacket *app) void Client::Handle_OP_GMTrainSkill(const EQApplicationPacket *app) { if (app->size != sizeof(GMSkillChange_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_GMTrainSkill expected %i got %i", sizeof(GMSkillChange_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_GMTrainSkill expected %i got %i", sizeof(GMSkillChange_Struct), app->size); DumpPacket(app); return; } @@ -6366,7 +6367,7 @@ void Client::Handle_OP_GMZoneRequest2(const EQApplicationPacket *app) return; } if (app->size < sizeof(uint32)) { - Log.Out(Logs::General, Logs::Error, "OP size error: OP_GMZoneRequest2 expected:%i got:%i", sizeof(uint32), app->size); + Log(Logs::General, Logs::Error, "OP size error: OP_GMZoneRequest2 expected:%i got:%i", sizeof(uint32), app->size); return; } @@ -6383,7 +6384,7 @@ void Client::Handle_OP_GroupAcknowledge(const EQApplicationPacket *app) void Client::Handle_OP_GroupCancelInvite(const EQApplicationPacket *app) { if (app->size != sizeof(GroupCancel_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for OP_GroupCancelInvite: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for OP_GroupCancelInvite: Expected: %i, Got: %i", sizeof(GroupCancel_Struct), app->size); return; } @@ -6427,12 +6428,12 @@ void Client::Handle_OP_GroupDelete(const EQApplicationPacket *app) void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app) { if (app->size != sizeof(GroupGeneric_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for GroupGeneric_Struct: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for GroupGeneric_Struct: Expected: %i, Got: %i", sizeof(GroupGeneric_Struct), app->size); return; } - Log.Out(Logs::General, Logs::None, "Member Disband Request from %s\n", GetName()); + Log(Logs::General, Logs::None, "Member Disband Request from %s\n", GetName()); GroupGeneric_Struct* gd = (GroupGeneric_Struct*)app->pBuffer; @@ -6458,8 +6459,8 @@ void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app) //we have a raid.. see if we're in a raid group uint32 grp = raid->GetGroup(memberToDisband->GetName()); bool wasGrpLdr = raid->members[raid->GetPlayerIndex(memberToDisband->GetName())].IsGroupLeader; - if (grp < 12){ - if (wasGrpLdr){ + if (grp < 12) { + if (wasGrpLdr) { raid->SetGroupLeader(memberToDisband->GetName(), false); for (int x = 0; x < MAX_RAID_MEMBERS; x++) { @@ -6475,8 +6476,8 @@ void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app) } raid->MoveMember(memberToDisband->GetName(), 0xFFFFFFFF); raid->GroupUpdate(grp); //break - //raid->SendRaidGroupRemove(memberToDisband->GetName(), grp); - //raid->SendGroupUpdate(memberToDisband->CastToClient()); + //raid->SendRaidGroupRemove(memberToDisband->GetName(), grp); + //raid->SendGroupUpdate(memberToDisband->CastToClient()); raid->SendGroupDisband(memberToDisband->CastToClient()); } //we're done @@ -6588,7 +6589,7 @@ void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app) } else { - Log.Out(Logs::General, Logs::Error, "Failed to remove player from group. Unable to find player named %s in player group", gd->name2); + Log(Logs::General, Logs::Error, "Failed to remove player from group. Unable to find player named %s in player group", gd->name2); } } if (LFP) @@ -6608,7 +6609,7 @@ void Client::Handle_OP_GroupFollow(const EQApplicationPacket *app) void Client::Handle_OP_GroupFollow2(const EQApplicationPacket *app) { if (app->size != sizeof(GroupGeneric_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for OP_GroupFollow: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for OP_GroupFollow: Expected: %i, Got: %i", sizeof(GroupGeneric_Struct), app->size); return; } @@ -6657,7 +6658,7 @@ void Client::Handle_OP_GroupInvite(const EQApplicationPacket *app) void Client::Handle_OP_GroupInvite2(const EQApplicationPacket *app) { if (app->size != sizeof(GroupInvite_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for OP_GroupInvite: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for OP_GroupInvite: Expected: %i, Got: %i", sizeof(GroupInvite_Struct), app->size); return; } @@ -6676,14 +6677,14 @@ void Client::Handle_OP_GroupInvite2(const EQApplicationPacket *app) { if (Invitee->IsClient()) { - if(Invitee->CastToClient()->MercOnlyOrNoGroup() && !Invitee->IsRaidGrouped()) + if (Invitee->CastToClient()->MercOnlyOrNoGroup() && !Invitee->IsRaidGrouped()) { if (app->GetOpcode() == OP_GroupInvite2) { //Make a new packet using all the same information but make sure it's a fixed GroupInvite opcode so we //Don't have to deal with GroupFollow2 crap. auto outapp = - new EQApplicationPacket(OP_GroupInvite, sizeof(GroupInvite_Struct)); + new EQApplicationPacket(OP_GroupInvite, sizeof(GroupInvite_Struct)); memcpy(outapp->pBuffer, app->pBuffer, outapp->size); Invitee->CastToClient()->QueuePacket(outapp); safe_delete(outapp); @@ -6727,7 +6728,7 @@ void Client::Handle_OP_GroupMakeLeader(const EQApplicationPacket *app) if (g->IsLeader(this)) g->ChangeLeader(NewLeader); else { - Log.Out(Logs::General, Logs::None, "Group /makeleader request originated from non-leader member: %s", GetName()); + Log(Logs::General, Logs::None, "Group /makeleader request originated from non-leader member: %s", GetName()); DumpPacket(app); } } @@ -6736,7 +6737,7 @@ void Client::Handle_OP_GroupMakeLeader(const EQApplicationPacket *app) void Client::Handle_OP_GroupMentor(const EQApplicationPacket *app) { if (app->size != sizeof(GroupMentor_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_GroupMentor, size=%i, expected %i", app->size, sizeof(GroupMentor_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_GroupMentor, size=%i, expected %i", app->size, sizeof(GroupMentor_Struct)); DumpPacket(app); return; } @@ -6772,7 +6773,7 @@ void Client::Handle_OP_GroupMentor(const EQApplicationPacket *app) void Client::Handle_OP_GroupRoles(const EQApplicationPacket *app) { if (app->size != sizeof(GroupRole_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_GroupRoles, size=%i, expected %i", app->size, sizeof(GroupRole_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_GroupRoles, size=%i, expected %i", app->size, sizeof(GroupRole_Struct)); DumpPacket(app); return; } @@ -6818,7 +6819,7 @@ void Client::Handle_OP_GroupUpdate(const EQApplicationPacket *app) { if (app->size != sizeof(GroupUpdate_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch on OP_GroupUpdate: got %u expected %u", + Log(Logs::General, Logs::None, "Size mismatch on OP_GroupUpdate: got %u expected %u", app->size, sizeof(GroupUpdate_Struct)); DumpPacket(app); return; @@ -6837,7 +6838,7 @@ void Client::Handle_OP_GroupUpdate(const EQApplicationPacket *app) if (group->IsLeader(this)) group->ChangeLeader(newleader); else { - Log.Out(Logs::General, Logs::None, "Group /makeleader request originated from non-leader member: %s", GetName()); + Log(Logs::General, Logs::None, "Group /makeleader request originated from non-leader member: %s", GetName()); DumpPacket(app); } } @@ -6846,7 +6847,7 @@ void Client::Handle_OP_GroupUpdate(const EQApplicationPacket *app) default: { - Log.Out(Logs::General, Logs::None, "Received unhandled OP_GroupUpdate requesting action %u", gu->action); + Log(Logs::General, Logs::None, "Received unhandled OP_GroupUpdate requesting action %u", gu->action); DumpPacket(app); return; } @@ -6866,7 +6867,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) } if (app->size < sizeof(uint32)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_GuildBank, size=%i, expected %i", app->size, sizeof(uint32)); + Log(Logs::General, Logs::Error, "Wrong size: OP_GuildBank, size=%i, expected %i", app->size, sizeof(uint32)); DumpPacket(app); return; } @@ -6892,7 +6893,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) { if ((Action != GuildBankDeposit) && (Action != GuildBankViewItem) && (Action != GuildBankWithdraw)) { - Log.Out(Logs::General, Logs::Error, "Suspected hacking attempt on guild bank from %s", GetName()); + Log(Logs::General, Logs::Error, "Suspected hacking attempt on guild bank from %s", GetName()); GuildBankAck(); @@ -7053,7 +7054,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) if (!IsGuildBanker() && !GuildBanks->AllowedToWithdraw(GuildID(), gbwis->Area, gbwis->SlotID, GetName())) { - Log.Out(Logs::General, Logs::Error, "Suspected attempted hack on the guild bank from %s", GetName()); + Log(Logs::General, Logs::Error, "Suspected attempted hack on the guild bank from %s", GetName()); GuildBankAck(); @@ -7124,7 +7125,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) { Message(13, "Unexpected GuildBank action."); - Log.Out(Logs::General, Logs::Error, "Received unexpected guild bank action code %i from %s", Action, GetName()); + Log(Logs::General, Logs::Error, "Received unexpected guild bank action code %i from %s", Action, GetName()); } } } @@ -7195,7 +7196,7 @@ void Client::Handle_OP_GuildCreate(const EQApplicationPacket *app) uint32 NewGuildID = guild_mgr.CreateGuild(GuildName, CharacterID()); - Log.Out(Logs::Detail, Logs::Guilds, "%s: Creating guild %s with leader %d via UF+ GUI. It was given id %lu.", GetName(), + Log(Logs::Detail, Logs::Guilds, "%s: Creating guild %s with leader %d via UF+ GUI. It was given id %lu.", GetName(), GuildName, CharacterID(), (unsigned long)NewGuildID); if (NewGuildID == GUILD_NONE) @@ -7217,12 +7218,12 @@ void Client::Handle_OP_GuildCreate(const EQApplicationPacket *app) void Client::Handle_OP_GuildDelete(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Received OP_GuildDelete"); + Log(Logs::Detail, Logs::Guilds, "Received OP_GuildDelete"); if (!IsInAGuild() || !guild_mgr.IsGuildLeader(GuildID(), CharacterID())) Message(0, "You are not a guild leader or not in a guild."); else { - Log.Out(Logs::Detail, Logs::Guilds, "Deleting guild %s (%d)", guild_mgr.GetGuildName(GuildID()), GuildID()); + Log(Logs::Detail, Logs::Guilds, "Deleting guild %s (%d)", guild_mgr.GetGuildName(GuildID()), GuildID()); if (!guild_mgr.DeleteGuild(GuildID())) Message(0, "Guild delete failed."); else { @@ -7233,10 +7234,10 @@ void Client::Handle_OP_GuildDelete(const EQApplicationPacket *app) void Client::Handle_OP_GuildDemote(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Received OP_GuildDemote"); + Log(Logs::Detail, Logs::Guilds, "Received OP_GuildDemote"); if (app->size != sizeof(GuildDemoteStruct)) { - Log.Out(Logs::Detail, Logs::Guilds, "Error: app size of %i != size of GuildDemoteStruct of %i\n", app->size, sizeof(GuildDemoteStruct)); + Log(Logs::Detail, Logs::Guilds, "Error: app size of %i != size of GuildDemoteStruct of %i\n", app->size, sizeof(GuildDemoteStruct)); return; } @@ -7266,7 +7267,7 @@ void Client::Handle_OP_GuildDemote(const EQApplicationPacket *app) uint8 rank = gci.rank - 1; - Log.Out(Logs::Detail, Logs::Guilds, "Demoting %s (%d) from rank %s (%d) to %s (%d) in %s (%d)", + Log(Logs::Detail, Logs::Guilds, "Demoting %s (%d) from rank %s (%d) to %s (%d) in %s (%d)", demote->target, gci.char_id, guild_mgr.GetRankName(GuildID(), gci.rank), gci.rank, guild_mgr.GetRankName(GuildID(), rank), rank, @@ -7284,7 +7285,7 @@ void Client::Handle_OP_GuildDemote(const EQApplicationPacket *app) void Client::Handle_OP_GuildInvite(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Received OP_GuildInvite"); + Log(Logs::Detail, Logs::Guilds, "Received OP_GuildInvite"); if (app->size != sizeof(GuildCommand_Struct)) { std::cout << "Wrong size: OP_GuildInvite, size=" << app->size << ", expected " << sizeof(GuildCommand_Struct) << std::endl; @@ -7325,7 +7326,7 @@ void Client::Handle_OP_GuildInvite(const EQApplicationPacket *app) //we could send this to the member and prompt them to see if they want to //be demoted (I guess), but I dont see a point in that. - Log.Out(Logs::Detail, Logs::Guilds, "%s (%d) is demoting %s (%d) to rank %d in guild %s (%d)", + Log(Logs::Detail, Logs::Guilds, "%s (%d) is demoting %s (%d) to rank %d in guild %s (%d)", GetName(), CharacterID(), client->GetName(), client->CharacterID(), gc->officer, @@ -7344,7 +7345,7 @@ void Client::Handle_OP_GuildInvite(const EQApplicationPacket *app) return; } - Log.Out(Logs::Detail, Logs::Guilds, "%s (%d) is asking to promote %s (%d) to rank %d in guild %s (%d)", + Log(Logs::Detail, Logs::Guilds, "%s (%d) is asking to promote %s (%d) to rank %d in guild %s (%d)", GetName(), CharacterID(), client->GetName(), client->CharacterID(), gc->officer, @@ -7356,7 +7357,7 @@ void Client::Handle_OP_GuildInvite(const EQApplicationPacket *app) if (gc->guildeqid == 0) gc->guildeqid = GuildID(); - Log.Out(Logs::Detail, Logs::Guilds, "Sending OP_GuildInvite for promotion to %s, length %d", client->GetName(), app->size); + Log(Logs::Detail, Logs::Guilds, "Sending OP_GuildInvite for promotion to %s, length %d", client->GetName(), app->size); client->QueuePacket(app); } @@ -7379,7 +7380,7 @@ void Client::Handle_OP_GuildInvite(const EQApplicationPacket *app) return; } - Log.Out(Logs::Detail, Logs::Guilds, "Inviting %s (%d) into guild %s (%d)", + Log(Logs::Detail, Logs::Guilds, "Inviting %s (%d) into guild %s (%d)", client->GetName(), client->CharacterID(), guild_mgr.GetGuildName(GuildID()), GuildID()); @@ -7399,7 +7400,7 @@ void Client::Handle_OP_GuildInvite(const EQApplicationPacket *app) gc->officer = 8; } - Log.Out(Logs::Detail, Logs::Guilds, "Sending OP_GuildInvite for invite to %s, length %d", client->GetName(), app->size); + Log(Logs::Detail, Logs::Guilds, "Sending OP_GuildInvite for invite to %s, length %d", client->GetName(), app->size); client->SetPendingGuildInvitation(true); client->QueuePacket(app); @@ -7422,7 +7423,7 @@ void Client::Handle_OP_GuildInvite(const EQApplicationPacket *app) void Client::Handle_OP_GuildInviteAccept(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Received OP_GuildInviteAccept"); + Log(Logs::Detail, Logs::Guilds, "Received OP_GuildInviteAccept"); SetPendingGuildInvitation(false); @@ -7460,7 +7461,7 @@ void Client::Handle_OP_GuildInviteAccept(const EQApplicationPacket *app) else if (!worldserver.Connected()) Message(0, "Error: World server disconnected"); else { - Log.Out(Logs::Detail, Logs::Guilds, "Guild Invite Accept: guild %d, response %d, inviter %s, person %s", + Log(Logs::Detail, Logs::Guilds, "Guild Invite Accept: guild %d, response %d, inviter %s, person %s", gj->guildeqid, gj->response, gj->inviter, gj->newmember); //ok, the invite is also used for changing rank as well. @@ -7490,7 +7491,7 @@ void Client::Handle_OP_GuildInviteAccept(const EQApplicationPacket *app) if (gj->guildeqid == GuildID()) { //only need to change rank. - Log.Out(Logs::Detail, Logs::Guilds, "Changing guild rank of %s (%d) to rank %d in guild %s (%d)", + Log(Logs::Detail, Logs::Guilds, "Changing guild rank of %s (%d) to rank %d in guild %s (%d)", GetName(), CharacterID(), gj->response, guild_mgr.GetGuildName(GuildID()), GuildID()); @@ -7502,7 +7503,7 @@ void Client::Handle_OP_GuildInviteAccept(const EQApplicationPacket *app) } else { - Log.Out(Logs::Detail, Logs::Guilds, "Adding %s (%d) to guild %s (%d) at rank %d", + Log(Logs::Detail, Logs::Guilds, "Adding %s (%d) to guild %s (%d) at rank %d", GetName(), CharacterID(), guild_mgr.GetGuildName(gj->guildeqid), gj->guildeqid, gj->response); @@ -7531,10 +7532,10 @@ void Client::Handle_OP_GuildInviteAccept(const EQApplicationPacket *app) void Client::Handle_OP_GuildLeader(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Received OP_GuildLeader"); + Log(Logs::Detail, Logs::Guilds, "Received OP_GuildLeader"); if (app->size < 2) { - Log.Out(Logs::Detail, Logs::Guilds, "Invalid length %d on OP_GuildLeader", app->size); + Log(Logs::Detail, Logs::Guilds, "Invalid length %d on OP_GuildLeader", app->size); return; } @@ -7553,11 +7554,11 @@ void Client::Handle_OP_GuildLeader(const EQApplicationPacket *app) Client* newleader = entity_list.GetClientByName(gml->target); if (newleader) { - Log.Out(Logs::Detail, Logs::Guilds, "Transfering leadership of %s (%d) to %s (%d)", + Log(Logs::Detail, Logs::Guilds, "Transfering leadership of %s (%d) to %s (%d)", guild_mgr.GetGuildName(GuildID()), GuildID(), newleader->GetName(), newleader->CharacterID()); - if (guild_mgr.SetGuildLeader(GuildID(), newleader->CharacterID())){ + if (guild_mgr.SetGuildLeader(GuildID(), newleader->CharacterID())) { Message(0, "Successfully Transfered Leadership to %s.", gml->target); newleader->Message(15, "%s has transfered the guild leadership into your hands.", GetName()); } @@ -7574,9 +7575,9 @@ void Client::Handle_OP_GuildLeader(const EQApplicationPacket *app) void Client::Handle_OP_GuildManageBanker(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Got OP_GuildManageBanker of len %d", app->size); + Log(Logs::Detail, Logs::Guilds, "Got OP_GuildManageBanker of len %d", app->size); if (app->size != sizeof(GuildManageBanker_Struct)) { - Log.Out(Logs::Detail, Logs::Guilds, "Error: app size of %i != size of OP_GuildManageBanker of %i\n", app->size, sizeof(GuildManageBanker_Struct)); + Log(Logs::Detail, Logs::Guilds, "Error: app size of %i != size of OP_GuildManageBanker of %i\n", app->size, sizeof(GuildManageBanker_Struct)); return; } GuildManageBanker_Struct* gmb = (GuildManageBanker_Struct*)app->pBuffer; @@ -7651,16 +7652,16 @@ void Client::Handle_OP_GuildManageBanker(const EQApplicationPacket *app) void Client::Handle_OP_GuildPeace(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Got OP_GuildPeace of len %d", app->size); + Log(Logs::Detail, Logs::Guilds, "Got OP_GuildPeace of len %d", app->size); return; } void Client::Handle_OP_GuildPromote(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Received OP_GuildPromote"); + Log(Logs::Detail, Logs::Guilds, "Received OP_GuildPromote"); if (app->size != sizeof(GuildPromoteStruct)) { - Log.Out(Logs::Detail, Logs::Guilds, "Error: app size of %i != size of GuildDemoteStruct of %i\n", app->size, sizeof(GuildPromoteStruct)); + Log(Logs::Detail, Logs::Guilds, "Error: app size of %i != size of GuildDemoteStruct of %i\n", app->size, sizeof(GuildPromoteStruct)); return; } @@ -7692,7 +7693,7 @@ void Client::Handle_OP_GuildPromote(const EQApplicationPacket *app) } - Log.Out(Logs::Detail, Logs::Guilds, "Promoting %s (%d) from rank %s (%d) to %s (%d) in %s (%d)", + Log(Logs::Detail, Logs::Guilds, "Promoting %s (%d) from rank %s (%d) to %s (%d) in %s (%d)", promote->target, gci.char_id, guild_mgr.GetRankName(GuildID(), gci.rank), gci.rank, guild_mgr.GetRankName(GuildID(), rank), rank, @@ -7709,7 +7710,7 @@ void Client::Handle_OP_GuildPromote(const EQApplicationPacket *app) void Client::Handle_OP_GuildPublicNote(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Received OP_GuildPublicNote"); + Log(Logs::Detail, Logs::Guilds, "Received OP_GuildPublicNote"); if (app->size < sizeof(GuildUpdate_PublicNote)) { // client calls for a motd on login even if they arent in a guild @@ -7728,7 +7729,7 @@ void Client::Handle_OP_GuildPublicNote(const EQApplicationPacket *app) return; } - Log.Out(Logs::Detail, Logs::Guilds, "Setting public note on %s (%d) in guild %s (%d) to: %s", + Log(Logs::Detail, Logs::Guilds, "Setting public note on %s (%d) in guild %s (%d) to: %s", gpn->target, gci.char_id, guild_mgr.GetGuildName(GuildID()), GuildID(), gpn->note); @@ -7745,7 +7746,7 @@ void Client::Handle_OP_GuildPublicNote(const EQApplicationPacket *app) void Client::Handle_OP_GuildRemove(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Received OP_GuildRemove"); + Log(Logs::Detail, Logs::Guilds, "Received OP_GuildRemove"); if (app->size != sizeof(GuildCommand_Struct)) { std::cout << "Wrong size: OP_GuildRemove, size=" << app->size << ", expected " << sizeof(GuildCommand_Struct) << std::endl; @@ -7775,7 +7776,7 @@ void Client::Handle_OP_GuildRemove(const EQApplicationPacket *app) } char_id = client->CharacterID(); - Log.Out(Logs::Detail, Logs::Guilds, "Removing %s (%d) from guild %s (%d)", + Log(Logs::Detail, Logs::Guilds, "Removing %s (%d) from guild %s (%d)", client->GetName(), client->CharacterID(), guild_mgr.GetGuildName(GuildID()), GuildID()); } @@ -7791,7 +7792,7 @@ void Client::Handle_OP_GuildRemove(const EQApplicationPacket *app) } char_id = gci.char_id; - Log.Out(Logs::Detail, Logs::Guilds, "Removing remote/offline %s (%d) into guild %s (%d)", + Log(Logs::Detail, Logs::Guilds, "Removing remote/offline %s (%d) into guild %s (%d)", gci.char_name.c_str(), gci.char_id, guild_mgr.GetGuildName(GuildID()), GuildID()); } @@ -7816,7 +7817,7 @@ void Client::Handle_OP_GuildStatus(const EQApplicationPacket *app) { if (app->size != sizeof(GuildStatus_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_GuildStatus expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_GuildStatus expected %i got %i", sizeof(GuildStatus_Struct), app->size); DumpPacket(app); @@ -7873,7 +7874,7 @@ void Client::Handle_OP_GuildUpdateURLAndChannel(const EQApplicationPacket *app) { if (app->size != sizeof(GuildUpdateURLAndChannel_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_GuildUpdateURLAndChannel expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_GuildUpdateURLAndChannel expected %i got %i", sizeof(GuildUpdateURLAndChannel_Struct), app->size); DumpPacket(app); @@ -7901,7 +7902,7 @@ void Client::Handle_OP_GuildUpdateURLAndChannel(const EQApplicationPacket *app) void Client::Handle_OP_GuildWar(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Got OP_GuildWar of len %d", app->size); + Log(Logs::Detail, Logs::Guilds, "Got OP_GuildWar of len %d", app->size); return; } @@ -7916,7 +7917,7 @@ void Client::Handle_OP_Hide(const EQApplicationPacket *app) if (app->size == 4) { auto data = app->ReadUInt32(0); if (data) - Log.Out(Logs::Detail, Logs::None, "Got OP_Hide with unexpected data %d", data); + Log(Logs::Detail, Logs::None, "Got OP_Hide with unexpected data %d", data); return; } @@ -7948,7 +7949,7 @@ void Client::Handle_OP_Hide(const EQApplicationPacket *app) sa_out->parameter = 1; entity_list.QueueClients(this, outapp, true); safe_delete(outapp); - if (spellbonuses.ShroudofStealth || aabonuses.ShroudofStealth || itembonuses.ShroudofStealth){ + if (spellbonuses.ShroudofStealth || aabonuses.ShroudofStealth || itembonuses.ShroudofStealth) { improved_hidden = true; hidden = true; } @@ -7956,7 +7957,7 @@ void Client::Handle_OP_Hide(const EQApplicationPacket *app) hidden = true; tmHidden = Timer::GetCurrentTime(); } - if (GetClass() == ROGUE){ + if (GetClass() == ROGUE) { auto outapp = new EQApplicationPacket(OP_SimpleMessage, sizeof(SimpleMessage_Struct)); SimpleMessage_Struct *msg = (SimpleMessage_Struct *)outapp->pBuffer; msg->color = 0x010E; @@ -7972,7 +7973,7 @@ void Client::Handle_OP_Hide(const EQApplicationPacket *app) } } else { - if (hidden){ + if (hidden) { msg->string_id = HIDE_SUCCESS; } else { @@ -7990,7 +7991,7 @@ void Client::Handle_OP_HideCorpse(const EQApplicationPacket *app) // if (app->size != sizeof(HideCorpse_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_HideCorpse expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_HideCorpse expected %i got %i", sizeof(HideCorpse_Struct), app->size); DumpPacket(app); @@ -8019,7 +8020,7 @@ void Client::Handle_OP_Ignore(const EQApplicationPacket *app) void Client::Handle_OP_Illusion(const EQApplicationPacket *app) { if (app->size != sizeof(Illusion_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received invalid sized OP_Illusion: got %d, expected %d", app->size, + Log(Logs::General, Logs::Error, "Received invalid sized OP_Illusion: got %d, expected %d", app->size, sizeof(Illusion_Struct)); DumpPacket(app); return; @@ -8049,7 +8050,7 @@ void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app) { if (app->size != sizeof(InspectResponse_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_InspectAnswer, size=%i, expected %i", app->size, sizeof(InspectResponse_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_InspectAnswer, size=%i, expected %i", app->size, sizeof(InspectResponse_Struct)); return; } @@ -8104,7 +8105,7 @@ void Client::Handle_OP_InspectMessageUpdate(const EQApplicationPacket *app) { if (app->size != sizeof(InspectMessage_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_InspectMessageUpdate, size=%i, expected %i", app->size, sizeof(InspectMessage_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_InspectMessageUpdate, size=%i, expected %i", app->size, sizeof(InspectMessage_Struct)); return; } @@ -8118,7 +8119,7 @@ void Client::Handle_OP_InspectRequest(const EQApplicationPacket *app) { if (app->size != sizeof(Inspect_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_InspectRequest, size=%i, expected %i", app->size, sizeof(Inspect_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_InspectRequest, size=%i, expected %i", app->size, sizeof(Inspect_Struct)); return; } @@ -8127,7 +8128,7 @@ void Client::Handle_OP_InspectRequest(const EQApplicationPacket *app) if (tmp != 0 && tmp->IsClient()) { if (tmp->CastToClient()->ClientVersion() < EQEmu::versions::ClientVersion::SoF) { tmp->CastToClient()->QueuePacket(app); } // Send request to target - // Inspecting an SoF or later client will make the server handle the request + // Inspecting an SoF or later client will make the server handle the request else { ProcessInspectRequest(tmp->CastToClient(), this); } } @@ -8155,7 +8156,7 @@ void Client::Handle_OP_InstillDoubt(const EQApplicationPacket *app) void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app) { if (app->size != sizeof(ItemViewRequest_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size on OP_ItemLinkClick. Got: %i, Expected: %i", app->size, + Log(Logs::General, Logs::Error, "Wrong size on OP_ItemLinkClick. Got: %i, Expected: %i", app->size, sizeof(ItemViewRequest_Struct)); DumpPacket(app); return; @@ -8205,29 +8206,33 @@ void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app) if (silentsaylink) { parse->EventNPC(EVENT_SAY, GetTarget()->CastToNPC(), this, response.c_str(), 0); parse->EventPlayer(EVENT_SAY, this, response.c_str(), 0); - } else { - Message(7, "You say, '%s'", response.c_str()); - ChannelMessageReceived(8, 0, 100, response.c_str()); } - return; - } else { - if (silentsaylink) { - parse->EventPlayer(EVENT_SAY, this, response.c_str(), 0); - } else { + else { Message(7, "You say, '%s'", response.c_str()); ChannelMessageReceived(8, 0, 100, response.c_str()); } return; } - } else { + else { + if (silentsaylink) { + parse->EventPlayer(EVENT_SAY, this, response.c_str(), 0); + } + else { + Message(7, "You say, '%s'", response.c_str()); + ChannelMessageReceived(8, 0, 100, response.c_str()); + } + return; + } + } + else { Message(13, "Error: Say Link not found or is too long."); return; } } EQEmu::ItemInstance *inst = - database.CreateItem(item, item->MaxCharges, ivrs->augments[0], ivrs->augments[1], ivrs->augments[2], - ivrs->augments[3], ivrs->augments[4], ivrs->augments[5]); + database.CreateItem(item, item->MaxCharges, ivrs->augments[0], ivrs->augments[1], ivrs->augments[2], + ivrs->augments[3], ivrs->augments[4], ivrs->augments[5]); if (inst) { SendItemPacket(0, inst, ItemPacketViewLink); safe_delete(inst); @@ -8238,7 +8243,7 @@ void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app) void Client::Handle_OP_ItemLinkResponse(const EQApplicationPacket *app) { if (app->size != sizeof(LDONItemViewRequest_Struct)) { - Log.Out(Logs::General, Logs::Error, "OP size error: OP_ItemLinkResponse expected:%i got:%i", sizeof(LDONItemViewRequest_Struct), app->size); + Log(Logs::General, Logs::Error, "OP size error: OP_ItemLinkResponse expected:%i got:%i", sizeof(LDONItemViewRequest_Struct), app->size); return; } LDONItemViewRequest_Struct* item = (LDONItemViewRequest_Struct*)app->pBuffer; @@ -8253,7 +8258,7 @@ void Client::Handle_OP_ItemLinkResponse(const EQApplicationPacket *app) void Client::Handle_OP_ItemName(const EQApplicationPacket *app) { if (app->size != sizeof(ItemNamePacket_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for ItemNamePacket_Struct: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for ItemNamePacket_Struct: Expected: %i, Got: %i", sizeof(ItemNamePacket_Struct), app->size); return; } @@ -8278,7 +8283,7 @@ void Client::Handle_OP_ItemPreview(const EQApplicationPacket *app) if (item) { auto outapp = new EQApplicationPacket(OP_ItemPreview, strlen(item->Name) + strlen(item->Lore) + - strlen(item->IDFile) + 898); + strlen(item->IDFile) + 898); int spacer; for (spacer = 0; spacer < 16; spacer++) { @@ -8453,7 +8458,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) using EQEmu::CastingSlot; if (app->size != sizeof(ItemVerifyRequest_Struct)) { - Log.Out(Logs::General, Logs::Error, "OP size error: OP_ItemVerifyRequest expected:%i got:%i", sizeof(ItemVerifyRequest_Struct), app->size); + Log(Logs::General, Logs::Error, "OP size error: OP_ItemVerifyRequest expected:%i got:%i", sizeof(ItemVerifyRequest_Struct), app->size); return; } @@ -8481,7 +8486,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) } if (slot_id < 0) { - Log.Out(Logs::General, Logs::None, "Unknown slot being used by %s, slot being used is: %i", GetName(), request->slot); + Log(Logs::General, Logs::None, "Unknown slot being used by %s, slot being used is: %i", GetName(), request->slot); return; } @@ -8503,28 +8508,28 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) if ( - spell_id > 0 && - ( - !IsValidSpell(spell_id) || - casting_spell_id || - delaytimer || - spellend_timer.Enabled() || - IsStunned() || - IsFeared() || - IsMezzed() || - DivineAura() || - (spells[spell_id].targettype == ST_Ring) || - (IsSilenced() && !IsDiscipline(spell_id)) || - (IsAmnesiad() && IsDiscipline(spell_id)) || - (IsDetrimentalSpell(spell_id) && !zone->CanDoCombat()) - ) - ) + spell_id > 0 && + ( + !IsValidSpell(spell_id) || + casting_spell_id || + delaytimer || + spellend_timer.Enabled() || + IsStunned() || + IsFeared() || + IsMezzed() || + DivineAura() || + (spells[spell_id].targettype == ST_Ring) || + (IsSilenced() && !IsDiscipline(spell_id)) || + (IsAmnesiad() && IsDiscipline(spell_id)) || + (IsDetrimentalSpell(spell_id) && !zone->CanDoCombat()) + ) + ) { SendSpellBarEnable(spell_id); return; } - Log.Out(Logs::General, Logs::None, "OP ItemVerifyRequest: spell=%i, target=%i, inv=%i", spell_id, target_id, slot_id); + Log(Logs::General, Logs::None, "OP ItemVerifyRequest: spell=%i, target=%i, inv=%i", spell_id, target_id, slot_id); if (m_inv.SupportsClickCasting(slot_id) || ((item->ItemType == EQEmu::item::ItemTypePotion || item->PotionBelt) && m_inv.SupportsPotionBeltCasting(slot_id))) // sanity check { @@ -8562,7 +8567,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) if ((spell_id <= 0) && (item->ItemType != EQEmu::item::ItemTypeFood && item->ItemType != EQEmu::item::ItemTypeDrink && item->ItemType != EQEmu::item::ItemTypeAlcohol && item->ItemType != EQEmu::item::ItemTypeSpell)) { - Log.Out(Logs::General, Logs::None, "Item with no effect right clicked by %s", GetName()); + Log(Logs::General, Logs::None, "Item with no effect right clicked by %s", GetName()); } else if (inst->IsClassCommon()) { @@ -8639,7 +8644,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) { if (item->ItemType != EQEmu::item::ItemTypeFood && item->ItemType != EQEmu::item::ItemTypeDrink && item->ItemType != EQEmu::item::ItemTypeAlcohol) { - Log.Out(Logs::General, Logs::None, "Error: unknown item->Click.Type (%i)", item->Click.Type); + Log(Logs::General, Logs::None, "Error: unknown item->Click.Type (%i)", item->Click.Type); } else { @@ -8655,7 +8660,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) else if (item->ItemType == EQEmu::item::ItemTypeAlcohol) { #if EQDEBUG >= 1 - Log.Out(Logs::General, Logs::None, "Drinking Alcohol from slot:%i", slot_id); + Log(Logs::General, Logs::None, "Drinking Alcohol from slot:%i", slot_id); #endif // This Seems to be handled in OP_DeleteItem handling //DeleteItemInInventory(slot_id, 1, false); @@ -8682,7 +8687,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) } else { - Log.Out(Logs::General, Logs::None, "Error: unknown item->Click.Type (%i)", item->Click.Type); + Log(Logs::General, Logs::None, "Error: unknown item->Click.Type (%i)", item->Click.Type); } } } @@ -8731,8 +8736,8 @@ void Client::Handle_OP_LDoNButton(const EQApplicationPacket *app) if (*p == true) { auto pack = - new ServerPacket(ServerOP_AdventureRequestCreate, - sizeof(ServerAdventureRequestCreate_Struct) + (64 * adv_requested_member_count)); + new ServerPacket(ServerOP_AdventureRequestCreate, + sizeof(ServerAdventureRequestCreate_Struct) + (64 * adv_requested_member_count)); ServerAdventureRequestCreate_Struct *sac = (ServerAdventureRequestCreate_Struct*)pack->pBuffer; strcpy(sac->leader, GetName()); sac->id = adv_requested_id; @@ -8824,7 +8829,7 @@ void Client::Handle_OP_LDoNSenseTraps(const EQApplicationPacket *app) void Client::Handle_OP_LeadershipExpToggle(const EQApplicationPacket *app) { if (app->size != 1) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_LeadershipExpToggle expected %i got %i", 1, app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_LeadershipExpToggle expected %i got %i", 1, app->size); DumpPacket(app); return; } @@ -8911,7 +8916,7 @@ void Client::Handle_OP_LFGGetMatchesRequest(const EQApplicationPacket *app) { if (app->size != sizeof(LFGGetMatchesRequest_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_LFGGetMatchesRequest, size=%i, expected %i", app->size, sizeof(LFGGetMatchesRequest_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_LFGGetMatchesRequest, size=%i, expected %i", app->size, sizeof(LFGGetMatchesRequest_Struct)); DumpPacket(app); return; } @@ -8994,8 +8999,8 @@ void Client::Handle_OP_LFGuild(const EQApplicationPacket *app) return; auto pack = - new ServerPacket(ServerOP_QueryServGeneric, strlen(GetName()) + strlen(gts->Comment) + - strlen(guild_mgr.GetGuildName(GuildID())) + 43); + new ServerPacket(ServerOP_QueryServGeneric, strlen(GetName()) + strlen(gts->Comment) + + strlen(guild_mgr.GetGuildName(GuildID())) + 43); pack->WriteUInt32(zone->GetZoneID()); pack->WriteUInt32(zone->GetInstanceID()); @@ -9073,7 +9078,7 @@ void Client::Handle_OP_LFPCommand(const EQApplicationPacket *app) { if (app->size != sizeof(LFP_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_LFPCommand, size=%i, expected %i", app->size, sizeof(LFP_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_LFPCommand, size=%i, expected %i", app->size, sizeof(LFP_Struct)); DumpPacket(app); return; } @@ -9110,7 +9115,7 @@ void Client::Handle_OP_LFPCommand(const EQApplicationPacket *app) // This should not happen. The client checks if you are in a group and will not let you put LFP on if // you are not the leader. if (!g->IsLeader(this)) { - Log.Out(Logs::General, Logs::Error, "Client sent LFP on for character %s who is grouped but not leader.", GetName()); + Log(Logs::General, Logs::Error, "Client sent LFP on for character %s who is grouped but not leader.", GetName()); return; } // Fill the LFPMembers array with the rest of the group members, excluding ourself @@ -9135,7 +9140,7 @@ void Client::Handle_OP_LFPGetMatchesRequest(const EQApplicationPacket *app) { if (app->size != sizeof(LFPGetMatchesRequest_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_LFPGetMatchesRequest, size=%i, expected %i", app->size, sizeof(LFPGetMatchesRequest_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_LFPGetMatchesRequest, size=%i, expected %i", app->size, sizeof(LFPGetMatchesRequest_Struct)); DumpPacket(app); return; } @@ -9175,7 +9180,7 @@ void Client::Handle_OP_LoadSpellSet(const EQApplicationPacket *app) void Client::Handle_OP_Logout(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::None, "%s sent a logout packet.", GetName()); + Log(Logs::Detail, Logs::None, "%s sent a logout packet.", GetName()); SendLogoutPackets(); @@ -9189,7 +9194,7 @@ void Client::Handle_OP_Logout(const EQApplicationPacket *app) void Client::Handle_OP_LootItem(const EQApplicationPacket *app) { if (app->size != sizeof(LootingItem_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_LootItem, size=%i, expected %i", app->size, sizeof(LootingItem_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_LootItem, size=%i, expected %i", app->size, sizeof(LootingItem_Struct)); return; } @@ -9256,7 +9261,7 @@ void Client::Handle_OP_ManaChange(const EQApplicationPacket *app) } else // I don't think the client sends proper manachanges { // with a length, just the 0 len ones for stopping songs - //ManaChange_Struct* p = (ManaChange_Struct*)app->pBuffer; + //ManaChange_Struct* p = (ManaChange_Struct*)app->pBuffer; printf("OP_ManaChange from client:\n"); DumpPacket(app); } @@ -9268,11 +9273,11 @@ void Client::Handle_OP_ManaChange(const EQApplicationPacket *app) // when the client is sitting void Client::Handle_OP_Medding(const EQApplicationPacket *app) { - if (app->pBuffer[0]) - medding = true; - else - medding = false; - return; +if (app->pBuffer[0]) +medding = true; +else +medding = false; +return; } #endif */ @@ -9300,7 +9305,7 @@ void Client::Handle_OP_Mend(const EQApplicationPacket *app) int criticalchance = spellbonuses.CriticalMend + itembonuses.CriticalMend + aabonuses.CriticalMend; - if (zone->random.Int(0, 99) < criticalchance){ + if (zone->random.Int(0, 99) < criticalchance) { mendhp *= 2; Message_StringID(4, MEND_CRITICAL); } @@ -9334,7 +9339,7 @@ void Client::Handle_OP_MercenaryCommand(const EQApplicationPacket *app) if (app->size != sizeof(MercenaryCommand_Struct)) { Message(13, "Size mismatch in OP_MercenaryCommand expected %i got %i", sizeof(MercenaryCommand_Struct), app->size); - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_MercenaryCommand expected %i got %i", sizeof(MercenaryCommand_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_MercenaryCommand expected %i got %i", sizeof(MercenaryCommand_Struct), app->size); DumpPacket(app); return; } @@ -9343,7 +9348,7 @@ void Client::Handle_OP_MercenaryCommand(const EQApplicationPacket *app) uint32 merc_command = mc->MercCommand; // Seen 0 (zone in with no merc or suspended), 1 (dismiss merc), 5 (normal state), 20 (unknown), 36 (zone in with merc) int32 option = mc->Option; // Seen -1 (zone in with no merc), 0 (setting to passive stance), 1 (normal or setting to balanced stance) - Log.Out(Logs::General, Logs::Mercenaries, "Command %i, Option %i received from %s.", merc_command, option, GetName()); + Log(Logs::General, Logs::Mercenaries, "Command %i, Option %i received from %s.", merc_command, option, GetName()); if (!RuleB(Mercs, AllowMercs)) return; @@ -9377,7 +9382,7 @@ void Client::Handle_OP_MercenaryCommand(const EQApplicationPacket *app) merc->SetStance(mercTemplate->Stances[option]); GetMercInfo().Stance = mercTemplate->Stances[option]; - Log.Out(Logs::General, Logs::Mercenaries, "Set Stance: %u for %s (%s)", merc->GetStance(), merc->GetName(), GetName()); + Log(Logs::General, Logs::Mercenaries, "Set Stance: %u for %s (%s)", merc->GetStance(), merc->GetName(), GetName()); } } } @@ -9389,7 +9394,7 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app) // The payload is 4 bytes. The EntityID of the Mercenary Liason which are of class 71. if (app->size != sizeof(MercenaryMerchantShopRequest_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_MercenaryDataRequest expected 4 got %i", app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_MercenaryDataRequest expected 4 got %i", app->size); DumpPacket(app); @@ -9400,7 +9405,7 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app) uint32 merchant_id = mmsr->MercMerchantID; uint32 altCurrentType = 19; - Log.Out(Logs::General, Logs::Mercenaries, "Data Request for Merchant ID (%i) for %s.", merchant_id, GetName()); + Log(Logs::General, Logs::Mercenaries, "Data Request for Merchant ID (%i) for %s.", merchant_id, GetName()); //client is requesting data about currently owned mercenary if (merchant_id == 0) { @@ -9408,12 +9413,12 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app) //send info about your current merc(s) if (GetMercInfo().mercid) { - Log.Out(Logs::General, Logs::Mercenaries, "SendMercPersonalInfo Request for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SendMercPersonalInfo Request for %s.", GetName()); SendMercPersonalInfo(); } else { - Log.Out(Logs::General, Logs::Mercenaries, "SendMercPersonalInfo Not Sent - MercID (%i) for %s.", GetMercInfo().mercid, GetName()); + Log(Logs::General, Logs::Mercenaries, "SendMercPersonalInfo Not Sent - MercID (%i) for %s.", GetMercInfo().mercid, GetName()); } } @@ -9461,7 +9466,7 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app) if (mercTypeCount > 0) { for (auto mercTypeListItr = mercTypeList.begin(); mercTypeListItr != mercTypeList.end(); - ++mercTypeListItr) { + ++mercTypeListItr) { mml->MercGrades[i] = mercTypeListItr->Type; // DBStringID for Type i++; } @@ -9472,7 +9477,7 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app) { i = 0; for (auto mercListIter = mercDataList.begin(); mercListIter != mercDataList.end(); - ++mercListIter) { + ++mercListIter) { mml->Mercs[i].MercID = mercListIter->MercTemplateID; mml->Mercs[i].MercType = mercListIter->MercType; mml->Mercs[i].MercSubType = mercListIter->MercSubType; @@ -9521,12 +9526,12 @@ void Client::Handle_OP_MercenaryDataUpdateRequest(const EQApplicationPacket *app if (app->size != 0) { Message(13, "Size mismatch in OP_MercenaryDataUpdateRequest expected 0 got %i", app->size); - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_MercenaryDataUpdateRequest expected 0 got %i", app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_MercenaryDataUpdateRequest expected 0 got %i", app->size); DumpPacket(app); return; } - Log.Out(Logs::General, Logs::Mercenaries, "Data Update Request Received for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "Data Update Request Received for %s.", GetName()); if (GetMercID()) { @@ -9540,7 +9545,7 @@ void Client::Handle_OP_MercenaryDismiss(const EQApplicationPacket *app) if (app->size > 1) { Message(13, "Size mismatch in OP_MercenaryDismiss expected 0 got %i", app->size); - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_MercenaryDismiss expected 0 got %i", app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_MercenaryDismiss expected 0 got %i", app->size); DumpPacket(app); return; } @@ -9552,7 +9557,7 @@ void Client::Handle_OP_MercenaryDismiss(const EQApplicationPacket *app) Command = VARSTRUCT_DECODE_TYPE(uint8, InBuffer); } - Log.Out(Logs::General, Logs::Mercenaries, "Dismiss Request ( %i ) Received for %s.", Command, GetName()); + Log(Logs::General, Logs::Mercenaries, "Dismiss Request ( %i ) Received for %s.", Command, GetName()); // Handle the dismiss here... DismissMerc(GetMercInfo().mercid); @@ -9564,7 +9569,7 @@ void Client::Handle_OP_MercenaryHire(const EQApplicationPacket *app) // The payload is 16 bytes. First four bytes are the Merc ID (Template ID) if (app->size != sizeof(MercenaryMerchantRequest_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_MercenaryHire expected %i got %i", sizeof(MercenaryMerchantRequest_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_MercenaryHire expected %i got %i", sizeof(MercenaryMerchantRequest_Struct), app->size); DumpPacket(app); @@ -9577,7 +9582,7 @@ void Client::Handle_OP_MercenaryHire(const EQApplicationPacket *app) uint32 merc_unk1 = mmrq->MercUnk01; uint32 merc_unk2 = mmrq->MercUnk02; - Log.Out(Logs::General, Logs::Mercenaries, "Template ID (%i), Merchant ID (%i), Unknown1 (%i), Unknown2 (%i), Client: %s", merc_template_id, merchant_id, merc_unk1, merc_unk2, GetName()); + Log(Logs::General, Logs::Mercenaries, "Template ID (%i), Merchant ID (%i), Unknown1 (%i), Unknown2 (%i), Client: %s", merc_template_id, merchant_id, merc_unk1, merc_unk2, GetName()); //HirePending = true; SetHoTT(0); @@ -9635,7 +9640,7 @@ void Client::Handle_OP_MercenarySuspendRequest(const EQApplicationPacket *app) if (app->size != sizeof(SuspendMercenary_Struct)) { Message(13, "Size mismatch in OP_MercenarySuspendRequest expected %i got %i", sizeof(SuspendMercenary_Struct), app->size); - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_MercenarySuspendRequest expected %i got %i", sizeof(SuspendMercenary_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_MercenarySuspendRequest expected %i got %i", sizeof(SuspendMercenary_Struct), app->size); DumpPacket(app); return; } @@ -9643,7 +9648,7 @@ void Client::Handle_OP_MercenarySuspendRequest(const EQApplicationPacket *app) SuspendMercenary_Struct* sm = (SuspendMercenary_Struct*)app->pBuffer; uint32 merc_suspend = sm->SuspendMerc; // Seen 30 for suspending or unsuspending - Log.Out(Logs::General, Logs::Mercenaries, "Suspend ( %i ) received for %s.", merc_suspend, GetName()); + Log(Logs::General, Logs::Mercenaries, "Suspend ( %i ) received for %s.", merc_suspend, GetName()); if (!RuleB(Mercs, AllowMercs)) return; @@ -9658,12 +9663,12 @@ void Client::Handle_OP_MercenaryTimerRequest(const EQApplicationPacket *app) if (app->size > 1) { Message(13, "Size mismatch in OP_MercenaryTimerRequest expected 0 got %i", app->size); - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_MercenaryTimerRequest expected 0 got %i", app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_MercenaryTimerRequest expected 0 got %i", app->size); DumpPacket(app); return; } - Log.Out(Logs::General, Logs::Mercenaries, "Timer Request received for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "Timer Request received for %s.", GetName()); if (!RuleB(Mercs, AllowMercs)) { return; @@ -9694,8 +9699,8 @@ void Client::Handle_OP_MercenaryTimerRequest(const EQApplicationPacket *app) void Client::Handle_OP_MoveCoin(const EQApplicationPacket *app) { - if (app->size != sizeof(MoveCoin_Struct)){ - Log.Out(Logs::General, Logs::Error, "Wrong size on OP_MoveCoin. Got: %i, Expected: %i", app->size, sizeof(MoveCoin_Struct)); + if (app->size != sizeof(MoveCoin_Struct)) { + Log(Logs::General, Logs::Error, "Wrong size on OP_MoveCoin. Got: %i, Expected: %i", app->size, sizeof(MoveCoin_Struct)); DumpPacket(app); return; } @@ -9711,7 +9716,7 @@ void Client::Handle_OP_MoveItem(const EQApplicationPacket *app) } if (app->size != sizeof(MoveItem_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_MoveItem, size=%i, expected %i", app->size, sizeof(MoveItem_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_MoveItem, size=%i, expected %i", app->size, sizeof(MoveItem_Struct)); return; } @@ -9794,7 +9799,7 @@ void Client::Handle_OP_OpenContainer(const EQApplicationPacket *app) void Client::Handle_OP_OpenGuildTributeMaster(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Tribute, "Received OP_OpenGuildTributeMaster of length %d", app->size); + Log(Logs::Detail, Logs::Tribute, "Received OP_OpenGuildTributeMaster of length %d", app->size); if (app->size != sizeof(StartTribute_Struct)) printf("Error in OP_OpenGuildTributeMaster. Expected size of: %zu, but got: %i\n", sizeof(StartTribute_Struct), app->size); @@ -9825,7 +9830,7 @@ void Client::Handle_OP_OpenInventory(const EQApplicationPacket *app) void Client::Handle_OP_OpenTributeMaster(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Tribute, "Received OP_OpenTributeMaster of length %d", app->size); + Log(Logs::Detail, Logs::Tribute, "Received OP_OpenTributeMaster of length %d", app->size); if (app->size != sizeof(StartTribute_Struct)) printf("Error in OP_OpenTributeMaster. Expected size of: %zu, but got: %i\n", sizeof(StartTribute_Struct), app->size); @@ -9851,7 +9856,7 @@ void Client::Handle_OP_OpenTributeMaster(const EQApplicationPacket *app) void Client::Handle_OP_PDeletePetition(const EQApplicationPacket *app) { if (app->size < 2) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_PDeletePetition, size=%i, expected %i", app->size, 2); + Log(Logs::General, Logs::Error, "Wrong size: OP_PDeletePetition, size=%i, expected %i", app->size, 2); return; } if (petition_list.DeletePetitionByCharName((char*)app->pBuffer)) @@ -9864,7 +9869,7 @@ void Client::Handle_OP_PDeletePetition(const EQApplicationPacket *app) void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) { if (app->size != sizeof(PetCommand_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_PetCommands, size=%i, expected %i", app->size, sizeof(PetCommand_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_PetCommands, size=%i, expected %i", app->size, sizeof(PetCommand_Struct)); return; } char val1[20] = { 0 }; @@ -9909,9 +9914,9 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) /* if (GetClientVersion() >= EQClientUnderfoot) { - if (PetCommand == PET_SITDOWN) - if (mypet->GetPetOrder() == SPO_Sit) - PetCommand = PET_STANDUP; + if (PetCommand == PET_SITDOWN) + if (mypet->GetPetOrder() == SPO_Sit) + PetCommand = PET_STANDUP; } */ @@ -10167,7 +10172,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) break; } case PET_HOLD: { - if (GetAA(aaPetDiscipline) && mypet->IsNPC()){ + if (GetAA(aaPetDiscipline) && mypet->IsNPC()) { if (mypet->IsFeared()) break; //could be exploited like PET_BACKOFF @@ -10322,7 +10327,7 @@ void Client::Handle_OP_PetitionBug(const EQApplicationPacket *app) { if (app->size != sizeof(PetitionBug_Struct)) printf("Wrong size of BugStruct! Expected: %zu, Got: %i\n", sizeof(PetitionBug_Struct), app->size); - else{ + else { Message(0, "Petition Bugs are not supported, please use /bug."); } return; @@ -10331,7 +10336,7 @@ void Client::Handle_OP_PetitionBug(const EQApplicationPacket *app) void Client::Handle_OP_PetitionCheckIn(const EQApplicationPacket *app) { if (app->size != sizeof(Petition_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_PetitionCheckIn, size=%i, expected %i", app->size, sizeof(Petition_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_PetitionCheckIn, size=%i, expected %i", app->size, sizeof(Petition_Struct)); return; } Petition_Struct* inpet = (Petition_Struct*)app->pBuffer; @@ -10375,7 +10380,7 @@ void Client::Handle_OP_PetitionCheckout(const EQApplicationPacket *app) void Client::Handle_OP_PetitionDelete(const EQApplicationPacket *app) { if (app->size != sizeof(PetitionUpdate_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_PetitionDelete, size=%i, expected %i", app->size, sizeof(PetitionUpdate_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_PetitionDelete, size=%i, expected %i", app->size, sizeof(PetitionUpdate_Struct)); return; } auto outapp = new EQApplicationPacket(OP_PetitionUpdate, sizeof(PetitionUpdate_Struct)); @@ -10470,7 +10475,7 @@ void Client::Handle_OP_PickPocket(const EQApplicationPacket *app) { if (app->size != sizeof(PickPocket_Struct)) { - Log.Out(Logs::General, Logs::Error, "Size mismatch for Pick Pocket packet"); + Log(Logs::General, Logs::Error, "Size mismatch for Pick Pocket packet"); DumpPacket(app); } @@ -10492,7 +10497,7 @@ void Client::Handle_OP_PickPocket(const EQApplicationPacket *app) return; p_timers.Start(pTimerBeggingPickPocket, 8); - if (victim == this){ + if (victim == this) { Message(0, "You catch yourself red-handed."); auto outapp = new EQApplicationPacket(OP_PickPocket, sizeof(sPickPocket_Struct)); sPickPocket_Struct* pick_out = (sPickPocket_Struct*)outapp->pBuffer; @@ -10505,7 +10510,7 @@ void Client::Handle_OP_PickPocket(const EQApplicationPacket *app) QueuePacket(outapp); safe_delete(outapp); } - else if (victim->GetOwnerID()){ + else if (victim->GetOwnerID()) { Message(0, "You cannot steal from pets!"); auto outapp = new EQApplicationPacket(OP_PickPocket, sizeof(sPickPocket_Struct)); sPickPocket_Struct* pick_out = (sPickPocket_Struct*)outapp->pBuffer; @@ -10518,10 +10523,10 @@ void Client::Handle_OP_PickPocket(const EQApplicationPacket *app) QueuePacket(outapp); safe_delete(outapp); } - else if (victim->IsNPC()){ + else if (victim->IsNPC()) { victim->CastToNPC()->PickPocket(this); } - else{ + else { Message(0, "Stealing from clients not yet supported."); auto outapp = new EQApplicationPacket(OP_PickPocket, sizeof(sPickPocket_Struct)); sPickPocket_Struct* pick_out = (sPickPocket_Struct*)outapp->pBuffer; @@ -10540,7 +10545,7 @@ void Client::Handle_OP_PopupResponse(const EQApplicationPacket *app) { if (app->size != sizeof(PopupResponse_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_PopupResponse expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_PopupResponse expected %i got %i", sizeof(PopupResponse_Struct), app->size); DumpPacket(app); return; @@ -10575,15 +10580,15 @@ void Client::Handle_OP_PopupResponse(const EQApplicationPacket *app) void Client::Handle_OP_PotionBelt(const EQApplicationPacket *app) { if (app->size != sizeof(MovePotionToBelt_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_PotionBelt expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_PotionBelt expected %i got %i", sizeof(MovePotionToBelt_Struct), app->size); DumpPacket(app); return; } MovePotionToBelt_Struct *mptbs = (MovePotionToBelt_Struct*)app->pBuffer; - if(!EQEmu::ValueWithin(mptbs->SlotNumber, 0U, 3U)) { - Log.Out(Logs::General, Logs::None, "Client::Handle_OP_PotionBelt mptbs->SlotNumber out of range."); + if (!EQEmu::ValueWithin(mptbs->SlotNumber, 0U, 3U)) { + Log(Logs::General, Logs::None, "Client::Handle_OP_PotionBelt mptbs->SlotNumber out of range."); return; } @@ -10606,7 +10611,7 @@ void Client::Handle_OP_PotionBelt(const EQApplicationPacket *app) void Client::Handle_OP_PurchaseLeadershipAA(const EQApplicationPacket *app) { if (app->size != sizeof(uint32)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_LeadershipExpToggle expected %i got %i", 1, app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_LeadershipExpToggle expected %i got %i", 1, app->size); DumpPacket(app); return; } @@ -10641,7 +10646,8 @@ void Client::Handle_OP_PurchaseLeadershipAA(const EQApplicationPacket *app) m_pp.leader_abilities.ranks[aaid]++; database.SaveCharacterLeadershipAA(this->CharacterID(), &m_pp); - } else { + } + else { //it is a group ability. if (cost > m_pp.group_leadership_points) { Message(13, "You do not have enough points to purchase this ability."); @@ -10674,12 +10680,14 @@ void Client::Handle_OP_PurchaseLeadershipAA(const EQApplicationPacket *app) if (aaid >= raidAAMarkNPC) { r->UpdateRaidAAs(); r->SendAllRaidLeadershipAA(); - } else { + } + else { uint32 gid = r->GetGroup(this); r->UpdateGroupAAs(gid); r->GroupUpdate(gid, false); } - } else if (IsGrouped()) { + } + else if (IsGrouped()) { Group *g = GetGroup(); if (!g) return; @@ -10696,7 +10704,7 @@ void Client::Handle_OP_PVPLeaderBoardDetailsRequest(const EQApplicationPacket *a // if (app->size != sizeof(PVPLeaderBoardDetailsRequest_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_PVPLeaderBoardDetailsRequest expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_PVPLeaderBoardDetailsRequest expected %i got %i", sizeof(PVPLeaderBoardDetailsRequest_Struct), app->size); DumpPacket(app); @@ -10723,7 +10731,7 @@ void Client::Handle_OP_PVPLeaderBoardRequest(const EQApplicationPacket *app) // if (app->size != sizeof(PVPLeaderBoardRequest_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_PVPLeaderBoardRequest expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_PVPLeaderBoardRequest expected %i got %i", sizeof(PVPLeaderBoardRequest_Struct), app->size); DumpPacket(app); @@ -10735,7 +10743,7 @@ void Client::Handle_OP_PVPLeaderBoardRequest(const EQApplicationPacket *app) auto outapp = new EQApplicationPacket(OP_PVPLeaderBoardReply, sizeof(PVPLeaderBoard_Struct)); /*PVPLeaderBoard_Struct *pvplb = (PVPLeaderBoard_Struct *)outapp->pBuffer;*/ //unused - // TODO: Record and send this data. + // TODO: Record and send this data. QueuePacket(outapp); safe_delete(outapp); @@ -10744,7 +10752,7 @@ void Client::Handle_OP_PVPLeaderBoardRequest(const EQApplicationPacket *app) void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) { if (app->size < sizeof(RaidGeneral_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_RaidCommand, size=%i, expected at least %i", app->size, sizeof(RaidGeneral_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_RaidCommand, size=%i, expected at least %i", app->size, sizeof(RaidGeneral_Struct)); DumpPacket(app); return; } @@ -10781,35 +10789,35 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) } case RaidCommandAcceptInvite: { Client *i = entity_list.GetClientByName(ri->player_name); - if (i){ - if (IsRaidGrouped()){ + if (i) { + if (IsRaidGrouped()) { i->Message_StringID(0, ALREADY_IN_RAID, GetName()); //group failed, must invite members not in raid... return; } Raid *r = entity_list.GetRaidByClient(i); - if (r){ + if (r) { r->VerifyRaid(); Group *g = GetGroup(); - if (g){ + if (g) { if (g->GroupCount() + r->RaidCount() > MAX_RAID_MEMBERS) { i->Message(13, "Invite failed, group invite would create a raid larger than the maximum number of members allowed."); return; } } - else{ + else { if (1 + r->RaidCount() > MAX_RAID_MEMBERS) { i->Message(13, "Invite failed, member invite would create a raid larger than the maximum number of members allowed."); return; } } - if (g){//add us all + if (g) {//add us all uint32 freeGroup = r->GetFreeGroup(); Client *addClient = nullptr; for (int x = 0; x < 6; x++) { - if (g->members[x]){ + if (g->members[x]) { Client *c = nullptr; if (g->members[x]->IsClient()) c = g->members[x]->CastToClient(); @@ -10838,7 +10846,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) g->DisbandGroup(true); r->GroupUpdate(freeGroup); } - else{ + else { r->SendRaidCreate(this); r->SendMakeLeaderPacketTo(r->leadername, this); r->AddMember(this); @@ -10859,18 +10867,18 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) r->SetRaidDetails(); uint32 groupFree = r->GetFreeGroup(); //get a free group - if (ig){ //if we already have a group then cycle through adding us... + if (ig) { //if we already have a group then cycle through adding us... Client *addClientig = nullptr; for (int x = 0; x < 6; x++) { - if (ig->members[x]){ - if (!addClientig){ - if (ig->members[x]->IsClient()){ + if (ig->members[x]) { + if (!addClientig) { + if (ig->members[x]->IsClient()) { addClientig = ig->members[x]->CastToClient(); r->SetGroupLeader(addClientig->GetName()); } } - if (ig->IsLeader(ig->members[x])){ + if (ig->IsLeader(ig->members[x])) { Client *c = nullptr; if (ig->members[x]->IsClient()) c = ig->members[x]->CastToClient(); @@ -10884,7 +10892,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) r->SendRaidLockTo(c); } } - else{ + else { Client *c = nullptr; if (ig->members[x]->IsClient()) c = ig->members[x]->CastToClient(); @@ -10905,7 +10913,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) r->GroupUpdate(groupFree); groupFree = r->GetFreeGroup(); } - else{ //else just add the inviter + else { //else just add the inviter r->SendRaidCreate(i); r->AddMember(i, 0xFFFFFFFF, true, false, true); } @@ -10914,10 +10922,10 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) //now add the existing group for (int x = 0; x < 6; x++) { - if (g->members[x]){ + if (g->members[x]) { if (!addClient) { - if (g->members[x]->IsClient()){ + if (g->members[x]->IsClient()) { addClient = g->members[x]->CastToClient(); r->SetGroupLeader(addClient->GetName()); } @@ -10960,7 +10968,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) } else // target does not have a group { - if (ig){ + if (ig) { r = new Raid(i); entity_list.AddRaid(r); r->SetRaidDetails(); @@ -10969,8 +10977,8 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) { if (ig->members[x]) { - if (!addClientig){ - if (ig->members[x]->IsClient()){ + if (!addClientig) { + if (ig->members[x]->IsClient()) { addClientig = ig->members[x]->CastToClient(); r->SetGroupLeader(addClientig->GetName()); } @@ -11020,7 +11028,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) r->SendRaidLockTo(this); } } - else{ // neither has a group + else { // neither has a group r = new Raid(i); entity_list.AddRaid(r); r->SetRaidDetails(); @@ -11041,16 +11049,16 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) } case RaidCommandDisband: { Raid *r = entity_list.GetRaidByClient(this); - if (r){ + if (r) { //if(this == r->GetLeader()){ uint32 grp = r->GetGroup(ri->leader_name); - if (grp < 12){ + if (grp < 12) { uint32 i = r->GetPlayerIndex(ri->leader_name); - if (r->members[i].IsGroupLeader){ //assign group leader to someone else - for (int x = 0; x < MAX_RAID_MEMBERS; x++){ - if (strlen(r->members[x].membername) > 0 && i != x){ - if (r->members[x].GroupNumber == grp){ + if (r->members[i].IsGroupLeader) { //assign group leader to someone else + for (int x = 0; x < MAX_RAID_MEMBERS; x++) { + if (strlen(r->members[x].membername) > 0 && i != x) { + if (r->members[x].GroupNumber == grp) { r->SetGroupLeader(ri->leader_name, false); r->SetGroupLeader(r->members[x].membername); r->UpdateGroupAAs(grp); @@ -11060,8 +11068,8 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) } } - if (r->members[i].IsRaidLeader){ - for (int x = 0; x < MAX_RAID_MEMBERS; x++){ + if (r->members[i].IsRaidLeader) { + for (int x = 0; x < MAX_RAID_MEMBERS; x++) { if (strlen(r->members[x].membername) > 0 && strcmp(r->members[x].membername, r->members[i].membername) != 0) { r->SetRaidLeader(r->members[i].membername, r->members[x].membername); @@ -11077,9 +11085,9 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) Client *c = entity_list.GetClientByName(ri->leader_name); if (c) r->SendGroupDisband(c); - else{ + else { auto pack = - new ServerPacket(ServerOP_RaidGroupDisband, sizeof(ServerRaidGeneralAction_Struct)); + new ServerPacket(ServerOP_RaidGroupDisband, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); rga->zoneid = zone->GetZoneID(); @@ -11090,7 +11098,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) } //r->SendRaidGroupRemove(ri->leader_name, grp); r->GroupUpdate(grp);// break - //} + //} } break; } @@ -11113,7 +11121,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) if (r->members[r->GetPlayerIndex(ri->leader_name)].IsGroupLeader) { r->SetGroupLeader(ri->leader_name, false); - if (oldgrp < 12){ //we were the leader of our old grp + if (oldgrp < 12) { //we were the leader of our old grp for (int x = 0; x < MAX_RAID_MEMBERS; x++) //assign a new grp leader if we can { if (r->members[x].GroupNumber == oldgrp) @@ -11123,7 +11131,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) r->SetGroupLeader(r->members[x].membername); r->UpdateGroupAAs(oldgrp); Client *cgl = entity_list.GetClientByName(r->members[x].membername); - if (cgl){ + if (cgl) { r->SendRaidRemove(r->members[x].membername, cgl); r->SendRaidCreate(cgl); r->SendMakeLeaderPacketTo(r->leadername, cgl); @@ -11133,11 +11141,11 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) r->SendRaidLockTo(cgl); } } - else{ + else { auto pack = new ServerPacket( - ServerOP_RaidChangeGroup, - sizeof( - ServerRaidGeneralAction_Struct)); + ServerOP_RaidChangeGroup, + sizeof( + ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = r->GetID(); strn0cpy(rga->playername, r->members[x].membername, 64); @@ -11158,12 +11166,12 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) } r->MoveMember(ri->leader_name, ri->parameter); - if (c){ + if (c) { r->SendGroupDisband(c); } - else{ + else { auto pack = new ServerPacket(ServerOP_RaidGroupDisband, - sizeof(ServerRaidGeneralAction_Struct)); + sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = r->GetID(); rga->zoneid = zone->GetZoneID(); @@ -11187,7 +11195,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) { Client *c = entity_list.GetClientByName(ri->leader_name); uint32 oldgrp = r->GetGroup(ri->leader_name); - if (r->members[r->GetPlayerIndex(ri->leader_name)].IsGroupLeader){ + if (r->members[r->GetPlayerIndex(ri->leader_name)].IsGroupLeader) { r->SetGroupLeader(ri->leader_name, false); for (int x = 0; x < MAX_RAID_MEMBERS; x++) { @@ -11196,7 +11204,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) r->SetGroupLeader(r->members[x].membername); r->UpdateGroupAAs(oldgrp); Client *cgl = entity_list.GetClientByName(r->members[x].membername); - if (cgl){ + if (cgl) { r->SendRaidRemove(r->members[x].membername, cgl); r->SendRaidCreate(cgl); r->SendMakeLeaderPacketTo(r->leadername, cgl); @@ -11206,10 +11214,10 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) r->SendRaidLockTo(cgl); } } - else{ + else { auto pack = new ServerPacket( - ServerOP_RaidChangeGroup, - sizeof(ServerRaidGeneralAction_Struct)); + ServerOP_RaidChangeGroup, + sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = r->GetID(); strn0cpy(rga->playername, r->members[x].membername, 64); @@ -11223,12 +11231,12 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) } } r->MoveMember(ri->leader_name, 0xFFFFFFFF); - if (c){ + if (c) { r->SendGroupDisband(c); } - else{ + else { auto pack = new ServerPacket(ServerOP_RaidGroupDisband, - sizeof(ServerRaidGeneralAction_Struct)); + sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = r->GetID(); rga->zoneid = zone->GetZoneID(); @@ -11309,7 +11317,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) Raid *r = entity_list.GetRaidByClient(this); if (r) { - if (strcmp(r->leadername, GetName()) == 0){ + if (strcmp(r->leadername, GetName()) == 0) { r->SetRaidLeader(GetName(), ri->leader_name); r->UpdateRaidAAs(); r->SendAllRaidLeadershipAA(); @@ -11341,7 +11349,7 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app) void Client::Handle_OP_RandomReq(const EQApplicationPacket *app) { if (app->size != sizeof(RandomReq_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_RandomReq, size=%i, expected %i", app->size, sizeof(RandomReq_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_RandomReq, size=%i, expected %i", app->size, sizeof(RandomReq_Struct)); return; } const RandomReq_Struct* rndq = (const RandomReq_Struct*)app->pBuffer; @@ -11370,7 +11378,7 @@ void Client::Handle_OP_RandomReq(const EQApplicationPacket *app) void Client::Handle_OP_ReadBook(const EQApplicationPacket *app) { if (app->size != sizeof(BookRequest_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_ReadBook, size=%i, expected %i", app->size, sizeof(BookRequest_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_ReadBook, size=%i, expected %i", app->size, sizeof(BookRequest_Struct)); return; } BookRequest_Struct* book = (BookRequest_Struct*)app->pBuffer; @@ -11386,7 +11394,7 @@ void Client::Handle_OP_ReadBook(const EQApplicationPacket *app) void Client::Handle_OP_RecipeAutoCombine(const EQApplicationPacket *app) { if (app->size != sizeof(RecipeAutoCombine_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for RecipeAutoCombine_Struct: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for RecipeAutoCombine_Struct: Expected: %i, Got: %i", sizeof(RecipeAutoCombine_Struct), app->size); return; } @@ -11400,7 +11408,7 @@ void Client::Handle_OP_RecipeAutoCombine(const EQApplicationPacket *app) void Client::Handle_OP_RecipeDetails(const EQApplicationPacket *app) { if (app->size < sizeof(uint32)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for RecipeDetails Request: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for RecipeDetails Request: Expected: %i, Got: %i", sizeof(uint32), app->size); return; } @@ -11414,14 +11422,14 @@ void Client::Handle_OP_RecipeDetails(const EQApplicationPacket *app) void Client::Handle_OP_RecipesFavorite(const EQApplicationPacket *app) { if (app->size != sizeof(TradeskillFavorites_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for TradeskillFavorites_Struct: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for TradeskillFavorites_Struct: Expected: %i, Got: %i", sizeof(TradeskillFavorites_Struct), app->size); return; } TradeskillFavorites_Struct* tsf = (TradeskillFavorites_Struct*)app->pBuffer; - Log.Out(Logs::General, Logs::None, "Requested Favorites for: %d - %d\n", tsf->object_type, tsf->some_id); + Log(Logs::General, Logs::None, "Requested Favorites for: %d - %d\n", tsf->object_type, tsf->some_id); // results show that object_type is combiner type // some_id = 0 if world combiner, item number otherwise @@ -11452,19 +11460,19 @@ void Client::Handle_OP_RecipesFavorite(const EQApplicationPacket *app) return; const std::string query = StringFormat("SELECT tr.id, tr.name, tr.trivial, " - "SUM(tre.componentcount), crl.madecount,tr.tradeskill " - "FROM tradeskill_recipe AS tr " - "LEFT JOIN tradeskill_recipe_entries AS tre ON tr.id=tre.recipe_id " - "LEFT JOIN (SELECT recipe_id, madecount " - "FROM char_recipe_list " - "WHERE char_id = %u) AS crl ON tr.id=crl.recipe_id " - "WHERE tr.enabled <> 0 AND tr.id IN (%s) " - "AND tr.must_learn & 0x20 <> 0x20 AND " - "((tr.must_learn & 0x3 <> 0 AND crl.madecount IS NOT NULL) " - "OR (tr.must_learn & 0x3 = 0)) " - "GROUP BY tr.id " - "HAVING sum(if(tre.item_id %s AND tre.iscontainer > 0,1,0)) > 0 " - "LIMIT 100 ", CharacterID(), favoriteIDs.c_str(), containers.c_str()); + "SUM(tre.componentcount), crl.madecount,tr.tradeskill " + "FROM tradeskill_recipe AS tr " + "LEFT JOIN tradeskill_recipe_entries AS tre ON tr.id=tre.recipe_id " + "LEFT JOIN (SELECT recipe_id, madecount " + "FROM char_recipe_list " + "WHERE char_id = %u) AS crl ON tr.id=crl.recipe_id " + "WHERE tr.enabled <> 0 AND tr.id IN (%s) " + "AND tr.must_learn & 0x20 <> 0x20 AND " + "((tr.must_learn & 0x3 <> 0 AND crl.madecount IS NOT NULL) " + "OR (tr.must_learn & 0x3 = 0)) " + "GROUP BY tr.id " + "HAVING sum(if(tre.item_id %s AND tre.iscontainer > 0,1,0)) > 0 " + "LIMIT 100 ", CharacterID(), favoriteIDs.c_str(), containers.c_str()); TradeskillSearchResults(query, tsf->object_type, tsf->some_id); return; @@ -11473,7 +11481,7 @@ void Client::Handle_OP_RecipesFavorite(const EQApplicationPacket *app) void Client::Handle_OP_RecipesSearch(const EQApplicationPacket *app) { if (app->size != sizeof(RecipesSearch_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for RecipesSearch_Struct: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for RecipesSearch_Struct: Expected: %i, Got: %i", sizeof(RecipesSearch_Struct), app->size); return; } @@ -11482,7 +11490,7 @@ void Client::Handle_OP_RecipesSearch(const EQApplicationPacket *app) rss->query[55] = '\0'; //just to be sure. - Log.Out(Logs::General, Logs::None, "Requested search recipes for: %d - %d\n", rss->object_type, rss->some_id); + Log(Logs::General, Logs::None, "Requested search recipes for: %d - %d\n", rss->object_type, rss->some_id); // make where clause segment for container(s) char containers[30]; @@ -11505,22 +11513,22 @@ void Client::Handle_OP_RecipesSearch(const EQApplicationPacket *app) } //arbitrary limit of 200 recipes, makes sense to me. - const std::string query = StringFormat("SELECT tr.id, tr.name, tr.trivial, " - "SUM(tre.componentcount), crl.madecount,tr.tradeskill " - "FROM tradeskill_recipe AS tr " - "LEFT JOIN tradeskill_recipe_entries AS tre ON tr.id = tre.recipe_id " - "LEFT JOIN (SELECT recipe_id, madecount " - "FROM char_recipe_list WHERE char_id = %u) AS crl ON tr.id=crl.recipe_id " - "WHERE %s tr.trivial >= %u AND tr.trivial <= %u AND tr.enabled <> 0 " - "AND tr.must_learn & 0x20 <> 0x20 " - "AND ((tr.must_learn & 0x3 <> 0 " - "AND crl.madecount IS NOT NULL) " - "OR (tr.must_learn & 0x3 = 0)) " - "GROUP BY tr.id " - "HAVING sum(if(tre.item_id %s AND tre.iscontainer > 0,1,0)) > 0 " - "LIMIT 200 ", - CharacterID(), searchClause.c_str(), - rss->mintrivial, rss->maxtrivial, containers); + const std::string query = StringFormat("SELECT tr.id, tr.name, tr.trivial, " + "SUM(tre.componentcount), crl.madecount,tr.tradeskill " + "FROM tradeskill_recipe AS tr " + "LEFT JOIN tradeskill_recipe_entries AS tre ON tr.id = tre.recipe_id " + "LEFT JOIN (SELECT recipe_id, madecount " + "FROM char_recipe_list WHERE char_id = %u) AS crl ON tr.id=crl.recipe_id " + "WHERE %s tr.trivial >= %u AND tr.trivial <= %u AND tr.enabled <> 0 " + "AND tr.must_learn & 0x20 <> 0x20 " + "AND ((tr.must_learn & 0x3 <> 0 " + "AND crl.madecount IS NOT NULL) " + "OR (tr.must_learn & 0x3 = 0)) " + "GROUP BY tr.id " + "HAVING sum(if(tre.item_id %s AND tre.iscontainer > 0,1,0)) > 0 " + "LIMIT 200 ", + CharacterID(), searchClause.c_str(), + rss->mintrivial, rss->maxtrivial, containers); TradeskillSearchResults(query, rss->object_type, rss->some_id); return; } @@ -11542,7 +11550,7 @@ void Client::Handle_OP_RemoveBlockedBuffs(const EQApplicationPacket *app) if (app->size != sizeof(BlockedBuffs_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_RemoveBlockedBuffs expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_RemoveBlockedBuffs expected %i got %i", sizeof(BlockedBuffs_Struct), app->size); DumpPacket(app); @@ -11705,7 +11713,7 @@ void Client::Handle_OP_RespawnWindow(const EQApplicationPacket *app) // if (app->size != 4) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_RespawnWindow expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_RespawnWindow expected %i got %i", 4, app->size); DumpPacket(app); return; @@ -11733,7 +11741,7 @@ void Client::Handle_OP_RezzAnswer(const EQApplicationPacket *app) const Resurrect_Struct* ra = (const Resurrect_Struct*)app->pBuffer; - Log.Out(Logs::Detail, Logs::Spells, "Received OP_RezzAnswer from client. Pendingrezzexp is %i, action is %s", + Log(Logs::Detail, Logs::Spells, "Received OP_RezzAnswer from client. Pendingrezzexp is %i, action is %s", PendingRezzXP, ra->action ? "ACCEPT" : "DECLINE"); @@ -11755,14 +11763,14 @@ void Client::Handle_OP_Sacrifice(const EQApplicationPacket *app) { if (app->size != sizeof(Sacrifice_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_Sacrifice expected %i got %i", sizeof(Sacrifice_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_Sacrifice expected %i got %i", sizeof(Sacrifice_Struct), app->size); DumpPacket(app); return; } Sacrifice_Struct *ss = (Sacrifice_Struct*)app->pBuffer; if (!PendingSacrifice) { - Log.Out(Logs::General, Logs::Error, "Unexpected OP_Sacrifice reply"); + Log(Logs::General, Logs::Error, "Unexpected OP_Sacrifice reply"); DumpPacket(app); return; } @@ -11800,12 +11808,12 @@ void Client::Handle_OP_SaveOnZoneReq(const EQApplicationPacket *app) void Client::Handle_OP_SelectTribute(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Tribute, "Received OP_SelectTribute of length %d", app->size); + Log(Logs::Detail, Logs::Tribute, "Received OP_SelectTribute of length %d", app->size); //we should enforce being near a real tribute master to change this //but im not sure how I wanna do that right now. if (app->size != sizeof(SelectTributeReq_Struct)) - Log.Out(Logs::General, Logs::Error, "Invalid size on OP_SelectTribute packet"); + Log(Logs::General, Logs::Error, "Invalid size on OP_SelectTribute packet"); else { SelectTributeReq_Struct *t = (SelectTributeReq_Struct *)app->pBuffer; SendTributeDetails(t->client_id, t->tribute_id); @@ -11818,7 +11826,7 @@ void Client::Handle_OP_SenseHeading(const EQApplicationPacket *app) if (!HasSkill(EQEmu::skills::SkillSenseHeading)) return; - int chancemod=0; + int chancemod = 0; // The client seems to limit sense heading packets based on skill // level. So if we're really low, we don't hit this routine very often. @@ -11827,7 +11835,7 @@ void Client::Handle_OP_SenseHeading(const EQApplicationPacket *app) // very low levels get a much better chance to skill up when the GUI // eventually sends a message. if (GetLevel() <= 8) - chancemod += (9-level) * 10; + chancemod += (9 - level) * 10; CheckIncreaseSkill(EQEmu::skills::SkillSenseHeading, nullptr, chancemod); @@ -11897,7 +11905,7 @@ void Client::Handle_OP_SenseTraps(const EQApplicationPacket *app) void Client::Handle_OP_SetGuildMOTD(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Guilds, "Received OP_SetGuildMOTD"); + Log(Logs::Detail, Logs::Guilds, "Received OP_SetGuildMOTD"); if (app->size != sizeof(GuildMOTD_Struct)) { // client calls for a motd on login even if they arent in a guild @@ -11915,7 +11923,7 @@ void Client::Handle_OP_SetGuildMOTD(const EQApplicationPacket *app) GuildMOTD_Struct* gmotd = (GuildMOTD_Struct*)app->pBuffer; - Log.Out(Logs::Detail, Logs::Guilds, "Setting MOTD for %s (%d) to: %s - %s", + Log(Logs::Detail, Logs::Guilds, "Setting MOTD for %s (%d) to: %s - %s", guild_mgr.GetGuildName(GuildID()), GuildID(), GetName(), gmotd->motd); if (!guild_mgr.SetGuildMOTD(GuildID(), gmotd->motd, GetName())) { @@ -11928,7 +11936,7 @@ void Client::Handle_OP_SetGuildMOTD(const EQApplicationPacket *app) void Client::Handle_OP_SetRunMode(const EQApplicationPacket *app) { if (app->size < sizeof(SetRunMode_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received invalid sized " + Log(Logs::General, Logs::Error, "Received invalid sized " "OP_SetRunMode: got %d, expected %d", app->size, sizeof(SetRunMode_Struct)); DumpPacket(app); @@ -11945,7 +11953,7 @@ void Client::Handle_OP_SetRunMode(const EQApplicationPacket *app) void Client::Handle_OP_SetServerFilter(const EQApplicationPacket *app) { if (app->size != sizeof(SetServerFilter_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received invalid sized " + Log(Logs::General, Logs::Error, "Received invalid sized " "OP_SetServerFilter: got %d, expected %d", app->size, sizeof(SetServerFilter_Struct)); DumpPacket(app); @@ -11965,7 +11973,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) } if (app->size < 1) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_SetStartCity, size=%i, expected %i", app->size, 1); + Log(Logs::General, Logs::Error, "Wrong size: OP_SetStartCity, size=%i, expected %i", app->size, 1); DumpPacket(app); return; } @@ -11979,7 +11987,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) m_pp.class_, m_pp.deity, m_pp.race); auto results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "No valid start zones found for /setstartcity"); + Log(Logs::General, Logs::Error, "No valid start zones found for /setstartcity"); return; } @@ -12030,7 +12038,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) void Client::Handle_OP_SetTitle(const EQApplicationPacket *app) { if (app->size != sizeof(SetTitle_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_SetTitle expected %i got %i", sizeof(SetTitle_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_SetTitle expected %i got %i", sizeof(SetTitle_Struct), app->size); DumpPacket(app); return; } @@ -12054,7 +12062,7 @@ void Client::Handle_OP_SetTitle(const EQApplicationPacket *app) void Client::Handle_OP_Shielding(const EQApplicationPacket *app) { if (app->size != sizeof(Shielding_Struct)) { - Log.Out(Logs::General, Logs::Error, "OP size error: OP_Shielding expected:%i got:%i", sizeof(Shielding_Struct), app->size); + Log(Logs::General, Logs::Error, "OP size error: OP_Shielding expected:%i got:%i", sizeof(Shielding_Struct), app->size); return; } if (GetClass() != WARRIOR) @@ -12145,7 +12153,7 @@ void Client::Handle_OP_ShopEnd(const EQApplicationPacket *app) void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) { if (app->size != sizeof(Merchant_Sell_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size on OP_ShopPlayerBuy: Expected %i, Got %i", + Log(Logs::General, Logs::Error, "Invalid size on OP_ShopPlayerBuy: Expected %i, Got %i", sizeof(Merchant_Sell_Struct), app->size); return; } @@ -12153,7 +12161,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) t1.start(); Merchant_Sell_Struct* mp = (Merchant_Sell_Struct*)app->pBuffer; #if EQDEBUG >= 5 - Log.Out(Logs::General, Logs::None, "%s, purchase item..", GetName()); + Log(Logs::General, Logs::None, "%s, purchase item..", GetName()); DumpPacket(app); #endif @@ -12175,13 +12183,13 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) uint32 item_id = 0; std::list merlist = zone->merchanttable[merchantid]; std::list::const_iterator itr; - for (itr = merlist.begin(); itr != merlist.end(); ++itr){ + for (itr = merlist.begin(); itr != merlist.end(); ++itr) { MerchantList ml = *itr; if (GetLevel() < ml.level_required) { continue; } - if (mp->itemslot == ml.slot){ + if (mp->itemslot == ml.slot) { item_id = ml.item; break; } @@ -12192,9 +12200,9 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) std::list tmp_merlist = zone->tmpmerchanttable[tmp->GetNPCTypeID()]; std::list::const_iterator tmp_itr; TempMerchantList ml; - for (tmp_itr = tmp_merlist.begin(); tmp_itr != tmp_merlist.end(); ++tmp_itr){ + for (tmp_itr = tmp_merlist.begin(); tmp_itr != tmp_merlist.end(); ++tmp_itr) { ml = *tmp_itr; - if (mp->itemslot == ml.slot){ + if (mp->itemslot == ml.slot) { item_id = ml.item; tmpmer_used = true; prevcharges = ml.charges; @@ -12203,7 +12211,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) } } item = database.GetItem(item_id); - if (!item){ + if (!item) { //error finding item, client didnt get the update packet for whatever reason, roleplay a tad Message(15, "%s tells you 'Sorry, that item is for display purposes only.' as they take the item off the shelf.", tmp->GetCleanName()); auto delitempacket = new EQApplicationPacket(OP_ShopDelItem, sizeof(Merchant_DelItem_Struct)); @@ -12312,14 +12320,14 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) PutItemInInventory(freeslotid, *inst); SendItemPacket(freeslotid, inst, ItemPacketTrade); } - else if (!stacked){ - Log.Out(Logs::General, Logs::Error, "OP_ShopPlayerBuy: item->ItemClass Unknown! Type: %i", item->ItemClass); + else if (!stacked) { + Log(Logs::General, Logs::Error, "OP_ShopPlayerBuy: item->ItemClass Unknown! Type: %i", item->ItemClass); } QueuePacket(outapp); - if (inst && tmpmer_used){ + if (inst && tmpmer_used) { int32 new_charges = prevcharges - mp->quantity; zone->SaveTempItem(merchantid, tmp->GetNPCTypeID(), item_id, new_charges); - if (new_charges <= 0){ + if (new_charges <= 0) { auto delitempacket = new EQApplicationPacket(OP_ShopDelItem, sizeof(Merchant_DelItem_Struct)); Merchant_DelItem_Struct* delitem = (Merchant_DelItem_Struct*)delitempacket->pBuffer; delitem->itemslot = mp->itemslot; @@ -12346,8 +12354,8 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) // stacking purchases not supported at this time - entire process will need some work to catch them properly if (RuleB(QueryServ, PlayerLogMerchantTransactions)) { auto qspack = - new ServerPacket(ServerOP_QSPlayerLogMerchantTransactions, - sizeof(QSMerchantLogTransaction_Struct) + sizeof(QSTransactionItems_Struct)); + new ServerPacket(ServerOP_QSPlayerLogMerchantTransactions, + sizeof(QSMerchantLogTransaction_Struct) + sizeof(QSTransactionItems_Struct)); QSMerchantLogTransaction_Struct* qsaudit = (QSMerchantLogTransaction_Struct*)qspack->pBuffer; qsaudit->zone_id = zone->GetZoneID(); @@ -12385,7 +12393,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) qsaudit->items[0].aug_5 = 0; if (freeslotid != INVALID_INDEX) { - Log.Out(Logs::General, Logs::Error, "Handle_OP_ShopPlayerBuy: QS Audit could not locate merchant (%u) purchased item in player (%u) inventory slot (%i)", + Log(Logs::General, Logs::Error, "Handle_OP_ShopPlayerBuy: QS Audit could not locate merchant (%u) purchased item in player (%u) inventory slot (%i)", qsaudit->merchant_id, qsaudit->char_id, freeslotid); } } @@ -12413,7 +12421,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) { if (app->size != sizeof(Merchant_Purchase_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size on OP_ShopPlayerSell: Expected %i, Got %i", + Log(Logs::General, Logs::Error, "Invalid size on OP_ShopPlayerSell: Expected %i, Got %i", sizeof(Merchant_Purchase_Struct), app->size); return; } @@ -12435,7 +12443,7 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) return; const EQEmu::ItemData* item = database.GetItem(itemid); EQEmu::ItemInstance* inst = GetInv().GetItem(mp->itemslot); - if (!item || !inst){ + if (!item || !inst) { Message(13, "You seemed to have misplaced that item.."); return; } @@ -12497,14 +12505,14 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) charges = 1; int freeslot = 0; - if (charges > 0 && (freeslot = zone->SaveTempItem(vendor->CastToNPC()->MerchantType, vendor->GetNPCTypeID(), itemid, charges, true)) > 0){ + if (charges > 0 && (freeslot = zone->SaveTempItem(vendor->CastToNPC()->MerchantType, vendor->GetNPCTypeID(), itemid, charges, true)) > 0) { EQEmu::ItemInstance* inst2 = inst->Clone(); while (true) { if (inst2 == nullptr) break; - if (RuleB(Merchant, UsePriceMod)){ + if (RuleB(Merchant, UsePriceMod)) { inst2->SetPrice(item->Price*(RuleR(Merchant, SellCostMod))*item->SellRate*Client::CalcPriceMod(vendor, false)); } else @@ -12528,8 +12536,8 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) // start QS code if (RuleB(QueryServ, PlayerLogMerchantTransactions)) { auto qspack = - new ServerPacket(ServerOP_QSPlayerLogMerchantTransactions, - sizeof(QSMerchantLogTransaction_Struct) + sizeof(QSTransactionItems_Struct)); + new ServerPacket(ServerOP_QSPlayerLogMerchantTransactions, + sizeof(QSMerchantLogTransaction_Struct) + sizeof(QSTransactionItems_Struct)); QSMerchantLogTransaction_Struct* qsaudit = (QSMerchantLogTransaction_Struct*)qspack->pBuffer; qsaudit->zone_id = zone->GetZoneID(); @@ -12581,7 +12589,7 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) this->DeleteItemInInventory(mp->itemslot, mp->quantity, false); } } - + //This forces the price to show up correctly for charged items. if (inst->IsCharged()) @@ -12606,7 +12614,7 @@ void Client::Handle_OP_ShopPlayerSell(const EQApplicationPacket *app) void Client::Handle_OP_ShopRequest(const EQApplicationPacket *app) { if (app->size != sizeof(Merchant_Click_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_ShopRequest, size=%i, expected %i", app->size, sizeof(Merchant_Click_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_ShopRequest, size=%i, expected %i", app->size, sizeof(Merchant_Click_Struct)); return; } @@ -12639,7 +12647,7 @@ void Client::Handle_OP_ShopRequest(const EQApplicationPacket *app) safe_delete(outapp); return; } - if (tmp->IsEngaged()){ + if (tmp->IsEngaged()) { this->Message_StringID(0, MERCHANT_BUSY); action = 0; } @@ -12670,7 +12678,7 @@ void Client::Handle_OP_ShopRequest(const EQApplicationPacket *app) mco->npcid = mc->npcid; mco->playerid = 0; mco->command = action; // Merchant command 0x01 = open - if (RuleB(Merchant, UsePriceMod)){ + if (RuleB(Merchant, UsePriceMod)) { mco->rate = 1 / ((RuleR(Merchant, BuyCostMod))*Client::CalcPriceMod(tmp, true)); // works } else @@ -12699,7 +12707,7 @@ void Client::Handle_OP_Sneak(const EQApplicationPacket *app) p_timers.Start(pTimerSneak, SneakReuseTime - 1); bool was = sneaking; - if (sneaking){ + if (sneaking) { sneaking = false; hidden = false; improved_hidden = false; @@ -12726,11 +12734,11 @@ void Client::Handle_OP_Sneak(const EQApplicationPacket *app) sa_out->parameter = sneaking; QueuePacket(outapp); safe_delete(outapp); - if (GetClass() == ROGUE){ + if (GetClass() == ROGUE) { outapp = new EQApplicationPacket(OP_SimpleMessage, 12); SimpleMessage_Struct *msg = (SimpleMessage_Struct *)outapp->pBuffer; msg->color = 0x010E; - if (sneaking){ + if (sneaking) { msg->string_id = 347; } else { @@ -12811,14 +12819,14 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) } else { - Log.Out(Logs::Detail, Logs::Error, "Client %s :: unknown appearance %i", name, (int)sa->parameter); + Log(Logs::Detail, Logs::Error, "Client %s :: unknown appearance %i", name, (int)sa->parameter); return; } entity_list.QueueClients(this, app, true); } else if (sa->type == AT_Anon) { - if(!anon_toggle_timer.Check()) { + if (!anon_toggle_timer.Check()) { return; } @@ -12833,7 +12841,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) m_pp.anon = 0; } else { - Log.Out(Logs::Detail, Logs::Error, "Client %s :: unknown Anon/Roleplay Switch %i", name, (int)sa->parameter); + Log(Logs::Detail, Logs::Error, "Client %s :: unknown Anon/Roleplay Switch %i", name, (int)sa->parameter); return; } entity_list.QueueClients(this, app, true); @@ -12843,7 +12851,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) return; } else if (sa->type == AT_AFK) { - if(afk_toggle_timer.Check()) { + if (afk_toggle_timer.Check()) { AFK = (sa->parameter == 1); entity_list.QueueClients(this, app, true); } @@ -12852,7 +12860,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) m_pp.autosplit = (sa->parameter == 1); } else if (sa->type == AT_Sneak) { - if(sneaking == 0) + if (sneaking == 0) return; if (sa->parameter != 0) @@ -12887,7 +12895,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) } else if (sa->type == AT_ShowHelm) { - if(helm_toggle_timer.Check()) { + if (helm_toggle_timer.Check()) { m_pp.showhelm = (sa->parameter == 1); entity_list.QueueClients(this, app, true); } @@ -12902,7 +12910,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) void Client::Handle_OP_Split(const EQApplicationPacket *app) { if (app->size != sizeof(Split_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_Split, size=%i, expected %i", app->size, sizeof(Split_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_Split, size=%i, expected %i", app->size, sizeof(Split_Struct)); return; } // The client removes the money on its own, but we have to @@ -12939,7 +12947,7 @@ void Client::Handle_OP_Surname(const EQApplicationPacket *app) { if (app->size != sizeof(Surname_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in Surname expected %i got %i", sizeof(Surname_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in Surname expected %i got %i", sizeof(Surname_Struct), app->size); return; } @@ -13008,17 +13016,17 @@ void Client::Handle_OP_SwapSpell(const EQApplicationPacket *app) return; swapspelltemp = m_pp.spell_book[swapspell->from_slot]; - if (swapspelltemp < 0){ + if (swapspelltemp < 0) { return; } m_pp.spell_book[swapspell->from_slot] = m_pp.spell_book[swapspell->to_slot]; m_pp.spell_book[swapspell->to_slot] = swapspelltemp; /* Save Spell Swaps */ - if (!database.SaveCharacterSpell(this->CharacterID(), m_pp.spell_book[swapspell->from_slot], swapspell->from_slot)){ + if (!database.SaveCharacterSpell(this->CharacterID(), m_pp.spell_book[swapspell->from_slot], swapspell->from_slot)) { database.DeleteCharacterSpell(this->CharacterID(), m_pp.spell_book[swapspell->from_slot], swapspell->from_slot); } - if (!database.SaveCharacterSpell(this->CharacterID(), swapspelltemp, swapspell->to_slot)){ + if (!database.SaveCharacterSpell(this->CharacterID(), swapspelltemp, swapspell->to_slot)) { database.DeleteCharacterSpell(this->CharacterID(), swapspelltemp, swapspell->to_slot); } @@ -13029,7 +13037,7 @@ void Client::Handle_OP_SwapSpell(const EQApplicationPacket *app) void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) { if (app->size != sizeof(ClientTarget_Struct)) { - Log.Out(Logs::General, Logs::Error, "OP size error: OP_TargetMouse expected:%i got:%i", sizeof(ClientTarget_Struct), app->size); + Log(Logs::General, Logs::Error, "OP size error: OP_TargetMouse expected:%i got:%i", sizeof(ClientTarget_Struct), app->size); return; } @@ -13057,7 +13065,8 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) if (gid < 12 && raid->GroupCount(gid) > 2) inspect_buffs = raid->GetLeadershipAA(groupAAInspectBuffs, gid); } - } else { + } + else { Group *group = GetGroup(); if (group && group->GroupCount() > 2) inspect_buffs = group->GetLeadershipAA(groupAAInspectBuffs); @@ -13126,7 +13135,7 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) // For /target, send reject or success packet if (app->GetOpcode() == OP_TargetCommand) { - if (GetTarget() && !GetTarget()->CastToMob()->IsInvisible(this) && (DistanceSquared(m_Position, GetTarget()->GetPosition()) <= TARGETING_RANGE*TARGETING_RANGE || GetGM())) { + if (GetTarget() && !GetTarget()->CastToMob()->IsInvisible(this) && (DistanceSquared(m_Position, GetTarget()->GetPosition()) <= TARGETING_RANGE*TARGETING_RANGE || GetGM())) { if (GetTarget()->GetBodyType() == BT_NoTarget2 || GetTarget()->GetBodyType() == BT_Special || GetTarget()->GetBodyType() == BT_NoTarget) { @@ -13176,9 +13185,9 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) } else if (RuleB(Character, AllowMQTarget)) { - GetTarget()->IsTargeted(1); - return; - } + GetTarget()->IsTargeted(1); + return; + } else if (IsAssistExempted()) { GetTarget()->IsTargeted(1); @@ -13264,7 +13273,7 @@ void Client::Handle_OP_TaskHistoryRequest(const EQApplicationPacket *app) { if (app->size != sizeof(TaskHistoryRequest_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_TaskHistoryRequest expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_TaskHistoryRequest expected %i got %i", sizeof(TaskHistoryRequest_Struct), app->size); DumpPacket(app); return; @@ -13317,7 +13326,7 @@ void Client::Handle_OP_Track(const EQApplicationPacket *app) CheckIncreaseSkill(EQEmu::skills::SkillTracking, nullptr, 15); if (!entity_list.MakeTrackPacket(this)) - Log.Out(Logs::General, Logs::Error, "Unable to generate OP_Track packet requested by client."); + Log(Logs::General, Logs::Error, "Unable to generate OP_Track packet requested by client."); return; } @@ -13331,7 +13340,7 @@ void Client::Handle_OP_TrackTarget(const EQApplicationPacket *app) if (app->size != sizeof(TrackTarget_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for OP_TrackTarget: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for OP_TrackTarget: Expected: %i, Got: %i", sizeof(TrackTarget_Struct), app->size); return; } @@ -13409,8 +13418,8 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) event_entry._detail_count = event_details.size(); auto qs_pack = new ServerPacket( - ServerOP_QSPlayerLogTrades, - sizeof(QSPlayerLogTrade_Struct) + + ServerOP_QSPlayerLogTrades, + sizeof(QSPlayerLogTrade_Struct) + (sizeof(QSTradeItems_Struct) * event_entry._detail_count)); QSPlayerLogTrade_Struct* qs_buf = (QSPlayerLogTrade_Struct*)qs_pack->pBuffer; @@ -13419,7 +13428,7 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) int offset = 0; for (auto iter = event_details.begin(); iter != event_details.end(); - ++iter, ++offset) { + ++iter, ++offset) { QSTradeItems_Struct* detail = reinterpret_cast(*iter); qs_buf->items[offset] = *detail; safe_delete(detail); @@ -13465,9 +13474,9 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) event_entry._detail_count = event_details.size(); auto qs_pack = - new ServerPacket(ServerOP_QSPlayerLogHandins, - sizeof(QSPlayerLogHandin_Struct) + - (sizeof(QSHandinItems_Struct) * event_entry._detail_count)); + new ServerPacket(ServerOP_QSPlayerLogHandins, + sizeof(QSPlayerLogHandin_Struct) + + (sizeof(QSHandinItems_Struct) * event_entry._detail_count)); QSPlayerLogHandin_Struct* qs_buf = (QSPlayerLogHandin_Struct*)qs_pack->pBuffer; memcpy(qs_buf, &event_entry, sizeof(QSPlayerLogHandin_Struct)); @@ -13506,7 +13515,7 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) void Client::Handle_OP_TradeBusy(const EQApplicationPacket *app) { if (app->size != sizeof(TradeBusy_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_TradeBusy, size=%i, expected %i", app->size, sizeof(TradeBusy_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_TradeBusy, size=%i, expected %i", app->size, sizeof(TradeBusy_Struct)); return; } // Trade request recipient is cancelling the trade due to being busy @@ -13533,7 +13542,7 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app) /* if (GetClientVersion() >= EQClientRoF) - max_items = 200; + max_items = 200; */ //Show Items @@ -13545,7 +13554,7 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app) { case BazaarTrader_EndTraderMode: { Trader_EndTrader(); - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: End Trader Session"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: End Trader Session"); break; } case BazaarTrader_EndTransaction: { @@ -13554,20 +13563,20 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app) if (c) { c->WithCustomer(0); - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: End Transaction"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: End Transaction"); } else - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Null Client Pointer"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Null Client Pointer"); break; } case BazaarTrader_ShowItems: { Trader_ShowItems(); - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Show Trader Items"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Show Trader Items"); break; } default: { - Log.Out(Logs::Detail, Logs::Trading, "Unhandled action code in OP_Trader ShowItems_Struct"); + Log(Logs::Detail, Logs::Trading, "Unhandled action code in OP_Trader ShowItems_Struct"); break; } } @@ -13586,7 +13595,7 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app) { GetItems_Struct* gis = GetTraderItems(); - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Start Trader Mode"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Start Trader Mode"); // Verify there are no NODROP or items with a zero price bool TradeItemsValid = true; @@ -13625,7 +13634,7 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app) gis->Charges[i], ints->ItemCost[i], i); auto inst = FindTraderItemBySerialNumber(gis->SerialNumber[i]); - if(inst) + if (inst) inst->SetPrice(ints->ItemCost[i]); } else { @@ -13649,32 +13658,32 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app) } } else { - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Unknown TraderStruct code of: %i\n", + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Unknown TraderStruct code of: %i\n", ints->Code); - Log.Out(Logs::General, Logs::Error, "Unknown TraderStruct code of: %i\n", ints->Code); + Log(Logs::General, Logs::Error, "Unknown TraderStruct code of: %i\n", ints->Code); } } else if (app->size == sizeof(TraderStatus_Struct)) { TraderStatus_Struct* tss = (TraderStatus_Struct*)app->pBuffer; - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Trader Status Code: %d", tss->Code); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Trader Status Code: %d", tss->Code); switch (tss->Code) { case BazaarTrader_EndTraderMode: { Trader_EndTrader(); - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: End Trader Session"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: End Trader Session"); break; } case BazaarTrader_ShowItems: { Trader_ShowItems(); - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Show Trader Items"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Show Trader Items"); break; } default: { - Log.Out(Logs::Detail, Logs::Trading, "Unhandled action code in OP_Trader ShowItems_Struct"); + Log(Logs::Detail, Logs::Trading, "Unhandled action code in OP_Trader ShowItems_Struct"); break; } } @@ -13683,12 +13692,12 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app) } else if (app->size == sizeof(TraderPriceUpdate_Struct)) { - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Trader Price Update"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Trader Price Update"); HandleTraderPriceUpdate(app); } else { - Log.Out(Logs::Detail, Logs::Trading, "Unknown size for OP_Trader: %i\n", app->size); - Log.Out(Logs::General, Logs::Error, "Unknown size for OP_Trader: %i\n", app->size); + Log(Logs::Detail, Logs::Trading, "Unknown size for OP_Trader: %i\n", app->size); + Log(Logs::General, Logs::Error, "Unknown size for OP_Trader: %i\n", app->size); DumpPacket(app); return; } @@ -13703,18 +13712,18 @@ void Client::Handle_OP_TraderBuy(const EQApplicationPacket *app) // Client has elected to buy an item from a Trader // if (app->size != sizeof(TraderBuy_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_TraderBuy, size=%i, expected %i", app->size, sizeof(TraderBuy_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_TraderBuy, size=%i, expected %i", app->size, sizeof(TraderBuy_Struct)); return; } TraderBuy_Struct* tbs = (TraderBuy_Struct*)app->pBuffer; - if (Client* Trader = entity_list.GetClientByID(tbs->TraderID)){ + if (Client* Trader = entity_list.GetClientByID(tbs->TraderID)) { BuyTraderItem(tbs, Trader, app); - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderBuy: Buy Trader Item "); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderBuy: Buy Trader Item "); } else { - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderBuy: Null Client Pointer"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderBuy: Null Client Pointer"); } @@ -13724,7 +13733,7 @@ void Client::Handle_OP_TraderBuy(const EQApplicationPacket *app) void Client::Handle_OP_TradeRequest(const EQApplicationPacket *app) { if (app->size != sizeof(TradeRequest_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_TradeRequest, size=%i, expected %i", app->size, sizeof(TradeRequest_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_TradeRequest, size=%i, expected %i", app->size, sizeof(TradeRequest_Struct)); return; } // Client requesting a trade session from an npc/client @@ -13755,12 +13764,12 @@ void Client::Handle_OP_TradeRequest(const EQApplicationPacket *app) safe_delete(outapp); } return; -} + } void Client::Handle_OP_TradeRequestAck(const EQApplicationPacket *app) { if (app->size != sizeof(TradeRequest_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size: OP_TradeRequestAck, size=%i, expected %i", app->size, sizeof(TradeRequest_Struct)); + Log(Logs::General, Logs::Error, "Wrong size: OP_TradeRequestAck, size=%i, expected %i", app->size, sizeof(TradeRequest_Struct)); return; } // Trade request recipient is acknowledging they are able to trade @@ -13785,12 +13794,12 @@ void Client::Handle_OP_TraderShop(const EQApplicationPacket *app) TraderClick_Struct* tcs = (TraderClick_Struct*)app->pBuffer; - Log.Out(Logs::Detail, Logs::Trading, "Handle_OP_TraderShop: TraderClick_Struct TraderID %d, Code %d, Unknown008 %d, Approval %d", + Log(Logs::Detail, Logs::Trading, "Handle_OP_TraderShop: TraderClick_Struct TraderID %d, Code %d, Unknown008 %d, Approval %d", tcs->TraderID, tcs->Code, tcs->Unknown008, tcs->Approval); if (tcs->Code == BazaarWelcome) { - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: Sent Bazaar Welcome Info"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: Sent Bazaar Welcome Info"); SendBazaarWelcome(); } else @@ -13806,10 +13815,10 @@ void Client::Handle_OP_TraderShop(const EQApplicationPacket *app) if (Trader) { outtcs->Approval = Trader->WithCustomer(GetID()); - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: Shop Request (%s) to (%s) with Approval: %d", GetCleanName(), Trader->GetCleanName(), outtcs->Approval); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: Shop Request (%s) to (%s) with Approval: %d", GetCleanName(), Trader->GetCleanName(), outtcs->Approval); } else { - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: entity_list.GetClientByID(tcs->traderid)" + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: entity_list.GetClientByID(tcs->traderid)" " returned a nullptr pointer"); safe_delete(outapp); return; @@ -13826,12 +13835,12 @@ void Client::Handle_OP_TraderShop(const EQApplicationPacket *app) this->BulkSendTraderInventory(Trader->CharacterID()); Trader->Trader_CustomerBrowsing(this); TraderID = tcs->TraderID; - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: Trader Inventory Sent"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: Trader Inventory Sent"); } else { Message_StringID(clientMessageYellow, TRADER_BUSY); - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: Trader Busy"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: Trader Busy"); } safe_delete(outapp); @@ -13844,7 +13853,7 @@ void Client::Handle_OP_TraderShop(const EQApplicationPacket *app) // RoF+ // Client requested Bazaar Welcome Info (Trader and Item Total Counts) SendBazaarWelcome(); - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: Sent Bazaar Welcome Info"); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_TraderShop: Sent Bazaar Welcome Info"); } else if (app->size == sizeof(TraderBuy_Struct)) { @@ -13856,12 +13865,12 @@ void Client::Handle_OP_TraderShop(const EQApplicationPacket *app) if (Client* Trader = entity_list.GetClientByID(tbs->TraderID)) { BuyTraderItem(tbs, Trader, app); - Log.Out(Logs::Detail, Logs::Trading, "Handle_OP_TraderShop: Buy Action %d, Price %d, Trader %d, ItemID %d, Quantity %d, ItemName, %s", + Log(Logs::Detail, Logs::Trading, "Handle_OP_TraderShop: Buy Action %d, Price %d, Trader %d, ItemID %d, Quantity %d, ItemName, %s", tbs->Action, tbs->Price, tbs->TraderID, tbs->ItemID, tbs->Quantity, tbs->ItemName); } else { - Log.Out(Logs::Detail, Logs::Trading, "OP_TraderShop: Null Client Pointer"); + Log(Logs::Detail, Logs::Trading, "OP_TraderShop: Null Client Pointer"); } } else if (app->size == 4) @@ -13877,24 +13886,24 @@ void Client::Handle_OP_TraderShop(const EQApplicationPacket *app) if (c) { c->WithCustomer(0); - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: End Transaction - Code %d", Command); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: End Transaction - Code %d", Command); } else { - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Null Client Pointer for Trader - Code %d", Command); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Null Client Pointer for Trader - Code %d", Command); } EQApplicationPacket empty(OP_ShopEndConfirm); QueuePacket(&empty); } else { - Log.Out(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Unhandled Code %d", Command); + Log(Logs::Detail, Logs::Trading, "Client::Handle_OP_Trader: Unhandled Code %d", Command); } } else { - Log.Out(Logs::Detail, Logs::Trading, "Unknown size for OP_TraderShop: %i\n", app->size); - Log.Out(Logs::General, Logs::Error, "Unknown size for OP_TraderShop: %i\n", app->size); + Log(Logs::Detail, Logs::Trading, "Unknown size for OP_TraderShop: %i\n", app->size); + Log(Logs::General, Logs::Error, "Unknown size for OP_TraderShop: %i\n", app->size); DumpPacket(app); return; } @@ -13903,7 +13912,7 @@ void Client::Handle_OP_TraderShop(const EQApplicationPacket *app) void Client::Handle_OP_TradeSkillCombine(const EQApplicationPacket *app) { if (app->size != sizeof(NewCombine_Struct)) { - Log.Out(Logs::General, Logs::Error, "Invalid size for NewCombine_Struct: Expected: %i, Got: %i", + Log(Logs::General, Logs::Error, "Invalid size for NewCombine_Struct: Expected: %i, Got: %i", sizeof(NewCombine_Struct), app->size); return; } @@ -13924,7 +13933,7 @@ void Client::Handle_OP_Translocate(const EQApplicationPacket *app) { if (app->size != sizeof(Translocate_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_Translocate expected %i got %i", sizeof(Translocate_Struct), app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_Translocate expected %i got %i", sizeof(Translocate_Struct), app->size); DumpPacket(app); return; } @@ -13952,7 +13961,7 @@ void Client::Handle_OP_Translocate(const EQApplicationPacket *app) // reversed in the pp, and since spells like Gate are handled serverside, this has not mattered before. if (((SpellID == 1422) || (SpellID == 1334) || (SpellID == 3243)) && (zone->GetZoneID() == PendingTranslocateData.zone_id && - zone->GetInstanceID() == PendingTranslocateData.instance_id)) + zone->GetInstanceID() == PendingTranslocateData.instance_id)) { PendingTranslocate = false; GoToBind(); @@ -13962,8 +13971,8 @@ void Client::Handle_OP_Translocate(const EQApplicationPacket *app) ////Was sending the packet back to initiate client zone... ////but that could be abusable, so lets go through proper channels MovePC(PendingTranslocateData.zone_id, PendingTranslocateData.instance_id, - PendingTranslocateData.x, PendingTranslocateData.y, - PendingTranslocateData.z, PendingTranslocateData.heading, 0, ZoneSolicited); + PendingTranslocateData.x, PendingTranslocateData.y, + PendingTranslocateData.z, PendingTranslocateData.heading, 0, ZoneSolicited); } } @@ -13972,7 +13981,7 @@ void Client::Handle_OP_Translocate(const EQApplicationPacket *app) void Client::Handle_OP_TributeItem(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Tribute, "Received OP_TributeItem of length %d", app->size); + Log(Logs::Detail, Logs::Tribute, "Received OP_TributeItem of length %d", app->size); //player donates an item... if (app->size != sizeof(TributeItem_Struct)) @@ -13990,7 +13999,7 @@ void Client::Handle_OP_TributeItem(const EQApplicationPacket *app) t->tribute_points = TributeItem(t->slot, t->quantity); - Log.Out(Logs::Detail, Logs::Tribute, "Sending tribute item reply with %d points", t->tribute_points); + Log(Logs::Detail, Logs::Tribute, "Sending tribute item reply with %d points", t->tribute_points); QueuePacket(app); } @@ -13999,7 +14008,7 @@ void Client::Handle_OP_TributeItem(const EQApplicationPacket *app) void Client::Handle_OP_TributeMoney(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Tribute, "Received OP_TributeMoney of length %d", app->size); + Log(Logs::Detail, Logs::Tribute, "Received OP_TributeMoney of length %d", app->size); //player donates money if (app->size != sizeof(TributeMoney_Struct)) @@ -14017,7 +14026,7 @@ void Client::Handle_OP_TributeMoney(const EQApplicationPacket *app) t->tribute_points = TributeMoney(t->platinum); - Log.Out(Logs::Detail, Logs::Tribute, "Sending tribute money reply with %d points", t->tribute_points); + Log(Logs::Detail, Logs::Tribute, "Sending tribute money reply with %d points", t->tribute_points); QueuePacket(app); } @@ -14026,17 +14035,17 @@ void Client::Handle_OP_TributeMoney(const EQApplicationPacket *app) void Client::Handle_OP_TributeNPC(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Tribute, "Received OP_TributeNPC of length %d", app->size); + Log(Logs::Detail, Logs::Tribute, "Received OP_TributeNPC of length %d", app->size); return; } void Client::Handle_OP_TributeToggle(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Tribute, "Received OP_TributeToggle of length %d", app->size); + Log(Logs::Detail, Logs::Tribute, "Received OP_TributeToggle of length %d", app->size); if (app->size != sizeof(uint32)) - Log.Out(Logs::General, Logs::Error, "Invalid size on OP_TributeToggle packet"); + Log(Logs::General, Logs::Error, "Invalid size on OP_TributeToggle packet"); else { uint32 *val = (uint32 *)app->pBuffer; ToggleTribute(*val ? true : false); @@ -14046,11 +14055,11 @@ void Client::Handle_OP_TributeToggle(const EQApplicationPacket *app) void Client::Handle_OP_TributeUpdate(const EQApplicationPacket *app) { - Log.Out(Logs::Detail, Logs::Tribute, "Received OP_TributeUpdate of length %d", app->size); + Log(Logs::Detail, Logs::Tribute, "Received OP_TributeUpdate of length %d", app->size); //sent when the client changes their tribute settings... if (app->size != sizeof(TributeInfo_Struct)) - Log.Out(Logs::General, Logs::Error, "Invalid size on OP_TributeUpdate packet"); + Log(Logs::General, Logs::Error, "Invalid size on OP_TributeUpdate packet"); else { TributeInfo_Struct *t = (TributeInfo_Struct *)app->pBuffer; ChangeTributeSettings(t); @@ -14061,7 +14070,7 @@ void Client::Handle_OP_TributeUpdate(const EQApplicationPacket *app) void Client::Handle_OP_VetClaimRequest(const EQApplicationPacket *app) { if (app->size < sizeof(VeteranClaim)) { - Log.Out(Logs::General, Logs::None, + Log(Logs::General, Logs::None, "OP_VetClaimRequest size lower than expected: got %u expected at least %u", app->size, sizeof(VeteranClaim)); DumpPacket(app); @@ -14093,7 +14102,7 @@ void Client::Handle_OP_VoiceMacroIn(const EQApplicationPacket *app) if (app->size != sizeof(VoiceMacroIn_Struct)) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_VoiceMacroIn expected %i got %i", + Log(Logs::General, Logs::None, "Size mismatch in OP_VoiceMacroIn expected %i got %i", sizeof(VoiceMacroIn_Struct), app->size); DumpPacket(app); @@ -14148,7 +14157,7 @@ void Client::Handle_OP_XTargetAutoAddHaters(const EQApplicationPacket *app) { if (app->size != 1) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_XTargetAutoAddHaters, expected 1, got %i", app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_XTargetAutoAddHaters, expected 1, got %i", app->size); DumpPacket(app); return; } @@ -14160,7 +14169,7 @@ void Client::Handle_OP_XTargetAutoAddHaters(const EQApplicationPacket *app) void Client::Handle_OP_XTargetOpen(const EQApplicationPacket *app) { if (app->size != 4) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_XTargetOpen, expected 1, got %i", app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_XTargetOpen, expected 1, got %i", app->size); DumpPacket(app); return; } @@ -14173,7 +14182,7 @@ void Client::Handle_OP_XTargetRequest(const EQApplicationPacket *app) { if (app->size < 12) { - Log.Out(Logs::General, Logs::None, "Size mismatch in OP_XTargetRequest, expected at least 12, got %i", app->size); + Log(Logs::General, Logs::None, "Size mismatch in OP_XTargetRequest, expected at least 12, got %i", app->size); DumpPacket(app); return; } @@ -14396,7 +14405,7 @@ void Client::Handle_OP_XTargetRequest(const EQApplicationPacket *app) } default: - Log.Out(Logs::General, Logs::None, "Unhandled XTarget Type %i", Type); + Log(Logs::General, Logs::None, "Unhandled XTarget Type %i", Type); break; } @@ -14413,10 +14422,9 @@ void Client::Handle_OP_YellForHelp(const EQApplicationPacket *app) void Client::Handle_OP_ResetAA(const EQApplicationPacket *app) { - if(Admin() >= 50) { + if (Admin() >= 50) { Message(0, "Resetting AA points."); ResetAA(); } return; } - diff --git a/zone/client_process.cpp b/zone/client_process.cpp index b2a010542..6cadc4be5 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -63,7 +63,7 @@ extern EntityList entity_list; bool Client::Process() { bool ret = true; - if(Connected() || IsLD()) + if (Connected() || IsLD()) { // try to send all packets that weren't sent before if (!IsLD() && zoneinpacket_timer.Check()) @@ -71,58 +71,58 @@ bool Client::Process() { SendAllPackets(); } - if(adventure_request_timer) + if (adventure_request_timer) { - if(adventure_request_timer->Check()) + if (adventure_request_timer->Check()) { safe_delete(adventure_request_timer); } } - if(adventure_create_timer) + if (adventure_create_timer) { - if(adventure_create_timer->Check()) + if (adventure_create_timer->Check()) { safe_delete(adventure_create_timer); } } - if(adventure_leave_timer) + if (adventure_leave_timer) { - if(adventure_leave_timer->Check()) + if (adventure_leave_timer->Check()) { safe_delete(adventure_leave_timer); } } - if(adventure_door_timer) + if (adventure_door_timer) { - if(adventure_door_timer->Check()) + if (adventure_door_timer->Check()) { safe_delete(adventure_door_timer); } } - if(adventure_stats_timer) + if (adventure_stats_timer) { - if(adventure_stats_timer->Check()) + if (adventure_stats_timer->Check()) { safe_delete(adventure_stats_timer); } } - if(adventure_leaderboard_timer) + if (adventure_leaderboard_timer) { - if(adventure_leaderboard_timer->Check()) + if (adventure_leaderboard_timer->Check()) { safe_delete(adventure_leaderboard_timer); } } - if(dead) + if (dead) { SetHP(-100); - if(RespawnFromHoverTimer.Check()) + if (RespawnFromHoverTimer.Check()) HandleRespawnFromHover(0); } @@ -131,13 +131,13 @@ bool Client::Process() { // SendHPUpdate calls hpupdate_timer.Start so it can delay this timer, so lets not reset with the check // since the function will anyways - if(hpupdate_timer.Check(false)) + if (hpupdate_timer.Check(false)) SendHPUpdate(); - if(mana_timer.Check()) + if (mana_timer.Check()) SendManaUpdatePacket(); - if(dead && dead_timer.Check()) { + if (dead && dead_timer.Check()) { database.MoveCharacterToZone(GetName(), database.GetZoneName(m_pp.binds[0].zoneId)); m_pp.zone_id = m_pp.binds[0].zoneId; @@ -150,7 +150,7 @@ bool Client::Process() { Group *mygroup = GetGroup(); if (mygroup) { - entity_list.MessageGroup(this,true,15,"%s died.", GetName()); + entity_list.MessageGroup(this, true, 15, "%s died.", GetName()); mygroup->MemberZoned(this); } Raid *myraid = entity_list.GetRaidByClient(this); @@ -161,34 +161,29 @@ bool Client::Process() { return(false); } - if(charm_update_timer.Check()) - { + if (charm_update_timer.Check()) { CalcItemScale(); } - if(TaskPeriodic_Timer.Check() && taskstate) + if (TaskPeriodic_Timer.Check() && taskstate) taskstate->TaskPeriodicChecks(this); - if(linkdead_timer.Check()) - { + if (linkdead_timer.Check()) { LeaveGroup(); Save(); - if (GetMerc()) - { + if (GetMerc()) { GetMerc()->Save(); GetMerc()->Depop(); } Raid *myraid = entity_list.GetRaidByClient(this); - if (myraid) - { + if (myraid) { myraid->MemberZoned(this); } return false; //delete client } - if (camp_timer.Check()) - { + if (camp_timer.Check()) { LeaveGroup(); Save(); if (GetMerc()) @@ -202,8 +197,7 @@ bool Client::Process() { if (IsStunned() && stunned_timer.Check()) Mob::UnStun(); - if(!m_CheatDetectMoved) - { + if (!m_CheatDetectMoved) { m_TimeSinceLastPositionCheck = Timer::GetCurrentTime(); } @@ -211,32 +205,32 @@ bool Client::Process() { //NOTE: this is kinda a heavy-handed check to make sure the mob still exists before //doing the next pulse on them... Mob *song_target = nullptr; - if(bardsong_target_id == GetID()) { + if (bardsong_target_id == GetID()) { song_target = this; - } else { + } + else { song_target = entity_list.GetMob(bardsong_target_id); } if (song_target == nullptr) { InterruptSpell(SONG_ENDS_ABRUPTLY, 0x121, bardsong); - } else { - if(!ApplyNextBardPulse(bardsong, song_target, bardsong_slot)) + } + else { + if (!ApplyNextBardPulse(bardsong, song_target, bardsong_slot)) InterruptSpell(SONG_ENDS_ABRUPTLY, 0x121, bardsong); //SpellFinished(bardsong, bardsong_target, bardsong_slot, spells[bardsong].mana); } } - if(GetMerc()) - { + if (GetMerc()) { UpdateMercTimer(); } - if(GetMercInfo().MercTemplateID != 0 && GetMercInfo().IsSuspended) - { + if (GetMercInfo().MercTemplateID != 0 && GetMercInfo().IsSuspended) { CheckMercSuspendTimer(); } - if(IsAIControlled()) + if (IsAIControlled()) AI_Process(); // Don't reset the bindwound timer so we can check it in BindWound as well. @@ -244,28 +238,36 @@ bool Client::Process() { BindWound(bindwound_target, false); } - if(KarmaUpdateTimer) - { - if(KarmaUpdateTimer->Check(false)) - { + if (KarmaUpdateTimer) { + if (KarmaUpdateTimer->Check(false)) { KarmaUpdateTimer->Start(RuleI(Chat, KarmaUpdateIntervalMS)); database.UpdateKarma(AccountID(), ++TotalKarma); } } - if(qGlobals) - { - if(qglobal_purge_timer.Check()) - { + if (qGlobals) { + if (qglobal_purge_timer.Check()) { qGlobals->PurgeExpiredGlobals(); } } - if(light_update_timer.Check()) { + /* Build a close range list of NPC's */ + if (npc_close_scan_timer.Check()) { - UpdateEquipmentLight(); - if(UpdateActiveLight()) { - SendAppearancePacket(AT_Light, GetActiveLightType()); + close_npcs.clear(); + + auto &npc_list = entity_list.GetNPCList(); + + float scan_range = RuleI(Range, ClientNPCScan); + for (auto itr = npc_list.begin(); itr != npc_list.end(); ++itr) { + NPC* npc = itr->second; + float distance = DistanceNoZ(m_Position, npc->GetPosition()); + if(distance <= scan_range) { + close_npcs.insert(std::pair(npc, distance)); + } + else if (npc->GetAggroRange() > scan_range) { + close_npcs.insert(std::pair(npc, distance)); + } } } @@ -279,35 +281,35 @@ bool Client::Process() { - being stunned or mezzed - having used a ranged weapon recently */ - if(auto_attack) { - if(!IsAIControlled() && !dead + if (auto_attack) { + if (!IsAIControlled() && !dead && !(spellend_timer.Enabled() && casting_spell_id && !IsBardSong(casting_spell_id)) && !IsStunned() && !IsFeared() && !IsMezzed() && GetAppearance() != eaDead && !IsMeleeDisabled() ) may_use_attacks = true; - if(may_use_attacks && ranged_timer.Enabled()) { + if (may_use_attacks && ranged_timer.Enabled()) { //if the range timer is enabled, we need to consider it - if(!ranged_timer.Check(false)) { + if (!ranged_timer.Check(false)) { //the ranged timer has not elapsed, cannot attack. may_use_attacks = false; } } } - if(AutoFireEnabled()){ + if (AutoFireEnabled()) { EQEmu::ItemInstance *ranged = GetInv().GetItem(EQEmu::inventory::slotRange); - if(ranged) + if (ranged) { - if (ranged->GetItem() && ranged->GetItem()->ItemType == EQEmu::item::ItemTypeBow){ - if(ranged_timer.Check(false)){ - if(GetTarget() && (GetTarget()->IsNPC() || GetTarget()->IsClient())){ - if(GetTarget()->InFrontMob(this, GetTarget()->GetX(), GetTarget()->GetY())){ - if(CheckLosFN(GetTarget())){ + if (ranged->GetItem() && ranged->GetItem()->ItemType == EQEmu::item::ItemTypeBow) { + if (ranged_timer.Check(false)) { + if (GetTarget() && (GetTarget()->IsNPC() || GetTarget()->IsClient())) { + if (GetTarget()->InFrontMob(this, GetTarget()->GetX(), GetTarget()->GetY())) { + if (CheckLosFN(GetTarget())) { //client has built in los check, but auto fire does not.. done last. RangedAttack(GetTarget()); - if (CheckDoubleRangedAttack()) - RangedAttack(GetTarget(), true); + if (CheckDoubleRangedAttack()) + RangedAttack(GetTarget(), true); } else ranged_timer.Start(); @@ -319,11 +321,11 @@ bool Client::Process() { ranged_timer.Start(); } } - else if (ranged->GetItem() && (ranged->GetItem()->ItemType == EQEmu::item::ItemTypeLargeThrowing || ranged->GetItem()->ItemType == EQEmu::item::ItemTypeSmallThrowing)){ - if(ranged_timer.Check(false)){ - if(GetTarget() && (GetTarget()->IsNPC() || GetTarget()->IsClient())){ - if(GetTarget()->InFrontMob(this, GetTarget()->GetX(), GetTarget()->GetY())){ - if(CheckLosFN(GetTarget())){ + else if (ranged->GetItem() && (ranged->GetItem()->ItemType == EQEmu::item::ItemTypeLargeThrowing || ranged->GetItem()->ItemType == EQEmu::item::ItemTypeSmallThrowing)) { + if (ranged_timer.Check(false)) { + if (GetTarget() && (GetTarget()->IsNPC() || GetTarget()->IsClient())) { + if (GetTarget()->InFrontMob(this, GetTarget()->GetX(), GetTarget()->GetY())) { + if (CheckLosFN(GetTarget())) { //client has built in los check, but auto fire does not.. done last. ThrowingAttack(GetTarget()); } @@ -345,9 +347,9 @@ bool Client::Process() { { //check if change //only check on primary attack.. sorry offhand you gotta wait! - if(aa_los_them_mob) + if (aa_los_them_mob) { - if(auto_attack_target != aa_los_them_mob || + if (auto_attack_target != aa_los_them_mob || m_AutoAttackPosition.x != GetX() || m_AutoAttackPosition.y != GetY() || m_AutoAttackPosition.z != GetZ() || @@ -379,11 +381,11 @@ bool Client::Process() { if (!CombatRange(auto_attack_target)) { - Message_StringID(MT_TooFarAway,TARGET_TOO_FAR); + Message_StringID(MT_TooFarAway, TARGET_TOO_FAR); } else if (auto_attack_target == this) { - Message_StringID(MT_TooFarAway,TRY_ATTACKING_SOMEONE); + Message_StringID(MT_TooFarAway, TRY_ATTACKING_SOMEONE); } else if (!los_status || !los_status_facing) { @@ -412,23 +414,23 @@ bool Client::Process() { } } - if(auto_attack && may_use_attacks && auto_attack_target != nullptr + if (auto_attack && may_use_attacks && auto_attack_target != nullptr && CanThisClassDualWield() && attack_dw_timer.Check()) { // Range check - if(!CombatRange(auto_attack_target)) { + if (!CombatRange(auto_attack_target)) { // this is a duplicate message don't use it. //Message_StringID(MT_TooFarAway,TARGET_TOO_FAR); } // Don't attack yourself - else if(auto_attack_target == this) { + else if (auto_attack_target == this) { //Message_StringID(MT_TooFarAway,TRY_ATTACKING_SOMEONE); } else if (!los_status || !los_status_facing) { //you can't see your target } - else if(auto_attack_target->GetHP() > -10) { + else if (auto_attack_target->GetHP() > -10) { CheckIncreaseSkill(EQEmu::skills::SkillDualWield, auto_attack_target, -10); if (CheckDualWield()) { EQEmu::ItemInstance *wpn = GetInv().GetItem(EQEmu::inventory::slotSecondary); @@ -442,7 +444,7 @@ bool Client::Process() { if (position_timer.Check()) { if (IsAIControlled()) { - if(!IsMoving()) + if (!IsMoving()) { animation = 0; m_Delta = glm::vec4(0.0f, 0.0f, 0.0f, m_Delta.w); @@ -464,25 +466,25 @@ bool Client::Process() { } } - if(HasVirus()) { - if(viral_timer.Check()) { + if (HasVirus()) { + if (viral_timer.Check()) { viral_timer_counter++; - for(int i = 0; i < MAX_SPELL_TRIGGER*2; i+=2) { - if(viral_spells[i]) { - if(viral_timer_counter % spells[viral_spells[i]].viral_timer == 0) { - SpreadVirus(viral_spells[i], viral_spells[i+1]); + for (int i = 0; i < MAX_SPELL_TRIGGER * 2; i += 2) { + if (viral_spells[i]) { + if (viral_timer_counter % spells[viral_spells[i]].viral_timer == 0) { + SpreadVirus(viral_spells[i], viral_spells[i + 1]); } } } } - if(viral_timer_counter > 999) + if (viral_timer_counter > 999) viral_timer_counter = 0; } ProjectileAttack(); - if(spellbonuses.GravityEffect == 1) { - if(gravity_timer.Check()) + if (spellbonuses.GravityEffect == 1) { + if (gravity_timer.Check()) DoGravityEffect(); } @@ -514,7 +516,7 @@ bool Client::Process() { } SpellProcess(); - if (endupkeep_timer.Check() && !dead){ + if (endupkeep_timer.Check() && !dead) { DoEnduranceUpkeep(); } @@ -530,7 +532,7 @@ bool Client::Process() { BuffProcess(); DoStaminaUpdate(); - if(tribute_timer.Check()) { + if (tribute_timer.Check()) { ToggleTribute(true); //re-activate the tribute. } @@ -542,18 +544,18 @@ bool Client::Process() { Save(0); } - if(m_pp.intoxication > 0) + if (m_pp.intoxication > 0) { --m_pp.intoxication; CalcBonuses(); } - if(ItemTickTimer.Check()) + if (ItemTickTimer.Check()) { TickItemCheck(); } - if(ItemQuestTimer.Check()) + if (ItemQuestTimer.Check()) { ItemTimerCheck(); } @@ -582,7 +584,7 @@ bool Client::Process() { if (client_state != CLIENT_LINKDEAD && !eqs->CheckState(ESTABLISHED)) { OnDisconnect(true); - Log.Out(Logs::General, Logs::Zone_Server, "Client linkdead: %s", name); + Log(Logs::General, Logs::Zone_Server, "Client linkdead: %s", name); if (GetGM()) { if (GetMerc()) @@ -592,8 +594,8 @@ bool Client::Process() { } return false; } - else if(!linkdead_timer.Enabled()){ - linkdead_timer.Start(RuleI(Zone,ClientLinkdeadMS)); + else if (!linkdead_timer.Enabled()) { + linkdead_timer.Start(RuleI(Zone, ClientLinkdeadMS)); client_state = CLIENT_LINKDEAD; AI_Start(CLIENT_LD_TIMEOUT); SendAppearancePacket(AT_Linkdead, 1); @@ -603,10 +605,10 @@ bool Client::Process() { /************ Get all packets from packet manager out queue and process them ************/ EQApplicationPacket *app = nullptr; - if(!eqs->CheckState(CLOSING)) + if (!eqs->CheckState(CLOSING)) { - while(ret && (app = (EQApplicationPacket *)eqs->PopPacket())) { - if(app) + while (ret && (app = (EQApplicationPacket *)eqs->PopPacket())) { + if (app) ret = HandlePacket(app); safe_delete(app); } @@ -616,8 +618,17 @@ bool Client::Process() { //At this point, we are still connected, everything important has taken //place, now check to see if anybody wants to aggro us. // only if client is not feigned - if(zone->CanDoCombat() && ret && !GetFeigned() && scanarea_timer.Check()) { - entity_list.CheckClientAggro(this); + if (zone->CanDoCombat() && ret && !GetFeigned() && client_scan_npc_aggro_timer.Check()) { + int npc_scan_count = 0; + for (auto it = close_npcs.begin(); it != close_npcs.end(); ++it) { + NPC *npc = it->first; + + if (npc->CheckWillAggro(this) && !npc->CheckAggro(this)) { + npc->AddToHateList(this, 25); + } + npc_scan_count++; + } + Log(Logs::General, Logs::Aggro, "Checking Reverse Aggro (client->npc) scanned_npcs (%i)", npc_scan_count); } #endif @@ -718,7 +729,7 @@ void Client::OnDisconnect(bool hard_disconnect) { Mob *Other = trade->With(); if(Other) { - Log.Out(Logs::Detail, Logs::Trading, "Client disconnected during a trade. Returning their items."); + Log(Logs::Detail, Logs::Trading, "Client disconnected during a trade. Returning their items."); FinishTrade(this); if(Other->IsClient()) @@ -750,7 +761,7 @@ void Client::BulkSendInventoryItems() if(inst) { bool is_arrow = (inst->GetItem()->ItemType == EQEmu::item::ItemTypeArrow) ? true : false; int16 free_slot_id = m_inv.FindFreeSlot(inst->IsClassBag(), true, inst->GetItem()->Size, is_arrow); - Log.Out(Logs::Detail, Logs::Inventory, "Incomplete Trade Transaction: Moving %s from slot %i to %i", inst->GetItem()->Name, slot_id, free_slot_id); + Log(Logs::Detail, Logs::Inventory, "Incomplete Trade Transaction: Moving %s from slot %i to %i", inst->GetItem()->Name, slot_id, free_slot_id); PutItemInInventory(free_slot_id, *inst, false); database.SaveInventory(character_id, nullptr, slot_id); safe_delete(inst); @@ -779,7 +790,7 @@ void Client::BulkSendInventoryItems() inst->Serialize(ob, slot_id); if (ob.tellp() == last_pos) - Log.Out(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", slot_id); + Log(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", slot_id); last_pos = ob.tellp(); } @@ -791,7 +802,7 @@ void Client::BulkSendInventoryItems() inst->Serialize(ob, EQEmu::inventory::slotPowerSource); if (ob.tellp() == last_pos) - Log.Out(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", EQEmu::inventory::slotPowerSource); + Log(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", EQEmu::inventory::slotPowerSource); last_pos = ob.tellp(); } @@ -806,7 +817,7 @@ void Client::BulkSendInventoryItems() inst->Serialize(ob, slot_id); if (ob.tellp() == last_pos) - Log.Out(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", slot_id); + Log(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", slot_id); last_pos = ob.tellp(); } @@ -820,7 +831,7 @@ void Client::BulkSendInventoryItems() inst->Serialize(ob, slot_id); if (ob.tellp() == last_pos) - Log.Out(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", slot_id); + Log(Logs::General, Logs::Inventory, "Serialization failed on item slot %d during BulkSendInventoryItems. Item skipped.", slot_id); last_pos = ob.tellp(); } @@ -908,7 +919,7 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) { // Account for merchant lists with gaps. if (ml.slot >= i) { if (ml.slot > i) - Log.Out(Logs::General, Logs::None, "(WARNING) Merchantlist contains gap at slot %d. Merchant: %d, NPC: %d", i, merchant_id, npcid); + Log(Logs::General, Logs::None, "(WARNING) Merchantlist contains gap at slot %d. Merchant: %d, NPC: %d", i, merchant_id, npcid); i = ml.slot + 1; } } @@ -1000,7 +1011,7 @@ uint8 Client::WithCustomer(uint16 NewCustomer){ Client* c = entity_list.GetClientByID(CustomerID); if(!c) { - Log.Out(Logs::Detail, Logs::Trading, "Previous customer has gone away."); + Log(Logs::Detail, Logs::Trading, "Previous customer has gone away."); CustomerID = NewCustomer; return 1; } @@ -1012,7 +1023,7 @@ void Client::OPRezzAnswer(uint32 Action, uint32 SpellID, uint16 ZoneID, uint16 I { if(PendingRezzXP < 0) { // pendingrezexp is set to -1 if we are not expecting an OP_RezzAnswer - Log.Out(Logs::Detail, Logs::Spells, "Unexpected OP_RezzAnswer. Ignoring it."); + Log(Logs::Detail, Logs::Spells, "Unexpected OP_RezzAnswer. Ignoring it."); Message(13, "You have already been resurrected.\n"); return; } @@ -1022,7 +1033,7 @@ void Client::OPRezzAnswer(uint32 Action, uint32 SpellID, uint16 ZoneID, uint16 I // Mark the corpse as rezzed in the database, just in case the corpse has buried, or the zone the // corpse is in has shutdown since the rez spell was cast. database.MarkCorpseAsRezzed(PendingRezzDBID); - Log.Out(Logs::Detail, Logs::Spells, "Player %s got a %i Rezz, spellid %i in zone%i, instance id %i", + Log(Logs::Detail, Logs::Spells, "Player %s got a %i Rezz, spellid %i in zone%i, instance id %i", this->name, (uint16)spells[SpellID].base[0], SpellID, ZoneID, InstanceID); @@ -1075,7 +1086,7 @@ void Client::OPMemorizeSpell(const EQApplicationPacket* app) { if(app->size != sizeof(MemorizeSpell_Struct)) { - Log.Out(Logs::General, Logs::Error, "Wrong size on OP_MemorizeSpell. Got: %i, Expected: %i", app->size, sizeof(MemorizeSpell_Struct)); + Log(Logs::General, Logs::Error, "Wrong size on OP_MemorizeSpell. Got: %i, Expected: %i", app->size, sizeof(MemorizeSpell_Struct)); DumpPacket(app); return; } @@ -1628,12 +1639,12 @@ void Client::OPGMTrainSkill(const EQApplicationPacket *app) EQEmu::skills::SkillType skill = (EQEmu::skills::SkillType)gmskill->skill_id; if(!CanHaveSkill(skill)) { - Log.Out(Logs::Detail, Logs::Skills, "Tried to train skill %d, which is not allowed.", skill); + Log(Logs::Detail, Logs::Skills, "Tried to train skill %d, which is not allowed.", skill); return; } if(MaxSkill(skill) == 0) { - Log.Out(Logs::Detail, Logs::Skills, "Tried to train skill %d, but training is not allowed at this level.", skill); + Log(Logs::Detail, Logs::Skills, "Tried to train skill %d, but training is not allowed at this level.", skill); return; } @@ -2027,7 +2038,7 @@ void Client::HandleRespawnFromHover(uint32 Option) { if (PendingRezzXP < 0 || PendingRezzSpellID == 0) { - Log.Out(Logs::Detail, Logs::Spells, "Unexpected Rezz from hover request."); + Log(Logs::Detail, Logs::Spells, "Unexpected Rezz from hover request."); return; } SetHP(GetMaxHP() / 5); @@ -2061,10 +2072,10 @@ void Client::HandleRespawnFromHover(uint32 Option) if (corpse && corpse->IsCorpse()) { - Log.Out(Logs::Detail, Logs::Spells, "Hover Rez in zone %s for corpse %s", + Log(Logs::Detail, Logs::Spells, "Hover Rez in zone %s for corpse %s", zone->GetShortName(), PendingRezzCorpseName.c_str()); - Log.Out(Logs::Detail, Logs::Spells, "Found corpse. Marking corpse as rezzed."); + Log(Logs::Detail, Logs::Spells, "Found corpse. Marking corpse as rezzed."); corpse->IsRezzed(true); corpse->CompleteResurrection(); diff --git a/zone/command.cpp b/zone/command.cpp index d093b94a4..efc90e01b 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -430,12 +430,12 @@ int command_init(void) auto iter_cs = command_settings.find(iter_cl->first); if (iter_cs == command_settings.end()) { if (iter_cl->second->access == 0) - Log.Out(Logs::General, Logs::Commands, "command_init(): Warning: Command '%s' defaulting to access level 0!", iter_cl->first.c_str()); + Log(Logs::General, Logs::Commands, "command_init(): Warning: Command '%s' defaulting to access level 0!", iter_cl->first.c_str()); continue; } iter_cl->second->access = iter_cs->second.first; - Log.Out(Logs::General, Logs::Commands, "command_init(): - Command '%s' set to access level %d.", iter_cl->first.c_str(), iter_cs->second.first); + Log(Logs::General, Logs::Commands, "command_init(): - Command '%s' set to access level %d.", iter_cl->first.c_str(), iter_cs->second.first); if (iter_cs->second.second.empty()) continue; @@ -444,14 +444,14 @@ int command_init(void) if (iter_aka->empty()) continue; if (commandlist.find(*iter_aka) != commandlist.end()) { - Log.Out(Logs::General, Logs::Commands, "command_init(): Warning: Alias '%s' already exists as a command - skipping!", iter_aka->c_str()); + Log(Logs::General, Logs::Commands, "command_init(): Warning: Alias '%s' already exists as a command - skipping!", iter_aka->c_str()); continue; } commandlist[*iter_aka] = iter_cl->second; commandaliases[*iter_aka] = iter_cl->first; - Log.Out(Logs::General, Logs::Commands, "command_init(): - Alias '%s' added to command '%s'.", iter_aka->c_str(), commandaliases[*iter_aka].c_str()); + Log(Logs::General, Logs::Commands, "command_init(): - Alias '%s' added to command '%s'.", iter_aka->c_str(), commandaliases[*iter_aka].c_str()); } } @@ -491,21 +491,21 @@ void command_deinit(void) int command_add(std::string command_name, const char *desc, int access, CmdFuncPtr function) { if (command_name.empty()) { - Log.Out(Logs::General, Logs::Error, "command_add() - Command added with empty name string - check command.cpp."); + Log(Logs::General, Logs::Error, "command_add() - Command added with empty name string - check command.cpp."); return -1; } if (function == nullptr) { - Log.Out(Logs::General, Logs::Error, "command_add() - Command '%s' added without a valid function pointer - check command.cpp.", command_name.c_str()); + Log(Logs::General, Logs::Error, "command_add() - Command '%s' added without a valid function pointer - check command.cpp.", command_name.c_str()); return -1; } if (commandlist.count(command_name) != 0) { - Log.Out(Logs::General, Logs::Error, "command_add() - Command '%s' is a duplicate command name - check command.cpp.", command_name.c_str()); + Log(Logs::General, Logs::Error, "command_add() - Command '%s' is a duplicate command name - check command.cpp.", command_name.c_str()); return -1; } for (auto iter = commandlist.begin(); iter != commandlist.end(); ++iter) { if (iter->second->function != function) continue; - Log.Out(Logs::General, Logs::Error, "command_add() - Command '%s' equates to an alias of '%s' - check command.cpp.", command_name.c_str(), iter->first.c_str()); + Log(Logs::General, Logs::Error, "command_add() - Command '%s' equates to an alias of '%s' - check command.cpp.", command_name.c_str(), iter->first.c_str()); return -1; } @@ -559,11 +559,11 @@ int command_realdispatch(Client *c, const char *message) } if(cur->access >= COMMANDS_LOGGING_MIN_STATUS) { - Log.Out(Logs::General, Logs::Commands, "%s (%s) used command: %s (target=%s)", c->GetName(), c->AccountName(), message, c->GetTarget()?c->GetTarget()->GetName():"NONE"); + Log(Logs::General, Logs::Commands, "%s (%s) used command: %s (target=%s)", c->GetName(), c->AccountName(), message, c->GetTarget()?c->GetTarget()->GetName():"NONE"); } if(cur->function == nullptr) { - Log.Out(Logs::General, Logs::Error, "Command '%s' has a null function\n", cstr.c_str()); + Log(Logs::General, Logs::Error, "Command '%s' has a null function\n", cstr.c_str()); return(-1); } else { //dispatch C++ command @@ -1262,7 +1262,7 @@ void command_viewpetition(Client *c, const Seperator *sep) if (!results.Success()) return; - Log.Out(Logs::General, Logs::Normal, "View petition request from %s, petition number: %i", c->GetName(), atoi(sep->argplus[1]) ); + Log(Logs::General, Logs::Normal, "View petition request from %s, petition number: %i", c->GetName(), atoi(sep->argplus[1]) ); if (results.RowCount() == 0) { c->Message(13,"There was an error in your request: ID not found! Please check the Id and try again."); @@ -1287,7 +1287,7 @@ void command_petitioninfo(Client *c, const Seperator *sep) if (!results.Success()) return; - Log.Out(Logs::General, Logs::Normal, "Petition information request from %s, petition number:", c->GetName(), atoi(sep->argplus[1]) ); + Log(Logs::General, Logs::Normal, "Petition information request from %s, petition number:", c->GetName(), atoi(sep->argplus[1]) ); if (results.RowCount() == 0) { c->Message(13,"There was an error in your request: ID not found! Please check the Id and try again."); @@ -1313,7 +1313,7 @@ void command_delpetition(Client *c, const Seperator *sep) if (!results.Success()) return; - Log.Out(Logs::General, Logs::Normal, "Delete petition request from %s, petition number:", c->GetName(), atoi(sep->argplus[1]) ); + Log(Logs::General, Logs::Normal, "Delete petition request from %s, petition number:", c->GetName(), atoi(sep->argplus[1]) ); } @@ -1549,7 +1549,7 @@ void command_permaclass(Client *c, const Seperator *sep) c->Message(0,"Target is not a client."); else { c->Message(0, "Setting %s's class...Sending to char select.", t->GetName()); - Log.Out(Logs::General, Logs::Normal, "Class change request from %s for %s, requested class:%i", c->GetName(), t->GetName(), atoi(sep->arg[1]) ); + Log(Logs::General, Logs::Normal, "Class change request from %s for %s, requested class:%i", c->GetName(), t->GetName(), atoi(sep->arg[1]) ); t->SetBaseClass(atoi(sep->arg[1])); t->Save(); t->Kick(); @@ -1571,7 +1571,7 @@ void command_permarace(Client *c, const Seperator *sep) c->Message(0,"Target is not a client."); else { c->Message(0, "Setting %s's race - zone to take effect", t->GetName()); - Log.Out(Logs::General, Logs::Normal, "Permanant race change request from %s for %s, requested race:%i", c->GetName(), t->GetName(), atoi(sep->arg[1]) ); + Log(Logs::General, Logs::Normal, "Permanant race change request from %s for %s, requested race:%i", c->GetName(), t->GetName(), atoi(sep->arg[1]) ); uint32 tmp = Mob::GetDefaultGender(atoi(sep->arg[1]), t->GetBaseGender()); t->SetBaseRace(atoi(sep->arg[1])); t->SetBaseGender(tmp); @@ -1595,7 +1595,7 @@ void command_permagender(Client *c, const Seperator *sep) c->Message(0,"Target is not a client."); else { c->Message(0, "Setting %s's gender - zone to take effect", t->GetName()); - Log.Out(Logs::General, Logs::Normal, "Permanant gender change request from %s for %s, requested gender:%i", c->GetName(), t->GetName(), atoi(sep->arg[1]) ); + Log(Logs::General, Logs::Normal, "Permanant gender change request from %s for %s, requested gender:%i", c->GetName(), t->GetName(), atoi(sep->arg[1]) ); t->SetBaseGender(atoi(sep->arg[1])); t->Save(); t->SendIllusionPacket(atoi(sep->arg[1])); @@ -1932,7 +1932,7 @@ void command_dbspawn2(Client *c, const Seperator *sep) { if (sep->IsNumber(1) && sep->IsNumber(2) && sep->IsNumber(3)) { - Log.Out(Logs::General, Logs::Normal, "Spawning database spawn"); + Log(Logs::General, Logs::Normal, "Spawning database spawn"); uint16 cond = 0; int16 cond_min = 0; if(sep->IsNumber(4)) { @@ -2255,7 +2255,7 @@ void command_setlanguage(Client *c, const Seperator *sep) } else { - Log.Out(Logs::General, Logs::Normal, "Set language request from %s, target:%s lang_id:%i value:%i", c->GetName(), c->GetTarget()->GetName(), atoi(sep->arg[1]), atoi(sep->arg[2]) ); + Log(Logs::General, Logs::Normal, "Set language request from %s, target:%s lang_id:%i value:%i", c->GetName(), c->GetTarget()->GetName(), atoi(sep->arg[1]), atoi(sep->arg[2]) ); uint8 langid = (uint8)atoi(sep->arg[1]); uint8 value = (uint8)atoi(sep->arg[2]); c->GetTarget()->CastToClient()->SetLanguageSkill( langid, value ); @@ -2280,7 +2280,7 @@ void command_setskill(Client *c, const Seperator *sep) c->Message(0, " x = 0 to %d", HIGHEST_CAN_SET_SKILL); } else { - Log.Out(Logs::General, Logs::Normal, "Set skill request from %s, target:%s skill_id:%i value:%i", c->GetName(), c->GetTarget()->GetName(), atoi(sep->arg[1]), atoi(sep->arg[2]) ); + Log(Logs::General, Logs::Normal, "Set skill request from %s, target:%s skill_id:%i value:%i", c->GetName(), c->GetTarget()->GetName(), atoi(sep->arg[1]), atoi(sep->arg[2]) ); int skill_num = atoi(sep->arg[1]); uint16 skill_value = atoi(sep->arg[2]); if (skill_num <= EQEmu::skills::HIGHEST_SKILL) @@ -2300,7 +2300,7 @@ void command_setskillall(Client *c, const Seperator *sep) } else { if (c->Admin() >= commandSetSkillsOther || c->GetTarget()==c || c->GetTarget()==0) { - Log.Out(Logs::General, Logs::Normal, "Set ALL skill request from %s, target:%s", c->GetName(), c->GetTarget()->GetName()); + Log(Logs::General, Logs::Normal, "Set ALL skill request from %s, target:%s", c->GetName(), c->GetTarget()->GetName()); uint16 level = atoi(sep->arg[1]); for (EQEmu::skills::SkillType skill_num = EQEmu::skills::Skill1HBlunt; skill_num <= EQEmu::skills::HIGHEST_SKILL; skill_num = (EQEmu::skills::SkillType)(skill_num + 1)) { c->GetTarget()->CastToClient()->SetSkill(skill_num, level); @@ -3123,7 +3123,7 @@ void command_listpetition(Client *c, const Seperator *sep) if (!results.Success()) return; - Log.Out(Logs::General, Logs::Normal, "Petition list requested by %s", c->GetName()); + Log(Logs::General, Logs::Normal, "Petition list requested by %s", c->GetName()); if (results.RowCount() == 0) return; @@ -3781,7 +3781,7 @@ void command_lastname(Client *c, const Seperator *sep) if(c->GetTarget() && c->GetTarget()->IsClient()) t=c->GetTarget()->CastToClient(); - Log.Out(Logs::General, Logs::Normal, "#lastname request from %s for %s", c->GetName(), t->GetName()); + Log(Logs::General, Logs::Normal, "#lastname request from %s for %s", c->GetName(), t->GetName()); if(strlen(sep->arg[1]) <= 70) t->ChangeLastName(sep->arg[1]); @@ -4338,7 +4338,7 @@ void command_iteminfo(Client *c, const Seperator *sep) } auto item = inst->GetItem(); if (!item) { - Log.Out(Logs::General, Logs::Inventory, "(%s) Command #iteminfo processed an item with no data pointer"); + Log(Logs::General, Logs::Inventory, "(%s) Command #iteminfo processed an item with no data pointer"); c->Message(13, "Error: This item has no data reference"); return; } @@ -4445,7 +4445,7 @@ void command_time(Client *c, const Seperator *sep) } c->Message(13, "Setting world time to %s:%i (Timezone: 0)...", sep->arg[1], minutes); zone->SetTime(atoi(sep->arg[1])+1, minutes); - Log.Out(Logs::General, Logs::Zone_Server, "%s :: Setting world time to %s:%i (Timezone: 0)...", c->GetCleanName(), sep->arg[1], minutes); + Log(Logs::General, Logs::Zone_Server, "%s :: Setting world time to %s:%i (Timezone: 0)...", c->GetCleanName(), sep->arg[1], minutes); } else { c->Message(13, "To set the Time: #time HH [MM]"); @@ -4460,7 +4460,7 @@ void command_time(Client *c, const Seperator *sep) zone->zone_time.getEQTimeZoneMin() ); c->Message(13, "It is now %s.", timeMessage); - Log.Out(Logs::General, Logs::Zone_Server, "Current Time is: %s", timeMessage); + Log(Logs::General, Logs::Zone_Server, "Current Time is: %s", timeMessage); } } @@ -4594,10 +4594,10 @@ void command_guild(Client *c, const Seperator *sep) } if(guild_id == GUILD_NONE) { - Log.Out(Logs::Detail, Logs::Guilds, "%s: Removing %s (%d) from guild with GM command.", c->GetName(), + Log(Logs::Detail, Logs::Guilds, "%s: Removing %s (%d) from guild with GM command.", c->GetName(), sep->arg[2], charid); } else { - Log.Out(Logs::Detail, Logs::Guilds, "%s: Putting %s (%d) into guild %s (%d) with GM command.", c->GetName(), + Log(Logs::Detail, Logs::Guilds, "%s: Putting %s (%d) into guild %s (%d) with GM command.", c->GetName(), sep->arg[2], charid, guild_mgr.GetGuildName(guild_id), guild_id); } @@ -4646,7 +4646,7 @@ void command_guild(Client *c, const Seperator *sep) return; } - Log.Out(Logs::Detail, Logs::Guilds, "%s: Setting %s (%d)'s guild rank to %d with GM command.", c->GetName(), + Log(Logs::Detail, Logs::Guilds, "%s: Setting %s (%d)'s guild rank to %d with GM command.", c->GetName(), sep->arg[2], charid, rank); if(!guild_mgr.SetGuildRank(charid, rank)) @@ -4688,7 +4688,7 @@ void command_guild(Client *c, const Seperator *sep) uint32 id = guild_mgr.CreateGuild(sep->argplus[3], leader); - Log.Out(Logs::Detail, Logs::Guilds, "%s: Creating guild %s with leader %d with GM command. It was given id %lu.", c->GetName(), + Log(Logs::Detail, Logs::Guilds, "%s: Creating guild %s with leader %d with GM command. It was given id %lu.", c->GetName(), sep->argplus[3], leader, (unsigned long)id); if (id == GUILD_NONE) @@ -4727,7 +4727,7 @@ void command_guild(Client *c, const Seperator *sep) } } - Log.Out(Logs::Detail, Logs::Guilds, "%s: Deleting guild %s (%d) with GM command.", c->GetName(), + Log(Logs::Detail, Logs::Guilds, "%s: Deleting guild %s (%d) with GM command.", c->GetName(), guild_mgr.GetGuildName(id), id); if (!guild_mgr.DeleteGuild(id)) @@ -4761,7 +4761,7 @@ void command_guild(Client *c, const Seperator *sep) } } - Log.Out(Logs::Detail, Logs::Guilds, "%s: Renaming guild %s (%d) to '%s' with GM command.", c->GetName(), + Log(Logs::Detail, Logs::Guilds, "%s: Renaming guild %s (%d) to '%s' with GM command.", c->GetName(), guild_mgr.GetGuildName(id), id, sep->argplus[3]); if (!guild_mgr.RenameGuild(id, sep->argplus[3])) @@ -4812,7 +4812,7 @@ void command_guild(Client *c, const Seperator *sep) } } - Log.Out(Logs::Detail, Logs::Guilds, "%s: Setting leader of guild %s (%d) to %d with GM command.", c->GetName(), + Log(Logs::Detail, Logs::Guilds, "%s: Setting leader of guild %s (%d) to %d with GM command.", c->GetName(), guild_mgr.GetGuildName(id), id, leader); if(!guild_mgr.SetGuildLeader(id, leader)) @@ -5272,7 +5272,7 @@ void command_scribespells(Client *c, const Seperator *sep) t->Message(0, "Scribing spells to spellbook."); if(t != c) c->Message(0, "Scribing spells for %s.", t->GetName()); - Log.Out(Logs::General, Logs::Normal, "Scribe spells request for %s from %s, levels: %u -> %u", t->GetName(), c->GetName(), min_level, max_level); + Log(Logs::General, Logs::Normal, "Scribe spells request for %s from %s, levels: %u -> %u", t->GetName(), c->GetName(), min_level, max_level); for(curspell = 0, book_slot = t->GetNextAvailableSpellBookSlot(), count = 0; curspell < SPDAT_RECORDS && book_slot < MAX_PP_SPELLBOOK; curspell++, book_slot = t->GetNextAvailableSpellBookSlot(book_slot)) { @@ -5329,7 +5329,7 @@ void command_scribespell(Client *c, const Seperator *sep) { if(t != c) c->Message(0, "Scribing spell: %s (%i) for %s.", spells[spell_id].name, spell_id, t->GetName()); - Log.Out(Logs::General, Logs::Normal, "Scribe spell: %s (%i) request for %s from %s.", spells[spell_id].name, spell_id, t->GetName(), c->GetName()); + Log(Logs::General, Logs::Normal, "Scribe spell: %s (%i) request for %s from %s.", spells[spell_id].name, spell_id, t->GetName(), c->GetName()); if (spells[spell_id].classes[WARRIOR] != 0 && spells[spell_id].skill != 52 && spells[spell_id].classes[t->GetPP().class_ - 1] > 0 && !IsDiscipline(spell_id)) { book_slot = t->GetNextAvailableSpellBookSlot(); @@ -5376,7 +5376,7 @@ void command_unscribespell(Client *c, const Seperator *sep) { if(t != c) c->Message(0, "Unscribing spell: %s (%i) for %s.", spells[spell_id].name, spell_id, t->GetName()); - Log.Out(Logs::General, Logs::Normal, "Unscribe spell: %s (%i) request for %s from %s.", spells[spell_id].name, spell_id, t->GetName(), c->GetName()); + Log(Logs::General, Logs::Normal, "Unscribe spell: %s (%i) request for %s from %s.", spells[spell_id].name, spell_id, t->GetName(), c->GetName()); } else { t->Message(13, "Unable to unscribe spell: %s (%i) from your spellbook. This spell is not scribed.", spells[spell_id].name, spell_id); @@ -7816,7 +7816,7 @@ void command_traindisc(Client *c, const Seperator *sep) t->Message(0, "Training disciplines"); if(t != c) c->Message(0, "Training disciplines for %s.", t->GetName()); - Log.Out(Logs::General, Logs::Normal, "Train disciplines request for %s from %s, levels: %u -> %u", t->GetName(), c->GetName(), min_level, max_level); + Log(Logs::General, Logs::Normal, "Train disciplines request for %s from %s, levels: %u -> %u", t->GetName(), c->GetName(), min_level, max_level); for(curspell = 0, count = 0; curspell < SPDAT_RECORDS; curspell++) { @@ -10613,7 +10613,7 @@ void command_logtest(Client *c, const Seperator *sep){ uint32 i = 0; t = std::clock(); for (i = 0; i < atoi(sep->arg[1]); i++){ - Log.Out(Logs::General, Logs::Debug, "[%u] Test #2... Took %f seconds", i, ((float)(std::clock() - t)) / CLOCKS_PER_SEC); + Log(Logs::General, Logs::Debug, "[%u] Test #2... Took %f seconds", i, ((float)(std::clock() - t)) / CLOCKS_PER_SEC); } } @@ -10645,22 +10645,22 @@ void command_logs(Client *c, const Seperator *sep){ c->Message(0, "[Category ID | console | file | gmsay | Category Description]"); redisplay_columns = 0; } - c->Message(0, StringFormat("--- %i | %u | %u | %u | %s", i, Log.log_settings[i].log_to_console, Log.log_settings[i].log_to_file, Log.log_settings[i].log_to_gmsay, Logs::LogCategoryName[i]).c_str()); + c->Message(0, StringFormat("--- %i | %u | %u | %u | %s", i, LogSys.log_settings[i].log_to_console, LogSys.log_settings[i].log_to_file, LogSys.log_settings[i].log_to_gmsay, Logs::LogCategoryName[i]).c_str()); redisplay_columns++; } } /* #logs set */ if (strcasecmp(sep->arg[1], "set") == 0){ if (strcasecmp(sep->arg[2], "console") == 0){ - Log.log_settings[atoi(sep->arg[3])].log_to_console = atoi(sep->arg[4]); + LogSys.log_settings[atoi(sep->arg[3])].log_to_console = atoi(sep->arg[4]); logs_set = 1; } else if (strcasecmp(sep->arg[2], "file") == 0){ - Log.log_settings[atoi(sep->arg[3])].log_to_file = atoi(sep->arg[4]); + LogSys.log_settings[atoi(sep->arg[3])].log_to_file = atoi(sep->arg[4]); logs_set = 1; } else if (strcasecmp(sep->arg[2], "gmsay") == 0){ - Log.log_settings[atoi(sep->arg[3])].log_to_gmsay = atoi(sep->arg[4]); + LogSys.log_settings[atoi(sep->arg[3])].log_to_gmsay = atoi(sep->arg[4]); logs_set = 1; } else{ @@ -10675,10 +10675,10 @@ void command_logs(Client *c, const Seperator *sep){ This is used in hot places of code to check if its enabled in any way before triggering logs */ if (atoi(sep->arg[4]) > 0){ - Log.log_settings[atoi(sep->arg[3])].is_category_enabled = 1; + LogSys.log_settings[atoi(sep->arg[3])].is_category_enabled = 1; } else{ - Log.log_settings[atoi(sep->arg[3])].is_category_enabled = 0; + LogSys.log_settings[atoi(sep->arg[3])].is_category_enabled = 0; } } } @@ -10701,7 +10701,7 @@ void command_mysqltest(Client *c, const Seperator *sep) auto results = database.QueryDatabase(query); } } - Log.Out(Logs::General, Logs::Debug, "MySQL Test... Took %f seconds", ((float)(std::clock() - t)) / CLOCKS_PER_SEC); + Log(Logs::General, Logs::Debug, "MySQL Test... Took %f seconds", ((float)(std::clock() - t)) / CLOCKS_PER_SEC); } void command_resetaa_timer(Client *c, const Seperator *sep) { diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 1bfc4ef10..a8f3e7ba1 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -798,7 +798,7 @@ bool Corpse::Process() { spc->zone_id = zone->graveyard_zoneid(); worldserver.SendPacket(pack); safe_delete(pack); - Log.Out(Logs::General, Logs::None, "Moved %s player corpse to the designated graveyard in zone %s.", this->GetName(), database.GetZoneName(zone->graveyard_zoneid())); + Log(Logs::General, Logs::None, "Moved %s player corpse to the designated graveyard in zone %s.", this->GetName(), database.GetZoneName(zone->graveyard_zoneid())); corpse_db_id = 0; } @@ -828,10 +828,10 @@ bool Corpse::Process() { Save(); player_corpse_depop = true; corpse_db_id = 0; - Log.Out(Logs::General, Logs::None, "Tagged %s player corpse has buried.", this->GetName()); + Log(Logs::General, Logs::None, "Tagged %s player corpse has buried.", this->GetName()); } else { - Log.Out(Logs::General, Logs::Error, "Unable to bury %s player corpse.", this->GetName()); + Log(Logs::General, Logs::Error, "Unable to bury %s player corpse.", this->GetName()); return true; } } @@ -1046,7 +1046,7 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a for(; cur != end; ++cur) { ServerLootItem_Struct* item_data = *cur; item = database.GetItem(item_data->item_id); - Log.Out(Logs::General, Logs::None, "Corpse Looting: %s was not sent to client loot window (corpse_dbid: %i, charname: %s(%s))", item->Name, GetCorpseDBID(), client->GetName(), client->GetGM() ? "GM" : "Owner"); + Log(Logs::General, Logs::None, "Corpse Looting: %s was not sent to client loot window (corpse_dbid: %i, charname: %s(%s))", item->Name, GetCorpseDBID(), client->GetName(), client->GetGM() ? "GM" : "Owner"); client->Message(0, "Inaccessable Corpse Item: %s", item->Name); } } diff --git a/zone/doors.cpp b/zone/doors.cpp index 45953fc89..b2cfede41 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -133,9 +133,9 @@ bool Doors::Process() void Doors::HandleClick(Client* sender, uint8 trigger) { //door debugging info dump - Log.Out(Logs::Detail, Logs::Doors, "%s clicked door %s (dbid %d, eqid %d) at %s", sender->GetName(), door_name, db_id, door_id, to_string(m_Position).c_str()); - Log.Out(Logs::Detail, Logs::Doors, " incline %d, opentype %d, lockpick %d, key %d, nokeyring %d, trigger %d type %d, param %d", incline, opentype, lockpick, keyitem, nokeyring, trigger_door, trigger_type, door_param); - Log.Out(Logs::Detail, Logs::Doors, " size %d, invert %d, dest: %s %s", size, invert_state, dest_zone, to_string(m_Destination).c_str()); + Log(Logs::Detail, Logs::Doors, "%s clicked door %s (dbid %d, eqid %d) at %s", sender->GetName(), door_name, db_id, door_id, to_string(m_Position).c_str()); + Log(Logs::Detail, Logs::Doors, " incline %d, opentype %d, lockpick %d, key %d, nokeyring %d, trigger %d type %d, param %d", incline, opentype, lockpick, keyitem, nokeyring, trigger_door, trigger_type, door_param); + Log(Logs::Detail, Logs::Doors, " size %d, invert %d, dest: %s %s", size, invert_state, dest_zone, to_string(m_Destination).c_str()); auto outapp = new EQApplicationPacket(OP_MoveDoor, sizeof(MoveDoor_Struct)); MoveDoor_Struct* md = (MoveDoor_Struct*)outapp->pBuffer; @@ -291,7 +291,7 @@ void Doors::HandleClick(Client* sender, uint8 trigger) float modskill = sender->GetSkill(EQEmu::skills::SkillPickLock); sender->CheckIncreaseSkill(EQEmu::skills::SkillPickLock, nullptr, 1); - Log.Out(Logs::General, Logs::Skills, "Client has lockpicks: skill=%f", modskill); + Log(Logs::General, Logs::Skills, "Client has lockpicks: skill=%f", modskill); if(GetLockpick() <= modskill) { @@ -547,13 +547,13 @@ void Doors::ToggleState(Mob *sender) } void Doors::DumpDoor(){ - Log.Out(Logs::General, Logs::None, + Log(Logs::General, Logs::None, "db_id:%i door_id:%i zone_name:%s door_name:%s %s", db_id, door_id, zone_name, door_name, to_string(m_Position).c_str()); - Log.Out(Logs::General, Logs::None, + Log(Logs::General, Logs::None, "opentype:%i guild_id:%i lockpick:%i keyitem:%i nokeyring:%i trigger_door:%i trigger_type:%i door_param:%i open:%s", opentype, guild_id, lockpick, keyitem, nokeyring, trigger_door, trigger_type, door_param, (isopen) ? "open":"closed"); - Log.Out(Logs::General, Logs::None, + Log(Logs::General, Logs::None, "dest_zone:%s destination:%s ", dest_zone, to_string(m_Destination).c_str()); } @@ -629,7 +629,7 @@ int32 ZoneDatabase::GetDoorsDBCountPlusOne(const char *zone_name, int16 version) } bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name, int16 version) { - Log.Out(Logs::General, Logs::Status, "Loading Doors from database..."); + Log(Logs::General, Logs::Status, "Loading Doors from database..."); // Door tmpDoor; @@ -656,7 +656,7 @@ bool ZoneDatabase::LoadDoors(int32 iDoorCount, Door *into, const char *zone_name into[rowIndex].db_id = atoi(row[0]); into[rowIndex].door_id = atoi(row[1]); - Log.Out(Logs::Detail, Logs::Doors, "Door Load: db id: %u, door_id %u", into[rowIndex].db_id, into[rowIndex].door_id); + Log(Logs::Detail, Logs::Doors, "Door Load: db id: %u, door_id %u", into[rowIndex].db_id, into[rowIndex].door_id); strn0cpy(into[rowIndex].zone_name,row[2],32); strn0cpy(into[rowIndex].door_name,row[3],32); diff --git a/zone/effects.cpp b/zone/effects.cpp index 9d3c64990..2537751aa 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -485,7 +485,7 @@ bool Client::TrainDiscipline(uint32 itemid) { const EQEmu::ItemData *item = database.GetItem(itemid); if(item == nullptr) { Message(13, "Unable to find the tome you turned in!"); - Log.Out(Logs::General, Logs::Error, "Unable to find turned in tome id %lu\n", (unsigned long)itemid); + Log(Logs::General, Logs::Error, "Unable to find turned in tome id %lu\n", (unsigned long)itemid); return(false); } diff --git a/zone/embparser.cpp b/zone/embparser.cpp index bf9bbe5cb..f76c2ea6a 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -144,7 +144,7 @@ void PerlembParser::ReloadQuests() { perl = nullptr; } - Log.Out(Logs::General, Logs::Status, "Error re-initializing perlembed: %s", e.what()); + Log(Logs::General, Logs::Status, "Error re-initializing perlembed: %s", e.what()); throw e.what(); } diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index c6b07e764..d74282211 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -3654,13 +3654,13 @@ XS(XS__debug) return; if (debug_level == Logs::General){ - Log.Out(Logs::General, Logs::QuestDebug, log_message); + Log(Logs::General, Logs::QuestDebug, log_message); } else if (debug_level == Logs::Moderate){ - Log.Out(Logs::Moderate, Logs::QuestDebug, log_message); + Log(Logs::Moderate, Logs::QuestDebug, log_message); } else if (debug_level == Logs::Detail){ - Log.Out(Logs::Detail, Logs::QuestDebug, log_message); + Log(Logs::Detail, Logs::QuestDebug, log_message); } } XSRETURN_EMPTY; @@ -3693,7 +3693,7 @@ EXTERN_C XS(boot_quest) file[255] = '\0'; if(items != 1) - Log.Out(Logs::General, Logs::Error, "boot_quest does not take any arguments."); + Log(Logs::General, Logs::Error, "boot_quest does not take any arguments."); char buf[128]; //shouldent have any function names longer than this. diff --git a/zone/embperl.cpp b/zone/embperl.cpp index d881cad5e..71338c05a 100644 --- a/zone/embperl.cpp +++ b/zone/embperl.cpp @@ -140,12 +140,12 @@ void Embperl::DoInit() { catch(const char *err) { //remember... lasterr() is no good if we crap out here, in construction - Log.Out(Logs::General, Logs::Quests, "perl error: %s", err); + Log(Logs::General, Logs::Quests, "perl error: %s", err); throw "failed to install eval_file hook"; } #ifdef EMBPERL_IO_CAPTURE - Log.Out(Logs::General, Logs::Quests, "Tying perl output to eqemu logs"); + Log(Logs::General, Logs::Quests, "Tying perl output to eqemu logs"); //make a tieable class to capture IO and pass it into EQEMuLog eval_pv( "package EQEmuIO; " @@ -170,7 +170,7 @@ void Embperl::DoInit() { ,FALSE ); - Log.Out(Logs::General, Logs::Quests, "Loading perlemb plugins."); + Log(Logs::General, Logs::Quests, "Loading perlemb plugins."); try { std::string perl_command; @@ -179,7 +179,7 @@ void Embperl::DoInit() { } catch(const char *err) { - Log.Out(Logs::General, Logs::Quests, "Warning - %s: %s", Config->PluginPlFile.c_str(), err); + Log(Logs::General, Logs::Quests, "Warning - %s: %s", Config->PluginPlFile.c_str(), err); } try { @@ -197,7 +197,7 @@ void Embperl::DoInit() { } catch(const char *err) { - Log.Out(Logs::General, Logs::Quests, "Perl warning: %s", err); + Log(Logs::General, Logs::Quests, "Perl warning: %s", err); } #endif //EMBPERL_PLUGIN in_use = false; diff --git a/zone/embxs.cpp b/zone/embxs.cpp index 5a4acc36d..fe4a12aee 100644 --- a/zone/embxs.cpp +++ b/zone/embxs.cpp @@ -68,7 +68,7 @@ EXTERN_C XS(boot_qc) file[255] = '\0'; if(items != 1) - Log.Out(Logs::General, Logs::Error, "boot_qc does not take any arguments."); + Log(Logs::General, Logs::Error, "boot_qc does not take any arguments."); char buf[128]; //shouldent have any function names longer than this. @@ -104,7 +104,7 @@ XS(XS_EQEmuIO_PRINT) int len = 0; for(i = 0; *cur != '\0'; i++, cur++) { if(*cur == '\n') { - Log.Out(Logs::General, Logs::Quests, str); + Log(Logs::General, Logs::Quests, str); len = 0; pos = i+1; } else { @@ -112,7 +112,7 @@ XS(XS_EQEmuIO_PRINT) } } if(len > 0) { - Log.Out(Logs::General, Logs::Quests, str); + Log(Logs::General, Logs::Quests, str); } } diff --git a/zone/entity.cpp b/zone/entity.cpp index 5f20dffc7..2189228c3 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -73,12 +73,12 @@ Entity::~Entity() Client *Entity::CastToClient() { if (this == 0x00) { - Log.Out(Logs::General, Logs::Error, "CastToClient error (nullptr)"); + Log(Logs::General, Logs::Error, "CastToClient error (nullptr)"); return 0; } #ifdef _EQDEBUG if (!IsClient()) { - Log.Out(Logs::General, Logs::Error, "CastToClient error (not client)"); + Log(Logs::General, Logs::Error, "CastToClient error (not client)"); return 0; } #endif @@ -90,7 +90,7 @@ NPC *Entity::CastToNPC() { #ifdef _EQDEBUG if (!IsNPC()) { - Log.Out(Logs::General, Logs::Error, "CastToNPC error (Not NPC)"); + Log(Logs::General, Logs::Error, "CastToNPC error (Not NPC)"); return 0; } #endif @@ -363,7 +363,7 @@ void EntityList::CheckGroupList (const char *fname, const int fline) { if (*it == nullptr) { - Log.Out(Logs::General, Logs::Error, "nullptr group, %s:%i", fname, fline); + Log(Logs::General, Logs::Error, "nullptr group, %s:%i", fname, fline); } } } @@ -521,17 +521,17 @@ void EntityList::MobProcess() #ifdef _WINDOWS struct in_addr in; in.s_addr = mob->CastToClient()->GetIP(); - Log.Out(Logs::General, Logs::Zone_Server, "Dropping client: Process=false, ip=%s port=%u", inet_ntoa(in), mob->CastToClient()->GetPort()); + Log(Logs::General, Logs::Zone_Server, "Dropping client: Process=false, ip=%s port=%u", inet_ntoa(in), mob->CastToClient()->GetPort()); #endif zone->StartShutdownTimer(); Group *g = GetGroupByMob(mob); if(g) { - Log.Out(Logs::General, Logs::Error, "About to delete a client still in a group."); + Log(Logs::General, Logs::Error, "About to delete a client still in a group."); g->DelMember(mob); } Raid *r = entity_list.GetRaidByClient(mob->CastToClient()); if(r) { - Log.Out(Logs::General, Logs::Error, "About to delete a client still in a raid."); + Log(Logs::General, Logs::Error, "About to delete a client still in a raid."); r->MemberZoned(mob->CastToClient()); } entity_list.RemoveClient(id); @@ -578,7 +578,7 @@ void EntityList::AddGroup(Group *group) uint32 gid = worldserver.NextGroupID(); if (gid == 0) { - Log.Out(Logs::General, Logs::Error, + Log(Logs::General, Logs::Error, "Unable to get new group ID from world server. group is going to be broken."); return; } @@ -607,7 +607,7 @@ void EntityList::AddRaid(Raid *raid) uint32 gid = worldserver.NextGroupID(); if (gid == 0) { - Log.Out(Logs::General, Logs::Error, + Log(Logs::General, Logs::Error, "Unable to get new group ID from world server. group is going to be broken."); return; } @@ -793,7 +793,7 @@ void EntityList::CheckSpawnQueue() auto it = npc_list.find(ns->spawn.spawnId); if (it == npc_list.end()) { // We must of despawned, hope that's the reason! - Log.Out(Logs::General, Logs::Error, "Error in EntityList::CheckSpawnQueue: Unable to find NPC for spawnId '%u'", ns->spawn.spawnId); + Log(Logs::General, Logs::Error, "Error in EntityList::CheckSpawnQueue: Unable to find NPC for spawnId '%u'", ns->spawn.spawnId); } else { NPC *pnpc = it->second; @@ -2288,10 +2288,15 @@ bool EntityList::RemoveNPC(uint16 delete_id) { auto it = npc_list.find(delete_id); if (it != npc_list.end()) { + NPC *npc = it->second; // make sure its proximity is removed RemoveProximity(delete_id); + // remove from client close lists + RemoveNPCFromClientCloseLists(npc); // remove from the list npc_list.erase(it); + + // remove from limit list if needed if (npc_limit_list.count(delete_id)) npc_limit_list.erase(delete_id); @@ -2300,6 +2305,16 @@ bool EntityList::RemoveNPC(uint16 delete_id) return false; } +bool EntityList::RemoveNPCFromClientCloseLists(NPC *npc) +{ + auto it = client_list.begin(); + while (it != client_list.end()) { + it->second->close_npcs.erase(npc); + ++it; + } + return false; +} + bool EntityList::RemoveMerc(uint16 delete_id) { auto it = merc_list.find(delete_id); @@ -2659,7 +2674,7 @@ char *EntityList::MakeNameUnique(char *name) return name; } } - Log.Out(Logs::General, Logs::Error, "Fatal error in EntityList::MakeNameUnique: Unable to find unique name for '%s'", name); + Log(Logs::General, Logs::Error, "Fatal error in EntityList::MakeNameUnique: Unable to find unique name for '%s'", name); char tmp[64] = "!"; strn0cpy(&tmp[1], name, sizeof(tmp) - 1); strcpy(name, tmp); @@ -3511,7 +3526,7 @@ void EntityList::ReloadAllClientsTaskState(int TaskID) // If we have been passed a TaskID, only reload the client state if they have // that Task active. if ((!TaskID) || (TaskID && client->IsTaskActive(TaskID))) { - Log.Out(Logs::General, Logs::Tasks, "[CLIENTLOAD] Reloading Task State For Client %s", client->GetName()); + Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] Reloading Task State For Client %s", client->GetName()); client->RemoveClientTaskState(); client->LoadClientTaskState(); taskmanager->SendActiveTasksToClient(client); diff --git a/zone/entity.h b/zone/entity.h index 0ee029940..193a17b8d 100644 --- a/zone/entity.h +++ b/zone/entity.h @@ -279,6 +279,7 @@ public: bool RemoveTrap(uint16 delete_id); bool RemoveObject(uint16 delete_id); bool RemoveProximity(uint16 delete_npc_id); + bool RemoveNPCFromClientCloseLists(NPC *npc); void RemoveAllMobs(); void RemoveAllClients(); void RemoveAllNPCs(); @@ -454,6 +455,14 @@ public: void GetSpawnList(std::list &d_list); void GetTargetsForConeArea(Mob *start, float min_radius, float radius, float height, int pcnpc, std::list &m_list); + inline const std::unordered_map &GetMobList() { return mob_list; } + inline const std::unordered_map &GetNPCList() { return npc_list; } + inline const std::unordered_map &GetMercList() { return merc_list; } + inline const std::unordered_map &GetClientList() { return client_list; } + inline const std::unordered_map &GetCorpseList() { return corpse_list; } + inline const std::unordered_map &GetObjectList() { return object_list; } + inline const std::unordered_map &GetDoorsList() { return door_list; } + void DepopAll(int NPCTypeID, bool StartSpawnTimer = true); uint16 GetFreeID(); diff --git a/zone/exp.cpp b/zone/exp.cpp index d6b0b903a..3dce744f5 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -331,7 +331,7 @@ void Client::AddEXP(uint32 in_add_exp, uint8 conlevel, bool resexp) { } void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { - Log.Out(Logs::Detail, Logs::None, "Attempting to Set Exp for %s (XP: %u, AAXP: %u, Rez: %s)", this->GetCleanName(), set_exp, set_aaxp, isrezzexp ? "true" : "false"); + Log(Logs::Detail, Logs::None, "Attempting to Set Exp for %s (XP: %u, AAXP: %u, Rez: %s)", this->GetCleanName(), set_exp, set_aaxp, isrezzexp ? "true" : "false"); //max_AAXP = GetEXPForLevel(52) - GetEXPForLevel(51); //GetEXPForLevel() doesn't depend on class/race, just level, so it shouldn't change between Clients max_AAXP = RuleI(AA, ExpPerPoint); //this may be redundant since we're doing this in Client::FinishConnState2() if (max_AAXP == 0 || GetEXPForLevel(GetLevel()) == 0xFFFFFFFF) { @@ -446,7 +446,7 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { //figure out how many AA points we get from the exp were setting m_pp.aapoints = set_aaxp / max_AAXP; - Log.Out(Logs::Detail, Logs::None, "Calculating additional AA Points from AAXP for %s: %u / %u = %.1f points", this->GetCleanName(), set_aaxp, max_AAXP, (float)set_aaxp / (float)max_AAXP); + Log(Logs::Detail, Logs::None, "Calculating additional AA Points from AAXP for %s: %u / %u = %.1f points", this->GetCleanName(), set_aaxp, max_AAXP, (float)set_aaxp / (float)max_AAXP); //get remainder exp points, set in PP below set_aaxp = set_aaxp - (max_AAXP * m_pp.aapoints); @@ -572,7 +572,7 @@ void Client::SetEXP(uint32 set_exp, uint32 set_aaxp, bool isrezzexp) { void Client::SetLevel(uint8 set_level, bool command) { if (GetEXPForLevel(set_level) == 0xFFFFFFFF) { - Log.Out(Logs::General, Logs::Error, "Client::SetLevel() GetEXPForLevel(%i) = 0xFFFFFFFF", set_level); + Log(Logs::General, Logs::Error, "Client::SetLevel() GetEXPForLevel(%i) = 0xFFFFFFFF", set_level); return; } @@ -630,7 +630,7 @@ void Client::SetLevel(uint8 set_level, bool command) safe_delete(outapp); this->SendAppearancePacket(AT_WhoLevel, set_level); // who level change - Log.Out(Logs::General, Logs::Normal, "Setting Level for %s to %i", GetName(), set_level); + Log(Logs::General, Logs::Normal, "Setting Level for %s to %i", GetName(), set_level); CalcBonuses(); diff --git a/zone/fearpath.cpp b/zone/fearpath.cpp index aa369b4c9..10af1e3a2 100644 --- a/zone/fearpath.cpp +++ b/zone/fearpath.cpp @@ -142,11 +142,11 @@ void Mob::CalculateNewFearpoint() m_FearWalkTarget = glm::vec3(Loc.x, Loc.y, Loc.z); currently_fleeing = true; - Log.Out(Logs::Detail, Logs::None, "Feared to node %i (%8.3f, %8.3f, %8.3f)", Node, Loc.x, Loc.y, Loc.z); + Log(Logs::Detail, Logs::None, "Feared to node %i (%8.3f, %8.3f, %8.3f)", Node, Loc.x, Loc.y, Loc.z); return; } - Log.Out(Logs::Detail, Logs::None, "No path found to selected node. Falling through to old fear point selection."); + Log(Logs::Detail, Logs::None, "No path found to selected node. Falling through to old fear point selection."); } int loop = 0; diff --git a/zone/forage.cpp b/zone/forage.cpp index cce6d9694..5d21d599f 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -69,7 +69,7 @@ uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) { item[index] = atoi(row[0]); chance[index] = atoi(row[1]) + chancepool; - Log.Out(Logs::General, Logs::Error, "Possible Forage: %d with a %d chance", item[index], chance[index]); + Log(Logs::General, Logs::Error, "Possible Forage: %d with a %d chance", item[index], chance[index]); chancepool = chance[index]; } @@ -405,7 +405,7 @@ void Client::ForageItem(bool guarantee) { const EQEmu::ItemData* food_item = database.GetItem(foragedfood); if(!food_item) { - Log.Out(Logs::General, Logs::Error, "nullptr returned from database.GetItem in ClientForageItem"); + Log(Logs::General, Logs::Error, "nullptr returned from database.GetItem in ClientForageItem"); return; } diff --git a/zone/groups.cpp b/zone/groups.cpp index 331303e8b..d2342b4d9 100644 --- a/zone/groups.cpp +++ b/zone/groups.cpp @@ -790,7 +790,7 @@ void Group::CastGroupSpell(Mob* caster, uint16 spell_id) { caster->SpellOnTarget(spell_id, members[z]->GetPet()); #endif } else - Log.Out(Logs::Detail, Logs::Spells, "Group spell: %s is out of range %f at distance %f from %s", members[z]->GetName(), range, distance, caster->GetName()); + Log(Logs::Detail, Logs::Spells, "Group spell: %s is out of range %f at distance %f from %s", members[z]->GetName(), range, distance, caster->GetName()); } } @@ -829,7 +829,7 @@ void Group::GroupBardPulse(Mob* caster, uint16 spell_id) { members[z]->GetPet()->BardPulse(spell_id, caster); #endif } else - Log.Out(Logs::Detail, Logs::Spells, "Group bard pulse: %s is out of range %f at distance %f from %s", members[z]->GetName(), range, distance, caster->GetName()); + Log(Logs::Detail, Logs::Spells, "Group bard pulse: %s is out of range %f at distance %f from %s", members[z]->GetName(), range, distance, caster->GetName()); } } } @@ -1133,7 +1133,7 @@ bool Group::LearnMembers() { return false; if (results.RowCount() == 0) { - Log.Out(Logs::General, Logs::Error, "Error getting group members for group %lu: %s", (unsigned long)GetID(), results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error getting group members for group %lu: %s", (unsigned long)GetID(), results.ErrorMessage().c_str()); return false; } @@ -1162,7 +1162,7 @@ void Group::VerifyGroup() { for (i = 0; i < MAX_GROUP_MEMBERS; i++) { if (membername[i][0] == '\0') { #if EQDEBUG >= 7 - Log.Out(Logs::General, Logs::None, "Group %lu: Verify %d: Empty.\n", (unsigned long)GetID(), i); + Log(Logs::General, Logs::None, "Group %lu: Verify %d: Empty.\n", (unsigned long)GetID(), i); #endif members[i] = nullptr; continue; @@ -1171,7 +1171,7 @@ void Group::VerifyGroup() { Mob *them = entity_list.GetMob(membername[i]); if(them == nullptr && members[i] != nullptr) { //they aren't in zone #if EQDEBUG >= 6 - Log.Out(Logs::General, Logs::None, "Member of group %lu named '%s' has disappeared!!", (unsigned long)GetID(), membername[i]); + Log(Logs::General, Logs::None, "Member of group %lu named '%s' has disappeared!!", (unsigned long)GetID(), membername[i]); #endif membername[i][0] = '\0'; members[i] = nullptr; @@ -1180,13 +1180,13 @@ void Group::VerifyGroup() { if(them != nullptr && members[i] != them) { //our pointer is out of date... not so good. #if EQDEBUG >= 5 - Log.Out(Logs::General, Logs::None, "Member of group %lu named '%s' had an out of date pointer!!", (unsigned long)GetID(), membername[i]); + Log(Logs::General, Logs::None, "Member of group %lu named '%s' had an out of date pointer!!", (unsigned long)GetID(), membername[i]); #endif members[i] = them; continue; } #if EQDEBUG >= 8 - Log.Out(Logs::General, Logs::None, "Member of group %lu named '%s' is valid.", (unsigned long)GetID(), membername[i]); + Log(Logs::General, Logs::None, "Member of group %lu named '%s' is valid.", (unsigned long)GetID(), membername[i]); #endif } } @@ -1521,7 +1521,7 @@ void Group::DelegateMainTank(const char *NewMainTankName, uint8 toggle) MainTankName.c_str(), GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to set group main tank: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to set group main tank: %s\n", results.ErrorMessage().c_str()); } } @@ -1567,7 +1567,7 @@ void Group::DelegateMainAssist(const char *NewMainAssistName, uint8 toggle) MainAssistName.c_str(), GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to set group main assist: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to set group main assist: %s\n", results.ErrorMessage().c_str()); } } @@ -1614,7 +1614,7 @@ void Group::DelegatePuller(const char *NewPullerName, uint8 toggle) PullerName.c_str(), GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to set group main puller: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to set group main puller: %s\n", results.ErrorMessage().c_str()); } @@ -1765,7 +1765,7 @@ void Group::UnDelegateMainTank(const char *OldMainTankName, uint8 toggle) std::string query = StringFormat("UPDATE group_leaders SET maintank = '' WHERE gid = %i LIMIT 1", GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to clear group main tank: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to clear group main tank: %s\n", results.ErrorMessage().c_str()); if(!toggle) { for(uint32 i = 0; i < MAX_GROUP_MEMBERS; ++i) { @@ -1814,7 +1814,7 @@ void Group::UnDelegateMainAssist(const char *OldMainAssistName, uint8 toggle) std::string query = StringFormat("UPDATE group_leaders SET assist = '' WHERE gid = %i LIMIT 1", GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to clear group main assist: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to clear group main assist: %s\n", results.ErrorMessage().c_str()); if(!toggle) { @@ -1842,7 +1842,7 @@ void Group::UnDelegatePuller(const char *OldPullerName, uint8 toggle) std::string query = StringFormat("UPDATE group_leaders SET puller = '' WHERE gid = %i LIMIT 1", GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to clear group main puller: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to clear group main puller: %s\n", results.ErrorMessage().c_str()); if(!toggle) { for(uint32 i = 0; i < MAX_GROUP_MEMBERS; ++i) { @@ -1925,7 +1925,7 @@ void Group::SetGroupMentor(int percent, char *name) mentoree_name.c_str(), mentor_percent, GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to set group mentor: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to set group mentor: %s\n", results.ErrorMessage().c_str()); } void Group::ClearGroupMentor() @@ -1936,7 +1936,7 @@ void Group::ClearGroupMentor() std::string query = StringFormat("UPDATE group_leaders SET mentoree = '', mentor_percent = 0 WHERE gid = %i LIMIT 1", GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to clear group mentor: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to clear group mentor: %s\n", results.ErrorMessage().c_str()); } void Group::NotifyAssistTarget(Client *c) @@ -2006,7 +2006,7 @@ void Group::DelegateMarkNPC(const char *NewNPCMarkerName) NewNPCMarkerName, GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to set group mark npc: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to set group mark npc: %s\n", results.ErrorMessage().c_str()); } void Group::NotifyMarkNPC(Client *c) @@ -2087,7 +2087,7 @@ void Group::UnDelegateMarkNPC(const char *OldNPCMarkerName) std::string query = StringFormat("UPDATE group_leaders SET marknpc = '' WHERE gid = %i LIMIT 1", GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to clear group marknpc: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to clear group marknpc: %s\n", results.ErrorMessage().c_str()); } @@ -2104,7 +2104,7 @@ void Group::SaveGroupLeaderAA() safe_delete_array(queryBuffer); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to store LeadershipAA: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to store LeadershipAA: %s\n", results.ErrorMessage().c_str()); } diff --git a/zone/guild.cpp b/zone/guild.cpp index 6cba3677a..bb39c7fc0 100644 --- a/zone/guild.cpp +++ b/zone/guild.cpp @@ -56,7 +56,7 @@ void Client::SendGuildMOTD(bool GetGuildMOTDReply) { } - Log.Out(Logs::Detail, Logs::Guilds, "Sending OP_GuildMOTD of length %d", outapp->size); + Log(Logs::Detail, Logs::Guilds, "Sending OP_GuildMOTD of length %d", outapp->size); FastQueuePacket(&outapp); } @@ -147,10 +147,10 @@ void Client::SendGuildSpawnAppearance() { if (!IsInAGuild()) { // clear guildtag SendAppearancePacket(AT_GuildID, GUILD_NONE); - Log.Out(Logs::Detail, Logs::Guilds, "Sending spawn appearance for no guild tag."); + Log(Logs::Detail, Logs::Guilds, "Sending spawn appearance for no guild tag."); } else { uint8 rank = guild_mgr.GetDisplayedRank(GuildID(), GuildRank(), CharacterID()); - Log.Out(Logs::Detail, Logs::Guilds, "Sending spawn appearance for guild %d at rank %d", GuildID(), rank); + Log(Logs::Detail, Logs::Guilds, "Sending spawn appearance for guild %d at rank %d", GuildID(), rank); SendAppearancePacket(AT_GuildID, GuildID()); if (ClientVersion() >= EQEmu::versions::ClientVersion::RoF) { @@ -174,11 +174,11 @@ void Client::SendGuildList() { //ask the guild manager to build us a nice guild list packet outapp->pBuffer = guild_mgr.MakeGuildList(/*GetName()*/"", outapp->size); if(outapp->pBuffer == nullptr) { - Log.Out(Logs::Detail, Logs::Guilds, "Unable to make guild list!"); + Log(Logs::Detail, Logs::Guilds, "Unable to make guild list!"); return; } - Log.Out(Logs::Detail, Logs::Guilds, "Sending OP_ZoneGuildList of length %d", outapp->size); + Log(Logs::Detail, Logs::Guilds, "Sending OP_ZoneGuildList of length %d", outapp->size); FastQueuePacket(&outapp); } @@ -195,7 +195,7 @@ void Client::SendGuildMembers() { outapp->pBuffer = data; data = nullptr; - Log.Out(Logs::Detail, Logs::Guilds, "Sending OP_GuildMemberList of length %d", outapp->size); + Log(Logs::Detail, Logs::Guilds, "Sending OP_GuildMemberList of length %d", outapp->size); FastQueuePacket(&outapp); @@ -227,7 +227,7 @@ void Client::RefreshGuildInfo() CharGuildInfo info; if(!guild_mgr.GetCharInfo(CharacterID(), info)) { - Log.Out(Logs::Detail, Logs::Guilds, "Unable to obtain guild char info for %s (%d)", GetName(), CharacterID()); + Log(Logs::Detail, Logs::Guilds, "Unable to obtain guild char info for %s (%d)", GetName(), CharacterID()); return; } @@ -341,7 +341,7 @@ void Client::SendGuildJoin(GuildJoin_Struct* gj){ outgj->rank = gj->rank; outgj->zoneid = gj->zoneid; - Log.Out(Logs::Detail, Logs::Guilds, "Sending OP_GuildManageAdd for join of length %d", outapp->size); + Log(Logs::Detail, Logs::Guilds, "Sending OP_GuildManageAdd for join of length %d", outapp->size); FastQueuePacket(&outapp); diff --git a/zone/guild_mgr.cpp b/zone/guild_mgr.cpp index 3dfa6b958..73a60cd66 100644 --- a/zone/guild_mgr.cpp +++ b/zone/guild_mgr.cpp @@ -32,7 +32,7 @@ extern WorldServer worldserver; extern volatile bool is_zone_loaded; void ZoneGuildManager::SendGuildRefresh(uint32 guild_id, bool name, bool motd, bool rank, bool relation) { - Log.Out(Logs::Detail, Logs::Guilds, "Sending guild refresh for %d to world, changes: name=%d, motd=%d, rank=d, relation=%d", guild_id, name, motd, rank, relation); + Log(Logs::Detail, Logs::Guilds, "Sending guild refresh for %d to world, changes: name=%d, motd=%d, rank=d, relation=%d", guild_id, name, motd, rank, relation); auto pack = new ServerPacket(ServerOP_RefreshGuild, sizeof(ServerGuildRefresh_Struct)); ServerGuildRefresh_Struct *s = (ServerGuildRefresh_Struct *) pack->pBuffer; s->guild_id = guild_id; @@ -46,7 +46,7 @@ void ZoneGuildManager::SendGuildRefresh(uint32 guild_id, bool name, bool motd, b void ZoneGuildManager::SendCharRefresh(uint32 old_guild_id, uint32 guild_id, uint32 charid) { if(guild_id == 0) { - Log.Out(Logs::Detail, Logs::Guilds, "Guild lookup for char %d when sending char refresh.", charid); + Log(Logs::Detail, Logs::Guilds, "Guild lookup for char %d when sending char refresh.", charid); CharGuildInfo gci; if(!GetCharInfo(charid, gci)) { @@ -56,7 +56,7 @@ void ZoneGuildManager::SendCharRefresh(uint32 old_guild_id, uint32 guild_id, uin } } - Log.Out(Logs::Detail, Logs::Guilds, "Sending char refresh for %d from guild %d to world", charid, guild_id); + Log(Logs::Detail, Logs::Guilds, "Sending char refresh for %d from guild %d to world", charid, guild_id); auto pack = new ServerPacket(ServerOP_GuildCharRefresh, sizeof(ServerGuildCharRefresh_Struct)); ServerGuildCharRefresh_Struct *s = (ServerGuildCharRefresh_Struct *) pack->pBuffer; @@ -89,7 +89,7 @@ void ZoneGuildManager::SendRankUpdate(uint32 CharID) } void ZoneGuildManager::SendGuildDelete(uint32 guild_id) { - Log.Out(Logs::Detail, Logs::Guilds, "Sending guild delete for guild %d to world", guild_id); + Log(Logs::Detail, Logs::Guilds, "Sending guild delete for guild %d to world", guild_id); auto pack = new ServerPacket(ServerOP_DeleteGuild, sizeof(ServerGuildID_Struct)); ServerGuildID_Struct *s = (ServerGuildID_Struct *) pack->pBuffer; s->guild_id = guild_id; @@ -261,12 +261,12 @@ void ZoneGuildManager::ProcessWorldPacket(ServerPacket *pack) { switch(pack->opcode) { case ServerOP_RefreshGuild: { if(pack->size != sizeof(ServerGuildRefresh_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildRefresh_Struct)); + Log(Logs::General, Logs::Error, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildRefresh_Struct)); return; } ServerGuildRefresh_Struct *s = (ServerGuildRefresh_Struct *) pack->pBuffer; - Log.Out(Logs::Detail, Logs::Guilds, "Received guild refresh from world for %d, changes: name=%d, motd=%d, rank=%d, relation=%d", s->guild_id, s->name_change, s->motd_change, s->rank_change, s->relation_change); + Log(Logs::Detail, Logs::Guilds, "Received guild refresh from world for %d, changes: name=%d, motd=%d, rank=%d, relation=%d", s->guild_id, s->name_change, s->motd_change, s->rank_change, s->relation_change); //reload all the guild details from the database. RefreshGuild(s->guild_id); @@ -295,12 +295,12 @@ void ZoneGuildManager::ProcessWorldPacket(ServerPacket *pack) { case ServerOP_GuildCharRefresh: { if(pack->size != sizeof(ServerGuildCharRefresh_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildCharRefresh_Struct)); + Log(Logs::General, Logs::Error, "Received ServerOP_RefreshGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildCharRefresh_Struct)); return; } ServerGuildCharRefresh_Struct *s = (ServerGuildCharRefresh_Struct *) pack->pBuffer; - Log.Out(Logs::Detail, Logs::Guilds, "Received guild member refresh from world for char %d from guild %d", s->char_id, s->guild_id); + Log(Logs::Detail, Logs::Guilds, "Received guild member refresh from world for char %d from guild %d", s->char_id, s->guild_id); Client *c = entity_list.GetClientByCharID(s->char_id); @@ -338,7 +338,7 @@ void ZoneGuildManager::ProcessWorldPacket(ServerPacket *pack) { { if(pack->size != sizeof(ServerGuildRankUpdate_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received ServerOP_RankUpdate of incorrect size %d, expected %d", + Log(Logs::General, Logs::Error, "Received ServerOP_RankUpdate of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildRankUpdate_Struct)); return; @@ -364,12 +364,12 @@ void ZoneGuildManager::ProcessWorldPacket(ServerPacket *pack) { case ServerOP_DeleteGuild: { if(pack->size != sizeof(ServerGuildID_Struct)) { - Log.Out(Logs::General, Logs::Error, "Received ServerOP_DeleteGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildID_Struct)); + Log(Logs::General, Logs::Error, "Received ServerOP_DeleteGuild of incorrect size %d, expected %d", pack->size, sizeof(ServerGuildID_Struct)); return; } ServerGuildID_Struct *s = (ServerGuildID_Struct *) pack->pBuffer; - Log.Out(Logs::Detail, Logs::Guilds, "Received guild delete from world for guild %d", s->guild_id); + Log(Logs::Detail, Logs::Guilds, "Received guild delete from world for guild %d", s->guild_id); //clear all the guild tags. entity_list.RefreshAllGuildInfo(s->guild_id); @@ -417,10 +417,10 @@ void ZoneGuildManager::ProcessWorldPacket(ServerPacket *pack) { if (!c || !c->IsInAGuild()) { - Log.Out(Logs::Detail, Logs::Guilds,"Invalid Client or not in guild. ID=%i", FromID); + Log(Logs::Detail, Logs::Guilds,"Invalid Client or not in guild. ID=%i", FromID); break; } - Log.Out(Logs::Detail, Logs::Guilds,"Processing ServerOP_OnlineGuildMembersResponse"); + Log(Logs::Detail, Logs::Guilds,"Processing ServerOP_OnlineGuildMembersResponse"); auto outapp = new EQApplicationPacket(OP_GuildMemberUpdate, sizeof(GuildMemberUpdate_Struct)); GuildMemberUpdate_Struct *gmus = (GuildMemberUpdate_Struct*)outapp->pBuffer; char Name[64]; @@ -433,7 +433,7 @@ void ZoneGuildManager::ProcessWorldPacket(ServerPacket *pack) { VARSTRUCT_DECODE_STRING(Name, Buffer); strn0cpy(gmus->MemberName, Name, sizeof(gmus->MemberName)); gmus->ZoneID = VARSTRUCT_DECODE_TYPE(uint32, Buffer); - Log.Out(Logs::Detail, Logs::Guilds,"Sending OP_GuildMemberUpdate to %i. Name=%s ZoneID=%i",FromID,Name,gmus->ZoneID); + Log(Logs::Detail, Logs::Guilds,"Sending OP_GuildMemberUpdate to %i. Name=%s ZoneID=%i",FromID,Name,gmus->ZoneID); c->QueuePacket(outapp); } safe_delete(outapp); @@ -683,7 +683,7 @@ void GuildBankManager::SendGuildBank(Client *c) if(Iterator == Banks.end()) { - Log.Out(Logs::General, Logs::Error, "Unable to find guild bank for guild ID %i", c->GuildID()); + Log(Logs::General, Logs::Error, "Unable to find guild bank for guild ID %i", c->GuildID()); return; } @@ -856,7 +856,7 @@ bool GuildBankManager::AddItem(uint32 GuildID, uint8 Area, uint32 ItemID, int32 if(Iterator == Banks.end()) { - Log.Out(Logs::General, Logs::Error, "Unable to find guild bank for guild ID %i", GuildID); + Log(Logs::General, Logs::Error, "Unable to find guild bank for guild ID %i", GuildID); return false; } @@ -902,7 +902,7 @@ bool GuildBankManager::AddItem(uint32 GuildID, uint8 Area, uint32 ItemID, int32 if(Slot < 0) { - Log.Out(Logs::General, Logs::Error, "No space to add item to the guild bank."); + Log(Logs::General, Logs::Error, "No space to add item to the guild bank."); return false; } diff --git a/zone/hate_list.cpp b/zone/hate_list.cpp index 225ff39ff..10b46a356 100644 --- a/zone/hate_list.cpp +++ b/zone/hate_list.cpp @@ -364,12 +364,20 @@ Mob *HateList::GetEntWithMostHateOnList(Mob *center, Mob *skip) int64 current_hate = cur->stored_hate_amount; +#ifdef BOTS + if (cur->entity_on_hatelist->IsClient() || cur->entity_on_hatelist->IsBot()){ + + if (cur->entity_on_hatelist->IsClient() && cur->entity_on_hatelist->CastToClient()->IsSitting()){ + aggro_mod += RuleI(Aggro, SittingAggroMod); + } +#else if (cur->entity_on_hatelist->IsClient()){ if (cur->entity_on_hatelist->CastToClient()->IsSitting()){ aggro_mod += RuleI(Aggro, SittingAggroMod); } - +#endif + if (center){ if (center->GetTarget() == cur->entity_on_hatelist) aggro_mod += RuleI(Aggro, CurrentTargetAggroMod); diff --git a/zone/heal_rotation.cpp b/zone/heal_rotation.cpp index 96703818f..c9bf54189 100644 --- a/zone/heal_rotation.cpp +++ b/zone/heal_rotation.cpp @@ -860,42 +860,42 @@ void HealRotation::bias_targets() m_casting_target_poke = true; #if (EQDEBUG >= 12) - Log.Out(Logs::General, Logs::Error, "HealRotation::bias_targets() - *** Post-processing state ***"); - Log.Out(Logs::General, Logs::Error, "HealRotation Settings:"); - Log.Out(Logs::General, Logs::Error, "HealRotation::m_interval_ms = %u", m_interval_ms); - Log.Out(Logs::General, Logs::Error, "HealRotation::m_next_cast_time_ms = %u (current_time: %u, time_diff: %i)", m_next_cast_time_ms, Timer::GetCurrentTime(), ((int32)Timer::GetCurrentTime() - (int32)m_next_cast_time_ms)); - Log.Out(Logs::General, Logs::Error, "HealRotation::m_next_poke_time_ms = %u (current_time: %u, time_diff: %i)", m_next_poke_time_ms, Timer::GetCurrentTime(), ((int32)Timer::GetCurrentTime() - (int32)m_next_poke_time_ms)); - Log.Out(Logs::General, Logs::Error, "HealRotation::m_fast_heals = %s", ((m_fast_heals) ? ("true") : ("false"))); - Log.Out(Logs::General, Logs::Error, "HealRotation::m_adaptive_targeting = %s", ((m_adaptive_targeting) ? ("true") : ("false"))); - Log.Out(Logs::General, Logs::Error, "HealRotation::m_casting_override = %s", ((m_casting_override) ? ("true") : ("false"))); - Log.Out(Logs::General, Logs::Error, "HealRotation::m_casting_target_poke = %s", ((m_casting_target_poke) ? ("true") : ("false"))); - Log.Out(Logs::General, Logs::Error, "HealRotation::m_active_heal_target = %s", ((m_active_heal_target) ? ("true") : ("false"))); - Log.Out(Logs::General, Logs::Error, "HealRotation::m_is_active = %s", ((m_is_active) ? ("true") : ("false"))); - Log.Out(Logs::General, Logs::Error, "HealRotation::m_member_list.size() = %i", m_member_pool.size()); - Log.Out(Logs::General, Logs::Error, "HealRotation::m_cycle_list.size() = %i", m_cycle_pool.size()); - Log.Out(Logs::General, Logs::Error, "HealRotation::m_target_list.size() = %i", m_target_pool.size()); - if (m_member_pool.size()) { Log.Out(Logs::General, Logs::Error, "(std::shared_ptr::use_count() = %i", m_member_pool.front()->MemberOfHealRotation()->use_count()); } - else { Log.Out(Logs::General, Logs::Error, "(std::shared_ptr::use_count() = unknown (0)"); } - Log.Out(Logs::General, Logs::Error, "HealRotation Members:"); + Log(Logs::General, Logs::Error, "HealRotation::bias_targets() - *** Post-processing state ***"); + Log(Logs::General, Logs::Error, "HealRotation Settings:"); + Log(Logs::General, Logs::Error, "HealRotation::m_interval_ms = %u", m_interval_ms); + Log(Logs::General, Logs::Error, "HealRotation::m_next_cast_time_ms = %u (current_time: %u, time_diff: %i)", m_next_cast_time_ms, Timer::GetCurrentTime(), ((int32)Timer::GetCurrentTime() - (int32)m_next_cast_time_ms)); + Log(Logs::General, Logs::Error, "HealRotation::m_next_poke_time_ms = %u (current_time: %u, time_diff: %i)", m_next_poke_time_ms, Timer::GetCurrentTime(), ((int32)Timer::GetCurrentTime() - (int32)m_next_poke_time_ms)); + Log(Logs::General, Logs::Error, "HealRotation::m_fast_heals = %s", ((m_fast_heals) ? ("true") : ("false"))); + Log(Logs::General, Logs::Error, "HealRotation::m_adaptive_targeting = %s", ((m_adaptive_targeting) ? ("true") : ("false"))); + Log(Logs::General, Logs::Error, "HealRotation::m_casting_override = %s", ((m_casting_override) ? ("true") : ("false"))); + Log(Logs::General, Logs::Error, "HealRotation::m_casting_target_poke = %s", ((m_casting_target_poke) ? ("true") : ("false"))); + Log(Logs::General, Logs::Error, "HealRotation::m_active_heal_target = %s", ((m_active_heal_target) ? ("true") : ("false"))); + Log(Logs::General, Logs::Error, "HealRotation::m_is_active = %s", ((m_is_active) ? ("true") : ("false"))); + Log(Logs::General, Logs::Error, "HealRotation::m_member_list.size() = %i", m_member_pool.size()); + Log(Logs::General, Logs::Error, "HealRotation::m_cycle_list.size() = %i", m_cycle_pool.size()); + Log(Logs::General, Logs::Error, "HealRotation::m_target_list.size() = %i", m_target_pool.size()); + if (m_member_pool.size()) { Log(Logs::General, Logs::Error, "(std::shared_ptr::use_count() = %i", m_member_pool.front()->MemberOfHealRotation()->use_count()); } + else { Log(Logs::General, Logs::Error, "(std::shared_ptr::use_count() = unknown (0)"); } + Log(Logs::General, Logs::Error, "HealRotation Members:"); int member_index = 0; for (auto mlist_iter : m_member_pool) { if (!mlist_iter) { continue; } - Log.Out(Logs::General, Logs::Error, "(%i) %s (hrcast: %c)", (++member_index), mlist_iter->GetCleanName(), ((mlist_iter->AmICastingForHealRotation())?('T'):('F'))); + Log(Logs::General, Logs::Error, "(%i) %s (hrcast: %c)", (++member_index), mlist_iter->GetCleanName(), ((mlist_iter->AmICastingForHealRotation())?('T'):('F'))); } - if (!member_index) { Log.Out(Logs::General, Logs::Error, "(0) None"); } - Log.Out(Logs::General, Logs::Error, "HealRotation Cycle:"); + if (!member_index) { Log(Logs::General, Logs::Error, "(0) None"); } + Log(Logs::General, Logs::Error, "HealRotation Cycle:"); int cycle_index = 0; for (auto clist_iter : m_cycle_pool) { if (!clist_iter) { continue; } - Log.Out(Logs::General, Logs::Error, "(%i) %s", (++cycle_index), clist_iter->GetCleanName()); + Log(Logs::General, Logs::Error, "(%i) %s", (++cycle_index), clist_iter->GetCleanName()); } - if (!cycle_index) { Log.Out(Logs::General, Logs::Error, "(0) None"); } - Log.Out(Logs::General, Logs::Error, "HealRotation Targets: (sort type: %u)", sort_type); + if (!cycle_index) { Log(Logs::General, Logs::Error, "(0) None"); } + Log(Logs::General, Logs::Error, "HealRotation Targets: (sort type: %u)", sort_type); int target_index = 0; for (auto tlist_iter : m_target_pool) { if (!tlist_iter) { continue; } - Log.Out(Logs::General, Logs::Error, "(%i) %s (hp: %3.1f%%, at: %u, dontheal: %c, crit(base): %c(%c), safe(base): %c(%c), hcnt(ext): %u(%u), hfreq(ext): %f(%f))", + Log(Logs::General, Logs::Error, "(%i) %s (hp: %3.1f%%, at: %u, dontheal: %c, crit(base): %c(%c), safe(base): %c(%c), hcnt(ext): %u(%u), hfreq(ext): %f(%f))", (++target_index), tlist_iter->GetCleanName(), tlist_iter->GetHPRatio(), ClassArmorType(tlist_iter->GetClass()), @@ -909,7 +909,7 @@ void HealRotation::bias_targets() tlist_iter->HealRotationHealFrequency(), tlist_iter->HealRotationExtendedHealFrequency()); } - if (!target_index) { Log.Out(Logs::General, Logs::Error, "(0) None (hp: 0.0\%, at: 0, dontheal: F, crit(base): F(F), safe(base): F(F), hcnt(ext): 0(0), hfreq(ext): 0.0(0.0))"); } + if (!target_index) { Log(Logs::General, Logs::Error, "(0) None (hp: 0.0\%, at: 0, dontheal: F, crit(base): F(F), safe(base): F(F), hcnt(ext): 0(0), hfreq(ext): 0.0(0.0))"); } #endif } diff --git a/zone/horse.cpp b/zone/horse.cpp index 62254a6b0..efe4fe898 100644 --- a/zone/horse.cpp +++ b/zone/horse.cpp @@ -79,7 +79,7 @@ const NPCType *Horse::BuildHorseType(uint16 spell_id) { } if (results.RowCount() != 1) { - Log.Out(Logs::General, Logs::Error, "No Database entry for mount: %s, check the horses table", fileName); + Log(Logs::General, Logs::Error, "No Database entry for mount: %s, check the horses table", fileName); return nullptr; } @@ -122,7 +122,7 @@ void Client::SummonHorse(uint16 spell_id) { return; } if(!Horse::IsHorseSpell(spell_id)) { - Log.Out(Logs::General, Logs::Error, "%s tried to summon an unknown horse, spell id %d", GetName(), spell_id); + Log(Logs::General, Logs::Error, "%s tried to summon an unknown horse, spell id %d", GetName(), spell_id); return; } diff --git a/zone/inventory.cpp b/zone/inventory.cpp index abc71723b..f9cd43206 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -200,7 +200,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, // make sure the item exists if(item == nullptr) { Message(13, "Item %u does not exist.", item_id); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create an item with an invalid id.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create an item with an invalid id.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", GetName(), account_name, item_id, aug1, aug2, aug3, aug4, aug5, aug6); return false; @@ -215,7 +215,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, // check to make sure we are augmenting an augmentable item else if (((!item->IsClassCommon()) || (item->AugType > 0)) && (aug1 | aug2 | aug3 | aug4 | aug5 | aug6)) { Message(13, "You can not augment an augment or a non-common class item."); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to augment an augment or a non-common class item.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug5: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to augment an augment or a non-common class item.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug5: %u)\n", GetName(), account_name, item->ID, aug1, aug2, aug3, aug4, aug5, aug6); return false; @@ -229,7 +229,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, /* else if(item->MinStatus && ((this->Admin() < item->MinStatus) || (this->Admin() < RuleI(GM, MinStatusToSummonItem)))) { Message(13, "You are not a GM or do not have the status to summon this item."); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create a GM-only item with a status of %i.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u, MinStatus: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create a GM-only item with a status of %i.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u, MinStatus: %u)\n", GetName(), account_name, this->Admin(), item->ID, aug1, aug2, aug3, aug4, aug5, aug6, item->MinStatus); return false; @@ -252,7 +252,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, if(augtest == nullptr) { if(augments[iter]) { Message(13, "Augment %u (Aug%i) does not exist.", augments[iter], iter + 1); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create an augment (Aug%i) with an invalid id.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create an augment (Aug%i) with an invalid id.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", GetName(), account_name, (iter + 1), item->ID, aug1, aug2, aug3, aug4, aug5, aug6); return false; @@ -269,7 +269,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, // check that augment is an actual augment else if(augtest->AugType == 0) { Message(13, "%s (%u) (Aug%i) is not an actual augment.", augtest->Name, augtest->ID, iter + 1); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to use a non-augment item (Aug%i) as an augment.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to use a non-augment item (Aug%i) as an augment.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", GetName(), account_name, item->ID, (iter + 1), aug1, aug2, aug3, aug4, aug5, aug6); return false; @@ -281,7 +281,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, /* else if(augtest->MinStatus && ((this->Admin() < augtest->MinStatus) || (this->Admin() < RuleI(GM, MinStatusToSummonItem)))) { Message(13, "You are not a GM or do not have the status to summon this augment."); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create a GM-only augment (Aug%i) with a status of %i.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, MinStatus: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create a GM-only augment (Aug%i) with a status of %i.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, MinStatus: %u)\n", GetName(), account_name, (iter + 1), this->Admin(), item->ID, aug1, aug2, aug3, aug4, aug5, aug6, item->MinStatus); return false; @@ -292,7 +292,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, if(enforcewear) { if ((item->AugSlotType[iter] == EQEmu::item::AugTypeNone) || !(((uint32)1 << (item->AugSlotType[iter] - 1)) & augtest->AugType)) { Message(13, "Augment %u (Aug%i) is not acceptable wear on Item %u.", augments[iter], iter + 1, item->ID); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to augment an item with an unacceptable augment type (Aug%i).\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to augment an item with an unacceptable augment type (Aug%i).\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", GetName(), account_name, (iter + 1), item->ID, aug1, aug2, aug3, aug4, aug5, aug6); return false; @@ -300,7 +300,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, if(item->AugSlotVisible[iter] == 0) { Message(13, "Item %u has not evolved enough to accept Augment %u (Aug%i).", item->ID, augments[iter], iter + 1); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to augment an unevolved item with augment type (Aug%i).\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to augment an unevolved item with augment type (Aug%i).\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", GetName(), account_name, (iter + 1), item->ID, aug1, aug2, aug3, aug4, aug5, aug6); return false; @@ -477,7 +477,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, if(restrictfail) { Message(13, "Augment %u (Aug%i) is restricted from wear on Item %u.", augments[iter], (iter + 1), item->ID); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to augment an item with a restricted augment (Aug%i).\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to augment an item with a restricted augment (Aug%i).\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", GetName(), account_name, (iter + 1), item->ID, aug1, aug2, aug3, aug4, aug5, aug6); return false; @@ -488,7 +488,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, // check for class usability if(item->Classes && !(classes &= augtest->Classes)) { Message(13, "Augment %u (Aug%i) will result in an item not usable by any class.", augments[iter], (iter + 1)); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create an item unusable by any class.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create an item unusable by any class.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", GetName(), account_name, item->ID, aug1, aug2, aug3, aug4, aug5, aug6); return false; @@ -497,7 +497,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, // check for race usability if(item->Races && !(races &= augtest->Races)) { Message(13, "Augment %u (Aug%i) will result in an item not usable by any race.", augments[iter], (iter + 1)); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create an item unusable by any race.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create an item unusable by any race.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", GetName(), account_name, item->ID, aug1, aug2, aug3, aug4, aug5, aug6); return false; @@ -506,7 +506,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, // check for slot usability if(item->Slots && !(slots &= augtest->Slots)) { Message(13, "Augment %u (Aug%i) will result in an item not usable in any slot.", augments[iter], (iter + 1)); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create an item unusable in any slot.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to create an item unusable in any slot.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", GetName(), account_name, item->ID, aug1, aug2, aug3, aug4, aug5, aug6); return false; @@ -533,7 +533,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, if(inst == nullptr) { Message(13, "An unknown server error has occurred and your item was not created."); // this goes to logfile since this is a major error - Log.Out(Logs::General, Logs::Error, "Player %s on account %s encountered an unknown item creation error.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", + Log(Logs::General, Logs::Error, "Player %s on account %s encountered an unknown item creation error.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", GetName(), account_name, item->ID, aug1, aug2, aug3, aug4, aug5, aug6); return false; @@ -559,7 +559,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, if(!(slots & ((uint32)1 << slottest))) { Message(0, "This item is not equipable at slot %u - moving to cursor.", to_slot); - Log.Out(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to equip an item unusable in slot %u - moved to cursor.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", + Log(Logs::Detail, Logs::Inventory, "Player %s on account %s attempted to equip an item unusable in slot %u - moved to cursor.\n(Item: %u, Aug1: %u, Aug2: %u, Aug3: %u, Aug4: %u, Aug5: %u, Aug6: %u)\n", GetName(), account_name, to_slot, item->ID, aug1, aug2, aug3, aug4, aug5, aug6); to_slot = EQEmu::inventory::slotCursor; @@ -596,7 +596,7 @@ bool Client::SummonItem(uint32 item_id, int16 charges, uint32 aug1, uint32 aug2, // Drop item from inventory to ground (generally only dropped from SLOT_CURSOR) void Client::DropItem(int16 slot_id, bool recurse) { - Log.Out(Logs::General, Logs::Inventory, "'%s' (char_id: %u) Attempting to drop item from slot %i on the ground", + Log(Logs::General, Logs::Inventory, "'%s' (char_id: %u) Attempting to drop item from slot %i on the ground", GetCleanName(), CharacterID(), slot_id); if(GetInv().CheckNoDrop(slot_id, recurse) && RuleI(World, FVNoDropFlag) == 0 || @@ -604,20 +604,20 @@ void Client::DropItem(int16 slot_id, bool recurse) { auto invalid_drop = m_inv.GetItem(slot_id); if (!invalid_drop) { - Log.Out(Logs::General, Logs::Inventory, "Error in InventoryProfile::CheckNoDrop() - returned 'true' for empty slot"); + Log(Logs::General, Logs::Inventory, "Error in InventoryProfile::CheckNoDrop() - returned 'true' for empty slot"); } else { - if (Log.log_settings[Logs::Inventory].is_category_enabled) { - Log.Out(Logs::General, Logs::Inventory, "DropItem() Hack detected - full item parse:"); - Log.Out(Logs::General, Logs::Inventory, "depth: 0, Item: '%s' (id: %u), IsDroppable: %s", + if (LogSys.log_settings[Logs::Inventory].is_category_enabled) { + Log(Logs::General, Logs::Inventory, "DropItem() Hack detected - full item parse:"); + Log(Logs::General, Logs::Inventory, "depth: 0, Item: '%s' (id: %u), IsDroppable: %s", (invalid_drop->GetItem() ? invalid_drop->GetItem()->Name : "null data"), invalid_drop->GetID(), invalid_drop->IsDroppable(false)); for (auto iter1 : *invalid_drop->GetContents()) { // depth 1 - Log.Out(Logs::General, Logs::Inventory, "-depth: 1, Item: '%s' (id: %u), IsDroppable: %s", + Log(Logs::General, Logs::Inventory, "-depth: 1, Item: '%s' (id: %u), IsDroppable: %s", (iter1.second->GetItem() ? iter1.second->GetItem()->Name : "null data"), iter1.second->GetID(), iter1.second->IsDroppable(false)); for (auto iter2 : *iter1.second->GetContents()) { // depth 2 - Log.Out(Logs::General, Logs::Inventory, "--depth: 2, Item: '%s' (id: %u), IsDroppable: %s", + Log(Logs::General, Logs::Inventory, "--depth: 2, Item: '%s' (id: %u), IsDroppable: %s", (iter2.second->GetItem() ? iter2.second->GetItem()->Name : "null data"), iter2.second->GetID(), iter2.second->IsDroppable(false)); } } @@ -633,39 +633,39 @@ void Client::DropItem(int16 slot_id, bool recurse) // Take control of item in client inventory EQEmu::ItemInstance *inst = m_inv.PopItem(slot_id); if(inst) { - if (Log.log_settings[Logs::Inventory].is_category_enabled) { - Log.Out(Logs::General, Logs::Inventory, "DropItem() Processing - full item parse:"); - Log.Out(Logs::General, Logs::Inventory, "depth: 0, Item: '%s' (id: %u), IsDroppable: %s", + if (LogSys.log_settings[Logs::Inventory].is_category_enabled) { + Log(Logs::General, Logs::Inventory, "DropItem() Processing - full item parse:"); + Log(Logs::General, Logs::Inventory, "depth: 0, Item: '%s' (id: %u), IsDroppable: %s", (inst->GetItem() ? inst->GetItem()->Name : "null data"), inst->GetID(), inst->IsDroppable(false)); if (!inst->IsDroppable(false)) - Log.Out(Logs::General, Logs::Error, "Non-droppable item being processed for drop by '%s'", GetCleanName()); + Log(Logs::General, Logs::Error, "Non-droppable item being processed for drop by '%s'", GetCleanName()); for (auto iter1 : *inst->GetContents()) { // depth 1 - Log.Out(Logs::General, Logs::Inventory, "-depth: 1, Item: '%s' (id: %u), IsDroppable: %s", + Log(Logs::General, Logs::Inventory, "-depth: 1, Item: '%s' (id: %u), IsDroppable: %s", (iter1.second->GetItem() ? iter1.second->GetItem()->Name : "null data"), iter1.second->GetID(), iter1.second->IsDroppable(false)); if (!iter1.second->IsDroppable(false)) - Log.Out(Logs::General, Logs::Error, "Non-droppable item being processed for drop by '%s'", GetCleanName()); + Log(Logs::General, Logs::Error, "Non-droppable item being processed for drop by '%s'", GetCleanName()); for (auto iter2 : *iter1.second->GetContents()) { // depth 2 - Log.Out(Logs::General, Logs::Inventory, "--depth: 2, Item: '%s' (id: %u), IsDroppable: %s", + Log(Logs::General, Logs::Inventory, "--depth: 2, Item: '%s' (id: %u), IsDroppable: %s", (iter2.second->GetItem() ? iter2.second->GetItem()->Name : "null data"), iter2.second->GetID(), iter2.second->IsDroppable(false)); if (!iter2.second->IsDroppable(false)) - Log.Out(Logs::General, Logs::Error, "Non-droppable item being processed for drop by '%s'", GetCleanName()); + Log(Logs::General, Logs::Error, "Non-droppable item being processed for drop by '%s'", GetCleanName()); } } } int i = parse->EventItem(EVENT_DROP_ITEM, this, inst, nullptr, "", slot_id); if(i != 0) { - Log.Out(Logs::General, Logs::Inventory, "Item drop handled by [EVENT_DROP_ITEM]"); + Log(Logs::General, Logs::Inventory, "Item drop handled by [EVENT_DROP_ITEM]"); safe_delete(inst); } } else { // Item doesn't exist in inventory! - Log.Out(Logs::General, Logs::Inventory, "DropItem() - No item found in slot %i", slot_id); + Log(Logs::General, Logs::Inventory, "DropItem() - No item found in slot %i", slot_id); Message(13, "Error: Item not found in slot %i", slot_id); return; } @@ -687,7 +687,7 @@ void Client::DropItem(int16 slot_id, bool recurse) entity_list.AddObject(object, true); object->StartDecay(); - Log.Out(Logs::General, Logs::Inventory, "Item drop handled ut assolet"); + Log(Logs::General, Logs::Inventory, "Item drop handled ut assolet"); safe_delete(inst); } @@ -758,7 +758,7 @@ void Client::SendCursorBuffer() } if (!lore_pass) { - Log.Out(Logs::General, Logs::Inventory, "(%s) Duplicate lore items are not allowed - destroying item %s(id:%u) on cursor", + Log(Logs::General, Logs::Inventory, "(%s) Duplicate lore items are not allowed - destroying item %s(id:%u) on cursor", GetName(), test_item->Name, test_item->ID); Message_StringID(MT_LootMessages, 290); parse->EventItem(EVENT_DESTROY_ITEM, this, test_inst, nullptr, "", 0); @@ -773,7 +773,7 @@ void Client::SendCursorBuffer() // Remove item from inventory void Client::DeleteItemInInventory(int16 slot_id, int8 quantity, bool client_update, bool update_db) { #if (EQDEBUG >= 5) - Log.Out(Logs::General, Logs::None, "DeleteItemInInventory(%i, %i, %s)", slot_id, quantity, (client_update) ? "true":"false"); + Log(Logs::General, Logs::None, "DeleteItemInInventory(%i, %i, %s)", slot_id, quantity, (client_update) ? "true":"false"); #endif // Added 'IsSlotValid(slot_id)' check to both segments of client packet processing. @@ -893,7 +893,7 @@ void Client::DeleteItemInInventory(int16 slot_id, int8 quantity, bool client_upd bool Client::PushItemOnCursor(const EQEmu::ItemInstance& inst, bool client_update) { - Log.Out(Logs::Detail, Logs::Inventory, "Putting item %s (%d) on the cursor", inst.GetItem()->Name, inst.GetItem()->ID); + Log(Logs::Detail, Logs::Inventory, "Putting item %s (%d) on the cursor", inst.GetItem()->Name, inst.GetItem()->ID); m_inv.PushCursor(inst); if (client_update) { @@ -909,7 +909,7 @@ bool Client::PushItemOnCursor(const EQEmu::ItemInstance& inst, bool client_updat // (Also saves changes back to the database: this may be optimized in the future) // client_update: Sends packet to client bool Client::PutItemInInventory(int16 slot_id, const EQEmu::ItemInstance& inst, bool client_update) { - Log.Out(Logs::Detail, Logs::Inventory, "Putting item %s (%d) into slot %d", inst.GetItem()->Name, inst.GetItem()->ID, slot_id); + Log(Logs::Detail, Logs::Inventory, "Putting item %s (%d) into slot %d", inst.GetItem()->Name, inst.GetItem()->ID, slot_id); if (slot_id == EQEmu::inventory::slotCursor) { // don't trust macros before conditional statements... return PushItemOnCursor(inst, client_update); @@ -938,7 +938,7 @@ bool Client::PutItemInInventory(int16 slot_id, const EQEmu::ItemInstance& inst, void Client::PutLootInInventory(int16 slot_id, const EQEmu::ItemInstance &inst, ServerLootItem_Struct** bag_item_data) { - Log.Out(Logs::Detail, Logs::Inventory, "Putting loot item %s (%d) into slot %d", inst.GetItem()->Name, inst.GetItem()->ID, slot_id); + Log(Logs::Detail, Logs::Inventory, "Putting loot item %s (%d) into slot %d", inst.GetItem()->Name, inst.GetItem()->ID, slot_id); bool cursor_empty = m_inv.CursorEmpty(); @@ -982,7 +982,7 @@ void Client::PutLootInInventory(int16 slot_id, const EQEmu::ItemInstance &inst, // Dump bag contents to cursor in the event that owning bag is not the first cursor item // (This assumes that the data passed is correctly associated..no safety checks are implemented) if (slot_id == EQEmu::inventory::slotCursor && !cursor_empty) { - Log.Out(Logs::Detail, Logs::Inventory, + Log(Logs::Detail, Logs::Inventory, "Putting bag loot item %s (%d) into slot %d (non-empty cursor override)", inst.GetItem()->Name, inst.GetItem()->ID, EQEmu::inventory::slotCursor); @@ -991,7 +991,7 @@ void Client::PutLootInInventory(int16 slot_id, const EQEmu::ItemInstance &inst, else { auto bag_slot = EQEmu::InventoryProfile::CalcSlotId(slot_id, index); - Log.Out(Logs::Detail, Logs::Inventory, + Log(Logs::Detail, Logs::Inventory, "Putting bag loot item %s (%d) into slot %d (bag slot %d)", inst.GetItem()->Name, inst.GetItem()->ID, bag_slot, index); @@ -1417,7 +1417,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { // SoF+ sends a Unix timestamp (should be int32) for src and dst slots every 10 minutes for some reason. if(src_slot_check < 2147483647) Message(13, "Warning: Invalid slot move from slot %u to slot %u with %u charges!", src_slot_check, dst_slot_check, stack_count_check); - Log.Out(Logs::Detail, Logs::Inventory, "Invalid slot move from slot %u to slot %u with %u charges!", src_slot_check, dst_slot_check, stack_count_check); + Log(Logs::Detail, Logs::Inventory, "Invalid slot move from slot %u to slot %u with %u charges!", src_slot_check, dst_slot_check, stack_count_check); return false; } @@ -1425,7 +1425,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { // SoF+ sends a Unix timestamp (should be int32) for src and dst slots every 10 minutes for some reason. if(src_slot_check < 2147483647) Message(13, "Warning: Invalid slot move from slot %u to slot %u with %u charges!", src_slot_check, dst_slot_check, stack_count_check); - Log.Out(Logs::Detail, Logs::Inventory, "Invalid slot move from slot %u to slot %u with %u charges!", src_slot_check, dst_slot_check, stack_count_check); + Log(Logs::Detail, Logs::Inventory, "Invalid slot move from slot %u to slot %u with %u charges!", src_slot_check, dst_slot_check, stack_count_check); return false; } @@ -1449,7 +1449,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { } if (!lore_pass) { - Log.Out(Logs::General, Logs::Inventory, "(%s) Duplicate lore items are not allowed - destroying item %s(id:%u) on cursor", + Log(Logs::General, Logs::Inventory, "(%s) Duplicate lore items are not allowed - destroying item %s(id:%u) on cursor", GetName(), test_item->Name, test_item->ID); Message_StringID(MT_LootMessages, 290); parse->EventItem(EVENT_DESTROY_ITEM, this, test_inst, nullptr, "", 0); @@ -1461,7 +1461,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { if (move_in->to_slot == (uint32)INVALID_INDEX) { if (move_in->from_slot == (uint32)EQEmu::inventory::slotCursor) { - Log.Out(Logs::Detail, Logs::Inventory, "Client destroyed item from cursor slot %d", move_in->from_slot); + Log(Logs::Detail, Logs::Inventory, "Client destroyed item from cursor slot %d", move_in->from_slot); if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit EQEmu::ItemInstance *inst = m_inv.GetItem(EQEmu::inventory::slotCursor); @@ -1475,7 +1475,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { return true; // Item destroyed by client } else { - Log.Out(Logs::Detail, Logs::Inventory, "Deleted item from slot %d as a result of an inventory container tradeskill combine.", move_in->from_slot); + Log(Logs::Detail, Logs::Inventory, "Deleted item from slot %d as a result of an inventory container tradeskill combine.", move_in->from_slot); if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit DeleteItemInInventory(move_in->from_slot); return true; // Item deletion @@ -1511,7 +1511,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { EQEmu::ItemInstance* src_inst = m_inv.GetItem(src_slot_id); EQEmu::ItemInstance* dst_inst = m_inv.GetItem(dst_slot_id); if (src_inst){ - Log.Out(Logs::Detail, Logs::Inventory, "Src slot %d has item %s (%d) with %d charges in it.", src_slot_id, src_inst->GetItem()->Name, src_inst->GetItem()->ID, src_inst->GetCharges()); + Log(Logs::Detail, Logs::Inventory, "Src slot %d has item %s (%d) with %d charges in it.", src_slot_id, src_inst->GetItem()->Name, src_inst->GetItem()->ID, src_inst->GetCharges()); srcitemid = src_inst->GetItem()->ID; //SetTint(dst_slot_id,src_inst->GetColor()); if (src_inst->GetCharges() > 0 && (src_inst->GetCharges() < (int16)move_in->number_in_stack || move_in->number_in_stack > src_inst->GetItem()->StackSize)) @@ -1521,7 +1521,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { } } if (dst_inst) { - Log.Out(Logs::Detail, Logs::Inventory, "Dest slot %d has item %s (%d) with %d charges in it.", dst_slot_id, dst_inst->GetItem()->Name, dst_inst->GetItem()->ID, dst_inst->GetCharges()); + Log(Logs::Detail, Logs::Inventory, "Dest slot %d has item %s (%d) with %d charges in it.", dst_slot_id, dst_inst->GetItem()->Name, dst_inst->GetItem()->ID, dst_inst->GetCharges()); dstitemid = dst_inst->GetItem()->ID; } if (Trader && srcitemid>0){ @@ -1558,7 +1558,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { move_in->from_slot = dst_slot_check; move_in->to_slot = src_slot_check; move_in->number_in_stack = dst_inst->GetCharges(); - if(!SwapItem(move_in)) { Log.Out(Logs::Detail, Logs::Inventory, "Recursive SwapItem call failed due to non-existent destination item (charid: %i, fromslot: %i, toslot: %i)", CharacterID(), src_slot_id, dst_slot_id); } + if(!SwapItem(move_in)) { Log(Logs::Detail, Logs::Inventory, "Recursive SwapItem call failed due to non-existent destination item (charid: %i, fromslot: %i, toslot: %i)", CharacterID(), src_slot_id, dst_slot_id); } } return false; @@ -1566,7 +1566,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { //verify shared bank transactions in the database if (src_inst && src_slot_id >= EQEmu::legacy::SHARED_BANK_BEGIN && src_slot_id <= EQEmu::legacy::SHARED_BANK_BAGS_END) { if(!database.VerifyInventory(account_id, src_slot_id, src_inst)) { - Log.Out(Logs::General, Logs::Error, "Player %s on account %s was found exploiting the shared bank.\n", GetName(), account_name); + Log(Logs::General, Logs::Error, "Player %s on account %s was found exploiting the shared bank.\n", GetName(), account_name); DeleteItemInInventory(dst_slot_id,0,true); return(false); } @@ -1581,7 +1581,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { } if (dst_inst && dst_slot_id >= EQEmu::legacy::SHARED_BANK_BEGIN && dst_slot_id <= EQEmu::legacy::SHARED_BANK_BAGS_END) { if(!database.VerifyInventory(account_id, dst_slot_id, dst_inst)) { - Log.Out(Logs::General, Logs::Error, "Player %s on account %s was found exploting the shared bank.\n", GetName(), account_name); + Log(Logs::General, Logs::Error, "Player %s on account %s was found exploting the shared bank.\n", GetName(), account_name); DeleteItemInInventory(src_slot_id,0,true); return(false); } @@ -1618,7 +1618,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { ndh_item_data.append(StringFormat(", nodrop=%s(%u)", (ndh_item->NoDrop == 0 ? "true" : "false"), ndh_item->NoDrop)); } } - Log.Out(Logs::General, Logs::Error, "WorldKick() of Player %s(id:%u, acct:%u) due to 'NoDrop Hack' detection >> SlotID:%i, ItemData:'%s'", + Log(Logs::General, Logs::Error, "WorldKick() of Player %s(id:%u, acct:%u) due to 'NoDrop Hack' detection >> SlotID:%i, ItemData:'%s'", GetName(), CharacterID(), AccountID(), src_slot_id, ndh_item_data.c_str()); ndh_inst = nullptr; @@ -1720,7 +1720,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { return false; } if (with) { - Log.Out(Logs::Detail, Logs::Inventory, "Trade item move from slot %d to slot %d (trade with %s)", src_slot_id, dst_slot_id, with->GetName()); + Log(Logs::Detail, Logs::Inventory, "Trade item move from slot %d to slot %d (trade with %s)", src_slot_id, dst_slot_id, with->GetName()); // Fill Trade list with items from cursor if (!m_inv[EQEmu::inventory::slotCursor]) { Message(13, "Error: Cursor item not located on server!"); @@ -1753,18 +1753,18 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { if (move_in->number_in_stack > 0) { // Determine if charged items can stack if(src_inst && !src_inst->IsStackable()) { - Log.Out(Logs::Detail, Logs::Inventory, "Move from %d to %d with stack size %d. %s is not a stackable item. (charname: %s)", src_slot_id, dst_slot_id, move_in->number_in_stack, src_inst->GetItem()->Name, GetName()); + Log(Logs::Detail, Logs::Inventory, "Move from %d to %d with stack size %d. %s is not a stackable item. (charname: %s)", src_slot_id, dst_slot_id, move_in->number_in_stack, src_inst->GetItem()->Name, GetName()); return false; } if (dst_inst) { if(src_inst->GetID() != dst_inst->GetID()) { - Log.Out(Logs::Detail, Logs::Inventory, "Move from %d to %d with stack size %d. Incompatible item types: %d != %d", src_slot_id, dst_slot_id, move_in->number_in_stack, src_inst->GetID(), dst_inst->GetID()); + Log(Logs::Detail, Logs::Inventory, "Move from %d to %d with stack size %d. Incompatible item types: %d != %d", src_slot_id, dst_slot_id, move_in->number_in_stack, src_inst->GetID(), dst_inst->GetID()); return(false); } if(dst_inst->GetCharges() < dst_inst->GetItem()->StackSize) { //we have a chance of stacking. - Log.Out(Logs::Detail, Logs::Inventory, "Move from %d to %d with stack size %d. dest has %d/%d charges", src_slot_id, dst_slot_id, move_in->number_in_stack, dst_inst->GetCharges(), dst_inst->GetItem()->StackSize); + Log(Logs::Detail, Logs::Inventory, "Move from %d to %d with stack size %d. dest has %d/%d charges", src_slot_id, dst_slot_id, move_in->number_in_stack, dst_inst->GetCharges(), dst_inst->GetItem()->StackSize); // Charges can be emptied into dst uint16 usedcharges = dst_inst->GetItem()->StackSize - dst_inst->GetCharges(); if (usedcharges > move_in->number_in_stack) @@ -1776,15 +1776,15 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { // Depleted all charges? if (src_inst->GetCharges() < 1) { - Log.Out(Logs::Detail, Logs::Inventory, "Dest (%d) now has %d charges, source (%d) was entirely consumed. (%d moved)", dst_slot_id, dst_inst->GetCharges(), src_slot_id, usedcharges); + Log(Logs::Detail, Logs::Inventory, "Dest (%d) now has %d charges, source (%d) was entirely consumed. (%d moved)", dst_slot_id, dst_inst->GetCharges(), src_slot_id, usedcharges); database.SaveInventory(CharacterID(),nullptr,src_slot_id); m_inv.DeleteItem(src_slot_id); all_to_stack = true; } else { - Log.Out(Logs::Detail, Logs::Inventory, "Dest (%d) now has %d charges, source (%d) has %d (%d moved)", dst_slot_id, dst_inst->GetCharges(), src_slot_id, src_inst->GetCharges(), usedcharges); + Log(Logs::Detail, Logs::Inventory, "Dest (%d) now has %d charges, source (%d) has %d (%d moved)", dst_slot_id, dst_inst->GetCharges(), src_slot_id, src_inst->GetCharges(), usedcharges); } } else { - Log.Out(Logs::Detail, Logs::Inventory, "Move from %d to %d with stack size %d. Exceeds dest maximum stack size: %d/%d", src_slot_id, dst_slot_id, move_in->number_in_stack, (src_inst->GetCharges()+dst_inst->GetCharges()), dst_inst->GetItem()->StackSize); + Log(Logs::Detail, Logs::Inventory, "Move from %d to %d with stack size %d. Exceeds dest maximum stack size: %d/%d", src_slot_id, dst_slot_id, move_in->number_in_stack, (src_inst->GetCharges()+dst_inst->GetCharges()), dst_inst->GetItem()->StackSize); return false; } } @@ -1793,12 +1793,12 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { if ((int16)move_in->number_in_stack >= src_inst->GetCharges()) { // Move entire stack if(!m_inv.SwapItem(src_slot_id, dst_slot_id)) { return false; } - Log.Out(Logs::Detail, Logs::Inventory, "Move entire stack from %d to %d with stack size %d. Dest empty.", src_slot_id, dst_slot_id, move_in->number_in_stack); + Log(Logs::Detail, Logs::Inventory, "Move entire stack from %d to %d with stack size %d. Dest empty.", src_slot_id, dst_slot_id, move_in->number_in_stack); } else { // Split into two src_inst->SetCharges(src_inst->GetCharges() - move_in->number_in_stack); - Log.Out(Logs::Detail, Logs::Inventory, "Split stack of %s (%d) from slot %d to %d with stack size %d. Src keeps %d.", src_inst->GetItem()->Name, src_inst->GetItem()->ID, src_slot_id, dst_slot_id, move_in->number_in_stack, src_inst->GetCharges()); + Log(Logs::Detail, Logs::Inventory, "Split stack of %s (%d) from slot %d to %d with stack size %d. Src keeps %d.", src_inst->GetItem()->Name, src_inst->GetItem()->ID, src_slot_id, dst_slot_id, move_in->number_in_stack, src_inst->GetCharges()); EQEmu::ItemInstance* inst = database.CreateItem(src_inst->GetItem(), move_in->number_in_stack); m_inv.PutItem(dst_slot_id, *inst); safe_delete(inst); @@ -1822,8 +1822,8 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { } SetMaterial(dst_slot_id,src_inst->GetItem()->ID); } - if(!m_inv.SwapItem(src_slot_id, dst_slot_id)) { return false; } - Log.Out(Logs::Detail, Logs::Inventory, "Moving entire item from slot %d to slot %d", src_slot_id, dst_slot_id); + if(!m_inv.SwapItem(src_slot_id, dst_slot_id, GetRace(), GetClass(), GetDeity(), GetLevel())) { return false; } + Log(Logs::Detail, Logs::Inventory, "Moving entire item from slot %d to slot %d", src_slot_id, dst_slot_id); if (src_slot_id <= EQEmu::legacy::EQUIPMENT_END || src_slot_id == EQEmu::inventory::slotPowerSource) { if(src_inst) { @@ -1886,7 +1886,7 @@ void Client::SwapItemResync(MoveItem_Struct* move_slots) { // resync the 'from' and 'to' slots on an as-needed basis // Not as effective as the full process, but less intrusive to gameplay - Log.Out(Logs::Detail, Logs::Inventory, "Inventory desyncronization. (charname: %s, source: %i, destination: %i)", GetName(), move_slots->from_slot, move_slots->to_slot); + Log(Logs::Detail, Logs::Inventory, "Inventory desyncronization. (charname: %s, source: %i, destination: %i)", GetName(), move_slots->from_slot, move_slots->to_slot); Message(15, "Inventory Desyncronization detected: Resending slot data..."); if ((move_slots->from_slot >= EQEmu::legacy::EQUIPMENT_BEGIN && move_slots->from_slot <= EQEmu::legacy::CURSOR_BAG_END) || move_slots->from_slot == EQEmu::inventory::slotPowerSource) { @@ -2267,7 +2267,7 @@ static bool CopyBagContents(EQEmu::ItemInstance* new_bag, const EQEmu::ItemInsta for (auto bag_slot = 0; bag_slot < old_bag->GetItem()->BagSlots; ++bag_slot) { if (!old_bag->GetItem(bag_slot)) { continue; } if (old_bag->GetItem(bag_slot)->GetItem()->Size > new_bag->GetItem()->BagSize) { - Log.Out(Logs::General, Logs::Inventory, "Copy Bag Contents: Failure due to %s is larger than size capacity of %s (%i > %i)", + Log(Logs::General, Logs::Inventory, "Copy Bag Contents: Failure due to %s is larger than size capacity of %s (%i > %i)", old_bag->GetItem(bag_slot)->GetItem()->Name, new_bag->GetItem()->Name, old_bag->GetItem(bag_slot)->GetItem()->Size, new_bag->GetItem()->BagSize); return false; } @@ -2298,7 +2298,7 @@ void Client::DisenchantSummonedBags(bool client_update) if (!new_inst) { continue; } if (CopyBagContents(new_inst, inst)) { - Log.Out(Logs::General, Logs::Inventory, "Disenchant Summoned Bags: Replacing %s with %s in slot %i", inst->GetItem()->Name, new_inst->GetItem()->Name, slot_id); + Log(Logs::General, Logs::Inventory, "Disenchant Summoned Bags: Replacing %s with %s in slot %i", inst->GetItem()->Name, new_inst->GetItem()->Name, slot_id); PutItemInInventory(slot_id, *new_inst, client_update); } safe_delete(new_inst); @@ -2319,7 +2319,7 @@ void Client::DisenchantSummonedBags(bool client_update) if (!new_inst) { continue; } if (CopyBagContents(new_inst, inst)) { - Log.Out(Logs::General, Logs::Inventory, "Disenchant Summoned Bags: Replacing %s with %s in slot %i", inst->GetItem()->Name, new_inst->GetItem()->Name, slot_id); + Log(Logs::General, Logs::Inventory, "Disenchant Summoned Bags: Replacing %s with %s in slot %i", inst->GetItem()->Name, new_inst->GetItem()->Name, slot_id); PutItemInInventory(slot_id, *new_inst, client_update); } safe_delete(new_inst); @@ -2340,7 +2340,7 @@ void Client::DisenchantSummonedBags(bool client_update) if (!new_inst) { continue; } if (CopyBagContents(new_inst, inst)) { - Log.Out(Logs::General, Logs::Inventory, "Disenchant Summoned Bags: Replacing %s with %s in slot %i", inst->GetItem()->Name, new_inst->GetItem()->Name, slot_id); + Log(Logs::General, Logs::Inventory, "Disenchant Summoned Bags: Replacing %s with %s in slot %i", inst->GetItem()->Name, new_inst->GetItem()->Name, slot_id); PutItemInInventory(slot_id, *new_inst, client_update); } safe_delete(new_inst); @@ -2361,7 +2361,7 @@ void Client::DisenchantSummonedBags(bool client_update) if (!new_inst) { break; } if (CopyBagContents(new_inst, inst)) { - Log.Out(Logs::General, Logs::Inventory, "Disenchant Summoned Bags: Replacing %s with %s in slot %i", inst->GetItem()->Name, new_inst->GetItem()->Name, EQEmu::inventory::slotCursor); + Log(Logs::General, Logs::Inventory, "Disenchant Summoned Bags: Replacing %s with %s in slot %i", inst->GetItem()->Name, new_inst->GetItem()->Name, EQEmu::inventory::slotCursor); std::list local; local.push_front(new_inst); m_inv.PopItem(EQEmu::inventory::slotCursor); @@ -2397,7 +2397,7 @@ void Client::RemoveNoRent(bool client_update) for (auto slot_id = EQEmu::legacy::EQUIPMENT_BEGIN; slot_id <= EQEmu::legacy::EQUIPMENT_END; ++slot_id) { auto inst = m_inv[slot_id]; if(inst && !inst->GetItem()->NoRent) { - Log.Out(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); + Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); DeleteItemInInventory(slot_id, 0, client_update); } } @@ -2405,7 +2405,7 @@ void Client::RemoveNoRent(bool client_update) for (auto slot_id = EQEmu::legacy::GENERAL_BEGIN; slot_id <= EQEmu::legacy::GENERAL_END; ++slot_id) { auto inst = m_inv[slot_id]; if (inst && !inst->GetItem()->NoRent) { - Log.Out(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); + Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); DeleteItemInInventory(slot_id, 0, client_update); } } @@ -2413,7 +2413,7 @@ void Client::RemoveNoRent(bool client_update) if (m_inv[EQEmu::inventory::slotPowerSource]) { auto inst = m_inv[EQEmu::inventory::slotPowerSource]; if (inst && !inst->GetItem()->NoRent) { - Log.Out(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, EQEmu::inventory::slotPowerSource); + Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, EQEmu::inventory::slotPowerSource); DeleteItemInInventory(EQEmu::inventory::slotPowerSource, 0, (ClientVersion() >= EQEmu::versions::ClientVersion::SoF) ? client_update : false); // Ti slot non-existent } } @@ -2421,7 +2421,7 @@ void Client::RemoveNoRent(bool client_update) for (auto slot_id = EQEmu::legacy::GENERAL_BAGS_BEGIN; slot_id <= EQEmu::legacy::CURSOR_BAG_END; ++slot_id) { auto inst = m_inv[slot_id]; if(inst && !inst->GetItem()->NoRent) { - Log.Out(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); + Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); DeleteItemInInventory(slot_id, 0, client_update); } } @@ -2429,7 +2429,7 @@ void Client::RemoveNoRent(bool client_update) for (auto slot_id = EQEmu::legacy::BANK_BEGIN; slot_id <= EQEmu::legacy::BANK_END; ++slot_id) { auto inst = m_inv[slot_id]; if(inst && !inst->GetItem()->NoRent) { - Log.Out(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); + Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); DeleteItemInInventory(slot_id, 0, false); // Can't delete from client Bank slots } } @@ -2437,7 +2437,7 @@ void Client::RemoveNoRent(bool client_update) for (auto slot_id = EQEmu::legacy::BANK_BAGS_BEGIN; slot_id <= EQEmu::legacy::BANK_BAGS_END; ++slot_id) { auto inst = m_inv[slot_id]; if(inst && !inst->GetItem()->NoRent) { - Log.Out(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); + Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); DeleteItemInInventory(slot_id, 0, false); // Can't delete from client Bank Container slots } } @@ -2445,7 +2445,7 @@ void Client::RemoveNoRent(bool client_update) for (auto slot_id = EQEmu::legacy::SHARED_BANK_BEGIN; slot_id <= EQEmu::legacy::SHARED_BANK_END; ++slot_id) { auto inst = m_inv[slot_id]; if(inst && !inst->GetItem()->NoRent) { - Log.Out(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); + Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); DeleteItemInInventory(slot_id, 0, false); // Can't delete from client Shared Bank slots } } @@ -2453,7 +2453,7 @@ void Client::RemoveNoRent(bool client_update) for (auto slot_id = EQEmu::legacy::SHARED_BANK_BAGS_BEGIN; slot_id <= EQEmu::legacy::SHARED_BANK_BAGS_END; ++slot_id) { auto inst = m_inv[slot_id]; if(inst && !inst->GetItem()->NoRent) { - Log.Out(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); + Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); DeleteItemInInventory(slot_id, 0, false); // Can't delete from client Shared Bank Container slots } } @@ -2471,7 +2471,7 @@ void Client::RemoveNoRent(bool client_update) auto inst = *iter; if (inst == nullptr) { continue; } if (!inst->GetItem()->NoRent) { - Log.Out(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from `Limbo`", inst->GetItem()->Name); + Log(Logs::Detail, Logs::Inventory, "NoRent Timer Lapse: Deleting %s from `Limbo`", inst->GetItem()->Name); } else { m_inv.PushCursor(*inst); @@ -2492,7 +2492,7 @@ void Client::RemoveDuplicateLore(bool client_update) auto inst = m_inv.PopItem(slot_id); if (inst == nullptr) { continue; } if(CheckLoreConflict(inst->GetItem())) { - Log.Out(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); + Log(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); database.SaveInventory(character_id, nullptr, slot_id); } else { @@ -2505,7 +2505,7 @@ void Client::RemoveDuplicateLore(bool client_update) auto inst = m_inv.PopItem(slot_id); if (inst == nullptr) { continue; } if (CheckLoreConflict(inst->GetItem())) { - Log.Out(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); + Log(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); database.SaveInventory(character_id, nullptr, slot_id); } else { @@ -2518,7 +2518,7 @@ void Client::RemoveDuplicateLore(bool client_update) auto inst = m_inv.PopItem(EQEmu::inventory::slotPowerSource); if (inst) { if (CheckLoreConflict(inst->GetItem())) { - Log.Out(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, EQEmu::inventory::slotPowerSource); + Log(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, EQEmu::inventory::slotPowerSource); database.SaveInventory(character_id, nullptr, EQEmu::inventory::slotPowerSource); } else { @@ -2532,7 +2532,7 @@ void Client::RemoveDuplicateLore(bool client_update) auto inst = m_inv.PopItem(slot_id); if (inst == nullptr) { continue; } if(CheckLoreConflict(inst->GetItem())) { - Log.Out(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); + Log(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); database.SaveInventory(character_id, nullptr, slot_id); } else { @@ -2545,7 +2545,7 @@ void Client::RemoveDuplicateLore(bool client_update) auto inst = m_inv.PopItem(slot_id); if (inst == nullptr) { continue; } if(CheckLoreConflict(inst->GetItem())) { - Log.Out(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); + Log(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); database.SaveInventory(character_id, nullptr, slot_id); } else { @@ -2558,7 +2558,7 @@ void Client::RemoveDuplicateLore(bool client_update) auto inst = m_inv.PopItem(slot_id); if (inst == nullptr) { continue; } if(CheckLoreConflict(inst->GetItem())) { - Log.Out(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); + Log(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from slot %i", inst->GetItem()->Name, slot_id); database.SaveInventory(character_id, nullptr, slot_id); } else { @@ -2583,7 +2583,7 @@ void Client::RemoveDuplicateLore(bool client_update) auto inst = *iter; if (inst == nullptr) { continue; } if (CheckLoreConflict(inst->GetItem())) { - Log.Out(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from `Limbo`", inst->GetItem()->Name); + Log(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from `Limbo`", inst->GetItem()->Name); safe_delete(inst); } else { @@ -2602,7 +2602,7 @@ void Client::RemoveDuplicateLore(bool client_update) m_inv.PushCursor(*inst); } else { - Log.Out(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from `Limbo`", inst->GetItem()->Name); + Log(Logs::Detail, Logs::Inventory, "Lore Duplication Error: Deleting %s from `Limbo`", inst->GetItem()->Name); } safe_delete(inst); } @@ -2620,7 +2620,7 @@ void Client::MoveSlotNotAllowed(bool client_update) auto inst = m_inv.PopItem(slot_id); bool is_arrow = (inst->GetItem()->ItemType == EQEmu::item::ItemTypeArrow) ? true : false; int16 free_slot_id = m_inv.FindFreeSlot(inst->IsClassBag(), true, inst->GetItem()->Size, is_arrow); - Log.Out(Logs::Detail, Logs::Inventory, "Slot Assignment Error: Moving %s from slot %i to %i", inst->GetItem()->Name, slot_id, free_slot_id); + Log(Logs::Detail, Logs::Inventory, "Slot Assignment Error: Moving %s from slot %i to %i", inst->GetItem()->Name, slot_id, free_slot_id); PutItemInInventory(free_slot_id, *inst, client_update); database.SaveInventory(character_id, nullptr, slot_id); safe_delete(inst); @@ -2631,7 +2631,7 @@ void Client::MoveSlotNotAllowed(bool client_update) auto inst = m_inv.PopItem(EQEmu::inventory::slotPowerSource); bool is_arrow = (inst->GetItem()->ItemType == EQEmu::item::ItemTypeArrow) ? true : false; int16 free_slot_id = m_inv.FindFreeSlot(inst->IsClassBag(), true, inst->GetItem()->Size, is_arrow); - Log.Out(Logs::Detail, Logs::Inventory, "Slot Assignment Error: Moving %s from slot %i to %i", inst->GetItem()->Name, EQEmu::inventory::slotPowerSource, free_slot_id); + Log(Logs::Detail, Logs::Inventory, "Slot Assignment Error: Moving %s from slot %i to %i", inst->GetItem()->Name, EQEmu::inventory::slotPowerSource, free_slot_id); PutItemInInventory(free_slot_id, *inst, (ClientVersion() >= EQEmu::versions::ClientVersion::SoF) ? client_update : false); database.SaveInventory(character_id, nullptr, EQEmu::inventory::slotPowerSource); safe_delete(inst); @@ -2768,7 +2768,7 @@ void Client::CreateBandolier(const EQApplicationPacket *app) BandolierCreate_Struct *bs = (BandolierCreate_Struct*)app->pBuffer; - Log.Out(Logs::Detail, Logs::Inventory, "Char: %s Creating Bandolier Set %i, Set Name: %s", GetName(), bs->Number, bs->Name); + Log(Logs::Detail, Logs::Inventory, "Char: %s Creating Bandolier Set %i, Set Name: %s", GetName(), bs->Number, bs->Name); strcpy(m_pp.bandoliers[bs->Number].Name, bs->Name); const EQEmu::ItemInstance* InvItem = nullptr; @@ -2782,13 +2782,13 @@ void Client::CreateBandolier(const EQApplicationPacket *app) InvItem = GetInv()[WeaponSlot]; if(InvItem) { BaseItem = InvItem->GetItem(); - Log.Out(Logs::Detail, Logs::Inventory, "Char: %s adding item %s to slot %i", GetName(),BaseItem->Name, WeaponSlot); + Log(Logs::Detail, Logs::Inventory, "Char: %s adding item %s to slot %i", GetName(),BaseItem->Name, WeaponSlot); m_pp.bandoliers[bs->Number].Items[BandolierSlot].ID = BaseItem->ID; m_pp.bandoliers[bs->Number].Items[BandolierSlot].Icon = BaseItem->Icon; database.SaveCharacterBandolier(this->CharacterID(), bs->Number, BandolierSlot, m_pp.bandoliers[bs->Number].Items[BandolierSlot].ID, m_pp.bandoliers[bs->Number].Items[BandolierSlot].Icon, bs->Name); } else { - Log.Out(Logs::Detail, Logs::Inventory, "Char: %s no item in slot %i", GetName(), WeaponSlot); + Log(Logs::Detail, Logs::Inventory, "Char: %s no item in slot %i", GetName(), WeaponSlot); m_pp.bandoliers[bs->Number].Items[BandolierSlot].ID = 0; m_pp.bandoliers[bs->Number].Items[BandolierSlot].Icon = 0; } @@ -2798,7 +2798,7 @@ void Client::CreateBandolier(const EQApplicationPacket *app) void Client::RemoveBandolier(const EQApplicationPacket *app) { BandolierDelete_Struct *bds = (BandolierDelete_Struct*)app->pBuffer; - Log.Out(Logs::Detail, Logs::Inventory, "Char: %s removing set", GetName(), bds->Number); + Log(Logs::Detail, Logs::Inventory, "Char: %s removing set", GetName(), bds->Number); memset(m_pp.bandoliers[bds->Number].Name, 0, 32); for(int i = bandolierPrimary; i <= bandolierAmmo; i++) { m_pp.bandoliers[bds->Number].Items[i].ID = 0; @@ -2813,7 +2813,7 @@ void Client::SetBandolier(const EQApplicationPacket *app) // any items currently in the weapon slots to inventory. BandolierSet_Struct *bss = (BandolierSet_Struct*)app->pBuffer; - Log.Out(Logs::Detail, Logs::Inventory, "Char: %s activating set %i", GetName(), bss->Number); + Log(Logs::Detail, Logs::Inventory, "Char: %s activating set %i", GetName(), bss->Number); int16 slot = 0; int16 WeaponSlot = 0; EQEmu::ItemInstance *BandolierItems[4]; // Temporary holding area for the weapons we pull out of their inventory @@ -2880,19 +2880,19 @@ void Client::SetBandolier(const EQApplicationPacket *app) else { // The player doesn't have the required weapon with them. BandolierItems[BandolierSlot] = 0; if (slot == INVALID_INDEX) { - Log.Out(Logs::Detail, Logs::Inventory, "Character does not have required bandolier item for slot %i", WeaponSlot); + Log(Logs::Detail, Logs::Inventory, "Character does not have required bandolier item for slot %i", WeaponSlot); EQEmu::ItemInstance *InvItem = m_inv.PopItem(WeaponSlot); if(InvItem) { // If there was an item in that weapon slot, put it in the inventory - Log.Out(Logs::Detail, Logs::Inventory, "returning item %s in weapon slot %i to inventory", + Log(Logs::Detail, Logs::Inventory, "returning item %s in weapon slot %i to inventory", InvItem->GetItem()->Name, WeaponSlot); - Log.Out(Logs::Detail, Logs::Inventory, "returning item %s in weapon slot %i to inventory", InvItem->GetItem()->Name, WeaponSlot); + Log(Logs::Detail, Logs::Inventory, "returning item %s in weapon slot %i to inventory", InvItem->GetItem()->Name, WeaponSlot); if (MoveItemToInventory(InvItem)) { database.SaveInventory(character_id, 0, WeaponSlot); - Log.Out(Logs::General, Logs::Error, "returning item %s in weapon slot %i to inventory", InvItem->GetItem()->Name, WeaponSlot); + Log(Logs::General, Logs::Error, "returning item %s in weapon slot %i to inventory", InvItem->GetItem()->Name, WeaponSlot); } else { - Log.Out(Logs::General, Logs::Error, "Char: %s, ERROR returning %s to inventory", GetName(), InvItem->GetItem()->Name); + Log(Logs::General, Logs::Error, "Char: %s, ERROR returning %s to inventory", GetName(), InvItem->GetItem()->Name); } safe_delete(InvItem); } @@ -2926,7 +2926,7 @@ void Client::SetBandolier(const EQApplicationPacket *app) if(InvItem) { // If there was already an item in that weapon slot that we replaced, find a place to put it if (!MoveItemToInventory(InvItem)) { - Log.Out(Logs::General, Logs::Error, "Char: %s, ERROR returning %s to inventory", GetName(), InvItem->GetItem()->Name); + Log(Logs::General, Logs::Error, "Char: %s, ERROR returning %s to inventory", GetName(), InvItem->GetItem()->Name); } safe_delete(InvItem); } @@ -2937,13 +2937,13 @@ void Client::SetBandolier(const EQApplicationPacket *app) // put it in the player's inventory. EQEmu::ItemInstance *InvItem = m_inv.PopItem(WeaponSlot); if(InvItem) { - Log.Out(Logs::Detail, Logs::Inventory, "Bandolier has no item for slot %i, returning item %s to inventory", WeaponSlot, InvItem->GetItem()->Name); + Log(Logs::Detail, Logs::Inventory, "Bandolier has no item for slot %i, returning item %s to inventory", WeaponSlot, InvItem->GetItem()->Name); // If there was an item in that weapon slot, put it in the inventory if (MoveItemToInventory(InvItem)) { database.SaveInventory(character_id, 0, WeaponSlot); } else { - Log.Out(Logs::General, Logs::Error, "Char: %s, ERROR returning %s to inventory", GetName(), InvItem->GetItem()->Name); + Log(Logs::General, Logs::Error, "Char: %s, ERROR returning %s to inventory", GetName(), InvItem->GetItem()->Name); } safe_delete(InvItem); } @@ -2976,7 +2976,7 @@ bool Client::MoveItemToInventory(EQEmu::ItemInstance *ItemToReturn, bool UpdateC return false; } - Log.Out(Logs::Detail, Logs::Inventory,"Char: %s Returning %s to inventory", GetName(), ItemToReturn->GetItem()->Name); + Log(Logs::Detail, Logs::Inventory,"Char: %s Returning %s to inventory", GetName(), ItemToReturn->GetItem()->Name); uint32 ItemID = ItemToReturn->GetItem()->ID; @@ -3056,7 +3056,7 @@ bool Client::MoveItemToInventory(EQEmu::ItemInstance *ItemToReturn, bool UpdateC database.SaveInventory(character_id, m_inv.GetItem(i), i); - Log.Out(Logs::Detail, Logs::Inventory, "Char: %s Storing in main inventory slot %i", GetName(), i); + Log(Logs::Detail, Logs::Inventory, "Char: %s Storing in main inventory slot %i", GetName(), i); return true; } @@ -3079,7 +3079,7 @@ bool Client::MoveItemToInventory(EQEmu::ItemInstance *ItemToReturn, bool UpdateC database.SaveInventory(character_id, m_inv.GetItem(BaseSlotID + BagSlot), BaseSlotID + BagSlot); - Log.Out(Logs::Detail, Logs::Inventory, "Char: %s Storing in bag slot %i", GetName(), BaseSlotID + BagSlot); + Log(Logs::Detail, Logs::Inventory, "Char: %s Storing in bag slot %i", GetName(), BaseSlotID + BagSlot); return true; } @@ -3089,7 +3089,7 @@ bool Client::MoveItemToInventory(EQEmu::ItemInstance *ItemToReturn, bool UpdateC // Store on the cursor // - Log.Out(Logs::Detail, Logs::Inventory, "Char: %s No space, putting on the cursor", GetName()); + Log(Logs::Detail, Logs::Inventory, "Char: %s No space, putting on the cursor", GetName()); PushItemOnCursor(*ItemToReturn, UpdateClient); @@ -3160,7 +3160,7 @@ bool Client::InterrogateInventory(Client* requester, bool log, bool silent, bool log = true; if (log) { - Log.Out(Logs::General, Logs::Error, "Client::InterrogateInventory() called for %s by %s with an error state of %s", GetName(), requester->GetName(), (error ? "TRUE" : "FALSE")); + Log(Logs::General, Logs::Error, "Client::InterrogateInventory() called for %s by %s with an error state of %s", GetName(), requester->GetName(), (error ? "TRUE" : "FALSE")); } if (!silent) { requester->Message(1, "--- Inventory Interrogation Report for %s (requested by: %s, error state: %s) ---", GetName(), requester->GetName(), (error ? "TRUE" : "FALSE")); @@ -3181,8 +3181,8 @@ bool Client::InterrogateInventory(Client* requester, bool log, bool silent, bool } if (log) { - Log.Out(Logs::General, Logs::Error, "Target interrogate inventory flag: %s", (GetInterrogateInvState() ? "TRUE" : "FALSE")); - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Client::InterrogateInventory() -- End"); + Log(Logs::General, Logs::Error, "Target interrogate inventory flag: %s", (GetInterrogateInvState() ? "TRUE" : "FALSE")); + Log(Logs::Detail, Logs::None, "[CLIENT] Client::InterrogateInventory() -- End"); } if (!silent) { requester->Message(1, "Target interrogation flag: %s", (GetInterrogateInvState() ? "TRUE" : "FALSE")); @@ -3197,7 +3197,7 @@ bool Client::InterrogateInventory(Client* requester, bool log, bool silent, bool void Client::InterrogateInventory_(bool errorcheck, Client* requester, int16 head, int16 index, const EQEmu::ItemInstance* inst, const EQEmu::ItemInstance* parent, bool log, bool silent, bool &error, int depth) { if (depth >= 10) { - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Client::InterrogateInventory_() - Recursion count has exceeded the maximum allowable (You have a REALLY BIG PROBLEM!!)"); + Log(Logs::Detail, Logs::None, "[CLIENT] Client::InterrogateInventory_() - Recursion count has exceeded the maximum allowable (You have a REALLY BIG PROBLEM!!)"); return; } @@ -3228,7 +3228,7 @@ void Client::InterrogateInventory_(bool errorcheck, Client* requester, int16 hea else { e = ""; } if (log) { - Log.Out(Logs::General, Logs::Error, "Head: %i, Depth: %i, Instance: %s, Parent: %s%s", + Log(Logs::General, Logs::Error, "Head: %i, Depth: %i, Instance: %s, Parent: %s%s", head, depth, i.c_str(), p.c_str(), e.c_str()); } if (!silent) { diff --git a/zone/loottables.cpp b/zone/loottables.cpp index 4fd9c893c..08d16e412 100644 --- a/zone/loottables.cpp +++ b/zone/loottables.cpp @@ -232,7 +232,7 @@ void NPC::AddLootDrop(const EQEmu::ItemData *item2, ItemList* itemlist, int16 ch auto item = new ServerLootItem_Struct; #if EQDEBUG>=11 - Log.Out(Logs::General, Logs::None, "Adding drop to npc: %s, Item: %i", GetName(), item2->ID); + Log(Logs::General, Logs::None, "Adding drop to npc: %s, Item: %i", GetName(), item2->ID); #endif EQApplicationPacket* outapp = nullptr; diff --git a/zone/lua_entity_list.cpp b/zone/lua_entity_list.cpp index 8ba338359..7626a709b 100644 --- a/zone/lua_entity_list.cpp +++ b/zone/lua_entity_list.cpp @@ -309,12 +309,11 @@ Lua_Client Lua_EntityList::GetRandomClient(float x, float y, float z, float dist Lua_Mob_List Lua_EntityList::GetMobList() { Lua_Safe_Call_Class(Lua_Mob_List); Lua_Mob_List ret; - std::list t_list; - self->GetMobList(t_list); + auto &t_list = self->GetMobList(); auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_Mob(*iter)); + ret.entries.push_back(Lua_Mob(iter->second)); ++iter; } @@ -324,12 +323,11 @@ Lua_Mob_List Lua_EntityList::GetMobList() { Lua_Client_List Lua_EntityList::GetClientList() { Lua_Safe_Call_Class(Lua_Client_List); Lua_Client_List ret; - std::list t_list; - self->GetClientList(t_list); + auto &t_list = self->GetClientList(); auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_Client(*iter)); + ret.entries.push_back(Lua_Client(iter->second)); ++iter; } @@ -339,12 +337,11 @@ Lua_Client_List Lua_EntityList::GetClientList() { Lua_NPC_List Lua_EntityList::GetNPCList() { Lua_Safe_Call_Class(Lua_NPC_List); Lua_NPC_List ret; - std::list t_list; - self->GetNPCList(t_list); + auto &t_list = self->GetNPCList(); auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_NPC(*iter)); + ret.entries.push_back(Lua_NPC(iter->second)); ++iter; } @@ -354,12 +351,11 @@ Lua_NPC_List Lua_EntityList::GetNPCList() { Lua_Corpse_List Lua_EntityList::GetCorpseList() { Lua_Safe_Call_Class(Lua_Corpse_List); Lua_Corpse_List ret; - std::list t_list; - self->GetCorpseList(t_list); + auto &t_list = self->GetCorpseList(); auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_Corpse(*iter)); + ret.entries.push_back(Lua_Corpse(iter->second)); ++iter; } @@ -369,12 +365,11 @@ Lua_Corpse_List Lua_EntityList::GetCorpseList() { Lua_Object_List Lua_EntityList::GetObjectList() { Lua_Safe_Call_Class(Lua_Object_List); Lua_Object_List ret; - std::list t_list; - self->GetObjectList(t_list); + auto &t_list = self->GetObjectList(); auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_Object(*iter)); + ret.entries.push_back(Lua_Object(iter->second)); ++iter; } @@ -384,12 +379,11 @@ Lua_Object_List Lua_EntityList::GetObjectList() { Lua_Doors_List Lua_EntityList::GetDoorsList() { Lua_Safe_Call_Class(Lua_Doors_List); Lua_Doors_List ret; - std::list t_list; - self->GetDoorsList(t_list); + auto &t_list = self->GetDoorsList(); auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_Door(*iter)); + ret.entries.push_back(Lua_Door(iter->second)); ++iter; } diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index e71153d8e..b1a2b9cfe 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -1298,14 +1298,14 @@ double lua_clock() { } void lua_debug(std::string message) { - Log.Out(Logs::General, Logs::QuestDebug, message); + Log(Logs::General, Logs::QuestDebug, message); } void lua_debug(std::string message, int level) { if (level < Logs::General || level > Logs::Detail) return; - Log.Out(static_cast(level), Logs::QuestDebug, message); + Log(static_cast(level), Logs::QuestDebug, message); } void lua_update_zone_header(std::string type, std::string value) { diff --git a/zone/lua_mob.cpp b/zone/lua_mob.cpp index add24d861..e59357ebf 100644 --- a/zone/lua_mob.cpp +++ b/zone/lua_mob.cpp @@ -2129,6 +2129,8 @@ luabind::scope lua_register_mob() { .def("SpellFinished", (bool(Lua_Mob::*)(int,Lua_Mob,int,int,uint32,int))&Lua_Mob::SpellFinished) .def("SpellFinished", (bool(Lua_Mob::*)(int,Lua_Mob,int,int,uint32,int,bool))&Lua_Mob::SpellFinished) .def("SpellEffect", &Lua_Mob::SpellEffect) + .def("GetPet", &Lua_Mob::GetPet) + .def("GetOwner", &Lua_Mob::GetOwner) .def("GetHateList", &Lua_Mob::GetHateList) .def("GetHateTop", (Lua_Mob(Lua_Mob::*)(void))&Lua_Mob::GetHateTop) .def("GetHateDamageTop", (Lua_Mob(Lua_Mob::*)(Lua_Mob))&Lua_Mob::GetHateDamageTop) diff --git a/zone/map.cpp b/zone/map.cpp index ceef7894a..32c6564b4 100644 --- a/zone/map.cpp +++ b/zone/map.cpp @@ -290,7 +290,7 @@ Map *Map::LoadMapFile(std::string file) { filename += file; filename += ".map"; - Log.Out(Logs::General, Logs::Status, "Attempting to load Map File :: '%s'", filename.c_str()); + Log(Logs::General, Logs::Status, "Attempting to load Map File :: '%s'", filename.c_str()); auto m = new Map(); if (m->Load(filename)) { @@ -305,7 +305,7 @@ Map *Map::LoadMapFile(std::string file) { bool Map::Load(std::string filename, bool force_mmf_overwrite) { if (LoadMMF(filename, force_mmf_overwrite)) { - Log.Out(Logs::General, Logs::Status, "Loaded .MMF Map File in place of '%s'", filename.c_str()); + Log(Logs::General, Logs::Status, "Loaded .MMF Map File in place of '%s'", filename.c_str()); return true; } #else @@ -322,7 +322,7 @@ bool Map::Load(std::string filename) } if(version == 0x01000000) { - Log.Out(Logs::General, Logs::Status, "Loaded V1 Map File :: '%s'", filename.c_str()); + Log(Logs::General, Logs::Status, "Loaded V1 Map File :: '%s'", filename.c_str()); bool v = LoadV1(f); fclose(f); @@ -333,7 +333,7 @@ bool Map::Load(std::string filename) return v; } else if(version == 0x02000000) { - Log.Out(Logs::General, Logs::Status, "Loaded V2 Map File :: '%s'", filename.c_str()); + Log(Logs::General, Logs::Status, "Loaded V2 Map File :: '%s'", filename.c_str()); bool v = LoadV2(f); fclose(f); @@ -1010,53 +1010,53 @@ bool Map::LoadMMF(const std::string& map_file_name, bool force_mmf_overwrite) std::string mmf_file_name = map_file_name; strip_map_extension(mmf_file_name); if (!add_mmf_extension(mmf_file_name)) { - Log.Out(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s'", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s'", mmf_file_name.c_str()); return false; } FILE *f = fopen(mmf_file_name.c_str(), "rb"); if (!f) { - Log.Out(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - could not open file", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - could not open file", mmf_file_name.c_str()); return false; } uint32 file_version; if (fread(&file_version, sizeof(uint32), 1, f) != 1) { fclose(f); - Log.Out(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - f@file_version", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - f@file_version", mmf_file_name.c_str()); return false; } uint32 rm_buffer_size; if (fread(&rm_buffer_size, sizeof(uint32), 1, f) != 1) { fclose(f); - Log.Out(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - f@rm_buffer_size", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - f@rm_buffer_size", mmf_file_name.c_str()); return false; } uint32 rm_buffer_crc32; if (fread(&rm_buffer_crc32, sizeof(uint32), 1, f) != 1) { fclose(f); - Log.Out(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - f@rm_buffer_crc32", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - f@rm_buffer_crc32", mmf_file_name.c_str()); return false; } if (rm_buffer_crc32 != /*crc32_check*/ 0) { fclose(f); - Log.Out(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - bad rm_buffer checksum", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - bad rm_buffer checksum", mmf_file_name.c_str()); return false; } uint32 mmf_buffer_size; if (fread(&mmf_buffer_size, sizeof(uint32), 1, f) != 1) { fclose(f); - Log.Out(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - f@mmf_buffer_size", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - f@mmf_buffer_size", mmf_file_name.c_str()); return false; } std::vector mmf_buffer(mmf_buffer_size); if (fread(mmf_buffer.data(), mmf_buffer_size, 1, f) != 1) { fclose(f); - Log.Out(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - f@mmf_buffer", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - f@mmf_buffer", mmf_file_name.c_str()); return false; } @@ -1083,7 +1083,7 @@ bool Map::LoadMMF(const std::string& map_file_name, bool force_mmf_overwrite) if (!imp->rm) { delete imp; imp = nullptr; - Log.Out(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - null RaycastMesh", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to load Map MMF file: '%s' - null RaycastMesh", mmf_file_name.c_str()); return false; } @@ -1093,14 +1093,14 @@ bool Map::LoadMMF(const std::string& map_file_name, bool force_mmf_overwrite) bool Map::SaveMMF(const std::string& map_file_name, bool force_mmf_overwrite) { if (!imp || !imp->rm) { - Log.Out(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file - No implementation (map_file_name: '%s')", map_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file - No implementation (map_file_name: '%s')", map_file_name.c_str()); return false; } std::string mmf_file_name = map_file_name; strip_map_extension(mmf_file_name); if (!add_mmf_extension(mmf_file_name)) { - Log.Out(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s'", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s'", mmf_file_name.c_str()); return false; } @@ -1114,7 +1114,7 @@ bool Map::SaveMMF(const std::string& map_file_name, bool force_mmf_overwrite) std::vector rm_buffer; // size set in MyRaycastMesh::serialize() serializeRaycastMesh(imp->rm, rm_buffer); if (rm_buffer.empty()) { - Log.Out(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - empty RaycastMesh buffer", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - empty RaycastMesh buffer", mmf_file_name.c_str()); return false; } @@ -1125,13 +1125,13 @@ bool Map::SaveMMF(const std::string& map_file_name, bool force_mmf_overwrite) mmf_buffer_size = DeflateData(rm_buffer.data(), rm_buffer.size(), mmf_buffer.data(), mmf_buffer.size()); if (!mmf_buffer_size) { - Log.Out(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - null MMF buffer size", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - null MMF buffer size", mmf_file_name.c_str()); return false; } f = fopen(mmf_file_name.c_str(), "wb"); if (!f) { - Log.Out(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - could not open file", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - could not open file", mmf_file_name.c_str()); return false; } @@ -1139,14 +1139,14 @@ bool Map::SaveMMF(const std::string& map_file_name, bool force_mmf_overwrite) if (fwrite(&file_version, sizeof(uint32), 1, f) != 1) { fclose(f); std::remove(mmf_file_name.c_str()); - Log.Out(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - f@file_version", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - f@file_version", mmf_file_name.c_str()); return false; } if (fwrite(&rm_buffer_size, sizeof(uint32), 1, f) != 1) { fclose(f); std::remove(mmf_file_name.c_str()); - Log.Out(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - f@rm_buffer_size", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - f@rm_buffer_size", mmf_file_name.c_str()); return false; } @@ -1154,21 +1154,21 @@ bool Map::SaveMMF(const std::string& map_file_name, bool force_mmf_overwrite) if (fwrite(&rm_buffer_crc32, sizeof(uint32), 1, f) != 1) { fclose(f); std::remove(mmf_file_name.c_str()); - Log.Out(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - f@rm_buffer_crc32", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - f@rm_buffer_crc32", mmf_file_name.c_str()); return false; } if (fwrite(&mmf_buffer_size, sizeof(uint32), 1, f) != 1) { fclose(f); std::remove(mmf_file_name.c_str()); - Log.Out(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - f@mmf_buffer_size", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - f@mmf_buffer_size", mmf_file_name.c_str()); return false; } if (fwrite(mmf_buffer.data(), mmf_buffer_size, 1, f) != 1) { fclose(f); std::remove(mmf_file_name.c_str()); - Log.Out(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - f@mmf_buffer", mmf_file_name.c_str()); + Log(Logs::General, Logs::Zone_Server, "Failed to save Map MMF file: '%s' - f@mmf_buffer", mmf_file_name.c_str()); return false; } diff --git a/zone/merc.cpp b/zone/merc.cpp index af533b64b..9da9d69c9 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -897,7 +897,7 @@ int32 Merc::CalcMaxMana() break; } default: { - Log.Out(Logs::General, Logs::None, "Invalid Class '%c' in CalcMaxMana", GetCasterClass()); + Log(Logs::General, Logs::None, "Invalid Class '%c' in CalcMaxMana", GetCasterClass()); max_mana = 0; break; } @@ -918,7 +918,7 @@ int32 Merc::CalcMaxMana() } #if EQDEBUG >= 11 - Log.Out(Logs::General, Logs::None, "Merc::CalcMaxMana() called for %s - returning %d", GetName(), max_mana); + Log(Logs::General, Logs::None, "Merc::CalcMaxMana() called for %s - returning %d", GetName(), max_mana); #endif return max_mana; } @@ -1708,7 +1708,7 @@ void Merc::AI_Process() { if (AI_movement_timer->Check()) { if(!IsRooted()) { - Log.Out(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", GetTarget()->GetCleanName()); + Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", GetTarget()->GetCleanName()); CalculateNewPosition2(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), GetRunspeed()); return; } @@ -1836,7 +1836,7 @@ bool Merc::AI_EngagedCastCheck() { { AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. - Log.Out(Logs::Detail, Logs::AI, "Merc Engaged autocast check triggered"); + Log(Logs::Detail, Logs::AI, "Merc Engaged autocast check triggered"); int8 mercClass = GetClass(); @@ -1891,7 +1891,7 @@ bool Merc::AI_IdleCastCheck() { if (AIautocastspell_timer->Check(false)) { #if MercAI_DEBUG_Spells >= 25 - Log.Out(Logs::Detail, Logs::AI, "Merc Non-Engaged autocast check triggered: %s", this->GetCleanName()); + Log(Logs::Detail, Logs::AI, "Merc Non-Engaged autocast check triggered: %s", this->GetCleanName()); #endif AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. @@ -1943,7 +1943,7 @@ bool EntityList::Merc_AICheckCloseBeneficialSpells(Merc* caster, uint8 iChance, // according to Rogean, Live NPCs will just cast through walls/floors, no problem.. // // This check was put in to address an idle-mob CPU issue - Log.Out(Logs::General, Logs::Error, "Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); + Log(Logs::General, Logs::Error, "Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); return(false); } @@ -2310,7 +2310,7 @@ bool Merc::AICastSpell(int8 iChance, uint32 iSpellTypes) { if(CheckAETaunt()) { //get AE taunt selectedMercSpell = GetBestMercSpellForAETaunt(this); - Log.Out(Logs::General, Logs::Mercenaries, "%s AE Taunting.", GetName()); + Log(Logs::General, Logs::Mercenaries, "%s AE Taunting.", GetName()); } if(selectedMercSpell.spellid == 0 && CheckTaunt()) { @@ -4209,7 +4209,7 @@ bool Merc::CheckAETaunt() { } if(result >= 1) { - Log.Out(Logs::General, Logs::Mercenaries, "%s: Attempting AE Taunt", GetCleanName()); + Log(Logs::General, Logs::Mercenaries, "%s: Attempting AE Taunt", GetCleanName()); return true; } } @@ -4518,7 +4518,7 @@ bool Merc::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, boo { if (!other) { SetTarget(nullptr); - Log.Out(Logs::General, Logs::Error, "A null Mob object was passed to Merc::Attack() for evaluation!"); + Log(Logs::General, Logs::Error, "A null Mob object was passed to Merc::Attack() for evaluation!"); return false; } @@ -4876,7 +4876,7 @@ Merc* Merc::LoadMerc(Client *c, MercTemplate* merc_template, uint32 merchant_id, merc->LoadMercSpells(); } - Log.Out(Logs::General, Logs::Mercenaries, "LoadMerc Successful for %s (%s).", merc->GetName(), c->GetName()); + Log(Logs::General, Logs::Mercenaries, "LoadMerc Successful for %s (%s).", merc->GetName(), c->GetName()); return merc; } } @@ -4908,7 +4908,7 @@ void Merc::UpdateMercInfo(Client *c) { void Merc::UpdateMercStats(Client *c, bool setmax) { if (c->GetMercInfo().MercTemplateID > 0) { - Log.Out(Logs::General, Logs::Mercenaries, "Updating Mercenary Stats for %s (%s).", GetName(), + Log(Logs::General, Logs::Mercenaries, "Updating Mercenary Stats for %s (%s).", GetName(), c->GetName()); const NPCType *npc_type = database.GetMercType( zone->GetMercTemplate(c->GetMercInfo().MercTemplateID)->MercNPCID, GetRace(), c->GetLevel()); @@ -4961,7 +4961,7 @@ void Merc::UpdateMercStats(Client *c, bool setmax) void Merc::ScaleStats(int scalepercent, bool setmax) { - Log.Out(Logs::General, Logs::Mercenaries, "Scaling Mercenary Stats to %d Percent for %s.", scalepercent, GetName()); + Log(Logs::General, Logs::Mercenaries, "Scaling Mercenary Stats to %d Percent for %s.", scalepercent, GetName()); if (scalepercent <= 0) return; @@ -5154,7 +5154,7 @@ bool Merc::Spawn(Client *owner) { SendPosition(); - Log.Out(Logs::General, Logs::Mercenaries, "Spawn Mercenary %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "Spawn Mercenary %s.", GetName()); //UpdateMercAppearance(); @@ -5300,7 +5300,7 @@ void Client::SendMercResponsePackets(uint32 ResponseType) SendMercMerchantResponsePacket(3); break; } - Log.Out(Logs::General, Logs::Mercenaries, "SendMercResponsePackets %i for %s.", ResponseType, GetName()); + Log(Logs::General, Logs::Mercenaries, "SendMercResponsePackets %i for %s.", ResponseType, GetName()); } @@ -5342,7 +5342,7 @@ void Client::UpdateMercTimer() SendMercResponsePackets(16); } - Log.Out(Logs::General, Logs::Mercenaries, "UpdateMercTimer Complete for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "UpdateMercTimer Complete for %s.", GetName()); // Normal upkeep charge message //Message(7, "You have been charged a mercenary upkeep cost of %i plat, and %i gold and your mercenary upkeep cost timer has been reset to 15 minutes.", upkeep_plat, upkeep_gold, (int)(RuleI(Mercs, UpkeepIntervalMS) / 1000 / 60)); @@ -5395,7 +5395,7 @@ bool Client::CheckCanHireMerc(Mob* merchant, uint32 template_id) { } } - Log.Out(Logs::General, Logs::Mercenaries, "CheckCanHireMerc True for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "CheckCanHireMerc True for %s.", GetName()); return true; } @@ -5468,7 +5468,7 @@ bool Client::CheckCanSpawnMerc(uint32 template_id) { return false; } - Log.Out(Logs::General, Logs::Mercenaries, "CheckCanSpawnMerc True for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "CheckCanSpawnMerc True for %s.", GetName()); return true; } @@ -5490,7 +5490,7 @@ bool Client::CheckCanUnsuspendMerc() { return false; } - Log.Out(Logs::General, Logs::Mercenaries, "CheckCanUnsuspendMerc True for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "CheckCanUnsuspendMerc True for %s.", GetName()); return true; } @@ -5505,7 +5505,7 @@ void Client::CheckMercSuspendTimer() { GetMercInfo().SuspendedTime = 0; SendMercResponsePackets(0); SendMercSuspendResponsePacket(GetMercInfo().SuspendedTime); - Log.Out(Logs::General, Logs::Mercenaries, "CheckMercSuspendTimer Ready for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "CheckMercSuspendTimer Ready for %s.", GetName()); } } } @@ -5518,7 +5518,7 @@ void Client::SuspendMercCommand() { { if(!CheckCanUnsuspendMerc()) { - Log.Out(Logs::General, Logs::Mercenaries, "SuspendMercCommand Unable to Unsuspend Merc for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SuspendMercCommand Unable to Unsuspend Merc for %s.", GetName()); return; } @@ -5528,13 +5528,13 @@ void Client::SuspendMercCommand() { if(merc) { SpawnMerc(merc, false); - Log.Out(Logs::General, Logs::Mercenaries, "SuspendMercCommand Successful Unsuspend for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SuspendMercCommand Successful Unsuspend for %s.", GetName()); } else { //merc failed to spawn SendMercResponsePackets(3); - Log.Out(Logs::General, Logs::Mercenaries, "SuspendMercCommand Failed to Spawn Merc for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SuspendMercCommand Failed to Spawn Merc for %s.", GetName()); } } else @@ -5553,7 +5553,7 @@ void Client::SuspendMercCommand() { if(CurrentMerc && GetMercID()) { CurrentMerc->Suspend(); - Log.Out(Logs::General, Logs::Mercenaries, "SuspendMercCommand Successful Suspend for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SuspendMercCommand Successful Suspend for %s.", GetName()); } else { @@ -5565,14 +5565,14 @@ void Client::SuspendMercCommand() { GetMercTimer()->Disable(); SendMercSuspendResponsePacket(GetMercInfo().SuspendedTime); SendMercTimer(nullptr); - Log.Out(Logs::General, Logs::Mercenaries, "SuspendMercCommand Failed to Get Merc to Suspend. Resetting Suspend State for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SuspendMercCommand Failed to Get Merc to Suspend. Resetting Suspend State for %s.", GetName()); } } } else { SpawnMercOnZone(); - Log.Out(Logs::General, Logs::Mercenaries, "SuspendMercCommand Request Failed to Load Merc for %s. Trying SpawnMercOnZone.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SuspendMercCommand Request Failed to Load Merc for %s. Trying SpawnMercOnZone.", GetName()); } } @@ -5605,7 +5605,7 @@ void Client::SpawnMercOnZone() { { SpawnMerc(merc, false); } - Log.Out(Logs::General, Logs::Mercenaries, "SpawnMercOnZone Normal Merc for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SpawnMercOnZone Normal Merc for %s.", GetName()); } else { @@ -5621,7 +5621,7 @@ void Client::SpawnMercOnZone() { // Send Mercenary Status/Timer packet SendMercTimer(GetMerc()); - Log.Out(Logs::General, Logs::Mercenaries, "SpawnMercOnZone Suspended Merc for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SpawnMercOnZone Suspended Merc for %s.", GetName()); } } else @@ -5629,7 +5629,7 @@ void Client::SpawnMercOnZone() { // No Merc Hired // RoF+ displays a message from the following packet, which seems useless //SendClearMercInfo(); - Log.Out(Logs::General, Logs::Mercenaries, "SpawnMercOnZone Failed to load Merc Info from the Database for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SpawnMercOnZone Failed to load Merc Info from the Database for %s.", GetName()); } } @@ -5643,17 +5643,17 @@ void Client::SendMercTimer(Merc* merc) { if (!merc) { SendMercTimerPacket(NO_MERC_ID, MERC_STATE_SUSPENDED, GetMercInfo().SuspendedTime, GetMercInfo().MercTimerRemaining, RuleI(Mercs, SuspendIntervalMS)); - Log.Out(Logs::General, Logs::Mercenaries, "SendMercTimer No Merc for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SendMercTimer No Merc for %s.", GetName()); } else if (merc->IsSuspended()) { SendMercTimerPacket(NO_MERC_ID, MERC_STATE_SUSPENDED, GetMercInfo().SuspendedTime, GetMercInfo().MercTimerRemaining, RuleI(Mercs, SuspendIntervalMS)); - Log.Out(Logs::General, Logs::Mercenaries, "SendMercTimer Suspended Merc for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SendMercTimer Suspended Merc for %s.", GetName()); } else { SendMercTimerPacket(merc->GetID(), MERC_STATE_NORMAL, NOT_SUSPENDED_TIME, GetMercInfo().MercTimerRemaining, RuleI(Mercs, SuspendIntervalMS)); - Log.Out(Logs::General, Logs::Mercenaries, "SendMercTimer Normal Merc for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SendMercTimer Normal Merc for %s.", GetName()); } } @@ -5675,7 +5675,7 @@ void Client::SpawnMerc(Merc* merc, bool setMaxStats) { merc->Unsuspend(setMaxStats); merc->SetStance(GetMercInfo().Stance); - Log.Out(Logs::General, Logs::Mercenaries, "SpawnMerc Success for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SpawnMerc Success for %s.", GetName()); return; @@ -5704,7 +5704,7 @@ bool Merc::Suspend() { // Start the timer to send the packet that refreshes the Unsuspend Button mercOwner->GetPTimers().Start(pTimerMercSuspend, RuleI(Mercs, SuspendIntervalS)); - Log.Out(Logs::General, Logs::Mercenaries, "Suspend Complete for %s.", mercOwner->GetName()); + Log(Logs::General, Logs::Mercenaries, "Suspend Complete for %s.", mercOwner->GetName()); return true; } @@ -5790,12 +5790,12 @@ bool Client::DismissMerc(uint32 MercID) { bool Dismissed = true; if (!database.DeleteMerc(MercID)) { - Log.Out(Logs::General, Logs::Mercenaries, "Dismiss Failed Database Query for MercID: %i, Client: %s.", MercID, GetName()); + Log(Logs::General, Logs::Mercenaries, "Dismiss Failed Database Query for MercID: %i, Client: %s.", MercID, GetName()); Dismissed = false; } else { - Log.Out(Logs::General, Logs::Mercenaries, "Dismiss Successful for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "Dismiss Successful for %s.", GetName()); } if (GetMerc()) @@ -5952,13 +5952,13 @@ bool Merc::MercJoinClientGroup() { database.SetGroupLeaderName(g->GetID(), mercOwner->GetName()); database.RefreshGroupFromDB(mercOwner); g->SaveGroupLeaderAA(); - Log.Out(Logs::General, Logs::Mercenaries, "Mercenary joined new group: %s (%s).", GetName(), mercOwner->GetName()); + Log(Logs::General, Logs::Mercenaries, "Mercenary joined new group: %s (%s).", GetName(), mercOwner->GetName()); } else { g->DisbandGroup(); Suspend(); - Log.Out(Logs::General, Logs::Mercenaries, "Mercenary disbanded new group: %s (%s).", GetName(), mercOwner->GetName()); + Log(Logs::General, Logs::Mercenaries, "Mercenary disbanded new group: %s (%s).", GetName(), mercOwner->GetName()); } } @@ -5968,12 +5968,12 @@ bool Merc::MercJoinClientGroup() { database.RefreshGroupFromDB(mercOwner); // Update members that are out of zone GetGroup()->SendGroupJoinOOZ(this); - Log.Out(Logs::General, Logs::Mercenaries, "Mercenary %s joined existing group with %s.", GetName(), mercOwner->GetName()); + Log(Logs::General, Logs::Mercenaries, "Mercenary %s joined existing group with %s.", GetName(), mercOwner->GetName()); } else { Suspend(); - Log.Out(Logs::General, Logs::Mercenaries, "Mercenary failed to join the group - Suspending %s for (%s).", GetName(), mercOwner->GetName()); + Log(Logs::General, Logs::Mercenaries, "Mercenary failed to join the group - Suspending %s for (%s).", GetName(), mercOwner->GetName()); } } @@ -6024,7 +6024,7 @@ Merc* Client::GetMerc() { if(GetMercID() == 0) { - Log.Out(Logs::Detail, Logs::Mercenaries, "GetMerc - GetMercID: 0 for %s.", GetName()); + Log(Logs::Detail, Logs::Mercenaries, "GetMerc - GetMercID: 0 for %s.", GetName()); return (nullptr); } @@ -6032,14 +6032,14 @@ Merc* Client::GetMerc() { if(tmp == nullptr) { SetMercID(0); - Log.Out(Logs::Detail, Logs::Mercenaries, "GetMerc No Merc for %s.", GetName()); + Log(Logs::Detail, Logs::Mercenaries, "GetMerc No Merc for %s.", GetName()); return (nullptr); } if(tmp->GetOwnerID() != GetID()) { SetMercID(0); - Log.Out(Logs::Detail, Logs::Mercenaries, "GetMerc Owner Mismatch - OwnerID: %d, ClientID: %d, Client: %s.", tmp->GetOwnerID(), GetID(), GetName()); + Log(Logs::Detail, Logs::Mercenaries, "GetMerc Owner Mismatch - OwnerID: %d, ClientID: %d, Client: %s.", tmp->GetOwnerID(), GetID(), GetName()); return (nullptr); } @@ -6057,7 +6057,7 @@ uint8 Client::GetNumMercs() { numMercs++; } } - Log.Out(Logs::General, Logs::Mercenaries, "GetNumMercs Number: %i for %s.", numMercs, GetName()); + Log(Logs::General, Logs::Mercenaries, "GetNumMercs Number: %i for %s.", numMercs, GetName()); return numMercs; } @@ -6098,7 +6098,7 @@ void Client::SetMerc(Merc* newmerc) { GetMercInfo().Gender = 0; GetMercInfo().State = 0; memset(GetMercInfo().merc_name, 0, 64); - Log.Out(Logs::General, Logs::Mercenaries, "SetMerc No Merc for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SetMerc No Merc for %s.", GetName()); } else { @@ -6115,7 +6115,7 @@ void Client::SetMerc(Merc* newmerc) { GetMercInfo().Gender = newmerc->GetGender(); GetMercInfo().State = newmerc->IsSuspended() ? MERC_STATE_SUSPENDED : MERC_STATE_NORMAL; snprintf(GetMercInfo().merc_name, 64, "%s", newmerc->GetName()); - Log.Out(Logs::General, Logs::Mercenaries, "SetMerc New Merc for %s.", GetName()); + Log(Logs::General, Logs::Mercenaries, "SetMerc New Merc for %s.", GetName()); } } @@ -6136,7 +6136,7 @@ void Client::SendMercMerchantResponsePacket(int32 response_type) { MercenaryMerchantResponse_Struct* mmr = (MercenaryMerchantResponse_Struct*)outapp->pBuffer; mmr->ResponseType = response_type; // send specified response type FastQueuePacket(&outapp); - Log.Out(Logs::Moderate, Logs::Mercenaries, "Sent SendMercMerchantResponsePacket ResponseType: %i, Client: %s.", response_type, GetName()); + Log(Logs::Moderate, Logs::Mercenaries, "Sent SendMercMerchantResponsePacket ResponseType: %i, Client: %s.", response_type, GetName()); } } @@ -6145,7 +6145,7 @@ void Client::SendMercenaryUnknownPacket(uint8 type) { auto outapp = new EQApplicationPacket(OP_MercenaryUnknown1, 1); outapp->WriteUInt8(type); FastQueuePacket(&outapp); - Log.Out(Logs::Moderate, Logs::Mercenaries, "Sent SendMercenaryUnknownPacket Type: %i, Client: %s.", type, GetName()); + Log(Logs::Moderate, Logs::Mercenaries, "Sent SendMercenaryUnknownPacket Type: %i, Client: %s.", type, GetName()); } @@ -6154,7 +6154,7 @@ void Client::SendMercenaryUnsuspendPacket(uint8 type) { auto outapp = new EQApplicationPacket(OP_MercenaryUnsuspendResponse, 1); outapp->WriteUInt8(type); FastQueuePacket(&outapp); - Log.Out(Logs::Moderate, Logs::Mercenaries, "Sent SendMercenaryUnsuspendPacket Type: %i, Client: %s.", type, GetName()); + Log(Logs::Moderate, Logs::Mercenaries, "Sent SendMercenaryUnsuspendPacket Type: %i, Client: %s.", type, GetName()); } @@ -6164,7 +6164,7 @@ void Client::SendMercSuspendResponsePacket(uint32 suspended_time) { SuspendMercenaryResponse_Struct* smr = (SuspendMercenaryResponse_Struct*)outapp->pBuffer; smr->SuspendTime = suspended_time; // Seen 0 (not suspended) or c9 c2 64 4f (suspended on Sat Mar 17 11:58:49 2012) - Unix Timestamp FastQueuePacket(&outapp); - Log.Out(Logs::Moderate, Logs::Mercenaries, "Sent SendMercSuspendResponsePacket Time: %i, Client: %s.", suspended_time, GetName()); + Log(Logs::Moderate, Logs::Mercenaries, "Sent SendMercSuspendResponsePacket Time: %i, Client: %s.", suspended_time, GetName()); } @@ -6179,7 +6179,7 @@ void Client::SendMercTimerPacket(int32 entity_id, int32 merc_state, int32 suspen mss->UpdateInterval = update_interval; // Seen 900000 - 15 minutes in ms mss->MercUnk01 = unk01; // Seen 180000 - 3 minutes in ms - Used for the unsuspend button refresh timer FastQueuePacket(&outapp); - Log.Out(Logs::Moderate, Logs::Mercenaries, "Sent SendMercTimerPacket EndID: %i, State: %i, SuspendTime: %i, Interval: %i, Unk1: %i, Client: %s.", entity_id, merc_state, suspended_time, update_interval, unk01, GetName()); + Log(Logs::Moderate, Logs::Mercenaries, "Sent SendMercTimerPacket EndID: %i, State: %i, SuspendTime: %i, Interval: %i, Unk1: %i, Client: %s.", entity_id, merc_state, suspended_time, update_interval, unk01, GetName()); } @@ -6190,7 +6190,7 @@ void Client::SendMercAssignPacket(uint32 entityID, uint32 unk01, uint32 unk02) { mas->MercUnk01 = unk01; mas->MercUnk02 = unk02; FastQueuePacket(&outapp); - Log.Out(Logs::Moderate, Logs::Mercenaries, "Sent SendMercAssignPacket EndID: %i, Unk1: %i, Unk2: %i, Client: %s.", entityID, unk01, unk02, GetName()); + Log(Logs::Moderate, Logs::Mercenaries, "Sent SendMercAssignPacket EndID: %i, Unk1: %i, Unk2: %i, Client: %s.", entityID, unk01, unk02, GetName()); } void NPC::LoadMercTypes() { @@ -6205,7 +6205,7 @@ void NPC::LoadMercTypes() { auto results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error in NPC::LoadMercTypes()"); + Log(Logs::General, Logs::Error, "Error in NPC::LoadMercTypes()"); return; } @@ -6238,7 +6238,7 @@ void NPC::LoadMercs() { if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error in NPC::LoadMercTypes()"); + Log(Logs::General, Logs::Error, "Error in NPC::LoadMercTypes()"); return; } diff --git a/zone/mob.cpp b/zone/mob.cpp index de4d8bb3f..d219a27af 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -1382,7 +1382,8 @@ void Mob::SendHPUpdate(bool skip_self) // send to self - we need the actual hps here if(IsClient() && (!skip_self || dospam)) { - this->CastToClient()->SendHPUpdateMarquee(); + if (RuleB(Character, MarqueeHPUpdates)) + this->CastToClient()->SendHPUpdateMarquee(); auto hp_app2 = new EQApplicationPacket(OP_HPUpdate, sizeof(SpawnHPUpdate_Struct)); SpawnHPUpdate_Struct* ds = (SpawnHPUpdate_Struct*)hp_app2->pBuffer; @@ -1800,7 +1801,7 @@ void Mob::SendIllusionPacket(uint16 in_race, uint8 in_gender, uint8 in_texture, /* Refresh armor and tints after send illusion packet */ this->SendArmorAppearance(); - Log.Out(Logs::Detail, Logs::Spells, "Illusion: Race = %i, Gender = %i, Texture = %i, HelmTexture = %i, HairColor = %i, BeardColor = %i, EyeColor1 = %i, EyeColor2 = %i, HairStyle = %i, Face = %i, DrakkinHeritage = %i, DrakkinTattoo = %i, DrakkinDetails = %i, Size = %f", + Log(Logs::Detail, Logs::Spells, "Illusion: Race = %i, Gender = %i, Texture = %i, HelmTexture = %i, HairColor = %i, BeardColor = %i, EyeColor1 = %i, EyeColor2 = %i, HairStyle = %i, Face = %i, DrakkinHeritage = %i, DrakkinTattoo = %i, DrakkinDetails = %i, Size = %f", race, gender, texture, helmtexture, haircolor, beardcolor, eyecolor1, eyecolor2, hairstyle, luclinface, drakkin_heritage, drakkin_tattoo, drakkin_details, size); } @@ -3255,7 +3256,7 @@ void Mob::ExecWeaponProc(const EQEmu::ItemInstance *inst, uint16 spell_id, Mob * if(!IsValidSpell(spell_id)) { // Check for a valid spell otherwise it will crash through the function if(IsClient()){ Message(0, "Invalid spell proc %u", spell_id); - Log.Out(Logs::Detail, Logs::Spells, "Player %s, Weapon Procced invalid spell %u", this->GetName(), spell_id); + Log(Logs::Detail, Logs::Spells, "Player %s, Weapon Procced invalid spell %u", this->GetName(), spell_id); } return; } @@ -4782,7 +4783,7 @@ void Mob::MeleeLifeTap(int32 damage) { if(lifetap_amt && damage > 0){ lifetap_amt = damage * lifetap_amt / 100; - Log.Out(Logs::Detail, Logs::Combat, "Melee lifetap healing for %d damage.", damage); + Log(Logs::Detail, Logs::Combat, "Melee lifetap healing for %d damage.", damage); if (lifetap_amt > 0) HealDamage(lifetap_amt); //Heal self for modified damage amount. diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index fce52d2de..0c8db2938 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -99,7 +99,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes) { ) { #if MobAI_DEBUG_Spells >= 21 - Log.Out(Logs::Detail, Logs::AI, "Mob::AICastSpell: Casting: spellid=%u, tar=%s, dist2[%f]<=%f, mana_cost[%i]<=%i, cancast[%u]<=%u, type=%u", + Log(Logs::Detail, Logs::AI, "Mob::AICastSpell: Casting: spellid=%u, tar=%s, dist2[%f]<=%f, mana_cost[%i]<=%i, cancast[%u]<=%u, type=%u", AIspells[i].spellid, tar->GetName(), dist2, (spells[AIspells[i].spellid].range * spells[AIspells[i].spellid].range), mana_cost, GetMana(), AIspells[i].time_cancast, Timer::GetCurrentTime(), AIspells[i].type); #endif @@ -321,7 +321,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes) { } #if MobAI_DEBUG_Spells >= 21 else { - Log.Out(Logs::Detail, Logs::AI, "Mob::AICastSpell: NotCasting: spellid=%u, tar=%s, dist2[%f]<=%f, mana_cost[%i]<=%i, cancast[%u]<=%u, type=%u", + Log(Logs::Detail, Logs::AI, "Mob::AICastSpell: NotCasting: spellid=%u, tar=%s, dist2[%f]<=%f, mana_cost[%i]<=%i, cancast[%u]<=%u, type=%u", AIspells[i].spellid, tar->GetName(), dist2, (spells[AIspells[i].spellid].range * spells[AIspells[i].spellid].range), mana_cost, GetMana(), AIspells[i].time_cancast, Timer::GetCurrentTime(), AIspells[i].type); } #endif @@ -332,7 +332,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes) { bool NPC::AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgainBefore) { #if MobAI_DEBUG_Spells >= 1 - Log.Out(Logs::Detail, Logs::AI, "Mob::AIDoSpellCast: spellid = %u, tar = %s, mana = %i, Name: '%s'", AIspells[i].spellid, tar->GetName(), mana_cost, spells[AIspells[i].spellid].name); + Log(Logs::Detail, Logs::AI, "Mob::AIDoSpellCast: spellid = %u, tar = %s, mana = %i, Name: '%s'", AIspells[i].spellid, tar->GetName(), mana_cost, spells[AIspells[i].spellid].name); #endif casting_spell_AIindex = i; @@ -351,7 +351,7 @@ bool EntityList::AICheckCloseBeneficialSpells(NPC* caster, uint8 iChance, float // according to Rogean, Live NPCs will just cast through walls/floors, no problem.. // // This check was put in to address an idle-mob CPU issue - Log.Out(Logs::General, Logs::Error, "Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); + Log(Logs::General, Logs::Error, "Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); return(false); } @@ -989,8 +989,8 @@ void Mob::AI_Process() { CastToNPC()->CheckSignal(); } - if (engaged) - { + if (engaged) { + if (!(m_PlayerState & static_cast(PlayerState::Aggressive))) SendAddPlayerState(PlayerState::Aggressive); // we are prevented from getting here if we are blind and don't have a target in range @@ -1017,8 +1017,7 @@ void Mob::AI_Process() { if (!target) return; - if (target->IsCorpse()) - { + if (target->IsCorpse()) { RemoveFromHateList(this); return; } @@ -1035,6 +1034,8 @@ void Mob::AI_Process() { if (DivineAura()) return; + ProjectileAttack(); + auto npcSpawnPoint = CastToNPC()->GetSpawnPoint(); if (GetSpecialAbility(TETHER)) { float tether_range = static_cast(GetSpecialAbilityParam(TETHER, 0)); @@ -1233,6 +1234,7 @@ void Mob::AI_Process() { } AI_EngagedCastCheck(); + } //end is within combat rangepet else { //we cannot reach our target... @@ -1271,7 +1273,7 @@ void Mob::AI_Process() { else if (AI_movement_timer->Check()) { if (!IsRooted()) { - Log.Out(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", target->GetName()); + Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", target->GetName()); if (!RuleB(Pathing, Aggro) || !zone->pathing) CalculateNewPosition2(target->GetX(), target->GetY(), target->GetZ(), GetRunspeed()); else @@ -1506,7 +1508,7 @@ void NPC::AI_DoMovement() { roambox_movingto_y = zone->random.Real(roambox_min_y+1,roambox_max_y-1); } - Log.Out(Logs::Detail, Logs::AI, "Roam Box: d=%.3f (%.3f->%.3f,%.3f->%.3f): Go To (%.3f,%.3f)", + Log(Logs::Detail, Logs::AI, "Roam Box: d=%.3f (%.3f->%.3f,%.3f->%.3f): Go To (%.3f,%.3f)", roambox_distance, roambox_min_x, roambox_max_x, roambox_min_y, roambox_max_y, roambox_movingto_x, roambox_movingto_y); if (!CalculateNewPosition2(roambox_movingto_x, roambox_movingto_y, GetZ(), walksp, true)) { @@ -1536,7 +1538,7 @@ void NPC::AI_DoMovement() { bool doMove = true; if (m_CurrentWayPoint.x == GetX() && m_CurrentWayPoint.y == GetY()) { // are we there yet? then stop - Log.Out(Logs::Detail, Logs::AI, "We have reached waypoint %d (%.3f,%.3f,%.3f) on grid %d", cur_wp, GetX(), GetY(), GetZ(), GetGrid()); + Log(Logs::Detail, Logs::AI, "We have reached waypoint %d (%.3f,%.3f,%.3f) on grid %d", cur_wp, GetX(), GetY(), GetZ(), GetGrid()); SetWaypointPause(); SetAppearance(eaStanding, false); @@ -1587,7 +1589,7 @@ void NPC::AI_DoMovement() { if (movetimercompleted==true) { // time to pause has ended SetGrid( 0 - GetGrid()); // revert to AI control - Log.Out(Logs::Detail, Logs::Pathing, "Quest pathing is finished. Resuming on grid %d", GetGrid()); + Log(Logs::Detail, Logs::Pathing, "Quest pathing is finished. Resuming on grid %d", GetGrid()); SetAppearance(eaStanding, false); @@ -1622,7 +1624,7 @@ void NPC::AI_DoMovement() { if (!CP2Moved) { if(moved) { - Log.Out(Logs::Detail, Logs::AI, "Reached guard point (%.3f,%.3f,%.3f)", m_GuardPoint.x, m_GuardPoint.y, m_GuardPoint.z); + Log(Logs::Detail, Logs::AI, "Reached guard point (%.3f,%.3f,%.3f)", m_GuardPoint.x, m_GuardPoint.y, m_GuardPoint.z); ClearFeignMemory(); moved=false; if (GetTarget() == nullptr || DistanceSquared(m_Position, GetTarget()->GetPosition()) >= 5*5 ) @@ -1668,11 +1670,11 @@ void NPC::AI_SetupNextWaypoint() { else { movetimercompleted = false; - Log.Out(Logs::Detail, Logs::Pathing, "We are departing waypoint %d.", cur_wp); + Log(Logs::Detail, Logs::Pathing, "We are departing waypoint %d.", cur_wp); //if we were under quest control (with no grid), we are done now.. if (cur_wp == -2) { - Log.Out(Logs::Detail, Logs::Pathing, "Non-grid quest mob has reached its quest ordered waypoint. Leaving pathing mode."); + Log(Logs::Detail, Logs::Pathing, "Non-grid quest mob has reached its quest ordered waypoint. Leaving pathing mode."); roamer = false; cur_wp = 0; } @@ -1809,7 +1811,7 @@ bool NPC::AI_EngagedCastCheck() { if (AIautocastspell_timer->Check(false)) { AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. - Log.Out(Logs::Detail, Logs::AI, "Engaged autocast check triggered. Trying to cast healing spells then maybe offensive spells."); + Log(Logs::Detail, Logs::AI, "Engaged autocast check triggered. Trying to cast healing spells then maybe offensive spells."); // try casting a heal or gate if (!AICastSpell(this, AISpellVar.engaged_beneficial_self_chance, SpellType_Heal | SpellType_Escape | SpellType_InCombatBuff)) { @@ -1832,7 +1834,7 @@ bool NPC::AI_PursueCastCheck() { if (AIautocastspell_timer->Check(false)) { AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. - Log.Out(Logs::Detail, Logs::AI, "Engaged (pursuing) autocast check triggered. Trying to cast offensive spells."); + Log(Logs::Detail, Logs::AI, "Engaged (pursuing) autocast check triggered. Trying to cast offensive spells."); if(!AICastSpell(GetTarget(), AISpellVar.pursue_detrimental_chance, SpellType_Root | SpellType_Nuke | SpellType_Lifetap | SpellType_Snare | SpellType_DOT | SpellType_Dispel | SpellType_Mez | SpellType_Slow | SpellType_Debuff)) { //no spell cast, try again soon. AIautocastspell_timer->Start(RandomTimer(AISpellVar.pursue_no_sp_recast_min, AISpellVar.pursue_no_sp_recast_max), false); @@ -1851,7 +1853,7 @@ bool NPC::AI_IdleCastCheck() { //last duration it was set to... try to put up a more reasonable timer... AIautocastspell_timer->Start(RandomTimer(AISpellVar.idle_no_sp_recast_min, AISpellVar.idle_no_sp_recast_max), false); - Log.Out(Logs::Moderate, Logs::Spells, "Triggering AI_IdleCastCheck :: Mob %s - Min : %u Max : %u", this->GetCleanName(), AISpellVar.idle_no_sp_recast_min, AISpellVar.idle_no_sp_recast_max); + Log(Logs::Moderate, Logs::Spells, "Triggering AI_IdleCastCheck :: Mob %s - Min : %u Max : %u", this->GetCleanName(), AISpellVar.idle_no_sp_recast_min, AISpellVar.idle_no_sp_recast_max); } //else, spell casting finishing will reset the timer. } //else, spell casting finishing will reset the timer. @@ -2244,7 +2246,7 @@ bool NPC::AI_AddNPCSpells(uint32 iDBSpellsID) { else { debug_msg.append(" (not found)"); } - Log.Out(Logs::Detail, Logs::AI, "%s", debug_msg.c_str()); + Log(Logs::Detail, Logs::AI, "%s", debug_msg.c_str()); #endif uint16 attack_proc_spell = -1; int8 proc_chance = 3; @@ -2408,7 +2410,7 @@ bool NPC::AI_AddNPCSpellsEffects(uint32 iDBSpellsEffectsID) { else { debug_msg.append(" (not found)"); } - Log.Out(Logs::Detail, Logs::AI, "%s", debug_msg.c_str()); + Log(Logs::Detail, Logs::AI, "%s", debug_msg.c_str()); #endif if (parentlist) { diff --git a/zone/net.cpp b/zone/net.cpp index bc098c369..d4958b9a0 100644 --- a/zone/net.cpp +++ b/zone/net.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2016 EQEMu Development Team (http://eqemu.org) +Copyright (C) 2001-2016 EQEMu Development Team (http://eqemu.org) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define DONT_SHARED_OPCODES @@ -79,16 +79,16 @@ #include #ifdef _CRTDBG_MAP_ALLOC - #undef new - #define new new(_NORMAL_BLOCK, __FILE__, __LINE__) +#undef new +#define new new(_NORMAL_BLOCK, __FILE__, __LINE__) #endif #ifdef _WINDOWS - #include - #include +#include +#include #else - #include - #include "../common/unix.h" +#include +#include "../common/unix.h" #endif volatile bool RunLoops = true; @@ -105,7 +105,7 @@ TitleManager title_manager; QueryServ *QServ = 0; TaskManager *taskmanager = 0; QuestParserCollection *parse = 0; -EQEmuLogSys Log; +EQEmuLogSys LogSys; const SPDat_Spell_Struct* spells; int32 SPDAT_RECORDS = -1; const ZoneConfig *Config; @@ -115,10 +115,10 @@ void Shutdown(); extern void MapOpcodes(); int main(int argc, char** argv) { - RegisterExecutablePlatform(ExePlatformZone); - Log.LoadLogSettingsDefaults(); + RegisterExecutablePlatform(ExePlatformZone); + LogSys.LoadLogSettingsDefaults(); - set_exception_handler(); + set_exception_handler(); #ifdef USE_MAP_MMFS if (argc == 3 && strcasecmp(argv[1], "convert_map") == 0) { @@ -135,16 +135,16 @@ int main(int argc, char** argv) { auto success = m->Load(filename, true); delete m; std::cout << mapfile.c_str() << " conversion " << (success ? "succeeded" : "failed") << std::endl; - + return 0; } #endif /*USE_MAP_MMFS*/ QServ = new QueryServ; - Log.Out(Logs::General, Logs::Zone_Server, "Loading server configuration.."); - if(!ZoneConfig::LoadConfig()) { - Log.Out(Logs::General, Logs::Error, "Loading server configuration failed."); + Log(Logs::General, Logs::Zone_Server, "Loading server configuration.."); + if (!ZoneConfig::LoadConfig()) { + Log(Logs::General, Logs::Error, "Loading server configuration failed."); return 1; } Config = ZoneConfig::get(); @@ -152,81 +152,85 @@ int main(int argc, char** argv) { const char *zone_name; uint32 instance_id = 0; std::string z_name; - if(argc == 4) { + if (argc == 4) { instance_id = atoi(argv[3]); worldserver.SetLauncherName(argv[2]); auto zone_port = SplitString(argv[1], ':'); - if(!zone_port.empty()) { + if (!zone_port.empty()) { z_name = zone_port[0]; } - if(zone_port.size() > 1) { + if (zone_port.size() > 1) { std::string p_name = zone_port[1]; Config->SetZonePort(atoi(p_name.c_str())); } worldserver.SetLaunchedName(z_name.c_str()); - if(strncmp(z_name.c_str(), "dynamic_", 8) == 0) { + if (strncmp(z_name.c_str(), "dynamic_", 8) == 0) { zone_name = "."; } else { zone_name = z_name.c_str(); } - } else if(argc == 3) { + } + else if (argc == 3) { worldserver.SetLauncherName(argv[2]); auto zone_port = SplitString(argv[1], ':'); - if(!zone_port.empty()) { + if (!zone_port.empty()) { z_name = zone_port[0]; } - if(zone_port.size() > 1) { + if (zone_port.size() > 1) { std::string p_name = zone_port[1]; Config->SetZonePort(atoi(p_name.c_str())); } worldserver.SetLaunchedName(z_name.c_str()); - if(strncmp(z_name.c_str(), "dynamic_", 8) == 0) { - zone_name = "."; - } else { - zone_name = z_name.c_str(); - } - } else if (argc == 2) { - worldserver.SetLauncherName("NONE"); - auto zone_port = SplitString(argv[1], ':'); - - if(!zone_port.empty()) { - z_name = zone_port[0]; - } - - if(zone_port.size() > 1) { - std::string p_name = zone_port[1]; - Config->SetZonePort(atoi(p_name.c_str())); - } - - worldserver.SetLaunchedName(z_name.c_str()); - if(strncmp(z_name.c_str(), "dynamic_", 8) == 0) { + if (strncmp(z_name.c_str(), "dynamic_", 8) == 0) { zone_name = "."; } else { zone_name = z_name.c_str(); } - } else { + } + else if (argc == 2) { + worldserver.SetLauncherName("NONE"); + auto zone_port = SplitString(argv[1], ':'); + + if (!zone_port.empty()) { + z_name = zone_port[0]; + } + + if (zone_port.size() > 1) { + std::string p_name = zone_port[1]; + Config->SetZonePort(atoi(p_name.c_str())); + } + + worldserver.SetLaunchedName(z_name.c_str()); + if (strncmp(z_name.c_str(), "dynamic_", 8) == 0) { + zone_name = "."; + } + else { + zone_name = z_name.c_str(); + } + } + else { zone_name = "."; worldserver.SetLaunchedName("."); worldserver.SetLauncherName("NONE"); } - - Log.Out(Logs::General, Logs::Zone_Server, "Connecting to MySQL..."); + + Log(Logs::General, Logs::Zone_Server, "Connecting to MySQL..."); if (!database.Connect( Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(), Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) { - Log.Out(Logs::General, Logs::Error, "Cannot continue without a database connection."); + Log(Logs::General, Logs::Error, "Cannot continue without a database connection."); return 1; } @@ -237,148 +241,150 @@ int main(int argc, char** argv) { Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) { - Log.Out(Logs::General, Logs::Error, "Cannot continue without a bots database connection."); + Log(Logs::General, Logs::Error, "Cannot continue without a bots database connection."); return 1; } #endif /* Register Log System and Settings */ - Log.OnLogHookCallBackZone(&Zone::GMSayHookCallBackProcess); - database.LoadLogSettings(Log.log_settings); - Log.StartFileLogs(); + LogSys.OnLogHookCallBackZone(&Zone::GMSayHookCallBackProcess); + database.LoadLogSettings(LogSys.log_settings); + LogSys.StartFileLogs(); /* Guilds */ guild_mgr.SetDatabase(&database); GuildBanks = nullptr; #ifdef _EQDEBUG - _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif - Log.Out(Logs::General, Logs::Zone_Server, "CURRENT_VERSION: %s", CURRENT_VERSION); + Log(Logs::General, Logs::Zone_Server, "CURRENT_VERSION: %s", CURRENT_VERSION); /* * Setup nice signal handlers */ - if (signal(SIGINT, CatchSignal) == SIG_ERR) { - Log.Out(Logs::General, Logs::Error, "Could not set signal handler"); + if (signal(SIGINT, CatchSignal) == SIG_ERR) { + Log(Logs::General, Logs::Error, "Could not set signal handler"); return 1; } - if (signal(SIGTERM, CatchSignal) == SIG_ERR) { - Log.Out(Logs::General, Logs::Error, "Could not set signal handler"); + if (signal(SIGTERM, CatchSignal) == SIG_ERR) { + Log(Logs::General, Logs::Error, "Could not set signal handler"); return 1; } - #ifndef WIN32 - if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { - Log.Out(Logs::General, Logs::Error, "Could not set signal handler"); +#ifndef WIN32 + if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { + Log(Logs::General, Logs::Error, "Could not set signal handler"); return 1; } - #endif +#endif - Log.Out(Logs::General, Logs::Zone_Server, "Mapping Incoming Opcodes"); + Log(Logs::General, Logs::Zone_Server, "Mapping Incoming Opcodes"); MapOpcodes(); - Log.Out(Logs::General, Logs::Zone_Server, "Loading Variables"); + Log(Logs::General, Logs::Zone_Server, "Loading Variables"); database.LoadVariables(); std::string hotfix_name; - if(database.GetVariable("hotfix_name", hotfix_name)) { - if(!hotfix_name.empty()) { - Log.Out(Logs::General, Logs::Zone_Server, "Current hotfix in use: '%s'", hotfix_name.c_str()); + if (database.GetVariable("hotfix_name", hotfix_name)) { + if (!hotfix_name.empty()) { + Log(Logs::General, Logs::Zone_Server, "Current hotfix in use: '%s'", hotfix_name.c_str()); } } - Log.Out(Logs::General, Logs::Zone_Server, "Loading zone names"); + Log(Logs::General, Logs::Zone_Server, "Loading zone names"); database.LoadZoneNames(); - Log.Out(Logs::General, Logs::Zone_Server, "Loading items"); - if(!database.LoadItems(hotfix_name)) { - Log.Out(Logs::General, Logs::Error, "Loading items FAILED!"); - Log.Out(Logs::General, Logs::Error, "Failed. But ignoring error and going on..."); + Log(Logs::General, Logs::Zone_Server, "Loading items"); + if (!database.LoadItems(hotfix_name)) { + Log(Logs::General, Logs::Error, "Loading items FAILED!"); + Log(Logs::General, Logs::Error, "Failed. But ignoring error and going on..."); } - Log.Out(Logs::General, Logs::Zone_Server, "Loading npc faction lists"); - if(!database.LoadNPCFactionLists(hotfix_name)) { - Log.Out(Logs::General, Logs::Error, "Loading npcs faction lists FAILED!"); + Log(Logs::General, Logs::Zone_Server, "Loading npc faction lists"); + if (!database.LoadNPCFactionLists(hotfix_name)) { + Log(Logs::General, Logs::Error, "Loading npcs faction lists FAILED!"); return 1; } - Log.Out(Logs::General, Logs::Zone_Server, "Loading loot tables"); - if(!database.LoadLoot(hotfix_name)) { - Log.Out(Logs::General, Logs::Error, "Loading loot FAILED!"); + Log(Logs::General, Logs::Zone_Server, "Loading loot tables"); + if (!database.LoadLoot(hotfix_name)) { + Log(Logs::General, Logs::Error, "Loading loot FAILED!"); return 1; } - Log.Out(Logs::General, Logs::Zone_Server, "Loading skill caps"); - if(!database.LoadSkillCaps(std::string(hotfix_name))) { - Log.Out(Logs::General, Logs::Error, "Loading skill caps FAILED!"); + Log(Logs::General, Logs::Zone_Server, "Loading skill caps"); + if (!database.LoadSkillCaps(std::string(hotfix_name))) { + Log(Logs::General, Logs::Error, "Loading skill caps FAILED!"); return 1; } - Log.Out(Logs::General, Logs::Zone_Server, "Loading spells"); - if(!database.LoadSpells(hotfix_name, &SPDAT_RECORDS, &spells)) { - Log.Out(Logs::General, Logs::Error, "Loading spells FAILED!"); + Log(Logs::General, Logs::Zone_Server, "Loading spells"); + if (!database.LoadSpells(hotfix_name, &SPDAT_RECORDS, &spells)) { + Log(Logs::General, Logs::Error, "Loading spells FAILED!"); return 1; } - Log.Out(Logs::General, Logs::Zone_Server, "Loading base data"); - if(!database.LoadBaseData(hotfix_name)) { - Log.Out(Logs::General, Logs::Error, "Loading base data FAILED!"); + Log(Logs::General, Logs::Zone_Server, "Loading base data"); + if (!database.LoadBaseData(hotfix_name)) { + Log(Logs::General, Logs::Error, "Loading base data FAILED!"); return 1; } - Log.Out(Logs::General, Logs::Zone_Server, "Loading guilds"); + Log(Logs::General, Logs::Zone_Server, "Loading guilds"); guild_mgr.LoadGuilds(); - - Log.Out(Logs::General, Logs::Zone_Server, "Loading factions"); + + Log(Logs::General, Logs::Zone_Server, "Loading factions"); database.LoadFactionData(); - - Log.Out(Logs::General, Logs::Zone_Server, "Loading titles"); + + Log(Logs::General, Logs::Zone_Server, "Loading titles"); title_manager.LoadTitles(); - - Log.Out(Logs::General, Logs::Zone_Server, "Loading tributes"); + + Log(Logs::General, Logs::Zone_Server, "Loading tributes"); database.LoadTributes(); - - Log.Out(Logs::General, Logs::Zone_Server, "Loading corpse timers"); + + Log(Logs::General, Logs::Zone_Server, "Loading corpse timers"); database.GetDecayTimes(npcCorpseDecayTimes); - - Log.Out(Logs::General, Logs::Zone_Server, "Loading commands"); - int retval=command_init(); - if(retval<0) - Log.Out(Logs::General, Logs::Error, "Command loading FAILED"); + + Log(Logs::General, Logs::Zone_Server, "Loading commands"); + int retval = command_init(); + if (retval<0) + Log(Logs::General, Logs::Error, "Command loading FAILED"); else - Log.Out(Logs::General, Logs::Zone_Server, "%d commands loaded", retval); + Log(Logs::General, Logs::Zone_Server, "%d commands loaded", retval); //rules: { std::string tmp; if (database.GetVariable("RuleSet", tmp)) { - Log.Out(Logs::General, Logs::Zone_Server, "Loading rule set '%s'", tmp.c_str()); - if(!RuleManager::Instance()->LoadRules(&database, tmp.c_str())) { - Log.Out(Logs::General, Logs::Error, "Failed to load ruleset '%s', falling back to defaults.", tmp.c_str()); + Log(Logs::General, Logs::Zone_Server, "Loading rule set '%s'", tmp.c_str()); + if (!RuleManager::Instance()->LoadRules(&database, tmp.c_str())) { + Log(Logs::General, Logs::Error, "Failed to load ruleset '%s', falling back to defaults.", tmp.c_str()); } - } else { - if(!RuleManager::Instance()->LoadRules(&database, "default")) { - Log.Out(Logs::General, Logs::Zone_Server, "No rule set configured, using default rules"); - } else { - Log.Out(Logs::General, Logs::Zone_Server, "Loaded default rule set 'default'", tmp.c_str()); + } + else { + if (!RuleManager::Instance()->LoadRules(&database, "default")) { + Log(Logs::General, Logs::Zone_Server, "No rule set configured, using default rules"); + } + else { + Log(Logs::General, Logs::Zone_Server, "Loaded default rule set 'default'", tmp.c_str()); } } } #ifdef BOTS - Log.Out(Logs::General, Logs::Zone_Server, "Loading bot commands"); + Log(Logs::General, Logs::Zone_Server, "Loading bot commands"); int botretval = bot_command_init(); if (botretval<0) - Log.Out(Logs::General, Logs::Error, "Bot command loading FAILED"); + Log(Logs::General, Logs::Error, "Bot command loading FAILED"); else - Log.Out(Logs::General, Logs::Zone_Server, "%d bot commands loaded", botretval); + Log(Logs::General, Logs::Zone_Server, "%d bot commands loaded", botretval); - Log.Out(Logs::General, Logs::Zone_Server, "Loading bot spell casting chances"); + Log(Logs::General, Logs::Zone_Server, "Loading bot spell casting chances"); if (!botdb.LoadBotSpellCastingChances()) - Log.Out(Logs::General, Logs::Error, "Bot spell casting chances loading FAILED"); + Log(Logs::General, Logs::Error, "Bot spell casting chances loading FAILED"); #endif - if(RuleB(TaskSystem, EnableTaskSystem)) { - Log.Out(Logs::General, Logs::Tasks, "[INIT] Loading Tasks"); + if (RuleB(TaskSystem, EnableTaskSystem)) { + Log(Logs::General, Logs::Tasks, "[INIT] Loading Tasks"); taskmanager = new TaskManager; taskmanager->LoadTasks(); } @@ -399,7 +405,7 @@ int main(int argc, char** argv) { #endif //now we have our parser, load the quests - Log.Out(Logs::General, Logs::Zone_Server, "Loading quests"); + Log(Logs::General, Logs::Zone_Server, "Loading quests"); parse->ReloadQuests(); worldserver.Connect(); @@ -407,14 +413,15 @@ int main(int argc, char** argv) { Timer InterserverTimer(INTERSERVER_TIMER); // does MySQL pings and auto-reconnect #ifdef EQPROFILE #ifdef PROFILE_DUMP_TIME - Timer profile_dump_timer(PROFILE_DUMP_TIME*1000); + Timer profile_dump_timer(PROFILE_DUMP_TIME * 1000); profile_dump_timer.Start(); #endif #endif - if (!strlen(zone_name) || !strcmp(zone_name,".")) { - Log.Out(Logs::General, Logs::Zone_Server, "Entering sleep mode"); - } else if (!Zone::Bootup(database.GetZoneID(zone_name), instance_id, true)) { - Log.Out(Logs::General, Logs::Error, "Zone Bootup failed :: Zone::Bootup"); + if (!strlen(zone_name) || !strcmp(zone_name, ".")) { + Log(Logs::General, Logs::Zone_Server, "Entering sleep mode"); + } + else if (!Zone::Bootup(database.GetZoneID(zone_name), instance_id, true)) { + Log(Logs::General, Logs::Error, "Zone Bootup failed :: Zone::Bootup"); zone = 0; } @@ -423,7 +430,7 @@ int main(int argc, char** argv) { RegisterAllPatches(stream_identifier); #ifndef WIN32 - Log.Out(Logs::Detail, Logs::None, "Main thread running with thread id %d", pthread_self()); + Log(Logs::Detail, Logs::None, "Main thread running with thread id %d", pthread_self()); #endif Timer quest_timers(100); @@ -436,94 +443,94 @@ int main(int argc, char** argv) { std::chrono::time_point frame_prev = std::chrono::system_clock::now(); EQ::Timer process_timer(32, true, [&](EQ::Timer* t) { - //Advance the timer to our current point in time - Timer::SetCurrentTime(); + //Advance the timer to our current point in time + Timer::SetCurrentTime(); - //Calculate frame time - std::chrono::time_point frame_now = std::chrono::system_clock::now(); - frame_time = std::chrono::duration_cast(frame_now - frame_prev).count(); - frame_prev = frame_now; - - if (!eqsf_open && Config->ZonePort != 0) { - Log.Out(Logs::General, Logs::Zone_Server, "Starting EQ Network server on port %d", Config->ZonePort); - - EQ::Net::EQStreamManagerOptions opts(Config->ZonePort, false, false); - eqsm.reset(new EQ::Net::EQStreamManager(opts)); - eqsf_open = true; - - eqsm->OnNewConnection([&stream_identifier](std::shared_ptr stream) { - stream_identifier.AddStream(stream); - Log.OutF(Logs::Detail, Logs::World_Server, "New connection from IP {0}:{1}", stream->RemoteEndpoint(), ntohs(stream->GetRemotePort())); - }); - } - - //give the stream identifier a chance to do its work.... - stream_identifier.Process(); - - //check the stream identifier for any now-identified streams - while((eqsi = stream_identifier.PopIdentified())) { - //now that we know what patch they are running, start up their client object - struct in_addr in; - in.s_addr = eqsi->GetRemoteIP(); - Log.Out(Logs::Detail, Logs::World_Server, "New client from %s:%d", inet_ntoa(in), ntohs(eqsi->GetRemotePort())); - auto client = new Client(eqsi); - entity_list.AddClient(client); - } - - if (worldserver.Connected()) { - worldwasconnected = true; - } - else { - if (worldwasconnected && is_zone_loaded) - entity_list.ChannelMessageFromWorld(0, 0, 6, 0, 0, "WARNING: World server connection lost"); - worldwasconnected = false; - } - - if (is_zone_loaded) { - { - if(net.group_timer.Enabled() && net.group_timer.Check()) - entity_list.GroupProcess(); - - if(net.door_timer.Enabled() && net.door_timer.Check()) - entity_list.DoorProcess(); - - if(net.object_timer.Enabled() && net.object_timer.Check()) - entity_list.ObjectProcess(); - - if(net.corpse_timer.Enabled() && net.corpse_timer.Check()) - entity_list.CorpseProcess(); - - if(net.trap_timer.Enabled() && net.trap_timer.Check()) - entity_list.TrapProcess(); - - if(net.raid_timer.Enabled() && net.raid_timer.Check()) - entity_list.RaidProcess(); - - entity_list.Process(); - entity_list.MobProcess(); - entity_list.BeaconProcess(); - entity_list.EncounterProcess(); - - if (zone) { - if(!zone->Process()) { - Zone::Shutdown(); - } + //Calculate frame time + std::chrono::time_point frame_now = std::chrono::system_clock::now(); + frame_time = std::chrono::duration_cast(frame_now - frame_prev).count(); + frame_prev = frame_now; + + if (!eqsf_open && Config->ZonePort != 0) { + Log(Logs::General, Logs::Zone_Server, "Starting EQ Network server on port %d", Config->ZonePort); + + EQ::Net::EQStreamManagerOptions opts(Config->ZonePort, false, true); + eqsm.reset(new EQ::Net::EQStreamManager(opts)); + eqsf_open = true; + + eqsm->OnNewConnection([&stream_identifier](std::shared_ptr stream) { + stream_identifier.AddStream(stream); + LogF(Logs::Detail, Logs::World_Server, "New connection from IP {0}:{1}", stream->RemoteEndpoint(), ntohs(stream->GetRemotePort())); + }); + } + + //give the stream identifier a chance to do its work.... + stream_identifier.Process(); + + //check the stream identifier for any now-identified streams + while ((eqsi = stream_identifier.PopIdentified())) { + //now that we know what patch they are running, start up their client object + struct in_addr in; + in.s_addr = eqsi->GetRemoteIP(); + Log(Logs::Detail, Logs::World_Server, "New client from %s:%d", inet_ntoa(in), ntohs(eqsi->GetRemotePort())); + auto client = new Client(eqsi); + entity_list.AddClient(client); + } + + if (worldserver.Connected()) { + worldwasconnected = true; + } + else { + if (worldwasconnected && is_zone_loaded) + entity_list.ChannelMessageFromWorld(0, 0, 6, 0, 0, "WARNING: World server connection lost"); + worldwasconnected = false; + } + + if (is_zone_loaded) { + { + if (net.group_timer.Enabled() && net.group_timer.Check()) + entity_list.GroupProcess(); + + if (net.door_timer.Enabled() && net.door_timer.Check()) + entity_list.DoorProcess(); + + if (net.object_timer.Enabled() && net.object_timer.Check()) + entity_list.ObjectProcess(); + + if (net.corpse_timer.Enabled() && net.corpse_timer.Check()) + entity_list.CorpseProcess(); + + if (net.trap_timer.Enabled() && net.trap_timer.Check()) + entity_list.TrapProcess(); + + if (net.raid_timer.Enabled() && net.raid_timer.Check()) + entity_list.RaidProcess(); + + entity_list.Process(); + entity_list.MobProcess(); + entity_list.BeaconProcess(); + entity_list.EncounterProcess(); + + if (zone) { + if (!zone->Process()) { + Zone::Shutdown(); } - - if(quest_timers.Check()) - quest_manager.Process(); - } - } - if (InterserverTimer.Check()) { - InterserverTimer.Start(); - database.ping(); - entity_list.UpdateWho(); + if (quest_timers.Check()) + quest_manager.Process(); + } + } + + if (InterserverTimer.Check()) { + InterserverTimer.Start(); + database.ping(); + entity_list.UpdateWho(); + } }); - - while(RunLoops) { + + while (RunLoops) { EQ::EventLoop::Get().Process(); if (is_zone_loaded) { Sleep(1); @@ -539,7 +546,7 @@ int main(int argc, char** argv) { parse->ClearInterfaces(); #ifdef EMBPERL - safe_delete(perl_parser); + safe_delete(perl_parser); #endif #ifdef LUA_EQEMU @@ -557,14 +564,14 @@ int main(int argc, char** argv) { bot_command_deinit(); #endif safe_delete(parse); - Log.Out(Logs::General, Logs::Zone_Server, "Proper zone shutdown complete."); - Log.CloseFileLogs(); + Log(Logs::General, Logs::Zone_Server, "Proper zone shutdown complete."); + LogSys.CloseFileLogs(); return 0; } void CatchSignal(int sig_num) { #ifdef _WINDOWS - Log.Out(Logs::General, Logs::Zone_Server, "Recieved signal: %i", sig_num); + Log(Logs::General, Logs::Zone_Server, "Recieved signal: %i", sig_num); #endif RunLoops = false; } @@ -573,13 +580,13 @@ void Shutdown() { Zone::Shutdown(true); RunLoops = false; - Log.Out(Logs::General, Logs::Zone_Server, "Shutting down..."); - Log.CloseFileLogs(); + Log(Logs::General, Logs::Zone_Server, "Shutting down..."); + LogSys.CloseFileLogs(); } uint32 NetConnection::GetIP() { - char name[255+1]; + char name[255 + 1]; size_t len = 0; hostent* host = 0; @@ -612,7 +619,7 @@ uint32 NetConnection::GetIP(char* name) } NetConnection::NetConnection() -: + : object_timer(5000), door_timer(5000), corpse_timer(2000), @@ -640,20 +647,20 @@ void UpdateWindowTitle(char* iNewTitle) { } else { if (zone) { - #if defined(GOTFRAGS) || defined(_EQDEBUG) - snprintf(tmp, sizeof(tmp), "%i: %s, %i clients, %i", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients, getpid()); - #else +#if defined(GOTFRAGS) || defined(_EQDEBUG) + snprintf(tmp, sizeof(tmp), "%i: %s, %i clients, %i", ZoneConfig::get()->ZonePort, zone->GetShortName(), numclients, getpid()); +#else snprintf(tmp, sizeof(tmp), "%s :: clients: %i inst_id: %i inst_ver: %i :: port: %i", zone->GetShortName(), numclients, zone->GetInstanceID(), zone->GetInstanceVersion(), ZoneConfig::get()->ZonePort); - #endif +#endif } else { - #if defined(GOTFRAGS) || defined(_EQDEBUG) - snprintf(tmp, sizeof(tmp), "%i: sleeping, %i", ZoneConfig::get()->ZonePort, getpid()); - #else - snprintf(tmp, sizeof(tmp), "%i: sleeping", ZoneConfig::get()->ZonePort); - #endif +#if defined(GOTFRAGS) || defined(_EQDEBUG) + snprintf(tmp, sizeof(tmp), "%i: sleeping, %i", ZoneConfig::get()->ZonePort, getpid()); +#else + snprintf(tmp, sizeof(tmp), "%i: sleeping", ZoneConfig::get()->ZonePort); +#endif } } SetConsoleTitle(tmp); #endif -} +} \ No newline at end of file diff --git a/zone/npc.cpp b/zone/npc.cpp index 24706505e..120bb0410 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -529,11 +529,11 @@ void NPC::QueryLoot(Client* to) int x = 0; for (auto cur = itemlist.begin(); cur != itemlist.end(); ++cur, ++x) { if (!(*cur)) { - Log.Out(Logs::General, Logs::Error, "NPC::QueryLoot() - ItemList error, null item"); + Log(Logs::General, Logs::Error, "NPC::QueryLoot() - ItemList error, null item"); continue; } if (!(*cur)->item_id || !database.GetItem((*cur)->item_id)) { - Log.Out(Logs::General, Logs::Error, "NPC::QueryLoot() - Database error, invalid item"); + Log(Logs::General, Logs::Error, "NPC::QueryLoot() - Database error, invalid item"); continue; } @@ -587,8 +587,7 @@ void NPC::RemoveCash() { bool NPC::Process() { - if (IsStunned() && stunned_timer.Check()) - { + if (IsStunned() && stunned_timer.Check()) { Mob::UnStun(); this->spun_timer.Disable(); } @@ -608,58 +607,60 @@ bool NPC::Process() SpellProcess(); - if(tic_timer.Check()) - { + if (tic_timer.Check()) { parse->EventNPC(EVENT_TICK, this, nullptr, "", 0); BuffProcess(); - if(currently_fleeing) + if (currently_fleeing) ProcessFlee(); uint32 bonus = 0; - if(GetAppearance() == eaSitting) - bonus+=3; + if (GetAppearance() == eaSitting) + bonus += 3; int32 OOCRegen = 0; - if(oocregen > 0){ //should pull from Mob class + if (oocregen > 0) { //should pull from Mob class OOCRegen += GetMaxHP() * oocregen / 100; - } + } //Lieka Edit:Fixing NPC regen.NPCs should regen to full during a set duration, not based on their HPs.Increase NPC's HPs by % of total HPs / tick. - if((GetHP() < GetMaxHP()) && !IsPet()) { - if(!IsEngaged()) {//NPC out of combat - if(GetNPCHPRegen() > OOCRegen) + if ((GetHP() < GetMaxHP()) && !IsPet()) { + if (!IsEngaged()) {//NPC out of combat + if (GetNPCHPRegen() > OOCRegen) SetHP(GetHP() + GetNPCHPRegen()); else SetHP(GetHP() + OOCRegen); - } else - SetHP(GetHP()+GetNPCHPRegen()); - } else if(GetHP() < GetMaxHP() && GetOwnerID() !=0) { - if(!IsEngaged()) //pet - SetHP(GetHP()+GetNPCHPRegen()+bonus+(GetLevel()/5)); + } else - SetHP(GetHP()+GetNPCHPRegen()+bonus); - } else - SetHP(GetHP()+GetNPCHPRegen()); + SetHP(GetHP() + GetNPCHPRegen()); + } + else if (GetHP() < GetMaxHP() && GetOwnerID() != 0) { + if (!IsEngaged()) //pet + SetHP(GetHP() + GetNPCHPRegen() + bonus + (GetLevel() / 5)); + else + SetHP(GetHP() + GetNPCHPRegen() + bonus); + } + else + SetHP(GetHP() + GetNPCHPRegen()); - if(GetMana() < GetMaxMana()) { - SetMana(GetMana()+mana_regen+bonus); + if (GetMana() < GetMaxMana()) { + SetMana(GetMana() + mana_regen + bonus); } - if(zone->adv_data && !p_depop) + if (zone->adv_data && !p_depop) { ServerZoneAdventureDataReply_Struct* ds = (ServerZoneAdventureDataReply_Struct*)zone->adv_data; - if(ds->type == Adventure_Rescue && ds->data_id == GetNPCTypeID()) + if (ds->type == Adventure_Rescue && ds->data_id == GetNPCTypeID()) { Mob *o = GetOwner(); - if(o && o->IsClient()) + if (o && o->IsClient()) { float x_diff = ds->dest_x - GetX(); float y_diff = ds->dest_y - GetY(); float z_diff = ds->dest_z - GetZ(); float dist = ((x_diff * x_diff) + (y_diff * y_diff) + (z_diff * z_diff)); - if(dist < RuleR(Adventure, DistanceForRescueComplete)) + if (dist < RuleR(Adventure, DistanceForRescueComplete)) { zone->DoAdventureCountIncrease(); Say("You don't know what this means to me. Thank you so much for finding and saving me from" @@ -693,8 +694,6 @@ bool NPC::Process() viral_timer_counter = 0; } - ProjectileAttack(); - if(spellbonuses.GravityEffect == 1) { if(gravity_timer.Check()) DoGravityEffect(); @@ -717,6 +716,11 @@ bool NPC::Process() if (enraged_timer.Check()){ ProcessEnrage(); + + /* Don't keep running the check every second if we don't have enrage */ + if (!GetSpecialAbility(SPECATK_ENRAGE)) { + enraged_timer.Disable(); + } } //Handle assists... @@ -1710,7 +1714,7 @@ void Mob::NPCSpecialAttacks(const char* parse, int permtag, bool reset, bool rem { if(database.SetSpecialAttkFlag(this->GetNPCTypeID(), orig_parse)) { - Log.Out(Logs::General, Logs::Normal, "NPCTypeID: %i flagged to '%s' for Special Attacks.\n",this->GetNPCTypeID(),orig_parse); + Log(Logs::General, Logs::Normal, "NPCTypeID: %i flagged to '%s' for Special Attacks.\n",this->GetNPCTypeID(),orig_parse); } } } @@ -2557,6 +2561,7 @@ void NPC::ClearLastName() void NPC::DepopSwarmPets() { + if (GetSwarmInfo()) { if (GetSwarmInfo()->duration->Check(false)){ Mob* owner = entity_list.GetMobID(GetSwarmInfo()->owner_id); diff --git a/zone/npc.h b/zone/npc.h index 5dcc7eac9..015128340 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -85,7 +85,7 @@ struct AISpellsVar_Struct { uint8 idle_beneficial_chance; }; -class AA_SwarmPetInfo; +class SwarmPet; class Client; class Group; class Raid; @@ -330,8 +330,8 @@ public: QGlobalCache *GetQGlobals() { return qGlobals; } QGlobalCache *CreateQGlobals() { qGlobals = new QGlobalCache(); return qGlobals; } - AA_SwarmPetInfo *GetSwarmInfo() { return (swarmInfoPtr); } - void SetSwarmInfo(AA_SwarmPetInfo *mSwarmInfo) { swarmInfoPtr = mSwarmInfo; } + SwarmPet *GetSwarmInfo() { return (swarmInfoPtr); } + void SetSwarmInfo(SwarmPet *mSwarmInfo) { swarmInfoPtr = mSwarmInfo; } int32 GetAccuracyRating() const { return (accuracy_rating); } void SetAccuracyRating(int32 d) { accuracy_rating = d;} @@ -515,7 +515,7 @@ protected: uint8 sec_melee_type; //Sets the Secondary Weapon attack message and animation uint8 ranged_type; //Sets the Ranged Weapon attack message and animation - AA_SwarmPetInfo *swarmInfoPtr; + SwarmPet *swarmInfoPtr; bool ldon_trapped; uint8 ldon_trap_type; diff --git a/zone/object.cpp b/zone/object.cpp index 3097ceba1..d8db2f1d8 100644 --- a/zone/object.cpp +++ b/zone/object.cpp @@ -339,7 +339,7 @@ const EQEmu::ItemInstance* Object::GetItem(uint8 index) { void Object::PutItem(uint8 index, const EQEmu::ItemInstance* inst) { if (index > 9) { - Log.Out(Logs::General, Logs::Error, "Object::PutItem: Invalid index specified (%i)", index); + Log(Logs::General, Logs::Error, "Object::PutItem: Invalid index specified (%i)", index); return; } @@ -465,7 +465,7 @@ void Object::RandomSpawn(bool send_packet) { } } - Log.Out(Logs::Detail, Logs::Zone_Server, "Object::RandomSpawn(%s): %d (%.2f, %.2f, %.2f)", m_data.object_name, m_inst->GetID(), m_data.x, m_data.y, m_data.z); + Log(Logs::Detail, Logs::Zone_Server, "Object::RandomSpawn(%s): %d (%.2f, %.2f, %.2f)", m_data.object_name, m_inst->GetID(), m_data.x, m_data.y, m_data.z); respawn_timer.Disable(); @@ -643,7 +643,7 @@ uint32 ZoneDatabase::AddObject(uint32 type, uint32 icon, const Object_Struct& ob safe_delete_array(object_name); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Unable to insert object: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to insert object: %s", results.ErrorMessage().c_str()); return 0; } @@ -682,7 +682,7 @@ void ZoneDatabase::UpdateObject(uint32 id, uint32 type, uint32 icon, const Objec safe_delete_array(object_name); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Unable to update object: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to update object: %s", results.ErrorMessage().c_str()); return; } @@ -726,7 +726,7 @@ void ZoneDatabase::DeleteObject(uint32 id) std::string query = StringFormat("DELETE FROM object WHERE id = %i", id); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Unable to delete object: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to delete object: %s", results.ErrorMessage().c_str()); } } diff --git a/zone/pathing.cpp b/zone/pathing.cpp index 16b340d94..417ee3af2 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -60,19 +60,19 @@ PathManager* PathManager::LoadPathFile(const char* ZoneName) if(Ret->loadPaths(PathFile)) { - Log.Out(Logs::General, Logs::Status, "Path File %s loaded.", ZonePathFileName); + Log(Logs::General, Logs::Status, "Path File %s loaded.", ZonePathFileName); } else { - Log.Out(Logs::General, Logs::Error, "Path File %s failed to load.", ZonePathFileName); + Log(Logs::General, Logs::Error, "Path File %s failed to load.", ZonePathFileName); safe_delete(Ret); } fclose(PathFile); } else { - Log.Out(Logs::General, Logs::Error, "Path File %s not found.", ZonePathFileName); + Log(Logs::General, Logs::Error, "Path File %s not found.", ZonePathFileName); } return Ret; @@ -102,18 +102,18 @@ bool PathManager::loadPaths(FILE *PathFile) if(strncmp(Magic, "EQEMUPATH", 9)) { - Log.Out(Logs::General, Logs::Error, "Bad Magic String in .path file."); + Log(Logs::General, Logs::Error, "Bad Magic String in .path file."); return false; } fread(&Head, sizeof(Head), 1, PathFile); - Log.Out(Logs::General, Logs::Status, "Path File Header: Version %ld, PathNodes %ld", + Log(Logs::General, Logs::Status, "Path File Header: Version %ld, PathNodes %ld", (long)Head.version, (long)Head.PathNodeCount); if(Head.version != 2) { - Log.Out(Logs::General, Logs::Error, "Unsupported path file version."); + Log(Logs::General, Logs::Error, "Unsupported path file version."); return false; } @@ -137,7 +137,7 @@ bool PathManager::loadPaths(FILE *PathFile) { if(PathNodes[i].Neighbours[j].id > MaxNodeID) { - Log.Out(Logs::General, Logs::Error, "Path Node %i, Neighbour %i (%i) out of range.", i, j, PathNodes[i].Neighbours[j].id); + Log(Logs::General, Logs::Error, "Path Node %i, Neighbour %i (%i) out of range.", i, j, PathNodes[i].Neighbours[j].id); PathFileValid = false; } @@ -206,7 +206,7 @@ glm::vec3 PathManager::GetPathNodeCoordinates(int NodeNumber, bool BestZ) std::deque PathManager::FindRoute(int startID, int endID) { - Log.Out(Logs::Detail, Logs::None, "FindRoute from node %i to %i", startID, endID); + Log(Logs::Detail, Logs::None, "FindRoute from node %i to %i", startID, endID); memset(ClosedListFlag, 0, sizeof(int) * Head.PathNodeCount); @@ -329,7 +329,7 @@ std::deque PathManager::FindRoute(int startID, int endID) } } - Log.Out(Logs::Detail, Logs::None, "Unable to find a route."); + Log(Logs::Detail, Logs::None, "Unable to find a route."); return Route; } @@ -351,7 +351,7 @@ auto path_compare = [](const PathNodeSortStruct& a, const PathNodeSortStruct& b) std::deque PathManager::FindRoute(glm::vec3 Start, glm::vec3 End) { - Log.Out(Logs::Detail, Logs::None, "FindRoute(%8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f)", Start.x, Start.y, Start.z, End.x, End.y, End.z); + Log(Logs::Detail, Logs::None, "FindRoute(%8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f)", Start.x, Start.y, Start.z, End.x, End.y, End.z); std::deque noderoute; @@ -384,7 +384,7 @@ std::deque PathManager::FindRoute(glm::vec3 Start, glm::vec3 End) for(auto Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator) { - Log.Out(Logs::Detail, Logs::None, "Checking Reachability of Node %i from Start Position.", PathNodes[(*Iterator).id].id); + Log(Logs::Detail, Logs::None, "Checking Reachability of Node %i from Start Position.", PathNodes[(*Iterator).id].id); if(!zone->zonemap->LineIntersectsZone(Start, PathNodes[(*Iterator).id].v, 1.0f, nullptr)) { @@ -394,11 +394,11 @@ std::deque PathManager::FindRoute(glm::vec3 Start, glm::vec3 End) } if(ClosestPathNodeToStart <0 ) { - Log.Out(Logs::Detail, Logs::None, "No LOS to any starting Path Node within range."); + Log(Logs::Detail, Logs::None, "No LOS to any starting Path Node within range."); return noderoute; } - Log.Out(Logs::Detail, Logs::None, "Closest Path Node To Start: %2d", ClosestPathNodeToStart); + Log(Logs::Detail, Logs::None, "Closest Path Node To Start: %2d", ClosestPathNodeToStart); // Find the nearest PathNode the end point has LOS to @@ -421,8 +421,8 @@ std::deque PathManager::FindRoute(glm::vec3 Start, glm::vec3 End) for(auto Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator) { - Log.Out(Logs::Detail, Logs::None, "Checking Reachability of Node %i from End Position.", PathNodes[(*Iterator).id].id); - Log.Out(Logs::Detail, Logs::None, " (%8.3f, %8.3f, %8.3f) to (%8.3f, %8.3f, %8.3f)", + Log(Logs::Detail, Logs::None, "Checking Reachability of Node %i from End Position.", PathNodes[(*Iterator).id].id); + Log(Logs::Detail, Logs::None, " (%8.3f, %8.3f, %8.3f) to (%8.3f, %8.3f, %8.3f)", End.x, End.y, End.z, PathNodes[(*Iterator).id].v.x, PathNodes[(*Iterator).id].v.y, PathNodes[(*Iterator).id].v.z); @@ -434,11 +434,11 @@ std::deque PathManager::FindRoute(glm::vec3 Start, glm::vec3 End) } if(ClosestPathNodeToEnd < 0) { - Log.Out(Logs::Detail, Logs::None, "No LOS to any end Path Node within range."); + Log(Logs::Detail, Logs::None, "No LOS to any end Path Node within range."); return noderoute; } - Log.Out(Logs::Detail, Logs::None, "Closest Path Node To End: %2d", ClosestPathNodeToEnd); + Log(Logs::Detail, Logs::None, "Closest Path Node To End: %2d", ClosestPathNodeToEnd); if(ClosestPathNodeToStart == ClosestPathNodeToEnd) { @@ -673,7 +673,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa if(To == From) return To; - Log.Out(Logs::Detail, Logs::None, "UpdatePath. From(%8.3f, %8.3f, %8.3f) To(%8.3f, %8.3f, %8.3f)", From.x, From.y, From.z, To.x, To.y, To.z); + Log(Logs::Detail, Logs::None, "UpdatePath. From(%8.3f, %8.3f, %8.3f) To(%8.3f, %8.3f, %8.3f)", From.x, From.y, From.z, To.x, To.y, To.z); if(From == PathingLastPosition) { @@ -681,7 +681,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa if((PathingLoopCount > 5) && !IsRooted()) { - Log.Out(Logs::Detail, Logs::None, "appears to be stuck. Teleporting them to next position.", GetName()); + Log(Logs::Detail, Logs::None, "appears to be stuck. Teleporting them to next position.", GetName()); if(Route.empty()) { @@ -721,7 +721,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa // If we are already pathing, and the destination is the same as before ... if(SameDestination) { - Log.Out(Logs::Detail, Logs::None, " Still pathing to the same destination."); + Log(Logs::Detail, Logs::None, " Still pathing to the same destination."); // Get the coordinates of the first path node we are going to. NextNode = Route.front(); @@ -732,7 +732,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa // We have reached the path node. if(NodeLoc == From) { - Log.Out(Logs::Detail, Logs::None, " Arrived at node %i", NextNode); + Log(Logs::Detail, Logs::None, " Arrived at node %i", NextNode); NodeReached = true; @@ -746,17 +746,17 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa // target, and we may run past the target if we don't check LOS at this point. int RouteSize = Route.size(); - Log.Out(Logs::Detail, Logs::None, "Route size is %i", RouteSize); + Log(Logs::Detail, Logs::None, "Route size is %i", RouteSize); if((RouteSize == 2) || ((PathingTraversedNodes >= RuleI(Pathing, MinNodesTraversedForLOSCheck)) && (RouteSize <= RuleI(Pathing, MinNodesLeftForLOSCheck)) && PathingLOSCheckTimer->Check())) { - Log.Out(Logs::Detail, Logs::None, " Checking distance to target."); + Log(Logs::Detail, Logs::None, " Checking distance to target."); float Distance = VectorDistanceNoRoot(From, To); - Log.Out(Logs::Detail, Logs::None, " Distance between From and To (NoRoot) is %8.3f", Distance); + Log(Logs::Detail, Logs::None, " Distance between From and To (NoRoot) is %8.3f", Distance); if ((Distance <= RuleR(Pathing, MinDistanceForLOSCheckShort)) && (std::abs(From.z - To.z) <= RuleR(Pathing, ZDiffThreshold))) { @@ -764,18 +764,18 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa PathingLOSState = HaveLOS; else PathingLOSState = NoLOS; - Log.Out(Logs::Detail, Logs::None, "NoLOS"); + Log(Logs::Detail, Logs::None, "NoLOS"); if((PathingLOSState == HaveLOS) && zone->pathing->NoHazards(From, To)) { - Log.Out(Logs::Detail, Logs::None, " No hazards. Running directly to target."); + Log(Logs::Detail, Logs::None, " No hazards. Running directly to target."); Route.clear(); return To; } else { - Log.Out(Logs::Detail, Logs::None, " Continuing on node path."); + Log(Logs::Detail, Logs::None, " Continuing on node path."); } } else @@ -801,7 +801,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa if(Route.empty()) { - Log.Out(Logs::Detail, Logs::None, "Missing node after teleport."); + Log(Logs::Detail, Logs::None, "Missing node after teleport."); return To; } @@ -811,7 +811,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa Teleport(NodeLoc); - Log.Out(Logs::Detail, Logs::None, " TELEPORTED to %8.3f, %8.3f, %8.3f\n", NodeLoc.x, NodeLoc.y, NodeLoc.z); + Log(Logs::Detail, Logs::None, " TELEPORTED to %8.3f, %8.3f, %8.3f\n", NodeLoc.x, NodeLoc.y, NodeLoc.z); Route.pop_front(); @@ -822,7 +822,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa } zone->pathing->OpenDoors(PathingLastNodeVisited, NextNode, this); - Log.Out(Logs::Detail, Logs::None, " Now moving to node %i", NextNode); + Log(Logs::Detail, Logs::None, " Now moving to node %i", NextNode); return zone->pathing->GetPathNodeCoordinates(NextNode); } @@ -830,7 +830,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa { // we have run all the nodes, all that is left is the direct path from the last node // to the destination - Log.Out(Logs::Detail, Logs::None, " Reached end of node path, running direct to target."); + Log(Logs::Detail, Logs::None, " Reached end of node path, running direct to target."); return To; } @@ -844,11 +844,11 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa && (RouteSize <= RuleI(Pathing, MinNodesLeftForLOSCheck)) && PathingLOSCheckTimer->Check()) { - Log.Out(Logs::Detail, Logs::None, " Checking distance to target."); + Log(Logs::Detail, Logs::None, " Checking distance to target."); float Distance = VectorDistanceNoRoot(From, To); - Log.Out(Logs::Detail, Logs::None, " Distance between From and To (NoRoot) is %8.3f", Distance); + Log(Logs::Detail, Logs::None, " Distance between From and To (NoRoot) is %8.3f", Distance); if ((Distance <= RuleR(Pathing, MinDistanceForLOSCheckShort)) && (std::abs(From.z - To.z) <= RuleR(Pathing, ZDiffThreshold))) { @@ -856,18 +856,18 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa PathingLOSState = HaveLOS; else PathingLOSState = NoLOS; - Log.Out(Logs::Detail, Logs::None, "NoLOS"); + Log(Logs::Detail, Logs::None, "NoLOS"); if((PathingLOSState == HaveLOS) && zone->pathing->NoHazards(From, To)) { - Log.Out(Logs::Detail, Logs::None, " No hazards. Running directly to target."); + Log(Logs::Detail, Logs::None, " No hazards. Running directly to target."); Route.clear(); return To; } else { - Log.Out(Logs::Detail, Logs::None, " Continuing on node path."); + Log(Logs::Detail, Logs::None, " Continuing on node path."); } } else @@ -879,7 +879,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa { // We get here if we were already pathing, but our destination has now changed. // - Log.Out(Logs::Detail, Logs::None, " Target has changed position."); + Log(Logs::Detail, Logs::None, " Target has changed position."); // Update our record of where we are going to. PathingDestination = To; // Check if we now have LOS etc to the new destination. @@ -889,23 +889,23 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa if ((Distance <= RuleR(Pathing, MinDistanceForLOSCheckShort)) && (std::abs(From.z - To.z) <= RuleR(Pathing, ZDiffThreshold))) { - Log.Out(Logs::Detail, Logs::None, " Checking for short LOS at distance %8.3f.", Distance); + Log(Logs::Detail, Logs::None, " Checking for short LOS at distance %8.3f.", Distance); if(!zone->zonemap->LineIntersectsZone(HeadPosition, To, 1.0f, nullptr)) PathingLOSState = HaveLOS; else PathingLOSState = NoLOS; - Log.Out(Logs::Detail, Logs::None, "NoLOS"); + Log(Logs::Detail, Logs::None, "NoLOS"); if((PathingLOSState == HaveLOS) && zone->pathing->NoHazards(From, To)) { - Log.Out(Logs::Detail, Logs::None, " No hazards. Running directly to target."); + Log(Logs::Detail, Logs::None, " No hazards. Running directly to target."); Route.clear(); return To; } else { - Log.Out(Logs::Detail, Logs::None, " Continuing on node path."); + Log(Logs::Detail, Logs::None, " Continuing on node path."); } } } @@ -916,19 +916,19 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa { if(!PathingRouteUpdateTimerShort->Check()) { - Log.Out(Logs::Detail, Logs::None, "Short route update timer not yet expired."); + Log(Logs::Detail, Logs::None, "Short route update timer not yet expired."); return zone->pathing->GetPathNodeCoordinates(Route.front()); } - Log.Out(Logs::Detail, Logs::None, "Short route update timer expired."); + Log(Logs::Detail, Logs::None, "Short route update timer expired."); } else { if(!PathingRouteUpdateTimerLong->Check()) { - Log.Out(Logs::Detail, Logs::None, "Long route update timer not yet expired."); + Log(Logs::Detail, Logs::None, "Long route update timer not yet expired."); return zone->pathing->GetPathNodeCoordinates(Route.front()); } - Log.Out(Logs::Detail, Logs::None, "Long route update timer expired."); + Log(Logs::Detail, Logs::None, "Long route update timer expired."); } // We are already pathing, destination changed, no LOS. Find the nearest node to our destination. @@ -937,7 +937,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa // Destination unreachable via pathing, return direct route. if(DestinationPathNode == -1) { - Log.Out(Logs::Detail, Logs::None, " Unable to find path node for new destination. Running straight to target."); + Log(Logs::Detail, Logs::None, " Unable to find path node for new destination. Running straight to target."); Route.clear(); return To; } @@ -945,7 +945,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa // one, we will carry on on our path. if(DestinationPathNode == Route.back()) { - Log.Out(Logs::Detail, Logs::None, " Same destination Node (%i). Continue with current path.", DestinationPathNode); + Log(Logs::Detail, Logs::None, " Same destination Node (%i). Continue with current path.", DestinationPathNode); NodeLoc = zone->pathing->GetPathNodeCoordinates(Route.front()); @@ -953,7 +953,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa // Check if we have reached a path node. if(NodeLoc == From) { - Log.Out(Logs::Detail, Logs::None, " Arrived at node %i, moving to next one.\n", Route.front()); + Log(Logs::Detail, Logs::None, " Arrived at node %i, moving to next one.\n", Route.front()); NodeReached = true; @@ -976,7 +976,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa if(Route.empty()) { - Log.Out(Logs::Detail, Logs::None, "Missing node after teleport."); + Log(Logs::Detail, Logs::None, "Missing node after teleport."); return To; } @@ -986,7 +986,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa Teleport(NodeLoc); - Log.Out(Logs::Detail, Logs::None, " TELEPORTED to %8.3f, %8.3f, %8.3f\n", NodeLoc.x, NodeLoc.y, NodeLoc.z); + Log(Logs::Detail, Logs::None, " TELEPORTED to %8.3f, %8.3f, %8.3f\n", NodeLoc.x, NodeLoc.y, NodeLoc.z); Route.pop_front(); @@ -996,7 +996,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa NextNode = Route.front(); } // Return the coords of our next path node on the route. - Log.Out(Logs::Detail, Logs::None, " Now moving to node %i", NextNode); + Log(Logs::Detail, Logs::None, " Now moving to node %i", NextNode); zone->pathing->OpenDoors(PathingLastNodeVisited, NextNode, this); @@ -1004,7 +1004,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa } else { - Log.Out(Logs::Detail, Logs::None, " Reached end of path grid. Running direct to target."); + Log(Logs::Detail, Logs::None, " Reached end of path grid. Running direct to target."); return To; } } @@ -1012,7 +1012,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa } else { - Log.Out(Logs::Detail, Logs::None, " Target moved. End node is different. Clearing route."); + Log(Logs::Detail, Logs::None, " Target moved. End node is different. Clearing route."); Route.clear(); // We will now fall through to get a new route. @@ -1022,11 +1022,11 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa } - Log.Out(Logs::Detail, Logs::None, " Our route list is empty."); + Log(Logs::Detail, Logs::None, " Our route list is empty."); if((SameDestination) && !PathingLOSCheckTimer->Check()) { - Log.Out(Logs::Detail, Logs::None, " Destination same as before, LOS check timer not reached. Returning To."); + Log(Logs::Detail, Logs::None, " Destination same as before, LOS check timer not reached. Returning To."); return To; } @@ -1040,22 +1040,22 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa if ((Distance <= RuleR(Pathing, MinDistanceForLOSCheckLong)) && (std::abs(From.z - To.z) <= RuleR(Pathing, ZDiffThreshold))) { - Log.Out(Logs::Detail, Logs::None, " Checking for long LOS at distance %8.3f.", Distance); + Log(Logs::Detail, Logs::None, " Checking for long LOS at distance %8.3f.", Distance); if(!zone->zonemap->LineIntersectsZone(HeadPosition, To, 1.0f, nullptr)) PathingLOSState = HaveLOS; else PathingLOSState = NoLOS; - Log.Out(Logs::Detail, Logs::None, "NoLOS"); + Log(Logs::Detail, Logs::None, "NoLOS"); if((PathingLOSState == HaveLOS) && zone->pathing->NoHazards(From, To)) { - Log.Out(Logs::Detail, Logs::None, "Target is reachable. Running directly there."); + Log(Logs::Detail, Logs::None, "Target is reachable. Running directly there."); return To; } } - Log.Out(Logs::Detail, Logs::None, " Calculating new route to target."); + Log(Logs::Detail, Logs::None, " Calculating new route to target."); Route = zone->pathing->FindRoute(From, To); @@ -1063,14 +1063,14 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa if(Route.empty()) { - Log.Out(Logs::Detail, Logs::None, " No route available, running direct."); + Log(Logs::Detail, Logs::None, " No route available, running direct."); return To; } if(SameDestination && (Route.front() == PathingLastNodeVisited)) { - Log.Out(Logs::Detail, Logs::None, " Probable loop detected. Same destination and Route.front() == PathingLastNodeVisited."); + Log(Logs::Detail, Logs::None, " Probable loop detected. Same destination and Route.front() == PathingLastNodeVisited."); Route.clear(); @@ -1078,7 +1078,7 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa } NodeLoc = zone->pathing->GetPathNodeCoordinates(Route.front()); - Log.Out(Logs::Detail, Logs::None, " New route determined, heading for node %i", Route.front()); + Log(Logs::Detail, Logs::None, " New route determined, heading for node %i", Route.front()); PathingLoopCount = 0; @@ -1119,7 +1119,7 @@ int PathManager::FindNearestPathNode(glm::vec3 Position) for(auto Iterator = SortedByDistance.begin(); Iterator != SortedByDistance.end(); ++Iterator) { - Log.Out(Logs::Detail, Logs::None, "Checking Reachability of Node %i from Start Position.", PathNodes[(*Iterator).id].id); + Log(Logs::Detail, Logs::None, "Checking Reachability of Node %i from Start Position.", PathNodes[(*Iterator).id].id); if(!zone->zonemap->LineIntersectsZone(Position, PathNodes[(*Iterator).id].v, 1.0f, nullptr)) { @@ -1129,7 +1129,7 @@ int PathManager::FindNearestPathNode(glm::vec3 Position) } if(ClosestPathNodeToStart <0 ) { - Log.Out(Logs::Detail, Logs::None, "No LOS to any starting Path Node within range."); + Log(Logs::Detail, Logs::None, "No LOS to any starting Path Node within range."); return -1; } return ClosestPathNodeToStart; @@ -1144,14 +1144,14 @@ bool PathManager::NoHazards(glm::vec3 From, glm::vec3 To) float NewZ = zone->zonemap->FindBestZ(MidPoint, nullptr); if (std::abs(NewZ - From.z) > RuleR(Pathing, ZDiffThreshold)) { - Log.Out(Logs::Detail, Logs::None, " HAZARD DETECTED moving from %8.3f, %8.3f, %8.3f to %8.3f, %8.3f, %8.3f. Z Change is %8.3f", + Log(Logs::Detail, Logs::None, " HAZARD DETECTED moving from %8.3f, %8.3f, %8.3f to %8.3f, %8.3f, %8.3f. Z Change is %8.3f", From.x, From.y, From.z, MidPoint.x, MidPoint.y, MidPoint.z, NewZ - From.z); return false; } else { - Log.Out(Logs::Detail, Logs::None, "No HAZARD DETECTED moving from %8.3f, %8.3f, %8.3f to %8.3f, %8.3f, %8.3f. Z Change is %8.3f", + Log(Logs::Detail, Logs::None, "No HAZARD DETECTED moving from %8.3f, %8.3f, %8.3f to %8.3f, %8.3f, %8.3f. Z Change is %8.3f", From.x, From.y, From.z, MidPoint.x, MidPoint.y, MidPoint.z, NewZ - From.z); } @@ -1182,7 +1182,7 @@ bool PathManager::NoHazardsAccurate(glm::vec3 From, glm::vec3 To) glm::vec3 TestPoint(curx, cury, curz); float NewZ = zone->zonemap->FindBestZ(TestPoint, nullptr); if (std::abs(NewZ - last_z) > 5.0f) { - Log.Out(Logs::Detail, Logs::None, " HAZARD DETECTED moving from %8.3f, %8.3f, %8.3f to %8.3f, %8.3f, %8.3f. Best Z %8.3f, Z Change is %8.3f", + Log(Logs::Detail, Logs::None, " HAZARD DETECTED moving from %8.3f, %8.3f, %8.3f to %8.3f, %8.3f, %8.3f. Best Z %8.3f, Z Change is %8.3f", From.x, From.y, From.z, TestPoint.x, TestPoint.y, TestPoint.z, NewZ, NewZ - From.z); return false; } @@ -1210,20 +1210,20 @@ bool PathManager::NoHazardsAccurate(glm::vec3 From, glm::vec3 To) } if (best_z2 == -999990) { - Log.Out(Logs::Detail, Logs::None, " HAZARD DETECTED, really deep water/lava!"); + Log(Logs::Detail, Logs::None, " HAZARD DETECTED, really deep water/lava!"); return false; } else { if (std::abs(NewZ - best_z2) > RuleR(Pathing, ZDiffThreshold)) { - Log.Out(Logs::Detail, Logs::None, + Log(Logs::Detail, Logs::None, " HAZARD DETECTED, water is fairly deep at %8.3f units deep", std::abs(NewZ - best_z2)); return false; } else { - Log.Out(Logs::Detail, Logs::None, + Log(Logs::Detail, Logs::None, " HAZARD NOT DETECTED, water is shallow at %8.3f units deep", std::abs(NewZ - best_z2)); } @@ -1231,12 +1231,12 @@ bool PathManager::NoHazardsAccurate(glm::vec3 From, glm::vec3 To) } else { - Log.Out(Logs::Detail, Logs::None, "Hazard point not in water or lava!"); + Log(Logs::Detail, Logs::None, "Hazard point not in water or lava!"); } } else { - Log.Out(Logs::Detail, Logs::None, "No water map loaded for hazards!"); + Log(Logs::Detail, Logs::None, "No water map loaded for hazards!"); } curx += stepx; @@ -1291,7 +1291,7 @@ void PathManager::OpenDoors(int Node1, int Node2, Mob *ForWho) if(d && !d->IsDoorOpen() ) { - Log.Out(Logs::Detail, Logs::None, "Opening door %i for %s", PathNodes[Node1].Neighbours[i].DoorID, ForWho->GetName()); + Log(Logs::Detail, Logs::None, "Opening door %i for %s", PathNodes[Node1].Neighbours[i].DoorID, ForWho->GetName()); d->ForceOpen(ForWho); } diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp index 65ff5a4e0..46746970c 100644 --- a/zone/perl_client.cpp +++ b/zone/perl_client.cpp @@ -1296,16 +1296,20 @@ XS(XS_Client_MovePC) THIS->MovePC(zoneID, x, y, z, heading); } else { - if (THIS->IsMerc()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePC) attempted to process a type Merc reference"); - else if (THIS->IsNPC()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePC) attempted to process a type NPC reference"); + if (THIS->IsMerc()) { + Log(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePC) attempted to process a type Merc reference"); + } + else if (THIS->IsNPC()) { + Log(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePC) attempted to process a type NPC reference"); + } #ifdef BOTS - else if (THIS->IsBot()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePC) attempted to process a type Bot reference"); + else if (THIS->IsBot()) { + Log(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePC) attempted to process a type Bot reference"); + } #endif - else - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePC) attempted to process an Unknown type reference"); + else { + Log(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePC) attempted to process an Unknown type reference"); + } Perl_croak(aTHX_ "THIS is not of type Client"); } @@ -1342,16 +1346,20 @@ XS(XS_Client_MovePCInstance) THIS->MovePC(zoneID, instanceID, x, y, z, heading); } else { - if (THIS->IsMerc()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePCInstance) attempted to process a type Merc reference"); - else if (THIS->IsNPC()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePCInstance) attempted to process a type NPC reference"); + if (THIS->IsMerc()) { + Log(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePCInstance) attempted to process a type Merc reference"); + } + else if (THIS->IsNPC()) { + Log(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePCInstance) attempted to process a type NPC reference"); + } #ifdef BOTS - else if (THIS->IsBot()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePCInstance) attempted to process a type Bot reference"); + else if (THIS->IsBot()) { + Log(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePCInstance) attempted to process a type Bot reference"); + } #endif - else - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePCInstance) attempted to process an Unknown type reference"); + else { + Log(Logs::Detail, Logs::None, "[CLIENT] Perl(XS_Client_MovePCInstance) attempted to process an Unknown type reference"); + } Perl_croak(aTHX_ "THIS is not of type Client"); diff --git a/zone/petitions.cpp b/zone/petitions.cpp index d3c350b5f..4ba73332d 100644 --- a/zone/petitions.cpp +++ b/zone/petitions.cpp @@ -252,7 +252,7 @@ void ZoneDatabase::InsertPetitionToDB(Petition* wpet) } #if EQDEBUG >= 5 - Log.Out(Logs::General, Logs::None, "New petition created"); + Log(Logs::General, Logs::None, "New petition created"); #endif } diff --git a/zone/pets.cpp b/zone/pets.cpp index a73f6b54d..39eeaeb5c 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -251,7 +251,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, PetRecord record; if(!database.GetPoweredPetEntry(pettype, act_power, &record)) { Message(13, "Unable to find data for pet %s", pettype); - Log.Out(Logs::General, Logs::Error, "Unable to find data for pet %s, check pets table.", pettype); + Log(Logs::General, Logs::Error, "Unable to find data for pet %s, check pets table.", pettype); return; } @@ -259,7 +259,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, const NPCType *base = database.LoadNPCTypesData(record.npc_type); if(base == nullptr) { Message(13, "Unable to load NPC data for pet %s", pettype); - Log.Out(Logs::General, Logs::Error, "Unable to load NPC data for pet %s (NPC ID %d), check pets and npc_types tables.", pettype, record.npc_type); + Log(Logs::General, Logs::Error, "Unable to load NPC data for pet %s (NPC ID %d), check pets and npc_types tables.", pettype, record.npc_type); return; } @@ -412,7 +412,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, npc_type->helmtexture = monster->helmtexture; npc_type->herosforgemodel = monster->herosforgemodel; } else - Log.Out(Logs::General, Logs::Error, "Error loading NPC data for monster summoning pet (NPC ID %d)", monsterid); + Log(Logs::General, Logs::Error, "Error loading NPC data for monster summoning pet (NPC ID %d)", monsterid); } @@ -714,7 +714,7 @@ bool ZoneDatabase::GetBasePetItems(int32 equipmentset, uint32 *items) { if (results.RowCount() != 1) { // invalid set reference, it doesn't exist - Log.Out(Logs::General, Logs::Error, "Error in GetBasePetItems equipment set '%d' does not exist", curset); + Log(Logs::General, Logs::Error, "Error in GetBasePetItems equipment set '%d' does not exist", curset); return false; } diff --git a/zone/quest_parser_collection.cpp b/zone/quest_parser_collection.cpp index 2c2086d8c..5604647f7 100644 --- a/zone/quest_parser_collection.cpp +++ b/zone/quest_parser_collection.cpp @@ -16,6 +16,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "../common/global_define.h" #include "../common/misc_functions.h" #include "../common/features.h" @@ -186,7 +187,7 @@ bool QuestParserCollection::SpellHasQuestSub(uint32 spell_id, QuestEventID evt) auto qiter = _interfaces.find(iter->second); return qiter->second->SpellHasQuestSub(spell_id, evt); } - } else { + } else if(_spell_quest_status[spell_id] != QuestFailedToLoad){ std::string filename; QuestInterface *qi = GetQIBySpellQuest(spell_id, filename); if(qi) { @@ -263,7 +264,7 @@ int QuestParserCollection::EventNPCLocal(QuestEventID evt, NPC* npc, Mob *init, auto qiter = _interfaces.find(iter->second); return qiter->second->EventNPC(evt, npc, init, data, extra_data, extra_pointers); } - } else { + } else if (_npc_quest_status[npc->GetNPCTypeID()] != QuestFailedToLoad){ std::string filename; QuestInterface *qi = GetQIByNPCQuest(npc->GetNPCTypeID(), filename); if(qi) { @@ -282,7 +283,8 @@ int QuestParserCollection::EventNPCGlobal(QuestEventID evt, NPC* npc, Mob *init, if(_global_npc_quest_status != QuestUnloaded && _global_npc_quest_status != QuestFailedToLoad) { auto qiter = _interfaces.find(_global_npc_quest_status); return qiter->second->EventGlobalNPC(evt, npc, init, data, extra_data, extra_pointers); - } else { + } + else if(_global_npc_quest_status != QuestFailedToLoad){ std::string filename; QuestInterface *qi = GetQIByGlobalNPCQuest(filename); if(qi) { @@ -380,7 +382,7 @@ int QuestParserCollection::EventItem(QuestEventID evt, Client *client, EQEmu::It return ret; } return DispatchEventItem(evt, client, item, mob, data, extra_data, extra_pointers); - } else { + } else if(_item_quest_status[item_id] != QuestFailedToLoad){ std::string filename; QuestInterface *qi = GetQIByItemQuest(item_script, filename); if(qi) { @@ -415,19 +417,21 @@ int QuestParserCollection::EventSpell(QuestEventID evt, NPC* npc, Client *client return ret; } return DispatchEventSpell(evt, npc, client, spell_id, extra_data, extra_pointers); - } else { + } + else if (_spell_quest_status[spell_id] != QuestFailedToLoad) { std::string filename; QuestInterface *qi = GetQIBySpellQuest(spell_id, filename); - if(qi) { + if (qi) { _spell_quest_status[spell_id] = qi->GetIdentifier(); qi->LoadSpellScript(filename, spell_id); int ret = DispatchEventSpell(evt, npc, client, spell_id, extra_data, extra_pointers); int i = qi->EventSpell(evt, npc, client, spell_id, extra_data, extra_pointers); - if(i != 0) { - ret = i; - } + if (i != 0) { + ret = i; + } return ret; - } else { + } + else { _spell_quest_status[spell_id] = QuestFailedToLoad; return DispatchEventSpell(evt, npc, client, spell_id, extra_data, extra_pointers); } @@ -444,7 +448,7 @@ int QuestParserCollection::EventEncounter(QuestEventID evt, std::string encounte auto qiter = _interfaces.find(iter->second); return qiter->second->EventEncounter(evt, encounter_name, data, extra_data, extra_pointers); } - } else { + } else if(_encounter_quest_status[encounter_name] != QuestFailedToLoad){ std::string filename; QuestInterface *qi = GetQIByEncounterQuest(encounter_name, filename); if(qi) { @@ -695,12 +699,15 @@ QuestInterface *QuestParserCollection::GetQIByGlobalNPCQuest(std::string &filena std::string tmp; FILE *f = nullptr; + + auto iter = _load_precedence.begin(); while(iter != _load_precedence.end()) { tmp = filename; auto ext = _extensions.find((*iter)->GetIdentifier()); tmp += "."; tmp += ext->second; + f = fopen(tmp.c_str(), "r"); if(f) { fclose(f); @@ -1043,7 +1050,7 @@ int QuestParserCollection::DispatchEventSpell(QuestEventID evt, NPC* npc, Client void QuestParserCollection::LoadPerlEventExportSettings(PerlEventExportSettings* perl_event_export_settings) { - Log.Out(Logs::General, Logs::Zone_Server, "Loading Perl Event Export Settings..."); + Log(Logs::General, Logs::Zone_Server, "Loading Perl Event Export Settings..."); /* Write Defaults First (All Enabled) */ for (int i = 0; i < _LargestEventID; i++){ diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 4668a1bbc..8c52460d6 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -157,7 +157,7 @@ void QuestManager::echo(int colour, const char *str) { void QuestManager::say(const char *str) { QuestManagerCurrentQuestVars(); if (!owner) { - Log.Out(Logs::General, Logs::Quests, "QuestManager::say called with nullptr owner. Probably syntax error in quest file."); + Log(Logs::General, Logs::Quests, "QuestManager::say called with nullptr owner. Probably syntax error in quest file."); return; } else { @@ -173,7 +173,7 @@ void QuestManager::say(const char *str) { void QuestManager::say(const char *str, uint8 language) { QuestManagerCurrentQuestVars(); if (!owner) { - Log.Out(Logs::General, Logs::Quests, "QuestManager::say called with nullptr owner. Probably syntax error in quest file."); + Log(Logs::General, Logs::Quests, "QuestManager::say called with nullptr owner. Probably syntax error in quest file."); return; } else { @@ -552,7 +552,7 @@ void QuestManager::stopalltimers(Mob *mob) { void QuestManager::emote(const char *str) { QuestManagerCurrentQuestVars(); if (!owner) { - Log.Out(Logs::General, Logs::Quests, "QuestManager::emote called with nullptr owner. Probably syntax error in quest file."); + Log(Logs::General, Logs::Quests, "QuestManager::emote called with nullptr owner. Probably syntax error in quest file."); return; } else { @@ -563,7 +563,7 @@ void QuestManager::emote(const char *str) { void QuestManager::shout(const char *str) { QuestManagerCurrentQuestVars(); if (!owner) { - Log.Out(Logs::General, Logs::Quests, "QuestManager::shout called with nullptr owner. Probably syntax error in quest file."); + Log(Logs::General, Logs::Quests, "QuestManager::shout called with nullptr owner. Probably syntax error in quest file."); return; } else { @@ -574,7 +574,7 @@ void QuestManager::shout(const char *str) { void QuestManager::shout2(const char *str) { QuestManagerCurrentQuestVars(); if (!owner) { - Log.Out(Logs::General, Logs::Quests, "QuestManager::shout2 called with nullptr owner. Probably syntax error in quest file."); + Log(Logs::General, Logs::Quests, "QuestManager::shout2 called with nullptr owner. Probably syntax error in quest file."); return; } else { @@ -593,7 +593,7 @@ void QuestManager::gmsay(const char *str, uint32 color, bool send_to_world, uint void QuestManager::depop(int npc_type) { QuestManagerCurrentQuestVars(); if (!owner || !owner->IsNPC()) { - Log.Out(Logs::General, Logs::Quests, "QuestManager::depop called with nullptr owner or non-NPC owner. Probably syntax error in quest file."); + Log(Logs::General, Logs::Quests, "QuestManager::depop called with nullptr owner or non-NPC owner. Probably syntax error in quest file."); return; } else { @@ -623,7 +623,7 @@ void QuestManager::depop(int npc_type) { void QuestManager::depop_withtimer(int npc_type) { QuestManagerCurrentQuestVars(); if (!owner || !owner->IsNPC()) { - Log.Out(Logs::General, Logs::Quests, "QuestManager::depop_withtimer called with nullptr owner or non-NPC owner. Probably syntax error in quest file."); + Log(Logs::General, Logs::Quests, "QuestManager::depop_withtimer called with nullptr owner or non-NPC owner. Probably syntax error in quest file."); return; } else { @@ -650,7 +650,7 @@ void QuestManager::depopall(int npc_type) { entity_list.DepopAll(npc_type); } else { - Log.Out(Logs::General, Logs::Quests, "QuestManager::depopall called with nullptr owner, non-NPC owner, or invalid NPC Type ID. Probably syntax error in quest file."); + Log(Logs::General, Logs::Quests, "QuestManager::depopall called with nullptr owner, non-NPC owner, or invalid NPC Type ID. Probably syntax error in quest file."); } } @@ -659,7 +659,7 @@ void QuestManager::depopzone(bool StartSpawnTimer) { zone->Depop(StartSpawnTimer); } else { - Log.Out(Logs::General, Logs::Quests, "QuestManager::depopzone called with nullptr zone. Probably syntax error in quest file."); + Log(Logs::General, Logs::Quests, "QuestManager::depopzone called with nullptr zone. Probably syntax error in quest file."); } } @@ -668,14 +668,14 @@ void QuestManager::repopzone() { zone->Repop(); } else { - Log.Out(Logs::General, Logs::Quests, "QuestManager::repopzone called with nullptr zone. Probably syntax error in quest file."); + Log(Logs::General, Logs::Quests, "QuestManager::repopzone called with nullptr zone. Probably syntax error in quest file."); } } void QuestManager::ConnectNodeToNode(int node1, int node2, int teleport, int doorid) { if (!node1 || !node2) { - Log.Out(Logs::General, Logs::Quests, "QuestManager::ConnectNodeToNode called without node1 or node2. Probably syntax error in quest file."); + Log(Logs::General, Logs::Quests, "QuestManager::ConnectNodeToNode called without node1 or node2. Probably syntax error in quest file."); } else { @@ -702,7 +702,7 @@ void QuestManager::ConnectNodeToNode(int node1, int node2, int teleport, int doo if (zone->pathing) { zone->pathing->ConnectNodeToNode(node1, node2, teleport, doorid); - Log.Out(Logs::Moderate, Logs::Quests, "QuestManager::ConnectNodeToNode connecting node %i to node %i.", node1, node2); + Log(Logs::Moderate, Logs::Quests, "QuestManager::ConnectNodeToNode connecting node %i to node %i.", node1, node2); } } } @@ -711,7 +711,7 @@ void QuestManager::AddNode(float x, float y, float z, float best_z, int32 reques { if (!x || !y || !z) { - Log.Out(Logs::General, Logs::Quests, "QuestManager::AddNode called without x, y, z. Probably syntax error in quest file."); + Log(Logs::General, Logs::Quests, "QuestManager::AddNode called without x, y, z. Probably syntax error in quest file."); } if (!best_z || best_z == 0) @@ -741,7 +741,7 @@ void QuestManager::AddNode(float x, float y, float z, float best_z, int32 reques if (zone->pathing) { zone->pathing->AddNode(x, y, z, best_z, requested_id); - Log.Out(Logs::Moderate, Logs::Quests, "QuestManager::AddNode adding node at (%i, %i, %i).", x, y, z); + Log(Logs::Moderate, Logs::Quests, "QuestManager::AddNode adding node at (%i, %i, %i).", x, y, z); } } @@ -1724,7 +1724,7 @@ void QuestManager::showgrid(int grid) { "ORDER BY `number`", grid, zone->GetZoneID()); auto results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Quests, "Error loading grid %d for showgrid(): %s", grid, results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Quests, "Error loading grid %d for showgrid(): %s", grid, results.ErrorMessage().c_str()); return; } @@ -2141,7 +2141,7 @@ bool QuestManager::istaskenabled(int taskid) { void QuestManager::tasksetselector(int tasksetid) { QuestManagerCurrentQuestVars(); - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] TaskSetSelector called for task set %i", tasksetid); + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSetSelector called for task set %i", tasksetid); if(RuleB(TaskSystem, EnableTaskSystem) && initiator && owner && taskmanager) initiator->TaskSetSelector(owner, tasksetid); } @@ -2747,7 +2747,7 @@ const char* QuestManager::saylink(char* Phrase, bool silent, const char* LinkNam std::string insert_query = StringFormat("INSERT INTO `saylink` (`phrase`) VALUES ('%s')", escaped_string); results = database.QueryDatabase(insert_query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error in saylink phrase queries", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in saylink phrase queries", results.ErrorMessage().c_str()); } else { results = database.QueryDatabase(query); if (results.Success()) { @@ -2755,7 +2755,7 @@ const char* QuestManager::saylink(char* Phrase, bool silent, const char* LinkNam for(auto row = results.begin(); row != results.end(); ++row) sayid = atoi(row[0]); } else { - Log.Out(Logs::General, Logs::Error, "Error in saylink phrase queries", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in saylink phrase queries", results.ErrorMessage().c_str()); } } } @@ -2914,7 +2914,7 @@ void QuestManager::voicetell(const char *str, int macronum, int racenum, int gen safe_delete(outapp); } else - Log.Out(Logs::General, Logs::Quests, "QuestManager::voicetell from %s. Client %s not found.", owner->GetName(), str); + Log(Logs::General, Logs::Quests, "QuestManager::voicetell from %s. Client %s not found.", owner->GetName(), str); } } diff --git a/zone/raids.cpp b/zone/raids.cpp index 070698e43..c9d4ee6c5 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -103,7 +103,7 @@ void Raid::AddMember(Client *c, uint32 group, bool rleader, bool groupleader, bo auto results = database.QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error inserting into raid members: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error inserting into raid members: %s", results.ErrorMessage().c_str()); } LearnMembers(); @@ -259,12 +259,12 @@ void Raid::SetRaidLeader(const char *wasLead, const char *name) std::string query = StringFormat("UPDATE raid_members SET israidleader = 0 WHERE name = '%s'", wasLead); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Set Raid Leader error: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Set Raid Leader error: %s\n", results.ErrorMessage().c_str()); query = StringFormat("UPDATE raid_members SET israidleader = 1 WHERE name = '%s'", name); results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Set Raid Leader error: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Set Raid Leader error: %s\n", results.ErrorMessage().c_str()); strn0cpy(leadername, name, 64); @@ -297,7 +297,7 @@ void Raid::SaveGroupLeaderAA(uint32 gid) safe_delete_array(queryBuffer); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to store LeadershipAA: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to store LeadershipAA: %s\n", results.ErrorMessage().c_str()); } void Raid::SaveRaidLeaderAA() @@ -311,7 +311,7 @@ void Raid::SaveRaidLeaderAA() safe_delete_array(queryBuffer); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to store LeadershipAA: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to store LeadershipAA: %s\n", results.ErrorMessage().c_str()); } void Raid::UpdateGroupAAs(uint32 gid) @@ -524,7 +524,7 @@ void Raid::CastGroupSpell(Mob* caster, uint16 spellid, uint32 gid) #endif } else{ - Log.Out(Logs::Detail, Logs::Spells, "Raid spell: %s is out of range %f at distance %f from %s", members[x].member->GetName(), range, distance, caster->GetName()); + Log(Logs::Detail, Logs::Spells, "Raid spell: %s is out of range %f at distance %f from %s", members[x].member->GetName(), range, distance, caster->GetName()); } } } @@ -825,7 +825,7 @@ void Raid::GroupBardPulse(Mob* caster, uint16 spellid, uint32 gid){ members[z].member->GetPet()->BardPulse(spellid, caster); #endif } else - Log.Out(Logs::Detail, Logs::Spells, "Group bard pulse: %s is out of range %f at distance %f from %s", members[z].member->GetName(), range, distance, caster->GetName()); + Log(Logs::Detail, Logs::Spells, "Group bard pulse: %s is out of range %f at distance %f from %s", members[z].member->GetName(), range, distance, caster->GetName()); } } } @@ -1433,7 +1433,7 @@ void Raid::GetRaidDetails() return; if (results.RowCount() == 0) { - Log.Out(Logs::General, Logs::Error, "Error getting raid details for raid %lu: %s", (unsigned long)GetID(), results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error getting raid details for raid %lu: %s", (unsigned long)GetID(), results.ErrorMessage().c_str()); return; } @@ -1465,7 +1465,7 @@ bool Raid::LearnMembers() return false; if(results.RowCount() == 0) { - Log.Out(Logs::General, Logs::Error, "Error getting raid members for raid %lu: %s", (unsigned long)GetID(), results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error getting raid members for raid %lu: %s", (unsigned long)GetID(), results.ErrorMessage().c_str()); disbandCheck = true; return false; } @@ -1671,7 +1671,7 @@ void Raid::SetGroupMentor(uint32 group_id, int percent, char *name) name, percent, group_id, GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to set raid group mentor: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to set raid group mentor: %s\n", results.ErrorMessage().c_str()); } void Raid::ClearGroupMentor(uint32 group_id) @@ -1686,7 +1686,7 @@ void Raid::ClearGroupMentor(uint32 group_id) group_id, GetID()); auto results = database.QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Unable to clear raid group mentor: %s\n", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Unable to clear raid group mentor: %s\n", results.ErrorMessage().c_str()); } // there isn't a nice place to add this in another function, unlike groups diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index ad5f3d89a..291ee9bb7 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -153,13 +153,13 @@ bool Spawn2::Process() { if (timer.Check()) { timer.Disable(); - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Timer has triggered", spawn2_id); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Timer has triggered", spawn2_id); //first check our spawn condition, if this isnt active //then we reset the timer and try again next time. if(condition_id != SC_AlwaysEnabled && !zone->spawn_conditions.Check(condition_id, condition_min_value)) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: spawning prevented by spawn condition %d", spawn2_id, condition_id); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: spawning prevented by spawn condition %d", spawn2_id, condition_id); Reset(); return(true); } @@ -170,14 +170,14 @@ bool Spawn2::Process() { } if (sg == nullptr) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Unable to locate spawn group %d. Disabling.", spawn2_id, spawngroup_id_); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Unable to locate spawn group %d. Disabling.", spawn2_id, spawngroup_id_); return false; } //have the spawn group pick an NPC for us uint32 npcid = sg->GetNPCType(); if (npcid == 0) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d did not yeild an NPC! not spawning.", spawn2_id, spawngroup_id_); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d did not yeild an NPC! not spawning.", spawn2_id, spawngroup_id_); Reset(); //try again later (why?) return(true); } @@ -185,7 +185,7 @@ bool Spawn2::Process() { //try to find our NPC type. const NPCType* tmp = database.LoadNPCTypesData(npcid); if (tmp == nullptr) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d yeilded an invalid NPC type %d", spawn2_id, spawngroup_id_, npcid); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d yeilded an invalid NPC type %d", spawn2_id, spawngroup_id_, npcid); Reset(); //try again later return(true); } @@ -194,7 +194,7 @@ bool Spawn2::Process() { { if(!entity_list.LimitCheckName(tmp->name)) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is unique and one already exists.", spawn2_id, spawngroup_id_, npcid); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is unique and one already exists.", spawn2_id, spawngroup_id_, npcid); timer.Start(5000); //try again in five seconds. return(true); } @@ -202,7 +202,7 @@ bool Spawn2::Process() { if(tmp->spawn_limit > 0) { if(!entity_list.LimitCheckType(npcid, tmp->spawn_limit)) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is over its spawn limit (%d)", spawn2_id, spawngroup_id_, npcid, tmp->spawn_limit); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d yeilded NPC type %d, which is over its spawn limit (%d)", spawn2_id, spawngroup_id_, npcid, tmp->spawn_limit); timer.Start(5000); //try again in five seconds. return(true); } @@ -230,10 +230,10 @@ bool Spawn2::Process() { if(sg->roamdist && sg->roambox[0] && sg->roambox[1] && sg->roambox[2] && sg->roambox[3] && sg->delay && sg->min_delay) npc->AI_SetRoambox(sg->roamdist,sg->roambox[0],sg->roambox[1],sg->roambox[2],sg->roambox[3],sg->delay,sg->min_delay); if(zone->InstantGrids()) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f).", spawn2_id, spawngroup_id_, npc->GetName(), npcid, x, y, z); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f).", spawn2_id, spawngroup_id_, npc->GetName(), npcid, x, y, z); LoadGrid(); } else { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f). Grid loading delayed.", spawn2_id, spawngroup_id_, tmp->name, npcid, x, y, z); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Group %d spawned %s (%d) at (%.3f, %.3f, %.3f). Grid loading delayed.", spawn2_id, spawngroup_id_, tmp->name, npcid, x, y, z); } } return true; @@ -258,7 +258,7 @@ void Spawn2::LoadGrid() { //dont set an NPC's grid until its loaded for them. npcthis->SetGrid(grid_); npcthis->AssignWaypoints(grid_); - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Loading grid %d for %s", spawn2_id, grid_, npcthis->GetName()); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Loading grid %d for %s", spawn2_id, grid_, npcthis->GetName()); } @@ -269,21 +269,21 @@ void Spawn2::LoadGrid() { void Spawn2::Reset() { timer.Start(resetTimer()); npcthis = nullptr; - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset, repop in %d ms", spawn2_id, timer.GetRemainingTime()); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset, repop in %d ms", spawn2_id, timer.GetRemainingTime()); } void Spawn2::Depop() { timer.Disable(); - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset, repop disabled", spawn2_id); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset, repop disabled", spawn2_id); npcthis = nullptr; } void Spawn2::Repop(uint32 delay) { if (delay == 0) { timer.Trigger(); - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset, repop immediately.", spawn2_id); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset, repop immediately.", spawn2_id); } else { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset for repop, repop in %d ms", spawn2_id, delay); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset for repop, repop in %d ms", spawn2_id, delay); timer.Start(delay); } npcthis = nullptr; @@ -325,7 +325,7 @@ void Spawn2::ForceDespawn() cur = despawnTimer(dtimer); } - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d set despawn timer to %d ms.", spawn2_id, spawngroup_id_, cur); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn group %d set despawn timer to %d ms.", spawn2_id, spawngroup_id_, cur); timer.Start(cur); } @@ -346,7 +346,7 @@ void Spawn2::DeathReset(bool realdeath) if(spawn2_id) { database.UpdateRespawnTime(spawn2_id, zone->GetInstanceID(), (cur/1000)); - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset by death, repop in %d ms", spawn2_id, timer.GetRemainingTime()); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Spawn reset by death, repop in %d ms", spawn2_id, timer.GetRemainingTime()); //store it to database too } } @@ -631,12 +631,12 @@ void Spawn2::SpawnConditionChanged(const SpawnCondition &c, int16 old_value) { if(GetSpawnCondition() != c.condition_id) return; - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Notified that our spawn condition %d has changed from %d to %d. Our min value is %d.", spawn2_id, c.condition_id, old_value, c.value, condition_min_value); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Notified that our spawn condition %d has changed from %d to %d. Our min value is %d.", spawn2_id, c.condition_id, old_value, c.value, condition_min_value); bool old_state = (old_value >= condition_min_value); bool new_state = (c.value >= condition_min_value); if(old_state == new_state) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our threshold for this condition was not crossed. Doing nothing.", spawn2_id); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our threshold for this condition was not crossed. Doing nothing.", spawn2_id); return; //no change } @@ -644,50 +644,50 @@ void Spawn2::SpawnConditionChanged(const SpawnCondition &c, int16 old_value) { switch(c.on_change) { case SpawnCondition::DoNothing: //that was easy. - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Taking no action on existing spawn.", spawn2_id, new_state?"enabled":"disabled"); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Taking no action on existing spawn.", spawn2_id, new_state?"enabled":"disabled"); break; case SpawnCondition::DoDepop: - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Depoping our mob.", spawn2_id, new_state?"enabled":"disabled"); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Depoping our mob.", spawn2_id, new_state?"enabled":"disabled"); if(npcthis != nullptr) npcthis->Depop(false); //remove the current mob Reset(); //reset our spawn timer break; case SpawnCondition::DoRepop: - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Forcing a repop.", spawn2_id, new_state?"enabled":"disabled"); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Forcing a repop.", spawn2_id, new_state?"enabled":"disabled"); if(npcthis != nullptr) npcthis->Depop(false); //remove the current mob Repop(); //repop break; case SpawnCondition::DoRepopIfReady: - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Forcing a repop if repsawn timer is expired.", spawn2_id, new_state?"enabled":"disabled"); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Forcing a repop if repsawn timer is expired.", spawn2_id, new_state?"enabled":"disabled"); if(npcthis != nullptr) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our npcthis is currently not null. The zone thinks it is %s. Forcing a depop.", spawn2_id, npcthis->GetName()); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our npcthis is currently not null. The zone thinks it is %s. Forcing a depop.", spawn2_id, npcthis->GetName()); npcthis->Depop(false); //remove the current mob npcthis = nullptr; } if(new_state) { // only get repawn timer remaining when the SpawnCondition is enabled. timer_remaining = database.GetSpawnTimeLeft(spawn2_id,zone->GetInstanceID()); - Log.Out(Logs::Detail, Logs::Spawns,"Spawn2 %d: Our condition is now %s. The respawn timer_remaining is %d. Forcing a repop if it is <= 0.", spawn2_id, new_state?"enabled":"disabled", timer_remaining); + Log(Logs::Detail, Logs::Spawns,"Spawn2 %d: Our condition is now %s. The respawn timer_remaining is %d. Forcing a repop if it is <= 0.", spawn2_id, new_state?"enabled":"disabled", timer_remaining); if(timer_remaining <= 0) Repop(); } else { - Log.Out(Logs::Detail, Logs::Spawns,"Spawn2 %d: Our condition is now %s. Not checking respawn timer.", spawn2_id, new_state?"enabled":"disabled"); + Log(Logs::Detail, Logs::Spawns,"Spawn2 %d: Our condition is now %s. Not checking respawn timer.", spawn2_id, new_state?"enabled":"disabled"); } break; default: if(c.on_change < SpawnCondition::DoSignalMin) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Invalid on-change action %d.", spawn2_id, new_state?"enabled":"disabled", c.on_change); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Invalid on-change action %d.", spawn2_id, new_state?"enabled":"disabled", c.on_change); return; //unknown onchange action } int signal_id = c.on_change - SpawnCondition::DoSignalMin; - Log.Out(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Signaling our mob with %d.", spawn2_id, new_state?"enabled":"disabled", signal_id); + Log(Logs::Detail, Logs::Spawns, "Spawn2 %d: Our condition is now %s. Signaling our mob with %d.", spawn2_id, new_state?"enabled":"disabled", signal_id); if(npcthis != nullptr) npcthis->SignalNPC(signal_id); } } void Zone::SpawnConditionChanged(const SpawnCondition &c, int16 old_value) { - Log.Out(Logs::Detail, Logs::Spawns, "Zone notified that spawn condition %d has changed from %d to %d. Notifying all spawn points.", c.condition_id, old_value, c.value); + Log(Logs::Detail, Logs::Spawns, "Zone notified that spawn condition %d has changed from %d to %d. Notifying all spawn points.", c.condition_id, old_value, c.value); LinkedListIterator iterator(spawn2_list); @@ -757,7 +757,7 @@ void SpawnConditionManager::Process() { EQTime::AddMinutes(cevent.period, &cevent.next); std::string t; EQTime::ToString(&cevent.next, t); - Log.Out(Logs::Detail, Logs::Spawns, "Event %d: Will trigger again in %d EQ minutes at %s.", cevent.id, cevent.period, t.c_str()); + Log(Logs::Detail, Logs::Spawns, "Event %d: Will trigger again in %d EQ minutes at %s.", cevent.id, cevent.period, t.c_str()); //save the next event time in the DB UpdateDBEvent(cevent); //find the next closest event timer. @@ -776,7 +776,7 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) { std::map::iterator condi; condi = spawn_conditions.find(event.condition_id); if(condi == spawn_conditions.end()) { - Log.Out(Logs::Detail, Logs::Spawns, "Event %d: Unable to find condition %d to execute on.", event.id, event.condition_id); + Log(Logs::Detail, Logs::Spawns, "Event %d: Unable to find condition %d to execute on.", event.id, event.condition_id); return; //unable to find the spawn condition to operate on } @@ -784,7 +784,7 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) { zone->zone_time.GetCurrentEQTimeOfDay(&tod); if(event.strict && (event.next.hour != tod.hour || event.next.day != tod.day || event.next.month != tod.month || event.next.year != tod.year)) { - Log.Out(Logs::Detail, Logs::Spawns, "Event %d: Unable to execute. Condition is strict, and event time has already passed.", event.id); + Log(Logs::Detail, Logs::Spawns, "Event %d: Unable to execute. Condition is strict, and event time has already passed.", event.id); return; } @@ -796,26 +796,26 @@ void SpawnConditionManager::ExecEvent(SpawnEvent &event, bool send_update) { switch(event.action) { case SpawnEvent::ActionSet: new_value = event.argument; - Log.Out(Logs::Detail, Logs::Spawns, "Event %d: Executing. Setting condition %d to %d.", event.id, event.condition_id, event.argument); + Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Setting condition %d to %d.", event.id, event.condition_id, event.argument); break; case SpawnEvent::ActionAdd: new_value += event.argument; - Log.Out(Logs::Detail, Logs::Spawns, "Event %d: Executing. Adding %d to condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value); + Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Adding %d to condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value); break; case SpawnEvent::ActionSubtract: new_value -= event.argument; - Log.Out(Logs::Detail, Logs::Spawns, "Event %d: Executing. Subtracting %d from condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value); + Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Subtracting %d from condition %d, yeilding %d.", event.id, event.argument, event.condition_id, new_value); break; case SpawnEvent::ActionMultiply: new_value *= event.argument; - Log.Out(Logs::Detail, Logs::Spawns, "Event %d: Executing. Multiplying condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value); + Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Multiplying condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value); break; case SpawnEvent::ActionDivide: new_value /= event.argument; - Log.Out(Logs::Detail, Logs::Spawns, "Event %d: Executing. Dividing condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value); + Log(Logs::Detail, Logs::Spawns, "Event %d: Executing. Dividing condition %d by %d, yeilding %d.", event.id, event.condition_id, event.argument, new_value); break; default: - Log.Out(Logs::Detail, Logs::Spawns, "Event %d: Invalid event action type %d", event.id, event.action); + Log(Logs::Detail, Logs::Spawns, "Event %d: Invalid event action type %d", event.id, event.action); return; } @@ -885,7 +885,7 @@ bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std: std::string timeAsString; EQTime::ToString(&event.next, timeAsString); - Log.Out(Logs::Detail, Logs::Spawns, "(LoadDBEvent) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d. Will trigger at %s", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict, timeAsString.c_str()); + Log(Logs::Detail, Logs::Spawns, "(LoadDBEvent) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d. Will trigger at %s", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict, timeAsString.c_str()); return true; } @@ -912,7 +912,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in cond.on_change = (SpawnCondition::OnChange) atoi(row[1]); spawn_conditions[cond.condition_id] = cond; - Log.Out(Logs::Detail, Logs::Spawns, "Loaded spawn condition %d with value %d and on_change %d", cond.condition_id, cond.value, cond.on_change); + Log(Logs::Detail, Logs::Spawns, "Loaded spawn condition %d with value %d and on_change %d", cond.condition_id, cond.value, cond.on_change); } //load values @@ -949,7 +949,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in event.period = atoi(row[2]); if(event.period == 0) { - Log.Out(Logs::General, Logs::Error, "Refusing to load spawn event #%d because it has a period of 0\n", event.id); + Log(Logs::General, Logs::Error, "Refusing to load spawn event #%d because it has a period of 0\n", event.id); continue; } @@ -966,7 +966,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in spawn_events.push_back(event); - Log.Out(Logs::Detail, Logs::Spawns, "(LoadSpawnConditions) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict); + Log(Logs::Detail, Logs::Spawns, "(LoadSpawnConditions) Loaded %s spawn event %d on condition %d with period %d, action %d, argument %d, strict %d", event.enabled? "enabled": "disabled", event.id, event.condition_id, event.period, event.action, event.argument, event.strict); } //now we need to catch up on events that happened while we were away @@ -1001,7 +1001,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in //watch for special case of all 0s, which means to reset next to now if(cevent.next.year == 0 && cevent.next.month == 0 && cevent.next.day == 0 && cevent.next.hour == 0 && cevent.next.minute == 0) { - Log.Out(Logs::Detail, Logs::Spawns, "Initial next trigger time set for spawn event %d", cevent.id); + Log(Logs::Detail, Logs::Spawns, "Initial next trigger time set for spawn event %d", cevent.id); memcpy(&cevent.next, &tod, sizeof(cevent.next)); //add one period EQTime::AddMinutes(cevent.period, &cevent.next); @@ -1012,7 +1012,7 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in bool ran = false; while(EQTime::IsTimeBefore(&tod, &cevent.next)) { - Log.Out(Logs::Detail, Logs::Spawns, "Catch up triggering on event %d", cevent.id); + Log(Logs::Detail, Logs::Spawns, "Catch up triggering on event %d", cevent.id); //this event has been triggered. //execute the event if(!cevent.strict || StrictCheck) @@ -1054,10 +1054,12 @@ void SpawnConditionManager::FindNearestEvent() { } } } - if(next_id == -1) - Log.Out(Logs::Detail, Logs::Spawns, "No spawn events enabled. Disabling next event."); - else - Log.Out(Logs::Detail, Logs::Spawns, "Next event determined to be event %d", next_id); + if (next_id == -1) { + Log(Logs::Detail, Logs::Spawns, "No spawn events enabled. Disabling next event."); + } + else { + Log(Logs::Detail, Logs::Spawns, "Next event determined to be event %d", next_id); + } } void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance_id, uint16 condition_id, int16 new_value, bool world_update) @@ -1069,14 +1071,14 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance std::map::iterator condi; condi = spawn_conditions.find(condition_id); if(condi == spawn_conditions.end()) { - Log.Out(Logs::Detail, Logs::Spawns, "Condition update received from world for %d, but we do not have that conditon.", condition_id); + Log(Logs::Detail, Logs::Spawns, "Condition update received from world for %d, but we do not have that conditon.", condition_id); return; //unable to find the spawn condition } SpawnCondition &cond = condi->second; if(cond.value == new_value) { - Log.Out(Logs::Detail, Logs::Spawns, "Condition update received from world for %d with value %d, which is what we already have.", condition_id, new_value); + Log(Logs::Detail, Logs::Spawns, "Condition update received from world for %d with value %d, which is what we already have.", condition_id, new_value); return; } @@ -1085,7 +1087,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance //set our local value cond.value = new_value; - Log.Out(Logs::Detail, Logs::Spawns, "Condition update received from world for %d with value %d", condition_id, new_value); + Log(Logs::Detail, Logs::Spawns, "Condition update received from world for %d with value %d", condition_id, new_value); //now we have to test each spawn point to see if it changed. zone->SpawnConditionChanged(cond, old_value); @@ -1096,14 +1098,14 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance std::map::iterator condi; condi = spawn_conditions.find(condition_id); if(condi == spawn_conditions.end()) { - Log.Out(Logs::Detail, Logs::Spawns, "Local Condition update requested for %d, but we do not have that conditon.", condition_id); + Log(Logs::Detail, Logs::Spawns, "Local Condition update requested for %d, but we do not have that conditon.", condition_id); return; //unable to find the spawn condition } SpawnCondition &cond = condi->second; if(cond.value == new_value) { - Log.Out(Logs::Detail, Logs::Spawns, "Local Condition update requested for %d with value %d, which is what we already have.", condition_id, new_value); + Log(Logs::Detail, Logs::Spawns, "Local Condition update requested for %d with value %d, which is what we already have.", condition_id, new_value); return; } @@ -1114,7 +1116,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance //save it in the DB too UpdateDBCondition(zone_short, instance_id, condition_id, new_value); - Log.Out(Logs::Detail, Logs::Spawns, "Local Condition update requested for %d with value %d", condition_id, new_value); + Log(Logs::Detail, Logs::Spawns, "Local Condition update requested for %d with value %d", condition_id, new_value); //now we have to test each spawn point to see if it changed. zone->SpawnConditionChanged(cond, old_value); @@ -1124,7 +1126,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance //this is a remote spawn condition, update the DB and send //an update packet to the zone if its up - Log.Out(Logs::Detail, Logs::Spawns, "Remote spawn condition %d set to %d. Updating DB and notifying world.", condition_id, new_value); + Log(Logs::Detail, Logs::Spawns, "Remote spawn condition %d set to %d. Updating DB and notifying world.", condition_id, new_value); UpdateDBCondition(zone_short, instance_id, condition_id, new_value); @@ -1144,7 +1146,7 @@ void SpawnConditionManager::SetCondition(const char *zone_short, uint32 instance void SpawnConditionManager::ReloadEvent(uint32 event_id) { std::string zone_short_name; - Log.Out(Logs::Detail, Logs::Spawns, "Requested to reload event %d from the database.", event_id); + Log(Logs::Detail, Logs::Spawns, "Requested to reload event %d from the database.", event_id); //first look for the event in our local event list std::vector::iterator cur,end; @@ -1157,7 +1159,7 @@ void SpawnConditionManager::ReloadEvent(uint32 event_id) { //load the event into the old event slot if(!LoadDBEvent(event_id, cevent, zone_short_name)) { //unable to find the event in the database... - Log.Out(Logs::Detail, Logs::Spawns, "Failed to reload event %d from the database.", event_id); + Log(Logs::Detail, Logs::Spawns, "Failed to reload event %d from the database.", event_id); return; } //sync up our nearest event @@ -1170,7 +1172,7 @@ void SpawnConditionManager::ReloadEvent(uint32 event_id) { SpawnEvent e; if(!LoadDBEvent(event_id, e, zone_short_name)) { //unable to find the event in the database... - Log.Out(Logs::Detail, Logs::Spawns, "Failed to reload event %d from the database.", event_id); + Log(Logs::Detail, Logs::Spawns, "Failed to reload event %d from the database.", event_id); return; } @@ -1187,7 +1189,7 @@ void SpawnConditionManager::ReloadEvent(uint32 event_id) { void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool strict, bool reset_base) { - Log.Out(Logs::Detail, Logs::Spawns, "Request to %s spawn event %d %sresetting trigger time", enabled?"enable":"disable", event_id, reset_base?"":"without "); + Log(Logs::Detail, Logs::Spawns, "Request to %s spawn event %d %sresetting trigger time", enabled?"enable":"disable", event_id, reset_base?"":"without "); //first look for the event in our local event list std::vector::iterator cur,end; @@ -1202,13 +1204,13 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri cevent.enabled = enabled; cevent.strict = strict; if(reset_base) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone. State set. Trigger time reset (period %d).", event_id, cevent.period); + Log(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone. State set. Trigger time reset (period %d).", event_id, cevent.period); //start with the time now zone->zone_time.GetCurrentEQTimeOfDay(&cevent.next); //advance the next time by our period EQTime::AddMinutes(cevent.period, &cevent.next); } else { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone. State changed.", event_id); + Log(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone. State changed.", event_id); } //save the event in the DB @@ -1217,7 +1219,7 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri //sync up our nearest event FindNearestEvent(); } else { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone but no change was needed.", event_id); + Log(Logs::Detail, Logs::Spawns, "Spawn event %d located in this zone but no change was needed.", event_id); } //even if we dont change anything, we still found it return; @@ -1236,24 +1238,24 @@ void SpawnConditionManager::ToggleEvent(uint32 event_id, bool enabled, bool stri SpawnEvent e; std::string zone_short_name; if(!LoadDBEvent(event_id, e, zone_short_name)) { - Log.Out(Logs::Detail, Logs::Spawns, "Unable to find spawn event %d in the database.", event_id); + Log(Logs::Detail, Logs::Spawns, "Unable to find spawn event %d in the database.", event_id); //unable to find the event in the database... return; } if(e.enabled == enabled && !reset_base) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn event %d is not located in this zone but no change was needed.", event_id); + Log(Logs::Detail, Logs::Spawns, "Spawn event %d is not located in this zone but no change was needed.", event_id); return; //no changes. } e.enabled = enabled; if(reset_base) { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn event %d is in zone %s. State set. Trigger time reset (period %d). Notifying world.", event_id, zone_short_name.c_str(), e.period); + Log(Logs::Detail, Logs::Spawns, "Spawn event %d is in zone %s. State set. Trigger time reset (period %d). Notifying world.", event_id, zone_short_name.c_str(), e.period); //start with the time now zone->zone_time.GetCurrentEQTimeOfDay(&e.next); //advance the next time by our period EQTime::AddMinutes(e.period, &e.next); } else { - Log.Out(Logs::Detail, Logs::Spawns, "Spawn event %d is in zone %s. State changed. Notifying world.", event_id, zone_short_name.c_str(), e.period); + Log(Logs::Detail, Logs::Spawns, "Spawn event %d is in zone %s. State changed. Notifying world.", event_id, zone_short_name.c_str(), e.period); } //save the event in the DB UpdateDBEvent(e); @@ -1278,7 +1280,7 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc condi = spawn_conditions.find(condition_id); if(condi == spawn_conditions.end()) { - Log.Out(Logs::Detail, Logs::Spawns, "Unable to find local condition %d in Get request.", condition_id); + Log(Logs::Detail, Logs::Spawns, "Unable to find local condition %d in Get request.", condition_id); return(0); //unable to find the spawn condition } @@ -1293,12 +1295,12 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc zone_short, instance_id, condition_id); auto results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::Detail, Logs::Spawns, "Unable to query remote condition %d from zone %s in Get request.", condition_id, zone_short); + Log(Logs::Detail, Logs::Spawns, "Unable to query remote condition %d from zone %s in Get request.", condition_id, zone_short); return 0; //dunno a better thing to do... } if (results.RowCount() == 0) { - Log.Out(Logs::Detail, Logs::Spawns, "Unable to load remote condition %d from zone %s in Get request.", condition_id, zone_short); + Log(Logs::Detail, Logs::Spawns, "Unable to load remote condition %d from zone %s in Get request.", condition_id, zone_short); return 0; //dunno a better thing to do... } diff --git a/zone/spawngroup.cpp b/zone/spawngroup.cpp index 94b2ed285..7cb5cd803 100644 --- a/zone/spawngroup.cpp +++ b/zone/spawngroup.cpp @@ -51,7 +51,7 @@ SpawnGroup::SpawnGroup( uint32 in_id, char* name, int in_group_spawn_limit, floa uint32 SpawnGroup::GetNPCType() { #if EQDEBUG >= 10 - Log.Out(Logs::General, Logs::None, "SpawnGroup[%08x]::GetNPCType()", (uint32) this); + Log(Logs::General, Logs::None, "SpawnGroup[%08x]::GetNPCType()", (uint32) this); #endif int npcType = 0; int totalchance = 0; @@ -169,7 +169,7 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG zone_name); results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error2 in PopulateZoneLists query '%'", query.c_str()); + Log(Logs::General, Logs::Error, "Error2 in PopulateZoneLists query '%'", query.c_str()); return false; } @@ -198,7 +198,7 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList *spawn_g spawngroupid); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error2 in PopulateZoneLists query %s", query.c_str()); + Log(Logs::General, Logs::Error, "Error2 in PopulateZoneLists query %s", query.c_str()); return false; } @@ -216,7 +216,7 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawngroupid, SpawnGroupList *spawn_g spawngroupid); results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error3 in PopulateZoneLists query '%s'", query.c_str()); + Log(Logs::General, Logs::Error, "Error3 in PopulateZoneLists query '%s'", query.c_str()); return false; } diff --git a/zone/special_attacks.cpp b/zone/special_attacks.cpp index 1508d4b59..4754efce3 100644 --- a/zone/special_attacks.cpp +++ b/zone/special_attacks.cpp @@ -491,7 +491,7 @@ int Mob::MonkSpecialAttack(Mob *other, uint8 unchecked_type) reuse = KickReuseTime; break; default: - Log.Out(Logs::Detail, Logs::Attack, "Invalid special attack type %d attempted", unchecked_type); + Log(Logs::Detail, Logs::Attack, "Invalid special attack type %d attempted", unchecked_type); return (1000); /* nice long delay for them, the caller depends on this! */ } @@ -629,7 +629,7 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) { //make sure the attack and ranged timers are up //if the ranged timer is disabled, then they have no ranged weapon and shouldent be attacking anyhow if(!CanDoubleAttack && ((attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check()))) { - Log.Out(Logs::Detail, Logs::Combat, "Throwing attack canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); + Log(Logs::Detail, Logs::Combat, "Throwing attack canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); // The server and client timers are not exact matches currently, so this would spam too often if enabled //Message(0, "Error: Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); return; @@ -641,12 +641,12 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) { const EQEmu::ItemInstance* Ammo = m_inv[EQEmu::inventory::slotAmmo]; if (!RangeWeapon || !RangeWeapon->IsClassCommon()) { - Log.Out(Logs::Detail, Logs::Combat, "Ranged attack canceled. Missing or invalid ranged weapon (%d) in slot %d", GetItemIDAt(EQEmu::inventory::slotRange), EQEmu::inventory::slotRange); + Log(Logs::Detail, Logs::Combat, "Ranged attack canceled. Missing or invalid ranged weapon (%d) in slot %d", GetItemIDAt(EQEmu::inventory::slotRange), EQEmu::inventory::slotRange); Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have no bow!", GetItemIDAt(EQEmu::inventory::slotRange)); return; } if (!Ammo || !Ammo->IsClassCommon()) { - Log.Out(Logs::Detail, Logs::Combat, "Ranged attack canceled. Missing or invalid ammo item (%d) in slot %d", GetItemIDAt(EQEmu::inventory::slotAmmo), EQEmu::inventory::slotAmmo); + Log(Logs::Detail, Logs::Combat, "Ranged attack canceled. Missing or invalid ammo item (%d) in slot %d", GetItemIDAt(EQEmu::inventory::slotAmmo), EQEmu::inventory::slotAmmo); Message(0, "Error: Ammo: GetItem(%i)==0, you have no ammo!", GetItemIDAt(EQEmu::inventory::slotAmmo)); return; } @@ -655,17 +655,17 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) { const EQEmu::ItemData* AmmoItem = Ammo->GetItem(); if (RangeItem->ItemType != EQEmu::item::ItemTypeBow) { - Log.Out(Logs::Detail, Logs::Combat, "Ranged attack canceled. Ranged item is not a bow. type %d.", RangeItem->ItemType); + Log(Logs::Detail, Logs::Combat, "Ranged attack canceled. Ranged item is not a bow. type %d.", RangeItem->ItemType); Message(0, "Error: Rangeweapon: Item %d is not a bow.", RangeWeapon->GetID()); return; } if (AmmoItem->ItemType != EQEmu::item::ItemTypeArrow) { - Log.Out(Logs::Detail, Logs::Combat, "Ranged attack canceled. Ammo item is not an arrow. type %d.", AmmoItem->ItemType); + Log(Logs::Detail, Logs::Combat, "Ranged attack canceled. Ammo item is not an arrow. type %d.", AmmoItem->ItemType); Message(0, "Error: Ammo: type %d != %d, you have the wrong type of ammo!", AmmoItem->ItemType, EQEmu::item::ItemTypeArrow); return; } - Log.Out(Logs::Detail, Logs::Combat, "Shooting %s with bow %s (%d) and arrow %s (%d)", other->GetName(), RangeItem->Name, RangeItem->ID, AmmoItem->Name, AmmoItem->ID); + Log(Logs::Detail, Logs::Combat, "Shooting %s with bow %s (%d) and arrow %s (%d)", other->GetName(), RangeItem->Name, RangeItem->ID, AmmoItem->Name, AmmoItem->ID); //look for ammo in inventory if we only have 1 left... if(Ammo->GetCharges() == 1) { @@ -692,7 +692,7 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) { Ammo = baginst; ammo_slot = m_inv.CalcSlotId(r, i); found = true; - Log.Out(Logs::Detail, Logs::Combat, "Using ammo from quiver stack at slot %d. %d in stack.", ammo_slot, Ammo->GetCharges()); + Log(Logs::Detail, Logs::Combat, "Using ammo from quiver stack at slot %d. %d in stack.", ammo_slot, Ammo->GetCharges()); break; } } @@ -707,17 +707,17 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) { if (aslot != INVALID_INDEX) { ammo_slot = aslot; Ammo = m_inv[aslot]; - Log.Out(Logs::Detail, Logs::Combat, "Using ammo from inventory stack at slot %d. %d in stack.", ammo_slot, Ammo->GetCharges()); + Log(Logs::Detail, Logs::Combat, "Using ammo from inventory stack at slot %d. %d in stack.", ammo_slot, Ammo->GetCharges()); } } } float range = RangeItem->Range + AmmoItem->Range + GetRangeDistTargetSizeMod(GetTarget()); - Log.Out(Logs::Detail, Logs::Combat, "Calculated bow range to be %.1f", range); + Log(Logs::Detail, Logs::Combat, "Calculated bow range to be %.1f", range); range *= range; float dist = DistanceSquared(m_Position, other->GetPosition()); if(dist > range) { - Log.Out(Logs::Detail, Logs::Combat, "Ranged attack out of range... client should catch this. (%f > %f).\n", dist, range); + Log(Logs::Detail, Logs::Combat, "Ranged attack out of range... client should catch this. (%f > %f).\n", dist, range); Message_StringID(13,TARGET_OUT_OF_RANGE);//Client enforces range and sends the message, this is a backup just incase. return; } @@ -745,9 +745,9 @@ void Client::RangedAttack(Mob* other, bool CanDoubleAttack) { if (RangeItem->ExpendableArrow || !ChanceAvoidConsume || (ChanceAvoidConsume < 100 && zone->random.Int(0,99) > ChanceAvoidConsume)){ DeleteItemInInventory(ammo_slot, 1, true); - Log.Out(Logs::Detail, Logs::Combat, "Consumed one arrow from slot %d", ammo_slot); + Log(Logs::Detail, Logs::Combat, "Consumed one arrow from slot %d", ammo_slot); } else { - Log.Out(Logs::Detail, Logs::Combat, "Endless Quiver prevented ammo consumption."); + Log(Logs::Detail, Logs::Combat, "Endless Quiver prevented ammo consumption."); } CheckIncreaseSkill(EQEmu::skills::SkillArchery, GetTarget(), -15); @@ -807,7 +807,7 @@ void Mob::DoArcheryAttackDmg(Mob *other, const EQEmu::ItemInstance *RangeWeapon, SendItemAnimation(other, AmmoItem, EQEmu::skills::SkillArchery); } - Log.Out(Logs::Detail, Logs::Combat, "Ranged attack hit %s.", other->GetName()); + Log(Logs::Detail, Logs::Combat, "Ranged attack hit %s.", other->GetName()); uint32 hate = 0; int TotalDmg = 0; @@ -838,12 +838,14 @@ void Mob::DoArcheryAttackDmg(Mob *other, const EQEmu::ItemInstance *RangeWeapon, int MaxDmg = WDmg + ADmg; hate = ((WDmg + ADmg)); - if (RuleB(Combat, ProjectileDmgOnImpact)) - Log.Out(Logs::Detail, Logs::Combat, "Bow and Arrow DMG %d, Max Damage %d.", WDmg, + if (RuleB(Combat, ProjectileDmgOnImpact)) { + Log(Logs::Detail, Logs::Combat, "Bow and Arrow DMG %d, Max Damage %d.", WDmg, MaxDmg); - else - Log.Out(Logs::Detail, Logs::Combat, "Bow DMG %d, Arrow DMG %d, Max Damage %d.", WDmg, + } + else { + Log(Logs::Detail, Logs::Combat, "Bow DMG %d, Arrow DMG %d, Max Damage %d.", WDmg, ADmg, MaxDmg); + } if (MaxDmg == 0) MaxDmg = 1; @@ -958,7 +960,6 @@ void Mob::ProjectileAttack() { if (!HasProjectileAttack()) return; - ; Mob *target = nullptr; bool disable = true; @@ -1085,7 +1086,7 @@ void NPC::RangedAttack(Mob* other) //make sure the attack and ranged timers are up //if the ranged timer is disabled, then they have no ranged weapon and shouldent be attacking anyhow if((attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check())){ - Log.Out(Logs::Detail, Logs::Combat, "Archery canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); + Log(Logs::Detail, Logs::Combat, "Archery canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); return; } @@ -1221,7 +1222,7 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51 //make sure the attack and ranged timers are up //if the ranged timer is disabled, then they have no ranged weapon and shouldent be attacking anyhow if((!CanDoubleAttack && (attack_timer.Enabled() && !attack_timer.Check(false)) || (ranged_timer.Enabled() && !ranged_timer.Check()))) { - Log.Out(Logs::Detail, Logs::Combat, "Throwing attack canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); + Log(Logs::Detail, Logs::Combat, "Throwing attack canceled. Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); // The server and client timers are not exact matches currently, so this would spam too often if enabled //Message(0, "Error: Timer not up. Attack %d, ranged %d", attack_timer.GetRemainingTime(), ranged_timer.GetRemainingTime()); return; @@ -1231,19 +1232,19 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51 const EQEmu::ItemInstance* RangeWeapon = m_inv[EQEmu::inventory::slotRange]; if (!RangeWeapon || !RangeWeapon->IsClassCommon()) { - Log.Out(Logs::Detail, Logs::Combat, "Ranged attack canceled. Missing or invalid ranged weapon (%d) in slot %d", GetItemIDAt(EQEmu::inventory::slotRange), EQEmu::inventory::slotRange); + Log(Logs::Detail, Logs::Combat, "Ranged attack canceled. Missing or invalid ranged weapon (%d) in slot %d", GetItemIDAt(EQEmu::inventory::slotRange), EQEmu::inventory::slotRange); Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have nothing to throw!", GetItemIDAt(EQEmu::inventory::slotRange)); return; } const EQEmu::ItemData* item = RangeWeapon->GetItem(); if (item->ItemType != EQEmu::item::ItemTypeLargeThrowing && item->ItemType != EQEmu::item::ItemTypeSmallThrowing) { - Log.Out(Logs::Detail, Logs::Combat, "Ranged attack canceled. Ranged item %d is not a throwing weapon. type %d.", item->ItemType); + Log(Logs::Detail, Logs::Combat, "Ranged attack canceled. Ranged item %d is not a throwing weapon. type %d.", item->ItemType); Message(0, "Error: Rangeweapon: GetItem(%i)==0, you have nothing useful to throw!", GetItemIDAt(EQEmu::inventory::slotRange)); return; } - Log.Out(Logs::Detail, Logs::Combat, "Throwing %s (%d) at %s", item->Name, item->ID, other->GetName()); + Log(Logs::Detail, Logs::Combat, "Throwing %s (%d) at %s", item->Name, item->ID, other->GetName()); if(RangeWeapon->GetCharges() == 1) { //first check ammo @@ -1252,7 +1253,7 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51 //more in the ammo slot, use it RangeWeapon = AmmoItem; ammo_slot = EQEmu::inventory::slotAmmo; - Log.Out(Logs::Detail, Logs::Combat, "Using ammo from ammo slot, stack at slot %d. %d in stack.", ammo_slot, RangeWeapon->GetCharges()); + Log(Logs::Detail, Logs::Combat, "Using ammo from ammo slot, stack at slot %d. %d in stack.", ammo_slot, RangeWeapon->GetCharges()); } else { //look through our inventory for more int32 aslot = m_inv.HasItem(item->ID, 1, invWherePersonal); @@ -1260,17 +1261,17 @@ void Client::ThrowingAttack(Mob* other, bool CanDoubleAttack) { //old was 51 //the item wont change, but the instance does, not that it matters ammo_slot = aslot; RangeWeapon = m_inv[aslot]; - Log.Out(Logs::Detail, Logs::Combat, "Using ammo from inventory slot, stack at slot %d. %d in stack.", ammo_slot, RangeWeapon->GetCharges()); + Log(Logs::Detail, Logs::Combat, "Using ammo from inventory slot, stack at slot %d. %d in stack.", ammo_slot, RangeWeapon->GetCharges()); } } } float range = item->Range + GetRangeDistTargetSizeMod(other); - Log.Out(Logs::Detail, Logs::Combat, "Calculated bow range to be %.1f", range); + Log(Logs::Detail, Logs::Combat, "Calculated bow range to be %.1f", range); range *= range; float dist = DistanceSquared(m_Position, other->GetPosition()); if(dist > range) { - Log.Out(Logs::Detail, Logs::Combat, "Throwing attack out of range... client should catch this. (%f > %f).\n", dist, range); + Log(Logs::Detail, Logs::Combat, "Throwing attack out of range... client should catch this. (%f > %f).\n", dist, range); Message_StringID(13,TARGET_OUT_OF_RANGE);//Client enforces range and sends the message, this is a backup just incase. return; } @@ -1336,7 +1337,7 @@ void Mob::DoThrowingAttackDmg(Mob *other, const EQEmu::ItemInstance *RangeWeapon SendItemAnimation(other, AmmoItem, EQEmu::skills::SkillThrowing); } - Log.Out(Logs::Detail, Logs::Combat, "Throwing attack hit %s.", other->GetName()); + Log(Logs::Detail, Logs::Combat, "Throwing attack hit %s.", other->GetName()); int WDmg = 0; @@ -1374,7 +1375,7 @@ void Mob::DoThrowingAttackDmg(Mob *other, const EQEmu::ItemInstance *RangeWeapon DoAttack(other, my_hit); TotalDmg = my_hit.damage_done; - Log.Out(Logs::Detail, Logs::Combat, "Item DMG %d. Hit for damage %d", WDmg, TotalDmg); + Log(Logs::Detail, Logs::Combat, "Item DMG %d. Hit for damage %d", WDmg, TotalDmg); } else { TotalDmg = DMG_INVULNERABLE; } diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 10cea0aec..b295286fa 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -488,7 +488,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove if(!target_zone) { #ifdef SPELL_EFFECT_SPAM - Log.Out(Logs::General, Logs::None, "Succor/Evacuation Spell In Same Zone."); + Log(Logs::General, Logs::None, "Succor/Evacuation Spell In Same Zone."); #endif if(IsClient()) CastToClient()->MovePC(zone->GetZoneID(), zone->GetInstanceID(), x, y, z, heading, 0, EvacToSafeCoords); @@ -497,7 +497,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove } else { #ifdef SPELL_EFFECT_SPAM - Log.Out(Logs::General, Logs::None, "Succor/Evacuation Spell To Another Zone."); + Log(Logs::General, Logs::None, "Succor/Evacuation Spell To Another Zone."); #endif if(IsClient()) CastToClient()->MovePC(target_zone, x, y, z, heading); @@ -709,7 +709,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove stun_resist += aabonuses.StunResist; if (stun_resist <= 0 || zone->random.Int(0,99) >= stun_resist) { - Log.Out(Logs::Detail, Logs::Combat, "Stunned. We had %d percent resist chance.", stun_resist); + Log(Logs::Detail, Logs::Combat, "Stunned. We had %d percent resist chance.", stun_resist); if (caster && caster->IsClient()) effect_value += effect_value*caster->GetFocusEffect(focusFcStunTimeMod, spell_id)/100; @@ -719,7 +719,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove if (IsClient()) Message_StringID(MT_Stun, SHAKE_OFF_STUN); - Log.Out(Logs::Detail, Logs::Combat, "Stun Resisted. We had %d percent resist chance.", stun_resist); + Log(Logs::Detail, Logs::Combat, "Stun Resisted. We had %d percent resist chance.", stun_resist); } } break; @@ -1660,7 +1660,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove if (IsCorpse() && CastToCorpse()->IsPlayerCorpse()) { if(caster) - Log.Out(Logs::Detail, Logs::Spells, " corpse being rezzed using spell %i by %s", + Log(Logs::Detail, Logs::Spells, " corpse being rezzed using spell %i by %s", spell_id, caster->GetName()); CastToCorpse()->CastRezz(spell_id, caster); @@ -1783,7 +1783,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove } else { Message_StringID(4, TARGET_NOT_FOUND); - Log.Out(Logs::General, Logs::Error, "%s attempted to cast spell id %u with spell effect SE_SummonCorpse, but could not cast target into a Client object.", GetCleanName(), spell_id); + Log(Logs::General, Logs::Error, "%s attempted to cast spell id %u with spell effect SE_SummonCorpse, but could not cast target into a Client object.", GetCleanName(), spell_id); } } @@ -3072,12 +3072,13 @@ int Mob::CalcSpellEffectValue(uint16 spell_id, int effect_id, int caster_level, spells[spell_id].effectid[effect_id] != SE_ChangeFrenzyRad && spells[spell_id].effectid[effect_id] != SE_Harmony && spells[spell_id].effectid[effect_id] != SE_CurrentMana && - spells[spell_id].effectid[effect_id] != SE_ManaRegen_v2) { + spells[spell_id].effectid[effect_id] != SE_ManaRegen_v2 && + spells[spell_id].effectid[effect_id] != SE_AddFaction) { int oval = effect_value; int mod = ApplySpellEffectiveness(spell_id, instrument_mod, true, caster_id); effect_value = effect_value * mod / 10; - Log.Out(Logs::Detail, Logs::Spells, "Effect value %d altered with bard modifier of %d to yeild %d", + Log(Logs::Detail, Logs::Spells, "Effect value %d altered with bard modifier of %d to yeild %d", oval, mod, effect_value); } @@ -3140,7 +3141,7 @@ snare has both of them negative, yet their range should work the same: updownsign = 1; } - Log.Out(Logs::Detail, Logs::Spells, "CSEV: spell %d, formula %d, base %d, max %d, lvl %d. Up/Down %d", + Log(Logs::Detail, Logs::Spells, "CSEV: spell %d, formula %d, base %d, max %d, lvl %d. Up/Down %d", spell_id, formula, base, max, caster_level, updownsign); switch(formula) @@ -3362,7 +3363,7 @@ snare has both of them negative, yet their range should work the same: result = ubase * (caster_level * (formula - 2000) + 1); } else - Log.Out(Logs::General, Logs::None, "Unknown spell effect value forumula %d", formula); + Log(Logs::General, Logs::None, "Unknown spell effect value forumula %d", formula); } } @@ -3387,7 +3388,7 @@ snare has both of them negative, yet their range should work the same: if (base < 0 && result > 0) result *= -1; - Log.Out(Logs::Detail, Logs::Spells, "Result: %d (orig %d), cap %d %s", result, oresult, max, (base < 0 && result > 0)?"Inverted due to negative base":""); + Log(Logs::Detail, Logs::Spells, "Result: %d (orig %d), cap %d %s", result, oresult, max, (base < 0 && result > 0)?"Inverted due to negative base":""); return result; } @@ -3414,12 +3415,12 @@ void Mob::BuffProcess() --buffs[buffs_i].ticsremaining; if (buffs[buffs_i].ticsremaining < 0) { - Log.Out(Logs::Detail, Logs::Spells, "Buff %d in slot %d has expired. Fading.", buffs[buffs_i].spellid, buffs_i); + Log(Logs::Detail, Logs::Spells, "Buff %d in slot %d has expired. Fading.", buffs[buffs_i].spellid, buffs_i); BuffFadeBySlot(buffs_i); } else { - Log.Out(Logs::Detail, Logs::Spells, "Buff %d in slot %d has %d tics remaining.", buffs[buffs_i].spellid, buffs_i, buffs[buffs_i].ticsremaining); + Log(Logs::Detail, Logs::Spells, "Buff %d in slot %d has %d tics remaining.", buffs[buffs_i].spellid, buffs_i, buffs[buffs_i].ticsremaining); } } else if (IsClient() && !(CastToClient()->ClientVersionBit() & EQEmu::versions::bit_SoFAndLater)) @@ -3760,7 +3761,7 @@ void Mob::BuffFadeBySlot(int slot, bool iRecalcBonuses) if (IsClient() && !CastToClient()->IsDead()) CastToClient()->MakeBuffFadePacket(buffs[slot].spellid, slot); - Log.Out(Logs::Detail, Logs::Spells, "Fading buff %d from slot %d", buffs[slot].spellid, slot); + Log(Logs::Detail, Logs::Spells, "Fading buff %d from slot %d", buffs[slot].spellid, slot); if(spells[buffs[slot].spellid].viral_targets > 0) { bool last_virus = true; @@ -4789,7 +4790,7 @@ int16 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, boo return 0; break; default: - Log.Out(Logs::General, Logs::Normal, "CalcFocusEffect: unknown limit spelltype %d", + Log(Logs::General, Logs::Normal, "CalcFocusEffect: unknown limit spelltype %d", focus_spell.base[i]); } break; @@ -5146,7 +5147,7 @@ int16 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, boo // this spits up a lot of garbage when calculating spell focuses // since they have all kinds of extra effects on them. default: - Log.Out(Logs::General, Logs::Normal, "CalcFocusEffect: unknown effectid %d", + Log(Logs::General, Logs::Normal, "CalcFocusEffect: unknown effectid %d", focus_spell.effectid[i]); #endif } diff --git a/zone/spells.cpp b/zone/spells.cpp index 622ec8e93..5facb54e8 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -132,7 +132,9 @@ void Mob::SpellProcess() void NPC::SpellProcess() { Mob::SpellProcess(); - DepopSwarmPets(); + if (swarm_timer.Check()) { + DepopSwarmPets(); + } } /////////////////////////////////////////////////////////////////////////////// @@ -153,7 +155,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, uint32 timer, uint32 timer_duration, int16 *resist_adjust, uint32 aa_id) { - Log.Out(Logs::Detail, Logs::Spells, "CastSpell called for spell %s (%d) on entity %d, slot %d, time %d, mana %d, from item slot %d", + Log(Logs::Detail, Logs::Spells, "CastSpell called for spell %s (%d) on entity %d, slot %d, time %d, mana %d, from item slot %d", (IsValidSpell(spell_id))?spells[spell_id].name:"UNKNOWN SPELL", spell_id, target_id, static_cast(slot), cast_time, mana_cost, (item_slot==0xFFFFFFFF)?999:item_slot); if(casting_spell_id == spell_id) @@ -172,7 +174,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, (IsAmnesiad() && IsDiscipline(spell_id)) ) { - Log.Out(Logs::Detail, Logs::Spells, "Spell casting canceled: not able to cast now. Valid? %d, casting %d, waiting? %d, spellend? %d, stunned? %d, feared? %d, mezed? %d, silenced? %d, amnesiad? %d", + Log(Logs::Detail, Logs::Spells, "Spell casting canceled: not able to cast now. Valid? %d, casting %d, waiting? %d, spellend? %d, stunned? %d, feared? %d, mezed? %d, silenced? %d, amnesiad? %d", IsValidSpell(spell_id), casting_spell_id, delaytimer, spellend_timer.Enabled(), IsStunned(), IsFeared(), IsMezzed(), IsSilenced(), IsAmnesiad() ); if(IsSilenced() && !IsDiscipline(spell_id)) Message_StringID(13, SILENCED_STRING); @@ -210,7 +212,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, //cannot cast under divine aura if(DivineAura()) { - Log.Out(Logs::Detail, Logs::Spells, "Spell casting canceled: cannot cast while Divine Aura is in effect."); + Log(Logs::Detail, Logs::Spells, "Spell casting canceled: cannot cast while Divine Aura is in effect."); InterruptSpell(173, 0x121, false); return(false); } @@ -232,7 +234,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, } if (HasActiveSong() && IsBardSong(spell_id)) { - Log.Out(Logs::Detail, Logs::Spells, "Casting a new song while singing a song. Killing old song %d.", bardsong); + Log(Logs::Detail, Logs::Spells, "Casting a new song while singing a song. Killing old song %d.", bardsong); //Note: this does NOT tell the client _StopSong(); } @@ -247,7 +249,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, if ((itm->GetItem()->Click.Type == EQEmu::item::ItemEffectEquipClick) && !(itm->GetItem()->Classes & bitmask)) { if (CastToClient()->ClientVersion() < EQEmu::versions::ClientVersion::SoF) { // They are casting a spell from an item that requires equipping but shouldn't let them equip it - Log.Out(Logs::General, Logs::Error, "HACKER: %s (account: %s) attempted to click an equip-only effect on item %s (id: %d) which they shouldn't be able to equip!", + Log(Logs::General, Logs::Error, "HACKER: %s (account: %s) attempted to click an equip-only effect on item %s (id: %d) which they shouldn't be able to equip!", CastToClient()->GetCleanName(), CastToClient()->AccountName(), itm->GetItem()->Name, itm->GetItem()->ID); database.SetHackerFlag(CastToClient()->AccountName(), CastToClient()->GetCleanName(), "Clicking equip-only item with an invalid class"); } @@ -259,7 +261,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, if ((itm->GetItem()->Click.Type == EQEmu::item::ItemEffectClick2) && !(itm->GetItem()->Classes & bitmask)) { if (CastToClient()->ClientVersion() < EQEmu::versions::ClientVersion::SoF) { // They are casting a spell from an item that they don't meet the race/class requirements to cast - Log.Out(Logs::General, Logs::Error, "HACKER: %s (account: %s) attempted to click a race/class restricted effect on item %s (id: %d) which they shouldn't be able to click!", + Log(Logs::General, Logs::Error, "HACKER: %s (account: %s) attempted to click a race/class restricted effect on item %s (id: %d) which they shouldn't be able to click!", CastToClient()->GetCleanName(), CastToClient()->AccountName(), itm->GetItem()->Name, itm->GetItem()->ID); database.SetHackerFlag(CastToClient()->AccountName(), CastToClient()->GetCleanName(), "Clicking race/class restricted item with an invalid class"); } @@ -280,7 +282,7 @@ bool Mob::CastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, if (itm && (itm->GetItem()->Click.Type == EQEmu::item::ItemEffectEquipClick) && !(item_slot <= EQEmu::inventory::slotAmmo || item_slot == EQEmu::inventory::slotPowerSource)){ if (CastToClient()->ClientVersion() < EQEmu::versions::ClientVersion::SoF) { // They are attempting to cast a must equip clicky without having it equipped - Log.Out(Logs::General, Logs::Error, "HACKER: %s (account: %s) attempted to click an equip-only effect on item %s (id: %d) without equiping it!", CastToClient()->GetCleanName(), CastToClient()->AccountName(), itm->GetItem()->Name, itm->GetItem()->ID); + Log(Logs::General, Logs::Error, "HACKER: %s (account: %s) attempted to click an equip-only effect on item %s (id: %d) without equiping it!", CastToClient()->GetCleanName(), CastToClient()->AccountName(), itm->GetItem()->Name, itm->GetItem()->ID); database.SetHackerFlag(CastToClient()->AccountName(), CastToClient()->GetCleanName(), "Clicking equip-only item without equiping it"); } else { @@ -337,7 +339,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, const SPDat_Spell_Struct &spell = spells[spell_id]; - Log.Out(Logs::Detail, Logs::Spells, "DoCastSpell called for spell %s (%d) on entity %d, slot %d, time %d, mana %d, from item %d", + Log(Logs::Detail, Logs::Spells, "DoCastSpell called for spell %s (%d) on entity %d, slot %d, time %d, mana %d, from item %d", spell.name, spell_id, target_id, static_cast(slot), cast_time, mana_cost, item_slot==0xFFFFFFFF?999:item_slot); casting_spell_id = spell_id; @@ -357,7 +359,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, int fizzle_msg = IsBardSong(spell_id) ? MISS_NOTE : SPELL_FIZZLE; uint32 use_mana = ((spells[spell_id].mana) / 4); - Log.Out(Logs::Detail, Logs::Spells, "Spell casting canceled: fizzled. %d mana has been consumed", use_mana); + Log(Logs::Detail, Logs::Spells, "Spell casting canceled: fizzled. %d mana has been consumed", use_mana); // fizzle 1/4 the mana away Mob::SetMana(GetMana() - use_mana); // We send StopCasting which will update mana @@ -386,7 +388,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, } SaveSpellLoc(); - Log.Out(Logs::Detail, Logs::Spells, "Casting %d Started at (%.3f,%.3f,%.3f)", spell_id, m_SpellLocation.x, m_SpellLocation.y, m_SpellLocation.z); + Log(Logs::Detail, Logs::Spells, "Casting %d Started at (%.3f,%.3f,%.3f)", spell_id, m_SpellLocation.x, m_SpellLocation.y, m_SpellLocation.z); // if this spell doesn't require a target, or if it's an optional target // and a target wasn't provided, then it's us; unless TGB is on and this @@ -399,7 +401,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, spell.targettype == ST_Beam || spell.targettype == ST_TargetOptional) && target_id == 0) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d auto-targeted the caster. Group? %d, target type %d", spell_id, IsGroupSpell(spell_id), spell.targettype); + Log(Logs::Detail, Logs::Spells, "Spell %d auto-targeted the caster. Group? %d, target type %d", spell_id, IsGroupSpell(spell_id), spell.targettype); target_id = GetID(); } @@ -416,7 +418,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, // we checked for spells not requiring targets above if(target_id == 0) { - Log.Out(Logs::Detail, Logs::Spells, "Spell Error: no target. spell=%d", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell Error: no target. spell=%d", spell_id); if(IsClient()) { //clients produce messages... npcs should not for this case Message_StringID(13, SPELL_NEED_TAR); @@ -449,7 +451,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, { mana_cost = 0; } else { - Log.Out(Logs::Detail, Logs::Spells, "Spell Error not enough mana spell=%d mymana=%d cost=%d\n", GetName(), spell_id, my_curmana, mana_cost); + Log(Logs::Detail, Logs::Spells, "Spell Error not enough mana spell=%d mymana=%d cost=%d\n", GetName(), spell_id, my_curmana, mana_cost); if(IsClient()) { //clients produce messages... npcs should not for this case Message_StringID(13, INSUFFICIENT_MANA); @@ -470,7 +472,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, casting_spell_resist_adjust = resist_adjust; - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Casting time %d (orig %d), mana cost %d", + Log(Logs::Detail, Logs::Spells, "Spell %d: Casting time %d (orig %d), mana cost %d", spell_id, cast_time, orgcasttime, mana_cost); // now tell the people in the area -- we ALWAYS want to send this, even instant cast spells. @@ -556,7 +558,7 @@ bool Mob::DoCastingChecks() if (RuleB(Spells, BuffLevelRestrictions)) { // casting_spell_targetid is guaranteed to be what we went, check for ST_Self for now should work though if (spell_target && spells[spell_id].targettype != ST_Self && !spell_target->CheckSpellLevelRestriction(spell_id)) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d failed: recipient did not meet the level restrictions", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d failed: recipient did not meet the level restrictions", spell_id); if (!IsBardSong(spell_id)) Message_StringID(MT_SpellFailure, SPELL_TOO_POWERFUL); return false; @@ -791,7 +793,7 @@ bool Client::CheckFizzle(uint16 spell_id) float fizzle_roll = zone->random.Real(0, 100); - Log.Out(Logs::Detail, Logs::Spells, "Check Fizzle %s spell %d fizzlechance: %0.2f%% diff: %0.2f roll: %0.2f", GetName(), spell_id, fizzlechance, diff, fizzle_roll); + Log(Logs::Detail, Logs::Spells, "Check Fizzle %s spell %d fizzlechance: %0.2f%% diff: %0.2f roll: %0.2f", GetName(), spell_id, fizzlechance, diff, fizzle_roll); if(fizzle_roll > fizzlechance) return(true); @@ -850,7 +852,7 @@ void Mob::InterruptSpell(uint16 message, uint16 color, uint16 spellid) ZeroCastingVars(); // resets all the state keeping stuff - Log.Out(Logs::Detail, Logs::Spells, "Spell %d has been interrupted.", spellid); + Log(Logs::Detail, Logs::Spells, "Spell %d has been interrupted.", spellid); if(!spellid) return; @@ -953,7 +955,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo if(!CastToClient()->GetPTimers().Expired(&database, pTimerSpellStart + spell_id, false)) { //should we issue a message or send them a spell gem packet? Message_StringID(13, SPELL_RECAST); - Log.Out(Logs::Detail, Logs::Spells, "Casting of %d canceled: spell reuse timer not expired", spell_id); + Log(Logs::Detail, Logs::Spells, "Casting of %d canceled: spell reuse timer not expired", spell_id); StopCasting(); return; } @@ -967,7 +969,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo { if(!CastToClient()->GetPTimers().Expired(&database, (pTimerItemStart + itm->GetItem()->RecastType), false)) { Message_StringID(13, SPELL_RECAST); - Log.Out(Logs::Detail, Logs::Spells, "Casting of %d canceled: item spell reuse timer not expired", spell_id); + Log(Logs::Detail, Logs::Spells, "Casting of %d canceled: item spell reuse timer not expired", spell_id); StopCasting(); return; } @@ -976,7 +978,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo if(!IsValidSpell(spell_id)) { - Log.Out(Logs::Detail, Logs::Spells, "Casting of %d canceled: invalid spell id", spell_id); + Log(Logs::Detail, Logs::Spells, "Casting of %d canceled: invalid spell id", spell_id); InterruptSpell(); return; } @@ -987,7 +989,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo { if(delaytimer) { - Log.Out(Logs::Detail, Logs::Spells, "Casting of %d canceled: recast too quickly", spell_id); + Log(Logs::Detail, Logs::Spells, "Casting of %d canceled: recast too quickly", spell_id); Message(13, "You are unable to focus."); InterruptSpell(); return; @@ -997,7 +999,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo // make sure they aren't somehow casting 2 timed spells at once if (casting_spell_id != spell_id) { - Log.Out(Logs::Detail, Logs::Spells, "Casting of %d canceled: already casting", spell_id); + Log(Logs::Detail, Logs::Spells, "Casting of %d canceled: already casting", spell_id); Message_StringID(13,ALREADY_CASTING); InterruptSpell(); return; @@ -1012,7 +1014,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo { if (IsBardSong(spell_id)) { if(spells[spell_id].buffduration == 0xFFFF) { - Log.Out(Logs::Detail, Logs::Spells, "Bard song %d not applying bard logic because duration. dur=%d, recast=%d", spells[spell_id].buffduration); + Log(Logs::Detail, Logs::Spells, "Bard song %d not applying bard logic because duration. dur=%d, recast=%d", spells[spell_id].buffduration); } else { // So long recast bard songs need special bard logic, although the effects don't repulse like other songs // This is basically a hack to get that effect @@ -1028,7 +1030,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo bardsong_target_id = spell_target->GetID(); bardsong_timer.Start(6000); } - Log.Out(Logs::Detail, Logs::Spells, "Bard song %d started: slot %d, target id %d", bardsong, bardsong_slot, bardsong_target_id); + Log(Logs::Detail, Logs::Spells, "Bard song %d started: slot %d, target id %d", bardsong, bardsong_slot, bardsong_target_id); bard_song_mode = true; } } @@ -1107,10 +1109,10 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo } } - Log.Out(Logs::Detail, Logs::Spells, "Checking Interruption: spell x: %f spell y: %f cur x: %f cur y: %f channelchance %f channeling skill %d\n", GetSpellX(), GetSpellY(), GetX(), GetY(), channelchance, GetSkill(EQEmu::skills::SkillChanneling)); + Log(Logs::Detail, Logs::Spells, "Checking Interruption: spell x: %f spell y: %f cur x: %f cur y: %f channelchance %f channeling skill %d\n", GetSpellX(), GetSpellY(), GetX(), GetY(), channelchance, GetSkill(EQEmu::skills::SkillChanneling)); if(!spells[spell_id].uninterruptable && zone->random.Real(0, 100) > channelchance) { - Log.Out(Logs::Detail, Logs::Spells, "Casting of %d canceled: interrupted.", spell_id); + Log(Logs::Detail, Logs::Spells, "Casting of %d canceled: interrupted.", spell_id); InterruptSpell(); return; } @@ -1126,10 +1128,10 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo if(IsClient()) { int reg_focus = CastToClient()->GetFocusEffect(focusReagentCost,spell_id);//Client only if(zone->random.Roll(reg_focus)) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Reagent focus item prevented reagent consumption (%d chance)", spell_id, reg_focus); + Log(Logs::Detail, Logs::Spells, "Spell %d: Reagent focus item prevented reagent consumption (%d chance)", spell_id, reg_focus); } else { if(reg_focus > 0) - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Reagent focus item failed to prevent reagent consumption (%d chance)", spell_id, reg_focus); + Log(Logs::Detail, Logs::Spells, "Spell %d: Reagent focus item failed to prevent reagent consumption (%d chance)", spell_id, reg_focus); Client *c = this->CastToClient(); int component, component_count, inv_slot_id; bool missingreags = false; @@ -1182,11 +1184,11 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo break; default: // some non-instrument component. Let it go, but record it in the log - Log.Out(Logs::Detail, Logs::Spells, "Something odd happened: Song %d required component %d", spell_id, component); + Log(Logs::Detail, Logs::Spells, "Something odd happened: Song %d required component %d", spell_id, component); } if(!HasInstrument) { // if the instrument is missing, log it and interrupt the song - Log.Out(Logs::Detail, Logs::Spells, "Song %d: Canceled. Missing required instrument %d", spell_id, component); + Log(Logs::Detail, Logs::Spells, "Song %d: Canceled. Missing required instrument %d", spell_id, component); if(c->GetGM()) c->Message(0, "Your GM status allows you to finish casting even though you're missing a required instrument."); else { @@ -1209,12 +1211,12 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo const EQEmu::ItemData *item = database.GetItem(component); if(item) { c->Message_StringID(13, MISSING_SPELL_COMP_ITEM, item->Name); - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Canceled. Missing required reagent %s (%d)", spell_id, item->Name, component); + Log(Logs::Detail, Logs::Spells, "Spell %d: Canceled. Missing required reagent %s (%d)", spell_id, item->Name, component); } else { char TempItemName[64]; strcpy((char*)&TempItemName, "UNKNOWN"); - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Canceled. Missing required reagent %s (%d)", spell_id, TempItemName, component); + Log(Logs::Detail, Logs::Spells, "Spell %d: Canceled. Missing required reagent %s (%d)", spell_id, TempItemName, component); } } } // end bard/not bard ifs @@ -1237,7 +1239,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo if (component == -1 || noexpend == component) continue; component_count = spells[spell_id].component_counts[t_count]; - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Consuming %d of spell component item id %d", spell_id, component_count, component); + Log(Logs::Detail, Logs::Spells, "Spell %d: Consuming %d of spell component item id %d", spell_id, component_count, component); // Components found, Deleting // now we go looking for and deleting the items one by one for(int s = 0; s < component_count; s++) @@ -1302,7 +1304,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo { if(!CastToClient()->GetPTimers().Expired(&database, (pTimerItemStart + recasttype), false)) { Message_StringID(13, SPELL_RECAST); - Log.Out(Logs::Detail, Logs::Spells, "Casting of %d canceled: item spell reuse timer not expired", spell_id); + Log(Logs::Detail, Logs::Spells, "Casting of %d canceled: item spell reuse timer not expired", spell_id); StopCasting(); return; } @@ -1323,15 +1325,15 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo if(fromaug) { charges = -1; } //Don't destroy the parent item if(charges > -1) { // charged item, expend a charge - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Consuming a charge from item %s (%d) which had %d/%d charges.", spell_id, inst->GetItem()->Name, inst->GetItem()->ID, inst->GetCharges(), inst->GetItem()->MaxCharges); + Log(Logs::Detail, Logs::Spells, "Spell %d: Consuming a charge from item %s (%d) which had %d/%d charges.", spell_id, inst->GetItem()->Name, inst->GetItem()->ID, inst->GetCharges(), inst->GetItem()->MaxCharges); DeleteChargeFromSlot = inventory_slot; } else { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Cast from unlimited charge item %s (%d) (%d charges)", spell_id, inst->GetItem()->Name, inst->GetItem()->ID, inst->GetItem()->MaxCharges); + Log(Logs::Detail, Logs::Spells, "Spell %d: Cast from unlimited charge item %s (%d) (%d charges)", spell_id, inst->GetItem()->Name, inst->GetItem()->ID, inst->GetItem()->MaxCharges); } } else { - Log.Out(Logs::Detail, Logs::Spells, "Item used to cast spell %d was missing from inventory slot %d after casting!", spell_id, inventory_slot); + Log(Logs::Detail, Logs::Spells, "Item used to cast spell %d was missing from inventory slot %d after casting!", spell_id, inventory_slot); Message(13, "Casting Error: Active casting item not found in inventory slot %i", inventory_slot); InterruptSpell(); return; @@ -1341,7 +1343,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo // we're done casting, now try to apply the spell if( !SpellFinished(spell_id, spell_target, slot, mana_used, inventory_slot, resist_adjust) ) { - Log.Out(Logs::Detail, Logs::Spells, "Casting of %d canceled: SpellFinished returned false.", spell_id); + Log(Logs::Detail, Logs::Spells, "Casting of %d canceled: SpellFinished returned false.", spell_id); // most of the cases we return false have a message already or are logic errors that shouldn't happen // if there are issues I guess we can do something else, but this should work StopCasting(); @@ -1384,7 +1386,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo c->SetLinkedSpellReuseTimer(spells[spell_id].EndurTimerIndex, spells[spell_id].recast_time / 1000); c->MemorizeSpell(static_cast(slot), spell_id, memSpellSpellbar); } - Log.Out(Logs::Detail, Logs::Spells, "Bard song %d should be started", spell_id); + Log(Logs::Detail, Logs::Spells, "Bard song %d should be started", spell_id); } else { @@ -1420,7 +1422,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo delaytimer = true; spellend_timer.Start(400,true); - Log.Out(Logs::Detail, Logs::Spells, "Spell casting of %d is finished.", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell casting of %d is finished.", spell_id); } @@ -1467,7 +1469,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce && (IsGrouped() // still self only if not grouped || IsRaidGrouped()) && (HasProjectIllusion())){ - Log.Out(Logs::Detail, Logs::AA, "Project Illusion overwrote target caster: %s spell id: %d was ON", GetName(), spell_id); + Log(Logs::Detail, Logs::AA, "Project Illusion overwrote target caster: %s spell id: %d was ON", GetName(), spell_id); targetType = ST_GroupClientAndPet; } @@ -1555,7 +1557,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce ) { //invalid target - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target of body type %d (undead)", spell_id, mob_body); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target of body type %d (undead)", spell_id, mob_body); if(!spell_target) Message_StringID(13,SPELL_NEED_TAR); else @@ -1570,7 +1572,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce if(!spell_target || (mob_body != BT_Summoned && mob_body != BT_Summoned2 && mob_body != BT_Summoned3)) { //invalid target - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target of body type %d (summoned)", spell_id, mob_body); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target of body type %d (summoned)", spell_id, mob_body); Message_StringID(13,SPELL_NEED_TAR); return false; } @@ -1583,7 +1585,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce if(!spell_target || (spell_target != GetPet()) || (mob_body != BT_Summoned && mob_body != BT_Summoned2 && mob_body != BT_Summoned3 && mob_body != BT_Animal)) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target of body type %d (summoned pet)", + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target of body type %d (summoned pet)", spell_id, mob_body); Message_StringID(13, SPELL_NEED_TAR); @@ -1608,7 +1610,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce if(!spell_target || mob_body != target_bt) { //invalid target - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target of body type %d (want body Type %d)", spell_id, mob_body, target_bt); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target of body type %d (want body Type %d)", spell_id, mob_body, target_bt); if(!spell_target) Message_StringID(13,SPELL_NEED_TAR); else @@ -1626,7 +1628,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce { if(!spell_target) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (ldon object)", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (ldon object)", spell_id); Message_StringID(13,SPELL_NEED_TAR); return false; } @@ -1634,14 +1636,14 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce { if(!spell_target->IsNPC()) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (normal)", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (normal)", spell_id); Message_StringID(13,SPELL_NEED_TAR); return false; } if(spell_target->GetClass() != LDON_TREASURE) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (normal)", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (normal)", spell_id); Message_StringID(13,SPELL_NEED_TAR); return false; } @@ -1650,7 +1652,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce if(!spell_target) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (normal)", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (normal)", spell_id); Message_StringID(13,SPELL_NEED_TAR); return false; // can't cast these unless we have a target } @@ -1662,7 +1664,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce { if(!spell_target || !spell_target->IsPlayerCorpse()) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (corpse)", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (corpse)", spell_id); uint32 message = ONLY_ON_CORPSES; if(!spell_target) message = SPELL_NEED_TAR; else if(!spell_target->IsCorpse()) message = ONLY_ON_CORPSES; @@ -1678,7 +1680,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce spell_target = GetPet(); if(!spell_target) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (no pet)", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (no pet)", spell_id); Message_StringID(13,NO_PET); return false; // can't cast these unless we have a target } @@ -1749,7 +1751,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce { if(!spell_target) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (AOE)", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (AOE)", spell_id); Message_StringID(13,SPELL_NEED_TAR); return false; } @@ -1786,7 +1788,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce { if(!spell_target) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (Group Required: Single Target)", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: invalid target (Group Required: Single Target)", spell_id); Message_StringID(13,SPELL_NEED_TAR); return false; } @@ -1903,14 +1905,14 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce if(group_id_caster == 0 || group_id_target == 0) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: Attempted to cast a Single Target Group spell on a ungrouped member.", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: Attempted to cast a Single Target Group spell on a ungrouped member.", spell_id); Message_StringID(13, TARGET_GROUP_MEMBER); return false; } if(group_id_caster != group_id_target) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d canceled: Attempted to cast a Single Target Group spell on a ungrouped member.", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d canceled: Attempted to cast a Single Target Group spell on a ungrouped member.", spell_id); Message_StringID(13, TARGET_GROUP_MEMBER); return false; } @@ -1981,7 +1983,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce default: { - Log.Out(Logs::Detail, Logs::Spells, "I dont know Target Type: %d Spell: (%d) %s", spells[spell_id].targettype, spell_id, spells[spell_id].name); + Log(Logs::Detail, Logs::Spells, "I dont know Target Type: %d Spell: (%d) %s", spells[spell_id].targettype, spell_id, spells[spell_id].name); Message(0, "I dont know Target Type: %d Spell: (%d) %s", spells[spell_id].targettype, spell_id, spells[spell_id].name); CastAction = CastActUnknown; break; @@ -2038,7 +2040,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui if (IsClient() && CastToClient()->GetGM()){ if (zone->IsSpellBlocked(spell_id, glm::vec3(GetPosition()))){ - Log.Out(Logs::Detail, Logs::Spells, "GM Cast Blocked Spell: %s (ID %i)", GetSpellName(spell_id), spell_id); + Log(Logs::Detail, Logs::Spells, "GM Cast Blocked Spell: %s (ID %i)", GetSpellName(spell_id), spell_id); } } @@ -2066,7 +2068,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui if(!DetermineSpellTargets(spell_id, spell_target, ae_center, CastAction, slot, isproc)) return(false); - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: target type %d, target %s, AE center %s", spell_id, CastAction, spell_target?spell_target->GetName():"NONE", ae_center?ae_center->GetName():"NONE"); + Log(Logs::Detail, Logs::Spells, "Spell %d: target type %d, target %s, AE center %s", spell_id, CastAction, spell_target?spell_target->GetName():"NONE", ae_center?ae_center->GetName():"NONE"); // if a spell has the AEDuration flag, it becomes an AE on target // spell that's recast every 2500 msec for AEDuration msec. There are @@ -2077,7 +2079,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui Mob *beacon_loc = spell_target ? spell_target : this; auto beacon = new Beacon(beacon_loc, spells[spell_id].AEDuration); entity_list.AddBeacon(beacon); - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: AE duration beacon created, entity id %d", spell_id, beacon->GetName()); + Log(Logs::Detail, Logs::Spells, "Spell %d: AE duration beacon created, entity id %d", spell_id, beacon->GetName()); spell_target = nullptr; ae_center = beacon; CastAction = AECaster; @@ -2086,7 +2088,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui // check line of sight to target if it's a detrimental spell if(!spells[spell_id].npc_no_los && spell_target && IsDetrimentalSpell(spell_id) && !CheckLosFN(spell_target) && !IsHarmonySpell(spell_id) && spells[spell_id].targettype != ST_TargetOptional) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: cannot see target %s", spell_id, spell_target->GetName()); + Log(Logs::Detail, Logs::Spells, "Spell %d: cannot see target %s", spell_id, spell_target->GetName()); Message_StringID(13,CANT_SEE_TARGET); return false; } @@ -2117,13 +2119,13 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui float min_range2 = spells[spell_id].min_range * spells[spell_id].min_range; if(dist2 > range2) { //target is out of range. - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Spell target is out of range (squared: %f > %f)", spell_id, dist2, range2); + Log(Logs::Detail, Logs::Spells, "Spell %d: Spell target is out of range (squared: %f > %f)", spell_id, dist2, range2); Message_StringID(13, TARGET_OUT_OF_RANGE); return(false); } else if (dist2 < min_range2){ //target is too close range. - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Spell target is too close (squared: %f < %f)", spell_id, dist2, min_range2); + Log(Logs::Detail, Logs::Spells, "Spell %d: Spell target is too close (squared: %f < %f)", spell_id, dist2, min_range2); Message_StringID(13, TARGET_TOO_CLOSE); return(false); } @@ -2153,7 +2155,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui #endif //BOTS if(spell_target == nullptr) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Targeted spell, but we have no target", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d: Targeted spell, but we have no target", spell_id); return(false); } if (isproc) { @@ -2177,11 +2179,11 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui if(IsPlayerIllusionSpell(spell_id) && IsClient() && (HasProjectIllusion())){ - Log.Out(Logs::Detail, Logs::AA, "Effect Project Illusion for %s on spell id: %d was ON", GetName(), spell_id); + Log(Logs::Detail, Logs::AA, "Effect Project Illusion for %s on spell id: %d was ON", GetName(), spell_id); SetProjectIllusion(false); } else{ - Log.Out(Logs::Detail, Logs::AA, "Effect Project Illusion for %s on spell id: %d was OFF", GetName(), spell_id); + Log(Logs::Detail, Logs::AA, "Effect Project Illusion for %s on spell id: %d was OFF", GetName(), spell_id); } break; } @@ -2361,7 +2363,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui // clamp if we some how got focused above our current mana if (GetMana() < mana_used) mana_used = GetMana(); - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: consuming %d mana", spell_id, mana_used); + Log(Logs::Detail, Logs::Spells, "Spell %d: consuming %d mana", spell_id, mana_used); if (!DoHPToManaCovert(mana_used)) { SetMana(GetMana() - mana_used); TryTriggerOnValueAmount(false, true); @@ -2394,7 +2396,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui { //aa new todo: aa expendable charges here CastToClient()->GetPTimers().Start(casting_spell_timer, casting_spell_timer_duration); - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Setting custom reuse timer %d to %d", spell_id, casting_spell_timer, casting_spell_timer_duration); + Log(Logs::Detail, Logs::Spells, "Spell %d: Setting custom reuse timer %d to %d", spell_id, casting_spell_timer, casting_spell_timer_duration); } else if(spells[spell_id].recast_time > 1000 && !spells[spell_id].IsDisciplineBuff) { int recast = spells[spell_id].recast_time/1000; @@ -2410,7 +2412,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui if(reduction) recast -= reduction; - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Setting long reuse timer to %d s (orig %d)", spell_id, recast, spells[spell_id].recast_time); + Log(Logs::Detail, Logs::Spells, "Spell %d: Setting long reuse timer to %d s (orig %d)", spell_id, recast, spells[spell_id].recast_time); CastToClient()->GetPTimers().Start(pTimerSpellStart + spell_id, recast); } } @@ -2452,7 +2454,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, CastingSlot slot, ui bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slot) { if(slot == CastingSlot::Item) { //bard songs should never come from items... - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: Supposidly cast from an item. Killing song.", spell_id); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: Supposidly cast from an item. Killing song.", spell_id); return(false); } @@ -2460,12 +2462,12 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slo Mob *ae_center = nullptr; CastAction_type CastAction; if(!DetermineSpellTargets(spell_id, spell_target, ae_center, CastAction, slot)) { - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: was unable to determine target. Stopping.", spell_id); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: was unable to determine target. Stopping.", spell_id); return(false); } if(ae_center != nullptr && ae_center->IsBeacon()) { - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: Unsupported Beacon NPC AE spell", spell_id); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: Unsupported Beacon NPC AE spell", spell_id); return(false); } @@ -2474,18 +2476,18 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slo if(mana_used > 0) { if(mana_used > GetMana()) { //ran out of mana... this calls StopSong() for us - Log.Out(Logs::Detail, Logs::Spells, "Ran out of mana while singing song %d", spell_id); + Log(Logs::Detail, Logs::Spells, "Ran out of mana while singing song %d", spell_id); return(false); } - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: consuming %d mana (have %d)", spell_id, mana_used, GetMana()); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: consuming %d mana (have %d)", spell_id, mana_used, GetMana()); SetMana(GetMana() - mana_used); } // check line of sight to target if it's a detrimental spell if(spell_target && IsDetrimentalSpell(spell_id) && !CheckLosFN(spell_target)) { - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: cannot see target %s", spell_target->GetName()); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: cannot see target %s", spell_target->GetName()); Message_StringID(13, CANT_SEE_TARGET); return(false); } @@ -2500,7 +2502,7 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slo float range2 = range * range; if(dist2 > range2) { //target is out of range. - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: Spell target is out of range (squared: %f > %f)", spell_id, dist2, range2); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: Spell target is out of range (squared: %f > %f)", spell_id, dist2, range2); Message_StringID(13, TARGET_OUT_OF_RANGE); return(false); } @@ -2516,10 +2518,10 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slo case SingleTarget: { if(spell_target == nullptr) { - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: Targeted spell, but we have no target", spell_id); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: Targeted spell, but we have no target", spell_id); return(false); } - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse: Targeted. spell %d, target %s", spell_id, spell_target->GetName()); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse: Targeted. spell %d, target %s", spell_id, spell_target->GetName()); spell_target->BardPulse(spell_id, this); break; } @@ -2537,7 +2539,7 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slo { // we can't cast an AE spell without something to center it on if(ae_center == nullptr) { - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: AE Targeted spell, but we have no target", spell_id); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: AE Targeted spell, but we have no target", spell_id); return(false); } @@ -2545,9 +2547,9 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slo if(spell_target) { // this must be an AETarget spell // affect the target too spell_target->BardPulse(spell_id, this); - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse: spell %d, AE target %s", spell_id, spell_target->GetName()); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse: spell %d, AE target %s", spell_id, spell_target->GetName()); } else { - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse: spell %d, AE with no target", spell_id); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse: spell %d, AE with no target", spell_id); } bool affect_caster = !IsNPC(); //NPC AE spells do not affect the NPC caster entity_list.AEBardPulse(this, ae_center, spell_id, affect_caster); @@ -2557,13 +2559,13 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slo case GroupSpell: { if(spell_target->IsGrouped()) { - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse: spell %d, Group targeting group of %s", spell_id, spell_target->GetName()); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse: spell %d, Group targeting group of %s", spell_id, spell_target->GetName()); Group *target_group = entity_list.GetGroupByMob(spell_target); if(target_group) target_group->GroupBardPulse(this, spell_id); } else if(spell_target->IsRaidGrouped() && spell_target->IsClient()) { - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse: spell %d, Raid group targeting raid group of %s", spell_id, spell_target->GetName()); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse: spell %d, Raid group targeting raid group of %s", spell_id, spell_target->GetName()); Raid *r = entity_list.GetRaidByClient(spell_target->CastToClient()); if(r){ uint32 gid = r->GetGroup(spell_target->GetName()); @@ -2580,7 +2582,7 @@ bool Mob::ApplyNextBardPulse(uint16 spell_id, Mob *spell_target, CastingSlot slo } } else { - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse: spell %d, Group target without group. Affecting caster.", spell_id); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse: spell %d, Group target without group. Affecting caster.", spell_id); BardPulse(spell_id, this); #ifdef GROUP_BUFF_PETS if (GetPet() && HasPetAffinity() && !GetPet()->IsCharmed()) @@ -2606,13 +2608,13 @@ void Mob::BardPulse(uint16 spell_id, Mob *caster) { if(buffs[buffs_i].spellid != spell_id) continue; if(buffs[buffs_i].casterid != caster->GetID()) { - Log.Out(Logs::Detail, Logs::Spells, "Bard Pulse for %d: found buff from caster %d and we are pulsing for %d... are there two bards playing the same song???", spell_id, buffs[buffs_i].casterid, caster->GetID()); + Log(Logs::Detail, Logs::Spells, "Bard Pulse for %d: found buff from caster %d and we are pulsing for %d... are there two bards playing the same song???", spell_id, buffs[buffs_i].casterid, caster->GetID()); return; } //extend the spell if it will expire before the next pulse if(buffs[buffs_i].ticsremaining <= 3) { buffs[buffs_i].ticsremaining += 3; - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: extending duration in slot %d to %d tics", spell_id, buffs_i, buffs[buffs_i].ticsremaining); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: extending duration in slot %d to %d tics", spell_id, buffs_i, buffs[buffs_i].ticsremaining); } //should we send this buff update to the client... seems like it would @@ -2711,7 +2713,7 @@ void Mob::BardPulse(uint16 spell_id, Mob *caster) { //we are done... return; } - Log.Out(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: Buff not found, reapplying spell.", spell_id); + Log(Logs::Detail, Logs::Spells, "Bard Song Pulse %d: Buff not found, reapplying spell.", spell_id); //this spell is not affecting this mob, apply it. caster->SpellOnTarget(spell_id, this); } @@ -2757,7 +2759,7 @@ int Mob::CalcBuffDuration(Mob *caster, Mob *target, uint16 spell_id, int32 caste res = mod_buff_duration(res, caster, target, spell_id); - Log.Out(Logs::Detail, Logs::Spells, "Spell %d: Casting level %d, formula %d, base_duration %d: result %d", + Log(Logs::Detail, Logs::Spells, "Spell %d: Casting level %d, formula %d, base_duration %d: result %d", spell_id, castlevel, formula, duration, res); return res; @@ -2848,24 +2850,24 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, int blocked_effect, blocked_below_value, blocked_slot; int overwrite_effect, overwrite_below_value, overwrite_slot; - Log.Out(Logs::Detail, Logs::Spells, "Check Stacking on old %s (%d) @ lvl %d (by %s) vs. new %s (%d) @ lvl %d (by %s)", sp1.name, spellid1, caster_level1, (caster1==nullptr)?"Nobody":caster1->GetName(), sp2.name, spellid2, caster_level2, (caster2==nullptr)?"Nobody":caster2->GetName()); + Log(Logs::Detail, Logs::Spells, "Check Stacking on old %s (%d) @ lvl %d (by %s) vs. new %s (%d) @ lvl %d (by %s)", sp1.name, spellid1, caster_level1, (caster1==nullptr)?"Nobody":caster1->GetName(), sp2.name, spellid2, caster_level2, (caster2==nullptr)?"Nobody":caster2->GetName()); if (spellid1 == spellid2 ) { if (!IsStackableDot(spellid1) && !IsEffectInSpell(spellid1, SE_ManaBurn)) { // mana burn spells we need to use the stacking command blocks live actually checks those first, we should probably rework to that too if (caster_level1 > caster_level2) { // cur buff higher level than new if (IsEffectInSpell(spellid1, SE_ImprovedTaunt)) { - Log.Out(Logs::Detail, Logs::Spells, "SE_ImprovedTaunt level exception, overwriting."); + Log(Logs::Detail, Logs::Spells, "SE_ImprovedTaunt level exception, overwriting."); return 1; } else { - Log.Out(Logs::Detail, Logs::Spells, "Spells the same but existing is higher level, stopping."); + Log(Logs::Detail, Logs::Spells, "Spells the same but existing is higher level, stopping."); return -1; } } else { - Log.Out(Logs::Detail, Logs::Spells, "Spells the same but newer is higher or equal level, overwriting."); + Log(Logs::Detail, Logs::Spells, "Spells the same but newer is higher or equal level, overwriting."); return 1; } } else if (spellid1 == 2751) { - Log.Out(Logs::Detail, Logs::Spells, "Blocking spell because manaburn does not stack with itself."); + Log(Logs::Detail, Logs::Spells, "Blocking spell because manaburn does not stack with itself."); return -1; } } @@ -2880,7 +2882,7 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, { if(!IsDetrimentalSpell(spellid1) && !IsDetrimentalSpell(spellid2)) { - Log.Out(Logs::Detail, Logs::Spells, "%s and %s are beneficial, and one is a bard song, no action needs to be taken", sp1.name, sp2.name); + Log(Logs::Detail, Logs::Spells, "%s and %s are beneficial, and one is a bard song, no action needs to be taken", sp1.name, sp2.name); return (0); } } @@ -2895,7 +2897,7 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, } } } else if (IsEffectInSpell(spellid1, SE_ManaBurn)) { - Log.Out(Logs::Detail, Logs::Spells, "We have a Mana Burn spell that is the same, they won't stack"); + Log(Logs::Detail, Logs::Spells, "We have a Mana Burn spell that is the same, they won't stack"); return -1; } @@ -2953,16 +2955,16 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, { sp1_value = CalcSpellEffectValue(spellid1, overwrite_slot, caster_level1); - Log.Out(Logs::Detail, Logs::Spells, "%s (%d) overwrites existing spell if effect %d on slot %d is below %d. Old spell has value %d on that slot/effect. %s.", + Log(Logs::Detail, Logs::Spells, "%s (%d) overwrites existing spell if effect %d on slot %d is below %d. Old spell has value %d on that slot/effect. %s.", sp2.name, spellid2, overwrite_effect, overwrite_slot, overwrite_below_value, sp1_value, (sp1_value < overwrite_below_value)?"Overwriting":"Not overwriting"); if(sp1_value < overwrite_below_value) { - Log.Out(Logs::Detail, Logs::Spells, "Overwrite spell because sp1_value < overwrite_below_value"); + Log(Logs::Detail, Logs::Spells, "Overwrite spell because sp1_value < overwrite_below_value"); return 1; // overwrite spell if its value is less } } else { - Log.Out(Logs::Detail, Logs::Spells, "%s (%d) overwrites existing spell if effect %d on slot %d is below %d, but we do not have that effect on that slot. Ignored.", + Log(Logs::Detail, Logs::Spells, "%s (%d) overwrites existing spell if effect %d on slot %d is below %d, but we do not have that effect on that slot. Ignored.", sp2.name, spellid2, overwrite_effect, overwrite_slot, overwrite_below_value); } @@ -2976,22 +2978,22 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, { sp2_value = CalcSpellEffectValue(spellid2, blocked_slot, caster_level2); - Log.Out(Logs::Detail, Logs::Spells, "%s (%d) blocks effect %d on slot %d below %d. New spell has value %d on that slot/effect. %s.", + Log(Logs::Detail, Logs::Spells, "%s (%d) blocks effect %d on slot %d below %d. New spell has value %d on that slot/effect. %s.", sp1.name, spellid1, blocked_effect, blocked_slot, blocked_below_value, sp2_value, (sp2_value < blocked_below_value)?"Blocked":"Not blocked"); if (sp2_value < blocked_below_value) { - Log.Out(Logs::Detail, Logs::Spells, "Blocking spell because sp2_Value < blocked_below_value"); + Log(Logs::Detail, Logs::Spells, "Blocking spell because sp2_Value < blocked_below_value"); return -1; //blocked } } else { - Log.Out(Logs::Detail, Logs::Spells, "%s (%d) blocks effect %d on slot %d below %d, but we do not have that effect on that slot. Ignored.", + Log(Logs::Detail, Logs::Spells, "%s (%d) blocks effect %d on slot %d below %d, but we do not have that effect on that slot. Ignored.", sp1.name, spellid1, blocked_effect, blocked_slot, blocked_below_value); } } } } else { - Log.Out(Logs::Detail, Logs::Spells, "%s (%d) and %s (%d) appear to be in the same line, skipping Stacking Overwrite/Blocking checks", + Log(Logs::Detail, Logs::Spells, "%s (%d) and %s (%d) appear to be in the same line, skipping Stacking Overwrite/Blocking checks", sp1.name, spellid1, sp2.name, spellid2); } @@ -3034,13 +3036,13 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, */ if(IsNPC() && caster1 && caster2 && caster1 != caster2) { if(effect1 == SE_CurrentHP && sp1_detrimental && sp2_detrimental) { - Log.Out(Logs::Detail, Logs::Spells, "Both casters exist and are not the same, the effect is a detrimental dot, moving on"); + Log(Logs::Detail, Logs::Spells, "Both casters exist and are not the same, the effect is a detrimental dot, moving on"); continue; } } if(effect1 == SE_CompleteHeal){ //SE_CompleteHeal never stacks or overwrites ever, always block. - Log.Out(Logs::Detail, Logs::Spells, "Blocking spell because complete heal never stacks or overwries"); + Log(Logs::Detail, Logs::Spells, "Blocking spell because complete heal never stacks or overwries"); return (-1); } @@ -3049,7 +3051,7 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, and the effect is a dot we can go ahead and stack it */ if(effect1 == SE_CurrentHP && spellid1 != spellid2 && sp1_detrimental && sp2_detrimental) { - Log.Out(Logs::Detail, Logs::Spells, "The spells are not the same and it is a detrimental dot, passing"); + Log(Logs::Detail, Logs::Spells, "The spells are not the same and it is a detrimental dot, passing"); continue; } @@ -3074,7 +3076,7 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, sp2_value = 0 - sp2_value; if(sp2_value < sp1_value) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %s (value %d) is not as good as %s (value %d). Rejecting %s.", + Log(Logs::Detail, Logs::Spells, "Spell %s (value %d) is not as good as %s (value %d). Rejecting %s.", sp2.name, sp2_value, sp1.name, sp1_value, sp2.name); return -1; // can't stack } @@ -3083,7 +3085,7 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, //we dont return here... a better value on this one effect dosent mean they are //all better... - Log.Out(Logs::Detail, Logs::Spells, "Spell %s (value %d) is not as good as %s (value %d). We will overwrite %s if there are no other conflicts.", + Log(Logs::Detail, Logs::Spells, "Spell %s (value %d) is not as good as %s (value %d). We will overwrite %s if there are no other conflicts.", sp1.name, sp1_value, sp2.name, sp2_value, sp1.name); will_overwrite = true; } @@ -3092,15 +3094,15 @@ int Mob::CheckStackConflict(uint16 spellid1, int caster_level1, uint16 spellid2, //so now we see if this new spell is any better, or if its not related at all if(will_overwrite) { if (values_equal && effect_match && !IsGroupSpell(spellid2) && IsGroupSpell(spellid1)) { - Log.Out(Logs::Detail, Logs::Spells, "%s (%d) appears to be the single target version of %s (%d), rejecting", + Log(Logs::Detail, Logs::Spells, "%s (%d) appears to be the single target version of %s (%d), rejecting", sp2.name, spellid2, sp1.name, spellid1); return -1; } - Log.Out(Logs::Detail, Logs::Spells, "Stacking code decided that %s should overwrite %s.", sp2.name, sp1.name); + Log(Logs::Detail, Logs::Spells, "Stacking code decided that %s should overwrite %s.", sp2.name, sp1.name); return(1); } - Log.Out(Logs::Detail, Logs::Spells, "Stacking code decided that %s is not affected by %s.", sp2.name, sp1.name); + Log(Logs::Detail, Logs::Spells, "Stacking code decided that %s is not affected by %s.", sp2.name, sp1.name); return 0; } @@ -3187,11 +3189,11 @@ int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_overrid } if (duration == 0) { - Log.Out(Logs::Detail, Logs::Spells, "Buff %d failed to add because its duration came back as 0.", spell_id); + Log(Logs::Detail, Logs::Spells, "Buff %d failed to add because its duration came back as 0.", spell_id); return -2; // no duration? this isn't a buff } - Log.Out(Logs::Detail, Logs::Spells, "Trying to add buff %d cast by %s (cast level %d) with duration %d", + Log(Logs::Detail, Logs::Spells, "Trying to add buff %d cast by %s (cast level %d) with duration %d", spell_id, caster?caster->GetName():"UNKNOWN", caster_level, duration); // first we loop through everything checking that the spell @@ -3211,7 +3213,7 @@ int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_overrid ret = CheckStackConflict(curbuf.spellid, curbuf.casterlevel, spell_id, caster_level, entity_list.GetMobID(curbuf.casterid), caster, buffslot); if (ret == -1) { // stop the spell - Log.Out(Logs::Detail, Logs::Spells, "Adding buff %d failed: stacking prevented by spell %d in slot %d with caster level %d", + Log(Logs::Detail, Logs::Spells, "Adding buff %d failed: stacking prevented by spell %d in slot %d with caster level %d", spell_id, curbuf.spellid, buffslot, curbuf.casterlevel); if (caster && caster->IsClient() && RuleB(Client, UseLiveBlockedMessage)) { caster->Message(13, "Your %s did not take hold on %s. (Blocked by %s.)", spells[spell_id].name, this->GetName(), spells[curbuf.spellid].name); @@ -3219,7 +3221,7 @@ int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_overrid return -1; } if (ret == 1) { // set a flag to indicate that there will be overwriting - Log.Out(Logs::Detail, Logs::Spells, "Adding buff %d will overwrite spell %d in slot %d with caster level %d", + Log(Logs::Detail, Logs::Spells, "Adding buff %d will overwrite spell %d in slot %d with caster level %d", spell_id, curbuf.spellid, buffslot, curbuf.casterlevel); // If this is the first buff it would override, use its slot if (!will_overwrite && !IsDisciplineBuff(spell_id)) @@ -3243,7 +3245,7 @@ int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_overrid for (buffslot = 0; buffslot < buff_count; buffslot++) { const Buffs_Struct &curbuf = buffs[buffslot]; if (IsBeneficialSpell(curbuf.spellid)) { - Log.Out(Logs::Detail, Logs::Spells, "No slot for detrimental buff %d, so we are overwriting a beneficial buff %d in slot %d", + Log(Logs::Detail, Logs::Spells, "No slot for detrimental buff %d, so we are overwriting a beneficial buff %d in slot %d", spell_id, curbuf.spellid, buffslot); BuffFadeBySlot(buffslot, false); emptyslot = buffslot; @@ -3251,11 +3253,11 @@ int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_overrid } } if(emptyslot == -1) { - Log.Out(Logs::Detail, Logs::Spells, "Unable to find a buff slot for detrimental buff %d", spell_id); + Log(Logs::Detail, Logs::Spells, "Unable to find a buff slot for detrimental buff %d", spell_id); return -1; } } else { - Log.Out(Logs::Detail, Logs::Spells, "Unable to find a buff slot for beneficial buff %d", spell_id); + Log(Logs::Detail, Logs::Spells, "Unable to find a buff slot for beneficial buff %d", spell_id); return -1; } } @@ -3307,7 +3309,7 @@ int Mob::AddBuff(Mob *caster, uint16 spell_id, int duration, int32 level_overrid buffs[emptyslot].UpdateClient = true; } - Log.Out(Logs::Detail, Logs::Spells, "Buff %d added to slot %d with caster level %d", spell_id, emptyslot, caster_level); + Log(Logs::Detail, Logs::Spells, "Buff %d added to slot %d with caster level %d", spell_id, emptyslot, caster_level); if (IsPet() && GetOwner() && GetOwner()->IsClient()) SendPetBuffsToClient(); @@ -3349,7 +3351,7 @@ int Mob::CanBuffStack(uint16 spellid, uint8 caster_level, bool iFailIfOverwrite) { int i, ret, firstfree = -2; - Log.Out(Logs::Detail, Logs::AI, "Checking if buff %d cast at level %d can stack on me.%s", spellid, caster_level, iFailIfOverwrite?" failing if we would overwrite something":""); + Log(Logs::Detail, Logs::AI, "Checking if buff %d cast at level %d can stack on me.%s", spellid, caster_level, iFailIfOverwrite?" failing if we would overwrite something":""); int buff_count = GetMaxTotalSlots(); for (i=0; i < buff_count; i++) @@ -3373,7 +3375,7 @@ int Mob::CanBuffStack(uint16 spellid, uint8 caster_level, bool iFailIfOverwrite) if(ret == 1) { // should overwrite current slot if(iFailIfOverwrite) { - Log.Out(Logs::Detail, Logs::AI, "Buff %d would overwrite %d in slot %d, reporting stack failure", spellid, curbuf.spellid, i); + Log(Logs::Detail, Logs::AI, "Buff %d would overwrite %d in slot %d, reporting stack failure", spellid, curbuf.spellid, i); return(-1); } if(firstfree == -2) @@ -3381,12 +3383,12 @@ int Mob::CanBuffStack(uint16 spellid, uint8 caster_level, bool iFailIfOverwrite) } if(ret == -1) { - Log.Out(Logs::Detail, Logs::AI, "Buff %d would conflict with %d in slot %d, reporting stack failure", spellid, curbuf.spellid, i); + Log(Logs::Detail, Logs::AI, "Buff %d would conflict with %d in slot %d, reporting stack failure", spellid, curbuf.spellid, i); return -1; // stop the spell, can't stack it } } - Log.Out(Logs::Detail, Logs::AI, "Reporting that buff %d could successfully be placed into slot %d", spellid, firstfree); + Log(Logs::Detail, Logs::AI, "Reporting that buff %d could successfully be placed into slot %d", spellid, firstfree); return firstfree; } @@ -3414,7 +3416,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r // well we can't cast a spell on target without a target if(!spelltar) { - Log.Out(Logs::Detail, Logs::Spells, "Unable to apply spell %d without a target", spell_id); + Log(Logs::Detail, Logs::Spells, "Unable to apply spell %d without a target", spell_id); Message(13, "SOT: You must have a target for this spell."); return false; } @@ -3448,7 +3450,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r uint16 caster_level = level_override > 0 ? level_override : GetCasterLevel(spell_id); - Log.Out(Logs::Detail, Logs::Spells, "Casting spell %d on %s with effective caster level %d", spell_id, spelltar->GetName(), caster_level); + Log(Logs::Detail, Logs::Spells, "Casting spell %d on %s with effective caster level %d", spell_id, spelltar->GetName(), caster_level); // Actual cast action - this causes the caster animation and the particles // around the target @@ -3537,7 +3539,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r if (RuleB(Spells, EnableBlockedBuffs)) { // We return true here since the caster's client should act like normal if (spelltar->IsBlockedBuff(spell_id)) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %i not applied to %s as it is a Blocked Buff.", + Log(Logs::Detail, Logs::Spells, "Spell %i not applied to %s as it is a Blocked Buff.", spell_id, spelltar->GetName()); safe_delete(action_packet); return true; @@ -3545,7 +3547,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r if (spelltar->IsPet() && spelltar->GetOwner() && spelltar->GetOwner()->IsBlockedPetBuff(spell_id)) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %i not applied to %s (%s's pet) as it is a Pet Blocked Buff.", + Log(Logs::Detail, Logs::Spells, "Spell %i not applied to %s (%s's pet) as it is a Pet Blocked Buff.", spell_id, spelltar->GetName(), spelltar->GetOwner()->GetName()); safe_delete(action_packet); return true; @@ -3554,7 +3556,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r // invuln mobs can't be affected by any spells, good or bad if(spelltar->GetInvul() || spelltar->DivineAura()) { - Log.Out(Logs::Detail, Logs::Spells, "Casting spell %d on %s aborted: they are invulnerable.", spell_id, spelltar->GetName()); + Log(Logs::Detail, Logs::Spells, "Casting spell %d on %s aborted: they are invulnerable.", spell_id, spelltar->GetName()); safe_delete(action_packet); return false; } @@ -3565,17 +3567,17 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r if (RuleB(Pets, UnTargetableSwarmPet)) { if (spelltar->IsNPC()) { if (!spelltar->CastToNPC()->GetSwarmOwner()) { - Log.Out(Logs::Detail, Logs::Spells, "Casting spell %d on %s aborted: they are untargetable", spell_id, spelltar->GetName()); + Log(Logs::Detail, Logs::Spells, "Casting spell %d on %s aborted: they are untargetable", spell_id, spelltar->GetName()); safe_delete(action_packet); return(false); } } else { - Log.Out(Logs::Detail, Logs::Spells, "Casting spell %d on %s aborted: they are untargetable", spell_id, spelltar->GetName()); + Log(Logs::Detail, Logs::Spells, "Casting spell %d on %s aborted: they are untargetable", spell_id, spelltar->GetName()); safe_delete(action_packet); return(false); } } else { - Log.Out(Logs::Detail, Logs::Spells, "Casting spell %d on %s aborted: they are untargetable", spell_id, spelltar->GetName()); + Log(Logs::Detail, Logs::Spells, "Casting spell %d on %s aborted: they are untargetable", spell_id, spelltar->GetName()); safe_delete(action_packet); return(false); } @@ -3684,9 +3686,9 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r { if(spells[spell_id].targettype == ST_AEBard) { //if it was a beneficial AE bard song don't spam the window that it would not hold - Log.Out(Logs::Detail, Logs::Spells, "Beneficial ae bard song %d can't take hold %s -> %s, IBA? %d", spell_id, GetName(), spelltar->GetName(), IsBeneficialAllowed(spelltar)); + Log(Logs::Detail, Logs::Spells, "Beneficial ae bard song %d can't take hold %s -> %s, IBA? %d", spell_id, GetName(), spelltar->GetName(), IsBeneficialAllowed(spelltar)); } else { - Log.Out(Logs::Detail, Logs::Spells, "Beneficial spell %d can't take hold %s -> %s, IBA? %d", spell_id, GetName(), spelltar->GetName(), IsBeneficialAllowed(spelltar)); + Log(Logs::Detail, Logs::Spells, "Beneficial spell %d can't take hold %s -> %s, IBA? %d", spell_id, GetName(), spelltar->GetName(), IsBeneficialAllowed(spelltar)); Message_StringID(MT_SpellFailure, SPELL_NO_HOLD); } safe_delete(action_packet); @@ -3696,7 +3698,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r } else if ( !IsAttackAllowed(spelltar, true) && !IsResurrectionEffects(spell_id)) // Detrimental spells - PVP check { - Log.Out(Logs::Detail, Logs::Spells, "Detrimental spell %d can't take hold %s -> %s", spell_id, GetName(), spelltar->GetName()); + Log(Logs::Detail, Logs::Spells, "Detrimental spell %d can't take hold %s -> %s", spell_id, GetName(), spelltar->GetName()); spelltar->Message_StringID(MT_SpellFailure, YOU_ARE_PROTECTED, GetCleanName()); safe_delete(action_packet); return false; @@ -3710,7 +3712,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r if(spelltar->IsImmuneToSpell(spell_id, this)) { //the above call does the message to the client if needed - Log.Out(Logs::Detail, Logs::Spells, "Spell %d can't take hold due to immunity %s -> %s", spell_id, GetName(), spelltar->GetName()); + Log(Logs::Detail, Logs::Spells, "Spell %d can't take hold due to immunity %s -> %s", spell_id, GetName(), spelltar->GetName()); safe_delete(action_packet); return false; } @@ -3783,7 +3785,9 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r if(reflect_chance) { Message_StringID(MT_Spells, SPELL_REFLECT, GetCleanName(), spelltar->GetCleanName()); CheckNumHitsRemaining(NumHit::ReflectSpell); - SpellOnTarget(spell_id, this, true, use_resist_adjust, resist_adjust); + // caster actually appears to change + // ex. During OMM fight you click your reflect mask and you get the recourse from the reflected spell + spelltar->SpellOnTarget(spell_id, this, true, use_resist_adjust, resist_adjust); safe_delete(action_packet); return false; } @@ -3805,7 +3809,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r { if(spell_effectiveness == 0 || !IsPartialCapableSpell(spell_id) ) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d was completely resisted by %s", spell_id, spelltar->GetName()); + Log(Logs::Detail, Logs::Spells, "Spell %d was completely resisted by %s", spell_id, spelltar->GetName()); if (spells[spell_id].resisttype == RESIST_PHYSICAL){ Message_StringID(MT_SpellFailure, PHYSICAL_RESIST_FAIL,spells[spell_id].name); @@ -3857,7 +3861,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r if (spelltar->IsAIControlled() && IsDetrimentalSpell(spell_id) && !IsHarmonySpell(spell_id)) { int32 aggro_amount = CheckAggroAmount(spell_id, spelltar, isproc); - Log.Out(Logs::Detail, Logs::Spells, "Spell %d cast on %s generated %d hate", spell_id, + Log(Logs::Detail, Logs::Spells, "Spell %d cast on %s generated %d hate", spell_id, spelltar->GetName(), aggro_amount); if (aggro_amount > 0) { spelltar->AddToHateList(this, aggro_amount); @@ -3874,7 +3878,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r // make sure spelltar is high enough level for the buff if(RuleB(Spells, BuffLevelRestrictions) && !spelltar->CheckSpellLevelRestriction(spell_id)) { - Log.Out(Logs::Detail, Logs::Spells, "Spell %d failed: recipient did not meet the level restrictions", spell_id); + Log(Logs::Detail, Logs::Spells, "Spell %d failed: recipient did not meet the level restrictions", spell_id); if(!IsBardSong(spell_id)) Message_StringID(MT_SpellFailure, SPELL_TOO_POWERFUL); safe_delete(action_packet); @@ -3886,7 +3890,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r { // if SpellEffect returned false there's a problem applying the // spell. It's most likely a buff that can't stack. - Log.Out(Logs::Detail, Logs::Spells, "Spell %d could not apply its effects %s -> %s\n", spell_id, GetName(), spelltar->GetName()); + Log(Logs::Detail, Logs::Spells, "Spell %d could not apply its effects %s -> %s\n", spell_id, GetName(), spelltar->GetName()); if(casting_spell_aa_id) Message_StringID(MT_SpellFailure, SPELL_NO_HOLD); safe_delete(action_packet); @@ -3998,14 +4002,14 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r safe_delete(action_packet); safe_delete(message_packet); - Log.Out(Logs::Detail, Logs::Spells, "Cast of %d by %s on %s complete successfully.", spell_id, GetName(), spelltar->GetName()); + Log(Logs::Detail, Logs::Spells, "Cast of %d by %s on %s complete successfully.", spell_id, GetName(), spelltar->GetName()); return true; } void Corpse::CastRezz(uint16 spellid, Mob* Caster) { - Log.Out(Logs::Detail, Logs::Spells, "Corpse::CastRezz spellid %i, Rezzed() is %i, rezzexp is %i", spellid,IsRezzed(),rez_experience); + Log(Logs::Detail, Logs::Spells, "Corpse::CastRezz spellid %i, Rezzed() is %i, rezzexp is %i", spellid,IsRezzed(),rez_experience); if(IsRezzed()){ if(Caster && Caster->IsClient()) @@ -4177,7 +4181,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) //this spell like 10 times, this could easily be consolidated //into one loop through with a switch statement. - Log.Out(Logs::Detail, Logs::Spells, "Checking to see if we are immune to spell %d cast by %s", spell_id, caster->GetName()); + Log(Logs::Detail, Logs::Spells, "Checking to see if we are immune to spell %d cast by %s", spell_id, caster->GetName()); if(!IsValidSpell(spell_id)) return true; @@ -4188,7 +4192,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) if(IsMezSpell(spell_id)) { if(GetSpecialAbility(UNMEZABLE)) { - Log.Out(Logs::Detail, Logs::Spells, "We are immune to Mez spells."); + Log(Logs::Detail, Logs::Spells, "We are immune to Mez spells."); caster->Message_StringID(MT_Shout, CANNOT_MEZ); int32 aggro = caster->CheckAggroAmount(spell_id, this); if(aggro > 0) { @@ -4206,7 +4210,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) if((GetLevel() > spells[spell_id].max[effect_index]) && (!caster->IsNPC() || (caster->IsNPC() && !RuleB(Spells, NPCIgnoreBaseImmunity)))) { - Log.Out(Logs::Detail, Logs::Spells, "Our level (%d) is higher than the limit of this Mez spell (%d)", GetLevel(), spells[spell_id].max[effect_index]); + Log(Logs::Detail, Logs::Spells, "Our level (%d) is higher than the limit of this Mez spell (%d)", GetLevel(), spells[spell_id].max[effect_index]); caster->Message_StringID(MT_Shout, CANNOT_MEZ_WITH_SPELL); return true; } @@ -4215,7 +4219,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) // slow and haste spells if(GetSpecialAbility(UNSLOWABLE) && IsEffectInSpell(spell_id, SE_AttackSpeed)) { - Log.Out(Logs::Detail, Logs::Spells, "We are immune to Slow spells."); + Log(Logs::Detail, Logs::Spells, "We are immune to Slow spells."); caster->Message_StringID(MT_Shout, IMMUNE_ATKSPEED); int32 aggro = caster->CheckAggroAmount(spell_id, this); if(aggro > 0) { @@ -4231,7 +4235,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) { effect_index = GetSpellEffectIndex(spell_id, SE_Fear); if(GetSpecialAbility(UNFEARABLE)) { - Log.Out(Logs::Detail, Logs::Spells, "We are immune to Fear spells."); + Log(Logs::Detail, Logs::Spells, "We are immune to Fear spells."); caster->Message_StringID(MT_Shout, IMMUNE_FEAR); int32 aggro = caster->CheckAggroAmount(spell_id, this); if(aggro > 0) { @@ -4242,13 +4246,13 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) return true; } else if(IsClient() && caster->IsClient() && (caster->CastToClient()->GetGM() == false)) { - Log.Out(Logs::Detail, Logs::Spells, "Clients cannot fear eachother!"); + Log(Logs::Detail, Logs::Spells, "Clients cannot fear eachother!"); caster->Message_StringID(MT_Shout, IMMUNE_FEAR); return true; } else if(GetLevel() > spells[spell_id].max[effect_index] && spells[spell_id].max[effect_index] != 0) { - Log.Out(Logs::Detail, Logs::Spells, "Level is %d, cannot be feared by this spell.", GetLevel()); + Log(Logs::Detail, Logs::Spells, "Level is %d, cannot be feared by this spell.", GetLevel()); caster->Message_StringID(MT_Shout, FEAR_TOO_HIGH); int32 aggro = caster->CheckAggroAmount(spell_id, this); if (aggro > 0) { @@ -4261,7 +4265,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) else if (CheckAATimer(aaTimerWarcry)) { Message(13, "Your are immune to fear."); - Log.Out(Logs::Detail, Logs::Spells, "Clients has WarCry effect, immune to fear!"); + Log(Logs::Detail, Logs::Spells, "Clients has WarCry effect, immune to fear!"); caster->Message_StringID(MT_Shout, IMMUNE_FEAR); return true; } @@ -4271,7 +4275,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) { if(GetSpecialAbility(UNCHARMABLE)) { - Log.Out(Logs::Detail, Logs::Spells, "We are immune to Charm spells."); + Log(Logs::Detail, Logs::Spells, "We are immune to Charm spells."); caster->Message_StringID(MT_Shout, CANNOT_CHARM); int32 aggro = caster->CheckAggroAmount(spell_id, this); if(aggro > 0) { @@ -4284,7 +4288,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) if(this == caster) { - Log.Out(Logs::Detail, Logs::Spells, "You are immune to your own charms."); + Log(Logs::Detail, Logs::Spells, "You are immune to your own charms."); caster->Message(MT_Shout, "You cannot charm yourself."); return true; } @@ -4297,7 +4301,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) assert(effect_index >= 0); if(GetLevel() > spells[spell_id].max[effect_index] && spells[spell_id].max[effect_index] != 0) { - Log.Out(Logs::Detail, Logs::Spells, "Our level (%d) is higher than the limit of this Charm spell (%d)", GetLevel(), spells[spell_id].max[effect_index]); + Log(Logs::Detail, Logs::Spells, "Our level (%d) is higher than the limit of this Charm spell (%d)", GetLevel(), spells[spell_id].max[effect_index]); caster->Message_StringID(MT_Shout, CANNOT_CHARM_YET); return true; } @@ -4311,7 +4315,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) ) { if(GetSpecialAbility(UNSNAREABLE)) { - Log.Out(Logs::Detail, Logs::Spells, "We are immune to Snare spells."); + Log(Logs::Detail, Logs::Spells, "We are immune to Snare spells."); caster->Message_StringID(MT_Shout, IMMUNE_MOVEMENT); int32 aggro = caster->CheckAggroAmount(spell_id, this); if(aggro > 0) { @@ -4327,7 +4331,7 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) { if(this == caster) { - Log.Out(Logs::Detail, Logs::Spells, "You cannot lifetap yourself."); + Log(Logs::Detail, Logs::Spells, "You cannot lifetap yourself."); caster->Message_StringID(MT_Shout, CANT_DRAIN_SELF); return true; } @@ -4337,13 +4341,13 @@ bool Mob::IsImmuneToSpell(uint16 spell_id, Mob *caster) { if(this == caster) { - Log.Out(Logs::Detail, Logs::Spells, "You cannot sacrifice yourself."); + Log(Logs::Detail, Logs::Spells, "You cannot sacrifice yourself."); caster->Message_StringID(MT_Shout, CANNOT_SAC_SELF); return true; } } - Log.Out(Logs::Detail, Logs::Spells, "No immunities to spell %d found.", spell_id); + Log(Logs::Detail, Logs::Spells, "No immunities to spell %d found.", spell_id); return false; } @@ -4380,7 +4384,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use if(GetSpecialAbility(IMMUNE_MAGIC)) { - Log.Out(Logs::Detail, Logs::Spells, "We are immune to magic, so we fully resist the spell %d", spell_id); + Log(Logs::Detail, Logs::Spells, "We are immune to magic, so we fully resist the spell %d", spell_id); return(0); } @@ -4401,7 +4405,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use int fear_resist_bonuses = CalcFearResistChance(); if(zone->random.Roll(fear_resist_bonuses)) { - Log.Out(Logs::Detail, Logs::Spells, "Resisted spell in fear resistance, had %d chance to resist", fear_resist_bonuses); + Log(Logs::Detail, Logs::Spells, "Resisted spell in fear resistance, had %d chance to resist", fear_resist_bonuses); return 0; } } @@ -4419,7 +4423,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use int resist_bonuses = CalcResistChanceBonus(); if(resist_bonuses && zone->random.Roll(resist_bonuses)) { - Log.Out(Logs::Detail, Logs::Spells, "Resisted spell in sanctification, had %d chance to resist", resist_bonuses); + Log(Logs::Detail, Logs::Spells, "Resisted spell in sanctification, had %d chance to resist", resist_bonuses); return 0; } } @@ -4427,7 +4431,7 @@ float Mob::ResistSpell(uint8 resist_type, uint16 spell_id, Mob *caster, bool use //Get the resist chance for the target if(resist_type == RESIST_NONE || spells[spell_id].no_resist) { - Log.Out(Logs::Detail, Logs::Spells, "Spell was unresistable"); + Log(Logs::Detail, Logs::Spells, "Spell was unresistable"); return 100; } @@ -4994,7 +4998,7 @@ void Client::MemSpell(uint16 spell_id, int slot, bool update_client) } m_pp.mem_spells[slot] = spell_id; - Log.Out(Logs::Detail, Logs::Spells, "Spell %d memorized into slot %d", spell_id, slot); + Log(Logs::Detail, Logs::Spells, "Spell %d memorized into slot %d", spell_id, slot); database.SaveCharacterMemorizedSpell(this->CharacterID(), m_pp.mem_spells[slot], slot); @@ -5009,7 +5013,7 @@ void Client::UnmemSpell(int slot, bool update_client) if(slot > MAX_PP_MEMSPELL || slot < 0) return; - Log.Out(Logs::Detail, Logs::Spells, "Spell %d forgotten from slot %d", m_pp.mem_spells[slot], slot); + Log(Logs::Detail, Logs::Spells, "Spell %d forgotten from slot %d", m_pp.mem_spells[slot], slot); m_pp.mem_spells[slot] = 0xFFFFFFFF; database.DeleteCharacterMemorizedSpell(this->CharacterID(), m_pp.mem_spells[slot], slot); @@ -5052,7 +5056,7 @@ void Client::ScribeSpell(uint16 spell_id, int slot, bool update_client) m_pp.spell_book[slot] = spell_id; database.SaveCharacterSpell(this->CharacterID(), spell_id, slot); - Log.Out(Logs::Detail, Logs::Spells, "Spell %d scribed into spell book slot %d", spell_id, slot); + Log(Logs::Detail, Logs::Spells, "Spell %d scribed into spell book slot %d", spell_id, slot); if(update_client) { @@ -5065,7 +5069,7 @@ void Client::UnscribeSpell(int slot, bool update_client) if(slot >= MAX_PP_SPELLBOOK || slot < 0) return; - Log.Out(Logs::Detail, Logs::Spells, "Spell %d erased from spell book slot %d", m_pp.spell_book[slot], slot); + Log(Logs::Detail, Logs::Spells, "Spell %d erased from spell book slot %d", m_pp.spell_book[slot], slot); m_pp.spell_book[slot] = 0xFFFFFFFF; database.DeleteCharacterSpell(this->CharacterID(), m_pp.spell_book[slot], slot); @@ -5096,7 +5100,7 @@ void Client::UntrainDisc(int slot, bool update_client) if(slot >= MAX_PP_DISCIPLINES || slot < 0) return; - Log.Out(Logs::Detail, Logs::Spells, "Discipline %d untrained from slot %d", m_pp.disciplines.values[slot], slot); + Log(Logs::Detail, Logs::Spells, "Discipline %d untrained from slot %d", m_pp.disciplines.values[slot], slot); m_pp.disciplines.values[slot] = 0; database.DeleteCharacterDisc(this->CharacterID(), slot); @@ -5163,12 +5167,12 @@ bool Client::SpellGlobalCheck(uint16 spell_ID, uint32 char_ID) { char_ID, spell_Global_Name.c_str()); results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Spell ID %i query of spell_globals with Name: '%s' Value: '%i' failed", spell_ID, spell_Global_Name.c_str(), spell_Global_Value); + Log(Logs::General, Logs::Error, "Spell ID %i query of spell_globals with Name: '%s' Value: '%i' failed", spell_ID, spell_Global_Name.c_str(), spell_Global_Value); return false; } if (results.RowCount() != 1) { - Log.Out(Logs::General, Logs::Error, "Char ID: %i does not have the Qglobal Name: '%s' for Spell ID %i", char_ID, spell_Global_Name.c_str(), spell_ID); + Log(Logs::General, Logs::Error, "Char ID: %i does not have the Qglobal Name: '%s' for Spell ID %i", char_ID, spell_Global_Name.c_str(), spell_ID); return false; } @@ -5182,7 +5186,7 @@ bool Client::SpellGlobalCheck(uint16 spell_ID, uint32 char_ID) { return true; // Check if the qglobal value is greater than the require spellglobal value // If no matching result found in qglobals, don't scribe this spell - Log.Out(Logs::General, Logs::Error, "Char ID: %i Spell_globals Name: '%s' Value: '%i' did not match QGlobal Value: '%i' for Spell ID %i", char_ID, spell_Global_Name.c_str(), spell_Global_Value, global_Value, spell_ID); + Log(Logs::General, Logs::Error, "Char ID: %i Spell_globals Name: '%s' Value: '%i' did not match QGlobal Value: '%i' for Spell ID %i", char_ID, spell_Global_Name.c_str(), spell_Global_Value, global_Value, spell_ID); return false; } @@ -5221,7 +5225,7 @@ bool Mob::FindType(uint16 type, bool bOffensive, uint16 threshold) { spells[buffs[i].spellid].base[j], spells[buffs[i].spellid].max[j], buffs[i].casterlevel, buffs[i].spellid); - Log.Out(Logs::General, Logs::Normal, + Log(Logs::General, Logs::Normal, "FindType: type = %d; value = %d; threshold = %d", type, value, threshold); if (value < threshold) @@ -5271,12 +5275,12 @@ bool Mob::AddProcToWeapon(uint16 spell_id, bool bPerma, uint16 iChance, uint16 b PermaProcs[i].chance = iChance; PermaProcs[i].base_spellID = base_spell_id; PermaProcs[i].level_override = level_override; - Log.Out(Logs::Detail, Logs::Spells, "Added permanent proc spell %d with chance %d to slot %d", spell_id, iChance, i); + Log(Logs::Detail, Logs::Spells, "Added permanent proc spell %d with chance %d to slot %d", spell_id, iChance, i); return true; } } - Log.Out(Logs::Detail, Logs::Spells, "Too many perma procs for %s", GetName()); + Log(Logs::Detail, Logs::Spells, "Too many perma procs for %s", GetName()); } else { for (i = 0; i < MAX_PROCS; i++) { if (SpellProcs[i].spellID == SPELL_UNKNOWN) { @@ -5284,11 +5288,11 @@ bool Mob::AddProcToWeapon(uint16 spell_id, bool bPerma, uint16 iChance, uint16 b SpellProcs[i].chance = iChance; SpellProcs[i].base_spellID = base_spell_id;; SpellProcs[i].level_override = level_override; - Log.Out(Logs::Detail, Logs::Spells, "Added spell-granted proc spell %d with chance %d to slot %d", spell_id, iChance, i); + Log(Logs::Detail, Logs::Spells, "Added spell-granted proc spell %d with chance %d to slot %d", spell_id, iChance, i); return true; } } - Log.Out(Logs::Detail, Logs::Spells, "Too many procs for %s", GetName()); + Log(Logs::Detail, Logs::Spells, "Too many procs for %s", GetName()); } return false; } @@ -5300,7 +5304,7 @@ bool Mob::RemoveProcFromWeapon(uint16 spell_id, bool bAll) { SpellProcs[i].chance = 0; SpellProcs[i].base_spellID = SPELL_UNKNOWN; SpellProcs[i].level_override = -1; - Log.Out(Logs::Detail, Logs::Spells, "Removed proc %d from slot %d", spell_id, i); + Log(Logs::Detail, Logs::Spells, "Removed proc %d from slot %d", spell_id, i); } } return true; @@ -5317,7 +5321,7 @@ bool Mob::AddDefensiveProc(uint16 spell_id, uint16 iChance, uint16 base_spell_id DefensiveProcs[i].spellID = spell_id; DefensiveProcs[i].chance = iChance; DefensiveProcs[i].base_spellID = base_spell_id; - Log.Out(Logs::Detail, Logs::Spells, "Added spell-granted defensive proc spell %d with chance %d to slot %d", spell_id, iChance, i); + Log(Logs::Detail, Logs::Spells, "Added spell-granted defensive proc spell %d with chance %d to slot %d", spell_id, iChance, i); return true; } } @@ -5332,7 +5336,7 @@ bool Mob::RemoveDefensiveProc(uint16 spell_id, bool bAll) DefensiveProcs[i].spellID = SPELL_UNKNOWN; DefensiveProcs[i].chance = 0; DefensiveProcs[i].base_spellID = SPELL_UNKNOWN; - Log.Out(Logs::Detail, Logs::Spells, "Removed defensive proc %d from slot %d", spell_id, i); + Log(Logs::Detail, Logs::Spells, "Removed defensive proc %d from slot %d", spell_id, i); } } return true; @@ -5349,7 +5353,7 @@ bool Mob::AddRangedProc(uint16 spell_id, uint16 iChance, uint16 base_spell_id) RangedProcs[i].spellID = spell_id; RangedProcs[i].chance = iChance; RangedProcs[i].base_spellID = base_spell_id; - Log.Out(Logs::Detail, Logs::Spells, "Added spell-granted ranged proc spell %d with chance %d to slot %d", spell_id, iChance, i); + Log(Logs::Detail, Logs::Spells, "Added spell-granted ranged proc spell %d with chance %d to slot %d", spell_id, iChance, i); return true; } } @@ -5364,7 +5368,7 @@ bool Mob::RemoveRangedProc(uint16 spell_id, bool bAll) RangedProcs[i].spellID = SPELL_UNKNOWN; RangedProcs[i].chance = 0; RangedProcs[i].base_spellID = SPELL_UNKNOWN;; - Log.Out(Logs::Detail, Logs::Spells, "Removed ranged proc %d from slot %d", spell_id, i); + Log(Logs::Detail, Logs::Spells, "Removed ranged proc %d from slot %d", spell_id, i); } } return true; @@ -5395,8 +5399,8 @@ bool Mob::UseBardSpellLogic(uint16 spell_id, int slot) int Mob::GetCasterLevel(uint16 spell_id) { int level = GetLevel(); level += itembonuses.effective_casting_level + spellbonuses.effective_casting_level + aabonuses.effective_casting_level; - Log.Out(Logs::Detail, Logs::Spells, "Determined effective casting level %d+%d+%d=%d", GetLevel(), spellbonuses.effective_casting_level, itembonuses.effective_casting_level, level); - return(level); + Log(Logs::Detail, Logs::Spells, "Determined effective casting level %d+%d+%d=%d", GetLevel(), spellbonuses.effective_casting_level, itembonuses.effective_casting_level, level); + return std::max(1, level); } //this method does NOT tell the client to stop singing the song. @@ -5823,7 +5827,7 @@ void Client::SetLinkedSpellReuseTimer(uint32 timer_id, uint32 duration) { if (timer_id > 19) return; - Log.Out(Logs::Detail, Logs::Spells, "Setting Linked Spell Reuse %d for %d", timer_id, duration); + Log(Logs::Detail, Logs::Spells, "Setting Linked Spell Reuse %d for %d", timer_id, duration); GetPTimers().Start(pTimerLinkedSpellReuseStart + timer_id, duration); auto outapp = new EQApplicationPacket(OP_LinkedReuse, sizeof(LinkedSpellReuseTimer_Struct)); auto lr = (LinkedSpellReuseTimer_Struct *)outapp->pBuffer; diff --git a/zone/tasks.cpp b/zone/tasks.cpp index dff042388..bcddfcf0a 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -75,7 +75,7 @@ bool TaskManager::LoadTaskSets() { MAXTASKSETS, MAXTASKS); auto results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "[TASKS]Error in TaskManager::LoadTaskSets: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "[TASKS]Error in TaskManager::LoadTaskSets: %s", results.ErrorMessage().c_str()); return false; } @@ -84,7 +84,7 @@ bool TaskManager::LoadTaskSets() { int taskID = atoi(row[1]); TaskSets[taskSet].push_back(taskID); - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Adding TaskID %4i to TaskSet %4i", taskID, taskSet); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Adding TaskID %4i to TaskSet %4i", taskID, taskSet); } return true; @@ -92,7 +92,7 @@ bool TaskManager::LoadTaskSets() { bool TaskManager::LoadSingleTask(int TaskID) { - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskManager::LoadSingleTask(%i)", TaskID); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskManager::LoadSingleTask(%i)", TaskID); if((TaskID <= 0) || (TaskID >= MAXTASKS)) return false; @@ -116,21 +116,21 @@ bool TaskManager::LoadSingleTask(int TaskID) { void TaskManager::ReloadGoalLists() { if(!GoalListManager.LoadLists()) - Log.Out(Logs::Detail, Logs::Tasks,"TaskManager::LoadTasks LoadLists failed"); + Log(Logs::Detail, Logs::Tasks,"TaskManager::LoadTasks LoadLists failed"); } bool TaskManager::LoadTasks(int singleTask) { // If TaskID !=0, then just load the task specified. - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskManager::LoadTasks Called"); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskManager::LoadTasks Called"); std::string query; if(singleTask == 0) { if(!GoalListManager.LoadLists()) - Log.Out(Logs::Detail, Logs::Tasks,"TaskManager::LoadTasks LoadLists failed"); + Log(Logs::Detail, Logs::Tasks,"TaskManager::LoadTasks LoadLists failed"); if(!LoadTaskSets()) - Log.Out(Logs::Detail, Logs::Tasks,"TaskManager::LoadTasks LoadTaskSets failed"); + Log(Logs::Detail, Logs::Tasks,"TaskManager::LoadTasks LoadTaskSets failed"); query = StringFormat("SELECT `id`, `duration`, `title`, `description`, `reward`, " "`rewardid`, `cashreward`, `xpreward`, `rewardmethod`, " @@ -147,7 +147,7 @@ bool TaskManager::LoadTasks(int singleTask) { auto results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); return false; } @@ -156,7 +156,7 @@ bool TaskManager::LoadTasks(int singleTask) { if((taskID <= 0) || (taskID >= MAXTASKS)) { // This shouldn't happen, as the SELECT is bounded by MAXTASKS - Log.Out(Logs::General, Logs::Error, "[TASKS]Task ID %i out of range while loading tasks from database", taskID); + Log(Logs::General, Logs::Error, "[TASKS]Task ID %i out of range while loading tasks from database", taskID); continue; } @@ -180,11 +180,11 @@ bool TaskManager::LoadTasks(int singleTask) { Tasks[taskID]->SequenceMode = ActivitiesSequential; Tasks[taskID]->LastStep = 0; - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskID: %5i, Duration: %8i, StartZone: %3i Reward: %s MinLevel %i MaxLevel %i Repeatable: %s", + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskID: %5i, Duration: %8i, StartZone: %3i Reward: %s MinLevel %i MaxLevel %i Repeatable: %s", taskID, Tasks[taskID]->Duration, Tasks[taskID]->StartZone, Tasks[taskID]->Reward, Tasks[taskID]->MinLevel, Tasks[taskID]->MaxLevel, Tasks[taskID]->Repeatable ? "Yes" : "No"); - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Title: %s", Tasks[taskID]->Title); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Title: %s", Tasks[taskID]->Title); } @@ -204,7 +204,7 @@ bool TaskManager::LoadTasks(int singleTask) { "ORDER BY taskid, activityid ASC", singleTask, MAXACTIVITIESPERTASK); results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); return false; } @@ -216,13 +216,13 @@ bool TaskManager::LoadTasks(int singleTask) { if((taskID <= 0) || (taskID >= MAXTASKS) || (activityID < 0) || (activityID >= MAXACTIVITIESPERTASK)) { // This shouldn't happen, as the SELECT is bounded by MAXTASKS - Log.Out(Logs::General, Logs::Error, "[TASKS]Task or Activity ID (%i, %i) out of range while loading " + Log(Logs::General, Logs::Error, "[TASKS]Task or Activity ID (%i, %i) out of range while loading " "activities from database", taskID, activityID); continue; } if(Tasks[taskID]==nullptr) { - Log.Out(Logs::General, Logs::Error, "[TASKS]Activity for non-existent task (%i, %i) while loading activities from database", taskID, activityID); + Log(Logs::General, Logs::Error, "[TASKS]Activity for non-existent task (%i, %i) while loading activities from database", taskID, activityID); continue; } @@ -239,7 +239,7 @@ bool TaskManager::LoadTasks(int singleTask) { // ERR_NOTASK errors. // Change to (activityID != (Tasks[taskID]->ActivityCount + 1)) to index from 1 if(activityID != Tasks[taskID]->ActivityCount) { - Log.Out(Logs::General, Logs::Error, "[TASKS]Activities for Task %i are not sequential starting at 0. Not loading task.", taskID, activityID); + Log(Logs::General, Logs::Error, "[TASKS]Activities for Task %i are not sequential starting at 0. Not loading task.", taskID, activityID); Tasks[taskID] = nullptr; continue; } @@ -274,7 +274,7 @@ bool TaskManager::LoadTasks(int singleTask) { Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].ZoneID = atoi(row[11]); Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].Optional = atoi(row[12]); - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Activity Slot %2i: ID %i for Task %5i. Type: %3i, GoalID: %8i, " + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Activity Slot %2i: ID %i for Task %5i. Type: %3i, GoalID: %8i, " "GoalMethod: %i, GoalCount: %3i, ZoneID:%3i", Tasks[taskID]->ActivityCount, activityID, taskID, Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].Type, @@ -283,9 +283,9 @@ bool TaskManager::LoadTasks(int singleTask) { Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].GoalCount, Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].ZoneID); - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Text1: %s", Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].Text1); - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Text2: %s", Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].Text2); - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Text3: %s", Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].Text3); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Text1: %s", Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].Text1); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Text2: %s", Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].Text2); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Text3: %s", Tasks[taskID]->Activity[Tasks[taskID]->ActivityCount].Text3); Tasks[taskID]->ActivityCount++; } @@ -307,7 +307,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) { int characterID = c->CharacterID(); - Log.Out(Logs::Detail, Logs::Tasks,"TaskManager::SaveClientState for character ID %d", characterID); + Log(Logs::Detail, Logs::Tasks,"TaskManager::SaveClientState for character ID %d", characterID); if(state->ActiveTaskCount > 0) { for(int task=0; taskActiveTasks[task].Updated) { - Log.Out(Logs::General, Logs::Tasks, "[CLIENTSAVE] TaskManager::SaveClientState for character ID %d, Updating TaskIndex %i TaskID %i", characterID, task, taskID); + Log(Logs::General, Logs::Tasks, "[CLIENTSAVE] TaskManager::SaveClientState for character ID %d, Updating TaskIndex %i TaskID %i", characterID, task, taskID); std::string query = StringFormat("REPLACE INTO character_tasks (charid, taskid, slot, acceptedtime) " "VALUES (%i, %i, %i, %i)", characterID, taskID, task, state->ActiveTasks[task].AcceptedTime); auto results = database.QueryDatabase(query); - if(!results.Success()) - Log.Out(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); - else + if (!results.Success()) { + Log(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); + } + else { state->ActiveTasks[task].Updated = false; + } } @@ -339,7 +341,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) { if(!state->ActiveTasks[task].Activity[activityIndex].Updated) continue; - Log.Out(Logs::General, Logs::Tasks, "[CLIENTSAVE] TaskManager::SaveClientSate for character ID %d, Updating Activity %i, %i", + Log(Logs::General, Logs::Tasks, "[CLIENTSAVE] TaskManager::SaveClientSate for character ID %d, Updating Activity %i, %i", characterID, task, activityIndex); if(updatedActivityCount==0) @@ -359,11 +361,11 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) { if(updatedActivityCount == 0) continue; - Log.Out(Logs::General, Logs::Tasks, "[CLIENTSAVE] Executing query %s", query.c_str()); + Log(Logs::General, Logs::Tasks, "[CLIENTSAVE] Executing query %s", query.c_str()); auto results = database.QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); continue; } @@ -384,7 +386,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) { for(unsigned int i=state->LastCompletedTaskLoaded; iCompletedTasks.size(); i++) { - Log.Out(Logs::General, Logs::Tasks, "[CLIENTSAVE] TaskManager::SaveClientState Saving Completed Task at slot %i", i); + Log(Logs::General, Logs::Tasks, "[CLIENTSAVE] TaskManager::SaveClientState Saving Completed Task at slot %i", i); int taskID = state->CompletedTasks[i].TaskID; if((taskID <= 0) || (taskID >= MAXTASKS) || (Tasks[taskID] == nullptr)) @@ -397,7 +399,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) { std::string query = StringFormat(completedTaskQuery, characterID, state->CompletedTasks[i].CompletedTime, taskID, -1); auto results = database.QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); continue; } @@ -414,7 +416,7 @@ bool TaskManager::SaveClientState(Client *c, ClientTaskState *state) { query = StringFormat(completedTaskQuery, characterID, state->CompletedTasks[i].CompletedTime, taskID, j); results = database.QueryDatabase(query); if(!results.Success()) - Log.Out(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, ERR_MYSQLERROR, results.ErrorMessage().c_str()); } @@ -460,14 +462,14 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { state->ActiveTaskCount = 0; - Log.Out(Logs::General, Logs::Tasks, "[CLIENTLOAD] TaskManager::LoadClientState for character ID %d", characterID); + Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] TaskManager::LoadClientState for character ID %d", characterID); std::string query = StringFormat("SELECT `taskid`, `slot`, `acceptedtime` " "FROM `character_tasks` " "WHERE `charid` = %i ORDER BY acceptedtime", characterID); auto results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "[TASKS]Error in TaskManager::LoadClientState load Tasks: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "[TASKS]Error in TaskManager::LoadClientState load Tasks: %s", results.ErrorMessage().c_str()); return false; } @@ -476,17 +478,17 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { int slot = atoi(row[1]); if((taskID<0) || (taskID>=MAXTASKS)) { - Log.Out(Logs::General, Logs::Error, "[TASKS]Task ID %i out of range while loading character tasks from database", taskID); + Log(Logs::General, Logs::Error, "[TASKS]Task ID %i out of range while loading character tasks from database", taskID); continue; } if((slot<0) || (slot>=MAXACTIVETASKS)) { - Log.Out(Logs::General, Logs::Error, "[TASKS] Slot %i out of range while loading character tasks from database", slot); + Log(Logs::General, Logs::Error, "[TASKS] Slot %i out of range while loading character tasks from database", slot); continue; } if(state->ActiveTasks[slot].TaskID != TASKSLOTEMPTY) { - Log.Out(Logs::General, Logs::Error, "[TASKS] Slot %i for Task %is is already occupied.", slot, taskID); + Log(Logs::General, Logs::Error, "[TASKS] Slot %i for Task %is is already occupied.", slot, taskID); continue; } @@ -502,11 +504,11 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { ++state->ActiveTaskCount; - Log.Out(Logs::General, Logs::Tasks, "[CLIENTLOAD] TaskManager::LoadClientState. Char: %i Task ID %i, Accepted Time: %8X", characterID, taskID, acceptedtime); + Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] TaskManager::LoadClientState. Char: %i Task ID %i, Accepted Time: %8X", characterID, taskID, acceptedtime); } // Load Activities - Log.Out(Logs::General, Logs::Tasks, "[CLIENTLOAD] LoadClientState. Loading activities for character ID %d", characterID); + Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] LoadClientState. Loading activities for character ID %d", characterID); query = StringFormat("SELECT `taskid`, `activityid`, `donecount`, `completed` " "FROM `character_activities` " @@ -514,20 +516,20 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { "ORDER BY `taskid` ASC, `activityid` ASC", characterID); results = database.QueryDatabase(query); if (!results.Success()){ - Log.Out(Logs::General, Logs::Error, "[TASKS]Error in TaskManager::LoadClientState load Activities: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "[TASKS]Error in TaskManager::LoadClientState load Activities: %s", results.ErrorMessage().c_str()); return false; } for (auto row = results.begin(); row != results.end(); ++row) { int taskID = atoi(row[0]); if((taskID<0) || (taskID>=MAXTASKS)) { - Log.Out(Logs::General, Logs::Error, "[TASKS]Task ID %i out of range while loading character activities from database", taskID); + Log(Logs::General, Logs::Error, "[TASKS]Task ID %i out of range while loading character activities from database", taskID); continue; } int activityID = atoi(row[1]); if((activityID<0) || (activityID>=MAXACTIVITIESPERTASK)) { - Log.Out(Logs::General, Logs::Error, "[TASKS]Activity ID %i out of range while loading character activities from database", activityID); + Log(Logs::General, Logs::Error, "[TASKS]Activity ID %i out of range while loading character activities from database", activityID); continue; } @@ -541,7 +543,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { } if(activeTaskIndex == -1) { - Log.Out(Logs::General, Logs::Error, "[TASKS]Activity %i found for task %i which client does not have.", activityID, taskID); + Log(Logs::General, Logs::Error, "[TASKS]Activity %i found for task %i which client does not have.", activityID, taskID); continue; } @@ -556,7 +558,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { state->ActiveTasks[activeTaskIndex].Activity[activityID].Updated = false; - Log.Out(Logs::General, Logs::Tasks, "[CLIENTLOAD] TaskManager::LoadClientState. Char: %i Task ID %i, ActivityID: %i, DoneCount: %i, Completed: %i", characterID, taskID, activityID, doneCount, completed); + Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] TaskManager::LoadClientState. Char: %i Task ID %i, ActivityID: %i, DoneCount: %i, Completed: %i", characterID, taskID, activityID, doneCount, completed); } @@ -567,7 +569,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { characterID); results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "[TASKS]Error in TaskManager::LoadClientState load completed tasks: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "[TASKS]Error in TaskManager::LoadClientState load completed tasks: %s", results.ErrorMessage().c_str()); return false; } @@ -583,7 +585,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { int taskID = atoi(row[0]); if((taskID <= 0) || (taskID >=MAXTASKS)) { - Log.Out(Logs::General, Logs::Error, "[TASKS]Task ID %i out of range while loading completed tasks from database", taskID); + Log(Logs::General, Logs::Error, "[TASKS]Task ID %i out of range while loading completed tasks from database", taskID); continue; } @@ -593,7 +595,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { // completed. int activityID = atoi(row[1]); if((activityID<-1) || (activityID>=MAXACTIVITIESPERTASK)) { - Log.Out(Logs::General, Logs::Error, "[TASKS]Activity ID %i out of range while loading completed tasks from database", activityID); + Log(Logs::General, Logs::Error, "[TASKS]Activity ID %i out of range while loading completed tasks from database", activityID); continue; } @@ -634,14 +636,16 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { "ORDER BY `taskid` ASC", characterID, MAXTASKS); results = database.QueryDatabase(query); - if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "[TASKS]Error in TaskManager::LoadClientState load enabled tasks: %s", results.ErrorMessage().c_str()); - else - for (auto row = results.begin(); row != results.end(); ++row) { + if (!results.Success()) { + Log(Logs::General, Logs::Error, "[TASKS]Error in TaskManager::LoadClientState load enabled tasks: %s", results.ErrorMessage().c_str()); + } + else { + for (auto row = results.begin(); row != results.end(); ++row) { int taskID = atoi(row[0]); state->EnabledTasks.push_back(taskID); - Log.Out(Logs::General, Logs::Tasks, "[CLIENTLOAD] Adding TaskID %i to enabled tasks", taskID); + Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] Adding TaskID %i to enabled tasks", taskID); } + } // Check that there is an entry in the client task state for every activity in each task // This should only break if a ServerOP adds or deletes activites for a task that players already @@ -653,7 +657,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { c->Message(13, "Active Task Slot %i, references a task (%i), that does not exist. " "Removing from memory. Contact a GM to resolve this.",i, taskID); - Log.Out(Logs::General, Logs::Error, "[TASKS]Character %i has task %i which does not exist.", characterID, taskID); + Log(Logs::General, Logs::Error, "[TASKS]Character %i has task %i which does not exist.", characterID, taskID); state->ActiveTasks[i].TaskID=TASKSLOTEMPTY; continue; @@ -665,7 +669,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { "Removing from memory. Contact a GM to resolve this.", taskID, Tasks[taskID]->Title); - Log.Out(Logs::General, Logs::Error, "[TASKS]Fatal error in character %i task state. Activity %i for " + Log(Logs::General, Logs::Error, "[TASKS]Fatal error in character %i task state. Activity %i for " "Task %i either missing from client state or from task.", characterID, j, taskID); state->ActiveTasks[i].TaskID=TASKSLOTEMPTY; break; @@ -677,7 +681,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { if(state->ActiveTasks[i].TaskID != TASKSLOTEMPTY) state->UnlockActivities(characterID, i); - Log.Out(Logs::General, Logs::Tasks, "[CLIENTLOAD] LoadClientState for Character ID %d DONE!", characterID); + Log(Logs::General, Logs::Tasks, "[CLIENTLOAD] LoadClientState for Character ID %d DONE!", characterID); return true; } @@ -711,9 +715,9 @@ void ClientTaskState::EnableTask(int characterID, int taskCount, int *tasks) { } } - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] New enabled task list "); + Log(Logs::General, Logs::Tasks, "[UPDATE] New enabled task list "); for(unsigned int i=0; iGetLevel(); - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] TaskSetSelector called for taskset %i. EnableTaskSize is %i", TaskSetID, + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSetSelector called for taskset %i. EnableTaskSize is %i", TaskSetID, state->EnabledTasks.size()); if((TaskSetID<=0) || (TaskSetID>=MAXTASKSETS)) return; @@ -949,7 +953,7 @@ void TaskManager::TaskSetSelector(Client *c, ClientTaskState *state, Mob *mob, i if(TaskSets[TaskSetID][0] == 0) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] TaskSets[%i][0] == 0. All Tasks in Set enabled.", TaskSetID); + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSets[%i][0] == 0. All Tasks in Set enabled.", TaskSetID); auto Iterator = TaskSets[TaskSetID].begin(); while((Iterator != TaskSets[TaskSetID].end()) && (TaskListIndex < MAXCHOOSERENTRIES)) { @@ -972,7 +976,7 @@ void TaskManager::TaskSetSelector(Client *c, ClientTaskState *state, Mob *mob, i while((EnabledTaskIndex < state->EnabledTasks.size()) && (TaskSetIndex < TaskSets[TaskSetID].size()) && (TaskListIndex < MAXCHOOSERENTRIES)) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Comparing EnabledTasks[%i] (%i) with TaskSets[%i][%i] (%i)", + Log(Logs::General, Logs::Tasks, "[UPDATE] Comparing EnabledTasks[%i] (%i) with TaskSets[%i][%i] (%i)", EnabledTaskIndex, state->EnabledTasks[EnabledTaskIndex], TaskSetID, TaskSetIndex, TaskSets[TaskSetID][TaskSetIndex]); @@ -1012,7 +1016,7 @@ void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *Task return; } // Titanium OpCode: 0x5e7c - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] TaskSelector for %i Tasks", TaskCount); + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSelector for %i Tasks", TaskCount); char *Ptr; int PlayerLevel = c->GetLevel(); @@ -1136,7 +1140,7 @@ void TaskManager::SendTaskSelector(Client *c, Mob *mob, int TaskCount, int *Task void TaskManager::SendTaskSelectorNew(Client *c, Mob *mob, int TaskCount, int *TaskList) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] TaskSelector for %i Tasks", TaskCount); + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskSelector for %i Tasks", TaskCount); int PlayerLevel = c->GetLevel(); @@ -1304,7 +1308,7 @@ int ClientTaskState::GetActiveTaskID(int index) { static void DeleteCompletedTaskFromDatabase(int charID, int taskID) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] DeleteCompletedTasksFromDatabase. CharID = %i, TaskID = %i", charID, taskID); + Log(Logs::General, Logs::Tasks, "[UPDATE] DeleteCompletedTasksFromDatabase. CharID = %i, TaskID = %i", charID, taskID); const std::string query = StringFormat("DELETE FROM completed_tasks WHERE charid=%i AND taskid = %i", charID, taskID); auto results = database.QueryDatabase(query); @@ -1312,7 +1316,7 @@ static void DeleteCompletedTaskFromDatabase(int charID, int taskID) { return; } - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Delete query %s", query.c_str()); + Log(Logs::General, Logs::Tasks, "[UPDATE] Delete query %s", query.c_str()); } bool ClientTaskState::UnlockActivities(int CharID, int TaskIndex) { @@ -1326,7 +1330,7 @@ bool ClientTaskState::UnlockActivities(int CharID, int TaskIndex) { // On loading the client state, all activities that are not completed, are // marked as hidden. For Sequential (non-stepped) mode, we mark the first // activity as active if not complete. - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] CharID: %i Task: %i Sequence mode is %i", + Log(Logs::General, Logs::Tasks, "[UPDATE] CharID: %i Task: %i Sequence mode is %i", CharID, ActiveTasks[TaskIndex].TaskID, Task->SequenceMode); if(Task->SequenceMode == ActivitiesSequential) { @@ -1348,7 +1352,7 @@ bool ClientTaskState::UnlockActivities(int CharID, int TaskIndex) { } if(AllActivitiesComplete && RuleB(TaskSystem, RecordCompletedTasks)) { if(RuleB(TasksSystem, KeepOneRecordPerCompletedTask)) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] KeepOneRecord enabled"); + Log(Logs::General, Logs::Tasks, "[UPDATE] KeepOneRecord enabled"); auto Iterator = CompletedTasks.begin(); int ErasedElements = 0; while(Iterator != CompletedTasks.end()) { @@ -1360,7 +1364,7 @@ bool ClientTaskState::UnlockActivities(int CharID, int TaskIndex) { else ++Iterator; } - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Erased Element count is %i", ErasedElements); + Log(Logs::General, Logs::Tasks, "[UPDATE] Erased Element count is %i", ErasedElements); if(ErasedElements) { LastCompletedTaskLoaded -= ErasedElements; DeleteCompletedTaskFromDatabase(CharID, ActiveTasks[TaskIndex].TaskID); @@ -1377,7 +1381,7 @@ bool ClientTaskState::UnlockActivities(int CharID, int TaskIndex) { CompletedTasks.push_back(cti); } - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Returning sequential task, AllActivitiesComplete is %i", AllActivitiesComplete); + Log(Logs::General, Logs::Tasks, "[UPDATE] Returning sequential task, AllActivitiesComplete is %i", AllActivitiesComplete); return AllActivitiesComplete; } @@ -1386,7 +1390,7 @@ bool ClientTaskState::UnlockActivities(int CharID, int TaskIndex) { bool CurrentStepComplete = true; - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Current Step is %i, Last Step is %i", ActiveTasks[TaskIndex].CurrentStep, Task->LastStep); + Log(Logs::General, Logs::Tasks, "[UPDATE] Current Step is %i, Last Step is %i", ActiveTasks[TaskIndex].CurrentStep, Task->LastStep); // If CurrentStep is -1, this is the first call to this method since loading the // client state. Unlock all activities with a step number of 0 if(ActiveTasks[TaskIndex].CurrentStep == -1) { @@ -1421,7 +1425,7 @@ bool ClientTaskState::UnlockActivities(int CharID, int TaskIndex) { // If we are only keeping one completed record per task, and the player has done // the same task again, erase the previous completed entry for this task. if(RuleB(TasksSystem, KeepOneRecordPerCompletedTask)) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] KeepOneRecord enabled"); + Log(Logs::General, Logs::Tasks, "[UPDATE] KeepOneRecord enabled"); auto Iterator = CompletedTasks.begin(); int ErasedElements = 0; while(Iterator != CompletedTasks.end()) { @@ -1433,7 +1437,7 @@ bool ClientTaskState::UnlockActivities(int CharID, int TaskIndex) { else ++Iterator; } - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Erased Element count is %i", ErasedElements); + Log(Logs::General, Logs::Tasks, "[UPDATE] Erased Element count is %i", ErasedElements); if(ErasedElements) { LastCompletedTaskLoaded -= ErasedElements; DeleteCompletedTaskFromDatabase(CharID, ActiveTasks[TaskIndex].TaskID); @@ -1483,7 +1487,7 @@ bool ClientTaskState::UpdateTasksByNPC(Client *c, int ActivityType, int NPCTypeI int Ret = false; - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasks for NPCTypeID: %d", NPCTypeID); + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasks for NPCTypeID: %d", NPCTypeID); // If the client has no tasks, there is nothing further to check. @@ -1505,7 +1509,7 @@ bool ClientTaskState::UpdateTasksByNPC(Client *c, int ActivityType, int NPCTypeI if(Task->Activity[j].Type != ActivityType) continue; // Is there a zone restriction on the activity ? if((Task->Activity[j].ZoneID >0) && (Task->Activity[j].ZoneID != (int)zone->GetZoneID())) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Char: %s Task: %i, Activity %i, Activity type %i for NPC %i failed zone check", + Log(Logs::General, Logs::Tasks, "[UPDATE] Char: %s Task: %i, Activity %i, Activity type %i for NPC %i failed zone check", c->GetName(), ActiveTasks[i].TaskID, j, ActivityType, NPCTypeID); continue; } @@ -1526,7 +1530,7 @@ bool ClientTaskState::UpdateTasksByNPC(Client *c, int ActivityType, int NPCTypeI continue; } // We found an active task to kill this type of NPC, so increment the done count - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Calling increment done count ByNPC"); + Log(Logs::General, Logs::Tasks, "[UPDATE] Calling increment done count ByNPC"); IncrementDoneCount(c, Task, i, j); Ret = true; } @@ -1605,7 +1609,7 @@ void ClientTaskState::UpdateTasksForItem(Client *c, ActivityType Type, int ItemI // If the client has no tasks, there is nothing further to check. - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasksForItem(%d,%d)", Type, ItemID); + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasksForItem(%d,%d)", Type, ItemID); if(ActiveTaskCount == 0) return; @@ -1625,7 +1629,7 @@ void ClientTaskState::UpdateTasksForItem(Client *c, ActivityType Type, int ItemI if(Task->Activity[j].Type != (int)Type) continue; // Is there a zone restriction on the activity ? if((Task->Activity[j].ZoneID >0) && (Task->Activity[j].ZoneID != (int)zone->GetZoneID())) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Char: %s Activity type %i for Item %i failed zone check", + Log(Logs::General, Logs::Tasks, "[UPDATE] Char: %s Activity type %i for Item %i failed zone check", c->GetName(), Type, ItemID); continue; } @@ -1646,7 +1650,7 @@ void ClientTaskState::UpdateTasksForItem(Client *c, ActivityType Type, int ItemI continue; } // We found an active task related to this item, so increment the done count - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Calling increment done count ForItem"); + Log(Logs::General, Logs::Tasks, "[UPDATE] Calling increment done count ForItem"); IncrementDoneCount(c, Task, i, j, Count); } } @@ -1658,7 +1662,7 @@ void ClientTaskState::UpdateTasksOnExplore(Client *c, int ExploreID) { // If the client has no tasks, there is nothing further to check. - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasksOnExplore(%i)", ExploreID); + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasksOnExplore(%i)", ExploreID); if(ActiveTaskCount == 0) return; for(int i=0; iActivity[j].Type != ActivityExplore) continue; if((Task->Activity[j].ZoneID >0) && (Task->Activity[j].ZoneID != (int)zone->GetZoneID())) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Char: %s Explore exploreid %i failed zone check", + Log(Logs::General, Logs::Tasks, "[UPDATE] Char: %s Explore exploreid %i failed zone check", c->GetName(), ExploreID); continue; } @@ -1698,7 +1702,7 @@ void ClientTaskState::UpdateTasksOnExplore(Client *c, int ExploreID) { } // We found an active task to explore this area, so set done count to goal count // (Only a goal count of 1 makes sense for explore activities?) - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Increment on explore"); + Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on explore"); IncrementDoneCount(c, Task, i, j, Task->Activity[j].GoalCount - ActiveTasks[i].Activity[j].DoneCount); @@ -1712,7 +1716,7 @@ bool ClientTaskState::UpdateTasksOnDeliver(Client *c, std::listActivity[j].Type != ActivityGiveCash)) continue; // Is there a zone restriction on the activity ? if((Task->Activity[j].ZoneID >0) && (Task->Activity[j].ZoneID != (int)zone->GetZoneID())) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Char: %s Deliver activity failed zone check (current zone %i, need zone %i", + Log(Logs::General, Logs::Tasks, "[UPDATE] Char: %s Deliver activity failed zone check (current zone %i, need zone %i", c->GetName(), zone->GetZoneID(), Task->Activity[j].ZoneID); continue; } @@ -1742,7 +1746,7 @@ bool ClientTaskState::UpdateTasksOnDeliver(Client *c, std::listActivity[j].Type == ActivityGiveCash) && Cash) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Increment on GiveCash"); + Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on GiveCash"); IncrementDoneCount(c, Task, i, j, Cash); Ret = true; } @@ -1764,7 +1768,7 @@ bool ClientTaskState::UpdateTasksOnDeliver(Client *c, std::listGetCharges() <= 0 ? 1 : k->GetCharges()); Ret = true; } @@ -1779,7 +1783,7 @@ void ClientTaskState::UpdateTasksOnTouch(Client *c, int ZoneID) { // If the client has no tasks, there is nothing further to check. - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasksOnTouch(%i)", ZoneID); + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState::UpdateTasksOnTouch(%i)", ZoneID); if(ActiveTaskCount == 0) return; for(int i=0; iActivity[j].Type != ActivityTouch) continue; if(Task->Activity[j].GoalMethod != METHODSINGLEID) continue; if(Task->Activity[j].ZoneID != ZoneID) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Char: %s Touch activity failed zone check", + Log(Logs::General, Logs::Tasks, "[UPDATE] Char: %s Touch activity failed zone check", c->GetName()); continue; } // We found an active task to zone into this zone, so set done count to goal count // (Only a goal count of 1 makes sense for touch activities?) - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Increment on Touch"); + Log(Logs::General, Logs::Tasks, "[UPDATE] Increment on Touch"); IncrementDoneCount(c, Task, i, j, Task->Activity[j].GoalCount - ActiveTasks[i].Activity[j].DoneCount); } @@ -1814,7 +1818,7 @@ void ClientTaskState::UpdateTasksOnTouch(Client *c, int ZoneID) { } void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation* Task, int TaskIndex, int ActivityID, int Count, bool ignore_quest_update) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] IncrementDoneCount"); + Log(Logs::General, Logs::Tasks, "[UPDATE] IncrementDoneCount"); ActiveTasks[TaskIndex].Activity[ActivityID].DoneCount += Count; @@ -1831,7 +1835,7 @@ void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation* Task, int T ActiveTasks[TaskIndex].Activity[ActivityID].Updated=true; // Have we reached the goal count for this activity ? if(ActiveTasks[TaskIndex].Activity[ActivityID].DoneCount >= Task->Activity[ActivityID].GoalCount) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Done (%i) = Goal (%i) for Activity %i", + Log(Logs::General, Logs::Tasks, "[UPDATE] Done (%i) = Goal (%i) for Activity %i", ActiveTasks[TaskIndex].Activity[ActivityID].DoneCount, Task->Activity[ActivityID].GoalCount, ActivityID); @@ -1840,7 +1844,7 @@ void ClientTaskState::IncrementDoneCount(Client *c, TaskInformation* Task, int T ActiveTasks[TaskIndex].Activity[ActivityID].State = ActivityCompleted; // Unlock subsequent activities for this task bool TaskComplete = UnlockActivities(c->CharacterID(), TaskIndex); - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] TaskCompleted is %i", TaskComplete); + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskCompleted is %i", TaskComplete); // and by the 'Task Stage Completed' message c->SendTaskActivityComplete(ActiveTasks[TaskIndex].TaskID, ActivityID, TaskIndex); // Send the updated task/activity list to the client @@ -2017,7 +2021,7 @@ bool ClientTaskState::IsTaskActive(int TaskID) { void ClientTaskState::FailTask(Client *c, int TaskID) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] FailTask %i, ActiveTaskCount is %i", TaskID, ActiveTaskCount); + Log(Logs::General, Logs::Tasks, "[UPDATE] FailTask %i, ActiveTaskCount is %i", TaskID, ActiveTaskCount); if(ActiveTaskCount == 0) return; for(int i=0; i= Task->ActivityCount) return false; - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState IsTaskActivityActive(%i, %i). State is %i ", TaskID, ActivityID, + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState IsTaskActivityActive(%i, %i). State is %i ", TaskID, ActivityID, ActiveTasks[ActiveTaskIndex].Activity[ActivityID].State); @@ -2071,7 +2075,7 @@ bool ClientTaskState::IsTaskActivityActive(int TaskID, int ActivityID) { void ClientTaskState::UpdateTaskActivity(Client *c, int TaskID, int ActivityID, int Count, bool ignore_quest_update /*= false*/) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState UpdateTaskActivity(%i, %i, %i).", TaskID, ActivityID, Count); + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState UpdateTaskActivity(%i, %i, %i).", TaskID, ActivityID, Count); // Quick sanity check if((ActivityID<0) || (ActiveTaskCount==0)) return; @@ -2098,14 +2102,14 @@ void ClientTaskState::UpdateTaskActivity(Client *c, int TaskID, int ActivityID, // The Activity is not currently active if(ActiveTasks[ActiveTaskIndex].Activity[ActivityID].State != ActivityActive) return; - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Increment done count on UpdateTaskActivity"); + Log(Logs::General, Logs::Tasks, "[UPDATE] Increment done count on UpdateTaskActivity"); IncrementDoneCount(c, Task, ActiveTaskIndex, ActivityID, Count, ignore_quest_update); } void ClientTaskState::ResetTaskActivity(Client *c, int TaskID, int ActivityID) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState UpdateTaskActivity(%i, %i, 0).", TaskID, ActivityID); + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState UpdateTaskActivity(%i, %i, 0).", TaskID, ActivityID); // Quick sanity check if((ActivityID<0) || (ActiveTaskCount==0)) return; @@ -2133,7 +2137,7 @@ void ClientTaskState::ResetTaskActivity(Client *c, int TaskID, int ActivityID) { // The Activity is not currently active if(ActiveTasks[ActiveTaskIndex].Activity[ActivityID].State != ActivityActive) return; - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] ResetTaskActivityCount"); + Log(Logs::General, Logs::Tasks, "[UPDATE] ResetTaskActivityCount"); ActiveTasks[ActiveTaskIndex].Activity[ActivityID].DoneCount = 0; @@ -2199,7 +2203,7 @@ int ClientTaskState::IsTaskCompleted(int TaskID) { if(!(RuleB(TaskSystem, RecordCompletedTasks))) return -1; for(unsigned int i=0; iunknown5 = 0x00000001; tac->unknown5 = 0; // 0 for task complete or failed. - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] TaskFailed"); + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskFailed"); QueuePacket(outapp); safe_delete(outapp); @@ -2449,7 +2453,7 @@ void TaskManager::SendCompletedTasksToClient(Client *c, ClientTaskState *State) if(State->CompletedTasks.size() > 50) FirstTaskToSend = State->CompletedTasks.size() - 50; - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Completed Task Count: %i, First Task to send is %i, Last is %i", + Log(Logs::General, Logs::Tasks, "[UPDATE] Completed Task Count: %i, First Task to send is %i, Last is %i", State->CompletedTasks.size(), FirstTaskToSend, LastTaskToSend); /* for(iterator=State->CompletedTasks.begin(); iterator!=State->CompletedTasks.end(); iterator++) { @@ -2706,12 +2710,12 @@ void TaskManager::SendActiveTasksToClient(Client *c, bool TaskComplete) { int StartTime = c->GetTaskStartTime(TaskIndex); SendActiveTaskDescription(c, TaskID, TaskIndex, StartTime, Tasks[TaskID]->Duration, false); - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] SendActiveTasksToClient: Task %i, Activities: %i", TaskID, GetActivityCount(TaskID)); + Log(Logs::General, Logs::Tasks, "[UPDATE] SendActiveTasksToClient: Task %i, Activities: %i", TaskID, GetActivityCount(TaskID)); int Sequence = 0; for(int Activity=0; ActivityGetTaskActivityState(TaskIndex, Activity) != ActivityHidden) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Long: %i, %i, %i Complete=%i", TaskID, Activity, TaskIndex, TaskComplete); + Log(Logs::General, Logs::Tasks, "[UPDATE] Long: %i, %i, %i Complete=%i", TaskID, Activity, TaskIndex, TaskComplete); if(Activity==GetActivityCount(TaskID)-1) SendTaskActivityLong(c, TaskID, Activity, TaskIndex, Tasks[TaskID]->Activity[Activity].Optional, @@ -2721,7 +2725,7 @@ void TaskManager::SendActiveTasksToClient(Client *c, bool TaskComplete) { Tasks[TaskID]->Activity[Activity].Optional, 0); } else { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Short: %i, %i, %i", TaskID, Activity, TaskIndex); + Log(Logs::General, Logs::Tasks, "[UPDATE] Short: %i, %i, %i", TaskID, Activity, TaskIndex); SendTaskActivityShort(c, TaskID, Activity, TaskIndex); } Sequence++; @@ -2742,13 +2746,13 @@ void TaskManager::SendSingleActiveTaskToClient(Client *c, int TaskIndex, bool Ta int StartTime = c->GetTaskStartTime(TaskIndex); SendActiveTaskDescription(c, TaskID, TaskIndex, StartTime, Tasks[TaskID]->Duration, BringUpTaskJournal); - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] SendSingleActiveTasksToClient: Task %i, Activities: %i", TaskID, GetActivityCount(TaskID)); + Log(Logs::General, Logs::Tasks, "[UPDATE] SendSingleActiveTasksToClient: Task %i, Activities: %i", TaskID, GetActivityCount(TaskID)); int Sequence = 0; for(int Activity=0; ActivityGetTaskActivityState(TaskIndex, Activity) != ActivityHidden) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Long: %i, %i, %i Complete=%i", TaskID, Activity, TaskIndex, TaskComplete); + Log(Logs::General, Logs::Tasks, "[UPDATE] Long: %i, %i, %i Complete=%i", TaskID, Activity, TaskIndex, TaskComplete); if(Activity==GetActivityCount(TaskID)-1) SendTaskActivityLong(c, TaskID, Activity, TaskIndex, Tasks[TaskID]->Activity[Activity].Optional, TaskComplete); @@ -2757,7 +2761,7 @@ void TaskManager::SendSingleActiveTaskToClient(Client *c, int TaskIndex, bool Ta Tasks[TaskID]->Activity[Activity].Optional, 0); } else { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] Short: %i, %i, %i", TaskID, Activity, TaskIndex); + Log(Logs::General, Logs::Tasks, "[UPDATE] Short: %i, %i, %i", TaskID, Activity, TaskIndex); SendTaskActivityShort(c, TaskID, Activity, TaskIndex); } Sequence++; @@ -2944,7 +2948,7 @@ void ClientTaskState::CancelTask(Client *c, int SequenceNumber, bool RemoveFromD cts->SequenceNumber = SequenceNumber; cts->unknown4 = 0x00000002; - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] CancelTask"); + Log(Logs::General, Logs::Tasks, "[UPDATE] CancelTask"); c->QueuePacket(outapp); safe_delete(outapp); @@ -2956,24 +2960,24 @@ void ClientTaskState::CancelTask(Client *c, int SequenceNumber, bool RemoveFromD void ClientTaskState::RemoveTask(Client *c, int sequenceNumber) { int characterID = c->CharacterID(); - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState Cancel Task %i ", sequenceNumber); + Log(Logs::General, Logs::Tasks, "[UPDATE] ClientTaskState Cancel Task %i ", sequenceNumber); std::string query = StringFormat("DELETE FROM character_activities WHERE charid=%i AND taskid = %i", characterID, ActiveTasks[sequenceNumber].TaskID); auto results = database.QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::General, Logs::Error, "[TASKS] Error in CientTaskState::CancelTask %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "[TASKS] Error in CientTaskState::CancelTask %s", results.ErrorMessage().c_str()); return; } - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] CancelTask: %s", query.c_str()); + Log(Logs::General, Logs::Tasks, "[UPDATE] CancelTask: %s", query.c_str()); query = StringFormat("DELETE FROM character_tasks WHERE charid=%i AND taskid = %i", characterID, ActiveTasks[sequenceNumber].TaskID); results = database.QueryDatabase(query); if(!results.Success()) - Log.Out(Logs::General, Logs::Error, "[TASKS] Error in CientTaskState::CancelTask %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "[TASKS] Error in CientTaskState::CancelTask %s", results.ErrorMessage().c_str()); - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] CancelTask: %s", query.c_str()); + Log(Logs::General, Logs::Tasks, "[UPDATE] CancelTask: %s", query.c_str()); ActiveTasks[sequenceNumber].TaskID = TASKSLOTEMPTY; ActiveTaskCount--; @@ -3020,7 +3024,7 @@ void ClientTaskState::AcceptNewTask(Client *c, int TaskID, int NPCID, bool enfor // int FreeSlot = -1; for(int i=0; iProximityManager.CheckProximities(X, Y, Z); if(ExploreID > 0) { - Log.Out(Logs::General, Logs::Tasks, "[PROXIMITY] Position %8.3f, %8.3f, %8.3f is within proximity %i", X, Y, Z, ExploreID); + Log(Logs::General, Logs::Tasks, "[PROXIMITY] Position %8.3f, %8.3f, %8.3f is within proximity %i", X, Y, Z, ExploreID); UpdateTasksOnExplore(c, ExploreID); } } @@ -3103,7 +3107,7 @@ TaskGoalListManager::~TaskGoalListManager() { bool TaskGoalListManager::LoadLists() { - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskGoalListManager::LoadLists Called"); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskGoalListManager::LoadLists Called"); for(int i=0; i< NumberOfLists; i++) safe_delete_array(TaskGoalLists[i].GoalItemEntries); @@ -3122,7 +3126,7 @@ bool TaskGoalListManager::LoadLists() { } NumberOfLists = results.RowCount(); - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Database returned a count of %i lists", NumberOfLists); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Database returned a count of %i lists", NumberOfLists); TaskGoalLists = new TaskGoalList_Struct[NumberOfLists]; @@ -3235,7 +3239,7 @@ std::vector TaskGoalListManager::GetListContents(int ListID) { bool TaskGoalListManager::IsInList(int ListID, int Entry) { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i)", ListID, Entry); + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i)", ListID, Entry); int ListIndex = GetListByID(ListID); @@ -3255,7 +3259,7 @@ bool TaskGoalListManager::IsInList(int ListID, int Entry) { else if(Entry < TaskGoalLists[ListIndex].GoalItemEntries[MiddleEntry]) LastEntry = MiddleEntry - 1; else { - Log.Out(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i) returning true", ListIndex, Entry); + Log(Logs::General, Logs::Tasks, "[UPDATE] TaskGoalListManager::IsInList(%i, %i) returning true", ListIndex, Entry); return true; } @@ -3278,7 +3282,7 @@ TaskProximityManager::~TaskProximityManager() { bool TaskProximityManager::LoadProximities(int zoneID) { TaskProximity proximity; - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskProximityManager::LoadProximities Called for zone %i", zoneID); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] TaskProximityManager::LoadProximities Called for zone %i", zoneID); TaskProximities.clear(); std::string query = StringFormat("SELECT `exploreid`, `minx`, `maxx`, " @@ -3312,7 +3316,7 @@ int TaskProximityManager::CheckProximities(float X, float Y, float Z) { TaskProximity* P = &TaskProximities[i]; - Log.Out(Logs::General, Logs::Tasks, "[PROXIMITY] Checking %8.3f, %8.3f, %8.3f against %8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f", + Log(Logs::General, Logs::Tasks, "[PROXIMITY] Checking %8.3f, %8.3f, %8.3f against %8.3f, %8.3f, %8.3f, %8.3f, %8.3f, %8.3f", X, Y, Z, P->MinX, P->MaxX, P->MinY, P->MaxY, P->MinZ, P->MaxZ); if(X < P->MinX || X > P->MaxX || Y < P->MinY || Y > P->MaxY || diff --git a/zone/titles.cpp b/zone/titles.cpp index 95bebc442..033edd144 100644 --- a/zone/titles.cpp +++ b/zone/titles.cpp @@ -349,7 +349,7 @@ void Client::EnableTitle(int titleSet) { CharacterID(), titleSet); auto results = database.QueryDatabase(query); if(!results.Success()) - Log.Out(Logs::General, Logs::Error, "Error in EnableTitle query for titleset %i and charid %i", titleSet, CharacterID()); + Log(Logs::General, Logs::Error, "Error in EnableTitle query for titleset %i and charid %i", titleSet, CharacterID()); } diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 4c8dfdeaf..ab9167a4b 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -42,7 +42,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme { if (!user || !in_augment) { - Log.Out(Logs::General, Logs::Error, "Client or AugmentItem_Struct not set in Object::HandleAugmentation"); + Log(Logs::General, Logs::Error, "Client or AugmentItem_Struct not set in Object::HandleAugmentation"); return; } @@ -89,7 +89,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme if(!container) { - Log.Out(Logs::General, Logs::Error, "Player tried to augment an item without a container set."); + Log(Logs::General, Logs::Error, "Player tried to augment an item without a container set."); user->Message(13, "Error: This item is not a container!"); return; } @@ -169,7 +169,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme bool isSolvent = auged_with->GetItem()->ItemType == EQEmu::item::ItemTypeAugmentationSolvent; if (!isSolvent && auged_with->GetItem()->ItemType != EQEmu::item::ItemTypeAugmentationDistiller) { - Log.Out(Logs::General, Logs::Error, "Player tried to remove an augment without a solvent or distiller."); + Log(Logs::General, Logs::Error, "Player tried to remove an augment without a solvent or distiller."); user->Message(13, "Error: Missing an augmentation solvent or distiller for removing this augment."); return; @@ -179,7 +179,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme if (aug) { if (!isSolvent && auged_with->GetItem()->ID != aug->GetItem()->AugDistiller) { - Log.Out(Logs::General, Logs::Error, "Player tried to safely remove an augment with the wrong distiller (item %u vs expected %u).", auged_with->GetItem()->ID, aug->GetItem()->AugDistiller); + Log(Logs::General, Logs::Error, "Player tried to safely remove an augment with the wrong distiller (item %u vs expected %u).", auged_with->GetItem()->ID, aug->GetItem()->AugDistiller); user->Message(13, "Error: Wrong augmentation distiller for safely removing this augment."); return; } @@ -252,7 +252,7 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Object *worldo) { if (!user || !in_combine) { - Log.Out(Logs::General, Logs::Error, "Client or NewCombine_Struct not set in Object::HandleCombine"); + Log(Logs::General, Logs::Error, "Client or NewCombine_Struct not set in Object::HandleCombine"); return; } @@ -427,7 +427,7 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob if(success && spec.replace_container) { if(worldcontainer){ //should report this error, but we dont have the recipe ID, so its not very useful - Log.Out(Logs::General, Logs::Error, "Replace container combine executed in a world container."); + Log(Logs::General, Logs::Error, "Replace container combine executed in a world container."); } else user->DeleteItemInInventory(in_combine->container_slot, 0, true); @@ -453,7 +453,7 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac //ask the database for the recipe to make sure it exists... DBTradeskillRecipe_Struct spec; if (!database.GetTradeRecipe(rac->recipe_id, rac->object_type, rac->some_id, user->CharacterID(), &spec)) { - Log.Out(Logs::General, Logs::Error, "Unknown recipe for HandleAutoCombine: %u\n", rac->recipe_id); + Log(Logs::General, Logs::Error, "Unknown recipe for HandleAutoCombine: %u\n", rac->recipe_id); user->QueuePacket(outapp); safe_delete(outapp); return; @@ -482,14 +482,14 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac } if(results.RowCount() < 1) { - Log.Out(Logs::General, Logs::Error, "Error in HandleAutoCombine: no components returned"); + Log(Logs::General, Logs::Error, "Error in HandleAutoCombine: no components returned"); user->QueuePacket(outapp); safe_delete(outapp); return; } if(results.RowCount() > 10) { - Log.Out(Logs::General, Logs::Error, "Error in HandleAutoCombine: too many components returned (%u)", results.RowCount()); + Log(Logs::General, Logs::Error, "Error in HandleAutoCombine: too many components returned (%u)", results.RowCount()); user->QueuePacket(outapp); safe_delete(outapp); return; @@ -700,7 +700,7 @@ void Client::TradeskillSearchResults(const std::string &query, unsigned long obj return; //search gave no results... not an error if(results.ColumnCount() != 6) { - Log.Out(Logs::General, Logs::Error, "Error in TradeskillSearchResults query '%s': Invalid column count in result", query.c_str()); + Log(Logs::General, Logs::Error, "Error in TradeskillSearchResults query '%s': Invalid column count in result", query.c_str()); return; } @@ -750,12 +750,12 @@ void Client::SendTradeskillDetails(uint32 recipe_id) { } if(results.RowCount() < 1) { - Log.Out(Logs::General, Logs::Error, "Error in SendTradeskillDetails: no components returned"); + Log(Logs::General, Logs::Error, "Error in SendTradeskillDetails: no components returned"); return; } if(results.RowCount() > 10) { - Log.Out(Logs::General, Logs::Error, "Error in SendTradeskillDetails: too many components returned (%u)", results.RowCount()); + Log(Logs::General, Logs::Error, "Error in SendTradeskillDetails: too many components returned (%u)", results.RowCount()); return; } @@ -934,7 +934,7 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { //handle caps if(spec->nofail) { chance = 100; //cannot fail. - Log.Out(Logs::Detail, Logs::Tradeskills, "...This combine cannot fail."); + Log(Logs::Detail, Logs::Tradeskills, "...This combine cannot fail."); } else if(over_trivial >= 0) { // At reaching trivial the chance goes to 95% going up an additional // percent for every 40 skillpoints above the trivial. @@ -954,8 +954,8 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { chance = 95; } - Log.Out(Logs::Detail, Logs::Tradeskills, "...Current skill: %d , Trivial: %d , Success chance: %f percent", user_skill , spec->trivial , chance); - Log.Out(Logs::Detail, Logs::Tradeskills, "...Bonusstat: %d , INT: %d , WIS: %d , DEX: %d , STR: %d", bonusstat , GetINT() , GetWIS() , GetDEX() , GetSTR()); + Log(Logs::Detail, Logs::Tradeskills, "...Current skill: %d , Trivial: %d , Success chance: %f percent", user_skill , spec->trivial , chance); + Log(Logs::Detail, Logs::Tradeskills, "...Bonusstat: %d , INT: %d , WIS: %d , DEX: %d , STR: %d", bonusstat , GetINT() , GetWIS() , GetDEX() , GetSTR()); float res = zone->random.Real(0, 99); int aa_chance = 0; @@ -974,7 +974,7 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { Message_StringID(4, TRADESKILL_SUCCEED, spec->name.c_str()); - Log.Out(Logs::Detail, Logs::Tradeskills, "Tradeskill success"); + Log(Logs::Detail, Logs::Tradeskills, "Tradeskill success"); itr = spec->onsuccess.begin(); while(itr != spec->onsuccess.end() && !spec->quest) { @@ -1006,7 +1006,7 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) { Message_StringID(MT_Emote,TRADESKILL_FAILED); - Log.Out(Logs::Detail, Logs::Tradeskills, "Tradeskill failed"); + Log(Logs::Detail, Logs::Tradeskills, "Tradeskill failed"); if (this->GetGroup()) { entity_list.MessageGroup(this,true,MT_Skills,"%s was unsuccessful in %s tradeskill attempt.",GetName(),this->GetGender() == 0 ? "his" : this->GetGender() == 1 ? "her" : "its"); @@ -1085,9 +1085,9 @@ void Client::CheckIncreaseTradeskill(int16 bonusstat, int16 stat_modifier, float NotifyNewTitlesAvailable(); } - Log.Out(Logs::Detail, Logs::Tradeskills, "...skillup_modifier: %f , success_modifier: %d , stat modifier: %d", skillup_modifier , success_modifier , stat_modifier); - Log.Out(Logs::Detail, Logs::Tradeskills, "...Stage1 chance was: %f percent", chance_stage1); - Log.Out(Logs::Detail, Logs::Tradeskills, "...Stage2 chance was: %f percent. 0 percent means stage1 failed", chance_stage2); + Log(Logs::Detail, Logs::Tradeskills, "...skillup_modifier: %f , success_modifier: %d , stat modifier: %d", skillup_modifier , success_modifier , stat_modifier); + Log(Logs::Detail, Logs::Tradeskills, "...Stage1 chance was: %f percent", chance_stage1); + Log(Logs::Detail, Logs::Tradeskills, "...Stage2 chance was: %f percent. 0 percent means stage1 failed", chance_stage2); } bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_type, uint32 some_id, @@ -1140,8 +1140,8 @@ bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_ buf2.c_str(), containers.c_str(), count, sum); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error in GetTradeRecipe search, query: %s", query.c_str()); - Log.Out(Logs::General, Logs::Error, "Error in GetTradeRecipe search, error: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in GetTradeRecipe search, query: %s", query.c_str()); + Log(Logs::General, Logs::Error, "Error in GetTradeRecipe search, error: %s", results.ErrorMessage().c_str()); return false; } @@ -1162,7 +1162,7 @@ bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_ //length limit on buf2 if(index == 214) { //Maximum number of recipe matches (19 * 215 = 4096) - Log.Out(Logs::General, Logs::Error, "GetTradeRecipe warning: Too many matches. Unable to search all recipe entries. Searched %u of %u possible entries.", index + 1, results.RowCount()); + Log(Logs::General, Logs::Error, "GetTradeRecipe warning: Too many matches. Unable to search all recipe entries. Searched %u of %u possible entries.", index + 1, results.RowCount()); break; } } @@ -1174,8 +1174,8 @@ bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_ "AND sum(tre.item_id * tre.componentcount) = %u", buf2.c_str(), count, sum); results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error in GetTradeRecipe, re-query: %s", query.c_str()); - Log.Out(Logs::General, Logs::Error, "Error in GetTradeRecipe, error: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, re-query: %s", query.c_str()); + Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, error: %s", results.ErrorMessage().c_str()); return false; } } @@ -1200,18 +1200,18 @@ bool ZoneDatabase::GetTradeRecipe(const EQEmu::ItemInstance* container, uint8 c_ "AND tre.item_id = %u;", buf2.c_str(), containerId); results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error in GetTradeRecipe, re-query: %s", query.c_str()); - Log.Out(Logs::General, Logs::Error, "Error in GetTradeRecipe, error: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, re-query: %s", query.c_str()); + Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, error: %s", results.ErrorMessage().c_str()); return false; } if(results.RowCount() == 0) { //Recipe contents matched more than 1 recipe, but not in this container - Log.Out(Logs::General, Logs::Error, "Combine error: Incorrect container is being used!"); + Log(Logs::General, Logs::Error, "Combine error: Incorrect container is being used!"); return false; } if (results.RowCount() > 1) //Recipe contents matched more than 1 recipe in this container - Log.Out(Logs::General, Logs::Error, "Combine error: Recipe is not unique! %u matches found for container %u. Continuing with first recipe match.", results.RowCount(), containerId); + Log(Logs::General, Logs::Error, "Combine error: Recipe is not unique! %u matches found for container %u. Continuing with first recipe match.", results.RowCount(), containerId); } @@ -1282,8 +1282,8 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id char_id, (unsigned long)recipe_id, containers.c_str()); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error in GetTradeRecipe, query: %s", query.c_str()); - Log.Out(Logs::General, Logs::Error, "Error in GetTradeRecipe, error: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, query: %s", query.c_str()); + Log(Logs::General, Logs::Error, "Error in GetTradeRecipe, error: %s", results.ErrorMessage().c_str()); return false; } @@ -1318,7 +1318,7 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id } if(results.RowCount() < 1 && !spec->quest) { - Log.Out(Logs::General, Logs::Error, "Error in GetTradeRecept success: no success items returned"); + Log(Logs::General, Logs::Error, "Error in GetTradeRecept success: no success items returned"); return false; } @@ -1385,7 +1385,7 @@ void Client::LearnRecipe(uint32 recipeID) } if (results.RowCount() != 1) { - Log.Out(Logs::General, Logs::Normal, "Client::LearnRecipe - RecipeID: %d had %d occurences.", recipeID, results.RowCount()); + Log(Logs::General, Logs::Normal, "Client::LearnRecipe - RecipeID: %d had %d occurences.", recipeID, results.RowCount()); return; } diff --git a/zone/trading.cpp b/zone/trading.cpp index 227e8ac4f..5c069cacd 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -87,7 +87,7 @@ void Trade::AddEntity(uint16 trade_slot_id, uint32 stack_size) { if (!owner || !owner->IsClient()) { // This should never happen - Log.Out(Logs::General, Logs::None, "Programming error: NPC's should not call Trade::AddEntity()"); + Log(Logs::General, Logs::None, "Programming error: NPC's should not call Trade::AddEntity()"); return; } @@ -127,7 +127,7 @@ void Trade::AddEntity(uint16 trade_slot_id, uint32 stack_size) { inst2->SetCharges(stack_size + inst2->GetCharges()); } - Log.Out(Logs::Detail, Logs::Trading, "%s added partial item '%s' stack (qty: %i) to trade slot %i", owner->GetName(), inst->GetItem()->Name, stack_size, trade_slot_id); + Log(Logs::Detail, Logs::Trading, "%s added partial item '%s' stack (qty: %i) to trade slot %i", owner->GetName(), inst->GetItem()->Name, stack_size, trade_slot_id); if (_stack_size > 0) inst->SetCharges(_stack_size); @@ -144,7 +144,7 @@ void Trade::AddEntity(uint16 trade_slot_id, uint32 stack_size) { SendItemData(inst, trade_slot_id); - Log.Out(Logs::Detail, Logs::Trading, "%s added item '%s' to trade slot %i", owner->GetName(), inst->GetItem()->Name, trade_slot_id); + Log(Logs::Detail, Logs::Trading, "%s added item '%s' to trade slot %i", owner->GetName(), inst->GetItem()->Name, trade_slot_id); client->PutItemInInventory(trade_slot_id, *inst); client->DeleteItemInInventory(EQEmu::inventory::slotCursor); @@ -297,7 +297,7 @@ void Trade::LogTrade() void Trade::DumpTrade() { Mob* with = With(); - Log.Out(Logs::Detail, Logs::Trading, "Dumping trade data: '%s' in TradeState %i with '%s'", + Log(Logs::Detail, Logs::Trading, "Dumping trade data: '%s' in TradeState %i with '%s'", this->owner->GetName(), state, ((with==nullptr)?"(null)":with->GetName())); if (!owner->IsClient()) @@ -308,7 +308,7 @@ void Trade::DumpTrade() const EQEmu::ItemInstance* inst = trader->GetInv().GetItem(i); if (inst) { - Log.Out(Logs::Detail, Logs::Trading, "Item %i (Charges=%i, Slot=%i, IsBag=%s)", + Log(Logs::Detail, Logs::Trading, "Item %i (Charges=%i, Slot=%i, IsBag=%s)", inst->GetItem()->ID, inst->GetCharges(), i, ((inst->IsClassBag()) ? "True" : "False")); @@ -316,7 +316,7 @@ void Trade::DumpTrade() for (uint8 j = EQEmu::inventory::containerBegin; j < EQEmu::inventory::ContainerCount; j++) { inst = trader->GetInv().GetItem(i, j); if (inst) { - Log.Out(Logs::Detail, Logs::Trading, "\tBagItem %i (Charges=%i, Slot=%i)", + Log(Logs::Detail, Logs::Trading, "\tBagItem %i (Charges=%i, Slot=%i)", inst->GetItem()->ID, inst->GetCharges(), EQEmu::InventoryProfile::CalcSlotId(i, j)); } @@ -325,7 +325,7 @@ void Trade::DumpTrade() } } - Log.Out(Logs::Detail, Logs::Trading, "\tpp:%i, gp:%i, sp:%i, cp:%i", pp, gp, sp, cp); + Log(Logs::Detail, Logs::Trading, "\tpp:%i, gp:%i, sp:%i, cp:%i", pp, gp, sp, cp); } @@ -369,7 +369,7 @@ void Client::ResetTrade() { break; if (partial_inst->GetID() != inst->GetID()) { - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Client::ResetTrade() - an incompatible location reference was returned by Inventory::FindFreeSlotForTradeItem()"); + Log(Logs::Detail, Logs::None, "[CLIENT] Client::ResetTrade() - an incompatible location reference was returned by Inventory::FindFreeSlotForTradeItem()"); break; } @@ -459,7 +459,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st bool qs_log = false; if(other) { - Log.Out(Logs::Detail, Logs::Trading, "Finishing trade with client %s", other->GetName()); + Log(Logs::Detail, Logs::Trading, "Finishing trade with client %s", other->GetName()); this->AddMoneyToPP(other->trade->cp, other->trade->sp, other->trade->gp, other->trade->pp, true); @@ -492,7 +492,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st const EQEmu::ItemInstance* inst = m_inv[trade_slot]; if (inst && inst->IsClassBag()) { - Log.Out(Logs::Detail, Logs::Trading, "Giving container %s (%d) in slot %d to %s", inst->GetItem()->Name, inst->GetItem()->ID, trade_slot, other->GetName()); + Log(Logs::Detail, Logs::Trading, "Giving container %s (%d) in slot %d to %s", inst->GetItem()->Name, inst->GetItem()->ID, trade_slot, other->GetName()); // TODO: need to check bag items/augments for no drop..everything for attuned... if (inst->GetItem()->NoDrop != 0 || Admin() >= RuleI(Character, MinStatusForNoDropExemptions) || RuleI(World, FVNoDropFlag) == 1 || other == this) { @@ -500,7 +500,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st if (free_slot != INVALID_INDEX) { if (other->PutItemInInventory(free_slot, *inst, true)) { - Log.Out(Logs::Detail, Logs::Trading, "Container %s (%d) successfully transferred, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID); + Log(Logs::Detail, Logs::Trading, "Container %s (%d) successfully transferred, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID); if (qs_log) { auto detail = new QSTradeItems_Struct; @@ -553,17 +553,17 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st } } else { - Log.Out(Logs::Detail, Logs::Trading, "Transfer of container %s (%d) to %s failed, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName()); + Log(Logs::Detail, Logs::Trading, "Transfer of container %s (%d) to %s failed, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName()); PushItemOnCursor(*inst, true); } } else { - Log.Out(Logs::Detail, Logs::Trading, "%s's inventory is full, returning container %s (%d) to giver.", other->GetName(), inst->GetItem()->Name, inst->GetItem()->ID); + Log(Logs::Detail, Logs::Trading, "%s's inventory is full, returning container %s (%d) to giver.", other->GetName(), inst->GetItem()->Name, inst->GetItem()->ID); PushItemOnCursor(*inst, true); } } else { - Log.Out(Logs::Detail, Logs::Trading, "Container %s (%d) is NoDrop, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID); + Log(Logs::Detail, Logs::Trading, "Container %s (%d) is NoDrop, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID); PushItemOnCursor(*inst, true); } @@ -589,7 +589,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st break; if (partial_inst->GetID() != inst->GetID()) { - Log.Out(Logs::Detail, Logs::Trading, "[CLIENT] Client::ResetTrade() - an incompatible location reference was returned by Inventory::FindFreeSlotForTradeItem()"); + Log(Logs::Detail, Logs::Trading, "[CLIENT] Client::ResetTrade() - an incompatible location reference was returned by Inventory::FindFreeSlotForTradeItem()"); break; } @@ -607,10 +607,10 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st inst->SetCharges(0); } - Log.Out(Logs::Detail, Logs::Trading, "Transferring partial stack %s (%d) in slot %d to %s", inst->GetItem()->Name, inst->GetItem()->ID, trade_slot, other->GetName()); + Log(Logs::Detail, Logs::Trading, "Transferring partial stack %s (%d) in slot %d to %s", inst->GetItem()->Name, inst->GetItem()->ID, trade_slot, other->GetName()); if (other->PutItemInInventory(partial_slot, *partial_inst, true)) { - Log.Out(Logs::Detail, Logs::Trading, "Partial stack %s (%d) successfully transferred, deleting %i charges from trade slot.", + Log(Logs::Detail, Logs::Trading, "Partial stack %s (%d) successfully transferred, deleting %i charges from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID, (old_charges - inst->GetCharges())); if (qs_log) { auto detail = new QSTradeItems_Struct; @@ -636,7 +636,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st } } else { - Log.Out(Logs::Detail, Logs::Trading, "Transfer of partial stack %s (%d) to %s failed, returning %i charges to trade slot.", + Log(Logs::Detail, Logs::Trading, "Transfer of partial stack %s (%d) to %s failed, returning %i charges to trade slot.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName(), (old_charges - inst->GetCharges())); inst->SetCharges(old_charges); @@ -711,7 +711,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st const EQEmu::ItemInstance* inst = m_inv[trade_slot]; if (inst) { - Log.Out(Logs::Detail, Logs::Trading, "Giving item %s (%d) in slot %d to %s", inst->GetItem()->Name, inst->GetItem()->ID, trade_slot, other->GetName()); + Log(Logs::Detail, Logs::Trading, "Giving item %s (%d) in slot %d to %s", inst->GetItem()->Name, inst->GetItem()->ID, trade_slot, other->GetName()); // TODO: need to check bag items/augments for no drop..everything for attuned... if (inst->GetItem()->NoDrop != 0 || Admin() >= RuleI(Character, MinStatusForNoDropExemptions) || RuleI(World, FVNoDropFlag) == 1 || other == this) { @@ -719,7 +719,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st if (free_slot != INVALID_INDEX) { if (other->PutItemInInventory(free_slot, *inst, true)) { - Log.Out(Logs::Detail, Logs::Trading, "Item %s (%d) successfully transferred, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID); + Log(Logs::Detail, Logs::Trading, "Item %s (%d) successfully transferred, deleting from trade slot.", inst->GetItem()->Name, inst->GetItem()->ID); if (qs_log) { auto detail = new QSTradeItems_Struct; @@ -773,17 +773,17 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st } } else { - Log.Out(Logs::Detail, Logs::Trading, "Transfer of Item %s (%d) to %s failed, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName()); + Log(Logs::Detail, Logs::Trading, "Transfer of Item %s (%d) to %s failed, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID, other->GetName()); PushItemOnCursor(*inst, true); } } else { - Log.Out(Logs::Detail, Logs::Trading, "%s's inventory is full, returning item %s (%d) to giver.", other->GetName(), inst->GetItem()->Name, inst->GetItem()->ID); + Log(Logs::Detail, Logs::Trading, "%s's inventory is full, returning item %s (%d) to giver.", other->GetName(), inst->GetItem()->Name, inst->GetItem()->ID); PushItemOnCursor(*inst, true); } } else { - Log.Out(Logs::Detail, Logs::Trading, "Item %s (%d) is NoDrop, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID); + Log(Logs::Detail, Logs::Trading, "Item %s (%d) is NoDrop, returning to giver.", inst->GetItem()->Name, inst->GetItem()->ID); PushItemOnCursor(*inst, true); } @@ -1176,7 +1176,7 @@ void Client::SendTraderItem(uint32 ItemID, uint16 Quantity) { const EQEmu::ItemData* item = database.GetItem(ItemID); if(!item){ - Log.Out(Logs::Detail, Logs::Trading, "Bogus item deleted in Client::SendTraderItem!\n"); + Log(Logs::Detail, Logs::Trading, "Bogus item deleted in Client::SendTraderItem!\n"); return; } @@ -1235,10 +1235,10 @@ void Client::BulkSendTraderInventory(uint32 char_id) { safe_delete(inst); } else - Log.Out(Logs::Detail, Logs::Trading, "Client::BulkSendTraderInventory nullptr inst pointer"); + Log(Logs::Detail, Logs::Trading, "Client::BulkSendTraderInventory nullptr inst pointer"); } else - Log.Out(Logs::Detail, Logs::Trading, "Client::BulkSendTraderInventory nullptr item pointer or item is NODROP %8X",item); + Log(Logs::Detail, Logs::Trading, "Client::BulkSendTraderInventory nullptr item pointer or item is NODROP %8X",item); } safe_delete(TraderItems); } @@ -1261,7 +1261,7 @@ uint32 Client::FindTraderItemSerialNumber(int32 ItemID) { } } } - Log.Out(Logs::Detail, Logs::Trading, "Client::FindTraderItemSerialNumber Couldn't find item! Item ID %i", ItemID); + Log(Logs::Detail, Logs::Trading, "Client::FindTraderItemSerialNumber Couldn't find item! Item ID %i", ItemID); return 0; } @@ -1284,7 +1284,7 @@ EQEmu::ItemInstance* Client::FindTraderItemBySerialNumber(int32 SerialNumber){ } } } - Log.Out(Logs::Detail, Logs::Trading, "Client::FindTraderItemBySerialNumber Couldn't find item! Serial No. was %i", SerialNumber); + Log(Logs::Detail, Logs::Trading, "Client::FindTraderItemBySerialNumber Couldn't find item! Serial No. was %i", SerialNumber); return nullptr; } @@ -1341,7 +1341,7 @@ uint16 Client::FindTraderItem(int32 SerialNumber, uint16 Quantity){ } } } - Log.Out(Logs::Detail, Logs::Trading, "Could NOT find a match for Item: %i with a quantity of: %i on Trader: %s\n", + Log(Logs::Detail, Logs::Trading, "Could NOT find a match for Item: %i with a quantity of: %i on Trader: %s\n", SerialNumber , Quantity, this->GetName()); return 0; @@ -1352,7 +1352,7 @@ void Client::NukeTraderItem(uint16 Slot,int16 Charges,uint16 Quantity,Client* Cu if(!Customer) return; - Log.Out(Logs::Detail, Logs::Trading, "NukeTraderItem(Slot %i, Charges %i, Quantity %i", Slot, Charges, Quantity); + Log(Logs::Detail, Logs::Trading, "NukeTraderItem(Slot %i, Charges %i, Quantity %i", Slot, Charges, Quantity); if(Quantity < Charges) { @@ -1439,7 +1439,7 @@ void Client::FindAndNukeTraderItem(int32 SerialNumber, uint16 Quantity, Client* if (!item) { - Log.Out(Logs::Detail, Logs::Trading, "Could not find Item: %i on Trader: %s", SerialNumber, Quantity, this->GetName()); + Log(Logs::Detail, Logs::Trading, "Could not find Item: %i on Trader: %s", SerialNumber, Quantity, this->GetName()); return; } @@ -1450,7 +1450,7 @@ void Client::FindAndNukeTraderItem(int32 SerialNumber, uint16 Quantity, Client* if (!Stackable) Quantity = (Charges > 0) ? Charges : 1; - Log.Out(Logs::Detail, Logs::Trading, "FindAndNuke %s, Charges %i, Quantity %i", item->GetItem()->Name, Charges, Quantity); + Log(Logs::Detail, Logs::Trading, "FindAndNuke %s, Charges %i, Quantity %i", item->GetItem()->Name, Charges, Quantity); if (Charges <= Quantity || (Charges <= 0 && Quantity==1) || !Stackable) { @@ -1492,7 +1492,7 @@ void Client::FindAndNukeTraderItem(int32 SerialNumber, uint16 Quantity, Client* } } - Log.Out(Logs::Detail, Logs::Trading, "Could NOT find a match for Item: %i with a quantity of: %i on Trader: %s\n",SerialNumber, + Log(Logs::Detail, Logs::Trading, "Could NOT find a match for Item: %i with a quantity of: %i on Trader: %s\n",SerialNumber, Quantity,this->GetName()); } @@ -1592,7 +1592,7 @@ void Client::BuyTraderItem(TraderBuy_Struct* tbs, Client* Trader, const EQApplic BuyItem = Trader->FindTraderItemBySerialNumber(tbs->ItemID); if(!BuyItem) { - Log.Out(Logs::Detail, Logs::Trading, "Unable to find item on trader."); + Log(Logs::Detail, Logs::Trading, "Unable to find item on trader."); TradeRequestFailed(app); safe_delete(outapp); return; @@ -1600,7 +1600,7 @@ void Client::BuyTraderItem(TraderBuy_Struct* tbs, Client* Trader, const EQApplic tbs->Price = BuyItem->GetPrice(); - Log.Out(Logs::Detail, Logs::Trading, "Buyitem: Name: %s, IsStackable: %i, Requested Quantity: %i, Charges on Item %i", + Log(Logs::Detail, Logs::Trading, "Buyitem: Name: %s, IsStackable: %i, Requested Quantity: %i, Charges on Item %i", BuyItem->GetItem()->Name, BuyItem->IsStackable(), tbs->Quantity, BuyItem->GetCharges()); // If the item is not stackable, then we can only be buying one of them. if(!BuyItem->IsStackable()) @@ -1618,12 +1618,12 @@ void Client::BuyTraderItem(TraderBuy_Struct* tbs, Client* Trader, const EQApplic outtbs->Quantity = tbs->Quantity; } - Log.Out(Logs::Detail, Logs::Trading, "Actual quantity that will be traded is %i", outtbs->Quantity); + Log(Logs::Detail, Logs::Trading, "Actual quantity that will be traded is %i", outtbs->Quantity); if((tbs->Price * outtbs->Quantity) <= 0) { Message(13, "Internal error. Aborting trade. Please report this to the ServerOP. Error code is 1"); Trader->Message(13, "Internal error. Aborting trade. Please report this to the ServerOP. Error code is 1"); - Log.Out(Logs::General, Logs::Error, "Bazaar: Zero price transaction between %s and %s aborted." + Log(Logs::General, Logs::Error, "Bazaar: Zero price transaction between %s and %s aborted." "Item: %s, Charges: %i, TBS: Qty %i, Price: %i", GetName(), Trader->GetName(), BuyItem->GetItem()->Name, BuyItem->GetCharges(), tbs->Quantity, tbs->Price); @@ -1661,7 +1661,7 @@ void Client::BuyTraderItem(TraderBuy_Struct* tbs, Client* Trader, const EQApplic return; } - Log.Out(Logs::Detail, Logs::Trading, "Customer Paid: %d in Copper", TotalCost); + Log(Logs::Detail, Logs::Trading, "Customer Paid: %d in Copper", TotalCost); uint32 platinum = TotalCost / 1000; TotalCost -= (platinum * 1000); @@ -1673,7 +1673,7 @@ void Client::BuyTraderItem(TraderBuy_Struct* tbs, Client* Trader, const EQApplic Trader->AddMoneyToPP(copper, silver, gold, platinum, true); - Log.Out(Logs::Detail, Logs::Trading, "Trader Received: %d Platinum, %d Gold, %d Silver, %d Copper", platinum, gold, silver, copper); + Log(Logs::Detail, Logs::Trading, "Trader Received: %d Platinum, %d Gold, %d Silver, %d Copper", platinum, gold, silver, copper); ReturnTraderReq(app, outtbs->Quantity, ItemID); @@ -1932,7 +1932,7 @@ void Client::SendBazaarResults(uint32 TraderID, uint32 Class_, uint32 Race, uint return; } - Log.Out(Logs::Detail, Logs::Trading, "SRCH: %s", query.c_str()); + Log(Logs::Detail, Logs::Trading, "SRCH: %s", query.c_str()); int Size = 0; uint32 ID = 0; @@ -1977,7 +1977,7 @@ void Client::SendBazaarResults(uint32 TraderID, uint32 Class_, uint32 Race, uint ID = Trader2->GetID(); VARSTRUCT_ENCODE_TYPE(uint32, bufptr, ID); } else { - Log.Out(Logs::Detail, Logs::Trading, "Unable to find trader: %i\n", atoi(row[1])); + Log(Logs::Detail, Logs::Trading, "Unable to find trader: %i\n", atoi(row[1])); VARSTRUCT_ENCODE_TYPE(uint32, bufptr, 0); } Cost = atoi(row[5]); @@ -2067,7 +2067,7 @@ static void UpdateTraderCustomerItemsAdded(uint32 CustomerID, TraderCharges_Stru if(inst->IsStackable()) inst->SetMerchantCount(gis->Charges[i]); - Log.Out(Logs::Detail, Logs::Trading, "Sending price update for %s, Serial No. %i with %i charges", + Log(Logs::Detail, Logs::Trading, "Sending price update for %s, Serial No. %i with %i charges", item->Name, gis->SerialNumber[i], gis->Charges[i]); Customer->SendItemPacket(30, inst, ItemPacketMerchant); // MainCursor? @@ -2113,7 +2113,7 @@ static void UpdateTraderCustomerPriceChanged(uint32 CustomerID, TraderCharges_St tdis->ItemID = gis->SerialNumber[i]; } tdis->ItemID = gis->SerialNumber[i]; - Log.Out(Logs::Detail, Logs::Trading, "Telling customer to remove item %i with %i charges and S/N %i", + Log(Logs::Detail, Logs::Trading, "Telling customer to remove item %i with %i charges and S/N %i", ItemID, Charges, gis->SerialNumber[i]); @@ -2125,7 +2125,7 @@ static void UpdateTraderCustomerPriceChanged(uint32 CustomerID, TraderCharges_St return; } - Log.Out(Logs::Detail, Logs::Trading, "Sending price updates to customer %s", Customer->GetName()); + Log(Logs::Detail, Logs::Trading, "Sending price updates to customer %s", Customer->GetName()); EQEmu::ItemInstance* inst = database.CreateItem(item); @@ -2151,7 +2151,7 @@ static void UpdateTraderCustomerPriceChanged(uint32 CustomerID, TraderCharges_St inst->SetMerchantSlot(gis->SerialNumber[i]); - Log.Out(Logs::Detail, Logs::Trading, "Sending price update for %s, Serial No. %i with %i charges", + Log(Logs::Detail, Logs::Trading, "Sending price update for %s, Serial No. %i with %i charges", item->Name, gis->SerialNumber[i], gis->Charges[i]); Customer->SendItemPacket(30, inst, ItemPacketMerchant); // MainCursor?? @@ -2167,7 +2167,7 @@ void Client::HandleTraderPriceUpdate(const EQApplicationPacket *app) { // TraderPriceUpdate_Struct* tpus = (TraderPriceUpdate_Struct*)app->pBuffer; - Log.Out(Logs::Detail, Logs::Trading, "Received Price Update for %s, Item Serial No. %i, New Price %i", + Log(Logs::Detail, Logs::Trading, "Received Price Update for %s, Item Serial No. %i, New Price %i", GetName(), tpus->SerialNumber, tpus->NewPrice); // Pull the items this Trader currently has for sale from the trader table. @@ -2175,7 +2175,7 @@ void Client::HandleTraderPriceUpdate(const EQApplicationPacket *app) { TraderCharges_Struct* gis = database.LoadTraderItemWithCharges(CharacterID()); if(!gis) { - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Error retrieving Trader items details to update price."); + Log(Logs::Detail, Logs::None, "[CLIENT] Error retrieving Trader items details to update price."); return; } @@ -2195,7 +2195,7 @@ void Client::HandleTraderPriceUpdate(const EQApplicationPacket *app) { if((gis->ItemID[i] > 0) && (gis->SerialNumber[i] == tpus->SerialNumber)) { // We found the item that the Trader wants to change the price of (or add back up for sale). // - Log.Out(Logs::Detail, Logs::Trading, "ItemID is %i, Charges is %i", gis->ItemID[i], gis->Charges[i]); + Log(Logs::Detail, Logs::Trading, "ItemID is %i, Charges is %i", gis->ItemID[i], gis->Charges[i]); IDOfItemToUpdate = gis->ItemID[i]; @@ -2221,7 +2221,7 @@ void Client::HandleTraderPriceUpdate(const EQApplicationPacket *app) { return ; } - Log.Out(Logs::Detail, Logs::Trading, "Unable to find item to update price for. Rechecking trader satchels"); + Log(Logs::Detail, Logs::Trading, "Unable to find item to update price for. Rechecking trader satchels"); // Find what is in their Trader Satchels GetItems_Struct* newgis=GetTraderItems(); @@ -2234,7 +2234,7 @@ void Client::HandleTraderPriceUpdate(const EQApplicationPacket *app) { if((newgis->Items[i] > 0) && (newgis->SerialNumber[i] == tpus->SerialNumber)) { - Log.Out(Logs::Detail, Logs::Trading, "Found new Item to Add, ItemID is %i, Charges is %i", newgis->Items[i], + Log(Logs::Detail, Logs::Trading, "Found new Item to Add, ItemID is %i, Charges is %i", newgis->Items[i], newgis->Charges[i]); IDOfItemToAdd = newgis->Items[i]; @@ -2252,7 +2252,7 @@ void Client::HandleTraderPriceUpdate(const EQApplicationPacket *app) { if(!IDOfItemToAdd || !item) { - Log.Out(Logs::Detail, Logs::Trading, "Item not found in Trader Satchels either."); + Log(Logs::Detail, Logs::Trading, "Item not found in Trader Satchels either."); tpus->SubAction = BazaarPriceChange_Fail; QueuePacket(app); Trader_EndTrader(); @@ -2297,7 +2297,7 @@ void Client::HandleTraderPriceUpdate(const EQApplicationPacket *app) { gis->SerialNumber[i] = newgis->SerialNumber[i]; gis->ItemCost[i] = tpus->NewPrice; - Log.Out(Logs::Detail, Logs::Trading, "Adding new item for %s. ItemID %i, SerialNumber %i, Charges %i, Price: %i, Slot %i", + Log(Logs::Detail, Logs::Trading, "Adding new item for %s. ItemID %i, SerialNumber %i, Charges %i, Price: %i, Slot %i", GetName(), newgis->Items[i], newgis->SerialNumber[i], newgis->Charges[i], tpus->NewPrice, i); } @@ -2343,7 +2343,7 @@ void Client::HandleTraderPriceUpdate(const EQApplicationPacket *app) { QueuePacket(app); if(OldPrice == tpus->NewPrice) { - Log.Out(Logs::Detail, Logs::Trading, "The new price is the same as the old one."); + Log(Logs::Detail, Logs::Trading, "The new price is the same as the old one."); safe_delete(gis); return; } @@ -2364,7 +2364,7 @@ void Client::SendBuyerResults(char* searchString, uint32 searchID) { // This method is called when a potential seller in the /barter window searches for matching buyers // - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Client::SendBuyerResults %s\n", searchString); + Log(Logs::Detail, Logs::None, "[CLIENT] Client::SendBuyerResults %s\n", searchString); auto escSearchString = new char[strlen(searchString) * 2 + 1]; database.DoEscapeString(escSearchString, searchString, strlen(searchString)); @@ -2612,7 +2612,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { Quantity = i; break; } - Log.Out(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); + Log(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); Message(13, "Internal error while processing transaction."); return; } @@ -2620,7 +2620,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { EQEmu::ItemInstance* ItemToTransfer = m_inv.PopItem(SellerSlot); if(!ItemToTransfer || !Buyer->MoveItemToInventory(ItemToTransfer, true)) { - Log.Out(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); + Log(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); Message(13, "Internal error while processing transaction."); if(ItemToTransfer) @@ -2658,7 +2658,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { int16 SellerSlot = m_inv.HasItem(ItemID, 1, invWhereWorn|invWherePersonal|invWhereCursor); if (SellerSlot == INVALID_INDEX) { - Log.Out(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); + Log(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); Message(13, "Internal error while processing transaction."); return; } @@ -2666,7 +2666,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { EQEmu::ItemInstance* ItemToTransfer = m_inv.PopItem(SellerSlot); if(!ItemToTransfer) { - Log.Out(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); + Log(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); Message(13, "Internal error while processing transaction."); return; } @@ -2678,7 +2678,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { QuantityMoved += ItemToTransfer->GetCharges(); if(!Buyer->MoveItemToInventory(ItemToTransfer, true)) { - Log.Out(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); + Log(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); Message(13, "Internal error while processing transaction."); safe_delete(ItemToTransfer); return; @@ -2713,7 +2713,7 @@ void Client::SellToBuyer(const EQApplicationPacket *app) { ItemToTransfer->SetCharges(QuantityToRemoveFromStack); if(!Buyer->MoveItemToInventory(ItemToTransfer, true)) { - Log.Out(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); + Log(Logs::General, Logs::Error, "Unexpected error while moving item from seller to buyer."); Message(13, "Internal error while processing transaction."); safe_delete(ItemToTransfer); return; @@ -2948,11 +2948,11 @@ void Client::UpdateBuyLine(const EQApplicationPacket *app) { bool LoreConflict = CheckLoreConflict(item); - Log.Out(Logs::Detail, Logs::Trading, "UpdateBuyLine: Char: %s BuySlot: %i ItemID %i %s Quantity %i Toggle: %i Price %i ItemCount %i LoreConflict %i", + Log(Logs::Detail, Logs::Trading, "UpdateBuyLine: Char: %s BuySlot: %i ItemID %i %s Quantity %i Toggle: %i Price %i ItemCount %i LoreConflict %i", GetName(), BuySlot, ItemID, item->Name, Quantity, ToggleOnOff, Price, ItemCount, LoreConflict); if((item->NoDrop != 0) && !LoreConflict && (Quantity > 0) && HasMoney(Quantity * Price) && ToggleOnOff && (ItemCount == 0)) { - Log.Out(Logs::Detail, Logs::Trading, "Adding to database"); + Log(Logs::Detail, Logs::Trading, "Adding to database"); database.AddBuyLine(CharacterID(), BuySlot, ItemID, ItemName, Quantity, Price); QueuePacket(app); } diff --git a/zone/tribute.cpp b/zone/tribute.cpp index 537473e72..641549cda 100644 --- a/zone/tribute.cpp +++ b/zone/tribute.cpp @@ -220,7 +220,7 @@ void Client::ChangeTributeSettings(TributeInfo_Struct *t) { void Client::SendTributeDetails(uint32 client_id, uint32 tribute_id) { if(tribute_list.count(tribute_id) != 1) { - Log.Out(Logs::General, Logs::Error, "Details request for invalid tribute %lu", (unsigned long)tribute_id); + Log(Logs::General, Logs::Error, "Details request for invalid tribute %lu", (unsigned long)tribute_id); return; } TributeData &td = tribute_list[tribute_id]; @@ -413,14 +413,14 @@ bool ZoneDatabase::LoadTributes() { uint32 id = atoul(row[0]); if(tribute_list.count(id) != 1) { - Log.Out(Logs::General, Logs::Error, "Error in LoadTributes: unknown tribute %lu in tribute_levels", (unsigned long)id); + Log(Logs::General, Logs::Error, "Error in LoadTributes: unknown tribute %lu in tribute_levels", (unsigned long)id); continue; } TributeData &cur = tribute_list[id]; if(cur.tier_count >= MAX_TRIBUTE_TIERS) { - Log.Out(Logs::General, Logs::Error, "Error in LoadTributes: on tribute %lu: more tiers defined than permitted", (unsigned long)id); + Log(Logs::General, Logs::Error, "Error in LoadTributes: on tribute %lu: more tiers defined than permitted", (unsigned long)id); continue; } diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 33e825c47..7416e38e8 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2004 EQEMu Development Team (http://eqemu.org) +Copyright (C) 2001-2004 EQEMu Development Team (http://eqemu.org) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" #ifdef _EQDEBUG @@ -40,7 +40,7 @@ struct wp_distance }; void NPC::AI_SetRoambox(float iDist, float iRoamDist, uint32 iDelay, uint32 iMinDelay) { - AI_SetRoambox(iDist, GetX()+iRoamDist, GetX()-iRoamDist, GetY()+iRoamDist, GetY()-iRoamDist, iDelay, iMinDelay); + AI_SetRoambox(iDist, GetX() + iRoamDist, GetX() - iRoamDist, GetY() + iRoamDist, GetY() - iRoamDist, iDelay, iMinDelay); } void NPC::AI_SetRoambox(float iDist, float iMaxX, float iMinX, float iMaxY, float iMinY, uint32 iDelay, uint32 iMinDelay) { @@ -60,64 +60,64 @@ void NPC::DisplayWaypointInfo(Client *c) { GetGrid(), GetSp2(), GetCurWp(), - GetMaxWp() ); + GetMaxWp()); std::vector::iterator cur, end; cur = Waypoints.begin(); end = Waypoints.end(); - for(; cur != end; ++cur) { - c->Message(0,"Waypoint %d: (%.2f,%.2f,%.2f,%.2f) pause %d", - cur->index, - cur->x, - cur->y, - cur->z, - cur->heading, - cur->pause ); + for (; cur != end; ++cur) { + c->Message(0, "Waypoint %d: (%.2f,%.2f,%.2f,%.2f) pause %d", + cur->index, + cur->x, + cur->y, + cur->z, + cur->heading, + cur->pause); } } void NPC::StopWandering() { // stops a mob from wandering, takes him off grid and sends him back to spawn point - roamer=false; + roamer = false; CastToNPC()->SetGrid(0); SendPosition(); - Log.Out(Logs::Detail, Logs::Pathing, "Stop Wandering requested."); + Log(Logs::Detail, Logs::Pathing, "Stop Wandering requested."); return; } void NPC::ResumeWandering() { // causes wandering to continue - overrides waypoint pause timer and PauseWandering() - if(!IsNPC()) + if (!IsNPC()) return; if (GetGrid() != 0) { if (GetGrid() < 0) { // we were paused by a quest AI_walking_timer->Disable(); - SetGrid( 0 - GetGrid()); - if (cur_wp==-1) + SetGrid(0 - GetGrid()); + if (cur_wp == -1) { // got here by a MoveTo() - cur_wp=save_wp; + cur_wp = save_wp; UpdateWaypoint(cur_wp); // have him head to last destination from here } - Log.Out(Logs::Detail, Logs::Pathing, "Resume Wandering requested. Grid %d, wp %d", GetGrid(), cur_wp); + Log(Logs::Detail, Logs::Pathing, "Resume Wandering requested. Grid %d, wp %d", GetGrid(), cur_wp); } else if (AI_walking_timer->Enabled()) { // we are at a waypoint paused normally - Log.Out(Logs::Detail, Logs::Pathing, "Resume Wandering on timed pause. Grid %d, wp %d", GetGrid(), cur_wp); + Log(Logs::Detail, Logs::Pathing, "Resume Wandering on timed pause. Grid %d, wp %d", GetGrid(), cur_wp); AI_walking_timer->Trigger(); // disable timer to end pause now } else { - Log.Out(Logs::General, Logs::Error, "NPC not paused - can't resume wandering: %lu", (unsigned long)GetNPCTypeID()); + Log(Logs::General, Logs::Error, "NPC not paused - can't resume wandering: %lu", (unsigned long)GetNPCTypeID()); return; } if (m_CurrentWayPoint.x == GetX() && m_CurrentWayPoint.y == GetY()) { // are we we at a waypoint? if so, trigger event and start to next char temp[100]; - itoa(cur_wp,temp,10); //do this before updating to next waypoint + itoa(cur_wp, temp, 10); //do this before updating to next waypoint CalculateNewWaypoint(); SetAppearance(eaStanding, false); parse->EventNPC(EVENT_WAYPOINT_DEPART, this, nullptr, temp, 0); @@ -125,7 +125,7 @@ void NPC::ResumeWandering() } else { - Log.Out(Logs::General, Logs::Error, "NPC not on grid - can't resume wandering: %lu", (unsigned long)GetNPCTypeID()); + Log(Logs::General, Logs::Error, "NPC not on grid - can't resume wandering: %lu", (unsigned long)GetNPCTypeID()); } return; } @@ -137,18 +137,19 @@ void NPC::PauseWandering(int pausetime) if (GetGrid() != 0) { DistractedFromGrid = true; - Log.Out(Logs::Detail, Logs::Pathing, "Paused Wandering requested. Grid %d. Resuming in %d ms (0=not until told)", GetGrid(), pausetime); + Log(Logs::Detail, Logs::Pathing, "Paused Wandering requested. Grid %d. Resuming in %d ms (0=not until told)", GetGrid(), pausetime); SendPosition(); if (pausetime<1) { // negative grid number stops him dead in his tracks until ResumeWandering() - SetGrid( 0 - GetGrid()); + SetGrid(0 - GetGrid()); } else { // specified waiting time, he'll resume after that - AI_walking_timer->Start(pausetime*1000); // set the timer + AI_walking_timer->Start(pausetime * 1000); // set the timer } - } else { - Log.Out(Logs::General, Logs::Error, "NPC not on grid - can't pause wandering: %lu", (unsigned long)GetNPCTypeID()); + } + else { + Log(Logs::General, Logs::Error, "NPC not on grid - can't pause wandering: %lu", (unsigned long)GetNPCTypeID()); } return; } @@ -159,48 +160,48 @@ void NPC::MoveTo(const glm::vec4& position, bool saveguardspot) { // he is on a grid if (GetGrid() < 0) { // currently stopped by a quest command - SetGrid( 0 - GetGrid()); // get him moving again - Log.Out(Logs::Detail, Logs::AI, "MoveTo during quest wandering. Canceling quest wandering and going back to grid %d when MoveTo is done.", GetGrid()); + SetGrid(0 - GetGrid()); // get him moving again + Log(Logs::Detail, Logs::AI, "MoveTo during quest wandering. Canceling quest wandering and going back to grid %d when MoveTo is done.", GetGrid()); } AI_walking_timer->Disable(); // disable timer in case he is paused at a wp - if (cur_wp>=0) + if (cur_wp >= 0) { // we've not already done a MoveTo() - save_wp=cur_wp; // save the current waypoint - cur_wp=-1; // flag this move as quest controlled + save_wp = cur_wp; // save the current waypoint + cur_wp = -1; // flag this move as quest controlled } - Log.Out(Logs::Detail, Logs::AI, "MoveTo %s, pausing regular grid wandering. Grid %d, save_wp %d",to_string(static_cast(position)).c_str(), -GetGrid(), save_wp); + Log(Logs::Detail, Logs::AI, "MoveTo %s, pausing regular grid wandering. Grid %d, save_wp %d", to_string(static_cast(position)).c_str(), -GetGrid(), save_wp); } else { // not on a grid - roamer=true; - save_wp=0; - cur_wp=-2; // flag as quest controlled w/no grid - Log.Out(Logs::Detail, Logs::AI, "MoveTo %s without a grid.", to_string(static_cast(position)).c_str()); + roamer = true; + save_wp = 0; + cur_wp = -2; // flag as quest controlled w/no grid + Log(Logs::Detail, Logs::AI, "MoveTo %s without a grid.", to_string(static_cast(position)).c_str()); } if (saveguardspot) { m_GuardPoint = position; - if(m_GuardPoint.w == 0) - m_GuardPoint.w = 0.0001; //hack to make IsGuarding simpler + if (m_GuardPoint.w == 0) + m_GuardPoint.w = 0.0001; //hack to make IsGuarding simpler - if(m_GuardPoint.w == -1) - m_GuardPoint.w = this->CalculateHeadingToTarget(position.x, position.y); + if (m_GuardPoint.w == -1) + m_GuardPoint.w = this->CalculateHeadingToTarget(position.x, position.y); - Log.Out(Logs::Detail, Logs::AI, "Setting guard position to %s", to_string(static_cast(m_GuardPoint)).c_str()); + Log(Logs::Detail, Logs::AI, "Setting guard position to %s", to_string(static_cast(m_GuardPoint)).c_str()); } m_CurrentWayPoint = position; cur_wp_pause = 0; pLastFightingDelayMoving = 0; - if(AI_walking_timer->Enabled()) + if (AI_walking_timer->Enabled()) AI_walking_timer->Start(100); } void NPC::UpdateWaypoint(int wp_index) { - if(wp_index >= static_cast(Waypoints.size())) { - Log.Out(Logs::Detail, Logs::AI, "Update to waypoint %d failed. Not found.", wp_index); + if (wp_index >= static_cast(Waypoints.size())) { + Log(Logs::Detail, Logs::AI, "Update to waypoint %d failed. Not found.", wp_index); return; } std::vector::iterator cur; @@ -209,14 +210,14 @@ void NPC::UpdateWaypoint(int wp_index) m_CurrentWayPoint = glm::vec4(cur->x, cur->y, cur->z, cur->heading); cur_wp_pause = cur->pause; - Log.Out(Logs::Detail, Logs::AI, "Next waypoint %d: (%.3f, %.3f, %.3f, %.3f)", wp_index, m_CurrentWayPoint.x, m_CurrentWayPoint.y, m_CurrentWayPoint.z, m_CurrentWayPoint.w); + Log(Logs::Detail, Logs::AI, "Next waypoint %d: (%.3f, %.3f, %.3f, %.3f)", wp_index, m_CurrentWayPoint.x, m_CurrentWayPoint.y, m_CurrentWayPoint.z, m_CurrentWayPoint.w); //fix up pathing Z - if(zone->HasMap() && RuleB(Map, FixPathingZAtWaypoints) && !IsBoat()) + if (zone->HasMap() && RuleB(Map, FixPathingZAtWaypoints) && !IsBoat()) { - if(!RuleB(Watermap, CheckForWaterAtWaypoints) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_CurrentWayPoint)))) + if (!RuleB(Watermap, CheckForWaterAtWaypoints) || !zone->HasWaterMap() || + (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_CurrentWayPoint)))) { glm::vec3 dest(m_CurrentWayPoint.x, m_CurrentWayPoint.y, m_CurrentWayPoint.z); @@ -239,7 +240,7 @@ void NPC::CalculateNewWaypoint() if (cur_wp == 0) reached_beginning = true; - switch(wandertype) + switch (wandertype) { case 0: //circle { @@ -254,7 +255,7 @@ void NPC::CalculateNewWaypoint() std::list closest; GetClosestWaypoint(closest, 10, glm::vec3(GetPosition())); auto iter = closest.begin(); - if(closest.size() != 0) + if (closest.size() != 0) { iter = closest.begin(); std::advance(iter, zone->random.Int(0, closest.size() - 1)); @@ -266,18 +267,18 @@ void NPC::CalculateNewWaypoint() case 2: //random { cur_wp = zone->random.Int(0, Waypoints.size() - 1); - if(cur_wp == old_wp) + if (cur_wp == old_wp) { - if(cur_wp == (Waypoints.size() - 1)) + if (cur_wp == (Waypoints.size() - 1)) { - if(cur_wp > 0) + if (cur_wp > 0) { cur_wp--; } } - else if(cur_wp == 0) + else if (cur_wp == 0) { - if((Waypoints.size() - 1) > 0) + if ((Waypoints.size() - 1) > 0) { cur_wp++; } @@ -288,11 +289,11 @@ void NPC::CalculateNewWaypoint() } case 3: //patrol { - if(reached_end) + if (reached_end) patrol = 1; - else if(reached_beginning) + else if (reached_beginning) patrol = 0; - if(patrol == 1) + if (patrol == 1) cur_wp = cur_wp - 1; else cur_wp = cur_wp + 1; @@ -311,9 +312,9 @@ void NPC::CalculateNewWaypoint() GetClosestWaypoint(closest, 5, glm::vec3(GetPosition())); auto iter = closest.begin(); - while(iter != closest.end()) + while (iter != closest.end()) { - if(CheckLosFN((*iter).x, (*iter).y, (*iter).z, GetSize())) + if (CheckLosFN((*iter).x, (*iter).y, (*iter).z, GetSize())) { ++iter; } @@ -323,7 +324,7 @@ void NPC::CalculateNewWaypoint() } } - if(closest.size() != 0) + if (closest.size() != 0) { iter = closest.begin(); std::advance(iter, zone->random.Int(0, closest.size() - 1)); @@ -352,9 +353,9 @@ bool wp_distance_pred(const wp_distance& left, const wp_distance& right) void NPC::GetClosestWaypoint(std::list &wp_list, int count, const glm::vec3& location) { wp_list.clear(); - if(Waypoints.size() <= count) + if (Waypoints.size() <= count) { - for(int i = 0; i < Waypoints.size(); ++i) + for (int i = 0; i < Waypoints.size(); ++i) { wp_list.push_back(Waypoints[i]); } @@ -362,7 +363,7 @@ void NPC::GetClosestWaypoint(std::list &wp_list, int count, const glm::v } std::list distances; - for(int i = 0; i < Waypoints.size(); ++i) + for (int i = 0; i < Waypoints.size(); ++i) { float cur_x = (Waypoints[i].x - location.x); cur_x *= cur_x; @@ -381,7 +382,7 @@ void NPC::GetClosestWaypoint(std::list &wp_list, int count, const glm::v }); auto iter = distances.begin(); - for(int i = 0; i < count; ++i) + for (int i = 0; i < count; ++i) { wp_list.push_back(Waypoints[(*iter).index]); ++iter; @@ -401,41 +402,41 @@ void NPC::SetWaypointPause() switch (pausetype) { - case 0: //Random Half - AI_walking_timer->Start((cur_wp_pause - zone->random.Int(0, cur_wp_pause-1)/2)*1000); - break; - case 1: //Full - AI_walking_timer->Start(cur_wp_pause*1000); - break; - case 2: //Random Full - AI_walking_timer->Start(zone->random.Int(0, cur_wp_pause-1)*1000); - break; + case 0: //Random Half + AI_walking_timer->Start((cur_wp_pause - zone->random.Int(0, cur_wp_pause - 1) / 2) * 1000); + break; + case 1: //Full + AI_walking_timer->Start(cur_wp_pause * 1000); + break; + case 2: //Random Full + AI_walking_timer->Start(zone->random.Int(0, cur_wp_pause - 1) * 1000); + break; } } } void NPC::SaveGuardSpot(bool iClearGuardSpot) { if (iClearGuardSpot) { - Log.Out(Logs::Detail, Logs::AI, "Clearing guard order."); + Log(Logs::Detail, Logs::AI, "Clearing guard order."); m_GuardPoint = glm::vec4(); } else { m_GuardPoint = m_Position; - if(m_GuardPoint.w == 0) + if (m_GuardPoint.w == 0) m_GuardPoint.w = 0.0001; //hack to make IsGuarding simpler - Log.Out(Logs::Detail, Logs::AI, "Setting guard position to %s", to_string(static_cast(m_GuardPoint)).c_str()); + Log(Logs::Detail, Logs::AI, "Setting guard position to %s", to_string(static_cast(m_GuardPoint)).c_str()); } } void NPC::NextGuardPosition() { if (!CalculateNewPosition2(m_GuardPoint.x, m_GuardPoint.y, m_GuardPoint.z, GetMovespeed())) { SetHeading(m_GuardPoint.w); - Log.Out(Logs::Detail, Logs::AI, "Unable to move to next guard position. Probably rooted."); + Log(Logs::Detail, Logs::AI, "Unable to move to next guard position. Probably rooted."); } - else if((m_Position.x == m_GuardPoint.x) && (m_Position.y == m_GuardPoint.y) && (m_Position.z == m_GuardPoint.z)) + else if ((m_Position.x == m_GuardPoint.x) && (m_Position.y == m_GuardPoint.y) && (m_Position.z == m_GuardPoint.z)) { - if(moved) + if (moved) { moved = false; SetCurrentSpeed(0); @@ -444,19 +445,19 @@ void NPC::NextGuardPosition() { } float Mob::CalculateDistance(float x, float y, float z) { - return (float)sqrtf( ((m_Position.x-x)*(m_Position.x-x)) + ((m_Position.y-y)*(m_Position.y-y)) + ((m_Position.z-z)*(m_Position.z-z)) ); + return (float)sqrtf(((m_Position.x - x)*(m_Position.x - x)) + ((m_Position.y - y)*(m_Position.y - y)) + ((m_Position.z - z)*(m_Position.z - z))); } float Mob::CalculateHeadingToTarget(float in_x, float in_y) { float angle; - if (in_x-m_Position.x > 0) - angle = - 90 + atan((float)(in_y-m_Position.y) / (float)(in_x-m_Position.x)) * 180 / M_PI; - else if (in_x-m_Position.x < 0) - angle = + 90 + atan((float)(in_y-m_Position.y) / (float)(in_x-m_Position.x)) * 180 / M_PI; + if (in_x - m_Position.x > 0) + angle = -90 + atan((float)(in_y - m_Position.y) / (float)(in_x - m_Position.x)) * 180 / M_PI; + else if (in_x - m_Position.x < 0) + angle = +90 + atan((float)(in_y - m_Position.y) / (float)(in_x - m_Position.x)) * 180 / M_PI; else // Added? { - if (in_y-m_Position.y > 0) + if (in_y - m_Position.y > 0) angle = 0; else angle = 180; @@ -465,28 +466,29 @@ float Mob::CalculateHeadingToTarget(float in_x, float in_y) { angle += 360; if (angle > 360) angle -= 360; - return (256*(360-angle)/360.0f); + return (256 * (360 - angle) / 360.0f); } bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, bool checkZ) { - if(GetID()==0) + if (GetID() == 0) return true; - if(speed <= 0) + if (speed <= 0) { SetCurrentSpeed(0); return true; } - if ((m_Position.x-x == 0) && (m_Position.y-y == 0)) {//spawn is at target coords - if(m_Position.z-z != 0) { + if ((m_Position.x - x == 0) && (m_Position.y - y == 0)) {//spawn is at target coords + if (m_Position.z - z != 0) { m_Position.z = z; - Log.Out(Logs::Detail, Logs::AI, "Calc Position2 (%.3f, %.3f, %.3f): Jumping pure Z.", x, y, z); + Log(Logs::Detail, Logs::AI, "Calc Position2 (%.3f, %.3f, %.3f): Jumping pure Z.", x, y, z); return true; } return false; - } else if ((std::abs(m_Position.x - x) < 0.1) && (std::abs(m_Position.y - y) < 0.1)) { - if(IsNPC()) { + } + else if ((std::abs(m_Position.x - x) < 0.1) && (std::abs(m_Position.y - y) < 0.1)) { + if (IsNPC()) { entity_list.ProcessMove(CastToNPC(), x, y, z); } @@ -498,12 +500,12 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo bool send_update = false; int compare_steps = 20; - if(tar_ndx < compare_steps && m_TargetLocation.x==x && m_TargetLocation.y==y) { + if (tar_ndx < compare_steps && m_TargetLocation.x == x && m_TargetLocation.y == y) { float new_x = m_Position.x + m_TargetV.x*tar_vector; float new_y = m_Position.y + m_TargetV.y*tar_vector; float new_z = m_Position.z + m_TargetV.z*tar_vector; - if(IsNPC()) { + if (IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } @@ -513,28 +515,28 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo uint8 NPCFlyMode = 0; - if(IsNPC()) { - if(CastToNPC()->GetFlyMode() == 1 || CastToNPC()->GetFlyMode() == 2) + if (IsNPC()) { + if (CastToNPC()->GetFlyMode() == 1 || CastToNPC()->GetFlyMode() == 2) NPCFlyMode = 1; } //fix up pathing Z - if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) + if (!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { - if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) + if (!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || + (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) { glm::vec3 dest(m_Position.x, m_Position.y, m_Position.z); float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f; if ((newz > -2000) && - std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. + std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. { if ((std::abs(x - m_Position.x) < 0.5) && - (std::abs(y - m_Position.y) < 0.5)) { + (std::abs(y - m_Position.y) < 0.5)) { if (std::abs(z - m_Position.z) <= - RuleR(Map, FixPathingZMaxDeltaMoving)) + RuleR(Map, FixPathingZMaxDeltaMoving)) m_Position.z = z; else m_Position.z = newz + 1; @@ -552,15 +554,16 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo if (tar_ndx>50) { tar_ndx--; - } else { - tar_ndx=0; + } + else { + tar_ndx = 0; } m_TargetLocation = glm::vec3(x, y, z); float nx = this->m_Position.x; float ny = this->m_Position.y; float nz = this->m_Position.z; -// float nh = this->heading; + // float nh = this->heading; m_TargetV.x = x - nx; m_TargetV.y = y - ny; @@ -568,39 +571,39 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo SetCurrentSpeed((int8)speed); pRunAnimSpeed = speed; #ifdef BOTS - if(IsClient() || IsBot()) + if (IsClient() || IsBot()) #else - if(IsClient()) + if (IsClient()) #endif { animation = speed / 2; } - + // -------------------------------------------------------------------------- // 2: get unit vector // -------------------------------------------------------------------------- - float mag = sqrtf (m_TargetV.x*m_TargetV.x + m_TargetV.y*m_TargetV.y + m_TargetV.z*m_TargetV.z); + float mag = sqrtf(m_TargetV.x*m_TargetV.x + m_TargetV.y*m_TargetV.y + m_TargetV.z*m_TargetV.z); tar_vector = (float)speed / mag; -// mob move fix - int numsteps = (int) ( mag * 16.0f / (float)speed + 0.5f); + // mob move fix + int numsteps = (int)(mag * 16.0f / (float)speed + 0.5f); -// mob move fix + // mob move fix if (numsteps<20) { if (numsteps>1) { - tar_vector=1.0f ; - m_TargetV.x = m_TargetV.x/(float)numsteps; - m_TargetV.y = m_TargetV.y/(float)numsteps; - m_TargetV.z = m_TargetV.z/(float)numsteps; + tar_vector = 1.0f; + m_TargetV.x = m_TargetV.x / (float)numsteps; + m_TargetV.y = m_TargetV.y / (float)numsteps; + m_TargetV.z = m_TargetV.z / (float)numsteps; float new_x = m_Position.x + m_TargetV.x; float new_y = m_Position.y + m_TargetV.y; float new_z = m_Position.z + m_TargetV.z; - if(IsNPC()) { + if (IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } @@ -612,7 +615,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo } else { - if(IsNPC()) { + if (IsNPC()) { entity_list.ProcessMove(CastToNPC(), x, y, z); } @@ -623,9 +626,9 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo } else { - tar_vector/=16.0f; + tar_vector /= 16.0f; float dur = Timer::GetCurrentTime() - pLastChange; - if(dur < 1.0f) { + if (dur < 1.0f) { dur = 1.0f; } tar_vector = (tar_vector * AImovement_duration) / 100.0f; @@ -633,7 +636,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo float new_x = m_Position.x + m_TargetV.x*tar_vector; float new_y = m_Position.y + m_TargetV.y*tar_vector; float new_z = m_Position.z + m_TargetV.z*tar_vector; - if(IsNPC()) { + if (IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } @@ -645,23 +648,23 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo uint8 NPCFlyMode = 0; - if(IsNPC()) { - if(CastToNPC()->GetFlyMode() == 1 || CastToNPC()->GetFlyMode() == 2) + if (IsNPC()) { + if (CastToNPC()->GetFlyMode() == 1 || CastToNPC()->GetFlyMode() == 2) NPCFlyMode = 1; } //fix up pathing Z - if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { + if (!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { - if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || - (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) + if (!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || + (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) { glm::vec3 dest(m_Position.x, m_Position.y, m_Position.z); float newz = zone->zonemap->FindBestZ(dest, nullptr); if ((newz > -2000) && - std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. + std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. { if (std::abs(x - m_Position.x) < 0.5 && std::abs(y - m_Position.y) < 0.5) { if (std::abs(z - m_Position.z) <= RuleR(Map, FixPathingZMaxDeltaMoving)) @@ -670,13 +673,13 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo m_Position.z = newz + 1; } else - m_Position.z = newz+1; - } + m_Position.z = newz + 1; + } } } SetMoving(true); - moved=true; + moved = true; m_Delta = glm::vec4(m_Position.x - nx, m_Position.y - ny, m_Position.z - nz, 0.0f); @@ -700,7 +703,7 @@ bool Mob::CalculateNewPosition2(float x, float y, float z, int speed, bool check } bool Mob::CalculateNewPosition(float x, float y, float z, int speed, bool checkZ, bool calcHeading) { - if(GetID()==0) + if (GetID() == 0) return true; float nx = m_Position.x; @@ -710,15 +713,15 @@ bool Mob::CalculateNewPosition(float x, float y, float z, int speed, bool checkZ // if NPC is rooted if (speed == 0) { SetHeading(CalculateHeadingToTarget(x, y)); - if(moved){ + if (moved) { SetCurrentSpeed(0); - moved=false; + moved = false; } - Log.Out(Logs::Detail, Logs::AI, "Rooted while calculating new position to (%.3f, %.3f, %.3f)", x, y, z); + Log(Logs::Detail, Logs::AI, "Rooted while calculating new position to (%.3f, %.3f, %.3f)", x, y, z); return true; } - float old_test_vector=test_vector; + float old_test_vector = test_vector; m_TargetV.x = x - nx; m_TargetV.y = y - ny; m_TargetV.z = z - nz; @@ -726,62 +729,62 @@ bool Mob::CalculateNewPosition(float x, float y, float z, int speed, bool checkZ if (m_TargetV.x == 0 && m_TargetV.y == 0) return false; SetCurrentSpeed((int8)(speed)); //*NPC_RUNANIM_RATIO); - //speed *= NPC_SPEED_MULTIPLIER; + //speed *= NPC_SPEED_MULTIPLIER; - Log.Out(Logs::Detail, Logs::AI, "Calculating new position to (%.3f, %.3f, %.3f) vector (%.3f, %.3f, %.3f) rate %.3f RAS %d", x, y, z, m_TargetV.x, m_TargetV.y, m_TargetV.z, speed, pRunAnimSpeed); + Log(Logs::Detail, Logs::AI, "Calculating new position to (%.3f, %.3f, %.3f) vector (%.3f, %.3f, %.3f) rate %.3f RAS %d", x, y, z, m_TargetV.x, m_TargetV.y, m_TargetV.z, speed, pRunAnimSpeed); // -------------------------------------------------------------------------- // 2: get unit vector // -------------------------------------------------------------------------- - test_vector=sqrtf (x*x + y*y + z*z); - tar_vector = speed / sqrtf (m_TargetV.x*m_TargetV.x + m_TargetV.y*m_TargetV.y + m_TargetV.z*m_TargetV.z); + test_vector = sqrtf(x*x + y*y + z*z); + tar_vector = speed / sqrtf(m_TargetV.x*m_TargetV.x + m_TargetV.y*m_TargetV.y + m_TargetV.z*m_TargetV.z); m_Position.w = CalculateHeadingToTarget(x, y); if (tar_vector >= 1.0) { - if(IsNPC()) { + if (IsNPC()) { entity_list.ProcessMove(CastToNPC(), x, y, z); } m_Position.x = x; m_Position.y = y; m_Position.z = z; - Log.Out(Logs::Detail, Logs::AI, "Close enough, jumping to waypoint"); + Log(Logs::Detail, Logs::AI, "Close enough, jumping to waypoint"); } else { float new_x = m_Position.x + m_TargetV.x*tar_vector; float new_y = m_Position.y + m_TargetV.y*tar_vector; float new_z = m_Position.z + m_TargetV.z*tar_vector; - if(IsNPC()) { + if (IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } m_Position.x = new_x; m_Position.y = new_y; m_Position.z = new_z; - Log.Out(Logs::Detail, Logs::AI, "Next position (%.3f, %.3f, %.3f)", m_Position.x, m_Position.y, m_Position.z); + Log(Logs::Detail, Logs::AI, "Next position (%.3f, %.3f, %.3f)", m_Position.x, m_Position.y, m_Position.z); } uint8 NPCFlyMode = 0; - if(IsNPC()) { - if(CastToNPC()->GetFlyMode() == 1 || CastToNPC()->GetFlyMode() == 2) + if (IsNPC()) { + if (CastToNPC()->GetFlyMode() == 1 || CastToNPC()->GetFlyMode() == 2) NPCFlyMode = 1; } //fix up pathing Z - if(!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) + if (!NPCFlyMode && checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) { - if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || + if (!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() || (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) { glm::vec3 dest(m_Position.x, m_Position.y, m_Position.z); float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f; - Log.Out(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.x,m_Position.y,m_Position.z); + Log(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz, m_Position.x, m_Position.y, m_Position.z); if ((newz > -2000) && - std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. + std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check. { if (std::abs(x - m_Position.x) < 0.5 && std::abs(y - m_Position.y) < 0.5) { if (std::abs(z - m_Position.z) <= RuleR(Map, FixPathingZMaxDeltaMoving)) @@ -790,16 +793,16 @@ bool Mob::CalculateNewPosition(float x, float y, float z, int speed, bool checkZ m_Position.z = newz + 1; } else - m_Position.z = newz+1; + m_Position.z = newz + 1; } } } //OP_MobUpdate - if((old_test_vector!=test_vector) || tar_ndx>20){ //send update - tar_ndx=0; + if ((old_test_vector != test_vector) || tar_ndx>20) { //send update + tar_ndx = 0; this->SetMoving(true); - moved=true; + moved = true; m_Delta = glm::vec4(m_Position.x - nx, m_Position.y - ny, m_Position.z - nz, 0.0f); SendPosUpdate(); } @@ -827,7 +830,7 @@ void NPC::AssignWaypoints(int32 grid) // Retrieve the wander and pause types for this grid std::string query = StringFormat("SELECT `type`, `type2` FROM `grid` WHERE `id` = %i AND `zoneid` = %i", grid, - zone->GetZoneID()); + zone->GetZoneID()); auto results = database.QueryDatabase(query); if (!results.Success()) { return; @@ -843,10 +846,10 @@ void NPC::AssignWaypoints(int32 grid) SetGrid(grid); // Assign grid number - // Retrieve all waypoints for this grid + // Retrieve all waypoints for this grid query = StringFormat("SELECT `x`,`y`,`z`,`pause`,`heading` " - "FROM grid_entries WHERE `gridid` = %i AND `zoneid` = %i " - "ORDER BY `number`", grid, zone->GetZoneID()); + "FROM grid_entries WHERE `gridid` = %i AND `zoneid` = %i " + "ORDER BY `number`", grid, zone->GetZoneID()); results = database.QueryDatabase(query); if (!results.Success()) { return; @@ -863,10 +866,10 @@ void NPC::AssignWaypoints(int32 grid) newwp.y = atof(row[1]); newwp.z = atof(row[2]); - if(zone->HasMap() && RuleB(Map, FixPathingZWhenLoading) ) + if (zone->HasMap() && RuleB(Map, FixPathingZWhenLoading)) { - auto positon = glm::vec3(newwp.x,newwp.y,newwp.z); - if(!RuleB(Watermap, CheckWaypointsInWaterWhenLoading) || !zone->HasWaterMap() || + auto positon = glm::vec3(newwp.x, newwp.y, newwp.z); + if (!RuleB(Watermap, CheckWaypointsInWaterWhenLoading) || !zone->HasWaterMap() || (zone->HasWaterMap() && !zone->watermap->InWater(positon))) { glm::vec3 dest(newwp.x, newwp.y, newwp.z); @@ -893,32 +896,32 @@ void NPC::AssignWaypoints(int32 grid) } void Mob::SendTo(float new_x, float new_y, float new_z) { - if(IsNPC()) { + if (IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z); } m_Position.x = new_x; m_Position.y = new_y; m_Position.z = new_z; - Log.Out(Logs::Detail, Logs::AI, "Sent To (%.3f, %.3f, %.3f)", new_x, new_y, new_z); + Log(Logs::Detail, Logs::AI, "Sent To (%.3f, %.3f, %.3f)", new_x, new_y, new_z); - if(flymode == FlyMode1) + if (flymode == FlyMode1) return; //fix up pathing Z, this shouldent be needed IF our waypoints //are corrected instead - if(zone->HasMap() && RuleB(Map, FixPathingZOnSendTo) ) + if (zone->HasMap() && RuleB(Map, FixPathingZOnSendTo)) { - if(!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() || + if (!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() || (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) { glm::vec3 dest(m_Position.x, m_Position.y, m_Position.z); float newz = zone->zonemap->FindBestZ(dest, nullptr); - Log.Out(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.x,m_Position.y,m_Position.z); + Log(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz, m_Position.x, m_Position.y, m_Position.z); - if( (newz > -2000) && std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaSendTo)) // Sanity check. + if ((newz > -2000) && std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaSendTo)) // Sanity check. m_Position.z = newz + 1; } } @@ -927,7 +930,7 @@ void Mob::SendTo(float new_x, float new_y, float new_z) { } void Mob::SendToFixZ(float new_x, float new_y, float new_z) { - if(IsNPC()) { + if (IsNPC()) { entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z + 0.1); } @@ -938,18 +941,18 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) { //fix up pathing Z, this shouldent be needed IF our waypoints //are corrected instead - if(zone->HasMap() && RuleB(Map, FixPathingZOnSendTo)) + if (zone->HasMap() && RuleB(Map, FixPathingZOnSendTo)) { - if(!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() || + if (!RuleB(Watermap, CheckForWaterOnSendTo) || !zone->HasWaterMap() || (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position)))) { glm::vec3 dest(m_Position.x, m_Position.y, m_Position.z); float newz = zone->zonemap->FindBestZ(dest, nullptr); - Log.Out(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.x,m_Position.y,m_Position.z); + Log(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz, m_Position.x, m_Position.y, m_Position.z); - if( (newz > -2000) && std::abs(newz-dest.z) < RuleR(Map, FixPathingZMaxDeltaSendTo)) // Sanity check. + if ((newz > -2000) && std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaSendTo)) // Sanity check. m_Position.z = newz + 1; } } @@ -993,7 +996,7 @@ bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* return false; std::string query = StringFormat("SELECT x, y, z, pause, heading FROM grid_entries " - "WHERE gridid = %i AND number = %i AND zoneid = %i", grid, num, zoneid); + "WHERE gridid = %i AND number = %i AND zoneid = %i", grid, num, zoneid); auto results = QueryDatabase(query); if (!results.Success()) { return false; @@ -1040,7 +1043,7 @@ void ZoneDatabase::ModifyGrid(Client *client, bool remove, uint32 id, uint8 type if (!remove) { std::string query = StringFormat("INSERT INTO grid(id, zoneid, type, type2) " - "VALUES (%i, %i, %i, %i)", id, zoneid, type, type2); + "VALUES (%i, %i, %i, %i)", id, zoneid, type, type2); auto results = QueryDatabase(query); if (!results.Success()) { return; @@ -1062,8 +1065,8 @@ void ZoneDatabase::ModifyGrid(Client *client, bool remove, uint32 id, uint8 type void ZoneDatabase::AddWP(Client *client, uint32 gridid, uint32 wpnum, const glm::vec4& position, uint32 pause, uint16 zoneid) { std::string query = StringFormat("INSERT INTO grid_entries (gridid, zoneid, `number`, x, y, z, pause, heading) " - "VALUES (%i, %i, %i, %f, %f, %f, %i, %f)", - gridid, zoneid, wpnum, position.x, position.y, position.z, pause, position.w); + "VALUES (%i, %i, %i, %f, %f, %f, %i, %f)", + gridid, zoneid, wpnum, position.x, position.y, position.z, pause, position.w); auto results = QueryDatabase(query); if (!results.Success()) { return; @@ -1084,10 +1087,10 @@ void ZoneDatabase::AddWP(Client *client, uint32 gridid, uint32 wpnum, const glm: void ZoneDatabase::DeleteWaypoint(Client *client, uint32 grid_num, uint32 wp_num, uint16 zoneid) { std::string query = StringFormat("DELETE FROM grid_entries WHERE " - "gridid = %i AND zoneid = %i AND `number` = %i", - grid_num, zoneid, wp_num); + "gridid = %i AND zoneid = %i AND `number` = %i", + grid_num, zoneid, wp_num); auto results = QueryDatabase(query); - if(!results.Success()) { + if (!results.Success()) { return; } } @@ -1106,7 +1109,7 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, const glm::v uint32 next_wp_num; // The waypoint number we should be assigning to the new waypoint bool createdNewGrid; // Did we create a new grid in this function? - // See what grid number our spawn is assigned + // See what grid number our spawn is assigned std::string query = StringFormat("SELECT pathgrid FROM spawn2 WHERE id = %i", spawn2id); auto results = QueryDatabase(query); if (!results.Success()) { @@ -1124,11 +1127,11 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, const glm::v { // Our spawn doesn't have a grid assigned to it -- we need to create a new grid and assign it to the spawn createdNewGrid = true; grid_num = GetFreeGrid(zoneid); - if(grid_num == 0) // There are no grids for the current zone -- create Grid #1 + if (grid_num == 0) // There are no grids for the current zone -- create Grid #1 grid_num = 1; query = StringFormat("INSERT INTO grid SET id = '%i', zoneid = %i, type ='%i', type2 = '%i'", - grid_num, zoneid, type1, type2); + grid_num, zoneid, type1, type2); QueryDatabase(query); query = StringFormat("UPDATE spawn2 SET pathgrid = '%i' WHERE id = '%i'", grid_num, spawn2id); @@ -1142,22 +1145,22 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, const glm::v query = StringFormat("SELECT max(`number`) FROM grid_entries WHERE zoneid = '%i' AND gridid = '%i'", zoneid, grid_num); results = QueryDatabase(query); - if(!results.Success()) { // Query error + if (!results.Success()) { // Query error return 0; } row = results.begin(); - if(row[0] != 0) + if (row[0] != 0) next_wp_num = atoi(row[0]) + 1; else // No waypoints in this grid yet next_wp_num = 1; query = StringFormat("INSERT INTO grid_entries(gridid, zoneid, `number`, x, y, z, pause, heading) " - "VALUES (%i, %i, %i, %f, %f, %f, %i, %f)", - grid_num, zoneid, next_wp_num, position.x, position.y, position.z, pause, position.w); + "VALUES (%i, %i, %i, %f, %f, %f, %i, %f)", + grid_num, zoneid, next_wp_num, position.x, position.y, position.z, pause, position.w); results = QueryDatabase(query); - return createdNewGrid? grid_num: 0; + return createdNewGrid ? grid_num : 0; } uint32 ZoneDatabase::GetFreeGrid(uint16 zoneid) { @@ -1180,7 +1183,7 @@ uint32 ZoneDatabase::GetFreeGrid(uint16 zoneid) { int ZoneDatabase::GetHighestWaypoint(uint32 zoneid, uint32 gridid) { std::string query = StringFormat("SELECT COALESCE(MAX(number), 0) FROM grid_entries " - "WHERE zoneid = %i AND gridid = %i", zoneid, gridid); + "WHERE zoneid = %i AND gridid = %i", zoneid, gridid); auto results = QueryDatabase(query); if (!results.Success()) { return 0; @@ -1201,4 +1204,4 @@ void NPC::SaveGuardSpotCharm() void NPC::RestoreGuardSpotCharm() { m_GuardPoint = m_GuardPointSaved; -} +} \ No newline at end of file diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index 3b1c6122f..b0ea2ea5d 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -1,19 +1,19 @@ /* EQEMu: Everquest Server Emulator - Copyright (C) 2001-2016 EQEMu Development Team (http://eqemu.org) +Copyright (C) 2001-2016 EQEMu Development Team (http://eqemu.org) - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY except by those people which sell it, which - are required to give you total support for your newly bought product; - without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY except by those people which sell it, which +are required to give you total support for your newly bought product; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "../common/global_define.h" @@ -24,11 +24,11 @@ #include #ifdef _WINDOWS - #include +#include - #define snprintf _snprintf - #define strncasecmp _strnicmp - #define strcasecmp _stricmp +#define snprintf _snprintf +#define strncasecmp _strnicmp +#define strcasecmp _stricmp #endif #include "../common/eq_packet_structs.h" @@ -108,7 +108,7 @@ bool WorldServer::Connected() const void WorldServer::SetZoneData(uint32 iZoneID, uint32 iInstanceID) { auto pack = new ServerPacket(ServerOP_SetZone, sizeof(SetZone_Struct)); - SetZone_Struct* szs = (SetZone_Struct*) pack->pBuffer; + SetZone_Struct* szs = (SetZone_Struct*)pack->pBuffer; szs->zoneid = iZoneID; szs->instanceid = iInstanceID; if (zone) { @@ -122,7 +122,7 @@ void WorldServer::OnConnected() { ServerPacket* pack; /* Tell the launcher what our information is */ - pack = new ServerPacket(ServerOP_SetLaunchName,sizeof(LaunchName_Struct)); + pack = new ServerPacket(ServerOP_SetLaunchName, sizeof(LaunchName_Struct)); LaunchName_Struct* ln = (LaunchName_Struct*)pack->pBuffer; strn0cpy(ln->launcher_name, m_launcherName.c_str(), 32); strn0cpy(ln->zone_name, m_launchedName.c_str(), 16); @@ -131,19 +131,19 @@ void WorldServer::OnConnected() { /* Tell the Worldserver basic information about this zone process */ pack = new ServerPacket(ServerOP_SetConnectInfo, sizeof(ServerConnectInfo)); - ServerConnectInfo* sci = (ServerConnectInfo*) pack->pBuffer; + ServerConnectInfo* sci = (ServerConnectInfo*)pack->pBuffer; auto config = ZoneConfig::get(); sci->port = ZoneConfig::get()->ZonePort; - if(config->WorldAddress.length() > 0) { + if (config->WorldAddress.length() > 0) { strn0cpy(sci->address, config->WorldAddress.c_str(), 250); } - if(config->LocalAddress.length() > 0) { + if (config->LocalAddress.length() > 0) { strn0cpy(sci->local_address, config->LocalAddress.c_str(), 250); } /* Fetch process ID */ - if (getpid()){ + if (getpid()) { sci->process_id = getpid(); } else { @@ -163,9 +163,9 @@ void WorldServer::OnConnected() { this->SetZoneData(0); } - pack = new ServerPacket(ServerOP_LSZoneBoot,sizeof(ZoneBoot_Struct)); + pack = new ServerPacket(ServerOP_LSZoneBoot, sizeof(ZoneBoot_Struct)); ZoneBoot_Struct* zbs = (ZoneBoot_Struct*)pack->pBuffer; - strcpy(zbs->compile_time,LAST_MODIFIED); + strcpy(zbs->compile_time, LAST_MODIFIED); SendPacket(pack); safe_delete(pack); } @@ -176,7 +176,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) ServerPacket tpack(opcode, p); ServerPacket *pack = &tpack; - switch(opcode) { + switch (opcode) { case 0: { break; } @@ -184,22 +184,23 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) // ignore this break; } - // World is tellins us what port to use. + // World is tellins us what port to use. case ServerOP_SetConnectInfo: { if (pack->size != sizeof(ServerConnectInfo)) break; - ServerConnectInfo* sci = (ServerConnectInfo*) pack->pBuffer; - Log.Out(Logs::Detail, Logs::Zone_Server, "World assigned Port: %d for this zone.", sci->port); + ServerConnectInfo* sci = (ServerConnectInfo*)pack->pBuffer; + Log(Logs::Detail, Logs::Zone_Server, "World assigned Port: %d for this zone.", sci->port); ZoneConfig::SetZonePort(sci->port); break; } case ServerOP_ChannelMessage: { if (!is_zone_loaded) break; - ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*) pack->pBuffer; + ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*)pack->pBuffer; if (scm->deliverto[0] == 0) { entity_list.ChannelMessageFromWorld(scm->from, scm->to, scm->chan_num, scm->guilddbid, scm->language, scm->message); - } else { + } + else { Client* client = entity_list.GetClientByName(scm->deliverto); if (client) { if (client->Connected()) { @@ -212,7 +213,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) else // normal stuff client->ChannelMessageSend(scm->from, scm->to, scm->chan_num, scm->language, scm->message); if (!scm->noreply && scm->chan_num != 2) { //dont echo on group chat - // if it's a tell, echo back so it shows up + // if it's a tell, echo back so it shows up scm->noreply = true; scm->chan_num = 14; memset(scm->deliverto, 0, sizeof(scm->deliverto)); @@ -229,86 +230,86 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) if (!is_zone_loaded) break; - ServerVoiceMacro_Struct* svm = (ServerVoiceMacro_Struct*) pack->pBuffer; + ServerVoiceMacro_Struct* svm = (ServerVoiceMacro_Struct*)pack->pBuffer; auto outapp = new EQApplicationPacket(OP_VoiceMacroOut, sizeof(VoiceMacroOut_Struct)); VoiceMacroOut_Struct* vmo = (VoiceMacroOut_Struct*)outapp->pBuffer; strcpy(vmo->From, svm->From); vmo->Type = svm->Type; - vmo->Voice =svm->Voice; + vmo->Voice = svm->Voice; vmo->MacroNumber = svm->MacroNumber; - switch(svm->Type) { - case VoiceMacroTell: { - Client* c = entity_list.GetClientByName(svm->To); - if(!c) - break; - - c->QueuePacket(outapp); + switch (svm->Type) { + case VoiceMacroTell: { + Client* c = entity_list.GetClientByName(svm->To); + if (!c) break; - } - case VoiceMacroGroup: { - Group* g = entity_list.GetGroupByID(svm->GroupID); + c->QueuePacket(outapp); + break; + } - if(!g) - break; + case VoiceMacroGroup: { + Group* g = entity_list.GetGroupByID(svm->GroupID); - for(unsigned int i = 0; i < MAX_GROUP_MEMBERS; i++) { - if(g->members[i] && g->members[i]->IsClient()) - g->members[i]->CastToClient()->QueuePacket(outapp); - - } + if (!g) break; + + for (unsigned int i = 0; i < MAX_GROUP_MEMBERS; i++) { + if (g->members[i] && g->members[i]->IsClient()) + g->members[i]->CastToClient()->QueuePacket(outapp); + } + break; + } - case VoiceMacroRaid: { - Raid *r = entity_list.GetRaidByID(svm->RaidID); - - if(!r) - break; - - for(int i = 0; i < MAX_RAID_MEMBERS; i++) - if(r->members[i].member) - r->members[i].member->QueuePacket(outapp); + case VoiceMacroRaid: { + Raid *r = entity_list.GetRaidByID(svm->RaidID); + if (!r) break; - } + + for (int i = 0; i < MAX_RAID_MEMBERS; i++) + if (r->members[i].member) + r->members[i].member->QueuePacket(outapp); + + break; + } } safe_delete(outapp); break; } case ServerOP_SpawnCondition: { - if(pack->size != sizeof(ServerSpawnCondition_Struct)) + if (pack->size != sizeof(ServerSpawnCondition_Struct)) break; if (!is_zone_loaded) break; - ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*) pack->pBuffer; + ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*)pack->pBuffer; zone->spawn_conditions.SetCondition(zone->GetShortName(), zone->GetInstanceID(), ssc->condition_id, ssc->value, true); break; } case ServerOP_SpawnEvent: { - if(pack->size != sizeof(ServerSpawnEvent_Struct)) + if (pack->size != sizeof(ServerSpawnEvent_Struct)) break; if (!is_zone_loaded) break; - ServerSpawnEvent_Struct* sse = (ServerSpawnEvent_Struct*) pack->pBuffer; + ServerSpawnEvent_Struct* sse = (ServerSpawnEvent_Struct*)pack->pBuffer; zone->spawn_conditions.ReloadEvent(sse->event_id); break; } case ServerOP_AcceptWorldEntrance: { - if(pack->size != sizeof(WorldToZone_Struct)) + if (pack->size != sizeof(WorldToZone_Struct)) break; if (!is_zone_loaded) break; - WorldToZone_Struct* wtz = (WorldToZone_Struct*) pack->pBuffer; + WorldToZone_Struct* wtz = (WorldToZone_Struct*)pack->pBuffer; - if(zone->GetMaxClients() != 0 && numclients >= zone->GetMaxClients()) + if (zone->GetMaxClients() != 0 && numclients >= zone->GetMaxClients()) wtz->response = -1; else wtz->response = 1; @@ -317,43 +318,43 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } case ServerOP_ZoneToZoneRequest: { - if(pack->size != sizeof(ZoneToZone_Struct)) + if (pack->size != sizeof(ZoneToZone_Struct)) break; if (!is_zone_loaded) break; - ZoneToZone_Struct* ztz = (ZoneToZone_Struct*) pack->pBuffer; + ZoneToZone_Struct* ztz = (ZoneToZone_Struct*)pack->pBuffer; - if(ztz->current_zone_id == zone->GetZoneID() + if (ztz->current_zone_id == zone->GetZoneID() && ztz->current_instance_id == zone->GetInstanceID()) { // it's a response Entity* entity = entity_list.GetClientByName(ztz->name); - if(entity == 0) + if (entity == 0) break; EQApplicationPacket *outapp; - outapp = new EQApplicationPacket(OP_ZoneChange,sizeof(ZoneChange_Struct)); - ZoneChange_Struct* zc2=(ZoneChange_Struct*)outapp->pBuffer; + outapp = new EQApplicationPacket(OP_ZoneChange, sizeof(ZoneChange_Struct)); + ZoneChange_Struct* zc2 = (ZoneChange_Struct*)outapp->pBuffer; - if(ztz->response <= 0) { + if (ztz->response <= 0) { zc2->success = ZONE_ERROR_NOTREADY; entity->CastToMob()->SetZone(ztz->current_zone_id, ztz->current_instance_id); } else { entity->CastToClient()->UpdateWho(1); - strn0cpy(zc2->char_name,entity->CastToMob()->GetName(),64); - zc2->zoneID=ztz->requested_zone_id; - zc2->instanceID=ztz->requested_instance_id; + strn0cpy(zc2->char_name, entity->CastToMob()->GetName(), 64); + zc2->zoneID = ztz->requested_zone_id; + zc2->instanceID = ztz->requested_instance_id; zc2->success = 1; // This block is necessary to clean up any merc objects owned by a Client. Maybe we should do this for bots, too? - if(entity->CastToClient()->GetMerc() != nullptr) + if (entity->CastToClient()->GetMerc() != nullptr) { - entity->CastToClient()->GetMerc()->ProcessClientZoneChange(entity->CastToClient()); + entity->CastToClient()->GetMerc()->ProcessClientZoneChange(entity->CastToClient()); } entity->CastToMob()->SetZone(ztz->requested_zone_id, ztz->requested_instance_id); - if(ztz->ignorerestrictions == 3) + if (ztz->ignorerestrictions == 3) entity->CastToClient()->GoToSafeCoords(ztz->requested_zone_id, ztz->requested_instance_id); } @@ -361,18 +362,18 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) entity->CastToClient()->QueuePacket(outapp); safe_delete(outapp); - switch(ztz->response) + switch (ztz->response) { case -2: { - entity->CastToClient()->Message(13,"You do not own the required locations to enter this zone."); + entity->CastToClient()->Message(13, "You do not own the required locations to enter this zone."); break; } case -1: { - entity->CastToClient()->Message(13,"The zone is currently full, please try again later."); + entity->CastToClient()->Message(13, "The zone is currently full, please try again later."); break; } - case 0: { - entity->CastToClient()->Message(13,"All zone servers are taken at this time, please try again later."); + case 0: { + entity->CastToClient()->Message(13, "All zone servers are taken at this time, please try again later."); break; } } @@ -381,7 +382,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) // it's a request ztz->response = 0; - if(zone->GetMaxClients() != 0 && numclients >= zone->GetMaxClients()) + if (zone->GetMaxClients() != 0 && numclients >= zone->GetMaxClients()) ztz->response = -1; else { ztz->response = 1; @@ -394,18 +395,18 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } break; } - case ServerOP_WhoAllReply:{ - if(!is_zone_loaded) + case ServerOP_WhoAllReply: { + if (!is_zone_loaded) break; - WhoAllReturnStruct* wars= (WhoAllReturnStruct*)pack->pBuffer; - if (wars && wars->id!=0 && wars->id<0xFFFFFFFF){ + WhoAllReturnStruct* wars = (WhoAllReturnStruct*)pack->pBuffer; + if (wars && wars->id != 0 && wars->id<0xFFFFFFFF) { Client* client = entity_list.GetClientByID(wars->id); if (client) { - if(pack->size==64)//no results - client->Message_StringID(0,WHOALL_NO_RESULTS); - else{ + if (pack->size == 64)//no results + client->Message_StringID(0, WHOALL_NO_RESULTS); + else { auto outapp = new EQApplicationPacket(OP_WhoAllResponse, pack->size); memcpy(outapp->pBuffer, pack->pBuffer, pack->size); client->QueuePacket(outapp); @@ -413,55 +414,55 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } } else { - Log.Out(Logs::Detail, Logs::None, "[CLIENT] id=%i, playerineqstring=%i, playersinzonestring=%i. Dumping WhoAllReturnStruct:", + Log(Logs::Detail, Logs::None, "[CLIENT] id=%i, playerineqstring=%i, playersinzonestring=%i. Dumping WhoAllReturnStruct:", wars->id, wars->playerineqstring, wars->playersinzonestring); } } else - Log.Out(Logs::General, Logs::Error, "WhoAllReturnStruct: Could not get return struct!"); + Log(Logs::General, Logs::Error, "WhoAllReturnStruct: Could not get return struct!"); break; } case ServerOP_EmoteMessage: { if (!is_zone_loaded) break; - ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*) pack->pBuffer; + ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer; if (sem->to[0] != 0) { if (strcasecmp(sem->to, zone->GetShortName()) == 0) entity_list.MessageStatus(sem->guilddbid, sem->minstatus, sem->type, (char*)sem->message); else { Client* client = entity_list.GetClientByName(sem->to); - if (client != 0){ - char* newmessage=0; - if(strstr(sem->message,"^")==0) + if (client != 0) { + char* newmessage = 0; + if (strstr(sem->message, "^") == 0) client->Message(sem->type, (char*)sem->message); - else{ - for(newmessage = strtok((char*)sem->message,"^");newmessage!=nullptr;newmessage=strtok(nullptr, "^")) + else { + for (newmessage = strtok((char*)sem->message, "^"); newmessage != nullptr; newmessage = strtok(nullptr, "^")) client->Message(sem->type, newmessage); } } } } - else{ - char* newmessage=0; - if(strstr(sem->message,"^")==0) + else { + char* newmessage = 0; + if (strstr(sem->message, "^") == 0) entity_list.MessageStatus(sem->guilddbid, sem->minstatus, sem->type, sem->message); - else{ - for(newmessage = strtok((char*)sem->message,"^");newmessage!=nullptr;newmessage=strtok(nullptr, "^")) + else { + for (newmessage = strtok((char*)sem->message, "^"); newmessage != nullptr; newmessage = strtok(nullptr, "^")) entity_list.MessageStatus(sem->guilddbid, sem->minstatus, sem->type, newmessage); } } break; } case ServerOP_Motd: { - ServerMotd_Struct* smotd = (ServerMotd_Struct*) pack->pBuffer; + ServerMotd_Struct* smotd = (ServerMotd_Struct*)pack->pBuffer; EQApplicationPacket *outapp; outapp = new EQApplicationPacket(OP_MOTD); - char tmp[500] = {0}; + char tmp[500] = { 0 }; sprintf(tmp, "%s", smotd->motd); - outapp->size = strlen(tmp)+1; + outapp->size = strlen(tmp) + 1; outapp->pBuffer = new uchar[outapp->size]; - memset(outapp->pBuffer,0,outapp->size); + memset(outapp->pBuffer, 0, outapp->size); strcpy((char*)outapp->pBuffer, tmp); entity_list.QueueClients(0, outapp); @@ -486,7 +487,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) else { SendEmoteMessage(0, 0, 15, "Zone shutdown: %s", zone->GetLongName()); - ServerZoneStateChange_struct* zst = (ServerZoneStateChange_struct *) pack->pBuffer; + ServerZoneStateChange_struct* zst = (ServerZoneStateChange_struct *)pack->pBuffer; std::cout << "Zone shutdown by " << zst->adminname << std::endl; Zone::Shutdown(); } @@ -497,7 +498,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) std::cout << "Wrong size on ServerOP_ZoneBootup. Got: " << pack->size << ", Expected: " << sizeof(ServerZoneStateChange_struct) << std::endl; break; } - ServerZoneStateChange_struct* zst = (ServerZoneStateChange_struct *) pack->pBuffer; + ServerZoneStateChange_struct* zst = (ServerZoneStateChange_struct *)pack->pBuffer; if (is_zone_loaded) { SetZoneData(zone->GetZoneID(), zone->GetInstanceID()); if (zst->zoneid == zone->GetZoneID()) { @@ -521,7 +522,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) std::cout << "Wrong size on ServerOP_ZoneIncClient. Got: " << pack->size << ", Expected: " << sizeof(ServerZoneIncomingClient_Struct) << std::endl; break; } - ServerZoneIncomingClient_Struct* szic = (ServerZoneIncomingClient_Struct*) pack->pBuffer; + ServerZoneIncomingClient_Struct* szic = (ServerZoneIncomingClient_Struct*)pack->pBuffer; if (is_zone_loaded) { SetZoneData(zone->GetZoneID(), zone->GetInstanceID()); if (szic->zoneid == zone->GetZoneID()) { @@ -538,7 +539,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } case ServerOP_ZonePlayer: { - ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*) pack->pBuffer; + ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*)pack->pBuffer; Client* client = entity_list.GetClientByName(szp->name); printf("Zoning %s to %s(%u) - %u\n", client != nullptr ? client->GetCleanName() : "Unknown", szp->zone, database.GetZoneID(szp->zone), szp->instance_id); if (client != 0) { @@ -551,11 +552,13 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } if (!szp->instance_id) { client->MovePC(database.GetZoneID(szp->zone), szp->instance_id, szp->x_pos, szp->y_pos, szp->z_pos, client->GetHeading(), szp->ignorerestrictions, GMSummon); - } else { + } + else { if (database.GetInstanceID(client->CharacterID(), database.GetZoneID(szp->zone)) == 0) { client->AssignToInstance(szp->instance_id); client->MovePC(database.GetZoneID(szp->zone), szp->instance_id, szp->x_pos, szp->y_pos, szp->z_pos, client->GetHeading(), szp->ignorerestrictions, GMSummon); - } else { + } + else { client->RemoveFromInstance(database.GetInstanceID(client->CharacterID(), database.GetZoneID(szp->zone))); client->AssignToInstance(szp->instance_id); client->MovePC(database.GetZoneID(szp->zone), szp->instance_id, szp->x_pos, szp->y_pos, szp->z_pos, client->GetHeading(), szp->ignorerestrictions, GMSummon); @@ -565,7 +568,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } case ServerOP_KickPlayer: { - ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*) pack->pBuffer; + ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*)pack->pBuffer; Client* client = entity_list.GetClientByName(skp->name); if (client != 0) { if (skp->adminrank >= client->Admin()) { @@ -581,7 +584,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } case ServerOP_KillPlayer: { - ServerKillPlayer_Struct* skp = (ServerKillPlayer_Struct*) pack->pBuffer; + ServerKillPlayer_Struct* skp = (ServerKillPlayer_Struct*)pack->pBuffer; Client* client = entity_list.GetClientByName(skp->target); if (client != 0) { if (skp->admin >= client->Admin()) { @@ -597,23 +600,23 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - //hand all the guild related packets to the guild manager for processing. + //hand all the guild related packets to the guild manager for processing. case ServerOP_OnlineGuildMembersResponse: case ServerOP_RefreshGuild: -// case ServerOP_GuildInvite: + // case ServerOP_GuildInvite: case ServerOP_DeleteGuild: case ServerOP_GuildCharRefresh: case ServerOP_GuildMemberUpdate: case ServerOP_GuildRankUpdate: case ServerOP_LFGuildUpdate: -// case ServerOP_GuildGMSet: -// case ServerOP_GuildGMSetRank: -// case ServerOP_GuildJoin: + // case ServerOP_GuildGMSet: + // case ServerOP_GuildGMSetRank: + // case ServerOP_GuildJoin: guild_mgr.ProcessWorldPacket(pack); break; case ServerOP_FlagUpdate: { - Client* client = entity_list.GetClientByAccID(*((uint32*) pack->pBuffer)); + Client* client = entity_list.GetClientByAccID(*((uint32*)pack->pBuffer)); if (client != 0) { client->UpdateAdmin(); } @@ -626,12 +629,12 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } if (!is_zone_loaded) break; - ServerGMGoto_Struct* gmg = (ServerGMGoto_Struct*) pack->pBuffer; + ServerGMGoto_Struct* gmg = (ServerGMGoto_Struct*)pack->pBuffer; Client* client = entity_list.GetClientByName(gmg->gotoname); if (client != 0) { SendEmoteMessage(gmg->myname, 0, 13, "Summoning you to: %s @ %s, %1.1f, %1.1f, %1.1f", client->GetName(), zone->GetShortName(), client->GetX(), client->GetY(), client->GetZ()); auto outpack = new ServerPacket(ServerOP_ZonePlayer, sizeof(ServerZonePlayer_Struct)); - ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*) outpack->pBuffer; + ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*)outpack->pBuffer; strcpy(szp->adminname, gmg->myname); strcpy(szp->name, gmg->myname); strcpy(szp->zone, zone->GetShortName()); @@ -648,11 +651,11 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } case ServerOP_MultiLineMsg: { - ServerMultiLineMsg_Struct* mlm = (ServerMultiLineMsg_Struct*) pack->pBuffer; + ServerMultiLineMsg_Struct* mlm = (ServerMultiLineMsg_Struct*)pack->pBuffer; Client* client = entity_list.GetClientByName(mlm->to); if (client) { auto outapp = new EQApplicationPacket(OP_MultiLineMsg, strlen(mlm->message)); - strcpy((char*) outapp->pBuffer, mlm->message); + strcpy((char*)outapp->pBuffer, mlm->message); client->QueuePacket(outapp); safe_delete(outapp); } @@ -663,7 +666,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) std::cout << "Wrong size on ServerOP_Uptime. Got: " << pack->size << ", Expected: " << sizeof(ServerUptime_Struct) << std::endl; break; } - ServerUptime_Struct* sus = (ServerUptime_Struct*) pack->pBuffer; + ServerUptime_Struct* sus = (ServerUptime_Struct*)pack->pBuffer; uint32 ms = Timer::GetCurrentTime(); uint32 d = ms / 86400000; ms -= d * 86400000; @@ -681,14 +684,14 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_Petition: { std::cout << "Got Server Requested Petition List Refresh" << std::endl; - ServerPetitionUpdate_Struct* sus = (ServerPetitionUpdate_Struct*) pack->pBuffer; + ServerPetitionUpdate_Struct* sus = (ServerPetitionUpdate_Struct*)pack->pBuffer; // this was typoed to = instead of ==, not that it acts any different now though.. if (sus->status == 0) petition_list.ReadDatabase(); else if (sus->status == 1) petition_list.ReadDatabase(); // Until I fix this to be better.... break; } case ServerOP_RezzPlayer: { - RezzPlayer_Struct* srs = (RezzPlayer_Struct*) pack->pBuffer; + RezzPlayer_Struct* srs = (RezzPlayer_Struct*)pack->pBuffer; if (srs->rezzopcode == OP_RezzRequest) { // The Rezz request has arrived in the zone the player to be rezzed is currently in, @@ -696,10 +699,10 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) Client* client = entity_list.GetClientByName(srs->rez.your_name); if (client) { - if(client->IsRezzPending()) + if (client->IsRezzPending()) { auto Response = new ServerPacket(ServerOP_RezzPlayerReject, - strlen(srs->rez.rezzer_name) + 1); + strlen(srs->rez.rezzer_name) + 1); char *Buffer = (char *)Response->pBuffer; sprintf(Buffer, "%s", srs->rez.rezzer_name); @@ -710,25 +713,25 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) //pendingrezexp is the amount of XP on the corpse. Setting it to a value >= 0 //also serves to inform Client::OPRezzAnswer to expect a packet. client->SetPendingRezzData(srs->exp, srs->dbid, srs->rez.spellid, srs->rez.corpse_name); - Log.Out(Logs::Detail, Logs::Spells, "OP_RezzRequest in zone %s for %s, spellid:%i", - zone->GetShortName(), client->GetName(), srs->rez.spellid); - auto outapp = new EQApplicationPacket(OP_RezzRequest, - sizeof(Resurrect_Struct)); - memcpy(outapp->pBuffer, &srs->rez, sizeof(Resurrect_Struct)); - client->QueuePacket(outapp); - safe_delete(outapp); - break; + Log(Logs::Detail, Logs::Spells, "OP_RezzRequest in zone %s for %s, spellid:%i", + zone->GetShortName(), client->GetName(), srs->rez.spellid); + auto outapp = new EQApplicationPacket(OP_RezzRequest, + sizeof(Resurrect_Struct)); + memcpy(outapp->pBuffer, &srs->rez, sizeof(Resurrect_Struct)); + client->QueuePacket(outapp); + safe_delete(outapp); + break; } } - if (srs->rezzopcode == OP_RezzComplete){ + if (srs->rezzopcode == OP_RezzComplete) { // We get here when the Rezz complete packet has come back via the world server // to the zone that the corpse is in. Corpse* corpse = entity_list.GetCorpseByName(srs->rez.corpse_name); if (corpse && corpse->IsCorpse()) { - Log.Out(Logs::Detail, Logs::Spells, "OP_RezzComplete received in zone %s for corpse %s", - zone->GetShortName(), srs->rez.corpse_name); + Log(Logs::Detail, Logs::Spells, "OP_RezzComplete received in zone %s for corpse %s", + zone->GetShortName(), srs->rez.corpse_name); - Log.Out(Logs::Detail, Logs::Spells, "Found corpse. Marking corpse as rezzed if needed."); + Log(Logs::Detail, Logs::Spells, "Found corpse. Marking corpse as rezzed if needed."); // I don't know why Rezzed is not set to true in CompleteRezz(). if (!IsEffectInSpell(srs->rez.spellid, SE_SummonToCorpse)) { corpse->IsRezzed(true); @@ -752,12 +755,12 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_ZoneReboot: { std::cout << "Got Server Requested Zone reboot" << std::endl; - ServerZoneReboot_Struct* zb = (ServerZoneReboot_Struct*) pack->pBuffer; + ServerZoneReboot_Struct* zb = (ServerZoneReboot_Struct*)pack->pBuffer; break; } case ServerOP_SyncWorldTime: { if (zone != 0 && !zone->is_zone_time_localized) { - Log.Out(Logs::Moderate, Logs::Zone_Server, "%s Received Message SyncWorldTime", __FUNCTION__); + Log(Logs::Moderate, Logs::Zone_Server, "%s Received Message SyncWorldTime", __FUNCTION__); eqTimeOfDay* newtime = (eqTimeOfDay*)pack->pBuffer; zone->zone_time.SetCurrentEQTimeOfDay(newtime->start_eqtime, newtime->start_realtime); @@ -777,14 +780,14 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) (eq_time.minute < 10) ? "0" : "", eq_time.minute, (eq_time.hour >= 13) ? "pm" : "am" - ); + ); - Log.Out(Logs::General, Logs::Zone_Server, "Time Broadcast Packet: %s", time_message); + Log(Logs::General, Logs::Zone_Server, "Time Broadcast Packet: %s", time_message); zone->SetZoneHasCurrentTime(true); } - if (zone && zone->is_zone_time_localized){ - Log.Out(Logs::General, Logs::Zone_Server, "Received request to sync time from world, but our time is localized currently"); + if (zone && zone->is_zone_time_localized) { + Log(Logs::General, Logs::Zone_Server, "Received request to sync time from world, but our time is localized currently"); } break; } @@ -793,7 +796,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) std::cout << "Wrong size on ServerChangeWID_Struct. Got: " << pack->size << ", Expected: " << sizeof(ServerChangeWID_Struct) << std::endl; break; } - ServerChangeWID_Struct* scw = (ServerChangeWID_Struct*) pack->pBuffer; + ServerChangeWID_Struct* scw = (ServerChangeWID_Struct*)pack->pBuffer; Client* client = entity_list.GetClientByCharID(scw->charid); if (client) client->SetWID(scw->newwid); @@ -804,25 +807,25 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } case ServerOP_Revoke: { - RevokeStruct* rev = (RevokeStruct*) pack->pBuffer; + RevokeStruct* rev = (RevokeStruct*)pack->pBuffer; Client* client = entity_list.GetClientByName(rev->name); if (client) { - SendEmoteMessage(rev->adminname, 0, 0, "%s: %srevoking %s", zone->GetShortName(), rev->toggle?"":"un", client->GetName()); + SendEmoteMessage(rev->adminname, 0, 0, "%s: %srevoking %s", zone->GetShortName(), rev->toggle ? "" : "un", client->GetName()); client->SetRevoked(rev->toggle); } break; } case ServerOP_GroupIDReply: { - ServerGroupIDReply_Struct* ids = (ServerGroupIDReply_Struct*) pack->pBuffer; + ServerGroupIDReply_Struct* ids = (ServerGroupIDReply_Struct*)pack->pBuffer; cur_groupid = ids->start; last_groupid = ids->end; break; } case ServerOP_GroupLeave: { ServerGroupLeave_Struct* gl = (ServerGroupLeave_Struct*)pack->pBuffer; - if(zone){ - if(gl->zoneid == zone->GetZoneID() && gl->instance_id == zone->GetInstanceID()) + if (zone) { + if (gl->zoneid == zone->GetZoneID() && gl->instance_id == zone->GetInstanceID()) break; entity_list.SendGroupLeave(gl->gid, gl->member_name); @@ -835,7 +838,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) Mob *Invitee = entity_list.GetMob(gis->invitee_name); - if(Invitee && Invitee->IsClient() && Invitee->CastToClient()->MercOnlyOrNoGroup() && !Invitee->IsRaidGrouped()) + if (Invitee && Invitee->IsClient() && Invitee->CastToClient()->MercOnlyOrNoGroup() && !Invitee->IsRaidGrouped()) { auto outapp = new EQApplicationPacket(OP_GroupInvite, sizeof(GroupInvite_Struct)); memcpy(outapp->pBuffer, gis, sizeof(GroupInvite_Struct)); @@ -847,15 +850,15 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_GroupFollow: { // Player in another zone accepted a group invitation from a player in this zone. - ServerGroupFollow_Struct* sgfs = (ServerGroupFollow_Struct*) pack->pBuffer; + ServerGroupFollow_Struct* sgfs = (ServerGroupFollow_Struct*)pack->pBuffer; Mob* Inviter = entity_list.GetClientByName(sgfs->gf.name1); - if(Inviter && Inviter->IsClient()) + if (Inviter && Inviter->IsClient()) { Group* group = entity_list.GetGroupByClient(Inviter->CastToClient()); - if(!group) + if (!group) { //Make new group group = new Group(Inviter); @@ -867,7 +870,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) entity_list.AddGroup(group); - if(group->GetID() == 0) { + if (group->GetID() == 0) { Inviter->Message(13, "Unable to get new group id. Cannot create group."); break; } @@ -879,8 +882,8 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) if (Inviter->CastToClient()->ClientVersion() < EQEmu::versions::ClientVersion::SoD) { auto outapp = - new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupJoin_Struct)); - GroupJoin_Struct* outgj=(GroupJoin_Struct*)outapp->pBuffer; + new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupJoin_Struct)); + GroupJoin_Struct* outgj = (GroupJoin_Struct*)outapp->pBuffer; strcpy(outgj->membername, Inviter->GetName()); strcpy(outgj->yourname, Inviter->GetName()); outgj->action = groupActInviteInitial; // 'You have formed the group'. @@ -895,13 +898,13 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) Inviter->CastToClient()->SendGroupLeaderChangePacket(Inviter->GetName()); Inviter->CastToClient()->SendGroupJoinAcknowledge(); } - + group->GetXTargetAutoMgr()->merge(*Inviter->CastToClient()->GetXTargetAutoMgr()); Inviter->CastToClient()->GetXTargetAutoMgr()->clear(); Inviter->CastToClient()->SetXTargetAutoMgr(group->GetXTargetAutoMgr()); } - if(!group) + if (!group) { break; } @@ -913,10 +916,10 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) Inviter->CastToClient()->QueuePacket(outapp); safe_delete(outapp); - if(!group->AddMember(nullptr, sgfs->gf.name2, sgfs->CharacterID)) + if (!group->AddMember(nullptr, sgfs->gf.name2, sgfs->CharacterID)) break; - if(Inviter->CastToClient()->IsLFP()) + if (Inviter->CastToClient()->IsLFP()) Inviter->CastToClient()->UpdateLFP(); auto pack2 = new ServerPacket(ServerOP_GroupJoin, sizeof(ServerGroupJoin_Struct)); @@ -927,12 +930,12 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) strn0cpy(gj->member_name, sgfs->gf.name2, sizeof(gj->member_name)); worldserver.SendPacket(pack2); safe_delete(pack2); - - + + // Send acknowledgement back to the Invitee to let them know we have added them to the group. auto pack3 = - new ServerPacket(ServerOP_GroupFollowAck, sizeof(ServerGroupFollowAck_Struct)); + new ServerPacket(ServerOP_GroupFollowAck, sizeof(ServerGroupFollowAck_Struct)); ServerGroupFollowAck_Struct* sgfas = (ServerGroupFollowAck_Struct*)pack3->pBuffer; strn0cpy(sgfas->Name, sgfs->gf.name2, sizeof(sgfas->Name)); worldserver.SendPacket(pack3); @@ -946,39 +949,39 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) Client *client = entity_list.GetClientByName(sgfas->Name); - if(!client) + if (!client) break; uint32 groupid = database.GetGroupID(client->GetName()); Group* group = nullptr; - if(groupid > 0) + if (groupid > 0) { group = entity_list.GetGroupByID(groupid); - if(!group) + if (!group) { //nobody from our group is here... start a new group group = new Group(groupid); - if(group->GetID() != 0) + if (group->GetID() != 0) entity_list.AddGroup(group, groupid); else group = nullptr; } - if(group) + if (group) group->UpdatePlayer(client); else { - if(client->GetMerc()) + if (client->GetMerc()) database.SetGroupID(client->GetMerc()->GetCleanName(), 0, client->CharacterID(), true); database.SetGroupID(client->GetName(), 0, client->CharacterID(), false); //cannot re-establish group, kill it } } - if(group) + if (group) { if (client->GetMerc()) { @@ -989,7 +992,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) group->SendHPPacketsTo(client); // If the group leader is not set, pull the group leader information from the database. - if(!group->GetLeader()) + if (!group->GetLeader()) { char ln[64]; char MainTankName[64]; @@ -1002,7 +1005,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) memset(ln, 0, 64); strcpy(ln, database.GetGroupLeadershipInfo(group->GetID(), ln, MainTankName, AssistName, PullerName, NPCMarkerName, mentoree_name, &mentor_percent, &GLAA)); Client *lc = entity_list.GetClientByName(ln); - if(lc) + if (lc) group->SetLeader(lc); group->SetMainTank(MainTankName); @@ -1023,11 +1026,11 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_GroupCancelInvite: { - GroupCancel_Struct* sgcs = (GroupCancel_Struct*) pack->pBuffer; + GroupCancel_Struct* sgcs = (GroupCancel_Struct*)pack->pBuffer; Mob* Inviter = entity_list.GetClientByName(sgcs->name1); - if(Inviter && Inviter->IsClient()) + if (Inviter && Inviter->IsClient()) { auto outapp = new EQApplicationPacket(OP_GroupCancelInvite, sizeof(GroupCancel_Struct)); memcpy(outapp->pBuffer, sgcs, sizeof(GroupCancel_Struct)); @@ -1038,12 +1041,12 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_GroupJoin: { ServerGroupJoin_Struct* gj = (ServerGroupJoin_Struct*)pack->pBuffer; - if(zone){ - if(gj->zoneid == zone->GetZoneID() && gj->instance_id == zone->GetInstanceID()) + if (zone) { + if (gj->zoneid == zone->GetZoneID() && gj->instance_id == zone->GetInstanceID()) break; Group* g = entity_list.GetGroupByID(gj->gid); - if(g) + if (g) g->AddMember(gj->member_name); entity_list.SendGroupJoin(gj->gid, gj->member_name); @@ -1053,8 +1056,8 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_ForceGroupUpdate: { ServerForceGroupUpdate_Struct* fgu = (ServerForceGroupUpdate_Struct*)pack->pBuffer; - if(zone){ - if(fgu->origZoneID == zone->GetZoneID() && fgu->instance_id == zone->GetInstanceID()) + if (zone) { + if (fgu->origZoneID == zone->GetZoneID() && fgu->instance_id == zone->GetInstanceID()) break; entity_list.ForceGroupUpdate(fgu->gid); @@ -1064,8 +1067,8 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_OOZGroupMessage: { ServerGroupChannelMessage_Struct* gcm = (ServerGroupChannelMessage_Struct*)pack->pBuffer; - if(zone){ - if(gcm->zoneid == zone->GetZoneID() && gcm->instanceid == zone->GetInstanceID()) + if (zone) { + if (gcm->zoneid == zone->GetZoneID() && gcm->instanceid == zone->GetInstanceID()) break; entity_list.GroupMessage(gcm->groupid, gcm->from, gcm->message); @@ -1074,24 +1077,24 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_DisbandGroup: { ServerDisbandGroup_Struct* sd = (ServerDisbandGroup_Struct*)pack->pBuffer; - if(zone){ - if(sd->zoneid == zone->GetZoneID() && sd->instance_id == zone->GetInstanceID()) + if (zone) { + if (sd->zoneid == zone->GetZoneID() && sd->instance_id == zone->GetInstanceID()) break; Group *g = entity_list.GetGroupByID(sd->groupid); - if(g) + if (g) g->DisbandGroup(); } break; } - case ServerOP_RaidAdd:{ + case ServerOP_RaidAdd: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - if(zone){ - if(rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) + if (zone) { + if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) break; Raid *r = entity_list.GetRaidByID(rga->rid); - if(r){ + if (r) { r->LearnMembers(); r->VerifyRaid(); r->SendRaidAddAll(rga->playername); @@ -1100,17 +1103,17 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_RaidRemove:{ + case ServerOP_RaidRemove: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - if(zone){ - if(rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) + if (zone) { + if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) break; Raid *r = entity_list.GetRaidByID(rga->rid); - if(r){ + if (r) { r->SendRaidRemoveAll(rga->playername); Client *rem = entity_list.GetClientByName(rga->playername); - if(rem){ + if (rem) { rem->LeaveRaidXTargets(r); r->SendRaidDisband(rem); } @@ -1121,14 +1124,14 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_RaidDisband:{ + case ServerOP_RaidDisband: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - if(zone){ - if(rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) + if (zone) { + if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) break; Raid *r = entity_list.GetRaidByID(rga->rid); - if(r){ + if (r) { r->SendRaidDisbandAll(); r->LearnMembers(); r->VerifyRaid(); @@ -1137,16 +1140,16 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_RaidLockFlag:{ + case ServerOP_RaidLockFlag: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - if(zone){ - if(rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) + if (zone) { + if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) break; Raid *r = entity_list.GetRaidByID(rga->rid); - if(r){ + if (r) { r->GetRaidDetails(); //update our details - if(rga->gid) + if (rga->gid) r->SendRaidLock(); else r->SendRaidUnlock(); @@ -1155,27 +1158,27 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_RaidChangeGroup:{ + case ServerOP_RaidChangeGroup: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - if(zone){ - if(rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) + if (zone) { + if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) break; Raid *r = entity_list.GetRaidByID(rga->rid); - if(r){ + if (r) { r->LearnMembers(); r->VerifyRaid(); Client *c = entity_list.GetClientByName(rga->playername); - if(c){ + if (c) { r->SendRaidDisband(c); r->SendRaidRemoveAll(rga->playername); r->SendRaidCreate(c); r->SendMakeLeaderPacketTo(r->leadername, c); r->SendBulkRaid(c); r->SendRaidAddAll(rga->playername); - if(r->IsLocked()) { r->SendRaidLockTo(c); } + if (r->IsLocked()) { r->SendRaidLockTo(c); } } - else{ + else { r->SendRaidRemoveAll(rga->playername); r->SendRaidAddAll(rga->playername); } @@ -1184,40 +1187,40 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_UpdateGroup:{ + case ServerOP_UpdateGroup: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - if(zone){ - if(rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) + if (zone) { + if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) break; Raid *r = entity_list.GetRaidByID(rga->rid); - if(r){ + if (r) { r->GroupUpdate(rga->gid, false); } } break; } - case ServerOP_RaidGroupLeader:{ + case ServerOP_RaidGroupLeader: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - if(zone){ - if(rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) + if (zone) { + if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) break; } break; } - case ServerOP_RaidLeader:{ + case ServerOP_RaidLeader: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - if(zone){ - if(rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) + if (zone) { + if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) break; Raid *r = entity_list.GetRaidByID(rga->rid); - if(r){ + if (r) { Client *c = entity_list.GetClientByName(rga->playername); strn0cpy(r->leadername, rga->playername, 64); - if(c){ + if (c) { r->SetLeader(c); } r->LearnMembers(); @@ -1228,14 +1231,14 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_DetailsChange:{ + case ServerOP_DetailsChange: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - if(zone){ - if(rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) + if (zone) { + if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) break; Raid *r = entity_list.GetRaidByID(rga->rid); - if(r){ + if (r) { r->GetRaidDetails(); r->LearnMembers(); r->VerifyRaid(); @@ -1244,18 +1247,18 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_RaidGroupDisband:{ + case ServerOP_RaidGroupDisband: { ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; - if(zone){ - if(rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) + if (zone) { + if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID()) break; Client *c = entity_list.GetClientByName(rga->playername); - if(c) + if (c) { auto outapp = - new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupUpdate_Struct)); - GroupUpdate_Struct* gu = (GroupUpdate_Struct*) outapp->pBuffer; + new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupUpdate_Struct)); + GroupUpdate_Struct* gu = (GroupUpdate_Struct*)outapp->pBuffer; gu->action = groupActDisband; strn0cpy(gu->leadersname, c->GetName(), 64); strn0cpy(gu->yourname, c->GetName(), 64); @@ -1265,24 +1268,24 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_RaidGroupAdd:{ + case ServerOP_RaidGroupAdd: { ServerRaidGroupAction_Struct* rga = (ServerRaidGroupAction_Struct*)pack->pBuffer; - if(zone){ + if (zone) { Raid *r = entity_list.GetRaidByID(rga->rid); - if(r){ + if (r) { r->LearnMembers(); r->VerifyRaid(); auto outapp = new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupJoin_Struct)); - GroupJoin_Struct* gj = (GroupJoin_Struct*) outapp->pBuffer; + GroupJoin_Struct* gj = (GroupJoin_Struct*)outapp->pBuffer; strn0cpy(gj->membername, rga->membername, 64); gj->action = groupActJoin; - for(int x = 0; x < MAX_RAID_MEMBERS; x++) + for (int x = 0; x < MAX_RAID_MEMBERS; x++) { - if(r->members[x].member) + if (r->members[x].member) { - if(strcmp(r->members[x].member->GetName(), rga->membername) != 0){ - if((rga->gid < 12) && rga->gid == r->members[x].GroupNumber) + if (strcmp(r->members[x].member->GetName(), rga->membername) != 0) { + if ((rga->gid < 12) && rga->gid == r->members[x].GroupNumber) { strn0cpy(gj->yourname, r->members[x].member->GetName(), 64); r->members[x].member->QueuePacket(outapp); @@ -1296,24 +1299,24 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_RaidGroupRemove:{ + case ServerOP_RaidGroupRemove: { ServerRaidGroupAction_Struct* rga = (ServerRaidGroupAction_Struct*)pack->pBuffer; - if(zone){ + if (zone) { Raid *r = entity_list.GetRaidByID(rga->rid); - if(r){ + if (r) { r->LearnMembers(); r->VerifyRaid(); auto outapp = new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupJoin_Struct)); - GroupJoin_Struct* gj = (GroupJoin_Struct*) outapp->pBuffer; + GroupJoin_Struct* gj = (GroupJoin_Struct*)outapp->pBuffer; strn0cpy(gj->membername, rga->membername, 64); gj->action = groupActLeave; - for(int x = 0; x < MAX_RAID_MEMBERS; x++) + for (int x = 0; x < MAX_RAID_MEMBERS; x++) { - if(r->members[x].member) + if (r->members[x].member) { - if(strcmp(r->members[x].member->GetName(), rga->membername) != 0){ - if((rga->gid < 12) && rga->gid == r->members[x].GroupNumber) + if (strcmp(r->members[x].member->GetName(), rga->membername) != 0) { + if ((rga->gid < 12) && rga->gid == r->members[x].GroupNumber) { strn0cpy(gj->yourname, r->members[x].member->GetName(), 64); r->members[x].member->QueuePacket(outapp); @@ -1327,19 +1330,19 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_RaidGroupSay:{ + case ServerOP_RaidGroupSay: { ServerRaidMessage_Struct* rmsg = (ServerRaidMessage_Struct*)pack->pBuffer; - if(zone){ + if (zone) { Raid *r = entity_list.GetRaidByID(rmsg->rid); - if(r) + if (r) { - for(int x = 0; x < MAX_RAID_MEMBERS; x++) + for (int x = 0; x < MAX_RAID_MEMBERS; x++) { - if(r->members[x].member){ - if(strcmp(rmsg->from, r->members[x].member->GetName()) != 0) + if (r->members[x].member) { + if (strcmp(rmsg->from, r->members[x].member->GetName()) != 0) { - if(r->members[x].GroupNumber == rmsg->gid){ - if(r->members[x].member->GetFilter(FilterGroupChat)!=0) + if (r->members[x].GroupNumber == rmsg->gid) { + if (r->members[x].member->GetFilter(FilterGroupChat) != 0) { r->members[x].member->ChannelMessageSend(rmsg->from, r->members[x].member->GetName(), 2, 0, rmsg->message); } @@ -1352,19 +1355,19 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } - case ServerOP_RaidSay:{ + case ServerOP_RaidSay: { ServerRaidMessage_Struct* rmsg = (ServerRaidMessage_Struct*)pack->pBuffer; - if(zone) + if (zone) { Raid *r = entity_list.GetRaidByID(rmsg->rid); - if(r) + if (r) { - for(int x = 0; x < MAX_RAID_MEMBERS; x++) + for (int x = 0; x < MAX_RAID_MEMBERS; x++) { - if(r->members[x].member){ - if(strcmp(rmsg->from, r->members[x].member->GetName()) != 0) + if (r->members[x].member) { + if (strcmp(rmsg->from, r->members[x].member->GetName()) != 0) { - if(r->members[x].member->GetFilter(FilterGroupChat)!=0) + if (r->members[x].member->GetFilter(FilterGroupChat) != 0) { r->members[x].member->ChannelMessageSend(rmsg->from, r->members[x].member->GetName(), 15, 0, rmsg->message); } @@ -1391,29 +1394,29 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_SpawnPlayerCorpse: { SpawnPlayerCorpse_Struct* s = (SpawnPlayerCorpse_Struct*)pack->pBuffer; Corpse* NewCorpse = database.LoadCharacterCorpse(s->player_corpse_id); - if(NewCorpse) + if (NewCorpse) NewCorpse->Spawn(); else - Log.Out(Logs::General, Logs::Error, "Unable to load player corpse id %u for zone %s.", s->player_corpse_id, zone->GetShortName()); + Log(Logs::General, Logs::Error, "Unable to load player corpse id %u for zone %s.", s->player_corpse_id, zone->GetShortName()); break; } case ServerOP_Consent: { ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer; Client* client = entity_list.GetClientByName(s->grantname); - if(client) { - if(s->permission == 1) + if (client) { + if (s->permission == 1) client->consent_list.push_back(s->ownername); else client->consent_list.remove(s->ownername); auto outapp = - new EQApplicationPacket(OP_ConsentResponse, sizeof(ConsentResponse_Struct)); + new EQApplicationPacket(OP_ConsentResponse, sizeof(ConsentResponse_Struct)); ConsentResponse_Struct* crs = (ConsentResponse_Struct*)outapp->pBuffer; strcpy(crs->grantname, s->grantname); strcpy(crs->ownername, s->ownername); crs->permission = s->permission; - strcpy(crs->zonename,"all zones"); + strcpy(crs->zonename, "all zones"); client->QueuePacket(outapp); safe_delete(outapp); } @@ -1426,7 +1429,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) // TARGET_NOT_FOUND = 101 auto scs_pack = - new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct)); + new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct)); ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)scs_pack->pBuffer; strcpy(scs->grantname, s->grantname); strcpy(scs->ownername, s->ownername); @@ -1442,13 +1445,13 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_Consent_Response: { ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer; Client* client = entity_list.GetClientByName(s->ownername); - if(client) { + if (client) { client->Message_StringID(0, s->message_string_id); } break; } case ServerOP_ReloadTasks: { - if(RuleB(Tasks,EnableTaskSystem)) { + if (RuleB(Tasks, EnableTaskSystem)) { HandleReloadTasks(pack); } break; @@ -1463,16 +1466,16 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_UpdateSpawn: { - if(zone) + if (zone) { UpdateSpawnTimer_Struct *ust = (UpdateSpawnTimer_Struct*)pack->pBuffer; LinkedListIterator iterator(zone->spawn2_list); iterator.Reset(); while (iterator.MoreElements()) { - if(iterator.GetData()->GetID() == ust->id) + if (iterator.GetData()->GetID() == ust->id) { - if(!iterator.GetData()->NPCPointerValid()) + if (!iterator.GetData()->NPCPointerValid()) { iterator.GetData()->SetTimer(ust->duration); } @@ -1487,9 +1490,9 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_InstanceUpdateTime: { ServerInstanceUpdateTime_Struct *iut = (ServerInstanceUpdateTime_Struct*)pack->pBuffer; - if(zone) + if (zone) { - if(zone->GetInstanceID() == iut->instance_id) + if (zone->GetInstanceID() == iut->instance_id) { zone->SetInstanceTimer(iut->new_duration); } @@ -1501,7 +1504,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { ServerDepopAllPlayersCorpses_Struct *sdapcs = (ServerDepopAllPlayersCorpses_Struct *)pack->pBuffer; - if(zone && !((zone->GetZoneID() == sdapcs->ZoneID) && (zone->GetInstanceID() == sdapcs->InstanceID))) + if (zone && !((zone->GetZoneID() == sdapcs->ZoneID) && (zone->GetInstanceID() == sdapcs->InstanceID))) entity_list.RemoveAllCorpsesByCharID(sdapcs->CharacterID); break; @@ -1512,7 +1515,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { ServerDepopPlayerCorpse_Struct *sdpcs = (ServerDepopPlayerCorpse_Struct *)pack->pBuffer; - if(zone && !((zone->GetZoneID() == sdpcs->ZoneID) && (zone->GetInstanceID() == sdpcs->InstanceID))) + if (zone && !((zone->GetZoneID() == sdpcs->ZoneID) && (zone->GetInstanceID() == sdpcs->InstanceID))) entity_list.RemoveCorpseByDBID(sdpcs->DBID); break; @@ -1527,16 +1530,16 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_SpawnStatusChange: { - if(zone) + if (zone) { ServerSpawnStatusChange_Struct *ssc = (ServerSpawnStatusChange_Struct*)pack->pBuffer; LinkedListIterator iterator(zone->spawn2_list); iterator.Reset(); Spawn2 *found_spawn = nullptr; - while(iterator.MoreElements()) + while (iterator.MoreElements()) { Spawn2* cur = iterator.GetData(); - if(cur->GetID() == ssc->id) + if (cur->GetID() == ssc->id) { found_spawn = cur; break; @@ -1544,9 +1547,9 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) iterator.Advance(); } - if(found_spawn) + if (found_spawn) { - if(ssc->new_status == 0) + if (ssc->new_status == 0) { found_spawn->Disable(); } @@ -1561,15 +1564,15 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_QGlobalUpdate: { - if(pack->size != sizeof(ServerQGlobalUpdate_Struct)) + if (pack->size != sizeof(ServerQGlobalUpdate_Struct)) { break; } - if(zone) + if (zone) { ServerQGlobalUpdate_Struct *qgu = (ServerQGlobalUpdate_Struct*)pack->pBuffer; - if(qgu->from_zone_id != zone->GetZoneID() || qgu->from_instance_id != zone->GetInstanceID()) + if (qgu->from_zone_id != zone->GetZoneID() || qgu->from_instance_id != zone->GetInstanceID()) { QGlobal temp; temp.npc_id = qgu->npc_id; @@ -1587,15 +1590,15 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_QGlobalDelete: { - if(pack->size != sizeof(ServerQGlobalDelete_Struct)) + if (pack->size != sizeof(ServerQGlobalDelete_Struct)) { break; } - if(zone) + if (zone) { ServerQGlobalDelete_Struct *qgd = (ServerQGlobalDelete_Struct*)pack->pBuffer; - if(qgd->from_zone_id != zone->GetZoneID() || qgd->from_instance_id != zone->GetInstanceID()) + if (qgd->from_zone_id != zone->GetZoneID() || qgd->from_instance_id != zone->GetInstanceID()) { entity_list.DeleteQGlobal(std::string((char*)qgd->name), qgd->npc_id, qgd->char_id, qgd->zone_id); zone->DeleteQGlobal(std::string((char*)qgd->name), qgd->npc_id, qgd->char_id, qgd->zone_id); @@ -1608,7 +1611,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { ServerAdventureRequestAccept_Struct *ars = (ServerAdventureRequestAccept_Struct*)pack->pBuffer; Client *c = entity_list.GetClientByName(ars->leader); - if(c) + if (c) { c->NewAdventure(ars->id, ars->theme, ars->text, ars->member_count, (const char*)(pack->pBuffer + sizeof(ServerAdventureRequestAccept_Struct))); c->ClearPendingAdventureRequest(); @@ -1620,7 +1623,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { ServerAdventureRequestDeny_Struct *ars = (ServerAdventureRequestDeny_Struct*)pack->pBuffer; Client *c = entity_list.GetClientByName(ars->leader); - if(c) + if (c) { c->SendAdventureError(ars->reason); c->ClearPendingAdventureRequest(); @@ -1631,7 +1634,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_AdventureCreateDeny: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); - if(c) + if (c) { c->ClearPendingAdventureData(); c->ClearPendingAdventureCreate(); @@ -1642,7 +1645,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_AdventureData: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); - if(c) + if (c) { c->ClearAdventureData(); auto adv_data = new char[pack->size]; @@ -1658,9 +1661,9 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_AdventureDataClear: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); - if(c) + if (c) { - if(c->HasAdventureData()) + if (c->HasAdventureData()) { c->ClearAdventureData(); c->SendAdventureError("You are not currently assigned to an adventure."); @@ -1673,7 +1676,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { ServerPlayerClickedAdventureDoorReply_Struct *adr = (ServerPlayerClickedAdventureDoorReply_Struct*)pack->pBuffer; Client *c = entity_list.GetClientByName(adr->player); - if(c) + if (c) { c->ClearPendingAdventureDoorClick(); c->MovePC(adr->zone_id, adr->instance_id, adr->x, adr->y, adr->z, adr->h, 0); @@ -1684,7 +1687,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_AdventureClickDoorError: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); - if(c) + if (c) { c->ClearPendingAdventureDoorClick(); c->Message_StringID(13, 5141); @@ -1695,7 +1698,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_AdventureLeaveReply: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); - if(c) + if (c) { c->ClearPendingAdventureLeave(); c->ClearCurrentAdventure(); @@ -1706,7 +1709,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_AdventureLeaveDeny: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); - if(c) + if (c) { c->ClearPendingAdventureLeave(); c->Message(13, "You cannot leave this adventure at this time."); @@ -1718,7 +1721,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { ServerAdventureCountUpdate_Struct *ac = (ServerAdventureCountUpdate_Struct*)pack->pBuffer; Client *c = entity_list.GetClientByName(ac->player); - if(c) + if (c) { c->SendAdventureCount(ac->count, ac->total); } @@ -1727,7 +1730,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_AdventureZoneData: { - if(zone) + if (zone) { safe_delete(zone->adv_data); zone->adv_data = new char[pack->size]; @@ -1741,7 +1744,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { ServerAdventureFinish_Struct *af = (ServerAdventureFinish_Struct*)pack->pBuffer; Client *c = entity_list.GetClientByName(af->player); - if(c) + if (c) { c->AdventureFinish(af->win, af->theme, af->points); } @@ -1751,11 +1754,11 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_AdventureLeaderboard: { Client *c = entity_list.GetClientByName((const char*)pack->pBuffer); - if(c) + if (c) { auto outapp = new EQApplicationPacket(OP_AdventureLeaderboardReply, - sizeof(AdventureLeaderboard_Struct)); - memcpy(outapp->pBuffer, pack->pBuffer+64, sizeof(AdventureLeaderboard_Struct)); + sizeof(AdventureLeaderboard_Struct)); + memcpy(outapp->pBuffer, pack->pBuffer + 64, sizeof(AdventureLeaderboard_Struct)); c->FastQueuePacket(&outapp); } break; @@ -1766,7 +1769,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } case ServerOP_ReloadLogs: { - database.LoadLogSettings(Log.log_settings); + database.LoadLogSettings(LogSys.log_settings); break; } case ServerOP_ReloadPerlExportSettings: { @@ -1775,10 +1778,10 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_CameraShake: { - if(zone) + if (zone) { - ServerCameraShake_Struct *scss = (ServerCameraShake_Struct*)pack->pBuffer; - entity_list.CameraEffect(scss->duration, scss->intensity); + ServerCameraShake_Struct *scss = (ServerCameraShake_Struct*)pack->pBuffer; + entity_list.CameraEffect(scss->duration, scss->intensity); } break; } @@ -1790,21 +1793,21 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) Client *c = entity_list.GetClientByName(From); - if(!c) + if (!c) return; uint32 Type = pack->ReadUInt32();; - switch(Type) + switch (Type) { - case QSG_LFGuild: - { - c->HandleLFGuildResponse(pack); - break; - } + case QSG_LFGuild: + { + c->HandleLFGuildResponse(pack); + break; + } - default: - break; + default: + break; } break; @@ -1821,7 +1824,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_CZSignalNPC: { CZNPCSignal_Struct* CZCN = (CZNPCSignal_Struct*)pack->pBuffer; - NPC* n = entity_list.GetNPCByNPCTypeID(CZCN->npctype_id); + NPC* n = entity_list.GetNPCByNPCTypeID(CZCN->npctype_id); if (n != 0) { n->SignalNPC(CZCN->data); } @@ -1829,7 +1832,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_CZSignalClient: { - CZClientSignal_Struct* CZCS = (CZClientSignal_Struct*) pack->pBuffer; + CZClientSignal_Struct* CZCS = (CZClientSignal_Struct*)pack->pBuffer; Client* client = entity_list.GetClientByCharID(CZCS->charid); if (client != 0) { client->Signal(CZCS->data); @@ -1838,7 +1841,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_CZSignalClientByName: { - CZClientSignalByName_Struct* CZCS = (CZClientSignalByName_Struct*) pack->pBuffer; + CZClientSignalByName_Struct* CZCS = (CZClientSignalByName_Struct*)pack->pBuffer; Client* client = entity_list.GetClientByName(CZCS->Name); if (client != 0) { client->Signal(CZCS->data); @@ -1847,7 +1850,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_CZMessagePlayer: { - CZMessagePlayer_Struct* CZCS = (CZMessagePlayer_Struct*) pack->pBuffer; + CZMessagePlayer_Struct* CZCS = (CZMessagePlayer_Struct*)pack->pBuffer; Client* client = entity_list.GetClientByName(CZCS->CharName); if (client != 0) { client->Message(CZCS->Type, CZCS->Message); @@ -1856,7 +1859,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_WWMarquee: { - WWMarquee_Struct* WWMS = (WWMarquee_Struct*) pack->pBuffer; + WWMarquee_Struct* WWMS = (WWMarquee_Struct*)pack->pBuffer; std::list client_list; entity_list.GetClientList(client_list); auto iter = client_list.begin(); @@ -1869,8 +1872,8 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } case ServerOP_ReloadWorld: { - ReloadWorld_Struct* RW = (ReloadWorld_Struct*) pack->pBuffer; - if(zone){ + ReloadWorld_Struct* RW = (ReloadWorld_Struct*)pack->pBuffer; + if (zone) { zone->ReloadWorld(RW->Option); } break; @@ -1879,34 +1882,34 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) case ServerOP_ChangeSharedMem: { std::string hotfix_name = std::string((char*)pack->pBuffer); - Log.Out(Logs::General, Logs::Zone_Server, "Loading items"); - if(!database.LoadItems(hotfix_name)) { - Log.Out(Logs::General, Logs::Error, "Loading items FAILED!"); + Log(Logs::General, Logs::Zone_Server, "Loading items"); + if (!database.LoadItems(hotfix_name)) { + Log(Logs::General, Logs::Error, "Loading items FAILED!"); } - Log.Out(Logs::General, Logs::Zone_Server, "Loading npc faction lists"); - if(!database.LoadNPCFactionLists(hotfix_name)) { - Log.Out(Logs::General, Logs::Error, "Loading npcs faction lists FAILED!"); + Log(Logs::General, Logs::Zone_Server, "Loading npc faction lists"); + if (!database.LoadNPCFactionLists(hotfix_name)) { + Log(Logs::General, Logs::Error, "Loading npcs faction lists FAILED!"); } - Log.Out(Logs::General, Logs::Zone_Server, "Loading loot tables"); - if(!database.LoadLoot(hotfix_name)) { - Log.Out(Logs::General, Logs::Error, "Loading loot FAILED!"); + Log(Logs::General, Logs::Zone_Server, "Loading loot tables"); + if (!database.LoadLoot(hotfix_name)) { + Log(Logs::General, Logs::Error, "Loading loot FAILED!"); } - Log.Out(Logs::General, Logs::Zone_Server, "Loading skill caps"); - if(!database.LoadSkillCaps(std::string(hotfix_name))) { - Log.Out(Logs::General, Logs::Error, "Loading skill caps FAILED!"); + Log(Logs::General, Logs::Zone_Server, "Loading skill caps"); + if (!database.LoadSkillCaps(std::string(hotfix_name))) { + Log(Logs::General, Logs::Error, "Loading skill caps FAILED!"); } - Log.Out(Logs::General, Logs::Zone_Server, "Loading spells"); - if(!database.LoadSpells(hotfix_name, &SPDAT_RECORDS, &spells)) { - Log.Out(Logs::General, Logs::Error, "Loading spells FAILED!"); + Log(Logs::General, Logs::Zone_Server, "Loading spells"); + if (!database.LoadSpells(hotfix_name, &SPDAT_RECORDS, &spells)) { + Log(Logs::General, Logs::Error, "Loading spells FAILED!"); } - Log.Out(Logs::General, Logs::Zone_Server, "Loading base data"); - if(!database.LoadBaseData(hotfix_name)) { - Log.Out(Logs::General, Logs::Error, "Loading base data FAILED!"); + Log(Logs::General, Logs::Zone_Server, "Loading base data"); + if (!database.LoadBaseData(hotfix_name)) { + Log(Logs::General, Logs::Error, "Loading base data FAILED!"); } break; } @@ -1919,7 +1922,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) } bool WorldServer::SendChannelMessage(Client* from, const char* to, uint8 chan_num, uint32 guilddbid, uint8 language, const char* message, ...) { - if(!worldserver.Connected()) + if (!worldserver.Connected()) return false; va_list argptr; char buffer[512]; @@ -1930,19 +1933,21 @@ bool WorldServer::SendChannelMessage(Client* from, const char* to, uint8 chan_nu buffer[511] = '\0'; auto pack = new ServerPacket(ServerOP_ChannelMessage, sizeof(ServerChannelMessage_Struct) + strlen(buffer) + 1); - ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*) pack->pBuffer; + ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*)pack->pBuffer; if (from == 0) { strcpy(scm->from, "ZServer"); scm->fromadmin = 0; - } else { + } + else { strcpy(scm->from, from->GetName()); scm->fromadmin = from->Admin(); } if (to == 0) { scm->to[0] = 0; scm->deliverto[0] = '\0'; - } else { + } + else { strn0cpy(scm->to, to, sizeof(scm->to)); strn0cpy(scm->deliverto, to, sizeof(scm->deliverto)); } @@ -1983,7 +1988,7 @@ bool WorldServer::SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to } auto pack = new ServerPacket(ServerOP_EmoteMessage, sizeof(ServerEmoteMessage_Struct) + strlen(buffer) + 1); - ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*) pack->pBuffer; + ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer; sem->type = type; if (to != 0) strcpy(sem->to, to); @@ -1998,28 +2003,28 @@ bool WorldServer::SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to bool WorldServer::SendVoiceMacro(Client* From, uint32 Type, char* Target, uint32 MacroNumber, uint32 GroupOrRaidID) { - if(!worldserver.Connected() || !From) + if (!worldserver.Connected() || !From) return false; auto pack = new ServerPacket(ServerOP_VoiceMacro, sizeof(ServerVoiceMacro_Struct)); - ServerVoiceMacro_Struct* svm = (ServerVoiceMacro_Struct*) pack->pBuffer; + ServerVoiceMacro_Struct* svm = (ServerVoiceMacro_Struct*)pack->pBuffer; strcpy(svm->From, From->GetName()); - switch(Type) { + switch (Type) { - case VoiceMacroTell: - strcpy(svm->To, Target); - break; + case VoiceMacroTell: + strcpy(svm->To, Target); + break; - case VoiceMacroGroup: - svm->GroupID = GroupOrRaidID; - break; + case VoiceMacroGroup: + svm->GroupID = GroupOrRaidID; + break; - case VoiceMacroRaid: - svm->RaidID = GroupOrRaidID; - break; + case VoiceMacroRaid: + svm->RaidID = GroupOrRaidID; + break; } svm->Type = Type; @@ -2037,18 +2042,18 @@ bool WorldServer::SendVoiceMacro(Client* From, uint32 Type, char* Target, uint32 bool WorldServer::RezzPlayer(EQApplicationPacket* rpack, uint32 rezzexp, uint32 dbid, uint16 opcode) { - Log.Out(Logs::Detail, Logs::Spells, "WorldServer::RezzPlayer rezzexp is %i (0 is normal for RezzComplete", rezzexp); + Log(Logs::Detail, Logs::Spells, "WorldServer::RezzPlayer rezzexp is %i (0 is normal for RezzComplete", rezzexp); auto pack = new ServerPacket(ServerOP_RezzPlayer, sizeof(RezzPlayer_Struct)); - RezzPlayer_Struct* sem = (RezzPlayer_Struct*) pack->pBuffer; + RezzPlayer_Struct* sem = (RezzPlayer_Struct*)pack->pBuffer; sem->rezzopcode = opcode; - sem->rez = *(Resurrect_Struct*) rpack->pBuffer; + sem->rez = *(Resurrect_Struct*)rpack->pBuffer; sem->exp = rezzexp; sem->dbid = dbid; bool ret = SendPacket(pack); if (ret) - Log.Out(Logs::Detail, Logs::Spells, "Sending player rezz packet to world spellid:%i", sem->rez.spellid); + Log(Logs::Detail, Logs::Spells, "Sending player rezz packet to world spellid:%i", sem->rez.spellid); else - Log.Out(Logs::Detail, Logs::Spells, "NOT Sending player rezz packet to world"); + Log(Logs::Detail, Logs::Spells, "NOT Sending player rezz packet to world"); safe_delete(pack); return ret; @@ -2056,7 +2061,7 @@ bool WorldServer::RezzPlayer(EQApplicationPacket* rpack, uint32 rezzexp, uint32 void WorldServer::SendReloadTasks(int Command, int TaskID) { auto pack = new ServerPacket(ServerOP_ReloadTasks, sizeof(ReloadTasks_Struct)); - ReloadTasks_Struct* rts = (ReloadTasks_Struct*) pack->pBuffer; + ReloadTasks_Struct* rts = (ReloadTasks_Struct*)pack->pBuffer; rts->Command = Command; rts->Parameter = TaskID; @@ -2066,50 +2071,50 @@ void WorldServer::SendReloadTasks(int Command, int TaskID) { void WorldServer::HandleReloadTasks(ServerPacket *pack) { - ReloadTasks_Struct* rts = (ReloadTasks_Struct*) pack->pBuffer; + ReloadTasks_Struct* rts = (ReloadTasks_Struct*)pack->pBuffer; - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Zone received ServerOP_ReloadTasks from World, Command %i", rts->Command); + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Zone received ServerOP_ReloadTasks from World, Command %i", rts->Command); - switch(rts->Command) { - case RELOADTASKS: - entity_list.SaveAllClientsTaskState(); + switch (rts->Command) { + case RELOADTASKS: + entity_list.SaveAllClientsTaskState(); - if(rts->Parameter == 0) { - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload ALL tasks"); - safe_delete(taskmanager); - taskmanager = new TaskManager; - taskmanager->LoadTasks(); - if(zone) - taskmanager->LoadProximities(zone->GetZoneID()); - entity_list.ReloadAllClientsTaskState(); - } - else { - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload only task %i", rts->Parameter); - taskmanager->LoadTasks(rts->Parameter); - entity_list.ReloadAllClientsTaskState(rts->Parameter); - } - - break; - - case RELOADTASKPROXIMITIES: - if(zone) { - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task proximities"); + if (rts->Parameter == 0) { + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload ALL tasks"); + safe_delete(taskmanager); + taskmanager = new TaskManager; + taskmanager->LoadTasks(); + if (zone) taskmanager->LoadProximities(zone->GetZoneID()); - } - break; + entity_list.ReloadAllClientsTaskState(); + } + else { + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload only task %i", rts->Parameter); + taskmanager->LoadTasks(rts->Parameter); + entity_list.ReloadAllClientsTaskState(rts->Parameter); + } - case RELOADTASKGOALLISTS: - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task goal lists"); - taskmanager->ReloadGoalLists(); - break; + break; - case RELOADTASKSETS: - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task sets"); - taskmanager->LoadTaskSets(); - break; + case RELOADTASKPROXIMITIES: + if (zone) { + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task proximities"); + taskmanager->LoadProximities(zone->GetZoneID()); + } + break; - default: - Log.Out(Logs::General, Logs::Tasks, "[GLOBALLOAD] Unhandled ServerOP_ReloadTasks command %i", rts->Command); + case RELOADTASKGOALLISTS: + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task goal lists"); + taskmanager->ReloadGoalLists(); + break; + + case RELOADTASKSETS: + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task sets"); + taskmanager->LoadTaskSets(); + break; + + default: + Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Unhandled ServerOP_ReloadTasks command %i", rts->Command); } @@ -2121,13 +2126,13 @@ uint32 WorldServer::NextGroupID() { //this system wastes a lot of potential group IDs (~5%), but //if you are creating 2 billion groups in 1 run of the emu, //something else is wrong... - if(cur_groupid >= last_groupid) { + if (cur_groupid >= last_groupid) { //this is an error... This means that 50 groups were created before //1 packet could make the zone->world->zone trip... so let it error. - Log.Out(Logs::General, Logs::Error, "Ran out of group IDs before the server sent us more."); + Log(Logs::General, Logs::Error, "Ran out of group IDs before the server sent us more."); return(0); } - if(cur_groupid > (last_groupid - /*50*/995)) { + if (cur_groupid > (last_groupid - /*50*/995)) { //running low, request more auto pack = new ServerPacket(ServerOP_GroupIDReq); SendPacket(pack); @@ -2138,10 +2143,10 @@ uint32 WorldServer::NextGroupID() { } void WorldServer::UpdateLFP(uint32 LeaderID, uint8 Action, uint8 MatchFilter, uint32 FromLevel, uint32 ToLevel, uint32 Classes, - const char *Comments, GroupLFPMemberEntry *LFPMembers) { + const char *Comments, GroupLFPMemberEntry *LFPMembers) { auto pack = new ServerPacket(ServerOP_LFPUpdate, sizeof(ServerLFPUpdate_Struct)); - ServerLFPUpdate_Struct* sus = (ServerLFPUpdate_Struct*) pack->pBuffer; + ServerLFPUpdate_Struct* sus = (ServerLFPUpdate_Struct*)pack->pBuffer; sus->LeaderID = LeaderID; sus->Action = Action; @@ -2179,10 +2184,10 @@ void WorldServer::HandleLFGMatches(ServerPacket *pack) { Client* client = entity_list.GetClientByID(EntityID); - if(client) { + if (client) { ServerLFGMatchesResponse_Struct* smrs = (ServerLFGMatchesResponse_Struct*)Buffer; - for(int i=0; iName) + strlen(smrs->Comments); smrs++; } @@ -2195,7 +2200,7 @@ void WorldServer::HandleLFGMatches(ServerPacket *pack) { VARSTRUCT_ENCODE_TYPE(uint32, OutBuffer, 0x00074af); // Unknown - for(int i=0; iComments); VARSTRUCT_ENCODE_STRING(OutBuffer, smrs->Name); VARSTRUCT_ENCODE_TYPE(uint16, OutBuffer, smrs->Class_); @@ -2224,12 +2229,12 @@ void WorldServer::HandleLFPMatches(ServerPacket *pack) { Client* client = entity_list.GetClientByID(EntityID); - if(client) { - for(int i=0; iComments) + 11; - for(unsigned int j=0; jMembers[j].Name[0] != '\0') + if (smrs->Members[j].Name[0] != '\0') PacketLength += strlen(smrs->Members[j].Name) + 9; } smrs++; @@ -2242,12 +2247,12 @@ void WorldServer::HandleLFPMatches(ServerPacket *pack) { VARSTRUCT_ENCODE_TYPE(uint32, OutBuffer, 0x00074af); // Unknown - for(int i=0; iMembers[j].Name[0] != '\0') + for (unsigned int j = 0; jMembers[j].Name[0] != '\0') MemberCount++; VARSTRUCT_ENCODE_STRING(OutBuffer, smrs->Comments); @@ -2256,8 +2261,8 @@ void WorldServer::HandleLFPMatches(ServerPacket *pack) { VARSTRUCT_ENCODE_TYPE(uint32, OutBuffer, smrs->Classes); VARSTRUCT_ENCODE_TYPE(uint16, OutBuffer, MemberCount); - for(unsigned int j=0; jMembers[j].Name[0] != '\0') { + for (unsigned int j = 0; jMembers[j].Name[0] != '\0') { VARSTRUCT_ENCODE_STRING(OutBuffer, smrs->Members[j].Name); VARSTRUCT_ENCODE_TYPE(uint16, OutBuffer, smrs->Members[j].Class); VARSTRUCT_ENCODE_TYPE(uint16, OutBuffer, smrs->Members[j].Level); @@ -2278,7 +2283,7 @@ void WorldServer::RequestTellQueue(const char *who) return; auto pack = new ServerPacket(ServerOP_RequestTellQueue, sizeof(ServerRequestTellQueue_Struct)); - ServerRequestTellQueue_Struct* rtq = (ServerRequestTellQueue_Struct*) pack->pBuffer; + ServerRequestTellQueue_Struct* rtq = (ServerRequestTellQueue_Struct*)pack->pBuffer; strn0cpy(rtq->name, who, sizeof(rtq->name)); @@ -2286,4 +2291,3 @@ void WorldServer::RequestTellQueue(const char *who) safe_delete(pack); return; } - diff --git a/zone/zone.cpp b/zone/zone.cpp index 599e5e802..086754d55 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -88,7 +88,7 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { return false; } - Log.Out(Logs::General, Logs::Status, "Booting %s (%d:%d)", zonename, iZoneID, iInstanceID); + Log(Logs::General, Logs::Status, "Booting %s (%d:%d)", zonename, iZoneID, iInstanceID); numclients = 0; zone = new Zone(iZoneID, iInstanceID, zonename); @@ -113,13 +113,13 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { log_levels[i]=0; //set to zero on a bogue char } zone->loglevelvar = log_levels[0]; - Log.Out(Logs::General, Logs::Status, "General logging level: %i", zone->loglevelvar); + Log(Logs::General, Logs::Status, "General logging level: %i", zone->loglevelvar); zone->merchantvar = log_levels[1]; - Log.Out(Logs::General, Logs::Status, "Merchant logging level: %i", zone->merchantvar); + Log(Logs::General, Logs::Status, "Merchant logging level: %i", zone->merchantvar); zone->tradevar = log_levels[2]; - Log.Out(Logs::General, Logs::Status, "Trade logging level: %i", zone->tradevar); + Log(Logs::General, Logs::Status, "Trade logging level: %i", zone->tradevar); zone->lootvar = log_levels[3]; - Log.Out(Logs::General, Logs::Status, "Loot logging level: %i", zone->lootvar); + Log(Logs::General, Logs::Status, "Loot logging level: %i", zone->lootvar); } else { zone->loglevelvar = uint8(tmp_i); //continue supporting only command logging (for now) @@ -140,15 +140,15 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) { delete pack; } - Log.Out(Logs::General, Logs::Normal, "---- Zone server %s, listening on port:%i ----", zonename, ZoneConfig::get()->ZonePort); - Log.Out(Logs::General, Logs::Status, "Zone Bootup: %s (%i: %i)", zonename, iZoneID, iInstanceID); + Log(Logs::General, Logs::Normal, "---- Zone server %s, listening on port:%i ----", zonename, ZoneConfig::get()->ZonePort); + Log(Logs::General, Logs::Status, "Zone Bootup: %s (%i: %i)", zonename, iZoneID, iInstanceID); parse->Init(); UpdateWindowTitle(); zone->GetTimeSync(); /* Set Logging */ - Log.StartFileLogs(StringFormat("%s_version_%u_inst_id_%u_port_%u", zone->GetShortName(), zone->GetInstanceVersion(), zone->GetInstanceID(), ZoneConfig::get()->ZonePort)); + LogSys.StartFileLogs(StringFormat("%s_version_%u_inst_id_%u_port_%u", zone->GetShortName(), zone->GetInstanceVersion(), zone->GetInstanceID(), ZoneConfig::get()->ZonePort)); return true; } @@ -163,12 +163,12 @@ bool Zone::LoadZoneObjects() zoneid, instanceversion); auto results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error Loading Objects from DB: %s", + Log(Logs::General, Logs::Error, "Error Loading Objects from DB: %s", results.ErrorMessage().c_str()); return false; } - Log.Out(Logs::General, Logs::Status, "Loading Objects from DB..."); + Log(Logs::General, Logs::Status, "Loading Objects from DB..."); for (auto row = results.begin(); row != results.end(); ++row) { if (atoi(row[9]) == 0) { // Type == 0 - Static Object @@ -287,7 +287,7 @@ bool Zone::LoadGroundSpawns() { memset(&groundspawn, 0, sizeof(groundspawn)); int gsindex=0; - Log.Out(Logs::General, Logs::Status, "Loading Ground Spawns from DB..."); + Log(Logs::General, Logs::Status, "Loading Ground Spawns from DB..."); database.LoadGroundSpawns(zoneid, GetInstanceVersion(), &groundspawn); uint32 ix=0; char* name = nullptr; @@ -406,7 +406,7 @@ uint32 Zone::GetTempMerchantQuantity(uint32 NPCID, uint32 Slot) { } void Zone::LoadTempMerchantData() { - Log.Out(Logs::General, Logs::Status, "Loading Temporary Merchant Lists..."); + Log(Logs::General, Logs::Status, "Loading Temporary Merchant Lists..."); std::string query = StringFormat( "SELECT " "DISTINCT ml.npcid, " @@ -476,7 +476,7 @@ void Zone::LoadNewMerchantData(uint32 merchantid) { } void Zone::GetMerchantDataForZoneLoad() { - Log.Out(Logs::General, Logs::Status, "Loading Merchant Lists..."); + Log(Logs::General, Logs::Status, "Loading Merchant Lists..."); std::string query = StringFormat( "SELECT " "DISTINCT ml.merchantid, " @@ -499,7 +499,7 @@ void Zone::GetMerchantDataForZoneLoad() { std::map >::iterator cur; uint32 npcid = 0; if (results.RowCount() == 0) { - Log.Out(Logs::General, Logs::None, "No Merchant Data found for %s.", GetShortName()); + Log(Logs::General, Logs::None, "No Merchant Data found for %s.", GetShortName()); return; } for (auto row = results.begin(); row != results.end(); ++row) { @@ -548,8 +548,9 @@ void Zone::LoadMercTemplates(){ std::string query = "SELECT `class_id`, `proficiency_id`, `stance_id`, `isdefault` FROM " "`merc_stance_entries` ORDER BY `class_id`, `proficiency_id`, `stance_id`"; auto results = database.QueryDatabase(query); - if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Error in ZoneDatabase::LoadMercTemplates()"); + if (!results.Success()) { + Log(Logs::General, Logs::Error, "Error in ZoneDatabase::LoadMercTemplates()"); + } else { for (auto row = results.begin(); row != results.end(); ++row) { MercStanceInfo tempMercStanceInfo; @@ -572,7 +573,7 @@ void Zone::LoadMercTemplates(){ "ORDER BY MTyp.race_id, MS.class_id, MTyp.proficiency_id;"; results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error in ZoneDatabase::LoadMercTemplates()"); + Log(Logs::General, Logs::Error, "Error in ZoneDatabase::LoadMercTemplates()"); return; } @@ -616,7 +617,7 @@ void Zone::LoadLevelEXPMods(){ const std::string query = "SELECT level, exp_mod, aa_exp_mod FROM level_exp_mods"; auto results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error in ZoneDatabase::LoadEXPLevelMods()"); + Log(Logs::General, Logs::Error, "Error in ZoneDatabase::LoadEXPLevelMods()"); return; } @@ -640,7 +641,7 @@ void Zone::LoadMercSpells(){ "ORDER BY msl.class_id, msl.proficiency_id, msle.spell_type, msle.minlevel, msle.slot;"; auto results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error in Zone::LoadMercSpells()"); + Log(Logs::General, Logs::Error, "Error in Zone::LoadMercSpells()"); return; } @@ -661,7 +662,7 @@ void Zone::LoadMercSpells(){ merc_spells_list[classid].push_back(tempMercSpellEntry); } - Log.Out(Logs::General, Logs::Mercenaries, "Loaded %i merc spells.", merc_spells_list[1].size() + merc_spells_list[2].size() + merc_spells_list[9].size() + merc_spells_list[12].size()); + Log(Logs::General, Logs::Mercenaries, "Loaded %i merc spells.", merc_spells_list[1].size() + merc_spells_list[2].size() + merc_spells_list[9].size() + merc_spells_list[12].size()); } @@ -700,11 +701,11 @@ void Zone::Shutdown(bool quite) } zone->ldon_trap_entry_list.clear(); - Log.Out(Logs::General, Logs::Status, "Zone Shutdown: %s (%i)", zone->GetShortName(), zone->GetZoneID()); + Log(Logs::General, Logs::Status, "Zone Shutdown: %s (%i)", zone->GetShortName(), zone->GetZoneID()); petition_list.ClearPetitions(); zone->SetZoneHasCurrentTime(false); if (!quite) - Log.Out(Logs::General, Logs::Normal, "Zone shutdown: going to sleep"); + Log(Logs::General, Logs::Normal, "Zone shutdown: going to sleep"); is_zone_loaded = false; zone->ResetAuth(); @@ -713,24 +714,24 @@ void Zone::Shutdown(bool quite) parse->ReloadQuests(true); UpdateWindowTitle(); - Log.CloseFileLogs(); + LogSys.CloseFileLogs(); } void Zone::LoadZoneDoors(const char* zone, int16 version) { - Log.Out(Logs::General, Logs::Status, "Loading doors for %s ...", zone); + Log(Logs::General, Logs::Status, "Loading doors for %s ...", zone); uint32 maxid; int32 count = database.GetDoorsCount(&maxid, zone, version); if(count < 1) { - Log.Out(Logs::General, Logs::Status, "... No doors loaded."); + Log(Logs::General, Logs::Status, "... No doors loaded."); return; } auto dlist = new Door[count]; if(!database.LoadDoors(count, dlist, zone, version)) { - Log.Out(Logs::General, Logs::Error, "... Failed to load doors."); + Log(Logs::General, Logs::Error, "... Failed to load doors."); delete[] dlist; return; } @@ -740,7 +741,7 @@ void Zone::LoadZoneDoors(const char* zone, int16 version) for(r = 0; r < count; r++, d++) { auto newdoor = new Doors(d); entity_list.AddDoor(newdoor); - Log.Out(Logs::Detail, Logs::Doors, "Door Add to Entity List, index: %u db id: %u, door_id %u", r, dlist[r].db_id, dlist[r].door_id); + Log(Logs::Detail, Logs::Doors, "Door Add to Entity List, index: %u db id: %u, door_id %u", r, dlist[r].db_id, dlist[r].door_id); } delete[] dlist; } @@ -791,13 +792,15 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) database.GetZoneLongName(short_name, &long_name, file_name, &m_SafePoint.x, &m_SafePoint.y, &m_SafePoint.z, &pgraveyard_id, &pMaxClients); if(graveyard_id() > 0) { - Log.Out(Logs::General, Logs::None, "Graveyard ID is %i.", graveyard_id()); + Log(Logs::General, Logs::None, "Graveyard ID is %i.", graveyard_id()); bool GraveYardLoaded = database.GetZoneGraveyard(graveyard_id(), &pgraveyard_zoneid, &m_Graveyard.x, &m_Graveyard.y, &m_Graveyard.z, &m_Graveyard.w); - if(GraveYardLoaded) - Log.Out(Logs::General, Logs::None, "Loaded a graveyard for zone %s: graveyard zoneid is %u at %s.", short_name, graveyard_zoneid(), to_string(m_Graveyard).c_str()); - else - Log.Out(Logs::General, Logs::Error, "Unable to load the graveyard id %i for zone %s.", graveyard_id(), short_name); + if (GraveYardLoaded) { + Log(Logs::General, Logs::None, "Loaded a graveyard for zone %s: graveyard zoneid is %u at %s.", short_name, graveyard_zoneid(), to_string(m_Graveyard).c_str()); + } + else { + Log(Logs::General, Logs::Error, "Unable to load the graveyard id %i for zone %s.", graveyard_id(), short_name); + } } if (long_name == 0) { long_name = strcpy(new char[18], "Long zone missing"); @@ -805,7 +808,7 @@ Zone::Zone(uint32 in_zoneid, uint32 in_instanceid, const char* in_short_name) autoshutdown_timer.Start(AUTHENTICATION_TIMEOUT * 1000, false); Weather_Timer = new Timer(60000); Weather_Timer->Start(); - Log.Out(Logs::General, Logs::None, "The next weather check for zone: %s will be in %i seconds.", short_name, Weather_Timer->GetRemainingTime()/1000); + Log(Logs::General, Logs::None, "The next weather check for zone: %s will be in %i seconds.", short_name, Weather_Timer->GetRemainingTime()/1000); zone_weather = 0; weather_intensity = 0; blocked_spells = nullptr; @@ -892,59 +895,59 @@ bool Zone::Init(bool iStaticZone) { zone->watermap = WaterMap::LoadWaterMapfile(zone->map_name); zone->pathing = PathManager::LoadPathFile(zone->map_name); - Log.Out(Logs::General, Logs::Status, "Loading spawn conditions..."); + Log(Logs::General, Logs::Status, "Loading spawn conditions..."); if(!spawn_conditions.LoadSpawnConditions(short_name, instanceid)) { - Log.Out(Logs::General, Logs::Error, "Loading spawn conditions failed, continuing without them."); + Log(Logs::General, Logs::Error, "Loading spawn conditions failed, continuing without them."); } - Log.Out(Logs::General, Logs::Status, "Loading static zone points..."); + Log(Logs::General, Logs::Status, "Loading static zone points..."); if (!database.LoadStaticZonePoints(&zone_point_list, short_name, GetInstanceVersion())) { - Log.Out(Logs::General, Logs::Error, "Loading static zone points failed."); + Log(Logs::General, Logs::Error, "Loading static zone points failed."); return false; } - Log.Out(Logs::General, Logs::Status, "Loading spawn groups..."); + Log(Logs::General, Logs::Status, "Loading spawn groups..."); if (!database.LoadSpawnGroups(short_name, GetInstanceVersion(), &spawn_group_list)) { - Log.Out(Logs::General, Logs::Error, "Loading spawn groups failed."); + Log(Logs::General, Logs::Error, "Loading spawn groups failed."); return false; } - Log.Out(Logs::General, Logs::Status, "Loading spawn2 points..."); + Log(Logs::General, Logs::Status, "Loading spawn2 points..."); if (!database.PopulateZoneSpawnList(zoneid, spawn2_list, GetInstanceVersion())) { - Log.Out(Logs::General, Logs::Error, "Loading spawn2 points failed."); + Log(Logs::General, Logs::Error, "Loading spawn2 points failed."); return false; } - Log.Out(Logs::General, Logs::Status, "Loading player corpses..."); + Log(Logs::General, Logs::Status, "Loading player corpses..."); if (!database.LoadCharacterCorpses(zoneid, instanceid)) { - Log.Out(Logs::General, Logs::Error, "Loading player corpses failed."); + Log(Logs::General, Logs::Error, "Loading player corpses failed."); return false; } - Log.Out(Logs::General, Logs::Status, "Loading traps..."); + Log(Logs::General, Logs::Status, "Loading traps..."); if (!database.LoadTraps(short_name, GetInstanceVersion())) { - Log.Out(Logs::General, Logs::Error, "Loading traps failed."); + Log(Logs::General, Logs::Error, "Loading traps failed."); return false; } - Log.Out(Logs::General, Logs::Status, "Loading adventure flavor text..."); + Log(Logs::General, Logs::Status, "Loading adventure flavor text..."); LoadAdventureFlavor(); - Log.Out(Logs::General, Logs::Status, "Loading ground spawns..."); + Log(Logs::General, Logs::Status, "Loading ground spawns..."); if (!LoadGroundSpawns()) { - Log.Out(Logs::General, Logs::Error, "Loading ground spawns failed. continuing."); + Log(Logs::General, Logs::Error, "Loading ground spawns failed. continuing."); } - Log.Out(Logs::General, Logs::Status, "Loading World Objects from DB..."); + Log(Logs::General, Logs::Status, "Loading World Objects from DB..."); if (!LoadZoneObjects()) { - Log.Out(Logs::General, Logs::Error, "Loading World Objects failed. continuing."); + Log(Logs::General, Logs::Error, "Loading World Objects failed. continuing."); } - Log.Out(Logs::General, Logs::Status, "Flushing old respawn timers..."); + Log(Logs::General, Logs::Status, "Flushing old respawn timers..."); database.QueryDatabase("DELETE FROM `respawn_times` WHERE (`start` + `duration`) < UNIX_TIMESTAMP(NOW())"); //load up the zone's doors (prints inside) @@ -983,10 +986,10 @@ bool Zone::Init(bool iStaticZone) { petition_list.ClearPetitions(); petition_list.ReadDatabase(); - Log.Out(Logs::General, Logs::Status, "Loading timezone data..."); + Log(Logs::General, Logs::Status, "Loading timezone data..."); zone->zone_time.setEQTimeZone(database.GetZoneTZ(zoneid, GetInstanceVersion())); - Log.Out(Logs::General, Logs::Status, "Init Finished: ZoneID = %d, Time Offset = %d", zoneid, zone->zone_time.getEQTimeZone()); + Log(Logs::General, Logs::Status, "Init Finished: ZoneID = %d, Time Offset = %d", zoneid, zone->zone_time.getEQTimeZone()); LoadTickItems(); @@ -997,32 +1000,32 @@ bool Zone::Init(bool iStaticZone) { } void Zone::ReloadStaticData() { - Log.Out(Logs::General, Logs::Status, "Reloading Zone Static Data..."); + Log(Logs::General, Logs::Status, "Reloading Zone Static Data..."); - Log.Out(Logs::General, Logs::Status, "Reloading static zone points..."); + Log(Logs::General, Logs::Status, "Reloading static zone points..."); zone_point_list.Clear(); if (!database.LoadStaticZonePoints(&zone_point_list, GetShortName(), GetInstanceVersion())) { - Log.Out(Logs::General, Logs::Error, "Loading static zone points failed."); + Log(Logs::General, Logs::Error, "Loading static zone points failed."); } - Log.Out(Logs::General, Logs::Status, "Reloading traps..."); + Log(Logs::General, Logs::Status, "Reloading traps..."); entity_list.RemoveAllTraps(); if (!database.LoadTraps(GetShortName(), GetInstanceVersion())) { - Log.Out(Logs::General, Logs::Error, "Reloading traps failed."); + Log(Logs::General, Logs::Error, "Reloading traps failed."); } - Log.Out(Logs::General, Logs::Status, "Reloading ground spawns..."); + Log(Logs::General, Logs::Status, "Reloading ground spawns..."); if (!LoadGroundSpawns()) { - Log.Out(Logs::General, Logs::Error, "Reloading ground spawns failed. continuing."); + Log(Logs::General, Logs::Error, "Reloading ground spawns failed. continuing."); } entity_list.RemoveAllObjects(); - Log.Out(Logs::General, Logs::Status, "Reloading World Objects from DB..."); + Log(Logs::General, Logs::Status, "Reloading World Objects from DB..."); if (!LoadZoneObjects()) { - Log.Out(Logs::General, Logs::Error, "Reloading World Objects failed. continuing."); + Log(Logs::General, Logs::Error, "Reloading World Objects failed. continuing."); } entity_list.RemoveAllDoors(); @@ -1038,7 +1041,7 @@ void Zone::ReloadStaticData() { if (!LoadZoneCFG(zone->GetShortName(), zone->GetInstanceVersion(), true)) // try loading the zone name... LoadZoneCFG(zone->GetFileName(), zone->GetInstanceVersion()); // if that fails, try the file name, then load defaults - Log.Out(Logs::General, Logs::Status, "Zone Static Data Reloaded."); + Log(Logs::General, Logs::Status, "Zone Static Data Reloaded."); } bool Zone::LoadZoneCFG(const char* filename, uint16 instance_id, bool DontLoadDefault) @@ -1050,7 +1053,7 @@ bool Zone::LoadZoneCFG(const char* filename, uint16 instance_id, bool DontLoadDe if(!database.GetZoneCFG(database.GetZoneID(filename), 0, &newzone_data, can_bind, can_combat, can_levitate, can_castoutdoor, is_city, is_hotzone, allow_mercs, zone_type, default_ruleset, &map_name)) { - Log.Out(Logs::General, Logs::Error, "Error loading the Zone Config."); + Log(Logs::General, Logs::Error, "Error loading the Zone Config."); return false; } } @@ -1065,7 +1068,7 @@ bool Zone::LoadZoneCFG(const char* filename, uint16 instance_id, bool DontLoadDe if(!database.GetZoneCFG(database.GetZoneID(filename), 0, &newzone_data, can_bind, can_combat, can_levitate, can_castoutdoor, is_city, is_hotzone, allow_mercs, zone_type, default_ruleset, &map_name)) { - Log.Out(Logs::General, Logs::Error, "Error loading the Zone Config."); + Log(Logs::General, Logs::Error, "Error loading the Zone Config."); return false; } } @@ -1076,7 +1079,7 @@ bool Zone::LoadZoneCFG(const char* filename, uint16 instance_id, bool DontLoadDe strcpy(newzone_data.zone_long_name, GetLongName()); strcpy(newzone_data.zone_short_name2, GetShortName()); - Log.Out(Logs::General, Logs::Status, "Successfully loaded Zone Config."); + Log(Logs::General, Logs::Status, "Successfully loaded Zone Config."); return true; } @@ -1379,11 +1382,11 @@ void Zone::ChangeWeather() weathertimer = weatherTimerRule*1000; Weather_Timer->Start(weathertimer); } - Log.Out(Logs::General, Logs::None, "The next weather check for zone: %s will be in %i seconds.", zone->GetShortName(), Weather_Timer->GetRemainingTime()/1000); + Log(Logs::General, Logs::None, "The next weather check for zone: %s will be in %i seconds.", zone->GetShortName(), Weather_Timer->GetRemainingTime()/1000); } else { - Log.Out(Logs::General, Logs::None, "The weather for zone: %s has changed. Old weather was = %i. New weather is = %i The next check will be in %i seconds. Rain chance: %i, Rain duration: %i, Snow chance %i, Snow duration: %i", zone->GetShortName(), tmpOldWeather, zone_weather,Weather_Timer->GetRemainingTime()/1000,rainchance,rainduration,snowchance,snowduration); + Log(Logs::General, Logs::None, "The weather for zone: %s has changed. Old weather was = %i. New weather is = %i The next check will be in %i seconds. Rain chance: %i, Rain duration: %i, Snow chance %i, Snow duration: %i", zone->GetShortName(), tmpOldWeather, zone_weather,Weather_Timer->GetRemainingTime()/1000,rainchance,rainduration,snowchance,snowduration); this->weatherSend(); if (zone->weather_intensity == 0) { @@ -1471,7 +1474,7 @@ void Zone::RepopClose(const glm::vec4& client_position, uint32 repop_distance) quest_manager.ClearAllTimers(); if (!database.PopulateZoneSpawnListClose(zoneid, spawn2_list, GetInstanceVersion(), client_position, repop_distance)) - Log.Out(Logs::General, Logs::None, "Error in Zone::Repop: database.PopulateZoneSpawnList failed"); + Log(Logs::General, Logs::None, "Error in Zone::Repop: database.PopulateZoneSpawnList failed"); initgrids_timer.Start(); @@ -1493,7 +1496,7 @@ void Zone::Repop(uint32 delay) { quest_manager.ClearAllTimers(); if (!database.PopulateZoneSpawnList(zoneid, spawn2_list, GetInstanceVersion(), delay)) - Log.Out(Logs::General, Logs::None, "Error in Zone::Repop: database.PopulateZoneSpawnList failed"); + Log(Logs::General, Logs::None, "Error in Zone::Repop: database.PopulateZoneSpawnList failed"); initgrids_timer.Start(); @@ -1541,7 +1544,7 @@ void Zone::SetTime(uint8 hour, uint8 minute, bool update_world /*= true*/) /* By Default we update worlds time, but we can optionally no update world which updates the rest of the zone servers */ if (update_world){ - Log.Out(Logs::General, Logs::Zone_Server, "Setting master time on world server to: %d:%d (%d)\n", hour, minute, (int)eq_time_of_day->start_realtime); + Log(Logs::General, Logs::Zone_Server, "Setting master time on world server to: %d:%d (%d)\n", hour, minute, (int)eq_time_of_day->start_realtime); worldserver.SendPacket(pack); /* Set Time Localization Flag */ @@ -1550,7 +1553,7 @@ void Zone::SetTime(uint8 hour, uint8 minute, bool update_world /*= true*/) /* When we don't update world, we are localizing ourselves, we become disjointed from normal syncs and set time locally */ else{ - Log.Out(Logs::General, Logs::Zone_Server, "Setting zone localized time..."); + Log(Logs::General, Logs::Zone_Server, "Setting zone localized time..."); zone->zone_time.SetCurrentEQTimeOfDay(eq_time_of_day->start_eqtime, eq_time_of_day->start_realtime); auto outapp = new EQApplicationPacket(OP_TimeOfDay, sizeof(TimeOfDay_Struct)); @@ -1604,8 +1607,8 @@ ZonePoint* Zone::GetClosestZonePoint(const glm::vec3& location, uint32 to, Clien { if(client) client->CheatDetected(MQZoneUnknownDest, location.x, location.y, location.z); // Someone is trying to use /zone - Log.Out(Logs::General, Logs::Status, "WARNING: Closest zone point for zone id %d is %f, you might need to update your zone_points table if you dont arrive at the right spot.", to, closest_dist); - Log.Out(Logs::General, Logs::Status, ". %s", to_string(location).c_str()); + Log(Logs::General, Logs::Status, "WARNING: Closest zone point for zone id %d is %f, you might need to update your zone_points table if you dont arrive at the right spot.", to, closest_dist); + Log(Logs::General, Logs::Status, ". %s", to_string(location).c_str()); } if(closest_dist > max_distance2) @@ -1881,7 +1884,7 @@ void Zone::LoadBlockedSpells(uint32 zoneid) blocked_spells = new ZoneSpellsBlocked[totalBS]; if(!database.LoadBlockedSpells(totalBS, blocked_spells, zoneid)) { - Log.Out(Logs::General, Logs::Error, "... Failed to load blocked spells."); + Log(Logs::General, Logs::Error, "... Failed to load blocked spells."); ClearBlockedSpells(); } } diff --git a/zone/zone.h b/zone/zone.h index d7ecc6237..a3e9f59b4 100644 --- a/zone/zone.h +++ b/zone/zone.h @@ -280,13 +280,13 @@ public: if (message.find("\n") != std::string::npos){ auto message_split = SplitString(message, '\n'); - entity_list.MessageStatus(0, 80, Log.GetGMSayColorFromCategory(log_category), "%s", message_split[0].c_str()); + entity_list.MessageStatus(0, 80, LogSys.GetGMSayColorFromCategory(log_category), "%s", message_split[0].c_str()); for (size_t iter = 1; iter < message_split.size(); ++iter) { - entity_list.MessageStatus(0, 80, Log.GetGMSayColorFromCategory(log_category), "--- %s", message_split[iter].c_str()); + entity_list.MessageStatus(0, 80, LogSys.GetGMSayColorFromCategory(log_category), "--- %s", message_split[iter].c_str()); } } else{ - entity_list.MessageStatus(0, 80, Log.GetGMSayColorFromCategory(log_category), "%s", message.c_str()); + entity_list.MessageStatus(0, 80, LogSys.GetGMSayColorFromCategory(log_category), "%s", message.c_str()); } } diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index a36042610..dae62340d 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -197,7 +197,7 @@ bool ZoneDatabase::GetZoneCFG(uint32 zoneid, uint16 instance_id, NewZone_Struct //not in the DB yet: zone_data->gravity = atof(row[56]); - Log.Out(Logs::General, Logs::Debug, "Zone Gravity is %f", zone_data->gravity); + Log(Logs::General, Logs::Debug, "Zone Gravity is %f", zone_data->gravity); allow_mercs = true; int bindable = 0; @@ -471,7 +471,7 @@ void ZoneDatabase::GetEventLogs(const char* name,char* target,uint32 account_id, void ZoneDatabase::LoadWorldContainer(uint32 parentid, EQEmu::ItemInstance* container) { if (!container) { - Log.Out(Logs::General, Logs::Error, "Programming error: LoadWorldContainer passed nullptr pointer"); + Log(Logs::General, Logs::Error, "Programming error: LoadWorldContainer passed nullptr pointer"); return; } @@ -479,7 +479,7 @@ void ZoneDatabase::LoadWorldContainer(uint32 parentid, EQEmu::ItemInstance* cont "FROM object_contents WHERE parentid = %i", parentid); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error in DB::LoadWorldContainer: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in DB::LoadWorldContainer: %s", results.ErrorMessage().c_str()); return; } @@ -544,7 +544,7 @@ void ZoneDatabase::SaveWorldContainer(uint32 zone_id, uint32 parent_id, const EQ augslot[0], augslot[1], augslot[2], augslot[3], augslot[4], augslot[5]); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Error in ZoneDatabase::SaveWorldContainer: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in ZoneDatabase::SaveWorldContainer: %s", results.ErrorMessage().c_str()); } @@ -556,7 +556,7 @@ void ZoneDatabase::DeleteWorldContainer(uint32 parent_id, uint32 zone_id) std::string query = StringFormat("DELETE FROM object_contents WHERE parentid = %i AND zoneid = %i", parent_id, zone_id); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::General, Logs::Error, "Error in ZoneDatabase::DeleteWorldContainer: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error in ZoneDatabase::DeleteWorldContainer: %s", results.ErrorMessage().c_str()); } @@ -568,14 +568,14 @@ Trader_Struct* ZoneDatabase::LoadTraderItem(uint32 char_id) std::string query = StringFormat("SELECT * FROM trader WHERE char_id = %i ORDER BY slot_id LIMIT 80", char_id); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::Detail, Logs::Trading, "Failed to load trader information!\n"); + Log(Logs::Detail, Logs::Trading, "Failed to load trader information!\n"); return loadti; } loadti->Code = BazaarTrader_ShowItems; for (auto row = results.begin(); row != results.end(); ++row) { if (atoi(row[5]) >= 80 || atoi(row[4]) < 0) { - Log.Out(Logs::Detail, Logs::Trading, "Bad Slot number when trying to load trader information!\n"); + Log(Logs::Detail, Logs::Trading, "Bad Slot number when trying to load trader information!\n"); continue; } @@ -593,13 +593,13 @@ TraderCharges_Struct* ZoneDatabase::LoadTraderItemWithCharges(uint32 char_id) std::string query = StringFormat("SELECT * FROM trader WHERE char_id=%i ORDER BY slot_id LIMIT 80", char_id); auto results = QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::Detail, Logs::Trading, "Failed to load trader information!\n"); + Log(Logs::Detail, Logs::Trading, "Failed to load trader information!\n"); return loadti; } for (auto row = results.begin(); row != results.end(); ++row) { if (atoi(row[5]) >= 80 || atoi(row[5]) < 0) { - Log.Out(Logs::Detail, Logs::Trading, "Bad Slot number when trying to load trader information!\n"); + Log(Logs::Detail, Logs::Trading, "Bad Slot number when trying to load trader information!\n"); continue; } @@ -619,7 +619,7 @@ EQEmu::ItemInstance* ZoneDatabase::LoadSingleTraderItem(uint32 CharID, int Seria return nullptr; if (results.RowCount() == 0) { - Log.Out(Logs::Detail, Logs::Trading, "Bad result from query\n"); fflush(stdout); + Log(Logs::Detail, Logs::Trading, "Bad result from query\n"); fflush(stdout); return nullptr; } @@ -632,7 +632,7 @@ EQEmu::ItemInstance* ZoneDatabase::LoadSingleTraderItem(uint32 CharID, int Seria const EQEmu::ItemData *item = database.GetItem(ItemID); if(!item) { - Log.Out(Logs::Detail, Logs::Trading, "Unable to create item\n"); + Log(Logs::Detail, Logs::Trading, "Unable to create item\n"); fflush(stdout); return nullptr; } @@ -642,7 +642,7 @@ EQEmu::ItemInstance* ZoneDatabase::LoadSingleTraderItem(uint32 CharID, int Seria EQEmu::ItemInstance* inst = database.CreateItem(item); if(!inst) { - Log.Out(Logs::Detail, Logs::Trading, "Unable to create item instance\n"); + Log(Logs::Detail, Logs::Trading, "Unable to create item instance\n"); fflush(stdout); return nullptr; } @@ -664,25 +664,25 @@ void ZoneDatabase::SaveTraderItem(uint32 CharID, uint32 ItemID, uint32 SerialNum CharID, ItemID, SerialNumber, Charges, ItemCost, Slot); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to save trader item: %i for char_id: %i, the error was: %s\n", ItemID, CharID, results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to save trader item: %i for char_id: %i, the error was: %s\n", ItemID, CharID, results.ErrorMessage().c_str()); } void ZoneDatabase::UpdateTraderItemCharges(int CharID, uint32 SerialNumber, int32 Charges) { - Log.Out(Logs::Detail, Logs::Trading, "ZoneDatabase::UpdateTraderItemCharges(%i, %i, %i)", CharID, SerialNumber, Charges); + Log(Logs::Detail, Logs::Trading, "ZoneDatabase::UpdateTraderItemCharges(%i, %i, %i)", CharID, SerialNumber, Charges); std::string query = StringFormat("UPDATE trader SET charges = %i WHERE char_id = %i AND serialnumber = %i", Charges, CharID, SerialNumber); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to update charges for trader item: %i for char_id: %i, the error was: %s\n", + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to update charges for trader item: %i for char_id: %i, the error was: %s\n", SerialNumber, CharID, results.ErrorMessage().c_str()); } void ZoneDatabase::UpdateTraderItemPrice(int CharID, uint32 ItemID, uint32 Charges, uint32 NewPrice) { - Log.Out(Logs::Detail, Logs::Trading, "ZoneDatabase::UpdateTraderPrice(%i, %i, %i, %i)", CharID, ItemID, Charges, NewPrice); + Log(Logs::Detail, Logs::Trading, "ZoneDatabase::UpdateTraderPrice(%i, %i, %i, %i)", CharID, ItemID, Charges, NewPrice); const EQEmu::ItemData *item = database.GetItem(ItemID); @@ -690,12 +690,12 @@ void ZoneDatabase::UpdateTraderItemPrice(int CharID, uint32 ItemID, uint32 Charg return; if(NewPrice == 0) { - Log.Out(Logs::Detail, Logs::Trading, "Removing Trader items from the DB for CharID %i, ItemID %i", CharID, ItemID); + Log(Logs::Detail, Logs::Trading, "Removing Trader items from the DB for CharID %i, ItemID %i", CharID, ItemID); std::string query = StringFormat("DELETE FROM trader WHERE char_id = %i AND item_id = %i",CharID, ItemID); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to remove trader item(s): %i for char_id: %i, the error was: %s\n", ItemID, CharID, results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to remove trader item(s): %i for char_id: %i, the error was: %s\n", ItemID, CharID, results.ErrorMessage().c_str()); return; } @@ -706,7 +706,7 @@ void ZoneDatabase::UpdateTraderItemPrice(int CharID, uint32 ItemID, uint32 Charg NewPrice, CharID, ItemID, Charges); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to update price for trader item: %i for char_id: %i, the error was: %s\n", ItemID, CharID, results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to update price for trader item: %i for char_id: %i, the error was: %s\n", ItemID, CharID, results.ErrorMessage().c_str()); return; } @@ -716,7 +716,7 @@ void ZoneDatabase::UpdateTraderItemPrice(int CharID, uint32 ItemID, uint32 Charg NewPrice, CharID, ItemID); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to update price for trader item: %i for char_id: %i, the error was: %s\n", ItemID, CharID, results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to update price for trader item: %i for char_id: %i, the error was: %s\n", ItemID, CharID, results.ErrorMessage().c_str()); } void ZoneDatabase::DeleteTraderItem(uint32 char_id){ @@ -725,7 +725,7 @@ void ZoneDatabase::DeleteTraderItem(uint32 char_id){ const std::string query = "DELETE FROM trader"; auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to delete all trader items data, the error was: %s\n", results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to delete all trader items data, the error was: %s\n", results.ErrorMessage().c_str()); return; } @@ -733,7 +733,7 @@ void ZoneDatabase::DeleteTraderItem(uint32 char_id){ std::string query = StringFormat("DELETE FROM trader WHERE char_id = %i", char_id); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to delete trader item data for char_id: %i, the error was: %s\n", char_id, results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to delete trader item data for char_id: %i, the error was: %s\n", char_id, results.ErrorMessage().c_str()); } void ZoneDatabase::DeleteTraderItem(uint32 CharID,uint16 SlotID) { @@ -741,7 +741,7 @@ void ZoneDatabase::DeleteTraderItem(uint32 CharID,uint16 SlotID) { std::string query = StringFormat("DELETE FROM trader WHERE char_id = %i And slot_id = %i", CharID, SlotID); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to delete trader item data for char_id: %i, the error was: %s\n",CharID, results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to delete trader item data for char_id: %i, the error was: %s\n",CharID, results.ErrorMessage().c_str()); } void ZoneDatabase::DeleteBuyLines(uint32 CharID) { @@ -750,7 +750,7 @@ void ZoneDatabase::DeleteBuyLines(uint32 CharID) { const std::string query = "DELETE FROM buyer"; auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to delete all buyer items data, the error was: %s\n",results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to delete all buyer items data, the error was: %s\n",results.ErrorMessage().c_str()); return; } @@ -758,7 +758,7 @@ void ZoneDatabase::DeleteBuyLines(uint32 CharID) { std::string query = StringFormat("DELETE FROM buyer WHERE charid = %i", CharID); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to delete buyer item data for charid: %i, the error was: %s\n",CharID,results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to delete buyer item data for charid: %i, the error was: %s\n",CharID,results.ErrorMessage().c_str()); } @@ -767,7 +767,7 @@ void ZoneDatabase::AddBuyLine(uint32 CharID, uint32 BuySlot, uint32 ItemID, cons CharID, BuySlot, ItemID, ItemName, Quantity, Price); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to save buline item: %i for char_id: %i, the error was: %s\n", ItemID, CharID, results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to save buline item: %i for char_id: %i, the error was: %s\n", ItemID, CharID, results.ErrorMessage().c_str()); } @@ -775,7 +775,7 @@ void ZoneDatabase::RemoveBuyLine(uint32 CharID, uint32 BuySlot) { std::string query = StringFormat("DELETE FROM buyer WHERE charid = %i AND buyslot = %i", CharID, BuySlot); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to delete buyslot %i for charid: %i, the error was: %s\n", BuySlot, CharID, results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to delete buyslot %i for charid: %i, the error was: %s\n", BuySlot, CharID, results.ErrorMessage().c_str()); } @@ -788,7 +788,7 @@ void ZoneDatabase::UpdateBuyLine(uint32 CharID, uint32 BuySlot, uint32 Quantity) std::string query = StringFormat("UPDATE buyer SET quantity = %i WHERE charid = %i AND buyslot = %i", Quantity, CharID, BuySlot); auto results = QueryDatabase(query); if (!results.Success()) - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Failed to update quantity in buyslot %i for charid: %i, the error was: %s\n", BuySlot, CharID, results.ErrorMessage().c_str()); + Log(Logs::Detail, Logs::None, "[CLIENT] Failed to update quantity in buyslot %i for charid: %i, the error was: %s\n", BuySlot, CharID, results.ErrorMessage().c_str()); } @@ -1288,7 +1288,7 @@ bool ZoneDatabase::LoadCharacterBindPoint(uint32 character_id, PlayerProfile_Str bool ZoneDatabase::SaveCharacterLanguage(uint32 character_id, uint32 lang_id, uint32 value){ std::string query = StringFormat("REPLACE INTO `character_languages` (id, lang_id, value) VALUES (%u, %u, %u)", character_id, lang_id, value); QueryDatabase(query); - Log.Out(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterLanguage for character ID: %i, lang_id:%u value:%u done", character_id, lang_id, value); + Log(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterLanguage for character ID: %i, lang_id:%u value:%u done", character_id, lang_id, value); return true; } @@ -1300,13 +1300,13 @@ bool ZoneDatabase::SaveCharacterBindPoint(uint32 character_id, const BindStruct "%u, %u, %f, %f, %f, %f, %i)", character_id, bind.zoneId, bind.instance_id, bind.x, bind.y, bind.z, bind.heading, bind_num); - Log.Out(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterBindPoint for character ID: %i zone_id: %u " + Log(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterBindPoint for character ID: %i zone_id: %u " "instance_id: %u position: %f %f %f %f bind_num: %u", character_id, bind.zoneId, bind.instance_id, bind.x, bind.y, bind.z, bind.heading, bind_num); auto results = QueryDatabase(query); if (!results.RowsAffected()) - Log.Out(Logs::General, Logs::None, "ERROR Bind Home Save: %s. %s", results.ErrorMessage().c_str(), + Log(Logs::General, Logs::None, "ERROR Bind Home Save: %s. %s", results.ErrorMessage().c_str(), query.c_str()); return true; @@ -1318,20 +1318,20 @@ bool ZoneDatabase::SaveCharacterMaterialColor(uint32 character_id, uint32 slot_i uint8 blue = (color & 0x000000FF); std::string query = StringFormat("REPLACE INTO `character_material` (id, slot, red, green, blue, color, use_tint) VALUES (%u, %u, %u, %u, %u, %u, 255)", character_id, slot_id, red, green, blue, color); auto results = QueryDatabase(query); - Log.Out(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterMaterialColor for character ID: %i, slot_id: %u color: %u done", character_id, slot_id, color); + Log(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterMaterialColor for character ID: %i, slot_id: %u color: %u done", character_id, slot_id, color); return true; } bool ZoneDatabase::SaveCharacterSkill(uint32 character_id, uint32 skill_id, uint32 value){ std::string query = StringFormat("REPLACE INTO `character_skills` (id, skill_id, value) VALUES (%u, %u, %u)", character_id, skill_id, value); auto results = QueryDatabase(query); - Log.Out(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterSkill for character ID: %i, skill_id:%u value:%u done", character_id, skill_id, value); + Log(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterSkill for character ID: %i, skill_id:%u value:%u done", character_id, skill_id, value); return true; } bool ZoneDatabase::SaveCharacterDisc(uint32 character_id, uint32 slot_id, uint32 disc_id){ std::string query = StringFormat("REPLACE INTO `character_disciplines` (id, slot_id, disc_id) VALUES (%u, %u, %u)", character_id, slot_id, disc_id); auto results = QueryDatabase(query); - Log.Out(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterDisc for character ID: %i, slot:%u disc_id:%u done", character_id, slot_id, disc_id); + Log(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterDisc for character ID: %i, slot:%u disc_id:%u done", character_id, slot_id, disc_id); return true; } @@ -1343,7 +1343,7 @@ bool ZoneDatabase::SaveCharacterTribute(uint32 character_id, PlayerProfile_Struc if (pp->tributes[i].tribute > 0 && pp->tributes[i].tribute != TRIBUTE_NONE){ std::string query = StringFormat("REPLACE INTO `character_tribute` (id, tier, tribute) VALUES (%u, %u, %u)", character_id, pp->tributes[i].tier, pp->tributes[i].tribute); QueryDatabase(query); - Log.Out(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterTribute for character ID: %i, tier:%u tribute:%u done", character_id, pp->tributes[i].tier, pp->tributes[i].tribute); + Log(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterTribute for character ID: %i, tier:%u tribute:%u done", character_id, pp->tributes[i].tier, pp->tributes[i].tribute); } } return true; @@ -1355,7 +1355,7 @@ bool ZoneDatabase::SaveCharacterBandolier(uint32 character_id, uint8 bandolier_i DoEscapeString(bandolier_name_esc, bandolier_name, strlen(bandolier_name)); std::string query = StringFormat("REPLACE INTO `character_bandolier` (id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name) VALUES (%u, %u, %u, %u, %u,'%s')", character_id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name_esc); auto results = QueryDatabase(query); - Log.Out(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterBandolier for character ID: %i, bandolier_id: %u, bandolier_slot: %u item_id: %u, icon:%u band_name:%s done", character_id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name); + Log(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterBandolier for character ID: %i, bandolier_id: %u, bandolier_slot: %u item_id: %u, icon:%u band_name:%s done", character_id, bandolier_id, bandolier_slot, item_id, icon, bandolier_name); return true; } @@ -1427,7 +1427,7 @@ bool ZoneDatabase::SaveCharacterInventorySnapshot(uint32 character_id){ character_id ); auto results = database.QueryDatabase(query); - Log.Out(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterInventorySnapshot %i (%s)", character_id, (results.Success() ? "pass" : "fail")); + Log(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterInventorySnapshot %i (%s)", character_id, (results.Success() ? "pass" : "fail")); return results.Success(); } @@ -1722,7 +1722,7 @@ bool ZoneDatabase::SaveCharacterData(uint32 character_id, uint32 account_id, Pla m_epp->last_invsnapshot_time ); auto results = database.QueryDatabase(query); - Log.Out(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterData %i, done... Took %f seconds", character_id, ((float)(std::clock() - t)) / CLOCKS_PER_SEC); + Log(Logs::General, Logs::None, "ZoneDatabase::SaveCharacterData %i, done... Took %f seconds", character_id, ((float)(std::clock() - t)) / CLOCKS_PER_SEC); return true; } @@ -1763,7 +1763,7 @@ bool ZoneDatabase::SaveCharacterCurrency(uint32 character_id, PlayerProfile_Stru pp->currentEbonCrystals, pp->careerEbonCrystals); auto results = database.QueryDatabase(query); - Log.Out(Logs::General, Logs::None, "Saving Currency for character ID: %i, done", character_id); + Log(Logs::General, Logs::None, "Saving Currency for character ID: %i, done", character_id); return true; } @@ -1772,7 +1772,7 @@ bool ZoneDatabase::SaveCharacterAA(uint32 character_id, uint32 aa_id, uint32 cur " VALUES (%u, %u, %u, %u)", character_id, aa_id, current_level, charges); auto results = QueryDatabase(rquery); - Log.Out(Logs::General, Logs::None, "Saving AA for character ID: %u, aa_id: %u current_level: %u", character_id, aa_id, current_level); + Log(Logs::General, Logs::None, "Saving AA for character ID: %u, aa_id: %u current_level: %u", character_id, aa_id, current_level); return true; } @@ -1859,7 +1859,7 @@ const NPCType* ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load std::string where_condition = ""; if (bulk_load){ - Log.Out(Logs::General, Logs::Debug, "Performing bulk NPC Types load"); + Log(Logs::General, Logs::Debug, "Performing bulk NPC Types load"); where_condition = StringFormat( "INNER JOIN spawnentry ON npc_types.id = spawnentry.npcID " "INNER JOIN spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID " @@ -2547,7 +2547,7 @@ void ZoneDatabase::SaveMercBuffs(Merc *merc) { std::string query = StringFormat("DELETE FROM merc_buffs WHERE MercId = %u", merc->GetMercID()); auto results = database.QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error While Deleting Merc Buffs before save: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error While Deleting Merc Buffs before save: %s", results.ErrorMessage().c_str()); return; } @@ -2573,7 +2573,7 @@ void ZoneDatabase::SaveMercBuffs(Merc *merc) { buffs[buffCount].caston_z, buffs[buffCount].ExtraDIChance); results = database.QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error Saving Merc Buffs: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error Saving Merc Buffs: %s", results.ErrorMessage().c_str()); break; } } @@ -2592,7 +2592,7 @@ void ZoneDatabase::LoadMercBuffs(Merc *merc) { merc->GetMercID()); auto results = database.QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error Loading Merc Buffs: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error Loading Merc Buffs: %s", results.ErrorMessage().c_str()); return; } @@ -2637,7 +2637,7 @@ void ZoneDatabase::LoadMercBuffs(Merc *merc) { query = StringFormat("DELETE FROM merc_buffs WHERE MercId = %u", merc->GetMercID()); results = database.QueryDatabase(query); if(!results.Success()) - Log.Out(Logs::General, Logs::Error, "Error Loading Merc Buffs: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error Loading Merc Buffs: %s", results.ErrorMessage().c_str()); } @@ -2653,14 +2653,14 @@ bool ZoneDatabase::DeleteMerc(uint32 merc_id) { auto results = database.QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error Deleting Merc Buffs: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error Deleting Merc Buffs: %s", results.ErrorMessage().c_str()); } query = StringFormat("DELETE FROM mercs WHERE MercID = '%u'", merc_id); results = database.QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error Deleting Merc: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error Deleting Merc: %s", results.ErrorMessage().c_str()); return false; } @@ -2678,7 +2678,7 @@ void ZoneDatabase::LoadMercEquipment(Merc *merc) { merc->GetLevel(), merc->GetLevel()); auto results = database.QueryDatabase(query); if(!results.Success()) { - Log.Out(Logs::General, Logs::Error, "Error Loading Merc Inventory: %s", results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "Error Loading Merc Inventory: %s", results.ErrorMessage().c_str()); return; } @@ -2889,7 +2889,7 @@ int32 ZoneDatabase::GetBlockedSpellsCount(uint32 zoneid) bool ZoneDatabase::LoadBlockedSpells(int32 blockedSpellsCount, ZoneSpellsBlocked* into, uint32 zoneid) { - Log.Out(Logs::General, Logs::Status, "Loading Blocked Spells from database..."); + Log(Logs::General, Logs::Status, "Loading Blocked Spells from database..."); std::string query = StringFormat("SELECT id, spellid, type, x, y, z, x_diff, y_diff, z_diff, message " "FROM blocked_spells WHERE zoneid = %d ORDER BY id ASC", zoneid); @@ -3980,7 +3980,7 @@ Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_z corpse->SetDecayTimer(RuleI(Character, CorpseDecayTimeMS)); corpse->Spawn(); if (!UnburyCharacterCorpse(corpse->GetCorpseDBID(), dest_zone_id, dest_instance_id, position)) - Log.Out(Logs::General, Logs::Error, "Unable to unbury a summoned player corpse for character id %u.", char_id); + Log(Logs::General, Logs::Error, "Unable to unbury a summoned player corpse for character id %u.", char_id); } return corpse; @@ -4019,7 +4019,7 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id ++CorpseCount; } else{ - Log.Out(Logs::General, Logs::Error, "Unable to construct a player corpse for character id %u.", char_id); + Log(Logs::General, Logs::Error, "Unable to construct a player corpse for character id %u.", char_id); } } diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 677dd3d18..c7be0a37e 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -44,12 +44,12 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { zoning = true; if (app->size != sizeof(ZoneChange_Struct)) { - Log.Out(Logs::General, Logs::None, "Wrong size: OP_ZoneChange, size=%d, expected %d", app->size, sizeof(ZoneChange_Struct)); + Log(Logs::General, Logs::None, "Wrong size: OP_ZoneChange, size=%d, expected %d", app->size, sizeof(ZoneChange_Struct)); return; } #if EQDEBUG >= 5 - Log.Out(Logs::General, Logs::None, "Zone request from %s", GetName()); + Log(Logs::General, Logs::None, "Zone request from %s", GetName()); DumpPacket(app); #endif ZoneChange_Struct* zc=(ZoneChange_Struct*)app->pBuffer; @@ -97,7 +97,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { CheatDetected(MQZone, zc->x, zc->y, zc->z); Message(13, "Invalid unsolicited zone request."); - Log.Out(Logs::General, Logs::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%d'.", GetName(), target_zone_id); + Log(Logs::General, Logs::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%d'.", GetName(), target_zone_id); SendZoneCancel(zc); return; } @@ -129,7 +129,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { //if we didnt get a zone point, or its to a different zone, //then we assume this is invalid. if(!zone_point || zone_point->target_zone_id != target_zone_id) { - Log.Out(Logs::General, Logs::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%d'.", GetName(), target_zone_id); + Log(Logs::General, Logs::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%d'.", GetName(), target_zone_id); CheatDetected(MQGate, zc->x, zc->y, zc->z); SendZoneCancel(zc); return; @@ -160,7 +160,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { if(target_zone_name == nullptr) { //invalid zone... Message(13, "Invalid target zone ID."); - Log.Out(Logs::General, Logs::Error, "Zoning %s: Unable to get zone name for zone id '%d'.", GetName(), target_zone_id); + Log(Logs::General, Logs::Error, "Zoning %s: Unable to get zone name for zone id '%d'.", GetName(), target_zone_id); SendZoneCancel(zc); return; } @@ -173,7 +173,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { if(!database.GetSafePoints(target_zone_name, database.GetInstanceVersion(target_instance_id), &safe_x, &safe_y, &safe_z, &minstatus, &minlevel, flag_needed)) { //invalid zone... Message(13, "Invalid target zone while getting safe points."); - Log.Out(Logs::General, Logs::Error, "Zoning %s: Unable to get safe coordinates for zone '%s'.", GetName(), target_zone_name); + Log(Logs::General, Logs::Error, "Zoning %s: Unable to get safe coordinates for zone '%s'.", GetName(), target_zone_name); SendZoneCancel(zc); return; } @@ -193,7 +193,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { switch(zone_mode) { case EvacToSafeCoords: case ZoneToSafeCoords: - Log.Out(Logs::General, Logs::None, "Zoning %s to safe coords (%f,%f,%f) in %s (%d)", GetName(), safe_x, safe_y, safe_z, target_zone_name, target_zone_id); + Log(Logs::General, Logs::None, "Zoning %s to safe coords (%f,%f,%f) in %s (%d)", GetName(), safe_x, safe_y, safe_z, target_zone_name, target_zone_id); dest_x = safe_x; dest_y = safe_y; dest_z = safe_z; @@ -253,7 +253,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { //could not find a valid reason for them to be zoning, stop it. CheatDetected(MQZoneUnknownDest, 0.0, 0.0, 0.0); - Log.Out(Logs::General, Logs::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%s'. Not near a zone point.", GetName(), target_zone_name); + Log(Logs::General, Logs::Error, "Zoning %s: Invalid unsolicited zone request to zone id '%s'. Not near a zone point.", GetName(), target_zone_name); SendZoneCancel(zc); return; default: @@ -288,7 +288,7 @@ void Client::Handle_OP_ZoneChange(const EQApplicationPacket *app) { //we have successfully zoned DoZoneSuccess(zc, target_zone_id, target_instance_id, dest_x, dest_y, dest_z, dest_h, ignorerestrictions); } else { - Log.Out(Logs::General, Logs::Error, "Zoning %s: Rules prevent this char from zoning into '%s'", GetName(), target_zone_name); + Log(Logs::General, Logs::Error, "Zoning %s: Rules prevent this char from zoning into '%s'", GetName(), target_zone_name); SendZoneError(zc, myerror); } } @@ -312,7 +312,7 @@ void Client::SendZoneCancel(ZoneChange_Struct *zc) { void Client::SendZoneError(ZoneChange_Struct *zc, int8 err) { - Log.Out(Logs::General, Logs::Error, "Zone %i is not available because target wasn't found or character insufficent level", zc->zoneID); + Log(Logs::General, Logs::Error, "Zone %i is not available because target wasn't found or character insufficent level", zc->zoneID); SetPortExemption(true); @@ -347,7 +347,7 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc if(this->GetPet()) entity_list.RemoveFromHateLists(this->GetPet()); - Log.Out(Logs::General, Logs::Status, "Zoning '%s' to: %s (%i) - (%i) x=%f, y=%f, z=%f", m_pp.name, database.GetZoneName(zone_id), zone_id, instance_id, dest_x, dest_y, dest_z); + Log(Logs::General, Logs::Status, "Zoning '%s' to: %s (%i) - (%i) x=%f, y=%f, z=%f", m_pp.name, database.GetZoneName(zone_id), zone_id, instance_id, dest_x, dest_y, dest_z); //set the player's coordinates in the new zone so they have them //when they zone into it @@ -470,7 +470,7 @@ void Client::ProcessMovePC(uint32 zoneID, uint32 instance_id, float x, float y, ZonePC(zoneID, instance_id, x, y, z, heading, ignorerestrictions, zm); break; default: - Log.Out(Logs::General, Logs::Error, "Client::ProcessMovePC received a reguest to perform an unsupported client zone operation."); + Log(Logs::General, Logs::Error, "Client::ProcessMovePC received a reguest to perform an unsupported client zone operation."); break; } } @@ -531,7 +531,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z heading = m_pp.binds[0].heading; zonesummon_ignorerestrictions = 1; - Log.Out(Logs::General, Logs::None, "Player %s has died and will be zoned to bind point in zone: %s at LOC x=%f, y=%f, z=%f, heading=%f", + Log(Logs::General, Logs::None, "Player %s has died and will be zoned to bind point in zone: %s at LOC x=%f, y=%f, z=%f, heading=%f", GetName(), pZoneName, m_pp.binds[0].x, m_pp.binds[0].y, m_pp.binds[0].z, m_pp.binds[0].heading); break; case SummonPC: @@ -540,7 +540,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z SetHeading(heading); break; case Rewind: - Log.Out(Logs::General, Logs::None, "%s has requested a /rewind from %f, %f, %f, to %f, %f, %f in %s", GetName(), + Log(Logs::General, Logs::None, "%s has requested a /rewind from %f, %f, %f, to %f, %f, %f in %s", GetName(), m_Position.x, m_Position.y, m_Position.z, m_RewindLocation.x, m_RewindLocation.y, m_RewindLocation.z, zone->GetShortName()); m_ZoneSummonLocation = glm::vec3(x, y, z); @@ -548,7 +548,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z SetHeading(heading); break; default: - Log.Out(Logs::General, Logs::Error, "Client::ZonePC() received a reguest to perform an unsupported client zone operation."); + Log(Logs::General, Logs::Error, "Client::ZonePC() received a reguest to perform an unsupported client zone operation."); ReadyToZone = false; break; } @@ -684,7 +684,7 @@ void Client::ZonePC(uint32 zoneID, uint32 instance_id, float x, float y, float z safe_delete(outapp); } - Log.Out(Logs::Detail, Logs::None, "Player %s has requested a zoning to LOC x=%f, y=%f, z=%f, heading=%f in zoneid=%i", GetName(), x, y, z, heading, zoneID); + Log(Logs::Detail, Logs::None, "Player %s has requested a zoning to LOC x=%f, y=%f, z=%f, heading=%f in zoneid=%i", GetName(), x, y, z, heading, zoneID); //Clear zonesummon variables if we're zoning to our own zone //Client wont generate a zone change packet to the server in this case so //They aren't needed and it keeps behavior on next zone attempt from being undefined. @@ -774,7 +774,7 @@ void Client::SetZoneFlag(uint32 zone_id) { std::string query = StringFormat("INSERT INTO zone_flags (charID,zoneID) VALUES(%d,%d)", CharacterID(), zone_id); auto results = database.QueryDatabase(query); if(!results.Success()) - Log.Out(Logs::General, Logs::Error, "MySQL Error while trying to set zone flag for %s: %s", GetName(), results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "MySQL Error while trying to set zone flag for %s: %s", GetName(), results.ErrorMessage().c_str()); } void Client::ClearZoneFlag(uint32 zone_id) { @@ -787,7 +787,7 @@ void Client::ClearZoneFlag(uint32 zone_id) { std::string query = StringFormat("DELETE FROM zone_flags WHERE charID=%d AND zoneID=%d", CharacterID(), zone_id); auto results = database.QueryDatabase(query); if(!results.Success()) - Log.Out(Logs::General, Logs::Error, "MySQL Error while trying to clear zone flag for %s: %s", GetName(), results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "MySQL Error while trying to clear zone flag for %s: %s", GetName(), results.ErrorMessage().c_str()); } @@ -797,7 +797,7 @@ void Client::LoadZoneFlags() { std::string query = StringFormat("SELECT zoneID from zone_flags WHERE charID=%d", CharacterID()); auto results = database.QueryDatabase(query); if (!results.Success()) { - Log.Out(Logs::General, Logs::Error, "MySQL Error while trying to load zone flags for %s: %s", GetName(), results.ErrorMessage().c_str()); + Log(Logs::General, Logs::Error, "MySQL Error while trying to load zone flags for %s: %s", GetName(), results.ErrorMessage().c_str()); return; } @@ -860,23 +860,23 @@ bool Client::CanBeInZone() { char flag_needed[128]; if(!database.GetSafePoints(zone->GetShortName(), zone->GetInstanceVersion(), &safe_x, &safe_y, &safe_z, &minstatus, &minlevel, flag_needed)) { //this should not happen... - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Unable to query zone info for ourself '%s'", zone->GetShortName()); + Log(Logs::Detail, Logs::None, "[CLIENT] Unable to query zone info for ourself '%s'", zone->GetShortName()); return(false); } if(GetLevel() < minlevel) { - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Character does not meet min level requirement (%d < %d)!", GetLevel(), minlevel); + Log(Logs::Detail, Logs::None, "[CLIENT] Character does not meet min level requirement (%d < %d)!", GetLevel(), minlevel); return(false); } if(Admin() < minstatus) { - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Character does not meet min status requirement (%d < %d)!", Admin(), minstatus); + Log(Logs::Detail, Logs::None, "[CLIENT] Character does not meet min status requirement (%d < %d)!", Admin(), minstatus); return(false); } if(flag_needed[0] != '\0') { //the flag needed string is not empty, meaning a flag is required. if(Admin() < minStatusToIgnoreZoneFlags && !HasZoneFlag(zone->GetZoneID())) { - Log.Out(Logs::Detail, Logs::None, "[CLIENT] Character does not have the flag to be in this zone (%s)!", flag_needed); + Log(Logs::Detail, Logs::None, "[CLIENT] Character does not have the flag to be in this zone (%s)!", flag_needed); return(false); } }