Fixes for the new update

This commit is contained in:
EvilFactory
2024-10-22 13:02:59 -03:00
parent 30a8f0c561
commit 14d3402b8d
5 changed files with 24 additions and 21 deletions
@@ -166,11 +166,6 @@ namespace Barotrauma.Networking
partial void UpdateWaiting(TeamSpecificState teamSpecificState) partial void UpdateWaiting(TeamSpecificState teamSpecificState)
{ {
if (!GameMain.LuaCs.Game.overrideRespawnSub)
{
RespawnShuttle.Velocity = Vector2.Zero;
}
//no respawns in the first minute of the round - otherwise it can be that bots //no respawns in the first minute of the round - otherwise it can be that bots
//are respawned to "fill" the spots of players who are taking a long time to load in //are respawned to "fill" the spots of players who are taking a long time to load in
if (GameMain.GameSession is { RoundDuration: < 60 }) if (GameMain.GameSession is { RoundDuration: < 60 })
@@ -180,7 +175,7 @@ namespace Barotrauma.Networking
var teamId = teamSpecificState.TeamID; var teamId = teamSpecificState.TeamID;
var respawnShuttle = GetShuttle(teamId); var respawnShuttle = GetShuttle(teamId);
if (respawnShuttle != null) if (respawnShuttle != null && !GameMain.LuaCs.Game.overrideRespawnSub)
{ {
respawnShuttle.Velocity = Vector2.Zero; respawnShuttle.Velocity = Vector2.Zero;
} }
@@ -228,7 +223,7 @@ namespace Barotrauma.Networking
} }
} }
private void DispatchShuttle(TeamSpecificState teamSpecificState) public void DispatchShuttle(TeamSpecificState teamSpecificState)
{ {
if (RespawnShuttles.Any()) if (RespawnShuttles.Any())
{ {
@@ -45,7 +45,6 @@ defaultLib["WearableType"] = CreateEnum("Barotrauma.WearableType")
defaultLib["NumberType"] = CreateEnum("Barotrauma.NumberType") defaultLib["NumberType"] = CreateEnum("Barotrauma.NumberType")
defaultLib["ChatMode"] = CreateEnum("Barotrauma.ChatMode") defaultLib["ChatMode"] = CreateEnum("Barotrauma.ChatMode")
defaultLib["CharacterType"] = CreateEnum("Barotrauma.CharacterType") defaultLib["CharacterType"] = CreateEnum("Barotrauma.CharacterType")
defaultLib["MissionType"] = CreateEnum("Barotrauma.MissionType")
defaultLib["VoteType"] = CreateEnum("Barotrauma.Networking.VoteType") defaultLib["VoteType"] = CreateEnum("Barotrauma.Networking.VoteType")
defaultLib["CanEnterSubmarine"] = CreateEnum("Barotrauma.CanEnterSubmarine") defaultLib["CanEnterSubmarine"] = CreateEnum("Barotrauma.CanEnterSubmarine")
defaultLib["InputType"] = CreateStatic("Barotrauma.InputType") defaultLib["InputType"] = CreateStatic("Barotrauma.InputType")
@@ -65,6 +65,7 @@ RegisterBarotrauma("DestructibleLevelWall")
RegisterBarotrauma("Biome") RegisterBarotrauma("Biome")
RegisterBarotrauma("Map") RegisterBarotrauma("Map")
RegisterBarotrauma("Networking.RespawnManager") RegisterBarotrauma("Networking.RespawnManager")
RegisterBarotrauma("Networking.RespawnManager+TeamSpecificState")
RegisterBarotrauma("Character") RegisterBarotrauma("Character")
RegisterBarotrauma("CharacterPrefab") RegisterBarotrauma("CharacterPrefab")
@@ -340,13 +340,11 @@ namespace Barotrauma
public static Submarine GetRespawnSub() public static Submarine GetRespawnSub()
{ {
#if SERVER #if SERVER
if (GameMain.Server.RespawnManager == null) if (GameMain.Server.RespawnManager == null) { return null; }
return null; return GameMain.Server.RespawnManager.GetShuttle(CharacterTeamType.Team1);
return GameMain.Server.RespawnManager.RespawnShuttle;
#else #else
if (GameMain.Client.RespawnManager == null) if (GameMain.Client.RespawnManager == null) { return null; }
return null; return GameMain.Client.RespawnManager.GetShuttle(CharacterTeamType.Team1);
return GameMain.Client.RespawnManager.RespawnShuttle;
#endif #endif
} }
@@ -470,18 +468,18 @@ namespace Barotrauma
public void SaveGame(string path) public void SaveGame(string path)
{ {
if (!LuaCsFile.CanWriteToPath(path)) { throw new ScriptRuntimeException($"Saving files to {path} is disallowed."); } if (!LuaCsFile.CanWriteToPath(path)) { throw new ScriptRuntimeException($"Saving files to {path} is disallowed."); }
SaveUtil.SaveGame(path); SaveUtil.SaveGame(CampaignDataPath.CreateRegular(path));
} }
public void LoadGame(string path) public void LoadGame(string path)
{ {
SaveUtil.LoadGame(path); SaveUtil.LoadGame(CampaignDataPath.CreateRegular(path));
} }
#if SERVER #if SERVER
public void LoadCampaign(string path, Client client = null) public void LoadCampaign(string path, Client client = null)
{ {
MultiPlayerCampaign.LoadCampaign(path, client); MultiPlayerCampaign.LoadCampaign(CampaignDataPath.CreateRegular(path), client);
} }
public static void SendMessage(string msg, ChatMessageType? messageType = null, Client sender = null, Character character = null) public static void SendMessage(string msg, ChatMessageType? messageType = null, Client sender = null, Character character = null)
@@ -513,10 +511,10 @@ namespace Barotrauma
public static void DispatchRespawnSub() public static void DispatchRespawnSub()
{ {
GameMain.Server.RespawnManager.DispatchShuttle(); GameMain.Server.RespawnManager.DispatchShuttle(GameMain.Server.RespawnManager.GetTeamSpecificState(CharacterTeamType.Team1));
} }
public static bool StartGame() public static GameServer.TryStartGameResult StartGame()
{ {
return GameMain.Server.TryStartGame(); return GameMain.Server.TryStartGame();
} }
@@ -44,7 +44,7 @@ namespace Barotrauma.Networking
private readonly Dictionary<CharacterTeamType, List<Door>> shuttleDoors = new Dictionary<CharacterTeamType, List<Door>>(); private readonly Dictionary<CharacterTeamType, List<Door>> shuttleDoors = new Dictionary<CharacterTeamType, List<Door>>();
private readonly Dictionary<CharacterTeamType, List<ItemContainer>> respawnContainers = new Dictionary<CharacterTeamType, List<ItemContainer>>(); private readonly Dictionary<CharacterTeamType, List<ItemContainer>> respawnContainers = new Dictionary<CharacterTeamType, List<ItemContainer>>();
private class TeamSpecificState public class TeamSpecificState
{ {
public readonly CharacterTeamType TeamID; public readonly CharacterTeamType TeamID;
@@ -267,7 +267,7 @@ namespace Barotrauma.Networking
partial void UpdateReturningProjSpecific(TeamSpecificState teamSpecificState, float deltaTime); partial void UpdateReturningProjSpecific(TeamSpecificState teamSpecificState, float deltaTime);
private Submarine GetShuttle(CharacterTeamType team) public Submarine GetShuttle(CharacterTeamType team)
{ {
if (respawnShuttles.TryGetValue(team, out Submarine sub)) if (respawnShuttles.TryGetValue(team, out Submarine sub))
{ {
@@ -276,6 +276,16 @@ namespace Barotrauma.Networking
return null; return null;
} }
public TeamSpecificState GetTeamSpecificState(CharacterTeamType team)
{
if (teamSpecificStates.TryGetValue(team, out TeamSpecificState state))
{
return state;
}
return null;
}
private void ResetShuttle(TeamSpecificState teamSpecificState) private void ResetShuttle(TeamSpecificState teamSpecificState)
{ {
teamSpecificState.ReturnTime = DateTime.Now + new TimeSpan(0, 0, 0, 0, milliseconds: (int)(maxTransportTime * 1000)); teamSpecificState.ReturnTime = DateTime.Now + new TimeSpan(0, 0, 0, 0, milliseconds: (int)(maxTransportTime * 1000));