Skip to content

Commit

Permalink
Fix build: Add a temporary compiler flag to set if liblcf contains th…
Browse files Browse the repository at this point in the history
…e custom "language" field
  • Loading branch information
florianessl committed Feb 3, 2025
1 parent 14f28d2 commit 56de05b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1175,11 +1175,13 @@ void Player::LoadSavegame(const std::string& save_name, int save_id) {
verstr.str(), Version::STRING);
}

#ifdef LIBLCF_HAS_LANG_FIELD
std::string savegame_language = ToString(save->easyrpg_data.language);
if (!savegame_language.empty() && savegame_language != "default") {
Output::Debug("Savegame language: '{}' ", savegame_language);
Player::translation.SelectLanguage(savegame_language);
}
#endif

// Compatibility hacks for old EasyRPG Player saves.
if (save->easyrpg_data.version == 0) {
Expand Down
3 changes: 3 additions & 0 deletions src/scene_save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,15 @@ bool Scene_Save::Save(std::ostream& os, int slot_id, bool prepare_save) {
Main_Data::game_system->IncSaveCount();
}

#ifdef LIBLCF_HAS_LANG_FIELD
if (!Tr::HasActiveTranslation()) {
save.easyrpg_data.language = lcf::DBString(lcf::rpg::SaveEasyRpgData::kDefaultLanguage);
}
else {
save.easyrpg_data.language = lcf::DBString(Player::translation.GetCurrentLanguage().lang_dir);
}
#endif

save.targets = Main_Data::game_targets->GetSaveData();
save.system = Main_Data::game_system->GetSaveData();
save.system.switches = Main_Data::game_switches->GetData();
Expand Down
6 changes: 5 additions & 1 deletion src/translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@ const std::vector<Language>& Translation::GetLanguages() const
std::string Translation::GetLatestSavegameLanguage() {
// TODO: Disable for platforms with slow I/O

#ifdef LIBLCF_HAS_LANG_FIELD
std::string latest_lang = std::string(lcf::rpg::SaveEasyRpgData::kDefaultLanguage);
// Refresh File Finder Save Folder
FilesystemView fs = FileFinder::Save();
double latest_time = 0;
std::string latest_lang = std::string(lcf::rpg::SaveEasyRpgData::kDefaultLanguage);

for (int i = 0; i < Utils::Clamp<int32_t>(lcf::Data::system.easyrpg_max_savefiles, 3, 99); i++) {
std::stringstream ss;
Expand All @@ -190,6 +191,9 @@ std::string Translation::GetLatestSavegameLanguage() {
}

return latest_lang;
#else
return "default";
#endif
}


Expand Down

0 comments on commit 56de05b

Please # to comment.