diff --git a/source/masterserver/functions.php b/source/masterserver/functions.php index 22e7051d..f3420d40 100644 --- a/source/masterserver/functions.php +++ b/source/masterserver/functions.php @@ -84,4 +84,25 @@ mysql_query( "UPDATE recent_servers SET name='$serverTitle', players='$players' WHERE id=$id LIMIT 1"); } + function getTimeString($frames) { + $framesleft = $frames; + $updateFps = 40.0; + + $hours = ( int )$frames / ( float )$updateFps / 3600.0; + $framesleft = $framesleft - $hours * 3600 * $updateFps; + $minutes = ( int )$framesleft / ( float )$updateFps / 60.0; + $framesleft = $framesleft - $minutes * 60 * $updateFps; + $seconds = ( int )$framesleft / ( float )$updateFps; + + $hourstr = strval(( int )$hours); + if($hours < 10) $hourstr = "0" . $hourstr; + + $minutestr = strval(( int )$minutes); + if($minutes < 10) $minutestr = "0" . $minutestr; + + $secondstr = strval(( int )$seconds); + if($seconds < 10) $secondstr = "0" . $secondstr; + + return $hourstr . ":" . $minutestr . ":" . $secondstr; + } ?> diff --git a/source/masterserver/showGameStats.php b/source/masterserver/showGameStats.php new file mode 100644 index 00000000..d6c4ff31 --- /dev/null +++ b/source/masterserver/showGameStats.php @@ -0,0 +1,208 @@ +' . PHP_EOL; + echo '' . PHP_EOL; + echo '
' . PHP_EOL; + echo ' ' . PHP_EOL; + echo 'Game Duration | ' . PHP_EOL; + echo 'Maximum Concurrent Units | ' . PHP_EOL; + echo 'Total Units at End | ' . PHP_EOL; + echo 'Headless Server | ' . PHP_EOL; + echo '|||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
%s | %s", htmlspecialchars( $gameDuration, ENT_QUOTES ), PHP_EOL ); + + printf( "\t\t\t\t%s | %s", htmlspecialchars( $stats['maxConcurrentUnitCount'], ENT_QUOTES ), PHP_EOL ); + printf( "\t\t\t\t%s | %s", htmlspecialchars( $stats['totalEndGameConcurrentUnitCount'], ENT_QUOTES ), PHP_EOL ); + printf( "\t\t\t\t%s | %s", htmlspecialchars( $stats['isHeadlessServer'], ENT_QUOTES ), PHP_EOL ); + + echo "\t\t\t" . '|||||||||||||||||||||||||||||
Faction Index | ' . PHP_EOL; + echo 'Player Type | ' . PHP_EOL; + echo 'Resource Multiplier | ' . PHP_EOL; + echo 'Faction Type | ' . PHP_EOL; + echo 'Personality Type | ' . PHP_EOL; + echo 'Team | ' . PHP_EOL; + echo 'Winner | ' . PHP_EOL; + echo 'Kills | ' . PHP_EOL; + echo 'Enemy Kills | ' . PHP_EOL; + echo 'Deaths | ' . PHP_EOL; + echo 'Units Produced | ' . PHP_EOL; + echo 'Resources Harvested | ' . PHP_EOL; + echo 'Player Name | ' . PHP_EOL; + echo 'Quit Before Game Ended | ' . PHP_EOL; + echo 'Quit Time | ' . PHP_EOL; + echo '
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
%s | %s", htmlspecialchars( $player_stats['factionIndex'], ENT_QUOTES ), PHP_EOL ); + + $controlType = $player_stats['controlType']; + switch ( $controlType ) + { + case 0: + $controlTypeTitle = "Closed"; + break; + case 1: + $controlTypeTitle = "CPU Easy"; + break; + case 2: + $controlTypeTitle = "CPU"; + break; + case 3: + $controlTypeTitle = "CPU Ultra"; + break; + case 4: + $controlTypeTitle = "CPU Mega"; + break; + case 5: + $controlTypeTitle = "Network Player"; + break; + case 6: + $controlTypeTitle = "Network Unassigned"; + break; + case 7: + $controlTypeTitle = "Human Host"; + break; + case 8: + $controlTypeTitle = "Network CPU Easy"; + break; + case 9: + $controlTypeTitle = "Network CPU"; + break; + case 10: + $controlTypeTitle = "Network CPU Ultra"; + break; + case 11: + $controlTypeTitle = "Network CPU Mega"; + break; + default: + $controlTypeTitle = 'unknown'; + } + + printf( "\t\t\t\t%s | %s", htmlspecialchars( $controlTypeTitle, ENT_QUOTES ), PHP_EOL ); + + printf( "\t\t\t\t%s | %s", htmlspecialchars( $player_stats['resourceMultiplier'], ENT_QUOTES ), PHP_EOL ); + printf( "\t\t\t\t%s | %s", htmlspecialchars( $player_stats['factionTypeName'], ENT_QUOTES ), PHP_EOL ); + + $personalityType = $player_stats['personalityType']; + switch ( $personalityType ) + { + case 0: + $personalityType = "Normal"; + break; + case 1: + $personalityType = "Observer"; + break; + default: + $personalityType = 'unknown'; + } + + printf( "\t\t\t\t%s | %s", htmlspecialchars( $personalityType, ENT_QUOTES ), PHP_EOL ); + + printf( "\t\t\t\t%s | %s", htmlspecialchars( $player_stats['teamIndex'], ENT_QUOTES ), PHP_EOL ); + printf( "\t\t\t\t%s | %s", htmlspecialchars( $player_stats['wonGame'], ENT_QUOTES ), PHP_EOL ); + printf( "\t\t\t\t%s | %s", htmlspecialchars( $player_stats['killCount'], ENT_QUOTES ), PHP_EOL ); + printf( "\t\t\t\t%s | %s", htmlspecialchars( $player_stats['enemyKillCount'], ENT_QUOTES ), PHP_EOL ); + printf( "\t\t\t\t%s | %s", htmlspecialchars( $player_stats['deathCount'], ENT_QUOTES ), PHP_EOL ); + printf( "\t\t\t\t%s | %s", htmlspecialchars( $player_stats['unitsProducedCount'], ENT_QUOTES ), PHP_EOL ); + printf( "\t\t\t\t%s | %s", htmlspecialchars( $player_stats['resourceHarvestedCount'], ENT_QUOTES ), PHP_EOL ); + printf( "\t\t\t\t%s | %s", htmlspecialchars( $player_stats['playerName'], ENT_QUOTES ), PHP_EOL ); + printf( "\t\t\t\t%s | %s", htmlspecialchars( $player_stats['quitBeforeGameEnd'], ENT_QUOTES ), PHP_EOL ); + + $quitTime = $stats['quitTime']; + $quitTime = getTimeString($quitTime); + + printf( "\t\t\t\t%s | %s", htmlspecialchars( $quitTime, ENT_QUOTES ), PHP_EOL ); + + echo "\t\t\t" . '
' . PHP_EOL;
+ echo '
' . PHP_EOL;
+ echo '