Windows and Linux saves are not compatible with each other

Issue #4 resolved
Gennady Trafimenkov repo owner created an issue

That's because strings are saved in each platform native format. For Windows this means 2-bytes per character, for Linux - 4 bytes.

See Build/SaveLoadGame.cc, ExtractSavedGameHeaderFromFile:

#ifdef _WIN32 // XXX HACK000A
    EXTR_WSTR16(d, h.sSavedGameDesc, lengthof(h.sSavedGameDesc))
#else
    EXTR_WSTR32(d, h.sSavedGameDesc, lengthof(h.sSavedGameDesc))
#endif

It is probably a good idea to save games in Windows format on all platforms.

Comments (3)

  1. Gennady Trafimenkov reporter

    The main difference between vanilla saved-games format and Stracciatella on Linux is how strings are saved. Strings are save in platforms' native wchar_t format. For Windows, it is basically UTF-16 (if not take into account surrogate charactes), for Linux it is UTF-32. See http://en.wikipedia.org/wiki/Wide_character for details.

    We need to write two saved-game parsers: one to handle vanilla format and another one for Stracciatella Linux format (also, check if we need another parser for Mac).

    On loading the game the correct parser should be chosen. This algorithm should work: first try vanilla parser to read the header (SAVED_GAME_HEADER) and validate the data. If fields after sSavedGameDesc hold invalid values (for example, uiDay == 0, sector coordinates not in valid range), then try Linux Stracciatella parser and validate data again. Most likely one of the two parsers should work.

    Load games using the correct parser.

    New saves should be done always in vanilla format on all platforms. Among other things, strings should be written in Windows native format, it means they should be converted to UTF-16.

  2. Gennady Trafimenkov reporter

    Windows and unix saves are now compatible

    Saves made on Windows can be loaded on Linux and vise-versa. That fixes issue #4 (Windows and Linux saves are not compatible with each other)

    → <<cset 40addaa335c9>>

  3. Log in to comment