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, f*ckfish, Assembler Maniac, TM-Patrol

User avatar
oliverde8
solid chaser
solid chaser
Posts: 1135
Joined: 07 Oct 2006 07:03
Owned TM-games: TMU
Manialink(s): oliverde8
Location: Turkey
Contact:

Re: Public DB temporarily offline

Post by oliverde8 » 10 Jun 2008 15:23

Okay did it
I thinked ı had to register it before. So I was keeping XASECO
ImageImage
Manialink : oliverde8color>
Servers : STATS <> United | VeryShort | Made In Turkey

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 » 10 Jun 2008 16:16

oliverde i was/am in your server atm and its nice to see that it works but the following should be adjusted:

/dedirecs
/dedinew
/dedilive

also manialink is bad. if you want i will look at code and fix it

Code: Select all

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

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 » 10 Jun 2008 17:04

Code: Select all

*[PHP Warning] usort(): Invalid comparison function. on line 563 in file D:\tmn\asecotmnf\plugins\plugin.dedimania.php
|...Calculating ranks
|...Done!
[Autotime] Track=W1lla01, time=03:00.00, AuthorTime=00:12.05
[06/10,19:00:32] map changed [$w$iW1lla01] >> [$w$iW1lla01]
[06/10,19:00:33] current record on $w$iW1lla01 is 00:11.63 and held by $l[www.mentiz.com]$900mTz`$fffฬ1llค$l
*[06/10,19:00:33] XMLRPC Error [-1000] - Start index out of bound.
*[06/10,19:00:35] XMLRPC Error [-502] - Not enough items in array
*are errors after map change i think atm. dont know what causes this so i think it has to do with usort.

Code: Select all

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

User avatar
oliverde8
solid chaser
solid chaser
Posts: 1135
Joined: 07 Oct 2006 07:03
Owned TM-games: TMU
Manialink(s): oliverde8
Location: Turkey
Contact:

Re: Public DB temporarily offline

Post by oliverde8 » 10 Jun 2008 18:08

w1lla wrote:

Code: Select all

*[PHP Warning] usort(): Invalid comparison function. on line 563 in file D:\tmn\asecotmnf\plugins\plugin.dedimania.php
|...Calculating ranks
|...Done!
[Autotime] Track=W1lla01, time=03:00.00, AuthorTime=00:12.05
[06/10,19:00:32] map changed [$w$iW1lla01] >> [$w$iW1lla01]
[06/10,19:00:33] current record on $w$iW1lla01 is 00:11.63 and held by $l[www.mentiz.com]$900mTz`$fffฬ1llค$l
*[06/10,19:00:33] XMLRPC Error [-1000] - Start index out of bound.
*[06/10,19:00:35] XMLRPC Error [-502] - Not enough items in array
*are errors after map change i think atm. dont know what causes this so i think it has to do with usort.
I don't have *[06/10,19:00:33] XMLRPC Error [-1000] - Start index out of bound. but the other 2 only :? still searching

Edit1: I found out CP times aren't sent to dedimania maybe something due to this :?
Edit2: Found out why it does that error will try to solve
Edit3:add this to the end :thumbsup:

Code: Select all

function dedi_timecompare($a, $b) {
		Global $Dedimania;
	return $Dedimania->dedi_timecompare($a, $b);
	}  // dedi_timecompare
ImageImage
Manialink : oliverde8color>
Servers : STATS <> United | VeryShort | Made In Turkey

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 » 11 Jun 2008 08:08

http://www.gamers.org/tmn/docs/ListDedimania.html shows the connection and status to dedimania so maybe that is what causes problems. Also the usort() thing is weird to say.

Code: Select all

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

User avatar
s!em
speedy pilot
speedy pilot
Posts: 573
Joined: 06 Dec 2005 12:53
Owned TM-games: ALL
Location: Belgium

Re: Public DB temporarily offline

Post by s!em » 11 Jun 2008 09:44

Oliverde8, when do u think this will be done?

User avatar
oliverde8
solid chaser
solid chaser
Posts: 1135
Joined: 07 Oct 2006 07:03
Owned TM-games: TMU
Manialink(s): oliverde8
Location: Turkey
Contact:

Re: Public DB temporarily offline

Post by oliverde8 » 11 Jun 2008 09:46

w1lla wrote:http://www.gamers.org/tmn/docs/ListDedimania.html shows the connection and status to dedimania so maybe that is what causes problems. Also the usort() thing is weird to say.
Usort is calling dedi_timecompare function that is in the class. As it is in the class it can't get it. So I added a function outside the class that calls the function that is in the class as I did for all queries.
I don't know why CP times aren't sent either even if records and players are sent.

Olso add

Code: Select all

if (array_key_exists($country, $nations)) {
		$nation = $nations[$country];
	} else {
		$nation = "OTH";
		trigger_error('Could not map country: ' . $country, E_USER_WARNING);
	}
	return $nation; 
at the end of MapCounty :oops: Bad copy Paste
ImageImage
Manialink : oliverde8color>
Servers : STATS <> United | VeryShort | Made In Turkey

