Monday, December 11, 2017

FMod - Level 0 detection fix

A new Keen Modding user wanted to know how to open a variety of mods. On one of them, Abiathar didn't show the world map and saving the levels caused the game to crash when going to the map. That is because Abiathar didn't see that the first level slot (level 0, the world map) actually had a level; the MAPHEAD pointer to the header was zero because the header was at the very beginning of the GAMEMAPS (which usually doesn't happen). FMod/FleexCore2 has some heuristics to deal with this, but they were not working in this case.

The problem was that, when writing the level 0 detection code, I used Location instead of Length in one spot, so it checked the plane pointer rather than plane length. That check was intended to make sure that the plane array wasn't absurdly long, which would indicate that the "header" was actually random garbage. Fixing the typo (and upping the maximum viable length a bit just for safety) solved the problem.

No comments:

Post a Comment