Android: Store saved files under game-id/ subdirectory

This is to prevent overwriting saved files of other games, since System3
uses common save file names regardless of the game.
This commit is contained in:
kichikuou
2020-02-10 13:09:07 +09:00
parent 8615df6e12
commit 2d0619a19a
4 changed files with 26 additions and 2 deletions
+2 -1
View File
@@ -5,6 +5,7 @@
*/
#include "fileio.h"
#include <string.h>
#include <sys/types.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
@@ -15,7 +16,7 @@ const char* g_savedir;
void FILEIO::SetSaveDir(const char* savedir)
{
g_savedir = savedir;
g_savedir = strdup(savedir);
}
int FILEIO::StatSavedata(const char* filename, struct stat* buf)
+14 -1
View File
@@ -37,6 +37,7 @@ int main(int argc, char *argv[])
const char* font_file = DEFAULT_FONT_PATH "MTLc3m.ttf";
const char* game_id = NULL;
char save_dir[256] = "";
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-gamedir") == 0)
@@ -44,7 +45,7 @@ int main(int argc, char *argv[])
else if (strcmp(argv[i], "-antialias") == 0)
ags_setAntialiasedStringMode(1);
else if (strcmp(argv[i], "-savedir") == 0)
FILEIO::SetSaveDir(argv[++i]);
strcpy(save_dir, argv[++i]);
else if (strcmp(argv[i], "-fontfile") == 0)
font_file = argv[++i];
else if (strcmp(argv[i], "-game") == 0)
@@ -54,6 +55,18 @@ int main(int argc, char *argv[])
// system3 初期化
NACT* nact = new NACT(game_id, font_file);
if (save_dir[0]) {
#ifdef __ANDROID__
const char* gid = nact->get_game_id();
if (gid) {
strcat(save_dir, gid);
mkdir(save_dir, 0777);
strcat(save_dir, "/");
}
#endif
FILEIO::SetSaveDir(save_dir);
}
const _TCHAR* title = nact->get_title();
if (title) {
#if defined(_SYSTEM1)
+1
View File
@@ -242,6 +242,7 @@ public:
void select_cursor();
void select_sound(int dev);
const char* get_game_id();
const _TCHAR* get_title();
bool text_skip_enb; // メッセージスキップ
+9
View File
@@ -124,6 +124,15 @@ uint32 NACT::calc_crc32(const char* game_id)
return crc;
}
const char* NACT::get_game_id()
{
for (const CRCTable* t = crc_table; t->id; t++) {
if (crc32 == t->crc32)
return t->id;
}
return NULL;
}
const _TCHAR* NACT::get_title()
{
for (const CRCTable* t = crc_table; t->id; t++) {