et.firespeed.net team wins statistics

<< Back
Team Wins For 201009
Team Wins Real Wins*
Axis 0
Allies 0
* Real Wins are for games that had both Axis and Allied team XP above 200.
Per Map Wins
Map Axis Wins (Real Wins) Allied Wins (Real Wins)
Source

Undoubtedly I would be accused of pulling these numbers out of my ass if I didn't show how I came up with them. Below are all of the tools I used in generating the page you see here. I would hope that the fact that this updates every hour is proof enough that it is using the actual server log file. I suppose it's possible that I've done something wrong, but don't bitch about these numbers being wrong unless you can explain why (you have the source).

teamwins.sh
This script runs every hour from my cron. It parses the server.log and writes the file teamwinsYYYYMM.txt.
#!/bin/sh

# Path to et game log
GAMELOG="server.log"

# Path to output file
OUTDATE=`date "+%Y%m"`
OUTFILE="teamwins${OUTDATE}.txt" 

printf "%-20s %-25s %-9s %-12s %-8s\n" \
	"MAP" "EXIT" "WINNER" "AXXP/ALXP" "OTHER" > $OUTFILE 
nice -19 grep -e "InitGame: " -e "Exit: " -e "red:" $GAMELOG | \
awk \
'BEGIN {
	# axis almost always defend
	mapdef["battery"] = "axis";
	mapdef["fueldump"] = "axis";
	mapdef["goldrush"] = "axis";
	mapdef["oasis"] = "axis";
	mapdef["temple_final"] = "axis";
	mapdef["mlb_temple"] = "axis";
	mapdef["radar"] = "axis";
	mapdef["fun_beach_final"] = "axis";
	mapdef["stalingrad"] = "axis";
	mapdef["venice"] = "axis";
	mapdef["venice_b4"] = "axis";
	mapdef["transmitter-beta2"] = "axis";
	mapdef["transmitter"] = "axis";
	mapdef["rhine_bridge"] = "axis";
	mapdef["northpole"] = "allies";
	mapdef["railgun"] = "allies";
	mapdef["glider"] = "axis";
	mapdef["saberpeak_final"] = "axis";
	mapdef["1944_beach"] = "axis";
	mapdef["caen"] = "allies";
	mapdef["alpine_assault_beta"] = "axis";
	mapdef["transmitter"] = "axis";
	mapdef["mlb_daybreak"] = "allies";
	mapdef["xdam"] = "axis";
	mapdef["caen2"] = "allies";
	mapdef["Goldrush-GA"] = "axis";
}
{
	if(index($0, "InitGame:") > 1)  {
		axis = 0;
		allied = 0;
		tail = substr($0, index($0, "\\mapname\\") + 9);
		mapname = substr(tail, 0, index(tail, "\\") -1); 
	}
	else if(index($0, "Exit:") > 1) {
		reason = substr($0, index($0, "Exit: ") + 6);

		if(reason == "Allied team eliminated.") {
			axis = 1;
			allies_elim++;
		}
		else if(reason == "Axis team eliminated.") {
			allied = 1; 
			axis_elim++; 
		}
		else if(reason == "Allies Surrender") {
			axis = 1; 
			allies_elim++; 
		}
		else if(reason == "Axis Surrender") {
			allied = 1; 
			axis_elim++; 
		}
		
		if(mapdef[mapname] != "") {
			if(reason == "Wolf EndRound.") {
				if(mapdef[mapname] == "axis") allied = 1; 
				else axis = 1;
			}
			else if(reason == "Timelimit hit.") {
				if(mapdef[mapname] == "allies") allied = 1; 
				else axis = 1;
			}
		}
	}
	else if(index($0, "red:") && index($0, "blue:")) {
		if(axis) {
			axis_wins++;
			winner="[AXIS]";
		}
		else if(allied) {
			allied_wins++;
			winner="[ALLIES]";
		}
		else winner = "[UNKNOWN]";
		
		tail = substr($0, index($0, "red:") + 4);
		red = substr(tail, 0, index(tail, " ") -1); 
		blue = substr($0, index($0, "blue:") + 5);
	
		xp = sprintf("[%s/%s]", red, blue);
		other = "";
		if(blue/1 < 200 || red/1 < 200) { 
			other = "[XPLOW]";
		}
		printf("%-20s %-25s %-9s %-12s %-8s\n", 
			mapname, reason, winner, xp, other); 
	}
}' >> $OUTFILE

	
teamwins.php
This script parses the teamwinsYYYYMM.txt file into some usable arrays.
<?
if($_GET["MONTH"]) $MONTH $_GET["MONTH"]; 
else 
$MONTH date("Ym");

