Skip to content

Commit 3c05ec1

Browse files
authored
[ENHANCEMENT,BREAKING] Serialize plugin version (#458)
* Put version in serialized state * Add header to serialized state
1 parent 3dba2cd commit 3c05ec1

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

NeuralAmpModeler/NeuralAmpModeler.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@ void NeuralAmpModeler::OnIdle()
391391

392392
bool NeuralAmpModeler::SerializeState(IByteChunk& chunk) const
393393
{
394+
// If this isn't here when unserializing, then we know we're dealing with something before v0.8.0.
395+
WDL_String header("###NeuralAmpModeler###"); // Don't change this!
396+
chunk.PutStr(header.Get());
397+
// Plugin version, so we can load legacy serialized states in the future!
398+
WDL_String version(PLUG_VERSION_STR);
399+
chunk.PutStr(version.Get());
394400
// Model directory (don't serialize the model itself; we'll just load it again
395401
// when we unserialize)
396402
chunk.PutStr(mNAMPath.Get());
@@ -400,7 +406,19 @@ bool NeuralAmpModeler::SerializeState(IByteChunk& chunk) const
400406

401407
int NeuralAmpModeler::UnserializeState(const IByteChunk& chunk, int startPos)
402408
{
403-
WDL_String dir;
409+
WDL_String header;
410+
startPos = chunk.GetStr(header, startPos);
411+
// TODO: Handle legacy plugin serialized states.
412+
//if strncmp (header.Get(), "###NeuralAmpModeler###")
413+
//{
414+
// return UnserializeStateLegacy(header, startPos); // (We'll assume 0.7.9).
415+
//}
416+
WDL_String version;
417+
startPos = chunk.GetStr(version, startPos);
418+
// Version-specific loading here if needed.
419+
// ...
420+
421+
// Current version loading:
404422
startPos = chunk.GetStr(mNAMPath, startPos);
405423
startPos = chunk.GetStr(mIRPath, startPos);
406424
int retcode = UnserializeParams(chunk, startPos);

0 commit comments

Comments
 (0)