fix issue which caused bots to duplicate

This commit is contained in:
Evil Factory
2021-12-18 02:29:42 -03:00
parent f71f598976
commit 6f6ceb4084
@@ -2261,7 +2261,6 @@ namespace Barotrauma.Networking
var result = new LuaResult(GameMain.Lua.hook.Call("jobsAssigned")); var result = new LuaResult(GameMain.Lua.hook.Call("jobsAssigned"));
List<CharacterInfo> characterInfos = new List<CharacterInfo>(); List<CharacterInfo> characterInfos = new List<CharacterInfo>();
foreach (Client client in teamClients) foreach (Client client in teamClients)
{ {
client.NeedsMidRoundSync = false; client.NeedsMidRoundSync = false;
@@ -2341,8 +2340,7 @@ namespace Barotrauma.Networking
spawnWaypoints = mainSubWaypoints; spawnWaypoints = mainSubWaypoints;
} }
Debug.Assert(spawnWaypoints.Count == mainSubWaypoints.Count); Debug.Assert(spawnWaypoints.Count == mainSubWaypoints.Count);
if (!result.Bool())
{
for (int i = 0; i < teamClients.Count; i++) for (int i = 0; i < teamClients.Count; i++)
{ {
Character spawnedCharacter = Character.Create(teamClients[i].CharacterInfo, spawnWaypoints[i].WorldPosition, teamClients[i].CharacterInfo.Name, isRemotePlayer: true, hasAi: false); Character spawnedCharacter = Character.Create(teamClients[i].CharacterInfo, spawnWaypoints[i].WorldPosition, teamClients[i].CharacterInfo.Name, isRemotePlayer: true, hasAi: false);
@@ -2401,20 +2399,6 @@ namespace Barotrauma.Networking
} }
} }
for (int i = teamClients.Count; i < teamClients.Count + bots.Count; i++)
{
Character spawnedCharacter = Character.Create(characterInfos[i], spawnWaypoints[i].WorldPosition, characterInfos[i].Name, isRemotePlayer: false, hasAi: true);
spawnedCharacter.TeamID = teamID;
spawnedCharacter.GiveJobItems(mainSubWaypoints[i]);
spawnedCharacter.GiveIdCardTags(mainSubWaypoints[i]);
spawnedCharacter.Info.InventoryData = new XElement("inventory");
spawnedCharacter.Info.StartItemsGiven = true;
spawnedCharacter.SaveInventory();
// talents are only avilable for players in online sessions, but modders or someone else might want to have them loaded anyway
spawnedCharacter.LoadTalents();
}
}
if (crewManager != null && crewManager.HasBots) if (crewManager != null && crewManager.HasBots)
{ {
if (hadBots) if (hadBots)
@@ -2472,7 +2456,6 @@ namespace Barotrauma.Networking
Log("Round started.", ServerLog.MessageType.ServerMessage); Log("Round started.", ServerLog.MessageType.ServerMessage);
gameStarted = true; gameStarted = true;
initiatedStartGame = false; initiatedStartGame = false;
GameMain.ResetFrameTime(); GameMain.ResetFrameTime();
@@ -2483,7 +2466,6 @@ namespace Barotrauma.Networking
GameMain.Lua.hook.Call("roundStart", new object[] { }); GameMain.Lua.hook.Call("roundStart", new object[] { });
startGameCoroutine = null; startGameCoroutine = null;
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
} }