|
|
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 m
Length: 4455 (0x1167)
Types: TextFile
Names: »map.c.orig«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Gb/map.c.orig«
/*
* Galactic Bloodshed (Robert Chansky, smq@b)
* map.c -- display sector map of current planet
*/
#include "vars.h"
#include "ships.h"
#include "races.h"
extern float compatibility();
extern int Ignore_filelocks;
char desshow();
map(APcount, argn,args)
int APcount;
int argn;
char args[MAXARGS][COMMANDSIZE];
{
int map_pdata;
planettype *p;
placetype where;
where=Getplace(args[1],0);
if (where.err) return;
if (where.level==LEVEL_PLAN) {
openpdata(&map_pdata);
getplanet(map_pdata,&p,Stars[where.snum]->planetpos[where.pnum]);
close(map_pdata);
show_map(p,1); /* 1 means display data */
free(p);
if (Stars[where.snum]->stability > 50)
printf("WARNING! This planet's primary is unstable.\n");
} else {
Dir.lastx = Dir.lasty = 0.0;
orbit(APcount, argn,args); /* make orbit map instead */
}
}
show_map(p, show)
planettype *p;
register int show;
{
register int x,y,i,f;
int map_sectdata,map_shdata;
shiptype *s;
char shiplocs[MAX_X][MAX_Y];
bzero((char *)shiplocs, sizeof(shiplocs));
Ignore_filelocks = 1;
opensectdata(&map_sectdata);
getsmap(map_sectdata,Smap,p->sectormappos,p->Maxx*p->Maxy);
close(map_sectdata);
openshdata(&map_shdata);
for (i=0; i<MAXPSHIPS; i++)
if (p->shipnums[i]) {
getship(map_shdata,&s, p->shipnums[i]);
if (s->is_docked && s->whatdest==LEVEL_PLAN)
shiplocs[(int)s->xpos][(int)s->ypos] = Shipltrs[s->type];
free(s);
}
close(map_shdata);
Ignore_filelocks = 0;
printf(" ");
for (x=0; x<p->Maxx; x++)
printf("%d",x/10);
if (show)
printf(" Sects %s: %d", Race->Thing ? "covered" : "owned",
p->info[Playernum-1].numsectsowned);
printf("\n ");
for (x=0; x<p->Maxx; x++)
printf("%d",x%10);
if (show) {
int i,f=0;
printf(" Aliens:");
if (p->is_explored || Race->tech >= TECH_EXPLORE) {
for (i=1; i<MAXPLAYERS; i++)
if (p->info[i-1].numsectsowned && i!=Playernum) {
f=1;
printf("%c%d", isset(Race->atwar,i) ? '*' : ' ', i);
}
if (!f) printf("(none)");
} else printf("???");
}
putchr('\n');
for (y=0; y<p->Maxy; y++) {
printf("%2d ",y);
for (x=0; x<p->Maxx; x++) {
if (shiplocs[x][y])
putchr(shiplocs[x][y]);
else
putchr(desshow(p, x, y));
}
if (show)
switch (y) { /* give stockpile info */
case 0: printf("| Combat readiness: %u", p->info[Playernum-1].comread);
break;
case 1: printf("| Compatibility: %.2f",compatibility(p,Race));
break;
case 3:printf("| Resource stockpile:%u",p->info[Playernum-1].resource);
break;
case 4: printf("| Fuel stockpile: %u",p->info[Playernum-1].fuel);
break;
case 5:printf("| Destruct cap: %u",p->info[Playernum-1].destruct);
break;
case 6:printf("| %s: %u (%u)", Race->Thing ? "Tons of biomass" :
"Total Population", p->popn, p->maxpopn);
break;
/*case 7:
break;
case 8:
break;
case 9:
break;
case 10:
break;*/
default: printf("|");
break;
}
putchr('\n');
}
}
char desshow(p,x,y)
register planettype *p;
register int x,y;
{
register sectortype *s;
s = &Smap[y*p->Maxx+x];
/* owned by you */
if (s->owner==Playernum) {
if (s->is_wasted)
return(CHAR_OWNED_WASTELAND);
if (s->VN)
return(Shipltrs[OTYPE_VN]);
switch (s->des) {
case DES_SEA: return(CHAR_OWNED_SEA);
case DES_LAND: return(Race->Thing ? CHAR_OWNED_THING : CHAR_OWNED_LAND);
case DES_MOUNT: return(Race->Thing ? CHAR_OWNED_THING : CHAR_OWNED_MOUNT);
case DES_GAS: return(CHAR_GAS);
case DES_PLATED: return(CHAR_PLATED);
default: return('!');
}
/* un-owned by anybody */
} else if (!s->owner) {
if (s->VN)
return Shipltrs[OTYPE_VN];
if (!p->is_explored && Race->tech < TECH_EXPLORE) {
if ( !( (x>0 && (s-1)->owner==Playernum) ||
(x<p->Maxx-1 && (s+1)->owner==Playernum) ||
(y>0 && (s-p->Maxx)->owner==Playernum) ||
(y<p->Maxy-1 && (s+p->Maxx)->owner==Playernum) ) )
return CHAR_CLOAKED;
}
if (s->is_wasted)
return(CHAR_WASTELAND);
switch (s->des) {
case DES_SEA: return(CHAR_SEA);
case DES_LAND: return(CHAR_UNOWNED_LAND);
case DES_MOUNT: return(CHAR_MOUNT);
case DES_GAS: return(CHAR_GAS);
case DES_PLATED: return(CHAR_PLATED);
default: return('!');
}
/* different owner */
} else
return CHAR_DIFFOWNED;
}