DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T s

⟦235394d6d⟧ TextFile

    Length: 3442 (0xd72)
    Types: TextFile
    Names: »scorelist.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/X/Xtrek/scorelist.c« 

TextFile

static char sccsid[] = "@(#)scorelist.c	1.1";
/* Copyright (c) 1986 	Chris Guthrie */


#include <X11/Xlib.h>
#include <stdio.h>
#include <math.h>
#include <signal.h>
#include "defs.h"
#include "data.h"
#include "bitmaps.h"

#define TEAM(p)	(1<<(p))
#define WINSIDE 500

scorelist(p)
register struct player	*p;
{
    register int i, t;
    register int k = 0;
    char buf[BUFSIZ];
    register struct player *j;
    struct player team;
    int active_team;

    p->infomapped = 1;
    p->infow = XCreateWindow(p->display, p->mapw, 10, 10, 77 * fontWidth(p->dfont),
	(MAXPLAYER + NUMTEAM + 4) * fontHeight(p->dfont), 2, DefaultDepth(p->display, p->screen), InputOutput,
	(Visual *) CopyFromParent, 0L, (XSetWindowAttributes *) 0);
/*	(MAXPLAYER + NUMTEAM + 4) * fontHeight(dfont), 2, p->foreTile, p->backTile);*/
    XSetWindowBackground(p->display, p->infow, p->backColor);
    XMapWindow(p->display, p->infow);
    sprintf(buf, " # Name              Kills   Max Killed Skill    Torps Phasers Planets Bombed");
    XDrawImageString(p->display, p->infow, p->dfgc, 0, fontHeight(p->dfont), buf,
       strlen(buf));
    k = 2;
    for (i = 0, j = &players[i]; i < MAXPLAYER; i++, j++) {
	if (j->p_status == PFREE)
	    continue;
	sprintf(buf, " %1x %-16.16s %6.2f %5.2f %6d %5.2f %7d %7d %7d %6d",
		j->p_no,
		j->p_name,
		j->p_stats.st_kills,
		j->p_stats.st_maxkills,
		j->p_stats.st_losses,
		(j->p_stats.st_losses == 0) ? 
		    0 : j->p_stats.st_kills / j->p_stats.st_losses,
		j->p_stats.st_torps,
		j->p_stats.st_phasers,
		j->p_stats.st_planets,
		j->p_stats.st_armsbomb
		);
	XDrawImageString(p->display, p->infow, p->dfgc, 0, fontHeight(p->dfont) * k++, buf, strlen(buf));
	XFlush(p->display);
    }

    k++;	/* leave a blank line between players and teams */

    for (t = 0; t < NUMTEAM; t++) {
	team.p_no = t;
	switch(TEAM(t)) {
	case FED:
		strcpy(team.p_name, "Federation");
		break;
	case ROM:
		strcpy(team.p_name, "Romulan");
		break;
	case ORI:
		strcpy(team.p_name, "Orion");
		break;
	case KLI:
		strcpy(team.p_name, "Klingon");
		break;
	}
	team.p_stats.st_kills = 0;
	team.p_stats.st_maxkills = 0;
	team.p_stats.st_losses = 0;
	team.p_stats.st_torps = 0;
	team.p_stats.st_phasers = 0;
	team.p_stats.st_planets = 0;
	team.p_stats.st_armsbomb = 0;
	active_team = 0;
    	for (i = 0, j = &players[i]; i < MAXPLAYER; i++, j++) {
	    if (j->p_status == PFREE || j->p_team != TEAM(t))
		continue;
	    active_team = 1;
	    team.p_stats.st_kills    += j->p_stats.st_kills;   
	    if (team.p_stats.st_maxkills < j->p_stats.st_maxkills)
	      team.p_stats.st_maxkills = j->p_stats.st_maxkills;
	    team.p_stats.st_losses   += j->p_stats.st_losses;  
	    team.p_stats.st_torps    += j->p_stats.st_torps;   
	    team.p_stats.st_phasers  += j->p_stats.st_phasers; 
	    team.p_stats.st_planets  += j->p_stats.st_planets; 
	    team.p_stats.st_armsbomb += j->p_stats.st_armsbomb;
	}
	if (active_team) {
	  sprintf(buf, " %1x %-16.16s %6.2f %5.2f %6d %5.2f %7d %7d %7d %6d",
		team.p_no,
		team.p_name,
		team.p_stats.st_kills,
		team.p_stats.st_maxkills,
		team.p_stats.st_losses,
		(team.p_stats.st_losses == 0) ? 
		    0 : team.p_stats.st_kills / team.p_stats.st_losses,
		team.p_stats.st_torps,
		team.p_stats.st_phasers,
		team.p_stats.st_planets,
		team.p_stats.st_armsbomb
		);
	  XDrawImageString(p->display, p->infow, p->dfgc, 0, fontHeight(p->dfont) * k++, buf, strlen(buf));
	  XFlush(p->display);
	}    
    }
}