ASECO 2.2.2 and stuff

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

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

Re: ASECO 2.2.2 and stuff

Post by Assembler Maniac » 28 Aug 2009 18:36

SilentStorm wrote:Yeah, after digging through the files that were giving errors (I discovered a bunch more where SQL Queries where flawed) and digging through even more files related to them so I could get a vague picture, I found that it all came down to the tag in rasp.xml that wasnt supposed to be there at all. After removing it, it fixed all the Problems I saw earlier. Rasp couldnt load the configuration properly and thus some values where NULL.

Anyways one thing I noticed during my digging and that still stands is that in plugin.localdb.php you have:

Code: Select all

    $result = mysql_query('SET CHARSET utf8');
    $result = mysql_query('SET NAMES utf8');
at line 70/71. The Method of sending SET NAMES over mysql_query() is depracted. There is a PHP Function for that.
Hadn't gone back to look at mysql functions lately. A lot of the code in ASECO/RASP was written several years ago, there are probably more than a few things that could use updating.

I'm glad it's working for you now.

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

Re: ASECO 2.2.2 and stuff

Post by nocturne » 04 Nov 2009 21:03

Found a little bug in how Aseco v2.3.0b deals with merging in plugin defined authitems, resulting in array_merge errors being thrown.

Aseco.php, line ~531, should be:

Code: Select all

				$this->_new_auth_items = $_PLUGIN->getAuthItems();
plugin.class.php needs a

Code: Select all

  private $_newauthitems;
Problem arises because the plugins are initiated before the admin groups are read, I suppose.

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

Re: ASECO 2.2.2 and stuff

Post by Assembler Maniac » 04 Nov 2009 21:20

nocturne wrote:Found a little bug in how Aseco v2.3.0b deals with merging in plugin defined authitems, resulting in array_merge errors being thrown.

Aseco.php, line ~531, should be:

Code: Select all

				$this->_new_auth_items = $_PLUGIN->getAuthItems();
plugin.class.php needs a

Code: Select all

  private $_newauthitems;
Problem arises because the plugins are initiated before the admin groups are read, I suppose.
Ummm, no, sorry, really, but your theory is flawed.

Line 531 is written correctly. By making your change you'll be overwriting the new auth item list with every new plugin that's loaded, which means only the new items from the last plugin will be considered "new" (if any).

Yes, you're right about the class needing the private var, but there's an assign in the constructor that would add it anyway (probably as public).

Now down to the real problem. Which plugin is throwing errors in the array merge? I suggest you add a print_r to find out exactly what's coming back from the $_PLUGIN->getAuthItems(). It sounds like something is behaving badly and making it not be an array of items.

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

Re: ASECO 2.2.2 and stuff

Post by nocturne » 04 Nov 2009 22:46

Ah, found the problem... failed to add addAuthItem an authitem in a plugin. :oops:

SilentStorm
wheelbarrow operator
wheelbarrow operator
Posts: 19
Joined: 30 Sep 2008 18:37
Owned TM-games: TMUF

Re: ASECO 2.2.2 and stuff

Post by SilentStorm » 02 Feb 2010 22:23

:o not much changed in here apparently.

Anyway I just downloaded the Files linked earlier in this Thread again and put up Aseco only to notice that Aseco crashes if I click the Admin Button in the Bar where it says the Aseco Version.
The Error from the Logs is:

Code: Select all

Fatal error: Cannot pass parameter 1 by reference in /home/tmn/asecotmf_222/plugins/plugin.admin.php on line 89
[02/02,23:03:34] Beginning to shutdown Aseco due to an error ...
If I manually type /admin it works and everything else seems to be working fine aswell.

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

Re: ASECO 2.2.2 and stuff

Post by Assembler Maniac » 02 Feb 2010 22:45

SilentStorm wrote::o not much changed in here apparently.

Anyway I just downloaded the Files linked earlier in this Thread again and put up Aseco only to notice that Aseco crashes if I click the Admin Button in the Bar where it says the Aseco Version.
The Error from the Logs is:

Code: Select all

Fatal error: Cannot pass parameter 1 by reference in /home/tmn/asecotmf_222/plugins/plugin.admin.php on line 89
[02/02,23:03:34] Beginning to shutdown Aseco due to an error ...
Ok, that's kinda strange.

What OS?
What version of PHP are you using?

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

Re: ASECO 2.2.2 and stuff

Post by nocturne » 02 Feb 2010 23:11

That's weird... it should work, looking at the code.

Try to replace the showAdminToPlayer function inside the Admin plugin to:

Code: Select all

	function showAdminToPlayer($player) {
		// simulate a chat command ...
		$command = array('author' => $player, 2 => '/admin');
		$this->Aseco->playerChat($command);
	}
I've had problems before assembling an array as a function parameter, probably reliant on the specific PHP version/configuration I'm using, and breaking it down usually fixes it, but if not try this:

Code: Select all

	function showAdminToPlayer($player) {
		// call the function directly
		$command = array('author' => $player);
		$this->showAdmin($command);
	}
Edit: Come to think of it, it's probably because I have php strict encoding enabled on my resident machine, why I've experienced similar issues... Makes debugging a little easier.

