From 9ad9d88e10d4251710724686a787c041157e047d Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Thu, 26 Jul 2012 12:42:15 -0300 Subject: [PATCH] Fix npc trade and npc chat --- modules/game_console/console.lua | 2 +- modules/game_minimap/minimap.lua | 3 ++- modules/game_npctrade/npctrade.otui | 16 ++++++++-------- src/otclient/protocolcodes.cpp | 4 ++-- src/otclient/protocolgameparse.cpp | 9 ++++++++- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index f35af22d..c5e290fd 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -239,7 +239,7 @@ end function addPrivateText(text, speaktype, name, isPrivateCommand, creatureName) local focus = false - if speaktype.speakType == SpeakNpcFrom then + if speaktype.npcChat then name = 'NPCs' focus = true end diff --git a/modules/game_minimap/minimap.lua b/modules/game_minimap/minimap.lua index 2dada8fc..27250f21 100644 --- a/modules/game_minimap/minimap.lua +++ b/modules/game_minimap/minimap.lua @@ -39,6 +39,7 @@ function init() reset() -- load only the first time (avoid load/save between reloads) + --[[ if G.minimapFirstLoad then G.minimapFirstLoad = false if g_resources.fileExists('/minimap.otcm') then @@ -53,7 +54,7 @@ function init() connect(g_app, { onTerminate = function() g_map.saveOtcm('/minimap.otcm') end}) - end + end]]-- end function terminate() diff --git a/modules/game_npctrade/npctrade.otui b/modules/game_npctrade/npctrade.otui index c9ad6754..d7e1f5c0 100644 --- a/modules/game_npctrade/npctrade.otui +++ b/modules/game_npctrade/npctrade.otui @@ -10,7 +10,7 @@ NPCItemBox < UICheckBox color: #aaaaaa text-align: center text-offset: 0 20 - @onCheckChange: NPCTrade.onItemBoxChecked(self) + @onCheckChange: modules.game_npctrade.onItemBoxChecked(self) Item id: item @@ -176,7 +176,7 @@ MainWindow minimum: 1 maximum: 100 step: 1 - @onValueChange: NPCTrade.onQuantityValueChange(self:getValue()) + @onValueChange: modules.game_npctrade.onQuantityValueChange(self:getValue()) FlatPanel id: buyOptions @@ -204,7 +204,7 @@ MainWindow margin-top: -2 margin-left: 5 margin-right: 5 - @onTextChange: NPCTrade.onSearchTextChange() + @onTextChange: modules.game_npctrade.onSearchTextChange() CheckBox id: buyWithBackpack @@ -214,7 +214,7 @@ MainWindow anchors.right: parent.right margin-left: 5 margin-top: 5 - @onCheckChange: NPCTrade.onBuyWithBackpackChange() + @onCheckChange: modules.game_npctrade.onBuyWithBackpackChange() CheckBox id: ignoreCapacity @@ -224,7 +224,7 @@ MainWindow anchors.right: parent.right margin-left: 5 margin-top: 5 - @onCheckChange: NPCTrade.onIgnoreCapacityChange() + @onCheckChange: modules.game_npctrade.onIgnoreCapacityChange() CheckBox id: ignoreEquipped @@ -236,7 +236,7 @@ MainWindow margin-top: 5 visible: false checked: true - @onCheckChange: NPCTrade.onIgnoreEquippedChange() + @onCheckChange: modules.game_npctrade.onIgnoreEquippedChange() CheckBox id: showAllItems @@ -248,7 +248,7 @@ MainWindow margin-top: 5 visible: false checked: true - @onCheckChange: NPCTrade.onShowAllItemsChange() + @onCheckChange: modules.game_npctrade.onShowAllItemsChange() Button id: tradeButton @@ -257,7 +257,7 @@ MainWindow anchors.right: next.left anchors.bottom: parent.bottom margin-right: 10 - @onClick: NPCTrade.onTradeClick() + @onClick: modules.game_npctrade.onTradeClick() Button !text: tr('Close') diff --git a/src/otclient/protocolcodes.cpp b/src/otclient/protocolcodes.cpp index d6460c8c..7214c9bb 100644 --- a/src/otclient/protocolcodes.cpp +++ b/src/otclient/protocolcodes.cpp @@ -62,8 +62,8 @@ void buildMessageModesMap(int version) { messageModesMap[Otc::MessageSay] = 1; messageModesMap[Otc::MessageWhisper] = 2; messageModesMap[Otc::MessageYell] = 3; - messageModesMap[Otc::MessageNpcFrom] = 4; - messageModesMap[Otc::MessageNpcTo] = 5; + messageModesMap[Otc::MessageNpcTo] = 4; + messageModesMap[Otc::MessageNpcFrom] = 5; messageModesMap[Otc::MessagePrivateFrom] = 6; messageModesMap[Otc::MessagePrivateTo] = 6; messageModesMap[Otc::MessageChannel] = 7; diff --git a/src/otclient/protocolgameparse.cpp b/src/otclient/protocolgameparse.cpp index 651fd0cb..b61fb921 100644 --- a/src/otclient/protocolgameparse.cpp +++ b/src/otclient/protocolgameparse.cpp @@ -574,7 +574,13 @@ void ProtocolGame::parseOpenNpcTrade(const InputMessagePtr& msg) if(g_game.getFeature(Otc::GameNameOnNpcTrade)) npcName = msg->getString(); - int listCount = msg->getU8(); + int listCount; + + if(g_game.getClientVersion() >= 960) + listCount = msg->getU16(); + else + listCount = msg->getU8(); + for(int i = 0; i < listCount; ++i) { uint16 itemId = msg->getU16(); uint8 count = msg->getU8(); @@ -953,6 +959,7 @@ void ProtocolGame::parseTalk(const InputMessagePtr& msg) case Otc::MessageYell: case Otc::MessageMonsterSay: case Otc::MessageMonsterYell: + case Otc::MessageNpcTo: case Otc::MessageNpcFrom: case Otc::MessageBarkLow: case Otc::MessageBarkLoud: