Update ignores

Use linux makefile
Fix crash on exit with -h arg
This commit is contained in:
rob 2022-08-28 13:52:39 +10:00
parent da3c8d46ba
commit 08ef45876a
3 changed files with 15 additions and 8 deletions

6
.gitignore vendored
View File

@ -1,4 +1,8 @@
nexus nexus
*.o *.o
*.swp *.swp
log.txt prof.txt
Makefile
gmon.out
hiscores.db
temp/*

View File

@ -1,4 +1,4 @@
CFLAGS=-fdiagnostics-color=always -g -Wall -Werror -Wno-format-truncation -Wno-unused-but-set-variable CFLAGS=-fdiagnostics-color=always -Wall -g -pg -Werror -Wno-format-truncation -Wno-unused-but-set-variable
nexus: ai.o astar.o attack.o data.o flag.o god.o io.o lf.o map.o move.o nexus.o objects.o save.o shops.o spell.o text.o vault.o ai.h attack.h data.h defs.h flag.h god.h io.h lf.h map.h move.h nexus.h objects.h save.h shops.h spell.h text.h vault.h Makefile nexus: ai.o astar.o attack.o data.o flag.o god.o io.o lf.o map.o move.o nexus.o objects.o save.o shops.o spell.o text.o vault.o ai.h attack.h data.h defs.h flag.h god.h io.h lf.h map.h move.h nexus.h objects.h save.h shops.h spell.h text.h vault.h Makefile
gcc $(CFLAGS) -o nexus ai.o astar.o attack.o data.o flag.o god.o io.o lf.o map.o move.o nexus.o objects.o save.o shops.o spell.o text.o vault.o -lm -lncursesw -lsqlite3 gcc $(CFLAGS) -o nexus ai.o astar.o attack.o data.o flag.o god.o io.o lf.o map.o move.o nexus.o objects.o save.o shops.o spell.o text.o vault.o -lm -lncursesw -lsqlite3

15
nexus.c
View File

@ -153,7 +153,7 @@ int main(int argc, char **argv) {
atexit(cleanup); atexit(cleanup);
while ((ch = getopt(argc, argv, "f:sS:")) != -1) { while ((ch = getopt(argc, argv, "f:hsS:")) != -1) {
switch (ch) { switch (ch) {
case 'f': case 'f':
playerfile = fopen(optarg, "rt"); playerfile = fopen(optarg, "rt");
@ -907,7 +907,7 @@ void cleanup(void) {
free(xpposs); free(xpposs);
free(raceposs); free(raceposs);
fclose(logfile); if (logfile) fclose(logfile);
// free commands & options // free commands & options
while (firstcommand) killcommand(firstcommand); while (firstcommand) killcommand(firstcommand);
@ -2461,9 +2461,12 @@ void timeeffectsworld(map_t *map, int updategametime) {
} }
void usage(char *progname) { void usage(char *progname) {
printf("usage: %s [options] \n",progname); char *fmt = " -%c %-10s %s\n";
printf("\t-f xx\tReads player details from file xx.\n"); printf("usage: %s [options]\n",progname);
printf("\t-s\tShows top 10 hiscores.\n"); printf(fmt, 'f', "filename", "Read player details from given file.");
printf("\t-S xx\tShows top xx hiscores (max 100).\n"); printf(fmt, 'h', "", "Show this text.");
printf(fmt, 's', "", "Show the top 10 hiscores.");
printf(fmt, 'S', "num", "Show the top 'num' hiscores.");
printf("\n");
} }