fix: Improve job type initialization and handle game state during loading

This commit is contained in:
2025-12-14 23:45:12 +01:00
parent 0d7d989f76
commit 8f13282e04
2 changed files with 15 additions and 4 deletions

View File

@@ -1660,9 +1660,10 @@ namespace KCM
__instance.JobCustomMaxEnabledFlag = new bool[World.inst.NumLandMasses][];
for (int lm = 0; lm < World.inst.NumLandMasses; lm++)
{
__instance.JobFilledAvailable[lm] = new int[38];
__instance.JobCustomMaxEnabledFlag[lm] = new bool[38];
for (int n = 0; n < 38; n++)
int numJobTypes = p.JobFilledAvailable.data[lm].GetLength(0);
__instance.JobFilledAvailable[lm] = new int[numJobTypes];
__instance.JobCustomMaxEnabledFlag[lm] = new bool[numJobTypes];
for (int n = 0; n < numJobTypes; n++)
{
__instance.JobFilledAvailable[lm][n] = p.JobFilledAvailable.data[lm][n, 1];
}

View File

@@ -56,9 +56,19 @@ namespace KCM.Packets.Lobby
}
public override void HandlePacketClient()
{
if (!LobbyManager.loadingSave)
{
Start();
}
else
{
// If loading a save, just ensure the game is in the correct UI state for loading.
// The actual game start will happen after save data is unpacked in SaveTransferPacket.HandlePacketClient().
// This prevents MainMenuMode.StartGame() from being called prematurely and causing NullReferenceExceptions.
GameState.inst.SetNewMode(GameState.inst.playingMode);
}
}
public override void HandlePacketServer()
{