Source:NetHack 3.6.1/src/sys.c

From NetHackWiki
(Redirected from Sys.c)
Jump to: navigation, search

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

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. */

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.

  1.  
  2.  #include "hack.h"
  3.  
  4.  #ifndef SYSCF
  5.  /* !SYSCF configurations need '#define DEBUGFILES "foo.c bar.c"'
  6.   * to enable debugging feedback for source files foo.c and bar.c;
  7.   * to activate debugpline(), set an appropriate value and uncomment
  8.   */
  9.  /* # define DEBUGFILES "*" */
  10.  
  11.  /* note: DEBUGFILES value here or in sysconf.DEBUGFILES can be overridden
  12.     at runtime by setting up a value for "DEBUGFILES" in the environment */
  13.  #endif
  14.  
  15.  struct sysopt sysopt;
  16.  

sys_early_init

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

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 DUMPLOG
  18.      if (sysopt.dumplogfile)
  19.          free((genericptr_t)sysopt.dumplogfile), sysopt.dumplogfile=(char *)0;
  20.  #endif
  21.      if (sysopt.genericusers)
  22.          free((genericptr_t) sysopt.genericusers),
  23.          sysopt.genericusers = (char *) 0;
  24.  #ifdef PANICTRACE
  25.      if (sysopt.gdbpath)
  26.          free((genericptr_t) sysopt.gdbpath), sysopt.gdbpath = (char *) 0;
  27.      if (sysopt.greppath)
  28.          free((genericptr_t) sysopt.greppath), sysopt.greppath = (char *) 0;
  29.  #endif
  30.      /* this one's last because it might be used in panic feedback, although
  31.         none of the preceding ones are likely to trigger a controlled panic */
  32.      if (sysopt.fmtd_wizard_list)
  33.          free((genericptr_t) sysopt.fmtd_wizard_list),
  34.          sysopt.fmtd_wizard_list = (char *) 0;
  35.      return;
  36.  }
  37.  
  38.  extern struct attack sa_yes[NATTK];
  39.  extern struct attack sa_no[NATTK];
  40.  

sysopt_seduce_set

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