diff --git a/osx/classes/party.cpp b/osx/classes/party.cpp index b16a44d7..4cb2a0c5 100644 --- a/osx/classes/party.cpp +++ b/osx/classes/party.cpp @@ -89,31 +89,25 @@ void cParty::append(legacy::party_record_type& old){ for(i = 0; i < 256; i++) m_noted[i] = old.m_seen[i]; journal.reserve(50); - for(i = 0; i < 50; i++){ - cJournal j; - j.day = old.journal_day[i]; - journal.push_back(j); -// journal[i].str_num = old.journal_str[i]; -// journal[i].day = old.journal_day[i]; - spec_items[i] = old.spec_items[i]; - } + // The journal wasn't used before, so let's not bother converting it +// for(i = 0; i < 50; i++){ +// cJournal j; +// j.day = old.journal_day[i]; +// journal.push_back(j); +// spec_items[i] = old.spec_items[i]; +// } special_notes.reserve(140); for(i = 0; i < 140; i++){ + if(old.special_notes_str[i][0] <= 0) continue; cEncNote n; - // TODO: Fix up this conversion by looking up the required strings. -// n.str_num = old.special_notes_str[i][0]; -// n.where = old.special_notes_str[i][1]; + n.append(old.special_notes_str[i], univ.scenario); special_notes.push_back(n); -// special_notes[i].str_num = old.special_notes_str[i][0]; -// special_notes[i].where = old.special_notes_str[i][1]; } talk_save.reserve(120); for(i = 0; i < 120; i++){ cConvers t; - // TODO: Fix up this conversion by looking up the required strings. -// t = old.talk_save[i]; + t.append(old.talk_save[i], univ.scenario); talk_save.push_back(t); -// talk_save[i] = old.talk_save[i]; help_received[i] = old.help_received[i]; } direction = old.direction; @@ -145,13 +139,33 @@ void cParty::append(legacy::setup_save_type& old){ setup[n][i][j] = old.setup[n][i][j]; } -cParty::cConvers& cParty::cConvers::operator = (legacy::talk_save_type old){ - // TODO: Fix up this conversion by looking up the required strings. -// personality = old.personality; -// town_num = old.town_num; -// str_num1 = old.str1; -// str_num2 = old.str2; - return *this; +void cParty::cConvers::append(legacy::talk_save_type old, const cScenario& scenario){ + who_said = scenario.towns[old.personality / 10]->talking.people[old.personality % 10].title; + in_town = scenario.towns[old.town_num]->town_name; + the_str1 = scenario.towns[old.personality / 10]->spec_strs[old.str1]; + the_str2 = scenario.towns[old.personality / 10]->spec_strs[old.str2]; +} + +void cParty::cEncNote::append(int16_t(& old)[2], const cScenario& scenario) { + in_scen = scenario.scen_name; + // TODO: Need to verify that I have the correct offsets here. + switch(old[0] / 1000) { + case 0: + the_str = scenario.spec_strs[old[0] - 160]; + where = scenario.scen_name; // Best we can do here; the actual location is long forgotten + type = NOTE_SCEN; + break; + case 1: + the_str = scenario.outdoors[old[1] % scenario.out_width][old[1] / scenario.out_width]->spec_strs[old[0] - 1010]; + where = scenario.outdoors[old[1] % scenario.out_width][old[1] / scenario.out_width]->out_name; + type = NOTE_OUT; + break; + case 2: + the_str = scenario.towns[old[1]]->spec_strs[old[0] - 2020]; + where = scenario.towns[old[1]]->town_name; + type= NOTE_TOWN; + break; + } } void cParty::add_pc(legacy::pc_record_type old){ diff --git a/osx/classes/party.h b/osx/classes/party.h index 21dac590..2f0a960d 100644 --- a/osx/classes/party.h +++ b/osx/classes/party.h @@ -43,7 +43,7 @@ public: bool filled = false; std::string who_said, in_town, the_str1, the_str2, in_scen; - cConvers& operator = (legacy::talk_save_type old); + void append(legacy::talk_save_type old, const cScenario& scenario); }; class cJournal { public: @@ -54,6 +54,8 @@ public: public: eEncNoteType type; std::string the_str, where, in_scen; + + void append(int16_t(& old)[2], const cScenario& scenario); }; class cTimer { public: diff --git a/osx/tools/fileio.cpp b/osx/tools/fileio.cpp index a367e7e4..2686c54c 100644 --- a/osx/tools/fileio.cpp +++ b/osx/tools/fileio.cpp @@ -729,8 +729,17 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo fin.close(); - // TODO: Need to convert after loading the scenario in order to look up saved strings. - // However, for that to work, the entire scenario (all towns and sections) would need to be in memory. + if(in_scen){ + fs::path path; + path = progDir/"Blades of Exile Scenarios"/univ.party.scen_name; + + if(!load_scenario(path, univ.scenario)) + return false; + univ.file = path; + }else{ + univ.party.scen_name = ""; + } + univ.party.append(store_party); univ.party.append(store_setup); univ.party.void_pcs(); @@ -749,16 +758,6 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo univ.append(o_maps); univ.town.append(sfx, misc_i); } - if(in_scen){ - fs::path path; - path = progDir/"Blades of Exile Scenarios"/univ.party.scen_name; - - if(!load_scenario(path, univ.scenario)) - return false; - univ.file = path; - }else{ - univ.party.scen_name = ""; - } // Compatibility flags // TODO: Pretty sure I did this elsewhere, so probably don't need it here diff --git a/osx/tools/vector2d.hpp b/osx/tools/vector2d.hpp index 25101914..482f8465 100644 --- a/osx/tools/vector2d.hpp +++ b/osx/tools/vector2d.hpp @@ -19,6 +19,8 @@ template> class vector2d { friend class row_ref; friend class col_ref; + friend class const_row_ref; + friend class const_col_ref; std::vector data; size_t w, h; public: @@ -42,12 +44,32 @@ public: return ref.data[ref.w * y + x]; } }; + class const_row_ref { + friend class vector2d; + const vector2d& ref; + size_t y; + const_row_ref(const vector2d& ref, size_t row) : ref(ref), y(row) {} + public: + const Type& operator[](size_t x) const { + return ref.data[ref.w * y + x]; + } + }; + class const_col_ref { + friend class vector2d; + const vector2d& ref; + size_t x; + const_col_ref(const vector2d& ref, size_t col) : ref(ref), x(col) {} + public: + const Type& operator[](size_t y) const { + return ref.data[ref.w * y + x]; + } + }; col_ref operator[](size_t x) { return col_ref(*this, x); } -// const col_ref operator[](size_t x) const { -// return col_ref(*this, x); -// } + const_col_ref operator[](size_t x) const { + return const_col_ref(*this, x); + } size_t width() { return w; }