Fixed crashing if a matching waypoint isn't found when spawning a monster
This commit is contained in:
@@ -226,18 +226,17 @@ namespace Barotrauma
|
|||||||
Character spawnedCharacter = null;
|
Character spawnedCharacter = null;
|
||||||
|
|
||||||
Vector2 spawnPosition = Vector2.Zero;
|
Vector2 spawnPosition = Vector2.Zero;
|
||||||
|
WayPoint spawnPoint = null;
|
||||||
spawnPosition = Vector2.Zero;
|
|
||||||
|
|
||||||
if (commands.Length > 2)
|
if (commands.Length > 2)
|
||||||
{
|
{
|
||||||
switch (commands[2].ToLowerInvariant())
|
switch (commands[2].ToLowerInvariant())
|
||||||
{
|
{
|
||||||
case "inside":
|
case "inside":
|
||||||
spawnPosition = WayPoint.GetRandom(SpawnType.Human, null, Submarine.MainSub).WorldPosition;
|
spawnPoint = WayPoint.GetRandom(SpawnType.Human, null, Submarine.MainSub);
|
||||||
break;
|
break;
|
||||||
case "outside":
|
case "outside":
|
||||||
spawnPosition = WayPoint.GetRandom(SpawnType.Enemy).WorldPosition;
|
spawnPoint = WayPoint.GetRandom(SpawnType.Enemy);
|
||||||
break;
|
break;
|
||||||
case "near":
|
case "near":
|
||||||
case "close":
|
case "close":
|
||||||
@@ -253,7 +252,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (closestDist < 0.0f || dist < closestDist)
|
if (closestDist < 0.0f || dist < closestDist)
|
||||||
{
|
{
|
||||||
spawnPosition = wp.WorldPosition;
|
spawnPoint = wp;
|
||||||
closestDist = dist;
|
closestDist = dist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,16 +261,17 @@ namespace Barotrauma
|
|||||||
spawnPosition = GameMain.GameScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
|
spawnPosition = GameMain.GameScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
spawnPosition = WayPoint.GetRandom(commands[1].ToLowerInvariant()=="human" ? SpawnType.Human : SpawnType.Enemy).WorldPosition;
|
spawnPoint = WayPoint.GetRandom(commands[1].ToLowerInvariant() == "human" ? SpawnType.Human : SpawnType.Enemy);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
spawnPosition = WayPoint.GetRandom(commands[1].ToLowerInvariant() == "human" ? SpawnType.Human : SpawnType.Enemy).WorldPosition;
|
spawnPoint = WayPoint.GetRandom(commands[1].ToLowerInvariant() == "human" ? SpawnType.Human : SpawnType.Enemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (spawnPoint != null) spawnPosition = spawnPoint.WorldPosition;
|
||||||
|
|
||||||
if (commands[1].ToLowerInvariant()=="human")
|
if (commands[1].ToLowerInvariant()=="human")
|
||||||
{
|
{
|
||||||
spawnedCharacter = Character.Create(Character.HumanConfigFile, spawnPosition);
|
spawnedCharacter = Character.Create(Character.HumanConfigFile, spawnPosition);
|
||||||
|
|||||||
Reference in New Issue
Block a user