Browse Source

Multiprotocol 8.1-9.6 finally working

Still have many minor issues, tests are needed
No recompilation needed anymore
9.60 messages is not fully implemented
Eduardo Bart 8 years ago
parent
commit
36c029fc69

+ 1
- 1
modules/client/client.lua View File

@@ -5,7 +5,7 @@ function Client.reloadScripts()
5 5
   dofile '/otclientrc'
6 6
   local message = tr('All modules and scripts were reloaded.')
7 7
 
8
-  modules.game_textmessage.displayEventAdvance(message)
8
+  modules.game_textmessage.displayGameMessage(message)
9 9
   print(message)
10 10
 end
11 11
 

+ 0
- 22
modules/corelib/const.lua View File

@@ -171,28 +171,6 @@ KeyNumpad7 = 148
171 171
 KeyNumpad8 = 149
172 172
 KeyNumpad9 = 150
173 173
 
174
-SpeakSay = 1
175
-SpeakWhisper = 2
176
-SpeakYell = 3
177
-SpeakBroadcast = 4
178
-SpeakPrivate = 5
179
-SpeakPrivateRed = 6
180
-SpeakPrivatePlayerToNpc = 7
181
-SpeakPrivateNpcToPlayer = 8
182
-SpeakChannelYellow = 9
183
-SpeakChannelWhite = 10
184
-SpeakChannelRed = 11
185
-SpeakChannelOrange = 12
186
-SpeakMonsterSay = 13
187
-SpeakMonsterYell = 14
188
-
189
-FightOffensive = 1
190
-FightBalanced = 2
191
-FightDefensive = 3
192
-
193
-DontChase = 0
194
-ChaseOpponent = 1
195
-
196 174
 ExtendedActivate = 0
197 175
 ExtendedLocales = 1
198 176
 ExtendedParticles = 2

+ 4
- 1
modules/game_battle/battle.lua View File

@@ -32,6 +32,7 @@ table.insert(LifeBarColors, {percentAbove = 3, color = '#3C0000' } )
32 32
 table.insert(LifeBarColors, {percentAbove = -1, color = '#4F0000' } )
33 33
 
34 34
 function init()
35
+  g_ui.importStyle('battlebutton.otui')
35 36
   battleWindow = g_ui.loadUI('battle.otui', modules.game_interface.getRightPanel())
36 37
   battleButton = TopMenu.addRightGameToggleButton('battleButton', tr('Battle') .. ' (Ctrl+B)', 'battle.png', toggle)
37 38
   battleButton:setOn(true)
@@ -173,10 +174,12 @@ function addCreature(creature)
173 174
   local creatureId = creature:getId()
174 175
 
175 176
   if battleButtonsByCreaturesList[creatureId] == nil then
176
-    local battleButton = g_ui.loadUI('battlebutton.otui', battlePanel)
177
+    local battleButton = g_ui.createWidget('BattleButton', battlePanel)
177 178
     local creatureWidget = battleButton:getChildById('creature')
178 179
     local labelWidget = battleButton:getChildById('label')
179 180
     local lifeBarWidget = battleButton:getChildById('lifeBar')
181
+    battleButton.onHoverChange = onbattleButtonHoverChange
182
+    battleButton.onMouseRelease = onMouseRelease
180 183
 
181 184
     battleButton:setId('BattleButton_' .. creature:getName():gsub('%s','_'))
182 185
     battleButton.creatureId = creatureId

+ 0
- 4
modules/game_battle/battlebutton.otui View File

@@ -1,11 +1,7 @@
1 1
 BattleButton < UIButton
2
-
3
-BattleButton
4 2
   height: 20
5 3
   margin-top: 5
6 4
   fixed-size: true
7
-  &onHoverChange: onbattleButtonHoverChange
8
-  &onMouseRelease: onMouseRelease
9 5
   &isBattleButton: true
10 6
 
11 7
   UICreature

+ 1
- 1
modules/game_bugreport/bugreport.lua View File

@@ -22,7 +22,7 @@ end
22 22
 function doReport()
23 23
   g_game.reportBug(bugTextEdit:getText())
24 24
   bugReportWindow:hide()
25
-  modules.game_textmessage.displayEventAdvance(tr('Bug report sent.'))
25
+  modules.game_textmessage.displayGameMessage(tr('Bug report sent.'))
26 26
 end
27 27
 
28 28
 function show()

+ 36
- 41
modules/game_console/console.lua View File

@@ -1,36 +1,36 @@
1 1
 SpeakTypesSettings = {
2
-  say = { speakType = SpeakSay, color = '#FFFF00' },
3
-  whisper = { speakType = SpeakWhisper, color = '#FFFF00' },
4
-  yell = { speakType = SpeakYell, color = '#FFFF00' },
5
-  broadcast = { speakType = SpeakBroadcast, color = '#F55E5E' },
6
-  private = { speakType = SpeakPrivate, color = '#5FF7F7', private = true },
7
-  privateRed = { speakType = SpeakPrivateRed, color = '#F55E5E', private = true },
8
-  privatePlayerToPlayer = { speakType = SpeakPrivate, color = '#9F9DFD', private = true },
9
-  privatePlayerToNpc = { speakType = SpeakPrivatePlayerToNpc, color = '#9F9DFD', private = true, npcChat = true },
10
-  privateNpcToPlayer = { speakType = SpeakPrivateNpcToPlayer, color = '#5FF7F7', private = true, npcChat = true },
11
-  channelYellow = { speakType = SpeakChannelYellow, color = '#FFFF00' },
12
-  channelWhite = { speakType = SpeakChannelWhite, color = '#FFFFFF' },
13
-  channelRed = { speakType = SpeakChannelRed, color = '#F55E5E' },
14
-  channelOrange = { speakType = SpeakChannelOrange, color = '#FE6500' },
15
-  monsterSay = { speakType = SpeakMonsterSay, color = '#FE6500', hideInConsole = true},
16
-  monsterYell = { speakType = SpeakMonsterYell, color = '#FE6500', hideInConsole = true},
2
+  say = { speakType = MessageModes.Say, color = '#FFFF00' },
3
+  whisper = { speakType = MessageModes.Whisper, color = '#FFFF00' },
4
+  yell = { speakType = MessageModes.Yell, color = '#FFFF00' },
5
+  broadcast = { speakType = MessageModes.GamemasterPrivateFrom, color = '#F55E5E' },
6
+  private = { speakType = MessageModes.PrivateTo, color = '#5FF7F7', private = true },
7
+  privateRed = { speakType = MessageModes.GamemasterTo, color = '#F55E5E', private = true },
8
+  privatePlayerToPlayer = { speakType = MessageModes.PrivateTo, color = '#9F9DFD', private = true },
9
+  privatePlayerToNpc = { speakType = MessageModes.NpcTo, color = '#9F9DFD', private = true, npcChat = true },
10
+  privateNpcToPlayer = { speakType = MessageModes.NpcFrom, color = '#5FF7F7', private = true, npcChat = true },
11
+  channelYellow = { speakType = MessageModes.Channel, color = '#FFFF00' },
12
+  channelWhite = { speakType = MessageModes.ChannelManagement, color = '#FFFFFF' },
13
+  channelRed = { speakType = MessageModes.GamemasterChannel, color = '#F55E5E' },
14
+  channelOrange = { speakType = MessageModes.ChannelHighlight, color = '#FE6500' },
15
+  monsterSay = { speakType = MessageModes.MonsterSay, color = '#FE6500', hideInConsole = true},
16
+  monsterYell = { speakType = MessageModes.MonsterYell, color = '#FE6500', hideInConsole = true},
17 17
 }
18 18
 
19 19
 SpeakTypes = {
20
-  [SpeakSay] = SpeakTypesSettings.say,
21
-  [SpeakWhisper] = SpeakTypesSettings.whisper,
22
-  [SpeakYell] = SpeakTypesSettings.yell,
23
-  [SpeakBroadcast] = SpeakTypesSettings.broadcast,
24
-  [SpeakPrivate] = SpeakTypesSettings.private,
25
-  [SpeakPrivateRed] = SpeakTypesSettings.privateRed,
26
-  [SpeakPrivatePlayerToNpc] = SpeakTypesSettings.privatePlayerToNpc,
27
-  [SpeakPrivateNpcToPlayer] = SpeakTypesSettings.privateNpcToPlayer,
28
-  [SpeakChannelYellow] = SpeakTypesSettings.channelYellow,
29
-  [SpeakChannelWhite] = SpeakTypesSettings.channelWhite,
30
-  [SpeakChannelRed] = SpeakTypesSettings.channelRed,
31
-  [SpeakChannelOrange] = SpeakTypesSettings.channelOrange,
32
-  [SpeakMonsterSay] = SpeakTypesSettings.monsterSay,
33
-  [SpeakMonsterYell] = SpeakTypesSettings.monsterYell,
20
+  [MessageModes.Say] = SpeakTypesSettings.say,
21
+  [MessageModes.Whisper] = SpeakTypesSettings.whisper,
22
+  [MessageModes.Yell] = SpeakTypesSettings.yell,
23
+  [MessageModes.GamemasterPrivateFrom] = SpeakTypesSettings.broadcast,
24
+  [MessageModes.PrivateFrom] = SpeakTypesSettings.private,
25
+  [MessageModes.GamemasterPrivateFrom] = SpeakTypesSettings.privateRed,
26
+  [MessageModes.NpcTo] = SpeakTypesSettings.privatePlayerToNpc,
27
+  [MessageModes.NpcFrom] = SpeakTypesSettings.privateNpcToPlayer,
28
+  [MessageModes.Channel] = SpeakTypesSettings.channelYellow,
29
+  [MessageModes.ChannelManagement] = SpeakTypesSettings.channelWhite,
30
+  [MessageModes.GamemasterChannel] = SpeakTypesSettings.channelRed,
31
+  [MessageModes.ChannelHighlight] = SpeakTypesSettings.channelOrange,
32
+  [MessageModes.MonsterSay] = SpeakTypesSettings.monsterSay,
33
+  [MessageModes.MonsterYell] = SpeakTypesSettings.monsterYell,
34 34
 }
