Fixed saving filename

This commit is contained in:
CTurt 2014-11-30 11:43:19 +00:00
parent b8b743ed28
commit b7014958d2
3 changed files with 9 additions and 6 deletions

View File

@ -9,18 +9,19 @@
#define DSGM_GotoNextRoom(persistent) DSGM_SwitchRoom(DSGM_currentRoom + 1, persistent)
void DSGM_InitSaving(int argc, char **argv) {
char saveName[256] = { '\0' };
if(argc > 0 && strlen(argv[0]) > 4) {
snprintf(saveName, 255, "fat:/%.*s.sav", strlen(argv[0]) - 4, argv[0]);
snprintf(DSGM_saveName, 255, "%.*s.sav", strlen(argv[0]) - 4, argv[0]);
}
else {
sprintf(saveName, "fat:/" GAME_NAME ".sav");
sprintf(DSGM_saveName, "fat:/" GAME_NAME ".sav");
}
if(!fopen(saveName, "rb")) fopen(saveName, "wb");
DSGM_save = fopen(DSGM_saveName, "r+b");
DSGM_save = fopen(saveName, "r+b");
if(!DSGM_save) {
DSGM_save = fopen(DSGM_saveName, "wb");
fclose(DSGM_save);
}
}
void DSGM_Init(int argc, char **argv) {

View File

@ -1,3 +1,4 @@
#pragma once
extern FILE *DSGM_save;
extern char DSGM_saveName[256];

View File

@ -1,3 +1,4 @@
#include "DSGM.h"
FILE *DSGM_save;
char DSGM_saveName[256];