Cmd/Rpc/TargetRpc/SyncEvent hashing uses hash(Type:Func) instead of hash(Func), so that Inventory.RpcUse is not called for Equipment.RpcUse etc. Original Weaver did this too, forgot to do it when moving hash calculation to HLAPI.

This commit is contained in:
vis2k 2018-12-31 13:59:34 +01:00
parent cbf8a462d0
commit 9fe8872968

View File

@ -94,7 +94,7 @@ protected void SendCommandInternal(string cmdName, NetworkWriter writer, int cha
CommandMessage message = new CommandMessage();
message.netId = netId;
message.componentIndex = ComponentIndex;
message.cmdHash = cmdName.GetStableHashCode();
message.cmdHash = (GetType() + ":" + cmdName).GetStableHashCode(); // type+func so Inventory.RpcUse != Equipment.RpcUse
message.payload = writer.ToArray();
ClientScene.readyConnection.Send((short)MsgType.Command, message, channelId);
@ -122,7 +122,7 @@ protected void SendRPCInternal(string rpcName, NetworkWriter writer, int channel
RpcMessage message = new RpcMessage();
message.netId = netId;
message.componentIndex = ComponentIndex;
message.rpcHash = rpcName.GetStableHashCode();
message.rpcHash = (GetType() + ":" + rpcName).GetStableHashCode(); // type+func so Inventory.RpcUse != Equipment.RpcUse
message.payload = writer.ToArray();
NetworkServer.SendToReady(gameObject, (short)MsgType.Rpc, message, channelId);
@ -142,7 +142,7 @@ protected void SendTargetRPCInternal(NetworkConnection conn, string rpcName, Net
RpcMessage message = new RpcMessage();
message.netId = netId;
message.componentIndex = ComponentIndex;
message.rpcHash = rpcName.GetStableHashCode();
message.rpcHash = (GetType() + ":" + rpcName).GetStableHashCode(); // type+func so Inventory.RpcUse != Equipment.RpcUse
message.payload = writer.ToArray();
conn.Send((short)MsgType.Rpc, message, channelId);
@ -169,7 +169,7 @@ protected void SendEventInternal(string eventName, NetworkWriter writer, int cha
SyncEventMessage message = new SyncEventMessage();
message.netId = netId;
message.componentIndex = ComponentIndex;
message.eventHash = eventName.GetStableHashCode();
message.eventHash = (GetType() + ":" + eventName).GetStableHashCode(); // type+func so Inventory.RpcUse != Equipment.RpcUse
message.payload = writer.ToArray();
NetworkServer.SendToReady(gameObject, (short)MsgType.SyncEvent, message, channelId);
@ -198,7 +198,7 @@ protected class Invoker
[EditorBrowsable(EditorBrowsableState.Never)]
protected static void RegisterDelegate(Type invokeClass, string cmdName, UNetInvokeType invokerType, CmdDelegate func)
{
int cmdHash = cmdName.GetStableHashCode();
int cmdHash = (invokeClass + ":" + cmdName).GetStableHashCode(); // type+func so Inventory.RpcUse != Equipment.RpcUse
if (s_CmdHandlerDelegates.ContainsKey(cmdHash))
{
return;