Gekko
speedy pilot
speedy pilot
Posts: 550
Joined: 03 Sep 2006 18:20
Owned TM-games: ALL
Location: Naples - Italy
Contact:

Re: ASECO 2.2.2 and stuff

Post by Gekko » 03 Feb 2010 12:08

Welcome back AM.
Nice to see you at work too.
:lovetm

User avatar
TheM
Pit Crew
Pit Crew
Posts: 286
Joined: 25 Feb 2009 16:43
Owned TM-games: TMU(F), TMN(F), TM2
Location: Brabant, Netherlands
Contact:

Re: ASECO 2.2.2 and stuff

Post by TheM » 05 Feb 2010 21:14

How is developing going? ^^

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

Re: ASECO 2.2.2 and stuff

Post by Assembler Maniac » 05 Feb 2010 21:46

TheM wrote:How is developing going? ^^
A new ver (mostly minor tweaks) should be finished before the next ice age.

User avatar
TheM
Pit Crew
Pit Crew
Posts: 286
Joined: 25 Feb 2009 16:43
Owned TM-games: TMU(F), TMN(F), TM2
Location: Brabant, Netherlands
Contact:

Re: ASECO 2.2.2 and stuff

Post by TheM » 06 Feb 2010 07:48

Assembler Maniac wrote:
TheM wrote:How is developing going? ^^
A new ver (mostly minor tweaks) should be finished before the next ice age.
Ah, okay... keep on going :P

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

Re: ASECO 2.2.2 and stuff

Post by nocturne » 08 Feb 2010 06:51

OOoo.. ooo.. ooo... :o

I have plenty of little tidbits to share, but I'll have to dig through all the code to root them out...

Meanwhile, first and foremost... Using Xaseco's ranking algorithm... Looking at the code I honestly can't see where the improvement is, but we've gone from 3-5+ secs for ranking to just over 1 sec.

rasp/plugin.rasp.php: The old ranking algorithm is commented out... can remove the comment brackets and see exactly the difference between using each algorithm.

