2015-04-21 08:55:20 -04:00
|
|
|
/*
|
|
|
|
|
main.c - setup code
|
|
|
|
|
|
|
|
|
|
XRogue: Expeditions into the Dungeons of Doom
|
|
|
|
|
Copyright (C) 1991 Robert Pietkivitch
|
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
Based on "Advanced Rogue"
|
|
|
|
|
Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
|
|
|
|
|
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.
|
|
|
|
|
*/
|
|
|
|
|
|
2015-04-21 10:34:01 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2015-04-21 08:55:20 -04:00
|
|
|
#include <curses.h>
|
|
|
|
|
#include <signal.h>
|
2021-05-03 19:05:37 -04:00
|
|
|
#include <limits.h>
|
2015-04-21 08:55:20 -04:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
#include "mach_dep.h"
|
|
|
|
|
#include "network.h"
|
|
|
|
|
#include "rogue.h"
|
|
|
|
|
|
2015-05-16 13:39:26 -04:00
|
|
|
void open_records(void);
|
2016-03-02 21:13:26 -05:00
|
|
|
bool too_much(void);
|
|
|
|
|
bool author(void);
|
|
|
|
|
bool playtime(void);
|
|
|
|
|
bool betaover(void);
|
2015-04-22 16:03:00 -04:00
|
|
|
|
2016-03-02 21:13:26 -05:00
|
|
|
int
|
|
|
|
|
main(int argc, char *argv[], char *envp[])
|
2015-04-21 08:55:20 -04:00
|
|
|
{
|
|
|
|
|
register char *env;
|
|
|
|
|
|
|
|
|
|
md_init();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* get home and options from environment
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
strncpy(home, md_gethomedir(), LINELEN);
|
2021-05-03 19:05:37 -04:00
|
|
|
home[LINELEN-1] = '\0';
|
2015-04-21 08:55:20 -04:00
|
|
|
|
|
|
|
|
/* Get default save file */
|
|
|
|
|
strcpy(file_name, home);
|
|
|
|
|
strcat(file_name, "xrogue.sav");
|
|
|
|
|
|
|
|
|
|
/* Get default score file */
|
2015-04-22 16:03:00 -04:00
|
|
|
#ifdef SCOREFILE
|
2021-05-03 19:05:37 -04:00
|
|
|
strncpy(score_file, SCOREFILE, PATH_MAX);
|
|
|
|
|
score_file[PATH_MAX-1] = '\0';
|
2015-04-22 16:03:00 -04:00
|
|
|
#else
|
2015-04-21 08:55:20 -04:00
|
|
|
strcpy(score_file, md_getroguedir());
|
|
|
|
|
|
|
|
|
|
if (*score_file)
|
|
|
|
|
strcat(score_file,"/");
|
|
|
|
|
|
|
|
|
|
strcat(score_file, "xrogue.scr");
|
2015-04-22 16:03:00 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SAVEDIR
|
|
|
|
|
/* Check for common save location */
|
|
|
|
|
if (argc >= 3 && strcmp(argv[1], "-n") == 0)
|
|
|
|
|
{
|
|
|
|
|
strncpy(whoami, argv[2], 79);
|
|
|
|
|
whoami[79] = '\0';
|
|
|
|
|
use_savedir = TRUE;
|
|
|
|
|
if (LINELEN <= snprintf(file_name, LINELEN, "%s/%d-%s.xrsav", SAVEDIR,
|
|
|
|
|
md_getuid(), whoami))
|
|
|
|
|
{
|
|
|
|
|
strcpy(file_name, "xrogue.sav");
|
|
|
|
|
use_savedir = FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2015-04-21 08:55:20 -04:00
|
|
|
|
|
|
|
|
if ((env = getenv("ROGUEOPTS")) != NULL)
|
|
|
|
|
parse_opts(env);
|
|
|
|
|
|
|
|
|
|
if (whoami[0] == '\0')
|
|
|
|
|
strucpy(whoami, md_getusername(), strlen(md_getusername()));
|
|
|
|
|
|
2015-05-16 13:39:26 -04:00
|
|
|
open_records();
|
|
|
|
|
if (!use_savedir)
|
|
|
|
|
md_normaluser();
|
2015-04-21 08:55:20 -04:00
|
|
|
/*
|
|
|
|
|
* check for print-score option
|
|
|
|
|
*/
|
|
|
|
|
if (argc == 2 && strcmp(argv[1], "-s") == 0)
|
|
|
|
|
{
|
|
|
|
|
waswizard = TRUE;
|
|
|
|
|
score((long)0, SCOREIT, (short)0);
|
|
|
|
|
exit_game(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check for a network update
|
|
|
|
|
*/
|
|
|
|
|
if (argc == 2 && strcmp(argv[1], "-u") == 0) {
|
|
|
|
|
int errcheck, errors = 0;
|
|
|
|
|
unsigned long amount;
|
|
|
|
|
short monster;
|
|
|
|
|
|
|
|
|
|
/* Read in the amount and monster values to pass to score */
|
|
|
|
|
amount = netread(&errcheck, sizeof(unsigned long), stdin);
|
|
|
|
|
if (errcheck) errors++;
|
|
|
|
|
|
|
|
|
|
monster = (short) netread(&errcheck, sizeof(short), stdin);
|
|
|
|
|
if (errcheck) errors++;
|
|
|
|
|
|
|
|
|
|
/* Now do the update if there were no errors */
|
|
|
|
|
if (errors) exit_game(0);
|
|
|
|
|
else {
|
|
|
|
|
score((long)amount, UPDATE, (short)monster);
|
|
|
|
|
exit_game(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check to see if he is a wizard
|
|
|
|
|
*/
|
2015-05-05 12:07:12 -04:00
|
|
|
#ifdef WIZARD
|
2015-04-21 08:55:20 -04:00
|
|
|
if (argc >= 2 && argv[1][0] == '\0')
|
|
|
|
|
if (strcmp(PASSWD, xcrypt(md_getpass("Wizard's password: "), "mT")) == 0)
|
|
|
|
|
{
|
|
|
|
|
wizard = TRUE;
|
|
|
|
|
argv++;
|
|
|
|
|
argc--;
|
|
|
|
|
}
|
2015-05-05 12:07:12 -04:00
|
|
|
#endif
|
2015-04-21 08:55:20 -04:00
|
|
|
|
|
|
|
|
if (betaover())
|
|
|
|
|
{
|
|
|
|
|
printf("Sorry, %s, but the test period of this prerelease version\n",whoami);
|
|
|
|
|
printf("of xrogue is over. Please acquire a new version. Sorry.\n");
|
|
|
|
|
exit_game(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!wizard && !author() && !playtime()) {
|
|
|
|
|
printf("Sorry, %s, but you can't play during working hours.\n", whoami);
|
|
|
|
|
printf("Try again later.\n");
|
|
|
|
|
exit_game(0);
|
|
|
|
|
}
|
|
|
|
|
if (!wizard && !author() && too_much()) {
|
|
|
|
|
printf("Sorry, %s, but the system is too loaded now.\n", whoami);
|
|
|
|
|
printf("Try again later.\n");
|
|
|
|
|
exit_game(0);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-22 16:03:00 -04:00
|
|
|
if (use_savedir)
|
|
|
|
|
{
|
|
|
|
|
/* restore() will return TRUE if a new game should be started. */
|
|
|
|
|
if (!restore(file_name, envp))
|
|
|
|
|
exit_game(0);
|
|
|
|
|
}
|
2015-04-21 08:55:20 -04:00
|
|
|
if (argc == 2)
|
|
|
|
|
if (!restore(argv[1], envp)) /* Note: restore will never return */
|
|
|
|
|
exit_game(0);
|
|
|
|
|
|
|
|
|
|
if (wizard && getenv("SEED") != NULL) {
|
|
|
|
|
seed = atoi(getenv("SEED"));
|
|
|
|
|
}
|
|
|
|
|
else {
|
2017-01-28 15:49:41 -05:00
|
|
|
seed = md_random_seed();
|
2015-04-21 08:55:20 -04:00
|
|
|
}
|
|
|
|
|
if (wizard)
|
2015-05-20 15:15:29 -04:00
|
|
|
printf("Hello %s, welcome to dungeon #%d\n", whoami, seed);
|
2015-04-21 08:55:20 -04:00
|
|
|
else
|
2015-05-20 15:15:29 -04:00
|
|
|
printf("Hello %s, just a moment while I dig the dungeon...\n", whoami);
|
2015-04-21 08:55:20 -04:00
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
|
|
md_srand(seed);
|
|
|
|
|
|
|
|
|
|
init_things(); /* Set up probabilities of things */
|
|
|
|
|
init_colors(); /* Set up colors of potions */
|
|
|
|
|
init_stones(); /* Set up stone settings of rings */
|
|
|
|
|
init_materials(); /* Set up materials of wands */
|
|
|
|
|
init_names(); /* Set up names of scrolls */
|
|
|
|
|
init_misc(); /* Set up miscellaneous magic */
|
|
|
|
|
init_foods(); /* set up the food table */
|
|
|
|
|
|
|
|
|
|
initscr(); /* Start up cursor package */
|
|
|
|
|
|
|
|
|
|
typeahead(-1); /* turn off 3.2/4.0 curses feature */
|
|
|
|
|
|
|
|
|
|
if (COLS < MINCOLS)
|
|
|
|
|
{
|
|
|
|
|
printf("\n\nSorry, %s, but your terminal window has too few columns.\n", whoami);
|
|
|
|
|
printf("Your terminal has %d columns, needs 70.\n",COLS);
|
|
|
|
|
byebye(0);
|
|
|
|
|
}
|
|
|
|
|
if (LINES < MINLINES)
|
|
|
|
|
{
|
|
|
|
|
printf("\n\nSorry, %s, but your terminal window has too few lines.\n", whoami);
|
|
|
|
|
printf("Your terminal has %d lines, needs 22.\n",LINES);
|
|
|
|
|
byebye(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cols = COLS;
|
|
|
|
|
lines = LINES;
|
|
|
|
|
|
|
|
|
|
if ( cols % 2 != 0) cols -=1; /* must be even for maze code */
|
|
|
|
|
if (lines % 2 != 0) lines -=1; /* must be even for maze code */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Now that we have cols and lines, we can update our window
|
|
|
|
|
* structure for non-hardware windows.
|
|
|
|
|
*/
|
|
|
|
|
setup();
|
|
|
|
|
/*
|
|
|
|
|
* Set up windows
|
|
|
|
|
*/
|
|
|
|
|
cw = newwin(lines, cols, 0, 0);
|
|
|
|
|
mw = newwin(lines, cols, 0, 0);
|
|
|
|
|
hw = newwin(lines, cols, 0, 0);
|
|
|
|
|
msgw = newwin(4, cols, 0, 0);
|
|
|
|
|
if (cw == NULL || hw == NULL || mw == NULL || msgw == NULL) {
|
|
|
|
|
exit_game(EXIT_CLS | EXIT_ENDWIN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
keypad(cw, TRUE);
|
|
|
|
|
keypad(hw, TRUE);
|
|
|
|
|
|
|
|
|
|
init_player(); /* Roll up the rogue */
|
|
|
|
|
waswizard = wizard;
|
|
|
|
|
|
|
|
|
|
draw(cw);
|
|
|
|
|
/* A super wizard doesn't have to get equipped */
|
|
|
|
|
/* Check if "" option is TRUE and get environment flag */
|
2021-04-14 18:55:33 -04:00
|
|
|
if ((wizard && strcmp(getenv("SUPER"),"YES") == 0) || def_attr == TRUE) {
|
2015-04-21 08:55:20 -04:00
|
|
|
level = 1;
|
|
|
|
|
new_level(NORMLEV);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
new_level(STARTLEV); /* Draw current level */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Start up daemons and fuses
|
|
|
|
|
*/
|
2015-05-28 10:21:43 -04:00
|
|
|
start_daemon(doctor, &player, AFTER);
|
2016-03-07 20:44:01 -05:00
|
|
|
fuse(swander, NULL, WANDERTIME, AFTER);
|
2015-04-21 08:55:20 -04:00
|
|
|
/* Give characters their innate abilities */
|
|
|
|
|
if (player.t_ctype == C_MAGICIAN || player.t_ctype == C_RANGER)
|
2016-03-07 20:44:01 -05:00
|
|
|
fuse(spell_recovery, NULL, SPELLTIME, AFTER);
|
2015-04-21 08:55:20 -04:00
|
|
|
if (player.t_ctype == C_DRUID || player.t_ctype == C_MONK)
|
2016-03-07 20:44:01 -05:00
|
|
|
fuse(chant_recovery, NULL, SPELLTIME, AFTER);
|
2015-04-21 08:55:20 -04:00
|
|
|
if (player.t_ctype == C_CLERIC || player.t_ctype == C_PALADIN)
|
2016-03-07 20:44:01 -05:00
|
|
|
fuse(prayer_recovery, NULL, SPELLTIME, AFTER);
|
|
|
|
|
start_daemon(stomach, NULL, AFTER);
|
2015-04-21 08:55:20 -04:00
|
|
|
if (player.t_ctype == C_THIEF ||
|
|
|
|
|
player.t_ctype == C_ASSASSIN ||
|
|
|
|
|
player.t_ctype == C_MONK)
|
2016-03-07 20:44:01 -05:00
|
|
|
start_daemon(trap_look, NULL, AFTER);
|
2015-04-21 08:55:20 -04:00
|
|
|
|
|
|
|
|
/* Does this character have any special knowledge? */
|
|
|
|
|
switch (player.t_ctype) {
|
|
|
|
|
case C_ASSASSIN:
|
|
|
|
|
/* Assassins automatically recognize poison */
|
|
|
|
|
p_know[P_POISON] = TRUE;
|
|
|
|
|
when C_FIGHTER:
|
|
|
|
|
/* Fighters automatically recognize skill */
|
|
|
|
|
p_know[P_SKILL] = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Choose an initial quest item */
|
|
|
|
|
if (!wizard) {
|
|
|
|
|
if (def_attr == FALSE)
|
|
|
|
|
quest_item = rnd(MAXRELIC);
|
|
|
|
|
}
|
|
|
|
|
mpos = 0;
|
|
|
|
|
draw(cw);
|
|
|
|
|
msg("You have been quested to retrieve the %s....",
|
|
|
|
|
rel_magic[quest_item].mi_name);
|
|
|
|
|
mpos = 0;
|
|
|
|
|
playit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* endit:
|
|
|
|
|
* Exit the program abnormally.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void
|
2016-03-02 21:13:26 -05:00
|
|
|
endit(int sig)
|
2015-04-21 08:55:20 -04:00
|
|
|
{
|
|
|
|
|
NOOP(sig);
|
|
|
|
|
fatal("Ok, if you want to exit that badly, I'll have to allow it\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* fatal:
|
|
|
|
|
* Exit the program, printing a message.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-03-02 21:13:26 -05:00
|
|
|
void
|
|
|
|
|
fatal(char *s)
|
2015-04-21 08:55:20 -04:00
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
move(lines-2, 0);
|
|
|
|
|
printw("%s", s);
|
|
|
|
|
draw(stdscr);
|
|
|
|
|
printf("\n"); /* So the curser doesn't stop at the end of the line */
|
|
|
|
|
exit_game(EXIT_ENDWIN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* rnd:
|
|
|
|
|
* Pick a very random number.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-03-02 21:13:26 -05:00
|
|
|
int
|
|
|
|
|
rnd(int range)
|
2015-04-21 08:55:20 -04:00
|
|
|
{
|
|
|
|
|
return( md_rand(range) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* roll:
|
|
|
|
|
* roll a number of dice
|
|
|
|
|
*/
|
|
|
|
|
|
2016-03-02 21:13:26 -05:00
|
|
|
int
|
|
|
|
|
roll(int number, int sides)
|
2015-04-21 08:55:20 -04:00
|
|
|
{
|
|
|
|
|
register int dtotal = 0;
|
|
|
|
|
|
|
|
|
|
while(number--)
|
|
|
|
|
dtotal += rnd(sides)+1;
|
|
|
|
|
return dtotal;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-02 21:13:26 -05:00
|
|
|
void
|
|
|
|
|
setup(void)
|
2015-04-21 08:55:20 -04:00
|
|
|
{
|
|
|
|
|
md_setup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* playit:
|
|
|
|
|
* The main loop of the program. Loop until the game is over,
|
|
|
|
|
* refreshing things and looking at the proper times.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-03-02 21:13:26 -05:00
|
|
|
void
|
|
|
|
|
playit(void)
|
2015-04-21 08:55:20 -04:00
|
|
|
{
|
|
|
|
|
register char *opts;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* parse environment declaration of options
|
|
|
|
|
*/
|
|
|
|
|
if ((opts = getenv("ROGUEOPTS")) != NULL)
|
|
|
|
|
parse_opts(opts);
|
|
|
|
|
|
|
|
|
|
player.t_oldpos = hero;
|
|
|
|
|
oldrp = roomin(&hero);
|
|
|
|
|
after = TRUE;
|
|
|
|
|
command(); /* Command execution */
|
|
|
|
|
endit(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* see if the system is being used too much for this game
|
|
|
|
|
*/
|
|
|
|
|
|
2016-03-02 21:13:26 -05:00
|
|
|
bool
|
|
|
|
|
too_much(void)
|
2015-04-21 08:55:20 -04:00
|
|
|
{
|
|
|
|
|
/* we no longer do load checking or user counts */
|
|
|
|
|
return(FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* author:
|
|
|
|
|
* See if a user is an author of the program
|
|
|
|
|
*/
|
|
|
|
|
|
2016-03-02 21:13:26 -05:00
|
|
|
bool
|
|
|
|
|
author(void)
|
2015-04-21 08:55:20 -04:00
|
|
|
{
|
|
|
|
|
switch (md_getuid()) {
|
|
|
|
|
case 0: /* always OK for root to play */
|
|
|
|
|
return TRUE;
|
|
|
|
|
default:
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* playtime:
|
|
|
|
|
* Returns TRUE when it is a good time to play rogue
|
|
|
|
|
*/
|
|
|
|
|
|
2016-03-02 21:13:26 -05:00
|
|
|
bool
|
|
|
|
|
playtime(void)
|
2015-04-21 08:55:20 -04:00
|
|
|
{
|
|
|
|
|
/* we no longer do playtime checking */
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* betaover:
|
|
|
|
|
* Returns TRUE if the test period of this version of the game is over
|
|
|
|
|
*/
|
|
|
|
|
|
2016-03-02 21:13:26 -05:00
|
|
|
bool
|
|
|
|
|
betaover(void)
|
2015-04-21 08:55:20 -04:00
|
|
|
{
|
|
|
|
|
return(FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-03-02 21:13:26 -05:00
|
|
|
void
|
|
|
|
|
exit_game(int flag)
|
2015-04-21 08:55:20 -04:00
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (flag & EXIT_CLS) /* Clear Screen */
|
|
|
|
|
{
|
|
|
|
|
wclear(cw);
|
|
|
|
|
draw(cw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flag & EXIT_ENDWIN) /* Shutdown Curses */
|
|
|
|
|
{
|
|
|
|
|
keypad(cw,FALSE);
|
|
|
|
|
keypad(hw,FALSE);
|
|
|
|
|
delwin(cw);
|
|
|
|
|
delwin(mw);
|
|
|
|
|
delwin(hw);
|
|
|
|
|
delwin(msgw);
|
|
|
|
|
if (!isendwin())
|
|
|
|
|
endwin();
|
|
|
|
|
}
|
|
|
|
|
o_free_list(player.t_pack);
|
|
|
|
|
t_free_list(mlist);
|
|
|
|
|
t_free_list(rlist);
|
|
|
|
|
t_free_list(tlist);
|
|
|
|
|
o_free_list(lvl_obj); /* Free up previous objects (if any) */
|
|
|
|
|
for (i = 0; i < MAXROOMS; i++)
|
|
|
|
|
{
|
|
|
|
|
r_free_list(rooms[i].r_exit); /* Free up the exit lists */
|
|
|
|
|
_r_free_fire_list(&rooms[i].r_fires);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i=0; i<MAXSCROLLS; i++)
|
|
|
|
|
{
|
|
|
|
|
if (s_names[i] != NULL)
|
|
|
|
|
free( s_names[i] );
|
|
|
|
|
if (s_guess[i] != NULL)
|
|
|
|
|
free( s_guess[i] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i=0; i<MAXPOTIONS; i++)
|
|
|
|
|
{
|
|
|
|
|
if (p_guess[i] != NULL)
|
|
|
|
|
free( p_guess[i] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i=0; i<MAXRINGS; i++)
|
|
|
|
|
{
|
|
|
|
|
if (r_guess[i] != NULL)
|
|
|
|
|
free( r_guess[i] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i=0; i<MAXSTICKS; i++)
|
|
|
|
|
{
|
|
|
|
|
if (ws_guess[i] != NULL)
|
|
|
|
|
free( ws_guess[i] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-16 13:39:26 -04:00
|
|
|
void
|
|
|
|
|
open_records(void)
|
|
|
|
|
{
|
|
|
|
|
if (scorefi == NULL)
|
|
|
|
|
scorefi = fopen(score_file, "rb+");
|
|
|
|
|
if (scorefi == NULL)
|
|
|
|
|
scorefi = fopen(score_file, "wb+");
|
|
|
|
|
/* If opening fails, that will be handled when trying to write. */
|
|
|
|
|
#ifdef LOGFILE
|
|
|
|
|
if (logfile == NULL)
|
|
|
|
|
logfile = fopen(LOGFILE, "a");
|
|
|
|
|
#endif
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|