00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
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
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 }