PointerWrapSection PointerWrap::Section(const char *title, int minVer, int ver) { char marker[16] = {0}; int foundVersion = ver; // This is strncpy because we rely on its weird non-null-terminating truncation behaviour. // Can't replace it with the more sensible truncate_cpy because that would break savestates. strncpy(marker, title, sizeof(marker)); if (!ExpectVoid(marker, sizeof(marker))) { // Might be before we added name markers for safety. if (foundVersion == 1 && ExpectVoid(&foundVersion, sizeof(foundVersion))) DoMarker(title); // Wasn't found, but maybe we can still load the state. else foundVersion = 0; } else Do(foundVersion); if (error == ERROR_FAILURE || foundVersion < minVer || foundVersion > ver) { WARN_LOG(SAVESTATE, "Savestate failure: wrong version %d found for %s", foundVersion, title); SetError(ERROR_FAILURE); return PointerWrapSection(*this, -1, title); } return PointerWrapSection(*this, foundVersion, title); }
PointerWrapSection PointerWrap::Section(const char *title, int minVer, int ver) { char marker[16] = {0}; int foundVersion = ver; strncpy(marker, title, sizeof(marker)); if (!ExpectVoid(marker, sizeof(marker))) { // Might be before we added name markers for safety. if (foundVersion == 1 && ExpectVoid(&foundVersion, sizeof(foundVersion))) DoMarker(title); // Wasn't found, but maybe we can still load the state. else foundVersion = 0; } else Do(foundVersion); if (error == ERROR_FAILURE || foundVersion < minVer || foundVersion > ver) { WARN_LOG(COMMON, "Savestate failure: wrong version %d found for %s", foundVersion, title); SetError(ERROR_FAILURE); return PointerWrapSection(*this, -1, title); } return PointerWrapSection(*this, foundVersion, title); }