Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

lib/worldmap.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  This program is free software; you can redistribute it and/or
00004  modify it under the terms of the GNU General Public License
00005  as published by the Free Software Foundation; either version 2
00006  of the License, or (at your option) any later version.
00007 
00008  This program is distributed in the hope that it will be useful,
00009  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  GNU General Public License for more details.
00012 
00013  You should have received a copy of the GNU General Public License
00014  along with this program; if not, write to the Free Software
00015  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00016  ***************************************************************************/
00017 
00029 class WorldMap
00030 {
00031     var $oDB;   
00032     var $oUser; 
00033 
00040     function WorldMap( &$oDB, &$oUser )
00041     {
00042         $this->oDB =& $oDB;
00043         $this->oUser =& $oUser;
00044     }
00045 
00054     function getTowns( $intFields = 1, $intZoom = 1, $intX = 0, $intY = 0, $strFilter = '' )
00055     {
00056         global $intMapSize;
00057         if( $strFilter != '' )
00058         {
00059             $strFilter = ' AND g.`guild_id` IN ('.str_replace('_', ',', substr($strFilter, 1)).')';
00060         }
00061 
00062         $intMinX    = $intX * $intFields;
00063         $intMinY    = $intY * $intFields;
00064         $intMaxX    = ($intX+1) * $intFields;
00065         $intMaxY    = ($intY+1) * $intFields;
00066 
00067         if( $this->oUser->intLimitView > 0 )
00068         {
00069             // user has not full view
00070             $strFilter .= ' AND t.x BETWEEN '.( $this->oUser->intHomeX - $this->oUser->intLimitView).' AND '.($this->oUser->intHomeX + $this->oUser->intLimitView);
00071             $strFilter .= ' AND t.y BETWEEN '.( $this->oUser->intHomeY - $this->oUser->intLimitView).' AND '.($this->oUser->intHomeY + $this->oUser->intLimitView);
00072         }
00073 
00074         // Stadtdaten
00075         $result = $this->oDB->query("SELECT p.`name`, p.typ, p.race, g.`tag`, g.`bgcolor`, g.`diplomacy`, t.`x`, t.`y`, m.building ".
00076                           "FROM `".$this->oDB->tblTown."` t ".
00077                           "LEFT JOIN `".$this->oDB->tblMapData."` m ON (t.x=m.x AND t.y=m.y) ".
00078                           "LEFT JOIN `".$this->oDB->tblPlayer."` p ON (t.`player_id`=p.`player_id`) ".
00079                           "LEFT JOIN `".$this->oDB->tblGuild."` g ON (g.`guild_id`=p.`guild_id`) ".
00080                           "WHERE `t`.`x` BETWEEN '$intMinX' AND '$intMaxX' AND `t`.`y` BETWEEN '$intMinY' AND '$intMaxY' AND t.`player_id`>'0' AND m.`building` > '-10' $strFilter;");
00081 
00082         $aReturn = array();
00083         while( $aRow = $this->oDB->fetch_assoc($result) )
00084         {
00085             $aReturn[] = $aRow;
00086         }
00087         return $aReturn;
00088     }
00089 
00093     function getGuilds()
00094     {
00095         $sqlResult = $this->oDB->query( "SELECT `tag`, `guild_id` FROM `".$this->oDB->tblGuild."` ORDER BY `tag`;");
00096         $aReturn = array();
00097         while( $aRow = $this->oDB->fetch_assoc() )
00098         {
00099             $aReturn[] = $aRow;
00100         }
00101         return $aReturn;
00102     }
00103 }

Generated on Sun May 8 19:29:45 2005 for PhpMap by  doxygen 1.4.2