Correct save game handling again

This commit is contained in:
simon.kagstrom 2009-01-10 13:19:08 +00:00
parent d34cb27cb8
commit 3ef8d0328d
2 changed files with 6 additions and 9 deletions

View File

@ -167,6 +167,7 @@ public:
int fake_key_keytime; int fake_key_keytime;
bool prefs_changed; bool prefs_changed;
char save_game_name[256];
void select_disc(Prefs *np); void select_disc(Prefs *np);
void bind_key(Prefs *np); void bind_key(Prefs *np);

View File

@ -71,6 +71,8 @@ void C64::c64_ctor1(void)
this->fake_key_type = 0; this->fake_key_type = 0;
this->prefs_changed = false; this->prefs_changed = false;
memset(this->save_game_name, 0, sizeof(this->save_game_name));
strcpy(this->save_game_name, "unknown");
MENU_SIZE_X = FULL_DISPLAY_X - FULL_DISPLAY_X / 4; MENU_SIZE_X = FULL_DISPLAY_X - FULL_DISPLAY_X / 4;
MENU_SIZE_Y = FULL_DISPLAY_Y - FULL_DISPLAY_Y / 4; MENU_SIZE_Y = FULL_DISPLAY_Y - FULL_DISPLAY_Y / 4;
@ -189,6 +191,7 @@ void C64::select_disc(Prefs *np)
{ {
snprintf(np->DrivePath[0], 255, "%s/%s", snprintf(np->DrivePath[0], 255, "%s/%s",
IMAGE_PATH, name); IMAGE_PATH, name);
strncpy(this->save_game_name, name, 255);
if (strstr(name, ".d64") || strstr(name, ".D64")) if (strstr(name, ".d64") || strstr(name, ".D64"))
np->DriveType[0] = DRVTYPE_D64; np->DriveType[0] = DRVTYPE_D64;
else if (strstr(name, ".prg") || strstr(name, ".PRG") || else if (strstr(name, ".prg") || strstr(name, ".PRG") ||
@ -360,16 +363,9 @@ void C64::save_load_state(Prefs *np)
case 1: /* save */ case 1: /* save */
{ {
char buf[255]; char buf[255];
char name[255];
char *p;
p = strrchr(ThePrefs.DrivePath[0], '/'); snprintf(buf, 255, "%s/%s.sav", SAVES_PATH,
if (p == NULL) this->save_game_name);
strcpy(name, "unknown");
else
strncpy(name, p + 1, 255);
snprintf(buf, 255, "%s/%s.sav", SAVES_PATH, name);
this->SaveSnapshot(buf); this->SaveSnapshot(buf);
} break; } break;