Code: Select all

	function resetRanks() {			// edit - nocturne  (shamelessly pilfered from Xaseco...)
		$utime_start = microtime();
		
		$players = array();
		$this->Aseco->console_text('[RASP] ...Calculating ranks');
		$this->getChallenges();
		$tracks = $this->challenges;
		$total = count($tracks);

		// erase old average data
		mysql_query('DELETE FROM rs_rank');

		// get list of players with at least $minrecs records (possibly unranked)
		$query = 'SELECT PlayerId, COUNT(*) AS cnt
		          FROM records
		          GROUP BY PlayerId
		          HAVING cnt >=' . $this->minrank;
		$res = mysql_query($query);
		while ($row = mysql_fetch_object($res)) {
			$players[$row->PlayerId] = array(0, 0);  // sum, count
		}
		mysql_free_result($res);

		// get ranked records for all tracks
		$order = ($this->Aseco->server->gameinfo->mode == 4 ? 'DESC' : 'ASC');
		foreach ($tracks as $track) {
			$query = 'SELECT PlayerId FROM records
			          WHERE ChallengeId=' . $track . '
			          ORDER BY Score ' . $order . ',date ASC
			          LIMIT ' . $this->maxrecs;
			$res = mysql_query($query);
			if (mysql_num_rows($res) > 0) {
				$i = 1;
				while ($row = mysql_fetch_object($res)) {
					$pid = $row->PlayerId;
					if (isset($players[$pid])) {
						$players[$pid][0] += $i;
						$players[$pid][1] ++;
					}
					$i++;
				}
			}
			mysql_free_result($res);
		}

		// compute each player's new average score
		foreach ($players as $player => $ranked) {
			// ranked tracks sum + $maxrecs rank for all remaining tracks
			$avg = ($ranked[0] + ($total - $ranked[1]) * $this->maxrecs) / $total;
			$query = 'INSERT INTO rs_rank (playerID, avg)
			          VALUES (' . $player . ', ' . round($avg * 10000) . ')';
			mysql_query($query);
			if (mysql_affected_rows() != 1) {
				trigger_error('{RASP_ERROR} Could not insert player average! (' . mysql_error() . ')' . CRLF . 'sql = ' . $query, E_USER_WARNING);
			}
		}
	$this->Aseco->console_text('[RASP] ...Done!');
	
		$utime_end = microtime();
			
		list($old_usec, $old_sec) = explode(' ',$utime_start);
		list($new_usec, $new_sec) = explode(' ',$utime_end);
		$old_ut = ((float)$old_usec + (float)$old_sec);
		$new_ut = ((float)$new_usec + (float)$new_sec);
		$utime = ($new_ut - $old_ut) * 1000;
		$this->console('New Ranking method: '. ($utime).'ms');

/*		$utime_start = microtime();			// edit - nocturne (Old Ranking Method)
		$players = array();
		$this->Aseco->console_text('[RASP] ...Calculating ranks');
		$this->getChallenges();

		$cleartable = 'DELETE FROM rs_rank';
		mysql_query($cleartable);
		$tracks = $this->challenges;
		$query = 'SELECT PlayerId, COUNT( * ) AS cnt
					FROM records
					GROUP BY PlayerId
					HAVING cnt >=' . $this->minrank;
		$res = mysql_query($query);
		while ($row = mysql_fetch_object($res)) {
			$players[] = $row->PlayerId;
		}
		mysql_free_result($res);

		foreach ($tracks as $track) {
			$rank = array();
			$query = 'SELECT PlayerId
						FROM records
						WHERE ChallengeId=\'' . $track . '\'
						ORDER BY Score ASC,`Date` ASC';		// added Date sorting, will force results to be consistent with person who got the score first staying first
			$res = mysql_query($query);
			$i = 1;
			if (mysql_num_rows($res) == 0) {
				$trank[$track] = array();
			} else {
				while ($row = mysql_fetch_object($res)) {
					$pid = $row->PlayerId;
					$trank[$track][$pid] = $i;
					$i++;
				}
			}
			mysql_free_result($res);
		}

		foreach ($players as $player) {
			$exists = false;
			$query = 'SELECT playerID FROM rs_rank WHERE playerID=\'' . $player . '\'';
			$res = mysql_query($query);
			if (mysql_num_rows($res) > 0){
				$exists = true;
			}
			$rank = array();
			foreach ($tracks as $cur) {
				if (array_key_exists($player, $trank[$cur])) {
					if ($trank[$cur][$player] > $this->maxrecs) {
						$rank[$cur] = $this->maxrecs;
					} else {
						$rank[$cur] = $trank[$cur][$player];
					}
				} else {
					$rank[$cur] = $this->maxrecs;
				}
			}
			$avg = array_sum($rank) / sizeof($tracks);
			$avg = floor(round($avg, 4)*10000);		// Mistral says this fixes the bouncing bug (older mysql doesn't handle floats quite right)
			if ($exists == true) {
				$query = 'UPDATE rs_rank SET avg=' . $avg . ' WHERE playerID=\'' . $player . '\'';
				$res2 = mysql_query($query);
			} else {
				$query = 'INSERT INTO rs_rank(playerID, avg) VALUES (\'' . $player . '\', ' . $avg . ')';
				$res2 = mysql_query($query);
				if (mysql_affected_rows() != 1) {
					$errmsg = '[RASP Error] Failed to insert into rs_rank playerid=' . $player . ' error text=' . mysql_error() . CRLF . 'sql=' . $query;
					$this->Aseco->console_text($errmsg);
				}
			}
			mysql_free_result($res);
		}
	$this->Aseco->console_text('[RASP] ...Done!');
	
		$utime_end = microtime();			// edit - nocturne
			
		list($old_usec, $old_sec) = explode(' ',$utime_start);
		list($new_usec, $new_sec) = explode(' ',$utime_end);
		$old_ut = ((float)$old_usec + (float)$old_sec);
		$new_ut = ((float)$new_usec + (float)$new_sec);
		$utime = ($new_ut - $old_ut) * 1000;
		$this->console('Old Ranking method: '. ($utime).'ms');
*/	
	}

Xymph
Pit Crew
Pit Crew
Posts: 5654
Joined: 19 Aug 2007 12:58
Owned TM-games: TMN, TMU, TMF, TM²
Contact:

Re: ASECO 2.2.2 and stuff

Post by Xymph » 08 Feb 2010 08:29

nocturne wrote:Meanwhile, first and foremost... Using Xaseco's ranking algorithm... Looking at the code I honestly can't see where the improvement is, but we've gone from 3-5+ secs for ranking to just over 1 sec.
Yup, it makes a big difference. I wrote it for v1.04 a year and a half ago, and it's basically a classic trade-off between memory (storing more intermediate data in $players) and code (the old algorithm needs an extra database loop), plus a smarter computation of the rank values themselves and the way unranked tracks are taken into account.
Developer of XASECO for TMF/TMN ESWC & XASECO2 for TM²: see XAseco.org
Find your way around the Mania community from the TMN ESWC hub, TMF hub, TM² hub, and SM hub

SilentStorm
wheelbarrow operator
wheelbarrow operator
Posts: 19
Joined: 30 Sep 2008 18:37
Owned TM-games: TMUF

Re: ASECO 2.2.2 and stuff

Post by SilentStorm » 01 Mar 2010 20:55

While talking about Memory Usage of Aseco... Mine keeps shutting down every few days due to more than 32MiB of Memory used. I have to start it again which leaves it running just fine until it crashes again due to too much memory used. Any Ideas?

OS is Debian 4 btw and PHP is 5.2.0

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: ASECO 2.2.2 and stuff

Post by oliverde8 » 01 Mar 2010 21:54

YOu can use this ,sh. It will restart Aseco when it crashes.

Code: Select all

while true
do
        php aseco.php TMU </dev/null >aseco.log 2>&1 &
        wait
        sleep 5
done
When my servers are full I have more then a Crash a day. I am obliged to use a code that restarts Aseco when it crashes
ImageImage
Manialink : oliverde8color>
Servers : STATS <> United | VeryShort | Made In Turkey

Post Reply