Skip to content

Commit

Permalink
Prevent CurrentRegionIndex out of range
Browse files Browse the repository at this point in the history
In certain unpatched game data there's multiple pixels in Wrothgarian Mountains with bad POLITIC.PAK indices.
This is not present using DaggerfallGameFiles or DaggerfallSetup with POLITIC.PAK fix v2.
Added patch for known bad index value in Wrothgarian Mountains.
Any remaining out of range results are clamped to 0 rather than crash.
  • Loading branch information
Interkarma committed Dec 19, 2022
1 parent 0f8dd23 commit 06687cf
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Assets/Scripts/Internal/PlayerGPS.cs
Expand Up @@ -154,10 +154,24 @@ public int CurrentPoliticIndex
/// </summary>
public int CurrentRegionIndex
{
get { if (currentPoliticIndex == 64)
return 31; // High Rock sea coast
get {
// Determine region from current politic index
int result = 0;
if (currentPoliticIndex == 64)
result = 31; // High Rock sea coast
else
return currentPoliticIndex - 128; }
result = currentPoliticIndex - 128;

// Patch known bad value to Wrothgarian Mountains
if (result == 105)
result = 16;

// Clamp any out of range results to 0
if (result < 0 || result >= 62)
result = 0;

return result;
}
}

/// <summary>
Expand Down

0 comments on commit 06687cf

Please sign in to comment.