|
From: Alexander H. <ba...@us...> - 2009-04-08 08:19:54
|
Update of /cvsroot/phgstats/phgstats/classes/phgslib/games In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30955/classes/phgslib/games Modified Files: nolf2.class.php Added Files: postal2.class.php Log Message: postal2 support --- NEW FILE: postal2.class.php --- <?php // postal2 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 postal2 extends prtcl_gsp { var $portdiff = 1; function getinfo() { if ($this->_getStream()) { // set rules vars $this->hostname = $this->rules['hostname']; $this->hostname_clr = $this->rules['hostname']; $this->gametype = $this->rules['gametype']; $this->gameversion = $this->rules['gamever']; $this->mapname = $this->rules['mapname']; $this->numplayers = $this->rules['numplayers']; $this->maxplayers = $this->rules['maxplayers']; $this->needpass = isset($this->rules['password']) ? $this->rules['password'] : 0; // 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['team_score1'] = 0; $this->rules['team_score2'] = 0; $this->rules['team_ping1'] = 0; $this->rules['team_ping2'] = 0; // scan team names; for ($index = 0; $index != $this->numplayers; $index++) { if ($index == 0 && isset($this->rules["team_$index"])) { $this->rules['team_name1'] = $this->rules["team_$index"]; } if ($index != 0 && $this->rules['team_name1'] != $this->rules["team_$index"] && isset($this->rules['team_name2']) == FALSE) { $this->rules['team_name2'] = $this->rules["team_$index"]; break; } } // 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]['team'] = $this->rules["team_$index"]; $this->players[$index]['character'] = $this->rules["character_$index"]; $this->players[$index]['ngsecret'] = $this->rules["ngsecret_$index"]; // create a team score variable if ($this->players[$index]['team'] == $this->rules['team_name1']) { $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'] == $this->rules['team_name2']) { $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']++; } } // 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']); } } } ?> Index: nolf2.class.php =================================================================== RCS file: /cvsroot/phgstats/phgstats/classes/phgslib/games/nolf2.class.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** nolf2.class.php 7 Apr 2009 17:29:21 -0000 1.1 --- nolf2.class.php 8 Apr 2009 08:19:36 -0000 1.2 *************** *** 1,3 **** ! <?php // NOLF2 extended class /* * Copyright (c) 2004-2009, woah-projekt.de --- 1,3 ---- ! <?php // No One Live Forever 2 extended class /* * Copyright (c) 2004-2009, woah-projekt.de |