home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3224 / patch01 < prev    next >
Encoding:
Text File  |  1991-04-21  |  17.7 KB  |  552 lines

  1. This says there should be a patchlevel.h file containing a 0; it should
  2. unpack with the shar containing this patch.  It will be updated to be
  3. patchlevel 1 by this patch.  Kent.
  4.  
  5. Prereq: 0
  6.  
  7. *** patchlevel.h.old    Sat Apr 20 00:24:56 1991
  8. --- patchlevel.h    Sat Apr 20 00:25:47 1991
  9. ***************
  10. *** 1 ****
  11. ! #define patchlevel 0
  12. --- 1 ----
  13. ! #define patchlevel 1
  14. *** README.old    Fri Apr 19 23:48:02 1991
  15. --- README    Sat Apr 20 00:19:09 1991
  16. ***************
  17. *** 1,4 ****
  18. ! Townmaze -- A Program to Design "Bard's Tale I"-Style City Mazes
  19.   
  20.   Copyright 1991 by Kent Paul Dolan, Mountain View, CA, USA 94039-0755
  21.   
  22. --- 1,4 ----
  23. ! Townmaze v1.1 -- A Program to Design "Bard's Tale I"-Style City Mazes
  24.   
  25.   Copyright 1991 by Kent Paul Dolan, Mountain View, CA, USA 94039-0755
  26.   
  27. ***************
  28. *** 71,76 ****
  29. --- 71,81 ----
  30.   display.  You may also want to read the townuser.doc and townpgmr.doc
  31.   files for more information about the program for users and programmers
  32.   respectively.
  33. + File CHANGES documents the running changes from release to release, and
  34. + file townmaze.test will do a complete test of the user interface code;
  35. + when you see how big script townmaze.test is, you'll know why providing
  36. + a script was a friendly gesture.
  37.   
  38.   Any non-commercial use of this code is permitted, in whole or in part;
  39.   credit to the author is requested but not demanded. Commercial use may
  40. *** getargs.c.old    Fri Apr 19 18:13:35 1991
  41. --- getargs.c    Fri Apr 19 22:18:55 1991
  42. ***************
  43. *** 21,28 ****
  44. --- 21,59 ----
  45.     char *argv[];
  46.   #endif
  47.   {
  48. +   int scantemp;
  49.     int i;
  50.   
  51. + /*
  52. + ** The next two data items and the code at the bottom to use them are
  53. + ** adapted, and mostly stolen wholesale and reformatted, from suggestions
  54. + ** submitted by "GLENN E. HOST" <host@ccf4.nrl.navy.mil> along with a
  55. + ** very prompt bug report.  Besides, his changes made me go back and look
  56. + ** harder at this interface; I hope this error reporting is more useful.
  57. + ** Thanks, Glenn!
  58. + */
  59. +   int errctr;
  60. +   static char *quit_messages[] =
  61. +   {
  62. +     " (-h): Maze height must be 11 or greater",
  63. +     " (-h): Maze height must be an odd number",
  64. +     " (-w): Maze width must be 11 or greater",
  65. +     " (-w): Maze width must be an odd number",
  66. +     " (-g): Maze gates must be a non-negative number",
  67. +     " (-g): Too many maze gates to fit",
  68. +     " (-l): Gates left must be a non-negative number",
  69. +     "s: Gates left (-l) must be no greater than gates at start (-g)",
  70. +     " (-c): Maze courts must be a non-negative number",
  71. +     " (-c): Too many maze courts to fit",
  72. +     "s: At least one court (-c) or one gate (-g) must exist",
  73. +     " (-u): Maze unused must be a non-negative number",
  74. +     " (-u): Too many unused cells to fit",
  75. +     " (-s): Straightness must be a non-negative number",
  76. +     " (-s): Straightness must be less than 999"
  77. +   };
  78.   #if PROGRESS
  79.     fprintf(stderr,"Get arguments ");
  80.   #endif
  81. ***************
  82. *** 31,36 ****
  83. --- 62,68 ----
  84.     {
  85.       if ((argc%2) != 1)
  86.       {
  87. +       fprintf(stderr,"\n*** Parameters must come in flag/value pairs\n\n");
  88.         usage();
  89.         exit(1);
  90.       }
  91. ***************
  92. *** 39,44 ****
  93. --- 71,79 ----
  94.       {
  95.         if ((*argv[i]) != '-')
  96.         {
  97. +         fprintf(stderr,
  98. +           "\n*** Expected flag, didn't see '-' for argument %d\n\n",i);
  99. +    
  100.           usage();
  101.           exit(1);
  102.         }
  103. ***************
  104. *** 45,52 ****
  105.         switch (*(argv[i]+1))
  106.         {
  107.         case 'h':
  108. !         if (sscanf(argv[i+1],"%d",&mazeheight) == EOF)
  109.           {
  110.             usage();
  111.             exit(1);
  112.           }
  113. --- 80,89 ----
  114.         switch (*(argv[i]+1))
  115.         {
  116.         case 'h':
  117. !         if (   ((scantemp = sscanf(argv[i+1],"%d",&mazeheight)) == EOF)
  118. !             || (scantemp == 0))
  119.           {
  120. +           fprintf(stderr,"\n*** Unable to read value after '-h'\n\n");
  121.             usage();
  122.             exit(1);
  123.           }
  124. ***************
  125. *** 53,112 ****
  126.           break;
  127.   
  128.         case 'w':
  129. !         if (sscanf(argv[i+1],"%d",&mazewidth) == EOF)
  130.           {
  131.             usage();
  132.             exit(1);
  133.           }
  134.           break;
  135.   
  136. !       case 'r':
  137. !         if (sscanf(argv[i+1],"%ld",&randomseed) == EOF)
  138.           {
  139.             usage();
  140.             exit(1);
  141.           }
  142. -         SEEDRANDOM(randomseed); /* override clock seed in main() */
  143.           break;
  144.   
  145. !       case 'g':
  146. !         if (sscanf(argv[i+1],"%d",&mazegates) == EOF)
  147.           {
  148.             usage();
  149.             exit(1);
  150.           }
  151.           break;
  152.   
  153. !       case 'l':
  154. !         if (sscanf(argv[i+1],"%d",&leftgates) == EOF)
  155.           {
  156.             usage();
  157.             exit(1);
  158.           }
  159.           break;
  160.   
  161. !       case 'c':
  162. !         if (sscanf(argv[i+1],"%d",&mazecourts) == EOF)
  163.           {
  164.             usage();
  165.             exit(1);
  166.           }
  167.           break;
  168.   
  169. !       case 'u':
  170. !         if (sscanf(argv[i+1],"%d",&mazeunused) == EOF)
  171.           {
  172.             usage();
  173.             exit(1);
  174.           }
  175.           break;
  176.   
  177. !       case 's':
  178. !         if (sscanf(argv[i+1],"%d",&mazestraightness) == EOF)
  179.           {
  180.             usage();
  181.             exit(1);
  182.           }
  183.           break;
  184.   
  185.         default:
  186. --- 90,163 ----
  187.           break;
  188.   
  189.         case 'w':
  190. !         if (   ((scantemp = sscanf(argv[i+1],"%d",&mazewidth)) == EOF)
  191. !             || (scantemp == 0))
  192.           {
  193. +           fprintf(stderr,"\n*** Unable to read value after '-w'\n\n");
  194.             usage();
  195.             exit(1);
  196.           }
  197.           break;
  198.   
  199. !       case 'g':
  200. !         if (   ((scantemp = sscanf(argv[i+1],"%d",&mazegates)) == EOF)
  201. !             || (scantemp == 0))
  202.           {
  203. +           fprintf(stderr,"\n*** Unable to read value after '-g'\n\n");
  204.             usage();
  205.             exit(1);
  206.           }
  207.           break;
  208.   
  209. !       case 'l':
  210. !         if (   ((scantemp = sscanf(argv[i+1],"%d",&leftgates)) == EOF)
  211. !             || (scantemp == 0))
  212.           {
  213. +           fprintf(stderr,"\n*** Unable to read value after '-l'\n\n");
  214.             usage();
  215.             exit(1);
  216.           }
  217.           break;
  218.   
  219. !       case 'c':
  220. !         if (   ((scantemp = sscanf(argv[i+1],"%d",&mazecourts)) == EOF)
  221. !             || (scantemp == 0))
  222.           {
  223. +           fprintf(stderr,"\n*** Unable to read value after '-c'\n\n");
  224.             usage();
  225.             exit(1);
  226.           }
  227.           break;
  228.   
  229. !       case 'u':
  230. !         if (   ((scantemp = sscanf(argv[i+1],"%d",&mazeunused)) == EOF)
  231. !             || (scantemp == 0))
  232.           {
  233. +           fprintf(stderr,"\n*** Unable to read value after '-u'\n\n");
  234.             usage();
  235.             exit(1);
  236.           }
  237.           break;
  238.   
  239. !       case 's':
  240. !         if (   ((scantemp = sscanf(argv[i+1],"%d",&mazestraightness)) == EOF)
  241. !             || (scantemp == 0))
  242.           {
  243. +           fprintf(stderr,"\n*** Unable to read value after '-s'\n\n");
  244.             usage();
  245.             exit(1);
  246.           }
  247.           break;
  248.   
  249. !       case 'r':
  250. !         if (   ((scantemp = sscanf(argv[i+1],"%ld",&randomseed)) == EOF)
  251. !             || (scantemp == 0))
  252.           {
  253. +           fprintf(stderr,"\n*** Unable to read value after '-r'\n\n");
  254.             usage();
  255.             exit(1);
  256.           }
  257. +         SEEDRANDOM(randomseed); /* override clock seed in main() */
  258.           break;
  259.   
  260.         default:
  261. ***************
  262. *** 116,137 ****
  263.         i += 2;
  264.       }
  265.     }
  266. !   if (   ((mazewidth%2) != 1)
  267. !       || ((mazeheight%2) != 1)
  268. !       || (mazewidth < 11)
  269. !       || (mazeheight < 11)
  270. !       || (mazegates < 0)
  271. !       || (mazegates > (2*((mazeheight - 6)/7) + 2*((mazewidth- 6)/7)))
  272. !       || (leftgates < 0)
  273. !       || (leftgates > mazegates)
  274. !       || (mazecourts < 0)
  275. !       || (mazecourts > (((mazeheight - 5)/6)*((mazewidth - 5)/6)))
  276. !       || ((mazecourts + mazegates) < 1)
  277. !       || (mazeunused > (((mazeheight - 1)/14)*((mazewidth - 1)/14)))
  278. !       || (mazestraightness < 0)
  279. !       || (mazestraightness > 998)
  280.        )
  281.     {
  282.       usage();
  283.       exit(1);
  284.     }
  285. --- 167,204 ----
  286.         i += 2;
  287.       }
  288.     }
  289. ! /*
  290. ! ** Thanks to "GLENN E. HOST" <host@ccf4.nrl.navy.mil> for the idea, and
  291. ! ** most of the new code here, to dump out the reason a command line
  292. ! ** failed when it does. The functionality was pretty obviously needed
  293. ! ** with this many parameters and ways to fail.  Don't blame Glenn for the
  294. ! ** way the code looks now, it's back in what he called my "interesting
  295. ! ** coding style".
  296. ! */
  297. !   if (   (errctr=0, mazeheight < 11)
  298. !       || (errctr++, (mazeheight%2) != 1)
  299. !       || (errctr++, mazewidth < 11)
  300. !       || (errctr++, (mazewidth%2) != 1)
  301. !       || (errctr++, mazegates < 0)
  302. !       || (errctr++, mazegates > (  2*((mazeheight - 5)/6)
  303. !                                  + 2*((mazewidth - 5)/6)))
  304. !       || (errctr++, leftgates < 0)
  305. !       || (errctr++, leftgates > mazegates)
  306. !       || (errctr++, mazecourts < 0)
  307. !       || (errctr++, mazecourts > (((mazeheight - 5)/6)*((mazewidth - 5)/6)))
  308. !       || (errctr++, (mazecourts + mazegates) < 1)
  309. !       || (errctr++, mazeunused < 0)
  310. !       || (errctr++, mazeunused > (((mazeheight - 5)/14)*((mazewidth - 5)/14)))
  311. !       || (errctr++, mazestraightness < 0)
  312. !       || (errctr++, mazestraightness > 998)
  313.        )
  314.     {
  315. +     fprintf(stderr,"\n*** Bad argument%s. You said:\n\n",
  316. +                    quit_messages[errctr]);
  317. +     fprintf(stderr,"ht %d wd %d gates %d left %d courts %d",
  318. +                     mazeheight,mazewidth,mazegates,leftgates,mazecourts);
  319. +     fprintf(stderr," unused %d straight %d seed %ld\n\n",
  320. +                    mazeunused, mazestraightness,randomseed);
  321.       usage();
  322.       exit(1);
  323.     }
  324. *** makespace.c.old    Fri Apr 19 18:12:19 1991
  325. --- makespace.c    Fri Apr 19 18:21:11 1991
  326. ***************
  327. *** 41,47 ****
  328.       exit(1);
  329.     }
  330.   
  331. !   for (i = 0; i < mazewidth; i++)
  332.     {
  333.       if ((cmaze[i] = (char *)malloc(mazewidth * sizeof(char))) == NULL)
  334.       {
  335. --- 41,53 ----
  336.       exit(1);
  337.     }
  338.   
  339. ! /*
  340. ! ** Thanks to  "GLENN E. HOST" <host@ccf4.nrl.navy.mil> for spotting a bug
  341. ! ** here that should have killed something during testing; I had mazewidth
  342. ! ** for mazeheight in the loop limit here.
  343. ! */
  344. !   for (i = 0; i < mazeheight; i++)
  345.     {
  346.       if ((cmaze[i] = (char *)malloc(mazewidth * sizeof(char))) == NULL)
  347.       {
  348. *** makestreet.c.old    Fri Apr 19 22:48:48 1991
  349. --- makestreet.c    Fri Apr 19 22:54:42 1991
  350. ***************
  351. *** 211,218 ****
  352.   /*
  353.   ** Only let an isolated cell become live if it is interior; stops
  354.   ** streets from running along the city wall, creating lots of gates.
  355.   */
  356. !       if (interiorcell(nhbris(chosencell,nhbrid)))
  357.           for (nextnhbrid = 0; nextnhbrid < 4; nextnhbrid++)
  358.             if (nhbrexists(nhbris(chosencell,nhbrid),nextnhbrid))
  359.               if (statlist[nhbris(nhbris(chosencell,nhbrid),nextnhbrid)].status
  360. --- 211,225 ----
  361.   /*
  362.   ** Only let an isolated cell become live if it is interior; stops
  363.   ** streets from running along the city wall, creating lots of gates.
  364. + ** Don't make it live if it is next to an unused cell, either, since
  365. + ** it can never become a street cell.
  366.   */
  367. !       if (   interiorcell(nhbris(chosencell,nhbrid))
  368. !           && (statlist[nhbris(nhbris(chosencell,nhbrid),0)].status != UNUSED)
  369. !           && (statlist[nhbris(nhbris(chosencell,nhbrid),1)].status != UNUSED)
  370. !           && (statlist[nhbris(nhbris(chosencell,nhbrid),2)].status != UNUSED)
  371. !           && (statlist[nhbris(nhbris(chosencell,nhbrid),3)].status != UNUSED)
  372. !          )
  373.           for (nextnhbrid = 0; nextnhbrid < 4; nextnhbrid++)
  374.             if (nhbrexists(nhbris(chosencell,nhbrid),nextnhbrid))
  375.               if (statlist[nhbris(nhbris(chosencell,nhbrid),nextnhbrid)].status
  376. *** townpgmr.doc.old    Fri Apr 19 22:55:34 1991
  377. --- townpgmr.doc    Sat Apr 20 00:16:48 1991
  378. ***************
  379. *** 1,4 ****
  380. ! File townpgmr.doc, the programmers' documentation for townmaze.
  381.   
  382.   
  383.   This file documents the C code; see file README for compile and
  384. --- 1,4 ----
  385. ! File townpgmr.doc, the programmers' documentation for townmaze Release 1.1.
  386.   
  387.   
  388.   This file documents the C code; see file README for compile and
  389. ***************
  390. *** 387,393 ****
  391.   
  392.   
  393.   -----------------------------------------------------------------------
  394. ! | getargs.c
  395.   -----------------------------------------------------------------------
  396.   
  397.   This routine accomplishes step 1) above.  Sigh again.  Lattice C for
  398. --- 387,393 ----
  399.   
  400.   
  401.   -----------------------------------------------------------------------
  402. ! | getargs.c -- getargs(argc,argv)
  403.   -----------------------------------------------------------------------
  404.   
  405.   This routine accomplishes step 1) above.  Sigh again.  Lattice C for
  406. ***************
  407. *** 416,422 ****
  408.   The check below the switch is about half of the sanity in the whole
  409.   program:
  410.   
  411. ! ((mazewidth%2) != 1) -- The maze width must be odd.
  412.   
  413.   ((mazeheight%2) != 1) -- The maze height must be odd.
  414.   
  415. --- 416,423 ----
  416.   The check below the switch is about half of the sanity in the whole
  417.   program:
  418.   
  419. ! (mazeheight < 11) -- The maze must be at least five cells wide to
  420. ! leave room for one interior row of buildings. 
  421.   
  422.   ((mazeheight%2) != 1) -- The maze height must be odd.
  423.   
  424. ***************
  425. *** 423,431 ****
  426.   (mazewidth < 11) -- The maze must be at least five cells high to leave
  427.   room for one interior row of buildings. 
  428.   
  429. ! (mazeheight < 11) -- The maze must be at least five cells wide to
  430. ! leave room for one interior row of buildings. 
  431.   
  432.   (mazegates < 0) -- There must be at least zero gates.
  433.   
  434.   (mazegates > (2*((mazeheight - 6)/7) + 2*((mazewidth- 6)/7))) -- There
  435. --- 424,435 ----
  436.   (mazewidth < 11) -- The maze must be at least five cells high to leave
  437.   room for one interior row of buildings. 
  438.   
  439. ! ((mazewidth%2) != 1) -- The maze width must be odd.
  440.   
  441. + The above four checks are order sensitive in the error messages they
  442. + produce, because C (at least the ones I have here) implements modulus
  443. + of a negative number wrong, so that ((-1)%2 != 1) comes out true.
  444.   (mazegates < 0) -- There must be at least zero gates.
  445.   
  446.   (mazegates > (2*((mazeheight - 6)/7) + 2*((mazewidth- 6)/7))) -- There
  447. ***************
  448. *** 445,450 ****
  449. --- 449,456 ----
  450.   
  451.   ((mazecourts + mazegates) < 1) -- There must be at least one street.
  452.   
  453. + (mazeunused < 0) -- There must be at least zero unused cells.
  454.   (mazeunused > (((mazeheight - 1)/14)*((mazewidth - 1)/14))) -- Unused
  455.   cells must have room for at least three squares between them,
  456.   otherwise they can trap DEAD cells away from streets and won't fit when
  457. ***************
  458. *** 458,463 ****
  459. --- 464,478 ----
  460.   occur. 999 is the highest value returned by the random roll modded
  461.   against 1000, so 998 is the largest accpetable straightness parameter. 
  462.   
  463. + The above checks now bump an error counter, and if the sanity check
  464. + drops out for any reason, an appropriate message telling which parameter
  465. + was wrong, and why, is printed. Since the values read in OK, but were
  466. + just inappropriate, the header line optional below to stdout is forced
  467. + here to stderr to show the user what the program thinks s/he said.
  468. + Similar error reporting is now in the switch statement cases for
  469. + unreadable parameters.
  470.   If all the parameters are right, the listsize (number of cell
  471.   structures in statlist) is computed from the requested maze width and
  472.   height. If the HEADER option is on (I always use it) a single line of
  473. ***************
  474. *** 465,470 ****
  475. --- 480,487 ----
  476.   [All other output goes to the standard error unit.]
  477.   
  478.   
  479.   -----------------------------------------------------------------------
  480.   | interiorcell.c -- interiorcell(cellid)
  481.   -----------------------------------------------------------------------
  482. ***************
  483. *** 598,604 ****
  484.   enough to see that it was the last big logic bug in the program.  If
  485.   the neighbor is ISOLATED, it becomes LIVE or DEAD, as appropriate,
  486.   except that border cells always become dead to keep the roads off the
  487. ! walls as mentioned previously. 
  488.   
  489.   This change, however, might mean that the formerly ISOLATED cells LIVE
  490.   neighbors, if any, no longer qualify as LIVE.  So, each of those
  491. --- 615,623 ----
  492.   enough to see that it was the last big logic bug in the program.  If
  493.   the neighbor is ISOLATED, it becomes LIVE or DEAD, as appropriate,
  494.   except that border cells always become dead to keep the roads off the
  495. ! walls as mentioned previously, and neighbors of UNUSED cells never
  496. ! become LIVE (because they aren't eligible to become streets), but
  497. ! always go from ISOLATED to DEAD. 
  498.   
  499.   This change, however, might mean that the formerly ISOLATED cells LIVE
  500.   neighbors, if any, no longer qualify as LIVE.  So, each of those
  501. *** townuser.doc.old    Fri Apr 19 23:48:44 1991
  502. --- townuser.doc    Sat Apr 20 00:16:16 1991
  503. ***************
  504. *** 1,9 ****
  505. ! Welcome, as it were, to townmaze.
  506.   
  507.   Just typing "townmaze" at the command line will do an example maze for
  508.   you, once the program has been compiled and installed (see README).
  509.   
  510. ! Typing "townmaze help" at the command line will get you a "usage"
  511.   display about 22 lines high, describing each of the parameters and
  512.   their limits.
  513.   
  514. --- 1,10 ----
  515. ! Welcome, as it were, to townmaze release 1.1.
  516.   
  517.   Just typing "townmaze" at the command line will do an example maze for
  518.   you, once the program has been compiled and installed (see README).
  519.   
  520. ! Typing "townmaze help" at the command line will get you an error
  521. ! message (Read it fast on a 25 line screen!) and then a  "usage"
  522.   display about 22 lines high, describing each of the parameters and
  523.   their limits.
  524.   
  525. ***************
  526. *** 168,173 ****
  527. --- 169,181 ----
  528.   you install the software in a computer game, to be able to use a level
  529.   over and over without having to store its design explicitly in the
  530.   game. 
  531. + As of release 1.1, townmaze does lots of error reporting on parameter
  532. + entry, before dumping the usage display. There is a file called
  533. + townmaze.test (a csh or AmigaOS script) which will test every error
  534. + message from the parameter reading routine. It's kind of tedious, but
  535. + you might want to run it once to make sure your installation is working
  536. + as it was intended to do.
  537.   
  538.   I hope you have fun with my toy.
  539.   
  540.