projects
/
open-adventure.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Restory working seed value for dwarf.log.
[open-adventure.git]
/
main.c
diff --git
a/main.c
b/main.c
index 881578def7c757011166db7608f75a7735a41e50..d84e4f2ad85a9aa54a1d624162e273b91a401251 100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-7,6
+7,7
@@
#include <stdio.h>
#include <stdbool.h>
#include <getopt.h>
#include <stdio.h>
#include <stdbool.h>
#include <getopt.h>
+#include <signal.h>
#include "main.h"
#include "misc.h"
#include "main.h"
#include "misc.h"
@@
-48,6
+49,14
@@
extern void initialise();
extern void score(long);
extern int action(FILE *, long);
extern void score(long);
extern int action(FILE *, long);
+void sig_handler(int signo)
+{
+ if (signo == SIGINT)
+ if (logfp != NULL)
+ fflush(logfp);
+ exit(0);
+}
+
/*
* MAIN PROGRAM
*/
/*
* MAIN PROGRAM
*/
@@
-75,6
+84,7
@@
int main(int argc, char *argv[]) {
fprintf(stderr,
"advent: can't open logfile %s for write\n",
optarg);
fprintf(stderr,
"advent: can't open logfile %s for write\n",
optarg);
+ signal(SIGINT, sig_handler);
break;
case 'o':
oldstyle = true;
break;
case 'o':
oldstyle = true;
@@
-150,6
+160,8
@@
static bool fallback_handler(signed char *buf)
if (sscanf(buf, "seed %ld", &sv) == 1) {
set_seed(sv);
printf("Seed set to %ld\n", sv);
if (sscanf(buf, "seed %ld", &sv) == 1) {
set_seed(sv);
printf("Seed set to %ld\n", sv);
+ // here we reconfigure any global game state that uses random numbers
+ ZZWORD=RNDVOC(3,0)+MESH*2;
return true;
}
return false;
return true;
}
return false;