mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2025-02-18 05:16:19 +01:00
Fix saving of game info
This commit is contained in:
parent
00ee6da738
commit
16eb63dfcd
@ -374,7 +374,11 @@ Font *Gui::loadThemeFont(const char *dir, const char *what, int size)
|
|||||||
void Gui::updateGameInfo(GameInfo *gi)
|
void Gui::updateGameInfo(GameInfo *gi)
|
||||||
{
|
{
|
||||||
panic_if(!gi, "gi must be set\n");
|
panic_if(!gi, "gi must be set\n");
|
||||||
|
|
||||||
|
/* Store the current game info */
|
||||||
|
this->saveGameInfo();
|
||||||
delete this->cur_gameInfo;
|
delete this->cur_gameInfo;
|
||||||
|
|
||||||
this->cur_gameInfo = gi;
|
this->cur_gameInfo = gi;
|
||||||
this->gameInfoChanged = true;
|
this->gameInfoChanged = true;
|
||||||
}
|
}
|
||||||
@ -385,21 +389,27 @@ void Gui::saveGameInfo()
|
|||||||
|
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
char buf[255];
|
char *new_name = (char *)xmalloc(strlen(this->metadata_base_path) +
|
||||||
|
3 + strlen(this->cur_gameInfo->filename));
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s/%s",
|
sprintf(new_name, "%s/%s", this->metadata_base_path,
|
||||||
METADATA_ROOT_PATH, this->cur_gameInfo->filename);
|
this->cur_gameInfo->filename);
|
||||||
fp = fopen(buf, "w");
|
fp = fopen(new_name, "w");
|
||||||
if (!fp)
|
if (fp)
|
||||||
{
|
{
|
||||||
warning("Could not open %s for writing\n", buf);
|
int n = fwrite((const void*)p, 1, p->sz, fp);
|
||||||
return;
|
|
||||||
|
if (ferror(fp))
|
||||||
|
warning("Write error on %s\n", new_name);
|
||||||
|
else if ((size_t)n != p->sz)
|
||||||
|
warning("Could only write %d bytes of %s\n", n, new_name);
|
||||||
|
fclose(fp);
|
||||||
}
|
}
|
||||||
int n = fwrite((const void*)p, 1, p->sz, fp);
|
else
|
||||||
if (n != (int)p->sz)
|
warning("Could not open %s for writing\n", new_name);
|
||||||
warning("Could only write %d bytes of %s\n", n, buf);
|
|
||||||
fclose(fp);
|
free(new_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->gameInfoChanged = false;
|
this->gameInfoChanged = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user