/ circle3.1 / FAQ
FAQ
   1  WARNING: THIS FAQ IS OUT OF DATE
   2           Please reference the FAQ in the doc/ directory of the distribution
   3           instead.  It is significantly more current.
   4  
   5  
   6  Frequently Asked Questions (FAQ) for Circle DikuMud with Answers
   7  Alex Fletcher, furry@circlemud.org
   8  
   9  This file is intended to cover common questions related to the CircleMUD
  10  distributon source by Jeremy Elson (http://www.circlemud.org/~jelson/) and
  11  not general DikuMUD questions.  Any contributions and corrections are more
  12  than welcome.  It is currently maintained by Alex Fletcher (aka Furry)
  13  <furry@circlemud.org>.  Please direct corrections to this address.  The
  14  original author was Ryan Watkins (aka VampLestat). More information about
  15  CircleMUD, including up-to-date versions of this documentation in ASCII and
  16  Postscript, can be found at the CircleMUD Home Page
  17  (http://www.circlemud.org/) or FTP site
  18  (ftp://ftp.circlemud.org/pub/CircleMUD/).
  19  
  20  ______________________________________________________________________
  21  
  22  Table of Contents
  23  
  24  1. Introduction
  25  
  26     1.1 I've never played a MUD before.  What should I do?
  27  
  28     1.2 I'm new to C and/or coding. What do I do?
  29  
  30     1.3 I want to build my own MUD.  Where do I start?
  31  
  32     1.4 What is CircleMUD?
  33  
  34     1.5 What is the history of CircleMUD?
  35  
  36     1.6 Where is the original CircleMUD so I can check it out?
  37  
  38     1.7 Will the CircleMUD creators visit my mud?
  39  
  40     1.8 What is UNIX?
  41  
  42  
  43  2. Resources
  44  
  45     2.1 Where do I find the source code for CircleMUD?
  46  
  47     2.2 Where do I find areas, etc. for CircleMUD?
  48  
  49     2.3 I have questions about CircleMUD.  Where should I go?
  50  
  51     2.4 How do I subscribe/unsubscribe to the Mailing List?
  52  
  53     2.5 To what platforms has CircleMUD been ported?
  54  
  55     2.6 How can I submit code or areas for use with CircleMUD?
  56  
  57     2.7 How do I use a patch file and how can I make one?
  58  
  59  
  60  3. Compiling CircleMUD
  61  
  62     3.1 Why do I get many syntax errors with Sun's ``cc'' compiler?
  63  
  64     3.2 Why do I get all sorts of errors with ``crypt'' functions and header files?
  65  
  66     3.3 When I try to compile, why do I get a lot of undefined symbols
  67         referenced in comm.o for functions like socket, accept, and bind?
  68  
  69     3.4 Every time I try to compile Circle (or any other piece of software)
  70         under Linux, it gives me errors and says it cannot find include header
  71         files in the linux/  and asm/  directories.  What can I do?
  72  
  73     3.5 I'm getting compilation errors from a header file, and I didn't even
  74         change it?
  75  
  76     3.6 I'm trying to compile the MUD on Windows '95 and am having problems,
  77         what can I do?
  78  
  79     3.7 How can I do a ``grep'' on Windows 95?
  80  
  81     3.8 While compiling the MUD, why do I get errors like ``foo.c:1231:
  82         Undefined symbol `_whereamI' referenced from text segment''
  83  
  84     3.9 What is a parse error and how do I fix it?
  85  
  86     3.10 I have this piece of code that calls bcopy(), bzero(), and bcmp()
  87          and it won't compile, so what can I do?
  88  
  89     3.11 My compiler doesn't have ``strdup()'', what can I do?
  90  
  91     3.12 I am having trouble with my ``makefile'', what could be the problem?
  92  
  93     3.13 How can I handle directories in C?
  94  
  95  
  96  4. Running CircleMUD
  97  
  98     4.1 I typed ``autorun'' but then my terminal just froze.
  99  
 100     4.2 I typed ``bin/circle'' and got lots of boot messages, but then it
 101         said ``Entering game loop'' and froze.
 102  
 103     4.3 Okay, I think the MUD is running but why don't I get a login prompt?
 104  
 105     4.4 How come I get this error when running my MUD: ``Error reading board:
 106         No such file or directory''
 107  
 108     4.5 I just got this SIGPIPE, what is it and what Can I Do About It?
 109  
 110     4.6 When I run Circle under Linux, it tells me ``gethostbyaddr:
 111         connection refused'' when the MUD boots, and then dies.  Why?
 112  
 113     4.7 When I run Circle under Windows 95, it tells me ``Winsock error
 114         #10047'' when the MUD boots, and then dies.  Why?
 115  
 116     4.8 When I run Circle under Windows 95, players can't rent---their
 117         equipment is just dropped on the ground, syslogs don't work, so what
 118         is the problem?
 119  
 120     4.9 When someone logs on to my Windows 95 MUD, the console screen gives:
 121         ``gethostbyaddr: No such file or directory''
 122  
 123     4.10 My MUD crashed and my connection got closed.  What can I do?
 124  
 125     4.11 Ok, so how do I use ``gdb''?
 126  
 127     4.12 How can I hunt bugs more effectively?
 128  
 129     4.13 I just added n levels to my MUD (from the stock 34).  How do I set
 130          my imps up to level n without a pfile wipe?
 131  
 132     4.14 I decided to wipe my pfile away anyway.  What steps should I take to
 133          do this?
 134  
 135     4.15 I want to expand the ability to pk in my MUD, allowing ASSASSINS
 136          that'll be able to PK without getting flagged.  How can I do this?
 137  
 138     4.16 Why does it say ``Connection closed by foreign host.'' and not
 139          display the ``Byebye!'' message I'm trying to send before cutting
 140          someone off?
 141  
 142     4.17 I run my MUD on a unix system and the pfile/rent file works great,
 143          but on my home system it's all screwed up.  What gives?
 144  
 145     4.18 How do I get the CircleMUD to autoload when the Linux server is
 146          restarted?
 147  
 148     4.19 My server shuts down my MUD everytime I logoff. How do I keep the
 149          MUD running when I logoff?
 150  
 151  
 152  5. Code Changes for CircleMUD 2.20
 153  
 154     5.1 How do I fix the bug where people can junk more coins than available?
 155  
 156     5.2 How do I fix the ``vstat'' bug that crashes the MUD?
 157  
 158     5.3 How do I fix the ``wizlock'' bug that lets lower immortals lock out
 159         higher immortals?
 160  
 161     5.4 How do I fix the ``mudlog'' bug that lets people see me log in, even
 162         if I'm wizinvis?
 163  
 164  
 165  6. CircleMUD 3.0 Questions
 166  
 167     6.1 Are there any bugs in patch level 19?
 168  
 169     6.2 How do I access Online Creation?
 170  
 171     6.3 How does the new bitvector system work?
 172  
 173     6.4 When will the production release of Circle 3.0 be?
 174  
 175     6.5 If someone logs in and just sits at the password prompt, the MUD
 176         hangs (i.e., no one else can connect or do anything) until the person
 177         enters their password.
 178  
 179     6.6 Why does CircleMUD use BUF switches all through the code, what's
 180         happening here?
 181  
 182     6.7 How do I add a new class?  How do I add more levels?
 183  
 184     6.8 Is there a complete ``coding.doc''?
 185  
 186  ______________________________________________________________________
 187  
 188  1.  Introduction
 189  
 190  
 191  1.1.  I've never played a MUD before.  What should I do?
 192  
 193  Don't try to use your own copy of CircleMUD!  There are two levels of MUD
 194  users: players and administrators.  Administrators do what you're trying to
 195  do now -- get a copy of a MUD's source code, compile it, and run it. 
 196  Players use MUDs that are being administered by someone else. If you try to
 197  actually run a MUD before you've ever played one, you'll get very confused
 198  indeed! Your best bet for now is to play someone else's MUD first.  There
 199  are a large number of excellent MUDs out there already, some of which are
 200  based on CircleMUD code.  A good place to start looking is the MUD Connector
 201  at:
 202  
 203  http://www.mudconnect.com/
 204  
 205  The CircleMUD web server also has a smaller CircleMUD Site List at:
 206  
 207  http://www.circlemud.org/sites.html
 208  
 209  
 210  1.2.  I'm new to C and/or coding.  What do I do?
 211  
 212  First, a MUD is not a learning project. It has thousands of lines to it,
 213  many of which are obscure and unclear to even moderately skilled
 214  programmers.  Those little, ``Hello, world,'' programs are for learning,
 215  maybe little math tests, etc.  A MUD is a pretty ambitous project to start
 216  with.  That's like trying to run before you can walk, and while there's more
 217  difficult things than a MUD to start with, there's a ton of easier things
 218  you should start with.  Second, if you are persistent, get a good C
 219  reference book and read the code, try to comprehend what everything is doing
 220  (to some small extent).  You should probably avoid comm.c as it is home to
 221  the socket functions which general C books don't cover and are usually
 222  explained in other books on network programming.  Then try small projects,
 223  something similar to what already exists.  This way, you can get away with a
 224  cut-and-paste job and changing some of the code.  Adding a simple version of
 225  races isn't all that difficult, just examine the class code in class.c and
 226  the CON_QCLASS block in interpreter.c, cut, paste, and modify.  Also look at
 227  structs.h, for "#define CLASS_" You'll begin understanding more and more of
 228  the code as you copy and change it, eventually you'll be able to write a
 229  whole function by yourself.  Spend time learning, going with haste will hurt
 230  you more than it will help you.
 231  
 232  
 233  1.3.  I want to build my own MUD.  Where do I start?
 234  
 235  Many common questions arise from new MUD admins.  It is a good idea to pay
 236  attention to them and take their answers to heart.  These include things
 237  like the following:
 238  
 239  I don't have any coding experience with MUDs, but do have a lot of ideas for
 240  my own.  I have played many MUDs for a LONG time, though.
 241  
 242  Read the FAQ.  MUD Experience doesn't help a huge amount.  Code experience
 243  does.
 244  
 245  I am interested in having a level system of 1-50 mortal and 51-60 imms.  I
 246  am also interested in adding races and classes. How can I accomplish these
 247  things?
 248  
 249  By checking the FTP Site under contrib.
 250  (ftp://ftp.circlemud.org/pub/CircleMUD/contrib).  Learn a lot from there.
 251  Learn from the Snippets page (http://developer.circlemud.org/snippets/), and
 252  *know* the FAQ.
 253  
 254  Also, is there anything that I should know about CircleMUD being a "newbie"
 255  to it?
 256  
 257  See the above comment.
 258  
 259  
 260  1.4.  What is CircleMUD?
 261  
 262  CircleMUD is a DikuMUD derivitave, developed by Jeremy Elson
 263  <jelson@circlemud.org> and is from the Gamma v0.0 of DikuMUD created by Hans
 264  Henrik Staerfeldt, Katja Nyboe, Tom Madsen, Michael Seifert and Sebastian
 265  Hammer at DIKU (Computer Science Instutute at Copenhagen University).  Note
 266  that CircleMUD is a Diku derivative, so its users must follow the DIKU
 267  license agreement---most notably it cannot be used to make money in ANY way,
 268  the original developers' names must be in the login screen and that the
 269  credits command always presents the same information, etc.
 270  
 271  Quoting from CircleMUD's release.doc:
 272  
 273       "CircleMUD is highly developed from the programming side, but highly
 274       UNdeveloped on the game-playing side.  So, if you're looking for a huge
 275       MUD with billions of spells, skills, classes, races, and areas, Circle
 276       will probably disappoint you severely.  Circle still has only the 4
 277       original Diku classes, the original spells, the original skills, and
 278       about a couple dozen areas. On the other hand, if you're looking for a
 279       highly stable, well-developed, well-organized "blank slate" MUD on
 280       which you can put your OWN ideas for spells, skills, classes, and
 281       areas, then Circle might be just what you're looking for."
 282  
 283  
 284  The latest full release of Circle is 2.20, released on November 17, 1993. 
 285  Currently 3.0 is in beta, at patch level 19, released on August 14, 2001.
 286  
 287  
 288  1.5.  What is the history of CircleMUD?
 289  
 290  o  Version 2.00: July 16, 1993
 291  o  Version 2.01: July 20, 1993
 292  o  Version 2.02: Early August
 293  o  Version 2.10: September 1, 1993
 294  o  Version 2.11: September 19, 1993
 295  o  Version 2.20: November 17, 1993
 296  
 297  Version 3.00 is currently in beta right now and is up to patchlevel 19.  The
 298  final release is due out Real Soon Now(tm).  Don't bother posting requests
 299  for it.  It will be out when Jeremy gets it done, and it will be announced
 300  on the mailing list and the newsgroup rec.games.mud.diku.
 301  
 302  
 303  1.6.  Where is the original CircleMUD so I can check it out?
 304  
 305  CircleMUD is a public code base, freely distributable, but the author of
 306  Circle doesn't actually run one personally.  There used to be CircleMUD, and
 307  while Jeremy Elson continues to develop it, there is no original CircleMUD
 308  any more.  To see other MUDs that are using the CircleMUD code base, check
 309  out this Site List: http://www.circlemud.org/sites.html
 310  
 311  
 312  1.7   Will the CircleMUD creators visit my mud?
 313  
 314  While there is a possibility that one (or more) of the CircleMUD creators
 315  will drop by your MUD for a visit, to play, or to simply look around, there
 316  is a slim chance that they will even identify themselves.
 317  
 318  Would you like to see us on your MUD?  You won't.  We don't want free wizzes
 319  or favours for our work here.  In fact, we will state categorically that if
 320  anyone comes on your MUD claiming to be associated with us, they aren't.
 321  
 322  If you want to check whether or not someone on your MUD really is one of us,
 323  we can all be contacted by email for verification:
 324    Jeremy Elson  <jelson@circlemud.org>
 325    Chris Epler   <cepler@circlemud.org>
 326    Alex Fletcher <furry@circlemud.org>
 327    George Greer  <greerga@circlemud.org>
 328    Daniel Koepke <dkoepke@circlemud.org>
 329    Tony Robbins  <tonyr@circlemud.org>
 330  
 331  As an interesting side note, there are two interesting things about the
 332  order of the addresses mentioned above:
 333  * They are in alphabetical order by last name.
 334  * They are in chronological order of when each person joined the
 335    CircleMUD team.
 336  
 337  
 338  1.8.  What is UNIX?
 339  
 340  UNIX is not an operating system of itself, it's a type (flavour, if you
 341  will) of operating systems.  Many different kinds of UNIXes exist.  Some of
 342  them are free, some of them are not.  How to tell if you have a UNIX
 343  operating system? Well, UNIXes have the `ps' command, tend to have a `%' or
 344  `#' prompt, give you a home directory, `who' will show who else is on the
 345  system, etc.  Many UNIX systems (such as Linux) strive to be POSIX
 346  compatible, so you'll probably see POSIX mentioned, too.  POSIX is, roughly,
 347  the standards which UNIX operating systems go by.  It says what makes an
 348  operating system part of the UNIX family and so forth.  Some UNIX operating
 349  systems are not 100% POSIX compatible, actually, most aren't.  The following
 350  are types of UNIX (but not all the existing flavours): Linux, FreeBSD, BSD,
 351  BSDi, Solaris.  There are others.  UNIX operating systems are command-based
 352  and Microsoft does not make a variant.
 353  
 354  
 355  
 356  2.  Resources
 357  
 358  2.1.  Where do I find the source code for CircleMUD?
 359  
 360  Circle's complete source code and areas are available for anonymous FTP at
 361  the CircleMUD FTP site:
 362  
 363  ftp://ftp.circlemud.org/pub/CircleMUD/
 364  
 365  There is also a CircleMUD Home Page:
 366  
 367  http://www.circlemud.org/
 368  
 369  for additional CircleMUD links and information.
 370  
 371  
 372  2.2.  Where do I find areas, etc. for CircleMUD?
 373  
 374  A number of CircleMUD based Implementors have submitted areas to the public
 375  and they are archived at:
 376  
 377  ftp://ftp.circlemud.org/pub/CircleMUD/contrib/areas/  (California, USA)
 378  
 379  Or you can use one of the CircleMUD mirrors:
 380  
 381  ftp://ftp2.circlemud.org/pub/CircleMUD/  (Ohio, USA)
 382  ftp://ftp.stormhaven.org/pub/CircleMUD/  (Virginia, USA)
 383  ftp://ftp.mono.org/pub/mud/CircleMUD/  (London, UK)
 384  
 385  If you cannot use FTP, you can contact one of the site maintainers and
 386  request a file.  The maintainers are:
 387  
 388  Alex Fletcher <furry@circlemud.org>
 389  Chris Epler <cepler@circlemud.org>
 390  George Greer <greerga@circlemud.org>
 391  
 392  If the FTP site is down, please try one of the mirrors and then contact Alex
 393  at his alternate address <fletchra@qsilver.queensu.ca> since he will be
 394  able to find out the situation.  There is also a code snippets site at:
 395  
 396  http://developer.circlemud.org/snippets/
 397  
 398  Where a number of code suggestions and hints are located.
 399  
 400  
 401  2.3.  I have questions about CircleMUD.  Where should I go?
 402  
 403  If you have general questions about the MUD such as how to get it running,
 404  how to add new spells, how to add new skills, etc., the first place you
 405  should look is the documentation. `coding.doc' will have information about
 406  how to add new spells, skills, commands, etc. `building.doc' has information
 407  about how to create new worlds, how to read the database files, etc. There
 408  are many other documents in the doc directory with useful information.
 409  
 410  There is also a new project, started in June of 1996, called the CircleMUD
 411  Documentation Project (http://www.circlemud.org/~jelson/circle/cdp/) which
 412  will eventually be a repository for all Circle-related information.  It's
 413  still being built as of this writing, but hopefully will become a valuable
 414  resource as more documentation is added.
 415  
 416  If you still have questions after reading the doucmentation, you can try
 417  asking on the CircleMUD mailing list (see next section).
 418  
 419  If you have a question you think is too "newbie" for the mailing list, try
 420  the help database <help@circlemud.org>.  Previous questions are accessible
 421  though the bugs database (http://bugs.circlemud.org/). That is also,
 422  incidently, where you should go to report bugs.
 423  
 424  You can also contact the author, Jeremy Elson <jelson@circlemud.org>. 
 425  George Greer <greerga@circlemud.org> can also be contacted for most
 426  problems.
 427  
 428  
 429  2.4.  How do I subscribe/unsubscribe to the Mailing List?
 430  
 431  There is a CircleMUD mailing list for coders, builders, and administrators.
 432  To subscribe, send a message to the list server <listserv@post.queensu.ca>
 433  with a message body of subscribe circle <first name> <last name>.  To
 434  unsubscribe from the list send a message to <listserv@post.queensu.ca> with
 435  the words unsubscribe circle as the message body.  DO NOT send subscription
 436  or unsubscription requests to the list in general.  There are hundreds of
 437  people on the list, and it will only irritate a ton of people who have no
 438  power to remove you from the list.  Read the Mailing List FAQ
 439  (http://qsilver.queensu.ca/~fletchra/Circle/list_faq.html) for more
 440  information.
 441  
 442  
 443  2.5.  To what platforms has CircleMUD been ported?
 444  
 445  Version 3.0, although still officially in beta-testing, is very portable
 446  because it uses the GNU autoconf system, meaning you only need to type
 447  ``configure'' to have it automatically determine various features of your
 448  system and configure the code accordingly.  3.0 compiles without changes
 449  under most BSD and SVR4 systems, including SunOS, Solaris, Ultrix, IRIX,
 450  AIX, Linux, BSD/OS, HP/UX, and others.
 451  
 452  Version 3.0 is also being ported to various non-UNIX platforms.  As of
 453  patchlevel 14, you can compile Circle under OS/2 2.x and 3.x with the OS/2
 454  port of gcc, Windows 95/NT using Microsoft Visual C++ version 4.0 or 5.0,
 455  Borland (now Inprise) C++ 4.5, Watcom v.11, Cygnus GNU-WIN32, LCC, Macintosh
 456  with CodeWarrior, Amiga, and Acorn RiscOS.
 457  
 458  The older version of the code, Version 2.20, compiles mainly on BSD UNIX
 459  systems but has trouble under SVR4-based systems such as Solaris. The author
 460  has personally compiled and tested v2.20 under Ultrix 4.0, IRIX 4.0.1, 4.0.4
 461  and 4.0.5, SunOS 4.1.1 and 4.1.3, AIX 3.2, Linux 0.99.x and 1.0.x, and
 462  ConvexOS V10.2.  Users have reported that v2.20 compiles with relatively
 463  minor changes under NeXTStep 2.1 and 3.0, and HP/UX 9.0.
 464  
 465  Jean-Jack Riethoven <J.J.M.Riethoven@ab.agro.nl> ported CircleMUD version
 466  2.20 to the Amiga and has contributed his code for version 3.0 of CircleMUD. 
 467  Questions about the Amiga source should be directed to Jean-Jack Riethoven,
 468  not Jeremy Elson or George Greer.
 469  
 470  
 471  2.6.  How can I submit code or areas for use with CircleMUD?
 472  
 473  There is a special uploads area:
 474  
 475  ftp://upload.circlemud.org/pub/CircleMUD/incoming/
 476  
 477  ..in the CircleMUD domain for submissions of code, areas, utilities,
 478  scripts, and anything else that might be of use to Circle users.  Please
 479  make sure only to upload to upload.circlemud.org and not any of the
 480  CircleMUD mirrors. These portions of code or areas will probably not be
 481  added to the full release of CircleMUD unless you make specific arrangements
 482  with Jeremy for code items, or with Alex for area/lib files.
 483  
 484  
 485  2.7.  How do I use a patch file and how can I make one?
 486  
 487  Patch files are created and used using the ``diff'' and ``patch'' utilities,
 488  respectively.  They can both be downloaded from the GNU FTP Site
 489  (ftp://ftp.gnu.org/pub/gnu/) under the name ``diffutils- xxx.tar.gz''.  If
 490  you happen to be using a DOS or Windows machine, you should get patch for
 491  DOS (ftp://204.119.24.14/pub/patch/patch12.zip). This does not support long
 492  filenames (but can be used with short filenames).  There is also a set of
 493  Windows 95 Utilities now available from the Cygnus Gnu-Win32 Project
 494  (http://www.cygnus.com/misc/gnu-win32/).
 495  
 496  These are the various parameters to use with diff (all work in general on
 497  unix based systems, but check out the help entries to be certain.
 498  
 499  diff -uN [original_src_directory] [altered_src_directory] > Patch
 500  
 501  -u is the unified output. ie. it tells diff to output the text what is
 502  called ``patch'' style.  On some systems, you will have to use -c but it
 503  generates much larger and harder to follow patches.
 504  
 505  -N  Tells diff to treat files that are in one directory and not there in the
 506  other as being empty in the one they are not there.  It allows entire files
 507  to be included into the patch.
 508  
 509  -r  recursive, add r to the uN above if you want it to recursively add in
 510  any subdirectories.  (be careful with this one)
 511  
 512  -p  Tells diff to indicate what function is being ``patched'' in each
 513  section. This may not be supported by all versions of ``diff.''
 514  
 515  If you download a patch file and would like to add it to your code, first
 516  make sure to read any instructions that the patch author might have written. 
 517  The command used to add the patch may vary depending on how the patch was
 518  created. This should given in the first line of the patch or in the
 519  instructions.  Normally, if using GNU patch with a unified diff, the command
 520  should be:
 521  
 522          patch -u < [patchfile]
 523  
 524  If the patch was created with a SYSV patcher (i.e. not a unified diff), the
 525  patch should be added with:
 526  
 527          patch -c < [patchfile]
 528  
 529  Of course, if the instructions state otherwise, ignore any instruc- tions
 530  given here and follow the instructions given with the patchfile instead.
 531  
 532  Finally, in modern patches, there are three characters of interest to note:
 533  
 534  o  ! :: The line changes between new and old.
 535  o  + :: This line is added to the old to make the new.
 536  o  - :: This line is removed from the old to make the new.
 537  o  The rest of the lines are just there to give you an idea of where
 538     to change.
 539  
 540  
 541  3.  Compiling CircleMUD
 542  
 543  3.1.  Why do I get many syntax errors with Sun's ``cc'' compiler?
 544  
 545  Because Circle is written in ANSI C, and Sun's standard cc compiler isn't
 546  capable of compiling ANSI C code.  You can try acc, Sun's ANSI C compiler,
 547  but it costs extra money to get it from Sun so your sysadmin may not have
 548  installed it.  Most don't.  The best solution is to get the GCC compiler
 549  from the GNU FTP site (ftp://ftp.gnu.org/pub/gnu) and install it, if you
 550  have enough time and space.
 551  
 552  
 553  3.2.  Why do I get all sorts of errors with ``crypt'' functions and
 554        header files?
 555  
 556  (This information applies ONLY to Version 3.0 of the code.) CircleMUD
 557  normally uses the UNIX crypt() function to enrypt players' passwords.
 558  Because of export restrictions imposed by the U.S., some systems do not have
 559  the crypt() function. ``configure'' will usually be able to figure out
 560  whether or not your system has crypt(), but if it guesses incorrectly and
 561  you see problems with the crypt() function or headers, you can manually
 562  disable password encryption by going into the sysdep.h source file and
 563  uncommenting the line that reads:
 564  
 565          #define NOCRYPT
 566  
 567  Be warned, however, that doing this causes the MUD to store players'
 568  passwords in plaintext rather than as encrypted strings.  Also, if you move
 569  from a system which has crypt to one that doesn't, players won't be able to
 570  log in with their old passwords!
 571  
 572  
 573  3.3.  When I try to compile, why do I get a lot of undefined symbols
 574        referenced in comm.o for functions like socket, accept, and bind?
 575  
 576  SVR4 systems require the socket and nsl libraries for network programs.  You
 577  shouldn't see this error any more with version 3.0 because ``configure''
 578  should automatically use those libraries for you; however, if you still have
 579  problems, try adding ``-lsocket -lnsl'' to the line in the Makefile that
 580  links all the object files together into the 'circle' binary.
 581  
 582  If you're using V2.20 and you have this error, the best thing to do is
 583  simply to use V3.0 instead.  If you insist on using 2.20, go into the
 584  Makefile and search for the comment next to ``SVR4''.
 585  
 586  3.4.  Every time I try to compile Circle (or any other piece of soft- ware)
 587        under Linux, it gives me errors and says it cannot find include header
 588        files in the linux/ and asm/ directories.  What can I do?
 589  
 590  Under Linux, you cannot compile any program unless you install the kernel
 591  source code because the kernel source includes the ANSI C header files.  You
 592  need the files in /usr/include/linux, which are distributed separately from
 593  the rest of /usr/include.
 594  
 595  The easiest way to do this if you're using the Slackware Linux distribution
 596  is simply to install the 'K' series of disks which is the kernel source.
 597  
 598  Otherwise, you'll have to set up your include files manually. The easiest
 599  way to get these is to download kernel source from:
 600  
 601  http://www.kernel.org/mirrors/
 602  
 603  Get the kernel source that matches the kernel you're running (type `uname
 604  -a' to find your kernel version).  Then unpack the kernel into the usr/src
 605  /directory.  It's about 13 megabytes compressed and 54 megabytes
 606  uncompressed (For the 2.2.9 kernel).
 607  
 608  Read the README file that comes with the kernel, and make the symbolic links
 609  you need for /usr/include/asm and /usr/include/linux.
 610  
 611  Now compile the MUD.  This will take care of most of the errors.  You may
 612  have to do `make config' and `make dep' in /usr/src/linux as well, in order
 613  to make linux/config.h and other files that get generated by these steps.
 614  
 615  You can remove the whole kernel source tree except for include/ at
 616  this point and get most of your 48.5 megs back.
 617  
 618  (Thanks to Michael Chastain for providing this answer.)
 619  
 620  
 621  3.5.  I'm getting compilation errors from a header file, and I didn't even
 622        change it?
 623  
 624  Okay, if you really didn't change ``structs.h'' then the error isn't in
 625  ``structs.h''.  I think I've seen 2 cases where this has happened, the
 626  first, is that the header file you included right before the header file
 627  messing has an error in it.  I can't really say much beyond that, but look
 628  for a missing semicolon, are any other errors you can find.
 629  
 630  If you include files out of order, it can mess things up.  For example, B.h
 631  has stuff in it that is defined in A.h, and if you include B.h before A.h,
 632  you can get errors, your best bet here is to mess with the order of the
 633  headers, making sure you put ``conf.h'' and ``sysdep.h'' at the top,
 634  followed by ``structs.h'', ``utils.h'', etc. Any file specific headers
 635  should be the last one included just for coding style.
 636  
 637  
 638  3.6.  I'm trying to compile the mud on Windows '95 and am having prob- lems,
 639        what can I do?
 640  
 641  The first thing to do is to make sure you are compiling a recent version of
 642  the source code.  Patch Level 11 and onwards all support Windows '95 winsock
 643  sockets now.  Second, you should ensure that you have carefully read the
 644  README.WIN file for instructions on what to include.  Next, ensure that you
 645  are using a C compiler that supports long filenames (for example, MSVC 4.0
 646  does, MSVC 1.0 does not).  If you happen to be trying to patch something
 647  into your code, you should use patch for DOS
 648  (ftp://204.119.24.14/pub/patch/patch12.zip).  This does not support long
 649  filenames (but can be used with short filenames).
 650  
 651  
 652  3.7.  How can I do a ``grep'' on Windows 95?
 653  
 654  1. Select ``start menu''->``find''->``files or folders''
 655  2. Enter the files/dirs to search in.
 656  3. Select ``Advanced''
 657  4. In the ``Containing Text'' input box, type in the text you want.
 658  5. Double click on a match to bring up the file that matched.
 659     Even better is to use MSVC's find command (if you have it).
 660  
 661  
 662  3.8.  While compiling the mud, why do I get errors like ``foo.c:1231:
 663        Undefined symbol `_whereamI' referenced from text segment''
 664  
 665  You forgot to include a source file into the make.  Go edit your Makefile
 666  and make sure all the necessary *.c files are in there, in particular,
 667  whichever C file defines the function that the compiler is complaining is
 668  undefined.  If all else fails, try deleting all the *.o files and
 669  recompiling from scratch.
 670  
 671  
 672  3.9.  What is a parse error and how do I fix it?
 673  
 674  A parsing error is often a missing or extra semicolon, parenthesis, or
 675  bracket ({).
 676  
 677  If the parse error is before a semicolon at the end of a line of code, it is
 678  something on that line.
 679  
 680  If it is at the beginning of a line within a function, it is usually a
 681  missing semicolon on the previous line.
 682  
 683  If it is at the beginning of a function, count your brackets (especially the
 684  {} ones) in the previous function.
 685  
 686  I can't think of any other parse errors.  These are the ones I commonly see. 
 687  With a bit of practice, they are very easy to locate and fix.  For a more
 688  detailed explanation, check out the C Language FAQ.
 689  
 690  
 691  3.10.  I have this piece of code that calls bcopy(), bzero(), and bcmp() and
 692         it won't compile, so what can I do?
 693  
 694  All three of these functions are fairly standard on BSD systems. However,
 695  they are not considered to be very portable, and thus should be redefined. 
 696  For example, the equivalents for SYSV are:
 697  
 698  
 699  #define bcopy(from,to,len)      memmove(to,from,len)
 700  #define bzero(mem,len)          memset(mem,0,len)
 701  #define bcmp(a,b,len)           memcmp(a,b,len)
 702  
 703  
 704  3.11.  My compiler doesn't have ``strdup()'', what can I do?
 705  
 706  Use Circle's built-in str_dup() function instead.
 707  
 708  
 709  3.12.  I am having trouble with my ``makefile'', what could be the problem?
 710  
 711  If you used cut and paste to insert items into your makefile, it is likely
 712  that you accidentally put spaces at the beginning of lines where tabs are
 713  needed.  This is how the makefile must be constructed:
 714  
 715  foo.o: foo.c conf.h sysdep.h structs.h utils.h interpreter.h \
 716    handler.h db.h
 717  {TAB}$(CC) -c $(CFLAGS)
 718  
 719  To add these lines properly, you can use gcc to assist you with the
 720  following shell script (from Daniel Koepke):
 721  
 722  #!/bin/sh
 723  gcc -MM $1 >> Makefile
 724  echo "{TAB}\$(CC) -c \$(CFLAGS) $1" >> Makefile
 725  
 726  To use this script, replace {TAB} with a tab, and then run the script
 727  like: add_file foo.c
 728  
 729  
 730  3.13.  How can I handle directories in C?
 731  
 732  Note that this seems only to be valid for UNIX OSes.  Handling of
 733  directories is accomplished through the dirent.h and sys/types.h files.  The
 734  function opendir() returns a ``DIR*'' pointer (it's like but not the same as
 735  the ``FILE *'' pointer) when you pass it the name of a directory to open or
 736  NULL if it can't open the dir.  After the directory has been opened, you can
 737  step through the files or search for particular files, etc. using readdir(),
 738  seekdir(), and scandir(). When you reach the end of the directory list, you
 739  can either go back to the start with rewinddir() or close the directory with
 740  closedir(). The following code (which has not been tested) should open a
 741  directory and go through it one by one and prints the filenames:
 742  
 743    struct dirent * ffile;
 744    DIR * my_dir;
 745  
 746    if (!(my_dir = opendir("foo")))
 747      return;
 748  
 749    while (1) {
 750      if (!(dirent = readdir(my_dir)))
 751        break;
 752      printf("%s\n", dirent->d_name);
 753    }
 754  
 755    closedir(my_dir);
 756  
 757  The dirent structure contains only two useful elements, the file's name
 758  (d_name) and the files length (d_reclen).
 759  
 760  Thanks to Daniel Koepke for the above.
 761  
 762  
 763  4.  Running CircleMUD
 764  
 765  4.1.  I typed ``autorun'' but then my terminal just froze.
 766  
 767  autorun is a script which automatically runs, logs, and reboots the game for
 768  long-term runs.  You should run autorun in the background by typing
 769  ``./autorun &'' -- the MUD will start running in the background and you'll
 770  get the normal UNIX prompt back immediately (see section 4.3). The game will
 771  then run unattended until you explicitly shut it down.
 772  
 773  On some systems, you may need to prepend ``nohup'' to the autorun command
 774  since some systems will kill off any processes left running when you leave
 775  the shell.
 776  
 777  
 778  4.2.  I typed ``bin/circle'' and got lots of boot messages, but then it said
 779        ``Entering game loop'' and froze.
 780  
 781  It is not frozen, it is just waiting for people to connect.  You have to run
 782  the MUD in the background by typing ``bin/circle &'' and then use telnet to
 783  connect to the game (see next section).
 784  
 785  
 786  4.3.  Okay, I think the MUD is running but why don't I get a login prompt?
 787  
 788  In order to play the MUD, you must connect to it using the telnet command,
 789  i.e. ``telnet localhost 4000''.
 790  
 791  
 792  4.4.  How come I get this error when running my mud: ``Error reading board:
 793        No such file or directory''
 794  
 795  This is not a bad thing, all it means is that you have some boards on the
 796  mud and that it can't find the file for them.  Since it can't find the file,
 797  the mud will just create the file on the fly and use that, so the next time
 798  something is posted to the board, the files will exist.  However, if you did
 799  have files for the boards and you are suddenly getting this error, it means
 800  that the board files have been deleted or something similar.
 801  
 802  
 803  4.5.  I just got this SIGPIPE, what is it and what Can I Do About It?
 804  
 805  Often it appears that other people send your system SIGPIPEs when their
 806  connection is closed, in fact, it is not the person sending the SIGPIPE, it
 807  is your system.  The SIGPIPE is generated when your program attempts to
 808  write to descriptor which has no one listening to it.  This occurs if the
 809  character is sent a message by the mud after connecting, but before the
 810  socket is flagged with an exception or reads 0 bytes.  By default, CircleMUD
 811  ignores these SIGPIPEs, with the line my_signal(SIGPIPE, SIG_IGN) in
 812  signal_setup().  Where most people see the problems with SIGPIPE is while
 813  debugging with GDB.  By default, GDB responds to a SIGPIPE by stoping the
 814  program, printing that a SIGPIPE was received, and passing it to the
 815  program.  You can change the action taken by GDB by using the `handle'
 816  command. To stop the program from stoping at SIGPIPE, you would give GDB the
 817  command `handle SIGPIPE nostop'
 818  
 819  
 820  4.6.  When I run Circle under Linux, it tells me ``gethostbyaddr: con-
 821        nection refused'' when the MUD boots, and then dies.  Why?
 822  
 823  You need to make sure you have Networking and TCP/IP support compiled into
 824  your Linux kernel, even if you aren't actually connected to the Internet. 
 825  The easiest way to do this if you're using Slackware is to install one of
 826  Slackware's precompiled networking kernels.  Also, make sure to install
 827  Slackware's `N' series of disks which contains other networking support
 828  files.
 829  
 830  If Slackware's precompiled kernel isn't available you'll have to compile the
 831  kernel yourself.  First make sure the kernel source is installed in
 832  /usr/src/linux (see section 3.1.4) and follow the instructions in
 833  /usr/src/linux/README. When you do `make config' it will ask you a series of
 834  questions about which kernel features you want; make sure to answer ``Y'' to
 835  ``Networking support'' and ``TCP/IP support''.
 836  
 837  
 838  4.7.  When I run Circle under Windows 95, it tells me ``Winsock error
 839        #10047'' when the MUD boots, and then dies.  Why?
 840  
 841  You need to configure TCP/IP networking from the Network Control Panel, even
 842  if you are not connected to the Internet.  From the Network Control Panel,
 843  select ``Add Protocol'', and under the vendor ``Microsoft'', choose
 844  ``TCP/IP''.  It may ask you to insert the Windows 95 CDROM in order to copy
 845  the drivers onto your hard drive.
 846  
 847  
 848  4.8.  When I run Circle under Windows 95, players can't rent---their
 849        equipment is just dropped on the ground, syslogs don't work, so what
 850        is the problem?
 851  
 852  The reason that objects aren't saved when your players quit is that certain
 853  unzip programs are buggy and don't completely recreate the MUD's directory
 854  structure (in particular, it doesn't create directories which have no files
 855  in them.) This is fixed in Circle 3.0 patchlevel 12 and above.  Before
 856  patchlevel 12, you can fix it simply by manually creating the needed
 857  directories:
 858  
 859          CD \Circle30bpl11
 860          cd lib\plrobjs
 861          mkdir A-E
 862          mkdir F-J
 863          mkdir K-O
 864          mkdir P-T
 865          mkdir U-Z
 866          mkdir ZZZ
 867  
 868  Object saving should then work.  The syslogs are a different story; no data
 869  is written to the system logs because the code currently is configured
 870  simply to write all errors to the standard error file descriptor (stderr),
 871  and Windows doesn't seem to let you redirect stderr to a file the same way
 872  UNIX does.  pl12 allows you to direct logs to a specific file instead.
 873  
 874  
 875  4.9.  When someone logs on to my Windows 95 MUD, the console screen
 876  gives: ``gethostbyaddr: No such file or directory''
 877  
 878  This means the MUD can't resolve the IP address of the connecting player's
 879  source site innto a hostname.  You probably don't have DNS correctly
 880  configured in the Windows Network Control Panel menu (under configuration of
 881  the TCP protocol).  Make sure you have the IP address of your ISP's DNS
 882  server listed.
 883  
 884  
 885  4.10.  My MUD crashed and my connection got closed.  What can I do?
 886  
 887  Just because your connection got closed from the MUD (for example, if you
 888  get too much information sent to you and the telnet session gets closed),
 889  this doesn't always mean that the game itself crashed. Before reporting
 890  something as a crash bug, make sure that the game itself crashed, and above
 891  all, try to duplicate the circumstances before reporting it as a crash bug. 
 892  You can also try using gdb to find out why the MUD is crashing if it gives
 893  you a core dump.
 894  
 895  
 896  4.11.  Ok, so how do I use ``gdb''?
 897  
 898  GDB has some online help, though it is not the best.  It does at least give
 899  a summary of commands and what they're supposed to do.  What follows is
 900  Sammy's short intro to gdb with some bughunting notes following it:
 901  
 902  If you've got a core file, go to your top circle directory and type:
 903  
 904  > gdb bin/circle lib/core
 905  
 906  If you want to hunt bugs in real time (causing bugs to find the cause as
 907  opposed to checking a core to see why the MUD crashed earlier) use:
 908  
 909  > gdb bin/circle
 910  
 911  If you're working with a core, gdb should show you where the crash occurred. 
 912  If you get an actual line that failed, you've got it made. If not, the
 913  included message should help.  If you're working in real time, now's the
 914  time to crash the MUD so you can see what gdb catches.
 915  
 916  When you've got the crash info, you can type ``where'' to see which function
 917  called the crash function, which function called that one, and so on all the
 918  way up to ``main()''.
 919  
 920  I should explain about ``context''  You may type ``print ch'' which you
 921  would expect to show you the ch variable, but if you're in a function that
 922  doesn't get a ch passed to it (real_mobile, etc), you can't see ch because
 923  it's not in that context.  To change contexts (the function levels you saw
 924  with where) type ``up'' to go up.  You start at the bottom, but once you go
 925  up, and up, and up, you can always go back ``down''.  You may be able to go
 926  up a couple functions to see a function with ch in it, if finding out who
 927  caused the crash is useful (it normally isn't).
 928  
 929  The ``print'' command is probably the single most useful command, and lets
 930  you print any variable, and arithmetic expressions (makes a nice calculator
 931  if you know C math).  Any of the following are valid and sometimes useful:
 932  
 933  print ch (fast way to see if ch is a valid pointer, 0 if it's not)
 934  print *ch (prints the contents of ch, rather than the pointer address)
 935  print ch->player.name (same as GET_NAME(ch))
 936  print world[ch->in_room].number (vnum of the room the char is in)
 937  
 938  etc..
 939  
 940  Note that you can't use macros (all those handy psuedo functions like
 941  GET_NAME and GET_MAX_HIT), so you'll have to look up the full structure path
 942  of variables you need.
 943  
 944  Type ``list'' to see the source before and after the line you're currently
 945  looking at.  There are other list options but I'm unfamiliar with them.
 946  
 947  (From Sammy <Samedi@cris.com>)
 948  
 949  For more information, you can try checking out the GDB Debugger
 950  (http://www.dgii.com/people/robertl/skunk/gdb/gdb_toc.html)
 951  
 952  
 953  4.12.  How can I hunt bugs more effectively?
 954  
 955  There are only a couple of commands to use in gdb, though with some patience
 956  they can be very powerful.  The only commands I've ever used are:
 957  
 958  run                     well, duh.
 959  print [variable]        also duh, though it does more than you might think
 960  list                    shows you the source code in context
 961  break [function]        set a breakpoint at a function
 962  clear [function]        remove a breakpoint
 963  step                    execute one line of code
 964  cont                    continue running after a break or ctrl-c
 965  
 966  I've run into nasty problems quite a few times.  The cause is often a memory
 967  problem, usually with pointers, pointers to nonexistent memory. If you free
 968  a structure, or a string or something, the pointer isn't always set to NULL,
 969  so you may have code that checks for a NULL pointer that thinks the pointer
 970  is ok since it's not NULL.  You should make sure you always set pointers to
 971  NULL after freeing them.
 972  
 973  Ok, now for the hard part.  If you know where the problem is, you should be
 974  able to duplicate it with a specific sequence of actions. That makes things
 975  much easier.  What you'll have to do is pick a function to ``break'' at. 
 976  The ideal place to break is immediately before the crash.  For example, if
 977  the crash occurred when you tried to save a mob with medit, you might be
 978  able to ``break mobs_to_file''.  Try that one first.
 979  
 980  When you `medit save', the MUD will hang.  GDB will either give you segfault
 981  info, or it will be stopped at the beginning of mobs_to_file.  If it
 982  segfaulted, pick an earlier function, like copy_mobile, or even do_medit.
 983  
 984  When you hit a breakpoint, print the variables that are passed to the
 985  function to make sure they look ok.  Note that printing the contents of
 986  pointers is possible with a little playing around.  For example, if you
 987  print ch, you get a hex number that shows you the memory location where ch
 988  is at.  It's a little helpful, but try print *ch and you'll notice that it
 989  prints the contents of the ch structure, which is usually more useful. 
 990  print ch->player will give you the name of the person who entered the
 991  command you're looking at, and some other info. If you get a no ch in this
 992  context it is because the ch variable wasn't passed to the function you're
 993  currently looking at.
 994  
 995  Ok, so now you're ready to start stepping.  When GDB hit your breakpoint, it
 996  showed you the first line of executable code in your function, which will
 997  sometimes be in your variable declarations if you initialized any variables
 998  (ex: int i = 0).  As you're stepping through lines of code, you'll see one
 999  line at a time.  Note that the line you see hasn't been run yet.  It's
1000  actually the _next_ line to be executed.  So if the line is a = b + c;,
1001  printing a will show you what a was before this line, not the sum of b and
1002  c. If you have an idea of where the crash is occurring, you can keep
1003  stepping till you get to that part of the code (tip: pressing return will
1004  repeat the last GDB command, so you can type step once, then keep pressing
1005  return to step quickly).  If you have no idea where the problem is, the
1006  quick and dirty way to find your crash is to keep pressing return rapidly
1007  (don't hold the eturn key or you'll probably miss it).  When you get the seg
1008  fault, you can't step any more, so it should be obvious when that happens.
1009  
1010  Now that you've found the exact line where you get the crash, you should
1011  start the MUD over and step more slowly this time. What I've found that
1012  works really well to save time is to create a dummy function.  This one will
1013  work just fine:
1014  
1015  void dummy(void){}
1016  
1017  Put that somewhere in the file you're working on.  Then, right before the
1018  crash, put a call to dummy in the code (ex: dummy();).  Then set your
1019  breakpoint at dummy, andwhen you hit the breakpoint, step once to get back
1020  to the crashing code.
1021  
1022  Now you're in total control.  You should be looking at the exact line that
1023  gave you the crash last time.  Print *every* variable on this line.  Chances
1024  are one of them will be a pointer to an unaccessable memory location.  For
1025  example, printing ch->player.name may give you an error.  If it does, work
1026  your way back and print ch->player to make sure that one's valid, and if it
1027  isn't, try printing ch.
1028  
1029  Somewhere in there you're going to have an invalid pointer.  Once you know
1030  which one it is, it's up to you to figure out why it's invalid. You may have
1031  to move dummy() up higher in the code and step slowly, checking your pointer
1032  all the way to see where it changes from valid to invalid.  You may just
1033  need to NULL a free'd pointer, or you may have to add a check for a NULL
1034  pointer, or you may have screwed up a loop.  I've done all that and more :)
1035  
1036  Well, that's it in a nutshell.  There's a lot more to GDB that I haven't
1037  even begun to learn, but if you get comfortable with print and stepping you
1038  can fix just about any bug.  I spent hours on the above procedure trying to
1039  get my ascii object and mail saving working right, but it could have taken
1040  weeks without gdb.  The only other suggestion I have is to check out the
1041  online gdb help.  It's not very helpful for learning, but you can see what
1042  commands are available and play around with them to see if you can find any
1043  new tools.
1044  
1045  (From Sammy <samedi@cris.com>)
1046  
1047  
1048  4.13.  I just added n levels to my MUD (from the stock 34).  How do I set my
1049         imps up to level n without a pfile wipe?
1050  
1051  You can write a quick and nasty function that will advance your imp (and imp
1052  only) to the max level (LVL_IMPL).  This can be done with a quick idnum
1053  check so that only the original player (the first imp, he with id 1) can use
1054  the command to get to maximum level.
1055  
1056  ACMD(do_upme)
1057  {
1058    if (GET_IDNUM(ch) != 1) {
1059      send_to_char("You think IMP positions are that easy to come by?  Go Figure...\r\n", ch);
1060    } else {
1061      GET_LEVEL(ch) = LVL_IMPL;
1062      send_to_char("Advanced.\r\n", ch);
1063    }
1064  }
1065  
1066  
1067  4.14.  I decided to wipe my pfile away anyway.  What steps should I take to
1068         do this?
1069  
1070  In order:
1071  1. Shutdown the MUD with ``shutdown die'' so that it won't restart.
1072  2. Remove the player file, lib/etc/players
1073  3. Restart the MUD and login to recreate your imp character.
1074  
1075  You should probably also remove files in plrobjs, unless you want the
1076  recreated characters to come back with the same equipment they had when they
1077  were deleted.
1078  
1079  
1080  4.15.  I want to expand the ability to pk in my MUD, allowing ASSASSINS
1081         that'll be able to PK without getting flagged.  How can I do this?
1082  
1083  The simple way to do this is to find all the ``pk_allowed'' checks and
1084  replace them with a can_murder(ch, vict) function call.  Prototype the
1085  function in utils.h.  Then, in utils.c, create a can_murder() function
1086  something like this:
1087  
1088  int can_murder(struct char_data *ch, struct char_data *victim) {
1089    if (pk_allowed == TRUE)
1090      return TRUE;
1091    if (IS_NPC(ch) || IS_NPC(victim))
1092      return TRUE;   /* you can always kill these */
1093    if (PLR_FLAGGED(ch, PLR_ASSASSIN))
1094      return TRUE;   /* they can kill anyone */
1095    /* Add further checks here */
1096  }
1097  
1098  
1099  4.16.  Why does it say ``Connection closed by foreign host.'' and not
1100         display the ``Byebye!'' message I'm trying to send before cutting
1101         someone off?
1102  
1103  This usually happens if you are doing something like this:
1104  
1105    send_to_char("Bye bye.  Come back soon, ya hear?", ch);
1106    close_socket(ch->desc);
1107  
1108  The close_socket immediately dispatches/closes the connection, while
1109  send_to_char puts the message on the output queue to be dispatched next
1110  game_loop cycle. Therefore, the socket is gone.  On some systems (ie old
1111  linux), this can even cause a infinite loop attempting to write to a closed
1112  socket. The proper way of doing this and other ``Byebye'' messages is to set
1113  the CON state of the player to CLOSE, like this:
1114  
1115    send_to_char("Bye bye.  Come back soon, ya hear?", ch);
1116    STATE(ch->desc) = CON_CLOSED;
1117  
1118  This will then cycle to the next game_loop, dispatch the output queues
1119  (therefore sending the byebye message) and then close the socket. Further
1120  note, in some bizarre cases, this only seems to send about 40 characters and
1121  no escape codes.  Sending more than 40 characters or escape codes (like the
1122  clear screen sequence) will crash the process reporting a problem similar to
1123  writing to a closed socket.
1124  
1125  
1126  4.17.  I run my MUD on a unix system and the pfile/rent file works great,
1127         but on my home system it's all screwed up.  What gives?
1128  
1129  Some operating systems write binary data least-signifigant-digit- first,
1130  while others write it most-significant-first (big endian vs. little endian).
1131  Moving player files, rent files, mail files, and board files from one of
1132  these systems to the other will result in corrupted files.  The solutions to
1133  this problem include:
1134  
1135  o  Don't bother trying to move those files.
1136  o  Edit your code to always write in one format.
1137  o  Develop a binary to ascii conversion tool (and ascii to binary) for
1138     all binary files.
1139  o  Develop an ascii read/write system to allow portability.
1140  
1141  
1142  4.18.  How do I get the CircleMUD to autoload when the Linux server is
1143         restarted?
1144  
1145  In /etc/rc.d/rc.local find where things like sendmail and (maybe) gpm
1146  are started.  Add something like:
1147  
1148  cd /home/mudlogin/circlebpl19/
1149  su mudlogin -c ./autorun &
1150  cd
1151  
1152  Of course, change the "mudlogin" to whatever the name of the account is that
1153  normally has control of the MUD, and change the path in the first cd to
1154  whereever the MUD is run from.
1155  
1156  For more info: man su
1157  
1158  
1159  4.19.  My server shuts down my MUD everytime I logoff. How do I keep the MUD
1160         running when I logoff?
1161  
1162  Instead of typing "autorun &" to start the autorun script (which starts and
1163  keeps the MUD running), type "nohup autorun &".  Running the autorun via
1164  nohup will keep the script and the MUD running when you logoff of the
1165  server. For more information type "man nohup" at the prompt on your server.
1166  
1167  
1168  5.  Code Changes for CircleMUD 2.20
1169  
1170  5.1.  How do I fix the bug where people can junk more coins than available?
1171  
1172  Apprently in Circle 2.2, you can drop any amount of coins, and then be
1173  rewarded with more coins than you had in the first place.  Here is the fix
1174  from Jeremy Elson:
1175  
1176  Around line 480 of act.obj1.c, you will find the code:
1177  
1178              if (!str_cmp("coins", arg) || !str_cmp("coin", arg))
1179                perform_drop_gold(ch, amount, mode, RDR);
1180              else {
1181                /* code to drop multiple items.  anyone want to write it? -je */
1182                send_to_char("Sorry, you can't do that (yet)...\n\r", ch);
1183  -->           return;
1184              }
1185            } else {
1186            ....
1187  
1188  It should be changed to:
1189  
1190              if (!str_cmp("coins", arg) || !str_cmp("coin", arg))
1191                perform_drop_gold(ch, amount, mode, RDR);
1192              else {
1193                /* code to drop multiple items.  anyone want to write it? -je */
1194                send_to_char("Sorry, you can't do that (yet)...\n\r", ch);
1195              }
1196  -->         return;
1197            } else {
1198            ....
1199  
1200  
1201  5.2.  How do I fix the ``vstat'' bug that crashes the MUD?
1202  
1203  To the fix for the vstat bug, from Jeremy Elson:
1204  
1205  In the file act.wizard.c, in the function do_vstat, in the mobile section of
1206  the switch (around line 1150), you'll find the code:
1207  
1208          mob = read_mobile(r_num, REAL);
1209          do_stat_character(ch, mob);
1210          extract_char(mob);
1211  
1212  Add the line char_to_room(mob, 0) before extract_char(), like this:
1213  
1214          mob = read_mobile(r_num, REAL);
1215          do_stat_character(ch, mob);
1216          char_to_room(mob, 0);
1217          extract_char(mob);
1218  
1219  
1220  5.3.  How do I fix the ``wizlock'' bug that lets lower immortals lock
1221        out higher immortals?
1222  
1223  Simple, insert this code into 'do_wizlock()' in 'act.wizard.c':
1224  
1225          if (value < 0 || value > LEVEL_IMPL) {
1226            send_to_char("Invalid wizlock value.\n\r", ch);
1227            return;
1228          }
1229  
1230  +        /*   Do not allow people to wizlock above their level.
1231  +        *   This bug came with Circle 2.20 source -- VampLestat
1232  +        */
1233  +        if (value > GET_LEVEL(ch)) {
1234  +          send_to_char("You may only wizlock below your level.\n\r", ch);
1235  +          return;
1236  +        }
1237          restrict = value;
1238  
1239  
1240  5.4.  How do I fix the ``mudlog'' bug that lets people see me log in,
1241  even if I'm wizinvis?
1242  
1243  For all the mudlog calls for entering the game, quitting, and so
1244  forth, you must change
1245  
1246          mudlog(MAX(LEVEL_IMMORT, ...
1247  
1248  to
1249  
1250          mudlog(MAX(GET_LEVEL(i), ...
1251  
1252  where ``i'' is either ``ch'' or ``d->character'' depending on the
1253  call.
1254  
1255  
1256  6.  CircleMUD 3.0 Questions
1257  
1258  6.1.  Are there any bugs in patch level 19?
1259  
1260  There are no bugs.  Only features.  Seriously though, if perchance you find
1261  a bug, please mail it (along with a possible fix) to the bugs database
1262  <bugs@circlemud.org> and the CircleMUD list.  Once in the bug database, it
1263  will be routed to the correct person.  Note that no confirmation is sent
1264  back automatically.  You can view the status of the bug at the bugs database
1265  (http://bugs.circlemud.org/).
1266  
1267  
1268  6.2.  How do I access Online Creation?
1269  
1270  Online Creation is not yet part of the Circle beta release. When it does
1271  become part of the release, it'll be accessed through a command called olc.
1272  Update: OLC will probably be in release 3.10 now, instead of 3.0. In the
1273  mean time, check out the CircleMUD FTP Server:
1274  
1275  ftp://ftp.circlemud.org/pub/CircleMUD/contrib/olc/
1276  
1277  
1278  6.3.  How does the new bitvector system work?
1279  
1280  The new bitvector system in CircleMUD 3.0 is an ascii based one. The old
1281  numeric values can still be used, but the new system should make sorting
1282  flags out substantially easier.  The system uses an ``a'' as the value for
1283  1, ``b'' for 2, ``c'' for 4, ``d'' for 8, etc.  Once ``z'' is reached, the
1284  next letter in sequence is ``A''.  Detailed information about how to use
1285  bitvectors with CircleMUD can be found in the CircleMUD Builder's Manual
1286  (http://www.circlemud.org/~jelson/cdp/building/).
1287  
1288  
1289  6.4.  When will the production release of Circle 3.0 be?
1290  
1291  I don't know.  Don't ask again.  Same for the next patch level.  If you must
1292  have bleeding edge stuff, check out the CVS Snapshot
1293  (ftp://ftp.circlemud.org/pub/CircleMUD/cvs/) until we get an online
1294  anonymous CVS.  And don't ask when the next CVS snapshot will be, we'll do
1295  it when we have some changes worth it.
1296  
1297  
1298  6.5.  If someone logs in and just sits at the password prompt, the MUD hangs
1299        (i.e., no one else can connect or do anything) until the person enters
1300        their password.
1301  
1302  Your system's POSIX non-blocking I/O might be broken.  Look in the source
1303  file sysdep.h at the comment above the line that says ``#define
1304  POSIX_NONBLOCK_BROKEN" for a possible fix. Once this is done, recompile the
1305  MUD and try again.  If you use the POSIX_NONBLOCK_BROKEN constant and it
1306  fixes your problem, please send mail to the bugs database
1307  <bugs@circlemud.org> and let us know exactly what kind of system you are
1308  using and what you had to do to fix it.
1309  
1310  
1311  6.6.  Why does CircleMUD use BUF switches all through the code, what's
1312        happening here?
1313  
1314  From Jeremy:
1315  
1316  This code is the new output buffering system that I wrote for Circle in the
1317  early (non-released) beta versions of 3.0.  The old Diku code for queueing
1318  output (which stayed with Circle until version 2.20) was memory- and
1319  time-inefficient in many cases (and, in my opinion, was inefficient for the
1320  normal behavior of most MUDs).
1321  
1322  First, I should explain what output queueing is and why it is necessary.  On
1323  each pass through the game_loop(), the MUD performs a number of steps: check
1324  to see if there are any new players connecting, kick out people with bad
1325  links, read input over the network for all players, then process the input
1326  for each player that has sent a complete line over the net.  The processing
1327  step is usually where output is generated because it is where MUD commands
1328  are processed (e.g., ``kill'' might generate output of ``Kill who?'') When
1329  output is generated, it is not immediately sent out to the player, but
1330  instead queued for output in a buffer.  After all players' commands are
1331  processed (and each command generates the appropriate output for various
1332  players), the next step of the game_loop() is to send all the queued output
1333  out over the network.
1334  
1335  The new output system that Circle now uses allocates a small, fixed size
1336  buffer (1024 bytes) for each descriptor in which output can be queued.  When
1337  output is generated (via such functions as send_to_char(), act(), etc.), it
1338  is written to the fixed size buffer until the buffer fills.  When the buffer
1339  fills, we switch over to a larger (12K) buffer instead.  A ``buffer
1340  switch'', therefore, is when the 1024-byte fixed buffer overflows.
1341  
1342  When a large (12K) buffer is needed, it is taken from a pool of 12K buffers
1343  that already been created.  It is used for the duration of that pass through
1344  the game_loop() and then returned to the pool immediately afterwards, when
1345  the output is sent to the descriptor.  If a large buffer is needed but none
1346  are in the pool, one is created (thereby increasing the size of the pool);
1347  the ``buf_largecount'' variable records the current pool size.
1348  
1349  If a player has already gone from their small to large buffer, and so much
1350  output is generated that it fills even the large buffer, the descriptor is
1351  changed to the overflow state, meaning that all future output for the
1352  duration of the current pass through the game loop is discarded.  This is a
1353  buffer overflow, and the only state in which output is lost.
1354  
1355  Now that I've described how the system works, I'll describe the rationale. 
1356  The main purpose for the two-tiered buffer system is to save memory and
1357  reduce CPU usage.  From a memory standpoint: Allocating a fixed 12K buffer
1358  for each socket is a simple scheme (and very easy to code), but on a large
1359  MUD, 100 12K buffers can add up to a lot of wasted memory.  (1.2 megs of
1360  memory used for buffering on a 100-player MUD may not seem like very much,
1361  but keep in mind that one of Circle's big selling points several years ago,
1362  when memory was expensive, was that it had a very small memory footprint (3
1363  or 4 megs total!) And from a CPU standpoint: the original Diku used a
1364  dynamically allocated buffer scheme to queue output, which unfortunately
1365  meant that for each player, on each pass through the game loop, dozens of
1366  tiny buffers (often one for every line of output, depending on the code to
1367  execute the command) were allocated with malloc(), individually written to
1368  the system using individual calls to write(), and then free()'d.  My system
1369  saves hundreds or thousands of calls per second to malloc() and free(), and
1370  reduces the number of system calls *drastically* (to at most one per player
1371  per pass through the game loop).
1372  
1373  The trick is to choose the size of the small and large buffers correctly in
1374  order to find the optimal behavior.  I consider ``optimal'' to mean that 90%
1375  of the time, most players stay within the limits of their small buffer (for
1376  example, when wandering through town or mindlessly killing some monster
1377  while watching damage messages go by).  Hopefully, a large buffer switch is
1378  only necessary when a player executes a special command that generates an
1379  unusually large amount of output, such as ``who'', ``read board'', or
1380  ``where sword''.  This critically depends on the fact that not everyone will
1381  be executing such a special large-output command at the same instant.
1382  
1383  For example, imagine you have 10 players on your MUD.  They are all
1384  wandering around town, and every once in a while one of them types ``who'',
1385  or reads the board, meaning that they are seeing more than 1024 bytes of
1386  output at a time.  On such a MUD, I would hope that there would only be a
1387  single 12K buffer allocated which gets passed around among all the 10
1388  players as needed.  Now, all players think they can queue up to 12K of
1389  output per command without getting truncated even though only one 12K buffer
1390  actually exists -- they are all sharing it.
1391  
1392  But - there's a problem with this.  There are certain cases when many
1393  players have to see a lot of output at the same instant (i.e. on the same
1394  pass through the game_loop()), all of them will need a large buffer at the
1395  same time and the pool will get very big.  For example, if an evil god types
1396  ``force all who''; or if the MUD lags for several seconds, then suddenly
1397  gets unlagged causing many commands to be processed at the same moment; or
1398  if 20 people are all trying to kill the same MOB and are all seeing 20
1399  damage messages (more than 1024 bytes) on the same pass through the
1400  game_loop().
1401  
1402  Unfortunately, the current patchlevel of Circle has no way to destroy large
1403  buffers so such cases are pathological and cause wasted memory.
1404  Unfortunately since I don't run a MUD I can't actually tell how often this
1405  happens on a real MUD.  (If there are any IMPs out there who run large MUDs
1406  (say, >= 30-50 players on regularly), and you've read this far, please send
1407  me the output of ``show stats'' after your MUD has been played for at least
1408  several hours.)
1409  
1410  Hopefully this clears up the way buffers work.
1411  
1412  
1413  6.7.  How do I add a new class?  How do I add more levels?
1414  
1415  Adding a new class is fairly easy in 3.0, in fact, someone has taken the
1416  time to put together a fairly complete document on adding a class, in this
1417  case a Knight class. The class.doc is available on the FTP site:
1418  
1419  ftp://ftp.circlemud.org/pub/CircleMUD/contrib/docs/3.x/class.txt
1420  
1421  The same applies for levels, in the file levels.doc
1422  (ftp://ftp.circlemud.org/pub/CircleMUD/contrib/docs/3.x/levels.txt)
1423  which can be found in the same place.
1424  
1425  
1426  6.8.  Is there a complete ``coding.doc''?
1427  
1428  No.  Look at the README.NOW in the docs directory.  It isn't complete, nor
1429  does anyone have the entire thing.  It is being worked upon.
1430  
1431  RTFM