This commit is contained in:
@@ -16,7 +16,7 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// There is a client-side implementation of the method in <see cref="CampaignMode"/>
|
||||
/// </summary>
|
||||
public bool AllowedToManageCampaign(Client client, ClientPermissions permissions)
|
||||
public static bool AllowedToManageCampaign(Client client, ClientPermissions permissions)
|
||||
{
|
||||
//allow managing the campaign if the client has permissions, is the owner, or the only client in the server,
|
||||
//or if no-one has management permissions
|
||||
@@ -25,7 +25,8 @@ namespace Barotrauma
|
||||
client.HasPermission(ClientPermissions.ManageCampaign) ||
|
||||
GameMain.Server.ConnectedClients.Count == 1 ||
|
||||
IsOwner(client) ||
|
||||
GameMain.Server.ConnectedClients.None(c => c.InGame && (IsOwner(c) || c.HasPermission(permissions)));
|
||||
//allow managing if no-one with permissions is alive
|
||||
GameMain.Server.ConnectedClients.None(c => c.InGame && c.Character is { IsIncapacitated: false, IsDead: false } && (IsOwner(c) || c.HasPermission(permissions)));
|
||||
}
|
||||
|
||||
public bool AllowedToManageWallets(Client client)
|
||||
|
||||
+1
-1
@@ -1019,7 +1019,7 @@ namespace Barotrauma
|
||||
UpgradeManager.PurchaseUpgrade(prefab, category, client: sender);
|
||||
|
||||
// unstable logging
|
||||
int price = prefab.Price.GetBuyprice(UpgradeManager.GetUpgradeLevel(prefab, category), Map?.CurrentLocation);
|
||||
int price = prefab.Price.GetBuyPrice(UpgradeManager.GetUpgradeLevel(prefab, category), Map?.CurrentLocation);
|
||||
int level = UpgradeManager.GetUpgradeLevel(prefab, category);
|
||||
GameServer.Log($"SERVER: Purchased level {level} {category.Identifier}.{prefab.Identifier} for {price}", ServerLog.MessageType.ServerMessage);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
var allowOutpostAutoDocking = (AllowOutpostAutoDocking)msg.ReadByte();
|
||||
if (outpostAutoDockingPromptShown &&
|
||||
(GameMain.GameSession?.Campaign?.AllowedToManageCampaign(c, ClientPermissions.ManageMap) ?? false))
|
||||
CampaignMode.AllowedToManageCampaign(c, ClientPermissions.ManageMap))
|
||||
{
|
||||
this.allowOutpostAutoDocking = allowOutpostAutoDocking;
|
||||
}
|
||||
|
||||
@@ -496,9 +496,18 @@ namespace Barotrauma.Networking
|
||||
// -> something wen't wrong during startup, re-enable start button and reset AutoRestartTimer
|
||||
if (startGameCoroutine != null && !CoroutineManager.IsCoroutineRunning(startGameCoroutine))
|
||||
{
|
||||
if (ServerSettings.AutoRestart) ServerSettings.AutoRestartTimer = Math.Max(ServerSettings.AutoRestartInterval, 5.0f);
|
||||
//GameMain.NetLobbyScreen.StartButtonEnabled = true;
|
||||
if (ServerSettings.AutoRestart) { ServerSettings.AutoRestartTimer = Math.Max(ServerSettings.AutoRestartInterval, 5.0f); }
|
||||
|
||||
if (startGameCoroutine.Exception != null && OwnerConnection != null)
|
||||
{
|
||||
SendConsoleMessage(
|
||||
startGameCoroutine.Exception.Message + '\n' +
|
||||
(startGameCoroutine.Exception.StackTrace?.CleanupStackTrace() ?? "null"),
|
||||
connectedClients.Find(c => c.Connection == OwnerConnection),
|
||||
Color.Red);
|
||||
}
|
||||
|
||||
EndGame();
|
||||
GameMain.NetLobbyScreen.LastUpdateID++;
|
||||
|
||||
startGameCoroutine = null;
|
||||
@@ -1390,9 +1399,9 @@ namespace Barotrauma.Networking
|
||||
bool end = inc.ReadBoolean();
|
||||
if (end)
|
||||
{
|
||||
if (mpCampaign == null ||
|
||||
mpCampaign.AllowedToManageCampaign(sender, ClientPermissions.ManageRound) ||
|
||||
mpCampaign.AllowedToManageCampaign(sender, ClientPermissions.ManageCampaign))
|
||||
if (mpCampaign == null ||
|
||||
CampaignMode.AllowedToManageCampaign(sender, ClientPermissions.ManageRound) ||
|
||||
CampaignMode.AllowedToManageCampaign(sender, ClientPermissions.ManageCampaign))
|
||||
{
|
||||
bool save = inc.ReadBoolean();
|
||||
if (GameStarted)
|
||||
@@ -1422,7 +1431,7 @@ namespace Barotrauma.Networking
|
||||
SendDirectChatMessage("Cannot continue the campaign from the previous save (round already running).", sender, ChatMessageType.Error);
|
||||
break;
|
||||
}
|
||||
else if (mpCampaign.AllowedToManageCampaign(sender, ClientPermissions.ManageCampaign) || mpCampaign.AllowedToManageCampaign(sender, ClientPermissions.ManageMap))
|
||||
else if (CampaignMode.AllowedToManageCampaign(sender, ClientPermissions.ManageCampaign) || CampaignMode.AllowedToManageCampaign(sender, ClientPermissions.ManageMap))
|
||||
{
|
||||
MultiPlayerCampaign.LoadCampaign(GameMain.GameSession.SavePath);
|
||||
}
|
||||
@@ -1433,7 +1442,7 @@ namespace Barotrauma.Networking
|
||||
Log("Client \"" + ClientLogName(sender) + "\" started the round.", ServerLog.MessageType.ServerMessage);
|
||||
StartGame();
|
||||
}
|
||||
else if (mpCampaign != null && (mpCampaign.AllowedToManageCampaign(sender, ClientPermissions.ManageCampaign) || mpCampaign.AllowedToManageCampaign(sender, ClientPermissions.ManageMap)))
|
||||
else if (mpCampaign != null && (CampaignMode.AllowedToManageCampaign(sender, ClientPermissions.ManageCampaign) || CampaignMode.AllowedToManageCampaign(sender, ClientPermissions.ManageMap)))
|
||||
{
|
||||
var availableTransition = mpCampaign.GetAvailableTransition(out _, out _);
|
||||
//don't force location if we've teleported
|
||||
@@ -2013,7 +2022,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
//and assume the message was received, so we don't have to keep resending
|
||||
//these large initial messages until the client acknowledges receiving them
|
||||
c.LastRecvLobbyUpdate++;
|
||||
c.LastRecvLobbyUpdate = GameMain.NetLobbyScreen.LastUpdateID;
|
||||
|
||||
}
|
||||
else
|
||||
@@ -2032,7 +2041,7 @@ namespace Barotrauma.Networking
|
||||
c.ChatMsgQueue.RemoveAll(cMsg => !NetIdUtils.IdMoreRecent(cMsg.NetStateID, c.LastRecvChatMsgID));
|
||||
for (int i = 0; i < c.ChatMsgQueue.Count && i < ChatMessage.MaxMessagesPerPacket; i++)
|
||||
{
|
||||
if (outmsg.LengthBytes + c.ChatMsgQueue[i].EstimateLengthBytesServer(c) > MsgConstants.MTU - 5)
|
||||
if (outmsg.LengthBytes + c.ChatMsgQueue[i].EstimateLengthBytesServer(c) > MsgConstants.MTU - 5 && i > 0)
|
||||
{
|
||||
//not enough room in this packet
|
||||
return;
|
||||
@@ -2616,19 +2625,17 @@ namespace Barotrauma.Networking
|
||||
|
||||
public void EndGame(CampaignMode.TransitionType transitionType = CampaignMode.TransitionType.None, bool wasSaved = false)
|
||||
{
|
||||
if (!GameStarted)
|
||||
if (GameStarted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (GameSettings.CurrentConfig.VerboseLogging)
|
||||
{
|
||||
Log("Ending the round...\n" + Environment.StackTrace.CleanupStackTrace(), ServerLog.MessageType.ServerMessage);
|
||||
|
||||
if (GameSettings.CurrentConfig.VerboseLogging)
|
||||
{
|
||||
Log("Ending the round...\n" + Environment.StackTrace.CleanupStackTrace(), ServerLog.MessageType.ServerMessage);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Ending the round...", ServerLog.MessageType.ServerMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Ending the round...", ServerLog.MessageType.ServerMessage);
|
||||
}
|
||||
}
|
||||
|
||||
string endMessage = TextManager.FormatServerMessage("RoundSummaryRoundHasEnded");
|
||||
@@ -2641,7 +2648,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
List<Mission> missions = GameMain.GameSession.Missions.ToList();
|
||||
if (GameMain.GameSession.IsRunning)
|
||||
if (GameMain.GameSession is { IsRunning: true })
|
||||
{
|
||||
GameMain.GameSession.EndRound(endMessage, traitorResults);
|
||||
}
|
||||
@@ -2667,7 +2674,10 @@ namespace Barotrauma.Networking
|
||||
c.PositionUpdateLastSent.Clear();
|
||||
}
|
||||
|
||||
KarmaManager.OnRoundEnded();
|
||||
if (GameStarted)
|
||||
{
|
||||
KarmaManager.OnRoundEnded();
|
||||
}
|
||||
|
||||
RespawnManager = null;
|
||||
GameStarted = false;
|
||||
|
||||
Reference in New Issue
Block a user