Pass partial information to guards so guards can do minimal checks if needed The guards can't prevent event so it would be incorrect to pass full InventoryValidation struct. We have to make sure guards don't inadvertantly produce different results in the FSM as that will create desync (two players attempting to put a rag into the same fireplace slot at the same time)
kumarjac: This indicates a failure in replication relationships as player full inventory should be synchronized always if player exists on the remote
TODO(kumarjac): Is this one correct to be 'RemoveMovableOverride' or are the other Validate methdos wrong with 'EnableMovableOverride'?
Do not check for action validity on remotes or when performing through juncture. Juncture locks guarentee the item is safe to interact with and the server has validated the command at this point. Checking at this point is both wasteful and can result in a failure which leads to desync
if it already happened on server, remote just needs to comply TODO(kumarjac): Move m_IsRemote check to inside of HandEventBase.CanPerformEventEx
Is called twice unfortunately... but it works so won't change
1520 {
1522 bool success = true;
1523
1525
1526
1528
1534
1535 EntityAI itemSrc = e.GetSrcEntity();
1537
1538 #ifdef ENABLE_LOGGING
1540 {
1541 Debug.
InventoryMoveLog(
"STS = " + e.m_Player.GetSimulationTimeStamp() +
" event= " + e.
DumpToString(),
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1542 }
1543 #endif
1544
1546 {
1547 Error(
"[syncinv] Inventory owner " + GetManOwner() +
" and event sender " + e.m_Player +
" do not match.");
1548 return true;
1549 }
1550
1552 {
1553 Error(
"[syncinv] ValidateHandEvent This event " + e.GetDebugName() +
" should not be use for synchronization.");
1554 return true;
1555 }
1556
1558 {
1561 {
1563 srcNew.
Copy(e.GetSrc());
1565
1566 Error(
"[syncinv] HandleInputData remote swap event REPLACED with TAKE (cmd=HAND_EVENT, event=" + e.
DumpToString() +
"), src item is null! Continuing.");
1567 }
1568 else
1569 {
1570 #ifdef ENABLE_LOGGING
1572 {
1573 Debug.
InventoryMoveLog(
"Failed - CheckRequestSrc",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1574 }
1575 #endif
1576
1577 Error(
"[syncinv] HandleInputData remote input (cmd=HAND_EVENT, event=" + e.
DumpToString() +
") dropped, item not in bubble");
1578
1579 return true;
1580 }
1581 }
1582
1584 if (itemSrc)
1586 if (itemDst)
1588
1593 {
1594 #ifdef ENABLE_LOGGING
1596 {
1597 Debug.
InventoryMoveLog(
"Failed - CheckRequestSrc",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1598 }
1599 #endif
1600
1602 {
1605 }
1606
1609
1611 {
1612 success = false;
1613 #ifdef DIAG_DEVELOPER
1614 if (PluginInventoryDebug.Cast(
GetPlugin(PluginInventoryDebug)).IsDesyncRepairEnable())
1615 {
1616 #endif
1619 if(!itemSrc)
1620 {
1621 return false;
1622 }
1623
1624 itemSrc.GetInventory().GetCurrentInventoryLocation(repairIl);
1625
1626 if(e.GetSrc() != repairIl)
1627 {
1628 itemsToRepair.Insert(itemSrc);
1629 }
1630
1631 if(itemDst && itemSrc != itemDst )
1632 {
1633 itemDst.GetInventory().GetCurrentInventoryLocation(repairIl);
1635 {
1636 itemsToRepair.Insert(itemDst);
1637 }
1638 }
1639
1640 if (itemsToRepair.Count())
1641 {
1643 }
1644 #ifdef DIAG_DEVELOPER
1645 }
1646 #endif
1647 }
1648 else
1649 {
1650 return true;
1651 }
1652 }
1653
1654 if (success && !e.CheckRequestEx(validation))
1655 {
1656 #ifdef ENABLE_LOGGING
1658 {
1659 Debug.
InventoryMoveLog(
"Failed - CheckRequest",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1660 }
1661 #endif
1662
1664
1667
1668#ifdef ENABLE_LOGGING
1670 {
1672 }
1673#endif
1674
1677
1679 {
1680 success = false;
1681 }
1682 else
1683 {
1684 return true;
1685 }
1686 }
1687
1691 {
1692 #ifdef ENABLE_LOGGING
1694 {
1695 Debug.
InventoryMoveLog(
"Failed - CanPerformEvent",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1696 }
1697 #endif
1698
1700
1703
1704#ifdef ENABLE_LOGGING
1706 {
1708 }
1709#endif
1710
1713
1715 {
1717 if (ilDst)
1719
1721 if (ilDst)
1723
1724 success = false;
1725 }
1726 else
1727 {
1728 return true;
1729 }
1730 }
1731
1734
1737 {
1740 {
1741 #ifdef ENABLE_LOGGING
1743 {
1744 Debug.
InventoryMoveLog(
"Juncture not required",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1745 }
1746 #endif
1747
1749 }
1751 {
1752 #ifdef ENABLE_LOGGING
1754 {
1755 Debug.
InventoryMoveLog(
"Juncture sended",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1756 }
1757 #endif
1758
1761
1763
1764 if (itemSrc)
1766 if (itemDst)
1768 return true;
1769 }
1770 else
1771 {
1772 #ifdef ENABLE_LOGGING
1774 {
1775 Debug.
InventoryMoveLog(
"Juncture denied",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1776 }
1777 #endif
1778
1781 return true;
1782 }
1783 }
1784
1786 {
1787 bool hasJuncture = false;
1788
1789 if (itemSrc != null && itemDst != null)
1790 {
1792 }
1793 else if (itemSrc != null)
1794 {
1796 }
1797 else if (itemDst != null)
1798 {
1800 }
1801
1802 if (!hasJuncture)
1803 {
1804#ifdef ENABLE_LOGGING
1806 {
1808 }
1809#endif
1810 success = false;
1811 }
1812 }
1813
1816 {
1818 }
1819
1820 #ifdef ENABLE_LOGGING
1822 {
1823 Debug.
InventoryMoveLog(
"Success - ProcessHandEvent",
"HAND_EVENT" ,
"n/a",
"ProcessInputData", e.m_Player.ToString() );
1824 }
1825 #endif
1826
1827 if (success)
1828 {
1830 if (!e.m_Player.GetHumanInventory().ProcessHandEvent(e))
1831 {
1833
1834 }
1835 }
1836
1837 return true;
1838 }
void syncDebugPrint(string s)
InventoryValidationResult
InventoryValidationReason
void EnableMovableOverride(EntityAI item)
void CheckForRope(InventoryLocation src, InventoryLocation dst)
void RemoveMovableOverride(EntityAI item)
void SendRepairToClientDst(notnull InventoryLocation dst)
DayZPlayer GetDayZPlayerOwner()
PluginBase GetPlugin(typename plugin_type)
static void InventoryMoveLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
override InventoryLocation GetSecondDst()
override InventoryLocation GetDst()
override bool AcquireInventoryJunctureFromServer(notnull Man player)
override EntityAI GetSecondSrcEntity()
override bool IsServerSideOnly()
override string DumpToString()
override void ClearInventoryReservation()
override bool CheckRequestSrc()
override bool CanPerformEventEx(InventoryValidation validation)
override InventoryLocation GetSecondSrc()
Abstracted event, not to be used, only inherited.
proto native InventoryLocation Copy(notnull InventoryLocation rhs)
copies location data to another location
InventoryValidationResult m_Result
InventoryValidationReason m_Reason
static bool IsSyncLogEnable()
static bool IsInventoryMoveLogEnable()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayerInstanceType
defined in C++
proto native DayZPlayerInstanceType GetInstanceType()
void Error(string err)
Messagebox with error message.