From 23ebcd904822ca2bf6c9643951cfbd4ccb8a6347 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Sun, 8 Jan 2012 18:11:50 -0200 Subject: [PATCH] protocol 860 fixes --- TODO | 10 +++++- modules/game_chat/chat.lua | 42 +++++++++++++++------- modules/game_textmessage/textmessage.lua | 37 ++++++++++--------- src/otclient/core/game.cpp | 2 +- src/otclient/net/protocolcodes.h | 46 +++++++++++++----------- src/otclient/net/protocolgameparse.cpp | 10 ++---- src/otclient/ui/uimap.cpp | 1 - 7 files changed, 88 insertions(+), 60 deletions(-) diff --git a/TODO b/TODO index 2f8814f7..560ee8aa 100644 --- a/TODO +++ b/TODO @@ -44,10 +44,12 @@ [bart] review and make more error prone with more warnings [bart] a real working border and background property in otui [bart] reapply anchor styles when adding new childs +[bart] ui text selection == Client modules [bart] modules managment interface [bart] console history, text selection, scrolling +[bart] make possible to reload modules == Client [bart] implement left panel with dragging windows @@ -64,7 +66,6 @@ [bart] draw lights using shaders [bart] chat with tabs [bart] limit FPS in options -[baxnie] display 'You are dead.' message [baxnie] display exit box when exiting from game [baxnie] do lua game event calls from Game instead from GameProtocol [baxnie] classic control @@ -89,3 +90,10 @@ [baxnie] fix walk jump when cancel creature following [baxnie] fix creature outfit when invisible or with item appearance +===== KNOWN BUGS +2x2 corpses is drawn above players +cratures with invisible effect is not rendered correctly +animatedtext is displayed in non visible floors +attack while walking cancels the walk +if a spell is used while pressing arrows keys the walk is canceled and it doesnt starts walking again +game map text message boxes is not displayed like tibia diff --git a/modules/game_chat/chat.lua b/modules/game_chat/chat.lua index 2207293e..38a143ce 100644 --- a/modules/game_chat/chat.lua +++ b/modules/game_chat/chat.lua @@ -1,22 +1,27 @@ Chat = {} -- private variables +--[[ +local SpeakTypes = { + say = { color = }, + whisper = { color = }, + yell, + monsterSay, + npcToPlayer, + cgannelYellow, + channelWhite, + channelRed, + channelOrange, + private, + playerToNpc, + broadcast, + privateRed +} +]]-- + local chatPanel local chatBuffer --- private functions -local function onCreatureSpeak(name, level, msgtype, message) - style = 'ChatLabel' - if name and level > 0 then - message = name .. ' [' .. level .. ']: ' .. message - style = 'YellowChatLabel' - end - - local label = createWidget(style) - label:setText(message) - chatBuffer:addChild(label) -end - -- public functions function Chat.create() chatPanel = displayUI('chat.otui', { parent = Game.gameBottomPanel } ) @@ -29,6 +34,17 @@ function Chat.destroy() end -- hooked events +local function onCreatureSpeak(name, level, msgtype, message) + style = 'ChatLabel' + if name and level > 0 then + message = name .. ' [' .. level .. ']: ' .. message + style = 'YellowChatLabel' + end + + local label = createWidget(style) + label:setText(message) + chatBuffer:addChild(label) +end connect(Game, { onLogin = Chat.create, onLogout = Chat.destroy, diff --git a/modules/game_textmessage/textmessage.lua b/modules/game_textmessage/textmessage.lua index ee75beab..bda642c2 100644 --- a/modules/game_textmessage/textmessage.lua +++ b/modules/game_textmessage/textmessage.lua @@ -5,15 +5,15 @@ importStyle 'textmessage.otui' -- private variables local MessageTypes = { - warning = { color = '#F55E5E', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, - eventAdvance = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, - eventDefault = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, - statusDefault = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, - infoDesc = { color = '#00EB00', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, - statusSmall = { color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' }, - consoleOrange = { color = '#FE6500', showOnConsole = true, showOnWindow = false }, - consoleBlue = { color = '#9F9DFD', showOnConsole = true, showOnWindow = false }, - consoleRed = { color = '#F55E5E', showOnConsole = true, showOnWindow = false } + warning = { color = '#F55E5E', showOnConsole = true, windowLocation = 'center' }, + eventAdvance = { color = '#FFFFFF', showOnConsole = true, windowLocation = 'center' }, + eventDefault = { color = '#FFFFFF', showOnConsole = true, windowLocation = 'bottom' }, + statusDefault = { color = '#FFFFFF', showOnConsole = true, windowLocation = 'bottom' }, + infoDescription = { color = '#00EB00', showOnConsole = true, windowLocation = 'center' }, + statusSmall = { color = '#FFFFFF', showOnConsole = false, windowLocation = 'bottom' }, + consoleOrange = { color = '#FE6500', showOnConsole = true }, + consoleBlue = { color = '#9F9DFD', showOnConsole = true }, + consoleRed = { color = '#F55E5E', showOnConsole = true } } local bottomLabelWidget @@ -23,21 +23,26 @@ local centerLabelHideEvent -- private functions local function displayMessage(msgtype, msg, time) + if not Game.isOnline() then return end + if msgtype.showOnConsole then -- TODO end - if msgtype.showOnWindow then + if msgtype.windowLocation then local label - if msgtype.windowLocation == 'BottomLabel' then + local style + if msgtype.windowLocation == 'bottom' then label = bottomLabelWidget - elseif msgtype.windowLocation == 'CenterLabel' then + style = 'BottomLabel' + elseif msgtype.windowLocation == 'center' then label = centerLabelWidget + style = 'CenterLabel' end label:setVisible(true) label:setText(msg) - label:setStyle(msgtype.windowLocation) + label:setStyle(style) label:setForegroundColor(msgtype.color) if not time then @@ -66,11 +71,9 @@ end function TextMessage.display(msgtypedesc, msg) local msgtype = MessageTypes[msgtypedesc] - if msgtype == nil then - error('unknown text msg type ' .. msgtype) - return + if msgtype then + displayMessage(msgtype, msg) end - displayMessage(msgtype, msg) end -- hooked events diff --git a/src/otclient/core/game.cpp b/src/otclient/core/game.cpp index 9ea61069..e3ad73a4 100644 --- a/src/otclient/core/game.cpp +++ b/src/otclient/core/game.cpp @@ -105,7 +105,7 @@ void Game::processDeath() 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()) { + if(creaturePos.isValid() && (type == "say" || type == "whisper" || type == "yell" || type == "monsterSay" || type == "monsterYell")) { StaticTextPtr staticText = StaticTextPtr(new StaticText); staticText->addMessage(name, type, message); g_map.addThing(staticText, creaturePos); diff --git a/src/otclient/net/protocolcodes.h b/src/otclient/net/protocolcodes.h index 8a30350d..372ff6dd 100644 --- a/src/otclient/net/protocolcodes.h +++ b/src/otclient/net/protocolcodes.h @@ -228,7 +228,13 @@ namespace Proto { SpeakPrivateRed, SpeakChannelOrange, SpeakMonsterSay, - SpeakMonsterYell + SpeakMonsterYell, + + // removed + SpeakRVRChannel = 255, + SpeakRVRAnswer, + SpeakRVRContinue, + SpeakChannelRed2 #elif PROTOCOL==860 SpeakSay = 1, SpeakWhisper, @@ -238,17 +244,15 @@ namespace Proto { SpeakPrivate, SpeakChannelYellow, SpeakChannelWhite, - SpeakReportChannel, - SpeakReportAnswer, - SpeakReportContinue, + SpeakRVRChannel, + SpeakRVRAnswer, + SpeakRVRContinue, SpeakBroadcast, SpeakChannelRed, SpeakPrivateRed, SpeakChannelOrange, - SpeakUnk1, - SpeakUnk2, - SpeakUnk3, - SpeakMonsterSay, + SpeakChannelRed2 = 17, + SpeakMonsterSay = 19, SpeakMonsterYell #endif }; @@ -256,18 +260,18 @@ namespace Proto { enum MessageTypes { #if PROTOCOL==860 MessageConsoleRed = 18, - MessageConsoleOrange1, - MessageConsoleOrange2, + MessageEventOrange, + MessageConsoleOrange, MessageWarning, MessageEventAdvance, MessageEventDefault, MessageStatusDefault, - MessageInfoDescription, + MessageInfoDescription , MessageStatusSmall, MessageConsoleBlue #elif PROTOCOL==862 - MessageConsoleOrange1 = 12, - MessageConsoleOrange2, + MessageEventOrange = 12, + MessageConsoleOrange, MessageWarning, MessageEventAdvance, MessageEventDefault, @@ -302,12 +306,12 @@ namespace Proto { return "monsterYell"; case Proto::SpeakPrivateNpcToPlayer: return "npcToPlayer"; - break; case Proto::SpeakChannelYellow: return "channelYellow"; case Proto::SpeakChannelWhite: return "channelWhite"; case Proto::SpeakChannelRed: + case Proto::SpeakChannelRed2: return "channelRed"; case Proto::SpeakChannelOrange: return "channelOrange"; @@ -320,18 +324,17 @@ namespace Proto { case Proto::SpeakPrivateRed: return "privateRed"; default: + logError("unknown protocol speak type ", type); return "unknown"; } } - inline std::string translateMessageType(int type) { + inline std::string translateTextMessageType(int type) { switch(type) { - case Proto::MessageConsoleRed: - return "consoleRed"; - case Proto::MessageConsoleOrange1: - return "consoleOrange"; - case Proto::MessageConsoleOrange2: + case Proto::MessageConsoleOrange: return "consoleOrange"; + case Proto::MessageEventOrange: + return "eventOrange"; case Proto::MessageWarning: return "warning"; case Proto::MessageEventAdvance: @@ -346,7 +349,10 @@ namespace Proto { return "statusSmall"; case Proto::MessageConsoleBlue: return "consoleBlue"; + case Proto::MessageConsoleRed: + return "consoleRed"; default: + logError("unknown protocol text message type ", type); return "unknown"; } } diff --git a/src/otclient/net/protocolgameparse.cpp b/src/otclient/net/protocolgameparse.cpp index f9e53314..4c21193e 100644 --- a/src/otclient/net/protocolgameparse.cpp +++ b/src/otclient/net/protocolgameparse.cpp @@ -755,9 +755,7 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg) case Proto::SpeakChannelYellow: case Proto::SpeakChannelWhite: case Proto::SpeakChannelRed: -#if PROTOCOL==860 - case Proto::SpeakUnk2: -#endif + case Proto::SpeakChannelRed2: case Proto::SpeakChannelOrange: channelId = msg.getU16(); break; @@ -766,11 +764,9 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg) case Proto::SpeakBroadcast: case Proto::SpeakPrivateRed: break; -#if PROTOCOL==860 - case Proto::SpeakReportChannel: + case Proto::SpeakRVRChannel: msg.getU32(); break; -#endif default: logTraceError("unknown speak type ", type); break; @@ -834,7 +830,7 @@ void ProtocolGame::parseTextMessage(InputMessage& msg) { uint8 type = msg.getU8(); - std::string typeDesc = Proto::translateMessageType(type); + std::string typeDesc = Proto::translateTextMessageType(type); std::string message = msg.getString(); g_dispatcher.addEvent(std::bind(&Game::processTextMessage, &g_game, typeDesc, message)); diff --git a/src/otclient/ui/uimap.cpp b/src/otclient/ui/uimap.cpp index 85576963..c31a381b 100644 --- a/src/otclient/ui/uimap.cpp +++ b/src/otclient/ui/uimap.cpp @@ -96,7 +96,6 @@ bool UIMap::onMousePress(const Point& mousePos, Fw::MouseButton button) EffectPtr effect = EffectPtr(new Effect); static int id = 0; effect->setId(id++); - dump << id; g_map.addThing(effect, tilePos); } else if(button == Fw::MouseRightButton) {