User avatar
oliverde8
solid chaser
solid chaser
Posts: 1135
Joined: 07 Oct 2006 07:03
Owned TM-games: TMU
Manialink(s): oliverde8
Location: Turkey
Contact:

Re: Public DB temporarily offline

Post by oliverde8 » 11 Jun 2008 10:10

s!em wrote:Oliverde8, when do u think this will be done?
The main is done there is some problems still but... I stoped everything to try to finish it. I have other things to do olso :x
2 problems now
[06/11,13:02:52] XMLRPC Error [-502] - Not enough items in array
and CPS not sent :shock:
ImageImage
Manialink : oliverde8color>
Servers : STATS <> United | VeryShort | Made In Turkey

User avatar
Slig
Pit Crew
Pit Crew
Posts: 2124
Joined: 05 Sep 2005 17:51
Owned TM-games: ALL
Location: TraxicoLand (Fr)
Contact:

Re: Public DB temporarily offline

Post by Slig » 11 Jun 2008 12:39

oliverde8 wrote:

Code: Select all

function dedi_timecompare($a, $b) {
		Global $Dedimania;
	return $Dedimania->dedi_timecompare($a, $b);
	}  // dedi_timecompare
instead you can also do it nicer by calling directly the object method :
usort(..., array($Dedimania,'dedi_timecompare') )

http://www.php.net/manual/en/language.p ... s.callback

User avatar
oliverde8
solid chaser
solid chaser
Posts: 1135
Joined: 07 Oct 2006 07:03
Owned TM-games: TMU
Manialink(s): oliverde8
Location: Turkey
Contact:

Re: Public DB temporarily offline

Post by oliverde8 » 11 Jun 2008 13:07

Slig wrote:
oliverde8 wrote:

Code: Select all

function dedi_timecompare($a, $b) {
		Global $Dedimania;
	return $Dedimania->dedi_timecompare($a, $b);
	}  // dedi_timecompare
instead you can also do it nicer by calling directly the object method :
usort(..., array($Dedimania,'dedi_timecompare') )

http://www.php.net/manual/en/language.p ... s.callback
Thanks a lot once more
Done to all callbacks :thumbsup:
ImageImage
Manialink : oliverde8color>
Servers : STATS <> United | VeryShort | Made In Turkey

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 » 12 Jun 2008 12:24

To the one porting dedimania to ASECO (probably oli ;-) ) I have a request. Since I'm writing a dedimania widget I need to be able to get the dedimania records, so I wished there could be a global variable "$dedi_db" like in XASECO or a public field in the Dedimania class, I can access like "$dedimania->dedi_db" or "$dedimania->getDediDB()" or something like that =)
Last edited by f*ckfish on 12 Jun 2008 14:15, edited 1 time in total.
inactive, sorry

User avatar
oliverde8
solid chaser
solid chaser
Posts: 1135
Joined: 07 Oct 2006 07:03
Owned TM-games: TMU
Manialink(s): oliverde8
Location: Turkey
Contact:

Re: Public DB temporarily offline

Post by oliverde8 » 12 Jun 2008 14:08

f*ckfish wrote:To the one porting dedimania to ASECO (probably oli ;-) ) I have a request. Since I'm writing a dedimania widget I need to be able to get the dedimania records, so I wished there could be a global variable "$dedi_db" like in XASECO or a public field in the Dedimania class, I can access like "$dedimania-$dedi_db" or "$dedimania->getDediDB()" or something like that =)
The variables are the exact same as XASECO thry are not global but can be aceest by $dedimania->$dedi_db as The Chat Plugin gets them the same way :thumbsupof course $dedimania=$this->GetPugin(Dedimania)

What I did on TheChat plugin was on start $this->dedimana=$this->GetPugin(Dedimania); and after use it as I wish as $this->dedimania->dedi_db
ImageImage
Manialink : oliverde8color>
Servers : STATS <> United | VeryShort | Made In Turkey

fordry
speedy pilot
speedy pilot
Posts: 368
Joined: 24 Jan 2008 20:53
Owned TM-games: TMUF TMN
Contact:

Re: Public DB temporarily offline

Post by fordry » 29 Jun 2008 07:20

Any word on the progress oliverde8? I seen your server on Dedimania's website :D.

User avatar
s!em
speedy pilot
speedy pilot
Posts: 573
Joined: 06 Dec 2005 12:53
Owned TM-games: ALL
Location: Belgium

Re: Public DB temporarily offline

Post by s!em » 29 Jun 2008 08:10

He's on vacation ;)

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 » 20 Jul 2008 17:17

i got bored so i started to make an dedimania plugin 2...
I succesfully connected etc. the only problem is that has an error sending new challenge info....well
not sending it but recieving info from the server...
this is my current code :

Code: Select all

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

