diff --git a/dep/ggpo-x/include/ggponet.h b/dep/ggpo-x/include/ggponet.h index 1f99e917a..96ce61500 100644 --- a/dep/ggpo-x/include/ggponet.h +++ b/dep/ggpo-x/include/ggponet.h @@ -231,6 +231,12 @@ typedef struct { */ bool (__cdecl *load_game_state)(void* context, unsigned char* buffer, int len, int framesToRollback, int frameToLoad); + /* + * copy_game_state - creates a copy of an existing save state. + */ + bool(__cdecl* copy_game_state)(void* context, unsigned char** out_buffer, int* out_len, int* out_checksum, + const unsigned char* in_buffer, const int in_len, const int in_checksum); + /* * log_game_state - Used in diagnostic testing. The client should use * the ggpo_log function to write the contents of the specified save diff --git a/dep/ggpo-x/src/backends/synctest.cpp b/dep/ggpo-x/src/backends/synctest.cpp index 692bab4d8..c82a9c60d 100644 --- a/dep/ggpo-x/src/backends/synctest.cpp +++ b/dep/ggpo-x/src/backends/synctest.cpp @@ -126,9 +126,12 @@ SyncTestBackend::IncrementFrame(uint16_t cs) SavedInfo info; info.frame = frame; info.input = _last_input; - info.cbuf = _sync.GetLastSavedFrame().cbuf; - info.buf = (char *)malloc(info.cbuf); - memcpy(info.buf, _sync.GetLastSavedFrame().buf, info.cbuf); + + const Sync::SavedFrame& lsf = _sync.GetLastSavedFrame(); + info.cbuf = 0; + info.buf = nullptr; + info.checksum = 0; + _callbacks.copy_game_state(_callbacks.context, &info.buf, &info.cbuf, &info.checksum, lsf.buf, lsf.cbuf, lsf.checksum); info.checksum = _sync.GetLastSavedFrame().checksum; _saved_frames.push(info); @@ -155,7 +158,7 @@ SyncTestBackend::IncrementFrame(uint16_t cs) RaiseSyncError("Checksum for frame %d does not match saved (%d != %d)", frame, checksum, info.checksum); } printf("Checksum %08d for frame %d matches.\n", checksum, info.frame); - free(info.buf); + _callbacks.free_buffer(_callbacks.context, info.buf); } _last_verified = frame; _rollingback = false; diff --git a/dep/ggpo-x/src/backends/synctest.h b/dep/ggpo-x/src/backends/synctest.h index f0955a35f..924dbfb27 100644 --- a/dep/ggpo-x/src/backends/synctest.h +++ b/dep/ggpo-x/src/backends/synctest.h @@ -31,7 +31,7 @@ protected: struct SavedInfo { int frame; int checksum; - char *buf; + byte *buf; int cbuf; GameInput input; };