Angband
Functions | Variables
main.c File Reference

Core game initialisation for UNIX (and other) machines. More...

#include "angband.h"
#include "init.h"
#include "mon-power.h"
#include "savefile.h"
#include "ui-command.h"
#include "ui-display.h"
#include "ui-game.h"
#include "ui-init.h"
#include "ui-input.h"
#include "ui-prefs.h"
#include "ui-signals.h"
#include "locale.h"
#include "langinfo.h"
#include "main.h"

Functions

static int init_sound_dummy (int argc, char *argv[])
static void quit_hook (const char *s)
 A hook for "quit()".
static void init_stuff (void)
 SDL needs a look-in.
static void change_path (const char *info)
 Handle a "-d<dir>=<path>" option.
static void user_name (char *buf, size_t len, int id)
 Find a default user name from the system.
static void list_saves (void)
 List all savefiles this player can access.
static void debug_opt (const char *arg)
int main (int argc, char *argv[])
 Simple "main" function for multiple platforms.

Variables

static struct module modules []
 locale junk
static struct module sound_modules []
 List of sound modules in the order they should be tried.
struct {
   const char *   name
   char **   path
   bool   setgid_ok
change_path_values []
static bool new_game

Detailed Description

Core game initialisation for UNIX (and other) machines.

Copyright (c) 1997 Ben Harrison, and others

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Function Documentation

static void change_path ( const char *  info)
static

Handle a "-d<dir>=<path>" option.

Sets any of angband's special directories to <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").

References change_path_values, dir_create(), i, my_stricmp(), N_ELEMENTS, path, path_build(), quit_fmt(), setgid_ok, string_free(), and string_make().

Referenced by main().

static void debug_opt ( const char *  arg)
static

References mem_flags, MEM_POISON_ALLOC, MEM_POISON_FREE, and streq.

Referenced by main().

static int init_sound_dummy ( int  argc,
char *  argv[] 
)
static
static void init_stuff ( void  )
static

SDL needs a look-in.

Initialize and verify the file paths, and the score file.

Use the ANGBAND_PATH environment var if possible, else use DEFAULT_PATH, and in either case, branch off appropriately.

First, we'll look for the ANGBAND_PATH environment variable, and then look for the files in there. If that doesn't work, we'll try the DEFAULT_PATH constants. So be sure that one of these two things works...

We must ensure that the path ends with "PATH_SEP" if needed, since the "init_file_paths()" function will simply append the relevant "sub-directory names" to the given path.

Make sure that the path doesn't overflow the buffer. We have to leave enough space for the path separator, directory, and filenames.

References DEFAULT_CONFIG_PATH, DEFAULT_DATA_PATH, DEFAULT_LIB_PATH, init_file_paths(), my_strcat(), my_strcpy(), PATH_SEP, and suffix().

Referenced by main().

static void list_saves ( void  )
static

List all savefiles this player can access.

References ANGBAND_DIR_SAVE, desc, my_dclose(), my_dopen(), my_dread(), path, path_build(), player_uid, quit_fmt(), savefile_get_description(), and strnfmt().

Referenced by main().

int main ( int  argc,
char *  argv[] 
)
static void quit_hook ( const char *  s)
static

A hook for "quit()".

Close down, then fall back into "quit()".

References angband_term, ANGBAND_TERM_MAX, term_nuke(), and void().

Referenced by main().

static void user_name ( char *  buf,
size_t  len,
int  id 
)
static

Find a default user name from the system.

References my_strcap(), and my_strcpy().

Referenced by main().

Variable Documentation

struct { ... } change_path_values[]

Referenced by change_path(), and main().

struct module modules[]
static
Initial value:
{
}

locale junk

Some machines have a "main()" function in their "main-xxx.c" file, all the others use this file for their "main()" function. List of the available modules in the order they are tried.

const char* name
bool new_game
static

Referenced by main().

char** path
bool setgid_ok

Referenced by change_path(), and main().

struct module sound_modules[]
static
Initial value:
{
{ "none", "No sound", init_sound_dummy },
}

List of sound modules in the order they should be tried.