Implement Rpc 44: SetRole

This commit is contained in:
miniduikboot committed 2021-11-12 22:56:35 +01:00
1 parent c3e0157209
commit 93c80c1412
2 files changed
+30

No files matched your search

@@ -0,0 +1,17 @@
using Impostor.Api.Innersloth;
namespace Impostor.Api.Net.Messages.Rpcs
{
public static class Rpc44SetRole
{
public static void Serialize(IMessageWriter writer, RoleTypes role)
{
writer.Write((ushort)role);
}
public static void Deserialize(IMessageReader reader, out RoleTypes role)
{
role = (RoleTypes)reader.ReadUInt16();
}
}
}
@@ -342,6 +342,19 @@ namespace Impostor.Server.Net.Inner.Objects
break;
}
case RpcCalls.SetRole:
{
if (!await ValidateHost(call, sender))
{
return false;
}
Rpc44SetRole.Deserialize(reader, out var role);
PlayerInfo.RoleType = role;
break;
}
default:
return await base.HandleRpcAsync(sender, target, call, reader);
}