35 35
 
36 36
 SayModes = {
@@ -56,7 +56,7 @@ ignoreNpcMessages = false
56 56
 
57 57
 
58 58
 function init()
59
-  connect(g_game, { onCreatureSpeak = onCreatureSpeak,
59
+  connect(g_game, { onTalk = onTalk,
60 60
                     onChannelList = onChannelList,
61 61
                     onOpenChannel = onOpenChannel,
62 62
                     onOpenPrivateChannel = onOpenPrivateChannel,
@@ -94,7 +94,7 @@ function init()
94 94
 end
95 95
 
96 96
 function terminate()
97
-  disconnect(g_game, { onCreatureSpeak = onCreatureSpeak,
97
+  disconnect(g_game, { onTalk = onTalk,
98 98
                        onChannelList = onChannelList,
99 99
                        onOpenChannel = onOpenChannel,
100 100
                        onOpenPrivateChannel = onOpenPrivateChannel,
@@ -239,7 +239,7 @@ end
239 239
 
240 240
 function addPrivateText(text, speaktype, name, isPrivateCommand, creatureName)
241 241
   local focus = false
242
-  if speaktype.speakType == SpeakPrivateNpcToPlayer then
242
+  if speaktype.speakType == SpeakNpcFrom then
243 243
     name = 'NPCs'
244 244
     focus = true
245 245
   end
@@ -301,9 +301,9 @@ function popupMenu(mousePos, mouseButton, creatureName, text)
301 301
       --TODO select all
302 302
       menu:addOption(tr('Copy message'), function () g_window.setClipboardText(text) end)
303 303
 
304
-      if RuleViolation.hasWindowAccess() then
304
+      if modules.game_ruleviolation.hasWindowAccess() then
305 305
         menu:addSeparator()
306
-        menu:addOption(tr('Rule Violation'), function() RuleViolation.show(creatureName, text:match('.+%:%s(.+)')) end)
306
+        menu:addOption(tr('Rule Violation'), function() modules.game_ruleviolation.show(creatureName, text:match('.+%:%s(.+)')) end)
307 307
       end
308 308
 
309 309
       menu:addSeparator()
@@ -448,8 +448,8 @@ function applyMessagePrefixies(name, level, message)
448 448
   return message
449 449
 end
450 450
 
451
-function onCreatureSpeak(name, level, speaktype, message, channelId, creaturePos)
452
-  if ignoreNpcMessages and speaktype == SpeakPrivateNpcToPlayer then return end
451
+function onTalk(name, level, speaktype, message, channelId, creaturePos)
452
+  if ignoreNpcMessages and speaktype == SpeakNpcFrom then return end
453 453
   local defaultMessage = speaktype < 3 and true or false
454 454
   speaktype = SpeakTypes[speaktype]
455 455
   if speaktype.hideInConsole then return end
@@ -458,11 +458,6 @@ function onCreatureSpeak(name, level, speaktype, message, channelId, creaturePos
458 458
 
459 459
   if speaktype.private then
460 460
     addPrivateText(composedMessage, speaktype, name, false, name)
461
-    if Options.getOption('showPrivateMessagesOnScreen') then
462
-      if(speaktype.speakType ~= SpeakPrivateNpcToPlayer) then
463
-        TextMessage.displayPrivate(name .. ':\n' .. message)
464
-      end
465
-    end
466 461
   else
467 462
     local channel = tr('Default')
468 463
     if not defaultMessage then

+ 3
- 3
modules/game_interface/gameinterface.lua View File

@@ -347,9 +347,9 @@ function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
347 347
       end
348 348
     end
349 349
 
350
-    if RuleViolation.hasWindowAccess() then
350
+    if modules.game_ruleviolation.hasWindowAccess() then
351 351
       menu:addSeparator()
352
-      menu:addOption(tr('Rule Violation'), function() RuleViolation.show(creatureThing:getName()) end)
352
+      menu:addOption(tr('Rule Violation'), function() modules.game_ruleviolation.show(creatureThing:getName()) end)
353 353
     end
354 354
 
355 355
     menu:addSeparator()
@@ -430,7 +430,7 @@ function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, u
430 430
   if autoWalkPos and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
431 431
     local dirs = g_map.findPath(g_game.getLocalPlayer():getPosition(), autoWalkPos, 127)
432 432
     if #dirs == 0 then
433
-      modules.game_textmessage.displayStatus(tr('There is no way.'))
433
+      modules.game_textmessage.displayStatusMessage(tr('There is no way.'))
434 434
       return true
435 435
     end
436 436
     g_game.autoWalk(dirs)

+ 1
- 1
modules/game_minimap/minimap.lua View File

@@ -146,7 +146,7 @@ function onMinimapMouseRelease(self, mousePosition, mouseButton)
146 146
   if tile and mouseButton == MouseLeftButton and self:isPressed() then
147 147
     local dirs = g_map.findPath(g_game.getLocalPlayer():getPosition(), tile:getPosition(), 127)
148 148
     if #dirs == 0 then
149
-      modules.game_textmessage.displayStatus(tr('There is no way.'))
149
+      modules.game_textmessage.displayStatusMessage(tr('There is no way.'))
150 150
       return true
151 151
     end
152 152
     g_game.autoWalk(dirs)

+ 1
- 1
modules/game_playerdeath/playerdeath.lua View File

@@ -32,7 +32,7 @@ function displayDeadMessage()
32 32
     return
33 33
   end
34 34
 
35
-  modules.game_textmessage.displayEventAdvance(tr('You are dead.'))
35
+  modules.game_textmessage.displayGameMessage(tr('You are dead.'))
36 36
 end
37 37
 
38 38
 function openWindow()

+ 0
- 60
modules/game_textmessage/protocol.lua View File

@@ -1,60 +0,0 @@
1
-function getMessageTypes(version)
2
-  if version >= 960 then
3
-    perror("TODO: message types for 9.6")
4
-    return {}
5
-  elseif version >= 861 then
6
-    return {
7
-      [13] = 'ConsoleOrange',
8
-      [14] = 'ConsoleOrange',
9
-      [15] = 'Warning',
10
-      [16] = 'EventAdvance',
11
-      [17] = 'EventDefault',
12
-      [18] = 'StatusDefault',
13
-      [19] = 'Info',
14
-      [20] = 'StatusSmall',
15
-      [21] = 'ConsoleBlue',
16
-      [22] = 'ConsoleRed'
17
-    }
18
-  elseif version >= 854 then
19
-    return {
20
-      [18] = 'ConsoleRed',
21
-      [19] = 'ConsoleOrange',
22
-      [20] = 'ConsoleOrange',
23
-      [21] = 'Warning',
24
-      [22] = 'EventAdvance',
25
-      [23] = 'EventDefault',
26
-      [24] = 'StatusDefault',
27
-      [25] = 'Info',
28
-      [26] = 'StatusSmall',
29
-      [27] = 'ConsoleBlue'
30
-    }
31
-  else
32
-    return {
33
-      [18] = 'Warning',
34
-      [19] = 'EventAdvance',
35
-      [20] = 'EventDefault',
36
-      [21] = 'StatusDefault',
37
-      [22] = 'Info',
38
-      [23] = 'StatusSmall',
39
-      [24] = 'ConsoleBlue',
40
-      [25] = 'ConsoleRed',
41
-      [26] = 'ConsoleOrange',
42
-      [27] = 'ConsoleOrange',
43
-    }
44
-   end
45
-end
46
-
47
-function parseTextMessage(msg)
48
-  local msgtype = msg:getU8()
49
-  local text = msg:getString()
50
-  msgtype = getMessageTypes(g_game.getClientVersion())[msgtype]
51
-  signalcall(g_game.onTextMessage, msgtype, text)
52
-end
53
-
54
-function registerProtocol()
55
-  ProtocolGame.registerOpcode(GameServerOpcodes.GameServerTextMessage, parseTextMessage)
56
-end
57
-
58
-function unregisterProtocol()
59
-  ProtocolGame.unregisterOpcode(GameServerOpcodes.GameServerTextMessage)
60
-end

+ 69
- 88
modules/game_textmessage/textmessage.lua View File

@@ -1,115 +1,96 @@
1
+MessageSettings = {
2
+  consoleRed      = { color = TextColors.red,    consoleTab='Default' },
3
+  consoleOrange   = { color = TextColors.orange, consoleTab='Default' },
4
+  consoleBlue     = { color = TextColors.blue,   consoleTab='Default' },
5
+  centerRed       = { color = TextColors.red,    consoleTab='Server Log', screenTarget='lowCenterLabel' },
6
+  centerGreen     = { color = TextColors.green,  consoleTab='Server Log', screenTarget='highCenterLabel',   consoleOption='showInfoMessagesInConsole' },
7
+  centerWhite     = { color = TextColors.white,  consoleTab='Server Log', screenTarget='middleCenterLabel', consoleOption='showEventMessagesInConsole' },
8
+  bottomWhite     = { color = TextColors.white,  consoleTab='Server Log', screenTarget='statusLabel',       consoleOption='showEventMessagesInConsole' },
9
+  status          = { color = TextColors.white,  consoleTab='Server Log', screenTarget='statusLabel',       consoleOption='showStatusMessagesInConsole' },
10
+  statusSmall     = { color = TextColors.white,                           screenTarget='statusLabel' },
11
+  private         = { color = TextColors.lightblue,                       screenTarget='privateLabel' }
12
+}
13
+
1 14
 MessageTypes = {
2
-  ConsoleRed      = { color = '#F55E5E', consoleTab = tr('Default') },
3
-  ConsoleOrange   = { color = '#FE6500', consoleTab = tr('Default') },
4
-  ConsoleBlue     = { color = '#9F9DFD', consoleTab = tr('Default') },
5
-  Warning         = { color = '#F55E5E', consoleTab = tr('Server Log'), labelId = 'warningLabel' },
6
-  Info            = { color = '#00EB00', consoleTab = tr('Server Log'), labelId = 'infoLabel', consoleOption = 'showInfoMessagesInConsole' },
7
-  EventAdvance    = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'advanceLabel', consoleOption = 'showEventMessagesInConsole' },
8
-  EventDefault    = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'statusLabel', consoleOption = 'showEventMessagesInConsole' },
9
-  StatusDefault   = { color = '#FFFFFF', consoleTab = tr('Server Log'), labelId = 'statusLabel', consoleOption = 'showStatusMessagesInConsole' },
10
-  StatusSmall     = { color = '#FFFFFF', labelId = 'statusLabel' },
11
-  Private         = { color = '#5FF7F7', labelId = 'privateLabel' }
15
+  [MessageModes.MonsterSay] = MessageSettings.orange,
16
+  [MessageModes.MonsterYell] = MessageSettings.orange,
17
+  [MessageModes.Failure] = MessageSettings.statusSmall,
18
+  [MessageModes.Login] = MessageSettings.bottomWhite,
19
+  [MessageModes.Game] = MessageSettings.centerWhite,
20
+  [MessageModes.Status] = MessageSettings.status,
21
+  [MessageModes.Warning] = MessageSettings.centerRed,
22
+  [MessageModes.Look] = MessageSettings.centerGreen,
23
+  [MessageModes.Loot] = MessageSettings.centerGreen,
24
+  [MessageModes.Red] = MessageSettings.consoleRed,
25
+  [MessageModes.Blue] = MessageSettings.consoleBlue,
26
+  [MessageModes.PrivateFrom] = MessageSettings.private
12 27
 }
13 28
 
14
-centerTextMessagePanel = nil
15
-statusLabel = nil
16
-privateLabel = nil
17
-warningLabel = nil
18
-advanceLabel = nil
19
-infoLabel = nil
29
+messagesPanel = nil
20 30
 
21 31
 function init()
22
-  connect(g_game, {
23
-    onTextMessage = displayMessage,
24
-    onGameStart = clearMessages
25
-  })
26
-  registerProtocol()
27
-
28
-  g_ui.importStyle('textmessage.otui')
29
-  centerTextMessagePanel = g_ui.createWidget('Panel', modules.game_interface.getMapPanel())
30
-  centerTextMessagePanel:setId('centerTextMessagePanel')
31
-
32
-  local layout = UIVerticalLayout.create(centerTextMessagePanel)
33
-  layout:setFitChildren(true)
34
-  centerTextMessagePanel:setLayout(layout)
35
-  centerTextMessagePanel:setWidth(360)
36
-  centerTextMessagePanel:centerIn('parent')
37
-
38
-  warningLabel = createTextMessageLabel('warningLabel', centerTextMessagePanel, 'CenterLabel')
39
-  advanceLabel = createTextMessageLabel('advanceLabel', centerTextMessagePanel, 'CenterLabel')
40
-  infoLabel = createTextMessageLabel('infoLabel', centerTextMessagePanel, 'CenterLabel')
41
-  privateLabel = createTextMessageLabel('privateLabel', modules.game_interface.getMapPanel(), 'TopCenterLabel')
42
-  statusLabel = createTextMessageLabel('statusLabel', modules.game_interface.getMapPanel(), 'BottomLabel')
32
+  connect(g_game, 'onTextMessage', displayMessage)
33
+  connect(g_game, 'onPrivateTalk', onPrivateTalk)
34
+  connect(g_game, 'onGameEnd', clearMessages)
35
+  messagesPanel = g_ui.loadUI('textmessage.otui', modules.game_interface.getRootPanel())
43 36
 end
44 37
 
45 38
 function terminate()
46
-  disconnect(g_game, {
47
-    onTextMessage = display,
48
-    onGameStart = clearMessages
49
-  })
50
-  unregisterProtocol()
51
-
52
-  removeEvent(warningLabel.hideEvent)
53
-  removeEvent(advanceLabel.hideEvent)
54
-  removeEvent(infoLabel.hideEvent)
55
-  removeEvent(privateLabel.hideEvent)
56
-  removeEvent(statusLabel.hideEvent)
57
-
58
-  centerTextMessagePanel:destroy()
59
-  statusLabel:destroy()
60
-  privateLabel:destroy()
39
+  disconnect(g_game, 'onTextMessage', displayMessage)
40
+  disconnect(g_game, 'onPrivateTalk', onPrivateTalk)
41
+  disconnect(g_game, 'onGameEnd',clearMessages)
42
+  clearMessages()
43
+  messagesPanel:destroy()
61 44
 end
62 45
 
63
-function clearMessages()
64
-  warningLabel:hide()
65
-  advanceLabel:hide()
66
-  infoLabel:hide()
67
-  privateLabel:hide()
68
-  statusLabel:hide()
46
+function calculateVisibleTime(text)
47
+  return math.max(#text * 100, 4000)
69 48
 end
70 49
 
71
-function createTextMessageLabel(id, parent, class)
72
-  local label = g_ui.createWidget(class, parent)
73
-  label:setFont('verdana-11px-rounded')
74
-  label:setId(id)
75
-  return label
76
-end
77
-
78
-function displayMessage(msgtype, msg, time)
50
+function displayMessage(mode, text)
79 51
   if not g_game.isOnline() then return end
80
-  msgtype = MessageTypes[msgtype]
81 52
 
82
-  if msgtype.consoleTab ~= nil then
83
-    if msgtype.consoleOption == nil or Options.getOption(msgtype.consoleOption) then
84
-      modules.game_console.addText(msg, msgtype, msgtype.consoleTab)
85
-    end
53
+  local msgtype = MessageTypes[mode]
54
+
55
+  if not msgtype then
56
+    perror('unhandled message mode ' .. mode)
57
+    return
86 58
   end
87 59
 
88
-  if msgtype.labelId then
89
-    local label = modules.game_interface.getMapPanel():recursiveGetChildById(msgtype.labelId)
60
+  if msgtype.consoleTab ~= nil and (msgtype.consoleOption == nil or Options.getOption(msgtype.consoleOption)) then
61
+    modules.game_console.addText(text, msgtype, tr(msgtype.consoleTab))
62
+    --TODO move to game_console
63
+  end
90 64
 
91
-    label:setText(msg)
65
+  if msgtype.screenTarget then
66
+    local label = messagesPanel:recursiveGetChildById(msgtype.screenTarget)
67
+    label:setText(text)
92 68
     label:setColor(msgtype.color)
93
-
94
-    if not time then
95
-      time = math.max(#msg * 100, 4000)
96
-    else
97
-      time = time * 1000
98
-    end
69
+    label:setVisible(true)
99 70
     removeEvent(label.hideEvent)
100
-    addEvent(function() label:setVisible(true) end)
101
-    label.hideEvent = scheduleEvent(function() label:setVisible(false) end, time)
71
+    label.hideEvent = scheduleEvent(function() label:setVisible(false) end, calculateVisibleTime(text))
102 72
   end
103 73
 end
104 74
 
105
-function displayStatus(msg, time)
106
-  displayMessage('StatusSmall', msg)
75
+function displayStatusMessage(text)
76
+  displayMessage(MessageModes.Status, text)
77
+end
78
+
79
+function displayGameMessage(text)
80
+  displayMessage(MessageModes.Game, text)
107 81
 end
108 82
 
109
-function displayEventAdvance(msg, time)
110
-  displayMessage('EventAdvance', msg, time)
83
+function clearMessages()
84
+  for _i,child in pairs(messagesPanel:recursiveGetChildren()) do
85
+    if child:getId():match('Label') then
86
+      child:hide()
87
+      removeEvent(child.hideEvent)
88
+    end
89
+  end
111 90
 end
112 91
 
113
-function displayPrivate(msg, time)
114
-  displayMessage('Private', time)
92
+function onPrivateTalk(code, text, speaker, speakerlevel, statmentid)
93
+  if Options.getOption('showPrivateMessagesOnScreen') then
94
+    displayMessage(code, speaker .. ':\n' .. text)
95
+  end
115 96
 end

+ 2
- 9
modules/game_textmessage/textmessage.otmod View File

@@ -4,13 +4,6 @@ Module
4 4
   author: edubart
5 5
   website: www.otclient.info
6 6
   sandboxed: true
7
-
8
-  dependencies:
9
-    - game_interface
10
-
11
-  scripts:
12
-    - protocol.lua
13
-    - textmessage.lua
14
-
7
+  scripts: [ textmessage.lua ]
15 8
   @onLoad: init()
16
-  @onUnload: terminate()
9
+  @onUnload: terminate()

+ 32
- 14
modules/game_textmessage/textmessage.otui View File

@@ -1,4 +1,4 @@
1
-CenterLabel < UILabel
1
+TextMessageLabel < UILabel
2 2
   font: verdana-11px-rounded
3 3
   text-align: center
4 4
   text-wrap: true
@@ -6,17 +6,35 @@ CenterLabel < UILabel
6 6
   margin-bottom: 2
7 7
   visible: false
8 8
 
9
-TopCenterLabel < UILabel
10
-  font: verdana-11px-rounded
11
-  text-align: center
12
-  text-wrap: true
13
-  visible: false
14
-  anchors.top: parent.top
15
-  anchors.bottom: centerTextMessagePanel.top
16
-  anchors.horizontalCenter: parent.horizontalCenter
17
-  width: 275
9
+Panel
10
+  anchors.fill: gameMapPanel
11
+  focusable: false
12
+
13
+  Panel
14
+    id: centerTextMessagePanel
15
+    layout:
16
+      type: verticalBox
17
+      fit-children: true
18
+    width: 360
19
+    anchors.centerIn: parent
20
+
21
+    TextMessageLabel
22
+      id: highCenterLabel
23
+    TextMessageLabel
24
+      id: middleCenterLabel
25
+    TextMessageLabel
26
+      id: lowCenterLabel
27
+
28
+  TextMessageLabel
29
+    id: privateLabel
30
+    anchors.top: parent.top
31
+    anchors.bottom: centerTextMessagePanel.top
32
+    anchors.horizontalCenter: parent.horizontalCenter
33
+    text-auto-resize: false
34
+    width: 275
18 35
 
19
-BottomLabel < CenterLabel
20
-  anchors.bottom: parent.bottom
21
-  anchors.left: parent.left
22
-  anchors.right: parent.right
36
+  TextMessageLabel
37
+    id: statusLabel
38
+    anchors.bottom: parent.bottom
39
+    anchors.left: parent.left
40
+    anchors.right: parent.right

+ 73
- 0
modules/gamelib/const.lua View File

@@ -34,6 +34,13 @@ SouthEast = 5
34 34
 SouthWest = 6
35 35
 NorthWest = 7
36 36
 
37
+FightOffensive = 1
38
+FightBalanced = 2
39
+FightDefensive = 3
40
+
41
+DontChase = 0
42
+ChaseOpponent = 1
43
+
37 44
 GameExtendedOpcode = 0
38 45
 GameProtocolChecksum = 1
39 46
 GameAccountNames = 2
@@ -59,6 +66,72 @@ GameReverseCreatureStack = 21
59 66
 GameMagicEffectU16 = 22
60 67
 GamePlayerMarket = 23
61 68
 
69
+TextColors = {
70
+  red       = '#f55e5e', --'#c83200'
71
+  orange    = '#f36500', --'#c87832'
72
+  yellow    = '#ffff00', --'#e6c832'
73
+  green     = '#00EB00', --'#3fbe32'
74
+  lightblue = '#5ff7f7',
75
+  --blue1     = '#6e50dc',
76
+  --blue2     = '#3264c8',
77
+  --blue3     = '#0096c8',
78
+  white     = '#ffffff' --'#bebebe'
79
+}
80
+
81
+MessageModes = {
82
+  None                    = 0,
83
+  Say                     = 1,
84
+  Whisper                 = 2,
85
+  Yell                    = 3,
86
+  PrivateFrom             = 4,
87
+  PrivateTo               = 5,
88
+  ChannelManagement       = 6,
89
+  Channel                 = 7,
90
+  ChannelHighlight        = 8,
91
+  Spell                   = 9,
92
+  NpcFrom                 = 10,
93
+  NpcTo                   = 11,
94
+  GamemasterBroadcast     = 12,
95
+  GamemasterChannel       = 13,
96
+  GamemasterPrivateFrom   = 14,
97
+  GamemasterPrivateTo     = 15,
98
+  Login                   = 16,
99
+  Warning                 = 17,
100
+  Game                    = 18,
101
+  Failure                 = 19,
102
+  Look                    = 20,
103
+  DamageDealed            = 21,
104
+  DamageReceived          = 22,
105
+  Heal                    = 23,
106
+  Exp                     = 24,
107
+  DamageOthers            = 25,
108
+  HealOthers              = 26,
109
+  ExpOthers               = 27,
110
+  Status                  = 28,
111
+  Loot                    = 29,
112
+  TradeNpc                = 30,
113
+  Guild                   = 31,
114
+  PartyManagement         = 32,
115
+  Party                   = 33,
116
+  BarkLow                 = 34,
117
+  BarkLoud                = 35,
118
+  Report                  = 36,
119
+  HotkeyUse               = 37,
120
+  TutorialHint            = 38,
121
+  Thankyou                = 39,
122
+  Market                  = 40,
123
+  BeyondLast              = 41,
124
+  MonsterYell             = 42,
125
+  MonsterSay              = 43,
126
+  Red                     = 44,
127
+  Blue                    = 45,
128
+  RVRChannel              = 46,
129
+  RVRAnswer               = 47,
130
+  RVRContinue             = 48,
131
+  Last                    = 49,
132
+  Invalid                 = 255
133
+}
134
+
62 135
 OTSERV_RSA  = "1091201329673994292788609605089955415282375029027981291234687579" ..
63 136
               "3726629149257644633073969600111060390723088861007265581882535850" ..
64 137
               "3429057592827629436413108566029093628212635953836686562675849720" ..

+ 1
- 0
src/otclient/CMakeLists.txt View File

@@ -87,6 +87,7 @@ set(otclient_SOURCES ${otclient_SOURCES}
87 87
     ${CMAKE_CURRENT_LIST_DIR}/luavaluecasts.h
88 88
 
89 89
     # net
90
+    ${CMAKE_CURRENT_LIST_DIR}/protocolcodes.cpp
90 91
     ${CMAKE_CURRENT_LIST_DIR}/protocolcodes.h
91 92
     ${CMAKE_CURRENT_LIST_DIR}/protocolgame.cpp
92 93
     ${CMAKE_CURRENT_LIST_DIR}/protocolgame.h

+ 54
- 15
src/otclient/const.h View File

@@ -255,21 +255,60 @@ namespace Otc
255 255
         IconPz = 16384
256 256
     };
257 257
 
258
-    enum SpeakType {
259
-        SpeakSay = 1,
260
-        SpeakWhisper,
261
-        SpeakYell,
262
-        SpeakBroadcast,
263
-        SpeakPrivate,
264
-        SpeakPrivateRed,
265
-        SpeakPrivatePlayerToNpc,
266
-        SpeakPrivateNpcToPlayer,
267
-        SpeakChannelYellow,
268
-        SpeakChannelWhite,
269
-        SpeakChannelRed,
270
-        SpeakChannelOrange,
271
-        SpeakMonsterSay,
272
-        SpeakMonsterYell
258
+    enum MessageMode {
259
+        MessageNone                    = 0,
260
+        MessageSay                     = 1,
261
+        MessageWhisper                 = 2,
262
+        MessageYell                    = 3,
263
+        MessagePrivateFrom             = 4,
264
+        MessagePrivateTo               = 5,
265
+        MessageChannelManagement       = 6,
266
+        MessageChannel                 = 7,
267
+        MessageChannelHighlight        = 8,
268
+        MessageSpell                   = 9,
269
+        MessageNpcFrom                 = 10,
270
+        MessageNpcTo                   = 11,
271
+        MessageGamemasterBroadcast     = 12,
272
+        MessageGamemasterChannel       = 13,
273
+        MessageGamemasterPrivateFrom   = 14,
274
+        MessageGamemasterPrivateTo     = 15,
275
+        MessageLogin                   = 16,
276
+        MessageWarning                 = 17,
277
+        MessageGame                    = 18,
278
+        MessageFailure                 = 19,
279
+        MessageLook                    = 20,
280
+        MessageDamageDealed            = 21,
281
+        MessageDamageReceived          = 22,
282
+        MessageHeal                    = 23,
283
+        MessageExp                     = 24,
284
+        MessageDamageOthers            = 25,
285
+        MessageHealOthers              = 26,
286
+        MessageExpOthers               = 27,
287
+        MessageStatus                  = 28,
288
+        MessageLoot                    = 29,
289
+        MessageTradeNpc                = 30,
290
+        MessageGuild                   = 31,
291
+        MessagePartyManagement         = 32,
292
+        MessageParty                   = 33,
293
+        MessageBarkLow                 = 34,
294
+        MessageBarkLoud                = 35,
295
+        MessageReport                  = 36,
296
+        MessageHotkeyUse               = 37,
297
+        MessageTutorialHint            = 38,
298
+        MessageThankyou                = 39,
299
+        MessageMarket                  = 40,
300
+        MessageBeyondLast              = 41,
301
+
302
+        // deprecated
303
+        MessageMonsterYell             = 42,
304
+        MessageMonsterSay              = 43,
305
+        MessageRed                     = 44,
306
+        MessageBlue                    = 45,
307
+        MessageRVRChannel              = 46,
308
+        MessageRVRAnswer               = 47,
309
+        MessageRVRContinue             = 48,
310
+        LastMessage                    = 49,
311
+        MessageInvalid                 = 255,
273 312
     };
274 313
 
275 314
     enum GameFeature {

+ 0
- 9
src/otclient/creature.cpp View File

@@ -57,15 +57,6 @@ Creature::Creature() : Thing()
57 57
     m_footStep = 0;
58 58
 }
59 59
 
60
-/*
61
-PainterShaderProgramPtr outfitProgram;
62
-int HEAD_COLOR_UNIFORM = 10;
63
-int BODY_COLOR_UNIFORM = 11;
64
-int LEGS_COLOR_UNIFORM = 12;
65
-int FEET_COLOR_UNIFORM = 13;
66
-int MASK_TEXTURE_UNIFORM = 14;
67
-*/
68
-
69 60
 void Creature::draw(const Point& dest, float scaleFactor, bool animate)
70 61
 {
71 62
     Point animationOffset = animate ? m_walkOffset : Point(0,0);

+ 16
- 13
src/otclient/game.cpp View File

@@ -32,6 +32,7 @@
32 32
 #include <framework/core/application.h>
33 33
 #include "luavaluecasts.h"
34 34
 #include "protocolgame.h"
35
+#include "protocolcodes.h"
35 36
 
36 37
 Game g_game;
37 38
 
@@ -151,22 +152,22 @@ void Game::processPing()
151 152
     g_lua.callGlobalField("g_game", "onPing");
152 153
 }
153 154
 
154
-void Game::processTextMessage(const std::string& type, const std::string& message)
155
+void Game::processTextMessage(Otc::MessageMode mode, const std::string& text)
155 156
 {
156
-    g_lua.callGlobalField("g_game","onTextMessage", type, message);
157
+    g_lua.callGlobalField("g_game", "onTextMessage", mode, text);
157 158
 }
158 159
 
159
-void Game::processCreatureSpeak(const std::string& name, int level, Otc::SpeakType type, const std::string& message, int channelId, const Position& creaturePos)
160
+void Game::processTalk(const std::string& name, int level, Otc::MessageMode mode, const std::string& text, int channelId, const Position& pos)
160 161
 {
161
-    if(creaturePos.isValid() && (type == Otc::SpeakSay || type == Otc::SpeakWhisper || type == Otc::SpeakYell
162
-        || type == Otc::SpeakMonsterSay || type == Otc::SpeakMonsterYell || type == Otc::SpeakPrivateNpcToPlayer))
162
+    if(pos.isValid() && (mode == Otc::MessageSay || mode == Otc::MessageWhisper || mode == Otc::MessageYell  ||
163
+                         mode == Otc::MessageMonsterSay || mode == Otc::MessageMonsterYell || mode == Otc::MessageNpcFrom))
163 164
     {
164 165
         StaticTextPtr staticText = StaticTextPtr(new StaticText);
165
-        staticText->addMessage(name, type, message);
166
-        g_map.addThing(staticText, creaturePos);
166
+        staticText->addMessage(name, mode, text);
167
+        g_map.addThing(staticText, pos);
167 168
     }
168 169
 
169
-    g_lua.callGlobalField("g_game", "onCreatureSpeak", name, level, type, message, channelId, creaturePos);
170
+    g_lua.callGlobalField("g_game", "onTalk", name, level, mode, text, channelId, pos);
170 171
 }
171 172
 
172 173
 void Game::processOpenContainer(int containerId, const ItemPtr& containerItem, const std::string& name, int capacity, bool hasParent, const std::vector<ItemPtr>& items)
@@ -769,21 +770,21 @@ void Game::talk(const std::string& message)
769 770
 {
770 771
     if(!canPerformGameAction() || message.empty())
771 772
         return;
772
-    talkChannel(Otc::SpeakSay, 0, message);
773
+    talkChannel(Otc::MessageSay, 0, message);
773 774
 }
774 775
 
775
-void Game::talkChannel(Otc::SpeakType speakType, int channelId, const std::string& message)
776
+void Game::talkChannel(Otc::MessageMode mode, int channelId, const std::string& message)
776 777
 {
777 778
     if(!canPerformGameAction() || message.empty())
778 779
         return;
779
-    m_protocolGame->sendTalk(speakType, channelId, "", message);
780
+    m_protocolGame->sendTalk(mode, channelId, "", message);
780 781
 }
781 782
 
782
-void Game::talkPrivate(Otc::SpeakType speakType, const std::string& receiver, const std::string& message)
783
+void Game::talkPrivate(Otc::MessageMode mode, const std::string& receiver, const std::string& message)
783 784
 {
784 785
     if(!canPerformGameAction() || receiver.empty() || message.empty())
785 786
         return;
786
-    m_protocolGame->sendTalk(speakType, 0, receiver, message);
787
+    m_protocolGame->sendTalk(mode, 0, receiver, message);
787 788
 }
788 789
 
789 790
 void Game::openPrivateChannel(const std::string& receiver)
@@ -1145,6 +1146,8 @@ void Game::setClientVersion(int version)
1145 1146
 
1146 1147
     m_protocolVersion = version;
1147 1148
 
1149
+    Proto::buildMessageModesMap(version);
1150
+
1148 1151
     g_lua.callGlobalField("g_game", "onClientVersionChange", version);
1149 1152
 }
1150 1153
 

+ 4
- 4
src/otclient/game.h View File

@@ -60,8 +60,8 @@ protected:
60 60
     void processWalkCancel(Otc::Direction direction);
61 61
 
62 62
     // message related
63
-    void processTextMessage(const std::string& type, const std::string& message); // deprecated
64
-    void processCreatureSpeak(const std::string& name, int level, Otc::SpeakType type, const std::string& message, int channelId, const Position& creaturePos);
63
+    void processTextMessage(Otc::MessageMode mode, const std::string& text);
64
+    void processTalk(const std::string& name, int level, Otc::MessageMode mode, const std::string& text, int channelId, const Position& pos);
65 65
 
66 66
     // container related
67 67
     void processOpenContainer(int containerId, const ItemPtr& containerItem, const std::string& name, int capacity, bool hasParent, const std::vector<ItemPtr>& items);
@@ -155,8 +155,8 @@ public:
155 155
 
156 156
     // talk related
157 157
     void talk(const std::string& message);
158
-    void talkChannel(Otc::SpeakType speakType, int channelId, const std::string& message);
159
-    void talkPrivate(Otc::SpeakType speakType, const std::string& receiver, const std::string& message);
158
+    void talkChannel(Otc::MessageMode mode, int channelId, const std::string& message);
159
+    void talkPrivate(Otc::MessageMode mode, const std::string& receiver, const std::string& message);
160 160
 
161 161
     // channel related
162 162
     void openPrivateChannel(const std::string& receiver);

+ 1
- 1
src/otclient/map.cpp View File

@@ -618,7 +618,7 @@ void Map::addThing(const ThingPtr& thing, const Position& pos, int stackPos)
618 618
             StaticTextPtr cStaticText = *it;
619 619
             if(cStaticText->getPosition() == pos) {
620 620
                 // try to combine messages
621
-                if(cStaticText->addMessage(staticText->getName(), staticText->getMessageType(), staticText->getFirstMessage())) {
621
+                if(cStaticText->addMessage(staticText->getName(), staticText->getMessageMode(), staticText->getFirstMessage())) {
622 622
                     mustAdd = false;
623 623
                     break;
624 624
                 } else {

+ 138
- 0
src/otclient/protocolcodes.cpp View File

@@ -0,0 +1,138 @@
1
+/*
2
+ * Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
21
+ */
22
+
23
+#include "protocolcodes.h"
24
+
25
+namespace Proto {
26
+
27
+std::map<uint8, uint8> messageModesMap;
28
+
29
+void buildMessageModesMap(int version) {
30
+    messageModesMap.clear();
31
+    if(version >= 900) {
32
+        for(int i=Otc::MessageNone;i<=Otc::MessageBeyondLast;++i)
33
+            messageModesMap[i] = i;
34
+    } else if(version >= 861) {
35
+        messageModesMap[Otc::MessageNone]                    = 0;
36
+        messageModesMap[Otc::MessageSay]                     = 1;
37
+        messageModesMap[Otc::MessageWhisper]                 = 2;
38
+        messageModesMap[Otc::MessageYell]                    = 3;
39
+        messageModesMap[Otc::MessageNpcFrom]                 = 4;
40
+        messageModesMap[Otc::MessageNpcTo]                   = 5;
41
+        messageModesMap[Otc::MessagePrivateFrom]             = 6;
42
+        messageModesMap[Otc::MessagePrivateTo]               = 6;
43
+        messageModesMap[Otc::MessageChannelHighlight]        = 7;
44
+        messageModesMap[Otc::MessageChannel]                 = 8;
45
+        messageModesMap[Otc::MessageGamemasterBroadcast]     = 9;
46
+        messageModesMap[Otc::MessageGamemasterChannel]       = 10;
47
+        messageModesMap[Otc::MessageGamemasterPrivateFrom]   = 11;
48
+        messageModesMap[Otc::MessageGamemasterPrivateTo]     = 11;
49
+        messageModesMap[Otc::MessageChannelManagement]       = 12;
50
+        messageModesMap[Otc::MessageMonsterSay]              = 13;
51
+        messageModesMap[Otc::MessageMonsterYell]             = 14;
52
+        messageModesMap[Otc::MessageWarning]                 = 15;
53
+        messageModesMap[Otc::MessageGame]                    = 16;
54
+        messageModesMap[Otc::MessageLogin]                   = 17;
55
+        messageModesMap[Otc::MessageStatus]                  = 18;
56
+        messageModesMap[Otc::MessageLook]                    = 19;
57
+        messageModesMap[Otc::MessageFailure]                 = 20;
58
+        messageModesMap[Otc::MessageBlue]                    = 21;
59
+        messageModesMap[Otc::MessageRed]                     = 22;
60
+    } else if(version >= 854) {
61
+        messageModesMap[Otc::MessageNone]                    = 0;
62
+        messageModesMap[Otc::MessageSay]                     = 1;
63
+        messageModesMap[Otc::MessageWhisper]                 = 2;
64
+        messageModesMap[Otc::MessageYell]                    = 3;
65
+        messageModesMap[Otc::MessageNpcFrom]                 = 4;
66
+        messageModesMap[Otc::MessageNpcTo]                   = 5;
67
+        messageModesMap[Otc::MessagePrivateFrom]             = 6;
68
+        messageModesMap[Otc::MessagePrivateTo]               = 6;
69
+        messageModesMap[Otc::MessageChannel]                 = 7;
70
+        messageModesMap[Otc::MessageChannelManagement]       = 8;
71
+        messageModesMap[Otc::MessageRVRChannel]              = 9;
72
+        messageModesMap[Otc::MessageRVRAnswer]               = 10;
73
+        messageModesMap[Otc::MessageRVRContinue]             = 11;
74
+        messageModesMap[Otc::MessageGamemasterBroadcast]     = 12;
75
+        messageModesMap[Otc::MessageGamemasterChannel]       = 13;
76
+        messageModesMap[Otc::MessageGamemasterPrivateFrom]   = 14;
77
+        messageModesMap[Otc::MessageGamemasterPrivateTo]     = 14;
78
+        messageModesMap[Otc::MessageChannelHighlight]        = 15;
79
+        // 16, 17, 18 ??
80
+        messageModesMap[Otc::MessageRed]                     = 18;
81
+        messageModesMap[Otc::MessageMonsterSay]              = 19;
82
+        messageModesMap[Otc::MessageMonsterYell]             = 20;
83
+        messageModesMap[Otc::MessageWarning]                 = 21;
84
+        messageModesMap[Otc::MessageGame]                    = 22;
85
+        messageModesMap[Otc::MessageLogin]                   = 23;
86
+        messageModesMap[Otc::MessageStatus]                  = 24;
87
+        messageModesMap[Otc::MessageLook]                    = 25;
88
+        messageModesMap[Otc::MessageFailure]                 = 26;
89
+        messageModesMap[Otc::MessageBlue]                    = 27;
90
+    } else if(version >= 810) {
91
+        messageModesMap[Otc::MessageNone]                    = 0;
92
+        messageModesMap[Otc::MessageSay]                     = 1;
93
+        messageModesMap[Otc::MessageWhisper]                 = 2;
94
+        messageModesMap[Otc::MessageYell]                    = 3;
95
+        messageModesMap[Otc::MessagePrivateFrom]             = 4;
96
+        messageModesMap[Otc::MessagePrivateTo]               = 4;
97
+        messageModesMap[Otc::MessageChannel]                 = 5;
98
+        messageModesMap[Otc::MessageRVRChannel]              = 6;
99
+        messageModesMap[Otc::MessageRVRAnswer]               = 7;
100
+        messageModesMap[Otc::MessageRVRContinue]             = 8;
101
+        messageModesMap[Otc::MessageGamemasterBroadcast]     = 9;
102
+        messageModesMap[Otc::MessageGamemasterChannel]       = 10;
103
+        messageModesMap[Otc::MessageGamemasterPrivateFrom]   = 11;
104
+        messageModesMap[Otc::MessageGamemasterPrivateTo]     = 11;
105
+        messageModesMap[Otc::MessageChannelHighlight]        = 12;
106
+        // 13, 14, 15 ??
107
+        messageModesMap[Otc::MessageMonsterSay]              = 16;
108
+        messageModesMap[Otc::MessageMonsterYell]             = 17;
109
+        messageModesMap[Otc::MessageWarning]                 = 18;
110
+        messageModesMap[Otc::MessageGame]                    = 19;
111
+        messageModesMap[Otc::MessageLogin]                   = 20;
112
+        messageModesMap[Otc::MessageStatus]                  = 21;
113
+        messageModesMap[Otc::MessageLook]                    = 22;
114
+        messageModesMap[Otc::MessageFailure]                 = 23;
115
+        messageModesMap[Otc::MessageBlue]                    = 24;
116
+        messageModesMap[Otc::MessageRed]                     = 25;
117
+    }
118
+}
119
+
120
+Otc::MessageMode translateMessageModeFromServer(uint8 mode)
121
+{
122
+    auto it = std::find_if(messageModesMap.begin(), messageModesMap.end(), [=] (const std::pair<uint8, uint8>& p) { return p.second == mode; });
123
+    if(it != messageModesMap.end())
124
+        return (Otc::MessageMode)it->first;
125
+    return Otc::MessageInvalid;
126
+}
127
+
128
+uint8 translateMessageModeToServer(Otc::MessageMode mode)
129
+{
130
+    if(mode < 0 || mode >= Otc::LastMessage)
131
+        return Otc::MessageInvalid;
132
+    auto it = messageModesMap.find(mode);
133
+    if(it != messageModesMap.end())
134
+        return it->second;
135
+    return Otc::MessageInvalid;
136
+}
137
+
138
+}

+ 7
- 147
src/otclient/protocolcodes.h View File

@@ -39,7 +39,8 @@ namespace Proto {
39 39
         Creature = 99
40 40
     };
41 41
 
42
-    enum GameServerOpcodes {
42
+    enum GameServerOpcodes : uint8
43
+    {
43 44
         GameServerInitGame                  = 10,
44 45
         GameServerGMActions                 = 11,
45 46
         GameServerLoginError                = 20,
@@ -139,7 +140,8 @@ namespace Proto {
139 140
         GameServerShowModalDialog           = 250  // 960
140 141
     };
141 142
 
142
-    enum ClientOpcodes {
143
+    enum ClientOpcodes : uint8
144
+    {
143 145
         ClientEnterAccount                  = 1,
144 146
         ClientEnterGame                     = 10,
145 147
         ClientLeaveGame                     = 20,
@@ -230,107 +232,6 @@ namespace Proto {
230 232
         ClientAnswerModalDialog             = 249  // 960
231 233
     };
232 234
 
233
-    enum ServerSpeakType {
234
-#if PROTOCOL>=910
235
-        ServerSpeakSay = 1,
236
-        ServerSpeakWhisper,
237
-        ServerSpeakYell,
238
-        ServerSpeakPrivateFrom,         // new
239
-        ServerSpeakPrivateTo,           // new
240
-        ServerSpeakChannelManagement,   // new
241
-        ServerSpeakChannelYellow,
242
-        ServerSpeakChannelOrange,
243
-        ServerSpeakSpell,               // new
244
-        ServerSpeakPrivatePlayerToNpc,
245
-        ServerSpeakPrivateNpcToPlayer,
246
-        ServerSpeakBroadcast,
247
-        ServerSpeakChannelRed,
248
-        ServerSpeakPrivateRedFrom,      // new
249
-        ServerSpeakPrivateRedTo,        // new
250
-        // 16 - 33
251
-        ServerSpeakMonsterSay = 34,
252
-        ServerSpeakMonsterYell,
253
-
254
-        // unsupported
255
-        ServerSpeakRVRChannel = 255,
256
-        ServerSpeakRVRAnswer,
257
-        ServerSpeakRVRContinue,
258
-        ServerSpeakChannelRed2,
259
-        ServerSpeakChannelWhite
260
-#elif PROTOCOL>=861
261
-        ServerSpeakSay = 1,
262
-        ServerSpeakWhisper,
263
-        ServerSpeakYell,
264
-        ServerSpeakPrivatePlayerToNpc,
265
-        ServerSpeakPrivateNpcToPlayer,
266
-        ServerSpeakPrivateTo,
267
-        ServerSpeakPrivateFrom = ServerSpeakPrivateTo,
268
-        ServerSpeakChannelYellow,
269
-        ServerSpeakChannelWhite,
270
-        ServerSpeakBroadcast,
271
-        ServerSpeakChannelRed,
272
-        ServerSpeakPrivateRedTo,
273
-        ServerSpeakPrivateRedFrom = ServerSpeakPrivateRedTo,
274
-        ServerSpeakChannelOrange,
275
-        ServerSpeakMonsterSay,
276
-        ServerSpeakMonsterYell,
277
-
278
-        // unsupported
279
-        ServerSpeakRVRChannel = 255,
280
-        ServerSpeakRVRAnswer,
281
-        ServerSpeakRVRContinue,
282
-        ServerSpeakChannelRed2
283
-#elif PROTOCOL>=854
284
-        ServerSpeakSay = 1,
285
-        ServerSpeakWhisper,
286
-        ServerSpeakYell,
287
-        ServerSpeakPrivatePlayerToNpc,
288
-        ServerSpeakPrivateNpcToPlayer,
289
-        ServerSpeakPrivateTo,
290
-        ServerSpeakPrivateFrom = ServerSpeakPrivateTo,
291
-        ServerSpeakChannelYellow,
292
-        ServerSpeakChannelWhite,
293
-        ServerSpeakRVRChannel,
294
-        ServerSpeakRVRAnswer,
295
-        ServerSpeakRVRContinue,
296
-        ServerSpeakBroadcast,
297
-        ServerSpeakChannelRed,
298
-        ServerSpeakPrivateRedTo,
299
-        ServerSpeakPrivateRedFrom = ServerSpeakPrivateRedTo,
300
-        ServerSpeakChannelOrange,
301
-        // 16
302
-        ServerSpeakChannelRed2 = 17,
303
-        // 18
304
-        ServerSpeakMonsterSay = 19,
305
-        ServerSpeakMonsterYell
306
-#elif PROTOCOL>=810
307
-        ServerSpeakSay = 1,
308
-        ServerSpeakWhisper,
309
-        ServerSpeakYell,
310
-        ServerSpeakPrivateTo,
311
-        ServerSpeakPrivateFrom = ServerSpeakPrivateTo,
312
-        ServerSpeakChannelYellow,
313
-        ServerSpeakRVRChannel,
314
-        ServerSpeakRVRAnswer,
315
-        ServerSpeakRVRContinue,
316
-        ServerSpeakBroadcast,
317
-        ServerSpeakChannelRed,
318
-        ServerSpeakPrivateRedTo,
319
-        ServerSpeakPrivateRedFrom = ServerSpeakPrivateRedTo,
320
-        ServerSpeakChannelOrange,
321
-        // 13
322
-        ServerSpeakChannelRed2 = 14,
323
-        // 15
324
-        ServerSpeakMonsterSay = 16,
325
-        ServerSpeakMonsterYell,
326
-
327
-        // unsupported
328
-        ServerSpeakPrivatePlayerToNpc = 255,
329
-        ServerSpeakPrivateNpcToPlayer,
330
-        ServerSpeakChannelWhite
331
-#endif
332
-    };
333
-
334 235
     enum CreatureType {
335 236
         CreatureTypePlayer = 0,
336 237
         CreatureTypeMonster,
@@ -346,50 +247,9 @@ namespace Proto {
346 247
         NpcEndId = 0xffffffff
347 248
     };
348 249
 
349
-    inline Otc::SpeakType translateSpeakTypeFromServer(int type) {
350
-        switch(type) {
351
-            case Proto::ServerSpeakSay: return Otc::SpeakSay;
352
-            case Proto::ServerSpeakWhisper: return Otc::SpeakWhisper;
353
-            case Proto::ServerSpeakYell: return Otc::SpeakYell;
354
-            case Proto::ServerSpeakMonsterSay: return Otc::SpeakMonsterSay;
355
-            case Proto::ServerSpeakMonsterYell: return Otc::SpeakMonsterYell;
356
-            case Proto::ServerSpeakPrivateNpcToPlayer: return Otc::SpeakPrivateNpcToPlayer;
357
-            case Proto::ServerSpeakChannelYellow: return Otc::SpeakChannelYellow;
358
-            case Proto::ServerSpeakChannelWhite: return Otc::SpeakChannelWhite;
359
-            case Proto::ServerSpeakChannelRed: return Otc::SpeakChannelRed;
360
-            case Proto::ServerSpeakChannelRed2: return Otc::SpeakChannelRed;
361
-            case Proto::ServerSpeakChannelOrange: return Otc::SpeakChannelOrange;
362
-            case Proto::ServerSpeakPrivateTo: return Otc::SpeakPrivate;
363
-            case Proto::ServerSpeakPrivatePlayerToNpc: return Otc::SpeakPrivate;
364
-            case Proto::ServerSpeakBroadcast: return Otc::SpeakBroadcast;
365
-            case Proto::ServerSpeakPrivateRedTo: return Otc::SpeakPrivateRed;
366
-            default:
367
-                g_logger.error(stdext::format("unknown protocol speak type %d", type));
368
-                return Otc::SpeakSay;
369
-        }
370
-    }
371
-
372
-    inline Proto::ServerSpeakType translateSpeakTypeToServer(int type) {
373
-        switch(type) {
374
-            case Otc::SpeakSay: return Proto::ServerSpeakSay;
375
-            case Otc::SpeakWhisper: return Proto::ServerSpeakWhisper;
376
-            case Otc::SpeakYell: return Proto::ServerSpeakYell;
377
-            case Otc::SpeakBroadcast: return Proto::ServerSpeakBroadcast;
378
-            case Otc::SpeakPrivate: return Proto::ServerSpeakPrivateFrom;
379
-            case Otc::SpeakPrivateRed: return Proto::ServerSpeakPrivateRedFrom;
380
-            case Otc::SpeakPrivatePlayerToNpc: return Proto::ServerSpeakPrivatePlayerToNpc;
381
-            case Otc::SpeakPrivateNpcToPlayer: return Proto::ServerSpeakPrivateNpcToPlayer;
382
-            case Otc::SpeakChannelYellow: return Proto::ServerSpeakChannelYellow;
383
-            case Otc::SpeakChannelWhite: return Proto::ServerSpeakChannelWhite;
384
-            case Otc::SpeakChannelRed: return Proto::ServerSpeakChannelRed;
385
-            case Otc::SpeakChannelOrange: return Proto::ServerSpeakChannelOrange;
386
-            case Otc::SpeakMonsterSay: return Proto::ServerSpeakMonsterSay;
387
-            case Otc::SpeakMonsterYell: return Proto::ServerSpeakMonsterYell;
388
-            default:
389
-                g_logger.error(stdext::format("unknown protocol speak type desc %d", type));
390
-                return Proto::ServerSpeakSay;
391
-        }
392
-    }
250
+    void buildMessageModesMap(int version);
251
+    Otc::MessageMode translateMessageModeFromServer(uint8 mode);
252
+    uint8 translateMessageModeToServer(Otc::MessageMode mode);
393 253
 }
394 254
 
395 255
 #endif

+ 2
- 2
src/otclient/protocolgame.h View File

@@ -72,7 +72,7 @@ public:
72 72
     void sendEditText(uint id, const std::string& text);
73 73
     void sendEditList(uint id, int doorId, const std::string& text);
74 74
     void sendLook(const Position& position, int thingId, int stackpos);
75
-    void sendTalk(Otc::SpeakType speakType, int channelId, const std::string& receiver, const std::string& message);
75
+    void sendTalk(Otc::MessageMode mode, int channelId, const std::string& receiver, const std::string& message);
76 76
     void sendRequestChannels();
77 77
     void sendJoinChannel(int channelId);
78 78
     void sendLeaveChannel(int channelId);
@@ -169,7 +169,7 @@ private:
169 169
     void parseSpellCooldown(const InputMessagePtr& msg);
170 170
     void parseSpellGroupCooldown(const InputMessagePtr& msg);
171 171
     void parseMultiUseCooldown(const InputMessagePtr& msg);
172
-    void parseCreatureSpeak(const InputMessagePtr& msg);
172
+    void parseTalk(const InputMessagePtr& msg);
173 173
     void parseChannelList(const InputMessagePtr& msg);
174 174
     void parseOpenChannel(const InputMessagePtr& msg);
175 175
     void parseOpenPrivateChannel(const InputMessagePtr& msg);

+ 79
- 33
src/otclient/protocolgameparse.cpp View File

@@ -211,7 +211,7 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg)
211 211
                 parsePlayerCancelAttack(msg);
212 212
                 break;
213 213
             case Proto::GameServerTalk:
214
-                parseCreatureSpeak(msg);
214
+                parseTalk(msg);
215 215
                 break;
216 216
             case Proto::GameServerChannels:
217 217
                 parseChannelList(msg);
@@ -469,7 +469,6 @@ void ProtocolGame::parseTileTransformThing(const InputMessagePtr& msg)
469 469
 
470 470
     Position pos = thing->getPosition();
471 471
     int stackpos = thing->getStackpos();
472
-    assert(thing->getStackPriority() == newThing->getStackPriority());
473 472
 
474 473
     if(!g_map.removeThing(thing)) {
475 474
         g_logger.traceError("unable to remove thing");
@@ -938,51 +937,49 @@ void ProtocolGame::parseMultiUseCooldown(const InputMessagePtr& msg)
938 937
     msg->getU32(); // cooldown
939 938
 }
940 939
 
941
-void ProtocolGame::parseCreatureSpeak(const InputMessagePtr& msg)
940
+void ProtocolGame::parseTalk(const InputMessagePtr& msg)
942 941
 {
943 942
     msg->getU32(); // channel statement guid
944 943
 
945 944
     std::string name = msg->getString();
946 945
     int level = msg->getU16();
947
-    int speakType = msg->getU8();
946
+    Otc::MessageMode mode = Proto::translateMessageModeFromServer(msg->getU8());
948 947
     int channelId = 0;
949
-    Position creaturePos;
950
-
951
-    switch(speakType) {
952
-        case Proto::ServerSpeakSay:
953
-        case Proto::ServerSpeakWhisper:
954
-        case Proto::ServerSpeakYell:
955
-        case Proto::ServerSpeakMonsterSay:
956
-        case Proto::ServerSpeakMonsterYell:
957
-        case Proto::ServerSpeakPrivateNpcToPlayer:
958
-            creaturePos = getPosition(msg);
948
+    Position pos;
949
+
950
+    switch(mode) {
951
+        case Otc::MessageSay:
952
+        case Otc::MessageWhisper:
953
+        case Otc::MessageYell:
954
+        case Otc::MessageMonsterSay:
955
+        case Otc::MessageMonsterYell:
956
+        case Otc::MessageNpcFrom:
957
+        case Otc::MessageBarkLow:
958
+        case Otc::MessageBarkLoud:
959
+        case Otc::MessageSpell:
960
+            pos = getPosition(msg);
959 961
             break;
960
-        case Proto::ServerSpeakChannelYellow:
961
-        case Proto::ServerSpeakChannelWhite:
962
-        case Proto::ServerSpeakChannelRed:
963
-        case Proto::ServerSpeakChannelRed2:
964
-        case Proto::ServerSpeakChannelOrange:
962
+        case Otc::MessageChannel:
963
+        case Otc::MessageChannelManagement:
964
+        case Otc::MessageChannelHighlight:
965
+        case Otc::MessageGamemasterChannel:
965 966
             channelId = msg->getU16();
966 967
             break;
967
-        case Proto::ServerSpeakPrivateFrom:
968
-        case Proto::ServerSpeakPrivatePlayerToNpc:
969
-        case Proto::ServerSpeakBroadcast:
970
-        case Proto::ServerSpeakPrivateRedFrom:
968
+        case Otc::MessagePrivateFrom:
969
+        case Otc::MessageGamemasterBroadcast:
970
+        case Otc::MessageGamemasterPrivateFrom:
971 971
             break;
972
-        case Proto::ServerSpeakRVRChannel:
972
+        case Otc::MessageRVRChannel:
973 973
             msg->getU32();
974 974
             break;
975
-        //case Proto::ServerSpeakChannelManagement:
976
-        //case Proto::ServerSpeakSpell:
977 975
         default:
978
-            stdext::throw_exception(stdext::format("unknown speak type %d", speakType));
976
+            stdext::throw_exception(stdext::format("unknown message mode %d", mode));
979 977
             break;
980 978
     }
981 979
 
982
-    std::string message = msg->getString();
983
-    Otc::SpeakType type = Proto::translateSpeakTypeFromServer(speakType);
980
+    std::string text = msg->getString();
984 981
 
985
-    g_game.processCreatureSpeak(name, level, type, message, channelId, creaturePos);
982
+    g_game.processTalk(name, level, mode, text, channelId, pos);
986 983
 }
987 984
 
988 985
 void ProtocolGame::parseChannelList(const InputMessagePtr& msg)
@@ -1066,9 +1063,58 @@ void ProtocolGame::parseRuleViolationLock(const InputMessagePtr& msg)
1066 1063
 
1067 1064
 void ProtocolGame::parseTextMessage(const InputMessagePtr& msg)
1068 1065
 {
1069
-    msg->getU8(); // type
1070
-    msg->getString(); // message
1071
-    // this is now handled by game_textmessage module
1066
+    int code = msg->getU8();
1067
+    Otc::MessageMode mode = Proto::translateMessageModeFromServer(code);
1068
+    std::string text;
1069
+
1070
+    switch(mode) {
1071
+        case Otc::MessageChannelManagement: {
1072
+            int channel = msg->getU16();
1073
+            text = msg->getString();
1074
+            break;
1075
+        }
1076
+        case Otc::MessageDamageDealed:
1077
+        case Otc::MessageDamageReceived:
1078
+        case Otc::MessageDamageOthers: {
1079
+            Position pos = getPosition(msg);
1080
+            uint value = msg->getU32();
1081
+            int color =  msg->getU8();
1082
+            msg->getU32(); // ??
1083
+            msg->getU8(); // ??
1084
+            text = msg->getString();
1085
+
1086
+            AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
1087
+            animatedText->setColor(color);
1088
+            animatedText->setText(stdext::to_string(value));
1089
+            g_map.addThing(animatedText, pos);
1090
+            break;
1091
+        }
1092
+        case Otc::MessageHeal:
1093
+        case Otc::MessageExp:
1094
+        case Otc::MessageHealOthers:
1095
+        case Otc::MessageExpOthers: {
1096
+            Position pos = getPosition(msg);
1097
+            uint value = msg->getU32();
1098
+            int color =  msg->getU8();
1099
+            msg->getU32(); // ??
1100
+            msg->getU8(); // ??
1101
+            text = msg->getString();
1102
+
1103
+            AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
1104
+            animatedText->setColor(color);
1105
+            animatedText->setText(stdext::to_string(value));
1106
+            g_map.addThing(animatedText, pos);
1107
+            break;
1108
+        }
1109
+        case Otc::MessageInvalid:
1110
+            stdext::throw_exception(stdext::format("unknown message mode %d", mode));
1111
+            break;
1112
+        default:
1113
+            text = msg->getString();
1114
+            break;
1115
+    }
1116
+
1117
+    g_game.processTextMessage(mode, text);
1072 1118
 }
1073 1119
 
1074 1120
 void ProtocolGame::parseCancelWalk(const InputMessagePtr& msg)

+ 16
- 9
src/otclient/protocolgamesend.cpp View File

@@ -435,26 +435,33 @@ void ProtocolGame::sendLook(const Position& position, int thingId, int stackpos)
435 435
     send(msg);
436 436
 }
437 437
 
438
-void ProtocolGame::sendTalk(Otc::SpeakType speakType, int channelId, const std::string& receiver, const std::string& message)
438
+void ProtocolGame::sendTalk(Otc::MessageMode mode, int channelId, const std::string& receiver, const std::string& message)
439 439
 {
440
-    if(message.length() > 255 || message.length() <= 0)
440
+    if(message.empty())
441 441
         return;
442 442
 
443
-    int serverSpeakType = Proto::translateSpeakTypeToServer(speakType);
443
+    if(message.length() > 255) {
444
+        g_logger.traceError("message too large");
445
+        return;
446
+    }
444 447
 
445 448
     OutputMessagePtr msg(new OutputMessage);
446 449
     msg->addU8(Proto::ClientTalk);
447
-    msg->addU8(serverSpeakType);
450
+    msg->addU8(Proto::translateMessageModeToServer(mode));
448 451
 
449
-    switch(serverSpeakType) {
450
-    case Proto::ServerSpeakPrivateFrom:
451
-    case Proto::ServerSpeakPrivateRedFrom:
452
+    switch(mode) {
453
+    case Otc::MessagePrivateTo:
454
+    case Otc::MessageGamemasterPrivateTo:
452 455
         msg->addString(receiver);
453 456
         break;
454
-    case Proto::ServerSpeakChannelYellow:
455
-    case Proto::ServerSpeakChannelRed:
457
+    case Otc::MessageChannel:
458
+    case Otc::MessageChannelHighlight:
459
+    case Otc::MessageChannelManagement:
460
+    case Otc::MessageGamemasterChannel:
456 461
         msg->addU16(channelId);
457 462
         break;
463
+    default:
464
+        break;
458 465
     }
459 466
 
460 467
     msg->addString(message);

+ 10
- 10
src/otclient/statictext.cpp View File

@@ -47,16 +47,16 @@ void StaticText::drawText(const Point& dest, const Rect& parentRect)
47 47
     //}
48 48
 }
49 49
 
50
-bool StaticText::addMessage(const std::string& name, Otc::SpeakType type, const std::string& message)
50
+bool StaticText::addMessage(const std::string& name, Otc::MessageMode mode, const std::string& text)
51 51
 {
52 52
     //TODO: this could be moved to lua
53 53
     // first message
54 54
     if(m_messages.size() == 0) {
55 55
         m_name = name;
56
-        m_messageType = type;
56
+        m_mode = mode;
57 57
     }
58 58
     // check if we can really own the message
59
-    else if(m_name != name || m_messageType != type) {
59
+    else if(m_name != name || m_mode != mode) {
60 60
         return false;
61 61
     }
62 62
     // too many messages
@@ -66,7 +66,7 @@ bool StaticText::addMessage(const std::string& name, Otc::SpeakType type, const
66 66
         m_updateEvent = nullptr;
67 67
     }
68 68
 
69
-    m_messages.push_back(message);
69
+    m_messages.push_back(text);
70 70
     compose();
71 71
 
72 72
     if(!m_updateEvent)
@@ -105,26 +105,26 @@ void StaticText::compose()
105 105
     //TODO: this could be moved to lua
106 106
     std::string text;
107 107
 
108
-    if(m_messageType == Otc::SpeakSay) {
108
+    if(m_mode == Otc::MessageSay) {
109 109
         text += m_name;
110 110
         text += " says:\n";
111 111
         m_color = Color(239, 239, 0);
112
-    } else if(m_messageType == Otc::SpeakWhisper) {
112
+    } else if(m_mode == Otc::MessageWhisper) {
113 113
         text += m_name;
114 114
         text += " whispers:\n";
115 115
         m_color = Color(239, 239, 0);
116
-    } else if(m_messageType == Otc::SpeakYell) {
116
+    } else if(m_mode == Otc::MessageYell) {
117 117
         text += m_name;
118 118
         text += " yells:\n";
119 119
         m_color = Color(239, 239, 0);
120
-    } else if(m_messageType == Otc::SpeakMonsterSay || m_messageType == Otc::SpeakMonsterYell) {
120
+    } else if(m_mode == Otc::MessageMonsterSay || m_mode == Otc::MessageMonsterYell) {
121 121
         m_color = Color(254, 101, 0);
122
-    } else if(m_messageType == Otc::SpeakPrivateNpcToPlayer) {
122
+    } else if(m_mode == Otc::MessageNpcFrom) {
123 123
         text += m_name;
124 124
         text += " says:\n";
125 125
         m_color = Color(95, 247, 247);
126 126
     } else {
127
-        g_logger.warning(stdext::format("Unknown speak type: %d", m_messageType));
127
+        g_logger.warning(stdext::format("Unknown speak type: %d", m_mode));
128 128
     }
129 129
 
130 130
     for(uint i = 0; i < m_messages.size(); ++i) {

+ 4
- 4
src/otclient/statictext.h View File

@@ -36,12 +36,12 @@ public:
36 36
     void drawText(const Point& dest, const Rect& parentRect);
37 37
 
38 38
     std::string getName() { return m_name; }
39
-    Otc::SpeakType getMessageType() { return m_messageType; }
39
+    Otc::MessageMode getMessageMode() { return m_mode; }
40 40
     std::string getFirstMessage() { return m_messages[0]; }
41 41
 
42
-    bool isYell() { return m_messageType == Otc::SpeakYell || m_messageType == Otc::SpeakMonsterYell; }
42
+    bool isYell() { return m_mode == Otc::MessageYell || m_mode == Otc::MessageMonsterYell; }
43 43
 
44
-    bool addMessage(const std::string& name, Otc::SpeakType type, const std::string& message);
44
+    bool addMessage(const std::string& name, Otc::MessageMode mode, const std::string& text);
45 45
 
46 46
     StaticTextPtr asStaticText() { return std::static_pointer_cast<StaticText>(shared_from_this()); }
47 47
     bool isStaticText() { return true; }
@@ -54,7 +54,7 @@ private:
54 54
     Boolean<false> m_yell;
55 55
     std::deque<std::string> m_messages;
56 56
     std::string m_name;
57
-    Otc::SpeakType m_messageType;
57
+    Otc::MessageMode m_mode;
58 58
     Color m_color;
59 59
     CachedText m_cachedText;
60 60
     ScheduledEventPtr m_updateEvent;

+ 11
- 9
src/otclient/tile.cpp View File

@@ -192,6 +192,17 @@ ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
192 192
     if(m_things.size() > MAX_THINGS)
193 193
         removeThing(m_things[MAX_THINGS]);
194 194
 
195
+    /*
196
+    // check stack priorities
197
+    // this code exists to find stackpos bugs faster
198
+    int lastPriority = 0;
199
+    for(const ThingPtr& thing : m_things) {
200
+        int priority = thing->getStackPriority();
201
+        assert(lastPriority <= priority);
202
+        lastPriority = priority;
203
+    }
204
+    */
205
+
195 206
     update();
196 207
     return oldObject;
197 208
 }
@@ -510,13 +521,4 @@ void Tile::update()
510 521
         if(c != 0)
511 522
             m_minimapColorByte = c;
512 523
     }
513
-
514
-    // check stack priorities
515
-    // this code exists to find stackpos bugs faster
516
-    int lastPriority = 0;
517
-    for(const ThingPtr& thing : m_things) {
518
-        int priority = thing->getStackPriority();
519
-        assert(lastPriority <= priority);
520
-        lastPriority = priority;
521
-    }
522 524
 }

Loading…
Cancel
Save