From c7619316bbf0f7456b1fd53150a6cb74f11e2fc1 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Sun, 8 Jan 2012 16:29:41 -0200 Subject: [PATCH] display 'you are dead message' on death, support speak/text messages in multiprotocol --- modules/game/game.lua | 4 - modules/game_textmessage/textmessage.lua | 62 ++-- modules/otclientrc.lua | 2 +- src/framework/CMakeLists.txt | 5 +- src/otclient/CMakeLists.txt | 1 + src/otclient/const.h | 217 -------------- src/otclient/core/game.cpp | 17 +- src/otclient/core/game.h | 3 +- src/otclient/core/localplayer.cpp | 3 +- src/otclient/core/statictext.cpp | 18 +- src/otclient/core/statictext.h | 6 +- src/otclient/luascript/luavaluecasts.cpp | 17 +- src/otclient/net/declarations.h | 1 + src/otclient/net/protocolcodes.h | 355 +++++++++++++++++++++++ src/otclient/net/protocolgameparse.cpp | 207 +++++++------ src/otclient/net/protocolgamesend.cpp | 134 ++++----- src/otclient/net/protocollogin.cpp | 18 +- 17 files changed, 602 insertions(+), 468 deletions(-) create mode 100644 src/otclient/net/protocolcodes.h diff --git a/modules/game/game.lua b/modules/game/game.lua index c4ffa040..72f4cd3c 100644 --- a/modules/game/game.lua +++ b/modules/game/game.lua @@ -56,10 +56,6 @@ function Game.onConnectionError(message) errorBox.onOk = CharacterList.show end -function Game.onDeath() - print('dead') -end - local function onApplicationClose() print('close app') if Game.isOnline() then diff --git a/modules/game_textmessage/textmessage.lua b/modules/game_textmessage/textmessage.lua index 707c5745..ee75beab 100644 --- a/modules/game_textmessage/textmessage.lua +++ b/modules/game_textmessage/textmessage.lua @@ -4,8 +4,6 @@ TextMessage = {} importStyle 'textmessage.otui' -- private variables -local bottomLabelWidget, centerLabelWidget - local MessageTypes = { warning = { color = '#F55E5E', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, eventAdvance = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, @@ -18,37 +16,13 @@ local MessageTypes = { consoleRed = { color = '#F55E5E', showOnConsole = true, showOnWindow = false } } -local MessageTypesMap = { - [12] = MessageTypes.consoleOrange, - [13] = MessageTypes.consoleOrange, - [14] = MessageTypes.warning, - [15] = MessageTypes.eventAdvance, - [15] = MessageTypes.eventDefault, - [16] = MessageTypes.statusDefault, - [17] = MessageTypes.infoDesc, - [18] = MessageTypes.statusSmall, - [19] = MessageTypes.consoleBlue, - [20] = MessageTypes.consoleRed, ---[[ - [18] = MessageTypes.consoleRed, - [19] = MessageTypes.consoleOrange, - [20] = MessageTypes.consoleOrange, - [21] = MessageTypes.warning, - [22] = MessageTypes.eventAdvance, - [23] = MessageTypes.eventDefault, - [24] = MessageTypes.statusDefault, - [25] = MessageTypes.infoDesc, - [26] = MessageTypes.statusSmall, - [27] = MessageTypes.consoleBlue -]]-- -} - --- private variables +local bottomLabelWidget +local centerLabelWidget local bottomLabelHideEvent local centerLabelHideEvent -- private functions -local function displayMessage(msgtype, msg) +local function displayMessage(msgtype, msg, time) if msgtype.showOnConsole then -- TODO end @@ -66,7 +40,11 @@ local function displayMessage(msgtype, msg) label:setStyle(msgtype.windowLocation) label:setForegroundColor(msgtype.color) - time = #msg * 75 + if not time then + time = math.max(#msg * 75, 3000) + else + time = time * 1000 + end removeEvent(label.hideEvent) label.hideEvent = scheduleEvent(function() label:setVisible(false) end, time) end @@ -78,25 +56,33 @@ function TextMessage.create() centerLabelWidget = createWidget('UILabel', Game.gameMapPanel) end -function TextMessage.displayWarning(msg) - TextMessage.display(MessageTypes.warning, msg) +function TextMessage.displayStatus(msg, time) + displayMessage(MessageTypes.warning, msg) +end + +function TextMessage.displayEventAdvance(msg, time) + displayMessage(MessageTypes.eventAdvance, msg, time) end -function TextMessage.display(msgtypeid, msg) - local msgtype = MessageTypesMap[msgtypeid] +function TextMessage.display(msgtypedesc, msg) + local msgtype = MessageTypes[msgtypedesc] if msgtype == nil then - error('unknown text msg type ' .. msgtypeid) + error('unknown text msg type ' .. msgtype) return end displayMessage(msgtype, msg) end -- hooked events -function TextMessage.onTextMessage(msgtypeid, msg) - TextMessage.display(msgtypeid, msg) +local function onGameDeath() + TextMessage.displayEventAdvance('You are dead.', 10) end +local function onGameTextMessage(msgtype, msg) + TextMessage.display(msgtype, msg) +end connect(Game, { onLogin = TextMessage.create, onLogout = TextMessage.destroy, - onTextMessage = TextMessage.onTextMessage }) + onDeath = onGameDeath, + onTextMessage = onGameTextMessage }) diff --git a/modules/otclientrc.lua b/modules/otclientrc.lua index 26756756..2a01f084 100644 --- a/modules/otclientrc.lua +++ b/modules/otclientrc.lua @@ -12,4 +12,4 @@ Hotkeys.bind('Ctrl+R', function() runscript('otclientrc.lua') end) if rcloaded then print('otclient.rc lua reloaded') end -rcloaded = true \ No newline at end of file +rcloaded = true diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index fc65aa43..1ae3eb32 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -39,9 +39,10 @@ FIND_PACKAGE(ZLIB REQUIRED) IF(CMAKE_COMPILER_IS_GNUCXX) SET(CXX_WARNS "-Wall -Wextra -Werror -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-unused-variable -Wno-switch -Wno-missing-field-initializers") SET(CMAKE_CXX_FLAGS "-std=gnu++0x -pipe ${CXX_WARNS}") - SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -ggdb3 -fno-inline") + SET(CMAKE_CXX_FLAGS_FULLDEBUG "-O0 -g3 -ggdb3 -fno-inline") + SET(CMAKE_CXX_FLAGS_DEBUG "-O1 -g -ggdb -fno-inline") SET(CMAKE_CXX_FLAGS_RELEASE "-O2") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O1 -g -ggdb -fno-inline") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -ggdb") SET(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++ -Wl,--as-needed") ENDIF(CMAKE_COMPILER_IS_GNUCXX) diff --git a/src/otclient/CMakeLists.txt b/src/otclient/CMakeLists.txt index 99e3b1cd..eb653cc3 100644 --- a/src/otclient/CMakeLists.txt +++ b/src/otclient/CMakeLists.txt @@ -7,6 +7,7 @@ ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6) OPTION(NO_BOT_PROTECTION "Disables bot protection" OFF) SET(PROTOCOL 862 CACHE "Protocol version" STRING) ADD_DEFINITIONS(-DPROTOCOL=${PROTOCOL}) +MESSAGE(STATUS "Protocol: " ${PROTOCOL}) IF(NO_BOT_PROTECTION) ADD_DEFINITIONS(-DNO_BOT_PROTECTION) diff --git a/src/otclient/const.h b/src/otclient/const.h index ddfa587f..1531b5e7 100644 --- a/src/otclient/const.h +++ b/src/otclient/const.h @@ -31,28 +31,6 @@ namespace Otc static const char* AppCompactName = "otclient"; static const char* AppVersion = "0.4.0"; - static const char* CipsoftPublicRSA = "1321277432058722840622950990822933849527763264961655079678763618" - "4334395343554449668205332383339435179772895415509701210392836078" - "6959821132214473291575712138800495033169914814069637740318278150" - "2907336840325241747827401343576296990629870233111328210165697754" - "88792221429527047321331896351555606801473202394175817"; - - static const char* OtservPublicRSA = "1091201329673994292788609605089955415282375029027981291234687579" - "3726629149257644633073969600111060390723088861007265581882535850" - "3429057592827629436413108566029093628212635953836686562675849720" - "6207862794310902180176810615217550567108238764764442605581471797" - "07119674283982419152118103759076030616683978566631413"; - - static const int ClientVersion = 862; - static const int PicSignature = 0x4E119CBF; - - enum OsTypes { - OsWindow = 1, - OsLinux = 2, - OsMac = 3, - OsBrowser = 4 - }; - enum DatOpts { DatGround = 0, DatGroundClip, @@ -91,165 +69,6 @@ namespace Otc DatLastOpt = 255 }; - enum LoginServerOpts { - LoginServerError = 10, - LoginServerMotd = 20, - LoginServerUpdateNeeded = 30, - LoginServerCharacterList = 100 - }; - - enum GameServerOpts { - GameServerInitGame = 10, - GameServerLoginError = 20, - GameServerLoginAdvice = 21, - GameServerLoginWait = 22, - GameServerPing = 30, - GameServerChallange = 31, - GameServerDead = 40, - GameServerFullMap = 100, - GameServerMapTopRow = 101, - GameServerMapRightRow = 102, - GameServerMapBottomRow = 103, - GameServerMapLeftRow = 104, - GameServerTileData = 105, - GameServerCreateOnMap = 106, - GameServerChangeOnMap = 107, - GameServerDeleteOnMap = 108, - GameServerMoveCreature = 109, - GameServerOpenContainer = 110, - GameServerCloseContainer = 111, - GameServerCreateContainer = 112, - GameServerChangeInContainer = 113, - GameServerDeleteInContainer = 114, - GameServerSetInventory = 120, - GameServerDeleteInventory = 121, - GameServerNpcOffer = 122, - GameServerPlayerGoods = 123, - GameServerCloseNpcTrade = 124, - GameServerOwnOffer = 125, - GameServerCounterOffer = 126, - GameServerCloseTrade = 127, - GameServerAmbient = 130, - GameServerGraphicalEffect = 131, - GameServerTextEffect = 132, // absolate in last tibia? - GameServerMissleEffect = 133, - GameServerMarkCreature = 134, - GameServerTrappers = 135, - GameServerCreatureHealth = 140, - GameServerCreatureLight = 141, - GameServerCreatureOutfit = 142, - GameServerCreatureSpeed = 143, - GameServerCreatureSkull = 144, - GameServerCreatureParty = 145, - GameServerCreatureUnpass = 146, - GameServerEditText = 150, - GameServerEditList = 151, - GameServerPlayerData = 160, - GameServerPlayerSkills = 161, - GameServerPlayerState = 162, - GameServerClearTarget = 163, - GameServerSpellDelay = 164, - GameServerSpellGroupDelay = 165, - GameServerTalk = 170, - GameServerChannels = 171, - GameServerOpenChannel = 172, - GameServerPrivateChannel = 173, - GameServerRuleViolation = 174, // absolate in last tibia? - GameServerRuleViolation1 = 175, // absolate in last tibia? - GameServerRuleViolation2 = 176, // absolate in last tibia? - GameServerRuleViolation3 = 177, // absolate in last tibia? - GameServerOpenOwnChannel = 178, - GameServerCloseChannel = 179, - GameServerMessage = 180, - GameServerSnapBack = 181, - GameServerWait = 182, - GameServerTopFloor = 190, - GameServerBottomFloor = 191, - GameServerOutfit = 200, - GameServerBuddyData = 210, - GameServerBuddyLogin = 211, - GameServerBuddyLogout = 212, - GameServerTutorialHint = 220, - GameServerAutomapFlag = 221, - GameServerQuestLog = 240, - GameServerQuestLine = 241, - GameServerChannelEvent = 243, - GameServerObjectInfo = 244, - GameServerPlayerInventory = 245 - }; - - enum ClientOpts { - ClientEnterAccount = 1, - ClientEnterGame = 10, - ClientQuitGame = 20, - ClientPingBack = 30, - ClientGoPath = 100, - ClientGoNorth = 101, - ClientGoEast = 102, - ClientGoSouth = 103, - ClientGoWest = 104, - ClientStop = 105, - ClientGoNorthEast = 106, - ClientGoSouthEast = 107, - ClientGoSouthWest = 108, - ClientGoNorthWest = 109, - ClientRotateNorth = 111, - ClientRotateEast = 112, - ClientRotateSouth = 113, - ClientRotateWest = 114, - ClientEquipObject = 119, - ClientMoveObject = 120, - ClientInspectNpcTrade = 121, - ClientBuyObject = 122, - ClientSellObject = 123, - ClientCloseNpcTrade = 124, - ClientTradeObject = 125, - ClientInspectTrade = 126, - ClientAcceptTrade = 127, - ClientRejectTrade = 128, - ClientUseObject = 130, - ClientUseTwoObjects = 131, - ClientUseOnCreature = 132, - ClientTurnObject = 133, - ClientCloseContainer = 135, - ClientUpContainer = 136, - ClientEditText = 137, - ClientEditList = 138, - ClientLook = 140, - ClientTalk = 150, - ClientGetChannels = 151, - ClientJoinChannel = 152, - ClientLeaveChannel = 153, - ClientPrivateChannel = 154, - ClientCloseNpcChannel = 158, - ClientSetTactics = 160, - ClientAttack = 161, - ClientFollow = 162, - ClientInviteToParty = 163, - ClientJoinParty = 164, - ClientRevokeInvitation = 165, - ClientPassLeadership = 166, - ClientLeaveParty = 167, - ClientShareExperience = 168, - ClientDisbandParty = 169, - ClientOpenChannel = 170, - ClientInviteToChannel = 171, - ClientExcludeFromChannel = 172, - ClientCancel = 190, - ClientRefreshContainer = 202, - ClientGetOutfit = 210, - ClientSetOutfit = 211, - ClientMount = 212, - ClientAddBuddy = 220, - ClientRemoveBuddy = 221, - ClientBugReport = 230, - ClientErrorFileEntry = 232, - ClientGetQuestLog = 240, - ClientGetQuestLine = 241, - ClientRuleViolationReport = 242, - ClientGetObjectInfo = 243 - }; - enum InventorySlots { InventorySlotHead = 1, InventorySlotNecklace, @@ -332,42 +151,6 @@ namespace Otc FluidCoconutMilk = 15 }; - enum SpeakClasses { - SpeakSay = 1, //normal talk - SpeakWhisper, //whispering - #w text - SpeakYell, //yelling - #y text - SpeakPrivatePlayerToNpc, //Player-to-NPC speaking(NPCs channel) - SpeakPrivateNpcToPlayer, //NPC-to-Player speaking - SpeakPrivate, //Players speaking privately to players - SpeakChannelYellow, //Yellow message in chat - SpeakChannelWhite, //White message in chat -#if PROTOCOL==860 - SpeakReportChannel, //Reporting rule violation - Ctrl+R - SpeakReportAnswer, //Answering report - SpeakReportContinue, //Answering the answer of the report -#endif - SpeakBroadcast, //Broadcast a message - #b - SpeakChannelRed, //Talk red on chat - #c - SpeakPrivateRed, //Red private - @name@ text - SpeakChannelOrange, //Talk orange on text -#if PROTOCOL==860 - SpeakUnk1, - SpeakChannelRed2, //Talk red anonymously on chat - #d - SpeakUnk2, -#endif - SpeakMonsterSay, //Talk orange - SpeakMonsterYell //Yell orange - }; - - enum CreaturesIdRange { - PlayerStartId = 0x10000000, - PlayerEndId = 0x40000000, - MonsterStartId = 0x40000000, - MonsterEndId = 0x80000000, - NpcStartId = 0x80000000, - NpcEndId = 0xffffffff - }; - enum FightModes { FightOffensive = 1, FightBalanced = 2, diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index 50c744fa..9ea61069 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -24,9 +24,11 @@ #include "localplayer.h" #include "map.h" #include "tile.h" -#include #include #include +#include +#include +#include Game g_game; @@ -101,7 +103,18 @@ void Game::processDeath() g_dispatcher.scheduleEvent(std::bind(&Game::forceLogout, &g_game), 5 * 1000); } -void Game::processTextMessage(int type, const std::string& message) +void Game::processCreatureSpeak(const std::string& name, int level, const std::string& type, const std::string& message, int channelId, const Position& creaturePos) +{ + if(creaturePos.isValid()) { + StaticTextPtr staticText = StaticTextPtr(new StaticText); + staticText->addMessage(name, type, message); + g_map.addThing(staticText, creaturePos); + } + + g_lua.callGlobalField("Game", "onCreatureSpeak", name, level, type, message, channelId, creaturePos); +} + +void Game::processTextMessage(const std::string& type, const std::string& message) { g_lua.callGlobalField("Game","onTextMessage", type, message); } diff --git a/src/otclient/core/game.h b/src/otclient/core/game.h index 0fa32552..9d50cb4e 100644 --- a/src/otclient/core/game.h +++ b/src/otclient/core/game.h @@ -45,7 +45,8 @@ public: void processLogout(); void processDeath(); - void processTextMessage(int type, const std::string& message); + void processTextMessage(const std::string& type, const std::string& message); + void processCreatureSpeak(const std::string& name, int level, const std::string& type, const std::string& message, int channelId, const Position& creaturePos); void processInventoryChange(int slot, const ItemPtr& item); void processAttackCancel(); diff --git a/src/otclient/core/localplayer.cpp b/src/otclient/core/localplayer.cpp index e58312fd..68b92b9b 100644 --- a/src/otclient/core/localplayer.cpp +++ b/src/otclient/core/localplayer.cpp @@ -100,8 +100,7 @@ bool LocalPlayer::canWalk(Otc::Direction direction) Position newPos = m_position + Position::getPosFromDirection(direction); TilePtr tile = g_map.getTile(newPos); if(!tile->isWalkable()) { - // TODO: create enum for 17, white message on screen bottom and console. - g_game.processTextMessage(17, "Sorry, not possible."); + g_game.processTextMessage("statusSmall", "Sorry, not possible."); return false; } diff --git a/src/otclient/core/statictext.cpp b/src/otclient/core/statictext.cpp index 14a4b12c..6daf9c0f 100644 --- a/src/otclient/core/statictext.cpp +++ b/src/otclient/core/statictext.cpp @@ -40,16 +40,16 @@ void StaticText::draw(const Point& p, const Rect& visibleRect) } } -bool StaticText::addMessage(const std::string& name, int type, const std::string& message) +bool StaticText::addMessage(const std::string& name, const std::string& type, const std::string& message) { // First message if(m_messages.size() == 0) { m_name = name; - m_type = type; + m_messageType = type; } else { // we can only add another message if it follows these conditions - if(m_name != name || m_type != type) + if(m_name != name || m_messageType != type) return false; } @@ -83,31 +83,31 @@ void StaticText::compose() { m_text.clear(); - if(m_type == Otc::SpeakSay) { + if(m_messageType == "say") { m_text += m_name; m_text += " says:\n"; m_color = Color(239, 239, 0); } - else if(m_type == Otc::SpeakWhisper) { + else if(m_messageType == "whisper") { m_text += m_name; m_text += " whispers:\n"; m_color = Color(239, 239, 0); } - else if(m_type == Otc::SpeakYell) { + else if(m_messageType == "yell") { m_text += m_name; m_text += " yells:\n"; m_color = Color(239, 239, 0); } - else if(m_type == Otc::SpeakMonsterSay || m_type == Otc::SpeakMonsterYell) { + else if(m_messageType == "monsterSay" || m_messageType == "monsterYell") { m_color = Color(254, 101, 0); } - else if(m_type == Otc::SpeakPrivateNpcToPlayer) { + else if(m_messageType == "npcToPlayer") { m_text += m_name; m_text += " says:\n"; m_color = Color(95, 247, 247); } else { - logWarning("unknown speak type: ", m_type); + logWarning("unknown speak type: ", m_messageType); } // Todo: add break lines diff --git a/src/otclient/core/statictext.h b/src/otclient/core/statictext.h index 1cde07ae..88a86572 100644 --- a/src/otclient/core/statictext.h +++ b/src/otclient/core/statictext.h @@ -38,10 +38,10 @@ public: void draw(const Point& p, const Rect& visibleRect); std::string getName() { return m_name; } - int getMessageType() { return m_type; } + std::string getMessageType() { return m_messageType; } std::string getFirstMessage() { return m_messages[0]; } - bool addMessage(const std::string& name, int type, const std::string& message); + bool addMessage(const std::string& name, const std::string& type, const std::string& message); void removeMessage(); StaticTextPtr asStaticText() { return std::static_pointer_cast(shared_from_this()); } @@ -53,7 +53,7 @@ private: Size m_textSize; std::vector m_messages; std::string m_name, m_text; - int m_type; + std::string m_messageType; Color m_color; }; diff --git a/src/otclient/luascript/luavaluecasts.cpp b/src/otclient/luascript/luavaluecasts.cpp index a82d49d9..2db519f4 100644 --- a/src/otclient/luascript/luavaluecasts.cpp +++ b/src/otclient/luascript/luavaluecasts.cpp @@ -62,13 +62,16 @@ bool luavalue_cast(int index, Outfit& outfit) void push_luavalue(const Position& pos) { - g_lua.newTable(); - g_lua.pushInteger(pos.x); - g_lua.setField("x"); - g_lua.pushInteger(pos.y); - g_lua.setField("y"); - g_lua.pushInteger(pos.z); - g_lua.setField("z"); + if(pos.isValid()) { + g_lua.newTable(); + g_lua.pushInteger(pos.x); + g_lua.setField("x"); + g_lua.pushInteger(pos.y); + g_lua.setField("y"); + g_lua.pushInteger(pos.z); + g_lua.setField("z"); + } else + g_lua.pushNil(); } bool luavalue_cast(int index, Position& pos) diff --git a/src/otclient/net/declarations.h b/src/otclient/net/declarations.h index 854f9471..1e7498f4 100644 --- a/src/otclient/net/declarations.h +++ b/src/otclient/net/declarations.h @@ -25,6 +25,7 @@ #include #include +#include "protocolcodes.h" class ProtocolLogin; class ProtocolGame; diff --git a/src/otclient/net/protocolcodes.h b/src/otclient/net/protocolcodes.h new file mode 100644 index 00000000..8a30350d --- /dev/null +++ b/src/otclient/net/protocolcodes.h @@ -0,0 +1,355 @@ +/* + * Copyright (c) 2010-2012 OTClient + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef PROTOCOLCODES_H +#define PROTOCOLCODES_H + +#include + +#if PROTOCOL != 860 && PROTOCOL != 862 +#error "the supplied protocol version is not supported" +#endif + +namespace Proto { +#ifdef CIPSOFT_RSA + static const char* RSA = "1321277432058722840622950990822933849527763264961655079678763618" + "4334395343554449668205332383339435179772895415509701210392836078" + "6959821132214473291575712138800495033169914814069637740318278150" + "2907336840325241747827401343576296990629870233111328210165697754" + "88792221429527047321331896351555606801473202394175817"; +#else + static const char* RSA = "1091201329673994292788609605089955415282375029027981291234687579" + "3726629149257644633073969600111060390723088861007265581882535850" + "3429057592827629436413108566029093628212635953836686562675849720" + "6207862794310902180176810615217550567108238764764442605581471797" + "07119674283982419152118103759076030616683978566631413"; +#endif + + static const int ClientVersion = PROTOCOL; + static const int PicSignature = 0x4E119CBF; + + enum OsTypes { + OsWindow = 1, + OsLinux = 2, + OsMac = 3, + OsBrowser = 4 + }; + + enum LoginServerOpts { + LoginServerError = 10, + LoginServerMotd = 20, + LoginServerUpdateNeeded = 30, + LoginServerCharacterList = 100 + }; + + enum GameServerOpts { + GameServerInitGame = 10, + GameServerLoginError = 20, + GameServerLoginAdvice = 21, + GameServerLoginWait = 22, + GameServerPing = 30, + GameServerChallange = 31, + GameServerDead = 40, + GameServerFullMap = 100, + GameServerMapTopRow = 101, + GameServerMapRightRow = 102, + GameServerMapBottomRow = 103, + GameServerMapLeftRow = 104, + GameServerTileData = 105, + GameServerCreateOnMap = 106, + GameServerChangeOnMap = 107, + GameServerDeleteOnMap = 108, + GameServerMoveCreature = 109, + GameServerOpenContainer = 110, + GameServerCloseContainer = 111, + GameServerCreateContainer = 112, + GameServerChangeInContainer = 113, + GameServerDeleteInContainer = 114, + GameServerSetInventory = 120, + GameServerDeleteInventory = 121, + GameServerNpcOffer = 122, + GameServerPlayerGoods = 123, + GameServerCloseNpcTrade = 124, + GameServerOwnOffer = 125, + GameServerCounterOffer = 126, + GameServerCloseTrade = 127, + GameServerAmbient = 130, + GameServerGraphicalEffect = 131, + GameServerTextEffect = 132, // absolate in last tibia? + GameServerMissleEffect = 133, + GameServerMarkCreature = 134, + GameServerTrappers = 135, + GameServerCreatureHealth = 140, + GameServerCreatureLight = 141, + GameServerCreatureOutfit = 142, + GameServerCreatureSpeed = 143, + GameServerCreatureSkull = 144, + GameServerCreatureParty = 145, + GameServerCreatureUnpass = 146, + GameServerEditText = 150, + GameServerEditList = 151, + GameServerPlayerData = 160, + GameServerPlayerSkills = 161, + GameServerPlayerState = 162, + GameServerClearTarget = 163, + GameServerSpellDelay = 164, + GameServerSpellGroupDelay = 165, + GameServerTalk = 170, + GameServerChannels = 171, + GameServerOpenChannel = 172, + GameServerPrivateChannel = 173, + GameServerRuleViolation = 174, // absolate in last tibia? + GameServerRuleViolation1 = 175, // absolate in last tibia? + GameServerRuleViolation2 = 176, // absolate in last tibia? + GameServerRuleViolation3 = 177, // absolate in last tibia? + GameServerOpenOwnChannel = 178, + GameServerCloseChannel = 179, + GameServerMessage = 180, + GameServerSnapBack = 181, + GameServerWait = 182, + GameServerTopFloor = 190, + GameServerBottomFloor = 191, + GameServerOutfit = 200, + GameServerBuddyData = 210, + GameServerBuddyLogin = 211, + GameServerBuddyLogout = 212, + GameServerTutorialHint = 220, + GameServerAutomapFlag = 221, + GameServerQuestLog = 240, + GameServerQuestLine = 241, + GameServerChannelEvent = 243, + GameServerObjectInfo = 244, + GameServerPlayerInventory = 245 + }; + + enum ClientOpts { + ClientEnterAccount = 1, + ClientEnterGame = 10, + ClientQuitGame = 20, + ClientPingBack = 30, + ClientGoPath = 100, + ClientGoNorth = 101, + ClientGoEast = 102, + ClientGoSouth = 103, + ClientGoWest = 104, + ClientStop = 105, + ClientGoNorthEast = 106, + ClientGoSouthEast = 107, + ClientGoSouthWest = 108, + ClientGoNorthWest = 109, + ClientRotateNorth = 111, + ClientRotateEast = 112, + ClientRotateSouth = 113, + ClientRotateWest = 114, + ClientEquipObject = 119, + ClientMoveObject = 120, + ClientInspectNpcTrade = 121, + ClientBuyObject = 122, + ClientSellObject = 123, + ClientCloseNpcTrade = 124, + ClientTradeObject = 125, + ClientInspectTrade = 126, + ClientAcceptTrade = 127, + ClientRejectTrade = 128, + ClientUseObject = 130, + ClientUseTwoObjects = 131, + ClientUseOnCreature = 132, + ClientTurnObject = 133, + ClientCloseContainer = 135, + ClientUpContainer = 136, + ClientEditText = 137, + ClientEditList = 138, + ClientLook = 140, + ClientTalk = 150, + ClientGetChannels = 151, + ClientJoinChannel = 152, + ClientLeaveChannel = 153, + ClientPrivateChannel = 154, + ClientCloseNpcChannel = 158, + ClientSetTactics = 160, + ClientAttack = 161, + ClientFollow = 162, + ClientInviteToParty = 163, + ClientJoinParty = 164, + ClientRevokeInvitation = 165, + ClientPassLeadership = 166, + ClientLeaveParty = 167, + ClientShareExperience = 168, + ClientDisbandParty = 169, + ClientOpenChannel = 170, + ClientInviteToChannel = 171, + ClientExcludeFromChannel = 172, + ClientCancel = 190, + ClientRefreshContainer = 202, + ClientGetOutfit = 210, + ClientSetOutfit = 211, + ClientMount = 212, + ClientAddBuddy = 220, + ClientRemoveBuddy = 221, + ClientBugReport = 230, + ClientErrorFileEntry = 232, + ClientGetQuestLog = 240, + ClientGetQuestLine = 241, + ClientRuleViolationReport = 242, + ClientGetObjectInfo = 243 + }; + + enum SpeakTypes { +#if PROTOCOL==862 + SpeakSay = 1, + SpeakWhisper, + SpeakYell, + SpeakPrivatePlayerToNpc, + SpeakPrivateNpcToPlayer, + SpeakPrivate, + SpeakChannelYellow, + SpeakChannelWhite, + SpeakBroadcast, + SpeakChannelRed, + SpeakPrivateRed, + SpeakChannelOrange, + SpeakMonsterSay, + SpeakMonsterYell +#elif PROTOCOL==860 + SpeakSay = 1, + SpeakWhisper, + SpeakYell, + SpeakPrivatePlayerToNpc, + SpeakPrivateNpcToPlayer, + SpeakPrivate, + SpeakChannelYellow, + SpeakChannelWhite, + SpeakReportChannel, + SpeakReportAnswer, + SpeakReportContinue, + SpeakBroadcast, + SpeakChannelRed, + SpeakPrivateRed, + SpeakChannelOrange, + SpeakUnk1, + SpeakUnk2, + SpeakUnk3, + SpeakMonsterSay, + SpeakMonsterYell +#endif + }; + + enum MessageTypes { +#if PROTOCOL==860 + MessageConsoleRed = 18, + MessageConsoleOrange1, + MessageConsoleOrange2, + MessageWarning, + MessageEventAdvance, + MessageEventDefault, + MessageStatusDefault, + MessageInfoDescription, + MessageStatusSmall, + MessageConsoleBlue +#elif PROTOCOL==862 + MessageConsoleOrange1 = 12, + MessageConsoleOrange2, + MessageWarning, + MessageEventAdvance, + MessageEventDefault, + MessageStatusDefault, + MessageInfoDescription, + MessageStatusSmall, + MessageConsoleBlue, + MessageConsoleRed +#endif + }; + + enum CreaturesIdRange { + PlayerStartId = 0x10000000, + PlayerEndId = 0x40000000, + MonsterStartId = 0x40000000, + MonsterEndId = 0x80000000, + NpcStartId = 0x80000000, + NpcEndId = 0xffffffff + }; + + inline std::string translateSpeakType(int type) { + switch(type) { + case Proto::SpeakSay: + return "say"; + case Proto::SpeakWhisper: + return "whisper"; + case Proto::SpeakYell: + return "yell"; + case Proto::SpeakMonsterSay: + return "monsterSay"; + case Proto::SpeakMonsterYell: + return "monsterYell"; + case Proto::SpeakPrivateNpcToPlayer: + return "npcToPlayer"; + break; + case Proto::SpeakChannelYellow: + return "channelYellow"; + case Proto::SpeakChannelWhite: + return "channelWhite"; + case Proto::SpeakChannelRed: + return "channelRed"; + case Proto::SpeakChannelOrange: + return "channelOrange"; + case Proto::SpeakPrivate: + return "private"; + case Proto::SpeakPrivatePlayerToNpc: + return "playerToNpc"; + case Proto::SpeakBroadcast: + return "broadcast"; + case Proto::SpeakPrivateRed: + return "privateRed"; + default: + return "unknown"; + } + } + + inline std::string translateMessageType(int type) { + switch(type) { + case Proto::MessageConsoleRed: + return "consoleRed"; + case Proto::MessageConsoleOrange1: + return "consoleOrange"; + case Proto::MessageConsoleOrange2: + return "consoleOrange"; + case Proto::MessageWarning: + return "warning"; + case Proto::MessageEventAdvance: + return "eventAdvance"; + case Proto::MessageEventDefault: + return "eventDefault"; + case Proto::MessageStatusDefault: + return "statusDefault"; + case Proto::MessageInfoDescription: + return "infoDescription"; + case Proto::MessageStatusSmall: + return "statusSmall"; + case Proto::MessageConsoleBlue: + return "consoleBlue"; + default: + return "unknown"; + } + } +} + +#endif diff --git a/src/otclient/net/protocolgameparse.cpp b/src/otclient/net/protocolgameparse.cpp index 6a1f3c8f..f9e53314 100644 --- a/src/otclient/net/protocolgameparse.cpp +++ b/src/otclient/net/protocolgameparse.cpp @@ -32,8 +32,6 @@ #include #include #include -#include -#include void ProtocolGame::parseMessage(InputMessage& msg) { @@ -42,216 +40,216 @@ void ProtocolGame::parseMessage(InputMessage& msg) uint8 opt = msg.getU8(); switch(opt) { - case Otc::GameServerInitGame: + case Proto::GameServerInitGame: parsePlayerLogin(msg); break; case 0x0B: parseGMActions(msg); break; - case Otc::GameServerLoginError: + case Proto::GameServerLoginError: parseLoginError(msg); break; - case Otc::GameServerLoginAdvice: + case Proto::GameServerLoginAdvice: parseFYIMessage(msg); break; - case Otc::GameServerLoginWait: + case Proto::GameServerLoginWait: parseWaitList(msg); break; - case Otc::GameServerPing: + case Proto::GameServerPing: parsePing(msg); break; - //case Otc::GameServerChallange: - case Otc::GameServerDead: + //case Proto::GameServerChallange: + case Proto::GameServerDead: parseDeath(msg); break; - case Otc::GameServerFullMap: + case Proto::GameServerFullMap: parseMapDescription(msg); break; - case Otc::GameServerMapTopRow: + case Proto::GameServerMapTopRow: parseMoveNorth(msg); break; - case Otc::GameServerMapRightRow: + case Proto::GameServerMapRightRow: parseMoveEast(msg); break; - case Otc::GameServerMapBottomRow: + case Proto::GameServerMapBottomRow: parseMoveSouth(msg); break; - case Otc::GameServerMapLeftRow: + case Proto::GameServerMapLeftRow: parseMoveWest(msg); break; - case Otc::GameServerTileData: + case Proto::GameServerTileData: parseUpdateTile(msg); break; - case Otc::GameServerCreateOnMap: + case Proto::GameServerCreateOnMap: parseTileAddThing(msg); break; - case Otc::GameServerChangeOnMap: + case Proto::GameServerChangeOnMap: parseTileTransformThing(msg); break; - case Otc::GameServerDeleteOnMap: + case Proto::GameServerDeleteOnMap: parseTileRemoveThing(msg); break; - case Otc::GameServerMoveCreature: + case Proto::GameServerMoveCreature: parseCreatureMove(msg); break; - case Otc::GameServerOpenContainer: + case Proto::GameServerOpenContainer: parseOpenContainer(msg); break; - case Otc::GameServerCloseContainer: + case Proto::GameServerCloseContainer: parseCloseContainer(msg); break; - case Otc::GameServerCreateContainer: + case Proto::GameServerCreateContainer: parseContainerAddItem(msg); break; - case Otc::GameServerChangeInContainer: + case Proto::GameServerChangeInContainer: parseContainerUpdateItem(msg); break; - case Otc::GameServerDeleteInContainer: + case Proto::GameServerDeleteInContainer: parseContainerRemoveItem(msg); break; - case Otc::GameServerSetInventory: + case Proto::GameServerSetInventory: parseAddInventoryItem(msg); break; - case Otc::GameServerDeleteInventory: + case Proto::GameServerDeleteInventory: parseRemoveInventoryItem(msg); break; - case Otc::GameServerNpcOffer: + case Proto::GameServerNpcOffer: parseOpenShopWindow(msg); break; - case Otc::GameServerPlayerGoods: + case Proto::GameServerPlayerGoods: parsePlayerCash(msg); break; - case Otc::GameServerCloseNpcTrade: + case Proto::GameServerCloseNpcTrade: parseCloseShopWindow(msg); break; - case Otc::GameServerOwnOffer: + case Proto::GameServerOwnOffer: parseSafeTradeRequest(msg); break; - case Otc::GameServerCounterOffer: + case Proto::GameServerCounterOffer: parseSafeTradeRequest(msg); break; - case Otc::GameServerCloseTrade: + case Proto::GameServerCloseTrade: parseSafeTradeClose(msg); break; - case Otc::GameServerAmbient: + case Proto::GameServerAmbient: parseWorldLight(msg); break; - case Otc::GameServerGraphicalEffect: + case Proto::GameServerGraphicalEffect: parseMagicEffect(msg); break; - case Otc::GameServerTextEffect: + case Proto::GameServerTextEffect: parseAnimatedText(msg); break; - case Otc::GameServerMissleEffect: + case Proto::GameServerMissleEffect: parseDistanceMissile(msg); break; - case Otc::GameServerMarkCreature: + case Proto::GameServerMarkCreature: parseCreatureSquare(msg); break; - //case Otc::GameServerTrappers - case Otc::GameServerCreatureHealth: + //case Proto::GameServerTrappers + case Proto::GameServerCreatureHealth: parseCreatureHealth(msg); break; - case Otc::GameServerCreatureLight: + case Proto::GameServerCreatureLight: parseCreatureLight(msg); break; - case Otc::GameServerCreatureOutfit: + case Proto::GameServerCreatureOutfit: parseCreatureOutfit(msg); break; - case Otc::GameServerCreatureSpeed: + case Proto::GameServerCreatureSpeed: parseCreatureSpeed(msg); break; - case Otc::GameServerCreatureSkull: + case Proto::GameServerCreatureSkull: parseCreatureSkulls(msg); break; - case Otc::GameServerCreatureParty: + case Proto::GameServerCreatureParty: parseCreatureShields(msg); break; - // case Otc::GameServerCreatureUnpass - case Otc::GameServerEditText: + // case Proto::GameServerCreatureUnpass + case Proto::GameServerEditText: parseItemTextWindow(msg); break; - case Otc::GameServerEditList: + case Proto::GameServerEditList: parseHouseTextWindow(msg); break; - case Otc::GameServerPlayerData: + case Proto::GameServerPlayerData: parsePlayerStats(msg); break; - case Otc::GameServerPlayerSkills: + case Proto::GameServerPlayerSkills: parsePlayerSkills(msg); break; - case Otc::GameServerPlayerState: + case Proto::GameServerPlayerState: parsePlayerIcons(msg); break; - case Otc::GameServerClearTarget: + case Proto::GameServerClearTarget: parsePlayerCancelAttack(msg); break; - //case Otc::GameServerSpellDelay: - //case Otc::GameServerSpellGroupDelay: - case Otc::GameServerTalk: + //case Proto::GameServerSpellDelay: + //case Proto::GameServerSpellGroupDelay: + case Proto::GameServerTalk: parseCreatureSpeak(msg); break; - case Otc::GameServerChannels: + case Proto::GameServerChannels: parseChannelList(msg); break; - case Otc::GameServerOpenChannel: + case Proto::GameServerOpenChannel: parseOpenChannel(msg); break; - case Otc::GameServerPrivateChannel: + case Proto::GameServerPrivateChannel: parseOpenPrivatePlayerChat(msg); break; - case Otc::GameServerRuleViolation: - case Otc::GameServerRuleViolation1: - case Otc::GameServerRuleViolation2: - case Otc::GameServerRuleViolation3: + case Proto::GameServerRuleViolation: + case Proto::GameServerRuleViolation1: + case Proto::GameServerRuleViolation2: + case Proto::GameServerRuleViolation3: parseOpenRuleViolation(msg); break; - case Otc::GameServerOpenOwnChannel: + case Proto::GameServerOpenOwnChannel: parseCreatePrivateChannel(msg); break; - case Otc::GameServerCloseChannel: + case Proto::GameServerCloseChannel: parseClosePrivateChannel(msg); break; - case Otc::GameServerMessage: + case Proto::GameServerMessage: parseTextMessage(msg); break; - case Otc::GameServerSnapBack: + case Proto::GameServerSnapBack: parseCancelWalk(msg); break; - //case Otc::GameServerWait: - case Otc::GameServerTopFloor: + //case Proto::GameServerWait: + case Proto::GameServerTopFloor: parseFloorChangeUp(msg); break; - case Otc::GameServerBottomFloor: + case Proto::GameServerBottomFloor: parseFloorChangeDown(msg); break; - case Otc::GameServerOutfit: + case Proto::GameServerOutfit: parseOutfitWindow(msg); break; - case Otc::GameServerBuddyData: + case Proto::GameServerBuddyData: parseVipState(msg); break; - case Otc::GameServerBuddyLogin: + case Proto::GameServerBuddyLogin: parseVipLogin(msg); break; - case Otc::GameServerBuddyLogout: + case Proto::GameServerBuddyLogout: parseVipLogout(msg); break; - case Otc::GameServerTutorialHint: + case Proto::GameServerTutorialHint: parseShowTutorial(msg); break; - case Otc::GameServerAutomapFlag: + case Proto::GameServerAutomapFlag: parseAddMarker(msg); break; - case Otc::GameServerQuestLog: + case Proto::GameServerQuestLog: parseQuestList(msg); break; - case Otc::GameServerQuestLine: + case Proto::GameServerQuestLine: parseQuestPartList(msg); break; - //case Otc::GameServerChannelEvent: - //case Otc::GameServerObjectInfo: - //case Otc::GameServerPlayerInventory: + //case Proto::GameServerChannelEvent: + //case Proto::GameServerObjectInfo: + //case Proto::GameServerPlayerInventory: default: Fw::throwException("unknown opt byte ", (int)opt); break; @@ -746,30 +744,30 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg) Position creaturePos; switch(type) { - case Otc::SpeakSay: - case Otc::SpeakWhisper: - case Otc::SpeakYell: - case Otc::SpeakMonsterSay: - case Otc::SpeakMonsterYell: - case Otc::SpeakPrivateNpcToPlayer: + case Proto::SpeakSay: + case Proto::SpeakWhisper: + case Proto::SpeakYell: + case Proto::SpeakMonsterSay: + case Proto::SpeakMonsterYell: + case Proto::SpeakPrivateNpcToPlayer: creaturePos = parsePosition(msg); break; - case Otc::SpeakChannelYellow: - case Otc::SpeakChannelWhite: - case Otc::SpeakChannelRed: + case Proto::SpeakChannelYellow: + case Proto::SpeakChannelWhite: + case Proto::SpeakChannelRed: #if PROTOCOL==860 - case Otc::SpeakChannelRed2: + case Proto::SpeakUnk2: #endif - case Otc::SpeakChannelOrange: + case Proto::SpeakChannelOrange: channelId = msg.getU16(); break; - case Otc::SpeakPrivate: - case Otc::SpeakPrivatePlayerToNpc: - case Otc::SpeakBroadcast: - case Otc::SpeakPrivateRed: + case Proto::SpeakPrivate: + case Proto::SpeakPrivatePlayerToNpc: + case Proto::SpeakBroadcast: + case Proto::SpeakPrivateRed: break; #if PROTOCOL==860 - case Otc::SpeakReportChannel: + case Proto::SpeakReportChannel: msg.getU32(); break; #endif @@ -779,16 +777,11 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg) } std::string message = msg.getString(); + std::string typeDesc = Proto::translateSpeakType(type); g_dispatcher.addEvent([=] { - g_lua.callGlobalField("Game", "onCreatureSpeak", name, level, type, message, channelId, creaturePos); + g_game.processCreatureSpeak(name, level, typeDesc, message, channelId, creaturePos); }); - - if(creaturePos.isValid()) { - StaticTextPtr staticText = StaticTextPtr(new StaticText); - staticText->addMessage(name, type, message); - g_map.addThing(staticText, creaturePos); - } } void ProtocolGame::parseChannelList(InputMessage& msg) @@ -840,9 +833,11 @@ void ProtocolGame::parseClosePrivateChannel(InputMessage& msg) void ProtocolGame::parseTextMessage(InputMessage& msg) { uint8 type = msg.getU8(); + + std::string typeDesc = Proto::translateMessageType(type); std::string message = msg.getString(); - g_dispatcher.addEvent(std::bind(&Game::processTextMessage, &g_game, type, message)); + g_dispatcher.addEvent(std::bind(&Game::processTextMessage, &g_game, typeDesc, message)); } void ProtocolGame::parseCancelWalk(InputMessage& msg) @@ -1091,11 +1086,11 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg) if(id == (uint32)m_localPlayer->getId()) creature = m_localPlayer->asCreature(); - else if(id >= Otc::PlayerStartId && id < Otc::PlayerEndId) + else if(id >= Proto::PlayerStartId && id < Proto::PlayerEndId) creature = PlayerPtr(new Player)->asCreature(); - else if(id >= Otc::MonsterStartId && id < Otc::MonsterEndId) + else if(id >= Proto::MonsterStartId && id < Proto::MonsterEndId) creature = CreaturePtr(new Creature); - else if(id >= Otc::NpcStartId && id < Otc::NpcEndId) + else if(id >= Proto::NpcStartId && id < Proto::NpcEndId) creature = CreaturePtr(new Creature); else logFatal("creature id is invalid"); diff --git a/src/otclient/net/protocolgamesend.cpp b/src/otclient/net/protocolgamesend.cpp index a63cb3ca..e75f5ba1 100644 --- a/src/otclient/net/protocolgamesend.cpp +++ b/src/otclient/net/protocolgamesend.cpp @@ -27,9 +27,9 @@ void ProtocolGame::sendLoginPacket(uint32 timestamp, uint8 unknown) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientEnterGame); - oMsg.addU16(Otc::OsLinux); - oMsg.addU16(Otc::ClientVersion); + oMsg.addU8(Proto::ClientEnterGame); + oMsg.addU16(Proto::OsLinux); + oMsg.addU16(Proto::ClientVersion); oMsg.addU8(0); // first RSA byte must be 0 @@ -52,7 +52,7 @@ void ProtocolGame::sendLoginPacket(uint32 timestamp, uint8 unknown) oMsg.addPaddingBytes(128 - (29 + m_accountName.length() + m_characterName.length() + m_accountPassword.length())); // encrypt with RSA - Rsa::encrypt((char*)oMsg.getBuffer() + 6 + oMsg.getMessageSize() - 128, 128, Otc::OtservPublicRSA); + Rsa::encrypt((char*)oMsg.getBuffer() + 6 + oMsg.getMessageSize() - 128, 128, Proto::RSA); send(oMsg); @@ -62,14 +62,14 @@ void ProtocolGame::sendLoginPacket(uint32 timestamp, uint8 unknown) void ProtocolGame::sendLogout() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientQuitGame); + oMsg.addU8(Proto::ClientQuitGame); send(oMsg); } void ProtocolGame::sendPing() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientPingBack); + oMsg.addU8(Proto::ClientPingBack); send(oMsg); } @@ -78,98 +78,98 @@ void ProtocolGame::sendPing() void ProtocolGame::sendWalkNorth() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientGoNorth); + oMsg.addU8(Proto::ClientGoNorth); send(oMsg); } void ProtocolGame::sendWalkEast() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientGoEast); + oMsg.addU8(Proto::ClientGoEast); send(oMsg); } void ProtocolGame::sendWalkSouth() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientGoSouth); + oMsg.addU8(Proto::ClientGoSouth); send(oMsg); } void ProtocolGame::sendWalkWest() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientGoWest); + oMsg.addU8(Proto::ClientGoWest); send(oMsg); } void ProtocolGame::sendStopAutowalk() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientStop); + oMsg.addU8(Proto::ClientStop); send(oMsg); } void ProtocolGame::sendWalkNorthEast() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientGoNorthEast); + oMsg.addU8(Proto::ClientGoNorthEast); send(oMsg); } void ProtocolGame::sendWalkSouthEast() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientGoSouthEast); + oMsg.addU8(Proto::ClientGoSouthEast); send(oMsg); } void ProtocolGame::sendWalkSouthWest() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientGoSouthWest); + oMsg.addU8(Proto::ClientGoSouthWest); send(oMsg); } void ProtocolGame::sendWalkNorthWest() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientGoNorthWest); + oMsg.addU8(Proto::ClientGoNorthWest); send(oMsg); } void ProtocolGame::sendTurnNorth() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientRotateNorth); + oMsg.addU8(Proto::ClientRotateNorth); send(oMsg); } void ProtocolGame::sendTurnEast() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientRotateEast); + oMsg.addU8(Proto::ClientRotateEast); send(oMsg); } void ProtocolGame::sendTurnSouth() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientRotateSouth); + oMsg.addU8(Proto::ClientRotateSouth); send(oMsg); } void ProtocolGame::sendTurnWest() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientRotateWest); + oMsg.addU8(Proto::ClientRotateWest); send(oMsg); } void ProtocolGame::sendThrow(const Position& fromPos, int thingId, int stackpos, const Position& toPos, int count) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientMoveObject); + oMsg.addU8(Proto::ClientMoveObject); addPosition(oMsg, fromPos); oMsg.addU16(thingId); oMsg.addU8(stackpos); @@ -181,7 +181,7 @@ void ProtocolGame::sendThrow(const Position& fromPos, int thingId, int stackpos, void ProtocolGame::sendLookInShop(int thingId, int count) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientInspectNpcTrade); + oMsg.addU8(Proto::ClientInspectNpcTrade); oMsg.addU16(thingId); oMsg.addU8(count); send(oMsg); @@ -190,7 +190,7 @@ void ProtocolGame::sendLookInShop(int thingId, int count) void ProtocolGame::sendPlayerPurchase(int thingId, int count, int amount, bool ignoreCapacity, bool buyWithBackpack) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientBuyObject); + oMsg.addU8(Proto::ClientBuyObject); oMsg.addU16(thingId); oMsg.addU8(count); oMsg.addU8(amount); @@ -202,7 +202,7 @@ void ProtocolGame::sendPlayerPurchase(int thingId, int count, int amount, bool i void ProtocolGame::sendPlayerSale(int thingId, int count, int amount, bool ignoreEquipped) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientSellObject); + oMsg.addU8(Proto::ClientSellObject); oMsg.addU16(thingId); oMsg.addU8(count); oMsg.addU8(amount); @@ -213,14 +213,14 @@ void ProtocolGame::sendPlayerSale(int thingId, int count, int amount, bool ignor void ProtocolGame::sendCloseShop() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientCloseNpcTrade); + oMsg.addU8(Proto::ClientCloseNpcTrade); send(oMsg); } void ProtocolGame::sendRequestTrade(const Position& pos, int thingId, int stackpos, int playerId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientTradeObject); + oMsg.addU8(Proto::ClientTradeObject); addPosition(oMsg, pos); oMsg.addU16(thingId); oMsg.addU8(stackpos); @@ -231,7 +231,7 @@ void ProtocolGame::sendRequestTrade(const Position& pos, int thingId, int stackp void ProtocolGame::sendLookInTrade(bool counterOffer, int index) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientInspectTrade); + oMsg.addU8(Proto::ClientInspectTrade); oMsg.addU8(counterOffer ? 0x01 : 0x00); oMsg.addU8(index); send(oMsg); @@ -240,21 +240,21 @@ void ProtocolGame::sendLookInTrade(bool counterOffer, int index) void ProtocolGame::sendAcceptTrade() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientAcceptTrade); + oMsg.addU8(Proto::ClientAcceptTrade); send(oMsg); } void ProtocolGame::sendRejectTrade() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientRejectTrade); + oMsg.addU8(Proto::ClientRejectTrade); send(oMsg); } void ProtocolGame::sendUseItem(const Position& position, int itemId, int stackpos, int index) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientUseObject); + oMsg.addU8(Proto::ClientUseObject); addPosition(oMsg, position); oMsg.addU16(itemId); oMsg.addU8(stackpos); @@ -265,7 +265,7 @@ void ProtocolGame::sendUseItem(const Position& position, int itemId, int stackpo void ProtocolGame::sendUseItemEx(const Position& fromPos, int fromThingId, int fromStackpos, const Position& toPos, int toThingId, int toStackpos) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientUseTwoObjects); + oMsg.addU8(Proto::ClientUseTwoObjects); addPosition(oMsg, fromPos); oMsg.addU16(fromThingId); oMsg.addU8(fromStackpos); @@ -278,7 +278,7 @@ void ProtocolGame::sendUseItemEx(const Position& fromPos, int fromThingId, int f void ProtocolGame::sendUseItemCreature(const Position& pos, int thingId, int stackpos, int creatureId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientUseOnCreature); + oMsg.addU8(Proto::ClientUseOnCreature); addPosition(oMsg, pos); oMsg.addU16(thingId); oMsg.addU8(stackpos); @@ -289,7 +289,7 @@ void ProtocolGame::sendUseItemCreature(const Position& pos, int thingId, int sta void ProtocolGame::sendRotateItem(const Position& pos, int thingId, int stackpos) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientTurnObject); + oMsg.addU8(Proto::ClientTurnObject); addPosition(oMsg, pos); oMsg.addU16(thingId); oMsg.addU8(stackpos); @@ -299,7 +299,7 @@ void ProtocolGame::sendRotateItem(const Position& pos, int thingId, int stackpos void ProtocolGame::sendCloseContainer(int containerId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientCloseContainer); + oMsg.addU8(Proto::ClientCloseContainer); oMsg.addU8(containerId); send(oMsg); } @@ -307,7 +307,7 @@ void ProtocolGame::sendCloseContainer(int containerId) void ProtocolGame::sendUpContainer(int containerId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientUpContainer); + oMsg.addU8(Proto::ClientUpContainer); oMsg.addU8(containerId); send(oMsg); } @@ -315,7 +315,7 @@ void ProtocolGame::sendUpContainer(int containerId) void ProtocolGame::sendTextWindow(int windowTextId, const std::string& text) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientEditText); + oMsg.addU8(Proto::ClientEditText); oMsg.addU32(windowTextId); oMsg.addString(text); send(oMsg); @@ -324,7 +324,7 @@ void ProtocolGame::sendTextWindow(int windowTextId, const std::string& text) void ProtocolGame::sendHouseWindow(int doorId, int id, const std::string& text) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientEditList); + oMsg.addU8(Proto::ClientEditList); oMsg.addU8(doorId); oMsg.addU32(id); oMsg.addString(text); @@ -334,7 +334,7 @@ void ProtocolGame::sendHouseWindow(int doorId, int id, const std::string& text) void ProtocolGame::sendLookAt(const Position& position, int thingId, int stackpos) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientLook); + oMsg.addU8(Proto::ClientLook); addPosition(oMsg, position); oMsg.addU16(thingId); oMsg.addU8(stackpos); @@ -347,18 +347,18 @@ void ProtocolGame::sendTalk(int channelType, int channelId, const std::string& r return; OutputMessage oMsg; - oMsg.addU8(Otc::ClientTalk); + oMsg.addU8(Proto::ClientTalk); assert(channelType >= 0); oMsg.addU8(channelType); switch(channelType) { - case Otc::SpeakPrivate: - case Otc::SpeakPrivateRed: + case Proto::SpeakPrivate: + case Proto::SpeakPrivateRed: oMsg.addString(receiver); break; - case Otc::SpeakChannelYellow: - case Otc::SpeakChannelRed: + case Proto::SpeakChannelYellow: + case Proto::SpeakChannelRed: oMsg.addU16(channelId); break; } @@ -370,14 +370,14 @@ void ProtocolGame::sendTalk(int channelType, int channelId, const std::string& r void ProtocolGame::sendGetChannels() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientGetChannels); + oMsg.addU8(Proto::ClientGetChannels); send(oMsg); } void ProtocolGame::sendJoinChannel(int channelId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientJoinChannel); + oMsg.addU8(Proto::ClientJoinChannel); oMsg.addU16(channelId); send(oMsg); } @@ -385,7 +385,7 @@ void ProtocolGame::sendJoinChannel(int channelId) void ProtocolGame::sendLeaveChannel(int channelId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientLeaveChannel); + oMsg.addU8(Proto::ClientLeaveChannel); oMsg.addU16(channelId); send(oMsg); } @@ -393,7 +393,7 @@ void ProtocolGame::sendLeaveChannel(int channelId) void ProtocolGame::sendPrivateChannel(const std::string& receiver) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientPrivateChannel); + oMsg.addU8(Proto::ClientPrivateChannel); oMsg.addString(receiver); send(oMsg); } @@ -406,14 +406,14 @@ void ProtocolGame::sendPrivateChannel(const std::string& receiver) void ProtocolGame::sendCloseNpcChannel() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientCloseNpcChannel); + oMsg.addU8(Proto::ClientCloseNpcChannel); send(oMsg); } void ProtocolGame::sendFightTatics(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeFight) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientSetTactics); + oMsg.addU8(Proto::ClientSetTactics); oMsg.addU8(fightMode); oMsg.addU8(chaseMode); oMsg.addU8(safeFight ? 0x01: 0x00); @@ -423,7 +423,7 @@ void ProtocolGame::sendFightTatics(Otc::FightModes fightMode, Otc::ChaseModes ch void ProtocolGame::sendAttack(int creatureId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientAttack); + oMsg.addU8(Proto::ClientAttack); oMsg.addU32(creatureId); oMsg.addU32(0); oMsg.addU32(0); @@ -433,7 +433,7 @@ void ProtocolGame::sendAttack(int creatureId) void ProtocolGame::sendFollow(int creatureId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientFollow); + oMsg.addU8(Proto::ClientFollow); oMsg.addU32(creatureId); send(oMsg); } @@ -441,7 +441,7 @@ void ProtocolGame::sendFollow(int creatureId) void ProtocolGame::sendInviteToParty(int creatureId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientInviteToParty); + oMsg.addU8(Proto::ClientInviteToParty); oMsg.addU32(creatureId); send(oMsg); } @@ -449,7 +449,7 @@ void ProtocolGame::sendInviteToParty(int creatureId) void ProtocolGame::sendJoinParty(int creatureId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientJoinParty); + oMsg.addU8(Proto::ClientJoinParty); oMsg.addU32(creatureId); send(oMsg); } @@ -457,7 +457,7 @@ void ProtocolGame::sendJoinParty(int creatureId) void ProtocolGame::sendRevokeInvitation(int creatureId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientRevokeInvitation); + oMsg.addU8(Proto::ClientRevokeInvitation); oMsg.addU32(creatureId); send(oMsg); } @@ -465,7 +465,7 @@ void ProtocolGame::sendRevokeInvitation(int creatureId) void ProtocolGame::sendPassLeadership(int creatureId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientPassLeadership); + oMsg.addU8(Proto::ClientPassLeadership); oMsg.addU32(creatureId); send(oMsg); } @@ -473,14 +473,14 @@ void ProtocolGame::sendPassLeadership(int creatureId) void ProtocolGame::sendLeaveParty() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientLeaveParty); + oMsg.addU8(Proto::ClientLeaveParty); send(oMsg); } void ProtocolGame::sendShareExperience(bool active, int unknown) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientShareExperience); + oMsg.addU8(Proto::ClientShareExperience); oMsg.addU8(active ? 0x01 : 0x00); oMsg.addU8(unknown); send(oMsg); @@ -489,14 +489,14 @@ void ProtocolGame::sendShareExperience(bool active, int unknown) void ProtocolGame::sendOpenChannel() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientOpenChannel); + oMsg.addU8(Proto::ClientOpenChannel); send(oMsg); } void ProtocolGame::sendInviteToChannel(const std::string& name) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientInviteToChannel); + oMsg.addU8(Proto::ClientInviteToChannel); oMsg.addString(name); send(oMsg); } @@ -504,7 +504,7 @@ void ProtocolGame::sendInviteToChannel(const std::string& name) void ProtocolGame::sendExcludeFromChannel(const std::string& name) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientExcludeFromChannel); + oMsg.addU8(Proto::ClientExcludeFromChannel); oMsg.addString(name); send(oMsg); } @@ -512,7 +512,7 @@ void ProtocolGame::sendExcludeFromChannel(const std::string& name) void ProtocolGame::sendCancel() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientCancel); + oMsg.addU8(Proto::ClientCancel); send(oMsg); } @@ -521,21 +521,21 @@ void ProtocolGame::sendCancel() void ProtocolGame::sendUpdateContainer() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientRefreshContainer); + oMsg.addU8(Proto::ClientRefreshContainer); send(oMsg); } void ProtocolGame::sendGetOutfit() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientGetOutfit); + oMsg.addU8(Proto::ClientGetOutfit); send(oMsg); } void ProtocolGame::sendSetOutfit(const Outfit& outfit) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientSetOutfit); + oMsg.addU8(Proto::ClientSetOutfit); oMsg.addU16(outfit.getType()); oMsg.addU8(outfit.getHead()); @@ -550,7 +550,7 @@ void ProtocolGame::sendSetOutfit(const Outfit& outfit) void ProtocolGame::sendAddVip(const std::string& name) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientAddBuddy); + oMsg.addU8(Proto::ClientAddBuddy); oMsg.addString(name); send(oMsg); } @@ -558,7 +558,7 @@ void ProtocolGame::sendAddVip(const std::string& name) void ProtocolGame::sendRemoveVip(int playerId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientRemoveBuddy); + oMsg.addU8(Proto::ClientRemoveBuddy); oMsg.addU32(playerId); send(oMsg); } @@ -570,14 +570,14 @@ void ProtocolGame::sendRemoveVip(int playerId) void ProtocolGame::sendGetQuestLog() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientGetQuestLog); + oMsg.addU8(Proto::ClientGetQuestLog); send(oMsg); } void ProtocolGame::sendGetQuestLine(int questId) { OutputMessage oMsg; - oMsg.addU8(Otc::ClientGetQuestLine); + oMsg.addU8(Proto::ClientGetQuestLine); oMsg.addU16(questId); send(oMsg); } diff --git a/src/otclient/net/protocollogin.cpp b/src/otclient/net/protocollogin.cpp index f6e2a232..188ca691 100644 --- a/src/otclient/net/protocollogin.cpp +++ b/src/otclient/net/protocollogin.cpp @@ -57,16 +57,16 @@ void ProtocolLogin::onRecv(InputMessage& inputMessage) while(!inputMessage.eof()) { uint8 opt = inputMessage.getU8(); switch(opt) { - case Otc::LoginServerError: + case Proto::LoginServerError: parseError(inputMessage); break; - case Otc::LoginServerMotd: + case Proto::LoginServerMotd: parseMOTD(inputMessage); break; - case Otc::LoginServerUpdateNeeded: + case Proto::LoginServerUpdateNeeded: callLuaField("onError", "Client needs update."); break; - case Otc::LoginServerCharacterList: + case Proto::LoginServerCharacterList: parseCharacterList(inputMessage); break; default: @@ -89,13 +89,13 @@ void ProtocolLogin::sendLoginPacket() { OutputMessage oMsg; - oMsg.addU8(Otc::ClientEnterAccount); - oMsg.addU16(Otc::OsLinux); - oMsg.addU16(Otc::ClientVersion); + oMsg.addU8(Proto::ClientEnterAccount); + oMsg.addU16(Proto::OsLinux); + oMsg.addU16(Proto::ClientVersion); oMsg.addU32(g_thingsType.getSignature()); // data signature oMsg.addU32(g_sprites.getSignature()); // sprite signature - oMsg.addU32(Otc::PicSignature); // pic signature + oMsg.addU32(Proto::PicSignature); // pic signature oMsg.addU8(0); // first RSA byte must be 0 @@ -111,7 +111,7 @@ void ProtocolLogin::sendLoginPacket() // complete the 128 bytes for rsa encryption with zeros oMsg.addPaddingBytes(128 - (21 + m_accountName.length() + m_accountPassword.length())); - Rsa::encrypt((char*)oMsg.getBuffer() + InputMessage::DATA_POS + oMsg.getMessageSize() - 128, 128, Otc::OtservPublicRSA); + Rsa::encrypt((char*)oMsg.getBuffer() + InputMessage::DATA_POS + oMsg.getMessageSize() - 128, 128, Proto::RSA); send(oMsg); enableXteaEncryption();