new hook call method + function to delegate conversion

This commit is contained in:
Oiltanker
2022-04-15 17:15:45 +03:00
parent 891efb4c4f
commit 3eba20ecb7
39 changed files with 470 additions and 676 deletions
@@ -184,9 +184,9 @@ namespace Barotrauma.Networking
var skipDeny = false;
{
var result = new LuaResult(GameMain.LuaCs.HookBase.Call("lidgren.handleConnection", inc));
if (!result.IsNull()) {
if (result.Bool()) skipDeny = true;
var result = GameMain.LuaCs.Hook.Call<bool?>("lidgren.handleConnection", inc);
if (result != null) {
if (result.Value) skipDeny = true;
else return;
}
}
@@ -206,18 +206,16 @@ namespace Barotrauma.Networking
protected void UpdatePendingClient(PendingClient pendingClient)
{
var result = new LuaResult(GameMain.LuaCs.HookBase.Call("handlePendingClient", pendingClient));
var skipRemove = false;
var result = GameMain.LuaCs.Hook.Call<bool?>("handlePendingClient", pendingClient);
if (result.Bool())
goto ignore;
if (result != null) skipRemove = result.Value;
if (connectedClients.Count >= serverSettings.MaxPlayers)
if (!skipRemove && connectedClients.Count >= serverSettings.MaxPlayers)
{
RemovePendingClient(pendingClient, DisconnectReason.ServerFull, "");
}
ignore:
if (IsPendingClientBanned(pendingClient, out string banReason))
{
RemovePendingClient(pendingClient, DisconnectReason.Banned, banReason);