billr@saab.CNA.TEK.COM (Bill Randle) (06/02/90)
Submitted-by: VANCLEEF@mps.ohio-state.edu Posting-number: Volume 10, Issue 8 Archive-name: gb3/Part08 Supersedes: GB2: Volume 7, Issue 44-51 #! /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 8 (of 14)." # Contents: Docs/profile.doc server/dosector.c server/doturn.c # server/files_shl.c server/makeuniv.c server/prof.c server/survey.c # Wrapped by billr@saab on Fri Jun 1 11:53:39 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH 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'\" \(2642 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 <race name> 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 17. X XTechnology -- This represents the technological achievement of your people. X Certain types of ships cannot be built without the appropriate X technology. This number increases in proportion to your race's X intelligence and the technological investment they make. X XAvg Intelligence -- This is the average IQ (human standard scale) of the X members of your race. 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). 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 Xsector preferences -- The sector types your race prefers, in numerical X proportion. X X X X XSEE ALSO X build, load, cs, survey, declare, relation X END_OF_FILE if test 2642 -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 'server/dosector.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/dosector.c'\" else echo shar: Extracting \"'server/dosector.c'\" \(8008 characters\) sed "s/^X//" >'server/dosector.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h, enroll.dat. X * Restrictions in GB_copyright.h. X * dosector.c X * produce() -- produce, stuff like that, on a sector. X * spread() -- spread population around. X * explore() -- mark sector and surrounding sectors as having been explored. X */ X X#include "GB_copyright.h" X#define EXTERN extern X#include "vars.h" X#include "races.h" X#include "ships.h" X#include "doturn.h" X#include <math.h> X X /* produce stuff in sector */ Xproduce(planet,s) Xreg planettype *planet; Xreg sectortype *s; X{ Xreg int fac; Xint ss; Xint maxsup; Xint pfuel, pdes, pres; X Xreg float factor; Xreg int eff,resdep; Xreg struct plinfo *pinf; Xreg int new; X Xif(s->resource < 0) X s->resource = -s->resource; X X check(planet,20); X factor = .4 * log10(1.0+(double)s->eff) * s->resource X * races[s->owner-1]->metabolism; X pinf = &planet->info[s->owner-1]; X X X pfuel = round_rand( factor * FUEL_PRODUCTION X * (100 - s->mobilization) * ((s->des==DES_GAS)+1) ); X prod_fuel[s->owner-1] += pfuel; X X pres = round_rand( factor * RESOURCE_PRODUCTION X * (100 - s->mobilization) ); X prod_res[s->owner-1] += pres; X X pdes = round_rand( factor * DEST_PRODUCTION X * s->mobilization ); X prod_destruct[s->owner-1] += pdes; X X /* increase mobilization to planetary quota */ X if (s->mobilization < pinf->mob_set) { X if (pinf->resource + prod_res[s->owner-1] > 0) { X s->mobilization++; X prod_res[s->owner-1] -= round_rand(MOB_COST); X prod_mob++; X } X check(planet,202); X } else if (s->mobilization > pinf->mob_set) { X s->mobilization--; X prod_mob--; X check(planet,203); X } X X X X /* add mobilization to get average mobilization */ X avg_mob[s->owner-1] += s->mobilization; X X X /* do efficiency */ X if (s->eff == 0) X s->eff = 1; X else if (s->eff<100) X s->eff += X round_rand(races[s->owner-1]->metabolism * float_rand()); X else X s->des = DES_PLATED; X Xcheck(planet,204); X X if (s->is_wasted) X s->popn = round_rand(s->popn * 0.10); X else if (s->popn >= races[s->owner-1]->number_sexes) { X X maxsup=maxsupport(races[s->owner-1],s, X Compat[s->owner-1],planet->conditions[TOXIC]); X X ss = round_rand( ((float)maxsup-(float)s->popn) * races[s->owner-1]->birthrate); X X s->popn = MAX(0, MIN(MAX_SECT_POPN,s->popn + ss)); X /* keep the result nonnegative and below MAX */ X X } else { X s->popn = round_rand(s->popn * .097); X } X X X if (s->popn == 0) X s->owner=0; X X check(planet,21); X} X X X/* X * spread population to surrounding sects. X * X * the way people move depends on the population of the planet unless X * NO_SLIDING_SCALE_AUTOMOVE is set (again for reasons of computer X * power). Otherwise, the populace will automatically migrate to all X * available surrounding areas if the planetary population is less than X * POPN_MOVE_SCALE_1, to either north-south or east-west areas if the X * population is less than POPN_MOVE_SCALE_2, and to only one adjacent X * random sector if it is greater. X */ X X Xspread(pl,s,x,y) Xreg planettype *pl; Xreg sectortype *s; Xreg int x,y; X{ Xint peep; X Xif(s->owner == 0) return; /* gvc hack sometimes owned sectors X have no owner - causes bus error ! X (someone has to figure this out) */ X X check(pl,22); Xif (pl->is_sheep || (pl->slaved_to!=0 && pl->slaved_to!=s->owner)) X return; /* no one wants to go anywhere */ X X /* peep == number of people who want to move - at least one family wants to move*/ X X peep = MAX(MIN(races[s->owner-1]->number_sexes, s->popn), X round_rand((float)s->popn * races[s->owner-1]->adventurism)); X Xif (peep) { X /*if (pl->type==TYPE_GASGIANT && s->des==DES_GAS && !int_rand(0,20)) { X /* random 'wind' sweeps people in this sector, somewhere else */ X reg int x2,y2; X sectortype *s2,s3; X /* huh. For some reason, this seems to mess up the next planet's X sector map. */ X /*x2 = int_rand(0,pl->Maxx-1); X y2 = int_rand(1,pl->Maxy-2); X printf(" wind: %d,%d to %d,%d\n",x,y,x2,y2); X s2 = &Sector(*pl,x2,y2); X if (s2->des==DES_GAS) { X s3 = *s2; X *s2 = *s; X *s = s3; X }*/ X /*} else {*/ X X#if NO_SLIDING_SCALE_AUTOMOVE X if (pl->popn < POPN_MOVE_SCALE_1) { X#endif X Migrate2(pl,x+1,y,s,peep/4); X Migrate2(pl,x-1,y,s,peep/4); X Migrate2(pl,x,y+1,s,peep/4); X Migrate2(pl,x,y-1,s,peep/4); X check(pl,23); X#if NO_SLIDING_SCALE_AUTOMOVE X } X else if (pl->popn < POPN_MOVE_SCALE_2) { X x2 = int_rand(-1,1); X y2 = (!x2) ? rposneg() : 0; /* 1/3 chance of migrating n-s*/ X Migrate2(pl,x+x2,y+y2,s,peep/2); X Migrate2(pl,x-x2,y-y2,s,peep/2); X /* migrate to destination, from source */ X } else { X Migrate2(pl, x + rposneg(), y + rposneg(), s, peep); X } X X#endif X /*}*/ X} X X} X X X XMigrate2(planet,xd,yd,ps,people) Xplanettype *planet; Xreg int xd,yd; Xsectortype *ps; Xreg int people; X{ Xreg sectortype *pd; X X /* attempt to migrate beyond screen, or too many people */ X if (ps->popn <= people || (yd>=planet->Maxy) || (yd<0) ) X return; X X if (xd<0) X xd=planet->Maxx-1; X else if (xd>=planet->Maxx) X xd=0; X X pd = &Sector(*planet,xd,yd); X X { X X /* check for planetary compatibility */ X if (pd->is_wasted || X people < races[ps->owner-1]->number_sexes || X float_rand()*100.0 > Compat[ps->owner-1] * races[ps->owner-1]->likes[pd->des]) { X return; X X } X X X if (!pd->owner) { X/* printf("claiming %d,%d (%d): %d\n",xd,yd,ps->owner,people);*/ X pd->popn += people; X ps->popn -= people; X pd->owner = ps->owner; X tot_captured++; X if (Sectinfo[xd][yd].done) X planet->info[pd->owner-1].numsectsowned++; X Claims = 1; X X } else if (pd->owner==ps->owner) { X pd->popn += people; X ps->popn -= people; X X } else if (isset(races[ps->owner-1]->atwar, pd->owner)) { X /* we are at war with them; do land combat */ X reg float ofac,dfac; X X ofac = (float)MAX_SECT_POPN/(ps->popn+people) * X (ps->mobilization+1) * X planet->info[ps->owner-1].comread/10000 * X races[ps->owner-1]->fighters/10 X + races[ps->owner-1]->tech/500.0; X/* printf(" %d,%d (before MIN) ofac %.2f -- ",xd,yd,ofac);*/ X ofac = MIN(ofac, 1.0); X dfac = (float)MAX_SECT_POPN/pd->popn * X (pd->mobilization+1) * X planet->info[pd->owner-1].comread/10000 * X races[pd->owner-1]->fighters/10 X + races[pd->owner-1]->tech/500; X/* printf(" dfac %.2f",dfac);*/ X dfac = MIN(dfac, 1.0); X {reg int od,os; X od=pd->popn;os=ps->popn; X pd->popn *= 1. - ofac; X ps->popn *= 1. - dfac; X/* printf("def cas %d (of %d), off cas %d (of %d)\n", X od-pd->popn,od,os-ps->popn,os); */ X } X if (pd->popn <= 0) { X /* the invasion was successful */ X if (races[ps->owner-1]->Thing) { X /* mesos absorb the bodies of enemies */ X pd->popn += MIN(people, ps->popn); X ps->popn -= MIN(people, ps->popn); X } else { X pd->popn = MIN(people, ps->popn); X ps->popn -= MIN(people, ps->popn); X } X sects_lost[pd->owner-1]++; X sects_gained[ps->owner-1]++; X pd->owner = ps->owner; X pd->eff *= 0.75; X pd->mobilization *= 0.75; X tot_captured++; X/* printf(" sec %d,%d CAPTURED\n",xd,yd); */ X } else X pd->popn -= round_rand(dfac); X X } else { X /* exchange prisoners */ X if (races[pd->owner-1]->captured_prisoners[ps->owner-1]<100) X races[pd->owner-1]->captured_prisoners[ps->owner-1]++; X if (races[ps->owner-1]->captured_prisoners[pd->owner-1]<100) X races[ps->owner-1]->captured_prisoners[pd->owner-1]++; X } X } X X check(planet,23); X} X X X/* mark sectors on the planet as having been "explored." for sea exploration X on earthtype planets. */ X Xexplore(planet, s, x, y, p) Xreg planettype *planet; Xreg sectortype *s; Xreg int x,y,p; X{ Xreg int d; X X /* explore sectors surrounding sectors currently explored. */ X if (Sectinfo[x][y].explored) { X Sectinfo[mod(x-1,planet->Maxx,d)][y].explored = p; X Sectinfo[mod(x+1,planet->Maxx,d)][y].explored = p; X if (y==0) { X Sectinfo[x][1].explored = p; X } else if (y==planet->Maxy-1) { X Sectinfo[x][y-1].explored = p; X } else { X Sectinfo[x][y-1].explored = Sectinfo[x][y+1].explored = p; X } X X } else if (s->owner==p) X Sectinfo[x][y].explored = p; X X} END_OF_FILE if test 8008 -ne `wc -c <'server/dosector.c'`; then echo shar: \"'server/dosector.c'\" unpacked with wrong size! fi # end of 'server/dosector.c' fi if test -f 'server/doturn.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/doturn.c'\" else echo shar: Extracting \"'server/doturn.c'\" \(8195 characters\) sed "s/^X//" >'server/doturn.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. X * Restrictions in GB_copyright.h. X * doturn -- does one turn. X */ X X#include "GB_copyright.h" X#define EXTERN extern X#include "vars.h" X#include "ships.h" X#include "races.h" X#include "doturn.h" X#include "power.h" X#include "buffers.h" X#include <math.h> Xint doturn_racedata; X Xdo_turn() X{ X int star,i,j,fd, x, y; X int shdata,stardata,pdata,sectdata; X boolean err=0; X shiptype *ship; X sectortype *p; X char t_buf[200]; Xint dummy; X X /* make all 0 for first iteration of doplanet */ X bzero((char *)starpopns, sizeof(starpopns)); X bzero((char *)starnumships, sizeof(starnumships)); X bzero((char *)Sdatanumships, sizeof(Sdatanumships)); X bzero((char *)Stinfo, sizeof(Stinfo)); X bzero((char *)StarsInhab, sizeof(StarsInhab)); X bzero((char *)Power, sizeof(Power)); X Xopenshdata(&shdata); XNum_ships = Numships(shdata); Xprintf("Num ships = %d\n", Num_ships); X X ships = (shiptype **)malloc(sizeof(shiptype *) * (Num_ships + 1)); X Xfor(i=1; i<=Num_ships;i++) X getship(shdata,&ships[i], i); X Xclose_file(shdata); X X/* get all stars and planets */ X openstardata(&stardata); X getsdata(stardata,&Sdata); X openpdata(&pdata); X for (star=0; star<Sdata.numstars; star++) { X free(Stars[star]); X getstar(stardata, &Stars[star], star); X fix_stability(Stars[star]); /* nova */ X for (i=0; i<Stars[star]->numplanets; i++) { X free(planets[star][i]); X getplanet(pdata,&planets[star][i],Stars[star]->planetpos[i]); X /* move planets in orbit; also sets StarsInhab[] */ X moveplanet(star, planets[star][i], i); X if(Stars[star]->pnames[i]=='\0') X sprintf(Stars[star]->pnames[i], "NULL-%d", i); X } X if(Stars[star]->name[0]=='\0') X sprintf(Stars[star]->name, "NULL-%d", star); X X putstar(stardata, Stars[star], star); X} Xclose_file(stardata); Xclose_file(pdata); X X/*printf("doing VN_brain\n");*/ XVN_brain.Most_mad = 0; /* not mad at anyone for starts */ X Xopenracedata(&doturn_racedata); XNum_races = Numraces(); Xprintf("Num_races = %d\n",Num_races); X Xfor (i=1; i<=Num_races; i++) { X X getrace(doturn_racedata, &(races[i-1]),i); X /* increase tech; change to something else */ X races[i-1]->tech += (float)races[i-1]->IQ / 100.0; X X /* add VN program */ X VN_brain.Total_mad += Sdata.VN_hitlist[i-1]; X /* find out who they're most mad at */ X if (Sdata.VN_hitlist[VN_brain.Most_mad-1] <= Sdata.VN_hitlist[i-1]) X VN_brain.Most_mad = i; X X} X close_file(doturn_racedata); X X X X /* do all ships one turn */ X for (i=1; i<=Num_ships; i++) { X/* printf("ship %d\n",i);*/ X doship(i,ships[i]); X } X/* erase next ship pointers - reset in insert_sh_... */ X for (i=1; i<Num_ships;i++) X ships[i]->nextship=0; X X /* clear ship list for insertion */ X Sdata.ships = 0; X for (star=0; star<Sdata.numstars; star++) { X Stars[star]->ships = 0; X for (i=0; i<Stars[star]->numplanets; i++) { X planets[star][i]->ships = 0; X } X } X X /* insert ship into the list of wherever it might be */ X openshdata(&shdata); X for (i=Num_ships; i>=1; i--) { X if(ships[i]->is_alive && !(ships[i]->type == STYPE_FIGHTER && X ships[i]->object.number4) ) { X switch(ships[i]->whatorbits) { X case LEVEL_UNIV: X insert_sh_univ(&Sdata, ships[i], i); X break; X case LEVEL_STAR: X insert_sh_star(Stars[ships[i]->storbits], ships[i],i); X break; X case LEVEL_PLAN: X insert_sh_plan(planets[ships[i]->storbits][ships[i]->pnumorbits], ships[i],i); X break; X default: X break; X } X } X putship(shdata,ships[i],i); X } X close_file(shdata); X X X X /* add APs to sdata for ea. player */ X for (i=1; i<=Num_races; i++) { X int a; X if ( (a = Sdata.AP[i-1] + APadd((int)Sdatanumships[i-1], (int)Sdatapopns[i],races[i-1]) + 1) > LIMIT_APs) X Sdata.AP[i-1] = LIMIT_APs; X else X Sdata.AP[i-1] = a; X } X X X for (star=0; star<Sdata.numstars; star++) { X X for (i=0; i<Stars[star]->numplanets; i++) { X/* printf("%s %d\n",Stars[star]->name,i); */ X if (doplanet(star, planets[star][i], i)) { X /* save smap gotten & altered by doplanet only if the planet is expl*/ X opensectdata(§data); X putsmap(sectdata,Smap,planets[star][i]); X close_file(sectdata); X } X Xopenpdata(&pdata); X putplanet(pdata,planets[star][i],Stars[star]->planetpos[i]); Xclose_file(pdata); X } X X /* do AP's for ea. player */ X for (i=1; i<=Num_races; i++) { X if (isset(Stars[star]->explored, i) ) { X if ((j = Stars[star]->AP[i-1] + APadd((int)starnumships[star][i-1], (int)starpopns[star][i-1], races[i-1]) + 1) > LIMIT_APs) X Stars[star]->AP[i-1] = LIMIT_APs; X else X Stars[star]->AP[i-1] = j; X } X X if (starpopns[star][i-1]) X setbit(Stars[star]->inhabited,i); X else X clrbit(Stars[star]->inhabited,i); X } X openstardata(&stardata); X putstar(stardata, Stars[star], star); X close_file(stardata); X} X Xopenstardata(&stardata); X putsdata(stardata,&Sdata); X close_file(stardata); X X X openshdata(&shdata); X for (i=1; i<=Num_ships; i++) X putship(shdata,ships[i],i); X X close_file(shdata); X X Xopenracedata(&doturn_racedata); Xfor (i=1; i<=Num_races; i++) { X putrace(doturn_racedata, races[i-1]); X free(races[i-1]); X } X close_file(doturn_racedata); X Xfree(ships); X XPutpower(Power); X X/* compute alliance block power */ X for (i=1; i<=Num_races; i++) { X dummy=(Blocks[i-1].invite & Blocks[i-1].pledge); X if(isset(dummy, j)){ X Power_blocks.members[i-1] = 0; X Power_blocks.sectors_owned[i-1] = 0; X Power_blocks.popn[i-1] = 0; X Power_blocks.ships_owned[i-1] = 0; X Power_blocks.planets_owned[i-1] = 0; X Power_blocks.resource[i-1] = 0; X Power_blocks.fuel[i-1] = 0; X Power_blocks.destruct[i-1] = 0; X Power_blocks.VPs[i-1] = 0; X for(j=1; j<=Num_races; j++) X if(isset(dummy, j)){ X Power_blocks.members[i-1] += 1; X Power_blocks.sectors_owned[i-1] += Power[j-1].sectors_owned; X Power_blocks.popn[i-1] += Power[j-1].popn; X Power_blocks.ships_owned[i-1] += Power[j-1].ships_owned; X Power_blocks.planets_owned[i-1] += Power[j-1].planets_owned; X Power_blocks.resource[i-1] += Power[j-1].resource; X Power_blocks.fuel[i-1] += Power[j-1].fuel; X Power_blocks.destruct[i-1] += Power[j-1].destruct; X Power_blocks.VPs[i-1] += Blocks[j-1].VPs; X } X } X} X X for (i=1; i<=Num_races; i++) X notify(i, "Finished with update.\n"); X printf("Finished.\n"); X} X X X X /* routine for number of AP's to add to each player in ea. system,scaled X by amount of crew in their palace */ X Xint APadd(sh, popn, race) Xint sh, popn; Xracetype *race; X{ X if (race->Gov_ship>0 && race->Gov_ship <= Num_ships && X ships[race->Gov_ship] != NULL && X ships[(int)(race->Gov_ship)]->is_alive && X ships[(int)(race->Gov_ship)]->is_docked && X ships[(int)(race->Gov_ship)]->whatdest==LEVEL_PLAN) X return X round_rand( ((float)sh / 10.0 + (float)log10(1.0+popn)) X * ((float)ships[(int)(race->Gov_ship)]->popn/Shipdata[OTYPE_GOV][ABIL_MAXCREW]) X * .01 * (100.0 - (float)ships[(int)(race->Gov_ship)]->damage) ); X else X return 0; X/* maybe we should give at least 1 AP? */ X} X X X X /* fix stability for stars */ Xfix_stability(s) Xstartype *s; X{ Xchar buf[100]; Xint a,i; X X X if (s->nova_stage > 0) { X if (s->nova_stage > 14) { X s->stability = 20; X s->nova_stage = 0; X sprintf(telegram_buf, "Notice\n"); X sprintf(buf,"\n Scientists report that star %s\n", s->name); X str_cat(telegram_buf, buf); X sprintf(buf, "is no longer undergoing nova.\n"); X str_cat(telegram_buf, buf); X for (i=1; i<=Num_races; i++) X push_message(TELEG_PLAYER_AUTO, i, telegram_buf); X X /* telegram everyone when nova over? */ X } else X s->nova_stage++; X X } else if (s->stability > 50) { X a = int_rand(-1,3); X /* nova just starting; notify everyone */ X if ( (s->stability + a) > 100) { X s->stability = 100; X s->nova_stage = 1; X sprintf(telegram_buf, "***** BULLETIN! ******\n"); X sprintf(buf,"\n Scientists report that star %s\n", s->name); X str_cat(telegram_buf, buf); X sprintf(buf, "is undergoing nova.\n"); X str_cat(telegram_buf, buf); X for (i=1; i<=Num_races; i++) X push_message(TELEG_PLAYER_AUTO, i, telegram_buf); X } else X s->stability += a; X } else X a = int_rand(-2,int_rand(0,int_rand(0,1) ) ); X if ( (s->stability + a) < 0) X s->stability = 0; X else X s->stability += a; X} X X X END_OF_FILE if test 8195 -ne `wc -c <'server/doturn.c'`; then echo shar: \"'server/doturn.c'\" unpacked with wrong size! fi # end of 'server/doturn.c' fi if test -f 'server/files_shl.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/files_shl.c'\" else echo shar: Extracting \"'server/files_shl.c'\" \(8096 characters\) sed "s/^X//" >'server/files_shl.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. X * Restrictions in GB_copyright.h. X * X * disk input/output routines & msc stuff X * all read routines lock the data they just accessed (the file is not X * closed). write routines close and thus unlock that area. X * X * openstardata(&fd),openpdata(&fd),openshdata(&fd),opensectdata(&fd) X * -- open different files, return file descriptors X * getsdata(fd,&Sdata) -- get root dir for univ X * getrace(**racetype,racenum) -- get race from disk X * getstar(fd,**startype,starnum) -- gets star from disk X * getplanet(fd,**planettype,filepos) -- gets planet from disk X * getsector(fd,**sectortype,filepos) -- gets 1 sect from disk X * getsmap(fd,*sectortype,planet) -- gets sector map from disk X * getship(fd,**shiptype,shipnum) -- gets ship from disk X * putsdata(fd,&Sdata) -- put root dir for univ X * putrace(*racetype) -- put race to disk X * putstar(fd,*startype,starnum) -- put star to disk X * putplanet(fd,*planettype,filepos) -- put planet to disk X * putsector(fd,*sectortype,filepos) -- write sector to disk X * putsmap(fd,*sectortype,*planet) -- put smap to disk X * putship(fd,*shiptype,shipnum) -- put ship to disk X * int Numships(fd) -- return highest ship # from file X * getdeadship(fd, &filepos) -- filepos of next dead ship from shipfreedatafile X * makeshipdead(shipnum) -- kill a ship X * int Getracenum(char *) -- return race # from login list X * int Numraces() -- return # of races that exist right now X * Putpower() -- puts Power struct to disk for power command X */ X X#include "GB_copyright.h" X#define EXTERN extern X#include "vars.h" X#include "ships.h" X#include "races.h" X#include "power.h" X#include <strings.h> X#include <sys/stat.h> X#include <signal.h> X#include <errno.h> Xextern int errno; Xint sys_nerr; Xextern char *sys_errlist[]; X X Xopenstardata(fd) Xint *fd; X{ X /*printf(" openstardata\n");*/ X if ( (*fd = open(STARDATAFL, O_RDWR, 0777)) < 0) { X perror("openstardata"); X printf("unable to open %s\n",STARDATAFL); X exit(-1); X } X} X X Xopenshdata(fd) Xint *fd; X{ Xif ( (*fd = open(SHIPDATAFL, O_RDWR, 0777)) < 0) { X perror("openshdata"); X printf("unable to open %s\n",SHIPDATAFL); X exit(-1); X } X} X X Xopenpdata(fd) Xint *fd; X{ Xif ( (*fd = open(PLANETDATAFL, O_RDWR, 0777)) < 0) { X perror("openpdata"); X printf("unable to open %s\n",PLANETDATAFL); X exit(-1); X } X} X X Xopensectdata(fd) Xint *fd; X{ X if ( (*fd = open(SECTORDATAFL, O_RDWR, 0777)) < 0) { X perror("opensectdata"); X printf("unable to open %s\n",SECTORDATAFL); X exit(-1); X } X} X Xopenracedata(fd) Xint *fd; X{ X if ( (*fd = open(RACEDATAFL, O_RDWR, 0777)) < 0) { X perror("openrdata"); X printf("unable to open %s\n",RACEDATAFL); X exit(-1); X } X} X X Xgetsdata(fd,S) Xint fd; Xstruct stardata *S; X{ X Fileread(fd,(char *)S, sizeof(struct stardata), STARDATAFL, 0); X} X X Xgetrace(fd, r,rnum) Xint fd; Xracetype **r; Xint rnum; X{ X *r = (racetype *)malloc(sizeof(racetype)); X Fileread(fd, (char *)*r, sizeof(racetype), RACEDATAFL, X (rnum-1)*sizeof(racetype) ); X} X Xgetstar(fd,s,star) Xint fd; Xstartype **s; Xint star; X{ X *s = (startype *)malloc(sizeof(startype)); X Fileread(fd,(char *)*s, sizeof(startype), STARDATAFL, X (int)(sizeof(Sdata)+star*sizeof(startype)) ); X} X X Xgetplanet(fd,p,filepos) Xint fd; Xplanettype **p; Xint filepos; X{ X *p = (planettype *)malloc(sizeof(planettype)); X Fileread(fd,(char *)*p, sizeof(planettype), PLANETDATAFL, filepos ); X} X X Xgetsector(fd,s,filepos) Xint fd; Xsectortype **s; Xint filepos; X{ X *s = (sectortype *)malloc(sizeof(sectortype)); X Fileread(fd,(char *)*s, sizeof(sectortype), SECTORDATAFL, filepos); X} X X Xgetsmap(fd,map,p) Xint fd; Xsectortype *map; Xplanettype *p; X{ X Fileread(fd,(char *)map, p->Maxx * p->Maxy * sizeof(sectortype), X SECTORDATAFL, p->sectormappos); X} X X Xint getship(fd,s,shipnum) Xint fd; Xshiptype **s; Xint shipnum; X{ X struct stat buf; X X if ((*s = (shiptype *)malloc(sizeof(shiptype)))==NULL) X printf("getship:Malloc() error \n"), exit(); X X fstat(fd,&buf); X if (buf.st_size / sizeof(shiptype) < shipnum) { X (*s)->is_alive = 0; X return 0; X } else { X X Fileread(fd, (char *)*s, sizeof(shiptype), SHIPDATAFL, X (shipnum-1)*sizeof(shiptype) ); X return 1; X } X} X X/* gets the ship # listed in the top of the file SHIPFREEDATAFL. this X** might have no other uses besides build(). X** also locks the fd in shipdata. X*/ Xint getdeadship() X{ X struct stat buf; X short shnum; X int fd,lerr; X int abort; X X if ( (fd = open(SHIPFREEDATAFL, O_RDWR, 0777)) < 0) { X perror("getdeadship"); X printf("unable to open %s\n",SHIPFREEDATAFL); X exit(-1); X } X abort = 1; X fstat(fd,&buf); X X if (buf.st_size && (abort ==1)) { X /* put topmost entry in fpos */ X Fileread(fd, (char *)&shnum, sizeof(short), SHIPFREEDATAFL, X buf.st_size - sizeof(short) ); X /* erase that entry, since it will now be filled */ X ftruncate(fd, (long)(buf.st_size-sizeof(short)) ); X close_file(fd); X return (int)shnum; X } else Xclose_file(fd); X return -1; X} X X X Xputsdata(fd,S) Xint fd; Xstruct stardata *S; X{ X Filewrite(fd,(char *)S, sizeof(struct stardata), STARDATAFL, 0 ); X} X X Xputrace(fd, r) Xint fd; Xracetype *r; X{ X X Filewrite(fd,(char *)r, sizeof(racetype), RACEDATAFL, X (r->Playernum-1)*sizeof(racetype) ); X } X X Xputstar(fd,s,snum) Xint fd; Xstartype *s; Xint snum; X{ X Filewrite(fd,(char *)s, sizeof(startype), STARDATAFL, X (int)(sizeof(Sdata)+snum*sizeof(startype)) ); X} X Xputplanet(fd,p,filepos) Xint fd; Xplanettype *p; Xint filepos; X{ X Filewrite(fd,(char *)p, sizeof(planettype), PLANETDATAFL, filepos ); X} X Xputsector(fd,s,filepos) Xint fd; Xsectortype *s; Xint filepos; X{ X Filewrite(fd,(char *)s, sizeof(sectortype), SECTORDATAFL, filepos ); X} X X Xputsmap(fd,map,p) Xint fd; Xsectortype *map; Xplanettype *p; X{ X Filewrite(fd, (char *)map, X p->Maxx * p->Maxy * sizeof(sectortype), SECTORDATAFL, p->sectormappos); X} X Xputship(fd,s,shipnum) Xint fd; Xshiptype *s; Xint shipnum; X{ X Filewrite(fd,(char *)s, sizeof(shiptype), SHIPDATAFL, X (shipnum-1)*sizeof(shiptype) ); X} X X Xint Numraces() X{ X struct stat buf; X X stat(RACEDATAFL,&buf); X return( (int)(buf.st_size / sizeof(racetype)) ); X} X X X Xint Numships(fd) /* return number of ships */ Xint fd; X{ X struct stat buf; X Xfstat(fd,&buf); X X/* printf("numships %d\n",(int)(buf.st_size / sizeof(shiptype)) ); */ Xreturn( (int)(buf.st_size / sizeof(shiptype)) ); X} X X X X X/* X** writes the ship to the dead ship file at its end. X*/ Xmakeshipdead(shipnum) Xint shipnum; X{ X int fd; X us shipno; X struct stat buf; X X shipno = shipnum; /* conv to u_short */ X X if(shipno == 0)return; X X if ( (fd = open(SHIPFREEDATAFL, O_WRONLY, 0777)) < 0) { X printf("fd = %d \n",fd); X printf("errno = %d \n",errno); X perror("openshfdata"); X printf("unable to open %s\n",SHIPFREEDATAFL); X exit(-1); X } X X printf("ship #%u destroyed.\n", shipno); X /* write the ship # at the very end of SHIPFREEDATAFL */ X fstat(fd,&buf); X Filewrite(fd,(char *)&shipno, sizeof(shipno), SHIPFREEDATAFL, buf.st_size ); X close_file(fd); X} X XPutpower(p) Xstruct power p[MAXPLAYERS]; X{ Xint power_fd; X X if ( (power_fd = open(POWFL, O_RDWR, 0777)) < 0) { X perror("open power data"); X printf("unable to open %s\n",POWFL); X return; X } X write(power_fd, (char *)p, sizeof(*p)*MAXPLAYERS ); X close_file(power_fd); X} X XGetpower(p) Xstruct power p[MAXPLAYERS]; X{ Xint power_fd; X X if ( (power_fd = open(POWFL, O_RDONLY, 0777)) < 0) { X perror("open power data"); X printf("unable to open %s\n",POWFL); X return; X} else { X read(power_fd, (char *)p, sizeof(*p)*MAXPLAYERS); X close_file(power_fd); X } X} X XPutblock(b) Xstruct block b[MAXPLAYERS]; X{ Xint block_fd; X X if ( (block_fd = open(BLOCKDATAFL, O_RDWR, 0777)) < 0) { X perror("open block data"); X printf("unable to open %s\n", BLOCKDATAFL); X return; X } X write(block_fd, (char *)b, sizeof(*b)*MAXPLAYERS ); X close_file(block_fd); X} X XGetblock(b) Xstruct block b[MAXPLAYERS]; X{ Xint block_fd; X X if ( (block_fd = open(BLOCKDATAFL, O_RDONLY, 0777)) < 0) { X perror("open block data"); X printf("unable to open %s\n", BLOCKDATAFL); X return; X} else { X read(block_fd, (char *)b, sizeof(*b)*MAXPLAYERS); X close_file(block_fd); X } X} X END_OF_FILE if test 8096 -ne `wc -c <'server/files_shl.c'`; then echo shar: \"'server/files_shl.c'\" unpacked with wrong size! fi # end of 'server/files_shl.c' fi if test -f 'server/makeuniv.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/makeuniv.c'\" else echo shar: Extracting \"'server/makeuniv.c'\" \(8050 characters\) sed "s/^X//" >'server/makeuniv.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. X * Restrictions in GB_copyright.h. X * X * makeuniv.c -- make data files for the game X */ X X#include "GB_copyright.h" X#define EXTERN X#include "vars.h" X#include "ships.h" X#include "races.h" X#include "power.h" /* (for power) */ X#include <math.h> X X XFILE *fopen(); Xplanettype Makeplanet(); Xchar *Numbers[] = { "1","2","3","4","5","6","7","8","9","10","11", X "12","13","14","15" }; /* for planet naming*/ X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ XFILE *teledata,*racedata,*stardata,*planetdata,*sectordata,*shipdata; Xplanettype planet; Xstartype *Star; Xint star,e,e2,type,lowp,hip, roll, temperature; Xregister int i,y,x; Xchar str[200]; Xfloat att,xspeed[NUMSTARS],yspeed[NUMSTARS], dist, dummy; Xfloat xpos, ypos; X X srandom(getpid()); X X Bzero(Sdata); X printf("# of stars(1-%d):",NUMSTARS-1); X scanf("%d",&(Sdata.numstars)); X printf("low # of planets (1-%d):",MAXPLANETS); X scanf("%d",&lowp); X printf("hi # of planets (%d-%d):",lowp,MAXPLANETS); X scanf("%d",&hip); X getchr(); X X sprintf(str, "/bin/mkdir %s", DATADIR ); X system(str); X X if ( (planetdata = fopen(PLANETDATAFL,"w+"))==NULL) { X printf("unable to open %s\n",PLANETDATAFL); X exit(-1); X } X if ( (sectordata = fopen(SECTORDATAFL,"w+")) == NULL ) { X printf("unable to open %s\n",SECTORDATAFL); X exit(-1); X } X X /* get names, positions of stars first */ X for (star=0; star<Sdata.numstars; star++) { X Stars[star]=(startype *)malloc(sizeof(startype)); X Bzero(*Stars[star]); X Star = Stars[star]; X Star->numplanets=int_rand(lowp, int_rand(lowp, hip)); X Star->temperature=int_rand(0, 4)+int_rand(1, 5); X /* heat of the star */ X Star->gravity = int_rand(10000,100000) / 100.0; X printf("[%d] name of star (%d planets):",star, Star->numplanets); X for (i=0; i<NAMESIZE-4; i++) X putchr('.'); X for (i=0; i<NAMESIZE-4; i++) X putchr('\010'); /* ^H */ X scanf("%14[^\n]",Star->name); X getchr(); X Star->xpos=(float)int_rand(-UNIVSIZE,UNIVSIZE); X xspeed[star] = 0; X Star->ypos=(float)int_rand(-UNIVSIZE,UNIVSIZE); X yspeed[star] = 0; X} X X for (star=0; star<Sdata.numstars; star++) { X X Star = Stars[star]; X X for (i=0; i<Star->numplanets; i++) { X sprintf(Star->pnames[i],"%s",Numbers[i]); X X dist = -1.0; X while (dist >= SYSTEMSIZE || dist <= 100.0) { X xpos=(float)int_rand(-SYSTEMSIZE,SYSTEMSIZE); X ypos=(float)int_rand(-SYSTEMSIZE,SYSTEMSIZE); X dist = sqrt(Distsq(xpos, ypos, 0, 0)); X } X roll=int_rand(0,100); X temperature = Temperature(dist, Star->temperature); X X if(temperature > 200) { X if(roll<=25) X type = TYPE_AIRLESS; X else X type = TYPE_ASTEROID; X } else if(temperature > 100 && temperature <=200) { X if(roll<=50) X type = TYPE_ASTEROID; X else X type = TYPE_AIRLESS; X } else if(temperature > 30 && temperature <= 100) { X if(roll<=25) X type = TYPE_ASTEROID; X else if(roll > 25 && roll <=50) X type = TYPE_AIRLESS; X else if(roll > 50 && roll <=75) X type = TYPE_EARTH; X else X type = TYPE_WATER; X } else if(temperature > -10 && temperature <= 30) { X if(roll <=25) X type = TYPE_ASTEROID; X else if(roll > 25 && roll <=50) X type = TYPE_AIRLESS; X else if(roll > 50 && roll <=75) X type = TYPE_EARTH; X else X type = TYPE_WATER; X } else if(temperature > -50 && temperature <= -10) { X if(roll <=25) X type = TYPE_ASTEROID; X else if(roll>25 && roll <=50) X type = TYPE_AIRLESS; X else if(roll>50 && roll <=75) X type = TYPE_ICEBALL; X else X type = TYPE_EARTH; X } else if(temperature <= -50) { X if(roll<=25) X type = TYPE_ASTEROID; X else if(roll>25 && roll <=50) X type = TYPE_AIRLESS; X else if(roll >50 && roll <=75) X type = TYPE_ICEBALL; X else X type = TYPE_GASGIANT; X } X X X planet = Makeplanet(dist, Star->temperature, type); X planet.xpos = xpos; X planet.ypos = ypos; X X X if (argc==2 && (argv[1][1]=='v' || argv[1][1]=='a')) X printf("planet %s is type %u\n",Star->pnames[i],planet.type); X X if (argc==2 && argv[1][1]=='v') { X printf("at %f,%f relative to %s.\n",planet.xpos,planet.ypos,Star->name); X printf("sect map(%dx%d):\n",planet.Maxx,planet.Maxy); X for (y=0; y<planet.Maxy; y++) { X for (x=0; x<planet.Maxx; x++) { X switch (Sector(planet,x,y).des) { X case DES_LAND: putchr(CHAR_LAND); break; X case DES_SEA: putchr(CHAR_SEA); break; X case DES_MOUNT: putchr(CHAR_MOUNT); break; X case DES_ICE: putchr(CHAR_ICE); break; X case DES_GAS: putchr(CHAR_GAS); break; X default: putchr('?'); break; X } X } X putchr('\n'); X } X } X Star->planetpos[i] = (int)ftell(planetdata); X /* posn of file-last write*/ X planet.sectormappos = (int)ftell(sectordata); /* sector map pos */ X fwrite(&planet,sizeof(planettype),1,planetdata); /* write planet */ X /* write each sector row */ X for (y=0; y < planet.Maxy; y++) X fwrite( &Sector(planet,0,y), X sizeof(sectortype),planet.Maxx,sectordata); X } X } X fchmod(planetdata,00660); /* change data files to group readwrite */ X fclose(planetdata); X fchmod(sectordata,00660); X fclose(sectordata); X X /* get rid of this */ X if ((stardata = fopen("data.starB","w+"))==NULL) { X printf(" unable to open %s\n","data.starB"); X exit(-1); X } X fwrite(&(Sdata),sizeof(Sdata),1,stardata); X for (star=0; star<Sdata.numstars; star++) { X fwrite(Stars[star],sizeof(startype),1,stardata); X } X fchmod(stardata,00660); X fclose(stardata); X X /* try to (more or less) evenly space the stars */ X for (i=0; i<CREAT_UNIV_ITERAT; i++) X for (star=0; star<Sdata.numstars; star++) { X for (x=0; x<Sdata.numstars; x++) /* star2 */ X if (x!=star) { X /* find inverse of distance squared */ X att = 10*UNIVSIZE / Distsq(Stars[star]->xpos, Stars[star]->ypos, Stars[x]->xpos, Stars[x]->ypos); X xspeed[star] += att * (Stars[star]->xpos - Stars[x]->xpos); X if (Stars[star]->xpos>UNIVSIZE || Stars[star]->xpos< -UNIVSIZE) X xspeed[star] *= -1; X yspeed[star] += att * (Stars[star]->ypos - Stars[x]->ypos); X if (Stars[star]->ypos>UNIVSIZE || Stars[star]->ypos< -UNIVSIZE) X yspeed[star] *= -1; X } X Stars[star]->xpos += xspeed[star]; X Stars[star]->ypos += yspeed[star]; X } X X if ((stardata = fopen(STARDATAFL,"w+"))==NULL) { X printf(" unable to open %s\n",STARDATAFL); X exit(-1); X } X fwrite(&(Sdata),sizeof(Sdata),1,stardata); X for (star=0; star<Sdata.numstars; star++) { X fwrite(Stars[star],sizeof(startype),1,stardata); X } X fchmod(stardata,00660); X fclose(stardata); X X { shiptype s; X if ((shipdata = fopen(SHIPDATAFL,"w+"))==NULL) { X printf(" unable to open %s\n",SHIPDATAFL); X exit(-1); X } X fchmod(shipdata,00660); X fclose(shipdata); X } X X { short s=1; X if ((shipdata = fopen(SHIPFREEDATAFL,"w+"))==NULL) { X printf(" unable to open %s\n",SHIPFREEDATAFL); X exit(-1); X } X fchmod(shipdata,00660); X fclose(shipdata); /* touch ship free position file */ X } X X if ((shipdata = fopen(PLAYERDATAFL,"w+"))==NULL) { X printf(" unable to open %s\n",PLAYERDATAFL); X exit(-1); X } X fchmod(shipdata,00660); X fclose(shipdata); /* touch player file */ X X if ((racedata = fopen(RACEDATAFL,"w+"))==NULL) { X printf(" unable to open %s\n",RACEDATAFL); X exit(-1); X } X fchmod(racedata,00660); X fclose(racedata); /* touch race data file */ X X { X struct power p[MAXPLAYERS]; X bzero((char *)p, sizeof(p)); X if ((racedata = fopen(POWFL,"w+"))==NULL) { X printf(" unable to open %s\n",POWFL); X exit(-1); X } X fwrite(p,sizeof(p),1,racedata); X fchmod(racedata,00660); X fclose(racedata); /* touch power data file */ X } X X { X struct block p[MAXPLAYERS]; X bzero((char *)p, sizeof(p)); X if ((racedata = fopen(BLOCKDATAFL,"w+"))==NULL) { X printf(" unable to open %s\n",BLOCKDATAFL); X exit(-1); X } X fwrite(p,sizeof(p),1,racedata); X fchmod(racedata,00660); X fclose(racedata); /* touch block data file */ X } X X sprintf(str, "/bin/mkdir %s", TELEGRAMDIR ); X system(str); X chmod(TELEGRAMDIR, 00770); X X /* make telegram files for each player */ X for (i=1; i<=MAXPLAYERS; i++) { X sprintf(str, "%s.%d", TELEGRAMFL, i ); X if ((teledata = fopen(str, "w+"))==NULL) { X printf(" unable to open %s\n",str); X } else { X fchmod(teledata,00660); X fclose(teledata); X } X } X} END_OF_FILE if test 8050 -ne `wc -c <'server/makeuniv.c'`; then echo shar: \"'server/makeuniv.c'\" unpacked with wrong size! fi # end of 'server/makeuniv.c' fi if test -f 'server/prof.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/prof.c'\" else echo shar: Extracting \"'server/prof.c'\" \(8213 characters\) sed "s/^X//" >'server/prof.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. X * Restrictions in GB_copyright.h. X * X * prof.c -- print out racial profile X */ X X#include "GB_copyright.h" X#define EXTERN extern X#include "vars.h" X#include "races.h" X#include "ships.h" X#include "buffers.h" X Xextern char *Desnames[]; Xint prof_racedata; Xchar *Estimate_f(), *Estimate_i(); X Xwhois(Playernum, APcount, argn, args) Xint Playernum; Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xint i, j, numraces; X Xif(argn <= 1) { X notify(Playernum, "You must give a list of player numbers.\n"); X return; X } Xnumraces = Numraces(); X Xfor(i=1; i<=argn-1; i++) { X j=atoi(args[i]); X if(!(j<1 || j>numraces)) { Xfree(Race); Xopenracedata(&prof_racedata); Xgetrace(prof_racedata, &Race, j); Xclose_file(prof_racedata); X sprintf(buf, "[%2d] %s\n", j, Race->name); X notify(Playernum, buf); X } X } X X} X Xprofile(Playernum,APcount, argn,args) Xint Playernum; Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ X int i, p, numraces; X racetype *r; X Xfree(Race); Xopenracedata(&prof_racedata); Xgetrace(prof_racedata, &Race,Playernum); Xclose_file(prof_racedata); X Xif(argn==1) { X sprintf(buf,"---==** Racial profile for %s (player %d) **==---\n",Race->name, X Race->Playernum); X notify(Playernum, buf); Xif(Race->God) { X sprintf(buf, " *** Diety Status ***\n"); X notify(Playernum, buf); X } X Xsprintf(buf," (default scope /%s/%s)\n\n",Stars[Race->homesystem]->name, X Stars[Race->homesystem]->pnames[Race->homeplanetnum] ); X notify(Playernum, buf); X sprintf(buf," %10srate: %.1f\n",Race->Thing ? "Infection " : "Birth",Race->birthrate); X notify(Playernum, buf); Xsprintf(buf," Technology: %.1f\n",Race->tech); X notify(Playernum, buf); Xsprintf(buf," Avg Intelligence: %u\n",Race->IQ); X notify(Playernum, buf); Xsprintf(buf," mass: %.2f\n",Race->mass); X notify(Playernum, buf); Xsprintf(buf," metabolism: %.1f\n",Race->metabolism); X notify(Playernum, buf); Xsprintf(buf," adventurists: %.2f%%\n",Race->adventurism*100.0); X notify(Playernum, buf); Xsprintf(buf," fighting ability: %d\n",Race->fighters); X notify(Playernum, buf); Xsprintf(buf," # of sexes: %d\n", Race->number_sexes); X notify(Playernum, buf); X if (Race->Thing) { Xsprintf(buf,"Mesomorphic race (like \"The Thing\").\n"); X notify(Playernum, buf); X } X sprintf(buf,"planetary conditions preferred by %s:\n", Race->name); X notify(Playernum, buf); Xsprintf(buf," temperature: %d\n", Temp(Race->conditions[TEMP]) ); X notify(Playernum, buf); Xsprintf(buf," atmosphere concentrations:\n"); X notify(Playernum, buf); Xsprintf(buf," methane %02d%% oxygen %02d%%\n", X Race->conditions[METHANE], Race->conditions[OXYGEN] ); X notify(Playernum, buf); Xsprintf(buf," CO2 %02d%% hydrogen %02d%%\n", X Race->conditions[CO2], Race->conditions[HYDROGEN] ); X notify(Playernum, buf); Xsprintf(buf," nitrogen %02d%% sulfur %02d%%\n", X Race->conditions[NITROGEN], Race->conditions[SULFUR] ); X notify(Playernum, buf); Xsprintf(buf," helium %02d%% other %02d%%\n", X Race->conditions[HELIUM], Race->conditions[OTHER]); X notify(Playernum, buf); Xsprintf(buf,"Sector type preferences:\n"); X notify(Playernum, buf); Xsprintf(buf," %c (%11s) %3.2f%% %c (%11s) %3.2f%%\n", X CHAR_SEA, Desnames[DES_SEA], Race->likes[DES_SEA]*100, X CHAR_GAS, Desnames[DES_GAS], Race->likes[DES_GAS]*100); X notify(Playernum, buf); Xsprintf(buf," %c (%11s) %3.2f%% %c (%11s) %3.2f%%\n", X CHAR_MOUNT, Desnames[DES_MOUNT], Race->likes[DES_MOUNT]*100, X CHAR_LAND, Desnames[DES_LAND], Race->likes[DES_LAND]*100); X notify(Playernum, buf); Xsprintf(buf," %c (%11s) %3.2f%% %c (%11s) %3.2f%%\n", X CHAR_ICE, Desnames[DES_ICE], Race->likes[DES_ICE]*100, X CHAR_PLATED, Desnames[DES_PLATED], Race->likes[DES_PLATED]*100); X notify(Playernum, buf); X if (Race->Gov_ship==0) { X sprintf(buf,"\nNo designated capitol!!\n"); X notify(Playernum, buf); X} else { X sprintf(buf,"\nDesignated capitol: #%d\n", Race->Gov_ship); X notify(Playernum, buf); X } X sprintf(buf,"\nTelescope ranges: ground: %.0f, space: %.0f\n", X tele_range(OTYPE_GTELE,Race->tech), tele_range(OTYPE_STELE,Race->tech) ); X notify(Playernum, buf); X sprintf(buf,"Gun range: %.0f\n", gun_range(Race, NULL) ); X notify(Playernum, buf); X} else { X X GetPlayer(args[1], &p, &r); X X if (p== -1) { X sprintf(buf,"Player does not exist.\n"); X notify(Playernum, buf); X return; X } X X sprintf(buf,"------ Race report on %s (%d) ------\n", r->name, p); X notify(Playernum, buf); X if(Race->God) { Xif(r->God) { X sprintf(buf, " *** Diety Status ***\n"); X notify(Playernum, buf); X } X Xsprintf(buf," (default scope /%s/%s)\n\n",Stars[r->homesystem]->name, X Stars[r->homesystem]->pnames[r->homeplanetnum] ); X notify(Playernum, buf); X } X if (Race->translate[p-1]>50) { X sprintf(buf,"\nType: %s\n", r->Thing ? "Mesomorphic" : "Normal"); X notify(Playernum, buf); X sprintf(buf," %10srate: %s%%\n", r->Thing ? "Infection " : "Birth", X Estimate_f(r->birthrate*100.0,Race,p) ); X notify(Playernum, buf); X } else { X sprintf(buf,"\nType (mesomorphic or normal): ?\n"); X notify(Playernum, buf); X sprintf(buf," Approx. expansion rate: %s\n", Estimate_f(r->birthrate,Race,p) ); X notify(Playernum, buf); X } X sprintf(buf," Technology: %s\n", Estimate_f(r->tech,Race,p) ); X notify(Playernum, buf); X sprintf(buf," Avg Intelligence: %s\n", Estimate_i((int)r->IQ, Race,p) ); X notify(Playernum, buf); X sprintf(buf," mass: %s\n", Estimate_f(r->mass,Race,p) ); X notify(Playernum, buf); X sprintf(buf," metabolism: %s\n", Estimate_f(r->metabolism,Race,p) ); X notify(Playernum, buf); X sprintf(buf," adventurists: %s%%\n", Estimate_f(r->adventurism*100.0, Race,p) ); X notify(Playernum, buf); Xsprintf(buf," fighting ability: %s\n", Estimate_i((int)r->fighters, Race,p) ); X notify(Playernum, buf); X sprintf(buf," # of sexes: %s\n", Estimate_i((int)r->number_sexes, Race,p) ); X notify(Playernum, buf); X X sprintf(buf,"planetary conditions preferred by %s:\n", r->name); X notify(Playernum, buf); X sprintf(buf," temperature: %s\n", X Estimate_i((int)Temp(r->conditions[TEMP]),Race,p) ); X notify(Playernum, buf); X sprintf(buf," atmosphere concentrations:\n"); X notify(Playernum, buf); X sprintf(buf," Methane %2s%% Oxygen %2s%%\n", X Estimate_i((int)r->conditions[METHANE],Race,p), X Estimate_i((int)r->conditions[OXYGEN],Race,p) ); X notify(Playernum, buf); X sprintf(buf," CO2 %2s%% Hydrogen %2s%%\n", X Estimate_i((int)r->conditions[CO2],Race,p), X Estimate_i((int)r->conditions[HYDROGEN],Race,p) ); X notify(Playernum, buf); X sprintf(buf," Nitrogen %2s%% Sulfur %2s%%\n", X Estimate_i((int)r->conditions[NITROGEN],Race,p), X Estimate_i((int)r->conditions[SULFUR],Race,p) ); X notify(Playernum, buf); X sprintf(buf," Helium %2s%% Other %2s%%\n", X Estimate_i((int)r->conditions[HELIUM],Race,p), X Estimate_i((int)r->conditions[OTHER],Race,p) ); X X notify(Playernum, buf); X sprintf(buf,"Sector type preference : %s\n", X Race->translate[p-1]>80 ? Desnames[r->likesbest] : " ? " ); X notify(Playernum, buf); X X sprintf(buf,"\nTelescope ranges: ground: %s, space: %s\n", X Estimate_f(tele_range(OTYPE_GTELE,r->tech), Race,p), X Estimate_f(tele_range(OTYPE_STELE,r->tech), Race,p) ); X notify(Playernum, buf); X sprintf(buf,"Gun range: %s\n", X Estimate_f(gun_range(r, NULL), Race,p) ); X notify(Playernum, buf); X X } X X} X Xstatic char est_buf[20]; X Xchar *Estimate_f(data, r, p) Xfloat data; Xracetype *r; Xint p; X{ X Xsprintf(est_buf, "?"); X X if (r->translate[p-1]>10) X sprintf(est_buf, "%d", round_perc((int)data, r,p) ); X X return est_buf; X X} X Xchar *Estimate_i(data, r, p) Xint data; Xracetype *r; Xint p; X{ X Xsprintf(est_buf, "?"); X X if (r->translate[p-1]>10) X sprintf(est_buf, "%2d", round_perc((int)data, r,p) ); X X return est_buf; X} X X Xint round_perc(data, r,p) Xint data; Xracetype *r; Xint p; X{ X int k; X X k = 101 - MIN(r->translate[p-1] + r->captured_prisoners[p-1], 100); X Xreturn ((data/k)*k); X X} END_OF_FILE if test 8213 -ne `wc -c <'server/prof.c'`; then echo shar: \"'server/prof.c'\" unpacked with wrong size! fi # end of 'server/prof.c' fi if test -f 'server/survey.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/survey.c'\" else echo shar: Extracting \"'server/survey.c'\" \(6864 characters\) sed "s/^X//" >'server/survey.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. X * Restrictions in GB_copyright.h. X * X * survey.c -- print out survey for planets X */ X X#include "GB_copyright.h" X#define EXTERN extern X#include "vars.h" X#include "ships.h" X#include "races.h" X#include "buffers.h" X#include <string.h> X#include <ctype.h> Xextern float compatibility(); Xextern char desshow(); Xextern char *Desnames[]; X /* user's guide to toxicity */ Xchar *Tox[] = { X "Stage 0, mild", X "Stage 1, mild", X "Stage 2, semi-mild", X "Stage 3, semi-semi mild", X "Stage 4, ecologically unsound", X "Stage 5: ecologically unsound", X "Stage 6: below birth threshold", X "Stage 7: ecologically unstable--below birth threshold", X "Stage 8: ecologically poisonous --below birth threshold", X "Stage 9: WARNING: nearing 100% toxicity", X "Stage 10: WARNING: COMPLETELY TOXIC!!!", X "???" X}; Xint survey_racedata; X X Xsurvey(Playernum,APcount, argn,args) Xint Playernum; Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xint lowx,hix,lowy,hiy,x2; Xchar d; Xsectortype *s; Xplanettype *p; Xint tindex,survey_pdata,survey_sectdata; Xplacetype where; Xfloat compat; X Xif (argn==1) { /* no args */ X X where.level = Dir[Playernum-1].level; X where.snum = Dir[Playernum-1].snum; X where.pnum = Dir[Playernum-1].pnum; X X} else { X X /* they are surveying a sector */ X if (isdigit(args[1][0]) && index(args[1],',')!=NULL) { X if (Dir[Playernum-1].level!=LEVEL_PLAN) { X sprintf(buf,"There are no sectors here.\n"); X notify(Playernum, buf); X return; X } else { X where.level = LEVEL_PLAN; X where.snum = Dir[Playernum-1].snum; X where.pnum = Dir[Playernum-1].pnum; X } X } else { X where = Getplace(Playernum,args[1],0); X if (where.err) X return; X } X X} X Xfree(Race); Xopenracedata(&survey_racedata); Xgetrace(survey_racedata, &Race, Playernum); Xclose_file(survey_racedata); X Xif (where.level==LEVEL_PLAN) { X X X openpdata(&survey_pdata); X getplanet(survey_pdata,&p,Stars[where.snum]->planetpos[where.pnum]); X close_file(survey_pdata); X X compat = compatibility(p,Race); X X X if (isdigit(args[1][0]) && index(args[1],',')!=NULL) { X X opensectdata(&survey_sectdata); X getsmap(survey_sectdata,Smap,p); X close_file(survey_sectdata); X X get4args(args[1],&x2,&hix,&lowy,&hiy); X /* ^^^ translate from lowx:hix,lowy:hiy */ X x2 = MAX(0, x2); X hix = MIN(hix, p->Maxx-1); X lowy = MAX(0, lowy); X hiy = MIN(hiy, p->Maxy-1); X X sprintf(buf," x,y des ( type ) owner eff mob frt res popn ^popn\n"); X notify(Playernum, buf); X X for (; lowy<=hiy; lowy++) X for (lowx=x2; lowx<=hix; lowx++) { X s = &Sector(*p, lowx, lowy); X /*if (s->owner==Playernum)*/ X sprintf(buf,"%2d,%-2d ", lowx, lowy); X notify(Playernum, buf); X if ( (d = desshow(Playernum, p, lowx, lowy, Race))==CHAR_CLOAKED) { X sprintf(buf,"? ( ? )\n"); X notify(Playernum, buf); X } else { X sprintf(buf,"%c (%11s) %6u%4u%4u%4u%4u%5u%6d\n", X d, Desnames[s->des], s->owner, s->eff, X s->mobilization, s->fert, s->resource, s->popn, X maxsupport(Race,s,compat,p->conditions[TOXIC]) ); X notify(Playernum, buf); X } X } X free(p); X X } else { X X /* survey of planet */ X X sprintf(buf,"%s:\n",Stars[where.snum]->pnames[where.pnum]); X notify(Playernum, buf); X sprintf(buf,"gravity x,y absolute x,y relative to %s\n",Stars[where.snum]->name); X notify(Playernum, buf); X sprintf(buf,"%7.2f %7.1f,%7.1f %8.1f,%8.1f\n", X gravity(p), X p->xpos + Stars[where.snum]->xpos, X p->ypos + Stars[where.snum]->ypos, X p->xpos, p->ypos ); X X notify(Playernum, buf); X sprintf(buf,"======== Planetary conditions: ========\n"); X notify(Playernum, buf); X sprintf(buf,"atmosphere concentrations:\n"); X notify(Playernum, buf); X sprintf(buf," methane %02d%%(%02d%%) oxygen %02d%%(%02d%%)\n", X p->conditions[METHANE], Race->conditions[METHANE], X p->conditions[OXYGEN], Race->conditions[OXYGEN] ); X notify(Playernum, buf); X sprintf(buf," CO2 %02d%%(%02d%%) hydrogen %02d%%(%02d%%) temperature: %3d (%3d)\n", X p->conditions[CO2], Race->conditions[CO2], X p->conditions[HYDROGEN], Race->conditions[HYDROGEN], X Temp(p->conditions[TEMP]), Temp(Race->conditions[TEMP]) ); X notify(Playernum, buf); X sprintf(buf," nitrogen %02d%%(%02d%%) sulfur %02d%%(%02d%%) normal: %3d\n", X p->conditions[NITROGEN], Race->conditions[NITROGEN], X p->conditions[SULFUR], Race->conditions[SULFUR], X Temp(p->conditions[RTEMP]) ); X notify(Playernum, buf); X sprintf(buf," helium %02d%%(%02d%%) other %02d%%(%02d%%)\n", X p->conditions[HELIUM], Race->conditions[HELIUM], X p->conditions[OTHER], Race->conditions[OTHER]); X notify(Playernum, buf); X if ((tindex = p->conditions[TOXIC]/10) < 0) X tindex = 0; X else if (tindex > 10) X tindex = 11; X sprintf(buf," Toxicity: %d%% (%s)\n", X p->conditions[TOXIC], Tox[tindex] ); X notify(Playernum, buf); X sprintf(buf,"Total planetary compatibility: %.2f%%\n", compatibility(p, Race) ); X notify(Playernum, buf); X X sprintf(buf,"fuel_stock resource_stock dest_pot. %s ^%s\n", X Race->Thing ? "biomass" : "popltn", X Race->Thing ? "biomass" : "popltn"); X notify(Playernum, buf); X sprintf(buf,"%10lu %14lu %9lu %7lu%11lu\n", p->info[Playernum-1].fuel, X p->info[Playernum-1].resource, X p->info[Playernum-1].destruct, X p->popn, p->maxpopn); X notify(Playernum, buf); X if (p->slaved_to) { X sprintf(buf,"This planet ENSLAVED to player %d!\n", p->slaved_to); X notify(Playernum, buf); X } X free(p); X X } X X } else if (where.level==LEVEL_STAR) { X X sprintf(buf,"Star %s\n",Stars[where.snum]->name); X notify(Playernum, buf); X sprintf(buf,"locn: %f,%f\n",Stars[where.snum]->xpos,Stars[where.snum]->ypos); X notify(Playernum, buf); X sprintf(buf,"gravity: %.2f\tstability: ", Stars[where.snum]->gravity); X notify(Playernum, buf); X sprintf(buf,"temperature class (1->10) %d\n", Stars[where.snum]->temperature); X notify(Playernum, buf); Xif (Race->tech >= TECH_SEE_STABILITY) { X sprintf(buf,"%d%% (%s)\n", X Stars[where.snum]->stability, X Stars[where.snum]->stability<20 ? "stable" : X Stars[where.snum]->stability<40 ? "unstable" : X Stars[where.snum]->stability<60 ? "dangerous" : X Stars[where.snum]->stability<100 ? "WARNING! nova iminent!" : X "undergoing nova" ); X notify(Playernum, buf); X } else { X sprintf(buf,"(cannot determine)\n"); X notify(Playernum, buf); X } X sprintf(buf,"%d planets are ",Stars[where.snum]->numplanets); X notify(Playernum, buf); X for (x2=0; x2<Stars[where.snum]->numplanets; x2++) { X sprintf(buf,"%s ", Stars[where.snum]->pnames[x2]); X notify(Playernum, buf); X } X sprintf(buf,"\n"); X notify(Playernum, buf); X X } else if (where.level==LEVEL_UNIV) { X sprintf(buf,"It's just _there_, you know?\n"); X notify(Playernum, buf); X X} else { X sprintf(buf,"scope must be a planet.\n"); X notify(Playernum, buf); X } X} END_OF_FILE if test 6864 -ne `wc -c <'server/survey.c'`; then echo shar: \"'server/survey.c'\" unpacked with wrong size! fi # end of 'server/survey.c' fi echo shar: End of archive 8 \(of 14\). cp /dev/null ark8isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 14 archives. 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