Skip reading more things for file previews
This commit is contained in:
@@ -335,7 +335,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, bool preview){
|
||||
return false;
|
||||
}
|
||||
file.readFrom(fin);
|
||||
univ.party.readFrom(file);
|
||||
univ.party.readFrom(file, preview);
|
||||
}
|
||||
|
||||
// Next load the PCs
|
||||
@@ -348,7 +348,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, bool preview){
|
||||
return false;
|
||||
}
|
||||
file.readFrom(fin);
|
||||
univ.party[i].readFrom(file);
|
||||
univ.party[i].readFrom(file, preview);
|
||||
}
|
||||
|
||||
// Including stored PCs
|
||||
|
||||
@@ -870,16 +870,28 @@ void cParty::writeTo(cTagFile& file) const {
|
||||
}
|
||||
}
|
||||
|
||||
void cParty::readFrom(const cTagFile& file) {
|
||||
void cParty::readFrom(const cTagFile& file, bool preview) {
|
||||
size_t monst_i = 0;
|
||||
for(const auto& page : file) {
|
||||
if(page.index() == 0) {
|
||||
as_hex<unsigned long long> version{0};
|
||||
page["CREATEVERSION"] >> version;
|
||||
// This warning shouldn't interrupt the player when loading previews for the fancy file picker.
|
||||
if(version > OBOE_CURRENT_VERSION) {
|
||||
showWarning("This game appears to have been created with a newer version of Blades of Exile than you are running. Exile will do its best to load the saved game anyway, but there may be loss of information.");
|
||||
if(!preview){
|
||||
showWarning("This game appears to have been created with a newer version of Blades of Exile than you are running. Exile will do its best to load the saved game anyway, but there may be loss of information.");
|
||||
}else{
|
||||
// TODO It could put a silent warning icon on the slot, though.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
page["SCENARIO"] >> scen_name;
|
||||
page["OUTCORNER"] >> outdoor_corner.x >> outdoor_corner.y;
|
||||
page["INWHICHCORNER"] >> i_w_c.x >> i_w_c.y;
|
||||
page["SECTOR"] >> out_loc.x >> out_loc.y;
|
||||
page["LOCINSECTOR"] >> loc_in_sec.x >> loc_in_sec.y;
|
||||
if(preview) return;
|
||||
|
||||
page["AGE"] >> age;
|
||||
page["GOLD"] >> gold;
|
||||
page["FOOD"] >> food;
|
||||
@@ -888,10 +900,6 @@ void cParty::readFrom(const cTagFile& file) {
|
||||
page["EASY"] >> easy_mode;
|
||||
page["LESSWM"] >> less_wm;
|
||||
page["LIGHT"] >> light_level;
|
||||
page["OUTCORNER"] >> outdoor_corner.x >> outdoor_corner.y;
|
||||
page["INWHICHCORNER"] >> i_w_c.x >> i_w_c.y;
|
||||
page["SECTOR"] >> out_loc.x >> out_loc.y;
|
||||
page["LOCINSECTOR"] >> loc_in_sec.x >> loc_in_sec.y;
|
||||
page["IN"] >> in_boat >> in_horse;
|
||||
page["DIRECTION"] >> direction;
|
||||
page["WHICHSLOT"] >> at_which_save_slot;
|
||||
@@ -899,7 +907,6 @@ void cParty::readFrom(const cTagFile& file) {
|
||||
page["DAMAGE"] >> total_dam_done;
|
||||
page["WOUNDS"] >> total_dam_taken;
|
||||
page["EXPERIENCE"] >> total_xp_gained;
|
||||
page["SCENARIO"] >> scen_name;
|
||||
page["WON"] >> scen_won;
|
||||
page["PLAYED"] >> scen_played;
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ public:
|
||||
cPlayer& operator[](unsigned short n);
|
||||
const cPlayer& operator[](unsigned short n) const;
|
||||
void writeTo(cTagFile& file) const;
|
||||
void readFrom(const cTagFile& file);
|
||||
void readFrom(const cTagFile& file, bool preview = false);
|
||||
|
||||
bool give_item(cItem item,int flags);
|
||||
bool forced_give(cItem item,eItemAbil abil,short dat = -1);
|
||||
|
||||
@@ -1303,11 +1303,17 @@ void cPlayer::writeTo(cTagFile& file) const {
|
||||
}
|
||||
}
|
||||
|
||||
void cPlayer::readFrom(const cTagFile& file) {
|
||||
void cPlayer::readFrom(const cTagFile& file, bool preview) {
|
||||
for(const auto& page : file) {
|
||||
if(page.index() == 0) {
|
||||
status.clear();
|
||||
page["STATUS"] >> eStatus::MAIN >> main_status;
|
||||
page["LEVEL"] >> level;
|
||||
page["ICON"] >> which_graphic;
|
||||
|
||||
if(preview)
|
||||
return;
|
||||
|
||||
status.clear();
|
||||
page["STATUS"].extractSparse(status);
|
||||
status.erase(eStatus::MAIN);
|
||||
|
||||
@@ -1318,11 +1324,8 @@ void cPlayer::readFrom(const cTagFile& file) {
|
||||
page["MANA"] >> cur_sp;
|
||||
page["EXPERIENCE"] >> experience;
|
||||
page["SKILLPTS"] >> skill_pts;
|
||||
page["LEVEL"] >> level;
|
||||
page["ICON"] >> which_graphic;
|
||||
page["DIRECTION"] >> direction;
|
||||
page["RACE"] >> race;
|
||||
|
||||
skills.clear();
|
||||
page["SKILL"].extractSparse(skills);
|
||||
max_health = skills[eSkill::MAX_HP];
|
||||
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
cPlayer(cParty& party, const cPlayer& other);
|
||||
short get_tnl() const;
|
||||
void writeTo(cTagFile& file) const;
|
||||
void readFrom(const cTagFile& file);
|
||||
void readFrom(const cTagFile& file, bool preview = false);
|
||||
virtual ~cPlayer() = default;
|
||||
// Copy-and-swap
|
||||
friend void swap(cPlayer& lhs, cPlayer& rhs);
|
||||
|
||||
Reference in New Issue
Block a user