Skip to content

Commit 4bdb6c3

Browse files
committed
1.0.7
* Obtaining the victim will now check if the player is null and move on to the next player instead of throwing an exception and preventing the SCP-575 from spawning.
1 parent 1c4ccc4 commit 4bdb6c3

File tree

2 files changed

+47
-30
lines changed

2 files changed

+47
-30
lines changed

Cerberus.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<PropertyGroup>
1818
<!-- This is the global version and is used for all projects that don't have a version -->
19-
<Version Condition="$(Version) == ''">1.0.6</Version>
19+
<Version Condition="$(Version) == ''">1.0.7</Version>
2020
<!-- Enables public beta warning via the PUBLIC_BETA constant -->
2121
<PublicBeta>false</PublicBeta>
2222

SCP575/Scp575.cs

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class Scp575
5252
/// <summary>
5353
/// Plugin version
5454
/// </summary>
55-
private const string Version = "1.0.6";
55+
private const string Version = "1.0.7";
5656

5757
[PluginEntryPoint("SCP-575", Version, "Add SCP-575 to SCP:SL", "SrLicht")]
5858
private void OnLoadPlugin()
@@ -244,7 +244,7 @@ private void Spawn575(float duration)
244244
}
245245
catch (Exception e)
246246
{
247-
Log.Error($"Error on {nameof(Spawn575)}: {e} -- {e.StackTrace}");
247+
Log.Error($"Error on {nameof(Spawn575)}: {e} -- {e.Message}");
248248
}
249249
}
250250

@@ -254,49 +254,66 @@ private void Spawn575(float duration)
254254
/// <returns></returns>
255255
private Player GetVictim()
256256
{
257-
var players = new List<Player>();
258-
var playerList = Player.GetPlayers();
259-
260-
if (Config.ActiveInLight)
257+
try
261258
{
262-
foreach (var player in playerList)
263-
{
264-
if (player.IsAlive && !player.IsSCP && !player.IsTutorial &&
265-
player.Zone == FacilityZone.LightContainment
266-
&& !player.IsInInvalidRoom())
259+
var players = new List<Player>();
260+
var playerList = Player.GetPlayers();
267261

262+
if (Config.ActiveInLight)
263+
{
264+
foreach (var player in playerList)
268265
{
269-
players.Add(player);
266+
if (player?.Room is null) continue;
267+
268+
if (player.IsAlive && !player.IsSCP && !player.IsTutorial &&
269+
player.Zone == FacilityZone.LightContainment
270+
&& !player.IsInInvalidRoom())
271+
272+
{
273+
players.Add(player);
274+
}
270275
}
271276
}
272-
}
273277

274-
if (Config.ActiveInHeavy)
275-
{
276-
foreach (var player in playerList)
278+
if (Config.ActiveInHeavy)
277279
{
278-
if (player.IsAlive && !player.IsSCP && !player.IsTutorial &&
279-
player.Zone == FacilityZone.HeavyContainment
280-
&& !player.IsInInvalidRoom())
280+
foreach (var player in playerList)
281281
{
282-
players.Add(player);
282+
if (player?.Room is null) continue;
283+
284+
if (player.IsAlive && !player.IsSCP && !player.IsTutorial &&
285+
player.Zone == FacilityZone.HeavyContainment
286+
&& !player.IsInInvalidRoom())
287+
{
288+
players.Add(player);
289+
}
283290
}
284291
}
285-
}
286292

287-
if (Config.ActiveInEntrance)
288-
{
289-
foreach (var player in playerList)
293+
if (!Config.ActiveInEntrance)
294+
return players.Any()
295+
? players.ElementAtOrDefault(UnityEngine.Random.Range(0, players.Count))
296+
: null;
290297
{
291-
if (player.IsAlive && !player.IsSCP && !player.IsTutorial && player.Zone == FacilityZone.Entrance
292-
&& !player.IsInInvalidRoom())
298+
foreach (var player in playerList)
293299
{
294-
players.Add(player);
300+
if (player?.Room is null) continue;
301+
302+
if (player.IsAlive && !player.IsSCP && !player.IsTutorial && player.Zone == FacilityZone.Entrance
303+
&& !player.IsInInvalidRoom())
304+
{
305+
players.Add(player);
306+
}
295307
}
296308
}
297-
}
298309

299-
return players.Any() ? players.ElementAtOrDefault(UnityEngine.Random.Range(0, players.Count)) : null;
310+
return players.Any() ? players.ElementAtOrDefault(UnityEngine.Random.Range(0, players.Count)) : null;
311+
}
312+
catch (Exception e)
313+
{
314+
Log.Error($"Error on {nameof(GetVictim)}: {e} -- {e.Message}");
315+
return null;
316+
}
300317
}
301318

302319
/// <summary>

0 commit comments

Comments
 (0)