Add objects ID inverse mapping from client to server for proper C# networking codegen

This commit is contained in:
Wojtek Figat
2023-06-18 19:27:46 +02:00
parent dd8817582a
commit 228ef4e130
4 changed files with 49 additions and 11 deletions

View File

@@ -687,8 +687,6 @@ void NetworkReplicator::AddRPC(const ScriptingTypeHandle& typeHandle, const Stri
if (!typeHandle)
return;
const NetworkRpcName rpcName(typeHandle, GetCSharpCachedName(name));
NetworkRpcInfo rpcInfo;
rpcInfo.Server = isServer;
rpcInfo.Client = isClient;
@@ -698,6 +696,7 @@ void NetworkReplicator::AddRPC(const ScriptingTypeHandle& typeHandle, const Stri
rpcInfo.Tag = (void*)*(SerializeFunc*)&execute;
// Add to the global RPCs table
const NetworkRpcName rpcName(typeHandle, GetCSharpCachedName(name));
NetworkRpcInfo::RPCsTable[rpcName] = rpcInfo;
}
@@ -1110,11 +1109,13 @@ NetworkStream* NetworkReplicator::BeginInvokeRPC()
CachedWriteStream = New<NetworkStream>();
CachedWriteStream->Initialize();
CachedWriteStream->SenderId = NetworkManager::LocalClientId;
Scripting::ObjectsLookupIdMapping.Set(&IdsRemappingTable);
return CachedWriteStream;
}
void NetworkReplicator::EndInvokeRPC(ScriptingObject* obj, const ScriptingTypeHandle& type, const StringAnsiView& name, NetworkStream* argsStream, Span<uint32> targetIds)
{
Scripting::ObjectsLookupIdMapping.Set(nullptr);
const NetworkRpcInfo* info = NetworkRpcInfo::RPCsTable.TryGet(NetworkRpcName(type, name));
if (!info || !obj || NetworkManager::IsOffline())
return;