[ltd_dump_html added quozl@us.netrek.org**20090203054725] { hunk ./Vanilla/tools/Makefile.in 44 - ntpasswd ltd_dump ltd_convert nuke trekon metaget \ + ntpasswd ltd_dump ltd_dump_html ltd_convert nuke trekon metaget \ hunk ./Vanilla/tools/Makefile.in 93 + $(INSTALLPROG) $(INSTALLOPTS) ltd_dump_html $(DESTDIR)$(LIBDIR)/tools/ltd_dump_html hunk ./Vanilla/tools/Makefile.in 181 +ltd_dump_html: ltd_dump_html.o + $(CC) $(CFLAGS) ${LDFLAGS} -o ltd_dump_html ltd_dump_html.o $(OBJS) + addfile ./Vanilla/tools/ltd_dump_html.c hunk ./Vanilla/tools/ltd_dump_html.c 1 +/* + * + * Dave Ahn + * + * LTD stats dump utility program. + * + */ + +#include "config.h" + +#include + +#ifdef LTD_STATS + +#include +#include +#include +#include +#include +#include +#include +#include "defs.h" +#include "ltd_stats.h" +#include "struct.h" +#include "data.h" +#include "proto.h" + +static FILE *fp; + +static void dump_prefix(const char *abbr, const char *name) { + fprintf(fp, "%s%s", abbr, name); +} + +#define dump_stat(STAT) { \ + int xxx; \ + unsigned int ttt; \ + ttt = 0; \ + for (xxx=1; xxx<8; xxx++) { \ + fprintf(fp, "%4u", (unsigned int) ltd[xxx].STAT); \ + if (xxx != LTD_SB) ttt += ltd[xxx].STAT; \ + } \ + fprintf(fp, "%4u\n", (unsigned int) ttt); \ +} + +#define dump_max(STAT) { \ + int xxx; \ + unsigned int ttt; \ + ttt = 0; \ + for (xxx=1; xxx<8; xxx++) { \ + fprintf(fp, "%4u", (unsigned int) ltd[xxx].STAT); \ + if (xxx != LTD_SB) \ + if (ttt < ltd[xxx].STAT) \ + ttt = ltd[xxx].STAT; \ + } \ + fprintf(fp, "%4u\n", (unsigned int) ttt); \ +} + +static void dump_full(const char *name, const char *race, + struct ltd_stats *ltd) { + + int i, t; + + t = 0; + for (i=1; i<8; i++) + t += ltd[i].ticks.total; + + if (t < 10) return; + + fprintf(fp, "

LTD statistics for player [%s] (%s)

\n\n", name, race); + fprintf(fp, + "\n" + "\n"); + + dump_prefix("kt", "kills total"); dump_stat(kills.total); + dump_prefix("kmax", "kills max"); dump_max(kills.max); + dump_prefix("k1", "kills first"); dump_stat(kills.first); + dump_prefix("k1p", "kills first potential"); dump_stat(kills.first_potential); + dump_prefix("k1c", "kills first converted"); dump_stat(kills.first_converted); + dump_prefix("k2", "kills second"); dump_stat(kills.second); + dump_prefix("k2p", "kills second potential"); dump_stat(kills.second_potential); + dump_prefix("k2c", "kills second converted"); dump_stat(kills.second_converted); + dump_prefix("kbp", "kills by phaser"); dump_stat(kills.phasered); + dump_prefix("kbt", "kills by torp"); dump_stat(kills.torped); + dump_prefix("kbs", "kills by smack"); dump_stat(kills.plasmaed); + dump_prefix("dt", "deaths total"); dump_stat(deaths.total); + dump_prefix("dpc", "deaths as potential carrier"); dump_stat(deaths.potential); + dump_prefix("dcc", "deaths as converted carrier"); dump_stat(deaths.converted); + dump_prefix("ddc", "deaths as dooshed carrier"); dump_stat(deaths.dooshed); + dump_prefix("dbp", "deaths by phaser"); dump_stat(deaths.phasered); + dump_prefix("dbt", "deaths by torp"); dump_stat(deaths.torped); + dump_prefix("dbs", "deaths by smack"); dump_stat(deaths.plasmaed); + dump_prefix("acc", "actual carriers created"); dump_stat(deaths.acc); + dump_prefix("ptt", "planets taken total"); dump_stat(planets.taken); + dump_prefix("pdt", "planets destroyed total"); dump_stat(planets.destroyed); + dump_prefix("bpt", "bombed planets total"); dump_stat(bomb.planets); + dump_prefix("bp8", "bombed planets <=8"); dump_stat(bomb.planets_8); + dump_prefix("bpc", "bombed planets core"); dump_stat(bomb.planets_core); + dump_prefix("bat", "bombed armies total"); dump_stat(bomb.armies); + dump_prefix("ba8", "bombed_armies <= 8"); dump_stat(bomb.armies_8); + dump_prefix("bac", "bombed armies core"); dump_stat(bomb.armies_core); + dump_prefix("oat", "ogged armies total"); dump_stat(ogged.armies); + dump_prefix("odc", "ogged dooshed carrier"); dump_stat(ogged.dooshed); + dump_prefix("occ", "ogged converted carrier"); dump_stat(ogged.converted); + dump_prefix("opc", "ogged potential carrier"); dump_stat(ogged.potential); + dump_prefix("o>c", "ogged bigger carrier"); dump_stat(ogged.bigger_ship); + dump_prefix("o=c", "ogged same carrier"); dump_stat(ogged.same_ship); + dump_prefix("o\n\n"); + +} + +static void dump_sb_header1(void) { + + fprintf(fp, + "
 nameSCDDCABBASSBGAtotal
\n" + "\n" + "\n" + ); +} + +static void dump_sb_stats1(char *name, char race, struct ltd_stats *ltd) { + + ltd = &(ltd[LTD_SB]); + + if (ltd->ticks.total < 10) return; + + fprintf(fp, + "\n", + name, + race, + ltd->kills.total, + ltd->deaths.total, + ltd->kills.phasered, + ltd->kills.torped, + (int) ltd->kills.max, + (float) ltd->kills.total * 36000.0f / (float) ltd->ticks.total, + ltd->armies.total, + ltd->armies.killed, + (ltd->armies.total > 0)? + (ltd->armies.total - ltd->armies.killed) * 100 / ltd->armies.total: + 0, + ltd->ticks.total / 600, + ltd->ticks.repair * 100 / ltd->ticks.total, + ltd->ticks.carrier * 100 / ltd->ticks.total, + ltd->ticks.red * 100 / ltd->ticks.total, + ltd->ticks.yellow * 100 / ltd->ticks.total); + +} + +static void dump_sb_header2(void) { + + fprintf(fp, "
 killsarmies time
nameracektdtkbpkbtmaxkphatakpadtttrtccredyel
%-16s%c%3d%2d%3d%3d%3d%5.1f%3d%3d%3d%3d%3d%3d%3d%3d
\n\n"); +} + +static void dump_sb_stats2(char *name, char race, struct ltd_stats *ltd) { + + ltd = &(ltd[LTD_SB]); + + if (ltd->ticks.total < 10) return; + fprintf(fp, + "\n", + name, + race, + ltd->ogged.armies, + ltd->ogged.dooshed, + ltd->ogged.converted, + ltd->ogged.potential, + ltd->ogged.friendly, + ltd->ogged.friendly_armies, + ltd->weapons.phaser.fired, + (ltd->weapons.phaser.fired > 0)? + ltd->weapons.phaser.hit * 100 / ltd->weapons.phaser.fired: + 0, + (ltd->weapons.phaser.hit > 0)? + (float) ltd->weapons.phaser.damage.inflicted / (float) ltd->weapons.phaser.hit: + 0.0f, + ltd->weapons.torps.fired, + (ltd->weapons.torps.fired > 0)? ltd->weapons.torps.hit * 100 / ltd->weapons.torps.fired: + 0, + (ltd->weapons.torps.hit > 0)? + (float) ltd->weapons.torps.damage.inflicted / (float) ltd->weapons.torps.hit: + 0.0f, + (float) ltd->damage_repaired * 600 / ltd->ticks.total); + +} + +int main(const int argc, const char *argv[]) { + + struct statentry p; + int plf; + int race; + char *who; + +#ifdef LTD_PER_RACE + + const char *races[] = { + "FED", + "ROM", + "KLI", + "ORI", + "IND" + }; + +#else + + const char *races[] = { + "ALL" + }; + +#endif + + fp = stdout; + + getpath(); + + if (argc == 2) + plf = open(argv[1], O_RDONLY, 0744); + else + plf = open(PlayerFile, O_RDONLY, 0744); + + if (argc == 3) + who = (char *)argv[2]; + else + who = NULL; + + if (plf <= -1) { + + fprintf(stderr, "ltd_dump_html: can't open playerfile\n"); + exit(-1); + + } + + fprintf(fp, "

LTD Starbase Statistics

\n"); + + dump_sb_header1(); + + while (read(plf, &p, sizeof(struct statentry)) > 1) { + + for (race=0; race\n\n"); + + dump_sb_header2(); + + while (read(plf, &p, sizeof(struct statentry)) > 1) { + + for (race=0; race\n\n"); + fprintf(fp, "

LTD Extended Player Statistics Dump

\n\n"); + + if (lseek(plf, 0, SEEK_SET) == -1) { + + fprintf(stderr, "ltd_dump_html: lseek failed\n"); + exit(-1); + + } + + while (read(plf, &p, sizeof(struct statentry)) > 1) { + + + for (race=0; race

 oggsweaponsrepair
nameraceoatodcoccopcofcofawpfwphwpdiawtfwthwtdiadrpm
%-16s%c%3d%3d%3d%3d%3d%3d%4d%3d%5.1f%4d%3d%5.1f%5.3f