mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
Merge fixes, hopefully didn't break anything.
This commit is contained in:
commit
17af9e3808
@ -1,5 +1,13 @@
|
||||
EQEMu Changelog (Started on Sept 24, 2003 15:50)
|
||||
-------------------------------------------------------
|
||||
== 01/22/2015 ==
|
||||
Akkadius: Massive Log System overhaul, see: http://wiki.eqemulator.org/p?Logging_System_Overhaul&frm=Main
|
||||
|
||||
== 01/21/2015 ==
|
||||
Uleat: Added `light` field to npctypes load query (all six clients tested positive for functionality.)
|
||||
Note: This only affects 'innate' light. Equipment (other) light is still in-work.
|
||||
Optional SQL: utils/sql/git/optional/2015_01_21_NPC_Types_Light_Field_Primer.sql
|
||||
|
||||
== 01/20/2015 ==
|
||||
Uleat: Fix for Inventory::_HasItemByUse(bucket) using the parent container when searching for bag container items.
|
||||
|
||||
|
||||
@ -17,7 +17,9 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../../common/debug.h"
|
||||
|
||||
#include "../../common/eqemu_logsys.h"
|
||||
#include "../../common/global_define.h"
|
||||
#include "../../common/shareddb.h"
|
||||
#include "../../common/eqemu_config.h"
|
||||
#include "../../common/platform.h"
|
||||
@ -25,47 +27,53 @@
|
||||
#include "../../common/rulesys.h"
|
||||
#include "../../common/string_util.h"
|
||||
|
||||
EQEmuLogSys Log;
|
||||
|
||||
void ExportSpells(SharedDatabase *db);
|
||||
void ExportSkillCaps(SharedDatabase *db);
|
||||
void ExportBaseData(SharedDatabase *db);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
RegisterExecutablePlatform(ExePlatformClientExport);
|
||||
Log.LoadLogSettingsDefaults();
|
||||
set_exception_handler();
|
||||
|
||||
LogFile->write(EQEmuLog::Status, "Client Files Export Utility");
|
||||
Log.Out(Logs::General, Logs::Status, "Client Files Export Utility");
|
||||
if(!EQEmuConfig::LoadConfig()) {
|
||||
LogFile->write(EQEmuLog::Error, "Unable to load configuration file.");
|
||||
Log.Out(Logs::General, Logs::Error, "Unable to load configuration file.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const EQEmuConfig *config = EQEmuConfig::get();
|
||||
if(!load_log_settings(config->LogSettingsFile.c_str())) {
|
||||
LogFile->write(EQEmuLog::Error, "Warning: unable to read %s.", config->LogSettingsFile.c_str());
|
||||
}
|
||||
|
||||
SharedDatabase database;
|
||||
LogFile->write(EQEmuLog::Status, "Connecting to database...");
|
||||
Log.Out(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)) {
|
||||
LogFile->write(EQEmuLog::Error, "Unable to connect to the database, cannot continue without a "
|
||||
Log.Out(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();
|
||||
|
||||
ExportSpells(&database);
|
||||
ExportSkillCaps(&database);
|
||||
ExportBaseData(&database);
|
||||
|
||||
Log.CloseFileLogs();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ExportSpells(SharedDatabase *db) {
|
||||
LogFile->write(EQEmuLog::Status, "Exporting Spells...");
|
||||
Log.Out(Logs::General, Logs::Status, "Exporting Spells...");
|
||||
|
||||
FILE *f = fopen("export/spells_us.txt", "w");
|
||||
if(!f) {
|
||||
LogFile->write(EQEmuLog::Error, "Unable to open export/spells_us.txt to write, skipping.");
|
||||
Log.Out(Logs::General, Logs::Error, "Unable to open export/spells_us.txt to write, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -89,7 +97,6 @@ void ExportSpells(SharedDatabase *db) {
|
||||
fprintf(f, "%s\n", line.c_str());
|
||||
}
|
||||
} else {
|
||||
LogFile->write(EQEmuLog::Error, "Error in ExportSpells query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
@ -103,7 +110,6 @@ bool SkillUsable(SharedDatabase *db, int skill_id, int class_id) {
|
||||
class_id, skill_id);
|
||||
auto results = db->QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error in skill_usable query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -123,7 +129,6 @@ int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) {
|
||||
class_id, skill_id, level);
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error in get_skill query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -135,11 +140,11 @@ int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) {
|
||||
}
|
||||
|
||||
void ExportSkillCaps(SharedDatabase *db) {
|
||||
LogFile->write(EQEmuLog::Status, "Exporting Skill Caps...");
|
||||
Log.Out(Logs::General, Logs::Status, "Exporting Skill Caps...");
|
||||
|
||||
FILE *f = fopen("export/SkillCaps.txt", "w");
|
||||
if(!f) {
|
||||
LogFile->write(EQEmuLog::Error, "Unable to open export/SkillCaps.txt to write, skipping.");
|
||||
Log.Out(Logs::General, Logs::Error, "Unable to open export/SkillCaps.txt to write, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -164,11 +169,11 @@ void ExportSkillCaps(SharedDatabase *db) {
|
||||
}
|
||||
|
||||
void ExportBaseData(SharedDatabase *db) {
|
||||
LogFile->write(EQEmuLog::Status, "Exporting Base Data...");
|
||||
Log.Out(Logs::General, Logs::Status, "Exporting Base Data...");
|
||||
|
||||
FILE *f = fopen("export/BaseData.txt", "w");
|
||||
if(!f) {
|
||||
LogFile->write(EQEmuLog::Error, "Unable to open export/BaseData.txt to write, skipping.");
|
||||
Log.Out(Logs::General, Logs::Error, "Unable to open export/BaseData.txt to write, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -190,7 +195,6 @@ void ExportBaseData(SharedDatabase *db) {
|
||||
fprintf(f, "%s\n", line.c_str());
|
||||
}
|
||||
} else {
|
||||
LogFile->write(EQEmuLog::Error, "Error in ExportBaseData query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
@ -16,7 +16,8 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "../../common/debug.h"
|
||||
#include "../../common/eqemu_logsys.h"
|
||||
#include "../../common/global_define.h"
|
||||
#include "../../common/shareddb.h"
|
||||
#include "../../common/eqemu_config.h"
|
||||
#include "../../common/platform.h"
|
||||
@ -24,38 +25,43 @@
|
||||
#include "../../common/rulesys.h"
|
||||
#include "../../common/string_util.h"
|
||||
|
||||
EQEmuLogSys Log;
|
||||
|
||||
void ImportSpells(SharedDatabase *db);
|
||||
void ImportSkillCaps(SharedDatabase *db);
|
||||
void ImportBaseData(SharedDatabase *db);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
RegisterExecutablePlatform(ExePlatformClientImport);
|
||||
Log.LoadLogSettingsDefaults();
|
||||
set_exception_handler();
|
||||
|
||||
LogFile->write(EQEmuLog::Status, "Client Files Import Utility");
|
||||
Log.Out(Logs::General, Logs::Status, "Client Files Import Utility");
|
||||
if(!EQEmuConfig::LoadConfig()) {
|
||||
LogFile->write(EQEmuLog::Error, "Unable to load configuration file.");
|
||||
Log.Out(Logs::General, Logs::Error, "Unable to load configuration file.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const EQEmuConfig *config = EQEmuConfig::get();
|
||||
if(!load_log_settings(config->LogSettingsFile.c_str())) {
|
||||
LogFile->write(EQEmuLog::Error, "Warning: unable to read %s.", config->LogSettingsFile.c_str());
|
||||
}
|
||||
|
||||
SharedDatabase database;
|
||||
LogFile->write(EQEmuLog::Status, "Connecting to database...");
|
||||
Log.Out(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)) {
|
||||
LogFile->write(EQEmuLog::Error, "Unable to connect to the database, cannot continue without a "
|
||||
Log.Out(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();
|
||||
|
||||
ImportSpells(&database);
|
||||
ImportSkillCaps(&database);
|
||||
ImportBaseData(&database);
|
||||
|
||||
Log.CloseFileLogs();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -64,7 +70,6 @@ int GetSpellColumns(SharedDatabase *db) {
|
||||
const std::string query = "DESCRIBE spells_new";
|
||||
auto results = db->QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error in GetSpellColumns query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -72,10 +77,10 @@ int GetSpellColumns(SharedDatabase *db) {
|
||||
}
|
||||
|
||||
void ImportSpells(SharedDatabase *db) {
|
||||
LogFile->write(EQEmuLog::Status, "Importing Spells...");
|
||||
Log.Out(Logs::General, Logs::Status, "Importing Spells...");
|
||||
FILE *f = fopen("import/spells_us.txt", "r");
|
||||
if(!f) {
|
||||
LogFile->write(EQEmuLog::Error, "Unable to open import/spells_us.txt to read, skipping.");
|
||||
Log.Out(Logs::General, Logs::Error, "Unable to open import/spells_us.txt to read, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -138,23 +143,23 @@ void ImportSpells(SharedDatabase *db) {
|
||||
|
||||
spells_imported++;
|
||||
if(spells_imported % 1000 == 0) {
|
||||
LogFile->write(EQEmuLog::Status, "%d spells imported.", spells_imported);
|
||||
Log.Out(Logs::General, Logs::Status, "%d spells imported.", spells_imported);
|
||||
}
|
||||
}
|
||||
|
||||
if(spells_imported % 1000 != 0) {
|
||||
LogFile->write(EQEmuLog::Status, "%d spells imported.", spells_imported);
|
||||
Log.Out(Logs::General, Logs::Status, "%d spells imported.", spells_imported);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void ImportSkillCaps(SharedDatabase *db) {
|
||||
LogFile->write(EQEmuLog::Status, "Importing Skill Caps...");
|
||||
Log.Out(Logs::General, Logs::Status, "Importing Skill Caps...");
|
||||
|
||||
FILE *f = fopen("import/SkillCaps.txt", "r");
|
||||
if(!f) {
|
||||
LogFile->write(EQEmuLog::Error, "Unable to open import/SkillCaps.txt to read, skipping.");
|
||||
Log.Out(Logs::General, Logs::Error, "Unable to open import/SkillCaps.txt to read, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -186,11 +191,11 @@ void ImportSkillCaps(SharedDatabase *db) {
|
||||
}
|
||||
|
||||
void ImportBaseData(SharedDatabase *db) {
|
||||
LogFile->write(EQEmuLog::Status, "Importing Base Data...");
|
||||
Log.Out(Logs::General, Logs::Status, "Importing Base Data...");
|
||||
|
||||
FILE *f = fopen("import/BaseData.txt", "r");
|
||||
if(!f) {
|
||||
LogFile->write(EQEmuLog::Error, "Unable to open import/BaseData.txt to read, skipping.");
|
||||
Log.Out(Logs::General, Logs::Error, "Unable to open import/BaseData.txt to read, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@ SET(common_sources
|
||||
crc32.cpp
|
||||
database.cpp
|
||||
dbcore.cpp
|
||||
debug.cpp
|
||||
emu_opcodes.cpp
|
||||
emu_tcp_connection.cpp
|
||||
emu_tcp_server.cpp
|
||||
@ -18,7 +17,7 @@ SET(common_sources
|
||||
eqdb_res.cpp
|
||||
eqemu_exception.cpp
|
||||
eqemu_config.cpp
|
||||
eqemu_error.cpp
|
||||
eqemu_logsys.cpp
|
||||
eq_packet.cpp
|
||||
eq_stream.cpp
|
||||
eq_stream_factory.cpp
|
||||
@ -31,8 +30,6 @@ SET(common_sources
|
||||
guilds.cpp
|
||||
ipc_mutex.cpp
|
||||
item.cpp
|
||||
logsys.cpp
|
||||
logsys_eqemu.cpp
|
||||
md5.cpp
|
||||
memory_mapped_file.cpp
|
||||
misc.cpp
|
||||
@ -106,7 +103,6 @@ SET(common_headers
|
||||
data_verification.h
|
||||
database.h
|
||||
dbcore.h
|
||||
debug.h
|
||||
deity.h
|
||||
emu_opcodes.h
|
||||
emu_oplist.h
|
||||
@ -120,7 +116,7 @@ SET(common_headers
|
||||
eqemu_exception.h
|
||||
eqemu_config.h
|
||||
eqemu_config_elements.h
|
||||
eqemu_error.h
|
||||
eqemu_logsys.h
|
||||
eq_packet.h
|
||||
eq_stream.h
|
||||
eq_stream_factory.h
|
||||
@ -136,6 +132,7 @@ SET(common_headers
|
||||
features.h
|
||||
fixed_memory_hash_set.h
|
||||
fixed_memory_variable_hash_set.h
|
||||
global_define.h
|
||||
guild_base.h
|
||||
guilds.h
|
||||
ipc_mutex.h
|
||||
@ -144,8 +141,6 @@ SET(common_headers
|
||||
item_struct.h
|
||||
languages.h
|
||||
linked_list.h
|
||||
logsys.h
|
||||
logtypes.h
|
||||
loottable.h
|
||||
mail_oplist.h
|
||||
md5.h
|
||||
|
||||
@ -40,7 +40,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#include "../debug.h"
|
||||
#include "../global_define.h"
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <stdarg.h>
|
||||
|
||||
@ -26,7 +26,7 @@ along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "../debug.h"
|
||||
#include "../global_define.h"
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#include "../debug.h"
|
||||
#include "../global_define.h"
|
||||
#include "Utility.h"
|
||||
#include "HttpdCookies.h"
|
||||
#include "HttpdForm.h"
|
||||
@ -194,7 +194,6 @@ void HttpdSocket::OnHeaderComplete()
|
||||
|
||||
void HttpdSocket::OnData(const char *p,size_t l)
|
||||
{
|
||||
//printf("Got %d bytes: %.*s\n", l, l, p);
|
||||
if (m_file)
|
||||
{
|
||||
m_file -> fwrite(p,1,l);
|
||||
|
||||
@ -110,7 +110,6 @@ size_t MemFile::fread(char *ptr, size_t size, size_t nmemb)
|
||||
size_t sz = size * nmemb;
|
||||
if (p + sz < BLOCKSIZE)
|
||||
{
|
||||
//printf("Read @ %d(%d). %d bytes. (%c)\n", m_read_ptr, p, sz, *(m_current_read -> data + p));
|
||||
memcpy(ptr, m_current_read -> data + p, sz);
|
||||
m_read_ptr += sz;
|
||||
}
|
||||
@ -142,7 +141,6 @@ size_t MemFile::fwrite(const char *ptr, size_t size, size_t nmemb)
|
||||
size_t sz = size * nmemb;
|
||||
if (p + sz < BLOCKSIZE)
|
||||
{
|
||||
//printf("Write @ %d(%d). %d bytes.\n", m_write_ptr, p, sz);
|
||||
memcpy(m_current_write -> data + p, ptr, sz);
|
||||
m_write_ptr += sz;
|
||||
}
|
||||
|
||||
@ -1128,7 +1128,6 @@ BOOL __stdcall StackWalker::myReadProcMem(
|
||||
SIZE_T st;
|
||||
BOOL bRet = ReadProcessMemory(hProcess, (LPVOID) qwBaseAddress, lpBuffer, nSize, &st);
|
||||
*lpNumberOfBytesRead = (DWORD) st;
|
||||
//printf("ReadMemory: hProcess: %p, baseAddr: %p, buffer: %p, size: %d, read: %d, result: %d\n", hProcess, (LPVOID) qwBaseAddress, lpBuffer, nSize, (DWORD) st, (DWORD) bRet);
|
||||
return bRet;
|
||||
}
|
||||
else
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "base_packet.h"
|
||||
#include "misc.h"
|
||||
#include "packet_dump.h"
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
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/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/classes.h"
|
||||
|
||||
const char* GetEQClassName(uint8 class_, uint8 level) {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#ifndef CLIENTVERSIONS_H
|
||||
#define CLIENTVERSIONS_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
static const uint32 BIT_Client62 = 1;
|
||||
static const uint32 BIT_Titanium = 2;
|
||||
static const uint32 BIT_SoF = 4;
|
||||
|
||||
@ -18,7 +18,8 @@
|
||||
#ifndef __CONDITION_H
|
||||
#define __CONDITION_H
|
||||
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "mutex.h"
|
||||
#ifndef WIN32
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "eqemu_logsys.h"
|
||||
#include "crash.h"
|
||||
|
||||
#if defined(_WINDOWS) && defined(CRASH_LOGGING)
|
||||
@ -24,7 +25,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
LogFile->write(EQEmuLog::Crash, buffer);
|
||||
Log.Out(Logs::General, Logs::Crash, buffer);
|
||||
StackWalker::OnOutput(szText);
|
||||
}
|
||||
};
|
||||
@ -34,67 +35,67 @@ LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
|
||||
switch(ExceptionInfo->ExceptionRecord->ExceptionCode)
|
||||
{
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_ACCESS_VIOLATION");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_ACCESS_VIOLATION");
|
||||
break;
|
||||
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
|
||||
break;
|
||||
case EXCEPTION_BREAKPOINT:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_BREAKPOINT");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_BREAKPOINT");
|
||||
break;
|
||||
case EXCEPTION_DATATYPE_MISALIGNMENT:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT");
|
||||
break;
|
||||
case EXCEPTION_FLT_DENORMAL_OPERAND:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND");
|
||||
break;
|
||||
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO");
|
||||
break;
|
||||
case EXCEPTION_FLT_INEXACT_RESULT:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_FLT_INEXACT_RESULT");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_INEXACT_RESULT");
|
||||
break;
|
||||
case EXCEPTION_FLT_INVALID_OPERATION:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_FLT_INVALID_OPERATION");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_INVALID_OPERATION");
|
||||
break;
|
||||
case EXCEPTION_FLT_OVERFLOW:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_FLT_OVERFLOW");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_OVERFLOW");
|
||||
break;
|
||||
case EXCEPTION_FLT_STACK_CHECK:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_FLT_STACK_CHECK");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_STACK_CHECK");
|
||||
break;
|
||||
case EXCEPTION_FLT_UNDERFLOW:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_FLT_UNDERFLOW");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_UNDERFLOW");
|
||||
break;
|
||||
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION");
|
||||
break;
|
||||
case EXCEPTION_IN_PAGE_ERROR:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_IN_PAGE_ERROR");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_IN_PAGE_ERROR");
|
||||
break;
|
||||
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO");
|
||||
break;
|
||||
case EXCEPTION_INT_OVERFLOW:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_INT_OVERFLOW");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_INT_OVERFLOW");
|
||||
break;
|
||||
case EXCEPTION_INVALID_DISPOSITION:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_INVALID_DISPOSITION");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_INVALID_DISPOSITION");
|
||||
break;
|
||||
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION");
|
||||
break;
|
||||
case EXCEPTION_PRIV_INSTRUCTION:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_PRIV_INSTRUCTION");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_PRIV_INSTRUCTION");
|
||||
break;
|
||||
case EXCEPTION_SINGLE_STEP:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_SINGLE_STEP");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_SINGLE_STEP");
|
||||
break;
|
||||
case EXCEPTION_STACK_OVERFLOW:
|
||||
LogFile->write(EQEmuLog::Crash, "EXCEPTION_STACK_OVERFLOW");
|
||||
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_STACK_OVERFLOW");
|
||||
break;
|
||||
default:
|
||||
LogFile->write(EQEmuLog::Crash, "Unknown Exception");
|
||||
Log.Out(Logs::General, Logs::Crash, "Unknown Exception");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
|
||||
Copyright (C) 2001-2015 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
|
||||
@ -16,7 +16,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/rulesys.h"
|
||||
|
||||
#include <ctype.h>
|
||||
@ -58,15 +58,7 @@ extern Client client;
|
||||
# define _ISNAN_(a) std::isnan(a)
|
||||
#endif
|
||||
|
||||
/*
|
||||
Establish a connection to a mysql database with the supplied parameters
|
||||
|
||||
Added a very simple .ini file parser - Bounce
|
||||
|
||||
Modify to use for win32 & linux - misanthropicfiend
|
||||
*/
|
||||
Database::Database ()
|
||||
{
|
||||
Database::Database () {
|
||||
DBInitVars();
|
||||
}
|
||||
|
||||
@ -84,12 +76,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)) {
|
||||
LogFile->write(EQEmuLog::Error, "Failed to connect to database: Error: %s", errbuf);
|
||||
|
||||
Log.Out(Logs::General, Logs::Error, "Failed to connect to database: Error: %s", errbuf);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
LogFile->write(EQEmuLog::Status, "Using database '%s' at %s:%d",database,host,port);
|
||||
Log.Out(Logs::General, Logs::Status, "Using database '%s' at %s:%d", database, host,port);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -137,7 +128,6 @@ uint32 Database::CheckLogin(const char* name, const char* password, int16* oStat
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in CheckLogin query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -163,7 +153,6 @@ bool Database::CheckBannedIPs(const char* loginIP)
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in CheckBannedIPs query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -177,7 +166,6 @@ bool Database::AddBannedIP(char* bannedIP, const char* notes) {
|
||||
std::string query = StringFormat("INSERT into Banned_IPs SET ip_address='%s', notes='%s'", bannedIP, notes);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in Database::AddBannedIP query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -204,9 +192,7 @@ bool Database::AddGMIP(char* ip_address, char* name) {
|
||||
|
||||
void Database::LoginIP(uint32 AccountID, const char* LoginIP) {
|
||||
std::string query = StringFormat("INSERT INTO account_ip SET accid=%i, ip='%s' ON DUPLICATE KEY UPDATE count=count+1, lastused=now()", AccountID, LoginIP);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
std::cerr << "Error in Log IP query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
int16 Database::CheckStatus(uint32 account_id) {
|
||||
@ -215,7 +201,6 @@ int16 Database::CheckStatus(uint32 account_id) {
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in CheckStatus query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -247,17 +232,15 @@ 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);
|
||||
|
||||
std::cerr << "Account Attempting to be created:" << name << " " << (int16) status << std::endl;
|
||||
Log.Out(Logs::General, Logs::World_Server, "Account Attempting to be created: '%s' status: %i", name, status);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in CreateAccount query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (results.LastInsertedID() == 0)
|
||||
{
|
||||
std::cerr << "Error in CreateAccount query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -266,13 +249,10 @@ 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);
|
||||
std::cout << "Account Attempting to be deleted:" << name << std::endl;
|
||||
Log.Out(Logs::General, Logs::World_Server, "Account Attempting to be deleted:'%s'", name);
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in DeleteAccount query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -285,7 +265,6 @@ bool Database::SetLocalPassword(uint32 accid, const char* password) {
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in SetLocalPassword query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -325,11 +304,11 @@ bool Database::ReserveName(uint32 account_id, char* name) {
|
||||
*/
|
||||
bool Database::DeleteCharacter(char *name) {
|
||||
uint32 charid = 0;
|
||||
printf("Database::DeleteCharacter name : %s \n", name);
|
||||
if(!name || !strlen(name)) {
|
||||
std::cerr << "DeleteCharacter: request to delete without a name (empty char slot)" << std::endl;
|
||||
Log.Out(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);
|
||||
|
||||
/* 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);
|
||||
@ -706,7 +685,7 @@ bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inven
|
||||
charid = GetCharacterID(pp->name);
|
||||
|
||||
if(!charid) {
|
||||
LogFile->write(EQEmuLog::Error, "StoreCharacter: no character id");
|
||||
Log.Out(Logs::General, Logs::Error, "StoreCharacter: no character id");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -734,13 +713,6 @@ bool Database::StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inven
|
||||
charid, i, newinv->GetItem()->ID, newinv->GetCharges(), newinv->GetColor());
|
||||
|
||||
auto results = QueryDatabase(invquery);
|
||||
|
||||
if (!results.RowsAffected())
|
||||
LogFile->write(EQEmuLog::Error, "StoreCharacter inventory failed. Query '%s' %s", invquery.c_str(), results.ErrorMessage().c_str());
|
||||
#if EQDEBUG >= 9
|
||||
else
|
||||
LogFile->write(EQEmuLog::Debug, "StoreCharacter inventory succeeded. Query '%s'", invquery.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == MainCursor) {
|
||||
@ -783,7 +755,6 @@ uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in GetAccountIDByChar query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -805,7 +776,6 @@ uint32 Database::GetAccountIDByChar(uint32 char_id) {
|
||||
std::string query = StringFormat("SELECT `account_id` FROM `character_data` WHERE `id` = %i LIMIT 1", char_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error in GetAccountIDByChar query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -824,7 +794,6 @@ uint32 Database::GetAccountIDByName(const char* accname, int16* status, uint32*
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in GetAccountIDByAcc query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -853,7 +822,6 @@ void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in GetAccountName query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -874,7 +842,6 @@ void Database::GetCharName(uint32 char_id, char* name) {
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in GetCharName query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1388,7 +1355,6 @@ bool Database::CheckDatabaseConvertPPDeblob(){
|
||||
}
|
||||
/* Continue of PP Size does not match (Usually a created character never logged in) */
|
||||
else {
|
||||
// printf("%s ID: %i profile mismatch, not converting. PP %u - Profile Length %u \n", row2[2] ? row2[2] : "Unknown", character_id, sizeof(PlayerProfile_Struct), lengths);
|
||||
std::cout << (row2[2] ? row2[2] : "Unknown") << " ID: " << character_id << " size mismatch. Expected Size: " << sizeof(Convert::PlayerProfile_Struct) << " Seen: " << lengths << std::endl;
|
||||
continue;
|
||||
}
|
||||
@ -1817,7 +1783,6 @@ bool Database::CheckDatabaseConvertPPDeblob(){
|
||||
rquery = rquery + StringFormat(", (%u, %u, %u)", character_id, i, pp->spell_book[i]);
|
||||
}
|
||||
}
|
||||
// std::cout << rquery << "\n";
|
||||
if (rquery != ""){ results = QueryDatabase(rquery); }
|
||||
/* Run Max Memmed Spell Convert */
|
||||
first_entry = 0; rquery = "";
|
||||
@ -2191,7 +2156,6 @@ bool Database::CheckDatabaseConvertCorpseDeblob(){
|
||||
c_type = "Legacy";
|
||||
}
|
||||
if (in_datasize != esize2 && in_datasize != esize1) {
|
||||
// std::cout << "[Error] in Corpse Size - OLD SIZE: " << esize1 << " SOF SIZE: " << esize2 << " db_blob_datasize: " << in_datasize << std::endl;
|
||||
is_sof = false;
|
||||
c_type = "NULL";
|
||||
continue;
|
||||
@ -2434,7 +2398,6 @@ bool Database::LoadVariables() {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in LoadVariables query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
safe_delete_array(query);
|
||||
return false;
|
||||
}
|
||||
@ -2546,7 +2509,6 @@ bool Database::SetVariable(const char* varname_in, const char* varvalue_in) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in SetVariable query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
free(varname);
|
||||
free(varvalue);
|
||||
return false;
|
||||
@ -2579,7 +2541,6 @@ uint32 Database::GetMiniLoginAccount(char* ip){
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in GetMiniLoginAccount query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2596,14 +2557,7 @@ bool Database::GetSafePoints(const char* short_name, uint32 version, float* safe
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in GetSafePoint query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
std::cerr << "If it errors, run the following querys:\n";
|
||||
std::cerr << "ALTER TABLE `zone` CHANGE `minium_level` `min_level` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n";
|
||||
std::cerr << "ALTER TABLE `zone` CHANGE `minium_status` `min_status` TINYINT(3) UNSIGNED DEFAULT \"0\" NOT NULL;\n";
|
||||
std::cerr << "ALTER TABLE `zone` ADD flag_needed VARCHAR(128) NOT NULL DEFAULT '';\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return false;
|
||||
@ -2632,7 +2586,6 @@ bool Database::GetZoneLongName(const char* short_name, char** long_name, char* f
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in GetZoneLongName query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2672,7 +2625,6 @@ uint32 Database::GetZoneGraveyardID(uint32 zone_id, uint32 version) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in GetZoneGraveyardID query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2689,7 +2641,6 @@ bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zon
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()){
|
||||
std::cerr << "Error in GetZoneGraveyard query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2719,7 +2670,6 @@ bool Database::LoadZoneNames() {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in LoadZoneNames query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2762,9 +2712,7 @@ uint8 Database::GetPEQZone(uint32 zoneID, uint32 version){
|
||||
std::string query = StringFormat("SELECT peqzone from zone where zoneidnumber='%i' AND (version=%i OR version=0) ORDER BY version DESC", zoneID, version);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in GetPEQZone query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
if (!results.Success()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2835,7 +2783,6 @@ bool Database::CheckNameFilter(const char* name, bool surname)
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in CheckNameFilter query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
// false through to true? shouldn't it be falls through to false?
|
||||
return true;
|
||||
}
|
||||
@ -2861,7 +2808,6 @@ bool Database::AddToNameFilter(const char* name) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in AddToNameFilter query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2876,9 +2822,7 @@ uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* o
|
||||
std::string query = StringFormat("SELECT id, name, status FROM account WHERE lsaccount_id=%i", iLSID);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in GetAccountIDFromLSID query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
if (!results.Success()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2902,9 +2846,7 @@ void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
|
||||
std::string query = StringFormat("SELECT name, status FROM account WHERE id=%i", id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in GetAccountFromID query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
if (!results.Success()){
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2920,12 +2862,7 @@ void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) {
|
||||
}
|
||||
|
||||
void Database::ClearMerchantTemp(){
|
||||
|
||||
std::string query("delete from merchantlist_temp");
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
std::cerr << "Error in ClearMerchantTemp query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
QueryDatabase("DELETE FROM merchantlist_temp");
|
||||
}
|
||||
|
||||
bool Database::UpdateName(const char* oldname, const char* newname) {
|
||||
@ -2947,7 +2884,6 @@ bool Database::CheckUsedName(const char* name) {
|
||||
std::string query = StringFormat("SELECT `id` FROM `character_data` WHERE `name` = '%s'", name);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in CheckUsedName query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2961,7 +2897,6 @@ uint8 Database::GetServerType() {
|
||||
std::string query("SELECT `value` FROM `variables` WHERE `varname` = 'ServerType' LIMIT 1");
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in GetServerType query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2980,7 +2915,6 @@ bool Database::MoveCharacterToZone(const char* charname, const char* zonename, u
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in MoveCharacterToZone(name) query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2999,7 +2933,6 @@ bool Database::MoveCharacterToZone(uint32 iCharID, const char* iZonename) {
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in MoveCharacterToZone(id) query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3011,7 +2944,6 @@ bool Database::SetHackerFlag(const char* accountname, const char* charactername,
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in SetHackerFlag query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3025,7 +2957,6 @@ bool Database::SetMQDetectionFlag(const char* accountname, const char* character
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in SetMQDetectionFlag query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3105,7 +3036,6 @@ uint32 Database::GetCharacterInfo(const char* iName, uint32* oAccID, uint32* oZo
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in GetCharacterInfo query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3129,9 +3059,7 @@ bool Database::UpdateLiveChar(char* charname,uint32 lsaccount_id) {
|
||||
std::string query = StringFormat("UPDATE account SET charname='%s' WHERE id=%i;",charname, lsaccount_id);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in UpdateLiveChar query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
if (!results.Success()){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3145,7 +3073,6 @@ bool Database::GetLiveChar(uint32 account_id, char* cname) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in GetLiveChar query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3160,30 +3087,22 @@ bool Database::GetLiveChar(uint32 account_id, char* cname) {
|
||||
|
||||
void Database::SetLFP(uint32 CharID, bool LFP) {
|
||||
std::string query = StringFormat("UPDATE `character_data` SET `lfp` = %i WHERE `id` = %i",LFP, CharID);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
LogFile->write(EQEmuLog::Error, "Error updating LFP for character %i : %s", CharID, results.ErrorMessage().c_str());
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
void Database::SetLoginFlags(uint32 CharID, bool LFP, bool LFG, uint8 firstlogon) {
|
||||
std::string query = StringFormat("update `character_data` SET `lfp` = %i, `lfg` = %i, `firstlogon` = %i WHERE `id` = %i",LFP, LFG, firstlogon, CharID);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
LogFile->write(EQEmuLog::Error, "Error updating LFP for character %i : %s", CharID, results.ErrorMessage().c_str());
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
void Database::SetLFG(uint32 CharID, bool LFG) {
|
||||
std::string query = StringFormat("update `character_data` SET `lfg` = %i WHERE `id` = %i",LFG, CharID);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
LogFile->write(EQEmuLog::Error, "Error updating LFP for character %i : %s", CharID, results.ErrorMessage().c_str());
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
void Database::SetFirstLogon(uint32 CharID, uint8 firstlogon) {
|
||||
std::string query = StringFormat( "UPDATE `character_data` SET `firstlogon` = %i WHERE `id` = %i",firstlogon, CharID);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
LogFile->write(EQEmuLog::Error, "Error updating firstlogon for character %i : %s", CharID, results.ErrorMessage().c_str());
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
void Database::AddReport(std::string who, std::string against, std::string lines) {
|
||||
@ -3191,11 +3110,8 @@ void Database::AddReport(std::string who, std::string against, std::string lines
|
||||
DoEscapeString(escape_str, lines.c_str(), lines.size());
|
||||
|
||||
std::string query = StringFormat("INSERT INTO reports (name, reported, reported_text) VALUES('%s', '%s', '%s')", who.c_str(), against.c_str(), escape_str);
|
||||
auto results = QueryDatabase(query);
|
||||
QueryDatabase(query);
|
||||
safe_delete_array(escape_str);
|
||||
|
||||
if (!results.Success())
|
||||
LogFile->write(EQEmuLog::Error, "Error adding a report for %s: %s", who.c_str(), results.ErrorMessage().c_str());
|
||||
}
|
||||
|
||||
void Database::SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ismerc) {
|
||||
@ -3206,27 +3122,20 @@ void Database::SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ism
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
LogFile->write(EQEmuLog::Error, "Error deleting character from group id: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::General, Logs::Error, "Error deleting character from group id: %s", results.ErrorMessage().c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add to the Group */
|
||||
query = StringFormat("REPLACE INTO `group_id` SET `charid` = %i, `groupid` = %i, `name` = '%s', `ismerc` = '%i'", charid, id, name, ismerc);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
LogFile->write(EQEmuLog::Error, "Error adding character to group id: %s", results.ErrorMessage().c_str());
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
void Database::ClearAllGroups(void)
|
||||
{
|
||||
std::string query("delete from group_id");
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
std::cout << "Unable to clear groups: " << results.ErrorMessage() << std::endl;
|
||||
|
||||
std::string query("DELETE FROM `group_id`");
|
||||
QueryDatabase(query);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -3242,27 +3151,21 @@ void Database::ClearGroup(uint32 gid) {
|
||||
|
||||
//clear a specific group
|
||||
std::string query = StringFormat("delete from group_id where groupid = %lu", (unsigned long)gid);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
std::cout << "Unable to clear groups: " << results.ErrorMessage() << std::endl;
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
uint32 Database::GetGroupID(const char* name){
|
||||
|
||||
uint32 Database::GetGroupID(const char* name){
|
||||
std::string query = StringFormat("SELECT groupid from group_id where name='%s'", name);
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
LogFile->write(EQEmuLog::Error, "Error getting group id: %s", results.ErrorMessage().c_str());
|
||||
if (!results.Success()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
{
|
||||
// Commenting this out until logging levels can prevent this from going to console
|
||||
//LogFile->write(EQEmuLog::Debug, "Character not in a group: %s", name);
|
||||
//Log.Out(Logs::General, Logs::None,, "Character not in a group: %s", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3309,7 +3212,7 @@ void Database::SetGroupLeaderName(uint32 gid, const char* name) {
|
||||
result = QueryDatabase(query);
|
||||
|
||||
if(!result.Success()) {
|
||||
LogFile->write(EQEmuLog::Debug, "Error in Database::SetGroupLeaderName: %s", result.ErrorMessage().c_str());
|
||||
Log.Out(Logs::General, Logs::None, "Error in Database::SetGroupLeaderName: %s", result.ErrorMessage().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -3488,7 +3391,7 @@ uint32 Database::GetRaidID(const char* name){
|
||||
|
||||
if (row == results.end())
|
||||
{
|
||||
std::cout << "Unable to get raid id, char not found!" << std::endl;
|
||||
Log.Out(Logs::General, Logs::Error, "Unable to get raid id, char not found!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4049,7 +3952,6 @@ void Database::GetCharactersInInstance(uint16 instance_id, std::list<uint32> &ch
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
LogFile->write(EQEmuLog::Error, "Error in GetCharactersInInstace query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -4247,7 +4149,6 @@ uint32 Database::GetGuildIDByCharID(uint32 char_id)
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
std::cerr << "Error in GetGuildIDByChar query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4257,3 +4158,35 @@ uint32 Database::GetGuildIDByCharID(uint32 char_id)
|
||||
auto row = results.begin();
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings){
|
||||
std::string query =
|
||||
"SELECT "
|
||||
"log_category_id, "
|
||||
"log_category_description, "
|
||||
"log_to_console, "
|
||||
"log_to_file, "
|
||||
"log_to_gmsay "
|
||||
"FROM "
|
||||
"logsys_categories "
|
||||
"ORDER BY log_category_id";
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
int log_category = 0;
|
||||
Log.file_logs_enabled = false;
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
log_category = atoi(row[0]);
|
||||
log_settings[log_category].log_to_console = atoi(row[2]);
|
||||
log_settings[log_category].log_to_file = atoi(row[3]);
|
||||
log_settings[log_category].log_to_gmsay = atoi(row[4]);
|
||||
|
||||
/*
|
||||
This determines whether or not the process needs to actually file log anything.
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -21,7 +21,8 @@
|
||||
#define AUTHENTICATION_TIMEOUT 60
|
||||
#define INVALID_ID 0xFFFFFFFF
|
||||
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "eqemu_logsys.h"
|
||||
#include "types.h"
|
||||
#include "dbcore.h"
|
||||
#include "linked_list.h"
|
||||
@ -644,6 +645,9 @@ public:
|
||||
void SetLoginFlags(uint32 CharID, bool LFP, bool LFG, uint8 firstlogon);
|
||||
void AddReport(std::string who, std::string against, std::string lines);
|
||||
|
||||
/* EQEmuLogSys */
|
||||
void LoadLogSettings(EQEmuLogSys::LogSettings* log_settings);
|
||||
|
||||
private:
|
||||
void DBInitVars();
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#endif
|
||||
|
||||
#include "../common/misc_functions.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
|
||||
#include "dbcore.h"
|
||||
|
||||
@ -101,25 +102,15 @@ MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, boo
|
||||
|
||||
snprintf(errorBuffer, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
|
||||
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||
|
||||
return MySQLRequestResult(nullptr, 0, 0, 0, 0, (uint32)mysql_errno(&mysql), errorBuffer);
|
||||
}
|
||||
|
||||
char *errorBuffer = new char[MYSQL_ERRMSG_SIZE];
|
||||
snprintf(errorBuffer, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
|
||||
#ifdef _EQDEBUG
|
||||
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||
#endif
|
||||
|
||||
/* Implement Logging at the Root */
|
||||
if (mysql_errno(&mysql) > 0 && strlen(query) > 0){
|
||||
std::cout << "\n[MYSQL ERR] " << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << " [Query]: \n" << query << "\n" << std::endl;
|
||||
/* Write to log file */
|
||||
std::ofstream log("eqemu_query_error_log.txt", std::ios_base::app | std::ios_base::out);
|
||||
log << "[MYSQL ERR] " << mysql_error(&mysql) << "\n" << query << "\n";
|
||||
log.close();
|
||||
Log.Out(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);
|
||||
@ -135,20 +126,7 @@ 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 DEBUG_MYSQL_QUERIES >= 1
|
||||
if (requestResult.Success())
|
||||
{
|
||||
std::cout << "query successful";
|
||||
if (requestResult.Result())
|
||||
std::cout << ", " << (int) mysql_num_rows(requestResult.Result()) << " rows returned";
|
||||
|
||||
std::cout << ", " << requestResult.RowCount() << " rows affected";
|
||||
std::cout<< std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "QUERY: query FAILED" << std::endl;
|
||||
}
|
||||
#endif
|
||||
Log.Out(Logs::General, Logs::MySQLQuery, "%s (%u rows returned)", query, rowCount, requestResult.RowCount());
|
||||
|
||||
return requestResult;
|
||||
}
|
||||
|
||||
565
common/debug.cpp
565
common/debug.cpp
@ -1,565 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <process.h>
|
||||
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
|
||||
#include <conio.h>
|
||||
#include <iostream>
|
||||
#include <dos.h>
|
||||
|
||||
namespace ConsoleColor {
|
||||
enum Colors {
|
||||
Black = 0,
|
||||
Blue = 1,
|
||||
Green = 2,
|
||||
Cyan = 3,
|
||||
Red = 4,
|
||||
Magenta = 5,
|
||||
Brown = 6,
|
||||
LightGray = 7,
|
||||
DarkGray = 8,
|
||||
LightBlue = 9,
|
||||
LightGreen = 10,
|
||||
LightCyan = 11,
|
||||
LightRed = 12,
|
||||
LightMagenta = 13,
|
||||
Yellow = 14,
|
||||
White = 15,
|
||||
};
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include "debug.h"
|
||||
#include "misc_functions.h"
|
||||
#include "platform.h"
|
||||
|
||||
#ifndef va_copy
|
||||
#define va_copy(d,s) ((d) = (s))
|
||||
#endif
|
||||
|
||||
static volatile bool logFileValid = false;
|
||||
static EQEmuLog realLogFile;
|
||||
EQEmuLog *LogFile = &realLogFile;
|
||||
|
||||
static const char* FileNames[EQEmuLog::MaxLogID] = { "logs/eqemu", "logs/eqemu", "logs/eqemu_error", "logs/eqemu_debug", "logs/eqemu_quest", "logs/eqemu_commands", "logs/crash" };
|
||||
static const char* LogNames[EQEmuLog::MaxLogID] = { "Status", "Normal", "Error", "Debug", "Quest", "Command", "Crash" };
|
||||
|
||||
EQEmuLog::EQEmuLog()
|
||||
{
|
||||
for (int i = 0; i < MaxLogID; i++) {
|
||||
fp[i] = 0;
|
||||
logCallbackFmt[i] = nullptr;
|
||||
logCallbackBuf[i] = nullptr;
|
||||
logCallbackPva[i] = nullptr;
|
||||
}
|
||||
pLogStatus[EQEmuLog::LogIDs::Status] = LOG_LEVEL_STATUS;
|
||||
pLogStatus[EQEmuLog::LogIDs::Normal] = LOG_LEVEL_NORMAL;
|
||||
pLogStatus[EQEmuLog::LogIDs::Error] = LOG_LEVEL_ERROR;
|
||||
pLogStatus[EQEmuLog::LogIDs::Debug] = LOG_LEVEL_DEBUG;
|
||||
pLogStatus[EQEmuLog::LogIDs::Quest] = LOG_LEVEL_QUEST;
|
||||
pLogStatus[EQEmuLog::LogIDs::Commands] = LOG_LEVEL_COMMANDS;
|
||||
pLogStatus[EQEmuLog::LogIDs::Crash] = LOG_LEVEL_CRASH;
|
||||
logFileValid = true;
|
||||
}
|
||||
|
||||
EQEmuLog::~EQEmuLog()
|
||||
{
|
||||
logFileValid = false;
|
||||
for (int i = 0; i < MaxLogID; i++) {
|
||||
LockMutex lock(&MLog[i]); //to prevent termination race
|
||||
if (fp[i]) {
|
||||
fclose(fp[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool EQEmuLog::open(LogIDs id)
|
||||
{
|
||||
if (!logFileValid) {
|
||||
return false;
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
LockMutex lock(&MOpen);
|
||||
if (pLogStatus[id] & 4) {
|
||||
return false;
|
||||
}
|
||||
if (fp[id]) {
|
||||
//cerr<<"Warning: LogFile already open"<<endl;
|
||||
return true;
|
||||
}
|
||||
char exename[200] = "";
|
||||
const EQEmuExePlatform &platform = GetExecutablePlatform();
|
||||
if (platform == ExePlatformWorld) {
|
||||
snprintf(exename, sizeof(exename), "_world");
|
||||
} else if (platform == ExePlatformZone) {
|
||||
snprintf(exename, sizeof(exename), "_zone");
|
||||
} else if (platform == ExePlatformLaunch) {
|
||||
snprintf(exename, sizeof(exename), "_launch");
|
||||
} else if (platform == ExePlatformUCS) {
|
||||
snprintf(exename, sizeof(exename), "_ucs");
|
||||
} else if (platform == ExePlatformQueryServ) {
|
||||
snprintf(exename, sizeof(exename), "_queryserv");
|
||||
} else if (platform == ExePlatformSharedMemory) {
|
||||
snprintf(exename, sizeof(exename), "_shared_memory");
|
||||
} else if (platform == ExePlatformClientImport) {
|
||||
snprintf(exename, sizeof(exename), "_import");
|
||||
} else if (platform == ExePlatformClientExport) {
|
||||
snprintf(exename, sizeof(exename), "_export");
|
||||
}
|
||||
char filename[200];
|
||||
#ifndef NO_PIDLOG
|
||||
snprintf(filename, sizeof(filename), "%s%s_%04i.log", FileNames[id], exename, getpid());
|
||||
#else
|
||||
snprintf(filename, sizeof(filename), "%s%s.log", FileNames[id], exename);
|
||||
#endif
|
||||
fp[id] = fopen(filename, "a");
|
||||
if (!fp[id]) {
|
||||
std::cerr << "Failed to open log file: " << filename << std::endl;
|
||||
pLogStatus[id] |= 4; // set file state to error
|
||||
return false;
|
||||
}
|
||||
fputs("---------------------------------------------\n", fp[id]);
|
||||
write(id, "Starting Log: %s", filename);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmuLog::write(LogIDs id, const char *fmt, ...)
|
||||
{
|
||||
if (!logFileValid) {
|
||||
return false;
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
bool dofile = false;
|
||||
if (pLogStatus[id] & 1) {
|
||||
dofile = open(id);
|
||||
}
|
||||
if (!(dofile || pLogStatus[id] & 2)) {
|
||||
return false;
|
||||
}
|
||||
LockMutex lock(&MLog[id]);
|
||||
if (!logFileValid) {
|
||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||
}
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
if (dofile)
|
||||
#ifndef NO_PIDLOG
|
||||
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon + 1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||
#else
|
||||
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon + 1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||
#endif
|
||||
va_list argptr, tmpargptr;
|
||||
va_start(argptr, fmt);
|
||||
if (dofile) {
|
||||
va_copy(tmpargptr, argptr);
|
||||
vfprintf( fp[id], fmt, tmpargptr );
|
||||
}
|
||||
if (logCallbackFmt[id]) {
|
||||
msgCallbackFmt p = logCallbackFmt[id];
|
||||
va_copy(tmpargptr, argptr);
|
||||
p(id, fmt, tmpargptr );
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "[%s] ", LogNames[id]);
|
||||
vfprintf( stderr, fmt, argptr );
|
||||
}
|
||||
/* This is what's outputted to console */
|
||||
else {
|
||||
|
||||
#ifdef _WINDOWS
|
||||
HANDLE console_handle;
|
||||
console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
CONSOLE_FONT_INFOEX info = { 0 };
|
||||
info.cbSize = sizeof(info);
|
||||
info.dwFontSize.Y = 12; // leave X as zero
|
||||
info.FontWeight = FW_NORMAL;
|
||||
wcscpy(info.FaceName, L"Lucida Console");
|
||||
SetCurrentConsoleFontEx(console_handle, NULL, &info);
|
||||
|
||||
if (id == EQEmuLog::LogIDs::Status){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::Yellow); }
|
||||
if (id == EQEmuLog::LogIDs::Error){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightRed); }
|
||||
if (id == EQEmuLog::LogIDs::Normal){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightGreen); }
|
||||
if (id == EQEmuLog::LogIDs::Debug){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::Yellow); }
|
||||
if (id == EQEmuLog::LogIDs::Quest){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightCyan); }
|
||||
if (id == EQEmuLog::LogIDs::Commands){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightMagenta); }
|
||||
if (id == EQEmuLog::LogIDs::Crash){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightRed); }
|
||||
#endif
|
||||
|
||||
fprintf(stdout, "[%s] ", LogNames[id]);
|
||||
vfprintf( stdout, fmt, argptr );
|
||||
|
||||
#ifdef _WINDOWS
|
||||
/* Always set back to white*/
|
||||
SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::White);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
va_end(argptr);
|
||||
if (dofile) {
|
||||
fprintf(fp[id], "\n");
|
||||
}
|
||||
|
||||
/* Print Lind Endings */
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
} else {
|
||||
fprintf(stdout, "\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
if (dofile) {
|
||||
fflush(fp[id]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//write with Prefix and a VA_list
|
||||
bool EQEmuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list argptr)
|
||||
{
|
||||
if (!logFileValid) {
|
||||
return false;
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
bool dofile = false;
|
||||
if (pLogStatus[id] & 1) {
|
||||
dofile = open(id);
|
||||
}
|
||||
if (!(dofile || pLogStatus[id] & 2)) {
|
||||
return false;
|
||||
}
|
||||
LockMutex lock(&MLog[id]);
|
||||
if (!logFileValid) {
|
||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||
}
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
va_list tmpargptr;
|
||||
if (dofile) {
|
||||
#ifndef NO_PIDLOG
|
||||
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] %s", newtime->tm_mon + 1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
|
||||
#else
|
||||
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] %s", getpid(), newtime->tm_mon + 1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
|
||||
#endif
|
||||
va_copy(tmpargptr, argptr);
|
||||
vfprintf( fp[id], fmt, tmpargptr );
|
||||
}
|
||||
if (logCallbackPva[id]) {
|
||||
msgCallbackPva p = logCallbackPva[id];
|
||||
va_copy(tmpargptr, argptr);
|
||||
p(id, prefix, fmt, tmpargptr );
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "[%s] %s", LogNames[id], prefix);
|
||||
vfprintf( stderr, fmt, argptr );
|
||||
}
|
||||
/* Console Output */
|
||||
else {
|
||||
|
||||
|
||||
#ifdef _WINDOWS
|
||||
HANDLE console_handle;
|
||||
console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
CONSOLE_FONT_INFOEX info = { 0 };
|
||||
info.cbSize = sizeof(info);
|
||||
info.dwFontSize.Y = 12; // leave X as zero
|
||||
info.FontWeight = FW_NORMAL;
|
||||
wcscpy(info.FaceName, L"Lucida Console");
|
||||
SetCurrentConsoleFontEx(console_handle, NULL, &info);
|
||||
|
||||
if (id == EQEmuLog::LogIDs::Status){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::Yellow); }
|
||||
if (id == EQEmuLog::LogIDs::Error){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightRed); }
|
||||
if (id == EQEmuLog::LogIDs::Normal){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightGreen); }
|
||||
if (id == EQEmuLog::LogIDs::Debug){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::Yellow); }
|
||||
if (id == EQEmuLog::LogIDs::Quest){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightCyan); }
|
||||
if (id == EQEmuLog::LogIDs::Commands){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightMagenta); }
|
||||
if (id == EQEmuLog::LogIDs::Crash){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightRed); }
|
||||
#endif
|
||||
|
||||
fprintf(stdout, "[%s] %s", LogNames[id], prefix);
|
||||
vfprintf(stdout, fmt, argptr);
|
||||
|
||||
#ifdef _WINDOWS
|
||||
/* Always set back to white*/
|
||||
SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::White);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
va_end(argptr);
|
||||
if (dofile) {
|
||||
fprintf(fp[id], "\n");
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "\n");
|
||||
} else {
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
if (dofile) {
|
||||
fflush(fp[id]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count)
|
||||
{
|
||||
if (!logFileValid) {
|
||||
return false;
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
bool dofile = false;
|
||||
if (pLogStatus[id] & 1) {
|
||||
dofile = open(id);
|
||||
}
|
||||
if (!(dofile || pLogStatus[id] & 2)) {
|
||||
return false;
|
||||
}
|
||||
LockMutex lock(&MLog[id]);
|
||||
if (!logFileValid) {
|
||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||
}
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
if (dofile)
|
||||
#ifndef NO_PIDLOG
|
||||
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon + 1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||
#else
|
||||
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon + 1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||
#endif
|
||||
if (dofile) {
|
||||
fwrite(buf, size, count, fp[id]);
|
||||
fprintf(fp[id], "\n");
|
||||
}
|
||||
if (logCallbackBuf[id]) {
|
||||
msgCallbackBuf p = logCallbackBuf[id];
|
||||
p(id, buf, size, count);
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "[%s] ", LogNames[id]);
|
||||
fwrite(buf, size, count, stderr);
|
||||
fprintf(stderr, "\n");
|
||||
} else {
|
||||
#ifdef _WINDOWS
|
||||
HANDLE console_handle;
|
||||
console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
CONSOLE_FONT_INFOEX info = { 0 };
|
||||
info.cbSize = sizeof(info);
|
||||
info.dwFontSize.Y = 12; // leave X as zero
|
||||
info.FontWeight = FW_NORMAL;
|
||||
wcscpy(info.FaceName, L"Lucida Console");
|
||||
SetCurrentConsoleFontEx(console_handle, NULL, &info);
|
||||
|
||||
if (id == EQEmuLog::LogIDs::Status){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::Yellow); }
|
||||
if (id == EQEmuLog::LogIDs::Error){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightRed); }
|
||||
if (id == EQEmuLog::LogIDs::Normal){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightGreen); }
|
||||
if (id == EQEmuLog::LogIDs::Debug){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightGreen); }
|
||||
if (id == EQEmuLog::LogIDs::Quest){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightCyan); }
|
||||
if (id == EQEmuLog::LogIDs::Commands){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightMagenta); }
|
||||
if (id == EQEmuLog::LogIDs::Crash){ SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::LightRed); }
|
||||
#endif
|
||||
|
||||
fprintf(stdout, "[%s] ", LogNames[id]);
|
||||
fwrite(buf, size, count, stdout);
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
#ifdef _WINDOWS
|
||||
/* Always set back to white*/
|
||||
SetConsoleTextAttribute(console_handle, ConsoleColor::Colors::White);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (dofile) {
|
||||
fflush(fp[id]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEmuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...)
|
||||
{
|
||||
va_list argptr, tmpargptr;
|
||||
va_start(argptr, fmt);
|
||||
if (dofile) {
|
||||
va_copy(tmpargptr, argptr);
|
||||
vfprintf( fp[id], fmt, tmpargptr );
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
vfprintf( stderr, fmt, argptr );
|
||||
} else {
|
||||
vfprintf( stdout, fmt, argptr );
|
||||
}
|
||||
}
|
||||
va_end(argptr);
|
||||
return true;
|
||||
};
|
||||
|
||||
bool EQEmuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip)
|
||||
{
|
||||
if (!logFileValid) {
|
||||
#if EQDEBUG >= 10
|
||||
std::cerr << "Error: Dump() from null pointer" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
if (size == 0) {
|
||||
return true;
|
||||
}
|
||||
if (!LogFile) {
|
||||
return false;
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
bool dofile = false;
|
||||
if (pLogStatus[id] & 1) {
|
||||
dofile = open(id);
|
||||
}
|
||||
if (!(dofile || pLogStatus[id] & 2)) {
|
||||
return false;
|
||||
}
|
||||
LockMutex lock(&MLog[id]);
|
||||
if (!logFileValid) {
|
||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||
}
|
||||
write(id, "Dumping Packet: %i", size);
|
||||
// Output as HEX
|
||||
int beginningOfLineOffset = 0;
|
||||
uint32 indexInData;
|
||||
std::string asciiOutput;
|
||||
for (indexInData = skip; indexInData < size; indexInData++) {
|
||||
if ((indexInData - skip) % cols == 0) {
|
||||
if (indexInData != skip) {
|
||||
writeNTS(id, dofile, " | %s\n", asciiOutput.c_str());
|
||||
}
|
||||
writeNTS(id, dofile, "%4i: ", indexInData - skip);
|
||||
asciiOutput.clear();
|
||||
beginningOfLineOffset = 0;
|
||||
} else if ((indexInData - skip) % (cols / 2) == 0) {
|
||||
writeNTS(id, dofile, "- ");
|
||||
}
|
||||
writeNTS(id, dofile, "%02X ", (unsigned char)data[indexInData]);
|
||||
if (data[indexInData] >= 32 && data[indexInData] < 127) {
|
||||
// According to http://msdn.microsoft.com/en-us/library/vstudio/ee404875(v=vs.100).aspx
|
||||
// Visual Studio 2010 doesn't have std::to_string(int) but it does have the long long
|
||||
// version.
|
||||
asciiOutput.append(std::to_string((long long)data[indexInData]));
|
||||
} else {
|
||||
asciiOutput.append(".");
|
||||
}
|
||||
}
|
||||
uint32 k = ((indexInData - skip) - 1) % cols;
|
||||
if (k < 8) {
|
||||
writeNTS(id, dofile, " ");
|
||||
}
|
||||
for (uint32 h = k + 1; h < cols; h++) {
|
||||
writeNTS(id, dofile, " ");
|
||||
}
|
||||
writeNTS(id, dofile, " | %s\n", asciiOutput.c_str());
|
||||
if (dofile) {
|
||||
fflush(fp[id]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void EQEmuLog::SetCallback(LogIDs id, msgCallbackFmt proc)
|
||||
{
|
||||
if (!logFileValid) {
|
||||
return;
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return;
|
||||
}
|
||||
logCallbackFmt[id] = proc;
|
||||
}
|
||||
|
||||
void EQEmuLog::SetCallback(LogIDs id, msgCallbackBuf proc)
|
||||
{
|
||||
if (!logFileValid) {
|
||||
return;
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return;
|
||||
}
|
||||
logCallbackBuf[id] = proc;
|
||||
}
|
||||
|
||||
void EQEmuLog::SetCallback(LogIDs id, msgCallbackPva proc)
|
||||
{
|
||||
if (!logFileValid) {
|
||||
return;
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return;
|
||||
}
|
||||
logCallbackPva[id] = proc;
|
||||
}
|
||||
|
||||
void EQEmuLog::SetAllCallbacks(msgCallbackFmt proc)
|
||||
{
|
||||
if (!logFileValid) {
|
||||
return;
|
||||
}
|
||||
int r;
|
||||
for (r = Status; r < MaxLogID; r++) {
|
||||
SetCallback((LogIDs)r, proc);
|
||||
}
|
||||
}
|
||||
|
||||
void EQEmuLog::SetAllCallbacks(msgCallbackBuf proc)
|
||||
{
|
||||
if (!logFileValid) {
|
||||
return;
|
||||
}
|
||||
int r;
|
||||
for (r = Status; r < MaxLogID; r++) {
|
||||
SetCallback((LogIDs)r, proc);
|
||||
}
|
||||
}
|
||||
|
||||
void EQEmuLog::SetAllCallbacks(msgCallbackPva proc)
|
||||
{
|
||||
if (!logFileValid) {
|
||||
return;
|
||||
}
|
||||
int r;
|
||||
for (r = Status; r < MaxLogID; r++) {
|
||||
SetCallback((LogIDs)r, proc);
|
||||
}
|
||||
}
|
||||
|
||||
149
common/debug.h
149
common/debug.h
@ -1,149 +0,0 @@
|
||||
/* 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
|
||||
*/
|
||||
|
||||
// Debug Levels
|
||||
#ifndef EQDEBUG
|
||||
#define EQDEBUG 1
|
||||
#else
|
||||
////// File/Console options
|
||||
// 0 <= Quiet mode Errors to file Status and Normal ignored
|
||||
// 1 >= Status and Normal to console, Errors to file
|
||||
// 2 >= Status, Normal, and Error to console and logfile
|
||||
// 3 >= Lite debug
|
||||
// 4 >= Medium debug
|
||||
// 5 >= Debug release (Anything higher is not recommended for regular use)
|
||||
// 6 == (Reserved for special builds) Login opcode debug All packets dumped
|
||||
// 7 == (Reserved for special builds) Chat Opcode debug All packets dumped
|
||||
// 8 == (Reserved for special builds) World opcode debug All packets dumped
|
||||
// 9 == (Reserved for special builds) Zone Opcode debug All packets dumped
|
||||
// 10 >= More than you ever wanted to know
|
||||
//
|
||||
/////
|
||||
// Add more below to reserve for file's functions ect.
|
||||
/////
|
||||
// Any setup code based on defines should go here
|
||||
//
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_DEBUG) && defined(WIN32)
|
||||
#ifndef _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EQDEBUG_H
|
||||
#define EQDEBUG_H
|
||||
|
||||
#ifndef _WINDOWS
|
||||
#define DebugBreak() if(0) {}
|
||||
#endif
|
||||
|
||||
#define _WINSOCKAPI_ //stupid windows, trying to fix the winsock2 vs. winsock issues
|
||||
#if defined(WIN32) && ( defined(PACKETCOLLECTOR) || defined(COLLECTOR) )
|
||||
// Packet Collector on win32 requires winsock.h due to latest pcap.h
|
||||
// winsock.h must come before windows.h
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#include "logsys.h"
|
||||
|
||||
#include "../common/mutex.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
class EQEmuLog {
|
||||
public:
|
||||
EQEmuLog();
|
||||
~EQEmuLog();
|
||||
|
||||
enum LogIDs {
|
||||
Status = 0, /* This must stay the first entry in this list */
|
||||
Normal, /* Normal Logs */
|
||||
Error, /* Error Logs */
|
||||
Debug, /* Debug Logs */
|
||||
Quest, /* Quest Logs */
|
||||
Commands, /* Issued Comamnds */
|
||||
Crash, /* Crash Logs */
|
||||
Save, /* Client Saves */
|
||||
MaxLogID /* Max, used in functions to get the max log ID */
|
||||
};
|
||||
|
||||
//these are callbacks called for each
|
||||
typedef void (* msgCallbackBuf)(LogIDs id, const char *buf, uint8 size, uint32 count);
|
||||
typedef void (* msgCallbackFmt)(LogIDs id, const char *fmt, va_list ap);
|
||||
typedef void (* msgCallbackPva)(LogIDs id, const char *prefix, const char *fmt, va_list ap);
|
||||
|
||||
void SetAllCallbacks(msgCallbackFmt proc);
|
||||
void SetAllCallbacks(msgCallbackBuf proc);
|
||||
void SetAllCallbacks(msgCallbackPva proc);
|
||||
void SetCallback(LogIDs id, msgCallbackFmt proc);
|
||||
void SetCallback(LogIDs id, msgCallbackBuf proc);
|
||||
void SetCallback(LogIDs id, msgCallbackPva proc);
|
||||
|
||||
bool writebuf(LogIDs id, const char *buf, uint8 size, uint32 count);
|
||||
bool write(LogIDs id, const char *fmt, ...);
|
||||
bool writePVA(LogIDs id, const char *prefix, const char *fmt, va_list args);
|
||||
bool Dump(LogIDs id, uint8* data, uint32 size, uint32 cols=16, uint32 skip=0);
|
||||
private:
|
||||
bool open(LogIDs id);
|
||||
bool writeNTS(LogIDs id, bool dofile, const char *fmt, ...); // no error checking, assumes is open, no locking, no timestamp, no newline
|
||||
|
||||
Mutex MOpen;
|
||||
Mutex MLog[MaxLogID];
|
||||
FILE* fp[MaxLogID];
|
||||
|
||||
/* LogStatus: bitwise variable
|
||||
1 = output to file
|
||||
2 = output to stdout
|
||||
4 = fopen error, dont retry
|
||||
8 = use stderr instead (2 must be set)
|
||||
*/
|
||||
uint8 pLogStatus[MaxLogID];
|
||||
|
||||
msgCallbackFmt logCallbackFmt[MaxLogID];
|
||||
msgCallbackBuf logCallbackBuf[MaxLogID];
|
||||
msgCallbackPva logCallbackPva[MaxLogID];
|
||||
};
|
||||
|
||||
extern EQEmuLog* LogFile;
|
||||
|
||||
#ifdef _EQDEBUG
|
||||
class PerformanceMonitor {
|
||||
public:
|
||||
PerformanceMonitor(int64* ip) {
|
||||
p = ip;
|
||||
QueryPerformanceCounter(&tmp);
|
||||
}
|
||||
~PerformanceMonitor() {
|
||||
LARGE_INTEGER tmp2;
|
||||
QueryPerformanceCounter(&tmp2);
|
||||
*p += tmp2.QuadPart - tmp.QuadPart;
|
||||
}
|
||||
LARGE_INTEGER tmp;
|
||||
int64* p;
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
@ -16,7 +16,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "emu_opcodes.h"
|
||||
|
||||
const char *OpcodeNames[_maxEmuOpcode+1] = {
|
||||
|
||||
@ -23,7 +23,7 @@ crap into its own subclass of this object, it will clean things up
|
||||
tremendously.
|
||||
*/
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "emu_tcp_server.h"
|
||||
#include "emu_tcp_connection.h"
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#define EQ_CONSTANTS_H
|
||||
|
||||
#include "skills.h"
|
||||
#include "types.h"
|
||||
|
||||
/*
|
||||
** Item attributes
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "crc16.h"
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "eq_packet.h"
|
||||
#include "misc.h"
|
||||
#include "op_codes.h"
|
||||
|
||||
@ -16,7 +16,8 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "eqemu_logsys.h"
|
||||
#include "eq_packet.h"
|
||||
#include "eq_stream.h"
|
||||
#include "op_codes.h"
|
||||
@ -80,19 +81,19 @@ void EQStream::init(bool resetSession) {
|
||||
|
||||
OpMgr = nullptr;
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
_log(NET__ERROR, _L "init Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, 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);
|
||||
}
|
||||
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
_log(NET__ERROR, _L "init Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "init Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
}
|
||||
|
||||
EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
|
||||
{
|
||||
EQRawApplicationPacket *ap=nullptr;
|
||||
_log(NET__APP_CREATE, _L "Creating new application packet, length %d" __L, p->size);
|
||||
_raw(NET__APP_CREATE_HEX, 0xFFFF, p);
|
||||
Log.Out(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,8 +101,7 @@ EQRawApplicationPacket *EQStream::MakeApplicationPacket(EQProtocolPacket *p)
|
||||
EQRawApplicationPacket *EQStream::MakeApplicationPacket(const unsigned char *buf, uint32 len)
|
||||
{
|
||||
EQRawApplicationPacket *ap=nullptr;
|
||||
_log(NET__APP_CREATE, _L "Creating new application packet, length %d" __L, len);
|
||||
_hex(NET__APP_CREATE_HEX, buf, len);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Creating new application packet, length %d" __L, len);
|
||||
ap = new EQRawApplicationPacket(buf, len);
|
||||
return ap;
|
||||
}
|
||||
@ -131,8 +131,8 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
}
|
||||
|
||||
if (!Session && p->opcode!=OP_SessionRequest && p->opcode!=OP_SessionResponse) {
|
||||
_log(NET__DEBUG, _L "Session not initialized, packet ignored" __L);
|
||||
_raw(NET__DEBUG, 0xFFFF, p);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Session not initialized, packet ignored" __L);
|
||||
// _raw(NET__DEBUG, 0xFFFF, p);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -142,8 +142,8 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
while(processed < p->size) {
|
||||
subpacket_length=*(p->pBuffer+processed);
|
||||
EQProtocolPacket *subp=MakeProtocolPacket(p->pBuffer+processed+1,subpacket_length);
|
||||
_log(NET__NET_CREATE, _L "Extracting combined packet of length %d" __L, subpacket_length);
|
||||
_raw(NET__NET_CREATE_HEX, 0xFFFF, subp);
|
||||
Log.Out(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);
|
||||
delete subp;
|
||||
@ -157,12 +157,12 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
while(processed<p->size) {
|
||||
EQRawApplicationPacket *ap=nullptr;
|
||||
if ((subpacket_length=(unsigned char)*(p->pBuffer+processed))!=0xff) {
|
||||
_log(NET__NET_CREATE, _L "Extracting combined app packet of length %d, short len" __L, subpacket_length);
|
||||
Log.Out(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(NET__NET_CREATE, _L "Extracting combined app packet of length %d, short len" __L, subpacket_length);
|
||||
Log.Out(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;
|
||||
}
|
||||
@ -177,29 +177,29 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
case OP_Packet: {
|
||||
if(!p->pBuffer || (p->Size() < 4))
|
||||
{
|
||||
_log(NET__ERROR, _L "Received OP_Packet that was of malformed size" __L);
|
||||
Log.Out(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(NET__DEBUG, _L "Future OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq);
|
||||
_raw(NET__DEBUG, seq, p);
|
||||
Log.Out(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(NET__APP_TRACE, _L "OP_Packet Queue size=%d" __L, PacketQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "OP_Packet Queue size=%d" __L, PacketQueue.size());
|
||||
|
||||
//SendOutOfOrderAck(seq);
|
||||
|
||||
} else if (check == SeqPast) {
|
||||
_log(NET__DEBUG, _L "Duplicate OP_Packet: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq);
|
||||
_raw(NET__DEBUG, seq, p);
|
||||
Log.Out(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(NET__NET_TRACE, "OP_Packet: Removing older queued packet with sequence %d", seq);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[NET_TRACE] OP_Packet: Removing older queued packet with sequence %d", seq);
|
||||
delete qp;
|
||||
}
|
||||
|
||||
@ -208,8 +208,8 @@ 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(NET__NET_CREATE, _L "seq %d, Extracting combined packet of length %d" __L, seq, subp->size);
|
||||
_raw(NET__NET_CREATE_HEX, seq, subp);
|
||||
Log.Out(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);
|
||||
delete subp;
|
||||
@ -227,29 +227,29 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
case OP_Fragment: {
|
||||
if(!p->pBuffer || (p->Size() < 4))
|
||||
{
|
||||
_log(NET__ERROR, _L "Received OP_Fragment that was of malformed size" __L);
|
||||
Log.Out(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(NET__DEBUG, _L "Future OP_Fragment: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq);
|
||||
_raw(NET__DEBUG, seq, p);
|
||||
Log.Out(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(NET__APP_TRACE, _L "OP_Fragment Queue size=%d" __L, PacketQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "OP_Fragment Queue size=%d" __L, PacketQueue.size());
|
||||
|
||||
//SendOutOfOrderAck(seq);
|
||||
|
||||
} else if (check == SeqPast) {
|
||||
_log(NET__DEBUG, _L "Duplicate OP_Fragment: Expecting Seq=%d, but got Seq=%d" __L, NextInSeq, seq);
|
||||
_raw(NET__DEBUG, seq, p);
|
||||
Log.Out(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(NET__NET_TRACE, "OP_Fragment: Removing older queued packet with sequence %d", seq);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[NET_TRACE] OP_Fragment: Removing older queued packet with sequence %d", seq);
|
||||
delete qp;
|
||||
}
|
||||
SetNextAckToSend(seq);
|
||||
@ -257,18 +257,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(NET__NET_TRACE, _L "Fragment of oversized of length %d, seq %d: now at %d/%d" __L, p->size-2, seq, oversize_offset, oversize_length);
|
||||
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);
|
||||
if (oversize_offset==oversize_length) {
|
||||
if (*(p->pBuffer+2)==0x00 && *(p->pBuffer+3)==0x19) {
|
||||
EQProtocolPacket *subp=MakeProtocolPacket(oversize_buffer,oversize_offset);
|
||||
_log(NET__NET_CREATE, _L "seq %d, Extracting combined oversize packet of length %d" __L, seq, subp->size);
|
||||
//_raw(NET__NET_CREATE_HEX, subp);
|
||||
Log.Out(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(NET__NET_CREATE, _L "seq %d, completed combined oversize packet of length %d" __L, seq, ap->size);
|
||||
Log.Out(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);
|
||||
@ -283,7 +283,7 @@ 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(NET__NET_TRACE, _L "First fragment of oversized of seq %d: now at %d/%d" __L, seq, oversize_offset, oversize_length);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "First fragment of oversized of seq %d: now at %d/%d" __L, seq, oversize_offset, oversize_length);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -291,14 +291,14 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
case OP_KeepAlive: {
|
||||
#ifndef COLLECTOR
|
||||
NonSequencedPush(new EQProtocolPacket(p->opcode,p->pBuffer,p->size));
|
||||
_log(NET__NET_TRACE, _L "Received and queued reply to keep alive" __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Received and queued reply to keep alive" __L);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case OP_Ack: {
|
||||
if(!p->pBuffer || (p->Size() < 4))
|
||||
{
|
||||
_log(NET__ERROR, _L "Received OP_Ack that was of malformed size" __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_Ack that was of malformed size" __L);
|
||||
break;
|
||||
}
|
||||
#ifndef COLLECTOR
|
||||
@ -314,12 +314,12 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
case OP_SessionRequest: {
|
||||
if(p->Size() < sizeof(SessionRequest))
|
||||
{
|
||||
_log(NET__ERROR, _L "Received OP_SessionRequest that was of malformed size" __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionRequest that was of malformed size" __L);
|
||||
break;
|
||||
}
|
||||
#ifndef COLLECTOR
|
||||
if (GetState()==ESTABLISHED) {
|
||||
_log(NET__ERROR, _L "Received OP_SessionRequest in ESTABLISHED state (%d) streamactive (%i) attempt (%i)" __L, GetState(),streamactive,sessionAttempts);
|
||||
Log.Out(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,6 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//std::cout << "Got OP_SessionRequest" << std::endl;
|
||||
sessionAttempts++;
|
||||
// we set established below, so statistics will not be reset for session attempts/stream active.
|
||||
init(GetState()!=ESTABLISHED);
|
||||
@ -339,7 +338,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
SessionRequest *Request=(SessionRequest *)p->pBuffer;
|
||||
Session=ntohl(Request->Session);
|
||||
SetMaxLen(ntohl(Request->MaxLength));
|
||||
_log(NET__NET_TRACE, _L "Received OP_SessionRequest: session %lu, maxlen %d" __L, (unsigned long)Session, MaxLen);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionRequest: session %lu, maxlen %d" __L, (unsigned long)Session, MaxLen);
|
||||
SetState(ESTABLISHED);
|
||||
#ifndef COLLECTOR
|
||||
Key=0x11223344;
|
||||
@ -350,7 +349,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
case OP_SessionResponse: {
|
||||
if(p->Size() < sizeof(SessionResponse))
|
||||
{
|
||||
_log(NET__ERROR, _L "Received OP_SessionResponse that was of malformed size" __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionResponse that was of malformed size" __L);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -366,7 +365,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
compressed=(Response->Format&FLAG_COMPRESSED);
|
||||
encoded=(Response->Format&FLAG_ENCODED);
|
||||
|
||||
_log(NET__NET_TRACE, _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.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");
|
||||
|
||||
// Kinda kludgy, but trie for now
|
||||
if (StreamType==UnknownStream) {
|
||||
@ -389,17 +388,17 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
EQStreamState state = GetState();
|
||||
if(state == ESTABLISHED) {
|
||||
//client initiated disconnect?
|
||||
_log(NET__NET_TRACE, _L "Received unsolicited OP_SessionDisconnect. Treating like a client-initiated disconnect." __L);
|
||||
Log.Out(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(NET__NET_TRACE, _L "Received OP_SessionDisconnect when we have a pending close, they beat us to it. Were happy though." __L);
|
||||
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);
|
||||
_SendDisconnect();
|
||||
SetState(CLOSED);
|
||||
} else {
|
||||
//we are expecting this (or have already gotten it, but dont care either way)
|
||||
_log(NET__NET_TRACE, _L "Received expected OP_SessionDisconnect. Moving to closed state." __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Received expected OP_SessionDisconnect. Moving to closed state." __L);
|
||||
SetState(CLOSED);
|
||||
}
|
||||
}
|
||||
@ -407,7 +406,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
case OP_OutOfOrderAck: {
|
||||
if(!p->pBuffer || (p->Size() < 4))
|
||||
{
|
||||
_log(NET__ERROR, _L "Received OP_OutOfOrderAck that was of malformed size" __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfOrderAck that was of malformed size" __L);
|
||||
break;
|
||||
}
|
||||
#ifndef COLLECTOR
|
||||
@ -415,15 +414,15 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
MOutboundQueue.lock();
|
||||
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
_log(NET__ERROR, _L "Pre-OOA Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, 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);
|
||||
}
|
||||
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
_log(NET__ERROR, _L "Pre-OOA Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-OOA Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
//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(NET__NET_TRACE, _L "Received OP_OutOfOrderAck for sequence %d, starting retransmit at the start of our unacked buffer (seq %d, was %d)." __L,
|
||||
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,
|
||||
seq, SequencedBase, SequencedBase+NextSequencedSend);
|
||||
|
||||
bool retransmit_acked_packets = false;
|
||||
@ -434,7 +433,7 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
if(!retransmit_acked_packets) {
|
||||
uint16 sqsize = SequencedQueue.size();
|
||||
uint16 index = seq - SequencedBase;
|
||||
_log(NET__NET_TRACE, _L "OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize);
|
||||
if (index < sqsize) {
|
||||
std::deque<EQProtocolPacket *>::iterator sitr;
|
||||
sitr = SequencedQueue.begin();
|
||||
@ -449,15 +448,15 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
|
||||
NextSequencedSend = 0;
|
||||
} else {
|
||||
_log(NET__NET_TRACE, _L "Received OP_OutOfOrderAck for out-of-window %d. Window (%d->%d)." __L, seq, SequencedBase, NextOutSeq);
|
||||
Log.Out(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(NET__ERROR, _L "Post-OOA Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, 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);
|
||||
}
|
||||
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
_log(NET__ERROR, _L "Post-OOA Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Post-OOA Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
MOutboundQueue.unlock();
|
||||
#endif
|
||||
@ -466,12 +465,12 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
case OP_SessionStatRequest: {
|
||||
if(p->Size() < sizeof(SessionStats))
|
||||
{
|
||||
_log(NET__ERROR, _L "Received OP_SessionStatRequest that was of malformed size" __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionStatRequest that was of malformed size" __L);
|
||||
break;
|
||||
}
|
||||
#ifndef COLLECTOR
|
||||
SessionStats *Stats=(SessionStats *)p->pBuffer;
|
||||
_log(NET__NET_TRACE, _L "Received Stats: %lu packets received, %lu packets sent, Deltas: local %lu, (%lu <- %lu -> %lu) remote %lu" __L,
|
||||
Log.Out(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(Stats->packets_received), (unsigned long)ntohl(Stats->packets_sent), (unsigned long)ntohl(Stats->last_local_delta),
|
||||
(unsigned long)ntohl(Stats->low_delta), (unsigned long)ntohl(Stats->average_delta),
|
||||
(unsigned long)ntohl(Stats->high_delta), (unsigned long)ntohl(Stats->last_remote_delta));
|
||||
@ -492,18 +491,18 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
||||
}
|
||||
if(retransmittimeout > RETRANSMIT_TIMEOUT_MAX)
|
||||
retransmittimeout = RETRANSMIT_TIMEOUT_MAX;
|
||||
_log(NET__NET_TRACE, _L "Retransmit timeout recalculated to %dms" __L, retransmittimeout);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Retransmit timeout recalculated to %dms" __L, retransmittimeout);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case OP_SessionStatResponse: {
|
||||
_log(NET__NET_TRACE, _L "Received OP_SessionStatResponse. Ignoring." __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_SessionStatResponse. Ignoring." __L);
|
||||
}
|
||||
break;
|
||||
case OP_OutOfSession: {
|
||||
_log(NET__NET_TRACE, _L "Received OP_OutOfSession. Ignoring." __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Received OP_OutOfSession. Ignoring." __L);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -534,7 +533,7 @@ void EQStream::FastQueuePacket(EQApplicationPacket **p, bool ack_req)
|
||||
return;
|
||||
|
||||
if(OpMgr == nullptr || *OpMgr == nullptr) {
|
||||
_log(NET__DEBUG, _L "Packet enqueued into a stream with no opcode manager, dropping." __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Packet enqueued into a stream with no opcode manager, dropping." __L);
|
||||
delete pack;
|
||||
return;
|
||||
}
|
||||
@ -561,7 +560,7 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
|
||||
|
||||
// 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(NET__FRAGMENT, _L "Making oversized packet, len %d" __L, p->size);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Making oversized packet, len %d" __L, p->size);
|
||||
|
||||
unsigned char *tmpbuff=new unsigned char[p->size+3];
|
||||
length=p->serialize(opcode, tmpbuff);
|
||||
@ -570,7 +569,7 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
|
||||
*(uint32 *)(out->pBuffer+2)=htonl(p->Size());
|
||||
used=MaxLen-10;
|
||||
memcpy(out->pBuffer+6,tmpbuff,used);
|
||||
_log(NET__FRAGMENT, _L "First fragment: used %d/%d. Put size %d in the packet" __L, used, p->size, p->Size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "First fragment: used %d/%d. Put size %d in the packet" __L, used, p->size, p->Size());
|
||||
SequencedPush(out);
|
||||
|
||||
|
||||
@ -581,7 +580,7 @@ void EQStream::SendPacket(uint16 opcode, EQApplicationPacket *p)
|
||||
out->size=chunksize+2;
|
||||
SequencedPush(out);
|
||||
used+=chunksize;
|
||||
_log(NET__FRAGMENT, _L "Subsequent fragment: len %d, used %d/%d." __L, chunksize, used, p->size);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Subsequent fragment: len %d, used %d/%d." __L, chunksize, used, p->size);
|
||||
}
|
||||
delete p;
|
||||
delete[] tmpbuff;
|
||||
@ -605,22 +604,22 @@ void EQStream::SequencedPush(EQProtocolPacket *p)
|
||||
#else
|
||||
MOutboundQueue.lock();
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
_log(NET__ERROR, _L "Pre-Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
}
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
_log(NET__ERROR, _L "Pre-Push Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Push Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
|
||||
_log(NET__APP_TRACE, _L "Pushing sequenced packet %d of length %d. Base Seq is %d." __L, NextOutSeq, p->size, SequencedBase);
|
||||
Log.Out(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(NET__ERROR, _L "Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
}
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
_log(NET__ERROR, _L "Push Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Push Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
MOutboundQueue.unlock();
|
||||
#endif
|
||||
@ -632,7 +631,7 @@ void EQStream::NonSequencedPush(EQProtocolPacket *p)
|
||||
delete p;
|
||||
#else
|
||||
MOutboundQueue.lock();
|
||||
_log(NET__APP_TRACE, _L "Pushing non-sequenced packet of length %d" __L, p->size);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pushing non-sequenced packet of length %d" __L, p->size);
|
||||
NonSequencedQueue.push(p);
|
||||
MOutboundQueue.unlock();
|
||||
#endif
|
||||
@ -641,14 +640,14 @@ void EQStream::NonSequencedPush(EQProtocolPacket *p)
|
||||
void EQStream::SendAck(uint16 seq)
|
||||
{
|
||||
uint16 Seq=htons(seq);
|
||||
_log(NET__NET_ACKS, _L "Sending ack with sequence %d" __L, seq);
|
||||
Log.Out(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(NET__APP_TRACE, _L "Sending out of order ack with sequence %d" __L, seq);
|
||||
Log.Out(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)));
|
||||
}
|
||||
@ -664,7 +663,6 @@ void EQStream::Write(int eq_fd)
|
||||
int32 threshold=RateThreshold;
|
||||
MRate.unlock();
|
||||
if (BytesWritten > threshold) {
|
||||
//std::cout << "Over threshold: " << BytesWritten << " > " << threshold << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -684,7 +682,7 @@ void EQStream::Write(int eq_fd)
|
||||
// if we have a timeout defined and we have not received an ack recently enough, retransmit from beginning of queue
|
||||
if (RETRANSMIT_TIMEOUT_MULT && !SequencedQueue.empty() && NextSequencedSend &&
|
||||
(GetState()==ESTABLISHED) && ((retransmittimer+retransmittimeout) < Timer::GetCurrentTime())) {
|
||||
_log(NET__NET_TRACE, _L "Timeout since last ack received, starting retransmit at the start of our unacked "
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Timeout since last ack received, starting retransmit at the start of our unacked "
|
||||
"buffer (seq %d, was %d)." __L, SequencedBase, SequencedBase+NextSequencedSend);
|
||||
NextSequencedSend = 0;
|
||||
retransmittimer = Timer::GetCurrentTime(); // don't want to endlessly retransmit the first packet
|
||||
@ -705,24 +703,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(NET__NET_COMBINE, _L "Starting combined packet with non-seq packet of len %d" __L, p->size);
|
||||
Log.Out(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())) {
|
||||
// Tryint 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(NET__NET_COMBINE, _L "Combined packet full at len %d, next non-seq packet is len %d" __L, p->size, (NonSequencedQueue.front())->size);
|
||||
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);
|
||||
ReadyToSend.push(p);
|
||||
BytesWritten+=p->size;
|
||||
p=nullptr;
|
||||
|
||||
if (BytesWritten > threshold) {
|
||||
// Sent enough this round, lets stop to be fair
|
||||
_log(NET__RATES, _L "Exceeded write threshold in nonseq (%d > %d)" __L, BytesWritten, threshold);
|
||||
Log.Out(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(NET__NET_COMBINE, _L "Combined non-seq packet of len %d, yeilding %d combined." __L, (NonSequencedQueue.front())->size, p->size);
|
||||
Log.Out(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();
|
||||
}
|
||||
@ -733,48 +731,48 @@ void EQStream::Write(int eq_fd)
|
||||
|
||||
if (sitr!=SequencedQueue.end()) {
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
_log(NET__ERROR, _L "Pre-Send Seq NSS=%d Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, NextSequencedSend, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Send Seq NSS=%d Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, NextSequencedSend, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
}
|
||||
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
_log(NET__ERROR, _L "Pre-Send Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Send Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
uint16 seq_send = SequencedBase + NextSequencedSend; //just for logging...
|
||||
|
||||
if(SequencedQueue.empty()) {
|
||||
_log(NET__ERROR, _L "Tried to write a packet with an empty queue (%d is past next out %d)" __L, seq_send, NextOutSeq);
|
||||
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);
|
||||
SeqEmpty=true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(GetExecutablePlatform() == ExePlatformWorld || GetExecutablePlatform() == ExePlatformZone) {
|
||||
if (!RETRANSMIT_ACKED_PACKETS && (*sitr)->acked) {
|
||||
_log(NET__NET_TRACE, _L "Not retransmitting seq packet %d because already marked as acked" __L, seq_send);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Not retransmitting seq packet %d because already marked as acked" __L, seq_send);
|
||||
sitr++;
|
||||
NextSequencedSend++;
|
||||
} 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(NET__NET_COMBINE, _L "Starting combined packet with seq packet %d of len %d" __L, seq_send, p->size);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Starting combined packet with seq packet %d of len %d" __L, seq_send, p->size);
|
||||
++sitr;
|
||||
NextSequencedSend++;
|
||||
} 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(NET__NET_COMBINE, _L "Combined packet full at len %d, next seq packet %d is len %d" __L, p->size, seq_send, (*sitr)->size);
|
||||
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);
|
||||
ReadyToSend.push(p);
|
||||
BytesWritten+=p->size;
|
||||
p=nullptr;
|
||||
|
||||
if (BytesWritten > threshold) {
|
||||
// Sent enough this round, lets stop to be fair
|
||||
_log(NET__RATES, _L "Exceeded write threshold in seq (%d > %d)" __L, BytesWritten, threshold);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Exceeded write threshold in seq (%d > %d)" __L, BytesWritten, threshold);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Combine worked
|
||||
_log(NET__NET_COMBINE, _L "Combined seq packet %d of len %d, yeilding %d combined." __L, seq_send, (*sitr)->size, p->size);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Combined seq packet %d of len %d, yeilding %d combined." __L, seq_send, (*sitr)->size, p->size);
|
||||
++sitr;
|
||||
NextSequencedSend++;
|
||||
}
|
||||
@ -783,35 +781,35 @@ void EQStream::Write(int eq_fd)
|
||||
// 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(NET__NET_COMBINE, _L "Starting combined packet with seq packet %d of len %d" __L, seq_send, p->size);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Starting combined packet with seq packet %d of len %d" __L, seq_send, p->size);
|
||||
++sitr;
|
||||
NextSequencedSend++;
|
||||
} 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(NET__NET_COMBINE, _L "Combined packet full at len %d, next seq packet %d is len %d" __L, p->size, seq_send, (*sitr)->size);
|
||||
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);
|
||||
ReadyToSend.push(p);
|
||||
BytesWritten+=p->size;
|
||||
p=nullptr;
|
||||
|
||||
if (BytesWritten > threshold) {
|
||||
// Sent enough this round, lets stop to be fair
|
||||
_log(NET__RATES, _L "Exceeded write threshold in seq (%d > %d)" __L, BytesWritten, threshold);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Exceeded write threshold in seq (%d > %d)" __L, BytesWritten, threshold);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Combine worked
|
||||
_log(NET__NET_COMBINE, _L "Combined seq packet %d of len %d, yeilding %d combined." __L, seq_send, (*sitr)->size, p->size);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Combined seq packet %d of len %d, yeilding %d combined." __L, seq_send, (*sitr)->size, p->size);
|
||||
++sitr;
|
||||
NextSequencedSend++;
|
||||
}
|
||||
}
|
||||
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
_log(NET__ERROR, _L "Post send Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, 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);
|
||||
}
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
_log(NET__ERROR, _L "Post send Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Post send Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
} else {
|
||||
// No more sequenced packets
|
||||
@ -823,7 +821,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(NET__NET_COMBINE, _L "Final combined packet not full, len %d" __L, p->size);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Final combined packet not full, len %d" __L, p->size);
|
||||
ReadyToSend.push(p);
|
||||
BytesWritten+=p->size;
|
||||
}
|
||||
@ -840,7 +838,7 @@ void EQStream::Write(int eq_fd)
|
||||
if(SeqEmpty && NonSeqEmpty) {
|
||||
//no more data to send
|
||||
if(CheckState(CLOSING)) {
|
||||
_log(NET__DEBUG, _L "All outgoing data flushed, closing stream." __L );
|
||||
Log.Out(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();
|
||||
@ -903,7 +901,7 @@ EQProtocolPacket *out=new EQProtocolPacket(OP_SessionResponse,nullptr,sizeof(Ses
|
||||
|
||||
out->size=sizeof(SessionResponse);
|
||||
|
||||
_log(NET__NET_TRACE, _L "Sending OP_SessionResponse: session %lu, maxlen=%d, key=0x%x, compressed? %s, encoded? %s" __L,
|
||||
Log.Out(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);
|
||||
@ -917,7 +915,7 @@ EQProtocolPacket *out=new EQProtocolPacket(OP_SessionRequest,nullptr,sizeof(Sess
|
||||
Request->Session=htonl(time(nullptr));
|
||||
Request->MaxLength=htonl(512);
|
||||
|
||||
_log(NET__NET_TRACE, _L "Sending OP_SessionRequest: session %lu, maxlen=%d" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength));
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Sending OP_SessionRequest: session %lu, maxlen=%d" __L, (unsigned long)ntohl(Request->Session), ntohl(Request->MaxLength));
|
||||
|
||||
NonSequencedPush(out);
|
||||
}
|
||||
@ -931,7 +929,7 @@ void EQStream::_SendDisconnect()
|
||||
*(uint32 *)out->pBuffer=htonl(Session);
|
||||
NonSequencedPush(out);
|
||||
|
||||
_log(NET__NET_TRACE, _L "Sending OP_SessionDisconnect: session %lu" __L, (unsigned long)Session);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Sending OP_SessionDisconnect: session %lu" __L, (unsigned long)Session);
|
||||
}
|
||||
|
||||
void EQStream::InboundQueuePush(EQRawApplicationPacket *p)
|
||||
@ -957,11 +955,10 @@ EQRawApplicationPacket *p=nullptr;
|
||||
if(p) {
|
||||
if(OpMgr != nullptr && *OpMgr != nullptr) {
|
||||
EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode);
|
||||
#if EQDEBUG >= 4
|
||||
if(emu_op == OP_Unknown) {
|
||||
_log(NET__ERROR, "Unable to convert EQ opcode 0x%.4x to an Application opcode.", p->opcode);
|
||||
if (emu_op == OP_Unknown) {
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Unable to convert EQ opcode 0x%.4x to an Application opcode.", p->opcode);
|
||||
}
|
||||
#endif
|
||||
|
||||
p->SetOpcode(emu_op);
|
||||
}
|
||||
}
|
||||
@ -985,11 +982,10 @@ EQRawApplicationPacket *p=nullptr;
|
||||
if(p) {
|
||||
if(OpMgr != nullptr && *OpMgr != nullptr) {
|
||||
EmuOpcode emu_op = (*OpMgr)->EQToEmu(p->opcode);
|
||||
#if EQDEBUG >= 4
|
||||
if(emu_op == OP_Unknown) {
|
||||
LogFile->write(EQEmuLog::Debug, "Unable to convert EQ opcode 0x%.4x to an Application opcode.", p->opcode);
|
||||
Log.Out(Logs::General, Logs::Netcode, "Unable to convert EQ opcode 0x%.4x to an Application opcode.", p->opcode);
|
||||
}
|
||||
#endif
|
||||
|
||||
p->SetOpcode(emu_op);
|
||||
}
|
||||
}
|
||||
@ -1015,7 +1011,7 @@ void EQStream::InboundQueueClear()
|
||||
{
|
||||
EQApplicationPacket *p=nullptr;
|
||||
|
||||
_log(NET__APP_TRACE, _L "Clearing inbound queue" __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing inbound queue" __L);
|
||||
|
||||
MInboundQueue.lock();
|
||||
if (!InboundQueue.empty()) {
|
||||
@ -1058,7 +1054,7 @@ void EQStream::OutboundQueueClear()
|
||||
{
|
||||
EQProtocolPacket *p=nullptr;
|
||||
|
||||
_log(NET__APP_TRACE, _L "Clearing outbound queue" __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing outbound queue" __L);
|
||||
|
||||
MOutboundQueue.lock();
|
||||
while(!NonSequencedQueue.empty()) {
|
||||
@ -1080,7 +1076,7 @@ void EQStream::PacketQueueClear()
|
||||
{
|
||||
EQProtocolPacket *p=nullptr;
|
||||
|
||||
_log(NET__APP_TRACE, _L "Clearing future packet queue" __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Clearing future packet queue" __L);
|
||||
|
||||
if(!PacketQueue.empty()) {
|
||||
std::map<unsigned short,EQProtocolPacket *>::iterator itr;
|
||||
@ -1112,8 +1108,7 @@ uint32 newlength=0;
|
||||
delete p;
|
||||
ProcessQueue();
|
||||
} else {
|
||||
_log(NET__DEBUG, _L "Incoming packet failed checksum" __L);
|
||||
_hex(NET__NET_CREATE_HEX, buffer, length);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Incoming packet failed checksum" __L);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1142,33 +1137,33 @@ std::deque<EQProtocolPacket *>::iterator itr, tmp;
|
||||
MOutboundQueue.lock();
|
||||
//do a bit of sanity checking.
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
_log(NET__ERROR, _L "Pre-Ack Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Ack Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||
}
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
_log(NET__ERROR, _L "Pre-Ack Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Ack Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
|
||||
SeqOrder ord = CompareSequence(SequencedBase, seq);
|
||||
if(ord == SeqInOrder) {
|
||||
//they are not acking anything new...
|
||||
_log(NET__NET_ACKS, _L "Received an ack with no window advancement (seq %d)." __L, seq);
|
||||
Log.Out(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(NET__NET_ACKS, _L "Received an ack with backward window advancement (they gave %d, our window starts at %d). This is bad." __L, seq, SequencedBase);
|
||||
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);
|
||||
} else {
|
||||
_log(NET__NET_ACKS, _L "Received an ack up through sequence %d. Our base is %d." __L, seq, SequencedBase);
|
||||
Log.Out(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(NET__ERROR, _L "OUT OF PACKETS acked packet with sequence %lu. Next send is %d before this." __L, (unsigned long)SequencedBase, NextSequencedSend);
|
||||
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, NextSequencedSend);
|
||||
SequencedBase = NextOutSeq;
|
||||
NextSequencedSend = 0;
|
||||
break;
|
||||
}
|
||||
_log(NET__NET_ACKS, _L "Removing acked packet with sequence %lu. Next send is %d before this." __L, (unsigned long)SequencedBase, NextSequencedSend);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Removing acked packet with sequence %lu. Next send is %d before this." __L, (unsigned long)SequencedBase, NextSequencedSend);
|
||||
//clean out the acked packet
|
||||
delete SequencedQueue.front();
|
||||
SequencedQueue.pop_front();
|
||||
@ -1179,10 +1174,10 @@ _log(NET__ERROR, _L "OUT OF PACKETS acked packet with sequence %lu. Next send is
|
||||
SequencedBase++;
|
||||
}
|
||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||
_log(NET__ERROR, _L "Post-Ack on %d Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, seq, 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);
|
||||
}
|
||||
if(NextSequencedSend > SequencedQueue.size()) {
|
||||
_log(NET__ERROR, _L "Post-Ack Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Post-Ack Next Send Sequence is beyond the end of the queue NSS %d > SQ %d" __L, NextSequencedSend, SequencedQueue.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1192,7 +1187,7 @@ if(NextSequencedSend > SequencedQueue.size()) {
|
||||
void EQStream::SetNextAckToSend(uint32 seq)
|
||||
{
|
||||
MAcks.lock();
|
||||
_log(NET__NET_ACKS, _L "Set Next Ack To Send to %lu" __L, (unsigned long)seq);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Set Next Ack To Send to %lu" __L, (unsigned long)seq);
|
||||
NextAckToSend=seq;
|
||||
MAcks.unlock();
|
||||
}
|
||||
@ -1200,7 +1195,7 @@ void EQStream::SetNextAckToSend(uint32 seq)
|
||||
void EQStream::SetLastAckSent(uint32 seq)
|
||||
{
|
||||
MAcks.lock();
|
||||
_log(NET__NET_ACKS, _L "Set Last Ack Sent to %lu" __L, (unsigned long)seq);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Set Last Ack Sent to %lu" __L, (unsigned long)seq);
|
||||
LastAckSent=seq;
|
||||
MAcks.unlock();
|
||||
}
|
||||
@ -1213,10 +1208,10 @@ void EQStream::ProcessQueue()
|
||||
|
||||
EQProtocolPacket *qp=nullptr;
|
||||
while((qp=RemoveQueue(NextInSeq))!=nullptr) {
|
||||
_log(NET__DEBUG, _L "Processing Queued Packet: Seq=%d" __L, NextInSeq);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Processing Queued Packet: Seq=%d" __L, NextInSeq);
|
||||
ProcessPacket(qp);
|
||||
delete qp;
|
||||
_log(NET__APP_TRACE, _L "OP_Packet Queue size=%d" __L, PacketQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "OP_Packet Queue size=%d" __L, PacketQueue.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1227,21 +1222,21 @@ EQProtocolPacket *qp=nullptr;
|
||||
if ((itr=PacketQueue.find(seq))!=PacketQueue.end()) {
|
||||
qp=itr->second;
|
||||
PacketQueue.erase(itr);
|
||||
_log(NET__APP_TRACE, _L "OP_Packet Queue size=%d" __L, PacketQueue.size());
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "OP_Packet Queue size=%d" __L, PacketQueue.size());
|
||||
}
|
||||
return qp;
|
||||
}
|
||||
|
||||
void EQStream::SetStreamType(EQStreamType type)
|
||||
{
|
||||
_log(NET__NET_TRACE, _L "Changing stream type from %s to %s" __L, StreamTypeString(StreamType), StreamTypeString(type));
|
||||
Log.Out(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(NET__NET_TRACE, _L "Login stream has app opcode size %d, is not compressed or encoded." __L, app_opcode_size);
|
||||
Log.Out(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:
|
||||
@ -1249,7 +1244,7 @@ void EQStream::SetStreamType(EQStreamType type)
|
||||
app_opcode_size=1;
|
||||
compressed=false;
|
||||
encoded=true;
|
||||
_log(NET__NET_TRACE, _L "Chat/Mail stream has app opcode size %d, is not compressed, and is encoded." __L, app_opcode_size);
|
||||
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);
|
||||
break;
|
||||
case ZoneStream:
|
||||
case WorldStream:
|
||||
@ -1257,7 +1252,7 @@ void EQStream::SetStreamType(EQStreamType type)
|
||||
app_opcode_size=2;
|
||||
compressed=true;
|
||||
encoded=false;
|
||||
_log(NET__NET_TRACE, _L "World/Zone stream has app opcode size %d, is compressed, and is not encoded." __L, app_opcode_size);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1307,7 +1302,7 @@ EQStream::SeqOrder EQStream::CompareSequence(uint16 expected_seq , uint16 seq)
|
||||
|
||||
void EQStream::SetState(EQStreamState state) {
|
||||
MState.lock();
|
||||
_log(NET__NET_TRACE, _L "Changing state from %d to %d" __L, State, state);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Changing state from %d to %d" __L, State, state);
|
||||
State=state;
|
||||
MState.unlock();
|
||||
}
|
||||
@ -1319,29 +1314,29 @@ void EQStream::CheckTimeout(uint32 now, uint32 timeout) {
|
||||
|
||||
EQStreamState orig_state = GetState();
|
||||
if (orig_state == CLOSING && !outgoing_data) {
|
||||
_log(NET__NET_TRACE, _L "Out of data in closing state, disconnecting." __L);
|
||||
Log.Out(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(NET__DEBUG, _L "Timeout expired in closing state. Moving to closed state." __L);
|
||||
Log.Out(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(NET__DEBUG, _L "Timeout expired in disconnecting state. Moving to closed state." __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Timeout expired in disconnecting state. Moving to closed state." __L);
|
||||
SetState(CLOSED);
|
||||
break;
|
||||
case CLOSED:
|
||||
_log(NET__DEBUG, _L "Timeout expired in closed state??" __L);
|
||||
Log.Out(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(NET__DEBUG, _L "Timeout expired in established state. Closing connection." __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Timeout expired in established state. Closing connection." __L);
|
||||
_SendDisconnect();
|
||||
SetState(DISCONNECTING);
|
||||
break;
|
||||
@ -1370,11 +1365,11 @@ void EQStream::AdjustRates(uint32 average_delta)
|
||||
MRate.lock();
|
||||
RateThreshold=RATEBASE/average_delta;
|
||||
DecayRate=DECAYBASE/average_delta;
|
||||
_log(NET__RATES, _L "Adjusting data rate to thresh %d, decay %d based on avg delta %d" __L,
|
||||
Log.Out(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(NET__RATES, _L "Not adjusting data rate because avg delta over max (%d > %d)" __L,
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Not adjusting data rate because avg delta over max (%d > %d)" __L,
|
||||
average_delta, AVERAGE_DELTA_MAX);
|
||||
}
|
||||
} else {
|
||||
@ -1382,7 +1377,7 @@ void EQStream::AdjustRates(uint32 average_delta)
|
||||
MRate.lock();
|
||||
RateThreshold=RATEBASE/average_delta;
|
||||
DecayRate=DECAYBASE/average_delta;
|
||||
_log(NET__RATES, _L "Adjusting data rate to thresh %d, decay %d based on avg delta %d" __L,
|
||||
Log.Out(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();
|
||||
}
|
||||
@ -1392,12 +1387,12 @@ void EQStream::AdjustRates(uint32 average_delta)
|
||||
void EQStream::Close() {
|
||||
if(HasOutgoingData()) {
|
||||
//there is pending data, wait for it to go out.
|
||||
_log(NET__DEBUG, _L "Stream requested to Close(), but there is pending data, waiting for it." __L);
|
||||
Log.Out(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(NET__DEBUG, _L "Stream closing immediate due to Close()" __L);
|
||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Stream closing immediate due to Close()" __L);
|
||||
SetState(DISCONNECTING);
|
||||
}
|
||||
}
|
||||
@ -1425,19 +1420,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(NET__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.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);
|
||||
res = MatchSuccessful;
|
||||
} else if(sig->first_length == 0) {
|
||||
_log(NET__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.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);
|
||||
res = MatchSuccessful;
|
||||
} else {
|
||||
//opcode matched but length did not.
|
||||
_log(NET__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.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);
|
||||
res = MatchFailed;
|
||||
}
|
||||
} else {
|
||||
//first opcode did not match..
|
||||
_log(NET__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.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);
|
||||
res = MatchFailed;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "eqemu_logsys.h"
|
||||
#include "eq_stream_factory.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
@ -25,13 +26,13 @@ ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
|
||||
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Starting EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
|
||||
Log.Out(Logs::Detail, Logs::None, "Starting EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
fs->ReaderLoop();
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
|
||||
Log.Out(Logs::Detail, Logs::None, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
THREAD_RETURN(nullptr);
|
||||
@ -42,13 +43,13 @@ ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
|
||||
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Starting EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
|
||||
Log.Out(Logs::Detail, Logs::None, "Starting EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
fs->WriterLoop();
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Ending EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
|
||||
Log.Out(Logs::Detail, Logs::None, "Ending EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
THREAD_RETURN(nullptr);
|
||||
@ -105,8 +106,6 @@ struct sockaddr_in address;
|
||||
fcntl(sock, F_SETFL, O_NONBLOCK);
|
||||
#endif
|
||||
//moved these because on windows the output was delayed and causing the console window to look bad
|
||||
//std::cout << "Starting factory Reader" << std::endl;
|
||||
//std::cout << "Starting factory Writer" << std::endl;
|
||||
#ifdef _WINDOWS
|
||||
_beginthread(EQStreamFactoryReaderLoop,0, this);
|
||||
_beginthread(EQStreamFactoryWriterLoop,0, this);
|
||||
@ -120,7 +119,6 @@ struct sockaddr_in address;
|
||||
EQStream *EQStreamFactory::Pop()
|
||||
{
|
||||
EQStream *s=nullptr;
|
||||
//std::cout << "Pop():Locking MNewStreams" << std::endl;
|
||||
MNewStreams.lock();
|
||||
if (NewStreams.size()) {
|
||||
s=NewStreams.front();
|
||||
@ -128,18 +126,15 @@ EQStream *s=nullptr;
|
||||
s->PutInUse();
|
||||
}
|
||||
MNewStreams.unlock();
|
||||
//std::cout << "Pop(): Unlocking MNewStreams" << std::endl;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void EQStreamFactory::Push(EQStream *s)
|
||||
{
|
||||
//std::cout << "Push():Locking MNewStreams" << std::endl;
|
||||
MNewStreams.lock();
|
||||
NewStreams.push(s);
|
||||
MNewStreams.unlock();
|
||||
//std::cout << "Push(): Unlocking MNewStreams" << std::endl;
|
||||
}
|
||||
|
||||
void EQStreamFactory::ReaderLoop()
|
||||
@ -240,7 +235,6 @@ void EQStreamFactory::CheckTimeout()
|
||||
//give it a little time for everybody to finish with it
|
||||
} else {
|
||||
//everybody is done, we can delete it now
|
||||
//std::cout << "Removing connection" << std::endl;
|
||||
std::map<std::pair<uint32, uint16>,EQStream *>::iterator temp=stream_itr;
|
||||
++stream_itr;
|
||||
//let whoever has the stream outside delete it
|
||||
@ -318,9 +312,7 @@ Timer DecayTimer(20);
|
||||
stream_count=Streams.size();
|
||||
MStreams.unlock();
|
||||
if (!stream_count) {
|
||||
//std::cout << "No streams, waiting on condition" << std::endl;
|
||||
WriterWork.Wait();
|
||||
//std::cout << "Awake from condition, must have a stream now" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "eqemu_logsys.h"
|
||||
#include "eq_stream_ident.h"
|
||||
#include "eq_stream_proxy.h"
|
||||
#include "logsys.h"
|
||||
|
||||
|
||||
EQStreamIdentifier::~EQStreamIdentifier() {
|
||||
while(!m_identified.empty()) {
|
||||
@ -45,7 +46,7 @@ void EQStreamIdentifier::Process() {
|
||||
//first see if this stream has expired
|
||||
if(r->expire.Check(false)) {
|
||||
//this stream has failed to match any pattern in our timeframe.
|
||||
_log(NET__IDENTIFY, "Unable to identify stream from %s:%d before timeout.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()));
|
||||
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Unable to identify stream from %s:%d before timeout.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()));
|
||||
r->stream->ReleaseFromUse();
|
||||
delete r;
|
||||
cur = m_streams.erase(cur);
|
||||
@ -61,23 +62,23 @@ void EQStreamIdentifier::Process() {
|
||||
}
|
||||
if(r->stream->GetState() != ESTABLISHED) {
|
||||
//the stream closed before it was identified.
|
||||
_log(NET__IDENTIFY, "Unable to identify stream from %s:%d before it closed.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()));
|
||||
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()));
|
||||
switch(r->stream->GetState())
|
||||
{
|
||||
case ESTABLISHED:
|
||||
_log(NET__IDENTIFY, "Stream state was Established");
|
||||
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Established");
|
||||
break;
|
||||
case CLOSING:
|
||||
_log(NET__IDENTIFY, "Stream state was Closing");
|
||||
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Closing");
|
||||
break;
|
||||
case DISCONNECTING:
|
||||
_log(NET__IDENTIFY, "Stream state was Disconnecting");
|
||||
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Disconnecting");
|
||||
break;
|
||||
case CLOSED:
|
||||
_log(NET__IDENTIFY, "Stream state was Closed");
|
||||
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Closed");
|
||||
break;
|
||||
default:
|
||||
_log(NET__IDENTIFY, "Stream state was Unestablished or unknown");
|
||||
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Stream state was Unestablished or unknown");
|
||||
break;
|
||||
}
|
||||
r->stream->ReleaseFromUse();
|
||||
@ -102,13 +103,13 @@ void EQStreamIdentifier::Process() {
|
||||
switch(res) {
|
||||
case EQStream::MatchNotReady:
|
||||
//the stream has not received enough packets to compare with this signature
|
||||
// _log(NET__IDENT_TRACE, "%s:%d: Tried patch %s, but stream is not ready for it.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()), p->name.c_str());
|
||||
// Log.LogDebugType(Logs::General, Logs::Netcode, "[IDENT_TRACE] %s:%d: Tried patch %s, but stream is not ready for it.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()), p->name.c_str());
|
||||
all_ready = false;
|
||||
break;
|
||||
case EQStream::MatchSuccessful: {
|
||||
//yay, a match.
|
||||
|
||||
_log(NET__IDENTIFY, "Identified stream %s:%d with signature %s", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()), p->name.c_str());
|
||||
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());
|
||||
|
||||
// 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);
|
||||
@ -122,7 +123,7 @@ void EQStreamIdentifier::Process() {
|
||||
}
|
||||
case EQStream::MatchFailed:
|
||||
//do nothing...
|
||||
_log(NET__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.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());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -130,7 +131,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(NET__IDENTIFY, "Unable to identify stream from %s:%d, no match found.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()));
|
||||
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()));
|
||||
r->stream->ReleaseFromUse();
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "eq_stream_proxy.h"
|
||||
#include "eq_stream.h"
|
||||
#include "struct_strategy.h"
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "eqdb.h"
|
||||
#include "database.h"
|
||||
#include <mysql.h>
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "eqdb_res.h"
|
||||
#include <mysql.h>
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "eqemu_config.h"
|
||||
#include "misc_functions.h"
|
||||
|
||||
@ -254,10 +254,6 @@ void EQEmuConfig::do_files(TiXmlElement *ele)
|
||||
if (text) {
|
||||
OpCodesFile = text;
|
||||
}
|
||||
text = ParseTextBlock(ele, "logsettings", true);
|
||||
if (text) {
|
||||
LogSettingsFile = text;
|
||||
}
|
||||
text = ParseTextBlock(ele, "eqtime", true);
|
||||
if (text) {
|
||||
EQTimeFile = text;
|
||||
@ -415,9 +411,6 @@ std::string EQEmuConfig::GetByName(const std::string &var_name) const
|
||||
if (var_name == "EQTimeFile") {
|
||||
return (EQTimeFile);
|
||||
}
|
||||
if (var_name == "LogSettingsFile") {
|
||||
return (LogSettingsFile);
|
||||
}
|
||||
if (var_name == "MapDir") {
|
||||
return (MapDir);
|
||||
}
|
||||
@ -483,7 +476,6 @@ void EQEmuConfig::Dump() const
|
||||
std::cout << "SpellsFile = " << SpellsFile << std::endl;
|
||||
std::cout << "OpCodesFile = " << OpCodesFile << std::endl;
|
||||
std::cout << "EQTimeFile = " << EQTimeFile << std::endl;
|
||||
std::cout << "LogSettingsFile = " << LogSettingsFile << std::endl;
|
||||
std::cout << "MapDir = " << MapDir << std::endl;
|
||||
std::cout << "QuestDir = " << QuestDir << std::endl;
|
||||
std::cout << "PluginDir = " << PluginDir << std::endl;
|
||||
|
||||
@ -80,7 +80,6 @@ class EQEmuConfig : public XMLParser
|
||||
std::string SpellsFile;
|
||||
std::string OpCodesFile;
|
||||
std::string EQTimeFile;
|
||||
std::string LogSettingsFile;
|
||||
|
||||
// From <directories/>
|
||||
std::string MapDir;
|
||||
@ -156,7 +155,6 @@ class EQEmuConfig : public XMLParser
|
||||
SpellsFile = "spells_us.txt";
|
||||
OpCodesFile = "opcodes.conf";
|
||||
EQTimeFile = "eqtime.cfg";
|
||||
LogSettingsFile = "log.ini";
|
||||
// Dirs
|
||||
MapDir = "Maps";
|
||||
QuestDir = "quests";
|
||||
|
||||
@ -1,135 +0,0 @@
|
||||
/* 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
|
||||
*/
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "eqemu_error.h"
|
||||
#include "linked_list.h"
|
||||
#include "mutex.h"
|
||||
#include "misc_functions.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef _WINDOWS
|
||||
#include <conio.h>
|
||||
#endif
|
||||
|
||||
void UpdateWindowTitle(char* iNewTitle = 0);
|
||||
void CatchSignal(int sig_num);
|
||||
|
||||
const char* EQEMuErrorText[EQEMuError_MaxErrorID] = { "ErrorID# 0, No Error",
|
||||
"MySQL Error #1405 or #2001 means your mysql server rejected the username and password you presented it.",
|
||||
"MySQL Error #2003 means you were unable to connect to the mysql server.",
|
||||
"MySQL Error #2005 means you there are too many connections on the mysql server. The server is overloaded.",
|
||||
"MySQL Error #2007 means you the server is out of memory. The server is overloaded.",
|
||||
};
|
||||
|
||||
LinkedList<char*>* EQEMuErrorList;
|
||||
Mutex* MEQEMuErrorList;
|
||||
AutoDelete< LinkedList<char*> > ADEQEMuErrorList(&EQEMuErrorList);
|
||||
AutoDelete<Mutex> ADMEQEMuErrorList(&MEQEMuErrorList);
|
||||
|
||||
const char* GetErrorText(uint32 iError) {
|
||||
if (iError >= EQEMuError_MaxErrorID)
|
||||
return "ErrorID# out of range";
|
||||
else
|
||||
return EQEMuErrorText[iError];
|
||||
}
|
||||
|
||||
void AddEQEMuError(eEQEMuError iError, bool iExitNow) {
|
||||
if (!iError)
|
||||
return;
|
||||
if (!EQEMuErrorList) {
|
||||
EQEMuErrorList = new LinkedList<char*>;
|
||||
MEQEMuErrorList = new Mutex;
|
||||
}
|
||||
LockMutex lock(MEQEMuErrorList);
|
||||
|
||||
LinkedListIterator<char*> iterator(*EQEMuErrorList);
|
||||
iterator.Reset();
|
||||
while (iterator.MoreElements()) {
|
||||
if (iterator.GetData()[0] == 1) {
|
||||
//Umm... this gets a big WTF...
|
||||
// if (*((uint32*) iterator.GetData()[1]) == iError)
|
||||
//not sure whats going on, using a character as a pointer....
|
||||
if (*((eEQEMuError*) &(iterator.GetData()[1])) == iError)
|
||||
return;
|
||||
}
|
||||
iterator.Advance();
|
||||
}
|
||||
|
||||
char* tmp = new char[6];
|
||||
tmp[0] = 1;
|
||||
tmp[5] = 0;
|
||||
*((uint32*) &tmp[1]) = iError;
|
||||
EQEMuErrorList->Append(tmp);
|
||||
|
||||
if (iExitNow)
|
||||
CatchSignal(2);
|
||||
}
|
||||
|
||||
void AddEQEMuError(char* iError, bool iExitNow) {
|
||||
if (!iError)
|
||||
return;
|
||||
if (!EQEMuErrorList) {
|
||||
EQEMuErrorList = new LinkedList<char*>;
|
||||
MEQEMuErrorList = new Mutex;
|
||||
}
|
||||
LockMutex lock(MEQEMuErrorList);
|
||||
char* tmp = strcpy(new char[strlen(iError) + 1], iError);
|
||||
EQEMuErrorList->Append(tmp);
|
||||
|
||||
if (iExitNow)
|
||||
CatchSignal(2);
|
||||
}
|
||||
|
||||
uint32 CheckEQEMuError() {
|
||||
if (!EQEMuErrorList)
|
||||
return 0;
|
||||
uint32 ret = 0;
|
||||
char* tmp = 0;
|
||||
bool HeaderPrinted = false;
|
||||
LockMutex lock(MEQEMuErrorList);
|
||||
|
||||
while ((tmp = EQEMuErrorList->Pop() )) {
|
||||
if (!HeaderPrinted) {
|
||||
fprintf(stdout, "===============================\nRuntime errors:\n\n");
|
||||
HeaderPrinted = true;
|
||||
}
|
||||
if (tmp[0] == 1) {
|
||||
fprintf(stdout, "%s\n", GetErrorText(*((uint32*) &tmp[1])));
|
||||
fprintf(stdout, "For more information on this error, visit http://www.eqemu.net/eqemuerror.php?id=%u\n\n", *((uint32*) &tmp[1]));
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "%s\n\n", tmp);
|
||||
}
|
||||
safe_delete(tmp);
|
||||
ret++;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void CheckEQEMuErrorAndPause() {
|
||||
#ifdef _WINDOWS
|
||||
if (CheckEQEMuError()) {
|
||||
fprintf(stdout, "Hit any key to exit\n");
|
||||
UpdateWindowTitle("Error");
|
||||
getch();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
343
common/eqemu_logsys.cpp
Normal file
343
common/eqemu_logsys.cpp
Normal file
@ -0,0 +1,343 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2015 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 "eqemu_logsys.h"
|
||||
#include "platform.h"
|
||||
#include "string_util.h"
|
||||
#include "database.h"
|
||||
#include "misc.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <time.h>
|
||||
|
||||
std::ofstream process_log;
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <direct.h>
|
||||
#include <conio.h>
|
||||
#include <iostream>
|
||||
#include <dos.h>
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
/* Linux ANSI console color defines */
|
||||
#define LC_RESET "\033[0m"
|
||||
#define LC_BLACK "\033[30m" /* Black */
|
||||
#define LC_RED "\033[31m" /* Red */
|
||||
#define LC_GREEN "\033[32m" /* Green */
|
||||
#define LC_YELLOW "\033[33m" /* Yellow */
|
||||
#define LC_BLUE "\033[34m" /* Blue */
|
||||
#define LC_MAGENTA "\033[35m" /* Magenta */
|
||||
#define LC_CYAN "\033[36m" /* Cyan */
|
||||
#define LC_WHITE "\033[37m" /* White */
|
||||
|
||||
namespace Console {
|
||||
enum Color {
|
||||
Black = 0,
|
||||
Blue = 1,
|
||||
Green = 2,
|
||||
Cyan = 3,
|
||||
Red = 4,
|
||||
Magenta = 5,
|
||||
Brown = 6,
|
||||
LightGray = 7,
|
||||
DarkGray = 8,
|
||||
LightBlue = 9,
|
||||
LightGreen = 10,
|
||||
LightCyan = 11,
|
||||
LightRed = 12,
|
||||
LightMagenta = 13,
|
||||
Yellow = 14,
|
||||
White = 15,
|
||||
};
|
||||
}
|
||||
|
||||
EQEmuLogSys::EQEmuLogSys(){
|
||||
on_log_gmsay_hook = [](uint16 log_type, std::string&) {};
|
||||
bool file_logs_enabled = false;
|
||||
int log_platform = 0;
|
||||
}
|
||||
|
||||
EQEmuLogSys::~EQEmuLogSys(){
|
||||
}
|
||||
|
||||
void EQEmuLogSys::LoadLogSettingsDefaults()
|
||||
{
|
||||
/* Get Executable platform currently running this code (Zone/World/etc) */
|
||||
log_platform = GetExecutablePlatformInt();
|
||||
|
||||
/* Zero out Array */
|
||||
for (int i = 0; i < Logs::LogCategory::MaxCategoryID; i++){
|
||||
log_settings[i].log_to_console = 0;
|
||||
log_settings[i].log_to_file = 0;
|
||||
log_settings[i].log_to_gmsay = 0;
|
||||
}
|
||||
|
||||
/* Set Defaults */
|
||||
log_settings[Logs::World_Server].log_to_console = Logs::General;
|
||||
log_settings[Logs::Zone_Server].log_to_console = Logs::General;
|
||||
log_settings[Logs::QS_Server].log_to_console = Logs::General;
|
||||
log_settings[Logs::UCS_Server].log_to_console = Logs::General;
|
||||
log_settings[Logs::Crash].log_to_console = Logs::General;
|
||||
log_settings[Logs::MySQLError].log_to_console = Logs::General;
|
||||
|
||||
/* Declare process file names for log writing
|
||||
If there is no process_file_name declared, no log file will be written, simply
|
||||
*/
|
||||
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformWorld){
|
||||
platform_file_name = "world";
|
||||
}
|
||||
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformQueryServ){
|
||||
platform_file_name = "query_server";
|
||||
}
|
||||
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone){
|
||||
platform_file_name = "zone";
|
||||
}
|
||||
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformUCS){
|
||||
platform_file_name = "ucs";
|
||||
}
|
||||
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformLogin){
|
||||
platform_file_name = "login";
|
||||
}
|
||||
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformLogin){
|
||||
platform_file_name = "launcher";
|
||||
}
|
||||
}
|
||||
|
||||
std::string EQEmuLogSys::FormatOutMessageString(uint16 log_category, std::string in_message){
|
||||
std::string category_string = "";
|
||||
if (log_category > 0 && Logs::LogCategoryName[log_category]){
|
||||
category_string = StringFormat("[%s] ", Logs::LogCategoryName[log_category]);
|
||||
}
|
||||
return StringFormat("%s%s", category_string.c_str(), in_message.c_str());
|
||||
}
|
||||
|
||||
void EQEmuLogSys::ProcessGMSay(uint16 debug_level, uint16 log_category, std::string message)
|
||||
{
|
||||
/* Check if category enabled for process */
|
||||
if (log_settings[log_category].log_to_gmsay == 0)
|
||||
return;
|
||||
|
||||
/* Enabling Netcode based GMSay output creates a feedback loop that ultimately ends in a crash */
|
||||
if (log_category == Logs::LogCategory::Netcode)
|
||||
return;
|
||||
|
||||
/* Make sure the message inbound is at a debug level we're set at */
|
||||
if (log_settings[log_category].log_to_gmsay < debug_level)
|
||||
return;
|
||||
|
||||
/* Check to see if the process that actually ran this is zone */
|
||||
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone){
|
||||
on_log_gmsay_hook(log_category, message);
|
||||
}
|
||||
}
|
||||
|
||||
void EQEmuLogSys::ProcessLogWrite(uint16 debug_level, uint16 log_category, std::string message)
|
||||
{
|
||||
if (log_category == Logs::Crash){
|
||||
char time_stamp[80];
|
||||
EQEmuLogSys::SetCurrentTimeStamp(time_stamp);
|
||||
std::ofstream crash_log;
|
||||
EQEmuLogSys::MakeDirectory("logs/crashes");
|
||||
crash_log.open(StringFormat("logs/crashes/crash_%s_%i.log", platform_file_name.c_str(), getpid()), std::ios_base::app | std::ios_base::out);
|
||||
crash_log << time_stamp << " " << message << "\n";
|
||||
crash_log.close();
|
||||
}
|
||||
|
||||
/* Check if category enabled for process */
|
||||
if (log_settings[log_category].log_to_file == 0)
|
||||
return;
|
||||
|
||||
/* Make sure the message inbound is at a debug level we're set at */
|
||||
if (log_settings[log_category].log_to_file < debug_level)
|
||||
return;
|
||||
|
||||
char time_stamp[80];
|
||||
EQEmuLogSys::SetCurrentTimeStamp(time_stamp);
|
||||
|
||||
if (process_log){
|
||||
process_log << time_stamp << " " << message << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
uint16 EQEmuLogSys::GetWindowsConsoleColorFromCategory(uint16 log_category){
|
||||
switch (log_category) {
|
||||
case Logs::Status:
|
||||
case Logs::Normal:
|
||||
return Console::Color::Yellow;
|
||||
case Logs::MySQLError:
|
||||
case Logs::Error:
|
||||
return Console::Color::LightRed;
|
||||
case Logs::MySQLQuery:
|
||||
case Logs::Debug:
|
||||
return Console::Color::LightGreen;
|
||||
case Logs::Quests:
|
||||
return Console::Color::LightCyan;
|
||||
case Logs::Commands:
|
||||
return Console::Color::LightMagenta;
|
||||
case Logs::Crash:
|
||||
return Console::Color::LightRed;
|
||||
default:
|
||||
return Console::Color::Yellow;
|
||||
}
|
||||
}
|
||||
|
||||
std::string EQEmuLogSys::GetLinuxConsoleColorFromCategory(uint16 log_category){
|
||||
switch (log_category) {
|
||||
case Logs::Status:
|
||||
case Logs::Normal:
|
||||
return LC_YELLOW;
|
||||
case Logs::MySQLError:
|
||||
case Logs::Error:
|
||||
return LC_RED;
|
||||
case Logs::MySQLQuery:
|
||||
case Logs::Debug:
|
||||
return LC_GREEN;
|
||||
case Logs::Quests:
|
||||
return LC_CYAN;
|
||||
case Logs::Commands:
|
||||
return LC_MAGENTA;
|
||||
case Logs::Crash:
|
||||
return LC_RED;
|
||||
default:
|
||||
return LC_YELLOW;
|
||||
}
|
||||
}
|
||||
|
||||
uint16 EQEmuLogSys::GetGMSayColorFromCategory(uint16 log_category){
|
||||
switch (log_category) {
|
||||
case Logs::Status:
|
||||
case Logs::Normal:
|
||||
return 15; /* Yellow */
|
||||
case Logs::MySQLError:
|
||||
case Logs::Error:
|
||||
return 13; /* Red */
|
||||
case Logs::MySQLQuery:
|
||||
case Logs::Debug:
|
||||
return 14; /* Light Green */
|
||||
case Logs::Quests:
|
||||
return 258; /* Light Cyan */
|
||||
case Logs::Commands:
|
||||
return 5; /* Light Purple */
|
||||
case Logs::Crash:
|
||||
return 13; /* Red */
|
||||
default:
|
||||
return 15; /* Yellow */
|
||||
}
|
||||
}
|
||||
|
||||
void EQEmuLogSys::ProcessConsoleMessage(uint16 debug_level, uint16 log_category, std::string message)
|
||||
{
|
||||
/* Check if category enabled for process */
|
||||
if (log_settings[log_category].log_to_console == 0)
|
||||
return;
|
||||
|
||||
/* Make sure the message inbound is at a debug level we're set at */
|
||||
if (log_settings[log_category].log_to_console < debug_level)
|
||||
return;
|
||||
|
||||
#ifdef _WINDOWS
|
||||
HANDLE console_handle;
|
||||
console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
CONSOLE_FONT_INFOEX info = { 0 };
|
||||
info.cbSize = sizeof(info);
|
||||
info.dwFontSize.Y = 12; // leave X as zero
|
||||
info.FontWeight = FW_NORMAL;
|
||||
wcscpy(info.FaceName, L"Lucida Console");
|
||||
SetCurrentConsoleFontEx(console_handle, NULL, &info);
|
||||
SetConsoleTextAttribute(console_handle, EQEmuLogSys::GetWindowsConsoleColorFromCategory(log_category));
|
||||
std::cout << message << "\n";
|
||||
SetConsoleTextAttribute(console_handle, Console::Color::White);
|
||||
#else
|
||||
std::cout << EQEmuLogSys::GetLinuxConsoleColorFromCategory(log_category) << message << LC_RESET << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQEmuLogSys::Out(Logs::DebugLevel debug_level, uint16 log_category, std::string message, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, message);
|
||||
std::string output_message = vStringFormat(message.c_str(), args);
|
||||
va_end(args);
|
||||
|
||||
std::string output_debug_message = EQEmuLogSys::FormatOutMessageString(log_category, output_message);
|
||||
|
||||
EQEmuLogSys::ProcessConsoleMessage(debug_level, log_category, output_debug_message);
|
||||
EQEmuLogSys::ProcessGMSay(debug_level, log_category, output_debug_message);
|
||||
EQEmuLogSys::ProcessLogWrite(debug_level, log_category, output_message);
|
||||
}
|
||||
|
||||
void EQEmuLogSys::SetCurrentTimeStamp(char* time_stamp){
|
||||
time_t raw_time;
|
||||
struct tm * time_info;
|
||||
time(&raw_time);
|
||||
time_info = localtime(&raw_time);
|
||||
strftime(time_stamp, 80, "[%m-%d-%Y :: %H:%M:%S]", time_info);
|
||||
}
|
||||
|
||||
void EQEmuLogSys::MakeDirectory(std::string directory_name){
|
||||
#ifdef _WINDOWS
|
||||
_mkdir(directory_name.c_str());
|
||||
#else
|
||||
mkdir(directory_name.c_str(), 0755);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQEmuLogSys::CloseFileLogs()
|
||||
{
|
||||
if (process_log.is_open()){
|
||||
process_log.close();
|
||||
}
|
||||
}
|
||||
|
||||
void EQEmuLogSys::StartFileLogs(std::string log_name)
|
||||
{
|
||||
EQEmuLogSys::CloseFileLogs();
|
||||
|
||||
/* When loading settings, we must have been given a reason in category based logging to output to a file in order to even create or open one... */
|
||||
if (file_logs_enabled == false)
|
||||
return;
|
||||
|
||||
if (EQEmuLogSys::log_platform == EQEmuExePlatform::ExePlatformZone){
|
||||
if (log_name != "")
|
||||
platform_file_name = log_name;
|
||||
|
||||
if (platform_file_name == ""){
|
||||
return;
|
||||
}
|
||||
|
||||
EQEmuLogSys::Out(Logs::General, Logs::Status, "Starting File Log 'logs/%s_%i.log'", platform_file_name.c_str(), getpid());
|
||||
EQEmuLogSys::MakeDirectory("logs/zone");
|
||||
process_log.open(StringFormat("logs/zone/%s_%i.log", platform_file_name.c_str(), getpid()), std::ios_base::app | std::ios_base::out);
|
||||
}
|
||||
else{
|
||||
if (platform_file_name == ""){
|
||||
return;
|
||||
}
|
||||
EQEmuLogSys::Out(Logs::General, Logs::Status, "Starting File Log 'logs/%s_%i.txt'", platform_file_name.c_str(), getpid());
|
||||
process_log.open(StringFormat("logs/%s_%i.txt", platform_file_name.c_str(), getpid()), std::ios_base::app | std::ios_base::out);
|
||||
}
|
||||
}
|
||||
192
common/eqemu_logsys.h
Normal file
192
common/eqemu_logsys.h
Normal file
@ -0,0 +1,192 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2015 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
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_LOGSYS_H
|
||||
#define EQEMU_LOGSYS_H
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
#include <functional>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
namespace Logs{
|
||||
enum DebugLevel {
|
||||
General = 1, /* 1 - Low-Level general debugging, useful info on single line */
|
||||
Moderate, /* 2 - Informational based, used in functions, when particular things load */
|
||||
Detail, /* 3 - Use this for extreme detail in logging, usually in extreme debugging in the stack or interprocess communication */
|
||||
};
|
||||
|
||||
/*
|
||||
If you add to this, make sure you update LogCategoryName
|
||||
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,
|
||||
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",
|
||||
"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",
|
||||
"MySQL Error",
|
||||
"MySQL Query",
|
||||
};
|
||||
}
|
||||
|
||||
class EQEmuLogSys {
|
||||
public:
|
||||
EQEmuLogSys();
|
||||
~EQEmuLogSys();
|
||||
|
||||
void CloseFileLogs(); /* Close File Logs wherever necessary, either at zone shutdown or entire process shutdown for everything else. This should be handled on deconstructor but to be safe we use it anyways. */
|
||||
void LoadLogSettingsDefaults(); /* Initializes log_settings and sets some defaults if DB is not present */
|
||||
void MakeDirectory(std::string directory_name); /* Platform independent way of performing a MakeDirectory based on name */
|
||||
/*
|
||||
The one and only Logging function that uses a debug level as a parameter, as well as a log_category
|
||||
log_category - defined in Logs::LogCategory::[]
|
||||
log_category name resolution works by passing the enum int ID to Logs::LogCategoryName[category_id]
|
||||
|
||||
Example: EQEmuLogSys::Out(Logs::General, Logs::Guilds, "This guild has no leader present");
|
||||
- This would pipe the same category and debug level to all output formats, but the internal memory reference of log_settings would
|
||||
be checked against to see if that piped output is set to actually process it for the category and debug level
|
||||
*/
|
||||
void Out(Logs::DebugLevel debug_level, uint16 log_category, std::string message, ...);
|
||||
void SetCurrentTimeStamp(char* time_stamp); /* Used in file logs to prepend a timestamp entry for logs */
|
||||
void StartFileLogs(std::string log_name = ""); /* Used to declare the processes file log and to keep it open for later use */
|
||||
|
||||
/*
|
||||
LogSettings Struct
|
||||
|
||||
This struct is the master reference for all settings for each category, and for each output
|
||||
|
||||
log_to_file[category_id] = [1-3] - Sets debug level for category to output to file
|
||||
log_to_console[category_id] = [1-3] - Sets debug level for category to output to console
|
||||
log_to_gmsay[category_id] = [1-3] - Sets debug level for category to output to gmsay
|
||||
*/
|
||||
|
||||
struct LogSettings{
|
||||
uint8 log_to_file;
|
||||
uint8 log_to_console;
|
||||
uint8 log_to_gmsay;
|
||||
};
|
||||
|
||||
/* Internally used memory reference for all log settings per category.
|
||||
These are loaded via DB and have defaults loaded in LoadLogSettingsDefaults.
|
||||
Database loaded via Database::LoadLogSettings(log_settings)
|
||||
*/
|
||||
LogSettings log_settings[Logs::LogCategory::MaxCategoryID];
|
||||
|
||||
bool file_logs_enabled; /* Set when log settings are loaded to determine if keeping a file open is necessary */
|
||||
|
||||
int log_platform; /* Sets Executable platform (Zone/World/UCS) etc. */
|
||||
|
||||
std::string platform_file_name; /* File name used in writing logs */
|
||||
|
||||
uint16 GetGMSayColorFromCategory(uint16 log_category); /* GMSay Client Message colors mapped by category */
|
||||
|
||||
void OnLogHookCallBackZone(std::function<void(uint16 log_type, std::string&)> f) { on_log_gmsay_hook = f; }
|
||||
|
||||
private:
|
||||
|
||||
std::function<void(uint16 log_category, std::string&)> on_log_gmsay_hook; /* Callback pointer to zone process for hooking logs to zone using GMSay */
|
||||
std::string FormatOutMessageString(uint16 log_category, std::string in_message); /* Formats log messages like '[Category] This is a log message' */
|
||||
std::string GetLinuxConsoleColorFromCategory(uint16 log_category); /* Linux console color messages mapped by category */
|
||||
|
||||
uint16 GetWindowsConsoleColorFromCategory(uint16 log_category); /* Windows console color messages mapped by category */
|
||||
|
||||
void ProcessConsoleMessage(uint16 debug_level, uint16 log_category, std::string message); /* ProcessConsoleMessage called via Log.Out */
|
||||
void ProcessGMSay(uint16 debug_level, uint16 log_category, std::string message); /* ProcessGMSay called via Log.Out */
|
||||
void ProcessLogWrite(uint16 debug_level, uint16 log_category, std::string message); /* ProcessLogWrite called via Log.Out */
|
||||
};
|
||||
|
||||
extern EQEmuLogSys Log;
|
||||
|
||||
#endif
|
||||
@ -17,7 +17,8 @@
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/eqtime.h"
|
||||
#include "../common/eq_packet_structs.h"
|
||||
#include <memory.h>
|
||||
@ -140,11 +141,10 @@ bool EQTime::saveFile(const char *filename)
|
||||
of.open(filename);
|
||||
if(!of)
|
||||
{
|
||||
LogFile->write(EQEmuLog::Error, "EQTime::saveFile failed: Unable to open file '%s'", filename);
|
||||
Log.Out(Logs::General, Logs::Error, "EQTime::saveFile failed: Unable to open file '%s'", filename);
|
||||
return false;
|
||||
}
|
||||
//Enable for debugging
|
||||
//std::cout << "SAVE: day=" << (long)eqTime.start_eqtime.day << ";hour=" << (long)eqTime.start_eqtime.hour << ";min=" << (long)eqTime.start_eqtime.minute << ";mon=" << (long)eqTime.start_eqtime.month << ";yr=" << eqTime.start_eqtime.year << ";timet=" << eqTime.start_realtime << std::endl;
|
||||
of << EQT_VERSION << std::endl;
|
||||
of << (long)eqTime.start_eqtime.day << std::endl;
|
||||
of << (long)eqTime.start_eqtime.hour << std::endl;
|
||||
@ -164,14 +164,14 @@ bool EQTime::loadFile(const char *filename)
|
||||
in.open(filename);
|
||||
if(!in)
|
||||
{
|
||||
LogFile->write(EQEmuLog::Error, "Could not load EQTime file %s", filename);
|
||||
Log.Out(Logs::General, Logs::Error, "Could not load EQTime file %s", filename);
|
||||
return false;
|
||||
}
|
||||
in >> version;
|
||||
in.ignore(80, '\n');
|
||||
if(version != EQT_VERSION)
|
||||
{
|
||||
LogFile->write(EQEmuLog::Error, "'%s' is NOT a valid EQTime file. File version is %i, EQTime version is %i", filename, version, EQT_VERSION);
|
||||
Log.Out(Logs::General, Logs::Error, "'%s' is NOT a valid EQTime file. File version is %i, EQTime version is %i", filename, version, EQT_VERSION);
|
||||
return false;
|
||||
}
|
||||
//in >> eqTime.start_eqtime.day;
|
||||
@ -194,7 +194,6 @@ bool EQTime::loadFile(const char *filename)
|
||||
in.ignore(80, '\n');
|
||||
in >> eqTime.start_realtime;
|
||||
//Enable for debugging...
|
||||
//std::cout << "LOAD: day=" << (long)eqTime.start_eqtime.day << ";hour=" << (long)eqTime.start_eqtime.hour << ";min=" << (long)eqTime.start_eqtime.minute << ";mon=" << (long)eqTime.start_eqtime.month << ";yr=" << eqTime.start_eqtime.year << ";timet=" << eqTime.start_realtime << std::endl;
|
||||
in.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "extprofile.h"
|
||||
|
||||
//Set defaults in the extended profile...
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
Copyright (C) 2001-2015 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
|
||||
@ -15,22 +15,27 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef EQEMuError_H
|
||||
#define EQEMuError_H
|
||||
|
||||
#include "../common/types.h"
|
||||
|
||||
enum eEQEMuError { EQEMuError_NoError,
|
||||
EQEMuError_Mysql_1405,
|
||||
EQEMuError_Mysql_2003,
|
||||
EQEMuError_Mysql_2005,
|
||||
EQEMuError_Mysql_2007,
|
||||
EQEMuError_MaxErrorID };
|
||||
|
||||
void AddEQEMuError(eEQEMuError iError, bool iExitNow = false);
|
||||
void AddEQEMuError(char* iError, bool iExitNow = false);
|
||||
uint32 CheckEQEMuError();
|
||||
void CheckEQEMuErrorAndPause();
|
||||
|
||||
#if defined(_DEBUG) && defined(WIN32)
|
||||
#ifndef _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EQDEBUG_H
|
||||
#define EQDEBUG_H
|
||||
|
||||
#define _WINSOCKAPI_ //stupid windows, trying to fix the winsock2 vs. winsock issues
|
||||
#if defined(WIN32) && ( defined(PACKETCOLLECTOR) || defined(COLLECTOR) )
|
||||
// Packet Collector on win32 requires winsock.h due to latest pcap.h
|
||||
// winsock.h must come before windows.h
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
#include "guild_base.h"
|
||||
#include "database.h"
|
||||
#include "logsys.h"
|
||||
|
||||
//#include "misc_functions.h"
|
||||
#include "string_util.h"
|
||||
#include <cstdlib>
|
||||
@ -46,7 +46,7 @@ bool BaseGuildManager::LoadGuilds() {
|
||||
ClearGuilds();
|
||||
|
||||
if(m_db == nullptr) {
|
||||
_log(GUILDS__DB, "Requested to load guilds when we have no database object.");
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Requested to load guilds when we have no database object.");
|
||||
return(false);
|
||||
}
|
||||
|
||||
@ -57,7 +57,6 @@ bool BaseGuildManager::LoadGuilds() {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error loading guilds '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -69,7 +68,6 @@ bool BaseGuildManager::LoadGuilds() {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error loading guild ranks '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -79,13 +77,13 @@ bool BaseGuildManager::LoadGuilds() {
|
||||
uint8 rankn = atoi(row[1]);
|
||||
|
||||
if(rankn > GUILD_MAX_RANK) {
|
||||
_log(GUILDS__ERROR, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id);
|
||||
Log.Out(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(GUILDS__ERROR, "Found rank %d for non-existent guild %d, skipping.", rankn, guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Found rank %d for non-existent guild %d, skipping.", rankn, guild_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -107,7 +105,7 @@ bool BaseGuildManager::LoadGuilds() {
|
||||
|
||||
bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
||||
if(m_db == nullptr) {
|
||||
_log(GUILDS__DB, "Requested to refresh guild %d when we have no database object.", guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Requested to refresh guild %d when we have no database object.", guild_id);
|
||||
return(false);
|
||||
}
|
||||
|
||||
@ -120,13 +118,12 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error reloading guilds '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
{
|
||||
_log(GUILDS__ERROR, "Unable to find guild %d in the database.", guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Unable to find guild %d in the database.", guild_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -140,7 +137,6 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error reloading guild ranks '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -149,7 +145,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
||||
uint8 rankn = atoi(row[1]);
|
||||
|
||||
if(rankn > GUILD_MAX_RANK) {
|
||||
_log(GUILDS__ERROR, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Found invalid (too high) rank %d for guild %d, skipping.", rankn, guild_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -166,7 +162,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) {
|
||||
rank.permissions[GUILD_WARPEACE] = (row[10][0] == '1') ? true: false;
|
||||
}
|
||||
|
||||
_log(GUILDS__DB, "Successfully refreshed guild %d from the database.", guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Successfully refreshed guild %d from the database.", guild_id);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -218,14 +214,14 @@ BaseGuildManager::GuildInfo *BaseGuildManager::_CreateGuild(uint32 guild_id, con
|
||||
|
||||
bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
||||
if(m_db == nullptr) {
|
||||
_log(GUILDS__DB, "Requested to store guild %d when we have no database object.", guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Requested to store guild %d when we have no database object.", guild_id);
|
||||
return(false);
|
||||
}
|
||||
|
||||
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||
res = m_guilds.find(guild_id);
|
||||
if(res == m_guilds.end()) {
|
||||
_log(GUILDS__DB, "Requested to store non-existent guild %d", guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Requested to store non-existent guild %d", guild_id);
|
||||
return(false);
|
||||
}
|
||||
GuildInfo *info = res->second;
|
||||
@ -235,16 +231,10 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
||||
//clear out old `guilds` entry
|
||||
auto results = m_db->QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
_log(GUILDS__ERROR, "Error clearing old guild record when storing %d '%s': %s", guild_id, query.c_str(), results.ErrorMessage().c_str());
|
||||
|
||||
//clear out old `guild_ranks` entries
|
||||
query = StringFormat("DELETE FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id);
|
||||
results = m_db->QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
_log(GUILDS__ERROR, "Error clearing old guild_ranks records when storing %d '%s': %s", guild_id, query.c_str(), results.ErrorMessage().c_str());
|
||||
|
||||
//escape our strings.
|
||||
char *name_esc = new char[info->name.length()*2+1];
|
||||
char *motd_esc = new char[info->motd.length()*2+1];
|
||||
@ -260,7 +250,6 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error inserting new guild record when storing %d. Giving up. '%s': %s", guild_id, query.c_str(), results.ErrorMessage().c_str());
|
||||
safe_delete_array(name_esc);
|
||||
safe_delete_array(motd_esc);
|
||||
safe_delete_array(motd_set_esc);
|
||||
@ -294,21 +283,20 @@ bool BaseGuildManager::_StoreGuildDB(uint32 guild_id) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error inserting new guild rank record when storing %d for %d. Giving up. '%s': %s", rank, guild_id, query.c_str(), results.ErrorMessage().c_str());
|
||||
safe_delete_array(title_esc);
|
||||
return false;
|
||||
}
|
||||
safe_delete_array(title_esc);
|
||||
}
|
||||
|
||||
_log(GUILDS__DB, "Stored guild %d in the database", guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Stored guild %d in the database", guild_id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 BaseGuildManager::_GetFreeGuildID() {
|
||||
if(m_db == nullptr) {
|
||||
_log(GUILDS__DB, "Requested find a free guild ID when we have no database object.");
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Requested find a free guild ID when we have no database object.");
|
||||
return(GUILD_NONE);
|
||||
}
|
||||
|
||||
@ -337,18 +325,17 @@ uint32 BaseGuildManager::_GetFreeGuildID() {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
LogFile->write(EQEmuLog::Error, "Error in _GetFreeGuildID query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
{
|
||||
_log(GUILDS__DB, "Located free guild ID %d in the database", index);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Located free guild ID %d in the database", index);
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
_log(GUILDS__ERROR, "Unable to find a free guild ID when requested.");
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Unable to find a free guild ID when requested.");
|
||||
return GUILD_NONE;
|
||||
}
|
||||
|
||||
@ -518,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(GUILDS__ERROR, "Error storing new guild. It may have been partially created which may need manual removal.");
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Error storing new guild. It may have been partially created which may need manual removal.");
|
||||
return(GUILD_NONE);
|
||||
}
|
||||
|
||||
_log(GUILDS__DB, "Created guild %d in the database.", new_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Created guild %d in the database.", new_id);
|
||||
|
||||
return(new_id);
|
||||
}
|
||||
@ -538,7 +525,7 @@ bool BaseGuildManager::DBDeleteGuild(uint32 guild_id) {
|
||||
}
|
||||
|
||||
if(m_db == nullptr) {
|
||||
_log(GUILDS__DB, "Requested to delete guild %d when we have no database object.", guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Requested to delete guild %d when we have no database object.", guild_id);
|
||||
return(false);
|
||||
}
|
||||
|
||||
@ -558,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(GUILDS__DB, "Deleted guild %d from the database.", guild_id);
|
||||
Log.Out(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(GUILDS__DB, "Requested to rename guild %d when we have no database object.", guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Requested to rename guild %d when we have no database object.", guild_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -586,13 +573,13 @@ bool BaseGuildManager::DBRenameGuild(uint32 guild_id, const char* name) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error renaming guild %d '%s': %s", guild_id, query.c_str(), results.Success());
|
||||
Log.Out(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(GUILDS__DB, "Renamed guild %s (%d) to %s in database.", info->name.c_str(), guild_id, name);
|
||||
Log.Out(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.
|
||||
|
||||
@ -601,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(GUILDS__DB, "Requested to set the leader for guild %d when we have no database object.", guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Requested to set the leader for guild %d when we have no database object.", guild_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -617,7 +604,6 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error changing leader on guild %d '%s': %s", guild_id, query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -628,7 +614,7 @@ bool BaseGuildManager::DBSetGuildLeader(uint32 guild_id, uint32 leader) {
|
||||
if(!DBSetGuildRank(leader, GUILD_LEADER))
|
||||
return false;
|
||||
|
||||
_log(GUILDS__DB, "Set guild leader for guild %d to %d in the database", guild_id, leader);
|
||||
Log.Out(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.
|
||||
|
||||
@ -637,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(GUILDS__DB, "Requested to set the MOTD for guild %d when we have no database object.", guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Requested to set the MOTD for guild %d when we have no database object.", guild_id);
|
||||
return(false);
|
||||
}
|
||||
|
||||
@ -661,7 +647,6 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error setting MOTD for guild %d '%s': %s", guild_id, query.c_str(), results.ErrorMessage().c_str());
|
||||
safe_delete_array(esc);
|
||||
safe_delete_array(esc_set);
|
||||
return false;
|
||||
@ -669,7 +654,7 @@ bool BaseGuildManager::DBSetGuildMOTD(uint32 guild_id, const char* motd, const c
|
||||
safe_delete_array(esc);
|
||||
safe_delete_array(esc_set);
|
||||
|
||||
_log(GUILDS__DB, "Set MOTD for guild %d in the database", guild_id);
|
||||
Log.Out(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.
|
||||
@ -698,13 +683,12 @@ bool BaseGuildManager::DBSetGuildURL(uint32 GuildID, const char* URL)
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error setting URL for guild %d '%s': %s", GuildID, query.c_str(), results.ErrorMessage().c_str());
|
||||
safe_delete_array(esc);
|
||||
return(false);
|
||||
}
|
||||
safe_delete_array(esc);
|
||||
|
||||
_log(GUILDS__DB, "Set URL for guild %d in the database", GuildID);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Set URL for guild %d in the database", GuildID);
|
||||
|
||||
info->url = URL; //update our local record.
|
||||
|
||||
@ -733,13 +717,12 @@ bool BaseGuildManager::DBSetGuildChannel(uint32 GuildID, const char* Channel)
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error setting Channel for guild %d '%s': %s", GuildID, query.c_str(), results.ErrorMessage().c_str());
|
||||
safe_delete_array(esc);
|
||||
return(false);
|
||||
}
|
||||
safe_delete_array(esc);
|
||||
|
||||
_log(GUILDS__DB, "Set Channel for guild %d in the database", GuildID);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Set Channel for guild %d in the database", GuildID);
|
||||
|
||||
info->channel = Channel; //update our local record.
|
||||
|
||||
@ -748,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(GUILDS__DB, "Requested to set char to guild %d when we have no database object.", guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Requested to set char to guild %d when we have no database object.", guild_id);
|
||||
return(false);
|
||||
}
|
||||
|
||||
@ -759,7 +742,6 @@ bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) {
|
||||
auto results = m_db->QueryDatabase(query);
|
||||
|
||||
if (!results.Success()) {
|
||||
_log(GUILDS__ERROR, "Error Changing char %d to guild %d '%s': %s", charid, guild_id, query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -768,11 +750,10 @@ bool BaseGuildManager::DBSetGuild(uint32 charid, uint32 guild_id, uint8 rank) {
|
||||
auto results = m_db->QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error removing char %d from guild '%s': %s", charid, guild_id, query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_log(GUILDS__DB, "Set char %d to guild %d and rank %d in the database.", charid, guild_id, rank);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Set char %d to guild %d and rank %d in the database.", charid, guild_id, rank);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -796,7 +777,6 @@ bool BaseGuildManager::GetBankerFlag(uint32 CharID)
|
||||
auto results = m_db->QueryDatabase(query);
|
||||
if(!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error retrieving banker flag '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -827,7 +807,6 @@ bool BaseGuildManager::GetAltFlag(uint32 CharID)
|
||||
auto results = m_db->QueryDatabase(query);
|
||||
if(!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error retrieving alt flag '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -863,11 +842,10 @@ bool BaseGuildManager::DBSetPublicNote(uint32 charid, const char* note) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error setting public note for char %d '%s': %s", charid, query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
_log(GUILDS__DB, "Set public not for char %d", charid);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Set public not for char %d", charid);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -880,7 +858,6 @@ bool BaseGuildManager::QueryWithLogging(std::string query, const char *errmsg) {
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error %s: '%s': %s", errmsg, query.c_str(), results.ErrorMessage().c_str());
|
||||
return(false);
|
||||
}
|
||||
|
||||
@ -938,7 +915,6 @@ bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector<CharGuildInfo
|
||||
std::string query = StringFormat(GuildMemberBaseQuery " WHERE g.guild_id=%d", guild_id);
|
||||
auto results = m_db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
_log(GUILDS__ERROR, "Error loading guild member list '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -948,14 +924,14 @@ bool BaseGuildManager::GetEntireGuild(uint32 guild_id, std::vector<CharGuildInfo
|
||||
members.push_back(ci);
|
||||
}
|
||||
|
||||
_log(GUILDS__DB, "Retreived entire guild member list for guild %d from the database", guild_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Retreived entire guild member list for guild %d from the database", guild_id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
|
||||
if(m_db == nullptr) {
|
||||
_log(GUILDS__DB, "Requested char info on %s when we have no database object.", char_name);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Requested char info on %s when we have no database object.", char_name);
|
||||
return(false);
|
||||
}
|
||||
|
||||
@ -969,7 +945,6 @@ bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
|
||||
safe_delete_array(esc);
|
||||
auto results = m_db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
_log(GUILDS__ERROR, "Error loading guild member '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -978,7 +953,7 @@ bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
|
||||
|
||||
auto row = results.begin();
|
||||
ProcessGuildMember(row, into);
|
||||
_log(GUILDS__DB, "Retreived guild member info for char %s from the database", char_name);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Retreived guild member info for char %s from the database", char_name);
|
||||
|
||||
return true;
|
||||
|
||||
@ -987,7 +962,7 @@ bool BaseGuildManager::GetCharInfo(const char *char_name, CharGuildInfo &into) {
|
||||
|
||||
bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) {
|
||||
if(m_db == nullptr) {
|
||||
_log(GUILDS__DB, "Requested char info on %d when we have no database object.", char_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Requested char info on %d when we have no database object.", char_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1000,7 +975,6 @@ bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) {
|
||||
#endif
|
||||
auto results = m_db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
_log(GUILDS__ERROR, "Error loading guild member '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1009,7 +983,7 @@ bool BaseGuildManager::GetCharInfo(uint32 char_id, CharGuildInfo &into) {
|
||||
|
||||
auto row = results.begin();
|
||||
ProcessGuildMember(row, into);
|
||||
_log(GUILDS__DB, "Retreived guild member info for char %d", char_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Retreived guild member info for char %d", char_id);
|
||||
|
||||
return true;
|
||||
|
||||
@ -1124,16 +1098,16 @@ bool BaseGuildManager::GuildExists(uint32 guild_id) const {
|
||||
|
||||
bool BaseGuildManager::IsGuildLeader(uint32 guild_id, uint32 char_id) const {
|
||||
if(guild_id == GUILD_NONE) {
|
||||
_log(GUILDS__PERMISSIONS, "Check leader for char %d: not a guild.", char_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Check leader for char %d: not a guild.", char_id);
|
||||
return(false);
|
||||
}
|
||||
std::map<uint32, GuildInfo *>::const_iterator res;
|
||||
res = m_guilds.find(guild_id);
|
||||
if(res == m_guilds.end()) {
|
||||
_log(GUILDS__PERMISSIONS, "Check leader for char %d: invalid guild.", char_id);
|
||||
Log.Out(Logs::Detail, Logs::Guilds, "Check leader for char %d: invalid guild.", char_id);
|
||||
return(false); //invalid guild
|
||||
}
|
||||
_log(GUILDS__PERMISSIONS, "Check leader for guild %d, char %d: leader id=%d", guild_id, char_id, res->second->leader_char_id);
|
||||
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);
|
||||
return(char_id == res->second->leader_char_id);
|
||||
}
|
||||
|
||||
@ -1163,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(GUILDS__PERMISSIONS, "Check permission on guild %d with user status %d > 250, granted.", guild_id, status);
|
||||
Log.Out(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<uint32, GuildInfo *>::const_iterator res;
|
||||
res = m_guilds.find(guild_id);
|
||||
if(res == m_guilds.end()) {
|
||||
_log(GUILDS__PERMISSIONS, "Check permission on guild %d with user status %d, no such guild, denied.", guild_id, status);
|
||||
Log.Out(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(GUILDS__PERMISSIONS, "Check permission on guild %s (%d) with user status %d. Min status %d: %s",
|
||||
Log.Out(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);
|
||||
@ -1184,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(GUILDS__PERMISSIONS, "Check permission on guild %d and rank %d for action %s (%d): Invalid rank, denied.",
|
||||
Log.Out(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<uint32, GuildInfo *>::const_iterator res;
|
||||
res = m_guilds.find(guild_id);
|
||||
if(res == m_guilds.end()) {
|
||||
_log(GUILDS__PERMISSIONS, "Check permission on guild %d and rank %d for action %s (%d): Invalid guild, denied.",
|
||||
Log.Out(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(GUILDS__PERMISSIONS, "Check permission on guild %s (%d) and rank %s (%d) for action %s (%d): %s",
|
||||
Log.Out(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,
|
||||
@ -1245,7 +1219,6 @@ uint32 BaseGuildManager::DoesAccountContainAGuildLeader(uint32 AccountID)
|
||||
auto results = m_db->QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(GUILDS__ERROR, "Error executing query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "misc_functions.h"
|
||||
#include "guilds.h"
|
||||
#include "database.h"
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "classes.h"
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "item.h"
|
||||
#include "races.h"
|
||||
#include "rulesys.h"
|
||||
@ -1145,7 +1145,7 @@ int16 Inventory::_PutItem(int16 slot_id, ItemInst* inst)
|
||||
}
|
||||
|
||||
if (result == INVALID_INDEX) {
|
||||
LogFile->write(EQEmuLog::Error, "Inventory::_PutItem: Invalid slot_id specified (%i) with parent slot id (%i)", slot_id, parentSlot);
|
||||
Log.Out(Logs::General, Logs::Error, "Inventory::_PutItem: Invalid slot_id specified (%i) with parent slot id (%i)", slot_id, parentSlot);
|
||||
Inventory::MarkDirty(inst); // Slot not found, clean up
|
||||
}
|
||||
|
||||
|
||||
@ -1,158 +0,0 @@
|
||||
/* 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 "debug.h"
|
||||
#include "eq_packet.h"
|
||||
#include "logsys.h"
|
||||
#include "misc.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define LOG_CATEGORY(category) #category ,
|
||||
const char *log_category_names[NUMBER_OF_LOG_CATEGORIES] = {
|
||||
#include "logtypes.h"
|
||||
};
|
||||
|
||||
|
||||
//this array is private to this file, only a const version of it is exposed
|
||||
#define LOG_TYPE(category, type, enabled) { enabled, LOG_ ##category, #category "__" #type },
|
||||
static LogTypeStatus real_log_type_info[NUMBER_OF_LOG_TYPES+1] =
|
||||
{
|
||||
#include "logtypes.h"
|
||||
{ false, NUMBER_OF_LOG_CATEGORIES, "BAD TYPE" } /* dummy trailing record */
|
||||
};
|
||||
const LogTypeStatus *log_type_info = real_log_type_info;
|
||||
|
||||
|
||||
|
||||
void log_hex(LogType type, const void *data, unsigned long length, unsigned char padding) {
|
||||
if(!is_log_enabled(type))
|
||||
return;
|
||||
char buffer[80];
|
||||
uint32 offset;
|
||||
for(offset=0;offset<length;offset+=16) {
|
||||
build_hex_line((const char *)data,length,offset,buffer,padding);
|
||||
log_message(type, "%s", buffer); //%s is to prevent % escapes in the ascii
|
||||
}
|
||||
}
|
||||
|
||||
void log_packet(LogType type, const BasePacket *p) {
|
||||
if(!is_log_enabled(type))
|
||||
return;
|
||||
char buffer[80];
|
||||
p->build_header_dump(buffer);
|
||||
log_message(type,"%s", buffer);
|
||||
log_hex(type,(const char *)p->pBuffer,p->size);
|
||||
}
|
||||
|
||||
void log_raw_packet(LogType type, uint16 seq, const BasePacket *p) {
|
||||
if(!is_log_enabled(type))
|
||||
return;
|
||||
char buffer[196];
|
||||
p->build_raw_header_dump(buffer, seq);
|
||||
log_message(type,buffer);
|
||||
log_hex(type,(const char *)p->pBuffer,p->size);
|
||||
}
|
||||
|
||||
|
||||
void log_enable(LogType t) {
|
||||
real_log_type_info[t].enabled = true;
|
||||
}
|
||||
|
||||
void log_disable(LogType t) {
|
||||
real_log_type_info[t].enabled = false;
|
||||
}
|
||||
|
||||
void log_toggle(LogType t) {
|
||||
real_log_type_info[t].enabled = !real_log_type_info[t].enabled;
|
||||
}
|
||||
|
||||
|
||||
bool load_log_settings(const char *filename) {
|
||||
//this is a terrible algorithm, but im lazy today
|
||||
FILE *f = fopen(filename, "r");
|
||||
if(f == nullptr)
|
||||
return(false);
|
||||
char linebuf[512], type_name[256], value[256];
|
||||
while(!feof(f)) {
|
||||
if(fgets(linebuf, 512, f) == nullptr)
|
||||
continue;
|
||||
#ifdef _WINDOWS
|
||||
if (sscanf(linebuf, "%[^=]=%[^\n]\n", type_name, value) != 2)
|
||||
continue;
|
||||
#else
|
||||
if (sscanf(linebuf, "%[^=]=%[^\r\n]\n", type_name, value) != 2)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
if(type_name[0] == '\0' || type_name[0] == '#')
|
||||
continue;
|
||||
|
||||
//first make sure we understand the value
|
||||
bool enabled;
|
||||
if(!strcasecmp(value, "on") || !strcasecmp(value, "true") || !strcasecmp(value, "yes") || !strcasecmp(value, "enabled") || !strcmp(value, "1"))
|
||||
enabled = true;
|
||||
else if(!strcasecmp(value, "off") || !strcasecmp(value, "false") || !strcasecmp(value, "no") || !strcasecmp(value, "disabled") || !strcmp(value, "0"))
|
||||
enabled = false;
|
||||
else {
|
||||
printf("Unable to parse value '%s' from %s. Skipping line.", value, filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
int r;
|
||||
//first see if it is a category name
|
||||
for(r = 0; r < NUMBER_OF_LOG_CATEGORIES; r++) {
|
||||
if(!strcasecmp(log_category_names[r], type_name))
|
||||
break;
|
||||
}
|
||||
if(r != NUMBER_OF_LOG_CATEGORIES) {
|
||||
//matched a category.
|
||||
int k;
|
||||
for(k = 0; k < NUMBER_OF_LOG_TYPES; k++) {
|
||||
if(log_type_info[k].category != r)
|
||||
continue; //does not match this category.
|
||||
if(enabled)
|
||||
log_enable(LogType(k));
|
||||
else
|
||||
log_disable(LogType(k));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
for(r = 0; r < NUMBER_OF_LOG_TYPES; r++) {
|
||||
if(!strcasecmp(log_type_info[r].name, type_name))
|
||||
break;
|
||||
}
|
||||
if(r == NUMBER_OF_LOG_TYPES) {
|
||||
printf("Unable to locate log type %s from file %s. Skipping line.", type_name, filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
//got it all figured out, do something now...
|
||||
if(enabled)
|
||||
log_enable(LogType(r));
|
||||
else
|
||||
log_disable(LogType(r));
|
||||
}
|
||||
fclose(f);
|
||||
return(true);
|
||||
}
|
||||
|
||||
179
common/logsys.h
179
common/logsys.h
@ -1,179 +0,0 @@
|
||||
/* 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
|
||||
*/
|
||||
#ifndef LOGSYS_H_
|
||||
#define LOGSYS_H_
|
||||
|
||||
/*
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* These are the main functions provided by logsys:
|
||||
* - _log(TYPE, fmt, ...) - Log a message in any context
|
||||
* - mlog(TYPE, fmt, ...) - Zone only. Log a message from a Mob:: context, prefixing it with the mob's name.
|
||||
* - clog(TYPE, fmt, ...) - World only. Log a message from a Client:: context, prefixing it with the client's account name.
|
||||
* - zlog(TYPE, fmt, ...) - World only. Log a message from a ZoneServer:: context, prefixing it with the zones id/name or ip/port.
|
||||
* - _hex(TYPE, data, length) - Log hex dump in any context.
|
||||
* - mhex(TYPE, data, length) - Zone only. Log a hex dump from a Mob:: context, prefixing it with the mob's name
|
||||
* - _pkt(TYPE, BasePacket *) - Log a packet hex dump with header in any context.
|
||||
* - mhex(TYPE, data, length) - Zone only. Log a packet hex dump from a Mob:: context, prefixing it with the mob's name
|
||||
* Types are defined in logtypes.h
|
||||
*
|
||||
* this is very C-ish, not C++ish, but thats how I felt like writting it
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "types.h"
|
||||
|
||||
#define LOG_CATEGORY(category) LOG_ ##category ,
|
||||
typedef enum {
|
||||
#include "logtypes.h"
|
||||
NUMBER_OF_LOG_CATEGORIES
|
||||
} LogCategory;
|
||||
|
||||
#define LOG_TYPE(category, type, enabled) category##__##type ,
|
||||
typedef enum {
|
||||
#include "logtypes.h"
|
||||
NUMBER_OF_LOG_TYPES
|
||||
} LogType;
|
||||
|
||||
extern const char *log_category_names[NUMBER_OF_LOG_CATEGORIES];
|
||||
|
||||
typedef struct {
|
||||
bool enabled;
|
||||
LogCategory category;
|
||||
const char *name;
|
||||
} LogTypeStatus;
|
||||
|
||||
//expose a read-only pointer
|
||||
extern const LogTypeStatus *log_type_info;
|
||||
|
||||
// For log_packet, et all.
|
||||
class BasePacket;
|
||||
|
||||
extern void log_message(LogType type, const char *fmt, ...);
|
||||
extern void log_messageVA(LogType type, const char *fmt, va_list args);
|
||||
extern void log_hex(LogType type, const void *data, unsigned long length, unsigned char padding=4);
|
||||
extern void log_packet(LogType type, const BasePacket *p);
|
||||
extern void log_raw_packet(LogType type, uint16 seq, const BasePacket *p);
|
||||
|
||||
#ifdef DISABLE_LOGSYS
|
||||
//completely disabled, this is the best I can come up with since we have no variadic macros
|
||||
inline void _log(LogType, const char *, ...) {}//i feel dirty for putting this ifdef here, but I dont wanna have to include a header in all zone files to get it
|
||||
inline void mlog(LogType, const char *, ...) {}
|
||||
inline void clog(LogType, const char *, ...) {}
|
||||
inline void zlog(LogType, const char *, ...) {}
|
||||
#else //!DISABLE_LOGSYS
|
||||
|
||||
//we have variadic macros, hooray!
|
||||
//the do-while construct is needed to allow a ; at the end of log(); lines when used
|
||||
//in conditional statements without {}'s
|
||||
#define _log( type, format, ...) \
|
||||
do { \
|
||||
if(log_type_info[ type ].enabled) { \
|
||||
log_message(type, format, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while(false)
|
||||
#ifdef ZONE
|
||||
class Mob;
|
||||
extern void log_message_mob(LogType type, Mob *who, const char *fmt, ...);
|
||||
#define mlog( type, format, ...) \
|
||||
do { \
|
||||
if(IsLoggingEnabled()) \
|
||||
if(log_type_info[ type ].enabled) { \
|
||||
log_message_mob(type, this, format, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while(false)
|
||||
#endif
|
||||
#ifdef WORLD
|
||||
class Client;
|
||||
extern void log_message_client(LogType type, Client *who, const char *fmt, ...);
|
||||
#define clog( type, format, ...) \
|
||||
do { \
|
||||
if(log_type_info[ type ].enabled) { \
|
||||
log_message_client(type, this, format, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while(false)
|
||||
|
||||
class ZoneServer;
|
||||
extern void log_message_zone(LogType type, ZoneServer *who, const char *fmt, ...);
|
||||
#define zlog( type, format, ...) \
|
||||
do { \
|
||||
if(log_type_info[ type ].enabled) { \
|
||||
log_message_zone(type, this, format, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while(false)
|
||||
#endif
|
||||
#endif //!DISABLE_LOGSYS
|
||||
|
||||
#ifndef DISABLE_LOGSYS
|
||||
/* these are macros which do not use ..., and work for anybody */
|
||||
#define _hex( type, data, len) \
|
||||
do { \
|
||||
if(log_type_info[ type ].enabled) { \
|
||||
log_hex(type, (const char *)data, len); \
|
||||
} \
|
||||
} while(false)
|
||||
#define _pkt( type, packet) \
|
||||
do { \
|
||||
if(log_type_info[ type ].enabled) { \
|
||||
log_packet(type, packet); \
|
||||
} \
|
||||
} while(false)
|
||||
#define _raw( type, seq, packet) \
|
||||
do { \
|
||||
if(log_type_info[ type ].enabled) { \
|
||||
log_raw_packet(type, seq, packet); \
|
||||
} \
|
||||
} while(false)
|
||||
|
||||
#else
|
||||
#define _hex( type, data, len) {}
|
||||
#define _pkt( type, packet) {}
|
||||
#define _raw( type, seq, packet) {}
|
||||
#endif //!DISABLE_LOGSYS
|
||||
#ifdef ZONE
|
||||
class Mob;
|
||||
extern void log_hex_mob(LogType type, Mob *who, const char *data, uint32 length);
|
||||
#define mhex( type, data, len) \
|
||||
do { \
|
||||
if(IsLoggingEnabled()) \
|
||||
if(log_type_info[ type ].enabled) { \
|
||||
log_hex_mob(type, this, data, len); \
|
||||
} \
|
||||
} while(false)
|
||||
extern void log_packet_mob(LogType type, Mob *who, const BasePacket *p);
|
||||
#define mpkt( type, packet) \
|
||||
do { \
|
||||
if(IsLoggingEnabled()) \
|
||||
if(log_type_info[ type ].enabled) { \
|
||||
log_packet_mob(type, this, packet); \
|
||||
} \
|
||||
} while(false)
|
||||
#endif
|
||||
|
||||
extern void log_enable(LogType t);
|
||||
extern void log_disable(LogType t);
|
||||
extern void log_toggle(LogType t);
|
||||
|
||||
#define is_log_enabled( type ) \
|
||||
log_type_info[ type ].enabled
|
||||
|
||||
extern bool load_log_settings(const char *filename);
|
||||
|
||||
#endif /*LOGSYS_H_*/
|
||||
|
||||
@ -1,40 +0,0 @@
|
||||
/* 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 "debug.h"
|
||||
#include "logsys.h"
|
||||
#include "string_util.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
void log_message(LogType type, const char *fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
log_messageVA(type, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void log_messageVA(LogType type, const char *fmt, va_list args) {
|
||||
std::string prefix_buffer = StringFormat("[%s] ", log_type_info[type].name);
|
||||
|
||||
LogFile->writePVA(EQEmuLog::Debug, prefix_buffer.c_str(), fmt, args);
|
||||
}
|
||||
|
||||
@ -1,266 +0,0 @@
|
||||
/* 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
|
||||
*/
|
||||
|
||||
#ifndef LOG_CATEGORY
|
||||
#define LOG_CATEGORY(name)
|
||||
#endif
|
||||
#ifndef LOG_TYPE
|
||||
#define LOG_TYPE(cat, type, default_value)
|
||||
#endif
|
||||
#ifndef ENABLED
|
||||
#define ENABLED true
|
||||
#endif
|
||||
#ifndef DISABLED
|
||||
#define DISABLED false
|
||||
#endif
|
||||
|
||||
|
||||
LOG_CATEGORY( CHAT )
|
||||
LOG_TYPE( CHAT, SAY, DISABLED )
|
||||
LOG_TYPE( CHAT, EMOTE, DISABLED )
|
||||
LOG_TYPE( CHAT, OOC, DISABLED )
|
||||
LOG_TYPE( CHAT, GROUP, DISABLED )
|
||||
LOG_TYPE( CHAT, GUILD, DISABLED )
|
||||
|
||||
LOG_CATEGORY( MAIL )
|
||||
LOG_TYPE( MAIL, INIT, ENABLED )
|
||||
LOG_TYPE( MAIL, ERROR, ENABLED )
|
||||
LOG_TYPE( MAIL, CLIENT, DISABLED )
|
||||
LOG_TYPE( MAIL, TRACE, DISABLED )
|
||||
LOG_TYPE( MAIL, PACKETS, DISABLED)
|
||||
|
||||
LOG_CATEGORY( CHANNELS )
|
||||
LOG_TYPE( CHANNELS, INIT, ENABLED )
|
||||
LOG_TYPE( CHANNELS, ERROR, ENABLED )
|
||||
LOG_TYPE( CHANNELS, CLIENT, DISABLED )
|
||||
LOG_TYPE( CHANNELS, TRACE, DISABLED )
|
||||
LOG_TYPE( CHANNELS, PACKETS, DISABLED)
|
||||
|
||||
LOG_CATEGORY( UCS )
|
||||
LOG_TYPE( UCS, INIT, ENABLED )
|
||||
LOG_TYPE( UCS, ERROR, ENABLED )
|
||||
LOG_TYPE( UCS, CLIENT, DISABLED )
|
||||
LOG_TYPE( UCS, TRACE, DISABLED )
|
||||
LOG_TYPE( UCS, PACKETS, DISABLED)
|
||||
|
||||
LOG_CATEGORY( QUERYSERV )
|
||||
LOG_TYPE( QUERYSERV, INIT, ENABLED )
|
||||
LOG_TYPE( QUERYSERV, ERROR, ENABLED )
|
||||
LOG_TYPE( QUERYSERV, CLIENT, DISABLED )
|
||||
LOG_TYPE( QUERYSERV, TRACE, DISABLED )
|
||||
LOG_TYPE( QUERYSERV, PACKETS, DISABLED)
|
||||
|
||||
LOG_CATEGORY( SOCKET_SERVER)
|
||||
LOG_TYPE( SOCKET_SERVER, INIT, ENABLED)
|
||||
LOG_TYPE( SOCKET_SERVER, ERROR, ENABLED)
|
||||
LOG_TYPE( SOCKET_SERVER, CLIENT, DISABLED)
|
||||
LOG_TYPE( SOCKET_SERVER, TRACE, DISABLED)
|
||||
LOG_TYPE( SOCKET_SERVER, PACKETS, DISABLED)
|
||||
|
||||
LOG_CATEGORY( SPAWNS )
|
||||
LOG_TYPE( SPAWNS, MAIN, DISABLED )
|
||||
LOG_TYPE( SPAWNS, CONDITIONS, DISABLED )
|
||||
LOG_TYPE( SPAWNS, LIMITS, DISABLED )
|
||||
|
||||
LOG_CATEGORY( AI )
|
||||
LOG_TYPE( AI, ERROR, ENABLED )
|
||||
LOG_TYPE( AI, WAYPOINTS, DISABLED )
|
||||
LOG_TYPE( AI, BUFFS, DISABLED )
|
||||
LOG_TYPE( AI, SPELLS, DISABLED )
|
||||
|
||||
LOG_CATEGORY( PATHING)
|
||||
LOG_TYPE( PATHING, DEBUG, DISABLED )
|
||||
|
||||
LOG_CATEGORY( QUESTS )
|
||||
LOG_TYPE( QUESTS, PATHING, DISABLED )
|
||||
|
||||
LOG_CATEGORY( SPELLS )
|
||||
LOG_TYPE( SPELLS, LOAD, DISABLED )
|
||||
LOG_TYPE( SPELLS, LOAD_ERR, DISABLED )
|
||||
LOG_TYPE( SPELLS, CASTING_ERR, DISABLED )
|
||||
LOG_TYPE( SPELLS, CASTING, DISABLED )
|
||||
LOG_TYPE( SPELLS, EFFECT_VALUES, DISABLED )
|
||||
LOG_TYPE( SPELLS, RESISTS, DISABLED )
|
||||
LOG_TYPE( SPELLS, STACKING, DISABLED )
|
||||
LOG_TYPE( SPELLS, BARDS, DISABLED )
|
||||
LOG_TYPE( SPELLS, BUFFS, DISABLED )
|
||||
LOG_TYPE( SPELLS, PROCS, DISABLED )
|
||||
LOG_TYPE( SPELLS, MODIFIERS, DISABLED )
|
||||
LOG_TYPE( SPELLS, CRITS, DISABLED )
|
||||
LOG_TYPE( SPELLS, REZ, DISABLED )
|
||||
|
||||
LOG_CATEGORY( FACTION )
|
||||
|
||||
LOG_CATEGORY( ZONE )
|
||||
LOG_TYPE( ZONE, GROUND_SPAWNS, DISABLED )
|
||||
LOG_TYPE( ZONE, SPAWNS, ENABLED)
|
||||
LOG_TYPE( ZONE, INIT, ENABLED )
|
||||
LOG_TYPE( ZONE, INIT_ERR, ENABLED )
|
||||
LOG_TYPE( ZONE, WORLD, ENABLED )
|
||||
LOG_TYPE( ZONE, WORLD_ERR, ENABLED )
|
||||
LOG_TYPE( ZONE, WORLD_TRACE, DISABLED )
|
||||
|
||||
LOG_CATEGORY( TASKS )
|
||||
LOG_TYPE( TASKS, GLOBALLOAD, DISABLED )
|
||||
LOG_TYPE( TASKS, CLIENTLOAD, DISABLED )
|
||||
LOG_TYPE( TASKS, UPDATE, DISABLED )
|
||||
LOG_TYPE( TASKS, CLIENTSAVE, DISABLED )
|
||||
LOG_TYPE( TASKS, PACKETS, DISABLED )
|
||||
LOG_TYPE( TASKS, PROXIMITY, DISABLED )
|
||||
|
||||
|
||||
LOG_CATEGORY( TRADING )
|
||||
LOG_TYPE( TRADING, ERROR, ENABLED )
|
||||
LOG_TYPE( TRADING, CLIENT, DISABLED )
|
||||
LOG_TYPE( TRADING, NPC, DISABLED )
|
||||
LOG_TYPE( TRADING, HOLDER, DISABLED )
|
||||
LOG_TYPE( TRADING, BARTER, DISABLED )
|
||||
LOG_TYPE( TRADING, PACKETS, DISABLED )
|
||||
|
||||
LOG_CATEGORY( INVENTORY )
|
||||
LOG_TYPE( INVENTORY, ERROR, ENABLED )
|
||||
LOG_TYPE( INVENTORY, SLOTS, ENABLED )
|
||||
LOG_TYPE( INVENTORY, BANDOLIER, ENABLED )
|
||||
|
||||
LOG_CATEGORY( TRADESKILLS )
|
||||
LOG_TYPE( TRADESKILLS, IN, DISABLED )
|
||||
LOG_TYPE( TRADESKILLS, OUT, DISABLED )
|
||||
LOG_TYPE( TRADESKILLS, SQL, DISABLED )
|
||||
LOG_TYPE( TRADESKILLS, TRACE, DISABLED )
|
||||
|
||||
LOG_CATEGORY( TRIBUTE )
|
||||
LOG_TYPE( TRIBUTE, ERROR, DISABLED )
|
||||
LOG_TYPE( TRIBUTE, IN, DISABLED )
|
||||
LOG_TYPE( TRIBUTE, OUT, DISABLED )
|
||||
|
||||
LOG_CATEGORY( AA )
|
||||
LOG_TYPE( AA, ERROR, ENABLED )
|
||||
LOG_TYPE( AA, MESSAGE, DISABLED )
|
||||
LOG_TYPE( AA, IN, DISABLED )
|
||||
LOG_TYPE( AA, OUT, DISABLED )
|
||||
LOG_TYPE( AA, BONUSES, DISABLED )
|
||||
|
||||
|
||||
LOG_CATEGORY( DOORS )
|
||||
LOG_TYPE( DOORS, INFO, DISABLED )
|
||||
|
||||
LOG_CATEGORY( PETS )
|
||||
LOG_TYPE( PETS, AGGRO, DISABLED )
|
||||
|
||||
LOG_CATEGORY( COMBAT )
|
||||
LOG_TYPE( COMBAT, ATTACKS, DISABLED )
|
||||
LOG_TYPE( COMBAT, TOHIT, DISABLED )
|
||||
LOG_TYPE( COMBAT, MISSES, DISABLED )
|
||||
LOG_TYPE( COMBAT, DAMAGE, DISABLED )
|
||||
LOG_TYPE( COMBAT, HITS, DISABLED )
|
||||
LOG_TYPE( COMBAT, RANGED, DISABLED )
|
||||
LOG_TYPE( COMBAT, SPECIAL_ATTACKS, DISABLED )
|
||||
LOG_TYPE( COMBAT, PROCS, DISABLED )
|
||||
|
||||
LOG_CATEGORY( GUILDS )
|
||||
LOG_TYPE( GUILDS, ERROR, ENABLED )
|
||||
LOG_TYPE( GUILDS, ACTIONS, ENABLED )
|
||||
LOG_TYPE( GUILDS, DB, DISABLED )
|
||||
LOG_TYPE( GUILDS, PERMISSIONS, DISABLED )
|
||||
LOG_TYPE( GUILDS, REFRESH, DISABLED ) //inter-zone refresh comm
|
||||
LOG_TYPE( GUILDS, IN_PACKETS, DISABLED )
|
||||
LOG_TYPE( GUILDS, OUT_PACKETS, DISABLED )
|
||||
LOG_TYPE( GUILDS, IN_PACKET_TRACE, DISABLED ) //hex dumps
|
||||
LOG_TYPE( GUILDS, OUT_PACKET_TRACE, DISABLED ) //hex dumps
|
||||
LOG_TYPE( GUILDS, BANK_ERROR, ENABLED )
|
||||
|
||||
LOG_CATEGORY( CLIENT )
|
||||
LOG_TYPE( CLIENT, ERROR, ENABLED )
|
||||
LOG_TYPE( CLIENT, DUELING, DISABLED )
|
||||
LOG_TYPE( CLIENT, SPELLS, DISABLED )
|
||||
LOG_TYPE( CLIENT, NET_ERR, ENABLED )
|
||||
LOG_TYPE( CLIENT, NET_IN_TRACE, DISABLED )
|
||||
LOG_TYPE( CLIENT, EXP, DISABLED )
|
||||
|
||||
LOG_CATEGORY( SKILLS )
|
||||
LOG_TYPE( SKILLS, GAIN, DISABLED )
|
||||
|
||||
LOG_CATEGORY( RULES )
|
||||
LOG_TYPE( RULES, ERROR, DISABLED )
|
||||
LOG_TYPE( RULES, CHANGE, DISABLED )
|
||||
|
||||
LOG_CATEGORY( NET )
|
||||
LOG_TYPE( NET, WORLD, ENABLED )
|
||||
LOG_TYPE( NET, OPCODES, ENABLED )
|
||||
LOG_TYPE( NET, IDENTIFY, ENABLED )
|
||||
LOG_TYPE( NET, IDENT_TRACE, ENABLED )
|
||||
LOG_TYPE( NET, STRUCTS, ENABLED )
|
||||
LOG_TYPE( NET, STRUCT_HEX, ENABLED )
|
||||
LOG_TYPE( NET, ERROR, ENABLED )
|
||||
LOG_TYPE( NET, DEBUG, DISABLED )
|
||||
LOG_TYPE( NET, APP_TRACE, DISABLED )
|
||||
LOG_TYPE( NET, APP_CREATE, DISABLED )
|
||||
LOG_TYPE( NET, APP_CREATE_HEX, DISABLED )
|
||||
LOG_TYPE( NET, NET_TRACE, DISABLED )
|
||||
LOG_TYPE( NET, NET_COMBINE, DISABLED )
|
||||
LOG_TYPE( NET, FRAGMENT, DISABLED )
|
||||
LOG_TYPE( NET, FRAGMENT_HEX, DISABLED )
|
||||
LOG_TYPE( NET, NET_CREATE, DISABLED )
|
||||
LOG_TYPE( NET, NET_CREATE_HEX, DISABLED )
|
||||
LOG_TYPE( NET, NET_ACKS, DISABLED )
|
||||
LOG_TYPE( NET, RATES, DISABLED )
|
||||
|
||||
LOG_CATEGORY( DATABASE )
|
||||
|
||||
LOG_CATEGORY( COMMON )
|
||||
LOG_TYPE( COMMON, ERROR, ENABLED )
|
||||
LOG_TYPE( COMMON, THREADS, ENABLED )
|
||||
|
||||
LOG_CATEGORY( LAUNCHER )
|
||||
LOG_TYPE( LAUNCHER, ERROR, ENABLED )
|
||||
LOG_TYPE( LAUNCHER, INIT, ENABLED )
|
||||
LOG_TYPE( LAUNCHER, STATUS, ENABLED )
|
||||
LOG_TYPE( LAUNCHER, NET, ENABLED )
|
||||
LOG_TYPE( LAUNCHER, WORLD, ENABLED )
|
||||
|
||||
LOG_CATEGORY( WORLD )
|
||||
LOG_TYPE( WORLD, CONFIG, ENABLED )
|
||||
LOG_TYPE( WORLD, INIT, ENABLED )
|
||||
LOG_TYPE( WORLD, INIT_ERR, ENABLED )
|
||||
LOG_TYPE( WORLD, CLIENT, ENABLED )
|
||||
LOG_TYPE( WORLD, ZONE, ENABLED )
|
||||
LOG_TYPE( WORLD, LS, ENABLED )
|
||||
LOG_TYPE( WORLD, CLIENT_ERR, ENABLED )
|
||||
LOG_TYPE( WORLD, ZONE_ERR, ENABLED )
|
||||
LOG_TYPE( WORLD, LS_ERR, ENABLED )
|
||||
LOG_TYPE( WORLD, SHUTDOWN, ENABLED )
|
||||
LOG_TYPE( WORLD, CLIENTLIST, DISABLED )
|
||||
LOG_TYPE( WORLD, CLIENTLIST_ERR, ENABLED )
|
||||
LOG_TYPE( WORLD, ZONELIST, ENABLED )
|
||||
LOG_TYPE( WORLD, ZONELIST_ERR, ENABLED )
|
||||
LOG_TYPE( WORLD, CLIENT_TRACE, DISABLED )
|
||||
LOG_TYPE( WORLD, ZONE_TRACE, DISABLED )
|
||||
LOG_TYPE( WORLD, LS_TRACE, DISABLED )
|
||||
LOG_TYPE( WORLD, CONSOLE, ENABLED )
|
||||
LOG_TYPE( WORLD, HTTP, ENABLED )
|
||||
LOG_TYPE( WORLD, HTTP_ERR, ENABLED )
|
||||
LOG_TYPE( WORLD, PERL, ENABLED )
|
||||
LOG_TYPE( WORLD, PERL_ERR, ENABLED )
|
||||
LOG_TYPE( WORLD, EQW, ENABLED )
|
||||
LOG_TYPE( WORLD, LAUNCH, ENABLED )
|
||||
LOG_TYPE( WORLD, LAUNCH_ERR, ENABLED )
|
||||
LOG_TYPE( WORLD, LAUNCH_TRACE, ENABLED )
|
||||
|
||||
#undef LOG_TYPE
|
||||
#undef LOG_CATEGORY
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#ifndef _EQEMU_LOOTTABLE_H
|
||||
#define _EQEMU_LOOTTABLE_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#pragma pack(1)
|
||||
struct LootTableEntries_Struct {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// VS6 doesn't like the length of STL generated names: disabling
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "misc_functions.h"
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
#define VERIFY_PACKET_LENGTH(OPCode, Packet, StructName) \
|
||||
if(Packet->size != sizeof(StructName)) \
|
||||
{ \
|
||||
_log(NET__ERROR, "Size mismatch in " #OPCode " expected %i got %i", sizeof(StructName), Packet->size); \
|
||||
Log.Out(Logs::Detail, Logs::Netcode, "Size mismatch in " #OPCode " expected %i got %i", sizeof(StructName), Packet->size); \
|
||||
DumpPacket(Packet); \
|
||||
return; \
|
||||
}
|
||||
|
||||
@ -15,7 +15,8 @@
|
||||
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/debug.h"
|
||||
|
||||
#include "types.h"
|
||||
|
||||
// Quagmire - i was really surprised, but i couldnt find the equivilent standard library function
|
||||
signed char sign(signed int tmp) {
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
#ifndef MOREMATH_H
|
||||
#define MOREMATH_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
signed char sign(signed int tmp);
|
||||
signed char sign(double tmp);
|
||||
uint32 pow32(uint32 base, uint32 exponet);
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
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/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/mutex.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -48,7 +48,7 @@ public:
|
||||
const std::string FieldName(int columnIndex);
|
||||
|
||||
MySQLRequestRow& begin() { return m_CurrentRow; }
|
||||
MySQLRequestRow& end() { return m_OneBeyondRow;}
|
||||
MySQLRequestRow& end() { return m_OneBeyondRow; }
|
||||
|
||||
private:
|
||||
void FreeInternals();
|
||||
|
||||
@ -30,6 +30,12 @@ MySQLRequestRow& MySQLRequestRow::operator=(MySQLRequestRow& moveItem)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
MySQLRequestRow MySQLRequestRow::operator*()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
MySQLRequestRow::MySQLRequestRow(MYSQL_RES *result)
|
||||
: m_Result(result)
|
||||
{
|
||||
|
||||
@ -28,7 +28,7 @@ public:
|
||||
MySQLRequestRow operator++(int);
|
||||
bool operator==(const MySQLRequestRow& rhs);
|
||||
bool operator!=(const MySQLRequestRow& rhs);
|
||||
|
||||
MySQLRequestRow operator*();
|
||||
char* operator[](int index);
|
||||
|
||||
};
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
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/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <string.h>
|
||||
|
||||
@ -221,7 +221,6 @@ OldPacketFileReader::~OldPacketFileReader() {
|
||||
bool OldPacketFileReader::OpenFile(const char *name) {
|
||||
CloseFile();
|
||||
|
||||
//printf("Opening packet file: %s\n", name);
|
||||
|
||||
in = fopen(name, "rb");
|
||||
if(in == NULL) {
|
||||
@ -263,7 +262,6 @@ void OldPacketFileReader::CloseFile() {
|
||||
if(in != NULL) {
|
||||
fclose(in);
|
||||
in = NULL;
|
||||
//printf("Closed packet file.\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -334,7 +332,6 @@ NewPacketFileReader::~NewPacketFileReader() {
|
||||
bool NewPacketFileReader::OpenFile(const char *name) {
|
||||
CloseFile();
|
||||
|
||||
//printf("Opening packet file: %s\n", name);
|
||||
|
||||
in = fopen(name, "rb");
|
||||
if(in == NULL) {
|
||||
@ -376,7 +373,6 @@ void NewPacketFileReader::CloseFile() {
|
||||
if(in != NULL) {
|
||||
fclose(in);
|
||||
in = NULL;
|
||||
//printf("Closed packet file.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
#include "../debug.h"
|
||||
#include "../global_define.h"
|
||||
#include "patches.h"
|
||||
|
||||
#include "titanium.h"
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
#include "../debug.h"
|
||||
#include "../global_define.h"
|
||||
#include "../eqemu_logsys.h"
|
||||
#include "rof.h"
|
||||
#include "../opcodemgr.h"
|
||||
#include "../logsys.h"
|
||||
|
||||
#include "../eq_stream_ident.h"
|
||||
#include "../crc32.h"
|
||||
|
||||
@ -51,7 +52,7 @@ namespace RoF
|
||||
//TODO: figure out how to support shared memory with multiple patches...
|
||||
opcodes = new RegularOpcodeManager();
|
||||
if (!opcodes->LoadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -77,7 +78,7 @@ namespace RoF
|
||||
|
||||
|
||||
|
||||
_log(NET__IDENTIFY, "Registered patch %s", name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name);
|
||||
}
|
||||
|
||||
void Reload()
|
||||
@ -92,10 +93,10 @@ namespace RoF
|
||||
opfile += name;
|
||||
opfile += ".conf";
|
||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
_log(NET__OPCODES, "Reloaded opcodes for patch %s", name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,7 +316,7 @@ namespace RoF
|
||||
|
||||
if (EntryCount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0)
|
||||
{
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -550,7 +551,7 @@ namespace RoF
|
||||
|
||||
if (ItemCount == 0 || (in->size % sizeof(InternalSerializedItem_Struct)) != 0) {
|
||||
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d",
|
||||
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(InternalSerializedItem_Struct));
|
||||
|
||||
delete in;
|
||||
@ -584,14 +585,14 @@ namespace RoF
|
||||
safe_delete_array(Serialized);
|
||||
}
|
||||
else {
|
||||
_log(NET__ERROR, "Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] __emu_buffer;
|
||||
|
||||
//_log(NET__ERROR, "Sending inventory to client");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Sending inventory to client");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
|
||||
dest->FastQueuePacket(&in, ack_req);
|
||||
}
|
||||
@ -1028,16 +1029,16 @@ namespace RoF
|
||||
|
||||
ENCODE(OP_GroupUpdate)
|
||||
{
|
||||
//_log(NET__ERROR, "OP_GroupUpdate");
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] OP_GroupUpdate");
|
||||
EQApplicationPacket *in = *p;
|
||||
GroupJoin_Struct *gjs = (GroupJoin_Struct*)in->pBuffer;
|
||||
|
||||
//_log(NET__ERROR, "Received outgoing OP_GroupUpdate with action code %i", gjs->action);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received outgoing OP_GroupUpdate with action code %i", gjs->action);
|
||||
if ((gjs->action == groupActLeave) || (gjs->action == groupActDisband))
|
||||
{
|
||||
if ((gjs->action == groupActDisband) || !strcmp(gjs->yourname, gjs->membername))
|
||||
{
|
||||
//_log(NET__ERROR, "Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
|
||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupDisbandYou, sizeof(structs::GroupGeneric_Struct));
|
||||
|
||||
@ -1055,14 +1056,14 @@ namespace RoF
|
||||
return;
|
||||
}
|
||||
//if(gjs->action == groupActLeave)
|
||||
// _log(NET__ERROR, "Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
// Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
|
||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupDisbandOther, sizeof(structs::GroupGeneric_Struct));
|
||||
|
||||
structs::GroupGeneric_Struct *ggs = (structs::GroupGeneric_Struct*)outapp->pBuffer;
|
||||
memcpy(ggs->name1, gjs->yourname, sizeof(ggs->name1));
|
||||
memcpy(ggs->name2, gjs->membername, sizeof(ggs->name2));
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
dest->FastQueuePacket(&outapp);
|
||||
|
||||
delete in;
|
||||
@ -1072,19 +1073,19 @@ namespace RoF
|
||||
if (in->size == sizeof(GroupUpdate2_Struct))
|
||||
{
|
||||
// Group Update2
|
||||
//_log(NET__ERROR, "Struct is GroupUpdate2");
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Struct is GroupUpdate2");
|
||||
|
||||
unsigned char *__emu_buffer = in->pBuffer;
|
||||
GroupUpdate2_Struct *gu2 = (GroupUpdate2_Struct*)__emu_buffer;
|
||||
|
||||
//_log(NET__ERROR, "Yourname is %s", gu2->yourname);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Yourname is %s", gu2->yourname);
|
||||
|
||||
int MemberCount = 1;
|
||||
int PacketLength = 8 + strlen(gu2->leadersname) + 1 + 22 + strlen(gu2->yourname) + 1;
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
//_log(NET__ERROR, "Membername[%i] is %s", i, gu2->membername[i]);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Membername[%i] is %s", i, gu2->membername[i]);
|
||||
if (gu2->membername[i][0] != '\0')
|
||||
{
|
||||
PacketLength += (22 + strlen(gu2->membername[i]) + 1);
|
||||
@ -1092,7 +1093,7 @@ namespace RoF
|
||||
}
|
||||
}
|
||||
|
||||
//_log(NET__ERROR, "Leadername is %s", gu2->leadersname);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Leadername is %s", gu2->leadersname);
|
||||
|
||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupUpdateB, PacketLength);
|
||||
|
||||
@ -1138,7 +1139,7 @@ namespace RoF
|
||||
VARSTRUCT_ENCODE_TYPE(uint16, Buffer, 0);
|
||||
}
|
||||
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
dest->FastQueuePacket(&outapp);
|
||||
|
||||
outapp = new EQApplicationPacket(OP_GroupLeadershipAAUpdate, sizeof(GroupLeadershipAAUpdate_Struct));
|
||||
@ -1154,7 +1155,7 @@ namespace RoF
|
||||
return;
|
||||
|
||||
}
|
||||
//_log(NET__ERROR, "Generic GroupUpdate, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Generic GroupUpdate, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
ENCODE_LENGTH_EXACT(GroupJoin_Struct);
|
||||
SETUP_DIRECT_ENCODE(GroupJoin_Struct, structs::GroupJoin_Struct);
|
||||
|
||||
@ -1166,7 +1167,7 @@ namespace RoF
|
||||
GLAAus->NPCMarkerID = emu->NPCMarkerID;
|
||||
|
||||
memcpy(&GLAAus->LeaderAAs, &emu->leader_aas, sizeof(GLAAus->LeaderAAs));
|
||||
//_hex(NET__ERROR, __packet->pBuffer, __packet->size);
|
||||
//Log.Hex(Logs::Netcode, __packet->pBuffer, __packet->size);
|
||||
|
||||
FINISH_ENCODE();
|
||||
|
||||
@ -1462,7 +1463,7 @@ namespace RoF
|
||||
char *serialized = SerializeItem((ItemInst *)int_struct->inst, int_struct->slot_id, &length, 0);
|
||||
|
||||
if (!serialized) {
|
||||
_log(NET__STRUCTS, "Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -2632,7 +2633,7 @@ namespace RoF
|
||||
|
||||
outapp->WriteUInt8(0); // Unknown
|
||||
|
||||
_log(NET__STRUCTS, "Player Profile Packet is %i bytes", outapp->GetWritePosition());
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Player Profile Packet is %i bytes", outapp->GetWritePosition());
|
||||
|
||||
unsigned char *NewBuffer = new unsigned char[outapp->GetWritePosition()];
|
||||
memcpy(NewBuffer, outapp->pBuffer, outapp->GetWritePosition());
|
||||
@ -2643,7 +2644,7 @@ namespace RoF
|
||||
outapp->WriteUInt32(outapp->size - 9);
|
||||
|
||||
CRC32::SetEQChecksum(outapp->pBuffer, outapp->size - 1, 8);
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
|
||||
dest->FastQueuePacket(&outapp, ack_req);
|
||||
delete in;
|
||||
@ -2885,8 +2886,6 @@ namespace RoF
|
||||
}
|
||||
}
|
||||
|
||||
_hex(NET__ERROR, eq, sizeof(structs::SendAA_Struct) + emu->total_abilities*sizeof(structs::AA_Ability));
|
||||
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
|
||||
@ -3453,7 +3452,7 @@ namespace RoF
|
||||
|
||||
if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0)
|
||||
{
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -3699,7 +3698,7 @@ namespace RoF
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, OutBuffer, x);
|
||||
}
|
||||
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
dest->FastQueuePacket(&outapp);
|
||||
delete in;
|
||||
}
|
||||
@ -3786,16 +3785,16 @@ namespace RoF
|
||||
//determine and verify length
|
||||
int entrycount = in->size / sizeof(Spawn_Struct);
|
||||
if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) {
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
|
||||
//_log(NET__STRUCTS, "Spawn name is [%s]", emu->name);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[STRUCTS] Spawn name is [%s]", emu->name);
|
||||
|
||||
emu = (Spawn_Struct *)__emu_buffer;
|
||||
|
||||
//_log(NET__STRUCTS, "Spawn packet size is %i, entries = %i", in->size, entrycount);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[STRUCTS] Spawn packet size is %i, entries = %i", in->size, entrycount);
|
||||
|
||||
char *Buffer = (char *)in->pBuffer, *BufferStart;
|
||||
|
||||
@ -4034,10 +4033,10 @@ namespace RoF
|
||||
Buffer += 29;
|
||||
if (Buffer != (BufferStart + PacketSize))
|
||||
{
|
||||
_log(NET__ERROR, "SPAWN ENCODE LOGIC PROBLEM: Buffer pointer is now %i from end", 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(NET__ERROR, "Sending zone spawn for %s packet is %i bytes", emu->name, outapp->size);
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//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);
|
||||
dest->FastQueuePacket(&outapp, ack_req);
|
||||
}
|
||||
|
||||
@ -4451,8 +4450,8 @@ namespace RoF
|
||||
DECODE(OP_GroupDisband)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_Disband");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_Disband");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupGeneric_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupGeneric_Struct);
|
||||
|
||||
@ -4465,8 +4464,8 @@ namespace RoF
|
||||
DECODE(OP_GroupFollow)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupFollow");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupFollow");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupFollow_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupFollow_Struct);
|
||||
|
||||
@ -4479,8 +4478,8 @@ namespace RoF
|
||||
DECODE(OP_GroupFollow2)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupFollow2");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupFollow2");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupFollow_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupFollow_Struct);
|
||||
|
||||
@ -4493,8 +4492,8 @@ namespace RoF
|
||||
DECODE(OP_GroupInvite)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupInvite");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupInvite");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupInvite_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupInvite_Struct);
|
||||
|
||||
@ -4506,7 +4505,7 @@ namespace RoF
|
||||
|
||||
DECODE(OP_GroupInvite2)
|
||||
{
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupInvite2. Forwarding");
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupInvite2. Forwarding");
|
||||
DECODE_FORWARD(OP_GroupInvite);
|
||||
}
|
||||
|
||||
@ -4650,14 +4649,12 @@ namespace RoF
|
||||
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
|
||||
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
|
||||
|
||||
//_log(NET__ERROR, "Moved item from %u to %u", eq->from_slot.MainSlot, eq->to_slot.MainSlot);
|
||||
_log(NET__ERROR, "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.SlotType, eq->to_slot.SlotType, eq->from_slot.MainSlot, eq->to_slot.MainSlot, eq->from_slot.SubSlot, eq->to_slot.SubSlot, eq->from_slot.AugSlot, eq->to_slot.AugSlot, eq->from_slot.Unknown01, eq->to_slot.Unknown01, eq->number_in_stack);
|
||||
//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, "[ERROR] 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.SlotType, eq->to_slot.SlotType, eq->from_slot.MainSlot, eq->to_slot.MainSlot, eq->from_slot.SubSlot, eq->to_slot.SubSlot, eq->from_slot.AugSlot, eq->to_slot.AugSlot, 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);
|
||||
|
||||
_hex(NET__ERROR, eq, sizeof(structs::MoveItem_Struct));
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
}
|
||||
|
||||
@ -4980,7 +4977,7 @@ namespace RoF
|
||||
std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary);
|
||||
|
||||
const Item_Struct *item = inst->GetUnscaledItem();
|
||||
//_log(NET__ERROR, "Serialize called for: %s", item->Name);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Serialize called for: %s", item->Name);
|
||||
|
||||
RoF::structs::ItemSerializationHeader hdr;
|
||||
|
||||
@ -5089,7 +5086,7 @@ namespace RoF
|
||||
}
|
||||
|
||||
ss.write((const char*)&null_term, sizeof(uint8));
|
||||
//_log(NET__ERROR, "ItemBody struct is %i bytes", sizeof(RoF::structs::ItemBodyStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody struct is %i bytes", sizeof(RoF::structs::ItemBodyStruct));
|
||||
RoF::structs::ItemBodyStruct ibs;
|
||||
memset(&ibs, 0, sizeof(RoF::structs::ItemBodyStruct));
|
||||
|
||||
@ -5196,7 +5193,7 @@ namespace RoF
|
||||
ss.write((const char*)&null_term, sizeof(uint8));
|
||||
}
|
||||
|
||||
//_log(NET__ERROR, "ItemBody secondary struct is %i bytes", sizeof(RoF::structs::ItemSecondaryBodyStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody secondary struct is %i bytes", sizeof(RoF::structs::ItemSecondaryBodyStruct));
|
||||
RoF::structs::ItemSecondaryBodyStruct isbs;
|
||||
memset(&isbs, 0, sizeof(RoF::structs::ItemSecondaryBodyStruct));
|
||||
|
||||
@ -5237,7 +5234,7 @@ namespace RoF
|
||||
ss.write((const char*)&null_term, sizeof(uint8));
|
||||
}
|
||||
|
||||
//_log(NET__ERROR, "ItemBody tertiary struct is %i bytes", sizeof(RoF::structs::ItemTertiaryBodyStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody tertiary struct is %i bytes", sizeof(RoF::structs::ItemTertiaryBodyStruct));
|
||||
RoF::structs::ItemTertiaryBodyStruct itbs;
|
||||
memset(&itbs, 0, sizeof(RoF::structs::ItemTertiaryBodyStruct));
|
||||
|
||||
@ -5276,7 +5273,7 @@ namespace RoF
|
||||
// Effect Structures Broken down to allow variable length strings for effect names
|
||||
int32 effect_unknown = 0;
|
||||
|
||||
//_log(NET__ERROR, "ItemBody Click effect struct is %i bytes", sizeof(RoF::structs::ClickEffectStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody Click effect struct is %i bytes", sizeof(RoF::structs::ClickEffectStruct));
|
||||
RoF::structs::ClickEffectStruct ices;
|
||||
memset(&ices, 0, sizeof(RoF::structs::ClickEffectStruct));
|
||||
|
||||
@ -5303,7 +5300,7 @@ namespace RoF
|
||||
|
||||
ss.write((const char*)&effect_unknown, sizeof(int32)); // clickunk7
|
||||
|
||||
//_log(NET__ERROR, "ItemBody proc effect struct is %i bytes", sizeof(RoF::structs::ProcEffectStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody proc effect struct is %i bytes", sizeof(RoF::structs::ProcEffectStruct));
|
||||
RoF::structs::ProcEffectStruct ipes;
|
||||
memset(&ipes, 0, sizeof(RoF::structs::ProcEffectStruct));
|
||||
|
||||
@ -5327,7 +5324,7 @@ namespace RoF
|
||||
|
||||
ss.write((const char*)&effect_unknown, sizeof(int32)); // unknown5
|
||||
|
||||
//_log(NET__ERROR, "ItemBody worn effect struct is %i bytes", sizeof(RoF::structs::WornEffectStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody worn effect struct is %i bytes", sizeof(RoF::structs::WornEffectStruct));
|
||||
RoF::structs::WornEffectStruct iwes;
|
||||
memset(&iwes, 0, sizeof(RoF::structs::WornEffectStruct));
|
||||
|
||||
@ -5418,7 +5415,7 @@ namespace RoF
|
||||
ss.write((const char*)&effect_unknown, sizeof(int32)); // unknown6
|
||||
// End of Effects
|
||||
|
||||
//_log(NET__ERROR, "ItemBody Quaternary effect struct is %i bytes", sizeof(RoF::structs::ItemQuaternaryBodyStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody Quaternary effect struct is %i bytes", sizeof(RoF::structs::ItemQuaternaryBodyStruct));
|
||||
RoF::structs::ItemQuaternaryBodyStruct iqbs;
|
||||
memset(&iqbs, 0, sizeof(RoF::structs::ItemQuaternaryBodyStruct));
|
||||
|
||||
@ -5608,7 +5605,7 @@ namespace RoF
|
||||
RoFSlot.MainSlot = TempSlot;
|
||||
}
|
||||
|
||||
_log(NET__ERROR, "Convert Server Slot %i to RoF Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i", ServerSlot, RoFSlot.SlotType, RoFSlot.Unknown02, RoFSlot.MainSlot, RoFSlot.SubSlot, RoFSlot.AugSlot, RoFSlot.Unknown01);
|
||||
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.SlotType, RoFSlot.Unknown02, RoFSlot.MainSlot, RoFSlot.SubSlot, RoFSlot.AugSlot, RoFSlot.Unknown01);
|
||||
|
||||
return RoFSlot;
|
||||
}
|
||||
@ -5649,7 +5646,7 @@ namespace RoF
|
||||
RoFSlot.SubSlot = TempSlot - ((RoFSlot.MainSlot + 2) * EmuConstants::ITEM_CONTAINER_SIZE);
|
||||
}
|
||||
|
||||
_log(NET__ERROR, "Convert Server Slot %i to RoF Slots: Main %i, Sub %i, Aug %i, Unk1 %i", ServerSlot, RoFSlot.MainSlot, RoFSlot.SubSlot, RoFSlot.AugSlot, RoFSlot.Unknown01);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF Slots: Main %i, Sub %i, Aug %i, Unk1 %i", ServerSlot, RoFSlot.MainSlot, RoFSlot.SubSlot, RoFSlot.AugSlot, RoFSlot.Unknown01);
|
||||
|
||||
return RoFSlot;
|
||||
}
|
||||
@ -5754,7 +5751,7 @@ namespace RoF
|
||||
ServerSlot = INVALID_INDEX;
|
||||
}
|
||||
|
||||
_log(NET__ERROR, "Convert RoF Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", RoFSlot.SlotType, RoFSlot.Unknown02, RoFSlot.MainSlot, RoFSlot.SubSlot, RoFSlot.AugSlot, RoFSlot.Unknown01, ServerSlot);
|
||||
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.SlotType, RoFSlot.Unknown02, RoFSlot.MainSlot, RoFSlot.SubSlot, RoFSlot.AugSlot, RoFSlot.Unknown01, ServerSlot);
|
||||
|
||||
return ServerSlot;
|
||||
}
|
||||
@ -5789,7 +5786,7 @@ namespace RoF
|
||||
ServerSlot = TempSlot;
|
||||
}
|
||||
|
||||
_log(NET__ERROR, "Convert RoF Slots: Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", RoFSlot.MainSlot, RoFSlot.SubSlot, RoFSlot.AugSlot, RoFSlot.Unknown01, ServerSlot);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert RoF Slots: Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", RoFSlot.MainSlot, RoFSlot.SubSlot, RoFSlot.AugSlot, RoFSlot.Unknown01, ServerSlot);
|
||||
|
||||
return ServerSlot;
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
#include "../debug.h"
|
||||
#include "../global_define.h"
|
||||
#include "../eqemu_logsys.h"
|
||||
#include "rof2.h"
|
||||
#include "../opcodemgr.h"
|
||||
#include "../logsys.h"
|
||||
|
||||
#include "../eq_stream_ident.h"
|
||||
#include "../crc32.h"
|
||||
|
||||
@ -51,7 +52,7 @@ namespace RoF2
|
||||
//TODO: figure out how to support shared memory with multiple patches...
|
||||
opcodes = new RegularOpcodeManager();
|
||||
if (!opcodes->LoadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -77,7 +78,7 @@ namespace RoF2
|
||||
|
||||
|
||||
|
||||
_log(NET__IDENTIFY, "Registered patch %s", name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name);
|
||||
}
|
||||
|
||||
void Reload()
|
||||
@ -92,10 +93,10 @@ namespace RoF2
|
||||
opfile += name;
|
||||
opfile += ".conf";
|
||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
_log(NET__OPCODES, "Reloaded opcodes for patch %s", name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -381,7 +382,7 @@ namespace RoF2
|
||||
|
||||
if (EntryCount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0)
|
||||
{
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -616,7 +617,7 @@ namespace RoF2
|
||||
|
||||
if (ItemCount == 0 || (in->size % sizeof(InternalSerializedItem_Struct)) != 0) {
|
||||
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d",
|
||||
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(InternalSerializedItem_Struct));
|
||||
|
||||
delete in;
|
||||
@ -650,14 +651,14 @@ namespace RoF2
|
||||
safe_delete_array(Serialized);
|
||||
}
|
||||
else {
|
||||
_log(NET__ERROR, "Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] __emu_buffer;
|
||||
|
||||
//_log(NET__ERROR, "Sending inventory to client");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Sending inventory to client");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
|
||||
dest->FastQueuePacket(&in, ack_req);
|
||||
}
|
||||
@ -1094,16 +1095,16 @@ namespace RoF2
|
||||
|
||||
ENCODE(OP_GroupUpdate)
|
||||
{
|
||||
//_log(NET__ERROR, "OP_GroupUpdate");
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] OP_GroupUpdate");
|
||||
EQApplicationPacket *in = *p;
|
||||
GroupJoin_Struct *gjs = (GroupJoin_Struct*)in->pBuffer;
|
||||
|
||||
//_log(NET__ERROR, "Received outgoing OP_GroupUpdate with action code %i", gjs->action);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received outgoing OP_GroupUpdate with action code %i", gjs->action);
|
||||
if ((gjs->action == groupActLeave) || (gjs->action == groupActDisband))
|
||||
{
|
||||
if ((gjs->action == groupActDisband) || !strcmp(gjs->yourname, gjs->membername))
|
||||
{
|
||||
//_log(NET__ERROR, "Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
|
||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupDisbandYou, sizeof(structs::GroupGeneric_Struct));
|
||||
|
||||
@ -1121,14 +1122,14 @@ namespace RoF2
|
||||
return;
|
||||
}
|
||||
//if(gjs->action == groupActLeave)
|
||||
// _log(NET__ERROR, "Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
// Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
|
||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupDisbandOther, sizeof(structs::GroupGeneric_Struct));
|
||||
|
||||
structs::GroupGeneric_Struct *ggs = (structs::GroupGeneric_Struct*)outapp->pBuffer;
|
||||
memcpy(ggs->name1, gjs->yourname, sizeof(ggs->name1));
|
||||
memcpy(ggs->name2, gjs->membername, sizeof(ggs->name2));
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
dest->FastQueuePacket(&outapp);
|
||||
|
||||
delete in;
|
||||
@ -1138,19 +1139,19 @@ namespace RoF2
|
||||
if (in->size == sizeof(GroupUpdate2_Struct))
|
||||
{
|
||||
// Group Update2
|
||||
//_log(NET__ERROR, "Struct is GroupUpdate2");
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Struct is GroupUpdate2");
|
||||
|
||||
unsigned char *__emu_buffer = in->pBuffer;
|
||||
GroupUpdate2_Struct *gu2 = (GroupUpdate2_Struct*)__emu_buffer;
|
||||
|
||||
//_log(NET__ERROR, "Yourname is %s", gu2->yourname);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Yourname is %s", gu2->yourname);
|
||||
|
||||
int MemberCount = 1;
|
||||
int PacketLength = 8 + strlen(gu2->leadersname) + 1 + 22 + strlen(gu2->yourname) + 1;
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
//_log(NET__ERROR, "Membername[%i] is %s", i, gu2->membername[i]);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Membername[%i] is %s", i, gu2->membername[i]);
|
||||
if (gu2->membername[i][0] != '\0')
|
||||
{
|
||||
PacketLength += (22 + strlen(gu2->membername[i]) + 1);
|
||||
@ -1158,7 +1159,7 @@ namespace RoF2
|
||||
}
|
||||
}
|
||||
|
||||
//_log(NET__ERROR, "Leadername is %s", gu2->leadersname);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Leadername is %s", gu2->leadersname);
|
||||
|
||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupUpdateB, PacketLength);
|
||||
|
||||
@ -1204,7 +1205,7 @@ namespace RoF2
|
||||
VARSTRUCT_ENCODE_TYPE(uint16, Buffer, 0);
|
||||
}
|
||||
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
dest->FastQueuePacket(&outapp);
|
||||
|
||||
outapp = new EQApplicationPacket(OP_GroupLeadershipAAUpdate, sizeof(GroupLeadershipAAUpdate_Struct));
|
||||
@ -1220,7 +1221,7 @@ namespace RoF2
|
||||
return;
|
||||
|
||||
}
|
||||
//_log(NET__ERROR, "Generic GroupUpdate, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Generic GroupUpdate, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
ENCODE_LENGTH_EXACT(GroupJoin_Struct);
|
||||
SETUP_DIRECT_ENCODE(GroupJoin_Struct, structs::GroupJoin_Struct);
|
||||
|
||||
@ -1232,7 +1233,7 @@ namespace RoF2
|
||||
GLAAus->NPCMarkerID = emu->NPCMarkerID;
|
||||
|
||||
memcpy(&GLAAus->LeaderAAs, &emu->leader_aas, sizeof(GLAAus->LeaderAAs));
|
||||
//_hex(NET__ERROR, __packet->pBuffer, __packet->size);
|
||||
//Log.Hex(Logs::Netcode, __packet->pBuffer, __packet->size);
|
||||
|
||||
FINISH_ENCODE();
|
||||
|
||||
@ -1528,7 +1529,7 @@ namespace RoF2
|
||||
char *serialized = SerializeItem((ItemInst *)int_struct->inst, int_struct->slot_id, &length, 0, old_item_pkt->PacketType);
|
||||
|
||||
if (!serialized) {
|
||||
_log(NET__STRUCTS, "Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -2716,7 +2717,7 @@ namespace RoF2
|
||||
// Think we need 1 byte of padding at the end
|
||||
outapp->WriteUInt8(0); // Unknown
|
||||
|
||||
_log(NET__STRUCTS, "Player Profile Packet is %i bytes", outapp->GetWritePosition());
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Player Profile Packet is %i bytes", outapp->GetWritePosition());
|
||||
|
||||
unsigned char *NewBuffer = new unsigned char[outapp->GetWritePosition()];
|
||||
memcpy(NewBuffer, outapp->pBuffer, outapp->GetWritePosition());
|
||||
@ -2727,7 +2728,7 @@ namespace RoF2
|
||||
outapp->WriteUInt32(outapp->size - 9);
|
||||
|
||||
CRC32::SetEQChecksum(outapp->pBuffer, outapp->size - 1, 8);
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
|
||||
dest->FastQueuePacket(&outapp, ack_req);
|
||||
delete in;
|
||||
@ -2969,8 +2970,6 @@ namespace RoF2
|
||||
}
|
||||
}
|
||||
|
||||
_hex(NET__ERROR, eq, sizeof(structs::SendAA_Struct) + emu->total_abilities*sizeof(structs::AA_Ability));
|
||||
|
||||
FINISH_ENCODE();
|
||||
}
|
||||
|
||||
@ -3519,7 +3518,7 @@ namespace RoF2
|
||||
|
||||
if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0)
|
||||
{
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -3766,7 +3765,7 @@ namespace RoF2
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, OutBuffer, x);
|
||||
}
|
||||
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
dest->FastQueuePacket(&outapp);
|
||||
delete in;
|
||||
}
|
||||
@ -3853,16 +3852,16 @@ namespace RoF2
|
||||
//determine and verify length
|
||||
int entrycount = in->size / sizeof(Spawn_Struct);
|
||||
if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) {
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
|
||||
//_log(NET__STRUCTS, "Spawn name is [%s]", emu->name);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[STRUCTS] Spawn name is [%s]", emu->name);
|
||||
|
||||
emu = (Spawn_Struct *)__emu_buffer;
|
||||
|
||||
//_log(NET__STRUCTS, "Spawn packet size is %i, entries = %i", in->size, entrycount);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[STRUCTS] Spawn packet size is %i, entries = %i", in->size, entrycount);
|
||||
|
||||
char *Buffer = (char *)in->pBuffer, *BufferStart;
|
||||
|
||||
@ -4105,10 +4104,10 @@ namespace RoF2
|
||||
Buffer += 29;
|
||||
if (Buffer != (BufferStart + PacketSize))
|
||||
{
|
||||
_log(NET__ERROR, "SPAWN ENCODE LOGIC PROBLEM: Buffer pointer is now %i from end", 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(NET__ERROR, "Sending zone spawn for %s packet is %i bytes", emu->name, outapp->size);
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//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);
|
||||
dest->FastQueuePacket(&outapp, ack_req);
|
||||
}
|
||||
|
||||
@ -4523,8 +4522,8 @@ namespace RoF2
|
||||
DECODE(OP_GroupDisband)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_Disband");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_Disband");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupGeneric_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupGeneric_Struct);
|
||||
|
||||
@ -4537,8 +4536,8 @@ namespace RoF2
|
||||
DECODE(OP_GroupFollow)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupFollow");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupFollow");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupFollow_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupFollow_Struct);
|
||||
|
||||
@ -4551,8 +4550,8 @@ namespace RoF2
|
||||
DECODE(OP_GroupFollow2)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupFollow2");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupFollow2");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupFollow_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupFollow_Struct);
|
||||
|
||||
@ -4565,8 +4564,8 @@ namespace RoF2
|
||||
DECODE(OP_GroupInvite)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupInvite");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupInvite");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupInvite_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupInvite_Struct);
|
||||
|
||||
@ -4578,7 +4577,7 @@ namespace RoF2
|
||||
|
||||
DECODE(OP_GroupInvite2)
|
||||
{
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupInvite2. Forwarding");
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupInvite2. Forwarding");
|
||||
DECODE_FORWARD(OP_GroupInvite);
|
||||
}
|
||||
|
||||
@ -4721,14 +4720,11 @@ namespace RoF2
|
||||
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
|
||||
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
|
||||
|
||||
//_log(NET__ERROR, "Moved item from %u to %u", eq->from_slot.MainSlot, eq->to_slot.MainSlot);
|
||||
_log(NET__ERROR, "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.SlotType, eq->to_slot.SlotType, eq->from_slot.MainSlot, eq->to_slot.MainSlot, eq->from_slot.SubSlot, eq->to_slot.SubSlot, eq->from_slot.AugSlot, eq->to_slot.AugSlot, eq->from_slot.Unknown01, eq->to_slot.Unknown01, eq->number_in_stack);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] 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.SlotType, eq->to_slot.SlotType, eq->from_slot.MainSlot, eq->to_slot.MainSlot, eq->from_slot.SubSlot, eq->to_slot.SubSlot, eq->from_slot.AugSlot, eq->to_slot.AugSlot, 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);
|
||||
|
||||
_hex(NET__ERROR, eq, sizeof(structs::MoveItem_Struct));
|
||||
|
||||
FINISH_DIRECT_DECODE();
|
||||
}
|
||||
|
||||
@ -5051,7 +5047,7 @@ namespace RoF2
|
||||
std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary);
|
||||
|
||||
const Item_Struct *item = inst->GetUnscaledItem();
|
||||
//_log(NET__ERROR, "Serialize called for: %s", item->Name);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Serialize called for: %s", item->Name);
|
||||
|
||||
RoF2::structs::ItemSerializationHeader hdr;
|
||||
|
||||
@ -5159,7 +5155,7 @@ namespace RoF2
|
||||
}
|
||||
|
||||
ss.write((const char*)&null_term, sizeof(uint8));
|
||||
//_log(NET__ERROR, "ItemBody struct is %i bytes", sizeof(RoF2::structs::ItemBodyStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody struct is %i bytes", sizeof(RoF2::structs::ItemBodyStruct));
|
||||
RoF2::structs::ItemBodyStruct ibs;
|
||||
memset(&ibs, 0, sizeof(RoF2::structs::ItemBodyStruct));
|
||||
|
||||
@ -5266,7 +5262,7 @@ namespace RoF2
|
||||
ss.write((const char*)&null_term, sizeof(uint8));
|
||||
}
|
||||
|
||||
//_log(NET__ERROR, "ItemBody secondary struct is %i bytes", sizeof(RoF2::structs::ItemSecondaryBodyStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody secondary struct is %i bytes", sizeof(RoF2::structs::ItemSecondaryBodyStruct));
|
||||
RoF2::structs::ItemSecondaryBodyStruct isbs;
|
||||
memset(&isbs, 0, sizeof(RoF2::structs::ItemSecondaryBodyStruct));
|
||||
|
||||
@ -5307,7 +5303,7 @@ namespace RoF2
|
||||
ss.write((const char*)&null_term, sizeof(uint8));
|
||||
}
|
||||
|
||||
//_log(NET__ERROR, "ItemBody tertiary struct is %i bytes", sizeof(RoF2::structs::ItemTertiaryBodyStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody tertiary struct is %i bytes", sizeof(RoF2::structs::ItemTertiaryBodyStruct));
|
||||
RoF2::structs::ItemTertiaryBodyStruct itbs;
|
||||
memset(&itbs, 0, sizeof(RoF2::structs::ItemTertiaryBodyStruct));
|
||||
|
||||
@ -5346,7 +5342,7 @@ namespace RoF2
|
||||
// Effect Structures Broken down to allow variable length strings for effect names
|
||||
int32 effect_unknown = 0;
|
||||
|
||||
//_log(NET__ERROR, "ItemBody Click effect struct is %i bytes", sizeof(RoF2::structs::ClickEffectStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody Click effect struct is %i bytes", sizeof(RoF2::structs::ClickEffectStruct));
|
||||
RoF2::structs::ClickEffectStruct ices;
|
||||
memset(&ices, 0, sizeof(RoF2::structs::ClickEffectStruct));
|
||||
|
||||
@ -5373,7 +5369,7 @@ namespace RoF2
|
||||
|
||||
ss.write((const char*)&effect_unknown, sizeof(int32)); // clickunk7
|
||||
|
||||
//_log(NET__ERROR, "ItemBody proc effect struct is %i bytes", sizeof(RoF2::structs::ProcEffectStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody proc effect struct is %i bytes", sizeof(RoF2::structs::ProcEffectStruct));
|
||||
RoF2::structs::ProcEffectStruct ipes;
|
||||
memset(&ipes, 0, sizeof(RoF2::structs::ProcEffectStruct));
|
||||
|
||||
@ -5397,7 +5393,7 @@ namespace RoF2
|
||||
|
||||
ss.write((const char*)&effect_unknown, sizeof(int32)); // unknown5
|
||||
|
||||
//_log(NET__ERROR, "ItemBody worn effect struct is %i bytes", sizeof(RoF2::structs::WornEffectStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody worn effect struct is %i bytes", sizeof(RoF2::structs::WornEffectStruct));
|
||||
RoF2::structs::WornEffectStruct iwes;
|
||||
memset(&iwes, 0, sizeof(RoF2::structs::WornEffectStruct));
|
||||
|
||||
@ -5488,7 +5484,7 @@ namespace RoF2
|
||||
ss.write((const char*)&effect_unknown, sizeof(int32)); // unknown6
|
||||
// End of Effects
|
||||
|
||||
//_log(NET__ERROR, "ItemBody Quaternary effect struct is %i bytes", sizeof(RoF2::structs::ItemQuaternaryBodyStruct));
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] ItemBody Quaternary effect struct is %i bytes", sizeof(RoF2::structs::ItemQuaternaryBodyStruct));
|
||||
RoF2::structs::ItemQuaternaryBodyStruct iqbs;
|
||||
memset(&iqbs, 0, sizeof(RoF2::structs::ItemQuaternaryBodyStruct));
|
||||
|
||||
@ -5699,7 +5695,7 @@ namespace RoF2
|
||||
RoF2Slot.MainSlot = TempSlot;
|
||||
}
|
||||
|
||||
_log(NET__ERROR, "Convert Server Slot %i to RoF2 Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i", ServerSlot, RoF2Slot.SlotType, RoF2Slot.Unknown02, RoF2Slot.MainSlot, RoF2Slot.SubSlot, RoF2Slot.AugSlot, RoF2Slot.Unknown01);
|
||||
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.SlotType, RoF2Slot.Unknown02, RoF2Slot.MainSlot, RoF2Slot.SubSlot, RoF2Slot.AugSlot, RoF2Slot.Unknown01);
|
||||
|
||||
return RoF2Slot;
|
||||
}
|
||||
@ -5740,7 +5736,7 @@ namespace RoF2
|
||||
RoF2Slot.SubSlot = TempSlot - ((RoF2Slot.MainSlot + 2) * EmuConstants::ITEM_CONTAINER_SIZE);
|
||||
}
|
||||
|
||||
_log(NET__ERROR, "Convert Server Slot %i to RoF2 Slots: Main %i, Sub %i, Aug %i, Unk1 %i", ServerSlot, RoF2Slot.MainSlot, RoF2Slot.SubSlot, RoF2Slot.AugSlot, RoF2Slot.Unknown01);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert Server Slot %i to RoF2 Slots: Main %i, Sub %i, Aug %i, Unk1 %i", ServerSlot, RoF2Slot.MainSlot, RoF2Slot.SubSlot, RoF2Slot.AugSlot, RoF2Slot.Unknown01);
|
||||
|
||||
return RoF2Slot;
|
||||
}
|
||||
@ -5849,7 +5845,7 @@ namespace RoF2
|
||||
ServerSlot = RoF2Slot.MainSlot + EmuConstants::CORPSE_BEGIN;
|
||||
}
|
||||
|
||||
_log(NET__ERROR, "Convert RoF2 Slots: Type %i, Unk2 %i, Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", RoF2Slot.SlotType, RoF2Slot.Unknown02, RoF2Slot.MainSlot, RoF2Slot.SubSlot, RoF2Slot.AugSlot, RoF2Slot.Unknown01, ServerSlot);
|
||||
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.SlotType, RoF2Slot.Unknown02, RoF2Slot.MainSlot, RoF2Slot.SubSlot, RoF2Slot.AugSlot, RoF2Slot.Unknown01, ServerSlot);
|
||||
|
||||
return ServerSlot;
|
||||
}
|
||||
@ -5884,7 +5880,7 @@ namespace RoF2
|
||||
ServerSlot = TempSlot;
|
||||
}
|
||||
|
||||
_log(NET__ERROR, "Convert RoF2 Slots: Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", RoF2Slot.MainSlot, RoF2Slot.SubSlot, RoF2Slot.AugSlot, RoF2Slot.Unknown01, ServerSlot);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Convert RoF2 Slots: Main %i, Sub %i, Aug %i, Unk1 %i to Server Slot %i", RoF2Slot.MainSlot, RoF2Slot.SubSlot, RoF2Slot.AugSlot, RoF2Slot.Unknown01, ServerSlot);
|
||||
|
||||
return ServerSlot;
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
#include "../debug.h"
|
||||
#include "../global_define.h"
|
||||
#include "../eqemu_logsys.h"
|
||||
#include "sod.h"
|
||||
#include "../opcodemgr.h"
|
||||
#include "../logsys.h"
|
||||
|
||||
#include "../eq_stream_ident.h"
|
||||
#include "../crc32.h"
|
||||
|
||||
@ -49,7 +50,7 @@ namespace SoD
|
||||
//TODO: figure out how to support shared memory with multiple patches...
|
||||
opcodes = new RegularOpcodeManager();
|
||||
if (!opcodes->LoadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -75,7 +76,7 @@ namespace SoD
|
||||
|
||||
|
||||
|
||||
_log(NET__IDENTIFY, "Registered patch %s", name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name);
|
||||
}
|
||||
|
||||
void Reload()
|
||||
@ -90,10 +91,10 @@ namespace SoD
|
||||
opfile += name;
|
||||
opfile += ".conf";
|
||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
_log(NET__OPCODES, "Reloaded opcodes for patch %s", name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -246,7 +247,7 @@ namespace SoD
|
||||
|
||||
if (EntryCount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0)
|
||||
{
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -358,7 +359,7 @@ namespace SoD
|
||||
|
||||
if (ItemCount == 0 || (in->size % sizeof(InternalSerializedItem_Struct)) != 0) {
|
||||
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d",
|
||||
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(InternalSerializedItem_Struct));
|
||||
|
||||
delete in;
|
||||
@ -390,14 +391,14 @@ namespace SoD
|
||||
|
||||
}
|
||||
else {
|
||||
_log(NET__ERROR, "Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] __emu_buffer;
|
||||
|
||||
//_log(NET__ERROR, "Sending inventory to client");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Sending inventory to client");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
|
||||
dest->FastQueuePacket(&in, ack_req);
|
||||
}
|
||||
@ -759,16 +760,16 @@ namespace SoD
|
||||
|
||||
ENCODE(OP_GroupUpdate)
|
||||
{
|
||||
//_log(NET__ERROR, "OP_GroupUpdate");
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] OP_GroupUpdate");
|
||||
EQApplicationPacket *in = *p;
|
||||
GroupJoin_Struct *gjs = (GroupJoin_Struct*)in->pBuffer;
|
||||
|
||||
//_log(NET__ERROR, "Received outgoing OP_GroupUpdate with action code %i", gjs->action);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received outgoing OP_GroupUpdate with action code %i", gjs->action);
|
||||
if ((gjs->action == groupActLeave) || (gjs->action == groupActDisband))
|
||||
{
|
||||
if ((gjs->action == groupActDisband) || !strcmp(gjs->yourname, gjs->membername))
|
||||
{
|
||||
//_log(NET__ERROR, "Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
|
||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupDisbandYou, sizeof(structs::GroupGeneric_Struct));
|
||||
|
||||
@ -786,14 +787,14 @@ namespace SoD
|
||||
return;
|
||||
}
|
||||
//if(gjs->action == groupActLeave)
|
||||
// _log(NET__ERROR, "Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
// Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
|
||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupDisbandOther, sizeof(structs::GroupGeneric_Struct));
|
||||
|
||||
structs::GroupGeneric_Struct *ggs = (structs::GroupGeneric_Struct*)outapp->pBuffer;
|
||||
memcpy(ggs->name1, gjs->yourname, sizeof(ggs->name1));
|
||||
memcpy(ggs->name2, gjs->membername, sizeof(ggs->name2));
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
dest->FastQueuePacket(&outapp);
|
||||
|
||||
delete in;
|
||||
@ -803,19 +804,19 @@ namespace SoD
|
||||
if (in->size == sizeof(GroupUpdate2_Struct))
|
||||
{
|
||||
// Group Update2
|
||||
//_log(NET__ERROR, "Struct is GroupUpdate2");
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Struct is GroupUpdate2");
|
||||
|
||||
unsigned char *__emu_buffer = in->pBuffer;
|
||||
GroupUpdate2_Struct *gu2 = (GroupUpdate2_Struct*)__emu_buffer;
|
||||
|
||||
//_log(NET__ERROR, "Yourname is %s", gu2->yourname);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Yourname is %s", gu2->yourname);
|
||||
|
||||
int MemberCount = 1;
|
||||
int PacketLength = 8 + strlen(gu2->leadersname) + 1 + 22 + strlen(gu2->yourname) + 1;
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
//_log(NET__ERROR, "Membername[%i] is %s", i, gu2->membername[i]);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Membername[%i] is %s", i, gu2->membername[i]);
|
||||
if (gu2->membername[i][0] != '\0')
|
||||
{
|
||||
PacketLength += (22 + strlen(gu2->membername[i]) + 1);
|
||||
@ -823,7 +824,7 @@ namespace SoD
|
||||
}
|
||||
}
|
||||
|
||||
//_log(NET__ERROR, "Leadername is %s", gu2->leadersname);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Leadername is %s", gu2->leadersname);
|
||||
|
||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupUpdateB, PacketLength);
|
||||
char *Buffer = (char *)outapp->pBuffer;
|
||||
@ -868,7 +869,7 @@ namespace SoD
|
||||
VARSTRUCT_ENCODE_TYPE(uint16, Buffer, 0);
|
||||
}
|
||||
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
dest->FastQueuePacket(&outapp);
|
||||
|
||||
outapp = new EQApplicationPacket(OP_GroupLeadershipAAUpdate, sizeof(GroupLeadershipAAUpdate_Struct));
|
||||
@ -883,7 +884,7 @@ namespace SoD
|
||||
return;
|
||||
}
|
||||
|
||||
//_log(NET__ERROR, "Generic GroupUpdate, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Generic GroupUpdate, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
ENCODE_LENGTH_EXACT(GroupJoin_Struct);
|
||||
SETUP_DIRECT_ENCODE(GroupJoin_Struct, structs::GroupJoin_Struct);
|
||||
|
||||
@ -895,7 +896,7 @@ namespace SoD
|
||||
GLAAus->NPCMarkerID = emu->NPCMarkerID;
|
||||
|
||||
memcpy(&GLAAus->LeaderAAs, &emu->leader_aas, sizeof(GLAAus->LeaderAAs));
|
||||
//_hex(NET__ERROR, __packet->pBuffer, __packet->size);
|
||||
//Log.Hex(Logs::Netcode, __packet->pBuffer, __packet->size);
|
||||
|
||||
FINISH_ENCODE();
|
||||
|
||||
@ -1043,7 +1044,7 @@ namespace SoD
|
||||
char *serialized = SerializeItem((ItemInst *)int_struct->inst, int_struct->slot_id, &length, 0);
|
||||
|
||||
if (!serialized) {
|
||||
_log(NET__STRUCTS, "Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -2237,7 +2238,7 @@ namespace SoD
|
||||
|
||||
if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0)
|
||||
{
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -2417,7 +2418,7 @@ namespace SoD
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, OutBuffer, x);
|
||||
}
|
||||
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
dest->FastQueuePacket(&outapp);
|
||||
delete in;
|
||||
}
|
||||
@ -2492,16 +2493,16 @@ namespace SoD
|
||||
//determine and verify length
|
||||
int entrycount = in->size / sizeof(Spawn_Struct);
|
||||
if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) {
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
|
||||
//_log(NET__STRUCTS, "Spawn name is [%s]", emu->name);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[STRUCTS] Spawn name is [%s]", emu->name);
|
||||
|
||||
emu = (Spawn_Struct *)__emu_buffer;
|
||||
|
||||
//_log(NET__STRUCTS, "Spawn packet size is %i, entries = %i", in->size, entrycount);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[STRUCTS] Spawn packet size is %i, entries = %i", in->size, entrycount);
|
||||
|
||||
char *Buffer = (char *)in->pBuffer;
|
||||
|
||||
@ -3113,8 +3114,8 @@ namespace SoD
|
||||
DECODE(OP_GroupDisband)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_Disband");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_Disband");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupGeneric_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupGeneric_Struct);
|
||||
|
||||
@ -3127,8 +3128,8 @@ namespace SoD
|
||||
DECODE(OP_GroupFollow)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupFollow");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupFollow");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupFollow_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupFollow_Struct);
|
||||
|
||||
@ -3141,8 +3142,8 @@ namespace SoD
|
||||
DECODE(OP_GroupFollow2)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupFollow2");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupFollow2");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupFollow_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupFollow_Struct);
|
||||
|
||||
@ -3155,8 +3156,8 @@ namespace SoD
|
||||
DECODE(OP_GroupInvite)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupInvite");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupInvite");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupInvite_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupInvite_Struct);
|
||||
|
||||
@ -3168,7 +3169,7 @@ namespace SoD
|
||||
|
||||
DECODE(OP_GroupInvite2)
|
||||
{
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupInvite2. Forwarding");
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupInvite2. Forwarding");
|
||||
DECODE_FORWARD(OP_GroupInvite);
|
||||
}
|
||||
|
||||
@ -3241,7 +3242,7 @@ namespace SoD
|
||||
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
|
||||
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
|
||||
|
||||
_log(NET__ERROR, "Moved item from %u to %u", eq->from_slot, eq->to_slot);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] 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);
|
||||
@ -3534,7 +3535,7 @@ namespace SoD
|
||||
std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary);
|
||||
|
||||
const Item_Struct *item = inst->GetUnscaledItem();
|
||||
//_log(NET__ERROR, "Serialize called for: %s", item->Name);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Serialize called for: %s", item->Name);
|
||||
SoD::structs::ItemSerializationHeader hdr;
|
||||
hdr.stacksize = stackable ? charges : 1;
|
||||
hdr.unknown004 = 0;
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
#include "../debug.h"
|
||||
#include "../global_define.h"
|
||||
#include "../eqemu_logsys.h"
|
||||
#include "sof.h"
|
||||
#include "../opcodemgr.h"
|
||||
#include "../logsys.h"
|
||||
|
||||
#include "../eq_stream_ident.h"
|
||||
#include "../crc32.h"
|
||||
|
||||
@ -49,7 +50,7 @@ namespace SoF
|
||||
//TODO: figure out how to support shared memory with multiple patches...
|
||||
opcodes = new RegularOpcodeManager();
|
||||
if (!opcodes->LoadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -75,7 +76,7 @@ namespace SoF
|
||||
|
||||
|
||||
|
||||
_log(NET__IDENTIFY, "Registered patch %s", name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name);
|
||||
}
|
||||
|
||||
void Reload()
|
||||
@ -90,10 +91,10 @@ namespace SoF
|
||||
opfile += name;
|
||||
opfile += ".conf";
|
||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
_log(NET__OPCODES, "Reloaded opcodes for patch %s", name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,7 +214,7 @@ namespace SoF
|
||||
//determine and verify length
|
||||
int entrycount = in->size / sizeof(BazaarSearchResults_Struct);
|
||||
if (entrycount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0) {
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d",
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
@ -336,7 +337,7 @@ namespace SoF
|
||||
|
||||
if (ItemCount == 0 || (in->size % sizeof(InternalSerializedItem_Struct)) != 0) {
|
||||
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d",
|
||||
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(InternalSerializedItem_Struct));
|
||||
|
||||
delete in;
|
||||
@ -370,14 +371,14 @@ namespace SoF
|
||||
|
||||
}
|
||||
else {
|
||||
_log(NET__ERROR, "Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] __emu_buffer;
|
||||
|
||||
//_log(NET__ERROR, "Sending inventory to client");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Sending inventory to client");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
|
||||
dest->FastQueuePacket(&in, ack_req);
|
||||
}
|
||||
@ -842,7 +843,7 @@ namespace SoF
|
||||
char *serialized = SerializeItem((ItemInst *)int_struct->inst, int_struct->slot_id, &length, 0);
|
||||
|
||||
if (!serialized) {
|
||||
_log(NET__STRUCTS, "Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -1836,7 +1837,7 @@ namespace SoF
|
||||
|
||||
if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0)
|
||||
{
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -2016,7 +2017,7 @@ namespace SoF
|
||||
//determine and verify length
|
||||
int entrycount = in->size / sizeof(Spawn_Struct);
|
||||
if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) {
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -2225,8 +2226,8 @@ namespace SoF
|
||||
//kill off the emu structure and send the eq packet.
|
||||
delete[] __emu_buffer;
|
||||
|
||||
//_log(NET__ERROR, "Sending zone spawns");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Sending zone spawns");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
|
||||
dest->FastQueuePacket(&in, ack_req);
|
||||
}
|
||||
@ -2579,7 +2580,7 @@ namespace SoF
|
||||
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
|
||||
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
|
||||
|
||||
_log(NET__ERROR, "Moved item from %u to %u", eq->from_slot, eq->to_slot);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] 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);
|
||||
@ -2858,7 +2859,7 @@ namespace SoF
|
||||
std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary);
|
||||
|
||||
const Item_Struct *item = inst->GetUnscaledItem();
|
||||
//_log(NET__ERROR, "Serialize called for: %s", item->Name);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Serialize called for: %s", item->Name);
|
||||
SoF::structs::ItemSerializationHeader hdr;
|
||||
hdr.stacksize = stackable ? charges : 1;
|
||||
hdr.unknown004 = 0;
|
||||
|
||||
@ -64,16 +64,14 @@
|
||||
//check length of packet before decoding. Call before setup.
|
||||
#define ENCODE_LENGTH_EXACT(struct_) \
|
||||
if((*p)->size != sizeof(struct_)) { \
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s (" #struct_ "): Got %d, expected %d", opcodes->EmuToName((*p)->GetOpcode()), (*p)->size, sizeof(struct_)); \
|
||||
_hex(NET__STRUCT_HEX, (*p)->pBuffer, (*p)->size); \
|
||||
Log.Out(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(NET__STRUCTS, "Wrong size on outbound %s (" #struct_ "): Got %d, expected at least %d", opcodes->EmuToName((*p)->GetOpcode()), (*p)->size, sizeof(struct_)); \
|
||||
_hex(NET__STRUCT_HEX, (*p)->pBuffer, (*p)->size); \
|
||||
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_)); \
|
||||
delete *p; \
|
||||
*p = nullptr; \
|
||||
return; \
|
||||
@ -127,15 +125,13 @@
|
||||
#define DECODE_LENGTH_EXACT(struct_) \
|
||||
if(__packet->size != sizeof(struct_)) { \
|
||||
__packet->SetOpcode(OP_Unknown); /* invalidate the packet */ \
|
||||
_log(NET__STRUCTS, "Wrong size on incoming %s (" #struct_ "): Got %d, expected %d", opcodes->EmuToName(__packet->GetOpcode()), __packet->size, sizeof(struct_)); \
|
||||
_hex(NET__STRUCT_HEX, __packet->pBuffer, __packet->size); \
|
||||
Log.Out(Logs::Detail, Logs::Netcode, "Wrong size on incoming %s (" #struct_ "): Got %d, expected %d", opcodes->EmuToName(__packet->GetOpcode()), __packet->size, sizeof(struct_)); \
|
||||
return; \
|
||||
}
|
||||
#define DECODE_LENGTH_ATLEAST(struct_) \
|
||||
if(__packet->size < sizeof(struct_)) { \
|
||||
__packet->SetOpcode(OP_Unknown); /* invalidate the packet */ \
|
||||
_log(NET__STRUCTS, "Wrong size on incoming %s (" #struct_ "): Got %d, expected at least %d", opcodes->EmuToName(__packet->GetOpcode()), __packet->size, sizeof(struct_)); \
|
||||
_hex(NET__STRUCT_HEX, __packet->pBuffer, __packet->size); \
|
||||
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_)); \
|
||||
return; \
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ void Register(EQStreamIdentifier &into) {
|
||||
//TODO: figure out how to support shared memory with multiple patches...
|
||||
opcodes = new RegularOpcodeManager();
|
||||
if(!opcodes->LoadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -55,10 +55,10 @@ void Reload() {
|
||||
opfile += name;
|
||||
opfile += ".conf";
|
||||
if(!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
_log(NET__OPCODES, "Reloaded opcodes for patch %s", name);
|
||||
logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
#include "../debug.h"
|
||||
#include "../global_define.h"
|
||||
#include "../eqemu_logsys.h"
|
||||
#include "titanium.h"
|
||||
#include "../opcodemgr.h"
|
||||
#include "../logsys.h"
|
||||
|
||||
#include "../eq_stream_ident.h"
|
||||
#include "../crc32.h"
|
||||
#include "../races.h"
|
||||
@ -47,7 +48,7 @@ namespace Titanium
|
||||
//TODO: figure out how to support shared memory with multiple patches...
|
||||
opcodes = new RegularOpcodeManager();
|
||||
if (!opcodes->LoadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -73,7 +74,7 @@ namespace Titanium
|
||||
|
||||
|
||||
|
||||
_log(NET__IDENTIFY, "Registered patch %s", name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name);
|
||||
}
|
||||
|
||||
void Reload()
|
||||
@ -88,10 +89,10 @@ namespace Titanium
|
||||
opfile += name;
|
||||
opfile += ".conf";
|
||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
_log(NET__OPCODES, "Reloaded opcodes for patch %s", name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +187,7 @@ namespace Titanium
|
||||
//determine and verify length
|
||||
int entrycount = in->size / sizeof(BazaarSearchResults_Struct);
|
||||
if (entrycount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0) {
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d",
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
@ -267,7 +268,7 @@ namespace Titanium
|
||||
|
||||
int itemcount = in->size / sizeof(InternalSerializedItem_Struct);
|
||||
if (itemcount == 0 || (in->size % sizeof(InternalSerializedItem_Struct)) != 0) {
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(InternalSerializedItem_Struct));
|
||||
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(InternalSerializedItem_Struct));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -284,7 +285,7 @@ namespace Titanium
|
||||
safe_delete_array(serialized);
|
||||
}
|
||||
else {
|
||||
_log(NET__STRUCTS, "Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
}
|
||||
|
||||
}
|
||||
@ -711,7 +712,7 @@ namespace Titanium
|
||||
char *serialized = SerializeItem((ItemInst *)int_struct->inst, int_struct->slot_id, &length, 0);
|
||||
|
||||
if (!serialized) {
|
||||
_log(NET__STRUCTS, "Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -1286,7 +1287,7 @@ namespace Titanium
|
||||
|
||||
if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0)
|
||||
{
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -1403,7 +1404,7 @@ namespace Titanium
|
||||
//determine and verify length
|
||||
int entrycount = in->size / sizeof(Spawn_Struct);
|
||||
if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) {
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -1773,7 +1774,7 @@ namespace Titanium
|
||||
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
|
||||
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
|
||||
|
||||
_log(NET__ERROR, "Moved item from %u to %u", eq->from_slot, eq->to_slot);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] 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);
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
#include "../debug.h"
|
||||
#include "../global_define.h"
|
||||
#include "../eqemu_logsys.h"
|
||||
#include "underfoot.h"
|
||||
#include "../opcodemgr.h"
|
||||
#include "../logsys.h"
|
||||
|
||||
#include "../eq_stream_ident.h"
|
||||
#include "../crc32.h"
|
||||
|
||||
@ -49,7 +50,7 @@ namespace Underfoot
|
||||
//TODO: figure out how to support shared memory with multiple patches...
|
||||
opcodes = new RegularOpcodeManager();
|
||||
if (!opcodes->LoadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error loading opcodes file %s. Not registering patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -75,7 +76,7 @@ namespace Underfoot
|
||||
|
||||
|
||||
|
||||
_log(NET__IDENTIFY, "Registered patch %s", name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[IDENTIFY] Registered patch %s", name);
|
||||
}
|
||||
|
||||
void Reload()
|
||||
@ -90,10 +91,10 @@ namespace Underfoot
|
||||
opfile += name;
|
||||
opfile += ".conf";
|
||||
if (!opcodes->ReloadOpcodes(opfile.c_str())) {
|
||||
_log(NET__OPCODES, "Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Error reloading opcodes file %s for patch %s.", opfile.c_str(), name);
|
||||
return;
|
||||
}
|
||||
_log(NET__OPCODES, "Reloaded opcodes for patch %s", name);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[OPCODES] Reloaded opcodes for patch %s", name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,7 +307,7 @@ namespace Underfoot
|
||||
|
||||
if (EntryCount == 0 || (in->size % sizeof(BazaarSearchResults_Struct)) != 0)
|
||||
{
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(BazaarSearchResults_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -493,7 +494,7 @@ namespace Underfoot
|
||||
|
||||
if (ItemCount == 0 || (in->size % sizeof(InternalSerializedItem_Struct)) != 0) {
|
||||
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d",
|
||||
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(InternalSerializedItem_Struct));
|
||||
|
||||
delete in;
|
||||
@ -525,14 +526,14 @@ namespace Underfoot
|
||||
safe_delete_array(Serialized);
|
||||
}
|
||||
else {
|
||||
_log(NET__ERROR, "Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] __emu_buffer;
|
||||
|
||||
//_log(NET__ERROR, "Sending inventory to client");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Sending inventory to client");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
|
||||
dest->FastQueuePacket(&in, ack_req);
|
||||
}
|
||||
@ -915,16 +916,16 @@ namespace Underfoot
|
||||
|
||||
ENCODE(OP_GroupUpdate)
|
||||
{
|
||||
//_log(NET__ERROR, "OP_GroupUpdate");
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] OP_GroupUpdate");
|
||||
EQApplicationPacket *in = *p;
|
||||
GroupJoin_Struct *gjs = (GroupJoin_Struct*)in->pBuffer;
|
||||
|
||||
//_log(NET__ERROR, "Received outgoing OP_GroupUpdate with action code %i", gjs->action);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received outgoing OP_GroupUpdate with action code %i", gjs->action);
|
||||
if ((gjs->action == groupActLeave) || (gjs->action == groupActDisband))
|
||||
{
|
||||
if ((gjs->action == groupActDisband) || !strcmp(gjs->yourname, gjs->membername))
|
||||
{
|
||||
//_log(NET__ERROR, "Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
|
||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupDisbandYou, sizeof(structs::GroupGeneric_Struct));
|
||||
|
||||
@ -943,14 +944,14 @@ namespace Underfoot
|
||||
return;
|
||||
}
|
||||
//if(gjs->action == groupActLeave)
|
||||
// _log(NET__ERROR, "Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
// Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
|
||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupDisbandOther, sizeof(structs::GroupGeneric_Struct));
|
||||
|
||||
structs::GroupGeneric_Struct *ggs = (structs::GroupGeneric_Struct*)outapp->pBuffer;
|
||||
memcpy(ggs->name1, gjs->yourname, sizeof(ggs->name1));
|
||||
memcpy(ggs->name2, gjs->membername, sizeof(ggs->name2));
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
dest->FastQueuePacket(&outapp);
|
||||
|
||||
delete in;
|
||||
@ -960,19 +961,19 @@ namespace Underfoot
|
||||
if (in->size == sizeof(GroupUpdate2_Struct))
|
||||
{
|
||||
// Group Update2
|
||||
//_log(NET__ERROR, "Struct is GroupUpdate2");
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Struct is GroupUpdate2");
|
||||
|
||||
unsigned char *__emu_buffer = in->pBuffer;
|
||||
GroupUpdate2_Struct *gu2 = (GroupUpdate2_Struct*)__emu_buffer;
|
||||
|
||||
//_log(NET__ERROR, "Yourname is %s", gu2->yourname);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Yourname is %s", gu2->yourname);
|
||||
|
||||
int MemberCount = 1;
|
||||
int PacketLength = 8 + strlen(gu2->leadersname) + 1 + 22 + strlen(gu2->yourname) + 1;
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
{
|
||||
//_log(NET__ERROR, "Membername[%i] is %s", i, gu2->membername[i]);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Membername[%i] is %s", i, gu2->membername[i]);
|
||||
if (gu2->membername[i][0] != '\0')
|
||||
{
|
||||
PacketLength += (22 + strlen(gu2->membername[i]) + 1);
|
||||
@ -980,7 +981,7 @@ namespace Underfoot
|
||||
}
|
||||
}
|
||||
|
||||
//_log(NET__ERROR, "Leadername is %s", gu2->leadersname);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Leadername is %s", gu2->leadersname);
|
||||
|
||||
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupUpdateB, PacketLength);
|
||||
|
||||
@ -1026,7 +1027,7 @@ namespace Underfoot
|
||||
VARSTRUCT_ENCODE_TYPE(uint16, Buffer, 0);
|
||||
}
|
||||
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
dest->FastQueuePacket(&outapp);
|
||||
|
||||
outapp = new EQApplicationPacket(OP_GroupLeadershipAAUpdate, sizeof(GroupLeadershipAAUpdate_Struct));
|
||||
@ -1040,7 +1041,7 @@ namespace Underfoot
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
//_log(NET__ERROR, "Generic GroupUpdate, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Generic GroupUpdate, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
|
||||
ENCODE_LENGTH_EXACT(GroupJoin_Struct);
|
||||
SETUP_DIRECT_ENCODE(GroupJoin_Struct, structs::GroupJoin_Struct);
|
||||
|
||||
@ -1052,7 +1053,7 @@ namespace Underfoot
|
||||
GLAAus->NPCMarkerID = emu->NPCMarkerID;
|
||||
|
||||
memcpy(&GLAAus->LeaderAAs, &emu->leader_aas, sizeof(GLAAus->LeaderAAs));
|
||||
//_hex(NET__ERROR, __packet->pBuffer, __packet->size);
|
||||
//Log.Hex(Logs::Netcode, __packet->pBuffer, __packet->size);
|
||||
|
||||
FINISH_ENCODE();
|
||||
|
||||
@ -1266,7 +1267,7 @@ namespace Underfoot
|
||||
char *serialized = SerializeItem((ItemInst *)int_struct->inst, int_struct->slot_id, &length, 0);
|
||||
|
||||
if (!serialized) {
|
||||
_log(NET__STRUCTS, "Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -2503,7 +2504,7 @@ namespace Underfoot
|
||||
|
||||
if (EntryCount == 0 || ((in->size % sizeof(Track_Struct))) != 0)
|
||||
{
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Track_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
@ -2683,7 +2684,7 @@ namespace Underfoot
|
||||
VARSTRUCT_ENCODE_TYPE(uint32, OutBuffer, x);
|
||||
}
|
||||
|
||||
//_hex(NET__ERROR, outapp->pBuffer, outapp->size);
|
||||
//Log.Hex(Logs::Netcode, outapp->pBuffer, outapp->size);
|
||||
dest->FastQueuePacket(&outapp);
|
||||
delete in;
|
||||
}
|
||||
@ -2753,16 +2754,16 @@ namespace Underfoot
|
||||
//determine and verify length
|
||||
int entrycount = in->size / sizeof(Spawn_Struct);
|
||||
if (entrycount == 0 || (in->size % sizeof(Spawn_Struct)) != 0) {
|
||||
_log(NET__STRUCTS, "Wrong size on outbound %s: Got %d, expected multiple of %d", opcodes->EmuToName(in->GetOpcode()), in->size, sizeof(Spawn_Struct));
|
||||
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));
|
||||
delete in;
|
||||
return;
|
||||
}
|
||||
|
||||
//_log(NET__STRUCTS, "Spawn name is [%s]", emu->name);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[STRUCTS] Spawn name is [%s]", emu->name);
|
||||
|
||||
emu = (Spawn_Struct *)__emu_buffer;
|
||||
|
||||
//_log(NET__STRUCTS, "Spawn packet size is %i, entries = %i", in->size, entrycount);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[STRUCTS] Spawn packet size is %i, entries = %i", in->size, entrycount);
|
||||
|
||||
char *Buffer = (char *)in->pBuffer;
|
||||
|
||||
@ -3426,8 +3427,8 @@ namespace Underfoot
|
||||
DECODE(OP_GroupDisband)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_Disband");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_Disband");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupGeneric_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupGeneric_Struct);
|
||||
|
||||
@ -3440,8 +3441,8 @@ namespace Underfoot
|
||||
DECODE(OP_GroupFollow)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupFollow");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupFollow");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupFollow_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupFollow_Struct);
|
||||
|
||||
@ -3454,8 +3455,8 @@ namespace Underfoot
|
||||
DECODE(OP_GroupFollow2)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupFollow2");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupFollow2");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupFollow_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupFollow_Struct);
|
||||
|
||||
@ -3468,8 +3469,8 @@ namespace Underfoot
|
||||
DECODE(OP_GroupInvite)
|
||||
{
|
||||
//EQApplicationPacket *in = __packet;
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupInvite");
|
||||
//_hex(NET__ERROR, in->pBuffer, in->size);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupInvite");
|
||||
//Log.Hex(Logs::Netcode, in->pBuffer, in->size);
|
||||
DECODE_LENGTH_EXACT(structs::GroupInvite_Struct);
|
||||
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupInvite_Struct);
|
||||
|
||||
@ -3481,7 +3482,7 @@ namespace Underfoot
|
||||
|
||||
DECODE(OP_GroupInvite2)
|
||||
{
|
||||
//_log(NET__ERROR, "Received incoming OP_GroupInvite2. Forwarding");
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Received incoming OP_GroupInvite2. Forwarding");
|
||||
DECODE_FORWARD(OP_GroupInvite);
|
||||
}
|
||||
|
||||
@ -3556,7 +3557,7 @@ namespace Underfoot
|
||||
DECODE_LENGTH_EXACT(structs::MoveItem_Struct);
|
||||
SETUP_DIRECT_DECODE(MoveItem_Struct, structs::MoveItem_Struct);
|
||||
|
||||
_log(NET__ERROR, "Moved item from %u to %u", eq->from_slot, eq->to_slot);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[ERROR] Moved item from %u to %u", eq->from_slot, eq->to_slot);
|
||||
|
||||
emu->from_slot = UnderfootToServerSlot(eq->from_slot);
|
||||
emu->to_slot = UnderfootToServerSlot(eq->to_slot);
|
||||
@ -3779,7 +3780,7 @@ namespace Underfoot
|
||||
std::stringstream ss(std::stringstream::in | std::stringstream::out | std::stringstream::binary);
|
||||
|
||||
const Item_Struct *item = inst->GetUnscaledItem();
|
||||
//_log(NET__ERROR, "Serialize called for: %s", item->Name);
|
||||
//Log.LogDebugType(Logs::General, Logs::Netcode, "[ERROR] Serialize called for: %s", item->Name);
|
||||
Underfoot::structs::ItemSerializationHeader hdr;
|
||||
hdr.stacksize = stackable ? charges : 1;
|
||||
hdr.unknown004 = 0;
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
typedef const char Const_char;
|
||||
|
||||
#ifdef EMBPERL
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/useperl.h"
|
||||
#include "eqdb.h"
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
typedef const char Const_char;
|
||||
|
||||
#ifdef EMBPERL
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/useperl.h"
|
||||
#include "eqdb_res.h"
|
||||
|
||||
|
||||
@ -10,3 +10,6 @@ const EQEmuExePlatform& GetExecutablePlatform() {
|
||||
return exe_platform;
|
||||
}
|
||||
|
||||
int GetExecutablePlatformInt(){
|
||||
return exe_platform;
|
||||
}
|
||||
@ -18,5 +18,6 @@ enum EQEmuExePlatform
|
||||
|
||||
void RegisterExecutablePlatform(EQEmuExePlatform p);
|
||||
const EQEmuExePlatform& GetExecutablePlatform();
|
||||
int GetExecutablePlatformInt();
|
||||
|
||||
#endif
|
||||
|
||||
@ -19,7 +19,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "types.h"
|
||||
#include "proc_launcher.h"
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#ifndef PROCLAUNCHER_H_
|
||||
#define PROCLAUNCHER_H_
|
||||
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
|
||||
#include "timer.h"
|
||||
#include "ptimer.h"
|
||||
@ -135,7 +135,7 @@ bool PersistentTimer::Load(Database *db) {
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
#if EQDEBUG > 5
|
||||
LogFile->write(EQEmuLog::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::General, Logs::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str());
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -168,7 +168,7 @@ bool PersistentTimer::Store(Database *db) {
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
#if EQDEBUG > 5
|
||||
LogFile->write(EQEmuLog::Error, "Error in PersistentTimer::Store, error: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::General, Logs::Error, "Error in PersistentTimer::Store, error: %s", results.ErrorMessage().c_str());
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -188,7 +188,7 @@ bool PersistentTimer::Clear(Database *db) {
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
#if EQDEBUG > 5
|
||||
LogFile->write(EQEmuLog::Error, "Error in PersistentTimer::Clear, error: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::General, Logs::Error, "Error in PersistentTimer::Clear, error: %s", results.ErrorMessage().c_str());
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -200,7 +200,7 @@ bool PersistentTimer::Clear(Database *db) {
|
||||
/* This function checks if the timer triggered */
|
||||
bool PersistentTimer::Expired(Database *db, bool iReset) {
|
||||
if (this == nullptr) {
|
||||
LogFile->write(EQEmuLog::Error, "Null timer during ->Check()!?\n");
|
||||
Log.Out(Logs::General, Logs::Error, "Null timer during ->Check()!?\n");
|
||||
return(true);
|
||||
}
|
||||
uint32 current_time = get_current_time();
|
||||
@ -292,7 +292,7 @@ bool PTimerList::Load(Database *db) {
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
#if EQDEBUG > 5
|
||||
LogFile->write(EQEmuLog::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::General, Logs::Error, "Error in PersistentTimer::Load, error: %s", results.ErrorMessage().c_str());
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -351,7 +351,7 @@ bool PTimerList::Clear(Database *db) {
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
#if EQDEBUG > 5
|
||||
LogFile->write(EQEmuLog::Error, "Error in PersistentTimer::Clear, error: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::General, Logs::Error, "Error in PersistentTimer::Clear, error: %s", results.ErrorMessage().c_str());
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -443,7 +443,7 @@ bool PTimerList::ClearOffline(Database *db, uint32 char_id, pTimerType type) {
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
#if EQDEBUG > 5
|
||||
LogFile->write(EQEmuLog::Error, "Error in PTimerList::ClearOffline, error: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::General, Logs::Error, "Error in PTimerList::ClearOffline, error: %s", results.ErrorMessage().c_str());
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "rulesys.h"
|
||||
#include "logsys.h"
|
||||
|
||||
#include "database.h"
|
||||
#include "string_util.h"
|
||||
#include <cstdlib>
|
||||
@ -107,7 +107,7 @@ bool RuleManager::ListRules(const char *catname, std::vector<const char *> &into
|
||||
if(catname != nullptr) {
|
||||
cat = FindCategory(catname);
|
||||
if(cat == InvalidCategory) {
|
||||
_log(RULES__ERROR, "Unable to find category '%s'", catname);
|
||||
Log.Out(Logs::Detail, Logs::Rules, "Unable to find category '%s'", catname);
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
@ -168,18 +168,18 @@ bool RuleManager::SetRule(const char *rule_name, const char *rule_value, Databas
|
||||
switch(type) {
|
||||
case IntRule:
|
||||
m_RuleIntValues [index] = atoi(rule_value);
|
||||
_log(RULES__CHANGE, "Set rule %s to value %d", rule_name, m_RuleIntValues[index]);
|
||||
Log.Out(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(RULES__CHANGE, "Set rule %s to value %.13f", rule_name, m_RuleRealValues[index]);
|
||||
Log.Out(Logs::Detail, Logs::Rules, "Set rule %s to value %.13f", rule_name, m_RuleRealValues[index]);
|
||||
break;
|
||||
case BoolRule:
|
||||
uint32 val = 0;
|
||||
if(!strcasecmp(rule_value, "on") || !strcasecmp(rule_value, "true") || !strcasecmp(rule_value, "yes") || !strcasecmp(rule_value, "enabled") || !strcmp(rule_value, "1"))
|
||||
val = 1;
|
||||
m_RuleBoolValues[index] = val;
|
||||
_log(RULES__CHANGE, "Set rule %s to value %s", rule_name, m_RuleBoolValues[index] == 1 ?"true":"false");
|
||||
Log.Out(Logs::Detail, Logs::Rules, "Set rule %s to value %s", rule_name, m_RuleBoolValues[index] == 1 ?"true":"false");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ bool RuleManager::SetRule(const char *rule_name, const char *rule_value, Databas
|
||||
}
|
||||
|
||||
void RuleManager::ResetRules() {
|
||||
_log(RULES__CHANGE, "Resetting running rules to default values");
|
||||
Log.Out(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) \
|
||||
@ -214,7 +214,7 @@ bool RuleManager::_FindRule(const char *rule_name, RuleType &type_into, uint16 &
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
_log(RULES__ERROR, "Unable to find rule '%s'", rule_name);
|
||||
Log.Out(Logs::Detail, Logs::Rules, "Unable to find rule '%s'", rule_name);
|
||||
return(false);
|
||||
}
|
||||
|
||||
@ -241,14 +241,14 @@ void RuleManager::SaveRules(Database *db, const char *ruleset) {
|
||||
|
||||
m_activeRuleset = _FindOrCreateRuleset(db, ruleset);
|
||||
if(m_activeRuleset == -1) {
|
||||
_log(RULES__ERROR, "Unable to find or create rule set %s", ruleset);
|
||||
Log.Out(Logs::Detail, Logs::Rules, "Unable to find or create rule set %s", ruleset);
|
||||
return;
|
||||
}
|
||||
m_activeName = ruleset;
|
||||
}
|
||||
_log(RULES__CHANGE, "Saving running rules into rule set %s (%d)", ruleset, m_activeRuleset);
|
||||
Log.Out(Logs::Detail, Logs::Rules, "Saving running rules into rule set %s (%d)", ruleset, m_activeRuleset);
|
||||
} else {
|
||||
_log(RULES__CHANGE, "Saving running rules into running rule set %s", m_activeName.c_str(), m_activeRuleset);
|
||||
Log.Out(Logs::Detail, Logs::Rules, "Saving running rules into running rule set %s", m_activeName.c_str(), m_activeRuleset);
|
||||
}
|
||||
|
||||
int r;
|
||||
@ -269,11 +269,11 @@ bool RuleManager::LoadRules(Database *db, const char *ruleset) {
|
||||
|
||||
int rsid = GetRulesetID(db, ruleset);
|
||||
if(rsid < 0) {
|
||||
_log(RULES__ERROR, "Failed to find ruleset '%s' for load operation. Canceling.", ruleset);
|
||||
Log.Out(Logs::Detail, Logs::Rules, "Failed to find ruleset '%s' for load operation. Canceling.", ruleset);
|
||||
return(false);
|
||||
}
|
||||
|
||||
_log(RULES__CHANGE, "Loading rule set '%s' (%d)", ruleset, rsid);
|
||||
Log.Out(Logs::Detail, Logs::Rules, "Loading rule set '%s' (%d)", ruleset, rsid);
|
||||
|
||||
m_activeRuleset = rsid;
|
||||
m_activeName = ruleset;
|
||||
@ -282,13 +282,12 @@ bool RuleManager::LoadRules(Database *db, const char *ruleset) {
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
{
|
||||
LogFile->write(EQEmuLog::Error, "Error in LoadRules query %s: %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
for(auto row = results.begin(); row != results.end(); ++row)
|
||||
if(!SetRule(row[0], row[1], nullptr, false))
|
||||
_log(RULES__ERROR, "Unable to interpret rule record for %s", row[0]);
|
||||
Log.Out(Logs::Detail, Logs::Rules, "Unable to interpret rule record for %s", row[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -313,8 +312,6 @@ void RuleManager::_SaveRule(Database *db, RuleType type, uint16 index) {
|
||||
" VALUES(%d, '%s', '%s')",
|
||||
m_activeRuleset, _GetRuleName(type, index), vstr);
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
_log(RULES__ERROR, "Fauled to set rule in the database: %s: %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
|
||||
}
|
||||
|
||||
@ -329,7 +326,6 @@ int RuleManager::GetRulesetID(Database *db, const char *rulesetname) {
|
||||
safe_delete_array(rst);
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error in LoadRules query %s: %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -356,7 +352,6 @@ int RuleManager::_FindOrCreateRuleset(Database *db, const char *ruleset) {
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
{
|
||||
_log(RULES__ERROR, "Fauled to create rule set in the database: %s: %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -369,7 +364,6 @@ std::string RuleManager::GetRulesetName(Database *db, int id) {
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
{
|
||||
LogFile->write(EQEmuLog::Error, "Error in LoadRules query %s: %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -390,7 +384,6 @@ bool RuleManager::ListRulesets(Database *db, std::map<int, std::string> &into) {
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (results.Success())
|
||||
{
|
||||
LogFile->write(EQEmuLog::Error, "Error in ListRulesets query %s: %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -602,4 +602,3 @@ RULE_CATEGORY_END()
|
||||
#undef RULE_REAL
|
||||
#undef RULE_BOOL
|
||||
#undef RULE_CATEGORY_END
|
||||
|
||||
|
||||
@ -23,8 +23,9 @@
|
||||
#ifndef SEPERATOR_H
|
||||
#define SEPERATOR_H
|
||||
|
||||
#include <string.h>
|
||||
#include "types.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
class Seperator
|
||||
{
|
||||
|
||||
@ -180,16 +180,17 @@
|
||||
#define ServerOP_CZSignalClientByName 0x4007
|
||||
#define ServerOP_CZMessagePlayer 0x4008
|
||||
#define ServerOP_ReloadWorld 0x4009
|
||||
|
||||
#define ServerOP_QSPlayerLogTrades 0x4010
|
||||
#define ServerOP_QSPlayerLogHandins 0x4011
|
||||
#define ServerOP_QSPlayerLogNPCKills 0x4012
|
||||
#define ServerOP_QSPlayerLogDeletes 0x4013
|
||||
#define ServerOP_QSPlayerLogMoves 0x4014
|
||||
#define ServerOP_QSPlayerLogMerchantTransactions 0x4015
|
||||
#define ServerOP_QSSendQuery 0x4016
|
||||
#define ServerOP_CZSignalNPC 0x4017
|
||||
#define ServerOP_CZSetEntityVariableByNPCTypeID 0x4018
|
||||
#define ServerOP_ReloadLogs 0x4010
|
||||
/* Query Server OP Codes */
|
||||
#define ServerOP_QSPlayerLogTrades 0x5010
|
||||
#define ServerOP_QSPlayerLogHandins 0x5011
|
||||
#define ServerOP_QSPlayerLogNPCKills 0x5012
|
||||
#define ServerOP_QSPlayerLogDeletes 0x5013
|
||||
#define ServerOP_QSPlayerLogMoves 0x5014
|
||||
#define ServerOP_QSPlayerLogMerchantTransactions 0x5015
|
||||
#define ServerOP_QSSendQuery 0x5016
|
||||
#define ServerOP_CZSignalNPC 0x5017
|
||||
#define ServerOP_CZSetEntityVariableByNPCTypeID 0x5018
|
||||
|
||||
/* Query Serv Generic Packet Flag/Type Enumeration */
|
||||
enum { QSG_LFGuild = 0 };
|
||||
|
||||
@ -46,7 +46,6 @@ bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
|
||||
std::string query = StringFormat("UPDATE account SET hideme = %i WHERE id = %i", hideme, account_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in SetGMSpeed query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -58,7 +57,6 @@ uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
|
||||
std::string query = StringFormat("SELECT gmspeed FROM account WHERE id = '%i'", account_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in GetGMSpeed query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -75,7 +73,6 @@ bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
|
||||
std::string query = StringFormat("UPDATE account SET gmspeed = %i WHERE id = %i", gmspeed, account_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in SetGMSpeed query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -127,7 +124,6 @@ bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const Ite
|
||||
account_id, slot_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error runing inventory verification query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
//returning true is less harmful in the face of a query error
|
||||
return true;
|
||||
}
|
||||
@ -219,7 +215,6 @@ bool SharedDatabase::UpdateInventorySlot(uint32 char_id, const ItemInst* inst, i
|
||||
}
|
||||
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "UpdateInventorySlot query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -265,7 +260,6 @@ bool SharedDatabase::UpdateSharedBankSlot(uint32 char_id, const ItemInst* inst,
|
||||
}
|
||||
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "UpdateSharedBankSlot query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -278,7 +272,6 @@ bool SharedDatabase::DeleteInventorySlot(uint32 char_id, int16 slot_id) {
|
||||
std::string query = StringFormat("DELETE FROM inventory WHERE charid = %i AND slotid = %i", char_id, slot_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "DeleteInventorySlot query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -291,7 +284,6 @@ bool SharedDatabase::DeleteInventorySlot(uint32 char_id, int16 slot_id) {
|
||||
char_id, base_slot_id, (base_slot_id+10));
|
||||
results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "DeleteInventorySlot, bags query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -306,7 +298,6 @@ bool SharedDatabase::DeleteSharedBankSlot(uint32 char_id, int16 slot_id) {
|
||||
std::string query = StringFormat("DELETE FROM sharedbank WHERE acctid=%i AND slotid=%i", account_id, slot_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "DeleteSharedBankSlot query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -320,7 +311,6 @@ bool SharedDatabase::DeleteSharedBankSlot(uint32 char_id, int16 slot_id) {
|
||||
account_id, base_slot_id, (base_slot_id+10));
|
||||
results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "DeleteSharedBankSlot, bags query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -334,7 +324,6 @@ int32 SharedDatabase::GetSharedPlatinum(uint32 account_id)
|
||||
std::string query = StringFormat("SELECT sharedplat FROM account WHERE id = '%i'", account_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in GetSharedPlatinum query '" << query << "' " << results.ErrorMessage().c_str() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -350,7 +339,6 @@ bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add) {
|
||||
std::string query = StringFormat("UPDATE account SET sharedplat = sharedplat + %i WHERE id = %i", amount_to_add, account_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in SetSharedPlatinum query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -410,7 +398,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
||||
"FROM sharedbank WHERE acctid=%i", id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Database::GetSharedBank(uint32 account_id): %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::General, Logs::Error, "Database::GetSharedBank(uint32 account_id): %s", results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -430,7 +418,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
||||
const Item_Struct* item = GetItem(item_id);
|
||||
|
||||
if (!item) {
|
||||
LogFile->write(EQEmuLog::Error,
|
||||
Log.Out(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;
|
||||
@ -479,7 +467,7 @@ bool SharedDatabase::GetSharedBank(uint32 id, Inventory* inv, bool is_charid) {
|
||||
if (put_slot_id != INVALID_INDEX)
|
||||
continue;
|
||||
|
||||
LogFile->write(EQEmuLog::Error, "Warning: Invalid slot_id for item in shared bank inventory: %s=%i, item_id=%i, slot_id=%i",
|
||||
Log.Out(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);
|
||||
|
||||
if (is_charid)
|
||||
@ -498,8 +486,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||
"FROM inventory WHERE charid = %i ORDER BY slotid", char_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "GetInventory query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
LogFile->write(EQEmuLog::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");
|
||||
Log.Out(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;
|
||||
}
|
||||
|
||||
@ -527,7 +514,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||
const Item_Struct* item = GetItem(item_id);
|
||||
|
||||
if (!item) {
|
||||
LogFile->write(EQEmuLog::Error,"Warning: charid %i has an invalid item_id %i in inventory slot %i", char_id, item_id, slot_id);
|
||||
Log.Out(Logs::General, Logs::Error,"Warning: charid %i has an invalid item_id %i in inventory slot %i", char_id, item_id, slot_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -595,7 +582,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||
else if (slot_id >= 3111 && slot_id <= 3179)
|
||||
{
|
||||
// Admins: please report any occurrences of this error
|
||||
LogFile->write(EQEmuLog::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);
|
||||
Log.Out(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);
|
||||
}
|
||||
else
|
||||
@ -607,7 +594,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, Inventory* inv) {
|
||||
|
||||
// Save ptr to item in inventory
|
||||
if (put_slot_id == INVALID_INDEX) {
|
||||
LogFile->write(EQEmuLog::Error, "Warning: Invalid slot_id for item in inventory: charid=%i, item_id=%i, slot_id=%i",char_id, item_id, slot_id);
|
||||
Log.Out(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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -625,8 +612,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv)
|
||||
name, account_id);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()){
|
||||
LogFile->write(EQEmuLog::Error, "GetInventory query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
LogFile->write(EQEmuLog::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");
|
||||
Log.Out(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;
|
||||
}
|
||||
|
||||
@ -714,7 +700,7 @@ bool SharedDatabase::GetInventory(uint32 account_id, char* name, Inventory* inv)
|
||||
|
||||
// Save ptr to item in inventory
|
||||
if (put_slot_id == INVALID_INDEX)
|
||||
LogFile->write(EQEmuLog::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);
|
||||
Log.Out(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);
|
||||
|
||||
}
|
||||
|
||||
@ -730,7 +716,6 @@ void SharedDatabase::GetItemsCount(int32 &item_count, uint32 &max_id) {
|
||||
const std::string query = "SELECT MAX(id), count(*) FROM items";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error in GetItemsCount '%s': '%s'", query.c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -770,7 +755,7 @@ bool SharedDatabase::LoadItems() {
|
||||
items_hash = new EQEmu::FixedMemoryHashSet<Item_Struct>(reinterpret_cast<uint8*>(items_mmf->Get()), size);
|
||||
mutex.Unlock();
|
||||
} catch(std::exception& ex) {
|
||||
LogFile->write(EQEmuLog::Error, "Error Loading Items: %s", ex.what());
|
||||
Log.Out(Logs::General, Logs::Error, "Error Loading Items: %s", ex.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -815,7 +800,6 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
|
||||
"updated FROM items ORDER BY id";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "LoadItems '%s', %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1028,7 +1012,7 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_
|
||||
try {
|
||||
hash.insert(item.ID, item);
|
||||
} catch(std::exception &ex) {
|
||||
LogFile->write(EQEmuLog::Error, "Database::LoadItems: %s", ex.what());
|
||||
Log.Out(Logs::General, Logs::Error, "Database::LoadItems: %s", ex.what());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1083,13 +1067,12 @@ std::string SharedDatabase::GetBook(const char *txtfile)
|
||||
std::string query = StringFormat("SELECT txtfile FROM books WHERE name = '%s'", txtfile2);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in GetBook query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
txtout.assign(" ",1);
|
||||
return txtout;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0) {
|
||||
LogFile->write(EQEmuLog::Error, "No book to send, (%s)", txtfile);
|
||||
Log.Out(Logs::General, Logs::Error, "No book to send, (%s)", txtfile);
|
||||
txtout.assign(" ",1);
|
||||
return txtout;
|
||||
}
|
||||
@ -1107,7 +1090,6 @@ void SharedDatabase::GetFactionListInfo(uint32 &list_count, uint32 &max_lists) {
|
||||
const std::string query = "SELECT COUNT(*), MAX(id) FROM npc_faction";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error getting npc faction info from database: %s, %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1142,7 +1124,6 @@ void SharedDatabase::LoadNPCFactionLists(void *data, uint32 size, uint32 list_co
|
||||
"ON npc_faction.id = npc_faction_entries.npc_faction_id ORDER BY npc_faction.id;";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error getting npc faction info from database: %s, %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1208,7 +1189,7 @@ bool SharedDatabase::LoadNPCFactionLists() {
|
||||
faction_hash = new EQEmu::FixedMemoryHashSet<NPCFactionList>(reinterpret_cast<uint8*>(faction_mmf->Get()), size);
|
||||
mutex.Unlock();
|
||||
} catch(std::exception& ex) {
|
||||
LogFile->write(EQEmuLog::Error, "Error Loading npc factions: %s", ex.what());
|
||||
Log.Out(Logs::General, Logs::Error, "Error Loading npc factions: %s", ex.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1226,8 +1207,8 @@ ItemInst* SharedDatabase::CreateItem(uint32 item_id, int16 charges, uint32 aug1,
|
||||
inst = CreateBaseItem(item, charges);
|
||||
|
||||
if (inst == nullptr) {
|
||||
LogFile->write(EQEmuLog::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateItem()");
|
||||
LogFile->write(EQEmuLog::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateItem()");
|
||||
Log.Out(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1252,8 +1233,8 @@ ItemInst* SharedDatabase::CreateItem(const Item_Struct* item, int16 charges, uin
|
||||
inst = CreateBaseItem(item, charges);
|
||||
|
||||
if (inst == nullptr) {
|
||||
LogFile->write(EQEmuLog::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateItem()");
|
||||
LogFile->write(EQEmuLog::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateItem()");
|
||||
Log.Out(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1283,8 +1264,8 @@ ItemInst* SharedDatabase::CreateBaseItem(const Item_Struct* item, int16 charges)
|
||||
inst = new ItemInst(item, charges);
|
||||
|
||||
if (inst == nullptr) {
|
||||
LogFile->write(EQEmuLog::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateBaseItem()");
|
||||
LogFile->write(EQEmuLog::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
|
||||
Log.Out(Logs::General, Logs::Error, "Error: valid item data returned a null reference for ItemInst creation in SharedDatabase::CreateBaseItem()");
|
||||
Log.Out(Logs::General, Logs::Error, "Item Data = ID: %u, Name: %s, Charges: %i", item->ID, item->Name, charges);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -1323,7 +1304,6 @@ bool SharedDatabase::GetCommandSettings(std::map<std::string,uint8> &commands) {
|
||||
const std::string query = "SELECT command, access FROM commands";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in GetCommands query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1354,7 +1334,7 @@ bool SharedDatabase::LoadSkillCaps() {
|
||||
|
||||
mutex.Unlock();
|
||||
} catch(std::exception &ex) {
|
||||
LogFile->write(EQEmuLog::Error, "Error loading skill caps: %s", ex.what());
|
||||
Log.Out(Logs::General, Logs::Error, "Error loading skill caps: %s", ex.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1370,7 +1350,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()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error loading skill caps from database: %s", results.ErrorMessage().c_str());
|
||||
Log.Out(Logs::General, Logs::Error, "Error loading skill caps from database: %s", results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1472,7 +1452,6 @@ void SharedDatabase::LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpe
|
||||
"AND `spellid` <= %i", iMaxSpellID);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error in LoadDamageShieldTypes: %s %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1492,7 +1471,6 @@ int SharedDatabase::GetMaxSpellID() {
|
||||
std::string query = "SELECT MAX(id) FROM spells_new";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
_log(SPELLS__LOAD_ERR, "Error in GetMaxSpellID query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1507,12 +1485,11 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) {
|
||||
const std::string query = "SELECT * FROM spells_new ORDER BY id ASC";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
_log(SPELLS__LOAD_ERR, "Error in LoadSpells query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if(results.ColumnCount() <= SPELL_LOAD_FIELD_COUNT) {
|
||||
_log(SPELLS__LOAD_ERR, "Fatal error loading spells: Spell field count < SPELL_LOAD_FIELD_COUNT(%u)", 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);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1522,7 +1499,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(SPELLS__LOAD_ERR, "Non fatal error: spell.id >= max_spells, ignoring.");
|
||||
Log.Out(Logs::Detail, Logs::Spells, "Non fatal error: spell.id >= max_spells, ignoring.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1668,7 +1645,6 @@ int SharedDatabase::GetMaxBaseDataLevel() {
|
||||
const std::string query = "SELECT MAX(level) FROM base_data";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error in GetMaxBaseDataLevel query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1701,7 +1677,7 @@ bool SharedDatabase::LoadBaseData() {
|
||||
|
||||
mutex.Unlock();
|
||||
} catch(std::exception& ex) {
|
||||
LogFile->write(EQEmuLog::Error, "Error Loading Base Data: %s", ex.what());
|
||||
Log.Out(Logs::General, Logs::Error, "Error Loading Base Data: %s", ex.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1714,7 +1690,6 @@ void SharedDatabase::LoadBaseData(void *data, int max_level) {
|
||||
const std::string query = "SELECT * FROM base_data ORDER BY level, class ASC";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error in LoadBaseData query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1726,22 +1701,22 @@ void SharedDatabase::LoadBaseData(void *data, int max_level) {
|
||||
cl = atoi(row[1]);
|
||||
|
||||
if(lvl <= 0) {
|
||||
LogFile->write(EQEmuLog::Error, "Non fatal error: base_data.level <= 0, ignoring.");
|
||||
Log.Out(Logs::General, Logs::Error, "Non fatal error: base_data.level <= 0, ignoring.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(lvl >= max_level) {
|
||||
LogFile->write(EQEmuLog::Error, "Non fatal error: base_data.level >= max_level, ignoring.");
|
||||
Log.Out(Logs::General, Logs::Error, "Non fatal error: base_data.level >= max_level, ignoring.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(cl <= 0) {
|
||||
LogFile->write(EQEmuLog::Error, "Non fatal error: base_data.cl <= 0, ignoring.");
|
||||
Log.Out(Logs::General, Logs::Error, "Non fatal error: base_data.cl <= 0, ignoring.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(cl > 16) {
|
||||
LogFile->write(EQEmuLog::Error, "Non fatal error: base_data.class > 16, ignoring.");
|
||||
Log.Out(Logs::General, Logs::Error, "Non fatal error: base_data.class > 16, ignoring.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1794,7 +1769,6 @@ void SharedDatabase::GetLootTableInfo(uint32 &loot_table_count, uint32 &max_loot
|
||||
const std::string query = "SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM loottable_entries) FROM loottable";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error getting loot table info from database: %s, %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1816,7 +1790,6 @@ void SharedDatabase::GetLootDropInfo(uint32 &loot_drop_count, uint32 &max_loot_d
|
||||
const std::string query = "SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM lootdrop_entries) FROM lootdrop";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error getting loot table info from database: %s, %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1842,7 +1815,6 @@ void SharedDatabase::LoadLootTables(void *data, uint32 size) {
|
||||
"ON loottable.id = loottable_entries.loottable_id ORDER BY id";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error getting loot table info from database: %s, %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1896,7 +1868,6 @@ void SharedDatabase::LoadLootDrops(void *data, uint32 size) {
|
||||
"ON lootdrop.id = lootdrop_entries.lootdrop_id ORDER BY lootdrop_id";
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEmuLog::Error, "Error getting loot drop info from database: %s, %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
}
|
||||
|
||||
uint32 current_id = 0;
|
||||
@ -1950,7 +1921,7 @@ bool SharedDatabase::LoadLoot() {
|
||||
loot_drop_mmf->Size());
|
||||
mutex.Unlock();
|
||||
} catch(std::exception &ex) {
|
||||
LogFile->write(EQEmuLog::Error, "Error loading loot: %s", ex.what());
|
||||
Log.Out(Logs::General, Logs::Error, "Error loading loot: %s", ex.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1966,7 +1937,7 @@ const LootTable_Struct* SharedDatabase::GetLootTable(uint32 loottable_id) {
|
||||
return &loot_table_hash->at(loottable_id);
|
||||
}
|
||||
} catch(std::exception &ex) {
|
||||
LogFile->write(EQEmuLog::Error, "Could not get loot table: %s", ex.what());
|
||||
Log.Out(Logs::General, Logs::Error, "Could not get loot table: %s", ex.what());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -1980,7 +1951,7 @@ const LootDrop_Struct* SharedDatabase::GetLootDrop(uint32 lootdrop_id) {
|
||||
return &loot_drop_hash->at(lootdrop_id);
|
||||
}
|
||||
} catch(std::exception &ex) {
|
||||
LogFile->write(EQEmuLog::Error, "Could not get loot drop: %s", ex.what());
|
||||
Log.Out(Logs::General, Logs::Error, "Could not get loot drop: %s", ex.what());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@ -2005,7 +1976,6 @@ void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* m
|
||||
std::string query = StringFormat("SELECT BotInspectMessage FROM bots WHERE BotID = %i", botid);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
std::cerr << "Error in GetBotInspectMessage query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2018,11 +1988,7 @@ void SharedDatabase::GetBotInspectMessage(uint32 botid, InspectMessage_Struct* m
|
||||
}
|
||||
|
||||
void SharedDatabase::SetBotInspectMessage(uint32 botid, const InspectMessage_Struct* message) {
|
||||
|
||||
std::string msg = EscapeString(message->text);
|
||||
std::string query = StringFormat("UPDATE bots SET BotInspectMessage = '%s' WHERE BotID = %i", msg.c_str(), botid);
|
||||
auto results = QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
std::cerr << "Error in SetBotInspectMessage query '" << query << "' " << results.ErrorMessage() << std::endl;
|
||||
|
||||
QueryDatabase(query);
|
||||
}
|
||||
|
||||
@ -70,8 +70,9 @@
|
||||
|
||||
*/
|
||||
|
||||
#include "../common/logsys.h"
|
||||
#include "../common/logtypes.h"
|
||||
|
||||
|
||||
#include "../common/eqemu_logsys.h"
|
||||
|
||||
#include "classes.h"
|
||||
#include "spdat.h"
|
||||
@ -838,7 +839,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(SPELLS__EFFECT_VALUES, "DamageShieldType for spell %i (%s) is %X\n", spell_id,
|
||||
Log.Out(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)
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "eqemu_logsys.h"
|
||||
#include "struct_strategy.h"
|
||||
#include "logsys.h"
|
||||
|
||||
#include "eq_stream.h"
|
||||
#include <map>
|
||||
|
||||
@ -38,13 +39,13 @@ void StructStrategy::ErrorEncoder(EQApplicationPacket **in_p, EQStream *dest, bo
|
||||
EQApplicationPacket *p = *in_p;
|
||||
*in_p = nullptr;
|
||||
|
||||
_log(NET__STRUCTS, "Error encoding opcode %s: no encoder provided. Dropping.", OpcodeManager::EmuToName(p->GetOpcode()));
|
||||
Log.Out(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(NET__STRUCTS, "Error decoding opcode %s: no decoder provided. Invalidating.", OpcodeManager::EmuToName(p->GetOpcode()));
|
||||
Log.Out(Logs::General, Logs::Netcode, "[STRUCTS] Error decoding opcode %s: no decoder provided. Invalidating.", OpcodeManager::EmuToName(p->GetOpcode()));
|
||||
p->SetOpcode(OP_Unknown);
|
||||
}
|
||||
|
||||
|
||||
@ -16,7 +16,8 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
@ -540,7 +541,6 @@ bool TCPConnection::Process() {
|
||||
if (!RecvData(errbuf)) {
|
||||
struct in_addr in;
|
||||
in.s_addr = GetrIP();
|
||||
//std::cout << inet_ntoa(in) << ":" << GetrPort() << ": " << errbuf << std::endl;
|
||||
return false;
|
||||
}
|
||||
/* we break to do the send */
|
||||
@ -899,7 +899,7 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
|
||||
}
|
||||
TCPConnection* tcpc = (TCPConnection*) tmp;
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Starting TCPConnectionLoop with thread ID %d", pthread_self());
|
||||
Log.Out(Logs::Detail, Logs::TCP_Connection, "%s Starting TCPConnectionLoop with thread ID %d", __FUNCTION__, pthread_self());
|
||||
#endif
|
||||
tcpc->MLoopRunning.lock();
|
||||
while (tcpc->RunLoop()) {
|
||||
@ -926,7 +926,7 @@ ThreadReturnType TCPConnection::TCPConnectionLoop(void* tmp) {
|
||||
tcpc->MLoopRunning.unlock();
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Ending TCPConnectionLoop with thread ID %d", pthread_self());
|
||||
Log.Out(Logs::Detail, Logs::TCP_Connection, "%s Ending TCPConnectionLoop with thread ID %d", __FUNCTION__, pthread_self());
|
||||
#endif
|
||||
|
||||
THREAD_RETURN(nullptr);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "tcp_server.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdlib>
|
||||
@ -67,7 +68,7 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
|
||||
BaseTCPServer* tcps = (BaseTCPServer*) tmp;
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Starting TCPServerLoop with thread ID %d", pthread_self());
|
||||
Log.Out(Logs::Detail, Logs::None, "Starting TCPServerLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
tcps->MLoopRunning.lock();
|
||||
@ -78,7 +79,7 @@ ThreadReturnType BaseTCPServer::TCPServerLoop(void* tmp) {
|
||||
tcps->MLoopRunning.unlock();
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Ending TCPServerLoop with thread ID %d", pthread_self());
|
||||
Log.Out(Logs::Detail, Logs::None, "Ending TCPServerLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
THREAD_RETURN(nullptr);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#define TCPSERVER_H_
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "mutex.h"
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
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/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
|
||||
//#define TIMEOUT_DEBUG
|
||||
|
||||
@ -43,7 +43,7 @@ void TimeoutManager::CheckTimeouts() {
|
||||
Timeoutable *it = *cur;
|
||||
if(it->next_check.Check()) {
|
||||
#ifdef TIMEOUT_DEBUG
|
||||
LogFile->write(EQEmuLog::Debug, "Checking timeout on 0x%x\n", it);
|
||||
Log.Out(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
|
||||
LogFile->write(EQEmuLog::Debug, "Adding timeoutable 0x%x\n", who);
|
||||
Log.Out(Logs::General, Logs::None,, "Adding timeoutable 0x%x\n", who);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TimeoutManager::DeleteMember(Timeoutable *who) {
|
||||
#ifdef TIMEOUT_DEBUG
|
||||
LogFile->write(EQEmuLog::Debug, "Removing timeoutable 0x%x\n", who);
|
||||
Log.Out(Logs::General, Logs::None,, "Removing timeoutable 0x%x\n", who);
|
||||
#endif
|
||||
std::vector<Timeoutable *>::iterator cur,end;
|
||||
cur = members.begin();
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
// Disgrace: for windows compile
|
||||
#ifdef _WINDOWS
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
int gettimeofday (timeval *tp, ...);
|
||||
#endif
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
||||
*/
|
||||
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9066
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9068
|
||||
#define COMPILE_DATE __DATE__
|
||||
#define COMPILE_TIME __TIME__
|
||||
#ifndef WIN32
|
||||
|
||||
@ -16,7 +16,8 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include <iomanip>
|
||||
|
||||
#include "worldconn.h"
|
||||
@ -43,7 +44,7 @@ bool WorldConnection::SendPacket(ServerPacket* pack) {
|
||||
|
||||
void WorldConnection::OnConnected() {
|
||||
const EQEmuConfig *Config=EQEmuConfig::get();
|
||||
_log(NET__WORLD, "Connected to World: %s:%d", Config->WorldIP.c_str(), Config->WorldTCPPort);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[WORLD] Connected to World: %s:%d", Config->WorldIP.c_str(), Config->WorldTCPPort);
|
||||
|
||||
ServerPacket* pack = new ServerPacket(ServerOP_ZAAuth, 16);
|
||||
MD5::Generate((const uchar*) m_password.c_str(), m_password.length(), pack->pBuffer);
|
||||
@ -75,7 +76,7 @@ bool WorldConnection::Connect() {
|
||||
if (tcpc.Connect(Config->WorldIP.c_str(), Config->WorldTCPPort, errbuf)) {
|
||||
return true;
|
||||
} else {
|
||||
_log(NET__WORLD, "WorldConnection connect: Connecting to the server %s:%d failed: %s", Config->WorldIP.c_str(), Config->WorldTCPPort, errbuf);
|
||||
Log.Out(Logs::General, Logs::Netcode, "[WORLD] WorldConnection connect: Connecting to the server %s:%d failed: %s", Config->WorldIP.c_str(), Config->WorldTCPPort, errbuf);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "xml_parser.h"
|
||||
|
||||
XMLParser::XMLParser() {
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#ifndef XMLParser_H
|
||||
#define XMLParser_H
|
||||
|
||||
#include "debug.h"
|
||||
#include "global_define.h"
|
||||
#include "tinyxml/tinyxml.h"
|
||||
#include "../common/types.h"
|
||||
|
||||
|
||||
@ -16,7 +16,8 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/proc_launcher.h"
|
||||
#include "../common/eqemu_config.h"
|
||||
#include "../common/servertalk.h"
|
||||
@ -30,12 +31,15 @@
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
EQEmuLogSys Log;
|
||||
|
||||
bool RunLoops = false;
|
||||
|
||||
void CatchSignal(int sig_num);
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
RegisterExecutablePlatform(ExePlatformLaunch);
|
||||
Log.LoadLogSettingsDefaults();
|
||||
set_exception_handler();
|
||||
|
||||
std::string launcher_name;
|
||||
@ -43,13 +47,13 @@ int main(int argc, char *argv[]) {
|
||||
launcher_name = argv[1];
|
||||
}
|
||||
if(launcher_name.length() < 1) {
|
||||
_log(LAUNCHER__ERROR, "You must specfify a launcher name as the first argument to this program.");
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "You must specfify a launcher name as the first argument to this program.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
_log(LAUNCHER__INIT, "Loading server configuration..");
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Loading server configuration..");
|
||||
if (!EQEmuConfig::LoadConfig()) {
|
||||
_log(LAUNCHER__ERROR, "Loading server configuration failed.");
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Loading server configuration failed.");
|
||||
return 1;
|
||||
}
|
||||
const EQEmuConfig *Config = EQEmuConfig::get();
|
||||
@ -58,16 +62,16 @@ int main(int argc, char *argv[]) {
|
||||
* Setup nice signal handlers
|
||||
*/
|
||||
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
|
||||
_log(LAUNCHER__ERROR, "Could not set signal handler");
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Could not set signal handler");
|
||||
return 1;
|
||||
}
|
||||
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
|
||||
_log(LAUNCHER__ERROR, "Could not set signal handler");
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Could not set signal handler");
|
||||
return 1;
|
||||
}
|
||||
#ifndef WIN32
|
||||
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
|
||||
_log(LAUNCHER__ERROR, "Could not set signal handler");
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Could not set signal handler");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -88,7 +92,7 @@ int main(int argc, char *argv[]) {
|
||||
std::map<std::string, ZoneLaunch *> zones;
|
||||
WorldServer world(zones, launcher_name.c_str(), Config);
|
||||
if (!world.Connect()) {
|
||||
_log(LAUNCHER__ERROR, "worldserver.Connect() FAILED! Will retry.");
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "worldserver.Connect() FAILED! Will retry.");
|
||||
}
|
||||
|
||||
std::map<std::string, ZoneLaunch *>::iterator zone, zend;
|
||||
@ -96,7 +100,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect
|
||||
|
||||
_log(LAUNCHER__INIT, "Starting main loop...");
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Starting main loop...");
|
||||
|
||||
// zones["test"] = new ZoneLaunch(&world, "./zone", "dynamic_1");
|
||||
|
||||
@ -173,12 +177,14 @@ int main(int argc, char *argv[]) {
|
||||
delete zone->second;
|
||||
}
|
||||
|
||||
Log.CloseFileLogs();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void CatchSignal(int sig_num) {
|
||||
_log(LAUNCHER__STATUS, "Caught signal %d", sig_num);
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Caught signal %d", sig_num);
|
||||
RunLoops = false;
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,9 @@
|
||||
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/debug.h"
|
||||
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/servertalk.h"
|
||||
#include "../common/eqemu_config.h"
|
||||
#include "../common/string_util.h"
|
||||
@ -72,14 +74,14 @@ void WorldServer::Process() {
|
||||
break;
|
||||
}
|
||||
case ServerOP_ZAAuthFailed: {
|
||||
_log(LAUNCHER__ERROR, "World server responded 'Not Authorized', disabling reconnect");
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World server responded 'Not Authorized', disabling reconnect");
|
||||
pTryReconnect = false;
|
||||
Disconnect();
|
||||
break;
|
||||
}
|
||||
case ServerOP_LauncherZoneRequest: {
|
||||
if(pack->size != sizeof(LauncherZoneRequest)) {
|
||||
_log(LAUNCHER__NET, "Invalid size of LauncherZoneRequest: %d", pack->size);
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Invalid size of LauncherZoneRequest: %d", pack->size);
|
||||
break;
|
||||
}
|
||||
const LauncherZoneRequest *lzr = (const LauncherZoneRequest *) pack->pBuffer;
|
||||
@ -88,9 +90,9 @@ void WorldServer::Process() {
|
||||
switch(ZoneRequestCommands(lzr->command)) {
|
||||
case ZR_Start: {
|
||||
if(m_zones.find(lzr->short_name) != m_zones.end()) {
|
||||
_log(LAUNCHER__ERROR, "World told us to start zone %s, but it is already running.", lzr->short_name);
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to start zone %s, but it is already running.", lzr->short_name);
|
||||
} else {
|
||||
_log(LAUNCHER__WORLD, "World told us to start zone %s.", lzr->short_name);
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to start zone %s.", lzr->short_name);
|
||||
ZoneLaunch *l = new ZoneLaunch(this, m_name, lzr->short_name, m_config);
|
||||
m_zones[lzr->short_name] = l;
|
||||
}
|
||||
@ -99,9 +101,9 @@ void WorldServer::Process() {
|
||||
case ZR_Restart: {
|
||||
std::map<std::string, ZoneLaunch *>::iterator res = m_zones.find(lzr->short_name);
|
||||
if(res == m_zones.end()) {
|
||||
_log(LAUNCHER__ERROR, "World told us to restart zone %s, but it is not running.", lzr->short_name);
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to restart zone %s, but it is not running.", lzr->short_name);
|
||||
} else {
|
||||
_log(LAUNCHER__WORLD, "World told us to restart zone %s.", lzr->short_name);
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to restart zone %s.", lzr->short_name);
|
||||
res->second->Restart();
|
||||
}
|
||||
break;
|
||||
@ -109,9 +111,9 @@ void WorldServer::Process() {
|
||||
case ZR_Stop: {
|
||||
std::map<std::string, ZoneLaunch *>::iterator res = m_zones.find(lzr->short_name);
|
||||
if(res == m_zones.end()) {
|
||||
_log(LAUNCHER__ERROR, "World told us to stop zone %s, but it is not running.", lzr->short_name);
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to stop zone %s, but it is not running.", lzr->short_name);
|
||||
} else {
|
||||
_log(LAUNCHER__WORLD, "World told us to stop zone %s.", lzr->short_name);
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "World told us to stop zone %s.", lzr->short_name);
|
||||
res->second->Stop();
|
||||
}
|
||||
break;
|
||||
@ -125,7 +127,7 @@ void WorldServer::Process() {
|
||||
}
|
||||
|
||||
default: {
|
||||
_log(LAUNCHER__NET, "Unknown opcode 0x%x from World of len %d", pack->opcode, pack->size);
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Unknown opcode 0x%x from World of len %d", pack->opcode, pack->size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,8 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/eqemu_config.h"
|
||||
#include "zone_launch.h"
|
||||
#include "worldserver.h"
|
||||
@ -71,7 +72,7 @@ void ZoneLaunch::Start() {
|
||||
//spec is consumed, even on failure
|
||||
m_ref = ProcLauncher::get()->Launch(spec);
|
||||
if(m_ref == ProcLauncher::ProcError) {
|
||||
_log(LAUNCHER__ERROR, "Failure to launch '%s %s %s'. ", m_config->ZoneExe.c_str(), m_zone.c_str(), m_launcherName);
|
||||
Log.Out(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;
|
||||
}
|
||||
@ -83,17 +84,17 @@ void ZoneLaunch::Start() {
|
||||
|
||||
SendStatus();
|
||||
|
||||
_log(LAUNCHER__STATUS, "Zone %s has been started.", m_zone.c_str());
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Zone %s has been started.", m_zone.c_str());
|
||||
}
|
||||
|
||||
void ZoneLaunch::Restart() {
|
||||
switch(m_state) {
|
||||
case StateRestartPending:
|
||||
_log(LAUNCHER__STATUS, "Restart of zone %s requested when a restart is already pending.", m_zone.c_str());
|
||||
Log.Out(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(LAUNCHER__STATUS, "Restart of %s before it has started. Ignoring.", m_zone.c_str());
|
||||
Log.Out(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..
|
||||
@ -101,20 +102,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(LAUNCHER__ERROR, "Failed to terminate zone %s. Giving up and moving to stopped.", m_zone.c_str());
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Failed to terminate zone %s. Giving up and moving to stopped.", m_zone.c_str());
|
||||
m_state = StateStopped;
|
||||
break;
|
||||
}
|
||||
_log(LAUNCHER__STATUS, "Termination signal sent to zone %s.", m_zone.c_str());
|
||||
Log.Out(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(LAUNCHER__STATUS, "Restart of zone %s requested when a stop is pending. Ignoring.", m_zone.c_str());
|
||||
Log.Out(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(LAUNCHER__STATUS, "Restart requested when zone %s is already stopped.", m_zone.c_str());
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Restart requested when zone %s is already stopped.", m_zone.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -123,7 +124,7 @@ void ZoneLaunch::Stop(bool graceful) {
|
||||
switch(m_state) {
|
||||
case StateStartPending:
|
||||
//we havent started yet, transition directly to stopped.
|
||||
_log(LAUNCHER__STATUS, "Stopping zone %s before it has started.", m_zone.c_str());
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Stopping zone %s before it has started.", m_zone.c_str());
|
||||
m_state = StateStopped;
|
||||
break;
|
||||
case StateStarted:
|
||||
@ -133,17 +134,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(LAUNCHER__ERROR, "Failed to terminate zone %s. Giving up and moving to stopped.", m_zone.c_str());
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Failed to terminate zone %s. Giving up and moving to stopped.", m_zone.c_str());
|
||||
m_state = StateStopped;
|
||||
break;
|
||||
}
|
||||
_log(LAUNCHER__STATUS, "Termination signal sent to zone %s.", m_zone.c_str());
|
||||
Log.Out(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(LAUNCHER__STATUS, "Stop requested when zone %s is already stopped.", m_zone.c_str());
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Stop requested when zone %s is already stopped.", m_zone.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -163,17 +164,17 @@ bool ZoneLaunch::Process() {
|
||||
m_timer.Disable();
|
||||
|
||||
//actually start up the program
|
||||
_log(LAUNCHER__STATUS, "Starting zone %s", m_zone.c_str());
|
||||
Log.Out(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(LAUNCHER__STATUS, "Waiting %d milliseconds before booting the second zone.", m_config->InitialBootWait);
|
||||
Log.Out(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(LAUNCHER__STATUS, "Waiting %d milliseconds before booting the next zone.", m_config->ZoneBootInterval);
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Waiting %d milliseconds before booting the next zone.", m_config->ZoneBootInterval);
|
||||
s_startTimer.Start(m_config->ZoneBootInterval);
|
||||
}
|
||||
|
||||
@ -186,7 +187,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(LAUNCHER__STATUS, "Zone %s refused to die, killing again.", m_zone.c_str());
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Zone %s refused to die, killing again.", m_zone.c_str());
|
||||
Restart();
|
||||
}
|
||||
break;
|
||||
@ -196,12 +197,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(LAUNCHER__STATUS, "Zone %s refused to die, giving up and acting like its dead.", m_zone.c_str());
|
||||
Log.Out(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(LAUNCHER__STATUS, "Zone %s refused to die, killing again.", m_zone.c_str());
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Zone %s refused to die, killing again.", m_zone.c_str());
|
||||
Stop(false);
|
||||
}
|
||||
}
|
||||
@ -220,29 +221,29 @@ void ZoneLaunch::OnTerminate(const ProcLauncher::ProcRef &ref, const ProcLaunche
|
||||
|
||||
switch(m_state) {
|
||||
case StateStartPending:
|
||||
_log(LAUNCHER__STATUS, "Zone %s has gone down before we started it..?? Restart timer started.", m_zone.c_str());
|
||||
Log.Out(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(LAUNCHER__STATUS, "Zone %s has gone down. Restart timer started.", m_zone.c_str());
|
||||
Log.Out(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(LAUNCHER__STATUS, "Zone %s has terminated. Transitioning to starting state.", m_zone.c_str());
|
||||
Log.Out(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(LAUNCHER__STATUS, "Zone %s has terminated. Transitioning to stopped state.", m_zone.c_str());
|
||||
Log.Out(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(LAUNCHER__STATUS, "Notified of zone %s terminating when we thought it was stopped.", m_zone.c_str());
|
||||
Log.Out(Logs::Detail, Logs::Launcher, "Notified of zone %s terminating when we thought it was stopped.", m_zone.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#ifndef EQEMU_CLIENT_H
|
||||
#define EQEMU_CLIENT_H
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/opcodemgr.h"
|
||||
#include "../common/eq_stream_type.h"
|
||||
#include "../common/eq_stream_factory.h"
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#ifndef EQEMU_CLIENTMANAGER_H
|
||||
#define EQEMU_CLIENTMANAGER_H
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "../common/opcodemgr.h"
|
||||
#include "../common/eq_stream_type.h"
|
||||
#include "../common/eq_stream_factory.h"
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
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/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "config.h"
|
||||
#include "error_log.h"
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
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/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "database.h"
|
||||
|
||||
#ifdef EQEMU_MYSQL_ENABLED
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
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/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "database.h"
|
||||
|
||||
#ifdef EQEMU_POSTGRESQL_ENABLED
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
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/debug.h"
|
||||
#include "../common/global_define.h"
|
||||
#include "encryption.h"
|
||||
#include "error_log.h"
|
||||
#include <string>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user