diff --git a/src/game/ChatCommands/debugcmds.cpp b/src/game/ChatCommands/debugcmds.cpp index 6e462733..d96eafda 100644 --- a/src/game/ChatCommands/debugcmds.cpp +++ b/src/game/ChatCommands/debugcmds.cpp @@ -122,6 +122,95 @@ bool ChatHandler::HandleDebugSendBuyErrorCommand(char* args) 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*/) { Unit* unit = getSelectedUnit(); @@ -184,9 +273,17 @@ bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/) data << value; } 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 { 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()); data.hexlike(); - ((Player*)unit)->GetSession()->SendPacket(&data); + unit->ToPlayer()->SendDirectMessage(&data); PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName()); diff --git a/src/game/Tools/Language.h b/src/game/Tools/Language.h index 2b4d95da..f402a716 100644 --- a/src/game/Tools/Language.h +++ b/src/game/Tools/Language.h @@ -582,7 +582,7 @@ enum MangosStrings LANG_YOURS_EXPLORE_SET_ALL = 553, LANG_YOURS_EXPLORE_SET_NOTHING = 554, - // 555, // not used + LANG_COMMAND_OPCODEGOT = 555, // 556, // not used LANG_YOURS_LEVEL_UP = 557, LANG_YOURS_LEVEL_DOWN = 558, diff --git a/src/game/WorldHandlers/Chat.cpp b/src/game/WorldHandlers/Chat.cpp index 428cd23b..6d6674b7 100644 --- a/src/game/WorldHandlers/Chat.cpp +++ b/src/game/WorldHandlers/Chat.cpp @@ -224,6 +224,7 @@ ChatCommand* ChatHandler::getCommandTable() { "moditemvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugModItemValueCommand, "", NULL }, { "modvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugModValueCommand, "", NULL }, { "play", SEC_MODERATOR, false, NULL, "", debugPlayCommandTable }, + { "recv", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugRecvOpcodeCommand, "", NULL }, { "send", SEC_ADMINISTRATOR, false, NULL, "", debugSendCommandTable }, { "setaurastate", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetAuraStateCommand, "", NULL }, { "setitemvalue", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDebugSetItemValueCommand, "", NULL }, diff --git a/src/game/WorldHandlers/Chat.h b/src/game/WorldHandlers/Chat.h index 1eecc1dc..221af441 100644 --- a/src/game/WorldHandlers/Chat.h +++ b/src/game/WorldHandlers/Chat.h @@ -226,6 +226,7 @@ class ChatHandler bool HandleDebugPlayCinematicCommand(char* args); bool HandleDebugPlaySoundCommand(char* args); + bool HandleDebugRecvOpcodeCommand(char* args); bool HandleDebugSendBuyErrorCommand(char* args); bool HandleDebugSendChannelNotifyCommand(char* args); bool HandleDebugSendChatMsgCommand(char* args); diff --git a/src/shared/revision.h b/src/shared/revision.h index b1081b3d..a4a34fdc 100644 --- a/src/shared/revision.h +++ b/src/shared/revision.h @@ -38,6 +38,6 @@ #define WORLD_DB_VERSION_NR 21 #define WORLD_DB_STRUCTURE_NR 14 - #define WORLD_DB_CONTENT_NR 14 - #define WORLD_DB_UPDATE_DESCRIPTION "Script_Binding" + #define WORLD_DB_CONTENT_NR 58 + #define WORLD_DB_UPDATE_DESCRIPTION "debug recv Command" #endif // __REVISION_H__