public int GetPaletteOffsetIndex(int imageIndex) { int lastGood = 0; int jobIndex = 0; Console.WriteLine($"JIL Search for:{imageIndex}"); for (int i = 0; i <= imageIndex; i++) { int gfxOffset = offsetTable.GetImageOffset(i); jobIndex = i; if (directionIndexList != null) { int dirOffset = directionIndexList.ReverseLookupOffset(i); jobIndex = jobIndexList.ReverseLookupOffset(dirOffset); jobIndex = jobIndex == -1 ? lastGood : jobIndex; lastGood = jobIndex; } } return(jobIndex); }
public int GetPaletteOffsetIndex(int imageIndex, bool useLastGood = true) { int lastGood = useLastGood ? lastGoodJob : 0; int jobIndex = 0; int start = useLastGood ? lastGoodIndex : 0; for (int i = start; i <= imageIndex; i++) { int gfxOffset = offsetTable.GetImageOffset(i); jobIndex = i; if (directionIndexList != null) { int dirOffset = directionIndexList.ReverseLookupOffset(i); jobIndex = jobIndexList.ReverseLookupOffset(dirOffset); jobIndex = jobIndex == -1 ? lastGood : jobIndex; lastGood = jobIndex; } } Console.WriteLine($"JIL Search for:{imageIndex}, got: {jobIndex}"); lastGoodIndex = imageIndex; lastGoodJob = jobIndex; return(jobIndex); }