$OUTFILE="teamwins".$MONTH.".txt";

$wf = @file($OUTFILE);
if(
is_array($wf)) while(list(,$line) = each($wf)) {
    
$map trim(substr($line020));
    
$reason trim(substr($line2025));
    
$winner trim(substr($line469));
    
$xp trim(substr($line5612));
    
$other trim(substr($line69));
    if(
$winner == "[ALLIES]") {
        
$map_wins[$map]["allied"]++;
        
$allied_wins["total"]++;
        if(
$other == "[XPLOW]") {
            
$map_wins[$map]["alliedxplow"]++;
            
$allied_wins["xplow"]++;
        }
    }
    if(
$winner == "[AXIS]") {
        
$map_wins[$map]["axis"]++;
        
$axis_wins["total"]++;
        if(
$other == "[XPLOW]") {
            
$map_wins[$map]["axisxplow"]++;
            
$axis_wins["xplow"]++;
        }
    }
}
?>
teamwins_short.php
This script draws the simple table displayed on the top of this page.
<?
require_once("teamwins.php");
?>
<dl>
<dt>
<b>Team Wins For <?echo $MONTH;?></b>
<dd>
<table border=1 cellspacing=0 cellpadding=3>
<tr>
<td class=header><b>Team</b></td>
<td class=header><b>Wins</b></td>
<td class=header><b>Real Wins*</b></td>
</tr>
<tr>
<td>Axis</td>
<td><?echo $axis_wins["total"];?></td>
<td>
<?echo $axis_wins["total"] - $axis_wins["xplow"];?>
</td>
</tr>
<tr>
<td>Allies</td>
<td><?echo $allied_wins["total"];?></td>
<td>
<?echo $allied_wins["total"] - $allied_wins["xplow"];?>
</td>
</tr>
</table>
<i>* Real Wins are for games that had both Axis and Allied team XP above 200.</i><br>
</dl>

teamwins_long.php
You're looking at it.
<link rel="stylesheet" href="/et.css">
<h2>et.firespeed.net team wins statistics</h2>
<a href="/">&lt;&lt; Back</a>
<br>
<?require("teamwins_short.php");?>

<dl>
<dt><b>Per Map Wins</b>
<dd>
<table border=1 cellspacing=0 cellpadding=3>
<tr>
<td class=header><b>Map</b></td>
<td class=header><b>Axis Wins (Real Wins)</b></td>
<td class=header><b>Allied Wins (Real Wins)</b></td>
</tr>
<?
if(is_array($map_wins)) while(list($map$team) = each($map_wins)) {
    
?>
    <tr>
    <td><?echo $map;?></td>
    <td><?echo $team["axis"];?> 
        (<?echo $team["axis"] - $team["axisxplow"];?>)</td>
    <td><?echo $team["allied"];?>
        (<?echo $team["allied"] - $team["alliedxplow"];?>)</td>
    </tr>
    <?
}
?>
</table>
</dl>


<dl>
<dt><b>Source</b>
<dd>
<p>
Undoubtedly I would be accused of pulling these numbers out of my ass if I 
didn't show how I came up with them.  Below are all of the tools I used
in generating the page you see here.  I would hope that the fact that this
updates every hour is proof enough that it is using the actual server 
log file.  I suppose it's possible that I've done something wrong, but 
don't bitch about these numbers being wrong unless you can explain why
(you have the source).
</p>
    <dl>
    <dt><b>teamwins.sh</b>
    <dd>This script runs every hour from my cron.  It parses the server.log
    and writes the file 
    <a href="teamwins<?echo date("Ym");?>.txt">teamwinsYYYYMM.txt</a>.
    <pre><?readfile("teamwins.txt");?>
    </pre>

    <dt><b>teamwins.php</b>
    <dd>This script parses the teamwinsYYYYMM.txt file into some usable 
    arrays.<br>
    <div class="code">
    <?show_source("teamwins.php");?>
    </div>
    
    <dt><b>teamwins_short.php</b>
    <dd>
    This script draws the simple table displayed on the top of this page.
    <div class="code">
    <?show_source("teamwins_short.php");?>
    </div>
    
    <dt><b>teamwins_long.php</b>
    <dd>
    You're looking at it.
    <div class="code">
    <?show_source("teamwins_long.php");?>
    </div>

    </dl>
</dl>