new hook call method + function to delegate conversion
This commit is contained in:
@@ -133,9 +133,9 @@ namespace Barotrauma.Networking
|
||||
return;
|
||||
}
|
||||
|
||||
var should = new LuaResult(GameMain.LuaCs.HookBase.Call("chatMessage", txt, c, type));
|
||||
var should = GameMain.LuaCs.Hook.Call<bool?>("chatMessage", txt, c, type);
|
||||
|
||||
if (should.Bool())
|
||||
if (should != null && should.Value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace Barotrauma.Networking
|
||||
SendConsoleMessage("Granted all permissions to " + newClient.Name + ".", newClient);
|
||||
}
|
||||
|
||||
GameMain.LuaCs.HookBase.Call("clientConnected", newClient);
|
||||
GameMain.LuaCs.Hook.Call("clientConnected", newClient);
|
||||
|
||||
|
||||
SendChatMessage($"ServerMessage.JoinedServer~[client]={clName}", ChatMessageType.Server, null, changeType: PlayerConnectionChangeType.Joined);
|
||||
@@ -1804,7 +1804,7 @@ namespace Barotrauma.Networking
|
||||
outmsg.Write((byte)ServerNetObject.CLIENT_LIST);
|
||||
outmsg.Write(LastClientListUpdateID);
|
||||
|
||||
GameMain.LuaCs.HookBase.Call("writeClientList", c, outmsg);
|
||||
GameMain.LuaCs.Hook.Call("writeClientList", c, outmsg);
|
||||
|
||||
outmsg.Write((byte)connectedClients.Count);
|
||||
foreach (Client client in connectedClients)
|
||||
@@ -2251,7 +2251,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
AssignJobs(teamClients);
|
||||
|
||||
var result = new LuaResult(GameMain.LuaCs.HookBase.Call("jobsAssigned"));
|
||||
GameMain.LuaCs.Hook.Call("jobsAssigned");
|
||||
|
||||
List<CharacterInfo> characterInfos = new List<CharacterInfo>();
|
||||
foreach (Client client in teamClients)
|
||||
@@ -2455,7 +2455,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
roundStartTime = DateTime.Now;
|
||||
|
||||
GameMain.LuaCs.HookBase.Call("roundStart");
|
||||
GameMain.LuaCs.Hook.Call("roundStart");
|
||||
|
||||
startGameCoroutine = null;
|
||||
yield return CoroutineStatus.Success;
|
||||
@@ -2586,7 +2586,7 @@ namespace Barotrauma.Networking
|
||||
Log("Ending the round...", ServerLog.MessageType.ServerMessage);
|
||||
}
|
||||
|
||||
GameMain.LuaCs.HookBase.Call("roundEnd");
|
||||
GameMain.LuaCs.Hook.Call("roundEnd");
|
||||
|
||||
|
||||
string endMessage = TextManager.FormatServerMessage("RoundSummaryRoundHasEnded");
|
||||
@@ -2697,12 +2697,12 @@ namespace Barotrauma.Networking
|
||||
newName = Client.SanitizeName(newName);
|
||||
if (newName == c.Name && newJob == c.PreferredJob && newTeam == c.PreferredTeam) { return false; }
|
||||
|
||||
var result = new LuaResult(GameMain.LuaCs.HookBase.Call("tryChangeClientName", c, newName, newJob, newTeam));
|
||||
var result = GameMain.LuaCs.Hook.Call<bool?>("tryChangeClientName", c, newName, newJob, newTeam);
|
||||
|
||||
if (!result.IsNull())
|
||||
if (result != null)
|
||||
{
|
||||
LastClientListUpdateID++;
|
||||
return result.Bool();
|
||||
return result.Value;
|
||||
}
|
||||
|
||||
c.PreferredJob = newJob;
|
||||
@@ -2892,7 +2892,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (client == null) return;
|
||||
|
||||
GameMain.LuaCs.HookBase.Call("clientDisconnected", client);
|
||||
GameMain.LuaCs.Hook.Call("clientDisconnected", client);
|
||||
|
||||
if (gameStarted && client.Character != null)
|
||||
{
|
||||
@@ -3142,9 +3142,9 @@ namespace Barotrauma.Networking
|
||||
|
||||
var hookChatMsg = ChatMessage.Create(senderName, message, (ChatMessageType)type, senderCharacter, senderClient, changeType);
|
||||
|
||||
var should = new LuaResult(GameMain.LuaCs.HookBase.Call("modifyChatMessage", hookChatMsg, senderRadio));
|
||||
var should = GameMain.LuaCs.Hook.Call<bool?>("modifyChatMessage", hookChatMsg, senderRadio);
|
||||
|
||||
if (should.Bool())
|
||||
if (should != null && should.Value)
|
||||
return;
|
||||
|
||||
|
||||
@@ -3874,7 +3874,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (GameMain.Server == null || !GameMain.Server.ServerSettings.SaveServerLogs) { return; }
|
||||
|
||||
GameMain.LuaCs?.HookBase?.Call("serverLog", line, messageType);
|
||||
GameMain.LuaCs?.Hook?.Call("serverLog", line, messageType);
|
||||
|
||||
GameMain.Server.ServerSettings.ServerLog.WriteLine(line, messageType);
|
||||
|
||||
|
||||
+3
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-6
@@ -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);
|
||||
|
||||
@@ -94,19 +94,19 @@ namespace Barotrauma.Networking
|
||||
ChatMessage.CanUseRadio(sender.Character, out WifiComponent senderRadio) &&
|
||||
ChatMessage.CanUseRadio(recipient.Character, out WifiComponent recipientRadio))
|
||||
{
|
||||
var should = new LuaResult(GameMain.LuaCs.HookBase.Call("canUseVoiceRadio", new object[] { sender, recipient }));
|
||||
var should = GameMain.LuaCs.Hook.Call<bool?>("canUseVoiceRadio", new object[] { sender, recipient });
|
||||
|
||||
if (!should.IsNull())
|
||||
return should.Bool();
|
||||
if (should != null)
|
||||
return should.Value;
|
||||
|
||||
if (recipientRadio.CanReceive(senderRadio)) { return true; }
|
||||
}
|
||||
|
||||
var should2 = new LuaResult(GameMain.LuaCs.HookBase.Call("changeLocalVoiceRange", new object[] { sender, recipient }));
|
||||
var should2 = GameMain.LuaCs.Hook.Call<float?>("changeLocalVoiceRange", sender, recipient);
|
||||
float range = 1.0f;
|
||||
|
||||
if (!should2.IsNull())
|
||||
range = should2.Float();
|
||||
if (should2 != null)
|
||||
range = should2.Value;
|
||||
|
||||
|
||||
//otherwise do a distance check
|
||||
|
||||
Reference in New Issue
Block a user