BinaryConstruct/Terraria-Map-Editor — Issue #150: TEdit should work around potential version upgrade problems with loading
Author: SineSwiper
Created: 2011-10-19 22:55:10+00:00
State: open
Labels: Code Improvement

As new versions of Terraria maps come online, some of those maps will have new tile numbers that we currently don't recognize. And some of those new tiles will have isFramed set. Because of this, we are forced to update the XML immediately after a new release.

If the loader code is robust enough to detect this situation, it can attempt to load the file correctly, and warn the user of the newly discovered tile numbers. This would buy us some time, as that the map editor is still usable during that period.

This can be detected because of certain byte ranges that should be expected. For example:

Tile # = should be between 0 and the current highest Tile # via XML; if it's higher, it might be a new type of tile
IsLighted = is boolean, so only 0 or 1. If it's higher, then it might be a new type of tile with isFramed set.

The rest of them are bool, 0-20ish, bool, byte, bool. All of these have small enough ranges to detect that something is wrong. If the tile # is over our expected range, it should try both cases (with and without frames) to see which version makes sense. Afterwards, if it finds a new tile that appears to have frames, it'll mark an internal Tile/FrameProperty with the settings to make the rest of the file loading (and saving) smoother.