display 'you are dead message' on death, support speak/text messages in multiprotocol

master
Eduardo Bart 13 years ago
parent fbaa7c8c43
commit c7619316bb

@ -56,10 +56,6 @@ function Game.onConnectionError(message)
errorBox.onOk = CharacterList.show errorBox.onOk = CharacterList.show
end end
function Game.onDeath()
print('dead')
end
local function onApplicationClose() local function onApplicationClose()
print('close app') print('close app')
if Game.isOnline() then if Game.isOnline() then

@ -4,8 +4,6 @@ TextMessage = {}
importStyle 'textmessage.otui' importStyle 'textmessage.otui'
-- private variables -- private variables
local bottomLabelWidget, centerLabelWidget
local MessageTypes = { local MessageTypes = {
warning = { color = '#F55E5E', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, warning = { color = '#F55E5E', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
eventAdvance = { color = '#FFFFFF', 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 } consoleRed = { color = '#F55E5E', showOnConsole = true, showOnWindow = false }
} }
local MessageTypesMap = { local bottomLabelWidget
[12] = MessageTypes.consoleOrange, local centerLabelWidget
[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 bottomLabelHideEvent local bottomLabelHideEvent
local centerLabelHideEvent local centerLabelHideEvent
-- private functions -- private functions
local function displayMessage(msgtype, msg) local function displayMessage(msgtype, msg, time)
if msgtype.showOnConsole then if msgtype.showOnConsole then
-- TODO -- TODO
end end
@ -66,7 +40,11 @@ local function displayMessage(msgtype, msg)
label:setStyle(msgtype.windowLocation) label:setStyle(msgtype.windowLocation)
label:setForegroundColor(msgtype.color) 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) removeEvent(label.hideEvent)
label.hideEvent = scheduleEvent(function() label:setVisible(false) end, time) label.hideEvent = scheduleEvent(function() label:setVisible(false) end, time)
end end
@ -78,25 +56,33 @@ function TextMessage.create()
centerLabelWidget = createWidget('UILabel', Game.gameMapPanel) centerLabelWidget = createWidget('UILabel', Game.gameMapPanel)
end end
function TextMessage.displayWarning(msg) function TextMessage.displayStatus(msg, time)
TextMessage.display(MessageTypes.warning, msg) displayMessage(MessageTypes.warning, msg)
end
function TextMessage.displayEventAdvance(msg, time)
displayMessage(MessageTypes.eventAdvance, msg, time)
end end
function TextMessage.display(msgtypeid, msg) function TextMessage.display(msgtypedesc, msg)
local msgtype = MessageTypesMap[msgtypeid] local msgtype = MessageTypes[msgtypedesc]
if msgtype == nil then if msgtype == nil then
error('unknown text msg type ' .. msgtypeid) error('unknown text msg type ' .. msgtype)
return return
end end
displayMessage(msgtype, msg) displayMessage(msgtype, msg)
end end
-- hooked events -- hooked events
function TextMessage.onTextMessage(msgtypeid, msg) local function onGameDeath()
TextMessage.display(msgtypeid, msg) TextMessage.displayEventAdvance('You are dead.', 10)
end end
local function onGameTextMessage(msgtype, msg)
TextMessage.display(msgtype, msg)
end
connect(Game, { onLogin = TextMessage.create, connect(Game, { onLogin = TextMessage.create,
onLogout = TextMessage.destroy, onLogout = TextMessage.destroy,
onTextMessage = TextMessage.onTextMessage }) onDeath = onGameDeath,
onTextMessage = onGameTextMessage })

@ -12,4 +12,4 @@ Hotkeys.bind('Ctrl+R', function() runscript('otclientrc.lua') end)
if rcloaded then if rcloaded then
print('otclient.rc lua reloaded') print('otclient.rc lua reloaded')
end end
rcloaded = true rcloaded = true

@ -39,9 +39,10 @@ FIND_PACKAGE(ZLIB REQUIRED)
IF(CMAKE_COMPILER_IS_GNUCXX) 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(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 "-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_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") SET(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++ -Wl,--as-needed")
ENDIF(CMAKE_COMPILER_IS_GNUCXX) ENDIF(CMAKE_COMPILER_IS_GNUCXX)

@ -7,6 +7,7 @@ ENDIF(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 6)
OPTION(NO_BOT_PROTECTION "Disables bot protection" OFF) OPTION(NO_BOT_PROTECTION "Disables bot protection" OFF)
SET(PROTOCOL 862 CACHE "Protocol version" STRING) SET(PROTOCOL 862 CACHE "Protocol version" STRING)
ADD_DEFINITIONS(-DPROTOCOL=${PROTOCOL}) ADD_DEFINITIONS(-DPROTOCOL=${PROTOCOL})
MESSAGE(STATUS "Protocol: " ${PROTOCOL})
IF(NO_BOT_PROTECTION) IF(NO_BOT_PROTECTION)
ADD_DEFINITIONS(-DNO_BOT_PROTECTION) ADD_DEFINITIONS(-DNO_BOT_PROTECTION)

@ -31,28 +31,6 @@ namespace Otc
static const char* AppCompactName = "otclient"; static const char* AppCompactName = "otclient";
static const char* AppVersion = "0.4.0"; 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 { enum DatOpts {
DatGround = 0, DatGround = 0,
DatGroundClip, DatGroundClip,
@ -91,165 +69,6 @@ namespace Otc
DatLastOpt = 255 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 { enum InventorySlots {
InventorySlotHead = 1, InventorySlotHead = 1,
InventorySlotNecklace, InventorySlotNecklace,
@ -332,42 +151,6 @@ namespace Otc
FluidCoconutMilk = 15 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 { enum FightModes {
FightOffensive = 1, FightOffensive = 1,
FightBalanced = 2, FightBalanced = 2,

@ -24,9 +24,11 @@
#include "localplayer.h" #include "localplayer.h"
#include "map.h" #include "map.h"
#include "tile.h" #include "tile.h"
#include <otclient/net/protocolgame.h>
#include <framework/core/eventdispatcher.h> #include <framework/core/eventdispatcher.h>
#include <framework/ui/uimanager.h> #include <framework/ui/uimanager.h>
#include <otclient/luascript/luavaluecasts.h>
#include <otclient/core/statictext.h>
#include <otclient/net/protocolgame.h>
Game g_game; Game g_game;
@ -101,7 +103,18 @@ void Game::processDeath()
g_dispatcher.scheduleEvent(std::bind(&Game::forceLogout, &g_game), 5 * 1000); 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); g_lua.callGlobalField("Game","onTextMessage", type, message);
} }

@ -45,7 +45,8 @@ public:
void processLogout(); void processLogout();
void processDeath(); 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 processInventoryChange(int slot, const ItemPtr& item);
void processAttackCancel(); void processAttackCancel();

@ -100,8 +100,7 @@ bool LocalPlayer::canWalk(Otc::Direction direction)
Position newPos = m_position + Position::getPosFromDirection(direction); Position newPos = m_position + Position::getPosFromDirection(direction);
TilePtr tile = g_map.getTile(newPos); TilePtr tile = g_map.getTile(newPos);
if(!tile->isWalkable()) { if(!tile->isWalkable()) {
// TODO: create enum for 17, white message on screen bottom and console. g_game.processTextMessage("statusSmall", "Sorry, not possible.");
g_game.processTextMessage(17, "Sorry, not possible.");
return false; return false;
} }

@ -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 // First message
if(m_messages.size() == 0) { if(m_messages.size() == 0) {
m_name = name; m_name = name;
m_type = type; m_messageType = type;
} }
else { else {
// we can only add another message if it follows these conditions // 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; return false;
} }
@ -83,31 +83,31 @@ void StaticText::compose()
{ {
m_text.clear(); m_text.clear();
if(m_type == Otc::SpeakSay) { if(m_messageType == "say") {
m_text += m_name; m_text += m_name;
m_text += " says:\n"; m_text += " says:\n";
m_color = Color(239, 239, 0); m_color = Color(239, 239, 0);
} }
else if(m_type == Otc::SpeakWhisper) { else if(m_messageType == "whisper") {
m_text += m_name; m_text += m_name;
m_text += " whispers:\n"; m_text += " whispers:\n";
m_color = Color(239, 239, 0); m_color = Color(239, 239, 0);
} }
else if(m_type == Otc::SpeakYell) { else if(m_messageType == "yell") {
m_text += m_name; m_text += m_name;
m_text += " yells:\n"; m_text += " yells:\n";
m_color = Color(239, 239, 0); 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); m_color = Color(254, 101, 0);
} }
else if(m_type == Otc::SpeakPrivateNpcToPlayer) { else if(m_messageType == "npcToPlayer") {
m_text += m_name; m_text += m_name;
m_text += " says:\n"; m_text += " says:\n";
m_color = Color(95, 247, 247); m_color = Color(95, 247, 247);
} }
else { else {
logWarning("unknown speak type: ", m_type); logWarning("unknown speak type: ", m_messageType);
} }
// Todo: add break lines // Todo: add break lines

@ -38,10 +38,10 @@ public:
void draw(const Point& p, const Rect& visibleRect); void draw(const Point& p, const Rect& visibleRect);
std::string getName() { return m_name; } std::string getName() { return m_name; }
int getMessageType() { return m_type; } std::string getMessageType() { return m_messageType; }
std::string getFirstMessage() { return m_messages[0]; } 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(); void removeMessage();
StaticTextPtr asStaticText() { return std::static_pointer_cast<StaticText>(shared_from_this()); } StaticTextPtr asStaticText() { return std::static_pointer_cast<StaticText>(shared_from_this()); }
@ -53,7 +53,7 @@ private:
Size m_textSize; Size m_textSize;
std::vector<std::string> m_messages; std::vector<std::string> m_messages;
std::string m_name, m_text; std::string m_name, m_text;
int m_type; std::string m_messageType;
Color m_color; Color m_color;
}; };

@ -62,13 +62,16 @@ bool luavalue_cast(int index, Outfit& outfit)
void push_luavalue(const Position& pos) void push_luavalue(const Position& pos)
{ {
g_lua.newTable(); if(pos.isValid()) {
g_lua.pushInteger(pos.x); g_lua.newTable();
g_lua.setField("x"); g_lua.pushInteger(pos.x);
g_lua.pushInteger(pos.y); g_lua.setField("x");
g_lua.setField("y"); g_lua.pushInteger(pos.y);
g_lua.pushInteger(pos.z); g_lua.setField("y");
g_lua.setField("z"); g_lua.pushInteger(pos.z);
g_lua.setField("z");
} else
g_lua.pushNil();
} }
bool luavalue_cast(int index, Position& pos) bool luavalue_cast(int index, Position& pos)

@ -25,6 +25,7 @@
#include <otclient/global.h> #include <otclient/global.h>
#include <framework/net/declarations.h> #include <framework/net/declarations.h>
#include "protocolcodes.h"
class ProtocolLogin; class ProtocolLogin;
class ProtocolGame; class ProtocolGame;

@ -0,0 +1,355 @@
/*
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/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 <otclient/global.h>
#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

@ -32,8 +32,6 @@
#include <otclient/core/tile.h> #include <otclient/core/tile.h>
#include <otclient/luascript/luavaluecasts.h> #include <otclient/luascript/luavaluecasts.h>
#include <framework/core/eventdispatcher.h> #include <framework/core/eventdispatcher.h>
#include <framework/graphics/particlemanager.h>
#include <otclient/core/statictext.h>
void ProtocolGame::parseMessage(InputMessage& msg) void ProtocolGame::parseMessage(InputMessage& msg)
{ {
@ -42,216 +40,216 @@ void ProtocolGame::parseMessage(InputMessage& msg)
uint8 opt = msg.getU8(); uint8 opt = msg.getU8();
switch(opt) { switch(opt) {
case Otc::GameServerInitGame: case Proto::GameServerInitGame:
parsePlayerLogin(msg); parsePlayerLogin(msg);
break; break;
case 0x0B: case 0x0B:
parseGMActions(msg); parseGMActions(msg);
break; break;
case Otc::GameServerLoginError: case Proto::GameServerLoginError:
parseLoginError(msg); parseLoginError(msg);
break; break;
case Otc::GameServerLoginAdvice: case Proto::GameServerLoginAdvice:
parseFYIMessage(msg); parseFYIMessage(msg);
break; break;
case Otc::GameServerLoginWait: case Proto::GameServerLoginWait:
parseWaitList(msg); parseWaitList(msg);
break; break;
case Otc::GameServerPing: case Proto::GameServerPing:
parsePing(msg); parsePing(msg);
break; break;
//case Otc::GameServerChallange: //case Proto::GameServerChallange:
case Otc::GameServerDead: case Proto::GameServerDead:
parseDeath(msg); parseDeath(msg);
break; break;
case Otc::GameServerFullMap: case Proto::GameServerFullMap:
parseMapDescription(msg); parseMapDescription(msg);
break; break;
case Otc::GameServerMapTopRow: case Proto::GameServerMapTopRow:
parseMoveNorth(msg); parseMoveNorth(msg);
break; break;
case Otc::GameServerMapRightRow: case Proto::GameServerMapRightRow:
parseMoveEast(msg); parseMoveEast(msg);
break; break;
case Otc::GameServerMapBottomRow: case Proto::GameServerMapBottomRow:
parseMoveSouth(msg); parseMoveSouth(msg);
break; break;
case Otc::GameServerMapLeftRow: case Proto::GameServerMapLeftRow:
parseMoveWest(msg); parseMoveWest(msg);
break; break;
case Otc::GameServerTileData: case Proto::GameServerTileData:
parseUpdateTile(msg); parseUpdateTile(msg);
break; break;
case Otc::GameServerCreateOnMap: case Proto::GameServerCreateOnMap:
parseTileAddThing(msg); parseTileAddThing(msg);
break; break;
case Otc::GameServerChangeOnMap: case Proto::GameServerChangeOnMap:
parseTileTransformThing(msg); parseTileTransformThing(msg);
break; break;
case Otc::GameServerDeleteOnMap: case Proto::GameServerDeleteOnMap:
parseTileRemoveThing(msg); parseTileRemoveThing(msg);
break; break;
case Otc::GameServerMoveCreature: case Proto::GameServerMoveCreature:
parseCreatureMove(msg); parseCreatureMove(msg);
break; break;
case Otc::GameServerOpenContainer: case Proto::GameServerOpenContainer:
parseOpenContainer(msg); parseOpenContainer(msg);
break; break;
case Otc::GameServerCloseContainer: case Proto::GameServerCloseContainer:
parseCloseContainer(msg); parseCloseContainer(msg);
break; break;
case Otc::GameServerCreateContainer: case Proto::GameServerCreateContainer:
parseContainerAddItem(msg); parseContainerAddItem(msg);
break; break;
case Otc::GameServerChangeInContainer: case Proto::GameServerChangeInContainer:
parseContainerUpdateItem(msg); parseContainerUpdateItem(msg);
break; break;
case Otc::GameServerDeleteInContainer: case Proto::GameServerDeleteInContainer:
parseContainerRemoveItem(msg); parseContainerRemoveItem(msg);
break; break;
case Otc::GameServerSetInventory: case Proto::GameServerSetInventory:
parseAddInventoryItem(msg); parseAddInventoryItem(msg);
break; break;
case Otc::GameServerDeleteInventory: case Proto::GameServerDeleteInventory:
parseRemoveInventoryItem(msg); parseRemoveInventoryItem(msg);
break; break;
case Otc::GameServerNpcOffer: case Proto::GameServerNpcOffer:
parseOpenShopWindow(msg); parseOpenShopWindow(msg);
break; break;
case Otc::GameServerPlayerGoods: case Proto::GameServerPlayerGoods:
parsePlayerCash(msg); parsePlayerCash(msg);
break; break;
case Otc::GameServerCloseNpcTrade: case Proto::GameServerCloseNpcTrade:
parseCloseShopWindow(msg); parseCloseShopWindow(msg);
break; break;
case Otc::GameServerOwnOffer: case Proto::GameServerOwnOffer:
parseSafeTradeRequest(msg); parseSafeTradeRequest(msg);
break; break;
case Otc::GameServerCounterOffer: case Proto::GameServerCounterOffer:
parseSafeTradeRequest(msg); parseSafeTradeRequest(msg);
break; break;
case Otc::GameServerCloseTrade: case Proto::GameServerCloseTrade:
parseSafeTradeClose(msg); parseSafeTradeClose(msg);
break; break;
case Otc::GameServerAmbient: case Proto::GameServerAmbient:
parseWorldLight(msg); parseWorldLight(msg);
break; break;
case Otc::GameServerGraphicalEffect: case Proto::GameServerGraphicalEffect:
parseMagicEffect(msg); parseMagicEffect(msg);
break; break;
case Otc::GameServerTextEffect: case Proto::GameServerTextEffect:
parseAnimatedText(msg); parseAnimatedText(msg);
break; break;
case Otc::GameServerMissleEffect: case Proto::GameServerMissleEffect:
parseDistanceMissile(msg); parseDistanceMissile(msg);
break; break;
case Otc::GameServerMarkCreature: case Proto::GameServerMarkCreature:
parseCreatureSquare(msg); parseCreatureSquare(msg);
break; break;
//case Otc::GameServerTrappers //case Proto::GameServerTrappers
case Otc::GameServerCreatureHealth: case Proto::GameServerCreatureHealth:
parseCreatureHealth(msg); parseCreatureHealth(msg);
break; break;
case Otc::GameServerCreatureLight: case Proto::GameServerCreatureLight:
parseCreatureLight(msg); parseCreatureLight(msg);
break; break;
case Otc::GameServerCreatureOutfit: case Proto::GameServerCreatureOutfit:
parseCreatureOutfit(msg); parseCreatureOutfit(msg);
break; break;
case Otc::GameServerCreatureSpeed: case Proto::GameServerCreatureSpeed:
parseCreatureSpeed(msg); parseCreatureSpeed(msg);
break; break;
case Otc::GameServerCreatureSkull: case Proto::GameServerCreatureSkull:
parseCreatureSkulls(msg); parseCreatureSkulls(msg);
break; break;
case Otc::GameServerCreatureParty: case Proto::GameServerCreatureParty:
parseCreatureShields(msg); parseCreatureShields(msg);
break; break;
// case Otc::GameServerCreatureUnpass // case Proto::GameServerCreatureUnpass
case Otc::GameServerEditText: case Proto::GameServerEditText:
parseItemTextWindow(msg); parseItemTextWindow(msg);
break; break;
case Otc::GameServerEditList: case Proto::GameServerEditList:
parseHouseTextWindow(msg); parseHouseTextWindow(msg);
break; break;
case Otc::GameServerPlayerData: case Proto::GameServerPlayerData:
parsePlayerStats(msg); parsePlayerStats(msg);
break; break;
case Otc::GameServerPlayerSkills: case Proto::GameServerPlayerSkills:
parsePlayerSkills(msg); parsePlayerSkills(msg);
break; break;
case Otc::GameServerPlayerState: case Proto::GameServerPlayerState:
parsePlayerIcons(msg); parsePlayerIcons(msg);
break; break;
case Otc::GameServerClearTarget: case Proto::GameServerClearTarget:
parsePlayerCancelAttack(msg); parsePlayerCancelAttack(msg);
break; break;
//case Otc::GameServerSpellDelay: //case Proto::GameServerSpellDelay:
//case Otc::GameServerSpellGroupDelay: //case Proto::GameServerSpellGroupDelay:
case Otc::GameServerTalk: case Proto::GameServerTalk:
parseCreatureSpeak(msg); parseCreatureSpeak(msg);
break; break;
case Otc::GameServerChannels: case Proto::GameServerChannels:
parseChannelList(msg); parseChannelList(msg);
break; break;
case Otc::GameServerOpenChannel: case Proto::GameServerOpenChannel:
parseOpenChannel(msg); parseOpenChannel(msg);
break; break;
case Otc::GameServerPrivateChannel: case Proto::GameServerPrivateChannel:
parseOpenPrivatePlayerChat(msg); parseOpenPrivatePlayerChat(msg);
break; break;
case Otc::GameServerRuleViolation: case Proto::GameServerRuleViolation:
case Otc::GameServerRuleViolation1: case Proto::GameServerRuleViolation1:
case Otc::GameServerRuleViolation2: case Proto::GameServerRuleViolation2:
case Otc::GameServerRuleViolation3: case Proto::GameServerRuleViolation3:
parseOpenRuleViolation(msg); parseOpenRuleViolation(msg);
break; break;
case Otc::GameServerOpenOwnChannel: case Proto::GameServerOpenOwnChannel:
parseCreatePrivateChannel(msg); parseCreatePrivateChannel(msg);
break; break;
case Otc::GameServerCloseChannel: case Proto::GameServerCloseChannel:
parseClosePrivateChannel(msg); parseClosePrivateChannel(msg);
break; break;
case Otc::GameServerMessage: case Proto::GameServerMessage:
parseTextMessage(msg); parseTextMessage(msg);
break; break;
case Otc::GameServerSnapBack: case Proto::GameServerSnapBack:
parseCancelWalk(msg); parseCancelWalk(msg);
break; break;
//case Otc::GameServerWait: //case Proto::GameServerWait:
case Otc::GameServerTopFloor: case Proto::GameServerTopFloor:
parseFloorChangeUp(msg); parseFloorChangeUp(msg);
break; break;
case Otc::GameServerBottomFloor: case Proto::GameServerBottomFloor:
parseFloorChangeDown(msg); parseFloorChangeDown(msg);
break; break;
case Otc::GameServerOutfit: case Proto::GameServerOutfit:
parseOutfitWindow(msg); parseOutfitWindow(msg);
break; break;
case Otc::GameServerBuddyData: case Proto::GameServerBuddyData:
parseVipState(msg); parseVipState(msg);
break; break;
case Otc::GameServerBuddyLogin: case Proto::GameServerBuddyLogin:
parseVipLogin(msg); parseVipLogin(msg);
break; break;
case Otc::GameServerBuddyLogout: case Proto::GameServerBuddyLogout:
parseVipLogout(msg); parseVipLogout(msg);
break; break;
case Otc::GameServerTutorialHint: case Proto::GameServerTutorialHint:
parseShowTutorial(msg); parseShowTutorial(msg);
break; break;
case Otc::GameServerAutomapFlag: case Proto::GameServerAutomapFlag:
parseAddMarker(msg); parseAddMarker(msg);
break; break;
case Otc::GameServerQuestLog: case Proto::GameServerQuestLog:
parseQuestList(msg); parseQuestList(msg);
break; break;
case Otc::GameServerQuestLine: case Proto::GameServerQuestLine:
parseQuestPartList(msg); parseQuestPartList(msg);
break; break;
//case Otc::GameServerChannelEvent: //case Proto::GameServerChannelEvent:
//case Otc::GameServerObjectInfo: //case Proto::GameServerObjectInfo:
//case Otc::GameServerPlayerInventory: //case Proto::GameServerPlayerInventory:
default: default:
Fw::throwException("unknown opt byte ", (int)opt); Fw::throwException("unknown opt byte ", (int)opt);
break; break;
@ -746,30 +744,30 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
Position creaturePos; Position creaturePos;
switch(type) { switch(type) {
case Otc::SpeakSay: case Proto::SpeakSay:
case Otc::SpeakWhisper: case Proto::SpeakWhisper:
case Otc::SpeakYell: case Proto::SpeakYell:
case Otc::SpeakMonsterSay: case Proto::SpeakMonsterSay:
case Otc::SpeakMonsterYell: case Proto::SpeakMonsterYell:
case Otc::SpeakPrivateNpcToPlayer: case Proto::SpeakPrivateNpcToPlayer:
creaturePos = parsePosition(msg); creaturePos = parsePosition(msg);
break; break;
case Otc::SpeakChannelYellow: case Proto::SpeakChannelYellow:
case Otc::SpeakChannelWhite: case Proto::SpeakChannelWhite:
case Otc::SpeakChannelRed: case Proto::SpeakChannelRed:
#if PROTOCOL==860 #if PROTOCOL==860
case Otc::SpeakChannelRed2: case Proto::SpeakUnk2:
#endif #endif
case Otc::SpeakChannelOrange: case Proto::SpeakChannelOrange:
channelId = msg.getU16(); channelId = msg.getU16();
break; break;
case Otc::SpeakPrivate: case Proto::SpeakPrivate:
case Otc::SpeakPrivatePlayerToNpc: case Proto::SpeakPrivatePlayerToNpc:
case Otc::SpeakBroadcast: case Proto::SpeakBroadcast:
case Otc::SpeakPrivateRed: case Proto::SpeakPrivateRed:
break; break;
#if PROTOCOL==860 #if PROTOCOL==860
case Otc::SpeakReportChannel: case Proto::SpeakReportChannel:
msg.getU32(); msg.getU32();
break; break;
#endif #endif
@ -779,16 +777,11 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
} }
std::string message = msg.getString(); std::string message = msg.getString();
std::string typeDesc = Proto::translateSpeakType(type);
g_dispatcher.addEvent([=] { 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) void ProtocolGame::parseChannelList(InputMessage& msg)
@ -840,9 +833,11 @@ void ProtocolGame::parseClosePrivateChannel(InputMessage& msg)
void ProtocolGame::parseTextMessage(InputMessage& msg) void ProtocolGame::parseTextMessage(InputMessage& msg)
{ {
uint8 type = msg.getU8(); uint8 type = msg.getU8();
std::string typeDesc = Proto::translateMessageType(type);
std::string message = msg.getString(); 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) void ProtocolGame::parseCancelWalk(InputMessage& msg)
@ -1091,11 +1086,11 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg)
if(id == (uint32)m_localPlayer->getId()) if(id == (uint32)m_localPlayer->getId())
creature = m_localPlayer->asCreature(); 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(); 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); creature = CreaturePtr(new Creature);
else if(id >= Otc::NpcStartId && id < Otc::NpcEndId) else if(id >= Proto::NpcStartId && id < Proto::NpcEndId)
creature = CreaturePtr(new Creature); creature = CreaturePtr(new Creature);
else else
logFatal("creature id is invalid"); logFatal("creature id is invalid");

@ -27,9 +27,9 @@ void ProtocolGame::sendLoginPacket(uint32 timestamp, uint8 unknown)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientEnterGame); oMsg.addU8(Proto::ClientEnterGame);
oMsg.addU16(Otc::OsLinux); oMsg.addU16(Proto::OsLinux);
oMsg.addU16(Otc::ClientVersion); oMsg.addU16(Proto::ClientVersion);
oMsg.addU8(0); // first RSA byte must be 0 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())); oMsg.addPaddingBytes(128 - (29 + m_accountName.length() + m_characterName.length() + m_accountPassword.length()));
// encrypt with RSA // 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); send(oMsg);
@ -62,14 +62,14 @@ void ProtocolGame::sendLoginPacket(uint32 timestamp, uint8 unknown)
void ProtocolGame::sendLogout() void ProtocolGame::sendLogout()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientQuitGame); oMsg.addU8(Proto::ClientQuitGame);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendPing() void ProtocolGame::sendPing()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientPingBack); oMsg.addU8(Proto::ClientPingBack);
send(oMsg); send(oMsg);
} }
@ -78,98 +78,98 @@ void ProtocolGame::sendPing()
void ProtocolGame::sendWalkNorth() void ProtocolGame::sendWalkNorth()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientGoNorth); oMsg.addU8(Proto::ClientGoNorth);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendWalkEast() void ProtocolGame::sendWalkEast()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientGoEast); oMsg.addU8(Proto::ClientGoEast);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendWalkSouth() void ProtocolGame::sendWalkSouth()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientGoSouth); oMsg.addU8(Proto::ClientGoSouth);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendWalkWest() void ProtocolGame::sendWalkWest()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientGoWest); oMsg.addU8(Proto::ClientGoWest);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendStopAutowalk() void ProtocolGame::sendStopAutowalk()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientStop); oMsg.addU8(Proto::ClientStop);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendWalkNorthEast() void ProtocolGame::sendWalkNorthEast()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientGoNorthEast); oMsg.addU8(Proto::ClientGoNorthEast);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendWalkSouthEast() void ProtocolGame::sendWalkSouthEast()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientGoSouthEast); oMsg.addU8(Proto::ClientGoSouthEast);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendWalkSouthWest() void ProtocolGame::sendWalkSouthWest()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientGoSouthWest); oMsg.addU8(Proto::ClientGoSouthWest);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendWalkNorthWest() void ProtocolGame::sendWalkNorthWest()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientGoNorthWest); oMsg.addU8(Proto::ClientGoNorthWest);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendTurnNorth() void ProtocolGame::sendTurnNorth()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientRotateNorth); oMsg.addU8(Proto::ClientRotateNorth);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendTurnEast() void ProtocolGame::sendTurnEast()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientRotateEast); oMsg.addU8(Proto::ClientRotateEast);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendTurnSouth() void ProtocolGame::sendTurnSouth()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientRotateSouth); oMsg.addU8(Proto::ClientRotateSouth);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendTurnWest() void ProtocolGame::sendTurnWest()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientRotateWest); oMsg.addU8(Proto::ClientRotateWest);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendThrow(const Position& fromPos, int thingId, int stackpos, const Position& toPos, int count) void ProtocolGame::sendThrow(const Position& fromPos, int thingId, int stackpos, const Position& toPos, int count)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientMoveObject); oMsg.addU8(Proto::ClientMoveObject);
addPosition(oMsg, fromPos); addPosition(oMsg, fromPos);
oMsg.addU16(thingId); oMsg.addU16(thingId);
oMsg.addU8(stackpos); oMsg.addU8(stackpos);
@ -181,7 +181,7 @@ void ProtocolGame::sendThrow(const Position& fromPos, int thingId, int stackpos,
void ProtocolGame::sendLookInShop(int thingId, int count) void ProtocolGame::sendLookInShop(int thingId, int count)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientInspectNpcTrade); oMsg.addU8(Proto::ClientInspectNpcTrade);
oMsg.addU16(thingId); oMsg.addU16(thingId);
oMsg.addU8(count); oMsg.addU8(count);
send(oMsg); 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) void ProtocolGame::sendPlayerPurchase(int thingId, int count, int amount, bool ignoreCapacity, bool buyWithBackpack)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientBuyObject); oMsg.addU8(Proto::ClientBuyObject);
oMsg.addU16(thingId); oMsg.addU16(thingId);
oMsg.addU8(count); oMsg.addU8(count);
oMsg.addU8(amount); 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) void ProtocolGame::sendPlayerSale(int thingId, int count, int amount, bool ignoreEquipped)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientSellObject); oMsg.addU8(Proto::ClientSellObject);
oMsg.addU16(thingId); oMsg.addU16(thingId);
oMsg.addU8(count); oMsg.addU8(count);
oMsg.addU8(amount); oMsg.addU8(amount);
@ -213,14 +213,14 @@ void ProtocolGame::sendPlayerSale(int thingId, int count, int amount, bool ignor
void ProtocolGame::sendCloseShop() void ProtocolGame::sendCloseShop()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientCloseNpcTrade); oMsg.addU8(Proto::ClientCloseNpcTrade);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendRequestTrade(const Position& pos, int thingId, int stackpos, int playerId) void ProtocolGame::sendRequestTrade(const Position& pos, int thingId, int stackpos, int playerId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientTradeObject); oMsg.addU8(Proto::ClientTradeObject);
addPosition(oMsg, pos); addPosition(oMsg, pos);
oMsg.addU16(thingId); oMsg.addU16(thingId);
oMsg.addU8(stackpos); oMsg.addU8(stackpos);
@ -231,7 +231,7 @@ void ProtocolGame::sendRequestTrade(const Position& pos, int thingId, int stackp
void ProtocolGame::sendLookInTrade(bool counterOffer, int index) void ProtocolGame::sendLookInTrade(bool counterOffer, int index)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientInspectTrade); oMsg.addU8(Proto::ClientInspectTrade);
oMsg.addU8(counterOffer ? 0x01 : 0x00); oMsg.addU8(counterOffer ? 0x01 : 0x00);
oMsg.addU8(index); oMsg.addU8(index);
send(oMsg); send(oMsg);
@ -240,21 +240,21 @@ void ProtocolGame::sendLookInTrade(bool counterOffer, int index)
void ProtocolGame::sendAcceptTrade() void ProtocolGame::sendAcceptTrade()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientAcceptTrade); oMsg.addU8(Proto::ClientAcceptTrade);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendRejectTrade() void ProtocolGame::sendRejectTrade()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientRejectTrade); oMsg.addU8(Proto::ClientRejectTrade);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendUseItem(const Position& position, int itemId, int stackpos, int index) void ProtocolGame::sendUseItem(const Position& position, int itemId, int stackpos, int index)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientUseObject); oMsg.addU8(Proto::ClientUseObject);
addPosition(oMsg, position); addPosition(oMsg, position);
oMsg.addU16(itemId); oMsg.addU16(itemId);
oMsg.addU8(stackpos); 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) void ProtocolGame::sendUseItemEx(const Position& fromPos, int fromThingId, int fromStackpos, const Position& toPos, int toThingId, int toStackpos)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientUseTwoObjects); oMsg.addU8(Proto::ClientUseTwoObjects);
addPosition(oMsg, fromPos); addPosition(oMsg, fromPos);
oMsg.addU16(fromThingId); oMsg.addU16(fromThingId);
oMsg.addU8(fromStackpos); 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) void ProtocolGame::sendUseItemCreature(const Position& pos, int thingId, int stackpos, int creatureId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientUseOnCreature); oMsg.addU8(Proto::ClientUseOnCreature);
addPosition(oMsg, pos); addPosition(oMsg, pos);
oMsg.addU16(thingId); oMsg.addU16(thingId);
oMsg.addU8(stackpos); 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) void ProtocolGame::sendRotateItem(const Position& pos, int thingId, int stackpos)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientTurnObject); oMsg.addU8(Proto::ClientTurnObject);
addPosition(oMsg, pos); addPosition(oMsg, pos);
oMsg.addU16(thingId); oMsg.addU16(thingId);
oMsg.addU8(stackpos); oMsg.addU8(stackpos);
@ -299,7 +299,7 @@ void ProtocolGame::sendRotateItem(const Position& pos, int thingId, int stackpos
void ProtocolGame::sendCloseContainer(int containerId) void ProtocolGame::sendCloseContainer(int containerId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientCloseContainer); oMsg.addU8(Proto::ClientCloseContainer);
oMsg.addU8(containerId); oMsg.addU8(containerId);
send(oMsg); send(oMsg);
} }
@ -307,7 +307,7 @@ void ProtocolGame::sendCloseContainer(int containerId)
void ProtocolGame::sendUpContainer(int containerId) void ProtocolGame::sendUpContainer(int containerId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientUpContainer); oMsg.addU8(Proto::ClientUpContainer);
oMsg.addU8(containerId); oMsg.addU8(containerId);
send(oMsg); send(oMsg);
} }
@ -315,7 +315,7 @@ void ProtocolGame::sendUpContainer(int containerId)
void ProtocolGame::sendTextWindow(int windowTextId, const std::string& text) void ProtocolGame::sendTextWindow(int windowTextId, const std::string& text)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientEditText); oMsg.addU8(Proto::ClientEditText);
oMsg.addU32(windowTextId); oMsg.addU32(windowTextId);
oMsg.addString(text); oMsg.addString(text);
send(oMsg); 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) void ProtocolGame::sendHouseWindow(int doorId, int id, const std::string& text)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientEditList); oMsg.addU8(Proto::ClientEditList);
oMsg.addU8(doorId); oMsg.addU8(doorId);
oMsg.addU32(id); oMsg.addU32(id);
oMsg.addString(text); 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) void ProtocolGame::sendLookAt(const Position& position, int thingId, int stackpos)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientLook); oMsg.addU8(Proto::ClientLook);
addPosition(oMsg, position); addPosition(oMsg, position);
oMsg.addU16(thingId); oMsg.addU16(thingId);
oMsg.addU8(stackpos); oMsg.addU8(stackpos);
@ -347,18 +347,18 @@ void ProtocolGame::sendTalk(int channelType, int channelId, const std::string& r
return; return;
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientTalk); oMsg.addU8(Proto::ClientTalk);
assert(channelType >= 0); assert(channelType >= 0);
oMsg.addU8(channelType); oMsg.addU8(channelType);
switch(channelType) { switch(channelType) {
case Otc::SpeakPrivate: case Proto::SpeakPrivate:
case Otc::SpeakPrivateRed: case Proto::SpeakPrivateRed:
oMsg.addString(receiver); oMsg.addString(receiver);
break; break;
case Otc::SpeakChannelYellow: case Proto::SpeakChannelYellow:
case Otc::SpeakChannelRed: case Proto::SpeakChannelRed:
oMsg.addU16(channelId); oMsg.addU16(channelId);
break; break;
} }
@ -370,14 +370,14 @@ void ProtocolGame::sendTalk(int channelType, int channelId, const std::string& r
void ProtocolGame::sendGetChannels() void ProtocolGame::sendGetChannels()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientGetChannels); oMsg.addU8(Proto::ClientGetChannels);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendJoinChannel(int channelId) void ProtocolGame::sendJoinChannel(int channelId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientJoinChannel); oMsg.addU8(Proto::ClientJoinChannel);
oMsg.addU16(channelId); oMsg.addU16(channelId);
send(oMsg); send(oMsg);
} }
@ -385,7 +385,7 @@ void ProtocolGame::sendJoinChannel(int channelId)
void ProtocolGame::sendLeaveChannel(int channelId) void ProtocolGame::sendLeaveChannel(int channelId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientLeaveChannel); oMsg.addU8(Proto::ClientLeaveChannel);
oMsg.addU16(channelId); oMsg.addU16(channelId);
send(oMsg); send(oMsg);
} }
@ -393,7 +393,7 @@ void ProtocolGame::sendLeaveChannel(int channelId)
void ProtocolGame::sendPrivateChannel(const std::string& receiver) void ProtocolGame::sendPrivateChannel(const std::string& receiver)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientPrivateChannel); oMsg.addU8(Proto::ClientPrivateChannel);
oMsg.addString(receiver); oMsg.addString(receiver);
send(oMsg); send(oMsg);
} }
@ -406,14 +406,14 @@ void ProtocolGame::sendPrivateChannel(const std::string& receiver)
void ProtocolGame::sendCloseNpcChannel() void ProtocolGame::sendCloseNpcChannel()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientCloseNpcChannel); oMsg.addU8(Proto::ClientCloseNpcChannel);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendFightTatics(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeFight) void ProtocolGame::sendFightTatics(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeFight)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientSetTactics); oMsg.addU8(Proto::ClientSetTactics);
oMsg.addU8(fightMode); oMsg.addU8(fightMode);
oMsg.addU8(chaseMode); oMsg.addU8(chaseMode);
oMsg.addU8(safeFight ? 0x01: 0x00); oMsg.addU8(safeFight ? 0x01: 0x00);
@ -423,7 +423,7 @@ void ProtocolGame::sendFightTatics(Otc::FightModes fightMode, Otc::ChaseModes ch
void ProtocolGame::sendAttack(int creatureId) void ProtocolGame::sendAttack(int creatureId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientAttack); oMsg.addU8(Proto::ClientAttack);
oMsg.addU32(creatureId); oMsg.addU32(creatureId);
oMsg.addU32(0); oMsg.addU32(0);
oMsg.addU32(0); oMsg.addU32(0);
@ -433,7 +433,7 @@ void ProtocolGame::sendAttack(int creatureId)
void ProtocolGame::sendFollow(int creatureId) void ProtocolGame::sendFollow(int creatureId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientFollow); oMsg.addU8(Proto::ClientFollow);
oMsg.addU32(creatureId); oMsg.addU32(creatureId);
send(oMsg); send(oMsg);
} }
@ -441,7 +441,7 @@ void ProtocolGame::sendFollow(int creatureId)
void ProtocolGame::sendInviteToParty(int creatureId) void ProtocolGame::sendInviteToParty(int creatureId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientInviteToParty); oMsg.addU8(Proto::ClientInviteToParty);
oMsg.addU32(creatureId); oMsg.addU32(creatureId);
send(oMsg); send(oMsg);
} }
@ -449,7 +449,7 @@ void ProtocolGame::sendInviteToParty(int creatureId)
void ProtocolGame::sendJoinParty(int creatureId) void ProtocolGame::sendJoinParty(int creatureId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientJoinParty); oMsg.addU8(Proto::ClientJoinParty);
oMsg.addU32(creatureId); oMsg.addU32(creatureId);
send(oMsg); send(oMsg);
} }
@ -457,7 +457,7 @@ void ProtocolGame::sendJoinParty(int creatureId)
void ProtocolGame::sendRevokeInvitation(int creatureId) void ProtocolGame::sendRevokeInvitation(int creatureId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientRevokeInvitation); oMsg.addU8(Proto::ClientRevokeInvitation);
oMsg.addU32(creatureId); oMsg.addU32(creatureId);
send(oMsg); send(oMsg);
} }
@ -465,7 +465,7 @@ void ProtocolGame::sendRevokeInvitation(int creatureId)
void ProtocolGame::sendPassLeadership(int creatureId) void ProtocolGame::sendPassLeadership(int creatureId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientPassLeadership); oMsg.addU8(Proto::ClientPassLeadership);
oMsg.addU32(creatureId); oMsg.addU32(creatureId);
send(oMsg); send(oMsg);
} }
@ -473,14 +473,14 @@ void ProtocolGame::sendPassLeadership(int creatureId)
void ProtocolGame::sendLeaveParty() void ProtocolGame::sendLeaveParty()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientLeaveParty); oMsg.addU8(Proto::ClientLeaveParty);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendShareExperience(bool active, int unknown) void ProtocolGame::sendShareExperience(bool active, int unknown)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientShareExperience); oMsg.addU8(Proto::ClientShareExperience);
oMsg.addU8(active ? 0x01 : 0x00); oMsg.addU8(active ? 0x01 : 0x00);
oMsg.addU8(unknown); oMsg.addU8(unknown);
send(oMsg); send(oMsg);
@ -489,14 +489,14 @@ void ProtocolGame::sendShareExperience(bool active, int unknown)
void ProtocolGame::sendOpenChannel() void ProtocolGame::sendOpenChannel()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientOpenChannel); oMsg.addU8(Proto::ClientOpenChannel);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendInviteToChannel(const std::string& name) void ProtocolGame::sendInviteToChannel(const std::string& name)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientInviteToChannel); oMsg.addU8(Proto::ClientInviteToChannel);
oMsg.addString(name); oMsg.addString(name);
send(oMsg); send(oMsg);
} }
@ -504,7 +504,7 @@ void ProtocolGame::sendInviteToChannel(const std::string& name)
void ProtocolGame::sendExcludeFromChannel(const std::string& name) void ProtocolGame::sendExcludeFromChannel(const std::string& name)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientExcludeFromChannel); oMsg.addU8(Proto::ClientExcludeFromChannel);
oMsg.addString(name); oMsg.addString(name);
send(oMsg); send(oMsg);
} }
@ -512,7 +512,7 @@ void ProtocolGame::sendExcludeFromChannel(const std::string& name)
void ProtocolGame::sendCancel() void ProtocolGame::sendCancel()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientCancel); oMsg.addU8(Proto::ClientCancel);
send(oMsg); send(oMsg);
} }
@ -521,21 +521,21 @@ void ProtocolGame::sendCancel()
void ProtocolGame::sendUpdateContainer() void ProtocolGame::sendUpdateContainer()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientRefreshContainer); oMsg.addU8(Proto::ClientRefreshContainer);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendGetOutfit() void ProtocolGame::sendGetOutfit()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientGetOutfit); oMsg.addU8(Proto::ClientGetOutfit);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendSetOutfit(const Outfit& outfit) void ProtocolGame::sendSetOutfit(const Outfit& outfit)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientSetOutfit); oMsg.addU8(Proto::ClientSetOutfit);
oMsg.addU16(outfit.getType()); oMsg.addU16(outfit.getType());
oMsg.addU8(outfit.getHead()); oMsg.addU8(outfit.getHead());
@ -550,7 +550,7 @@ void ProtocolGame::sendSetOutfit(const Outfit& outfit)
void ProtocolGame::sendAddVip(const std::string& name) void ProtocolGame::sendAddVip(const std::string& name)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientAddBuddy); oMsg.addU8(Proto::ClientAddBuddy);
oMsg.addString(name); oMsg.addString(name);
send(oMsg); send(oMsg);
} }
@ -558,7 +558,7 @@ void ProtocolGame::sendAddVip(const std::string& name)
void ProtocolGame::sendRemoveVip(int playerId) void ProtocolGame::sendRemoveVip(int playerId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientRemoveBuddy); oMsg.addU8(Proto::ClientRemoveBuddy);
oMsg.addU32(playerId); oMsg.addU32(playerId);
send(oMsg); send(oMsg);
} }
@ -570,14 +570,14 @@ void ProtocolGame::sendRemoveVip(int playerId)
void ProtocolGame::sendGetQuestLog() void ProtocolGame::sendGetQuestLog()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientGetQuestLog); oMsg.addU8(Proto::ClientGetQuestLog);
send(oMsg); send(oMsg);
} }
void ProtocolGame::sendGetQuestLine(int questId) void ProtocolGame::sendGetQuestLine(int questId)
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientGetQuestLine); oMsg.addU8(Proto::ClientGetQuestLine);
oMsg.addU16(questId); oMsg.addU16(questId);
send(oMsg); send(oMsg);
} }

@ -57,16 +57,16 @@ void ProtocolLogin::onRecv(InputMessage& inputMessage)
while(!inputMessage.eof()) { while(!inputMessage.eof()) {
uint8 opt = inputMessage.getU8(); uint8 opt = inputMessage.getU8();
switch(opt) { switch(opt) {
case Otc::LoginServerError: case Proto::LoginServerError:
parseError(inputMessage); parseError(inputMessage);
break; break;
case Otc::LoginServerMotd: case Proto::LoginServerMotd:
parseMOTD(inputMessage); parseMOTD(inputMessage);
break; break;
case Otc::LoginServerUpdateNeeded: case Proto::LoginServerUpdateNeeded:
callLuaField("onError", "Client needs update."); callLuaField("onError", "Client needs update.");
break; break;
case Otc::LoginServerCharacterList: case Proto::LoginServerCharacterList:
parseCharacterList(inputMessage); parseCharacterList(inputMessage);
break; break;
default: default:
@ -89,13 +89,13 @@ void ProtocolLogin::sendLoginPacket()
{ {
OutputMessage oMsg; OutputMessage oMsg;
oMsg.addU8(Otc::ClientEnterAccount); oMsg.addU8(Proto::ClientEnterAccount);
oMsg.addU16(Otc::OsLinux); oMsg.addU16(Proto::OsLinux);
oMsg.addU16(Otc::ClientVersion); oMsg.addU16(Proto::ClientVersion);
oMsg.addU32(g_thingsType.getSignature()); // data signature oMsg.addU32(g_thingsType.getSignature()); // data signature
oMsg.addU32(g_sprites.getSignature()); // sprite 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 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 // complete the 128 bytes for rsa encryption with zeros
oMsg.addPaddingBytes(128 - (21 + m_accountName.length() + m_accountPassword.length())); 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); send(oMsg);
enableXteaEncryption(); enableXteaEncryption();

Loading…
Cancel
Save