From 99500c9c91779daa2220ce7b51ce840b2a5c6b54 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 4 Dec 2013 16:01:51 +0100 Subject: [PATCH] Protocol 8.40-.42 fixes, closes #272 --- modules/game_ruleviolation/ruleviolation.lua | 21 ++++++++++++++++---- src/client/game.cpp | 5 +---- src/client/protocolcodes.cpp | 2 +- src/client/protocolgameparse.cpp | 6 ++++-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/modules/game_ruleviolation/ruleviolation.lua b/modules/game_ruleviolation/ruleviolation.lua index 79f98c58..3d74eb4e 100644 --- a/modules/game_ruleviolation/ruleviolation.lua +++ b/modules/game_ruleviolation/ruleviolation.lua @@ -43,7 +43,7 @@ function init() reasonsTextList = ruleViolationWindow:getChildById('reasonList') actionsTextList = ruleViolationWindow:getChildById('actionList') - g_keyboard.bindKeyDown('Ctrl+Y', show) + g_keyboard.bindKeyDown('Ctrl+Y', function() show() end) if g_game.isOnline() then loadReasons() @@ -63,6 +63,7 @@ end function loadReasons() reasonsTextList:destroyChildren() + actionsTextList:destroyChildren() local actions = g_game.getGMActions() for reason, actionFlags in pairs(actions) do @@ -100,7 +101,7 @@ function onSelectReason(reasonLabel, focused) if reasonLabel.actionFlags and focused then actionsTextList:destroyChildren() for actionBaseFlag = 0, #rvactions do - actionFlagString = rvactions[actionBaseFlag] + local actionFlagString = rvactions[actionBaseFlag] if bit32.band(reasonLabel.actionFlags, math.pow(2, actionBaseFlag)) > 0 then local label = g_ui.createWidget('RVListLabel', actionsTextList) label:setText(actionFlagString) @@ -111,9 +112,21 @@ function onSelectReason(reasonLabel, focused) end function report() + local reasonLabel = reasonsTextList:getFocusedChild() + if not reasonLabel then + displayErrorBox(tr("Error"), tr("You must select a reason.")) + return + end + + local actionLabel = actionsTextList:getFocusedChild() + if not actionLabel then + displayErrorBox(tr("Error"), tr("You must select an action.")) + return + end + local target = ruleViolationWindow:getChildById('nameText'):getText() - local reason = reasonsTextList:getFocusedChild().reasonId - local action = actionsTextList:getFocusedChild().actionId + local reason = reasonLabel.reasonId + local action = actionLabel.actionId local comment = ruleViolationWindow:getChildById('commentText'):getText() local statement = ruleViolationWindow:getChildById('statementText'):getText() local statementId = 0 -- TODO: message unique id ? diff --git a/src/client/game.cpp b/src/client/game.cpp index 2b69212c..ce12dfb6 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1468,16 +1468,13 @@ void Game::setProtocolVersion(int version) enableFeature(Otc::GameProtocolChecksum); enableFeature(Otc::GameChallengeOnLogin); enableFeature(Otc::GameAccountNames); + enableFeature(Otc::GameDoubleFreeCapacity); } if(version >= 780 && version <= 854) { // 780 might not be accurate enableFeature(Otc::GameChargeableItems); } - if(version >= 850) { - enableFeature(Otc::GameDoubleFreeCapacity); - } - if(version >= 854) { enableFeature(Otc::GameCreatureEmblems); } diff --git a/src/client/protocolcodes.cpp b/src/client/protocolcodes.cpp index 4a30be61..5fea82dd 100644 --- a/src/client/protocolcodes.cpp +++ b/src/client/protocolcodes.cpp @@ -57,7 +57,7 @@ void buildMessageModesMap(int version) { messageModesMap[Otc::MessageFailure] = 20; messageModesMap[Otc::MessageBlue] = 21; messageModesMap[Otc::MessageRed] = 22; - } else if(version >= 850) { + } else if(version >= 840) { messageModesMap[Otc::MessageNone] = 0; messageModesMap[Otc::MessageSay] = 1; messageModesMap[Otc::MessageWhisper] = 2; diff --git a/src/client/protocolgameparse.cpp b/src/client/protocolgameparse.cpp index 343558f7..2fa28046 100644 --- a/src/client/protocolgameparse.cpp +++ b/src/client/protocolgameparse.cpp @@ -407,7 +407,9 @@ void ProtocolGame::parseGMActions(const InputMessagePtr& msg) int numViolationReasons; - if(g_game.getProtocolVersion() >= 850) + if(g_game.getProtocolVersion() >= 840) + numViolationReasons = 23; + else if(g_game.getProtocolVersion() >= 850) numViolationReasons = 20; else numViolationReasons = 32; @@ -557,7 +559,7 @@ void ProtocolGame::parseTileAddThing(const InputMessagePtr& msg) Position pos = getPosition(msg); int stackPos = -1; - if(g_game.getProtocolVersion() >= 850) + if(g_game.getProtocolVersion() >= 841) stackPos = msg->getU8(); ThingPtr thing = getThing(msg);