mirror of
https://github.com/Impostor/Impostor.git
synced 2026-10-20 01:46:11 +00:00
Add handler for phantom rpcs
This commit is contained in:
1 parent
2860ef6d6f
commit
eeab337c75
2 files changed
+99
-7
No files matched your search
@@ -149,5 +149,18 @@ namespace Impostor.Server.Net.Inner.Objects
|
||||
// Notify plugins.
|
||||
await _eventManager.CallAsync(new PlayerExileEvent(Game, Game.GetClientPlayer(OwnerId)!, this));
|
||||
}
|
||||
|
||||
public async ValueTask StartVanishAsync()
|
||||
{
|
||||
using var writer = Game.StartRpc(NetId, RpcCalls.StartVanish);
|
||||
await Game.FinishRpcAsync(writer);
|
||||
}
|
||||
|
||||
public async ValueTask StartAppearAsync(bool shouldAnimate)
|
||||
{
|
||||
using var writer = Game.StartRpc(NetId, RpcCalls.StartAppear);
|
||||
writer.Write(shouldAnimate);
|
||||
await Game.FinishRpcAsync(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -535,7 +535,7 @@ namespace Impostor.Server.Net.Inner.Objects
|
||||
}
|
||||
|
||||
Rpc62CheckVanish.Deserialize(reader, out var maxDuration);
|
||||
break;
|
||||
return await HandleCheckVanish(sender, maxDuration);
|
||||
|
||||
case RpcCalls.StartVanish:
|
||||
if (!await ValidateHost(call, sender) ||
|
||||
@@ -545,7 +545,7 @@ namespace Impostor.Server.Net.Inner.Objects
|
||||
}
|
||||
|
||||
Rpc63StartVanish.Deserialize(reader);
|
||||
break;
|
||||
return await HandleStartVanish(sender);
|
||||
|
||||
case RpcCalls.CheckAppear:
|
||||
if (!await ValidateOwnership(call, sender) ||
|
||||
@@ -555,8 +555,8 @@ namespace Impostor.Server.Net.Inner.Objects
|
||||
return false;
|
||||
}
|
||||
|
||||
Rpc64CheckAppear.Deserialize(reader, out bool shouldAnimate);
|
||||
break;
|
||||
Rpc64CheckAppear.Deserialize(reader, out var shouldAnimate);
|
||||
return await HandleCheckAppear(sender, shouldAnimate);
|
||||
|
||||
case RpcCalls.StartAppear:
|
||||
if (!await ValidateHost(call, sender) ||
|
||||
@@ -565,8 +565,8 @@ namespace Impostor.Server.Net.Inner.Objects
|
||||
return false;
|
||||
}
|
||||
|
||||
Rpc65StartAppear.Deserialize(reader, out _);
|
||||
break;
|
||||
Rpc65StartAppear.Deserialize(reader, out var shouldAnimate1);
|
||||
return await HandleStartAppear(sender, shouldAnimate1);
|
||||
|
||||
default:
|
||||
return await base.HandleRpcAsync(sender, target, call, reader);
|
||||
@@ -715,7 +715,7 @@ namespace Impostor.Server.Net.Inner.Objects
|
||||
if (name != expected)
|
||||
{
|
||||
// TODO fix
|
||||
//if (await sender.Client.ReportCheatAsync(RpcCalls.SetName, CheatCategory.NameLimits, $"Client sent SetName with incorrect name, got '{name}', expected '{expected}'"))
|
||||
// if (await sender.Client.ReportCheatAsync(RpcCalls.SetName, CheatCategory.NameLimits, $"Client sent SetName with incorrect name, got '{name}', expected '{expected}'"))
|
||||
//{
|
||||
// await SetNameAsync(expected);
|
||||
// return false;
|
||||
@@ -1054,5 +1054,84 @@ namespace Impostor.Server.Net.Inner.Objects
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private async ValueTask<bool> HandleCheckVanish(ClientPlayer sender, float maxDuration)
|
||||
{
|
||||
if (!await ValidateRole(RpcCalls.CheckVanish, sender, PlayerInfo, RoleTypes.Phantom))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_game.IsHostAuthoritive)
|
||||
{
|
||||
if (sender.IsHost)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Due to InnerSloth's bug, + 25 host will not do check vanish at its side
|
||||
// And it will send cmd check vanish to server
|
||||
// I tried sending it back to host but the charge loop still occurs even the host receive its own check vanish
|
||||
// Leave this for innersloth to fix their trash
|
||||
return true;
|
||||
|
||||
// pass rpc calls to authoritive host
|
||||
}
|
||||
|
||||
// There should be a maxDuration value check but I don't know how to read options from server
|
||||
// Server should reject the calls during meeting or other actions,
|
||||
// but since check murder doesnt have this check, I'm not doing it here
|
||||
await StartVanishAsync();
|
||||
return false;
|
||||
}
|
||||
|
||||
private async ValueTask<bool> HandleStartVanish(ClientPlayer sender)
|
||||
{
|
||||
if (!_game.IsHostAuthoritive)
|
||||
{
|
||||
if (await sender.Client.ReportCheatAsync(RpcCalls.StartVanish, CheatCategory.GameFlow, "Client tried to send start vanish directly"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// InnerSloth is writing maxDuration in check vanish. Not sure whether they gonna add a server side timer in the future.
|
||||
// Leave this method for future usage.
|
||||
return true;
|
||||
}
|
||||
|
||||
private async ValueTask<bool> HandleCheckAppear(ClientPlayer sender, bool shouldAnimate)
|
||||
{
|
||||
if (!await ValidateRole(RpcCalls.CheckAppear, sender, PlayerInfo, RoleTypes.Phantom))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_game.IsHostAuthoritive)
|
||||
{
|
||||
return true;
|
||||
|
||||
// pass rpc calls to authoritive host
|
||||
}
|
||||
|
||||
// Same as the above one
|
||||
await StartAppearAsync(shouldAnimate);
|
||||
return false;
|
||||
}
|
||||
|
||||
private async ValueTask<bool> HandleStartAppear(ClientPlayer sender, bool shouldAnimate)
|
||||
{
|
||||
if (!_game.IsHostAuthoritive)
|
||||
{
|
||||
if (await sender.Client.ReportCheatAsync(RpcCalls.StartAppear, CheatCategory.GameFlow, "Client tried to send start appear directly"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// It makes sense to check should animate bool under certain game process.
|
||||
// But since shapeshift not doing this, I gonna leave this method for future usage.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user