Replace datime() with just time().

Also make the 'savetime' value meaningful.

This removes a separate library dependency on some systems.
This commit is contained in:
Jason S. Ninneman 2017-07-02 09:42:07 -07:00
parent fb8ba08986
commit d23111daba
4 changed files with 2 additions and 19 deletions

View file

@ -12,11 +12,6 @@ CCFLAGS+=-std=c99 -D_DEFAULT_SOURCE -DVERSION=\"$(VERS)\" -O2
LIBS=$(shell pkg-config --libs libedit) LIBS=$(shell pkg-config --libs libedit)
INC+=$(shell pkg-config --cflags 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 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 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 SOURCES=$(OBJS:.o=.c) advent.h adventure.yaml Makefile control make_dungeon.py

View file

@ -206,7 +206,6 @@ extern long atdwrf(long);
extern long setbit(long); extern long setbit(long);
extern bool tstbit(long, int); extern bool tstbit(long, int);
extern void make_zzword(char*); extern void make_zzword(char*);
extern void datime(long*, long*);
extern void set_seed(long); extern void set_seed(long);
extern unsigned long get_next_lcg_value(void); extern unsigned long get_next_lcg_value(void);
extern long randrange(long); extern long randrange(long);

8
misc.c
View file

@ -680,14 +680,6 @@ void make_zzword(char zzword[6])
zzword[5] = '\0'; 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 // LCOV_EXCL_START
void bug(enum bugtype num, const char *error_string) void bug(enum bugtype num, const char *error_string)
{ {

View file

@ -1,6 +1,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <editline/readline.h> #include <editline/readline.h>
#include <time.h>
#include "advent.h" #include "advent.h"
#include "dungeon.h" #include "dungeon.h"
@ -31,12 +32,8 @@ struct save_t save;
int savefile(FILE *fp, long version) int savefile(FILE *fp, long version)
/* Save game to file. No input or output from user. */ /* Save game to file. No input or output from user. */
{ {
long i, k; save.savetime = time(NULL);
datime(&i, &k);
k = i + 650 * k;
save.savetime = k;
save.mode = -1; save.mode = -1;
save.version = (version == 0) ? VRSION : version; save.version = (version == 0) ? VRSION : version;
memcpy(&save.game, &game, sizeof(struct game_t)); memcpy(&save.game, &game, sizeof(struct game_t));