/**
 * Dedimania plugin.
 * Handles interaction with the Dedimania world database.
 * Created by Calsmurf2904,Based on Xaseco's version 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_webaccess;
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_webaccess, $dedi_lastsent,
	       $checkpoints;  // from plugin.checkpoints.php

	// 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
	$dedi_webaccess = new Webaccess();

	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;
$dedi_debug = 6;
			} 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_webaccess;

	$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($dedi_webaccess, $this->dedi_db['Url'][count($this->dedi_db['Url']) - 1],
		                         $aseco->server->getGame(),
		                         $this->dedi_db['Login'],
		                         $this->dedi_db['Password'],
		                         'ASECO', ASECO_VERSION,
		                         $this->dedi_db['Nation'],
		                         $aseco->server->packmask,$this->Aseco);
		$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($dedi_webaccess, $url,
			                         $aseco->server->getGame(),
			                         $this->dedi_db['Login'],
			                         $this->dedi_db['Password'],
			                         'ASECO', ASECO_VERSION,
			                         $this->dedi_db['Nation'],
			                         $aseco->server->packmask);
			$this->dedi_db['XmlrpcDB'] = $xmlrpcdb;
			$this->dedi_db['News'] = $response['Data']['params']['Messages'];
			$aseco->console('* 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('* 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 = dedimania_serverinfo($aseco);
			$players = dedimania_players($aseco);

			$dedi_lastsent = time();
			$callback = array('dedimania_announce_cb');
			$this->dedi_db['XmlrpcDB']->addRequest($callback,
			                                 'dedimania.UpdateServerPlayers',
			                                 $aseco->server->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_webaccess;

	// 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;
	$dedi_webaccess->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 . ' : ' . stripColors($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('dedimania_playerconnect_cb', $player->login);    
			$this->dedi_db['XmlrpcDB']->addRequest($callback,
			                                 'dedimania.PlayerArrive',
			                                 $aseco->server->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 ($aseco->server->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 . ' : ' . stripColors($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',
			                                 $aseco->server->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('dedimania_newchallenge_cb', 0, $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, $tm_db_n, $challenge) {
	global $aseco, $dedi_db, $dedi_debug,
	       $checkpoints;  // from plugin.checkpoints.php

	// 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 ($aseco->server->getGame() == 'TMF') {
				setRecordsPanel('dedi', ($aseco->server->gameinfo->mode == 4 ?
				                         str_pad($this->dedi_db['Challenge']['Records'][0]['Best'], 5, ' ', STR_PAD_LEFT) :
				                         formatTime($this->dedi_db['Challenge']['Records'][0]['Best'])));
				if (function_exists('update_allrecpanels'))
					update_allrecpanels($aseco, null);  // from plugin.panels.php
			}
		}

		if ($this->dedi_db['ShowRecsBefore'])
			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;  // from plugin.checkpoints.php
$aseco = $this->Aseco;
	// notify records panel
	if ($aseco->server->getGame() == 'TMF') {
		setRecordsPanel('dedi', ($aseco->server->gameinfo->mode == 4 ?
		                         '  ---' : '   --.--'));
	}

	// 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, '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('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'],
				                                 $aseco->server->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'])
				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;
	global $dedi_db, $dedi_debug,
	       $checkpoints;  // from plugin.checkpoints.php

	// if no Dedimania records, bail out immediately - Stunts mode temporarily too
	if (!$this->dedi_db['RecsValid'] || $aseco->server->gameinfo->mode == 4)
		return;

	// in Laps mode on real PlayerFinish event, bail out immediately
	if ($aseco->server->gameinfo->mode == 3 && !$finish_item->new) return;

	// if no actual finish, bail out too
	if ($finish_item->score == 0) return;

	$login = $finish_item->player->login;
	$nickname = stripColors($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],
					                      $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],
						                      $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],
						                      $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],
				                      $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']) {
				// update all panels if new #1 record
				if ($aseco->server->getGame() == 'TMF' && $i == 0) {
					setRecordsPanel('dedi', ($aseco->server->gameinfo->mode == 4 ?
					                         str_pad($finish_item->score, 5, ' ', STR_PAD_LEFT) :
					                         formatTime($finish_item->score)));
					if (function_exists('update_allrecpanels'))
						update_allrecpanels($aseco, null);  // from plugin.panels.php
				}

				// 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 ($aseco->server->getGame() == 'TMF') {
			$aseco->client->query('GetDetailedPlayerInfo', $player->login);
			$info = $aseco->client->getResponse();

			$nation = explode('|', $info['Path']);
			$nation = 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 ($aseco->server->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";
		}
	}
}
$_PLUGIN = new DediMania();
$_PLUGIN->setAuthor("Calsmurf2904\Xymph\Slig");
$_PLUGIN->setVersion(0.1);
$_PLUGIN->addEvent('onSync','dedimania_init');
$_PLUGIN->addEvent('onMainLoop', '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;
?>

i get this error when it try's to update :

Code: Select all

[PHP Warning] call_user_func_array() : First argument is expected to be a valid callback, 'dedimania_newchallenge_cb'
was given on line 282 in file %pathtoasecofolder%\includes\xmlrpc_db.inc.php
does any1 knows how to fix this ?
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