Public DB temporarily offline

This forum is dedicated to the Aseco/Rasp 2 server records and control script by Flo and Assembler Maniac. Announcements and issues can be discussed in this forum.

Moderators: Flo, Assembler Maniac, f*ckfish, TM-Patrol

calsmurf2904
smooth traffic navigator
smooth traffic navigator
Posts: 199
Joined: 08 Jul 2008 15:23
Owned TM-games: TMNF,TMN
Location: Netherlands
Contact:

Re: Public DB temporarily offline

Post by calsmurf2904 » 21 Jul 2008 15:47

yeah lol....we should work together :P
Image
Current Projects :
Aseco 2.x Dedimania plugin
Aseco 2.x Clan management Plugin
Servers :
LSR Race Server
Server Specs :
TmForever Server 2.11.16 05-08-08 (D-M-Y)
Xaseco 1.03 with FufiMenu and FufiWidgets

User avatar
f*ckfish
Pit Crew
Pit Crew
Posts: 1302
Joined: 15 Jun 2007 07:59
Owned TM-games: TMNF, TMUF
Location: Dresden, Germany
Contact:

Re: Public DB temporarily offline

Post by f*ckfish » 21 Jul 2008 15:50

Btw, you can strip out the TMN specific code, since ASECO 2.x doesn't work with TMN.
inactive, sorry

calsmurf2904
smooth traffic navigator
smooth traffic navigator
Posts: 199
Joined: 08 Jul 2008 15:23
Owned TM-games: TMNF,TMN
Location: Netherlands
Contact:

Re: Public DB temporarily offline

Post by calsmurf2904 » 21 Jul 2008 15:53

does it work with the old original and sunrise ?
if not then it saves me alot of code :)
Image
Current Projects :
Aseco 2.x Dedimania plugin
Aseco 2.x Clan management Plugin
Servers :
LSR Race Server
Server Specs :
TmForever Server 2.11.16 05-08-08 (D-M-Y)
Xaseco 1.03 with FufiMenu and FufiWidgets

User avatar
f*ckfish
Pit Crew
Pit Crew
Posts: 1302
Joined: 15 Jun 2007 07:59
Owned TM-games: TMNF, TMUF
Location: Dresden, Germany
Contact:

Re: Public DB temporarily offline

Post by f*ckfish » 21 Jul 2008 15:57

Nope, at least the manialink part does not, since manialinks were introduced in United and there are most likely a lot of other things that only work in Forever. So go ahead and spare some code and time =)
inactive, sorry

User avatar
w1lla
TM-Patrol
TM-Patrol
Posts: 1466
Joined: 23 May 2007 07:20
Owned TM-games: TMU, TMN, TMF
Manialink(s): intr
Location: Venray

Re: Public DB temporarily offline

Post by w1lla » 21 Jul 2008 16:33

Calsmurf:

edited plugin.dedimania.php because aseco 2.2.0c gave me an error on line 441:

Code: Select all

$aseco->server->getGame(),
forgot to leave this alone.

Code: Select all

tmnforever is nations and united makes it special. tmnforever has united. I need united!

calsmurf2904
smooth traffic navigator
smooth traffic navigator
Posts: 199
Joined: 08 Jul 2008 15:23
Owned TM-games: TMNF,TMN
Location: Netherlands
Contact:

Re: Public DB temporarily offline

Post by calsmurf2904 » 21 Jul 2008 16:38

you should change every

Code: Select all

$aseco->server->getGame();
into

Code: Select all

$this->getGame();
because server->getGame(); doesn't return correct values.
That's why i included function getgame in the DediMania class.
Edit :
also add this code to the DediMania class :

Code: Select all

function mapCountry($country) {

	$nations = array(
		'Afghanistan' => 'AFG',
		'Albania' => 'ALB',
		'Algeria' => 'ALG',
		'Andorra' => 'AND',
		'Angola' => 'ANG',
		'Argentina' => 'ARG',
		'Armenia' => 'ARM',
		'Aruba' => 'ARU',
		'Australia' => 'AUS',
		'Austria' => 'AUT',
		'Azerbaijan' => 'AZE',
		'Bahamas' => 'BAH',
		'Bahrain' => 'BRN',
		'Bangladesh' => 'BAN',
		'Barbados' => 'BAR',
		'Belarus' => 'BLR',
		'Belgium' => 'BEL',
		'Belize' => 'BIZ',
		'Benin' => 'BEN',
		'Bermuda' => 'BER',
		'Bhutan' => 'BHU',
		'Bolivia' => 'BOL',
		'Bosnia&Herzegovina' => 'BIH',
		'Botswana' => 'BOT',
		'Brazil' => 'BRA',
		'Brunei' => 'BRU',
		'Bulgaria' => 'BUL',
		'Burkina Faso' => 'BUR',
		'Burundi' => 'BDI',
		'Cambodia' => 'CAM',
		'Cameroon' => 'CAR',  // actually CMR
		'Canada' => 'CAN',
		'Cape Verde' => 'CPV',
		'Central African Republic' => 'CAF',
		'Chad' => 'CHA',
		'Chile' => 'CHI',
		'China' => 'CHN',
		'Chinese Taipei' => 'TPE',
		'Colombia' => 'COL',
		'Congo' => 'CGO',
		'Costa Rica' => 'CRC',
		'Croatia' => 'CRO',
		'Cuba' => 'CUB',
		'Cyprus' => 'CYP',
		'Czech Republic' => 'CZE',
		'Czech republic' => 'CZE',
		'DR Congo' => 'COD',
		'Denmark' => 'DEN',
		'Djibouti' => 'DJI',
		'Dominica' => 'DMA',
		'Dominican Republic' => 'DOM',
		'Ecuador' => 'ECU',
		'Egypt' => 'EGY',
		'El Salvador' => 'ESA',
		'Eritrea' => 'ERI',
		'Estonia' => 'EST',
		'Ethiopia' => 'ETH',
		'Fiji' => 'FIJ',
		'Finland' => 'FIN',
		'France' => 'FRA',
		'Gabon' => 'GAB',
		'Gambia' => 'GAM',
		'Georgia' => 'GEO',
		'Germany' => 'GER',
		'Ghana' => 'GHA',
		'Greece' => 'GRE',
		'Grenada' => 'GRN',
		'Guam' => 'GUM',
		'Guatemala' => 'GUA',
		'Guinea' => 'GUI',
		'Guinea-Bissau' => 'GBS',
		'Guyana' => 'GUY',
		'Haiti' => 'HAI',
		'Honduras' => 'HON',
		'Hong Kong' => 'HKG',
		'Hungary' => 'HUN',
		'Iceland' => 'ISL',
		'India' => 'IND',
		'Indonesia' => 'INA',
		'Iran' => 'IRI',
		'Iraq' => 'IRQ',
		'Ireland' => 'IRL',
		'Israel' => 'ISR',
		'Italy' => 'ITA',
		'Ivory Coast' => 'CIV',
		'Jamaica' => 'JAM',
		'Japan' => 'JPN',
		'Jordan' => 'JOR',
		'Kazakhstan' => 'KAZ',
		'Kenya' => 'KEN',
		'Kiribati' => 'KIR',
		'Korea' => 'KOR',
		'Kuwait' => 'KUW',
		'Kyrgyzstan' => 'KGZ',
		'Laos' => 'LAO',
		'Latvia' => 'LAT',
		'Lebanon' => 'LIB',
		'Lesotho' => 'LES',
		'Liberia' => 'LBR',
		'Libya' => 'LBA',
		'Liechtenstein' => 'LIE',
		'Lithuania' => 'LTU',
		'Luxembourg' => 'LUX',
		'Macedonia' => 'MKD',
		'Malawi' => 'MAW',
		'Malaysia' => 'MAS',
		'Mali' => 'MLI',
		'Malta' => 'MLT',
		'Mauritania' => 'MTN',
		'Mauritius' => 'MRI',
		'Mexico' => 'MEX',
		'Moldova' => 'MDA',
		'Monaco' => 'MON',
		'Mongolia' => 'MGL',
		'Montenegro' => 'MNE',
		'Morocco' => 'MAR',
		'Mozambique' => 'MOZ',
		'Myanmar' => 'MYA',
		'Namibia' => 'NAM',
		'Nauru' => 'NRU',
		'Nepal' => 'NEP',
		'Netherlands' => 'NED',
		'New Zealand' => 'NZL',
		'Nicaragua' => 'NCA',
		'Niger' => 'NIG',
		'Nigeria' => 'NGR',
		'Norway' => 'NOR',
		'Oman' => 'OMA',
		'Other Countries' => 'OTH',
		'Pakistan' => 'PAK',
		'Palau' => 'PLW',
		'Palestine' => 'PLE',
		'Panama' => 'PAN',
		'Paraguay' => 'PAR',
		'Peru' => 'PER',
		'Philippines' => 'PHI',
		'Poland' => 'POL',
		'Portugal' => 'POR',
		'Puerto Rico' => 'PUR',
		'Qatar' => 'QAT',
		'Romania' => 'ROM',  // actually ROU
		'Russia' => 'RUS',
		'Rwanda' => 'RWA',
		'Samoa' => 'SAM',
		'San Marino' => 'SMR',
		'Saudi Arabia' => 'KSA',
		'Senegal' => 'SEN',
		'Serbia' => 'SCG',  // actually SRB
		'Sierra Leone' => 'SLE',
		'Singapore' => 'SIN',
		'Slovakia' => 'SVK',
		'Slovenia' => 'SLO',
		'Somalia' => 'SOM',
		'South Africa' => 'RSA',
		'Spain' => 'ESP',
		'Sri Lanka' => 'SRI',
		'Sudan' => 'SUD',
		'Suriname' => 'SUR',
		'Swaziland' => 'SWZ',
		'Sweden' => 'SWE',
		'Switzerland' => 'SUI',
		'Syria' => 'SYR',
		'Taiwan' => 'TWN',
		'Tajikistan' => 'TJK',
		'Tanzania' => 'TAN',
		'Thailand' => 'THA',
		'Togo' => 'TOG',
		'Tonga' => 'TGA',
		'Trinidad and Tobago' => 'TRI',
		'Tunisia' => 'TUN',
		'Turkey' => 'TUR',
		'Turkmenistan' => 'TKM',
		'Tuvalu' => 'TUV',
		'Uganda' => 'UGA',
		'Ukraine' => 'UKR',
		'United Arab Emirates' => 'UAE',
		'United Kingdom' => 'GBR',
		'United States of America' => 'USA',
		'Uruguay' => 'URU',
		'Uzbekistan' => 'UZB',
		'Vanuatu' => 'VAN',
		'Venezuela' => 'VEN',
		'Vietnam' => 'VIE',
		'Yemen' => 'YEM',
		'Zambia' => 'ZAM',
		'Zimbabwe' => 'ZIM',
	);

	if (array_key_exists($country, $nations)) {
		$nation = $nations[$country];
	} else {
		$nation = "OTH";
		if ($country != '')
			trigger_error('Could not map country: ' . $country, E_USER_WARNING);
	}
	return $nation;
}  // mapCountry
and change every

