Skip to content

Commit b5f7c7e

Browse files
committed
Clamping but still reload completely broken after cotlims edit
1 parent 3f5845d commit b5f7c7e

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

Common/Systems/AutoloadPlayerInWorldSystem.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ private static bool SelectPlayerAndWorld(bool onlyPlayer = false)
146146
return false;
147147
}
148148
int playerId = Utilities.FindPlayerId(Conf.C.Player);
149-
var player = Main.PlayerList.Count > playerId ? Main.PlayerList[playerId] : null;
149+
if (playerId < 0 || playerId >= Main.PlayerList.Count)
150+
{
151+
Log.Error($"Invalid player index {playerId}. Cannot autoload player.");
152+
return false;
153+
}
154+
var player = Main.PlayerList[playerId];
150155

151156
if (ClientDataJsonHelper.PlayerPath != null && ClientDataJsonHelper.ClientMode != ClientMode.FreshClient)
152157
{
@@ -174,7 +179,12 @@ private static bool SelectPlayerAndWorld(bool onlyPlayer = false)
174179
}
175180

176181
int worldId = Utilities.FindWorldId(Conf.C.World);
177-
var world = Main.WorldList.Count > worldId ? Main.WorldList[worldId] : null;
182+
if (worldId < 0 || worldId >= Main.WorldList.Count)
183+
{
184+
Log.Error($"Invalid world index {worldId}. Cannot autoload world.");
185+
return false;
186+
}
187+
var world = Main.WorldList[worldId];
178188

179189
if (ClientDataJsonHelper.WorldPath != null && ClientDataJsonHelper.ClientMode != ClientMode.FreshClient)
180190
{

0 commit comments

Comments
 (0)