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

Method ParseWindowClick

src/Protocol/Protocol125.cpp:1600–1655  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1598
1599
1600int cProtocol125::ParseWindowClick(void)
1601{
1602 HANDLE_PACKET_READ(ReadChar, char, WindowID);
1603 HANDLE_PACKET_READ(ReadBEShort, short, SlotNum);
1604 HANDLE_PACKET_READ(ReadBool, bool, IsRightClick);
1605 HANDLE_PACKET_READ(ReadBEShort, short, TransactionID);
1606 HANDLE_PACKET_READ(ReadBool, bool, IsShiftPressed);
1607 cItem HeldItem;
1608 int res = ParseItem(HeldItem);
1609 if (res < 0)
1610 {
1611 return res;
1612 }
1613
1614 // Convert IsShiftPressed, IsRightClick, SlotNum and HeldItem into eClickAction used in the newer protocols:
1615 eClickAction Action;
1616 if (IsRightClick)
1617 {
1618 if (IsShiftPressed)
1619 {
1620 Action = caShiftRightClick;
1621 }
1622 else
1623 {
1624 if (SlotNum == -999)
1625 {
1626 Action = (HeldItem.IsEmpty()) ? caRightClickOutsideHoldNothing : caRightClickOutside;
1627 }
1628 else
1629 {
1630 Action = caRightClick;
1631 }
1632 }
1633 }
1634 else
1635 {
1636 // IsLeftClick
1637 if (IsShiftPressed)
1638 {
1639 Action = caShiftLeftClick;
1640 }
1641 else
1642 {
1643 if (SlotNum == -999)
1644 {
1645 Action = (HeldItem.IsEmpty()) ? caLeftClickOutsideHoldNothing : caRightClickOutside;
1646 }
1647 else
1648 {
1649 Action = caLeftClick;
1650 }
1651 }
1652 }
1653 m_Client->HandleWindowClick(WindowID, SlotNum, Action, HeldItem);
1654 return PARSE_OK;
1655}
1656
1657

Callers

nothing calls this directly

Calls 2

HandleWindowClickMethod · 0.80
IsEmptyMethod · 0.45

Tested by

no test coverage detected