Skip to content

Commit

Permalink
Core: Add creator metadata extdata to savestates
Browse files Browse the repository at this point in the history
  • Loading branch information
endrift committed Jan 4, 2022
1 parent 398ee0c commit ea1abe2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/mgba/core/serialize.h
Expand Up @@ -17,6 +17,7 @@ enum mStateExtdataTag {
EXTDATA_CHEATS = 3,
EXTDATA_RTC = 4,
EXTDATA_META_TIME = 0x101,
EXTDATA_META_CREATOR = 0x102,
EXTDATA_MAX
};

Expand Down
10 changes: 10 additions & 0 deletions src/core/serialize.c
Expand Up @@ -8,6 +8,7 @@
#include <mgba/core/core.h>
#include <mgba/core/cheats.h>
#include <mgba/core/interface.h>
#include <mgba/core/version.h>
#include <mgba-util/memory.h>
#include <mgba-util/vfs.h>

Expand Down Expand Up @@ -386,6 +387,15 @@ bool mCoreSaveStateNamed(struct mCore* core, struct VFile* vf, int flags) {
};
mStateExtdataPut(&extdata, EXTDATA_META_TIME, &item);
}

char creator[256];
snprintf(creator, sizeof(creator), "%s %s", projectName, projectVersion);
struct mStateExtdataItem item = {
.size = strlen(creator) + 1,
.data = strdup(creator),
.clean = free
};
mStateExtdataPut(&extdata, EXTDATA_META_CREATOR, &item);
}

if (flags & SAVESTATE_SAVEDATA) {
Expand Down

0 comments on commit ea1abe2

Please sign in to comment.