home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / top2src.zip / SOURCE.TXT < prev    next >
Text File  |  2000-07-13  |  42KB  |  813 lines

  1. Notes for the TOP Source Code - July 13, 2000
  2. =============================
  3.  
  4.     This is a somewhat hastily written collection of instructions, notes,
  5. anecdotes, and tips for working with the source code for The Online Pub.
  6.  
  7.     Introduction
  8.     ------------
  9.  
  10.     This is the C source code for a beta version of what I originally intended
  11. to be The Online Pub v2.01 (though such a version was never released). In a
  12. move that I will regret for the rest of my life, I wiped out all traces of the
  13. TOP v3.00wb1 source when it became apparent that I couldn't afford any time to
  14. complete the project and didn't want it as a distraction.  Those who want any
  15. of the features of TOP v3.00wb1 will have to rewrite them.  I'm truly sorry for
  16. this, but believe me it hurts every time I think about it.  NOTE:  There's a
  17. section near the end about what needs to be done to this source to make it
  18. match v3.00wb1.
  19.  
  20.     Also, I must apologize for the unfinished condition of the entire source
  21. package.  It was my initial intention to complete all of the accompanying
  22. description files, including a more organized version of this file.  However,
  23. with my summer break winding down I decided it was best to wrap this up quickly
  24. while I have a chance.  If I didn't get the source released this summer I
  25. probably wouldn't have a chance to get it released again!
  26.  
  27.     Some of the source files refer to text descriptions which simply don't
  28. exist.  This includes, but is not limited to, BBS.TXT and PRIVCHAT.TXT.
  29. Another file, CHANNELS.TXT, is only partially completed.  These are files I
  30. wanted to write, but as I said I felt I was running out of time.  My code is
  31. fairly well-commented, and programmers nowadays are generally fairly smart, so
  32. I think people will be able to figure out what's going on.  If not, I am happy
  33. to answer questions regarding the source.  Please see the end of this file for
  34. contact instructions.  NOTE:  While as I say the code is commented, some late
  35. modifications may not have been commented.
  36.  
  37.     Please remember that it was never originally my intention for this source
  38. to be distributed, so it doesn't follow many good practices for portable code.
  39. Nevertheless it has been cleaned up significantly from its original state and
  40. should be fairly straightforward to use.
  41.  
  42.     Usage Restrictions
  43.     ------------------
  44.  
  45.     The TOP source is distributed under the terms of the GNU General
  46. Public Licence (GPL) version 2, which is included in the archive in the file
  47. COPYING.
  48.  
  49.     The GPL isn't exactly the licence I had wanted but it's close enough and
  50. will save me a lot of time writing my own.  It's also one that a lot of people
  51. are familiar with because it's been around for so long.  Besides, I've recently
  52. begun to use a lot of open source software, so it's only fair that I make my
  53. own small contribution!
  54.  
  55.     Below is the required information for the GPL.  This information applies to
  56. each and every file contained in the distribution archive of the TOP source,
  57. even if this information is missing from that file itself.
  58.  
  59.     Copyright 1993 - 2000 Paul J. Sidorsky
  60.  
  61.     This program is free software; you can redistribute it and/or modify
  62.     it under the terms of the GNU General Public License, version 2, as
  63.     published by the Free Software Foundation.
  64.  
  65.     This program is distributed in the hope that it will be useful,
  66.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  67.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  68.     GNU General Public License for more details.
  69.  
  70.     You should have received a copy of the GNU General Public License
  71.     along with this program; if not, write to the Free Software
  72.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  73.  
  74.     What This Package Contains
  75.     --------------------------
  76.  
  77.     This package will let you build a version of TOP that is essentially
  78. equivalent to TOP v2.00.  Actually, it's a little better than v2.00, because it
  79. has several bug fixes.  It's labelled as v2.01b because it was my intention to
  80. have such a version, but I never got around to releasing it and instead went
  81. straight to v3.00wb1.
  82.  
  83.     While the package only comes with a Project file for TOP for DOS, it's
  84. possible to build the Win32 version, and even the OS/2 version, with only a
  85. small amount of effort.  All versions are built from the same source.
  86.  
  87.     You also get the source to add-on programs like TOPMaint, TOPLink, and
  88. BJ4TOP, as well as some bonus goodies including removed features like Poker,
  89. though for any of this stuff you are on your own in getting it to work.  I will
  90. only provide support for compiling TOP, TOPACT, and TOPMaint.
  91.  
  92.     Requirements
  93.     ------------
  94.  
  95.     First, it's assumed you're familiar with TOP itself, and with BBSing in
  96. general, and of course with the C programming language.  I won't help anybody
  97. who doesn't meet these three requirements.
  98.  
  99.     To compile the TOP source, you need the following:
  100.  
  101.     - Borland C++ v4.52 or compatible.  Borland C++ Builder should work for the
  102. Win32 version but the project file will have to be converted, imported, and
  103. then modified according to the instructions given later.  It MAY be possible to
  104. use a different brand of compiler after making significant modifications, but I
  105. don't provide support for those wanting to try.
  106.  
  107.     - Version 6.0 or higher of the OpenDoors toolkit by Brian Pirie.  If you
  108. are a registered user of the OpenDoors toolkit I suggest you use v6.0 as it was
  109. the version TOP was originally compiled with and thus is known to be
  110. compatible.  However, if you are not registered then you should be able to use
  111. version 6.1 which is distributed under the GNU LGPL and thus does not require
  112. registration.  Note that I have not tested the TOP source with v6.1 so I can't
  113. say if it works or not.  v5.0 may work with minor modifications, but as
  114. registration entitled users to free upgrades there should be no reason not to
  115. upgrade.  (There's no Win32 version of v5.0 either.)  Customized versions may
  116. or may not work depending on how much customization was done.
  117.  
  118.     - You may also want to get Fortify by Simon P. Bullen.  Fortify is a handy
  119. shell that monitors memory allocation and access, and was instrumental in
  120. solving the infamous random-crashing bug that plagued RAP v1.82 (RAP's
  121. predecessor).  It's freely available.  TOP can be compiled without Fortify (and
  122. normally was anyhow) with very minor changes, however.  NOTE:  Fortify is used
  123. by TOP/DOS only.  If you're compiling the Win32 or OS/2 versions you won't even
  124. have to change anything as Fortify is not compiled in these cases.
  125.  
  126.     Extra Files
  127.     -----------
  128.  
  129.     I've included a whole bunch of extra files, including unfinished bits of
  130. code, my original design notes, and other tidbits, in the hope that at least
  131. some of them will be useful.  Below is a list of those files and a description
  132. of what each of them does, in no particular order.  Any file NOT listed below
  133. can be considered part of TOP proper, including documentation.
  134.  
  135.     NOTE:  When I say "this file" below I'm referring to the file you're
  136. reading, SOURCE.TXT, and not the file being described.
  137.  
  138.     OS2.ZIP - Files needed by anyone attempting to compile TOP for OS/2.
  139.  
  140.     BIORESP.TXT - A brief description of the BIO*.TOP data files.
  141.  
  142.     CMI.TXT - Some working notes for the Channel Management Interface.
  143.  
  144.     CONFIG.TXT - A largely outdated list of TOP configuration keywords.  It was
  145. left over from before TOP v2.00 and the final syntax doesn't even match in many
  146. cases.  There may be some ideas in here, though.
  147.  
  148.     EPI.TXT - Before I did any serious testing with External Commands (a la TOP
  149. v3.00wb1), I was worried they wouldn't work, so I had begun working on a
  150. scripting language for TOP add-ons called the EPI.  I don't even remember what
  151. EPI stood for, but I think it means External Program Interface.  It is mainly
  152. included as a curiousity.
  153.  
  154.     LNG_HELP.TXT - The beginnings of a detailed help file for the language
  155. items.  Obviously it's way incomplete.
  156.  
  157.     NEWCHAT.TXT - I had the wild idea of incorporating both a line-by-line
  158. style chat (as TOP is now) and a multi-window character-by-character (CBC) chat
  159. (like most Sysop Chat doors) into the same program so users could pick the way
  160. they liked best.  It was my way of competing against the CBC chat doors so
  161. sysops would use TOP no matter which style they liked.  Given enough time I
  162. would have implemented it, but it was a challenging task.  My
  163. design notes are in here, and are actually fairly complete, but of course I
  164. never got too far into any implementation.  Also see CHARCHAT.C.
  165.  
  166.     NEWFILES.TXT - A curiousity describing the renaming of TOP's data files.
  167.  
  168.     REVISION.TXT - My design diary.  This is a log of every change ever made to
  169. TOP, and is well worth reading for those interested in modifying the source.
  170. Here you'll read about idea, potential problems, alternate approaches, etc. as
  171. well as the feelings and emotions I experienced while working on TOP.
  172.  
  173.     BBSWC.C - An alpha version of Wildcat BBS support.  I never did get it to
  174. work and didn't get to spend much time testing it to find out why.
  175.  
  176.     CHARCHAT.C - A few functions that were to form the foundation of the CBC
  177. chat mode.  Mainly a curiousity.  See NEWCHAT.TXT.
  178.  
  179.     MAINT.C - Source for the TOP EDIT and TOP PACK commands.  This was
  180. superceded by the TOPMaint utility.  MAINT.C is actually required to build TOP
  181. without modifications, but it was always considered a quick hack and was not
  182. intended to be a part of RAP/TOP for as long as it was.  It should be easy
  183. enough to eliminate from the project with only minor code changes, and I
  184. recommend you do so.  Use TOPMaint instead.  I think even the 3.00wb1 version
  185. of TOPMaint will work with v2.01 if need be!
  186.  
  187.     SPAWN.C - The beginnings of what became ECP support in TOP v3.00wb1.
  188. Because of the importance of ECP support in TOP v3.00wb1, I've included a
  189. section later in this file that tells how to go about modifying SPAWN.C to
  190. achieve v3.00wb1-level ECP support.
  191.  
  192.     TOPACT.C - The TOP Action Compiler, which is of course a vital part of the
  193. TOP package but not required to actually recompile TOP.  Its source is not
  194. commented.  However, the compiler is very descriptive about what it is doing to
  195. the user so it should be easy to figure out the source from its output.
  196.  
  197.     GAMES.ZIP - The source code to three games that were, at one point, built
  198. into TOP:  Poker, Slots, and MatchGame.  All were eventually removed because
  199. of the amount of space they took up as well as because an external system for
  200. games was desired.  That system, of course, eventually became ECPs, but only
  201. Slots was ever converted.  There is a full section on the games (mainly poker)
  202. later in this file.
  203.  
  204.     TOPMAINT.ZIP - The source code for TOPMaint.  This should be unpacked to a
  205. separate directory.
  206.  
  207.     TOPLINK.ZIP - The source code for TOPLink.  This requires TurboPascal 7 to
  208. compile.
  209.  
  210.     BJ4TOP.ZIP - The source code for BJ4TOP.  Also requires TP 7.
  211.  
  212.     How to Compile TOP
  213.     ------------------
  214.  
  215.     This will briefly take you through the steps required to compile the DOS
  216. version of TOP.  It's assumed you've compiled many projects before and know the
  217. general routine.  If you haven't, don't ask me for help as I don't have the
  218. time to explain it.
  219.  
  220.     NOTE:  If you want to compile the Windows version you will have to modify
  221. all of the settings in the project (.IDE) file for the DOS version.  The files
  222. used are the same.  If you want to compile the OS/2 version with Borland C++
  223. for OS/2, it's possible to do something similar, but you're on your own!
  224.  
  225.     1) Unpack the entire distribution archive to its own directory.
  226.  
  227.     2) Obtain OpenDoors and (if desired) Fortify and install them per their own
  228. instructions.
  229.  
  230.     3) Run Borland C++ and load the TOP.IDE file.
  231.  
  232.     4) Check the settings for the Directories used by the project them.  Edit
  233. as needed to be sure they match the locations of the files where you put TOP.
  234.  
  235.     5) Similarly, check the source files for directories and change any you
  236. find.  I've tried to remove them all but may have missed some.
  237.  
  238.     6) If you don't have Fortify, do a GREP search for "fortify" in the source
  239. and remove any lines and conditional compilation sections that refer to it.
  240. Lastly, remove it from the project file.
  241.  
  242.     7) Hit F9 to compile.  Full build time on my PIII 500MHz was about 6
  243. seconds.  According to my revision log, it was around a minute on my old
  244. Pentium 133MHz and around 5 minutes on my even older 486DX/100.
  245.  
  246.     8) TOP will either compile, or give errors.  If you get errors, check your
  247. directories and the source files for the points mentioned above.  If you can't
  248. solve the problem, email me (see end of this file) and I'll try to help.
  249.  
  250.     9) If you didn't get errors, edit all of the configuration files (*.CFG)
  251. and then try to run TOP.  (You may be able to use TOP v3.00wb1 configuration
  252. files, but I don't recommend this.)  If it compiles but doesn't work, it is a
  253. configuration problem.  You need to get TOP properly configured before trying
  254. to modify it or you may spend time chasing bugs in the source that are actually
  255. simple misconfiguration problems.
  256.  
  257.     Making TOP Appear Registered
  258.     ----------------------------
  259.  
  260.     I removed as little of the registration system as possible because I didn't
  261. want to risk introducing any hidden problems that caused TOP to fail to work.
  262. So, the core of the system is intact, although of course the code verifiers
  263. have been removed.
  264.  
  265.     To make TOP appear as if you registered it, go to line 443 (or so) inside
  266. INIT.C, set registeredtop = RKVALID, and set the regname, regsystem, and
  267. regtype strings to whatever you want.  (I've never tested this but it should
  268. work.)
  269.  
  270.     However, I would appreciate it if, instead of trying to pass yourself off
  271. as a registered user, you simply remove all of the registration stuff and just
  272. let your version of TOP run without any indication that there was ever a
  273. registration system for it.  Unless, of course, you are in fact a registered
  274. user and have a key.  Your key won't work with any version compiled with this
  275. TOP source, so modifying the source is the only way to make TOP appear
  276. registered.
  277.  
  278.     Style Notes
  279.     -----------
  280.  
  281.     The coding style used in TOP is fairly consistent, however, there is one
  282. important thing to mention.  At some point during the development, I switched
  283. from this indentation style:
  284.  
  285. void myfunc(void)
  286.     {
  287.     int myvar;
  288.  
  289.     myvar = 555;
  290.  
  291.     }
  292.  
  293.     ...to this (more conventional) one:
  294.  
  295. void myfunc(void)
  296. {
  297.     int myvar;
  298.  
  299.     myvar = 555;
  300.  
  301. }
  302.  
  303.     Both styles appear throughout the source, so watch for it.  The different
  304. locations of the braces can be confusing if you start working on a section with
  305. one style after recently working on a section with the other.  It even confused
  306. me a few times, and I had to sort out a "missing }" error on more than one
  307. occaision.
  308.  
  309.     Also, for a large stretch of TOP's development period, I had the curious
  310. habit of prefixing local variables with a letter or two, usually the initials
  311. for the function itself.  I didn't really understand all of the things about
  312. scope in C, and became afraid that I may inadvertantly be affecting variables
  313. in other functions by naming them all the same.
  314.  
  315.     Finally there are the "stringarray" structs which were left over from very
  316. early in TOP's development, when I was still learning C.  I didn't know how to
  317. work string arrays, but I did know how to use arrays of structs, so I simply
  318. put a string in a struct and made an array of the structs.  Later on when I
  319. knew what I was doing it became very annoying to work with, having to put
  320. .string after things, but I never got around to reworking all of the areas
  321. where it was used.
  322.  
  323.     Building TOP/95 or TOP/2
  324.     ------------------------
  325.  
  326.     You can build TOP for Win32 (TOP/95) and TOP for OS/2 (TOP/2) from the same
  327. source as TOP for DOS (TOP/DOS).  I don't provide any support for those that
  328. try to do this, but I'll provide some tips to help you get it working:
  329.  
  330.     - First of all, it's recommended you get either the full TOP/95 v3.00wb1 or
  331. TOP/2 v2.00 package.  These packages have extra version-specific documentation
  332. that you will need to help get TOP running properly.  (Note that although there
  333. was no 2.00 version of TOP/95 available, v3.00wb1 is configured the same way as
  334. the version that will be built from the source you have.  Actually, I would
  335. have released a TOP/95 v2.00 but there was a stupid bug that kept it from
  336. working.  Unfortunately, because I didn't have Win95 when I released, I set the
  337. version aside until later, but the bug was so obvious that I could have seen it
  338. without Win95.  I just never looked!  See the end of REVISION.TXT for info.
  339. about the bug.  Anyhow, the bug IS FIXED in the source you have, so the Win95
  340. version should compile and work.)
  341.  
  342.     - For TOP/2, you need to obtain Doors/2 which is an authorized OS/2 port of
  343. OpenDoors by Joel Downer.  Like OpenDoors it has an unregistered version which
  344. can be obtained free of charge for trial purposes.  For TOP/95, you need
  345. OpenDoors v6.0 which is needed for TOP/DOS compilation anyhow.
  346.  
  347.     - All versions use the same source files, though the OS/2 version needs a
  348. few extra files (which are included).  We'll put that consideration aside for
  349. the moment, though.  I've only provided the DOS version of the project file,
  350. because the backups of the Win32 and OS/2 project files that I have are out of
  351. date.
  352.  
  353.     - For TOP/95, you can probably use Borland C++'s Project window to simply
  354. change the Target type of the existing project file.  It should be a Win32 GUI
  355. (_NOT_ CONSOLE) application.  For TOP/2, probably the best thing to do is to
  356. load the DOS project file, copy the list of all of the files, then make a new
  357. OS/2 project and add all of the files from the list.  If you do this, make sure
  358. to note the include and library directories from the original project as well,
  359. and be sure to change your new project file to include the equivalent
  360. directories for the OS/2 version.
  361.  
  362.     - For both projects, remove any references to the DOS OpenDoors libraries,
  363. then add the libraries required for the version you are making.
  364.  
  365.     - Be sure your compiler defines the __WIN32__ variable for TOP/95, or the
  366. __OS2__ variable for TOP/2.  The source uses these variables where conditional
  367. compilation is needed.  Borland C++ compilers should define these variables on
  368. their own.
  369.  
  370.     - That should be it for the Win95 version of TOP.  The OS/2 version needs
  371. some extra source files, though.  Unpack OS2.ZIP, then add CMDLINE.C,
  372. BBSMAXMC.C, and MCP32.LIB to the project file.  Be sure that you unpack to the
  373. same directory as the rest of the source because there are some header files
  374. that TOP will need.  (You don't need to change anything for the headers.  They
  375. will be included via conditional compilation directives.)  Once you add these
  376. files, you should be able to compile.
  377.  
  378.     Interlude
  379.     ---------
  380.  
  381.     The remainder of this file is dedicated to discussing certain sections of
  382. the TOP source itself.
  383.  
  384.     Comments
  385.     --------
  386.  
  387.     Comments enclosed in /* */ (C style) are used to document areas of TOP.
  388. These are the comments you will want to read.
  389.  
  390.     Comments following // (C++ style) are my own personal notes, and are used
  391. for "to-do's", bug notes, etc.  They are less crucial.  Borland C++ supports
  392. both style comments even for C, so I made no qualms about using them both.
  393.  
  394.     //| was used to comment out game-related code.  See the section on Games
  395. below.
  396.  
  397.     //! was used to denote sections that hadn't been converted to the language
  398. file system yet, and may still be lingering around in some places.
  399.  
  400.     XINT & XDATE
  401.     ------------
  402.  
  403.     For portability, I _ALWAYS_ used XINT and XDATE instead of int and struct
  404. date, respectively, and I recommend you do the same.  This convention was the
  405. result of a hasty conversion made when Doors/2 (the OS/2 port of OpenDoors) was
  406. released and I had the unexpected chance to compile an OS/2 version.
  407.  
  408.     Ideally I should have defined a bunch of types like byte and word and sbyte
  409. and stuff, but at the time I didn't know about how compilers worked out sizes
  410. of shorts and longs and stuff like that.  I just knew that OS/2 used 32-bit
  411. ints and that this would cause a problem with TOP/DOS's 16-bit ints when
  412. reading files, so I made the change and always stuck with it.
  413.  
  414.     XDATE is needed because TOP stores a few struct date's and they use the int
  415. keyword inside them, and thus would be a different size under OS/2 or Win32.
  416.  
  417.     Initialization & Main Loop
  418.     --------------------------
  419.  
  420.     TOP initializes by going through INIT.C, then proceding to USER.C where it
  421. checks if the user's name is found and loads all of the info.  Only after all
  422. of this does TOP end up back in MAIN.C where it finally begins executing
  423. main_loop(), which is an infinite loop that is only exited by a call to
  424. od_exit().
  425.  
  426.     The initialization is rather convoluted.  I seemed to like to use an
  427. "initialization-style-of-the-month" when implementing new features, so nearly
  428. everything is done differently.  Pay close attention to the comments for all
  429. initialization functions (which don't necessarily appear in INIT.C) so you know
  430. what's going on.
  431.  
  432.     Output
  433.     ------
  434.  
  435.     All output from TOP is done using the top_output() function, which is not
  436. unexpectedly housed in the file OUTPUT.C.  This is probably the most
  437. complicated module inside TOP.  The top_output() function itself is about 700
  438. lines long, plus almost 200 lines for support functions.  (process_messages()
  439. is longer but it is repetitive so it's not very complicated.)
  440.  
  441.     top_output() and its support functions provide many benefits:
  442.  
  443.     - Allowing output to be plain (via OpenDoors), emulated (i.e.
  444. ANSI/AVATAR/RIP/RA code translation, also via OpenDoors), sent to a string (either formatted or
  445. non-), or sent to the console (using plain C functions).
  446.     - Processing PubColour (^) codes.
  447.     - Processing language (@) codes.
  448.     - Word-wrap as the output is generated so it looks nice.
  449.  
  450.     top_output() is used everywhere in TOP, from normal output right through to
  451. logging.  About the only place a printf() function is used (usually sprintf())
  452. is for constructing filenames.
  453.  
  454.     top_output() works a lot like printf() in that it can take a variable
  455. number of parameters and uses a string to determine how many there are.  One
  456. important difference, though, is that all of the variable parameters MUST BE
  457. STRINGS.  top_output() can only handle strings so passing it anything else will
  458. generate some really strange results.  To use numbers, there is a global array
  459. of strings called outnum[] that can be used to hold the results of itoa() or
  460. ultoa() or fcvt() or other to-string conversions.  Simply store the results of
  461. a conversion in one of the outnum[] strings and then pass that string to
  462. top_output().
  463.  
  464.     top_output() is generally called with a language item as the string, that
  465. is:
  466.  
  467. top_output(OUT_SCREEN, getlang("MyLanguageItem"), myparamstring);
  468.  
  469.     It's important to keep track of how many parameters each language item has.
  470. The easiest way to do this is to build your default language items so as to use
  471. ALL of the parameters that they support.  For example, if you have three
  472. parameters, make sure to use @1, @2, and @3 in the default language item. Don't
  473. use just one or two, because this makes it easy forget the other parameter(s)
  474. exist(s).  And, obviously, don't try to use four because TOP won't know where
  475. to find the fourth parameter and will end up displaying garbage, possibly lots
  476. of it.
  477.  
  478.     Try to get into the habit of calling top_output() for everything.  It's
  479. very powerful, especially when combined with language items!
  480.  
  481.     DEBUG Mode
  482.     ----------
  483.  
  484.     DEBUG mode was hastily added to help me track the infamous random crashing
  485. bug that used to occur during startup in RAP 1.8x versions.  (RAP was TOP's
  486. original name.)
  487.  
  488.     DEBUG mode is enabled by running TOP with the word DEBUG following the node
  489. number.  This will open a debugging log (TOPDEBUG.LOG) and enable (or rather,
  490. not disable) Fortify.
  491.  
  492.     If you run into crashing problems, try DEBUG mode.  When you run TOP in
  493. debug mode, make sure to redirect stdout to a file (e.g. TOP 4 DEBUG >
  494. file.txt) so you can go back and look at any output from Fortify, as well as
  495. from a few TOP tests, later.  The code that you've been given does not cause
  496. Fortify to produce any output (no news is good news), at least not if TOP is
  497. configured properly.
  498.  
  499.     NOTE:  DEBUG mode often makes TOP _VERY_SLOW_ when starting up.  Be
  500. patient.  Once running, it should work at normal speed.  Cleanup on exit takes
  501. a bit longer than normal, but not much.
  502.  
  503.     From a source point of view, the DEBUG mode stuff is included in INIT.C.
  504. DEBUG mode is enabled by assigning the debuglog pointer to a file opened with
  505. fopen(), so it can also be done directly in the source, without using the DEBUG
  506. parameter.
  507.  
  508.     When debuglog is not NULL, the wdl() (which stands for "write debug log")
  509. function will log whatever messages it is passed.  This is what's written to
  510. TOPDEBUG.LOG.  wdl() is used throughout INIT.C and also in USER.C, but is not
  511. included in TOP.H so if you want to use it elsewhere you will need to make it
  512. visible to wherever you want to use it.
  513.  
  514.     In DEBUG mode, TOP also outputs a few things (like a memory check) to
  515. stdout using plain printf().  This is NOT RECOMMENDED, however, because it can
  516. cause OpenDoors to abort if it finds the text cursor is somewhere unexpected.
  517. I had meant to phase out all of these outputs but never got around to it.
  518.  
  519.     If you wish to remove DEBUG mode entirely, simply GREP search for
  520. "debuglog" and remove all relevant sections of code, and then remove the wdl()
  521. function and any calls to it.  Lastly, remove anything related to fortify as
  522. described in the compilation instructions above.
  523.  
  524.     wdl() and the debug log aren't really needed anymore.  However, I recommend
  525. keeping the Fortify part of DEBUG mode if you have Fortify (or can find it) as
  526. it is very handy, especially for a program like TOP which has a lot of pointers
  527. but was never really written with "safety" guidelines (e.g. initializing
  528. pointers to NULL) in mind.  I simply didn't know better at the time!
  529.  
  530.     Poker & Other Games
  531.     -------------------
  532.  
  533.     At one point during the development cycle I had planned to include some
  534. games with TOP, and had gone so far as to write them and integrate them into
  535. TOP.  They were eventually disabled in favour of looking for a way to make them
  536. external to TOP.  However, I still have the source, so I've included it in case
  537. anybody wants to try to get them working.
  538.  
  539.     The most well-known game is Slots, because it was eventually converted to
  540. an ECP to work with TOP v3.00wb1.  However, the biggest and, may I say, most
  541. impressive game was Poker.  As such, I'll be discussing Poker for most of this
  542. section, though near the end I'll give a little information on how to get Slots
  543. and a third TOP game, MatchGame, working as well.  I'll conclude with some
  544. information pertinent to ALL of the games.
  545.  
  546.     Poker was, like most of TOP, based on an add-on to the Major BBS.  It
  547. allowed players in a channel to play traditional 5-card draw poker.  The game
  548. and its commands were all built into TOP.  Ultimately, Poker made TOP rather
  549. bulky, because it needed 9 different source modules, a ton of language file
  550. items, and several extra configuration options.  So that's why it was removed.
  551. Keep this in mind, because it means a lot of work for anybody who wants to try
  552. to get it working!
  553.  
  554.     The good news is that in the source you have, almost all of the Poker
  555. support was not removed, but simply commented out.  Thus most of the work is
  556. done for you.  However, I'm pretty sure there were one or to things that were
  557. removed, so you may need to do some tweaking.  That's what the rest of this
  558. section focuses on.
  559.  
  560.     I didn't go to the trouble of reintegrating Poker myself, but I'll describe
  561. all of the modules and try to orient you with what's supposed to happen, so
  562. that you can find any missing pieces and fill them back in.
  563.  
  564.     Before I go on, I need to mention a few more things.  First of all, Poker
  565. is not completely stable.  There are occaisional problems with missing messages
  566. which can cause problems.  Secondly, there are actually two versions of Poker
  567. included in the source package.  "Old Poker" was the first version, and is
  568. somewhat more stable.  It's included in its own archive, OLDPOKER.ZIP, which is
  569. inside GAMES.ZIP.  However, it's not nearly as flexible, and more importantly,
  570. nearly everything in the TOP source that supports it has been removed.  You're
  571. on your own if you want to try to use it.
  572.  
  573.     These instructions focus on "New Poker", which is made up of 9 different
  574. modules.  Here is a description of each of the modules:
  575.  
  576.     POKER.C     This is the command processor for Poker commands.  It's only
  577.                 called when a Poker command is issued, so it should be easy to
  578.                 integrate in and of itself.
  579.  
  580.     POKERCOR.C  The "core" of Poker is its message processor.  This is called
  581.                 from PROCMSGS.C when a MSG_POKER is received.  MSG_POKER isn't
  582.                 in TOP.H but it's easy enough to add because the actual number
  583.                 of any TOP message doesn't matter.
  584.  
  585.     POKEREVT.C  The Poker event kernel, which is called from the main loop
  586.                 when the poker poll time is exceeded.  It performs
  587.                 time-sensitive functions.
  588.  
  589.     POKERNAM.C  A simple module that contains functions to get the name of a
  590.                 hand, e.g. "Two Pair" or "Full House".
  591.  
  592.     POKERSCO.C  Contains functions for scoring the hands and finding the
  593.                 winner of a hand.
  594.  
  595.     POKERSYS.C  Various basic ("system") functions, like displaying the hand
  596.                 and finding players.
  597.  
  598.     POKERTRN.C  Functions for tracking whose turn it is.
  599.  
  600.     POKER_IO.C  Functions for working with the poker data file (POKERDAT.TOP)
  601.                 and for communicating with other nodes.
  602.  
  603.     TOPPOKER.H  The header file that includes definitions needed for Poker.
  604.  
  605.     Here's a general idea of how Poker works.  This is all from memory, and
  606. keep in mind I haven't worked with TOP Poker in over 5 years so it probably
  607. isn't 100% accurate.
  608.  
  609.     1) One player starts a game.  The player's node creates a record in
  610. POKERDAT.TOP.
  611.  
  612.     2) Other players can join the game.  Each player's node adds a mention in
  613. POKERDAT.TOP.
  614.  
  615.     3) Eventually, the poker kernel will determine enough time has past and try
  616. to start the game.  If there are at least two players this will happen,
  617. otherwise the kernel will tell the player who started the game that it's not
  618. full enough.
  619.  
  620.     4) The Poker kernel works by having EACH NODE do its own checks based on an
  621. event time that's stored in POKERDAT.TOP.  This means that when it's time to
  622. start a game, each node will notice this and take action.  It's each node's
  623. responsibility to deduct the CyberCash and deal the hand.  The latter is done
  624. by maintaining a list of flags for each card, so two nodes can't have the same
  625. cards.
  626.  
  627.     5) While starting the game, the turn is advanced (by each node).  During
  628. this process, the node whose player has the first turn will notify the player
  629. that it's time for a bet.
  630.  
  631.     6) Any node can try to bet at any time, but its each nodes responsibility
  632. to check that this attempt is denied unless it's the node's turn to bet.  Nodes
  633. can fold or even quit the game entirely at any time, however.  This is done via
  634. direct access to POKERDAT.TOP.
  635.  
  636.     7) As I left it, Poker DOES NOT check if a node bets within the allowed
  637. time.  This is important functionality that should be added to POKEREVT.C if
  638. you want to use Poker on your BBS.  At the very least, a node should remove
  639. itself (from the game entirely) after a reasonable time has passed while it's
  640. the node's turn to bet.
  641.  
  642.     8) After betting, the turn is advanced and other nodes bet.  Once the
  643. betting has disintegrated according to game rules, the discard stage is
  644. performed in exactly the same way as betting.  A final round of betting
  645. follows.
  646.  
  647.     9) One the final betting is done, the last node sends a "GameOver" message
  648. to all other nodes.  Each node is then responsible for checking in with its
  649. hand and a checksum.  The last node to check in will detect that it's the last
  650. and then send the others a "Finished" message (which is actually done at the
  651. end of PROCMSGS.C because a node can't send a message while it is processing
  652. incoming messages), which will cause each node to display the results.
  653.  
  654.     10) Each node resets itself and we go back to the joining stage (step 2).
  655.  
  656.     Now that you've read this, you should read my original notes in
  657. NEWPOKER.TXT which is included in the GAMES.ZIP archive.  It describes all of
  658. the commands and operations.  Unfortunately, I described them somewhat in terms
  659. of Old Poker.  Nevertheless, after reading you should have a fairly good idea
  660. of how New Poker is supposed to work.
  661.  
  662.     I suggest you uncomment all of the //| lines (and /*//| sections) that
  663. pertain to Poker in TOP.H and the source files, insert all Poker modules into
  664. the project, and try to compile.  This may be all that's required, but I can't
  665. remember if I took anything out or not.  If I did, it was probably something
  666. minor that can easily be replaced.  To test Poker you'll need to be able to run
  667. two nodes of TOP. Local nodes will work fine, or you can borrow two nodes from
  668. your BBS.  Log into both with different accounts and try to play a game with
  669. yourself.  If you can do and things seem normal (i.e. games start, turns
  670. progress, discards work, and the player that wins is the one who's supposed to
  671. win) then you've succeeded!
  672.  
  673.     If you get it to work, I suggest you run through all of the // comments in
  674. the poker modules.  Most of them describe stuff that was to be added in.
  675. You'll need to add in any critical functionality if you want to let your users
  676. play.  New Poker was still in its infancy when I removed it so many key details
  677. were missing, such as the fact that the bet expiry time isn't enforced as
  678. mentioned earlier (step 7).
  679.  
  680.     I can provide LIMITED support for New Poker, but I'm not going to go to too
  681. much trouble to try and help somebody.  As I said, I won't support Old Poker.
  682.  
  683.     BTW, if you're wondering, Old Poker worked by relying on the lowest node in
  684. TOP to do most of the work.  This made it more stable because it had a central
  685. manager, but the "handoff" from one lowest node to another could sometimes be a
  686. problem, and also Old Poker didn't allow multiple games which is something I
  687. had hoped would become an integral part of New Poker.  Try it at your own risk.
  688.  
  689.     Lastly, on to the rest of the games.  The other two games are MUCH simpler
  690. and simply respond to commands.  There's no need for any timing or
  691. coordination with other nodes.  As such, each game is only one module and only
  692. requires a command processor and a bit of initialization code.  You should just
  693. be able to uncomment the //| lines relevant to each game, add the module to the
  694. project, and recompile with no trouble.
  695.  
  696.     Slots is the ancestor of the slot machine ECP that TOP v3.00wb1 users are
  697. familiar with. However, the version that was built into TOP had more
  698. functionality.  You could change the bet and even perform multiple "pulls of
  699. the handle" at a time to allow for quicker play.
  700.  
  701.     MatchGame is a simple and, I have to say, rather lame game that works kind
  702. of like a scratch-and-win lottery ticket.  You pick three squares of 20 and
  703. hope that the prizes behind each are the same.  If so, you win the prize!  It
  704. was written one day when I was really really bored and I didn't give it much
  705. attention.  It was also the last game added to TOP so it isn't very complete.
  706. The stats weren't finished.
  707.  
  708.     Okay, lastly some info. common to all games.
  709.  
  710.     You'll need to add the required items to your language file to use the
  711. games.  There's a file, GAMES.LNG, in the archive which should be APPENDED to
  712. your language file.  It may not be complete, so watch for areas where nothing
  713. is displayed as it means the language items may be missing.
  714.  
  715.     Also, some of the games had configuration options which WERE REMOVED from
  716. TOP.  Scan the game modules for references to "cfg.".  You'll need to add any
  717. variables that have cfg. in front of them to TOPCFG.H.  If you want, you can
  718. add support for them in CFG.C, but you can also just hard code the values by
  719. hand at the end of the init() function.
  720.  
  721.     SPAWN.C (ECP Support)
  722.     ---------------------
  723.  
  724.     SPAWN.C has the beginnings of what became ECP support inside TOP v3.00wb1.
  725. It is incomplete, but I'll tell you what needs to be finished in case you want
  726. to try to get it working.  Please also see the next section that talks about
  727. general concerns related to bringing this source up to par with v3.00wb1.
  728.  
  729.     I'll assume for this section that you have TOP v3.00wb1 as well as a copy
  730. of the TOP v3.00wb1 ECPDK, and are familiar with how ECPs work.
  731.  
  732.     The SPAWN.CFG configuration file loader, load_spawn_progs(), will read
  733. SPAWN.CFG files from TOP v3.00wb1 WITH ONE IMPORTANT EXCEPTION:  IT DOES NOT
  734. SUPPORT COMMENTS!  This was added later.  You've got two options here:  a)
  735. modify the loader to read comments, or b) remove all comments from a SPAWN.CFG
  736. file that you want to use.  Also, you need to uncomment the line in INIT.C that
  737. calls the configuration loader.
  738.  
  739.     The command processor, check_spawn_cmds(), is largely complete, but it
  740. needs to have support for the rest of the * tokens that are described in a TOP
  741. v3.00wb1 SPAWN.CFG as well as in ECPDK.DOC.  Most of these will be very easy to
  742. do.  The only problems are *M and *! which need to set OpenDoors variables to
  743. work, and */ which needs, at the very least, a one second delay.  (When I
  744. implemented */ in TOP v3.00wb1 I did so by storing the result of a time() call,
  745. then waiting until the result of a subsequent call changed, so that the delay
  746. was only as long as needed, but of course you don't need to go to this
  747. trouble.)
  748.  
  749.     The major thing that's missing from SPAWN.C is the TOP Spawn File (TSP)
  750. processor.  Luckily, it's just a simple text file processor, and the TSP files
  751. are documented very well in ECPDK.DOC so it should be very easy to build one
  752. yourself!
  753.  
  754.     You may also wish to add support for the Swap... group of configuration
  755. keywords that TOP v3.00wb1 features.  These shouldn't be too hard to support.
  756. See TOP.CFG from TOP v3.00wb1 for more details.
  757.  
  758.     Rebuilding TOP v3.00wb1
  759.     -----------------------
  760.  
  761.     For those that are interested in using the TOP source but also having some
  762. of the TOP v3.00wb1 features, you will of course have to rewrite these
  763. features.  If you are planning to rewrite a TOP v3.00wb1 feature and are
  764. willing to distribute your changes, PLEASE LET ME KNOW!  I will post this
  765. information to the TOP web site so that others don't waste time trying to
  766. rewrite the same feature.  Contact information is at the end of this file.
  767.  
  768.     First of all, anybody planning to add a TOP v3.00wb1 feature should obtain
  769. the TOP v3.00wb1 ECPDK.  This kit contains an extremely valuable file:  TOP.H
  770. from v3.00wb1!  It's the only surviving remnant of the v3.00wb1 source.  It's
  771. not complete because the function prototypes and global variable declarations
  772. were split off into another file, but it has all of the data structures and
  773. thus should provide some important clues.
  774.  
  775.     Next, make sure you get TOP v3.00wb1 itself, because the WHATSNEW.DOC file
  776. included with it has details of all of the changes made since v2.00 (i.e. this
  777. source).  Though these details have been generalized and "dumbed down" a fair
  778. bit, they will still be useful in reconstructing any feature.  In addition, you
  779. of course have TOP v3.00wb1 itself which will show you how all of the features
  780. are supposed to behave.  Remember, the program itself isn't the only useful
  781. source of information!  You also have configuration files and language file
  782. additions to go on.
  783.  
  784.     I will be more than happy to provide tips and advice to anybody
  785. implementing TOP v3.00wb1 features, as long as they are willing to release
  786. their additions.  I only have my memory to rely upon here, but I will help with
  787. what I can.
  788.  
  789.     Contacting the Author
  790.     ---------------------
  791.  
  792.     The author of TOP, Paul Sidorsky, can be reached at <ismware@home.com>.
  793. Email is the only way to reach me.  I don't use ICQ and have no access to a
  794. FidoNet BBS.  Please don't try to find my phone number and call me, either.
  795. (More than one person has done that in the past!)  If you happen to find and
  796. use one of my other email addresses, that's okay, but I may miss your message
  797. as I have lots of other email coming to my personal addresses.  Please use
  798. ismware@home.com to be sure I get your question.  Also, keep in mind that I'm
  799. very busy attending university most of the year, so it may take me up to two
  800. weeks to respond!  However, I do promise to respond to all legitimate questions
  801. regarding the TOP source.
  802.  
  803.     Before you contact me, please check the TOP web site.  This is where I'm
  804. consolidating my support for TOP, including the TOP source.  You may find
  805. answers to your questions on the site.  You may even find modified versions of
  806. the source there that already implement some of the things discussed in this
  807. file!  The TOP web site is at:
  808.  
  809. http://members.home.net/ismware/top/
  810.  
  811.     Good luck with the source!
  812.  
  813.