billr@saab.CNA.TEK.COM (Bill Randle) (07/19/89)
Submitted-by: VANCLEEF@mps.ohio-state.edu Posting-number: Volume 7, Issue 50 Archive-name: GB2/Part07 #! /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 7 (of 8)." # Contents: Docs/build.doc Docs/declare.doc Docs/enslave.doc # Docs/help.doc Docs/orbit.doc Docs/order.doc Docs/profile.doc # Docs/scope.doc Docs/survey.doc GB.c autoreport.c declare.c # enroll.dat examine.c explore.c files_rw.c max.c mobiliz.c more.c # moveplanet.c prof.c telegram.c # Wrapped by billr@saab on Thu Jul 6 07:39:55 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Docs/build.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Docs/build.doc'\" else echo shar: Extracting \"'Docs/build.doc'\" \(2186 characters\) sed "s/^X//" >'Docs/build.doc' <<'END_OF_FILE' XBUILD Galactic Bloodshed BUILD X X XNAME X [1] build -- construct a ship X XSYNTAX X build [type] [x,y] X XDESCRIPTION X build enables the user to construct a ship on the current scope (ship Xor planet) provided there are enough resources there to do so. X X If the ship type is not specified, build will prompt for one. At this Xpoint typing a '?' will produce a list of the different ship types, their Xcapabilities, and their resource cost in the 'cost' column. Ships are Xidentified by their letter. The player can also get a short paragraph Xdescription of a ship by typing a '?' and the ship letter. X X If there are enough resources, build will now ask the sector on which Xthe player wishes to construct the ship. This sector must belong to the Xplayer and be an area that can support his race. X X At this point the resource point cost will be deducted from the player's Xstockpiles. The ``load'' should be used after building, since many ships Xrequire at least one crew member to operate, and the player may wish to Xput fuel and weapons aboard. X X A short explanation of ship capabilities: X Xltr ship carg armr dstcap guns mass fuelcap ^crew tech speed cost X s Shuttle 40 1 2 1 10 20 25 15 2 50 X X ltr: Ship letter used to identfy the ship. This is the letter you must X type in to choose that ship. X ship: A short descriptive name for that type of ship. X carg: Maximum cargo (resources) the ship can carry (see ``load''). X armr: Resistance to damage in a straight ratio; the higher, the better. X dstcap: Maximum destructive capacity (weapons) the ship can carry. X guns: Amount of destructive capacity the ship can fire at once. X mass: Weight of the ship (in Standard Units). Heavier ships move slower. This X value changes as things are loaded/unloaded on the ship. X fuelcap: Maximum fuel the ship can carry. X mintech: You must be at this tech or above to build the ship. X cost: Amount of resource points required to build. X speed: the speed rating of the ship; it cannot be ordered to a value X greater than this number. X ^crew: Maximum number of crew (or tons of biomass) the ship can carry. X X X XSEE ALSO X load, stock, report, ship X END_OF_FILE if test 2186 -ne `wc -c <'Docs/build.doc'`; then echo shar: \"'Docs/build.doc'\" unpacked with wrong size! fi # end of 'Docs/build.doc' fi if test -f 'Docs/declare.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Docs/declare.doc'\" else echo shar: Extracting \"'Docs/declare.doc'\" \(1607 characters\) sed "s/^X//" >'Docs/declare.doc' <<'END_OF_FILE' XDECLARE Galactic Bloodshed DECLARE X X XNAME X [1] declare -- state relations with other players X XSYNTAX X declare X XDESCRIPTION X X The friction between two disparate races competing for the same limited Xresources may be such that no matter what diplomatic means exist between Xthem (telegram), conflict may still ensue. X X To facilitate this, a player may declare his/her race's intentions toward Xother players in the game, whether allied, neutral, or at war. X X When invoked, a prompt will ask how he wishes his relations to be with that Xplayer, and the player number. This will be in effect until the user changes Xhis/her mind. X X A state of war affects planetary and interstellar conflict in different ways. XFor example, if a player shares a planet with another, migration from sector Xto sector will halt upon reaching the sectors belonging to the other player Xif the players are neutral toward each other or allied. If they are at war, Xhowever, the sectors will be contested. Lives will be lost on both sides, and Xsectors are likely to be damaged. X X Likewise, ship-to-ship conflict is likely between races that are at war. XWhen a ship comes in range of another ship belonging to a player with which Xthe first ship's owning player is at war, it will fire, generally once per Xturn, until the enemy ship is disabled, out of range, or the war called off. X X Allies are prompted before firing on one another, and ships/planets fired Xupon by allies will not fire back (they wish to avoid a diplomatic incident, Xuntil otherwise ordered by the user). X X X XSEE ALSO X telegram, order, fire, attack X END_OF_FILE if test 1607 -ne `wc -c <'Docs/declare.doc'`; then echo shar: \"'Docs/declare.doc'\" unpacked with wrong size! fi # end of 'Docs/declare.doc' fi if test -f 'Docs/enslave.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Docs/enslave.doc'\" else echo shar: Extracting \"'Docs/enslave.doc'\" \(1607 characters\) sed "s/^X//" >'Docs/enslave.doc' <<'END_OF_FILE' XENSLAVE Galactic Bloodshed ENSLAVE X X XNAME X [1] enslave -- enslave a world X XSYNTAX X enslave [ship #] X XDESCRIPTION X This command is used to convert entire planets to a condition of slavery. XWhen invoked the ship specified must be an Orbital Assault Platform, which Xis the only ship type sufficiently impressive to convince the planetary Xpopulation of the futility of resistance. The platform must be orbiting Xthe planet to be enslaved. X X To commence a proper enslavement, the forces bearing (the platform itself Xplus the other ships which might be orbiting the planet) against the Xplanet must be more than twice the defending strength (weapons under the Xcontrol of the inhabitants plus the weapons on board any ships they own in Xorbit around the planet). The enslaving player is not told how much strength Xthe other players might have, but he is told whether the planet was enslaved Xor not. Telegram messages are sent to any players affected by the command. X X To keep the planet the enslaving player must maintain a garrison of at Xleast 0.1% of the total population on the planet. If the garrison EVER falls Xbelow this threshold, a revolution is immediate and devastating: all sectors Xbelonging to the former slave holder are destroyed in the inhabitants' fury Xof revolution. Other random sectors might be damaged as well in the fight. X X When a planet is under enslavement, everything produced there will be Xcredited to the slave-holding player's stockpiles. Races enslaved on a Xplanet can still survey, map, and otherwise observe things happening there X(there is an active resistance). X X END_OF_FILE if test 1607 -ne `wc -c <'Docs/enslave.doc'`; then echo shar: \"'Docs/enslave.doc'\" unpacked with wrong size! fi # end of 'Docs/enslave.doc' fi if test -f 'Docs/help.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Docs/help.doc'\" else echo shar: Extracting \"'Docs/help.doc'\" \(2437 characters\) sed "s/^X//" >'Docs/help.doc' <<'END_OF_FILE' XGalactic.Bloodshed commands: X X X () or none -required arguments. []-optional arguments. X xlow:xhi,ylow:yhi-means a range of sectors from xlow to xhi, and ylow to X yhi. also legal: x,y xlow:xhi,y x,ylow:yhi X path : a scope path; separated by '/'. ex: /sol/Earth means system sol, planet X Earth; ../Mars means the scope above you, planet (or star for that X matter) Mars. these may be abbreviated. Substitute ':' for the X current scope you are in for any command. 'path' can be substituted X with '#(shipno)' for many commands. X X Xsurvey [xlow:xhi,ylow:yhi] -- look at survey on range of sectors or planet X or star. X Xbuild [shiptypeletter] [x,y] -- build a ship/object. X Xscrap [#shipnum] -- turn a ship/object into scrap. X Xcs ([#(shipnumber)|[:]|[/]|[..]|[planetname]|[starname]|[/] etc.) -- X change scope. ( ".." = up one; X ':' = current scope; X <name> = down to planet or star, X #(shipnumber) = that ship number.) X Xdeclare -- state relations (alliance, neutrality, war) to other players. X Xfire -- fire from ship or planet, to ship or planet X Xload [#shipnum] -- load/unload commodities from ship. X Xlaunch [#shipnum] -- launch a ship from a planet or the ship it is docked with. X Xland [#shipnum] [x,y] -- land a ship on a planet, sector x,y. X Xmobilize -- build up military readiness in sectors. X Xmap [path] -- look at sector map if [path] is a planet; use orbit otherwise. X Xname -- rename an object (star or planet). X Xorbit [options] [path] -- graphic representation of ship and planet positions. X Xorder [ #shipnum ] -- send orders to ships: turn them on/off, X navigation, speed setting, various other things dependent X on the type of ship. X Xprofile -- racial profile. X Xpower -- report of all races and their approximate influence in the game. X Xstock [#shipnumber] -- ship report. X Xread -- read telegram messages. X Xrelation -- report on the relations between your player and the other players X in the game; also translation modifiers. X Xreport [#shipnumber] -- navigational ship report. X Xtactical [#shipnumber] -- tactical report of enemy ships within range of yours. X Xtelegram [ path | playername | player# ] -- send a message to another player, X or to whomever resides in (path): if ship, the owner of the ship, X if planet, anyone inhabiting it, X if star, anyone with colonies/ships X there. X Xzoom (amount) | (numerator/denominator) -- zoom in/out for orbit display. X Xquit -- quit. X Xhelp -- this file. X END_OF_FILE if test 2437 -ne `wc -c <'Docs/help.doc'`; then echo shar: \"'Docs/help.doc'\" unpacked with wrong size! fi # end of 'Docs/help.doc' fi if test -f 'Docs/orbit.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Docs/orbit.doc'\" else echo shar: Extracting \"'Docs/orbit.doc'\" \(2154 characters\) sed "s/^X//" >'Docs/orbit.doc' <<'END_OF_FILE' X XORBIT Galactic Bloodshed ORBIT X X XNAME X [0] orbit -- Graphic representation of objects in current scope X XSYNOPSIS X orbit [-n] [-S] [-p] [-s] [-ship/planet number] [path] X XDESCRIPTION X X Orbit gives a visual map of all stars, planets, and ships in the scope Xof ``path'' or the current scope if none is specified. You cannot map an Xarea that has not been visited by one of your ships. X X If ``path'' is the root, ``orbit'' will show all the stars in the game, Xand all ships travelling in interstellar space that belong to the player. X X If ``path'' is a star, orbit will display the solar system there Xwith its star in the center and orbiting planets around it, plus all ships Xthat are the player's (or can be detected). X X If ``path'' is a planet orbit will display that planet and orbiting Xships. X X If ``path'' is in the form ``#shipnum'' orbit will display a map of Xwhichever system or planet the ship is at. X X If no path has been specified, the current scope is used, and display will Xbe centered around the current ``lastx,lasty'' coordinates. These coordinates Xrepresent the x,y location of the last scope the player was in. For instance, Xif a player types the following: X X [xx] / >cs #5/.. X [yy] / Sol / Sol-III >orbit X X The orbit display will be centered around the location of ship #5. X X When no path is specified, the zoom factor comes into play as well. Display Xwill appear larger or smaller according to the zoom factor (1.0 being normal). XIf there is a specified path argument to orbit, zoom and last coordinates are Xnot dealt with. (It is as if they are 0,0 and 1.0, respectively.) X X X OPTIONS X X when invoking ``orbit'' the options given (except for ``-(number)'') can be Xeither in the form "-pSs" or spread out as in "-p -S -s -3". X X X -p : If this option is set, ``orbit'' will not display planet names. X X -S : Do not display star names. X X -s : Do not display ships. X X -(number) : Do not display that #'d ship or planet (should it obstruct X the view of another object). Stars or planets are numbered X sequentially from 1, while ships can be referenced by their X ship number. X X XSEE ALSO X map, cs, scope, zoom X END_OF_FILE if test 2154 -ne `wc -c <'Docs/orbit.doc'`; then echo shar: \"'Docs/orbit.doc'\" unpacked with wrong size! fi # end of 'Docs/orbit.doc' fi if test -f 'Docs/order.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Docs/order.doc'\" else echo shar: Extracting \"'Docs/order.doc'\" \(1899 characters\) sed "s/^X//" >'Docs/order.doc' <<'END_OF_FILE' XORDER Galactic Bloodshed ORDER X X XNAME X [1] order -- give ships standing orders X XSYNTAX X order [#shipnum] X XDESCRIPTION X ``order'' gives standing orders to the ship specified. If no ship Xis specified, ``order'' will prompt for the orders of all ships at and below Xthe current scope. The program will prompt for changes in orders in Xeach case. X X Currently the orders that can be changed are: X X (d)estination -- The ship will attempt to move towards the star/planet X specified. X X (s)peed -- Typing a '?' at this point gives help on the speed settings. X speed cannot be higher than the speed rating of the ship. X X The following order can not be made on space mirror ships: X X X (b)ombard -- if bombard is on and the ship is in orbit around a planet, X the ship will fire at the planet, targetting at sectors belonging to X players indicated in that player's war status. X X The following two orders can only be made to space mirrors: X X (a)im at -- change focus to the named object (0.3 fuel for maneuvering.) X Space mirrors can only have effect on objects within the same X solar system. Ships being focused on will take a certain amount X of damage per turn, and planets will experience a temperature change X corresponding to the intensity. X X (i)ntensity -- change degree of focus for a space mirror. X X X Action Points are deducted from the root and each star. No more than Xthe normal AP cost will be deducted from the root or each star, no matter Xhow many ship's orders are changed in each. X X Ships that are landed or docked cannot be given orders. X X To give orders to an object (other than a ship), the object number must Xbe specified, i.e. ``order #n'', where n is the number of some valid object. XObjects can be given orders whether landed or not, and the valid orders which Xcan be given, can be quite different from those given to regular ships. X X XSEE ALSO X scope, actionpoints X END_OF_FILE if test 1899 -ne `wc -c <'Docs/order.doc'`; then echo shar: \"'Docs/order.doc'\" unpacked with wrong size! fi # end of 'Docs/order.doc' fi if test -f 'Docs/profile.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Docs/profile.doc'\" else echo shar: Extracting \"'Docs/profile.doc'\" \(2506 characters\) sed "s/^X//" >'Docs/profile.doc' <<'END_OF_FILE' XPROFILE Galactic Bloodshed PROFILE X X XNAME X [0] profile -- racial profile X XSYNTAX X profile X XDESCRIPTION X This command prints out a short summary of your race's major characteristics. XA short explanation of the profile follows: X XThe Thing -- This means your race is mesomorphic, like John Carpenter's 'The X Thing'. You will receive certain bonuses, such as a high birthrate, X above-average fighting ability (as well as the ability to absorb your X enemies' population), and the ability to grow and launch spore pods; X but you will also have a very low intelligence. X XInfection/birth rate -- the rate at which your people reproduce themselves. X If this value is .5, each turn (resources willing) your population X will increase by 1.5. X X# of sexes -- This is the minimum population a planetary sector must have X before the population will increase. Colonies with fewer than this X amount will not be successful. Example: human beings must have at X least two members to be a successful colony, while members of the X Cetellan race ("Literature", by Robert Chansky, in X ~smq/public/alien.pornography) must have at least 35. X XTechnology -- This represents the technological achievement of your people. X Certain types of ships cannot be built without the appropriate X technology. X XAvg Intelligence -- This is the average IQ (human standard scale) of the X members of your race. Technology will increase by IQ/100 each turn. X XMass -- The average weight of individual members of your race (in Standard X Units). This is used in mass exchanges in ships (i.e., a heavier X ship moves more slowly for the same amount of fuel) in the ``load'' X command. X XMetabolism -- The speed at which your race ``operates''. A higher metabolism X means your race produces commodities at a correspondingly higher X rate. X XAdventurists -- This has to do with migration of your race across the X face of a planet. It represents the percentage of the population X that wish to move elsewhere. More sedentary races will have X a lower value, while energetic, conquering races (like 'The Thing') X will have a higher value. X Xdefault scope -- The scope changed to when the user types ``cs''. X Xplanetary conditions -- This is a list of the atmospheric and temperature X conditions perferred by your race. A planet that deviates from X these conditions by a sufficient amount will be unlivable by your X race. Planetary conditions are displayed with the ``survey'' command. X X X X XSEE ALSO X build, load, cs, survey, declare, relation X END_OF_FILE if test 2506 -ne `wc -c <'Docs/profile.doc'`; then echo shar: \"'Docs/profile.doc'\" unpacked with wrong size! fi # end of 'Docs/profile.doc' fi if test -f 'Docs/scope.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Docs/scope.doc'\" else echo shar: Extracting \"'Docs/scope.doc'\" \(1663 characters\) sed "s/^X//" >'Docs/scope.doc' <<'END_OF_FILE' Xscope Galactic Bloodshed scope X X XCONCEPT: scope X X Scope represents the ``operative scope'' of certain commands. The Xoperative scope (displayed along with AP's in the user's prompt, and changed Xwith ``cs'') is similar to the tree-like directory level structure found in Xmost computer systems, with the ``root'' directory being a ``universe'' Xscope followed by the various stars, followed by the planets orbiting these Xstars. The scope can also represent a single ship. X X Commands are affected by the scope in a different manner than that which Xoperating systems treat their directory structure. For example, if Xthe current scope is that of a star, the command ``order'', if given with Xno arguments, will prompt for orders for each ship orbiting that Xstar and each planet in that system. If the scope was the ``universal'' Xscope, order would prompt for each ship everywhere that the player owns. X X Many commands will work very differently, or not at all in certain scopes. X X The syntax of a scope, when prompted for, is thus: X X path = ``:'' | ``#shipnum'' | ``/path'' | ``../path'' | name | X ``path/name'' X X The shell will interpret a ``:'' as meaning the object of the current Xscope (star, planet, or ship). X X A ``/'' at the beginning of the string represents the root. It could be Xfollowed by a star name, or not, to represent the upper, interstellar, level. X X A ``..'' or ``.'' represents the scope just above the current scope. X X ``#shipnum'' represents that ship. A number by itself will be Xinterpreted as meaning a star or planet name. X X Specifying a name means to move down to that star or planet. X X XSEE ALSO X cs, order, actionpoints X END_OF_FILE if test 1663 -ne `wc -c <'Docs/scope.doc'`; then echo shar: \"'Docs/scope.doc'\" unpacked with wrong size! fi # end of 'Docs/scope.doc' fi if test -f 'Docs/survey.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Docs/survey.doc'\" else echo shar: Extracting \"'Docs/survey.doc'\" \(2497 characters\) sed "s/^X//" >'Docs/survey.doc' <<'END_OF_FILE' XSURVEY Galactic Bloodshed SURVEY X X XNAME X [0] survey -- more detailed survey of planet, sector, ship, star X XSYNOPSIS X survey [xlow:xhi,ylow:yhi] X XDESCRIPTION X survey gives a different report depending on what scope it is used on. XThe possible scopes are ship, planet, and star. X XCensus on sector X X x,y des eff mob frt res popn ^popn X 5,7 x 20 50 45 25 80 196 X X x,y: map coordinates on sector X des: designation of sector (land, water, etc) X eff: efficiency (%age it is built up) of the sector X mob: % mobilization of the citizens in that sector X frt: fertility of the sector (supports people) X res: resource deposits in the sector X popn: population of the sector X ^popn: maximum population the sector can support X XCensus on planet X X gravity x,y absolute x,y relative to Sol X 1.00 -24222,5424 -324,755 X X gravity: gravity of the planet (relative to Earth normal) X x,y absolute: coordinates relative to the Center of the Universe X x,y relative..: coordinates relative to the planet's primary X X ======== planetary conditions: ======== X Gives the atmospheric concentrations of certain key elements in the X planet's atmosphere: Oxygen, CO2, Methane, Hydrogen, Nitrogen, Helium, X Sulfur, surface temperature, normal temperature (without artificial X influencing factors like space mirrors), and 'Other'. The 'Total X planetary compatibility' is the difference between the weighted sum X of each of these characteristics and the preferences of the player X (expressed in parentheses after each characteristic). X X fuel_stock resource_stock dest_pot. popltn ^popltn X 173 92 101 1158 2901 X X x,y: the x,y coordinates of the planet relative to its star X fuel_stock: fuel the player has managed to stockpile on the planet X resource_stock: stockpiled resources on the planet X dest_pot: stockpiled destructive potential on the planet (weapons) X popltn: total population of living beings X ^popltn: maximum number of living beings the planet can support X (inhabited sectors only) X XCensus on star X X Locn: x,y coordinates of the star from the Center of the Universe X gravity: gravitational influence X stability: Stability of the star. As stability approaches 100, the star X will become more and more unstable. The player must have a technology X of 3 or more to determine the stability. X X XCensus on ship #n X X Same as the command 'ship #n' X XSEE ALSO X ship, report, map, weapons, mobilize END_OF_FILE if test 2497 -ne `wc -c <'Docs/survey.doc'`; then echo shar: \"'Docs/survey.doc'\" unpacked with wrong size! fi # end of 'Docs/survey.doc' fi if test -f 'GB.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'GB.c'\" else echo shar: Extracting \"'GB.c'\" \(2648 characters\) sed "s/^X//" >'GB.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@ssyx) X * GB.c -- X * main loop, prints instructions, grabs command line from X * standard output, executes command. X */ X X X#include "vars.h" X#include "races.h" X#include <curses.h> X#include <sys/stat.h> Xstruct stat buf; X#include <signal.h> X#include <strings.h> X#include <pwd.h> Xstruct passwd *passwd; X#include <setjmp.h> Xjmp_buf main_jenv; Xint God = 0; X Xextern char telegram_file[50]; X Xmain() X{ Xint notified=0,s,i; Xchar c,commstr[MAXCOMMSTRSIZE]; Xint maim_handler(); Xint maim_stardata; X X X setegid(PLAYER_GROUP_ID); X X srandom(getpid()); X initscr(); X X printf("Galactic Bloodshed ver %s\n type `help' for help.\n", VERS); X X/* printgame master messages */ X sprintf(commstr, " %s %s/%s*", PAGER, DOCS, "message.doc"); X system(commstr); X X printf(" type `help news' for latest GB updates and changes.\n"); X printf(" type `help install' for GB command installation.\n"); X printf("\n If you have unusual problems, send mail to `vancleef'.\n"); X X X openstardata(&maim_stardata); X getsdata(maim_stardata,&Sdata); X X for (s=0; s<Sdata.numstars; s++) X getstar(maim_stardata,&(Stars[s]),s); X close(maim_stardata); X X passwd = getpwuid(geteuid()); X if (!strcmp(passwd->pw_name, PLAYER_GOD)) { X X printf("Enter password: "); X scanf("%s",commstr); X getchr(); X X if(!strcmp(commstr, GOD_PASSWORD)){ X X God = 1; X printf("Login as what player? "); X scanf("%s",commstr); X getchr(); X X } else X sprintf(commstr,"%s", passwd->pw_name); X }else X sprintf(commstr,"%s", passwd->pw_name); X X i = Getracenum(commstr); X X if (!i) X enroll(commstr); X else X getrace(&Race,i); X Playernum = Race->Playernum; X if (God) X printf("Logging in as player %d.\n",Playernum); X X if(God) { X printf("Do you wish to use God capabilities? "); X scanf("%s",commstr); X getchr(); X if(!strcmp(commstr, "n")) X God=0; X } X X docommand("cs"); /* chdir to home scope */ X Dir.zoom = 1.1; X X setjmp(main_jenv); /* set up environment for jump if error */ X X sprintf(telegram_file, "%s.%d", TELEGRAMFL, Playernum); X /* used in several routines, + each csh command */ X X do { X signal(SIGINT, maim_handler ); X X stat(telegram_file, &buf); X if (buf.st_size > notified) { X printf("\nYou have telegram(s) waiting.\n\n"); X notified = buf.st_size; X } X X printf("%s",Dir.prompt); X i = 0; X while ((c=getchr()) != '\n' && i<MAXCOMMSTRSIZE) X commstr[i++] = c; X commstr[i] = '\0'; X if (*commstr==EOF) { X clearerr(stdin); X *commstr = '\0'; X } X X } while (docommand(commstr)); X X endwin(); X X X/* printf("\nhalelujah!\n\n");*/ X} X Xmaim_handler() X{ X tty_off(); X putchar('\n'); X longjmp(main_jenv,1); X} END_OF_FILE if test 2648 -ne `wc -c <'GB.c'`; then echo shar: \"'GB.c'\" unpacked with wrong size! fi # end of 'GB.c' fi if test -f 'autoreport.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'autoreport.c'\" else echo shar: Extracting \"'autoreport.c'\" \(1788 characters\) sed "s/^X//" >'autoreport.c' <<'END_OF_FILE' X X X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * autoreport.c -- tell server to generate a report for each planet X */ X X#include "vars.h" X#include "ships.h" X Xautoreport(APcount, argn,args) Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xplanettype *p; Xplacetype place; Xint autoreport_pdata,autoreport_sectdata; X Xif (argn==1) { /* no args */ X if (Dir.level==LEVEL_PLAN) { X openpdata(&autoreport_pdata); X getplanet(autoreport_pdata,&p,Stars[Dir.snum]->planetpos[Dir.pnum]); X if (p->info[Playernum-1].autorep) X p->info[Playernum-1].autorep = 0; X else X p->info[Playernum-1].autorep = TELEG_MAX_AUTO; X X putplanet(autoreport_pdata, p, Stars[Dir.snum]->planetpos[Dir.pnum]); X close(autoreport_pdata); X printf("Autoreport on %s is now %s.\n",Stars[Dir.snum]->pnames[Dir.pnum], X p->info[Playernum-1].autorep ? "on" : "off"); X free(p); X /* } else if (Dir.level==LEVEL_SHIP) { X openshdata(&autoreport_shdata); X getship(autoreport_shdata, [ ship-> autoreport field not specified yet] X */ X } else { X printf("scope must be a planet or ship.\n"); X return(1); X } X} else if (argn==2) { /* argn==2, place specified */ X place = Getplace(args[1], 0); X if (place.level==LEVEL_PLAN) { X openpdata(&autoreport_pdata); X getplanet(autoreport_pdata,&p,Stars[Dir.snum]->planetpos[Dir.pnum]); X printf("Autoreport on %s is now %s.\n",Stars[Dir.snum]->pnames[Dir.pnum], X p->info[Playernum-1].autorep ? "on" : "off"); X p->info[Playernum-1].autorep = !p->info[Playernum-1].autorep; X putplanet(autoreport_pdata, p, Stars[Dir.snum]->planetpos[Dir.pnum]); X close(autoreport_pdata); X free(p); X } else { X printf("scope must be a planet or ship.\n"); X return(1); X } X } else if (argn>2) { X printf("autoreport: error in args.\n"); X return(1); X } X X} END_OF_FILE if test 1788 -ne `wc -c <'autoreport.c'`; then echo shar: \"'autoreport.c'\" unpacked with wrong size! fi # end of 'autoreport.c' fi if test -f 'declare.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'declare.c'\" else echo shar: Extracting \"'declare.c'\" \(1824 characters\) sed "s/^X//" >'declare.c' <<'END_OF_FILE' X/* X** Galactic Bloodshed (Robert Chansky, smq@b) X** declare.c -- declare alliance, neutrality, war, the basic thing. X*/ X X#include "vars.h" X#include "races.h" X#include <signal.h> X#include <ctype.h> X#include <setjmp.h> Xextern jmp_buf main_jenv; X Xdeclare(APcount, argn,args) Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xvoid declare_handler(); Xchar str[RNAMESIZE]; Xracetype *alien; Xint n; X X signal(SIGINT, declare_handler); X X /* look in sdata for APs first */ X if (Sdata.AP[Playernum] >= APcount) /* enufAPs would print something */ X deductAPs(APcount, 0, 1); X /* otherwise use current star */ X else if (Dir.level==LEVEL_STAR && Dir.level==LEVEL_PLAN) { X if (enufAP(Stars[Dir.snum]->AP, APcount) ) X deductAPs(APcount, Dir.snum, 0); X } else { X printf("You don't have enough AP's (%d)\n",APcount); X declare_handler(); X } X X printf("declare with which player? "); X scanf("%25[^\n]", str); X getchr(); X GetPlayer(str, &n, &alien); X if (n == -1) { X printf("No such player.\n"); X return; X } X X printf("declare alliance, neutrality, or war on %s (%d)? ", alien->name, n); X scanf("%25s",str); X X switch (*str) { X case 'a': X setbit(Race->allied, n); X clrbit(Race->atwar, n); X if (int_rand(0,100) >= 96) X printf("But would you want your sister to marry one?\n"); X else X printf("Good for you.\n"); X break; X case 'n': X clrbit(Race->allied, n); X clrbit(Race->atwar, n); X printf("Done.\n"); X break; X case 'w': X setbit(Race->atwar, n); X clrbit(Race->allied, n); X if (int_rand(0,100) >= 96) X printf("Your enemies flaunt their secondary male reproductive glands in your\ngeneral direction.\n"); X else X printf("Give 'em hell!\n"); X break; X default: X declare_handler(); X break; X } X putrace(Race); X X} X X X Xvoid declare_handler() X{ X longjmp(main_jenv,1); X} END_OF_FILE if test 1824 -ne `wc -c <'declare.c'`; then echo shar: \"'declare.c'\" unpacked with wrong size! fi # end of 'declare.c' fi if test -f 'enroll.dat' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'enroll.dat'\" else echo shar: Extracting \"'enroll.dat'\" \(2607 characters\) sed "s/^X//" >'enroll.dat' <<'END_OF_FILE' X X X X X X X X X Welcome to X Galactic Bloodshed Version 0.975 X Written by Robert Chansky X X X X X X X X X X X X X X X X X X You look around in the slime. X X Isn't there, you think, something more to life? X Eradicating disease? Exploring the universe? A decent Pizza? X X You gather your followers and start on the road X to intelligence, to enlightenment, to purpose... X X X X X X X X X X X X X X X Choose what type of planet you prefer to live on: X X X Earth-type Planet X 000000000011111111112222222222333333333 X 012345678901234567890123456789012345678 X 0 ####################################### <-- Ice (polar cap) X 1 .##*###.**#^*##*..##***##.****.#...#### X 2 ......*.***^^#*^*.******...****.**.*.## X 3 ..*....***^***^*.***^^**..*******.*.... X 4 ..*...****^****^****^^**.***^****...... X 5 ...*...*.*******^****^*****^^^^**...... X 6 .....***.*****^^********.*****^**...... X 7 .....***.#***********.**..*.*****...... X 8 .###...####********###***......**###... X 9 #####.#########-####################### <-- Ice (polar cap) X X X Gasgiant Planet Airless Planet X 000000000011111111112222222222333333333 0000000000111111111122 X 012345678901234567890123456789012345678 0123456789012345678901 X 0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0 *^**^^^^^^^^^^*****^** X 1 .........~~~~~~~~~~~~~~~~~~~~~~~~~..... 1 **^^^^^****^^^^^*^^^^^ X 2 ....................................... 2 **^*^^^^^**^^^^^*^**^* X 3 ~~~~~~~~~~~~~~~~~~~~.........~~~~~~~~~~ 3 ***^**^*^^^^^****^**** X 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 ^^^^^***^****^^^^^**^* X 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 *^^^^^*******^^^^**^** X 6 ....................................... 6 **^****^****^********* X 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~............. X 8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Iceball X 9 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 000000000011111111112 X 012345678901234567890 X 0 ######^######^####### X 1 #^^#########^^^###### X 2 ^#^#^#^^####^^######^ X 3 ^##^#^#############^^ X 4 #####^############### X X END_OF_FILE if test 2607 -ne `wc -c <'enroll.dat'`; then echo shar: \"'enroll.dat'\" unpacked with wrong size! fi # end of 'enroll.dat' fi if test -f 'examine.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'examine.c'\" else echo shar: Extracting \"'examine.c'\" \(1662 characters\) sed "s/^X//" >'examine.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * examine -- check out an object X */ X X#include "vars.h" X#include "ships.h" Xextern int Shipdata[NUMSTYPES][NUMABILS]; Xextern char *Shipnames[]; X Xexamine(APcount, argn,args) Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ X shiptype *ship; X int c,t,shdata,shipno; X FILE *fd; X X if (argn==1) { X printf("ship #"); X scanf("%d",&shipno); X getchr(); X } else X sscanf(args[1] + ((*args[1]=='#') ? 1 : 0),"%d",&shipno); X X openshdata(&shdata); X if (!getship(shdata,&ship,shipno)) { X close(shdata); X return; X } X X if (ship->is_dead) { X printf("that ship is dead.\n"); X free(ship); X close(shdata); X return; X } X if (ship->whatorbits==LEVEL_UNIV || isclr(Stars[ship->storbits]->inhabited, Playernum)) { X printf("That ship it not visible to you.\n"); X close(shdata); X return; X } X X if ((fd=fopen(EXAM_FL, "r"))==NULL) { X perror(EXAM_FL); X close(shdata); X return; X } X X /* look through ship data file */ X for (t=0; t<=ship->type; t++) X while (fgetc(fd) != '~') ; X X /* give report */ X while ((c=fgetc(fd)) != '~') X putchr(c); X X fclose(fd); X X if (!ship->is_examined) { X if (ship->whatorbits==LEVEL_UNIV) X deductAPs(APcount, 0, 1); /* ded from sdata */ X else X deductAPs(APcount, ship->storbits, 0); X X ship->is_examined = 1; X putship(shdata,ship,shipno); X X } X close(shdata); X X if (has_switch(ship)) X printf("This device has an on/off switch that can be set with order.\n"); X if (ship->rad) X printf("This device has been irradiated;\nit's crew is dying and it cannot move for the time being.\n"); X X free(ship); X X} END_OF_FILE if test 1662 -ne `wc -c <'examine.c'`; then echo shar: \"'examine.c'\" unpacked with wrong size! fi # end of 'examine.c' fi if test -f 'explore.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'explore.c'\" else echo shar: Extracting \"'explore.c'\" \(2693 characters\) sed "s/^X//" >'explore.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@ssyx.ucsc.edu) X * explore.c -- display systems/worlds explored X * (this command written by Dan Corrin, dan@geomech.engrg.uwo.ca) X */ X X#include "vars.h" X#include "races.h" Xextern int God; Xextern float compatibility(); /* gvc modification */ X Xexploration(APcount, argn,args) Xint APcount, argn; Xchar *args[]; X{ Xint star,i,j; Xplanettype *pl; Xint inhab = 0; Xint stardata,pdata; Xint Num_races; X X Num_races = Numraces(); X X openstardata(&stardata); X getsdata(stardata,&Sdata); X openpdata(&pdata); X printf(" ========== Exploration Report ==========\n"); X printf(" Global action points : [%2d]\n",Sdata.AP[Playernum]); X printf(" Star (stability)[AP] # Planet [Attributes] Type (Compatibility)\n"); X for (star=0; star<Sdata.numstars; star++) { X free(Stars[star]); X getstar(stardata, &(Stars[star]), star); X if (isset(Stars[star]->explored,Playernum)) { X for (i=0; i<Stars[star]->numplanets; i++) { X getplanet(pdata,&pl,Stars[star]->planetpos[i]); X if (i == 0) X if (Race->tech >= TECH_SEE_STABILITY){ X printf(" \n"); X printf("%13s (%2d)[%2d]",Stars[star]->name,Stars[star]->stability,Stars[star]->AP[Playernum]);} X else { X printf(" \n"); X printf("%13s (??)[%2d]",Stars[star]->name,Stars[star]->stability,Stars[star]->AP[Playernum]);} X else X printf("\t\t "); X printf(" #%d. %-15s [ ",i+1,Stars[star]->pnames[i]); X if (pl->info[Playernum-1].explored) { X printf("Expl "); X if (pl->info[Playernum-1].autorep) X printf("Report "); X if (pl->info[Playernum-1].numsectsowned) X printf("Inhab "); X if (pl->slaved_to) X printf("SLAVED "); X inhab = 0; X for (j=1; j<=Num_races; j++) X if (j != Playernum) X inhab |= pl->info[j-1].numsectsowned; X if (inhab) X printf("Aliens "); X if (pl->conditions[TOXIC] > 70) X printf("TOXIC "); X switch(pl->type) { X case TYPE_EARTH: printf("] Class M"); break; X case TYPE_ASTEROID: printf("] Asteroid"); break; X case TYPE_AIRLESS: printf("] Airless"); break; X case TYPE_ICEBALL: printf("] Iceball"); break; X case TYPE_GASGIANT: printf("] Jovian"); break; X } X printf(" (%.2f%%)\n",compatibility(pl,Race)); X } else printf("No Data ]\n"); X free(pl); X } X } X } X close(stardata); X close(pdata); X} END_OF_FILE if test 2693 -ne `wc -c <'explore.c'`; then echo shar: \"'explore.c'\" unpacked with wrong size! fi # end of 'explore.c' fi if test -f 'files_rw.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'files_rw.c'\" else echo shar: Extracting \"'files_rw.c'\" \(3209 characters\) sed "s/^X//" >'files_rw.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * disk input/output routines X * most read routines lock the data they just accessed (the file is not X * closed). write routines close and thus unlock that area. X * Neither will work if the file LOCK_ALL exists, unless Ignore_lockfile X * is true, or Ignore_file_locks. X * X * Fileread(p, num, file, posn, routine); -- generic file read X * Filewrite(p, num, file, posn, routine); -- generic file write X * Locks(1 | 0) -- turn ignore file locking on, off X * X */ X X#include "tweakables.h" X#include "files.h" X#include <sys/file.h> X#include <signal.h> X#include <errno.h> Xint sys_nerr; Xchar *sys_errlist[]; Xint errno; X X Xstatic int Ignore_filelocks = 0; Xint Ignore_lockfile = 0; X XFileread(fd, p, num, file, posn) Xint fd; Xchar *p; Xint num; Xchar *file; Xint posn; X{ X int lockt = NUM_TIMES_TO_WAIT_FOR_LOCK; X int lerr,n2; X X/* printf(" fread fd=%d,reading %d bytes %s posn %d \n",fd,num,file,posn);*/ Xif (!Ignore_lockfile) { /* we are running for the shell filestuff */ X X while (access(LOCK_ALL, F_OK)==0) { /* if file exists */ X printf("doing update or enrolling; waiting (time %d)....\n", lockt); X if (!lockt--) X exit(1); X sleep(2); X } X X X X/*#ifdef VER_4_3 X lseek(fd, posn, L_SET); X while ((lerr=lockf(fd, F_TLOCK, (long)num))== -1 && errno==EACCES) { X close(fd); X if (!lockt--) { X printf("too long. exit.\n"); X exit(1); X } X printf("waiting on %s lock...\n",file); X sleep(1); X fd = open(file,O_RDWR,0777); X lseek(fd, posn, L_SET); X } X if (lerr<0 && errno!=EACCES) { X printf("weird error.\n"); X perror("Fileread 2"); X exit(); X } X#else*/ X if (!Ignore_filelocks) { X while ((lerr=flock(fd, LOCK_SH|LOCK_EX|LOCK_NB ))== -1 && errno==EWOULDBLOCK) { X if (!lockt--) { X printf("too long. exit.\n"); X exit(-1); X } X printf("waiting on %s lock...\n",file); X sleep(2); X } X if (lerr<0 && errno!=EWOULDBLOCK) { X perror("Fileread 2"); X exit(-1); X } X } X X } X X if (lseek(fd, posn, L_SET) < 0) { X perror("file read"); X return; X } X if ((n2=read(fd,p,num))!=num) { X printf("read: bad # of bytes read (%d != %d).\n",n2,num); X perror("fileread"); X return; X } X X} X X XFilewrite(fd, p, num, file, posn) Xint fd; Xchar *p; Xint num; Xchar *file; Xint posn; X{ Xint mask; Xint lockfd,n2; X X if (!Ignore_lockfile) { X if (access(LOCK_ALL, F_OK)==0) { X printf("doing update. Please come back later.\n"); X exit(-1); X } X mask = sigblock(SIGINT | SIGQUIT | SIGSTOP); X } X X /*printf(" fd =%d writing %d bytes to %s posn %d.\n",fd,num,file,posn);*/ X X if (lseek(fd, posn, L_SET) < 0) { X char buf[100]; X sprintf(buf,"%s: err %d",file,errno); X perror(buf); X return; X } X X if ((n2=write(fd,p,num))!=num) { X char buf[100]; X sprintf(buf,"%s:bad # of bytes written. (%d!=%d)\n",file,n2,num); X return; X } X X if (!Ignore_lockfile) /* (dont need to do this) */ X sigsetmask(mask); X} X X X/* turn file locking on and off. For the version on unix 4.3, this would be X * changed to a null function. However since I have not done testing with X * lockf() on my machine, I havent used it. If you are annoyed with the X * "waiting on ... lock" message, take out the comment starting with line 48. X */ XLocks(n) Xint n; X{ X X/*#ifdef VER_4_3*/ X X Ignore_filelocks = n; X/*#endif*/ X X} END_OF_FILE if test 3209 -ne `wc -c <'files_rw.c'`; then echo shar: \"'files_rw.c'\" unpacked with wrong size! fi # end of 'files_rw.c' fi if test -f 'max.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'max.c'\" else echo shar: Extracting \"'max.c'\" \(1752 characters\) sed "s/^X//" >'max.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * maxsupport() -- return how many people one sector can support X * Distmap() -- map-oriented distance that does not look square X * compatibility() -- return how much race is compatible with planet X * gravity() -- return gravity for planet X * prin_ship_orbits() -- prints place ship orbits X */ X X#include "vars.h" X#include "races.h" X#include "ships.h" X#include <math.h> X X X/* max this sector can support of specified race. X */ Xint maxsupport(r,p,c) Xreg racetype *r; Xreg sectortype *p; Xfloat c; /* (compatibility) */ X{ X return X (int)( X ( powscale(p->eff)*FACTOR_FERT_SUPPORT * p->fert + 1.0) * X ((r==NULL) ? 0.0 : r->likes[p->des]) * c X ); X} X X X Xint Distmap(x,y,x2,y2) Xreg int x,y,x2,y2; X{ X return( round_rand(fabs((double)x-x2) + fabs( (double)y-y2)*(RATIOXY*0.5) ) ); X} X X Xfloat compatibility(planet, race) Xreg planettype *planet; Xreg racetype *race; X{ X reg int i,add; X reg float sum=1.0; X X /* step through and report compatibility of each planetary gas */ X for (i=TEMP; i<=OTHER; i++) { X add = ((float)planet->conditions[i] - race->conditions[i]); X sum *= 1.0 - (abs(add)/100.0); X } X return sum * 100.0; /** planet->conditions[TOXIC]*/ X} X X X Xfloat gravity(p) Xplanettype *p; X{ X return (float)p->Maxx * p->Maxy * GRAV_FACTOR; X} X X X Xchar Dispshiporbits_buf[PLACENAMESIZE+13]; X Xchar *prin_ship_orbits(s) Xshiptype *s; X{ X X switch (s->whatorbits) { X case LEVEL_UNIV: X sprintf(Dispshiporbits_buf,"-"); X break; X case LEVEL_STAR: X sprintf(Dispshiporbits_buf,"/%s", Stars[s->storbits]->name); X break; X case LEVEL_PLAN: X sprintf(Dispshiporbits_buf,"/%s/%s", X Stars[s->storbits]->name, X Stars[s->storbits]->pnames[s->pnumorbits]); X break; X default: X break; X } X return Dispshiporbits_buf; X} END_OF_FILE if test 1752 -ne `wc -c <'max.c'`; then echo shar: \"'max.c'\" unpacked with wrong size! fi # end of 'max.c' fi if test -f 'mobiliz.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mobiliz.c'\" else echo shar: Extracting \"'mobiliz.c'\" \(1973 characters\) sed "s/^X//" >'mobiliz.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * mobilize.c -- persuade people to build military stuff. X * Sectors that are mobilized produce Destructive Potential in X * proportion to the % they are mobilized. they are also more X * damage-resistant. X */ X X#include "vars.h" X#include <signal.h> X#include <setjmp.h> X#include <ctype.h> Xextern jmp_buf main_jenv; Xint mobilize_sectdata,mobilize_pdata; X Xmobilize(APcount, argn, args) Xint APcount, argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xint owned=0,x,y,sum_mob=0; Xsectortype *s; Xplanettype *p; Xint mobilize_handler(); X Xmobilize_pdata = mobilize_sectdata = NEUTRAL_FD; Xsignal(SIGINT, mobilize_handler); X Xif (argn>1) { X printf("usage: mobilize\n"); X return; X} Xif (Dir.level!=LEVEL_PLAN) { X printf("scope must be a planet.\n"); X return; X} Xif (!enufAP(Stars[Dir.snum]->AP, APcount)) X mobilize_handler(); X X openpdata(&mobilize_pdata); X getplanet(mobilize_pdata,&p,Stars[Dir.snum]->planetpos[Dir.pnum]); X X X opensectdata(&mobilize_sectdata); X getsmap(mobilize_sectdata,Smap,p); X close(mobilize_sectdata); X X X /* (fix up some things, while we're at it) */ X p->popn = 0; X for (y=0; y<p->Maxy; y++) X for (x=0; x<p->Maxx; x++) { X s = &Sector(*p,x,y); X if (s->owner==Playernum) { X sum_mob += s->mobilization; X owned++; X } X p->popn += s->popn; X } X X p->info[Playernum-1].numsectsowned = owned; X X printf("(cost:%.3f resource points / 1 mobilization pt.)\n", MOB_COST); X printf("Number of sectors owned: %d.\n",owned); X printf(" Average mobilization: %.1f.\n",(float)sum_mob / owned); X printf(" Old mobilization quota: %u.\n",p->info[Playernum-1].mob_set); X printf(" New quota: "); X X if ( isdigit(x=getchr())) { X ungetc(x,stdin); X scanf("%d",&sum_mob); X getchr(); X p->info[Playernum-1].mob_set = sum_mob; X putplanet(mobilize_pdata,p,Stars[Dir.snum]->planetpos[Dir.pnum]); X } X close(mobilize_pdata); X X free(p); X X} X Xmobilize_handler() X{ X close(mobilize_pdata); X close(mobilize_sectdata); X longjmp(main_jenv,1); X} END_OF_FILE if test 1973 -ne `wc -c <'mobiliz.c'`; then echo shar: \"'mobiliz.c'\" unpacked with wrong size! fi # end of 'mobiliz.c' fi if test -f 'more.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'more.c'\" else echo shar: Extracting \"'more.c'\" \(1594 characters\) sed "s/^X//" >'more.c' <<'END_OF_FILE' X X#include <stdio.h> X#include <sys/file.h> X#include <sgtty.h> X X Xmain(c, v) Xint c; Xchar **v; X{ X while (*(++v)) X doc(*v); X} X Xdoc(s) Xchar *s; X{ X char filename[128], tmpfile[128]; X int fd, pid; X long t; X X sprintf(filename, "%s", s); X /* could stat the file here to make sure it's there */ X X time(&t); X sprintf(tmpfile, "/usr/tmp/#GBtrash%05d", (t >> 4) & 0x7fff); X fd = open(tmpfile, O_CREAT | O_WRONLY | O_TRUNC, 0600); X if (fd < 0) { X fprintf(stderr, "doc(): %s: ", filename); X perror("open failed"); X return; X } X X switch (pid = fork()) { X case -1 : X perror("doc(): fork for zcat failed"); X break; X X case 0 : X dup2(fd, 1); X execl("/usr/ucb/zcat", "zcat", filename, 0); X perror("doc(): execl for zcat failed"); X X default : X while (wait(0) != pid) X ; X } X X close(fd); X page(tmpfile); X unlink(tmpfile); X} X Xpage(file) Xchar *file; X{ X char buf[4096]; X FILE *fp; X int line; X X fp = fopen(file, "r"); X if (!fp) { X fprintf(stderr, "page(): %s: ", file); X perror("open failed"); X return; X } X X while (fgets(buf, sizeof(buf), fp)) { X ++line; X fputs(buf, stdout); X if (line == 23) { X char ch; X X fputs(" -- more -- ", stdout); X fflush(stdout); X do X ch = get_a_char(); X while (ch != ' '); X fputs("\b\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b\b", stdout); X line = 0; X } X } X fclose(fp); X} X Xget_a_char() X{ X struct sgttyb foo, bar; X char c; X X ioctl(0, TIOCGETP, &foo); X bar = foo; X foo.sg_flags |= CBREAK; X foo.sg_flags &= ~ECHO; X ioctl(0, TIOCSETN, &foo); X X c = getchar(); X/* while (!read(0, &c, 1)) */ X/* ; */ X X X ioctl(0, TIOCSETN, &bar); X X return c; X} END_OF_FILE if test 1594 -ne `wc -c <'more.c'`; then echo shar: \"'more.c'\" unpacked with wrong size! fi # end of 'more.c' fi if test -f 'moveplanet.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'moveplanet.c'\" else echo shar: Extracting \"'moveplanet.c'\" \(1636 characters\) sed "s/^X//" >'moveplanet.c' <<'END_OF_FILE' X/* X * moveplanet.c -- move the planet in orbit around its star. X */ X X#include "vars.h" X#include "ships.h" X#include "races.h" /* (needed only for races in doturn.h */ X#include "doturn.h" X#include <math.h> X Xbool StarsInhab[NUMSTARS]; X Xmoveplanet(star, starnum, planet, planetnum) Xstartype *star; Xint starnum; Xplanettype *planet; Xint planetnum; X{ Xfloat dist; Xfloat t,xadd,yadd; Xint sh; Xreg int i; Xshiptype *ship; X X/* return; */ X X for (i=0; i<howmanybytes(Num_races); i++) { X StarsInhab[starnum] |= Stars[starnum]->inhabited[i]; X } X if (planet->popn) X Stinfo[starnum][planetnum].inhab = 1; X X if (!StarsInhab[starnum]) X return 0; /* no one's explored the star yet */ X X X dist = hypot((double)planet->ypos, (double)planet->xpos); X /* closer planets orbit faster */ X t = atan2((double)planet->ypos, (double)planet->xpos) - SYSTEMGRAVCONST * SYSTEMSIZE / dist; X xadd = planet->xpos - dist * cos((double)t); X yadd = planet->ypos - dist * sin((double)t); X X printf("st %d pl %d xadd %g yadd %g \n", starnum, planetnum, xadd, yadd); X X X X /* adjust ships in orbit around the planet */ X X sh = planet->ships; X while (sh) { X if ( (ship = ships[sh]) && !ship->is_dead) X /* don't do landed ships */ X if (!(ship->is_docked && ship->whatdest==LEVEL_PLAN)) { X printf(" orb sh #%d\n",sh); X ship->xpos += xadd; X ship->ypos += yadd; X } X sh = ship->nextship; X } X X X planet->xpos += xadd; X planet->ypos += yadd; X if (planet->xpos>SYSTEMSIZE) planet->xpos *= .5; X else if (planet->xpos< -SYSTEMSIZE) planet->xpos *= .5; X if (planet->ypos>SYSTEMSIZE) planet->ypos *= .5; X else if (planet->ypos< -SYSTEMSIZE) planet->ypos *= .5; X X} END_OF_FILE if test 1636 -ne `wc -c <'moveplanet.c'`; then echo shar: \"'moveplanet.c'\" unpacked with wrong size! fi # end of 'moveplanet.c' fi if test -f 'prof.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'prof.c'\" else echo shar: Extracting \"'prof.c'\" \(2441 characters\) sed "s/^X//" >'prof.c' <<'END_OF_FILE' X X X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * prof.c -- print out racial profile X */ X X#include "vars.h" X#include "races.h" X#include "ships.h" X Xextern char *Desnames[]; X Xprofile(APcount, argn,args) Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ X int i, numraces; X X X printf("---==** Racial profile for %s (player %d) **==---\n",Race->name, X Race->Playernum); X printf(" (default scope /%s/%s)\n\n",Stars[Race->homesystem]->name, X Stars[Race->homesystem]->pnames[Race->homeplanetnum] ); X printf(" %10srate: %.1f\n",Race->Thing ? "Infection " : "Birth",Race->birthrate); X printf(" Technology: %.1f\n",Race->tech); X printf(" Avg Intelligence: %u\n",Race->IQ); X printf(" mass: %.2f\n",Race->mass); X printf(" metabolism: %.1f\n",Race->metabolism); X printf(" adventurists: %.2f%%\n",Race->nonhomebodies*100.0); X printf(" fighting ability: %d\n",Race->fighters); X printf(" # of sexes: %d\n", Race->number_sexes); X if (Race->Thing) X printf("Mesomorphic race (like \"The Thing\").\n"); X X printf("planetary conditions preferred by %s:\n", Race->name); X printf(" temperature: %d\n", Temp(Race->conditions[TEMP]) ); X printf(" atmosphere concentrations:\n"); X printf(" methane %02d%% oxygen %02d%%\n", X Race->conditions[METHANE], Race->conditions[OXYGEN] ); X printf(" CO2 %02d%% hydrogen %02d%%\n", X Race->conditions[CO2], Race->conditions[HYDROGEN] ); X printf(" nitrogen %02d%% sulfur %02d%%\n", X Race->conditions[NITROGEN], Race->conditions[SULFUR] ); X printf(" helium %02d%% other %02d%%\n", X Race->conditions[HELIUM], Race->conditions[OTHER]); X printf("Sector type preferences:\n"); X printf(" %c (%11s) %3.0f%% %c (%11s) %3.0f%%\n", X CHAR_SEA, Desnames[DES_SEA], Race->likes[DES_SEA]*100, X CHAR_GAS, Desnames[DES_GAS], Race->likes[DES_GAS]*100); X printf(" %c (%11s) %3.0f%% %c (%11s) %3.0f%%\n", X CHAR_MOUNT, Desnames[DES_MOUNT], Race->likes[DES_MOUNT]*100, X CHAR_LAND, Desnames[DES_LAND], Race->likes[DES_LAND]*100); X printf(" %c (%11s) %3.0f%% %c (%11s) %3.0f%%\n", X CHAR_ICE, Desnames[DES_ICE], Race->likes[DES_ICE]*100, X CHAR_PLATED, Desnames[DES_PLATED], Race->likes[DES_PLATED]*100); X X printf("\nTelescope ranges: ground: %g, space: %g\n", X tele_range(Race, OTYPE_GTELE), tele_range(Race, OTYPE_STELE) ); X printf("Gun range: %g\n", gun_range(Race, NULL) ); X X} END_OF_FILE if test 2441 -ne `wc -c <'prof.c'`; then echo shar: \"'prof.c'\" unpacked with wrong size! fi # end of 'prof.c' fi if test -f 'telegram.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'telegram.c'\" else echo shar: Extracting \"'telegram.c'\" \(2783 characters\) sed "s/^X//" >'telegram.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@ssyx) X * telegram.c -- send a telegram to user X */ X X#include "vars.h" X#include "races.h" X#include "ships.h" X#include <ctype.h> X#include <signal.h> X#include <strings.h> X#include <setjmp.h> Xextern jmp_buf main_jenv; Xextern char telegram_buf[AUTO_TELEG_SIZE]; X Xtelegram(APcount, argn,args) Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xracetype *alien; Xplacetype where; Xplanettype *pl; Xint c,i,numraces,recp = -1; Xbool Place = 0; Xchar telefl[100], tbuf[200], tmbuf[40], r[200]; Xint telegram_pdata,telegram_handler(); X X X signal(SIGINT, telegram_handler); X X if (Sdata.AP[Playernum] < APcount) { X if (Dir.level==LEVEL_UNIV) { X printf("You don't have enough AP's.\n"); X telegram_handler(); X } if (!enufAP(Stars[Dir.snum]->AP,APcount) ) X telegram_handler(); X } X X if (argn==1) { /* recipient not specified */ X printf("To whom/where? "); X scanf("%[^\n]",r); X getchr(); X } else X strncpy(r,args[1],RNAMESIZE); X X X if (r[0] == '/' || r[0]=='#' || r[0]=='.' || r[0]==CHAR_CURR_SCOPE) { X Place = 1; X where = Getplace(r,1); X if (where.err) X telegram_handler(); X } else { X GetPlayer(r, &recp, &alien); X if ( recp == -1) { X printf("Player does not exist.\n"); X telegram_handler(); X } X } X X printf("Enter telegram for %s,\n ending with ctrl-D.\n\n", X Place ? Dispplace(&where) : alien->name ); X X printf("Subject : "); X teleg_add("", telegram_buf); X if (Place) { X sprintf(tbuf, "Message received at %s%s.\n", X where.level==LEVEL_SHIP ? "ship " : "", Dispplace(&where) ); X teleg_add(tbuf, telegram_buf); X } X i = 0; X while ( (c=getchr()) != EOF) { X ungetc(c,stdin); X scanf("%199[^\n]", tbuf); X getchr(); X i += strlen(tbuf); X teleg_add(tbuf, telegram_buf); X printf("%d : ",TELEGRAM_SIZE - i ); X } X X /* send it */ X if (!Place) X teleg_send(Playernum, recp, telegram_buf); X else X switch (where.level) { X case LEVEL_STAR: X for (i=1; i<MAXPLAYERS; i++) X if (isset(Stars[where.snum]->inhabited,i)) X teleg_send(Playernum, i, telegram_buf); X break; X case LEVEL_PLAN: X openpdata(&telegram_pdata); X getplanet(telegram_pdata, &pl, Stars[where.snum]->planetpos[where.pnum]); X close(telegram_pdata); X for (i=1; i<MAXPLAYERS; i++) X if (pl->info[i-1].numsectsowned) X teleg_send(Playernum, i, telegram_buf); X break; X case LEVEL_SHIP: X teleg_send(Playernum, where.shipptr->owner, telegram_buf); X break; X case LEVEL_UNIV: X printf("We're sorry, no one is there to receive your call.\n"); X break; X } X X /* get rid of ctrl-D problem */ X clearerr(stdin); X X if (Sdata.AP[Playernum] >= APcount) X deductAPs(APcount, 0, 1); X else X deductAPs(APcount, Dir.snum, 0); X X printf("\nMessage delivered.\n"); X X} X X Xtelegram_handler() X{ X longjmp(main_jenv,1); X} END_OF_FILE if test 2783 -ne `wc -c <'telegram.c'`; then echo shar: \"'telegram.c'\" unpacked with wrong size! fi # end of 'telegram.c' fi echo shar: End of archive 7 \(of 8\). cp /dev/null ark7isdone MISSING="" for I in 1 2 3 4 5 6 7 8 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 8 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0