add a debug option, -D

usually do not need to save the game when debugging
This commit is contained in:
Enno Rehling 2021-01-02 20:16:20 +01:00
parent f4acff67e4
commit fb294d9118
3 changed files with 9 additions and 2 deletions

View file

@ -81,7 +81,7 @@
#define MAXPERSISTENT 128 #define MAXPERSISTENT 128
/* exported symbols symbols */ /* exported symbols symbols */
int firstx = 0, firsty = 0; int g_writegame = 1;
static void read_alliances(gamedata *data) static void read_alliances(gamedata *data)
{ {
@ -1719,6 +1719,9 @@ int writegame(const char *filename)
stream strm; stream strm;
FILE *F; FILE *F;
if (g_writegame == 0) {
return -1;
}
create_directories(); create_directories();
path_join(datapath(), filename, path, sizeof(path)); path_join(datapath(), filename, path, sizeof(path));
/* make sure we don't overwrite an existing file (hard links) */ /* make sure we don't overwrite an existing file (hard links) */

View file

@ -23,7 +23,7 @@ extern "C" {
* dass hier ein Fehler (fehlende ") vorliegt */ * dass hier ein Fehler (fehlende ") vorliegt */
/* TODO: is this *really* still in use? */ /* TODO: is this *really* still in use? */
extern int enc_gamedata; extern int g_writegame;
int readgame(const char *filename); int readgame(const char *filename);
int writegame(const char *filename); int writegame(const char *filename);

View file

@ -6,6 +6,7 @@
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/messages.h> #include <kernel/messages.h>
#include <kernel/version.h> #include <kernel/version.h>
#include <kernel/save.h>
#include <util/language.h> #include <util/language.h>
#include <util/log.h> #include <util/log.h>
@ -196,6 +197,9 @@ static int parse_args(int argc, char **argv)
else { else {
const char *arg; const char *arg;
switch (argi[1]) { switch (argi[1]) {
case 'D':
g_writegame = 0;
break;
case 'c': case 'c':
i = get_arg(argc, argv, 2, i, &arg, 0); i = get_arg(argc, argv, 2, i, &arg, 0);
config_set("config.path", arg); config_set("config.path", arg);