diff options
author | Willem Jan Palenstijn | 2013-09-05 21:53:33 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-09-05 22:12:49 +0200 |
commit | 023914d12166ea4af6e23685f96371f769cb0255 (patch) | |
tree | d4d2a8aa41689274935139ad5739bdf634240e28 /engines/wintermute/base/scriptables/script_value.cpp | |
parent | dd9ab7accbe7671134d6c9303d94f527ef599404 (diff) | |
download | scummvm-rg350-023914d12166ea4af6e23685f96371f769cb0255.tar.gz scummvm-rg350-023914d12166ea4af6e23685f96371f769cb0255.tar.bz2 scummvm-rg350-023914d12166ea4af6e23685f96371f769cb0255.zip |
WINTERMUTE: Disambiguate empty and NULL strings when saving
The string stored is now strlen(s)+1, with length 0 indicating NULL.
Increment savegame version for this new format.
Old savegames are fixed by assuming VAL_STRING should never be NULL.
Diffstat (limited to 'engines/wintermute/base/scriptables/script_value.cpp')
-rw-r--r-- | engines/wintermute/base/scriptables/script_value.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 3532e127d0..31ec457df1 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -827,6 +827,17 @@ bool ScValue::persist(BasePersistenceManager *persistMgr) { persistMgr->transferPtr(TMEMBER_PTR(_valRef)); persistMgr->transfer(TMEMBER(_valString)); + if (!persistMgr->getIsSaving() && !persistMgr->checkVersion(1,2,2)) { + // Savegames prior to 1.2.2 stored empty strings as NULL. + // We disambiguate those by turning NULL strings into empty + // strings if _type is VAL_STRING instead of VAL_NULL. + + if (_type == VAL_STRING && !_valString) { + _valString = new char[1]; + _valString[0] = '\0'; + } + } + /* // TODO: Convert to Debug-statements. FILE* f = fopen("c:\\val.log", "a+"); switch(_type) |