|
From: Alexander H. <ba...@us...> - 2009-04-08 10:15:44
|
Update of /cvsroot/phgstats/phgstats/classes/phgslib/games In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv26406/classes/phgslib/games Added Files: project.class.php Log Message: project:igir support --- NEW FILE: project.class.php --- <?php // Project:IGI2 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 project extends prtcl_gsp { var $portdiff = 0; function _readrules($rules_cache) { $rule_complete = FALSE; $rule_name = ''; $rule_value = ''; $player = 0; $frags = 0; $deaths = 0; $ping = 0; $team = 0; for ($index = 0, $length = strlen($rules_cache); $index < $length; $index++) { if ($rule_complete == FALSE && $rules_cache[$index] != '\\') { $rule_name .= $rules_cache[$index]; } elseif ($rule_complete == FALSE && $rules_cache[$index] == '\\') { $rule_complete = TRUE; } elseif ($rule_complete == TRUE && $rules_cache[$index] != '\\') { $rule_value .= $rules_cache[$index]; } elseif ($rule_complete == TRUE && $rules_cache[$index] == '\\') { // playerdata index is wrong and must be sort if (strstr($rule_name, 'player_')) { $rule_name = substr($rule_name, 0, 7) . $player; $player++; } if (strstr($rule_name, 'frags_')) { $rule_name = substr($rule_name, 0, 6) . $frags; $frags++; } if (strstr($rule_name, 'deaths_')) { $rule_name = substr($rule_name, 0, 7) . $deaths; $deaths++; } if (strstr($rule_name, 'ping_')) { $rule_name = substr($rule_name, 0, 5) . $ping; $ping++; } if (strstr($rule_name, 'team_') && $rule_name != 'team_t0' && $rule_name != 'team_t1') { $rule_name = substr($rule_name, 0, 5) . $team; $team++; } $this->rules[$rule_name] = htmlentities($rule_value); $rule_complete = FALSE; $rule_name = ''; $rule_value = ''; } else { echo "error while sort data stream"; } } } 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->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(); $index2 = 0; // second variable for lose data, if server load a new map $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; // remove html code from player names and set name_clr, ping_clr for ($index = 0; $index != ($this->numplayers); $index++) { if (isset($this->rules["player_$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]['deaths'] = $this->rules["deaths_$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']++; } $index2++; } } // sort players if there some online if ($index2 > 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']); } // create a second numplayers variable, to get only players with data $this->fixedplayers = $index2; } } ?> |