MCPcopy Create free account
hub / github.com/cuberite/cuberite / ParseWindowClick

Method ParseWindowClick

src/Protocol/Protocol15x.cpp:150–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148
149
150int cProtocol150::ParseWindowClick(void)
151{
152 HANDLE_PACKET_READ(ReadChar, char, WindowID);
153 HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
154 HANDLE_PACKET_READ(ReadByte, Byte, Button);
155 HANDLE_PACKET_READ(ReadBEShort, short, TransactionID);
156 HANDLE_PACKET_READ(ReadByte, Byte, Mode);
157 cItem HeldItem;
158 int res = ParseItem(HeldItem);
159 if (res < 0)
160 {
161 return res;
162 }
163
164 // Convert Button, Mode, SlotNum and HeldItem into eClickAction:
165 eClickAction Action = caUnknown;
166 switch ((Mode << 8) | Button)
167 {
168 case 0x0000: Action = (SlotNum != -999) ? caLeftClick : caLeftClickOutside; break;
169 case 0x0001: Action = (SlotNum != -999) ? caRightClick : caRightClickOutside; break;
170 case 0x0100: Action = caShiftLeftClick; break;
171 case 0x0101: Action = caShiftRightClick; break;
172 case 0x0200: Action = caNumber1; break;
173 case 0x0201: Action = caNumber2; break;
174 case 0x0202: Action = caNumber3; break;
175 case 0x0203: Action = caNumber4; break;
176 case 0x0204: Action = caNumber5; break;
177 case 0x0205: Action = caNumber6; break;
178 case 0x0206: Action = caNumber7; break;
179 case 0x0207: Action = caNumber8; break;
180 case 0x0208: Action = caNumber9; break;
181 case 0x0300: Action = caMiddleClick; break;
182 case 0x0400: Action = (SlotNum == -999) ? caLeftClickOutsideHoldNothing : caDropKey; break;
183 case 0x0401: Action = (SlotNum == -999) ? caRightClickOutsideHoldNothing : caCtrlDropKey; break;
184 case 0x0500: Action = (SlotNum == -999) ? caLeftPaintBegin : caUnknown; break;
185 case 0x0501: Action = (SlotNum != -999) ? caLeftPaintProgress : caUnknown; break;
186 case 0x0502: Action = (SlotNum == -999) ? caLeftPaintEnd : caUnknown; break;
187 case 0x0504: Action = (SlotNum == -999) ? caRightPaintBegin : caUnknown; break;
188 case 0x0505: Action = (SlotNum != -999) ? caRightPaintProgress : caUnknown; break;
189 case 0x0506: Action = (SlotNum == -999) ? caRightPaintEnd : caUnknown; break;
190 case 0x0600: Action = caDblClick; break;
191 }
192
193 if (Action == caUnknown)
194 {
195 LOGWARNING("Received an unknown click action combination: Mode = %d, Button = %d, Slot = %d, HeldItem = %s. Ignoring packet.",
196 Mode, Button, SlotNum, ItemToFullString(HeldItem).c_str()
197 );
198 ASSERT(!"Unknown click action");
199 return PARSE_OK;
200 }
201
202 m_Client->HandleWindowClick(WindowID, SlotNum, Action, HeldItem);
203 return PARSE_OK;
204}
205
206
207

Callers

nothing calls this directly

Calls 3

ItemToFullStringFunction · 0.85
c_strMethod · 0.80
HandleWindowClickMethod · 0.80

Tested by

no test coverage detected