home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!zephyr.ens.tek.com!master!saab!billr
- From: billr@saab.CNA.TEK.COM (Bill Randle)
- Newsgroups: comp.sources.games
- Subject: v13i061: dominion - a multi-player world simulation game, Part25/28
- Message-ID: <2464@masterCNA.TEK.COM>
- Date: 11 Feb 92 18:27:42 GMT
- Sender: news@masterCNA.TEK.COM
- Lines: 2060
- Approved: billr@saab.CNA.TEK.COM
-
- Submitted-by: rosalia@dirac.physics.sunysb.edu (Mark Galassi)
- Posting-number: Volume 13, Issue 61
- Archive-name: dominion/Part25
- Environment: Unix, curses
-
-
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 25 (of 28)."
- # Contents: COPYING cinfo.c diplolib.c maglib.c root.c
- # Wrapped by billr@saab on Tue Feb 11 10:14:58 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'COPYING' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'COPYING'\"
- else
- echo shar: Extracting \"'COPYING'\" \(12488 characters\)
- sed "s/^X//" >'COPYING' <<'END_OF_FILE'
- X
- X GNU GENERAL PUBLIC LICENSE
- X Version 1, February 1989
- X
- X Copyright (C) 1989 Free Software Foundation, Inc.
- X 675 Mass Ave, Cambridge, MA 02139, USA
- X Everyone is permitted to copy and distribute verbatim copies
- X of this license document, but changing it is not allowed.
- X
- X Preamble
- X
- X The license agreements of most software companies try to keep users
- Xat the mercy of those companies. By contrast, our General Public
- XLicense is intended to guarantee your freedom to share and change free
- Xsoftware--to make sure the software is free for all its users. The
- XGeneral Public License applies to the Free Software Foundation's
- Xsoftware and to any other program whose authors commit to using it.
- XYou can use it for your programs, too.
- X
- X When we speak of free software, we are referring to freedom, not
- Xprice. Specifically, the General Public License is designed to make
- Xsure that you have the freedom to give away or sell copies of free
- Xsoftware, that you receive source code or can get it if you want it,
- Xthat you can change the software or use pieces of it in new free
- Xprograms; and that you know you can do these things.
- X
- X To protect your rights, we need to make restrictions that forbid
- Xanyone to deny you these rights or to ask you to surrender the rights.
- XThese restrictions translate to certain responsibilities for you if you
- Xdistribute copies of the software, or if you modify it.
- X
- X For example, if you distribute copies of a such a program, whether
- Xgratis or for a fee, you must give the recipients all the rights that
- Xyou have. You must make sure that they, too, receive or can get the
- Xsource code. And you must tell them their rights.
- X
- X We protect your rights with two steps: (1) copyright the software, and
- X(2) offer you this license which gives you legal permission to copy,
- Xdistribute and/or modify the software.
- X
- X Also, for each author's protection and ours, we want to make certain
- Xthat everyone understands that there is no warranty for this free
- Xsoftware. If the software is modified by someone else and passed on, we
- Xwant its recipients to know that what they have is not the original, so
- Xthat any problems introduced by others will not reflect on the original
- Xauthors' reputations.
- X
- X The precise terms and conditions for copying, distribution and
- Xmodification follow.
- X
- X GNU GENERAL PUBLIC LICENSE
- X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- X
- X 0. This License Agreement applies to any program or other work which
- Xcontains a notice placed by the copyright holder saying it may be
- Xdistributed under the terms of this General Public License. The
- X"Program", below, refers to any such program or work, and a "work based
- Xon the Program" means either the Program or any work containing the
- XProgram or a portion of it, either verbatim or with modifications. Each
- Xlicensee is addressed as "you".
- X
- X 1. You may copy and distribute verbatim copies of the Program's source
- Xcode as you receive it, in any medium, provided that you conspicuously and
- Xappropriately publish on each copy an appropriate copyright notice and
- Xdisclaimer of warranty; keep intact all the notices that refer to this
- XGeneral Public License and to the absence of any warranty; and give any
- Xother recipients of the Program a copy of this General Public License
- Xalong with the Program. You may charge a fee for the physical act of
- Xtransferring a copy.
- X
- X 2. You may modify your copy or copies of the Program or any portion of
- Xit, and copy and distribute such modifications under the terms of Paragraph
- X1 above, provided that you also do the following:
- X
- X a) cause the modified files to carry prominent notices stating that
- X you changed the files and the date of any change; and
- X
- X b) cause the whole of any work that you distribute or publish, that
- X in whole or in part contains the Program or any part thereof, either
- X with or without modifications, to be licensed at no charge to all
- X third parties under the terms of this General Public License (except
- X that you may choose to grant warranty protection to some or all
- X third parties, at your option).
- X
- X c) If the modified program normally reads commands interactively when
- X run, you must cause it, when started running for such interactive use
- X in the simplest and most usual way, to print or display an
- X announcement including an appropriate copyright notice and a notice
- X that there is no warranty (or else, saying that you provide a
- X warranty) and that users may redistribute the program under these
- X conditions, and telling the user how to view a copy of this General
- X Public License.
- X
- X d) You may charge a fee for the physical act of transferring a
- X copy, and you may at your option offer warranty protection in
- X exchange for a fee.
- X
- XMere aggregation of another independent work with the Program (or its
- Xderivative) on a volume of a storage or distribution medium does not bring
- Xthe other work under the scope of these terms.
- X
- X 3. You may copy and distribute the Program (or a portion or derivative of
- Xit, under Paragraph 2) in object code or executable form under the terms of
- XParagraphs 1 and 2 above provided that you also do one of the following:
- X
- X a) accompany it with the complete corresponding machine-readable
- X source code, which must be distributed under the terms of
- X Paragraphs 1 and 2 above; or,
- X
- X b) accompany it with a written offer, valid for at least three
- X years, to give any third party free (except for a nominal charge
- X for the cost of distribution) a complete machine-readable copy of the
- X corresponding source code, to be distributed under the terms of
- X Paragraphs 1 and 2 above; or,
- X
- X c) accompany it with the information you received as to where the
- X corresponding source code may be obtained. (This alternative is
- X allowed only for noncommercial distribution and only if you
- X received the program in object code or executable form alone.)
- X
- XSource code for a work means the preferred form of the work for making
- Xmodifications to it. For an executable file, complete source code means
- Xall the source code for all modules it contains; but, as a special
- Xexception, it need not include source code for modules which are standard
- Xlibraries that accompany the operating system on which the executable
- Xfile runs, or for standard header files or definitions files that
- Xaccompany that operating system.
- X
- X 4. You may not copy, modify, sublicense, distribute or transfer the
- XProgram except as expressly provided under this General Public License.
- XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
- Xthe Program is void, and will automatically terminate your rights to use
- Xthe Program under this License. However, parties who have received
- Xcopies, or rights to use copies, from you under this General Public
- XLicense will not have their licenses terminated so long as such parties
- Xremain in full compliance.
- X
- X 5. By copying, distributing or modifying the Program (or any work based
- Xon the Program) you indicate your acceptance of this license to do so,
- Xand all its terms and conditions.
- X
- X 6. Each time you redistribute the Program (or any work based on the
- XProgram), the recipient automatically receives a license from the original
- Xlicensor to copy, distribute or modify the Program subject to these
- Xterms and conditions. You may not impose any further restrictions on the
- Xrecipients' exercise of the rights granted herein.
- X
- X 7. The Free Software Foundation may publish revised and/or new versions
- Xof the General Public License from time to time. Such new versions will
- Xbe similar in spirit to the present version, but may differ in detail to
- Xaddress new problems or concerns.
- X
- XEach version is given a distinguishing version number. If the Program
- Xspecifies a version number of the license which applies to it and "any
- Xlater version", you have the option of following the terms and conditions
- Xeither of that version or of any later version published by the Free
- XSoftware Foundation. If the Program does not specify a version number of
- Xthe license, you may choose any version ever published by the Free Software
- XFoundation.
- X
- X 8. If you wish to incorporate parts of the Program into other free
- Xprograms whose distribution conditions are different, write to the author
- Xto ask for permission. For software which is copyrighted by the Free
- XSoftware Foundation, write to the Free Software Foundation; we sometimes
- Xmake exceptions for this. Our decision will be guided by the two goals
- Xof preserving the free status of all derivatives of our free software and
- Xof promoting the sharing and reuse of software generally.
- X
- X NO WARRANTY
- X
- X 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
- XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
- XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
- XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
- XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
- XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
- XREPAIR OR CORRECTION.
- X
- X 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
- XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
- XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
- XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
- XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
- XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
- XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
- XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
- XPOSSIBILITY OF SUCH DAMAGES.
- X
- X END OF TERMS AND CONDITIONS
- X
- X Appendix: How to Apply These Terms to Your New Programs
- X
- X If you develop a new program, and you want it to be of the greatest
- Xpossible use to humanity, the best way to achieve this is to make it
- Xfree software which everyone can redistribute and change under these
- Xterms.
- X
- X To do so, attach the following notices to the program. It is safest to
- Xattach them to the start of each source file to most effectively convey
- Xthe exclusion of warranty; and each file should have at least the
- X"copyright" line and a pointer to where the full notice is found.
- X
- X <one line to give the program's name and a brief idea of what it does.>
- X Copyright (C) 19yy <name of author>
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- XAlso add information on how to contact you by electronic and paper mail.
- X
- XIf the program is interactive, make it output a short notice like this
- Xwhen it starts in an interactive mode:
- X
- X Gnomovision version 69, Copyright (C) 19xx name of author
- X Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- X This is free software, and you are welcome to redistribute it
- X under certain conditions; type `show c' for details.
- X
- XThe hypothetical commands `show w' and `show c' should show the
- Xappropriate parts of the General Public License. Of course, the
- Xcommands you use may be called something other than `show w' and `show
- Xc'; they could even be mouse-clicks or menu items--whatever suits your
- Xprogram.
- X
- XYou should also get your employer (if you work as a programmer) or your
- Xschool, if any, to sign a "copyright disclaimer" for the program, if
- Xnecessary. Here a sample; alter the names:
- X
- X Yoyodyne, Inc., hereby disclaims all copyright interest in the
- X program `Gnomovision' (a program to direct compilers to make passes
- X at assemblers) written by James Hacker.
- X
- X <signature of Ty Coon>, 1 April 1989
- X Ty Coon, President of Vice
- X
- XThat's all there is to it!
- END_OF_FILE
- if test 12488 -ne `wc -c <'COPYING'`; then
- echo shar: \"'COPYING'\" unpacked with wrong size!
- fi
- # end of 'COPYING'
- fi
- if test -f 'cinfo.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'cinfo.c'\"
- else
- echo shar: Extracting \"'cinfo.c'\" \(12038 characters\)
- sed "s/^X//" >'cinfo.c' <<'END_OF_FILE'
- X /* cinfo.c -- curses-based info browsing utility/library */
- X
- X/*
- X * Copyright (C) 1990 Free Software Foundation, Inc.
- X * Written by Mark Galassi.
- X *
- X * This file is part of cinfo.
- X *
- X * cinfo is free software; you can redistribute it and/or
- X * modify it under the terms of the GNU General Public License as published
- X * by the Free Software Foundation; either version 1, or (at your option)
- X * any later version.
- X *
- X * This software is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this software; see the file COPYING. If not, write to
- X * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include <stdio.h>
- X#include <curses.h>
- X#ifdef SYSV
- X# include <string.h>
- X#else
- X# include <strings.h>
- X#endif /* SYSV */
- X
- X/* some systems already have strstr() */
- X/* #define HAVE_STRSTR */
- X
- X#define LINE_LEN 80 /* longer than this is truncated */
- X /* this is defined in the Makefile */
- X/* #define STANDALONE /* if we run standalone... */
- X#define INFO_PATH "/usr/local/lib/emacs/info"
- X#ifndef INFO_INTRO
- X# define INFO_INTRO "/usr/local/lib/info_intro"
- X#endif /* INFO_INTRO */
- X#define INFO_CHAR 0x1F /* ^_, used to specify an info line */
- X#define DEL 0x7F /* DELETE character */
- X
- X /* global variables */
- X
- X /* current node fields */
- Xchar node[LINE_LEN], node_prev[LINE_LEN],
- X node_next[LINE_LEN], node_up[LINE_LEN];
- X
- X /* seek pointer in info file where the tag table is */
- Xlong tag_table_pos = 0;
- X
- X /* this tells us that we must show a new page */
- Xint update_info_page = 1;
- X
- X /* main routine if this program is run standalone. Otherwise,
- X the cinfo() routine can be called from anywhere.
- X */
- X#ifdef STANDALONE
- Xmain(argc, argv)
- X int argc;
- X char *argv[];
- X{
- X switch (argc) {
- X case 2:
- X cinfo(argv[1], "Top");
- X break;
- X case 3:
- X cinfo(argv[1], argv[2]);
- X break;
- X default:
- X printf("Useage: %s filename [tag]\n", argv[0]);
- X clean_exit();
- X exit(1);
- X }
- X clean_exit();
- X exit(0);
- X}
- Xclean_exit(){};
- X
- X#endif /* STANDALONE */
- X
- Xstatic WINDOW *infow; /* screen-size window in which it happens */
- X
- X /* run curses-based info browsing.
- X fname: name of info file
- X tag: topic we should try to search for
- X */
- Xcinfo(fname, tag)
- X char fname[], tag[];
- X{
- X char item[LINE_LEN];
- X int done = 0; /* for the input loop */
- X long old_pos;
- X char c;
- X FILE *fp, *intro_fp, *find_info_file();
- X
- X /* open up the info file */
- X fp = find_info_file(fname);
- X find_tag_table(fp);
- X if ((intro_fp = fopen(INFO_INTRO, "r")) == NULL) {
- X printf("Cannot open info file %s, exiting.\n", INFO_INTRO);
- X clean_exit();
- X exit(1);
- X }
- X cinfo_init_screen();
- X /* if they start at top level, give them the help screen */
- X if (strcmp(tag, "Top") == 0) {
- X cinfo_intro_screen(intro_fp, infow);
- X }
- X
- X find_menu_item(fp, tag);
- X parse_info_line(fp); /* make sure we have the current line parsed */
- X/* wclear(infow); */
- X
- X while (!done) {
- X old_pos = ftell(fp); /* before this page is shown */
- X if (show_page(fp, infow) == -1) {
- X /* means that we ran into a new info line */
- X parse_info_line(fp);
- X }
- X cinfo_statline("(SPACE, DEL/BS, m, n, p, u, q, ?)");
- X switch (wgetch(infow)) {
- X case ' ':
- X update_info_page = 1;
- X break;
- X case DEL: /* should go back a screen */
- X case '\b':
- X break;
- X case 'm': /* let user choose a tag */
- X if (prompt(item) != -1) { /* did they type something? */
- X fseek(fp, old_pos, 0); /* in case find_menu_item does not work */
- X find_menu_item(fp, item);
- X parse_info_line(fp); /* make sure we have the current line parsed */
- X update_info_page = 1;
- X }
- X break;
- X case 'n':
- X if (strlen(node_next) > 0) {
- X find_menu_item(fp, node_next);
- X parse_info_line(fp);
- X }
- X update_info_page = 1;
- X break;
- X case 'p':
- X if (strlen(node_prev) > 0) {
- X find_menu_item(fp, node_prev);
- X parse_info_line(fp);
- X }
- X update_info_page = 1;
- X break;
- X case 'u':
- X if (strlen(node_up) > 0) {
- X find_menu_item(fp, node_up);
- X parse_info_line(fp);
- X }
- X break;
- X case 'q':
- X done = 1;
- X break;
- X case '?':
- X cinfo_intro_screen(intro_fp, infow);
- X wclear(infow);
- X update_info_page = 1;
- X break;
- X default:
- X fseek(fp, old_pos, 0);
- X break;
- X }
- X }
- X fclose(fp);
- X fclose(intro_fp);
- X cinfo_cleanup();
- X}
- X
- X /* prepare the screen */
- Xcinfo_init_screen()
- X{
- X#ifdef STANDALONE
- X printf("initializing screen...\r\n");
- X initscr();
- X savetty();
- X nonl();
- X cbreak();
- X noecho();
- X#endif /* STANDALONE */
- X /* prepare a full-size window to work in */
- X infow = newwin(LINES, COLS, 0, 0);
- X wclear(infow);
- X wmove(infow, 0, 0);
- X wrefresh(infow);
- X}
- X
- X /* clean up curses, if necessary, and free memory */
- Xcinfo_cleanup()
- X{
- X wclear(infow);
- X wrefresh(infow);
- X delwin(infow);
- X#ifdef STANDALONE
- X resetty();
- X endwin();
- X#endif /* STANDALONE */
- X}
- X
- X /* shows the introductory page and waits for a key hit */
- Xcinfo_intro_screen(intro_fp, infow)
- X FILE *intro_fp;
- X WINDOW *infow;
- X{
- X char line[2*LINE_LEN];
- X int n = 0;
- X
- X wclear(infow);
- X rewind(intro_fp);
- X while (fgets(line, 2*LINE_LEN, intro_fp) != NULL) {
- X line[LINE_LEN-1] = '\0'; /* truncate it */
- X mvwaddstr(infow, n, 0, line);
- X wclrtoeol(infow);
- X wrefresh(infow);
- X ++n;
- X }
- X wgetch(infow);
- X}
- X
- X /* shows the given string at the bottom of the page */
- Xcinfo_statline(s)
- X char s[];
- X{
- X wmove(infow, LINES-1, 0);
- X waddstr(infow, s);
- X wclrtoeol(infow);
- X wrefresh(infow);
- X}
- X
- Xcinfo_statline2()
- X{
- X wmove(infow, LINES-2, 0);
- X wstandout(infow);
- X wprintw(infow ,"%s", node);
- X wstandend(infow);
- X wprintw(infow, ", p: %s, u: %s, n: %s", node_prev, node_up, node_next);
- X wclrtoeol(infow);
- X wrefresh(infow);
- X}
- X
- X /* this is kind of the guts of it:
- X setting the file pointer to a menu item.
- X this function also returns the seek pointer
- X */
- Xfind_menu_item(fp, tag)
- X FILE *fp;
- X char tag[];
- X{
- X long old_pos = ftell(fp), pos;
- X char line[2*LINE_LEN], s[LINE_LEN], item[LINE_LEN];
- X#ifndef HAVE_STRSTR
- X#ifdef __STDC__
- X extern char *strstr(char *, char *);
- X#else /* STDC */
- X extern char *strstr();
- X#endif /* STDC */
- X#endif /* HAVE_STRSTR */
- X
- X fseek(fp, tag_table_pos, 0);
- X /* prepare a scanning format string */
- X sprintf(s, "Node: %%[-A-Z a-z0-9_`\']");
- X while (1) {
- X if ((fgets(line, 2*LINE_LEN, fp) == NULL) || (sscanf(line, s, item) < 0)) {
- X fseek(fp, old_pos, 0);
- X return old_pos;
- X }
- X /* now convert all to lower case */
- X str_lower(item);
- X str_lower(tag);
- X if (strncmp(item, tag, strlen(tag)) == 0) {
- X /* ugly kludge, but scanf seems to not do what I want */
- X sscanf(line+strlen("Node: ")+strlen(item)+1, "%ld", &pos);
- X fseek(fp, pos-1, 0);
- X return pos;
- X }
- X }
- X}
- X
- X /* this function is essential:
- X it sets the node[], node_prev[], node_next[] and node_up[] strings
- X */
- Xparse_info_line(fp)
- X FILE *fp;
- X{
- X char line[2*LINE_LEN];
- X long old_pos = ftell(fp);
- X char *ptr;
- X int n;
- X
- X fgets(line, 2*LINE_LEN, fp);
- X /* we can only parse it if it is really a node line */
- X if (strncmp(line, "File:", strlen("File:")) != 0) {
- X fseek(fp, old_pos, 0);
- X return -1;
- X }
- X#define BAD_HACK
- X#ifdef BAD_HACK
- X /* now I play funny pointer games to parse
- X this line. I assume that strstr() returns NULL
- X if the second string is not a substring of the
- X first.
- X */
- X if (ptr = strstr(line, "Node: ")) {
- X n = (int) ((long) strchr(ptr, ',') - (long) ptr - strlen("Node: "));
- X strncpy(node, ptr+strlen("Node: "), n);
- X node[n] = '\0';
- X } else { /* field is not there */
- X strcpy(node, "");
- X }
- X
- X if (ptr = strstr(line, "Prev: ")) {
- X n = (int) ((long) strchr(ptr, ',') - (long) ptr - strlen("Prev: "));
- X strncpy(node_prev, ptr+strlen("Prev: "), n);
- X node_prev[n] = '\0';
- X } else { /* field is not there */
- X strcpy(node_prev, "");
- X }
- X
- X if (ptr = strstr(line, "Up: ")) {
- X n = (int) ((long) strchr(ptr, ',') - (long) ptr - strlen("Up: "));
- X strncpy(node_up, ptr+strlen("Up: "), n);
- X node_up[n] = '\0';
- X } else { /* field is not there */
- X strcpy(node_up, "");
- X }
- X
- X /* this last one is easier, because it is
- X the last field in an info line. but
- X remember to remove the newline.
- X */
- X if (ptr = strstr(line, "Next: ")) {
- X strcpy(node_next, ptr+strlen("Next: "));
- X node_next[strlen(node_next)-1] = '\0';
- X } else { /* field is not there */
- X strcpy(node_next, "");
- X }
- X
- X#endif /* BAD HACK */
- X fseek(fp, old_pos, 0); /* go back to where we were */
- X return 1;
- X}
- X
- X /* this is also an essential function:
- X it shows the current information page
- X */
- Xshow_page(fp, infow)
- X FILE *fp;
- X WINDOW *infow;
- X{
- X int n = 0; /* line counter */
- X char line[2*LINE_LEN];
- X
- X if (!update_info_page) { /* do we need to redraw? */
- X return 0;
- X }
- X update_info_page = 0;
- X wclear(infow);
- X for (n = 0; n < LINES-2; ++n) {
- X fgets(line, 2*LINE_LEN, fp);
- X line[LINE_LEN-1] = '\0'; /* truncate it */
- X /* stop if you get to a new info format entry */
- X if (line[0] == INFO_CHAR) {
- X cinfo_statline2();
- X return -1;
- X } else {
- X mvwaddstr(infow, n, 0, line);
- X wclrtoeol(infow);
- X wrefresh(infow);
- X }
- X }
- X cinfo_statline2();
- X return 1;
- X}
- X
- X /* prompt the user for a tag; return -1 if there is no input */
- Xprompt(item)
- X char item[];
- X{
- X int ret;
- X
- X echo();
- X nocbreak();
- X cinfo_statline("Enter your menu choice: ");
- X ret = wscanw(infow, "%[^\n]", item);
- X cbreak();
- X noecho();
- X if (ret <= 0) {
- X return -1;
- X }
- X return 1;
- X}
- X
- X /* called at the start, this finds the location of the tag table */
- Xfind_tag_table(fp)
- X FILE *fp;
- X{
- X char line[2*LINE_LEN];
- X long pos;
- X
- X while (1) {
- X pos = ftell(fp);
- X if (fgets(line, 2*LINE_LEN, fp) == NULL) {
- X break;
- X }
- X if (line[0] == INFO_CHAR) {
- X fgets(line, 2*LINE_LEN, fp);
- X if (strncmp(line, "Tag table:", strlen("Tag table:")) == 0) {
- X tag_table_pos = ftell(fp); /* got it!!! */
- X break;
- X }
- X }
- X }
- X}
- X
- X /* converts a string to lower case */
- Xstr_lower(s)
- X char s[];
- X{
- X while (*s) {
- X if (*s >= 'A' && *s <= 'Z') { /* is it upper case? */
- X *s = *s - ('A' - 'a'); /* if so, convert */
- X }
- X ++s;
- X }
- X}
- X
- X /* tries to find and fopen() the .info file in a variety
- X of paths. returns the file pointer or exits.
- X */
- XFILE *find_info_file(fname)
- X char fname[];
- X{
- X char full_fname[LINE_LEN];
- X FILE *fp, *fopen();
- X
- X /* try several file names, see if one of them works */
- X if ((fp = fopen(fname, "r")) == NULL) {
- X strcpy(full_fname, fname);
- X strcat(full_fname, ".info"); /* try it with a ".info" */
- X if ((fp = fopen(full_fname, "r")) == NULL) {
- X strcpy(full_fname, INFO_PATH);
- X strcat(full_fname, "/");
- X strcat(full_fname, fname);
- X if ((fp = fopen(full_fname, "r")) == NULL) {
- X strcat(full_fname, ".info");
- X if ((fp = fopen(full_fname, "r")) == NULL) {
- X printf("Cannot open file %s or %s, exiting.\n", fname, full_fname);
- X clean_exit();
- X exit(1);
- X }
- X }
- X }
- X }
- X return fp;
- X}
- X
- X
- X#ifndef HAVE_STRSTR
- X
- X /* System V has strstr(), which is useful, but bsd
- X does not. This is a replacement for strstr that
- X should make up for that. The algorithm is a
- X total hack, and probably not too fast.
- X */
- X /* strstr() returns a pointer to the first occurrence of
- X s2 inside s1. A generalization of index() or strchr().
- X strstr() returns NULL if s2 is not a substring of s1.
- X */
- Xchar *
- Xstrstr(s1, s2)
- X char *s1, *s2;
- X{
- X char *p = NULL; /* what we are looking for */
- X char *s;
- X int n = strlen(s2);
- X
- X /* run through s1, and see if at any point s2 appears */
- X for (s = s1; *s != '\0'; ++s) {
- X if (strncmp(s, s2, n) == 0) {
- X p = s; /* we found it!!! */
- X break;
- X }
- X }
- X return p;
- X}
- X
- X#endif /* HAVE_STRSTR */
- END_OF_FILE
- if test 12038 -ne `wc -c <'cinfo.c'`; then
- echo shar: \"'cinfo.c'\" unpacked with wrong size!
- fi
- # end of 'cinfo.c'
- fi
- if test -f 'diplolib.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'diplolib.c'\"
- else
- echo shar: Extracting \"'diplolib.c'\" \(11937 characters\)
- sed "s/^X//" >'diplolib.c' <<'END_OF_FILE'
- X/* diplolib.c -- basic, non-visual diplomacy routines */
- X
- X/*
- X * Copyright (C) 1990 Free Software Foundation, Inc.
- X * Written by the dominion project.
- X *
- X * This file is part of dominion.
- X *
- X * dominion is free software; you can redistribute it and/or
- X * modify it under the terms of the GNU General Public License as published
- X * by the Free Software Foundation; either version 1, or (at your option)
- X * any later version.
- X *
- X * This software is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this software; see the file COPYING. If not, write to
- X * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X/* what follows here is a list of ALL routines in this file and
- X a one-line blurb stating what it does......
- X*/
- X
- X/* allocate_diplo(n): allocates space for a new diplomacy matrix */
- X/* init_diplo(n): initializes diplo matrix of size n */
- X/* increase_diplo(dm_old, dm_new, n, np): used when new nations are added */
- X/* read_in_diplo(dm, n): reads in current diplo matrix from file */
- X/* read_initial_diplo(dm, n): reads beginning-of-turn diplomacy in */
- X/* dump_diplo(np, dm, n): dumps new diplo information to a file */
- X/* update_diplo(): called by dominionupdate to update newly met nations */
- X/* have_met(dm, nation1, nation2): returns true if nation 1 and 2 have met */
- X/* get_indices(dm, nation1, nation2, n1, n2): takes ids, gives indices in dm */
- X/* handle_meet(dm, nation1, nation2): actually changes from UNMET to NEUTRAL */
- X/* get_diplo_status(dm, nation1, nation2): will return the status of n1 to n2*/
- X/* set_diplo_status(dm, nation1, nation2, New_Status): changes status */
- X/* are_allied(nation1, nation2): returns 1 if they are allied */
- X/* lock_diplo(np): lock the diplomacy file */
- X/* unlock_diplo(): unlock the diplomacy file */
- X/* diplo_is_locked(): see if the diplo file is locked */
- X
- X#include "dominion.h"
- X#include "misc.h"
- X#include <stdio.h>
- X
- Xextern Sworld world;
- Xextern int (*wrapx)(), (*wrapy)();
- X
- X/* */
- X/* allocate_diplo(): allocates space for a new diplomacy matrix */
- X/* */
- X
- XSdiplo **allocate_diplo(n)
- X int n; /* number of nations */
- X{
- X int i;
- X Sdiplo **dm;
- X
- X dm = (Sdiplo **) malloc(n*sizeof(Sdiplo *));
- X for (i = 0; i < n; ++i) {
- X dm[i] = (Sdiplo *) malloc(n*sizeof(Sdiplo));
- X }
- X return dm;
- X}
- X
- X/* */
- X/* initializes a diplomacy data structure at the beginning
- X of the game, when there is no file, and all nations are unmet! */
- X/* */
- X
- Xinit_diplo(n)
- X int n; /* number of nations */
- X{
- X Sdiplo **dm;
- X int i, j;
- X FILE *fp, *fopen();
- X
- X dm = allocate_diplo(n);
- X
- X for (i = 0; i < n; ++i) {
- X for (j = 0; j < n; ++j) {
- X dm[i][j].status = UNMET;
- X dm[i][j].self_id = world.nations[i].id;
- X dm[i][j].neighbor_id = world.nations[j].id;
- X }
- X dm[i][i].status = SELF;
- X }
- X
- X if ((fp = fopen(DIPLO_FILE, "w")) == NULL) {
- X printf("sorry, cannot open file %s for writing\n", DIPLO_FILE);
- X return -1;
- X }
- X critical();
- X for (i = 0; i < n; ++i) {
- X fwrite(dm[i], n*sizeof(Sdiplo), 1, fp);
- X }
- X fclose(fp);
- X noncritical();
- X}
- X
- X/* increase_diplo(): Called when a nation has been added to world.
- X take a diplo matrix, and add a new blank entry to it.
- X assume that dm_old and dm_new both have storage */
- X
- Xincrease_diplo(dm_old, dm_new, n, np)
- X Sdiplo **dm_old, **dm_new;
- X int n; /* number of nations *before* increase */
- X Snation *np;
- X{
- X int i, j;
- X
- X /* first copy the old stuff */
- X for (i = 0; i < n; ++i) {
- X for (j = 0; j < n; ++j) {
- X dm_new[i][j] = dm_old[i][j];
- X }
- X }
- X /* then put defaults for the new stuff */
- X for (i = 0; i <= n; ++i) {
- X dm_new[n][i].status = UNMET;
- X dm_new[n][i].self_id = np->id; /* was world.nations[i].id */
- X dm_new[n][i].neighbor_id = world.nations[i].id;
- X /* now do the transpose */
- X dm_new[i][n].status = UNMET;
- X dm_new[i][n].self_id = world.nations[i].id;
- X dm_new[i][n].neighbor_id = np->id; /* was world.nations[n].id */
- X }
- X dm_new[n][n].status = SELF;
- X}
- X
- X
- X /* reads information into the diplomacy file */
- Xread_in_diplo(dm, n)
- X Sdiplo **dm;
- X int n; /* number of nations */
- X{
- X int i;
- X FILE *dfp, *fopen();
- X
- X if ((dfp = fopen(DIPLO_FILE, "r")) == NULL) {
- X return -1;
- X }
- X
- X for (i = 0; i < n; ++i) {
- X fread(dm[i], n*sizeof(Sdiplo), 1, dfp);
- X }
- X fclose(dfp);
- X return 1;
- X}
- X
- X/* This reads in the diplomacy matrix as it was at the beginning of
- X the turn. It is important to do this, because the software must
- X know if the user is changing diplomacy by more than 2 levels.
- X */
- Xread_initial_diplo(dm, n)
- X Sdiplo **dm;
- X int n; /* number of nations */
- X{
- X int i;
- X FILE *dfp, *fopen();
- X
- X if ((dfp = fopen(INIT_DIPLO_FILE, "r")) == NULL) {
- X return -1;
- X }
- X
- X for (i = 0; i < n; ++i) {
- X fread(dm[i], n*sizeof(Sdiplo), 1, dfp);
- X }
- X fclose(dfp);
- X}
- X
- X /* dumps the data structure to the diplomacy file. */
- Xdump_diplo(np, dm, n)
- X Snation *np; /* the nation that is writing (if any) */
- X Sdiplo **dm;
- X int n;
- X{
- X FILE *dfp, *fopen();
- X int i;
- X
- X if ((dfp = fopen(DIPLO_FILE, "w")) == NULL) {
- X return -1;
- X }
- X critical();
- X lock_diplo(np);
- X for (i = 0; i < n; ++i) {
- X fwrite(dm[i], n*sizeof(Sdiplo), 1, dfp);
- X }
- X fclose(dfp);
- X noncritical();
- X unlock_diplo();
- X}
- X
- X
- X/* update_diplo(): called by the update routine so that when two
- X nations have met, they will have their status changed from UNMET
- X to NEUTRAL. */
- X
- Xupdate_diplo()
- X{
- X Sdiplo **dm;
- X struct pt_list *plist;
- X Sarmy *army_ptr;
- X struct armyid *sect_alist;
- X Ssector *sect_ptr;
- X Snation *cn;
- X int x,y, i,j, k, cn_id;
- X FILE *fp, *fopen();
- X char cmd_str[PATHLEN];
- X
- X/* printf("updating diplomacy\n"); */
- X dm = allocate_diplo(world.n_nations);
- X read_in_diplo(dm, world.n_nations);
- X
- X for (k = 1; k < world.n_nations; ++k) { /* to run through all nations */
- X cn = &world.nations[k]; /* current nation */
- X cn_id = world.nations[k].id; /* current nation id */
- X
- X for (plist = cn->ptlist; plist != NULL; plist = plist->next){
- X x = plist->pt.x;
- X y = plist->pt.y;
- X for(i= x-LAND_SIGHT; i <= x+LAND_SIGHT; ++i) {
- X for(j= y-LAND_SIGHT; j <= y+LAND_SIGHT; ++j) {
- X /* unowned */
- X if ((world.map[(*wrapx)(i,j)][(*wrapy)(i,j)].owner != 0) &&
- X (world.map[(*wrapx)(i,j)][(*wrapy)(i,j)].owner != cn_id)) {
- X handle_meet(dm, cn_id,
- X world.map[(*wrapx)(i,j)][(*wrapy)(i,j)].owner);
- X }
- X }
- X }
- X }
- X for (army_ptr = cn->armies; army_ptr != NULL; army_ptr = army_ptr->next){
- X x = army_ptr->pos.x;
- X y = army_ptr->pos.y;
- X for(i= x-ARMY_SIGHT; i <= x+ARMY_SIGHT; ++i) {
- X for(j= y-ARMY_SIGHT; j <= y+ARMY_SIGHT; ++j) {
- X sect_ptr = &world.map[(*wrapx)(i,j)][(*wrapy)(i,j)];
- X /* unowned */
- X if ((world.map[(*wrapx)(i,j)][(*wrapy)(i,j)].owner != 0) &&
- X (world.map[(*wrapx)(i,j)][(*wrapy)(i,j)].owner != cn_id)) {
- X handle_meet(dm, cn_id,
- X world.map[(*wrapx)(i,j)][(*wrapy)(i,j)].owner);
- X }
- X for (sect_alist = sect_ptr->alist; sect_alist != NULL;
- X sect_alist = sect_alist->next) {
- X if ((sect_alist->owner != 0) && (sect_alist->owner != cn_id)) {
- X handle_meet(dm, cn_id, sect_alist->owner);
- X }
- X }
- X }
- X }
- X }
- X }
- X dump_diplo(NULL, dm, world.n_nations);
- X free_diplo(dm, world.n_nations);
- X sprintf(cmd_str, "cp %s %s\n", DIPLO_FILE, INIT_DIPLO_FILE);
- X system(cmd_str);
- X/* printf("done with diplomacy... too slow??\n"); */
- X}
- X
- Xhave_met(dm, nation1, nation2)
- X Sdiplo **dm;
- X int nation1, nation2;
- X{
- X int ind1, ind2;
- X
- X ind1=0; ind2=0;
- X if ((nation1 >= world.n_nations) || (nation2 >= world.n_nations)) {
- X return(0); /* bad nation id.... return false */
- X }
- X get_indices(dm, nation1, nation2, &ind1, &ind2);
- X
- X if ((dm[ind1][ind2].status==UNMET)||(dm[ind1][ind2].status == SELF)) {
- X /* if unmet, or self */
- X return(0); /* false */
- X } else {
- X return(1); /* true */
- X }
- X
- X}
- X
- Xget_indices(dm, nation1, nation2, n1, n2)
- X Sdiplo **dm;
- X int nation1, nation2, *n1, *n2;
- X{
- X
- X/* while(nation1 != dm[(*n1)++][0].self_id) /* find nation 1 */
- X/* ;
- X (*n1)--;
- X while(nation2 != dm[*n1][(*n2)++].neighbor_id) /* find nation 2 */
- X/* ;
- X (*n2)--;
- X*/
- X *n1 = nation1;
- X *n2 = nation2;
- X}
- X
- X
- Xhandle_meet(dm, nation1, nation2)
- X Sdiplo **dm;
- X int nation1, nation2;
- X{
- X
- X int n1, n2;
- X
- X n1=0; n2=0;
- X if (!have_met(dm,nation1,nation2)) {
- X get_indices(dm, nation1, nation2, &n1, &n2);
- X dm[n1][n2].status = NEUTRAL; /* set their status to neutral */
- X n1=0; n2=0; /* now do transpose */
- X get_indices(dm, nation2, nation1, &n2, &n1);
- X dm[n2][n1].status = NEUTRAL;
- X
- X }
- X}
- X
- X
- Xget_diplo_status(dm, nation1, nation2)
- X Sdiplo **dm;
- X int nation1, nation2;
- X{
- X int n1, n2;
- X
- X n1=0; n2=0;
- X if ((nation1 >= world.n_nations) || (nation2 >= world.n_nations)) {
- X return(0); /* bad nation id.... return false */
- X };
- X get_indices(dm, nation1, nation2, &n1, &n2);
- X return(dm[n1][n2].status);
- X}
- X
- Xset_diplo_status(dm, nation1, nation2, New_Status)
- X Sdiplo **dm;
- X int nation1, nation2, New_Status;
- X{
- X int n1,n2;
- X
- X n1 = 0; n2 = 0;
- X if ((nation1 >= world.n_nations) || (nation2 >= world.n_nations)) {
- X printf("Bad Nation ID in set_diplo_status.\n"); /* bad nation id... */
- X };
- X get_indices(dm, nation1, nation2, &n1, &n2);
- X dm[n1][n2].status = New_Status;
- X}
- X
- X/* */
- X/* free_diplo(): frees space for of diplomacy matrix */
- X/* */
- X
- Xfree_diplo(dm, n)
- X Sdiplo **dm;
- X int n; /* number of nations */
- X{
- X int i;
- X
- X for (i = 0; i < n; ++i) {
- X free(dm[i]);
- X }
- X free(dm);
- X
- X}
- X
- X#ifdef OLD_NPC_DIPLO
- Xupdate_npc_diplo()
- X{
- X Sdiplo **dm, **allocate_diplo();
- X Snation *np;
- X int Loop;
- X dm = allocate_diplo(world.n_nations);
- X read_in_diplo(dm, world.n_nations);
- X for (Loop = 1; Loop < world.n_nations; Loop++) {
- X np = &world.nations[Loop];
- X if (np->npc_flag !=0) {
- X do_npc_diplo(dm, np);
- X }
- X }
- X dump_diplo(NULL, dm, world.n_nations);
- X free_diplo(dm, world.n_nations);
- X}
- X
- Xdo_npc_diplo(dm,np)
- X Sdiplo **dm;
- X Snation *np;
- X{
- X int Loop;
- X
- X /* Take care of NPC diplomacy here */
- X
- X for (Loop = 1; Loop < world.n_nations; Loop++) {
- X set_diplo_status(dm,np->id,Loop,get_diplo_status(dm,Loop,np->id));
- X }
- X}
- X#endif /* OLD_NPC_DIPLO */
- X
- X /* this returns 1 if these two nationes are allied to each other.
- X It uses the user.diplo_matrix, instead of reading it in, for speed.
- X */
- Xare_allied(id1, id2)
- X int id1, id2;
- X{
- X/* Sdiplo **dm, **allocate_diplo(); */
- X extern Suser user;
- X Sdiplo **dm = user.diplo_matrix;
- X
- X/* dm = allocate_diplo(world.n_nations);
- X read_in_diplo(dm, world.n_nations);
- X*/
- X
- X if (dm[id1][id2].status >= ALLIED && dm[id2][id1].status >= ALLIED) {
- X return 1;
- X }
- X /* free_diplo(dm, world.n_nations); */
- X return 0;
- X}
- X
- X /* creates a diplomacy lock file, and puts some information into it */
- Xlock_diplo(np)
- X Snation *np;
- X{
- X FILE *lockfp, *fopen();
- X long now_secs;
- X
- X if ((lockfp = fopen("diplo.lock", "w")) == NULL) {
- X return -1;
- X }
- X now_secs = time(0L);
- X fprintf(lockfp, "%ld; Nation: %s; time: %s", now_secs,
- X np ? np->name : "none", ctime(&now_secs));
- X fclose(lockfp);
- X return 1;
- X}
- X
- Xunlock_diplo()
- X{
- X unlink("diplo.lock");
- X}
- X
- X /* returns 1 if the diplo file is locked */
- Xdiplo_is_locked()
- X{
- X FILE *lock_fp, *fopen();
- X char line[EXECLEN];
- X long now_secs, lock_secs;
- X
- X if ((lock_fp = fopen("diplo.lock", "r")) == NULL) {
- X return 0; /* there is no lock file */
- X }
- X /* now see if the lock file is outdated. if so, remove it */
- X fscanf(lock_fp, "%s", line);
- X sscanf(line, "%d", &lock_secs);
- X now_secs = time(0L);
- X if (abs(now_secs - lock_secs) > 2*30) { /* older than 2 minutes? */
- X unlink("diplo.lock");
- X return 0;
- X }
- X return 1; /* if not, it is locked!! */
- X}
- END_OF_FILE
- if test 11937 -ne `wc -c <'diplolib.c'`; then
- echo shar: \"'diplolib.c'\" unpacked with wrong size!
- fi
- # end of 'diplolib.c'
- fi
- if test -f 'maglib.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'maglib.c'\"
- else
- echo shar: Extracting \"'maglib.c'\" \(9209 characters\)
- sed "s/^X//" >'maglib.c' <<'END_OF_FILE'
- X/* maglib.c -- routines having to do with magic powers */
- X
- X/*
- X * Copyright (C) 1990 Free Software Foundation, Inc.
- X * Written by the dominion project.
- X *
- X * This file is part of dominion.
- X *
- X * dominion is free software; you can redistribute it and/or
- X * modify it under the terms of the GNU General Public License as published
- X * by the Free Software Foundation; either version 1, or (at your option)
- X * any later version.
- X *
- X * This software is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this software; see the file COPYING. If not, write to
- X * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include "dominion.h"
- X#include "misc.h"
- X#include <stdio.h>
- X#include <math.h>
- X
- X /* dynamic array, to be read from file */
- Xextern struct spirit_type *spirit_types;
- Xextern Suser user;
- X
- Xextern int debug;
- Xextern FILE *mailfile;
- X
- X /* this is the routine actually called by the update program */
- Xdomagic(np, mailfile)
- X Snation *np;
- X FILE *mailfile;
- X{
- X int old_skill, new_skill, old_pts, new_pts;
- X
- X old_skill = np->mag_skill;
- X old_pts = np->spell_pts;
- X new_skill = new_mag_skill(np);
- X /* must subtract the spell points used by spirits and such */
- X new_pts = new_spell_pts(np) - military_maint_spell_pts(np);
- X if (debug) {
- X printf("nation %s has old_mag_skill = %d, new_skill = %d\n",
- X np->name, old_skill, new_skill);
- X printf("nation %s has old_pts = %d, new_pts = %d\n",
- X np->name, old_pts, new_pts);
- X }
- X if (mailfile) {
- X fprintf(mailfile,
- X "Your skill in magic has increased from %d to %d\n",
- X old_skill, new_skill);
- X fprintf(mailfile,
- X "You have gained %d spell points, for a new total of %d\n",
- X new_pts-old_pts, new_pts);
- X }
- X/* get_new_spell(&user, old_skill, new_skill); should be in load_nation() or init_user() */
- X np->mag_skill = new_skill;
- X np->spell_pts = new_pts;
- X}
- X
- X#define JEWEL_MAG_POWER (3.0/4.0)
- X
- X /* this routine calculates the new mag_skill for a nation */
- Xnew_mag_skill(np)
- X Snation *np;
- X{
- X int increase;
- X
- X increase = (int)
- X ((np->race.mag_apt + priestliness(np)) / 100.0 *
- X (sqrt(1.0 * (calc_revenue (np) * np->mag_r_d/100.0
- X + np->cur_mag_r_d * np->money/100.0)) * MAG_MONEY_FACTOR
- X + pow((double)(calc_jewels (np) * np->mag_r_d_jewels / 100.0 +
- X np->jewels * np->cur_mag_r_d_jewels / 100.0),JEWEL_MAG_POWER)
- X * (MAG_JEWEL_FACTOR * 10))); /* 10 * the number of spell pts */
- X return np->mag_skill + increase;
- X}
- X
- X /* this calculates how many new spell points a nation gets this turn.
- X note that spell points accumulate but little.
- X */
- Xnew_spell_pts(np)
- X Snation *np;
- X{
- X int new_pts;
- X
- X new_pts = (int)( pow((calc_jewels (np) * (np->mag_r_d_jewels / 100.0) +
- X np->jewels * np->cur_mag_r_d_jewels / 100.0),JEWEL_MAG_POWER)
- X * MAG_JEWEL_FACTOR *
- X ((np->race.mag_apt + priestliness (np)) / 100.0));
- X if (np->spell_pts < 0) {
- X return new_pts + np->spell_pts;
- X } else {
- X return (3*new_pts + np->spell_pts)/3; /* a mild accumulation */
- X }
- X}
- X
- X /* these spells are loaded in init_user() */
- Xget_spells(up, skill)
- X Suser *up;
- X int skill;
- X{
- X FILE *fp, *fopen();
- X Sspell spell, *tmp_spell;
- X char fname[2*NAMELEN], line[EXECLEN];
- X int done = 0, level; /* cost */
- X
- X if (debug)
- X printf("nation %s, skill=%d\n", up->np->name, skill);
- X strcpy(fname, MAG_PREFIX);
- X strcat(fname, up->np->mag_order);
- X
- X if ((fp = fopen(fname, "r")) == NULL) {
- X printf("could not open file for magic order %s. returning.\n",
- X up->np->mag_order);
- X return -1;
- X }
- X while (!done) {
- X if (fgets(line, EXECLEN, fp) == NULL) {
- X done = 1;
- X fclose(fp);
- X return;
- X }
- X if (line[0] != '#') { /* lines with '#' are comments */
- X /* make sure this is a spell and NOT a
- X summoned spirit or an exec line
- X */
- X if (strncmp(line, "summon_", strlen("summon_")) != 0
- X && strncmp(line, "EXEC:", strlen("EXEC:")) != 0) {
- X sscanf(line, "%s%d%d%d", spell.name, &level, &spell.cost,
- X &spell.duration);
- X /* add it to the user's spell list (if they deserve) */
- X if (level <= skill) {
- X if (debug) {
- X printf("found %s, level=%d, cost=%d, duration=%d\n", spell.name,
- X level, spell.cost, spell.duration);
- X printf("nation %s gets new spell <%s>\n",
- X up->np->name, spell.name);
- X }
- X if (up->spell_list == NULL) {
- X up->spell_list = (Sspell *) malloc(sizeof(Sspell));
- X *(up->spell_list) = spell;
- X up->spell_list->next = NULL;
- X } else {
- X tmp_spell = up->spell_list;
- X while (tmp_spell != NULL) { /* find end of list */
- X if (tmp_spell->next == NULL) {
- X tmp_spell->next = (Sspell *) malloc(sizeof(Sspell));
- X spell.next = NULL; /* making sure */
- X *(tmp_spell->next) = spell;
- X break;
- X }
- X tmp_spell = tmp_spell->next;
- X }
- X }
- X }
- X }
- X }
- X }
- X fclose(fp);
- X}
- X
- X /* these spirits are loaded in init_user() */
- Xget_spirits(up, skill)
- X Suser *up;
- X int skill;
- X{
- X FILE *fp, *fopen();
- X Sspirit spirit, *tmp_spirit;
- X char fname[2*NAMELEN], line[EXECLEN];
- X int done = 0, level; /* , cost */
- X
- X if (debug)
- X printf("nation %s, new_skill=%d\n",
- X up->np->name, skill);
- X strcpy(fname, MAG_PREFIX);
- X strcat(fname, up->np->mag_order);
- X
- X if ((fp = fopen(fname, "r")) == NULL) {
- X printf("could not open file for magic order %s. returning.\n",
- X up->np->mag_order);
- X return -1;
- X }
- X while (!done) {
- X if (fgets(line, EXECLEN, fp) == NULL) {
- X done = 1;
- X fclose(fp);
- X return;
- X }
- X if (line[0] != '#') { /* lines with '#' are comments */
- X sscanf(line, "summon_%s%d%d", spirit.type, &level, &spirit.cost);
- X /* now we either get the spirit, or skip until the "end" of it */
- X /* now see if the line starts with a "summon_" */
- X if (strncmp(line, "summon_", strlen("summon_")) == 0) {
- X /* add it to the user's spirit list (if they deserve) */
- X if (level <= skill) {
- X if (up->spirit_list == NULL) {
- X up->spirit_list = (Sspirit *) malloc(sizeof(Sspirit));
- X *(up->spirit_list) = spirit;
- X up->spirit_list->next = NULL;
- X } else {
- X tmp_spirit = up->spirit_list;
- X while (tmp_spirit != NULL) { /* find end of list */
- X if (tmp_spirit->next == NULL) {
- X tmp_spirit->next = (Sspirit *) malloc(sizeof(Sspirit));
- X spirit.next = NULL; /* making sure */
- X *(tmp_spirit->next) = spirit;
- X break;
- X }
- X tmp_spirit = tmp_spirit->next;
- X }
- X }
- X }
- X }
- X }
- X }
- X fclose(fp);
- X}
- X
- X
- X /* show a user's collection of spells and spirits */
- Xlist_user_spells(up)
- X Suser *up;
- X{
- X Sspell *tmp_spell;
- X Sspirit *tmp_spirit;
- X
- X printf("Spells for Nation %s, of magic order %s:\n",
- X up->np->name, up->np->mag_order);
- X for (tmp_spell = up->spell_list; tmp_spell != NULL;
- X tmp_spell = tmp_spell->next) {
- X show_spell(tmp_spell);
- X }
- X printf("Spirits available to %s, of magic order %s:\n",
- X up->np->name, up->np->mag_order);
- X for (tmp_spirit = up->spirit_list; tmp_spirit != NULL;
- X tmp_spirit = tmp_spirit->next) {
- X show_spirit(tmp_spirit);
- X }
- X}
- X
- Xshow_spell(spellp)
- X Sspell *spellp;
- X{
- X int i;
- X
- X printf("Spell <%s>, cost %d\n",
- X spellp->name, spellp->cost);
- X}
- Xshow_spirit(spiritp)
- X Sspirit *spiritp;
- X{
- X int i;
- X
- X/* printf("Spirit <%s>, level %d, cost %d\n",
- X spiritp->type, spiritp->level, spiritp->cost);
- X for (i = 0; i < spiritp->n_lines; ++i) {
- X printf("%s", spiritp->lines[i]);
- X }
- X*/
- X printf("removed, since spirit/spell system has changed");
- X}
- X
- X /* at startup, this reads the spirit_types[] from a file */
- Xload_spirit_types()
- X{
- X FILE *fp, *fopen();
- X char line[210];
- X int i;
- X
- X if ((fp = fopen(SPIRIT_TYPES_FILE, "r")) == NULL) {
- X printf("cannot open spirit types file. quitting.\n");
- X perror("load_spirit_types");
- X clean_exit();
- X exit(1);
- X }
- X
- X do {
- X fgets(line, 200, fp);
- X } while (line[0] == '#');
- X /* we should have the line with the number of spirit types in file */
- X sscanf(line, "%d", &user.n_spirit_types);
- X
- X spirit_types =
- X (struct spirit_type *) malloc(user.n_spirit_types*sizeof(struct spirit_type));
- X
- X for (i = 0; i < user.n_spirit_types; ) {
- X fgets(line, 100, fp);
- X line[strlen(line)-1] = '\0';
- X if (line[0] != '#') { /* ignore comments */
- X sscanf(line,"%s : %1s : %d : %f : %d : %d : %d : %d : %d",
- X spirit_types[i].type, &spirit_types[i].type_char,
- X &spirit_types[i].size, &spirit_types[i].move_factor,
- X &spirit_types[i].bonus,
- X &spirit_types[i].spell_pts_draft, &spirit_types[i].jewel_draft,
- X &spirit_types[i].jewel_maint, &spirit_types[i].flags);
- X ++i;
- X }
- X }
- X
- X fclose(fp);
- X}
- X
- X /* returns true if this nation can draft that type of spirit */
- Xis_valid_spirit_type(np, type)
- X Snation *np;
- X char type[];
- X{
- X int i;
- X
- X /* for now, the all spirit types are fair game */
- X for (i = 0; i < user.n_spirit_types; ++i) {
- X if (strncmp(spirit_types[i].type, type, NAMELEN) == 0) {
- X return 1; /* got it!!! */
- X }
- X }
- X return 0; /* we did not find that spirit type */
- X}
- END_OF_FILE
- if test 9209 -ne `wc -c <'maglib.c'`; then
- echo shar: \"'maglib.c'\" unpacked with wrong size!
- fi
- # end of 'maglib.c'
- fi
- if test -f 'root.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'root.c'\"
- else
- echo shar: Extracting \"'root.c'\" \(11313 characters\)
- sed "s/^X//" >'root.c' <<'END_OF_FILE'
- X /* root.c -- special super-user commands */
- X
- X/*
- X * Copyright (C) 1990 Free Software Foundation, Inc.
- X * Written by the dominion project.
- X *
- X * This file is part of dominion.
- X *
- X * dominion is free software; you can redistribute it and/or
- X * modify it under the terms of the GNU General Public License as published
- X * by the Free Software Foundation; either version 1, or (at your option)
- X * any later version.
- X *
- X * This software is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this software; see the file COPYING. If not, write to
- X * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- X */
- X
- X#include "dominion.h"
- X
- X#include <stdio.h>
- X
- Xextern Sworld world;
- Xextern Suser user;
- X
- Xroot_edit()
- X{
- X WINDOW *rew;
- X char s[EXECLEN];
- X int done = 0;
- X
- X rew = newwin(6, COLS-20, LINES/4, 10);
- X touchwin(rew);
- X while (!done) {
- X werase(rew);
- X sprintf(s, "Root Editing");
- X wmove(rew, 1, (COLS/2-20-strlen(s))/2);
- X wstandout(rew);
- X waddstr(rew, s);
- X wstandend(rew);
- X mvwaddstr(rew, 3, 3, "Edit [s]ector or [n]ation? ");
- X wrefresh(rew);
- X switch (getch()) {
- X case 's':
- X root_edit_sector();
- X break;
- X case 'n':
- X root_edit_nation();
- X break;
- X case ' ':
- X done = 1;
- X break;
- X default:
- X break;
- X }
- X }
- X delwin(rew);
- X touch_all_wins(stdscr);
- X}
- X
- Xroot_edit_sector()
- X{
- X WINDOW *resw;
- X int pop_change, done = 0, new_owner, change;
- X
- X Ssector *sp = &world.map[user.cursor.x][user.cursor.y];
- X
- X resw = newwin(8, COLS-2, LINES-10, 1);
- X touchwin(resw);
- X
- X while (!done) {
- X werase(resw);
- X mvwaddstr(resw, 5, 2, "Change: [p]opulation, [o]wner ");
- X mvwaddstr(resw, 6, 2, " [s]oil, [m]etal, [j]ewels, [a]ltitude");
- X/* box(resw, 'R', 'R'); */
- X wrefresh(resw);
- X switch (getch()) {
- X case 'p':
- X mvwprintw(resw, 1, 1, "Sector (%d,%d), pop=%d, what population change? ",
- X sp->loc.x, sp->loc.y, sp->n_people);
- X wrefresh(resw);
- X if (wget_number(resw, &pop_change) > 0) {
- X sp->n_people += pop_change;
- X cpeople_sector(sp, pop_change);
- X }
- X break;
- X case 'o':
- X mvwprintw(resw, 1, 1, "Sector (%d,%d), owner=%d, which new owner id? ",
- X sp->loc.x, sp->loc.y, sp->owner);
- X wrefresh(resw);
- X if (wget_number(resw, &new_owner) > 0 && new_owner <= world.n_nations) {
- X /* 1. remove from old owner's list
- X 2. add to new owner's list
- X */
- X if (sp->owner != 0) {
- X subtsector(&world.nations[sp->owner], sp->loc.x, sp->loc.y);
- X }
- X sp->owner = new_owner;
- X cowner_sector(sp, new_owner);
- X if (new_owner != 0) { /* nation 0 has no sector list */
- X addsector(&world.nations[new_owner], sp->loc.x, sp->loc.y);
- X }
- X }
- X break;
- X case 's':
- X mvwprintw(resw, 1, 1, "Sector (%d,%d), soil=%d, what soil change? ",
- X sp->loc.x, sp->loc.y, sp->soil);
- X wrefresh(resw);
- X if (wget_number(resw, &change) > 0) {
- X sp->soil += change;
- X csoil_sector(sp, change);
- X }
- X break;
- X case 'm':
- X mvwprintw(resw, 1, 1, "Sector (%d,%d), metal=%d, what metal change? ",
- X sp->loc.x, sp->loc.y, sp->metal);
- X wrefresh(resw);
- X if (wget_number(resw, &change) > 0) {
- X sp->metal += change;
- X cmetal_sector(sp, change);
- X }
- X break;
- X case 'j':
- X mvwprintw(resw, 1, 1, "Sector (%d,%d), jewels=%d, what jewels change? ",
- X sp->loc.x, sp->loc.y, sp->jewels);
- X wrefresh(resw);
- X if (wget_number(resw, &change) > 0) {
- X sp->jewels += change;
- X cjewels_sector(sp, change);
- X }
- X break;
- X case 'a':
- X mvwprintw(resw,1,1,"Sector (%d,%d), altitude=%d, what altitude change? ",
- X sp->loc.x, sp->loc.y, sp->altitude);
- X wrefresh(resw);
- X if (wget_number(resw, &change) > 0) {
- X sp->altitude += change;
- X caltitude_sector(sp, change);
- X }
- X break;
- X case ' ':
- X done = 1;
- X break;
- X default:
- X break;
- X }
- X }
- X delwin(resw);
- X touch_all_wins(stdscr);
- X refresh();
- X}
- X
- X /* allows the game master to tinker with a nation */
- Xroot_edit_nation()
- X{
- X WINDOW *renw;
- X int done = 0, change, id;
- X Snation *np;
- X char name[NAMELEN], s[EXECLEN];
- X char c;
- X
- X Ssector *sp = &world.map[user.cursor.x][user.cursor.y];
- X
- X renw = newwin(9, COLS-2, LINES-12, 1);
- X touchwin(renw);
- X mvwaddstr(renw, 1, 3, "Which nation (id) do you want to change? ");
- X wrefresh(renw);
- X if (wget_number(renw, &id) < 0) {
- X return;
- X }
- X np = &world.nations[id];
- X while (!done) {
- X werase(renw);
- X mvwprintw(renw, 1, 6, "Editing nation %s [%c]", np->name, np->mark);
- X switch (np->npc_flag) {
- X case NPC_NOMAIL:
- X wprintw(renw, " [npc] ");
- X break;
- X case NPC_MAIL:
- X wprintw(renw, " [npc+mail]");
- X break;
- X case NOT_NPC:
- X default:
- X wprintw(renw, " ");
- X break;
- X }
- X/* np->npc_flag ? "npc" : "not npc"); */
- X mvwaddstr(renw, 4, 2,
- X "Change: [N]ame, [p]assword, [D]estroy, [t]oggle npc");
- X mvwaddstr(renw, 5, 2, " [s]heckles, [m]etal, [j]ewels, [f]ood");
- X mvwaddstr(renw, 6, 2, " [T]ech skill, [M]ag skill, [S]pell pts");
- X mvwaddstr(renw, 7, 2, " [d]iplomacy, mag. [o]rder, nation mar[k]");
- X if (np->npc_flag) {
- X mvwaddstr(renw, 8, 2, " [a]ggressiveness");
- X/* mvwaddstr(renw, 8, 2,
- X "[a]ggressiveness, [e]xpansionism, [i]solationism");
- X */
- X }
- X/* box(renw, 'R', 'R'); */
- X wrefresh(renw);
- X switch (getch()) {
- X case 'N':
- X mvwprintw(renw, 1, 1, "Give new name for nation: ");
- X wrefresh(renw);
- X if (wget_name(renw, name) > 0) {
- X strcpy(np->name, name);
- X sprintf(s, "NATION_NAME:%d:%s\n", np->id, name);
- X gen_exec(s);
- X }
- X break;
- X case 'p':
- X change_passwd(np, renw);
- X break;
- X case 'D':
- X root_destroy_nation(np, renw);
- X break;
- X case 't': /* rotate values for the npc flag */
- X np->npc_flag = (np->npc_flag + 1) % 3;
- X/* np->npc_flag = !np->npc_flag; */
- X if (np->npc_flag) {
- X sprintf(s, "SET_NPC:%d\n", np->id);
- X } else {
- X sprintf(s, "CLEAR_NPC:%d\n", np->id);
- X }
- X gen_exec(s);
- X break;
- X case 's':
- X mvwprintw(renw, 1, 1, "Nation's money=%d; what change? ", np->money);
- X wrefresh(renw);
- X if (wget_number(renw, &change) > 0) {
- X np->money += change;
- X cmoney(np, change);
- X }
- X break;
- X case 'm':
- X mvwprintw(renw, 1, 1, "Nation's metal=%d; what change? ", np->metal);
- X wrefresh(renw);
- X if (wget_number(renw, &change) > 0) {
- X np->metal += change;
- X cmetal(np, change);
- X }
- X break;
- X case 'j':
- X mvwprintw(renw, 1, 1, "Nation's jewels=%d; what change? ", np->jewels);
- X wrefresh(renw);
- X if (wget_number(renw, &change) > 0) {
- X np->jewels += change;
- X cjewels(np, change);
- X }
- X break;
- X case 'f':
- X mvwprintw(renw, 1, 1, "Nation's food=%d; what change? ", np->food);
- X wrefresh(renw);
- X if (wget_number(renw, &change) > 0) {
- X np->food += change;
- X cfood(np, change);
- X }
- X break;
- X case 'T':
- X mvwprintw(renw, 1, 1, "Nation's tech skill=%d; what change? ",
- X np->tech_skill);
- X wrefresh(renw);
- X if (wget_number(renw, &change) > 0) {
- X np->tech_skill += change;
- X ctech_skill(np, change);
- X }
- X break;
- X case 'M':
- X mvwprintw(renw, 1, 1, "Nation's mag skill=%d; what change? ",
- X np->mag_skill);
- X wrefresh(renw);
- X if (wget_number(renw, &change) > 0) {
- X np->mag_skill += change;
- X cmag_skill(np, change);
- X }
- X break;
- X case 'S':
- X mvwprintw(renw, 1, 1, "Nation's spell pts=%d; what change? ",
- X np->spell_pts);
- X wrefresh(renw);
- X if (wget_number(renw, &change) > 0) {
- X np->spell_pts += change;
- X cspell_pts(np, change);
- X }
- X break;
- X case 'o': /* change magic order */
- X do {
- X mvwprintw(renw, 1, 1, "Give new magic order (currently %s) ",
- X np->mag_order);
- X wclrtoeol(renw);
- X wrefresh(renw);
- X wget_name(renw, name);
- X } while (!is_good_order(name));
- X strcpy(np->mag_order, name);
- X sprintf(s, "NATION_ORDER:%d:%s\n", np->id, name);
- X gen_exec(s);
- X break;
- X case 'k': /* change nation mark */
- X mvwprintw(renw, 1, 1, "Give new nation mark ");
- X wclrtoeol(renw);
- X wrefresh(renw);
- X fflush(stdin);
- X do {
- X c = getchar();
- X putchar(c);
- X } while (!free_nation_mark(&world, c));
- X np->mark = c;
- X sprintf(s, "NATION_MARK:%d:%c\n", np->id, c);
- X gen_exec(s);
- X break;
- X case 'd':
- X diplo_report(np);
- X break;
- X case 'a':
- X if (np->npc_flag) {
- X set_aggressiveness(np, renw);
- X }
- X break;
- X case ' ':
- X done = 1;
- X break;
- X default:
- X break;
- X }
- X }
- X delwin(renw);
- X touch_all_wins();
- X refresh();
- X}
- X
- X /* here are some exec lines available only to the Gamemaster */
- Xcowner_sector(sp, owner)
- X Ssector *sp;
- X int owner;
- X{
- X char s[EXECLEN];
- X
- X sprintf(s, "COWNER_SECTOR:%d:%d:%d\n", sp->loc.x, sp->loc.y, owner);
- X gen_exec(s);
- X}
- X
- Xcsoil_sector(sp, change)
- X Ssector *sp;
- X int change;
- X{
- X char s[EXECLEN];
- X
- X sprintf(s, "CSOIL_SECTOR:%d:%d:%d\n", sp->loc.x, sp->loc.y, change);
- X gen_exec(s);
- X}
- X
- Xcmetal_sector(sp, change)
- X Ssector *sp;
- X int change;
- X{
- X char s[EXECLEN];
- X
- X sprintf(s, "CMETAL_SECTOR:%d:%d:%d\n", sp->loc.x, sp->loc.y, change);
- X gen_exec(s);
- X}
- X
- Xcjewels_sector(sp, change)
- X Ssector *sp;
- X int change;
- X{
- X char s[EXECLEN];
- X
- X sprintf(s, "CJEWELS_SECTOR:%d:%d:%d\n", sp->loc.x, sp->loc.y, change);
- X gen_exec(s);
- X}
- X
- Xcaltitude_sector(sp, change)
- X Ssector *sp;
- X int change;
- X{
- X char s[EXECLEN];
- X
- X sprintf(s, "CALTITUDE_SECTOR:%d:%d:%d\n", sp->loc.x, sp->loc.y, change);
- X gen_exec(s);
- X}
- X
- X /* this is serious: destroy a nation, interactively, as super user */
- Xroot_destroy_nation(np, renw)
- X Snation *np;
- X WINDOW *renw;
- X{
- X char c;
- X char s[EXECLEN];
- X
- X mvwaddstr(renw, 3, 4, "Are you quite sure? This is serious!!! ");
- X wrefresh(renw);
- X if ((c = wgetch(renw)) == 'y' || c == 'Y') {
- X mvwaddstr(renw, 4, 6, "Confirm again, dude: ");
- X wrefresh(renw);
- X if ((c = wgetch(renw)) == 'y' || c == 'Y') {
- X destroy_nation(np->id);
- X sprintf(s, "DESTROY:%d\n", np->id);
- X gen_exec(s);
- X }
- X }
- X}
- X
- X /* allow the nation's aggressiveness to be modified. we
- X will make a new window so that this can be called from
- X various different places (such as the root editing and
- X the info report).
- X */
- Xset_aggressiveness(np, current_win)
- X Snation *np;
- X WINDOW *current_win; /* for redrawing purposes */
- X{
- X WINDOW *aggw;
- X int aggr;
- X char s[EXECLEN];
- X
- X aggw = newwin(8, 30, LINES-14, 10);
- X touchwin(aggw);
- X mvwprintw(aggw, 3, 3, "Current aggressiveness %d", np->npc_agg);
- X mvwprintw(aggw, 4, 3, "Give new value: ");
- X box(aggw, '|', '-');
- X wrefresh(aggw);
- X if (wget_number(aggw, &aggr) < 0) { /* if user types nothing or bad value */
- X delwin(aggw);
- X touchwin(current_win);
- X return;
- X }
- X /* set the new value and make sure we don't overflow */
- X np->npc_agg = aggr;
- X np->npc_agg = min(np->npc_agg, 100);
- X np->npc_agg = max(np->npc_agg, 0);
- X sprintf(s, "NPC_PARAM:%d:%d:%d:%d\n", np->id, np->npc_agg,
- X np->npc_exp, np->npc_iso);
- X gen_exec(s);
- X delwin(aggw);
- X touchwin(current_win);
- X return;
- X}
- END_OF_FILE
- if test 11313 -ne `wc -c <'root.c'`; then
- echo shar: \"'root.c'\" unpacked with wrong size!
- fi
- # end of 'root.c'
- fi
- echo shar: End of archive 25 \(of 28\).
- cp /dev/null ark25isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 28 archives.
- echo "Now execute ./do_cat.sh to build doc files"
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-