protocol 860 fixes

This commit is contained in:
Eduardo Bart 2012-01-08 18:11:50 -02:00
parent e46f5fcb69
commit 23ebcd9048
7 changed files with 88 additions and 60 deletions

10
TODO
View File

@ -44,10 +44,12 @@
[bart] review and make more error prone with more warnings [bart] review and make more error prone with more warnings
[bart] a real working border and background property in otui [bart] a real working border and background property in otui
[bart] reapply anchor styles when adding new childs [bart] reapply anchor styles when adding new childs
[bart] ui text selection
== Client modules == Client modules
[bart] modules managment interface [bart] modules managment interface
[bart] console history, text selection, scrolling [bart] console history, text selection, scrolling
[bart] make possible to reload modules
== Client == Client
[bart] implement left panel with dragging windows [bart] implement left panel with dragging windows
@ -64,7 +66,6 @@
[bart] draw lights using shaders [bart] draw lights using shaders
[bart] chat with tabs [bart] chat with tabs
[bart] limit FPS in options [bart] limit FPS in options
[baxnie] display 'You are dead.' message
[baxnie] display exit box when exiting from game [baxnie] display exit box when exiting from game
[baxnie] do lua game event calls from Game instead from GameProtocol [baxnie] do lua game event calls from Game instead from GameProtocol
[baxnie] classic control [baxnie] classic control
@ -89,3 +90,10 @@
[baxnie] fix walk jump when cancel creature following [baxnie] fix walk jump when cancel creature following
[baxnie] fix creature outfit when invisible or with item appearance [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

View File

@ -1,22 +1,27 @@
Chat = {} Chat = {}
-- private variables -- private variables
--[[
local SpeakTypes = {
say = { color = },
whisper = { color = },
yell,
monsterSay,
npcToPlayer,
cgannelYellow,
channelWhite,
channelRed,
channelOrange,
private,
playerToNpc,
broadcast,
privateRed
}
]]--
local chatPanel local chatPanel
local chatBuffer 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 -- public functions
function Chat.create() function Chat.create()
chatPanel = displayUI('chat.otui', { parent = Game.gameBottomPanel } ) chatPanel = displayUI('chat.otui', { parent = Game.gameBottomPanel } )
@ -29,6 +34,17 @@ function Chat.destroy()
end end
-- hooked events -- 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, connect(Game, { onLogin = Chat.create,
onLogout = Chat.destroy, onLogout = Chat.destroy,

View File

@ -5,15 +5,15 @@ importStyle 'textmessage.otui'
-- private variables -- private variables
local MessageTypes = { local MessageTypes = {
warning = { color = '#F55E5E', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, warning = { color = '#F55E5E', showOnConsole = true, windowLocation = 'center' },
eventAdvance = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, eventAdvance = { color = '#FFFFFF', showOnConsole = true, windowLocation = 'center' },
eventDefault = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, eventDefault = { color = '#FFFFFF', showOnConsole = true, windowLocation = 'bottom' },
statusDefault = { color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' }, statusDefault = { color = '#FFFFFF', showOnConsole = true, windowLocation = 'bottom' },
infoDesc = { color = '#00EB00', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' }, infoDescription = { color = '#00EB00', showOnConsole = true, windowLocation = 'center' },
statusSmall = { color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' }, statusSmall = { color = '#FFFFFF', showOnConsole = false, windowLocation = 'bottom' },
consoleOrange = { color = '#FE6500', showOnConsole = true, showOnWindow = false }, consoleOrange = { color = '#FE6500', showOnConsole = true },
consoleBlue = { color = '#9F9DFD', showOnConsole = true, showOnWindow = false }, consoleBlue = { color = '#9F9DFD', showOnConsole = true },
consoleRed = { color = '#F55E5E', showOnConsole = true, showOnWindow = false } consoleRed = { color = '#F55E5E', showOnConsole = true }
} }
local bottomLabelWidget local bottomLabelWidget
@ -23,21 +23,26 @@ local centerLabelHideEvent
-- private functions -- private functions
local function displayMessage(msgtype, msg, time) local function displayMessage(msgtype, msg, time)
if not Game.isOnline() then return end
if msgtype.showOnConsole then if msgtype.showOnConsole then
-- TODO -- TODO
end end
if msgtype.showOnWindow then if msgtype.windowLocation then
local label local label
if msgtype.windowLocation == 'BottomLabel' then local style
if msgtype.windowLocation == 'bottom' then
label = bottomLabelWidget label = bottomLabelWidget
elseif msgtype.windowLocation == 'CenterLabel' then style = 'BottomLabel'
elseif msgtype.windowLocation == 'center' then
label = centerLabelWidget label = centerLabelWidget
style = 'CenterLabel'
end end
label:setVisible(true) label:setVisible(true)
label:setText(msg) label:setText(msg)
label:setStyle(msgtype.windowLocation) label:setStyle(style)
label:setForegroundColor(msgtype.color) label:setForegroundColor(msgtype.color)
if not time then if not time then
@ -66,11 +71,9 @@ end
function TextMessage.display(msgtypedesc, msg) function TextMessage.display(msgtypedesc, msg)
local msgtype = MessageTypes[msgtypedesc] local msgtype = MessageTypes[msgtypedesc]
if msgtype == nil then if msgtype then
error('unknown text msg type ' .. msgtype)
return
end
displayMessage(msgtype, msg) displayMessage(msgtype, msg)
end
end end
-- hooked events -- hooked events

View File

@ -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) 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); StaticTextPtr staticText = StaticTextPtr(new StaticText);
staticText->addMessage(name, type, message); staticText->addMessage(name, type, message);
g_map.addThing(staticText, creaturePos); g_map.addThing(staticText, creaturePos);

View File

@ -228,7 +228,13 @@ namespace Proto {
SpeakPrivateRed, SpeakPrivateRed,
SpeakChannelOrange, SpeakChannelOrange,
SpeakMonsterSay, SpeakMonsterSay,
SpeakMonsterYell SpeakMonsterYell,
// removed
SpeakRVRChannel = 255,
SpeakRVRAnswer,
SpeakRVRContinue,
SpeakChannelRed2
#elif PROTOCOL==860 #elif PROTOCOL==860
SpeakSay = 1, SpeakSay = 1,
SpeakWhisper, SpeakWhisper,
@ -238,17 +244,15 @@ namespace Proto {
SpeakPrivate, SpeakPrivate,
SpeakChannelYellow, SpeakChannelYellow,
SpeakChannelWhite, SpeakChannelWhite,
SpeakReportChannel, SpeakRVRChannel,
SpeakReportAnswer, SpeakRVRAnswer,
SpeakReportContinue, SpeakRVRContinue,
SpeakBroadcast, SpeakBroadcast,
SpeakChannelRed, SpeakChannelRed,
SpeakPrivateRed, SpeakPrivateRed,
SpeakChannelOrange, SpeakChannelOrange,
SpeakUnk1, SpeakChannelRed2 = 17,
SpeakUnk2, SpeakMonsterSay = 19,
SpeakUnk3,
SpeakMonsterSay,
SpeakMonsterYell SpeakMonsterYell
#endif #endif
}; };
@ -256,18 +260,18 @@ namespace Proto {
enum MessageTypes { enum MessageTypes {
#if PROTOCOL==860 #if PROTOCOL==860
MessageConsoleRed = 18, MessageConsoleRed = 18,
MessageConsoleOrange1, MessageEventOrange,
MessageConsoleOrange2, MessageConsoleOrange,
MessageWarning, MessageWarning,
MessageEventAdvance, MessageEventAdvance,
MessageEventDefault, MessageEventDefault,
MessageStatusDefault, MessageStatusDefault,
MessageInfoDescription, MessageInfoDescription ,
MessageStatusSmall, MessageStatusSmall,
MessageConsoleBlue MessageConsoleBlue
#elif PROTOCOL==862 #elif PROTOCOL==862
MessageConsoleOrange1 = 12, MessageEventOrange = 12,
MessageConsoleOrange2, MessageConsoleOrange,
MessageWarning, MessageWarning,
MessageEventAdvance, MessageEventAdvance,
MessageEventDefault, MessageEventDefault,
@ -302,12 +306,12 @@ namespace Proto {
return "monsterYell"; return "monsterYell";
case Proto::SpeakPrivateNpcToPlayer: case Proto::SpeakPrivateNpcToPlayer:
return "npcToPlayer"; return "npcToPlayer";
break;
case Proto::SpeakChannelYellow: case Proto::SpeakChannelYellow:
return "channelYellow"; return "channelYellow";
case Proto::SpeakChannelWhite: case Proto::SpeakChannelWhite:
return "channelWhite"; return "channelWhite";
case Proto::SpeakChannelRed: case Proto::SpeakChannelRed:
case Proto::SpeakChannelRed2:
return "channelRed"; return "channelRed";
case Proto::SpeakChannelOrange: case Proto::SpeakChannelOrange:
return "channelOrange"; return "channelOrange";
@ -320,18 +324,17 @@ namespace Proto {
case Proto::SpeakPrivateRed: case Proto::SpeakPrivateRed:
return "privateRed"; return "privateRed";
default: default:
logError("unknown protocol speak type ", type);
return "unknown"; return "unknown";
} }
} }
inline std::string translateMessageType(int type) { inline std::string translateTextMessageType(int type) {
switch(type) { switch(type) {
case Proto::MessageConsoleRed: case Proto::MessageConsoleOrange:
return "consoleRed";
case Proto::MessageConsoleOrange1:
return "consoleOrange";
case Proto::MessageConsoleOrange2:
return "consoleOrange"; return "consoleOrange";
case Proto::MessageEventOrange:
return "eventOrange";
case Proto::MessageWarning: case Proto::MessageWarning:
return "warning"; return "warning";
case Proto::MessageEventAdvance: case Proto::MessageEventAdvance:
@ -346,7 +349,10 @@ namespace Proto {
return "statusSmall"; return "statusSmall";
case Proto::MessageConsoleBlue: case Proto::MessageConsoleBlue:
return "consoleBlue"; return "consoleBlue";
case Proto::MessageConsoleRed:
return "consoleRed";
default: default:
logError("unknown protocol text message type ", type);
return "unknown"; return "unknown";
} }
} }

View File

@ -755,9 +755,7 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
case Proto::SpeakChannelYellow: case Proto::SpeakChannelYellow:
case Proto::SpeakChannelWhite: case Proto::SpeakChannelWhite:
case Proto::SpeakChannelRed: case Proto::SpeakChannelRed:
#if PROTOCOL==860 case Proto::SpeakChannelRed2:
case Proto::SpeakUnk2:
#endif
case Proto::SpeakChannelOrange: case Proto::SpeakChannelOrange:
channelId = msg.getU16(); channelId = msg.getU16();
break; break;
@ -766,11 +764,9 @@ void ProtocolGame::parseCreatureSpeak(InputMessage& msg)
case Proto::SpeakBroadcast: case Proto::SpeakBroadcast:
case Proto::SpeakPrivateRed: case Proto::SpeakPrivateRed:
break; break;
#if PROTOCOL==860 case Proto::SpeakRVRChannel:
case Proto::SpeakReportChannel:
msg.getU32(); msg.getU32();
break; break;
#endif
default: default:
logTraceError("unknown speak type ", type); logTraceError("unknown speak type ", type);
break; break;
@ -834,7 +830,7 @@ void ProtocolGame::parseTextMessage(InputMessage& msg)
{ {
uint8 type = msg.getU8(); uint8 type = msg.getU8();
std::string typeDesc = Proto::translateMessageType(type); std::string typeDesc = Proto::translateTextMessageType(type);
std::string message = msg.getString(); std::string message = msg.getString();
g_dispatcher.addEvent(std::bind(&Game::processTextMessage, &g_game, typeDesc, message)); g_dispatcher.addEvent(std::bind(&Game::processTextMessage, &g_game, typeDesc, message));

View File

@ -96,7 +96,6 @@ bool UIMap::onMousePress(const Point& mousePos, Fw::MouseButton button)
EffectPtr effect = EffectPtr(new Effect); EffectPtr effect = EffectPtr(new Effect);
static int id = 0; static int id = 0;
effect->setId(id++); effect->setId(id++);
dump << id;
g_map.addThing(effect, tilePos); g_map.addThing(effect, tilePos);
} }
else if(button == Fw::MouseRightButton) { else if(button == Fw::MouseRightButton) {