diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index 6ea6cfbad..ea2f467ca 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -1073,6 +1073,7 @@ namespace Barotrauma.Networking else { outmsg.Write(campaign.LastSaveID); + outmsg.Write(campaign.CampaignID); outmsg.Write(campaign.LastUpdateID); } diff --git a/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/MultiplayerCampaign.cs b/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/MultiplayerCampaign.cs index fb3d8d751..1c5c25487 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/MultiplayerCampaign.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/MultiplayerCampaign.cs @@ -30,9 +30,18 @@ namespace Barotrauma set; } + private static byte currentCampaignID; + + public byte CampaignID + { + get; private set; + } + public MultiplayerCampaign(GameModePreset preset, object param) : base(preset, param) { + currentCampaignID++; + CampaignID = currentCampaignID; } #if CLIENT @@ -303,6 +312,7 @@ namespace Barotrauma { System.Diagnostics.Debug.Assert(map.Locations.Count < UInt16.MaxValue); + msg.Write(CampaignID); msg.Write(lastUpdateID); msg.Write(lastSaveID); msg.Write(map.Seed); @@ -319,10 +329,10 @@ namespace Barotrauma } #if CLIENT + //static because we may need to instantiate the campaign if it hasn't been done yet public static void ClientRead(NetBuffer msg) { - //static because we may need to instantiate the campaign if it hasn't been done yet - + byte campaignID = msg.ReadByte(); UInt16 updateID = msg.ReadUInt16(); UInt16 saveID = msg.ReadUInt16(); string mapSeed = msg.ReadString(); @@ -333,20 +343,21 @@ namespace Barotrauma UInt16 purchasedItemCount = msg.ReadUInt16(); List purchasedItems = new List(); - for (int i = 0; i g.Name == "Campaign")); campaign = ((MultiplayerCampaign)GameMain.GameSession.GameMode); + campaign.CampaignID = campaignID; campaign.GenerateMap(mapSeed); } diff --git a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs index cb75b8492..878e358b7 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs @@ -605,7 +605,19 @@ namespace Barotrauma.Networking c.LastRecvCampaignSave = inc.ReadUInt16(); if (c.LastRecvCampaignSave > 0) { + byte campaignID = inc.ReadByte(); c.LastRecvCampaignUpdate = inc.ReadUInt16(); + + if (GameMain.GameSession?.GameMode is MultiplayerCampaign) + { + //the client has a campaign save for another campaign + //(the server started a new campaign and the client isn't aware of it yet?) + if (((MultiplayerCampaign)GameMain.GameSession.GameMode).CampaignID != campaignID) + { + c.LastRecvCampaignSave = 0; + c.LastRecvCampaignUpdate = 0; + } + } } break; case ClientNetObject.CHAT_MESSAGE: