| 1082 | } |
| 1083 | |
| 1084 | static bool CheckVersion(const std::string& filename, zip_t* zf, Error* error) |
| 1085 | { |
| 1086 | u32 savever; |
| 1087 | |
| 1088 | auto zff = zip_fopen_managed(zf, EntryFilename_StateVersion, 0); |
| 1089 | if (!zff || zip_fread(zff.get(), &savever, sizeof(savever)) != sizeof(savever)) |
| 1090 | { |
| 1091 | Error::SetString(error, "Savestate file does not contain version indicator."); |
| 1092 | return false; |
| 1093 | } |
| 1094 | |
| 1095 | char version_string[STATE_PCSX2_VERSION_SIZE]; |
| 1096 | if (zip_fread(zff.get(), version_string, STATE_PCSX2_VERSION_SIZE) == STATE_PCSX2_VERSION_SIZE) |
| 1097 | version_string[STATE_PCSX2_VERSION_SIZE - 1] = 0; |
| 1098 | else |
| 1099 | StringUtil::Strlcpy(version_string, "Unknown", std::size(version_string)); |
| 1100 | |
| 1101 | // Major version mismatch. Means we can't load this savestate at all. Support for it |
| 1102 | // was removed entirely. |
| 1103 | // check for a "minor" version incompatibility; which happens if the savestate being loaded is a newer version |
| 1104 | // than the emulator recognizes. 99% chance that trying to load it will just corrupt emulation or crash. |
| 1105 | if (savever > g_SaveVersion || (savever >> 16) != (g_SaveVersion >> 16)) |
| 1106 | { |
| 1107 | std::string current_emulator_version = BuildVersion::GitTag; |
| 1108 | if (current_emulator_version.empty()) |
| 1109 | { |
| 1110 | current_emulator_version = "Unknown"; |
| 1111 | } |
| 1112 | Error::SetString(error, fmt::format(TRANSLATE_FS("SaveState","This save state was created with PCSX2 version {0}. It is no longer compatible " |
| 1113 | "with your current PCSX2 version {1}.\n\n" |
| 1114 | "If you have any unsaved progress on this save state, you can download the compatible PCSX2 version {0} " |
| 1115 | "from pcsx2.net, load the save state, and save your progress to the memory card."), |
| 1116 | version_string, current_emulator_version)); |
| 1117 | return false; |
| 1118 | } |
| 1119 | |
| 1120 | return true; |
| 1121 | } |
| 1122 | |
| 1123 | static zip_int64_t CheckFileExistsInState(zip_t* zf, const char* name, bool required) |
| 1124 | { |
no test coverage detected