Accept RPC's called on GameManager

Previously Impostor would just throw when a method was called on a
GameManager, but this caused issues with client mods that did just this,
even through vanilla never calls an RPC on GameManager.

This commit changes that throw statement to pass the exception to the
custom message handler/anticheat instead, which is also how it works for
the other NetObjects
This commit is contained in:
miniduikboot committed 2024-06-13 20:52:25 +02:00
1 parent 468a71d01e
commit da0ee81b5d
2 files changed
+12 -4

No files matched your search

@@ -53,12 +53,20 @@ internal abstract class InnerGameManager : InnerNetObject, IInnerGameManager
public override async ValueTask<bool> HandleRpcAsync(ClientPlayer sender, ClientPlayer? target, RpcCalls call, IMessageReader reader)
{
// Let all logic components process this RPC. If at least one component handles it, return true.
var result = false;
foreach (var logicComponent in _logicComponents)
{
await logicComponent.HandleRpcAsync(call, reader);
result |= await logicComponent.HandleRpcAsync(call, reader);
}
return true;
// If no component accepted it, try and find a custom RPC that can deal with it.
if (!result)
{
result |= await base.HandleRpcAsync(sender, target, call, reader);
}
return result;
}
public override ValueTask<bool> SerializeAsync(IMessageWriter writer, bool initialState)
@@ -6,9 +6,9 @@ namespace Impostor.Server.Net.Inner.Objects.GameManager.Logic;
internal abstract class GameLogicComponent
{
public virtual ValueTask HandleRpcAsync(RpcCalls callId, IMessageReader reader)
public virtual ValueTask<bool> HandleRpcAsync(RpcCalls callId, IMessageReader reader)
{
throw new NotImplementedException($"Unhandled RpcCall {callId}");
return ValueTask.FromResult(false);
}
public virtual ValueTask<bool> SerializeAsync(IMessageWriter writer, bool initialState)