From 1afd60cd3e98725c59daf9cdc7a40655c454fb81 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 16 Jun 2019 18:03:17 -0700 Subject: GLK: Change language Id in savegames to more portable language code --- engines/glk/glk.cpp | 6 ++++-- engines/glk/quetzal.cpp | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/engines/glk/glk.cpp b/engines/glk/glk.cpp index 1208cba527..ffb5015633 100644 --- a/engines/glk/glk.cpp +++ b/engines/glk/glk.cpp @@ -25,6 +25,7 @@ #include "common/debug-channels.h" #include "common/events.h" #include "common/file.h" +#include "common/language.h" #include "engines/util.h" #include "graphics/scaler.h" #include "graphics/thumbnail.h" @@ -195,11 +196,12 @@ Common::Error GlkEngine::loadGameState(int slot) { rs->skip(14); uint32 interpType = rs->readUint32BE(); - byte language = rs->readByte(); + Common::String langCode = QuetzalReader::readString(rs); Common::String md5 = QuetzalReader::readString(rs); delete rs; - if (interpType != INTERPRETER_IDS[getInterpreterType()] || language != getLanguage() || md5 != getGameMD5()) + if (interpType != INTERPRETER_IDS[getInterpreterType()] || + parseLanguage(langCode) !=getLanguage() || md5 != getGameMD5()) errCode = Common::kReadingFailed; } } diff --git a/engines/glk/quetzal.cpp b/engines/glk/quetzal.cpp index a745d7586e..68c11d0996 100644 --- a/engines/glk/quetzal.cpp +++ b/engines/glk/quetzal.cpp @@ -23,8 +23,9 @@ #include "glk/quetzal.h" #include "glk/glk_api.h" #include "glk/events.h" -#include "common/memstream.h" #include "common/system.h" +#include "common/language.h" +#include "common/memstream.h" #include "common/translation.h" namespace Glk { @@ -202,7 +203,7 @@ void QuetzalWriter::addCommonChunks(const Common::String &saveName) { ws.write(saveName.c_str(), saveName.size()); ws.writeByte(0); } - + Common::Language l; // Write 'SCVM' chunk with game version & gameplay statistics { Common::WriteStream &ws = add(ID_SCVM); @@ -219,7 +220,8 @@ void QuetzalWriter::addCommonChunks(const Common::String &saveName) { // Write out intrepreter type, language, and game Id ws.writeUint32BE(INTERPRETER_IDS[g_vm->getInterpreterType()]); - ws.writeByte(g_vm->getLanguage()); + const char *langCode = getLanguageCode(g_vm->getLanguage()); + ws.write(langCode, strlen(langCode) + 1); Common::String md5 = g_vm->getGameMD5(); ws.write(md5.c_str(), md5.size()); ws.writeByte('\0'); -- cgit v1.2.3