Code: Select all

mapcountry(
into

Code: Select all

$this->mapcountry(
Edit :
You know what :P just change plugin.dedimania.php to this :

Code: Select all

<?php
/* vim: set noexpandtab tabstop=2 softtabstop=2 shiftwidth=2: */

/**
 * Dedimania plugin.
 * Handles interaction with the Dedimania world database.
 * Created by Xymph, based on FAST
 *
 * Dependencies: requires chat.dedimania.php, plugin.checkpoints.php
 *               used by chat.dedimania.php
 *               requires plugin.panels.php on TMF
 */

require_once('includes/GbxRemote.response.php');
require_once('includes/web_access.inc.php');
require_once('includes/xmlrpc_db.inc.php');
define ('DEDICONFIG','dedimania.xml');
global $dedi_db, $dedi_db_defaults, $dedi_debug, $dedi_lastsent, $dedi_timeout, $dedi_webacces;
class DediMania extends Plugin {

// how many seconds before retrying connection
var $dedi_timeout = 1800;  // 30 mins
var $dedi_debug = 0;  // max debug level = 4

// overrule these in dedimania.xml, don't change them here
var $dedi_db_defaults = array(
	'Name' => 'Dedimania',
	'LogNews' => false,
	'ShowMinRecs' => 8,
	'ShowRecsBefore' => true,
	'ShowRecsAfter' => true,
	'ShowRecsRange' => true,
	'DisplayRecs' => true,
	'LimitRecs' => 10,
	'MaxRecords' => 30,
);

// Initialize Dedimania subsystem
// called @ onSync
function dedimania_init() {
	global $dedi_db, $dedi_db_defaults, $dedi_debug, $dedi_webacces, $dedi_lastsent;
$checkpoints = $this->Aseco->getPlugin("CheckpointsExtended")->checkpoints;

	// check for checkpoints plugin
	if (!isset($checkpoints) || !is_array($checkpoints))
		trigger_error('Dedimania system cannot find $checkpoints - include plugin.checkpoints.php in plugins.xml!', E_USER_ERROR);

	// create web access
	$this->dedi_webacces = new Webaccess();
//Line 50
	if ($dedi_debug > 2)
		print_r($this->dedi_db_defaults);

	// read & parse config file
	$this->dedi_db = array();
	if ($config = $this->Aseco->xml_parser->parseXml(DEDICONFIG)) {
		if ($dedi_debug > 2)
			print_r($config);

		// read the XML structure into array
		if (isset($config['DEDIMANIA']['DATABASE']) && is_array($config['DEDIMANIA']['DATABASE']) &&
		    isset($config['DEDIMANIA']['MASTERSERVER_ACCOUNT']) && is_array($config['DEDIMANIA']['MASTERSERVER_ACCOUNT'])) {
			$dbdata = &$config['DEDIMANIA']['DATABASE'][0];

			if ($dedi_debug > 2)
				print_r($dbdata);

			if (isset($dbdata['URL'][0])) {
				if (!is_array($dbdata['URL'][0]))
					$this->dedi_db['Url'] = array($dbdata['URL'][0]);
				else {
					$this->dedi_db['Url'] = array();
					$urls = array_values($dbdata['URL'][0]);
					foreach ($urls as $url) {
						$this->dedi_db['Url'][] = $url[0];
					}
				}

				if (isset($dbdata['WELCOME'][0]))
					$this->dedi_db['Welcome'] = $dbdata['WELCOME'][0];
				else
					$this->dedi_db['Welcome'] = '';

				if (isset($dbdata['TIMEOUT'][0]))
					$this->dedi_db['Timeout'] = $dbdata['TIMEOUT'][0];
				else
					$this->dedi_db['Timeout'] = '';

				if (isset($dbdata['NAME'][0]))
					$this->dedi_db['Name'] = $dbdata['NAME'][0];
				else
					$this->dedi_db['Name'] = $this->dedi_db_defaults['Name'];

				if (isset($dbdata['LOG_NEWS'][0]))
					$this->dedi_db['LogNews'] = ($dbdata['LOG_NEWS'][0] != 0);
				else
					$this->dedi_db['LogNews'] = $this->dedi_db_defaults['LogNews'];

				if (isset($dbdata['SHOW_MIN_RECS'][0]))
					$this->dedi_db['ShowMinRecs'] = (int) $dbdata['SHOW_MIN_RECS'][0];
				else
					$this->dedi_db['ShowMinRecs'] = $this->dedi_db_defaults['ShowMinRecs'];

				if (isset($dbdata['SHOW_RECS_BEFORE'][0]))
					$this->dedi_db['ShowRecsBefore'] = ($dbdata['SHOW_RECS_BEFORE'][0] != 0);
				else
					$this->dedi_db['ShowRecsBefore'] = $this->dedi_db_defaults['ShowRecsBefore'];

				if (isset($dbdata['SHOW_RECS_AFTER'][0]))
					$this->dedi_db['ShowRecsAfter'] = ($dbdata['SHOW_RECS_AFTER'][0] != 0);
				else
					$this->dedi_db['ShowRecsAfter'] = $this->dedi_db_defaults['ShowRecsAfter'];

				if (isset($dbdata['SHOW_RECS_RANGE'][0]))
					$this->dedi_db['ShowRecsRange'] = ($dbdata['SHOW_RECS_RANGE'][0] != 0);
				else
					$this->dedi_db['ShowRecsRange'] = $this->dedi_db_defaults['ShowRecsRange'];

				if (isset($dbdata['DISPLAY_RECS'][0]))
					$this->dedi_db['DisplayRecs'] = ($dbdata['DISPLAY_RECS'][0] != 0);
				else
					$this->dedi_db['DisplayRecs'] = $this->dedi_db_defaults['DisplayRecs'];

				if (isset($dbdata['LIMIT_RECS'][0]))
					$this->dedi_db['LimitRecs'] = (int) $dbdata['LIMIT_RECS'][0];
				else
					$this->dedi_db['LimitRecs'] = $this->dedi_db_defaults['LimitRecs'];

				if (isset($dbdata['MAX_RECS'][0]))
					$this->dedi_db['MaxRecords'] = (int) $dbdata['MAX_RECS'][0];
				else
					$this->dedi_db['MaxRecords'] = $this->dedi_db_defaults['MaxRecords'];

				$dbdata = &$config['DEDIMANIA']['MASTERSERVER_ACCOUNT'][0];
				$this->dedi_db['Login'] = $dbdata['LOGIN'][0];
				$this->dedi_db['Password'] = $dbdata['PASSWORD'][0];
				$this->dedi_db['Nation'] = $dbdata['NATION'][0];

				$this->dedi_db['Messages'] = &$config['DEDIMANIA']['MESSAGES'][0];
				$this->dedi_db['RecsValid'] = false;
			} else {
				trigger_error('No URL specified in your Dedimania config file!', E_USER_ERROR);
			}
		} else {
			trigger_error('Structure error in your Dedimania config file!', E_USER_ERROR);
		}
	} else {
		trigger_error('Could not read/parse Dedimania config file ' . DEDICONFIG . ' !', E_USER_ERROR);
	}

	if ($dedi_debug > 1)
		print_r($this->dedi_db);

	// connect to Dedimania server
	$this->Aseco->console_text('************* (Dedimania) *************');
	$this->dedimania_connect($this->Aseco);
	$this->Aseco->console_text('************* (Dedimania) *************');

	$dedi_lastsent = time();
}  // dedimania_init

function dedimania_connect($aseco) {
	global $dedi_db, $dedi_debug, $dedi_timeout, $dedi_webacces;

	$time = time();

	// check for no or timed-out connection
	if (!isset($this->dedi_db['XmlrpcDB']) &&
	    (!isset($this->dedi_db['XmlrpcDBbadTime']) || ($time - $this->dedi_db['XmlrpcDBbadTime']) > $dedi_timeout)) {

		// set random or next available URL
		if (!isset($this->dedi_db['Urltest']))
			$urltest = rand(0, count($this->dedi_db['Url']) - 2);
		else
			$urltest = ($this->dedi_db['Urltest'] + 1) % count($this->dedi_db['Url']);
		$url = $this->dedi_db['Url'][$urltest];

		$aseco->console_text("* Dataserver connection on " . $this->dedi_db['Name'] . ' ...');
		$aseco->console_text('* Try connection on ' . $url . ' ...');

		// establish Dedimania connection and login (always on last URL)
		$xmlrpcdb = new XmlrpcDB($this->dedi_webacces, $this->dedi_db['Url'][count($this->dedi_db['Url']) - 1],
		                         $this->getGame(),
		                         $this->dedi_db['Login'],
		                         $this->dedi_db['Password'],
		                         'ASECO_CALSMURF2904', ASECO_VERSION,
		                         $this->dedi_db['Nation'],
		                         $aseco->server->packmask);
		$response = $xmlrpcdb->RequestWait('dedimania.ValidateAccount');
		if ($dedi_debug > 2)
			$aseco->console_text('databaseInit - response' . LF . print_r($response['Data'], true));

		// Reply a struct {'Status': boolean,
		//                 'Messages': array of struct {'Date': string, 'Text': string} }

		// check response
		if ($response === false) {
			$aseco->console_text("  !!!\n  !!! Error bad database response !\n  !!!");
		}
		elseif (isset($response['Data']['params']['Status']) && $response['Data']['params']['Status']) {
			// establish Dedimania connection and login (usually on primary URL)
			$xmlrpcdb = new XmlrpcDB($this->dedi_webacces, $url,
			                         $this->getGame(),
			                         $this->dedi_db['Login'],
			                         $this->dedi_db['Password'],
			                         'ASECO_CALSMURF2904', ASECO_VERSION,
			                         $this->dedi_db['Nation'],
			                         $aseco->server->packmask);
			$this->dedi_db['XmlrpcDB'] = $xmlrpcdb;
			$this->dedi_db['News'] = $response['Data']['params']['Messages'];
			$aseco->console_text('* Connection and status ok! :)');
			if (isset($response['Data']['errors']) && strlen($response['Data']['errors']) > 0)
				$aseco->console_text("  !!!\n  !!! ...with an authentication warning: " . $response['Data']['errors']);
		}
		elseif (isset($response['Data']['errors'])) {
			$aseco->console_text("  !!!\n  !!! Connection Error !!! \n" . $response['Data']['errors'] . "\n  !!!");
			if ($dedi_debug > 2)
				$aseco->console_text('databaseInit - response' . LF . print_r($response, true));
		}
		elseif (!isset($response['Code'])) {
			$aseco->console_text("  !!!\n  !!! Error no database response (" . $url . ")\n  !!!");
			if ($dedi_debug > 2)
				$aseco->console_text('databaseInit - response' . LF . print_r($response, true));
		}
		else {
			$aseco->console_text("  !!!\n  !!! Error bad database response or contents (" . $response['Code'] . ', ' . $response['Reason'] . ")\n  !!!");
			if ($dedi_debug > 0) {
				if ($response['Code'] == 200)
					$aseco->console_text('databaseInit - response[Message]' . LF . $response['Message']);
				elseif ($response['Code'] != 404)
					$aseco->console_text('databaseInit - response' . LF . print_r($response));
			}
		}

		// check for valid connection
		if (isset($this->dedi_db['XmlrpcDB'])) {
			// log Dedimania news
			if ($this->dedi_db['LogNews'])
				foreach ($this->dedi_db['News'] as $news)
					$aseco->console_text('* NEWS (' . $this->dedi_db['Name'] . ', ' . $news['Date'] . '): ' . $news['Text']);
			return;
		}

		// prepare for next connection attempt
		$this->dedi_db['Urltest'] = $urltest;
		$this->dedi_db['XmlrpcDBbadTime'] = $time;
	}
}  // dedimania_connect


function dedimania_announce() {
	global $aseco, $dedi_db, $dedi_debug, $dedi_lastsent;

	// check for valid track
	if (isset($aseco->server->challenge->uid)) {
		// check for valid connection
		if (isset($this->dedi_db['XmlrpcDB']) && !$this->dedi_db['XmlrpcDB']->isBad()) {
			if ($dedi_debug > 1)
				$aseco->console('** Update server Dedimania info...');

			// collect server & players info
			$serverinfo = $this->dedimania_serverinfo($aseco);
			$players = $this->dedimania_players($aseco);

			$dedi_lastsent = time();
			$callback = array(array($this,'dedimania_announce_cb'));
			$this->dedi_db['XmlrpcDB']->addRequest($callback,
			                                 'dedimania.UpdateServerPlayers',
			                                 $this->getGame(),
			                                 $aseco->server->gameinfo->mode,
			                                 $serverinfo,
			                                 $players);
			// UpdateServerPlayers(Game, Mode, SrvInfo, Players)
		}
	}
}  // dedimania_announce

function dedimania_announce_cb($response) {
	global $aseco, $dedi_debug;

	// Reply true

	if ($dedi_debug > 1 && isset($response['Data']['errors']) && count($response['Data']['errors']) > 0)
		$this->Aseco->console_text("dedimania_announce_cb - response['Data']" . LF . print_r($response['Data'], true));
}  // dedimania_announce_cb

// called @ onEverySecond
function dedimania_update() {
$aseco = $this->Aseco;
	global $dedi_db, $dedi_lastsent, $dedi_timeout, $dedi_webacces;

	// check for valid connection
	if (isset($this->dedi_db['XmlrpcDB'])) {
		// refresh DB every 3 mins after last DB update
		if ($dedi_lastsent + 180 < time())
			$this->dedimania_announce();

		if ($this->dedi_db['XmlrpcDB']->isBad()) {
			// retry after 30 mins of bad state
			if ($this->dedi_db['XmlrpcDB']->badTime() > $dedi_timeout) {
				$aseco->console('Dedimania retry to send after ' . round($dedi_timeout/60) . ' minutes...');
				$this->dedi_db['XmlrpcDB']->retry();
			}
		} else {
			$response = $this->dedi_db['XmlrpcDB']->sendRequests();
			if (!$response) {
				$message = '{#server}>> ' . formatText($this->dedi_db['Timeout'], round($dedi_timeout/60));
				$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
				trigger_error('Dedimania has consecutive connection errors!', E_USER_WARNING);
			}
		}
	} else {
		// reconnect to Dedimania server
		$this->dedimania_connect($aseco);
	}

	// trigger pending callbacks
	$read = array();
	$write = null;
	$except = null;
	$this->dedi_webacces->select($read, $write, $except, 0);
}  // dedimania_update


// called @ onPlayerConnect
function dedimania_playerconnect($player) {
$aseco = $this->Aseco;
	global $dedi_db, $dedi_debug;

	if ($dedi_debug > 1)
		$aseco->console_text('dedimania_playerconnect - ' . $player->login . ' : ' . $player->nickname);

	// get player info & check for non-LAN login
	if ($pinfo = $this->dedimania_playerinfo($aseco, $player)) {
		if ($dedi_debug > 1)
			$aseco->console_text('dedimania_playerconnect - pinfo' . LF . print_r($pinfo, true));

		// check for valid connection
		if (isset($this->dedi_db['XmlrpcDB']) && !$this->dedi_db['XmlrpcDB']->isBad()) {
			$callback = array(array($this,'dedimania_playerconnect_cb'), $player->login);    
			$this->dedi_db['XmlrpcDB']->addRequest($callback,
			                                 'dedimania.PlayerArrive',
			                                 $this->getGame(),
			                                 $player->login,
			                                 $player->nickname,
			                                 $pinfo['Nation'],
			                                 $pinfo['TeamName'],
			                                 $pinfo['Ranking'],
			                                 $pinfo['IsSpec'],
			                                 $pinfo['IsOff']);
			// PlayerArrive(Game, Login, Nickname, Nation, TeamName, LadderRanking, IsSpectator, IsOfficial)
		}
	}
}  // dedimania_playerconnect

function dedimania_playerconnect_cb($response, $login) {
	global $aseco, $dedi_db, $dedi_debug;

	// Reply a struct {'Login': string, 'TeamName': string, 'Nation': string,
	//                 'Options': array of struct {'Option': string, 'Value': string, 'Tool': string},
	//                 'Aliases': array of struct {'Alias': string, 'Text': string, 'Tool': string} }

	if ($dedi_debug > 2)
		$aseco->console_text('dedimania_playerconnect_cb - response' . LF . print_r($response, true));

	// check response
	if (!$player = $aseco->server->players->getPlayer($login)) {
		$aseco->console('dedimania_playerconnect_cb - ' . $login . ' does not exist!');
	}
	elseif (isset($response['Data']['params'])) {
		// update nickname in record
		if ($this->dedi_db['RecsValid'] && !empty($this->dedi_db['Challenge']['Records']) && isset($player->nickname)) {
			foreach ($this->dedi_db['Challenge']['Records'] as &$rec) {
				if ($rec['Login'] == $login) {
					$rec['NickName'] = $player->nickname;
					break;
				}
			}
		}

		// show welcome message
		$message = '{#server}> ' . $this->dedi_db['Welcome'];
		// hyperlink Dedimania site on TMF
		if ($this->getGame() == 'TMF')
			$message = str_replace('www.dedimania.com', '$l[http://www.dedimania.com/]www.dedimania.com$l', $message);
		$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
	}
	else {
		if ($dedi_debug > 2)
			$aseco->console('dedimania_playerconnect_cb - bad response!');
	}
}  // dedimania_playerconnect_cb


// called @ onPlayerDisconnect
function dedimania_playerdisconnect($player) {
$aseco = $this->Aseco;
	global $dedi_db, $dedi_debug;

	if ($dedi_debug > 1)
		$aseco->console_text('dedimania_playerdisconnect - ' . $player->login . ' : ' . $player->nickname);

	// check for non-LAN login
	if (!preg_match('/\/\d+\.\d+\.\d+\.\d+:\d+/', $player->login)) {
		// check for valid connection
		if (isset($this->dedi_db['XmlrpcDB']) && !$this->dedi_db['XmlrpcDB']->isBad()) {
			$this->dedi_db['XmlrpcDB']->addRequest(null,
			                                 'dedimania.PlayerLeave',
			                                 $this->getGame(),
			                                 $player->login);
			// PlayerLeave(Game, Login)
			// ignore: Reply a struct {'Login': string}
		}
	}
}  // dedimania_playerdisconnect


// called @ onNewChallenge
function dedimania_newchallenge($challenge) {
$aseco = $this->Aseco;
	global $dedi_db, $dedi_debug;

	if ($dedi_debug > 1)
		$aseco->console_text('dedimania_newchallenge - challenge' . LF . print_r($challenge, true));

	// check for valid connection
	if (isset($this->dedi_db['XmlrpcDB']) && !$this->dedi_db['XmlrpcDB']->isBad()) {
		$this->dedi_db['Challenge'] = array();

		// collect server & players info
		$serverinfo = $this->dedimania_serverinfo($aseco);
		$players = $this->dedimania_players($aseco);

		$callback = array(array($this,'dedimania_newchallenge_cb'), $challenge);
$this->dedi_db['XmlrpcDB']->addRequest($callback, 
					'dedimania.CurrentChallenge',
					$challenge->uid,
					$challenge->name,
					$challenge->environment,
					$challenge->author,
                              $this->getGame(),
					$aseco->server->gameinfo->mode,
					$serverinfo,
					$this->dedi_db['MaxRecords'],
					$players);
		// CurrentChallenge(Uid, Name, Environment, Author, Game, Mode, SrvInfos, MaxGetTimes, Players)
	}
}  // dedimania_newchallenge

function dedimania_newchallenge_cb($response, $challenge) {
	global $aseco, $dedi_db, $dedi_debug;
$checkpoints = $this->Aseco->getPlugin("CheckpointsExtended")->checkpoints;

	// Reply a struct {'Uid': string, 'TotalRaces': int, 'TotalPlayers': int,
	//                 'TimeAttackRaces': int, 'TimeAttackPlayers': int,
	//                 'NumberOfChecks': int, 'ServerMaxRecords': int,
	//                 'Records': array of struct {'Login': string, 'NickName': string,
	//                                             'Best': int, 'Rank': int,
	//                                             'Checks': array of int, 'Vote': int} }

	// if Stunts mode, temporarily bail out
	if ($aseco->server->gameinfo->mode == 4) return;

	if ($dedi_debug > 2)
		$aseco->console_text('dedimania_newchallenge_cb - response' . LF . print_r($response, true));

	// check response
	if (isset($response['Data']['params'])) {
		$this->dedi_db['Challenge'] = $response['Data']['params'];
		$this->dedi_db['RecsValid'] = true;

		if ($dedi_debug > 1)
			$aseco->console_text('dedimania_newchallenge_cb - records' . LF . print_r($this->dedi_db['Challenge']['Records'], true));

		// check for records
		if (!empty($this->dedi_db['Challenge']['Records'])) {
			// strip line breaks in nicknames
			foreach ($this->dedi_db['Challenge']['Records'] as &$rec) {
				$rec['NickName'] = str_replace("\n", "", $rec['NickName']);
			}

			// set Dedimania checkpoint references
			foreach ($checkpoints as $login => $cp) {
				$drec = $checkpoints[$login]->dedirec - 1;

				// check for specific record
				if ($drec+1 > 0) {
					// if specific record unavailable, use last one
					if ($drec > count($this->dedi_db['Challenge']['Records']) - 1)
						$drec = count($this->dedi_db['Challenge']['Records']) - 1;
					// check for valid checkpoints
					if (!empty($this->dedi_db['Challenge']['Records'][$drec]['Checks']) &&
					    $this->dedi_db['Challenge']['Records'][$drec]['Best'] ==
					    end($this->dedi_db['Challenge']['Records'][$drec]['Checks'])) {
						$checkpoints[$login]->best_fin = $this->dedi_db['Challenge']['Records'][$drec]['Best'];
						$checkpoints[$login]->best_cps = $this->dedi_db['Challenge']['Records'][$drec]['Checks'];
					}
				}
				elseif ($drec+1 == 0) {
					// search for own/last record
					$drec = 0;
					while ($drec < count($this->dedi_db['Challenge']['Records'])) {
						if ($this->dedi_db['Challenge']['Records'][$drec++]['Login'] == $login)
							break;
					}
					$drec--;
					// check for valid checkpoints
					if (!empty($this->dedi_db['Challenge']['Records'][$drec]['Checks']) &&
					    $this->dedi_db['Challenge']['Records'][$drec]['Best'] ==
					    end($this->dedi_db['Challenge']['Records'][$drec]['Checks'])) {
						$checkpoints[$login]->best_fin = $this->dedi_db['Challenge']['Records'][$drec]['Best'];
						$checkpoints[$login]->best_cps = $this->dedi_db['Challenge']['Records'][$drec]['Checks'];
					}
				}  // else -1
			}
			if ($dedi_debug > 3)
				$aseco->console_text('dedimania_newchallenge_cb - checkpoints' . LF . print_r($checkpoints, true));

			// notify records panel & update all panels
		}

		if ($this->dedi_db['ShowRecsBefore'])
			$this->Aseco->getPlugin("DediMania_Chat")->show_dedirecs($aseco, $challenge->name, $challenge->uid, $this->dedi_db['Challenge']['Records'], false, 1);  // from chat.dedimania.php
	} else {
		if ($dedi_debug > 2)
			$aseco->console('dedimania_newchallenge_cb - bad response!');
	}
}  // dedimania_newchallenge_cb


// called @ onEndRace
function dedimania_endrace($data) {
	global $dedi_db, $dedi_debug, $dedi_lastsent;
$checkpoints = $this->Aseco->getPlugin("CheckpointsExtended")->checkpoints;
$aseco = $this->Aseco;

	// if Stunts mode, temporarily bail out
	if ($aseco->server->gameinfo->mode == 4) return;

	if ($dedi_debug > 1)
		$aseco->console_text('dedimania_endrace - data' . LF . print_r($data, true));

	// check for valid track
	if (isset($data[1]['UId'])) {
		// check for valid connection
		if (isset($this->dedi_db['XmlrpcDB']) && !$this->dedi_db['XmlrpcDB']->isBad()) {
			// collect/sort new finish times & checkpoints
			if ($this->dedi_db['RecsValid'] && !empty($this->dedi_db['Challenge']['Records'])) {
				$times = array();
				foreach ($this->dedi_db['Challenge']['Records'] as $rec) {
					if ($rec['NewBest'])
						$times[] = array('Login' => $rec['Login'], 'Best' => $rec['Best'], 'Checks' => $rec['Checks']);
				}
				usort($times, array($this,'dedi_timecompare'));

				// compute number of checkpoints from best time
				$numchecks = 0;
				if (isset($times[0]['Checks']))
					$numchecks = count($times[0]['Checks']);

				if ($dedi_debug > 1) {
					$aseco->console_text('dedimania_endrace - numchecks: ' . $numchecks);
					$aseco->console_text('dedimania_endrace - times' . LF . print_r($times, true));
				}

				$dedi_lastsent = time();
				$callback = array(array($this,'dedimania_endrace_cb'), $data[1]);
				$this->dedi_db['XmlrpcDB']->addRequest($callback,
				                                 'dedimania.ChallengeRaceTimes',
				                                 $data[1]['UId'],
				                                 $data[1]['Name'],
				                                 $data[1]['Environnement'],
				                                 $data[1]['Author'],
				                                 $this->getGame(),
				                                 $aseco->server->gameinfo->mode,
				                                 $numchecks,
				                                 $this->dedi_db['MaxRecords'],
				                                 $times);
				// ChallengeRaceTimes(Uid, Name, Environment, Author, Game, Mode, MaxGetTimes, Times)
				// Times is an array of struct {'Login': string, 'Best': int, 'Checks': array of int}
			}
			$this->dedi_db['RecsValid'] = false;
		}
	}
}  // dedimania_endrace

function dedimania_endrace_cb($response, $challenge) {
	global $aseco, $dedi_db, $dedi_debug;

	//Reply a struct {'Uid': string, 'TotalRaces': int, 'TotalPlayers': int,
	//                'TimeAttackRaces': int, 'TimeAttackPlayers': int,
	//                'NumberOfChecks': int, 'ServerMaxRecords': int,
	//                'Records': array of struct {'Login': string, 'NickName': string,
	//                                            'Best': int, 'Rank': int,
	//                                            'Checks': array of int, 'NewBest': boolean} }

	if ($dedi_debug > 2)
		$aseco->console_text('dedimania_endrace_cb - response' . LF . print_r($response, true));

	// check response
	if (isset($response['Data']['params'])) {
		$this->dedi_db['Results'] = $response['Data']['params'];

		// check for records
		if (!empty($this->dedi_db['Results']['Records'])) {
			// strip line breaks in nicknames
			foreach ($this->dedi_db['Results']['Records'] as &$rec) {
				$rec['NickName'] = str_replace("\n", "", $rec['NickName']);
			}
			if ($dedi_debug > 1)
				$aseco->console_text('dedimania_endrace_cb - results' . LF . print_r($this->dedi_db['Results'], true));

			if ($this->dedi_db['ShowRecsAfter'])
				$this->Aseco->getPlugin("DediMania_Chat")->show_dedirecs($aseco, $challenge['Name'], $challenge['UId'], $this->dedi_db['Results']['Records'], false, 3);  // from chat.dedimania.php
		}
	} else {
		if ($dedi_debug > 2)
			$aseco->console('dedimania_endrace_cb - bad response!');
	}
}  // dedimania_endrace_cb


// called @ onPlayerFinish
function dedimania_playerfinish($finish_item) {
$aseco = $this->Aseco;
$dedi_db = $this->dedi_db;
$dedi_debug = $this->dedi_debug;
	$checkpoints = $this->Aseco->getPlugin("CheckpointsExtended")->checkpoints;  // from plugin.checkpoints.php
	// in Laps mode on real PlayerFinish event, bail out immediately
	if ($aseco->server->gameinfo->mode == 3) return;
	// if no actual finish, bail out too
	if ($finish_item->score == 0) return;
	$login = $finish_item->player->login;
	$nickname = $finish_item->player->nickname;
	// if LAN login, bail out immediately
	if (preg_match('/\/\d+\.\d+\.\d+\.\d+:\d+/', $login)) return;
	//if not best/equal run on this track so far, bail out unless Laps mode
	if ($aseco->server->gameinfo->mode != 3 &&
	    (!isset($checkpoints[$login]) ||
	     $checkpoints[$login]->curr_fin > $checkpoints[$login]->best_fin))
		return;
	//check for finish/checkpoints consistency, unless Stunts mode
	if ($dedi_debug > 0)
		if ($aseco->server->gameinfo->mode != 4 &&
		    ($finish_item->score != $checkpoints[$login]->best_fin ||
		     $finish_item->score != end($checkpoints[$login]->best_cps)))
			$aseco->console('dedimania_playerfinish - inconsistent finish/checks!  score: ' . $finish_item->score . '  checks:' . LF . print_r($checkpoints[$login], true));
	// point to master records list
	$dedi_recs = &$this->dedi_db['Challenge']['Records'];
	// go through all records
	for ($i = 0; $i < $this->dedi_db['MaxRecords']; $i++) {
		$cur_record = $dedi_recs[$i];
		// check if no record, or player's time/score is better
		if (!isset($cur_record) || ($aseco->server->gameinfo->mode == 4 ?
		                            $finish_item->score > $cur_record['Best'] :
		                            $finish_item->score < $cur_record['Best'])) {
			// does player have a record already?
			$cur_rank = -1;
			$cur_score = 0;
			for ($rank = 0; $rank < count($dedi_recs); $rank++) {
				$rec = $dedi_recs[$rank];

				if ($login == $rec['Login']) {
					// new record worse than old one
					if ($aseco->server->gameinfo->mode == 4 ?
					    $finish_item->score < $rec['Best'] :
					    $finish_item->score > $rec['Best']) {
						return;

					// new record is better than or equal to old one
					} else {
						$cur_rank = $rank;
						$cur_score = $rec['Best'];
						break;
					}
				}
			}

			$finish_time = $finish_item->score;
			if ($aseco->server->gameinfo->mode != 4)
				$finish_time = formatTime($finish_time);

			if ($cur_rank != -1) {  // player has a record in topXX already
				// compute difference to old record
				if ($aseco->server->gameinfo->mode != 4) {
					$diff = $cur_score - $finish_item->score;
					$sec = floor($diff/1000);
					$hun = ($diff - ($sec * 1000)) / 10;
				} else {  // Stunts
					$diff = $finish_item->score - $cur_score;
				}

				// update the record if improved
				if ($diff > 0) {
					// ignore 'Rank' field - not used in /dedi* commands
					$dedi_recs[$cur_rank]['Best'] = $finish_item->score;
					$dedi_recs[$cur_rank]['Checks'] = $checkpoints[$login]->best_cps;
					$dedi_recs[$cur_rank]['NewBest'] = true;
				}

				// player moved up in Dedimania list
				if ($cur_rank > $i) {
					// move record to the new position
					moveArrayElement($dedi_recs, $cur_rank, $i);

					// do a player improved his/her Dedimania rank message
					$message = formatText($this->dedi_db['Messages']['RECORD_NEW_RANK'][0],
					                      $this->stripColors($nickname),
					                      $i+1,
					                      ($aseco->server->gameinfo->mode == 4 ? 'Score' : 'Time'),
					                      $finish_time,
					                      $cur_rank+1,
					                      ($aseco->server->gameinfo->mode == 4 ?
					                       '+' . $diff : sprintf('-%d.%02d', $sec, $hun)));

					// show chat message to all or player
					if ($this->dedi_db['DisplayRecs']) {
						if ($i < $this->dedi_db['LimitRecs']) {
							$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
						} else {
							$message = str_replace('{#server}>> ', '{#server}> ', $message);
							$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
						}
					}
				} else {
					if ($diff == 0) {
						// do a player equaled his/her record message
						$message = formatText($this->dedi_db['Messages']['RECORD_EQUAL'][0],
						                      $this->stripColors($nickname),
						                      $cur_rank+1,
						                      ($aseco->server->gameinfo->mode == 4 ? 'Score' : 'Time'),
						                      $finish_time);
					} else {
						// do a player secured his/her record message
						$message = formatText($this->dedi_db['Messages']['RECORD_NEW'][0],
						                      $this->stripColors($nickname),
						                      $i+1,
						                      ($aseco->server->gameinfo->mode == 4 ? 'Score' : 'Time'),
						                      $finish_time,
						                      $cur_rank+1,
						                      ($aseco->server->gameinfo->mode == 4 ?
						                       '+' . $diff : sprintf('-%d.%02d', $sec, $hun)));
					}

					// show chat message to all or player
					if ($this->dedi_db['DisplayRecs']) {
						if ($i < $this->dedi_db['LimitRecs']) {
							$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
						} else {
							$message = str_replace('{#server}>> ', '{#server}> ', $message);
							$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
						}
					}
				}
			} else {  // player hasn't got a record yet

				// insert new record at the specified position
				// drop worst record if list full
				if (count($dedi_recs) >= $this->dedi_db['MaxRecords'])
					array_pop($dedi_recs);

				// ignore 'Rank' field - not used in /dedi* commands
				$record = array('Login' => $login,
				                'NickName' => $finish_item->player->nickname,
				                'Best' => $finish_item->score,
				                'Checks' => $checkpoints[$login]->best_cps,
				                'NewBest' => true);
				insertArrayElement($dedi_recs, $record, $i);

				// do a player drove first record message
				$message = formatText($this->dedi_db['Messages']['RECORD_FIRST'][0],
				                      $this->stripColors($nickname),
				                      $i+1,
				                      ($aseco->server->gameinfo->mode == 4 ? 'Score' : 'Time'),
				                      $finish_time);

				// show chat message to all or player
				if ($this->dedi_db['DisplayRecs']) {
					if ($i < $this->dedi_db['LimitRecs']) {
						$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
					} else {
						$message = str_replace('{#server}>> ', '{#server}> ', $message);
						$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
					}
				}
			}

			// log a new Dedimania record (not an equalled one)
			if ($dedi_recs[$i]['NewBest']) {

				// log record message in console
				$aseco->console('[Dedimania] player {1} finished with {2} and took the {3}. WR place!',
				                $login,
				                $finish_item->score,
				                $i+1);
			}
			if ($dedi_debug > 1)
				$aseco->console_text('dedimania_playerfinish - dedi_recs' . LF . print_r($dedi_recs, true));

			// got the record, now stop!
			return;
		}
	}
}  // dedimania_playerfinish


/*
 * Support functions
 */
function dedimania_players($aseco) {
	global $dedi_debug;

	// collect all players
	$players = array();
	foreach ($aseco->server->players->player_list as $pl) {
		$pinfo = $this->dedimania_playerinfo($aseco, $pl);
		if ($pinfo !== false) {
			$players[] = $pinfo;
		}
	}
	if ($dedi_debug > 2 || ($dedi_debug > 1 && count($players) > 0))
		$aseco->console_text('dedimania_players - players' . LF . print_r($players, true));
	return $players;
}  // dedimania_players

function dedimania_playerinfo($aseco, $player) {

	// check for non-LAN login
	if (!preg_match('/\/\d+\.\d+\.\d+\.\d+:\d+/', $player->login)) {
		// get current player info
		if ($this->getGame() == 'TMF') {
			$aseco->client->query('GetDetailedPlayerInfo', $player->login);
			$info = $aseco->client->getResponse();

			$nation = explode('|', $info['Path']);
			$nation = $this->mapCountry($nation[1]);

			if ($info['Login'] == $player->login)
				return array('Login' => $info['Login'],
				             'Nation' => $nation,
				             'TeamName' => $info['TeamName'],
				             'TeamId' => -1,
				             'IsSpec' => $info['IsSpectator'],
				             'Ranking' => $info['LadderStats']['PlayerRankings'][0]['Ranking'],
				             'IsOff' => $info['IsInOfficialMode']
				            );
		} else {  // TMN/TMS/TMO
			$aseco->client->query('GetPlayerInfo', $player->login);
			$info = $aseco->client->getResponse();

			if ($info['Login'] == $player->login)
				return array('Login' => $info['Login'],
				             'Nation' => $info['Nation'],
				             'TeamName' => $info['TeamName'],
				             'TeamId' => -1,
				             'IsSpec' => $info['IsSpectator'],
				             'Ranking' => $info['LadderStats']['Ranking'],
				             'IsOff' => $info['IsInOfficialMode']
				            );
		}
	}
	return false;
}  // dedimania_playerinfo

function dedimania_serverinfo($aseco) {
	global $dedi_debug;

	// compute number of players and spectators
	$numplayers = 0;
	$numspecs = 0;
	foreach ($aseco->server->players->player_list as $pl) {
		if ($aseco->isSpectator($pl))
			$numspecs++;
		else
			$numplayers++;
	}

	// get current server options
	$aseco->client->query('GetServerOptions');
	$options = $aseco->client->getResponse();

	$serverinfo = array('SrvName' => $options['Name'],
	                    'Comment' => $options['Comment'],
	                    'Private' => ($options['Password'] != ''),
	                    'SrvIP' => '',
	                    'SrvPort' => 0,
	                    'XmlrpcPort' => 0,
	                    'NumPlayers' => $numplayers,
	                    'MaxPlayers' => $options['CurrentMaxPlayers'],
	                    'NumSpecs' => $numspecs,
	                    'MaxSpecs' => $options['CurrentMaxSpectators'],
	                    'LadderMode' => $options['CurrentLadderMode'],
	                    'NextFiveUID' => $this->dedi_getnextuid($aseco)
	                   );
	if ($dedi_debug > 1)
		$aseco->console_text('dedimania_serverinfo - serverinfo' . LF . print_r($serverinfo, true));
	return $serverinfo;
}  // dedimania_serverinfo

function dedi_getnextuid($aseco) {
	global $jukebox;  // from plugin.rasp_jukebox.php

	// check for jukeboxed track
	if (isset($jukebox) && !empty($jukebox)) {
		$jbtemp = $jukebox;
		$track = array_shift($jbtemp);
		$next = $track['uid'];
	} else {
		// check server for next track
		if ($this->getGame() != 'TMF') {
			$aseco->client->query('GetCurrentChallengeIndex');
			$current = $aseco->client->getResponse();
			$current++;
			$rtn = $aseco->client->query('GetChallengeList', 1, $current);
			$track = $aseco->client->getResponse();
			if ($aseco->client->isError()) {
				$rtn = $aseco->client->query('GetChallengeList', 1, 0);
				$track = $aseco->client->getResponse();
			}
		} else {  // TMF
			$aseco->client->query('GetNextChallengeIndex');
			$next = $aseco->client->getResponse();
			$rtn = $aseco->client->query('GetChallengeList', 1, $next);
			$track = $aseco->client->getResponse();
		}
		$next = $track[0]['UId'];
	}
	return $next;
}  // dedi_getnextuid

// usort comparison function: return -1 if $a should be before $b, 1 if vice-versa
function dedi_timecompare($a, $b) {
	global $checkpoints;  // from plugin.checkpoints.php

	// best a better than best b
	if ($a['Best'] < $b['Best'])
		return -1;
	// best b better than best a
	elseif ($a['Best'] > $b['Best'])
		return 1;
	// same best, use timestamp
	else
		return ($checkpoints[$a['Login']]->best_time < $checkpoints[$b['Login']]->best_time) ? -1 : 1;
}  // dedi_timecompare

	function getGame() {
		switch ($this->Aseco->server->game) {
			case "TmForever":
				return "TMF";
			case "TmNationsESWC":
				return "TMN";
			case "TmSunrise":
				return "TMS";
			case "TmOriginal":
				return "TMO";
			default:
				return "Unknown";
		}
	}

function mapCountry($country) {

   $nations = array(
      'Afghanistan' => 'AFG',
      'Albania' => 'ALB',
      'Algeria' => 'ALG',
      'Andorra' => 'AND',
      'Angola' => 'ANG',
      'Argentina' => 'ARG',
      'Armenia' => 'ARM',
      'Aruba' => 'ARU',
      'Australia' => 'AUS',
      'Austria' => 'AUT',
      'Azerbaijan' => 'AZE',
      'Bahamas' => 'BAH',
      'Bahrain' => 'BRN',
      'Bangladesh' => 'BAN',
      'Barbados' => 'BAR',
      'Belarus' => 'BLR',
      'Belgium' => 'BEL',
      'Belize' => 'BIZ',
      'Benin' => 'BEN',
      'Bermuda' => 'BER',
      'Bhutan' => 'BHU',
      'Bolivia' => 'BOL',
      'Bosnia&Herzegovina' => 'BIH',
      'Botswana' => 'BOT',
      'Brazil' => 'BRA',
      'Brunei' => 'BRU',
      'Bulgaria' => 'BUL',
      'Burkina Faso' => 'BUR',
      'Burundi' => 'BDI',
      'Cambodia' => 'CAM',
      'Cameroon' => 'CAR',  // actually CMR
      'Canada' => 'CAN',
      'Cape Verde' => 'CPV',
      'Central African Republic' => 'CAF',
      'Chad' => 'CHA',
      'Chile' => 'CHI',
      'China' => 'CHN',
      'Chinese Taipei' => 'TPE',
      'Colombia' => 'COL',
      'Congo' => 'CGO',
      'Costa Rica' => 'CRC',
      'Croatia' => 'CRO',
      'Cuba' => 'CUB',
      'Cyprus' => 'CYP',
      'Czech Republic' => 'CZE',
      'Czech republic' => 'CZE',
      'DR Congo' => 'COD',
      'Denmark' => 'DEN',
      'Djibouti' => 'DJI',
      'Dominica' => 'DMA',
      'Dominican Republic' => 'DOM',
      'Ecuador' => 'ECU',
      'Egypt' => 'EGY',
      'El Salvador' => 'ESA',
      'Eritrea' => 'ERI',
      'Estonia' => 'EST',
      'Ethiopia' => 'ETH',
      'Fiji' => 'FIJ',
      'Finland' => 'FIN',
      'France' => 'FRA',
      'Gabon' => 'GAB',
      'Gambia' => 'GAM',
      'Georgia' => 'GEO',
      'Germany' => 'GER',
      'Ghana' => 'GHA',
      'Greece' => 'GRE',
      'Grenada' => 'GRN',
      'Guam' => 'GUM',
      'Guatemala' => 'GUA',
      'Guinea' => 'GUI',
      'Guinea-Bissau' => 'GBS',
      'Guyana' => 'GUY',
      'Haiti' => 'HAI',
      'Honduras' => 'HON',
      'Hong Kong' => 'HKG',
      'Hungary' => 'HUN',
      'Iceland' => 'ISL',
      'India' => 'IND',
      'Indonesia' => 'INA',
      'Iran' => 'IRI',
      'Iraq' => 'IRQ',
      'Ireland' => 'IRL',
      'Israel' => 'ISR',
      'Italy' => 'ITA',
      'Ivory Coast' => 'CIV',
      'Jamaica' => 'JAM',
      'Japan' => 'JPN',
      'Jordan' => 'JOR',
      'Kazakhstan' => 'KAZ',
      'Kenya' => 'KEN',
      'Kiribati' => 'KIR',
      'Korea' => 'KOR',
      'Kuwait' => 'KUW',
      'Kyrgyzstan' => 'KGZ',
      'Laos' => 'LAO',
      'Latvia' => 'LAT',
      'Lebanon' => 'LIB',
      'Lesotho' => 'LES',
      'Liberia' => 'LBR',
      'Libya' => 'LBA',
      'Liechtenstein' => 'LIE',
      'Lithuania' => 'LTU',
      'Luxembourg' => 'LUX',
      'Macedonia' => 'MKD',
      'Malawi' => 'MAW',
      'Malaysia' => 'MAS',
      'Mali' => 'MLI',
      'Malta' => 'MLT',
      'Mauritania' => 'MTN',
      'Mauritius' => 'MRI',
      'Mexico' => 'MEX',
      'Moldova' => 'MDA',
      'Monaco' => 'MON',
      'Mongolia' => 'MGL',
      'Montenegro' => 'MNE',
      'Morocco' => 'MAR',
      'Mozambique' => 'MOZ',
      'Myanmar' => 'MYA',
      'Namibia' => 'NAM',
      'Nauru' => 'NRU',
      'Nepal' => 'NEP',
      'Netherlands' => 'NED',
      'New Zealand' => 'NZL',
      'Nicaragua' => 'NCA',
      'Niger' => 'NIG',
      'Nigeria' => 'NGR',
      'Norway' => 'NOR',
      'Oman' => 'OMA',
      'Other Countries' => 'OTH',
      'Pakistan' => 'PAK',
      'Palau' => 'PLW',
      'Palestine' => 'PLE',
      'Panama' => 'PAN',
      'Paraguay' => 'PAR',
      'Peru' => 'PER',
      'Philippines' => 'PHI',
      'Poland' => 'POL',
      'Portugal' => 'POR',
      'Puerto Rico' => 'PUR',
      'Qatar' => 'QAT',
      'Romania' => 'ROM',  // actually ROU
      'Russia' => 'RUS',
      'Rwanda' => 'RWA',
      'Samoa' => 'SAM',
      'San Marino' => 'SMR',
      'Saudi Arabia' => 'KSA',
      'Senegal' => 'SEN',
      'Serbia' => 'SCG',  // actually SRB
      'Sierra Leone' => 'SLE',
      'Singapore' => 'SIN',
      'Slovakia' => 'SVK',
      'Slovenia' => 'SLO',
      'Somalia' => 'SOM',
      'South Africa' => 'RSA',
      'Spain' => 'ESP',
      'Sri Lanka' => 'SRI',
      'Sudan' => 'SUD',
      'Suriname' => 'SUR',
      'Swaziland' => 'SWZ',
      'Sweden' => 'SWE',
      'Switzerland' => 'SUI',
      'Syria' => 'SYR',
      'Taiwan' => 'TWN',
      'Tajikistan' => 'TJK',
      'Tanzania' => 'TAN',
      'Thailand' => 'THA',
      'Togo' => 'TOG',
      'Tonga' => 'TGA',
      'Trinidad and Tobago' => 'TRI',
      'Tunisia' => 'TUN',
      'Turkey' => 'TUR',
      'Turkmenistan' => 'TKM',
      'Tuvalu' => 'TUV',
      'Uganda' => 'UGA',
      'Ukraine' => 'UKR',
      'United Arab Emirates' => 'UAE',
      'United Kingdom' => 'GBR',
      'United States of America' => 'USA',
      'Uruguay' => 'URU',
      'Uzbekistan' => 'UZB',
      'Vanuatu' => 'VAN',
      'Venezuela' => 'VEN',
      'Vietnam' => 'VIE',
      'Yemen' => 'YEM',
      'Zambia' => 'ZAM',
      'Zimbabwe' => 'ZIM',
   );

   if (array_key_exists($country, $nations)) {
      $nation = $nations[$country];
   } else {
      $nation = "OTH";
      if ($country != '')
         trigger_error('Could not map country: ' . $country, E_USER_WARNING);
   }
   return $nation;
}  // mapCountry

}
$_PLUGIN = new DediMania();
$_PLUGIN->setAuthor("Calsmurf2904\Xymph\Slig");
$_PLUGIN->setVersion(0.1);
$_PLUGIN->addEvent('onSync','dedimania_init');
$_PLUGIN->addEvent('onEverySecond', 'dedimania_update');
$_PLUGIN->addEvent('onPlayerConnect', 'dedimania_playerconnect');
$_PLUGIN->addEvent('onPlayerDisconnect', 'dedimania_playerdisconnect');
$_PLUGIN->addEvent('onNewChallenge', 'dedimania_newchallenge');
$_PLUGIN->addEvent('onEndRace', 'dedimania_endrace');
$_PLUGIN->addEvent('onPlayerFinish', 'dedimania_playerfinish');
$_PLUGIN->Aseco->dedimania = $_PLUGIN;
?>
Image
Current Projects :
Aseco 2.x Dedimania plugin
Aseco 2.x Clan management Plugin
Servers :
LSR Race Server
Server Specs :
TmForever Server 2.11.16 05-08-08 (D-M-Y)
Xaseco 1.03 with FufiMenu and FufiWidgets

User avatar
w1lla
TM-Patrol
TM-Patrol
Posts: 1466
Joined: 23 May 2007 07:20
Owned TM-games: TMU, TMN, TMF
Manialink(s): intr
Location: Venray

Re: Public DB temporarily offline

Post by w1lla » 21 Jul 2008 16:56

just try my/oliverdes version which has all in it. only problem at the moment is the chat but will be away for phone problems

Code: Select all

tmnforever is nations and united makes it special. tmnforever has united. I need united!

calsmurf2904
smooth traffic navigator
smooth traffic navigator
Posts: 199
Joined: 08 Jul 2008 15:23
Owned TM-games: TMNF,TMN
Location: Netherlands
Contact:

Re: Public DB temporarily offline

Post by calsmurf2904 » 21 Jul 2008 16:59

by mine version is does show the the records (only in fufi's widgets it doesn't update...maybe f*ckfish can help me with that ?)the only problem is that /dedirecs gives me the error

Code: Select all

xmlrpc error [-1000] Invalid Manialink page: Error reading end tag.
if i can fix that then the chat.dedimania.php plugin should work great
@F*ckfish
can you help me ?
i currently have this code

Code: Select all

<?php
	function showRecordsWidgets($playerFinished=false){

		//the gamemode is needed to get the right configuration and display options
		$gamemode = $this->Aseco->server->gameinfo->mode;
		$roundsmode = $gamemode==0 || $gamemode==5;

		$showLocalRecs = $this->settings["localrecordswidget"]["enabled"] && $this->settings["localrecordswidget"]["states"][$gamemode]["enabled"];
		$showLiveRankings = $this->settings["liverankingswidget"]["enabled"] && $this->settings["liverankingswidget"]["states"][$gamemode]["enabled"];
		//$showDediRecs = $this->settings["dedimaniawidget"]["enabled"] && $this->settings["dedimaniawidget"]["states"][$gamemode]["enabled"];
            $showDediRecs = true;

		//in roundsmode, there is no need to react onPlayerFinish
		if ($roundsmode && $playerFinished) $showLiveRankings = false;

		if (!($showLiveRankings || $showLocalRecs || $showDediRecs)) return;
		if (!$this->settings["localrecordswidget"]["forceUpdate"] && (!$this->settings["localrecordswidget"]["needsUpdate"] && $playerFinished)) return;

		$showpointsLocalRecs = false;
		if ($gamemode==4) $showpointsLocalRecs = true;
		$showpointsLiveRankings = false;
		if ($gamemode==0 || $gamemode==4 || $gamemode==5) $showpointsLiveRankings = true;

		//get the manialink XML template for the widget and separate it to blocks

		$header = $this->settings["localrecordswidget"]["blocks"]["header"];
		$header = str_replace(array("%manialinksid%"), array($this->manialinksID), $header);

		$footer = $this->settings["localrecordswidget"]["blocks"]["footer"];
		$footer_window = $this->settings["localrecordswidget"]["blocks"]["footer_window"];
		$entry = $this->settings["localrecordswidget"]["blocks"]["entry"];
		$highlite = $this->settings["localrecordswidget"]["blocks"]["highlight_entry"];

		$localRecordsCount = $this->settings["localrecordswidget"]["states"][$gamemode]["entrycount"];
		$liveRankingsCount = $this->settings["liverankingswidget"]["states"][$gamemode]["entrycount"];
		$dediRecsCount = $this->settings["dedimaniawidget"]["states"][$gamemode]["entrycount"];


		//local record stuff

		if ($showLocalRecs){

			//replace the placeholders in the xml blocks with content

			$headerLocalRecs = $this->settings["localrecordswidget"]["blocks"]["header_window"].$this->settings["localrecordswidget"]["blocks"]["window"];
			$headerLocalRecs = str_replace(array("%widgetid%", "%height%", "%width%", "%widgetpos%") , array($this->closeToYouWidgetID, 2*$localRecordsCount+2, $this->settings["localrecordswidget"]["states"][$gamemode]["width"], $this->settings["localrecordswidget"]["states"][$gamemode]["pos"]), $headerLocalRecs);
			if ($this->settings["localrecordswidget"]["states"][$gamemode]["displaytitle"]){
				$headerLocalRecs .= str_replace(array('%titlepos%',	'%widgettitle%'), array($this->settings["localrecordswidget"]["states"][$gamemode]["width"]/2 + $this->settings["localrecordswidget"]["states"][$gamemode]["titleoffsetx"], $this->settings["localrecordswidget"]["title"]), $this->settings['localrecordswidget']['blocks']['title']);
			}
			$highliteLocalRecs = str_replace('%width%', $this->settings["localrecordswidget"]["states"][$gamemode]["width"]-1, $highlite);


			//get the records from Aseco

			$records = array();
			if (IN_XASECO){
				$recsAseco = $this->Aseco->server->records->record_list;
				foreach ($recsAseco as $recAseco){
					$rec = array();
					$rec["player"] = $recAseco->player;
					$rec["score"] = $recAseco->score;
					$records[]=$rec;
				}

			} else {
				for ($i=0; $i<$this->Aseco->records->count(); $i++){
					$records[$i] = array();
					$rec = $this->Aseco->records->getRecord($i);
					$records[$i]["player"] =  $rec->player;
					$records[$i]["score"] = $rec->score;
				}
			}
		}


		//live rankings stuff

		if ($showLiveRankings){

			//replace the placeholders in the xml blocks with content

			$headerLiveRecs = $this->settings["localrecordswidget"]["blocks"]["header_window"].$this->settings["localrecordswidget"]["blocks"]["window"];
			$headerLiveRecs = str_replace(array("%widgetid%", "%height%", "%width%", "%widgetpos%") , array($this->rankingWidgetID, 2*$liveRankingsCount+2, $this->settings["liverankingswidget"]["states"][$gamemode]["width"], $this->settings["liverankingswidget"]["states"][$gamemode]["pos"]), $headerLiveRecs);
			if ($this->settings["liverankingswidget"]["states"][$gamemode]["displaytitle"]){
				$headerLiveRecs .= str_replace(array('%titlepos%',	'%widgettitle%'), array($this->settings["liverankingswidget"]["states"][$gamemode]["width"]/2 + $this->settings["liverankingswidget"]["states"][$gamemode]["titleoffsetx"], $this->settings["liverankingswidget"]["title"]), $this->settings['liverankingswidget']['blocks']['title']);
			}
			$highliteLiveRankings = str_replace('%width%', $this->settings["liverankingswidget"]["states"][$gamemode]["width"]-1, $highlite);



			//get the current rankings

			$this->Aseco->client->query("GetCurrentRanking", 500,0);
			if ($this->Aseco->client->isError()){
				if (!$this->oldRanking) $this->oldRanking = array();
				$rankings = $this->oldRanking;
			} else {
				$rankings = $this->Aseco->client->getResponse();
				$this->oldRanking = $rankings;
			}
			$rankings_= array();

			for ($i=0; $i<count($rankings); $i++){
				if ($rankings[$i]["BestTime"]==0) $rankings[$i]["BestTime"]= $rankings[$i]["Score"];
				if ($rankings[$i]["BestTime"]>0){
					$playerObj = $this->Aseco->server->players->getPlayer($rankings[$i]["Login"]);
					if (IN_XASECO){
						$player = $playerObj;
					} else {
						$player = new RecPlayer($playerObj);
					}
					$ranking = array();
					$ranking["player"] = $player;
					$ranking["player"]->nickname = $rankings[$i]["NickName"];
					$ranking["score"] = $rankings[$i]["BestTime"];
					if ($gamemode==0 || $gamemode==4 || $gamemode==5){
						$ranking["score"] = $rankings[$i]["Score"];
					}

					$rankings_[]= $ranking;
				}
			}

			$rankings = $rankings_;

		}

		//dedimania widget stuff

		if ($showDediRecs){

			//replace the placeholders in the xml blocks with content

			$headerDediRecs = $this->settings["localrecordswidget"]["blocks"]["header_window"].$this->settings["localrecordswidget"]["blocks"]["window"];
			$headerDediRecs = str_replace(array("%widgetid%", "%height%", "%width%", "%widgetpos%") , array($this->dedimaniaWidgetID, 2*$dediRecsCount+2, $this->settings["dedimaniawidget"]["states"][$gamemode]["width"], $this->settings["dedimaniawidget"]["states"][$gamemode]["pos"]), $headerDediRecs);
			if ($this->settings["dedimaniawidget"]["states"][$gamemode]["displaytitle"]){
				$headerDediRecs .= str_replace(array('%titlepos%',	'%widgettitle%'), array($this->settings["dedimaniawidget"]["states"][$gamemode]["width"]/2 + $this->settings["dedimaniawidget"]["states"][$gamemode]["titleoffsetx"], $this->settings["dedimaniawidget"]["title"]), $this->settings['localrecordswidget']['blocks']['title']);
			}
			$highliteDediRecs = str_replace('%width%', $this->settings["dedimaniawidget"]["states"][$gamemode]["width"]-1, $highlite);

			global $dedi_db;

			$player = $command['author'];
			$dedi_recs = $this->Aseco->getPlugin("DediMania")->dedi_db['Challenge']['Records'];

			$dediRecs_ = array();
			if ($dedi_recs != NULL){
				for ($i=0; $i<count($dedi_recs); $i++){
					if ($dedi_recs[$i]["Best"]>0){
						$playerObj = $this->Aseco->server->players->getPlayer($dedi_recs[$i]["Login"]);
						//if (IN_XASECO){
							$player = $playerObj;
						//} else {
						//	$player = new RecPlayer($playerObj);
						//}
						$ranking = array();
						$ranking["player"] = $player;
						$ranking["player"]->nickname = $dedi_recs[$i]["NickName"];
						$ranking["score"] = $dedi_recs[$i]["Best"];

						$dediRecs_[]= $ranking;
					}
				}
			} else {
				$tryAgain = true;
			}
			$dediRecs = $dediRecs_;

		}

		if ($this->Aseco->debug){
			$playercount = count($this->Aseco->server->players->player_list);
			$this->Aseco->console("[FufiWidgets] Attempting to update rec widgets for ".$playercount." players.");
			$count=0;
		}

		foreach ($this->Aseco->server->players->player_list as $player){


			//local records stuff (create the Close2You array and a hash value)

			if ($showLocalRecs){

				$localRecordsCtu = $this->getCloseToYouArray($records, $player->login, $localRecordsCount, $this->settings['localrecordswidget']['states'][$gamemode]['topcount']);
				$localRecordsCtuHash = $this->ctuHash($localRecordsCtu);

				if (!isset($this->localRecordsHashs[$player->login])){
					$this->localRecordsHashs[$player->login]="-1";
				}
			}


			//live rankings stuff (create the Close2You array and a hash value)

			if ($showLiveRankings){

				$liveRankingCtu = $this->getCloseToYouArray($rankings, $player->login, $liveRankingsCount,  $this->settings['liverankingswidget']['states'][$gamemode]['topcount']);
				$liveRankingCtuHash = $this->ctuHash($liveRankingCtu);

				if (!isset($this->liveRankingHashs[$player->login])){
					$this->liveRankingHashs[$player->login]="-1";
				}
			}

			//dedimania stuff (create the Close2You array and a hash value)

			if ($showDediRecs){

				$dediRecsCtu = $this->getCloseToYouArray($dediRecs, $player->login, $dediRecsCount,  $this->settings['dedimaniawidget']['states'][$gamemode]['topcount']);
				$dediRecsCtuHash = $this->ctuHash($dediRecsCtu);

				if (!isset($this->dedimaniaHashs[$player->login])){
					$this->dedimaniaHashs[$player->login]="-1";
				}
			}

			// only update the widget manialink if something changed

			if (($this->localRecordsHashs[$player->login] != $localRecordsCtuHash) || ($this->liveRankingHashs[$player->login] != $liveRankingCtuHash || $this->dedimaniaHashs[$player->login] != $dediRecsCtuHash)){
				$localRecContent = '';
				$liveRankingContent = '';
				$dediRecsContent = '';


				// local records stuff (create the new widget manialink, if necessary)

				$localRecordsChanged = false;
				if (($this->localRecordsHashs[$player->login] != $localRecordsCtuHash) && $showLocalRecs){
					$this->localRecordsHashs[$player->login] = $localRecordsCtuHash;

					for ($i=0;$i<count($localRecordsCtu); $i++){

						$localRecContent.= str_replace('%nickwidth%', $this->settings["localrecordswidget"]["states"][$gamemode]["width"]-8.5, $this->getCTUEntry($localRecordsCtu[$i], $i, $highliteLocalRecs, $entry, $showpointsLocalRecs, $this->settings['localrecordswidget']['states'][$gamemode]["width"],  $this->settings['localrecordswidget']['states'][$gamemode]['topcount']));

					}
					$highliteTop='';
					if ($this->settings['localrecordswidget']['states'][$gamemode]['topcount']){
						$highliteTop = str_replace(array('%width%', '%height%', '%x%', '%y%'), array($this->settings['localrecordswidget']['states'][$gamemode]['width']-1,0.7+2*$this->settings['localrecordswidget']['states'][$gamemode]['topcount'],0.5,-0.5), $this->settings['localrecordswidget']['blocks']['windowtop']);
					}
					$localRecContent = $headerLocalRecs.$highliteTop.$localRecContent.$footer_window;
					$localRecordsChanged = true;
				}

				// live rankings stuff (create the new widget manialink, if necessary)

				$liveRankingsChanged = false;
				if (($this->liveRankingHashs[$player->login] != $liveRankingCtuHash) && $showLiveRankings){
					$this->liveRankingHashs[$player->login] = $liveRankingCtuHash;

					for ($i=0;$i<count($liveRankingCtu); $i++){
						$liveRankingContent.=str_replace('%nickwidth%', $this->settings["liverankingswidget"]["states"][$gamemode]["width"]-8.5, $this->getCTUEntry($liveRankingCtu[$i], $i, $highliteLiveRankings, $entry, $showpointsLiveRankings, $this->settings['liverankingswidget']['states'][$gamemode]["width"],  $this->settings['liverankingswidget']['states'][$gamemode]['topcount']));

					}
					$highliteTop='';
					if ($this->settings['liverankingswidget']['states'][$gamemode]['topcount']){
						$highliteTop = str_replace(array('%width%', '%height%', '%x%', '%y%'), array($this->settings['liverankingswidget']['states'][$gamemode]['width']-1,0.7+2*$this->settings['liverankingswidget']['states'][$gamemode]['topcount'],0.5,-0.5), $this->settings['localrecordswidget']['blocks']['windowtop']);
					}
					$liveRankingContent = $headerLiveRecs.$highliteTop.$liveRankingContent.$footer_window;
					$liveRankingsChanged = true;
				}

				// dedimania widget stuff (create the new widget manialink, if necessary)

				$dediRecsChanged = false;
				if (($this->dedimaniaHashs[$player->login] != $dediRecsCtuHash) && $showDediRecs){
					$this->dedimaniaHashs[$player->login] = $dediRecsCtuHash;

					for ($i=0;$i<count($dediRecsCtu); $i++){
						$dediRecsContent.=str_replace('%nickwidth%', $this->settings["dedimaniawidget"]["states"][$gamemode]["width"]-8.5, $this->getCTUEntry($dediRecsCtu[$i], $i, $highliteDediRecs, $entry, $showpointsLocalRecs, $this->settings['dedimaniawidget']['states'][$gamemode]["width"],  $this->settings['dedimaniawidget']['states'][$gamemode]['topcount']));
					}
					$highliteTop='';
					if ($this->settings['dedimaniawidget']['states'][$gamemode]['topcount']){
						$highliteTop = str_replace(array('%width%', '%height%', '%x%', '%y%'), array($this->settings['dedimaniawidget']['states'][$gamemode]['width']-1,0.7+2*$this->settings['dedimaniawidget']['states'][$gamemode]['topcount'],0.5,-0.5), $this->settings['dedimaniawidget']['blocks']['windowtop']);
					}
					$dediRecsContent = $headerDediRecs.$highliteTop.$dediRecsContent.$footer_window;
					$dediRecsChanged = true;
				}

				// send it
				$xml = $header.$localRecContent.$liveRankingContent.$dediRecsContent.$footer;
				if ($this->showRecordsWidgetsToLogin[$player->login] && ($localRecordsChanged || $liveRankingsChanged || $dediRecsChanged)){
					$this->sendMLtoLogin($player->login, $xml, '', 'rw', true);
					if ($this->Aseco->debug){
						$count++;
						echo ".";
					}
				}

			}
		}
		if ($this->Aseco->debug){
			if ($count>0) echo CRLF;
			$this->Aseco->console("[FufiWidgets] ".$count." of ".$playercount." rec widgets needed update.");
		}
		$this->settings["localrecordswidget"]["needsUpdate"] = false;
		$this->settings["localrecordswidget"]["forceUpdate"] = false;

		if ($tryAgain) $this->settings["localrecordswidget"]["needsUpdate"] = true;

	}
?>
Could you check the code to see why it isn't updating the dedimania records ?
nvm i fixed it by changing this :

Code: Select all

	function doMainLoop(){
		if ($this->racing){
			$this->showClockWidget();
			//update records if necessary
			$time = time();
			if ($time >= $this->lastKarmaUpdate + $this->updateInterval){
				$this->lastKarmaUpdate = $time;
				$this->showKarmaWidget();
			}
			if ($time >= $this->lastRecordsUpdate + $this->updateInterval + $this->updateInterval/2){
				$this->lastRecordsUpdate = $time;
				$this->showRecordsWidgets(true);
			}
			unset($time);
		}
	}
into this :

Code: Select all

	function doMainLoop(){
		if ($this->racing){
			$this->showClockWidget();
			//update records if necessary
			$time = time();
			if ($time >= $this->lastKarmaUpdate + $this->updateInterval){
				$this->lastKarmaUpdate = $time;
				$this->showKarmaWidget();
			}
			if ($time >= $this->lastRecordsUpdate + $this->updateInterval + $this->updateInterval/2){
$this->settings["localrecordswidget"]["needsUpdate"] = true;
				$this->lastRecordsUpdate = $time;
				$this->showRecordsWidgets(true);
			}
			unset($time);
		}
	}
Image
Current Projects :
Aseco 2.x Dedimania plugin
Aseco 2.x Clan management Plugin
Servers :
LSR Race Server
Server Specs :
TmForever Server 2.11.16 05-08-08 (D-M-Y)
Xaseco 1.03 with FufiMenu and FufiWidgets

User avatar
f*ckfish
Pit Crew
Pit Crew
Posts: 1302
Joined: 15 Jun 2007 07:59
Owned TM-games: TMNF, TMUF
Location: Dresden, Germany
Contact:

Re: Public DB temporarily offline

Post by f*ckfish » 22 Jul 2008 00:43

What you did is no real fix since it forces the server to perform unnecessary computations every few seconds. It may work for the testing but I recommend to not use this code on populated servers. I promise, as soon as the Dedimania plugin is published, I'll include its functionality in the widgets, but at the moment you really should not concentrate on making your plugin work there but on making it releasable.
inactive, sorry

calsmurf2904
smooth traffic navigator
smooth traffic navigator
Posts: 199
Joined: 08 Jul 2008 15:23
Owned TM-games: TMNF,TMN
Location: Netherlands
Contact:

Re: Public DB temporarily offline

Post by calsmurf2904 » 22 Jul 2008 12:10

i know its not a real fix but it forces the system to update....so that the records are shown..
i edited fufi widgets to show the records because i have no system for showing the recs yet....
so with this i can see some records.
Image
Current Projects :
Aseco 2.x Dedimania plugin
Aseco 2.x Clan management Plugin
Servers :
LSR Race Server
Server Specs :
TmForever Server 2.11.16 05-08-08 (D-M-Y)
Xaseco 1.03 with FufiMenu and FufiWidgets

nocturne
solid chaser
solid chaser
Posts: 1390
Joined: 08 Jun 2007 18:48
Owned TM-games: all
Contact:

Re: Public DB temporarily offline

Post by nocturne » 15 Aug 2008 05:20

I know the conversation steered a bit towards DM... but how about the pubdb? Are there plans to still revive it?

Assembler Maniac
Pit Crew
Pit Crew
Posts: 1493
Joined: 03 Jun 2006 13:24
Owned TM-games: TMU
Contact:

Re: Public DB temporarily offline

Post by Assembler Maniac » 15 Aug 2008 15:21

At this point I'm not even sure if Aseco2 will continue.

I've lost interest in TMF and haven't talked to Flo in over a month (6hr time diff is part of the problem). Real Life has gotten more involved, so my free time is very short.

I'm also disappointed by the quality (or lack thereof) of plugins being created. What's the point in creating a jokebot, irc, or trivia script for a racing game? Why clutter the HUD with useless sidebars and pretty graphics? An audio jukebox? Lottery? Bah!

This is not aimed at anyone specific, I'm just generally bummed on the whole public code thing right now. PHP is not an ideal language for doing things like this, but C/C++ wouldn't lend itself to modular construction and not too many other languages are *nix/windows portable.

calsmurf2904
smooth traffic navigator
smooth traffic navigator
Posts: 199
Joined: 08 Jul 2008 15:23
Owned TM-games: TMNF,TMN
Location: Netherlands
Contact:

Re: Public DB temporarily offline

Post by calsmurf2904 » 15 Aug 2008 16:10

why don't you just set up a team of developers ?
there are probally plenty of developers on this forum that are willing to help
Image
Current Projects :
Aseco 2.x Dedimania plugin
Aseco 2.x Clan management Plugin
Servers :
LSR Race Server
Server Specs :
TmForever Server 2.11.16 05-08-08 (D-M-Y)
Xaseco 1.03 with FufiMenu and FufiWidgets

User avatar
J-S
happy cruiser
happy cruiser
Posts: 149
Joined: 24 Apr 2008 18:20
Owned TM-games: TMN,TMUF,TMO,TMS
Manialink(s): shark
Location: Grenoble - France
Contact:

Re: Public DB temporarily offline

Post by J-S » 23 Aug 2008 11:09

I feel completely aimed by what you say. Aseco is very well built and for me the best controller of records who exists. But much of people found an interest different with the records's controllers by plugins which leave the ordinary one sometimes. I saw much people choosing another system that Aseco, precisely because it missed richness.

I know that plugins that I could make are not inevitably optimized and does not use all the functions provide by Aseco (I discover them every day …). But I miss also time to optimize them because that requires research and reflexion.

It would be damage to lose a so promising project. I already made the experiment with TMweb which was promised to a beautiful future. But was given up little by little by its creators

:lovetm
Last edited by J-S on 24 Aug 2008 17:51, edited 2 times in total.

calsmurf2904
smooth traffic navigator
smooth traffic navigator
Posts: 199
Joined: 08 Jul 2008 15:23
Owned TM-games: TMNF,TMN
Location: Netherlands
Contact:

Re: Public DB temporarily offline

Post by calsmurf2904 » 23 Aug 2008 11:22

Maybe we should create a topic just to see who wants to help if a development team is created ?
Image
Current Projects :
Aseco 2.x Dedimania plugin
Aseco 2.x Clan management Plugin
Servers :
LSR Race Server
Server Specs :
TmForever Server 2.11.16 05-08-08 (D-M-Y)
Xaseco 1.03 with FufiMenu and FufiWidgets

Post Reply