2010-11-25 12:21:41 +00:00
|
|
|
/*
|
|
|
|
|
* Rogue
|
|
|
|
|
* Exploring the dungeons of doom
|
|
|
|
|
*
|
|
|
|
|
* @(#)main.c 9.0 (rdk) 7/17/84
|
|
|
|
|
*
|
|
|
|
|
* Super-Rogue
|
|
|
|
|
* Copyright (C) 1984 Robert D. Kindelberger
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Based on "Rogue: Exploring the Dungeons of Doom"
|
|
|
|
|
* Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* See the file LICENSE.TXT for full copyright and licensing information.
|
|
|
|
|
*/
|
|
|
|
|
|
2012-01-27 17:29:30 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2010-11-25 12:21:41 +00:00
|
|
|
#include <time.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <limits.h>
|
2017-09-15 19:57:54 -04:00
|
|
|
#include <errno.h>
|
2010-11-25 12:21:41 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include "rogue.h"
|
|
|
|
|
|
|
|
|
|
#ifdef ATT
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef BSD
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "rogue.ext"
|
|
|
|
|
|
2016-01-31 13:45:07 -05:00
|
|
|
char *roguehome(void);
|
2015-08-01 15:12:11 -04:00
|
|
|
void open_records(void);
|
|
|
|
|
|
2017-09-15 19:57:54 -04:00
|
|
|
extern FILE *scoreboard;
|
2015-08-01 15:12:11 -04:00
|
|
|
extern FILE *logfile;
|
|
|
|
|
|
2016-01-31 13:45:07 -05:00
|
|
|
int
|
|
|
|
|
main(int argc, char *argv[], char *envp[])
|
2010-11-25 12:21:41 +00:00
|
|
|
{
|
|
|
|
|
register char *env;
|
|
|
|
|
register struct linked_list *item;
|
|
|
|
|
register struct object *obj;
|
2019-11-22 21:18:27 -05:00
|
|
|
char alldone;
|
|
|
|
|
int wpt;
|
2010-11-25 12:21:41 +00:00
|
|
|
char *getpass(), *xcrypt(), *strrchr();
|
|
|
|
|
char *homedir = roguehome();
|
|
|
|
|
|
2016-03-03 21:30:38 -05:00
|
|
|
md_init();
|
2010-11-25 12:21:41 +00:00
|
|
|
|
|
|
|
|
if (homedir == NULL)
|
|
|
|
|
homedir = "";
|
|
|
|
|
|
2014-05-02 15:06:23 -07:00
|
|
|
playuid = md_getuid();
|
|
|
|
|
playgid = md_getgid();
|
2010-11-25 12:21:41 +00:00
|
|
|
|
|
|
|
|
/* check for print-score option */
|
2010-11-25 17:28:29 +00:00
|
|
|
#ifdef SCOREFILE
|
|
|
|
|
strncpy(scorefile, SCOREFILE, LINLEN);
|
|
|
|
|
scorefile[LINLEN - 1] = '\0';
|
|
|
|
|
#else
|
2010-11-25 12:21:41 +00:00
|
|
|
|
2015-08-02 12:14:47 -04:00
|
|
|
strncpy(scorefile, homedir, LINLEN-11);
|
|
|
|
|
if (scorefile[LINLEN-12] != '\0')
|
|
|
|
|
scorefile[0] = '\0';
|
2010-11-25 12:21:41 +00:00
|
|
|
|
|
|
|
|
if (*scorefile)
|
|
|
|
|
strcat(scorefile,"/");
|
|
|
|
|
strcat(scorefile, "srogue.scr");
|
2010-11-25 17:28:29 +00:00
|
|
|
#endif
|
2015-08-01 15:12:11 -04:00
|
|
|
open_records();
|
2010-11-25 12:21:41 +00:00
|
|
|
|
|
|
|
|
if(argc >= 2 && strcmp(argv[1], "-s") == 0)
|
|
|
|
|
{
|
|
|
|
|
showtop(0);
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-31 14:24:31 -07:00
|
|
|
#ifdef WIZARD
|
2010-11-25 12:21:41 +00:00
|
|
|
if (argc >= 2 && author() && strcmp(argv[1],"-a") == 0)
|
|
|
|
|
{
|
|
|
|
|
wizard = TRUE;
|
|
|
|
|
argv++;
|
|
|
|
|
argc--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check to see if he is a wizard */
|
|
|
|
|
|
|
|
|
|
if (argc >= 2 && strcmp(argv[1],"-w") == 0)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(PASSWD, xcrypt(getpass(wizstr),"mT")) == 0)
|
|
|
|
|
{
|
|
|
|
|
wizard = TRUE;
|
|
|
|
|
argv++;
|
|
|
|
|
argc--;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-08-31 14:24:31 -07:00
|
|
|
#endif
|
2010-11-25 12:21:41 +00:00
|
|
|
|
2010-11-25 17:28:29 +00:00
|
|
|
#ifdef SAVEDIR
|
|
|
|
|
if (argc >= 3 && !strcmp(argv[1], "-n")) {
|
|
|
|
|
strncpy(whoami, argv[2], LINLEN);
|
|
|
|
|
whoami[LINLEN - 1] = '\0';
|
|
|
|
|
use_savedir = TRUE;
|
2014-03-23 21:27:14 -07:00
|
|
|
if (snprintf(file_name, 256, "%s/%d-%s.srsav", SAVEDIR,
|
|
|
|
|
playuid, whoami) >= 256) {
|
2010-11-25 17:28:29 +00:00
|
|
|
/* Just in case it doesn't fit */
|
|
|
|
|
strcpy(file_name, "srogue.save");
|
|
|
|
|
use_savedir = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-05-02 15:06:23 -07:00
|
|
|
if (!use_savedir)
|
2015-08-01 16:23:24 -04:00
|
|
|
md_normaluser();
|
2014-05-02 15:06:23 -07:00
|
|
|
|
2010-11-25 12:21:41 +00:00
|
|
|
/* get home and options from environment */
|
|
|
|
|
|
|
|
|
|
if ((env = getenv("HOME")) != NULL)
|
|
|
|
|
strcpy(home, env);
|
2014-04-30 14:46:30 -07:00
|
|
|
else {
|
|
|
|
|
strncpy(home, md_gethomedir(), LINLEN);
|
|
|
|
|
if (home[LINLEN-1] != '\0')
|
|
|
|
|
home[0] = '\0';
|
|
|
|
|
}
|
2010-11-25 12:21:41 +00:00
|
|
|
|
|
|
|
|
if (strcmp(home,"/") == 0)
|
|
|
|
|
home[0] = '\0';
|
|
|
|
|
|
|
|
|
|
if ((strlen(home) > 0) && (home[strlen(home)-1] != '/'))
|
|
|
|
|
strcat(home, "/");
|
|
|
|
|
|
2010-11-25 17:28:29 +00:00
|
|
|
if (!use_savedir) {
|
|
|
|
|
strcpy(file_name, home);
|
|
|
|
|
strcat(file_name, "srogue.sav");
|
|
|
|
|
}
|
2010-11-25 12:21:41 +00:00
|
|
|
|
|
|
|
|
if ((env = getenv("ROGUEOPTS")) != NULL)
|
|
|
|
|
parse_opts(env);
|
|
|
|
|
|
2010-11-25 17:28:29 +00:00
|
|
|
if (!use_savedir && (env == NULL || whoami[0] == '\0'))
|
2010-11-25 12:21:41 +00:00
|
|
|
{
|
2014-04-30 14:46:30 -07:00
|
|
|
strucpy(whoami, md_getusername(), strlen(md_getusername()));
|
2010-11-25 12:21:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (env == NULL || fruit[0] == '\0')
|
|
|
|
|
strcpy(fruit, "juicy-fruit");
|
|
|
|
|
|
2010-11-25 17:28:29 +00:00
|
|
|
if (use_savedir)
|
|
|
|
|
{
|
|
|
|
|
/* restore() won't return if the restore succeeded. If
|
|
|
|
|
* file_name doesn't exist, it will return TRUE. In that
|
|
|
|
|
* case, start a new game. */
|
|
|
|
|
if (!restore(file_name, envp))
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
else if (argc == 2)
|
2010-11-25 12:21:41 +00:00
|
|
|
if(!restore(argv[1], envp)) /* NOTE: NEVER RETURNS */
|
|
|
|
|
exit(1);
|
|
|
|
|
|
2010-11-25 17:28:29 +00:00
|
|
|
/* START NEW GAME */
|
|
|
|
|
|
2010-11-25 12:21:41 +00:00
|
|
|
dnum = (wizard && getenv("SEED") != NULL ?
|
2017-01-28 15:49:41 -05:00
|
|
|
atoi(getenv("SEED")) : md_random_seed());
|
2010-11-25 12:21:41 +00:00
|
|
|
|
|
|
|
|
if(wizard)
|
|
|
|
|
printf("Hello %s, welcome to dungeon #%d\n", whoami, dnum);
|
|
|
|
|
else
|
|
|
|
|
printf("Hello %s, One moment while I open the door to the dungeon...\n", whoami);
|
|
|
|
|
|
|
|
|
|
fflush(stdout);
|
|
|
|
|
seed = dnum;
|
2014-05-03 10:31:30 -07:00
|
|
|
md_srandom(seed); /* init rnd number gen */
|
2010-11-25 12:21:41 +00:00
|
|
|
|
2014-04-30 14:46:30 -07:00
|
|
|
md_onsignal_exit(); /* just in case */
|
2010-11-25 12:21:41 +00:00
|
|
|
|
|
|
|
|
init_everything();
|
|
|
|
|
|
|
|
|
|
#ifdef __INTERIX
|
|
|
|
|
setenv("TERM","interix");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
initscr(); /* Start up cursor package */
|
|
|
|
|
|
|
|
|
|
if (strcmp(termname(),"dumb") == 0)
|
|
|
|
|
{
|
|
|
|
|
endwin();
|
|
|
|
|
printf("ERROR in terminal parameters.\n");
|
|
|
|
|
printf("Check TERM in environment.\n");
|
|
|
|
|
byebye(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (LINES < 24 || COLS < 80) {
|
|
|
|
|
endwin();
|
|
|
|
|
printf("ERROR: screen size too small\n");
|
|
|
|
|
byebye(1);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-23 09:47:00 -04:00
|
|
|
if ((*whoami == '\0') || (strcmp(whoami,"dosuser")==0))
|
2010-11-25 12:21:41 +00:00
|
|
|
{
|
|
|
|
|
echo();
|
|
|
|
|
mvaddstr(23,2,"Rogue's Name? ");
|
|
|
|
|
wgetnstr(stdscr,whoami,MAXSTR);
|
|
|
|
|
noecho();
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-23 09:47:00 -04:00
|
|
|
if (*whoami == '\0')
|
2010-11-25 12:21:41 +00:00
|
|
|
strcpy(whoami,"Rodney");
|
|
|
|
|
|
|
|
|
|
setup();
|
|
|
|
|
|
|
|
|
|
/* Set up windows */
|
|
|
|
|
|
|
|
|
|
cw = newwin(0, 0, 0, 0);
|
|
|
|
|
mw = newwin(0, 0, 0, 0);
|
|
|
|
|
hw = newwin(0, 0, 0, 0);
|
2013-08-10 17:43:58 -07:00
|
|
|
keypad(cw, 1);
|
2010-11-25 12:21:41 +00:00
|
|
|
waswizard = wizard;
|
|
|
|
|
|
|
|
|
|
/* Draw current level */
|
|
|
|
|
|
|
|
|
|
new_level(NORMLEV);
|
|
|
|
|
|
|
|
|
|
/* Start up daemons and fuses */
|
|
|
|
|
|
2013-09-07 08:08:00 -04:00
|
|
|
start_daemon(status, TRUE, BEFORE);
|
|
|
|
|
start_daemon(runners, TRUE, AFTER);
|
2010-11-27 16:49:44 +00:00
|
|
|
/*
|
|
|
|
|
* These daemons have been moved to AFTER because BEFORE daemons
|
|
|
|
|
* get called every command, even invalid ones. Hopefully this
|
|
|
|
|
* won't break anything.
|
|
|
|
|
*/
|
2013-09-07 08:08:00 -04:00
|
|
|
start_daemon(doctor, TRUE, AFTER);
|
|
|
|
|
start_daemon(stomach, TRUE, AFTER);
|
2010-11-25 12:21:41 +00:00
|
|
|
fuse(swander, TRUE, WANDERTIME);
|
|
|
|
|
|
|
|
|
|
/* Give the rogue his weaponry */
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
wpt = pick_one(w_magic);
|
|
|
|
|
switch (wpt)
|
|
|
|
|
{
|
|
|
|
|
case MACE: case SWORD: case TWOSWORD:
|
|
|
|
|
case SPEAR: case TRIDENT: case SPETUM:
|
|
|
|
|
case BARDICHE: case PIKE: case BASWORD:
|
|
|
|
|
case HALBERD:
|
|
|
|
|
alldone = TRUE;
|
|
|
|
|
otherwise:
|
|
|
|
|
alldone = FALSE;
|
|
|
|
|
}
|
|
|
|
|
} while(!alldone);
|
|
|
|
|
|
|
|
|
|
item = new_thing(FALSE, WEAPON, wpt);
|
|
|
|
|
obj = OBJPTR(item);
|
|
|
|
|
obj->o_hplus = rnd(3);
|
|
|
|
|
obj->o_dplus = rnd(3);
|
|
|
|
|
obj->o_flags = ISKNOW;
|
|
|
|
|
add_pack(item, TRUE);
|
|
|
|
|
cur_weapon = obj;
|
|
|
|
|
|
|
|
|
|
/* Now a bow */
|
|
|
|
|
|
|
|
|
|
item = new_thing(FALSE, WEAPON, BOW);
|
|
|
|
|
obj = OBJPTR(item);
|
|
|
|
|
obj->o_hplus = rnd(3);
|
|
|
|
|
obj->o_dplus = rnd(3);
|
|
|
|
|
obj->o_flags = ISKNOW;
|
|
|
|
|
add_pack(item, TRUE);
|
|
|
|
|
|
|
|
|
|
/* Now some arrows */
|
|
|
|
|
|
|
|
|
|
item = new_thing(FALSE, WEAPON, ARROW);
|
|
|
|
|
obj = OBJPTR(item);
|
|
|
|
|
obj->o_count = 25 + rnd(15);
|
|
|
|
|
obj->o_hplus = rnd(2);
|
|
|
|
|
obj->o_dplus = rnd(2);
|
|
|
|
|
obj->o_flags = ISKNOW;
|
|
|
|
|
add_pack(item, TRUE);
|
|
|
|
|
|
|
|
|
|
/* And his suit of armor */
|
|
|
|
|
|
|
|
|
|
wpt = pick_one(a_magic);
|
|
|
|
|
item = new_thing(FALSE, ARMOR, wpt);
|
|
|
|
|
obj = OBJPTR(item);
|
|
|
|
|
obj->o_flags = ISKNOW;
|
|
|
|
|
obj->o_ac = armors[wpt].a_class - rnd(4);
|
|
|
|
|
cur_armor = obj;
|
|
|
|
|
add_pack(item, TRUE);
|
|
|
|
|
|
|
|
|
|
/* Give him some food */
|
|
|
|
|
|
|
|
|
|
item = new_thing(FALSE, FOOD, 0);
|
|
|
|
|
add_pack(item, TRUE);
|
|
|
|
|
|
|
|
|
|
playit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* endit:
|
|
|
|
|
* Exit the program abnormally.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
endit(int a)
|
|
|
|
|
{
|
|
|
|
|
fatal("Ok, if you want to exit that badly, I'll have to allow it");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* fatal:
|
|
|
|
|
* Exit the program, printing a message.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-01-31 13:45:07 -05:00
|
|
|
void
|
|
|
|
|
fatal(char *s)
|
2010-11-25 12:21:41 +00:00
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
refresh();
|
|
|
|
|
endwin();
|
|
|
|
|
fprintf(stderr,"%s\n\r",s);
|
|
|
|
|
fflush(stderr);
|
|
|
|
|
byebye(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* byebye:
|
|
|
|
|
* Exit here and reset the users terminal parameters
|
|
|
|
|
* to the way they were when he started
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void
|
2016-01-31 13:45:07 -05:00
|
|
|
byebye(int how)
|
2010-11-25 12:21:41 +00:00
|
|
|
{
|
|
|
|
|
if (!isendwin())
|
|
|
|
|
endwin();
|
|
|
|
|
|
|
|
|
|
exit(how); /* exit like flag says */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* rnd:
|
|
|
|
|
* Pick a very random number.
|
|
|
|
|
*/
|
2016-01-31 13:45:07 -05:00
|
|
|
int
|
|
|
|
|
rnd(int range)
|
2010-11-25 12:21:41 +00:00
|
|
|
{
|
|
|
|
|
reg int wh;
|
|
|
|
|
|
|
|
|
|
if (range == 0)
|
|
|
|
|
wh = 0;
|
|
|
|
|
else {
|
2014-05-03 10:31:30 -07:00
|
|
|
wh = md_random() % range;
|
2010-11-25 12:21:41 +00:00
|
|
|
wh &= 0x7FFFFFFF;
|
|
|
|
|
}
|
|
|
|
|
return wh;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* roll:
|
|
|
|
|
* roll a number of dice
|
|
|
|
|
*/
|
2016-01-31 13:45:07 -05:00
|
|
|
int
|
|
|
|
|
roll(int number, int sides)
|
2010-11-25 12:21:41 +00:00
|
|
|
{
|
|
|
|
|
reg int dtotal = 0;
|
|
|
|
|
|
|
|
|
|
while(number-- > 0)
|
|
|
|
|
dtotal += rnd(sides)+1;
|
|
|
|
|
return dtotal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** setup: Setup signal catching functions
|
|
|
|
|
*/
|
2016-01-31 13:45:07 -05:00
|
|
|
void
|
|
|
|
|
setup(void)
|
2010-11-25 12:21:41 +00:00
|
|
|
{
|
2014-04-30 14:46:30 -07:00
|
|
|
md_onsignal_autosave();
|
2010-11-25 12:21:41 +00:00
|
|
|
|
2010-12-06 19:43:32 +00:00
|
|
|
nonl();
|
2010-11-25 12:21:41 +00:00
|
|
|
cbreak();
|
|
|
|
|
noecho();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** playit: The main loop of the program. Loop until the game is over,
|
|
|
|
|
** refreshing things and looking at the proper times.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-01-31 13:45:07 -05:00
|
|
|
void
|
|
|
|
|
playit(void)
|
2010-11-25 12:21:41 +00:00
|
|
|
{
|
|
|
|
|
reg char *opts;
|
|
|
|
|
|
|
|
|
|
/* parse environment declaration of options */
|
|
|
|
|
|
|
|
|
|
if ((opts = getenv("ROGUEOPTS")) != NULL)
|
|
|
|
|
parse_opts(opts);
|
|
|
|
|
|
|
|
|
|
player.t_oldpos = hero;
|
|
|
|
|
oldrp = roomin(&hero);
|
|
|
|
|
nochange = FALSE;
|
|
|
|
|
while (playing)
|
|
|
|
|
command(); /* Command execution */
|
|
|
|
|
endit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** author: See if a user is an author of the program
|
|
|
|
|
*/
|
2016-01-31 13:45:07 -05:00
|
|
|
bool
|
|
|
|
|
author(void)
|
2010-11-25 12:21:41 +00:00
|
|
|
{
|
|
|
|
|
switch (playuid) {
|
|
|
|
|
case 100:
|
|
|
|
|
case 0:
|
|
|
|
|
return TRUE;
|
|
|
|
|
default:
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
directory_exists(char *dirname)
|
|
|
|
|
{
|
|
|
|
|
struct stat sb;
|
|
|
|
|
|
|
|
|
|
if (stat(dirname, &sb) == 0) /* path exists */
|
2015-08-03 09:05:15 -04:00
|
|
|
return ((sb.st_mode & S_IFMT) == S_IFDIR);
|
2010-11-25 12:21:41 +00:00
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *
|
2016-01-31 13:45:07 -05:00
|
|
|
roguehome(void)
|
2010-11-25 12:21:41 +00:00
|
|
|
{
|
2015-08-02 12:14:47 -04:00
|
|
|
static char path[LINLEN+16];
|
2010-11-25 12:21:41 +00:00
|
|
|
char *end,*home;
|
|
|
|
|
|
|
|
|
|
if ( (home = getenv("ROGUEHOME")) != NULL)
|
|
|
|
|
{
|
|
|
|
|
if (*home)
|
|
|
|
|
{
|
2015-08-02 12:14:47 -04:00
|
|
|
/* LINLEN - 11 is all that will fit into scorefile */
|
|
|
|
|
strncpy(path, home, LINLEN - 11);
|
|
|
|
|
if (path[LINLEN - 12] == '\0')
|
|
|
|
|
{
|
|
|
|
|
end = &path[strlen(path)-1];
|
|
|
|
|
while( (end >= path) && ((*end == '/') || (*end == '\\')))
|
|
|
|
|
*end-- = '\0';
|
|
|
|
|
|
|
|
|
|
if (directory_exists(path))
|
|
|
|
|
return(path);
|
|
|
|
|
}
|
|
|
|
|
/* Otherwise home was truncated and should be ignored */
|
2010-11-25 12:21:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (directory_exists("/var/games/roguelike"))
|
|
|
|
|
return("/var/games/roguelike");
|
|
|
|
|
if (directory_exists("/var/lib/roguelike"))
|
|
|
|
|
return("/var/lib/roguelike");
|
|
|
|
|
if (directory_exists("/var/roguelike"))
|
|
|
|
|
return("/var/roguelike");
|
|
|
|
|
if (directory_exists("/usr/games/lib"))
|
|
|
|
|
return("/usr/games/lib");
|
|
|
|
|
if (directory_exists("/games/roguelik"))
|
|
|
|
|
return("/games/roguelik");
|
|
|
|
|
|
|
|
|
|
return(NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-01 15:12:11 -04:00
|
|
|
void
|
|
|
|
|
open_records(void)
|
|
|
|
|
{
|
2017-09-15 19:57:54 -04:00
|
|
|
if (scoreboard == NULL)
|
|
|
|
|
scoreboard = fopen(scorefile, "r+");
|
|
|
|
|
if (scoreboard == NULL && errno == ENOENT) {
|
|
|
|
|
scoreboard = fopen(scorefile, "w+");
|
|
|
|
|
}
|
2015-08-01 15:12:11 -04:00
|
|
|
#ifdef LOGFILE
|
|
|
|
|
if (logfile == NULL)
|
|
|
|
|
logfile = fopen(LOGFILE, "a");
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|