|
From: Alexander H. <ba...@us...> - 2009-04-08 16:12:37
|
Update of /cvsroot/phgstats/phgstats/classes/phgslib/games In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1664/classes/phgslib/games Added Files: ut.class.php Log Message: unreal tournament support --- NEW FILE: ut.class.php --- <?php // Unreal Tournament extended class /* * Copyright (c) 2004-2009, woah-projekt.de * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * Neither the name of the phgstats project (woah-projekt.de) * nor the names of its contributors may be used to endorse or * promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ class ut extends prtcl_gsp { function getinfo() { if ($this->_getStream()) { // set rule vars $this->hostname = $this->rules['hostname']; $this->hostname_clr = $this->rules['hostname']; $this->gametype = $this->rules['gametype']; $this->gamename = $this->rules['gamename']; $this->gameversion = $this->rules['gamever']; $this->mapname = $this->rules['mapname']; $this->numplayers = $this->rules['numplayers']; $this->maxplayers = $this->rules['maxplayers']; $this->password = $this->rules['password']; // set map picture & path $this->_getmappic(); // set players $this->_getPlayers(); return TRUE; } else { return FALSE; } } function _getplayers() { $players = array(); $this->rules['team1'] = 0; $this->rules['team2'] = 0; $this->rules['team3'] = 0; $this->rules['team_score1'] = 0; $this->rules['team_score2'] = 0; $this->rules['team_score3'] = 0; $this->rules['team_ping1'] = 0; $this->rules['team_ping2'] = 0; $this->rules['team_ping3'] = 0; // remove html code from player names and set name_clr, ping_clr for ($index = 0; $index != $this->numplayers; $index++) { $this->players[$index]['name'] = $this->rules["player_$index"]; $this->players[$index]['name_clr'] = $this->players[$index]['name']; $this->players[$index]['score'] = $this->rules["frags_$index"]; $this->players[$index]['ping'] = $this->rules["ping_$index"]; //$this->players[$index]['ping_clr'] = $this->_check_color($this->players[$index]['ping'], 2); $this->players[$index]['ngsecret'] = isset($this->rules["ngsecret_$index"]) ? $this->rules["ngsecret_$index"] : 0; $this->players[$index]['skin'] = isset($this->rules["skin_$index"]) ? $this->rules["skin_$index"] : 0; $this->players[$index]['mesh'] = $this->rules["mesh_$index"]; $this->players[$index]['team'] = $this->rules["team_$index"]; // create a team score variable if ($this->players[$index]['team'] == '0') { $this->rules['team_score1'] = $this->rules['team_score1'] + $this->players[$index]['score']; $this->rules['team_ping1'] = $this->rules['team_ping1'] + $this->players[$index]['ping']; $this->rules['team1']++; } if ($this->players[$index]['team'] == '1') { $this->rules['team_score2'] = $this->rules['team_score2'] + $this->players[$index]['score']; $this->rules['team_ping2'] = $this->rules['team_ping2'] + $this->players[$index]['ping']; $this->rules['team2']++; } if ($this->players[$index]['team'] == '255') { $this->rules['team_score3'] = $this->rules['team_score3'] + $this->players[$index]['score']; $this->rules['team_ping3'] = $this->rules['team_ping3'] + $this->players[$index]['ping']; $this->rules['team3']++; } } // sort players if there some online if ($index > 0) { $this->_sortplayers(); } // get avarage ping of teams if available if ($this->rules['team_score1'] != 0) { $this->rules['team_ping1'] = sprintf("%3.0f", $this->rules['team_ping1'] / $this->rules['team1']); } if ($this->rules['team_score2'] != 0) { $this->rules['team_ping2'] = sprintf("%3.0f", $this->rules['team_ping2'] / $this->rules['team2']); } if ($this->rules['team_score3'] != 0) { $this->rules['team_ping3'] = sprintf("%3.0f", $this->rules['team_ping3'] / $this->rules['team3']); } } } ?> |