From: Jason S. Ninneman Date: Sun, 2 Jul 2017 16:42:07 +0000 (-0700) Subject: Replace datime() with just time(). X-Git-Tag: takebird~108 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=d23111dabab46a8bcdf7e453ec099e4521d1cad6;p=open-adventure.git Replace datime() with just time(). Also make the 'savetime' value meaningful. This removes a separate library dependency on some systems. --- diff --git a/Makefile b/Makefile index 906698a..6724a3b 100644 --- a/Makefile +++ b/Makefile @@ -12,11 +12,6 @@ CCFLAGS+=-std=c99 -D_DEFAULT_SOURCE -DVERSION=\"$(VERS)\" -O2 LIBS=$(shell pkg-config --libs libedit) INC+=$(shell pkg-config --cflags libedit) -UNAME_S := $(shell uname -s) -ifeq ($(UNAME_S),Linux) - LIBS+=-lrt -endif - OBJS=main.o init.o actions.o score.o misc.o saveresume.o CHEAT_OBJS=cheat.o init.o actions.o score.o misc.o saveresume.o SOURCES=$(OBJS:.o=.c) advent.h adventure.yaml Makefile control make_dungeon.py diff --git a/advent.h b/advent.h index 9de79f0..a8d53f2 100644 --- a/advent.h +++ b/advent.h @@ -206,7 +206,6 @@ extern long atdwrf(long); extern long setbit(long); extern bool tstbit(long, int); extern void make_zzword(char*); -extern void datime(long*, long*); extern void set_seed(long); extern unsigned long get_next_lcg_value(void); extern long randrange(long); diff --git a/misc.c b/misc.c index feebb4a..51760b5 100644 --- a/misc.c +++ b/misc.c @@ -680,14 +680,6 @@ void make_zzword(char zzword[6]) zzword[5] = '\0'; } -void datime(long* d, long* t) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - *d = (long) tv.tv_sec; - *t = (long) tv.tv_usec; -} - // LCOV_EXCL_START void bug(enum bugtype num, const char *error_string) { diff --git a/saveresume.c b/saveresume.c index 49e0021..088bab1 100644 --- a/saveresume.c +++ b/saveresume.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "advent.h" #include "dungeon.h" @@ -31,12 +32,8 @@ struct save_t save; int savefile(FILE *fp, long version) /* Save game to file. No input or output from user. */ { - long i, k; - datime(&i, &k); - k = i + 650 * k; - save.savetime = k; + save.savetime = time(NULL); save.mode = -1; - save.version = (version == 0) ? VRSION : version; memcpy(&save.game, &game, sizeof(struct game_t));