Convert netcode debugging _log to logger.LogDebugType

This commit is contained in:
Akkadius
2015-01-12 21:45:49 -06:00
parent 4811631127
commit ffdce868c1
11 changed files with 205 additions and 196 deletions
+30 -29
View File
@@ -1,4 +1,5 @@
#include "../debug.h"
#include "../eqemu_logsys.h"
#include "sod.h"
#include "../opcodemgr.h"
#include "../logsys.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);
logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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);
logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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);
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);
}
}
@@ -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));
logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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",
logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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,13 +391,13 @@ namespace SoD
}
else {
_log(NET__ERROR, "Serialization failed on item slot %d during OP_CharInventory. Item skipped.", eq->slot_id);
logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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");
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[ERROR] Sending inventory to client");
//_hex(NET__ERROR, in->pBuffer, in->size);
dest->FastQueuePacket(&in, ack_req);
@@ -682,16 +683,16 @@ namespace SoD
ENCODE(OP_GroupUpdate)
{
//_log(NET__ERROR, "OP_GroupUpdate");
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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);
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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);
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[ERROR] Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupDisbandYou, sizeof(structs::GroupGeneric_Struct));
@@ -709,7 +710,7 @@ namespace SoD
return;
}
//if(gjs->action == groupActLeave)
// _log(NET__ERROR, "Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
// logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[ERROR] Group Leave, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupDisbandOther, sizeof(structs::GroupGeneric_Struct));
@@ -726,19 +727,19 @@ namespace SoD
if (in->size == sizeof(GroupUpdate2_Struct))
{
// Group Update2
//_log(NET__ERROR, "Struct is GroupUpdate2");
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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);
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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]);
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[ERROR] Membername[%i] is %s", i, gu2->membername[i]);
if (gu2->membername[i][0] != '\0')
{
PacketLength += (22 + strlen(gu2->membername[i]) + 1);
@@ -746,7 +747,7 @@ namespace SoD
}
}
//_log(NET__ERROR, "Leadername is %s", gu2->leadersname);
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[ERROR] Leadername is %s", gu2->leadersname);
EQApplicationPacket *outapp = new EQApplicationPacket(OP_GroupUpdateB, PacketLength);
char *Buffer = (char *)outapp->pBuffer;
@@ -806,7 +807,7 @@ namespace SoD
return;
}
//_log(NET__ERROR, "Generic GroupUpdate, yourname = %s, membername = %s", gjs->yourname, gjs->membername);
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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);
@@ -966,7 +967,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);
logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[STRUCTS] Serialization failed on item slot %d.", int_struct->slot_id);
delete in;
return;
}
@@ -2107,7 +2108,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));
logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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;
}
@@ -2362,16 +2363,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));
logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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);
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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);
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[STRUCTS] Spawn packet size is %i, entries = %i", in->size, entrycount);
char *Buffer = (char *)in->pBuffer;
@@ -2962,7 +2963,7 @@ namespace SoD
DECODE(OP_GroupDisband)
{
//EQApplicationPacket *in = __packet;
//_log(NET__ERROR, "Received incoming OP_Disband");
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[ERROR] Received incoming OP_Disband");
//_hex(NET__ERROR, in->pBuffer, in->size);
DECODE_LENGTH_EXACT(structs::GroupGeneric_Struct);
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupGeneric_Struct);
@@ -2976,7 +2977,7 @@ namespace SoD
DECODE(OP_GroupFollow)
{
//EQApplicationPacket *in = __packet;
//_log(NET__ERROR, "Received incoming OP_GroupFollow");
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[ERROR] Received incoming OP_GroupFollow");
//_hex(NET__ERROR, in->pBuffer, in->size);
DECODE_LENGTH_EXACT(structs::GroupFollow_Struct);
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupFollow_Struct);
@@ -2990,7 +2991,7 @@ namespace SoD
DECODE(OP_GroupFollow2)
{
//EQApplicationPacket *in = __packet;
//_log(NET__ERROR, "Received incoming OP_GroupFollow2");
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[ERROR] Received incoming OP_GroupFollow2");
//_hex(NET__ERROR, in->pBuffer, in->size);
DECODE_LENGTH_EXACT(structs::GroupFollow_Struct);
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupFollow_Struct);
@@ -3004,7 +3005,7 @@ namespace SoD
DECODE(OP_GroupInvite)
{
//EQApplicationPacket *in = __packet;
//_log(NET__ERROR, "Received incoming OP_GroupInvite");
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[ERROR] Received incoming OP_GroupInvite");
//_hex(NET__ERROR, in->pBuffer, in->size);
DECODE_LENGTH_EXACT(structs::GroupInvite_Struct);
SETUP_DIRECT_DECODE(GroupGeneric_Struct, structs::GroupInvite_Struct);
@@ -3017,7 +3018,7 @@ namespace SoD
DECODE(OP_GroupInvite2)
{
//_log(NET__ERROR, "Received incoming OP_GroupInvite2. Forwarding");
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[ERROR] Received incoming OP_GroupInvite2. Forwarding");
DECODE_FORWARD(OP_GroupInvite);
}
@@ -3090,7 +3091,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);
logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::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);
@@ -3383,7 +3384,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);
//logger.LogDebugType(EQEmuLogSys::General, EQEmuLogSys::Netcode, "[ERROR] Serialize called for: %s", item->Name);
SoD::structs::ItemSerializationHeader hdr;
hdr.stacksize = stackable ? charges : 1;
hdr.unknown004 = 0;