diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index ddea8b5d..1f34389a 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -2854,6 +2854,7 @@ std::map 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()); } diff --git a/source/masterserver/addGameStats.php b/source/masterserver/addGameStats.php index 061493ed..45b20cc8 100644 --- a/source/masterserver/addGameStats.php +++ b/source/masterserver/addGameStats.php @@ -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()); diff --git a/source/masterserver/install/scheme_mysql.sql b/source/masterserver/install/scheme_mysql.sql index c2b34089..3d151da0 100644 --- a/source/masterserver/install/scheme_mysql.sql +++ b/source/masterserver/install/scheme_mysql.sql @@ -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; --