// SPDX-License-Identifier: GPL-3.0-only #include "modern/content/ui_contract.hpp" #include "modern/game/modern_state.hpp" #include #include using namespace bmh; namespace {using J=cli::Json;using O=J::Object;const J& at(const J& j,const char* k){return j.object()->at(k);}void check(bool ok,const char* why){if(!ok)throw std::runtime_error(why);}} int main() try { modern::ModernState g;g.manager_teams={0};g.manager_ids={"manager:1"};g.manager_serial=1;g.manager_records.resize(0xb0c);g.world_club_id={"club:one"};g.world_club_name={"Synthetic"};const std::string original="M}ller";for(size_t i=0;iat(0);check(*at(m,"name").string()==unicode,"UTF-8 manager name lost");check(*at(m,"portraitStyle").string()=="painted"&&*at(m,"portraitGuiKey").string()=="gui:manager/painted/0","portrait style lost");check(!g.manager_presentation(1)&&!g.manager_presentation(-1),"presentation crossed slot bounds");check(g.manager_records[0xa8+1]=='}',"display metadata modified original bytes"); g.manager_presentations.clear();const auto fallback=modern::ui_read(g,c,O{{"kind","session"}});const auto &old=at(at(fallback,"data"),"managers").array()->at(0);check(*at(old,"name").string()=="M\xc3\xbcller"&&*at(old,"portraitStyle").string()=="photo","old saves lost original-name/photo fallback");std::cout<<"Modern UTF-8 presentation, original bytes and older-save fallback passed\n";return 0; } catch(const std::exception& e){std::cerr<