Commit ff9ab8bd authored by saviola's avatar saviola
Browse files

- commiting version 0.9 of plugn.xts.php, check changelog for further details

parent 6af854ff
<?php
/**
* (X)Aseco Train Statistics version 0.8
* (X)Aseco Train Statistics version 0.9
*
*
* This plugin collects train statistics for each player on each map on a per
......@@ -8,6 +8,14 @@
*
* Changelog:
*
* Version 0.9:
*
* - removed majority of unused code
* - added configuration constant for the checkpoint hook (for busy servers)
* - times will be written into the database in the format ss.cc (where ss =
* seconds and cc = hundreth of a second), so wipe your xts table before this
* update, there is no backwards compatibility.
*
* Version 0.8:
*
* - renamed plugin file to plugin.xts.php
......@@ -29,6 +37,9 @@
// defines which messages will be send to the console
define('XTS_LOG_LEVEL', 3);
// Set this to false if you don't care about fails. Will improve performance.
define('XTS_CP_HOOK', true);
/*
* Tiny logging facility.
*/
......@@ -77,7 +88,8 @@ class XtsRecord
/**
* Merge two records of the same challenge
* TODO: compare challenges
* TODO: compare challenges
* @unused
*/
public function mergeInto(XtsRecord $record)
{
......@@ -121,7 +133,7 @@ class XtsRecord
// Registers time for player
public function registerTime($time)
{
$this->times[] = $time;
$this->times[] = $time/1000;
$this->checkpoint = null;
}
}
......@@ -146,26 +158,6 @@ class Xts
$this->setChallenge();
}
/**
* Loads overall statistics for $login on current challenge
*
* This method is currently not used
*/
public function fetchStats($login)
{
return null;
$record = $this->getRecord($login);
$query = 'SELECT * FROM xts WHERE PlayerId = "'.$record->idPlayer.'" AND ChallengeId = "'.$record->idChallenge.'"';
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
return $row;
}
/**
* Returns current challenge
*/
......@@ -258,6 +250,7 @@ class Xts
XtsLogger::log('New challenge: '.$challenge->id.', old challenge: '.$this->_challenge->id, XtsLogger::DEBUG);
// Save records only on map change
if (null != $this->_challenge && $this->_challenge->id != $challenge->id && !empty($this->_data))
{
XtsLogger::log('Saving records...', XtsLogger::DEBUG);
......@@ -268,13 +261,13 @@ class Xts
}
}
Aseco::registerEvent('onCheckpoint', 'xtsCheckpointReached');
if (XTS_CP_HOOK)
Aseco::registerEvent('onCheckpoint', 'xtsCheckpointReached');
//Aseco::registerEvent('onEndRound', 'xtsEndRound');
Aseco::registerEvent('onNewChallenge', 'xtsNewChallenge');
Aseco::registerEvent('onPlayerFinish', 'xtsFinished');
Aseco::registerEvent('onPlayerDisconnect', 'xtsPlayerDisconnects');
Aseco::registerEvent('onStartup', 'xtsInit');
//Aseco::registerEvent('onEndRace', 'xtsEndRace');
......@@ -283,7 +276,7 @@ Aseco::registerEvent('onStartup', 'xtsInit');
*/
function checkStatus($aseco)
{
return in_array($aseco->server->gameinfo->mode, array(0, 1, 2, 5)) ? $aseco->server->gameinfo->mode : false;
return in_array($aseco->server->gameinfo->mode, array(0, 1, 2, 3, 5)) ? $aseco->server->gameinfo->mode : false;
}
/**
......@@ -300,26 +293,6 @@ function xtsCheckpointReached($aseco, $params)
$xts->getRecord($login)->registerCheckpoint($index);
}
/**
* When the current challenge ends, all data is stored in the database
*/
function xtsEndRace($aseco, $challenge)
{
//global $xts;
//$xts->endRace($challenge);
}
/**
* When a round ends, player data is stored in the $xts object
*/
function xtsEndRound($aseco)
{
//global $xts;
//$xts->endRound();
}
/**
* When a player finishes, his record is saved
*/
......@@ -366,7 +339,7 @@ function xtsNewChallenge($aseco, $challenge)
}
/**
* When a player disconnects, his current dara are stored in the database
* When a player disconnects, his current data is stored in the database
*/
function xtsPlayerDisconnects($aseco, $player)
{
......@@ -375,4 +348,4 @@ function xtsPlayerDisconnects($aseco, $player)
XtsLogger::log('Player disconnecting: '.$player->login, XtsLogger::DEBUG);
Xts::getInstance()->saveRecords($player->login);
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment