Engine: Polymost per-map ART may not refresh properly between levels
This is a bug that has existed since the per-map art system has been introduced (starting with r4257), and has eluded me for over 2 years.
In short, the problem is that certain per-map art textures are not unloaded properly by the Polymost renderer when changing levels, causing the old texture, which was derived from per-map art in preceeding levels, to appear in place of the intended one. Both per-map art tiles share the same index, and the conditions for this to occur appear to be very specific.
After many fruitless attempts to reproduce the problem, we finally have a consistent test case: polymost_permap_bug.zip
The archive contains two map files, a CON file, as well as 3 ART files. Each ART file contains 256 tiles ranging from indices 15360 to 15615. The maps are identical and contain an exit switch, as well as a sprite with picnum 15579
. Two of the ART files are per-map art, with names that correspond to the two maps. The third ART file is named TILES060.ART
, which is always loaded by the game, and covers the same range of tiles as the per-map art. Note that this third ART file is absolutely essential to reproduce the problem; it will not occur without it.
Simply place all files in your eduke32 folder, and launch the game. Make sure that you start the game with the Polymost renderer, and pick the first episode. This should now start you in the first of the two maps, where you will find the sprite of a scientist in a chair, as well as the exit switch. You should be seeing the same view as in the screenshot:
Now proceed to the second level using the nuke button. If the bug was triggered, the second map will now be the exact same as the first, with the same view as in the above screenshot. This is the problem in question. Despite the scientist tile not being part of the map's assigned art file, it will still show up after continuing from E1L1 to E1L2.
Finally, open the console, execute the command restartvid
, and the sprite will change into its proper form:
As such, the problem must be caused by the renderer. Moreover, the glitch does not occur in Classic mode or in Polymer, as such it is a Polymost problem. I suspect that this is a cached texture from when the tile was loaded in the previous map, which is not properly flushed by the time the new per-map art is loaded.
Further observations:
- The dimensions of the tiles between ART files differ.
- Removing the file
TILES060.ART
will prevent the glitch from occurring. - Switching to Polymer will make the problem disappear temporarily, but it will reappear once switching back to Polymost.
- Switching to Classic mode will persistently resolve the issue, even if you switch back to Polymost.
- Skipping to the second level with the usermap menu will allow the tile to load properly. But if you enter the first map now, you will now see the incorrect tile here instead.
- Saving the game in the bugged state, restarting the game, and then reloading the save will clear the issue (this is what made it almost impossible to debug).
- The tile range may also play a significant role. If tilenum
490
is replaced instead of tilenum15579
, the glitch will not occur -- despite this tile having a base ART file in Duke3D.