|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T e
Length: 7667 (0x1df3) Types: TextFile Names: »enrol.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Gb/enrol.c«
/* * Galactic Bloodshed (Robert Chansky, smq@b) * enrol.c -- initializes to owner one sector and planet. */ #include "vars.h" #include "races.h" #include <signal.h> #include <strings.h> #include <curses.h> #include <errno.h> extern int errno; extern char desshow(); struct stype { char here; char x,y; int count; }; /* compatibility schematic for sectors. Note that plated sectors are compatible with everything. */ float Likes[DES_PLATED+1][DES_PLATED+1] = { /* DES_SEA DES_LAND DES_MOUNT DES_GAS DES_ICE DES_PLATED*/ /*DES_SEA */ 1.0, 0.0, 0.0, 0.3, 0.05, 1.0, /*DES_LAND */ 0.0, 1.0, 0.5, 0.0, 0.1, 1.0, /*DES_MOUNT*/ 0.0, 0.5, 1.0, 0.0, 0.7, 1.0, /*DES_GAS */ 0.5, 0.0, 0.0, 1.0, 0.0, 1.0, /*DES_ICE */ 0.15, 0.25, 0.7, 0.0, 1.0, 1.0, /*DES_PLATED*/ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 }; enroll(loginname) char *loginname; { int x,y, or; int pnum,star=0,found=0,i,j,enroll_pdata, enroll_sectdata, enroll_stardata,mask,ppref; char str[100], c; sectortype *sect; struct stype secttypes[DES_PLATED+1]; planettype *planet; FILE *fd; if ( (Playernum=Numraces()+1) >= MAXPLAYERS) { printf("There are already %d players; No more allowed.\n",Playernum); exit(-1); } printf("There is still space for player %d.", Playernum); printf("\n\tenroll(y/n)\?"); c = getchr(); getchr(); if (c!='y') { printf("why did you come here, then?\n"); endwin(); exit(0); } /* look at enroll screen */ sprintf(str, "%s %s", PAGER, ENROLL_FL); system(str); printf("\n Live on what type planet:(e)arthtype, (g)asgiant, (a)irless? "); c = getchr(); getchr(); switch (c) { case 'e': ppref = TYPE_EARTH; break; case 'a': ppref = TYPE_AIRLESS; break; case 'g': ppref = TYPE_GASGIANT; break; default: printf("Oh well.\n"); exit(-1); break; } /* find first planet of right type */ star = 0; found = 0; while (!found && star<Sdata.numstars) { for (or=i=0; i<howmanybytes(Playernum); i++ ) or |= Stars[star]->explored[i]; /* make sure no one has explored the star */ if (!or) { pnum = 0; while (!found && pnum<Stars[star]->numplanets) { printf(" getting st %d pl #%d\n",star, pnum); openpdata(&enroll_pdata); getplanet(enroll_pdata,&planet,Stars[star]->planetpos[pnum]); if (planet->type==ppref) { printf(" yep.\n"); found = 1; } else { printf(" nope.\n"); close(enroll_pdata); free(planet); pnum++; } } } if (!found) star++; } printf(" star %d, pl %d\n", star,pnum); if (!found) { printf(" Uhoh, there don't seem to be any of that type of planet left.\n"); printf(" Try a different one...\n"); endwin(); exit(0); } Race = Malloc(racetype); Bzero(*Race); tty_off(); printf("\n\nEnter a name for your race:"); dots(RNAMESIZE); scanf("%[^\n]",str); getchr(); printf("\n\nwait...\n"); strncpy(Race->name, str, RNAMESIZE); Race->homelevel = Race->deflevel = LEVEL_PLAN; Race->homesystem = Race->defsystem = star; Race->homeplanetnum = Race->defplanetnum = pnum; /* make conditions preferred by your people set to (more or less) those of the planet : higher the concentration of gas, the higher percentage difference between planet and race */ for (j=0; j<=OTHER; j++) Race->conditions[j] = planet->conditions[j]; /*+ int_rand( round_rand(-planet->conditions[j]*2.0), round_rand(planet->conditions[j]*2.0) )*/ for (i=0; i<MAXPLAYERS; i++) /* messages from autoreport, player #1 are decodable */ if (i==Playernum || i==1) Race->translate[i] = 100; /* you can talk to own race */ else Race->translate[i] = 1; i = 5; found = 0; tty_on(); do { if (i<=0) { printf("Too long. bye\n"); exit(0); } Race->tech = 0; Race->overbirthrate = float_rand() * 0.01; /* your race is like "the Thing" */ if (Race->Thing = !int_rand(0,10) ) { Race->mass = 1.0; Race->birthrate = float_rand()*0.25 + 0.55; Race->fighters = int_rand(7,9); Race->IQ = int_rand(30,60); Race->nonhomebodies = 0.99; Race->number_sexes = 1; Race->metabolism = float_rand() * 0.25 + 0.52; } else { Race->birthrate = float_rand()*0.25 + 0.25; Race->mass = 0.5 + 1.5 * float_rand(); Race->fighters = int_rand(1,3)+int_rand(1,3); Race->IQ = int_rand(103,220); Race->nonhomebodies = 0.70 + float_rand()*0.20; Race->metabolism = float_rand() * 0.25 + 0.875; Race->number_sexes = int_rand(1,int_rand(2,int_rand(3,9))); } clear(); move(0,0); printw("%s\n", Race->Thing ? "MESOMORPHIC" : ""); printw(" Birthrate: %.3f\n",Race->birthrate); printw("Fighting ability: %d\n",Race->fighters); printw(" IQ: %d\n",Race->IQ); printw(" Metabolism: %.2f\n",Race->metabolism); printw(" Adventurists: %.2f\n",Race->nonhomebodies); printw(" Mass: %.2f\n",Race->mass); if (!Race->Thing) printw(" Number of sexes: %d (min req'd for colonization)\n",Race->number_sexes); printw("\n\n (%d re-rolls left) space to reroll:", --i); refresh(); if (getchr()!=' ') found = 1; } while (!found); bzero((char *)secttypes, sizeof(secttypes)); opensectdata(&enroll_sectdata); getsmap(enroll_sectdata,Smap,planet->sectormappos,planet->Maxx*planet->Maxy); printf("\nChoose a primary sector preference. Your race will prefer to live\non this type of sector.\n"); PermuteSects(planet); Getxysect(planet, 0, 0, 1); while (Getxysect(planet,&x,&y,0)) { secttypes[Sector(*planet,x,y).des].count++; if (!secttypes[Sector(*planet,x,y).des].here) { secttypes[Sector(*planet,x,y).des].here = 1; secttypes[Sector(*planet,x,y).des].x = x; secttypes[Sector(*planet,x,y).des].y = y; } } Playernum = 1; planet->is_explored = 1; for (i=DES_SEA; i<=DES_PLATED; i++) if (secttypes[i].here) { Sector(*planet,secttypes[i].x,secttypes[i].y).is_wasted = 0; printf("(%2d): %c (%d sectors)\n", i, desshow(planet, secttypes[i].x,secttypes[i].y), secttypes[i].count); } planet->is_explored = 0; printf("\nchoice: "); scanf("%d", &i); if (i<DES_SEA || i>DES_PLATED || !secttypes[i].here) { printf("Forget it.\n"); endwin(); exit(0); } sect = &Sector(*planet,secttypes[i].x,secttypes[i].y); Race->likesbest = i; for (j=DES_SEA; j<=DES_PLATED; j++) Race->likes[j] = Likes[i][j]; Playernum = Race->Playernum = Numraces() + 1; mask = sigblock(SIGINT | SIGQUIT | SIGSTOP); putrace(Race); planet->info[Playernum-1].numsectsowned = 1; planet->is_explored = 0; planet->info[Playernum-1].explored = 1; /*planet->info[Playernum-1].autorep = 1;*/ sect->owner = Playernum; sect->popn = planet->popn = Race->number_sexes * 5; sect->fert = 100; sect->eff = 10; putsector(enroll_sectdata,sect,planet->sectormappos+(secttypes[i].y*planet->Maxx+secttypes[i].x)*sizeof(sectortype)); close(enroll_sectdata); putplanet(enroll_pdata,planet,Stars[star]->planetpos[pnum-1]); close(enroll_pdata); /* make star explored and stuff */ openstardata(&enroll_stardata); getstar(enroll_stardata,&Stars[star],star); setbit(Stars[star]->explored,Playernum); setbit(Stars[star]->inhabited,Playernum); Stars[star]->AP[Playernum] = 5; putstar(enroll_stardata,Stars[star],star); close(enroll_stardata); fd = fopen(PLAYERDATAFL,"a"); fprintf(fd,"%s\n",loginname ); fclose(fd); sigsetmask(mask); printf("You are player %d.\n",Playernum); printf("Your race has been created on sector %d,%d on\n", secttypes[i].x,secttypes[i].y); printf("Planet %d of star %s.\n",pnum+1,Stars[star]->name); /* chdir to your new home planet */ docommand("cs"); }