void chk_trj(const output_env_t oenv, const char *fn, const char *tpr, real tol) { t_trxframe fr; t_count count; t_fr_time first, last; int j = -1, new_natoms, natoms; real rdum, tt, old_t1, old_t2, prec; gmx_bool bShowTimestep = TRUE, bOK, newline = FALSE; t_trxstatus *status; gmx_mtop_t mtop; gmx_localtop_t *top = NULL; t_state state; t_inputrec ir; if (tpr) { read_tpx_state(tpr, &ir, &state, NULL, &mtop); top = gmx_mtop_generate_local_top(&mtop, &ir); } new_natoms = -1; natoms = -1; printf("Checking file %s\n", fn); j = 0; old_t2 = -2.0; old_t1 = -1.0; count.bStep = 0; count.bTime = 0; count.bLambda = 0; count.bX = 0; count.bV = 0; count.bF = 0; count.bBox = 0; first.bStep = 0; first.bTime = 0; first.bLambda = 0; first.bX = 0; first.bV = 0; first.bF = 0; first.bBox = 0; last.bStep = 0; last.bTime = 0; last.bLambda = 0; last.bX = 0; last.bV = 0; last.bF = 0; last.bBox = 0; read_first_frame(oenv, &status, fn, &fr, TRX_READ_X | TRX_READ_V | TRX_READ_F); do { if (j == 0) { fprintf(stderr, "\n# Atoms %d\n", fr.natoms); if (fr.bPrec) { fprintf(stderr, "Precision %g (nm)\n", 1/fr.prec); } } newline = TRUE; if ((natoms > 0) && (new_natoms != natoms)) { fprintf(stderr, "\nNumber of atoms at t=%g don't match (%d, %d)\n", old_t1, natoms, new_natoms); newline = FALSE; } if (j >= 2) { if (fabs((fr.time-old_t1)-(old_t1-old_t2)) > 0.1*(fabs(fr.time-old_t1)+fabs(old_t1-old_t2)) ) { bShowTimestep = FALSE; fprintf(stderr, "%sTimesteps at t=%g don't match (%g, %g)\n", newline ? "\n" : "", old_t1, old_t1-old_t2, fr.time-old_t1); } } natoms = new_natoms; if (tpr) { chk_bonds(&top->idef, ir.ePBC, fr.x, fr.box, tol); } if (fr.bX) { chk_coords(j, natoms, fr.x, fr.box, 1e5, tol); } if (fr.bV) { chk_vels(j, natoms, fr.v); } if (fr.bF) { chk_forces(j, natoms, fr.f); } old_t2 = old_t1; old_t1 = fr.time; j++; new_natoms = fr.natoms; #define INC(s, n, f, l, item) if (s.item != 0) { if (n.item == 0) { first.item = fr.time; } last.item = fr.time; n.item++; \ } INC(fr, count, first, last, bStep); INC(fr, count, first, last, bTime); INC(fr, count, first, last, bLambda); INC(fr, count, first, last, bX); INC(fr, count, first, last, bV); INC(fr, count, first, last, bF); INC(fr, count, first, last, bBox); #undef INC } while (read_next_frame(oenv, status, &fr)); fprintf(stderr, "\n"); close_trj(status); fprintf(stderr, "\nItem #frames"); if (bShowTimestep) { fprintf(stderr, " Timestep (ps)"); } fprintf(stderr, "\n"); #define PRINTITEM(label, item) fprintf(stderr, "%-10s %6d", label, count.item); if ((bShowTimestep) && (count.item > 1)) {fprintf(stderr, " %g\n", (last.item-first.item)/(count.item-1)); }else fprintf(stderr, "\n") PRINTITEM ( "Step", bStep ); PRINTITEM ( "Time", bTime ); PRINTITEM ( "Lambda", bLambda ); PRINTITEM ( "Coords", bX ); PRINTITEM ( "Velocities", bV ); PRINTITEM ( "Forces", bF ); PRINTITEM ( "Box", bBox ); }
int countthings(void) { /* Counts the things in a level's THINGS data. Returns zero if error. */ long nc[6] = {0, 0, 0, 0, 0, 0}; /* Number of things counted * at each skill level */ long wdam[6] = {0, 0, 0, 0, 0, 0}; /* Total weapon damage at * each skill level */ float dratio[6] = {0, 0, 0, 0, 0, 0}; /* Damage ratio for * difficulty */ int n, i; /** Player starts **/ printf(" Play modes:\n"); if (countth(1, -1)) /* Find player 1 start */ printf("\tSingle player\n"); n = 0; for (i = 1; i <= 4; i++) { /* Find player 1-4 starts */ if (countth(i, -1)) n++; } if (n > 1) printf("\tCooperative (%d player)\n", n); n = countth(11, -1); /* Find deathmatch starts */ if (n) printf("\tDeathmatch (%d starts)\n", n); /** Monsters **/ printf(" Bosses:\n"); prtth(3003, "Baron"); prtth(16, "Cyberdemon"); prtth(7, "Spiderdemon"); prtth(88, "Final Boss"); printf(" Monsters:\n"); prtth(3004, "Trooper"); prtth(9, "Sergeant"); prtth(65, "Chaingun guy"); prtth(84, "SS Nazi"); prtth(3001, "Imp"); prtth(3002, "Demon"); prtth(58, "Spectre"); prtth(3006, "Lost soul"); prtth(3005, "Cacodemon"); prtth(64, "Archvile"); prtth(66, "Revenant"); prtth(67, "Mancubis"); prtth(68, "Arachnotron"); prtth(69, "Mini Baron"); prtth(71, "Pain Elemental"); printf(" Weapons:\n"); prtth(2001, "Shotgun"); prtth(82, "Super shotgun"); prtth(2002, "Chaingun"); prtth(2003, "Rocket launcher"); prtth(2004, "Plasma gun"); prtth(2006, "BFG-9000"); prtth(2005, "Chainsaw"); printf(" Equipment:\n"); prtth(8, "Backpack"); prtth(2022, "Invulnerability"); prtth(2023, "Berserk"); prtth(2024, "Invisibility"); prtth(2025, "Radiation suit"); prtth(2026, "Computer map"); prtth(2045, "Lite amp goggles"); printf(" Expendibles:\n"); RESET(nc); addcountweighted(2002, nc, 20); /* Chainguns */ addcountweighted(2007, nc, 10); /* Clips */ addcountweighted(2048, nc, 50); /* Boxes of ammo */ addcountweighted(8, nc, 10); /* Backpacks */ addcountweighted(3004, nc, 5); /* Troopers */ PRINTITEM2("Bullets", nc); for (i = 0; i < 6; i++) wdam[i] += nc[i]; /* Accumulate damage */ RESET(nc); addcountweighted(2001, nc, 8); /* Shotguns */ addcountweighted(82, nc, 16); /* Super shotguns */ addcountweighted(2008, nc, 4); /* Shells */ addcountweighted(2049, nc, 20); /* Boxes of shells */ addcountweighted(8, nc, 4); /* Backpacks */ addcountweighted(9, nc, 4); /* Sergeants */ PRINTITEM2("Shells", nc); for (i = 0; i < 6; i++) wdam[i] += 7 * nc[i]; /* Accumulate damage */ RESET(nc); addcountweighted(2003, nc, 2); /* Rocket launchers */ addcountweighted(2010, nc, 1); /* Rockets */ addcountweighted(2046, nc, 5); /* Boxes of rockets */ addcountweighted(8, nc, 1); /* Backpacks */ PRINTITEM2("Rockets", nc); for (i = 0; i < 6; i++) wdam[i] += 20 * nc[i]; /* Accumulate damage */ RESET(nc); addcountweighted(2004, nc, 40); /* Plasma guns */ addcountweighted(2006, nc, 40); /* BFG-9000's */ addcountweighted(17, nc, 20); /* Cell packs */ addcountweighted(2047, nc, 100); /* Cell charges */ addcountweighted(8, nc, 20); /* Backpacks */ PRINTITEM2("Cells", nc); for (i = 0; i < 6; i++) wdam[i] += 2 * nc[i]; /* Accumulate damage */ RESET(nc); addcountweighted(2018, nc, 100); /* Armor */ addcountweighted(2019, nc, 200); /* Super armor */ addcountweighted(83, nc, 200); /* Megasphere */ addcountweighted(2015, nc, 1); /* Armor bonuses */ PRINTITEM2("Armor points", nc); RESET(nc); addcountweighted(2011, nc, 10); /* Stimpacks */ addcountweighted(2012, nc, 25); /* Medikits */ addcountweighted(2013, nc, 100); /* Soul spheres */ addcountweighted(83, nc, 200); /* Megasphere */ addcountweighted(2023, nc, 100); /* Berserk strength */ addcountweighted(2014, nc, 1); /* Health bonuses */ PRINTITEM2("Health points", nc); prtth(2035, "Barrels"); /* Calculate difficulty based on damage we can do vs. damage required to * kill all the monsters */ printf(" Difficulty:\n"); RESET(nc); addcountweighted(3004, nc, 2); /* Troopers */ addcountweighted(9, nc, 3); /* Sergeants */ addcountweighted(3001, nc, 6); /* Imps */ addcountweighted(3002, nc, 15); /* Demons */ addcountweighted(58, nc, 15); /* Spectres */ addcountweighted(3006, nc, 10); /* Lost souls */ addcountweighted(3005, nc, 40); /* Cacodemons */ addcountweighted(3003, nc, 100); /* Barons */ addcountweighted(16, nc, 400); /* Cyberdemons */ addcountweighted(7, nc, 300); /* Spiderdemons */ addcountweighted(64, nc, 70); /* Archviles */ addcountweighted(65, nc, 7); /* Chaingun guys */ addcountweighted(66, nc, 30); /* Revenants */ addcountweighted(67, nc, 40); /* Mancubi */ addcountweighted(68, nc, 50); /* Arachnotrae */ addcountweighted(69, nc, 50); /* Mini Barons */ addcountweighted(71, nc, 40); /* Pain Elementals */ addcountweighted(84, nc, 5); /* SS Nazis */ addcountweighted(88, nc, 25); /* Final bosses */ PRINTITEM("Total monster hp", nc); PRINTITEM2("Max ammo damage", wdam); for (i = 0; i < 6; i++) { if (!wdam[i]) continue; dratio[i] = (wdam[i] ? (float) nc[i] / (float) wdam[i] : 0); /* Prevent * divide-by-zero */ } printf("\t%-20s %0.3f %0.3f %0.3f %0.3f", "RATIO", 0.5 * dratio[0], dratio[0], dratio[1], dratio[2]); printf(" | %0.3f %0.3f %0.3f %0.3f\n", 0.5 * dratio[3], dratio[3], dratio[4], dratio[5]); /*** Return success ***/ return 1; }