Source:NetHack 3.6.0/src/sys.c

From NetHackWiki
Jump to: navigation, search

Below is the full text to sys.c from the source code of NetHack 3.6.0. To link to a particular line, write [[Source:NetHack 3.6.0/src/sys.c#line123]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

Top of file

  1.  /* NetHack 3.6	sys.c	$NHDT-Date: 1448241785 2015/11/23 01:23:05 $  $NHDT-Branch: master $:$NHDT-Revision: 1.35 $ */
  2.  /* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008. */
  3.  /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5.  #include "hack.h"
  6.  
  7.  #ifndef SYSCF
  8.  /* !SYSCF configurations need '#define DEBUGFILES "foo.c bar.c"'
  9.   * to enable debugging feedback for source files foo.c and bar.c;
  10.   * to activate debugpline(), set an appropriate value and uncomment
  11.   */
  12.  /* # define DEBUGFILES "*" */
  13.  
  14.  /* note: DEBUGFILES value here or in sysconf.DEBUGFILES can be overridden
  15.     at runtime by setting up a value for "DEBUGFILES" in the environment */
  16.  #endif
  17.  

sys_early_init

  1.  struct sysopt sysopt;
  2.  
  3.  void
  4.  sys_early_init()
  5.  {
  6.      sysopt.support = (char *) 0;
  7.      sysopt.recover = (char *) 0;
  8.  #ifdef SYSCF
  9.      sysopt.wizards = (char *) 0;
  10.  #else
  11.      sysopt.wizards = dupstr(WIZARD_NAME);
  12.  #endif
  13.  #if defined(SYSCF) || !defined(DEBUGFILES)
  14.      sysopt.debugfiles = (char *) 0;
  15.  #else
  16.      sysopt.debugfiles = dupstr(DEBUGFILES);
  17.  #endif
  18.      sysopt.env_dbgfl = 0; /* haven't checked getenv("DEBUGFILES") yet */
  19.      sysopt.shellers = (char *) 0;
  20.      sysopt.explorers = (char *) 0;
  21.      sysopt.maxplayers = 0; /* XXX eventually replace MAX_NR_OF_PLAYERS */
  22.  
  23.      /* record file */
  24.      sysopt.persmax = PERSMAX;
  25.      sysopt.entrymax = ENTRYMAX;
  26.      sysopt.pointsmin = POINTSMIN;
  27.      sysopt.pers_is_uid = PERS_IS_UID;
  28.      sysopt.tt_oname_maxrank = 10;
  29.  
  30.      /* sanity checks */
  31.      if (PERSMAX < 1)
  32.          sysopt.persmax = 1;
  33.      if (ENTRYMAX < 10)
  34.          sysopt.entrymax = 10;
  35.      if (POINTSMIN < 1)
  36.          sysopt.pointsmin = 1;
  37.      if (PERS_IS_UID != 0 && PERS_IS_UID != 1)
  38.          panic("config error: PERS_IS_UID must be either 0 or 1");
  39.  
  40.  #ifdef PANICTRACE
  41.      /* panic options */
  42.      sysopt.gdbpath = dupstr(GDBPATH);
  43.      sysopt.greppath = dupstr(GREPPATH);
  44.  #ifdef BETA
  45.      sysopt.panictrace_gdb = 1;
  46.  #ifdef PANICTRACE_LIBC
  47.      sysopt.panictrace_libc = 2;
  48.  #endif
  49.  #else
  50.      sysopt.panictrace_gdb = 0;
  51.  #ifdef PANICTRACE_LIBC
  52.      sysopt.panictrace_libc = 0;
  53.  #endif
  54.  #endif
  55.  #endif
  56.  
  57.      sysopt.check_save_uid = 1;
  58.      sysopt.seduce = 1; /* if it's compiled in, default to on */
  59.      sysopt_seduce_set(sysopt.seduce);
  60.      return;
  61.  }
  62.  

sysopt_release

  1.  void
  2.  sysopt_release()
  3.  {
  4.      if (sysopt.support)
  5.          free((genericptr_t) sysopt.support), sysopt.support = (char *) 0;
  6.      if (sysopt.recover)
  7.          free((genericptr_t) sysopt.recover), sysopt.recover = (char *) 0;
  8.      if (sysopt.wizards)
  9.          free((genericptr_t) sysopt.wizards), sysopt.wizards = (char *) 0;
  10.      if (sysopt.explorers)
  11.          free((genericptr_t) sysopt.explorers), sysopt.explorers = (char *) 0;
  12.      if (sysopt.shellers)
  13.          free((genericptr_t) sysopt.shellers), sysopt.shellers = (char *) 0;
  14.      if (sysopt.debugfiles)
  15.          free((genericptr_t) sysopt.debugfiles),
  16.          sysopt.debugfiles = (char *) 0;
  17.  #ifdef PANICTRACE
  18.      if (sysopt.gdbpath)
  19.          free((genericptr_t) sysopt.gdbpath), sysopt.gdbpath = (char *) 0;
  20.      if (sysopt.greppath)
  21.          free((genericptr_t) sysopt.greppath), sysopt.greppath = (char *) 0;
  22.  #endif
  23.      /* this one's last because it might be used in panic feedback, although
  24.         none of the preceding ones are likely to trigger a controlled panic */
  25.      if (sysopt.fmtd_wizard_list)
  26.          free((genericptr_t) sysopt.fmtd_wizard_list),
  27.          sysopt.fmtd_wizard_list = (char *) 0;
  28.      return;
  29.  }
  30.  

sysopt_seduce_set

  1.  extern struct attack sa_yes[NATTK];
  2.  extern struct attack sa_no[NATTK];
  3.  
  4.  void
  5.  sysopt_seduce_set(val)
  6.  int val;
  7.  {
  8.      struct attack *setval = val ? sa_yes : sa_no;
  9.      int x;
  10.  
  11.      for (x = 0; x < NATTK; x++) {
  12.          mons[PM_INCUBUS].mattk[x] = setval[x];
  13.          mons[PM_SUCCUBUS].mattk[x] = setval[x];
  14.      }
  15.      return;
  16.  }
  17.  
  18.  /*sys.c*/