diff --git a/source/masterserver/config.php b/source/masterserver/config.php index 64fdd309..41a95518 100644 --- a/source/masterserver/config.php +++ b/source/masterserver/config.php @@ -19,6 +19,9 @@ // http://php.net/manual/features.persistent-connections.php define( 'MYSQL_LINK_PERSIST', false ); + // Show games in the games list no older than x hours + define( 'MAX_HOURS_OLD_GAMES', 48 ); + // How many recently seen servers to store define( 'MAX_RECENT_SERVERS', 5 ); diff --git a/source/masterserver/scripts/utils.js b/source/masterserver/scripts/utils.js index b466e231..89a05e54 100644 --- a/source/masterserver/scripts/utils.js +++ b/source/masterserver/scripts/utils.js @@ -31,7 +31,8 @@ function setupGameStatsLink(gameIndex) { var link = document.getElementById('gameStats_' + gameIndex); link.onclick = function() { var row = document.getElementById('content_row_' + this.getAttribute('gameuuid')); - if(row && row.className == 'fullyhide') { + //if(row && row.className == 'fullyhide') { + if(row) { row.className = 'fullyshow'; row.innerHTML = 'Hide Stats
'; diff --git a/source/masterserver/showGameStats.php b/source/masterserver/showGameStats.php index 768e296e..acce50a6 100644 --- a/source/masterserver/showGameStats.php +++ b/source/masterserver/showGameStats.php @@ -103,11 +103,27 @@ echo ' ' . PHP_EOL; $best_score = 0; + $best_score_enemyKillCount = 0; + $best_score_unitsProducedCount = 0; + $best_score_resourceHarvestedCount = 0; foreach( $all_player_stats as $player_stats ) { + if($best_score_enemyKillCount < $player_stats['enemyKillCount']) + { + $best_score_enemyKillCount = $player_stats['enemyKillCount']; + } + if($best_score_unitsProducedCount < $player_stats['unitsProducedCount']) + { + $best_score_unitsProducedCount = $player_stats['unitsProducedCount']; + } + if($best_score_resourceHarvestedCount < $player_stats['resourceHarvestedCount']) + { + $best_score_resourceHarvestedCount = $player_stats['resourceHarvestedCount']; + } + $player_score = $player_stats['enemyKillCount'] * 100 + $player_stats['unitsProducedCount'] * 50 + $player_stats['resourceHarvestedCount'] / 10; - if($best_score < $player_score) + if($best_score < $player_score) { $best_score = $player_score; } @@ -176,10 +192,31 @@ printf( "\t\t\t\t%s%s", $wonGame_class, 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 ); + + $player_score_class = "player_losing_score"; + if($best_score_enemyKillCount == $player_stats['enemyKillCount']) + { + $player_score_class = "player_high_score"; + } + + printf( "\t\t\t\t%s%s", $player_score_class, 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 ); + + $player_score_class = "player_losing_score"; + if($best_score_unitsProducedCount == $player_stats['unitsProducedCount']) + { + $player_score_class = "player_high_score"; + } + + printf( "\t\t\t\t%s%s", $player_score_class, htmlspecialchars( $player_stats['unitsProducedCount'], ENT_QUOTES ), PHP_EOL ); + + $player_score_class = "player_losing_score"; + if($best_score_resourceHarvestedCount == $player_stats['resourceHarvestedCount']) + { + $player_score_class = "player_high_score"; + } + + printf( "\t\t\t\t%s%s", $player_score_class, htmlspecialchars( $player_stats['resourceHarvestedCount'], ENT_QUOTES ), PHP_EOL ); printf( "\t\t\t\t%s%s", htmlspecialchars( $player_stats['playerName'], ENT_QUOTES ), PHP_EOL ); $player_score = $player_stats['enemyKillCount'] * 100 + $player_stats['unitsProducedCount'] * 50 + $player_stats['resourceHarvestedCount'] / 10; diff --git a/source/masterserver/showServers.php b/source/masterserver/showServers.php index 157ef34f..8886c1af 100644 --- a/source/masterserver/showServers.php +++ b/source/masterserver/showServers.php @@ -31,7 +31,7 @@ // consider replacing this by a cron job cleanupServerList(); - $servers_in_db = mysql_query( 'SELECT * FROM glestserver WHERE status <> 3 OR (status = 3 AND lasttime > DATE_add(NOW(), INTERVAL -8 hour)) ORDER BY status, lasttime DESC, connectedClients > 0 DESC, (networkSlots - connectedClients) , ip DESC;' ); + $servers_in_db = mysql_query( 'SELECT * FROM glestserver WHERE status <> 3 OR (status = 3 AND lasttime > DATE_add(NOW(), INTERVAL - ' . MAX_HOURS_OLD_GAMES . ' hour)) ORDER BY status, lasttime DESC, connectedClients > 0 DESC, (networkSlots - connectedClients) , ip DESC;' ); $all_servers = array(); while ( $server = mysql_fetch_array( $servers_in_db ) ) { diff --git a/source/masterserver/showServersJson.php b/source/masterserver/showServersJson.php index 7db60dd0..eb78f287 100644 --- a/source/masterserver/showServersJson.php +++ b/source/masterserver/showServersJson.php @@ -12,7 +12,7 @@ // consider replacing this by a cron job cleanupServerList(); - $servers_in_db = mysql_query( 'SELECT * FROM glestserver WHERE status <> 3 OR (status = 3 AND lasttime > DATE_add(NOW(), INTERVAL -8 hour)) ORDER BY status, lasttime DESC, connectedClients > 0 DESC, (networkSlots - connectedClients), ip DESC;' ); + $servers_in_db = mysql_query( 'SELECT * FROM glestserver WHERE status <> 3 OR (status = 3 AND lasttime > DATE_add(NOW(), INTERVAL - ' . MAX_HOURS_OLD_GAMES . ' hour)) ORDER BY status, lasttime DESC, connectedClients > 0 DESC, (networkSlots - connectedClients), ip DESC;' ); $all_servers = array(); while ( $server = mysql_fetch_array( $servers_in_db ) ) {