-/* File: main.c */
+/* File: main.c */
/*
* Copyright (c) 1997 Ben Harrison, and others
*/
-#if !defined(MACINTOSH) && !defined(WINDOWS) && !defined(ACORN)
+#if !defined(MACINTOSH) && !defined(WINDOWS) && !defined(ACORN) && !defined(MACH_O_CARBON) && !defined(MACH_O_COCOA)
/*
*
* Close down, then fall back into "quit()".
*/
-static void quit_hook(cptr s)
+static void quit_hook(concptr s)
{
int j;
+ /* Unused */
+ (void)s;
+
/* Scan windows */
for (j = 8 - 1; j >= 0; j--)
{
}
-
-/*
- * Set the stack size (for the Amiga)
- */
-#ifdef AMIGA
-# include <dos.h>
-__near long __stack = 32768L;
-#endif
-
-
-/*
- * Set the stack size and overlay buffer (see main-286.c")
- */
-#ifdef USE_286
-# include <dos.h>
-extern unsigned _stklen = 32768U;
-extern unsigned _ovrbuffer = 0x1500;
-#endif
-
-#ifdef PRIVATE_USER_PATH
-
-/*
- * Create an ".angband/" directory in the users home directory.
- *
- * ToDo: Add error handling.
- * ToDo: Only create the directories when actually writing files.
- */
-static void create_user_dir(void)
-{
- char dirpath[1024];
- char subdirpath[1024];
-
- /* Drop privs */
- safe_setuid_drop();
-
- /* Get an absolute path from the filename */
- path_parse(dirpath, 1024, PRIVATE_USER_PATH);
-
- /* Create the ~/.angband/ directory */
- mkdir(dirpath, 0700);
-
- /* Build the path to the variant-specific sub-directory */
- path_build(subdirpath, 1024, dirpath, VERSION_NAME);
-
- /* Create the directory */
- mkdir(subdirpath, 0700);
-
- /* Grab privs */
- safe_setuid_grab();
-}
-
-#endif /* PRIVATE_USER_PATH */
-
-
/*
* Initialize and verify the file paths, and the score file.
*
* since the "init_file_paths()" function will simply append the
* relevant "sub-directory names" to the given path.
*
- * Note that the "path" must be "Angband:" for the Amiga, and it
- * is ignored for "VM/ESA", so I just combined the two.
- *
* Make sure that the path doesn't overflow the buffer. We have
* to leave enough space for the path separator, directory, and
* filenames.
{
char path[1024];
-#if defined(AMIGA) || defined(VM)
-
- /* Hack -- prepare "path" */
- strcpy(path, "Angband:");
-
-#else /* AMIGA / VM */
-
- cptr tail;
+ concptr tail;
/* Get the environment variable */
tail = getenv("ANGBAND_PATH");
/* Hack -- Add a path separator (only if needed) */
if (!suffix(path, PATH_SEP)) strcat(path, PATH_SEP);
-#endif /* AMIGA / VM */
-
/* Initialize */
- init_file_paths(path);
+ init_file_paths(path, path, path);
}
* The "<path>" can be any legal path for the given system, and should
* not end in any special path separator (i.e. "/tmp" or "~/.ang-info").
*/
-static void change_path(cptr info)
+static void change_path(concptr info)
{
- cptr s;
+ concptr s;
/* Find equal sign */
- s = strchr(info, '=');
+ s = my_strchr(info, '=');
/* Verify equal sign */
if (!s) quit_fmt("Try '-d<what>=<path>' not '-d%s'", info);
int i;
bool done = FALSE;
-
bool new_game = FALSE;
-
int show_score = 0;
-
- cptr mstr = NULL;
-
+ concptr mstr = NULL;
bool args = TRUE;
-
/* Save the "program name" XXX XXX XXX */
argv0 = argv[0];
-#ifdef USE_286
- /* Attempt to use XMS (or EMS) memory for swap space */
- if (_OvrInitExt(0L, 0L))
- {
- _OvrInitEms(0, 0, 64);
- }
-#endif
-
-
#ifdef SET_UID
/* Default permissions on files */
#endif
+ /* Drop permissions */
+ safe_setuid_drop();
+
+
#ifdef SET_UID
/* Initialize the "time" checker */
/* Acquire the "user name" as a default player name */
#ifdef ANGBAND_2_8_1
- user_name(player_name, player_uid);
+ user_name(p_ptr->name, player_uid);
#else /* ANGBAND_2_8_1 */
user_name(op_ptr->full_name, player_uid);
#endif /* ANGBAND_2_8_1 */
#ifdef PRIVATE_USER_PATH
- /* Create a directory for the users files. */
- create_user_dir();
+ /* Create directories for the user's files; handled by init2.c. */
+ create_needed_dirs();
#endif /* PRIVATE_USER_PATH */
break;
}
+ case 'B':
+ case 'b':
+ {
+ arg_music = TRUE;
+ break;
+ }
+
case 'V':
case 'v':
{
{
if (!argv[i][2]) goto usage;
#ifdef ANGBAND_2_8_1
- strcpy(player_name, &argv[i][2]);
+ strcpy(p_ptr->name, &argv[i][2]);
#else /* ANGBAND_2_8_1 */
/* Get the savefile name */
}
#endif
+ case 'x':
+ {
+ if (!argv[i][2]) goto usage;
+ prepare_browse_movie(&argv[i][2]);
+ break;
+ }
+
case '-':
{
argv[i] = argv[0];
puts(" -n Start a new character");
puts(" -f Request fiddle mode");
puts(" -w Request wizard mode");
+ puts(" -b Request BGM mode");
puts(" -v Request sound mode");
puts(" -g Request graphics mode");
puts(" -o Request original keyset");
puts(" -mibm To use IBM (BIOS text mode)");
#endif /* USE_IBM */
-#ifdef USE_SLA
- puts(" -msla To use SLA (SLANG)");
-#endif /* USE_SLA */
-
-#ifdef USE_LSL
- puts(" -mlsl To use LSL (Linux-SVGALIB)");
-#endif /* USE_LSL */
-
-#ifdef USE_AMI
- puts(" -mami To use AMI (Amiga)");
-#endif /* USE_AMI */
-
-#ifdef USE_VME
- puts(" -mvme To use VME (VAX/ESA)");
-#endif /* USE_VME */
-
/* Actually abort the process */
quit(NULL);
}
quit_aux = quit_hook;
- /* Drop privs (so X11 will work correctly) */
- safe_setuid_drop();
-
#ifdef USE_XAW
/* Attempt to use the "main-xaw.c" support */
#endif
-#ifdef USE_EMX
- /* Attempt to use the "main-emx.c" support */
- if (!done && (!mstr || (streq(mstr, "emx"))))
- {
- extern errr init_emx(void);
- if (0 == init_emx())
- {
- ANGBAND_SYS = "emx";
- done = TRUE;
- }
- }
-#endif
-
-
-#ifdef USE_SLA
- /* Attempt to use the "main-sla.c" support */
- if (!done && (!mstr || (streq(mstr, "sla"))))
- {
- extern errr init_sla(void);
- if (0 == init_sla())
- {
- ANGBAND_SYS = "sla";
- done = TRUE;
- }
- }
-#endif
-
-
-#ifdef USE_LSL
- /* Attempt to use the "main-lsl.c" support */
- if (!done && (!mstr || (streq(mstr, "lsl"))))
- {
- extern errr init_lsl(void);
- if (0 == init_lsl())
- {
- ANGBAND_SYS = "lsl";
- done = TRUE;
- }
- }
-#endif
-
-
-#ifdef USE_AMI
- /* Attempt to use the "main-ami.c" support */
- if (!done && (!mstr || (streq(mstr, "ami"))))
- {
- extern errr init_ami(void);
- if (0 == init_ami())
- {
- ANGBAND_SYS = "ami";
- done = TRUE;
- }
- }
-#endif
-
-
-#ifdef USE_VME
- /* Attempt to use the "main-vme.c" support */
- if (!done && (!mstr || (streq(mstr, "vme"))))
- {
- extern errr init_vme(void);
- if (0 == init_vme())
- {
- ANGBAND_SYS = "vme";
- done = TRUE;
- }
- }
-#endif
-
-
- /* Grab privs (dropped above for X11) */
- safe_setuid_grab();
-
-
/* Make sure we have a display! */
if (!done) quit("Unable to prepare any 'display module'!");