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
@@ -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);