Command: debug recv

Places the packet described in the ropcode.txt server-side file into own packet queue (counterpart of debug send opcode).
This commit is contained in:
Olion 2017-07-25 13:06:09 +03:00 committed by Antz
parent e14ede42ce
commit 55d99aa41b
5 changed files with 106 additions and 7 deletions

View File

@ -122,6 +122,95 @@ bool ChatHandler::HandleDebugSendBuyErrorCommand(char* args)
return true; return true;
} }
bool ChatHandler::HandleDebugRecvOpcodeCommand(char* /*args*/)
{
Unit* unit = getSelectedUnit();
if (!unit || (unit->GetTypeId() != TYPEID_PLAYER))
{ unit = m_session->GetPlayer(); }
std::ifstream stream("ropcode.txt");
if (!stream.is_open())
{ return false; }
uint32 opcode = 0;
if (!(stream >> opcode))
{
stream.close();
return false;
}
WorldPacket *data = new WorldPacket(opcode, 10);
std::string type;
while (stream >> type)
{
if (type.empty())
{ break; }
if (type == "uint8")
{
uint16 value;
stream >> value;
*data << uint8(value);
}
else if (type == "uint16")
{
uint16 value;
stream >> value;
*data << value;
}
else if (type == "uint32")
{
uint32 value;
stream >> value;
*data << value;
}
else if (type == "uint64")
{
uint64 value;
stream >> value;
*data << value;
}
else if (type == "float")
{
float value;
stream >> value;
*data << value;
}
else if (type == "string")
{
std::string value;
stream >> value;
*data << value;
}
else if (type == "pguid")
{ *data << unit->GetPackGUID(); }
else if (type == "guid")
{ *data << unit->GetObjectGuid(); }
else if (type == "mypguid")
{ *data << m_session->GetPlayer()->GetPackGUID(); }
else if (type == "myguid")
{ *data << m_session->GetPlayer()->GetObjectGuid(); }
else if (type == "name")
{ *data << unit->GetName(); }
else if (type == "myname")
{ *data << m_session->GetPlayerName(); }
else
{
DEBUG_LOG("Sending opcode: unknown type '%s'", type.c_str());
break;
}
}
stream.close();
DEBUG_LOG("Queued opcode %u, %s", data->GetOpcode(), data->GetOpcodeName());
m_session->QueuePacket(data);
PSendSysMessage(LANG_COMMAND_OPCODEGOT, data->GetOpcode(), unit->GetName());
return true;
}
bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/) bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/)
{ {
Unit* unit = getSelectedUnit(); Unit* unit = getSelectedUnit();
@ -184,9 +273,17 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/)
data << value; data << value;
} }
else if (type == "pguid") else if (type == "pguid")
{ { data << unit->GetPackGUID(); }
data << unit->GetPackGUID(); else if (type == "guid")
} { data << unit->GetObjectGuid(); }
else if(type == "mypguid")
{ data << m_session->GetPlayer()->GetPackGUID(); }
else if (type == "myguid")
{ data << m_session->GetPlayer()->GetObjectGuid(); }
else if (type == "name")
{ data << unit->GetName(); }
else if (type == "myname")
{ data << m_session->GetPlayerName(); }
else else
{ {
DEBUG_LOG("Sending opcode: unknown type '%s'", type.c_str()); DEBUG_LOG("Sending opcode: unknown type '%s'", type.c_str());
@ -198,7 +295,7 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/)
DEBUG_LOG("Sending opcode %u, %s", data.GetOpcode(), data.GetOpcodeName()); DEBUG_LOG("Sending opcode %u, %s", data.GetOpcode(), data.GetOpcodeName());
data.hexlike(); data.hexlike();
((Player*)unit)->GetSession()->SendPacket(&data); unit->ToPlayer()->SendDirectMessage(&data);
PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName()); PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName());

View File

@ -582,7 +582,7 @@ enum MangosStrings
LANG_YOURS_EXPLORE_SET_ALL = 553, LANG_YOURS_EXPLORE_SET_ALL = 553,
LANG_YOURS_EXPLORE_SET_NOTHING = 554, LANG_YOURS_EXPLORE_SET_NOTHING = 554,
// 555, // not used LANG_COMMAND_OPCODEGOT = 555,
// 556, // not used // 556, // not used
LANG_YOURS_LEVEL_UP = 557, LANG_YOURS_LEVEL_UP = 557,
LANG_YOURS_LEVEL_DOWN = 558, LANG_YOURS_LEVEL_DOWN = 558,

View File

@ -224,6 +224,7 @@ ChatCommand* ChatHandler::getCommandTable()
{ "moditemvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugModItemValueCommand, "", NULL }, { "moditemvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugModItemValueCommand, "", NULL },
{ "modvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugModValueCommand, "", NULL }, { "modvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugModValueCommand, "", NULL },
{ "play", SEC_MODERATOR, false, NULL, "", debugPlayCommandTable }, { "play", SEC_MODERATOR, false, NULL, "", debugPlayCommandTable },
{ "recv", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugRecvOpcodeCommand, "", NULL },
{ "send", SEC_ADMINISTRATOR, false, NULL, "", debugSendCommandTable }, { "send", SEC_ADMINISTRATOR, false, NULL, "", debugSendCommandTable },
{ "setaurastate", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetAuraStateCommand, "", NULL }, { "setaurastate", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetAuraStateCommand, "", NULL },
{ "setitemvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetItemValueCommand, "", NULL }, { "setitemvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetItemValueCommand, "", NULL },

View File

@ -226,6 +226,7 @@ class ChatHandler
bool HandleDebugPlayCinematicCommand(char* args); bool HandleDebugPlayCinematicCommand(char* args);
bool HandleDebugPlaySoundCommand(char* args); bool HandleDebugPlaySoundCommand(char* args);
bool HandleDebugRecvOpcodeCommand(char* args);
bool HandleDebugSendBuyErrorCommand(char* args); bool HandleDebugSendBuyErrorCommand(char* args);
bool HandleDebugSendChannelNotifyCommand(char* args); bool HandleDebugSendChannelNotifyCommand(char* args);
bool HandleDebugSendChatMsgCommand(char* args); bool HandleDebugSendChatMsgCommand(char* args);

View File

@ -38,6 +38,6 @@
#define WORLD_DB_VERSION_NR 21 #define WORLD_DB_VERSION_NR 21
#define WORLD_DB_STRUCTURE_NR 14 #define WORLD_DB_STRUCTURE_NR 14
#define WORLD_DB_CONTENT_NR 14 #define WORLD_DB_CONTENT_NR 58
#define WORLD_DB_UPDATE_DESCRIPTION "Script_Binding" #define WORLD_DB_UPDATE_DESCRIPTION "debug recv Command"
#endif // __REVISION_H__ #endif // __REVISION_H__