From 11c089d40876941b586d025498f7cc15be110b0b Mon Sep 17 00:00:00 2001 From: William JCM Date: Sat, 2 Apr 2022 19:54:32 +0200 Subject: [PATCH] Mass,Profile: improve safety by checking the save type. --- src/Mass/Mass.cpp | 4 ++++ src/Profile/Profile.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Mass/Mass.cpp b/src/Mass/Mass.cpp index a1a8109..3a42e54 100644 --- a/src/Mass/Mass.cpp +++ b/src/Mass/Mass.cpp @@ -106,6 +106,10 @@ void Mass::refreshValues() { } } + if(_mass->saveType() != "/Game/Core/Save/bpSaveGameUnit.bpSaveGameUnit_C"_s) { + Utility::Error{} << _filename << "is not a valid unit save."; + } + auto unit_data = _mass->at("UnitData"_s); if(!unit_data) { Utility::Error{} << "Couldn't find unit data in" << _filename; diff --git a/src/Profile/Profile.cpp b/src/Profile/Profile.cpp index c65fa6d..5e3a65f 100644 --- a/src/Profile/Profile.cpp +++ b/src/Profile/Profile.cpp @@ -106,6 +106,10 @@ void Profile::refreshValues() { return; } + if(_profile.saveType() != "/Game/Core/Save/bpSaveGameProfile.bpSaveGameProfile_C"_s) { + Utility::Error{} << _filename << "is not a valid profile save."; + } + auto name_prop = _profile.at("CompanyName"_s); if(!name_prop) { _lastError = "No company name in "_s + _filename;