Browse Source

Protocol 8.40-.42 fixes, closes #272

Sam 7 years ago
parent
commit
99500c9c91

+ 17
- 4
modules/game_ruleviolation/ruleviolation.lua View File

@@ -43,7 +43,7 @@ function init()
43 43
   reasonsTextList = ruleViolationWindow:getChildById('reasonList')
44 44
   actionsTextList = ruleViolationWindow:getChildById('actionList')
45 45
 
46
-  g_keyboard.bindKeyDown('Ctrl+Y', show)
46
+  g_keyboard.bindKeyDown('Ctrl+Y', function() show() end)
47 47
 
48 48
   if g_game.isOnline() then
49 49
     loadReasons()
@@ -63,6 +63,7 @@ end
63 63
 
64 64
 function loadReasons()
65 65
   reasonsTextList:destroyChildren()
66
+  actionsTextList:destroyChildren()
66 67
 
67 68
   local actions = g_game.getGMActions()
68 69
   for reason, actionFlags in pairs(actions) do
@@ -100,7 +101,7 @@ function onSelectReason(reasonLabel, focused)
100 101
   if reasonLabel.actionFlags and focused then
101 102
     actionsTextList:destroyChildren()
102 103
     for actionBaseFlag = 0, #rvactions do
103
-      actionFlagString = rvactions[actionBaseFlag]
104
+      local actionFlagString = rvactions[actionBaseFlag]
104 105
       if bit32.band(reasonLabel.actionFlags, math.pow(2, actionBaseFlag)) > 0 then
105 106
         local label = g_ui.createWidget('RVListLabel', actionsTextList)
106 107
         label:setText(actionFlagString)
@@ -111,9 +112,21 @@ function onSelectReason(reasonLabel, focused)
111 112
 end
112 113
 
113 114
 function report()
115
+  local reasonLabel = reasonsTextList:getFocusedChild()
116
+  if not reasonLabel then
117
+    displayErrorBox(tr("Error"), tr("You must select a reason."))
118
+    return
119
+  end
120
+
121
+  local actionLabel = actionsTextList:getFocusedChild()
122
+  if not actionLabel then
123
+    displayErrorBox(tr("Error"), tr("You must select an action."))
124
+    return
125
+  end
126
+
114 127
   local target = ruleViolationWindow:getChildById('nameText'):getText()
115
-  local reason = reasonsTextList:getFocusedChild().reasonId
116
-  local action = actionsTextList:getFocusedChild().actionId
128
+  local reason = reasonLabel.reasonId
129
+  local action = actionLabel.actionId
117 130
   local comment = ruleViolationWindow:getChildById('commentText'):getText()
118 131
   local statement = ruleViolationWindow:getChildById('statementText'):getText()
119 132
   local statementId = 0 -- TODO: message unique id ?

+ 1
- 4
src/client/game.cpp View File

@@ -1468,16 +1468,13 @@ void Game::setProtocolVersion(int version)
1468 1468
         enableFeature(Otc::GameProtocolChecksum);
1469 1469
         enableFeature(Otc::GameChallengeOnLogin);
1470 1470
         enableFeature(Otc::GameAccountNames);
1471
+        enableFeature(Otc::GameDoubleFreeCapacity);
1471 1472
     }
1472 1473
 
1473 1474
     if(version >= 780 && version <= 854) {          // 780 might not be accurate
1474 1475
         enableFeature(Otc::GameChargeableItems);
1475 1476
     }
1476 1477
 
1477
-    if(version >= 850) {
1478
-        enableFeature(Otc::GameDoubleFreeCapacity);
1479
-    }
1480
-
1481 1478
     if(version >= 854) {
1482 1479
         enableFeature(Otc::GameCreatureEmblems);
1483 1480
     }

+ 1
- 1
src/client/protocolcodes.cpp View File

@@ -57,7 +57,7 @@ void buildMessageModesMap(int version) {
57 57
         messageModesMap[Otc::MessageFailure]                 = 20;
58 58
         messageModesMap[Otc::MessageBlue]                    = 21;
59 59
         messageModesMap[Otc::MessageRed]                     = 22;
60
-    } else if(version >= 850) {
60
+    } else if(version >= 840) {
61 61
         messageModesMap[Otc::MessageNone]                    = 0;
62 62
         messageModesMap[Otc::MessageSay]                     = 1;
63 63
         messageModesMap[Otc::MessageWhisper]                 = 2;

+ 4
- 2
src/client/protocolgameparse.cpp View File

@@ -407,7 +407,9 @@ void ProtocolGame::parseGMActions(const InputMessagePtr& msg)
407 407
 
408 408
     int numViolationReasons;
409 409
 
410
-    if(g_game.getProtocolVersion() >= 850)
410
+    if(g_game.getProtocolVersion() >= 840)
411
+        numViolationReasons = 23;
412
+    else if(g_game.getProtocolVersion() >= 850)
411 413
         numViolationReasons = 20;
412 414
     else
413 415
         numViolationReasons = 32;
@@ -557,7 +559,7 @@ void ProtocolGame::parseTileAddThing(const InputMessagePtr& msg)
557 559
     Position pos = getPosition(msg);
558 560
     int stackPos = -1;
559 561
 
560
-    if(g_game.getProtocolVersion() >= 850)
562
+    if(g_game.getProtocolVersion() >= 841)
561 563
         stackPos = msg->getU8();
562 564
 
563 565
     ThingPtr thing = getThing(msg);

Loading…
Cancel
Save