add playerid to game stats so we canprovide historical stats for unique players

This commit is contained in:
Mark Vejvoda 2013-11-01 21:31:55 +00:00
parent a716e692c7
commit e3a8ee6d2f
3 changed files with 18 additions and 4 deletions

View File

@ -2854,6 +2854,7 @@ std::map<string,string> ServerInterface::publishToMasterserverStats() {
publishToServerInfo["playerName_" + intToStr(factionIndex)] = gameStats->getPlayerName(factionIndex);
publishToServerInfo["quitBeforeGameEnd_" + intToStr(factionIndex)] = intToStr(gameStats->getPlayerLeftBeforeEnd(factionIndex));
publishToServerInfo["quitTime_" + intToStr(factionIndex)] = intToStr(gameStats->getTimePlayerLeft(factionIndex));
publishToServerInfo["playerUUID_" + intToStr(factionIndex)] = this->getGameSettings()->getNetworkPlayerUUID(factionIndex);
}
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
}
@ -2919,13 +2920,13 @@ void ServerInterface::simpleTask(BaseThread *callingThread) {
requestStats += "&";
}
//printf("The Host stats request is:\n%s\n",requestStats.c_str());
printf("The Host stats request is:\n%s\n",requestStats.c_str());
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("The Host request is:\n%s\n",requestStats.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line %d] the request is:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,requestStats.c_str());
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Calling masterserver [%s]...\n",requestStats.c_str());
std::string serverInfoStats = SystemFlags::getHTTP(requestStats,handle);
//printf("Result:\n%s\n",serverInfoStats .c_str());
printf("Result:\n%s\n",serverInfoStats .c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line %d] the result is:\n'%s'\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,serverInfoStats.c_str());
}

View File

@ -35,12 +35,13 @@
{
$game_completed = @mysql_query( 'SELECT COUNT(*) FROM glestserver WHERE ' . $whereClause . ' AND status=3;' );
$game_completed_status = @mysql_fetch_row( $game_completed );
if( $game_completed_status > 0 )
if( $game_completed_status[0] > 0 )
{
mysql_query( 'DELETE FROM glestserver WHERE ' . $whereClause . ';');
mysql_query( 'DELETE FROM glestgamestats WHERE ' . $whereClause . ';');
mysql_query( 'DELETE FROM glestgameplayerstats WHERE ' . $whereClause . ';');
echo 'OK - ' . $gameDuration;
return;
}
}
@ -196,6 +197,11 @@
$quitTimer = clean_str( $_GET['quitTime_' . $factionNumber] );
}
$playerUUID = "";
if ( isset( $_GET['playerUUID_' . $factionNumber] ) ) {
$playerUUID = (string) clean_str( $_GET['playerUUID_' . $factionNumber] );
}
if($player_statsCount[0] > 0)
{
$result = mysql_query( 'UPDATE glestgameplayerstats SET ' .
@ -215,6 +221,7 @@
'playerName=\'' . mysql_real_escape_string( $playerName ) . '\', ' .
'quitBeforeGameEnd=' . $quitBeforeGameEnd . ', ' .
'quitTime=' . $quitTime . ', ' .
'playerUUID=\'' . mysql_real_escape_string( $playerUUID ) . '\', ' .
'lasttime=' . 'now()' . ' ' .
'WHERE ' . $whereClause . ' AND factionIndex = ' . $factionIndex . ';');
@ -243,7 +250,8 @@
'resourceHarvestedCount=' . $resourceHarvestedCount . ', ' .
'playerName=\'' . mysql_real_escape_string( $playerName ) . '\', ' .
'quitBeforeGameEnd=' . $quitBeforeGameEnd . ', ' .
'quitTime=' . $quitTime . ';');
'quitTime=' . $quitTime . ', ' .
'playerUUID=\'' . mysql_real_escape_string( $playerUUID ) . '\';');
if (!$result) {
die('part 2b: Invalid query: ' . mysql_error());

View File

@ -58,6 +58,8 @@ CREATE TABLE `glestserver` (
`status` int(11) NOT NULL DEFAULT '0',
`gameUUID` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL,
KEY `lasttime` (`lasttime`)
KEY `gameUUID` (`gameUUID`)
KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
@ -77,6 +79,7 @@ CREATE TABLE `glestgamestats` (
`isHeadlessServer` int(11) NOT NULL,
KEY `gameUUID` (`gameUUID`)
KEY `framesToCalculatePlaytime` (`framesToCalculatePlaytime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
@ -87,6 +90,7 @@ DROP TABLE IF EXISTS `glestgameplayerstats`;
CREATE TABLE `glestgameplayerstats` (
`lasttime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`gameUUID` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL,
`playerUUID` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL,
`factionIndex` int(11) NOT NULL,
`controlType` int(11) NOT NULL,
`resourceMultiplier` DECIMAL(10,6) NOT NULL,
@ -104,6 +108,7 @@ CREATE TABLE `glestgameplayerstats` (
`quitTime` int(11) NOT NULL,
KEY `gameUUID` (`gameUUID`)
KEY `playerUUID` (`playerUUID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--