Merge pull request #193 from badgerman/feature-gmtool-upgrades

misc gmtool upgrades
This commit is contained in:
Enno Rehling 2015-05-17 17:57:46 +02:00
commit 053adda3b4
7 changed files with 480 additions and 473 deletions

@ -1 +1 @@
Subproject commit 61989d93368022602a2a7ac4218c83f254701f0f Subproject commit b38f6f8acdc2ce5b0613a4bb2ff8082051a25ac3

View File

@ -761,6 +761,29 @@ static void select_regions(state * st, int selectmode)
st->wnd_map->update |= 3; st->wnd_map->update |= 3;
} }
void loaddata(state *st) {
char datafile[MAX_PATH];
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
if (strlen(datafile) > 0) {
create_backup(datafile);
readgame(datafile, false);
st->modified = 0;
}
}
void savedata(state *st) {
char datafile[MAX_PATH];
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
if (strlen(datafile) > 0) {
create_backup(datafile);
remove_empty_units();
writegame(datafile);
st->modified = 0;
}
}
static void handlekey(state * st, int c) static void handlekey(state * st, int c)
{ {
window *wnd; window *wnd;
@ -816,17 +839,11 @@ static void handlekey(state * st, int c)
case 'S': case 'S':
case KEY_SAVE: case KEY_SAVE:
case KEY_F(2): case KEY_F(2):
/* if (st->modified) */ { savedata(st);
char datafile[MAX_PATH]; break;
case KEY_F(3):
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile)); case KEY_OPEN:
if (strlen(datafile) > 0) { loaddata(st);
create_backup(datafile);
remove_empty_units();
writegame(datafile);
st->modified = 0;
}
}
break; break;
case 'B': case 'B':
/* /*

View File

@ -1348,7 +1348,7 @@ void writefaction(struct gamedata *data, const faction * f)
write_spellbook(f->spellbook, data->store); write_spellbook(f->spellbook, data->store);
} }
int readgame(const char *filename, int backup) int readgame(const char *filename, bool backup)
{ {
int n, p, nread; int n, p, nread;
faction *f, **fp; faction *f, **fp;

View File

@ -44,7 +44,7 @@ extern "C" {
int readorders(const char *filename); int readorders(const char *filename);
int creategame(void); int creategame(void);
int readgame(const char *filename, int backup); int readgame(const char *filename, bool backup);
int writegame(const char *filename); int writegame(const char *filename);
/* Versionsänderungen: */ /* Versionsänderungen: */

View File

@ -15,7 +15,7 @@ static void test_readwrite_data(CuTest * tc)
test_cleanup(); test_cleanup();
sprintf(path, "%s/%s", datapath(), filename); sprintf(path, "%s/%s", datapath(), filename);
CuAssertIntEquals(tc, 0, writegame(filename)); CuAssertIntEquals(tc, 0, writegame(filename));
CuAssertIntEquals(tc, 0, readgame(filename, 0)); CuAssertIntEquals(tc, 0, readgame(filename, false));
CuAssertIntEquals(tc, RELEASE_VERSION, global.data_version); CuAssertIntEquals(tc, RELEASE_VERSION, global.data_version);
CuAssertIntEquals(tc, 0, remove(path)); CuAssertIntEquals(tc, 0, remove(path));
test_cleanup(); test_cleanup();

File diff suppressed because it is too large Load Diff

@ -1 +1 @@
Subproject commit bcc2874cf289a1d0fc9cc79ff3ed271403b2e24c Subproject commit 48768e4bef7ff28365487e047d3b910127c716d0