Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
inventoryinputuserdata.c
Go to the documentation of this file.
1
3{
5 static void SerializeMove(ParamsWriteContext ctx, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
6 {
8 ctx.Write(type);
9 src.WriteToContext(ctx);
10 dst.WriteToContext(ctx);
11 }
12
13 static void SendInputUserDataMove(int type, notnull InventoryLocation src, notnull InventoryLocation dst)
14 {
15 if (g_Game.IsClient())
16 {
17 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + g_Game.GetTime() + "ms sending cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
19 SerializeMove(ctx, type, src, dst);
20 ctx.Send();
21 }
22 }
23
25 {
27 item.GetInventory().GetCurrentInventoryLocation(il);
28 il.WriteToContext(ctx);
29 }
30
32 {
34 int nItems = items.Count();
36 ctx.Write(nItems);
37 for (int i = 0; i < nItems; ++i)
38 {
39 SerializeInventoryCheckForItem(ctx, items[i]);
40 }
41 ctx.Send();
42 }
43
45 {
46 ScriptRPC ctx = new ScriptRPC();
47 int nItems = items.Count();
48 ctx.Write(nItems);
49 for (int i = 0; i < nItems; i++)
50 {
51 SerializeInventoryCheckForItem(ctx, items[i]);
52 }
53
54 ctx.Send(player, ERPCs.RPC_ITEM_REPAIR, false, player.GetIdentity());
55 }
56
57 static void SendServerMove(Man player, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
58 {
59 if (g_Game.IsServer())
60 {
61 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] server sending cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
63 SerializeMove(ctx, type, src, dst);
64 GameInventory.ServerLocationSyncMoveEntity(player, src.GetItem(), ctx);
65 }
66 }
67
68
70 static void SerializeSwap(ParamsWriteContext ctx, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap)
71 {
74 src1.WriteToContext(ctx);
75 src2.WriteToContext(ctx);
76 dst1.WriteToContext(ctx);
77 dst2.WriteToContext(ctx);
78 ctx.Write(skippedSwap);
79 }
80
81 static void SendInputUserDataSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap = false)
82 {
83 if (g_Game.IsClient())
84 {
85 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + g_Game.GetTime() + "ms sending cmd=SWAP src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
87 SerializeSwap(ctx, src1, src2, dst1, dst2, skippedSwap);
88 ctx.Send();
89 }
90 }
91
92 static void SendServerSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap = false)
93 {
94 if (g_Game.IsServer())
95 {
96 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] server sending cmd=SWAP src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
98 SerializeSwap(ctx, src1, src2, dst1, dst2, skippedSwap);
99 GameInventory.ServerLocationSwap(src1, src2, dst1, dst2, ctx);
100 }
101 }
102
103
106 {
108 ctx.Write(InventoryCommandType.HAND_EVENT);
109 e.WriteToContext(ctx);
110 }
111
113 {
114 if (g_Game.IsClient())
115 {
116 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + g_Game.GetTime() + "ms SendInputUserDataHandEvent e=" + e.DumpToString());
118 SerializeHandEvent(ctx, e);
119 ctx.Send();
120 }
121 }
122
123 static void SendServerHandEventViaInventoryCommand(notnull Man player, HandEventBase e)
124 {
125 // Warning: this uses NetworkMessageInventoryCommand
126 if (g_Game.IsServer())
127 {
128 if (e.IsServerSideOnly())
129 Error("[syncinv] SendServerHandEvent - called on server side event only, e=" + e.DumpToString());
130 if (player.IsAlive())
131 Error("[syncinv] SendServerHandEvent - called on living thing.. server hand command is only for dead people, e=" + e.DumpToString());
132 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] SendServerHandEventViaInventoryCommand SendInputUserDataHandEvent e=" + e.DumpToString());
134 SerializeHandEvent(ctx, e);
135 GameInventory.ServerHandEvent(player, e.GetSrcEntity(), ctx);
136 }
137 }
138
139}
140
void syncDebugPrint(string s)
Definition debug.c:1
InventoryCommandType
Definition inventory.c:3
const int INPUT_UDT_INVENTORY
Definition _constants.c:9
const int INPUT_UDT_INVENTORY_CHECK
Definition _constants.c:19
script counterpart to engine's class Inventory
Definition inventory.c:81
static proto native bool ServerHandEvent(notnull Man player, notnull EntityAI item, ParamsWriteContext ctx)
static proto native bool ServerLocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, ParamsWriteContext ctx)
static proto native bool ServerLocationSyncMoveEntity(Man player, notnull EntityAI item, ParamsWriteContext ctx)
Abstracted event, not to be used, only inherited.
override string DumpToString()
override void WriteToContext(ParamsWriteContext ctx)
override bool IsServerSideOnly()
static void SerializeSwap(ParamsWriteContext ctx, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap)
swap
static void SendServerSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap=false)
static void SendInputUserDataHandEvent(HandEventBase e)
static void SendServerHandEventViaInventoryCommand(notnull Man player, HandEventBase e)
static void SendServerMove(Man player, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
static void SendServerInventoryCheck(array< EntityAI > items, DayZPlayer player)
static void SendInputUserDataSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap=false)
static void SerializeInventoryCheckForItem(ParamsWriteContext ctx, EntityAI item)
static void SendClientInventoryCheck(array< EntityAI > items)
static void SerializeHandEvent(ParamsWriteContext ctx, HandEventBase e)
hand
static void SendInputUserDataMove(int type, notnull InventoryLocation src, notnull InventoryLocation dst)
static void SerializeMove(ParamsWriteContext ctx, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
move
InventoryLocation.
static string DumpToStringNullSafe(InventoryLocation loc)
bool WriteToContext(ParamsWriteContext ctx)
static bool IsSyncLogEnable()
Definition debug.c:776
proto native void Send()
proto native void Send(Object target, int rpc_type, bool guaranteed, PlayerIdentity recipient=NULL)
Initiate remote procedure call.
proto bool Write(void value_out)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3942
ERPCs
Definition erpcs.c:2
Serializer ParamsWriteContext
Definition gameplay.c:16
void Error(string err)
Messagebox with error message.
Definition endebug.c:90