|
|
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 f
Length: 12202 (0x2faa)
Types: TextFile
Names: »fix.c.orig«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Gb/fix.c.orig«
/*
* Galactic Bloodshed (Robert Chansky, smq@b)
* fix.c -- allows manager to edit various stuff.
* -not to be used by players cuz it will get boring fast
* note: may not work under machines w/
* sizeof(int) <> sizeof(float).
*/
#define FLOAT 0 /* to tell query what to input for */
#define INT 1
#define CHAR 2
#define SHORT 3
#define LONG 4
#define DOUBLE 5
#include "vars.h"
#include "tweakables.h"
#include "ships.h"
#include "races.h"
#include <strings.h>
#include <ctype.h>
#include <signal.h>
#include <setjmp.h>
extern jmp_buf main_jenv;
int fix_stardata,fix_shdata,fix_pdata,fix_sectdata;
char s[40];
extern char *Shipnames[];
bool fix_mod;
fix(argn,args)
int argn;
char args[MAXARGS][COMMANDSIZE];
{
char ch;
short shrt;
float f;
int i;
unsigned long unl;
planettype *p;
sectortype *sect;
shiptype *sh;
int fix_handler();
fix_mod = 0;
fix_stardata = fix_shdata = fix_pdata = fix_sectdata = NEUTRAL_FD;
/* so closure does not cause wanted files to close (like stdin
or stdout) -- should not cause probs most vers. of UNIX */
signal(SIGINT, fix_handler);
if (argn==2 && !strcmp(args[1],"race")) {
query(FLOAT,"tech",&Race->tech,0,0,0,0);
query(FLOAT,"birthrate",&Race->birthrate,0,0,0,0);
query(FLOAT,"mass",&Race->mass,0,0,0,0);
query(FLOAT,"adventurists",&Race->nonhomebodies,0,0,0,0);
query(FLOAT,"metabolism",&Race->metabolism,0,0,0,0);
query(FLOAT,"overbirthrate",&Race->overbirthrate,0,0,0,0);
query(INT, "Playernum",0,&Race->Playernum,0,0,0);
query(CHAR, "fighters",0,0,&Race->fighters,0,0);
query(CHAR, "IQ",0,0,&Race->IQ,0,0);
query(CHAR, "# sexes",0,0,&Race->number_sexes,0,0);
ch = Race->Thing;
query(CHAR, "Race is like 'The Thing'",0,0,&ch,0,0);
Race->Thing = ch;
/*float metabolism;*/
/*char homelevel,homesystem,homeplanetnum; /* home place */
printf("atmospheric cond preferred\n");
query(CHAR, "Temp",0,0,&Race->conditions[TEMP],0,0);
query(CHAR, "Rtemp",0,0,&Race->conditions[RTEMP],0,0);
query(CHAR, "Methane",0,0,&Race->conditions[METHANE],0,0);
query(CHAR, "Oxygen",0,0,&Race->conditions[OXYGEN],0,0);
query(CHAR, "CO2",0,0,&Race->conditions[CO2],0,0);
query(CHAR, "Hydrogen",0,0,&Race->conditions[HYDROGEN],0,0);
query(CHAR, "Nitrogen",0,0,&Race->conditions[NITROGEN],0,0);
query(CHAR, "Sulfur",0,0,&Race->conditions[SULFUR],0,0);
query(CHAR, "Helium",0,0,&Race->conditions[HELIUM],0,0);
query(CHAR, "Other",0,0,&Race->conditions[OTHER],0,0);
if (fix_mod)
putrace(Race);
} else {
switch (Dir.level) {
case LEVEL_UNIV:
openstardata(&fix_stardata);
getsdata(fix_stardata, &Sdata);
query(CHAR, "ActionPoints",0,0,&Sdata.AP[Playernum],0,0);
if (fix_mod) {
printf("Saving...\n");
putsdata(fix_stardata, &Sdata);
}
close(fix_stardata);
break;
case LEVEL_STAR:
openstardata(&fix_stardata);
getstar(fix_stardata, &Stars[Dir.snum], Dir.snum);
printf("Star #%d : %s\n\n", Dir.snum, Stars[Dir.snum]->name );
printf("(limit %d) ",MAXSSHIPS);
/*query(CHAR, "# ships orbiting",0,0,&Stars[Dir.snum]->numships,0,0);*/
for (ch=MAXSSHIPS-1; ch>1 && !Stars[Dir.snum]->shipnums[ch]; ch--) ;
printf("last ship slot is %d\n",ch);
for (i=0; i<MAXSSHIPS && i<ch; i++)
if (Stars[Dir.snum]->shipnums[i]) {
printf("Ship slot #%d is ",i);
query(SHORT, "ship number",0,0,0,&Stars[Dir.snum]->shipnums[i],0);
}
/*char explored[howmanybytes(MAXPLAYERS)];*/
/*char inhabited[howmanybytes(MAXPLAYERS)];*/
query(CHAR, "ActionPoints",0,0,&Stars[Dir.snum]->AP[Playernum],0,0);
query(FLOAT,"x position",&Stars[Dir.snum]->xpos,0,0,0,0);
query(FLOAT,"y position",&Stars[Dir.snum]->ypos,0,0,0,0);
printf("(limit %d) ",MAXPLANETS);
/*query(CHAR, "# planets",0,0,&Stars[Dir.snum]->numplanets,0,0);*/
query(CHAR, "stability",0,0,&Stars[Dir.snum]->stability,0,0);
ch = Stars[Dir.snum]->nova_stage;
query(CHAR, "nova stage",0,0,&ch,0,0);
Stars[Dir.snum]->nova_stage = ch;
/*for (i=0; i<Stars[Dir.snum]->numplanets; i++) {
printf("Planet #%d (%s) ", i, Stars[Dir.snum]->pnames[i]);
query(INT, "file position",0,&Stars[Dir.snum]->planetpos[i],0,0,0);
}*/
if (fix_mod) {
putstar(fix_stardata, Stars[Dir.snum], Dir.snum);
printf("Saving...\n");
}
close(fix_stardata);
break;
case LEVEL_PLAN:
openpdata(&fix_pdata);
getplanet(fix_pdata, &p, Stars[Dir.snum]->planetpos[Dir.pnum]);
if (argn==1) {
printf("\nPlanet / %s / %s\n", Stars[Dir.snum]->name, Stars[Dir.snum]->pnames[Dir.pnum]);
unl = p->info[Playernum-1].resource;
query(LONG, "\nstockpile resources",0,0,0,0,&unl);
p->info[Playernum-1].resource = unl;
unl = p->info[Playernum-1].destruct;
query(LONG, "stockpile destruct",0,0,0,0,&unl);
p->info[Playernum-1].destruct = unl;
unl = p->info[Playernum-1].fuel;
query(LONG, "stockpile fuel",0,0,0,0,&unl);
p->info[Playernum-1].fuel = unl;
unl = p->popn;
query(LONG, "total population(altered after turn)",0,0,0,0,&unl);
p->popn = unl;
ch = p->info[Playernum-1].numsectsowned;
query(CHAR, "numsectsowned",0,0,&ch,0,0);
p->info[Playernum-1].numsectsowned = ch;
ch = p->info[Playernum-1].explored;
query(CHAR, "explored",0,0,&ch,0,0);
p->info[Playernum-1].explored;
printf("atmospheric cond\n");
query(CHAR, "Temp",0,0,&p->conditions[TEMP],0,0);
query(CHAR, "Rtemp",0,0,&p->conditions[RTEMP],0,0);
query(CHAR, "Methane",0,0,&p->conditions[METHANE],0,0);
query(CHAR, "Oxygen",0,0,&p->conditions[OXYGEN],0,0);
query(CHAR, "CO2",0,0,&p->conditions[CO2],0,0);
query(CHAR, "Hydrogen",0,0,&p->conditions[HYDROGEN],0,0);
query(CHAR, "Nitrogen",0,0,&p->conditions[NITROGEN],0,0);
query(CHAR, "Sulfur",0,0,&p->conditions[SULFUR],0,0);
query(CHAR, "Helium",0,0,&p->conditions[HELIUM],0,0);
query(CHAR, "Other",0,0,&p->conditions[OTHER],0,0);
query(CHAR, "Toxicity",0,0,&p->conditions[TOXIC],0,0);
for (ch=MAXSSHIPS-1; ch>1 && !p->shipnums[ch]; ch--) ;
printf("last ship slot is %d\n",ch);
for (i=0; i<MAXPSHIPS && i<ch; i++)
if (p->shipnums[i]) {
printf("Ship slot #%d is ",i);
query(SHORT, "ship number",0,0,0,&p->shipnums[i],0);
}
/*printf("(limit %d) ", MAX_X);
query(CHAR, "sectormap size x",0,0,&p->Maxx,0,0);*/
/*printf("(limit %d) ", MAX_Y,0);
query(CHAR, "sectormap size y",0,0,&p->Maxy,0,0);*/
/*query(INT, "sect map file position",0,&p->sectormappos,0,0,0);*/
query(FLOAT,"x position",&p->xpos,0,0,0,0);
query(FLOAT,"y position",&p->ypos,0,0,0,0);
ch = p->slaved_to;
query(CHAR, "enslaved to player #",0,0,&ch,0,0);
p->slaved_to = ch;
/*ch = p->is_cloaked;
query(CHAR, "cloaked",0,0,&ch,0,0);
p->is_cloaked = ch;*/
ch = p->type;
query(CHAR, "planet type",0,0,&ch,0,0);
p->type = ch;
ch = p->info[Playernum-1].comread;
query(CHAR, "combat readiness",0,0,&ch,0,0);
p->info[Playernum-1].comread = ch;
ch = p->is_explored;
query(CHAR, "is_explored by owner",0,0,&ch,0,0);
p->is_explored = ch;
if (fix_mod) {
putplanet(fix_pdata, p, Stars[Dir.snum]->planetpos[Dir.pnum]);
printf("Saving...\n");
}
close(fix_pdata);
} else {
/* fix sector */
int x,y;
close(fix_pdata);
sscanf(args[1],"%d,%d", &x, &y);
printf(" sector %d,%d\n",x,y);
opensectdata(&fix_sectdata);
getsector(fix_sectdata,§,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
ch = sect->eff;
query(CHAR, "efficiency",0,0,&ch,0,0);
sect->eff = ch;
ch = sect->resource;
query(CHAR, "resource deposits",0,0,&ch,0,0);
sect->resource = ch;
ch = sect->fert;
query(CHAR, "fertility",0,0,&ch,0,0);
sect->fert = ch;
ch = sect->mobilization;
query(CHAR, "mobilization",0,0,&ch,0,0);
sect->mobilization = ch;
printf("(limit %d)",MAX_SECT_POPN);
i = sect->popn;
query(INT, "population",0,&i,0,0,0);
sect->popn = i;
i = sect->owner;
query(INT, "owner",0,&i,0,0,0);
sect->owner = i;
ch = sect->is_wasted;
query(CHAR, "is_wasted",0,0,&ch,0,0);
sect->is_wasted = ch;
ch = sect->des;
query(CHAR, "designation",0,0,&ch,0,0);
sect->des = ch;
/*unsigned is_cloaked : 1; /* 1 bit: is cloaked sector */
if (fix_mod) {
putsector(fix_sectdata,sect,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype));
printf("Saving...\n");
}
close(fix_sectdata);
}
free(p);
break;
case LEVEL_SHIP:
openshdata(&fix_shdata);
getship(fix_shdata, &sh, Dir.shipno);
printf("\n%s #%d.\n", Shipnames[sh->type], Dir.shipno);
ch = sh->owner;
query(CHAR, "owner",0,0,&ch,0,0);
sh->owner = ch;
query(FLOAT,"x position",&sh->xpos,0,0,0,0);
query(FLOAT,"y position",&sh->ypos,0,0,0,0);
query(FLOAT,"mass",&sh->mass,0,0,0,0);
query(FLOAT,"fuel",&sh->fuel,0,0,0,0);
unl = sh->destruct;
query(LONG, "destruct cap",0,0,0,0,&unl);
sh->destruct = unl;
unl = sh->resource;
query(LONG, "resource",0,0,0,0,&unl);
sh->resource = unl;
unl = sh->popn;
query(LONG, "crew",0,0,0,0,&unl);
sh->popn = unl;
unl = sh->rad;
query(LONG, "irradiated",0,0,0,0,&unl);
sh->rad = unl;
unl = sh->damage;
query(LONG, "damage",0,0,0,0,&unl);
sh->damage = unl;
ch = sh->whatorbits;
query(CHAR, "what orbits level",0,0,&ch,0,0);
sh->whatorbits = ch;
query(CHAR, "orbits what star ",0,0,&sh->storbits,0,0);
ch = sh->pnumorbits;
query(CHAR, "orbits what planet",0,0,&ch,0,0);
sh->pnumorbits = ch;
ch = sh->whatdest;
query(CHAR, "what destination level",0,0,&ch,0,0);
sh->whatdest = ch;
query(CHAR, "what star dest",0,0,&sh->deststar,0,0);
ch = sh->destpnum;
query(CHAR, "what planet dest",0,0,&ch,0,0);
sh->destpnum = ch;
ch = sh->is_docked;
query(CHAR, "is docked",0,0,&ch,0,0);
sh->is_docked = ch;
query(SHORT, "what ship dest",0,0,0,&sh->destshipno,0);
/*query(SHORT, "abil_cargo",0,0,0,&sh->abils[ABIL_CARGO],0);
query(SHORT, "abil_stealth",0,0,0,&sh->abils[ABIL_STEALTH],0);
query(SHORT, "abil_destruct cap",0,0,0,&sh->abils[ABIL_DESTCAP],0);
query(SHORT, "abil_num guns",0,0,0,&sh->abils[ABIL_GUNS],0);
query(SHORT, "abil_fuel cap",0,0,0,&sh->abils[ABIL_FUELCAP],0);
query(SHORT, "abil_tech level",0,0,0,&sh->abils[ABIL_MINTECH],0);
query(SHORT, "abil_max crew",0,0,0,&sh->abils[ABIL_MAXCREW],0);
query(SHORT, "abil_armor",0,0,0,&sh->abils[ABIL_ARMOR],0);*/
if (is_object(sh)) {
query(SHORT, "object:number",0,0,0,&sh->orders.object.number,0);
query(SHORT, "object:number2",0,0,0,&sh->orders.object.number2,0);
/*query(SHORT, "object:number3",0,0,0,&sh->orders.object.number3,0);*/
}
if (fix_mod) {
printf("Saving...\n");
putship(fix_shdata, sh, Dir.shipno);
}
close(fix_shdata);
break;
/*ordertype orders; /* standing orders for ship */
/*unsigned augmented : 4; /* # of times augmented (max 10) */
/*unsigned whatdest : 2; /* where going (same as Dir) */
/*unsigned whatorbits : 2; /* where orbited (same as Dir) */
/*unsigned type : 4; /* what type ship is */
/*unsigned is_sheep : 1; /* 1 bit: is under influence of mind control */
/*unsigned is_docked : 1; /* 1 bit: is landed on a planet or docked */
/*unsigned has_moved : 1; /* 1 bit: has been moved by user */
/*unsigned outtafuel_notified:1; /* 1bit: has been notified of no fuel */
}
}
}
query( kind, quest, fprev, iprev, cprev, sprev, lprev)
int kind;
char *quest;
float *fprev;
int *iprev;
char *cprev;
short *sprev;
long *lprev;
{
float f;
int i;
char c,ch;
short s;
long l;
printf("%s (", quest);
switch (kind) {
case FLOAT:
printf("%f", *fprev);
break;
case INT:
printf("%d", *iprev);
break;
case CHAR:
printf("%d", *cprev);
break;
case SHORT:
printf("%d", *sprev);
break;
case LONG:
printf("%ld", *lprev);
break;
}
printf(") : ");
if ( isdigit(ch=getchr()) || ch=='-' || ch=='.') {
ungetc(ch, stdin);
fix_mod = 1; /* set mod so fix knows to save data */
switch (kind) {
case FLOAT:
scanf("%f",fprev);
break;
case INT:
scanf("%d",iprev);
break;
case CHAR:
scanf("%d",&i);
*cprev = i; /* don't want to copy a whole int's worth */
break;
case SHORT:
scanf("%hd",sprev);
break;
case LONG:
scanf("%ld",lprev);
break;
}
getchr();
}
}
fix_handler(sig, code, scp)
int sig,code;
struct sigcontext *scp;
{
close(fix_stardata);
close(fix_shdata);
close(fix_pdata);
close(fix_sectdata);
printf("changes not saved!\n");
longjmp(main_jenv,1);
}