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

lib/map.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 
00024 class Map
00025 {
00026     var $oDB;           
00027     var $oUser;         
00028     var $aTerrainColor;
00029     var $aTerrainText;
00030     var $aTerrainPoints;
00031     var $aBuildingText;
00032     var $aBuildingKeys;
00033     var $aColor;
00034 
00035 
00036     var $intZoom;           
00037     var $intFieldWidth;     
00038     var $intFieldHeight;    
00039     var $booShowFog;        
00040     var $x,$y,$xx,$yy,$xs,$ys,$xe,$ye,$xx0,$yy0,$xx1,$yy1; 
00041 
00048     function Map( &$oDB, $oUser )
00049     {
00050         global $aTerrainColor, $aTerrainText, $aTerrainPoints, $aBuildingText, $aBuildingKeys, $aColor;
00051         $this->oDB =& $oDB;
00052         $this->oUser =& $oUser;
00053         $this->aTerrainColor  =& $aTerrainColor;
00054         $this->aTerrainText   =& $aTerrainText;
00055         $this->aTerrainPoints =& $aTerrainPoints;
00056         $this->aBuildingText  =& $aBuildingText;
00057         $this->aBuildingKeys  =& $aBuildingKeys;
00058         $this->aColor =& $aColor;
00059 
00060 
00061         // get variables
00062         $this->intZoom = isset( $_GET['zoom'] ) ? intval( $_GET['zoom'] ) : $this->oUser->intZoom;
00063         // Einstellung der Feldgröße
00064         $aZoomstufen = array( 4, 6, 8, 10, 12, 14, 18 );
00065         if( !isset( $aZoomstufen[$this->intZoom] ) )
00066         {
00067             // zoom is not available, get default zoom
00068             $this->intZoom = 12;
00069         }
00070         else
00071         {
00072             $this->intZoom = $aZoomstufen[$this->intZoom];
00073         }
00074         $this->intFieldWidth  = $this->intZoom;
00075         $this->intFieldHeight = $this->intZoom;
00076 
00077         $this->x = isset( $_GET['x'] ) ? intval( $_GET['x'] ) : $this->oUser->intLastX;
00078         $this->y = isset( $_GET['y'] ) ? intval( $_GET['y'] ) : $this->oUser->intLastY;
00079 
00080         $this->xx = ( isset( $_GET['xx'] ) ) ? intval( $_GET['xx'] )
00081                                         : intval( $this->oUser->intSizeX / ($this->intFieldWidth+1) );
00082 
00083         $this->yy = ( isset( $_GET['yy'] ) ) ? intval( $_GET['yy'] )
00084                                         : intval( $this->oUser->intSizeY / ($this->intFieldHeight+1) );
00085 
00086         $this->booShowFog = intval( (bool)( isset( $_GET['show_fog'] ) ? $_GET['show_fog'] : $this->oUser->intFog ) );
00087 
00088         // waycalc vars
00089         $this->xs = isset( $_GET['xs'] ) ? intval( $_GET['xs'] ) : -1;
00090         $this->ys = isset( $_GET['ys'] ) ? intval( $_GET['ys'] ) : -1;
00091         $this->xe = isset( $_GET['xe'] ) ? intval( $_GET['xe'] ) : -1;
00092         $this->ye = isset( $_GET['ye'] ) ? intval( $_GET['ye'] ) : -1;
00093 
00094         // Berechne Kartenstart und Endpunkt, aufgrund der Zentralen Koordinaten
00095         $this->xx0 = intval( $this->x - div($this->xx, 2) ); // <- top left
00096         $this->yy0 = intval( $this->y - div($this->yy, 2) );
00097         $this->xx1 = intval( $this->xx0 + $this->xx -1 );
00098         $this->yy1 = intval( $this->yy0 + $this->yy -1 ); // <- bottom right
00099 
00100         // adjust too small coords
00101         if( $this->xx0 < 1 )
00102         {
00103             $this->x -= ($this->xx0 - 1);
00104             $this->xx1 -= ($this->xx0 - 1);
00105             $this->xx0 = 1;
00106         }
00107         if( $this->yy0 < 1 )
00108         {
00109             $this->y -= ($this->yy0 - 1);
00110             $this->yy1 -= ($this->yy0 - 1);
00111             $this->yy0 = 1;
00112         }
00113 
00114         // adjust too big coords
00115         if( $this->xx1 > $GLOBALS['intMapSize'] )
00116         {
00117             $this->xx0 += ($GLOBALS['intMapSize'] - $this->xx1);
00118             $this->xx1 = $GLOBALS['intMapSize'];
00119         }
00120         if( $this->yy1 > $GLOBALS['intMapSize'] )
00121         {
00122             $this->yy0 += ($GLOBALS['intMapSize'] - $this->yy1);
00123             $this->yy1 = $GLOBALS['intMapSize'];
00124         }
00125     }
00126 
00130     function getPaletteColor( $im, $color )
00131     {
00132         $r = ($color & 0xff0000) >> 16;
00133         $g = ($color & 0x00ff00) >> 8;
00134         $b = ($color & 0x0000ff);
00135         return imagecolorallocate($im, $r, $g, $b);
00136     }
00137 
00138 
00155     function getImg( $strEffort='', $strWaytext='' )
00156     {
00157         $intX =& $this->x;
00158         $intY =& $this->y;
00159         $intXX =& $this->xx;
00160         $intYY =& $this->yy;
00161         $booShowFog =& $this->booShowFog;
00162         $intZoom =& $this->intZoom;
00163         $intXs =& $this->xs;
00164         $intYs =& $this->ys;
00165 
00166         $xx0 =& $this->xx0;
00167         $yy0 =& $this->yy0;
00168         $xx1 =& $this->xx1;
00169         $yy1 =& $this->yy1;
00170 
00171         $intFieldWidth  =& $this->intFieldWidth;
00172         $intFieldHeight =& $this->intFieldHeight;
00173 
00174         // try to disable memory limit
00175         @ini_set('memory_limit', '-1');
00176 
00177         //Straßen Einstellung
00178         $strasse_x = $intFieldWidth/2 - 1;
00179         $strasse_y = $intFieldHeight/2 - 1;
00180 
00181         // create graphic
00182         $img = @imagecreate($intXX * $intFieldWidth + $intXX + 1, $intYY * $intFieldHeight + $intYY + 1)
00183                         or die('Cannot Initialize new GD image stream');
00184 
00185         // Graphik für Fow laden
00186         $fow = imagecreate($intFieldWidth+2, $intFieldHeight+2);
00187         ImageFilledRectangle($fow, 0, 0, $intFieldWidth+2, $intFieldHeight+2, $this->getPaletteColor($fow, $this->aColor['fog']));
00188 
00189         // make druidhort image
00190         $druid = imagecreate( 1, 1 );
00191         ImageFilledRectangle($druid, 0, 0, $intFieldWidth+2, $intFieldHeight+2, $this->getPaletteColor($druid, $this->aColor['druid']));
00192 
00193 
00194         // palettenfarben erzeugen
00195         $this->aColor['black']    = $this->getPaletteColor($img, 0x000000);
00196         $this->aColor['strasse']  = $this->getPaletteColor($img, $this->aColor['strasse']);
00197         $this->aColor['grenze']   = $this->getPaletteColor($img, $this->aColor['grenze']);
00198         $this->aColor['e_grenze'] = $this->getPaletteColor($img, $this->aColor['e_grenze']);
00199         $this->aColor['stadt']    = $this->getPaletteColor($img, $this->aColor['stadt']);
00200         $this->aColor['stadt2']   = $this->getPaletteColor($img, $this->aColor['stadt2']);
00201         $this->aColor['stadt3']   = $this->getPaletteColor($img, $this->aColor['stadt3']);
00202         $this->aColor['dorf']     = $this->getPaletteColor($img, $this->aColor['dorf']);
00203         $this->aColor['dorf2']     = $this->getPaletteColor($img, $this->aColor['dorf2']);
00204         $this->aColor['wachturm'] = $this->getPaletteColor($img, $this->aColor['wachturm']);
00205         $this->aColor['fog']      = $this->getPaletteColor($img, $this->aColor['fog']);
00206         $this->aColor['einheit']  = $this->getPaletteColor($img, $this->aColor['einheit']);
00207         $this->aColor['text1']    = $this->getPaletteColor($img, $this->aColor['text1']);
00208         $this->aColor['text2']    = $this->getPaletteColor($img, $this->aColor['text2']);
00209         $this->aColor['path']     = $this->getPaletteColor($img, $this->aColor['path']);
00210         $this->aColor['druid']    = $this->getPaletteColor($img, $this->aColor['druid']);
00211         $this->aColor['dborder']  = $this->getPaletteColor($img, $this->aColor['dborder']);
00212         $intFogPercent = 60;
00213 
00214         if( $intFieldWidth >= 17 && $GLOBALS['booDetailedMap'] )
00215         {
00216             $intFogPercent = 50;
00217             $aTerrainImages = array(
00218                 0 => imagecreatefrompng("img/r0.png"),
00219                 1 => imagecreatefrompng("img/r1.png"),
00220                 2 => imagecreatefrompng("img/r2.png"),
00221                 3 => imagecreatefrompng("img/r3.png"),
00222                 4 => imagecreatefrompng("img/r4.png"),
00223                 5 => imagecreatefrompng("img/r5.png"),
00224                 6 => imagecreatefrompng("img/r6.png"),
00225                 7 => imagecreatefrompng("img/r7.png"),
00226                 8 => imagecreatefrompng("img/r8.png"),
00227                 9 => imagecreatefrompng("img/r9.png"));
00228         }
00229         elseif( $intFieldWidth >= 13 && $GLOBALS['booDetailedMap'] )
00230         {
00231             $intFogPercent = 50;
00232             $aTerrainImages = array(
00233                 0 => imagecreatefrompng("img/s0.png"),
00234                 1 => imagecreatefrompng("img/s1.png"),
00235                 2 => imagecreatefrompng("img/s2.png"),
00236                 3 => imagecreatefrompng("img/s3.png"),
00237                 4 => imagecreatefrompng("img/s4.png"),
00238                 5 => imagecreatefrompng("img/s5.png"),
00239                 6 => imagecreatefrompng("img/s6.png"),
00240                 7 => imagecreatefrompng("img/s7.png"),
00241                 8 => imagecreatefrompng("img/s8.png"),
00242                 9 => imagecreatefrompng("img/s9.png"));
00243         }
00244         elseif( $intFieldWidth >= 11 && $GLOBALS['booDetailedMap'] )
00245         {
00246             $intFogPercent = 50;
00247             $aTerrainImages = array(
00248                 0 => imagecreatefrompng("img/t0.png"),
00249                 1 => imagecreatefrompng("img/t1.png"),
00250                 2 => imagecreatefrompng("img/t2.png"),
00251                 3 => imagecreatefrompng("img/t3.png"),
00252                 4 => imagecreatefrompng("img/t4.png"),
00253                 5 => imagecreatefrompng("img/t5.png"),
00254                 6 => imagecreatefrompng("img/t6.png"),
00255                 7 => imagecreatefrompng("img/t7.png"),
00256                 8 => imagecreatefrompng("img/t8.png"),
00257                 9 => imagecreatefrompng("img/t9.png"));
00258         }
00259 
00260         for( $i=0; $i < 10; $i++ )
00261         {
00262             $this->aTerrainColor[$i] = $this->getPaletteColor($img, $this->aTerrainColor[$i]);
00263         }
00264 
00265         ImageFilledRectangle($img, 0, 0, $intXX * $intFieldWidth + $intXX + $intFieldWidth + 1, $intYY * $intFieldHeight + $intYY + $intFieldHeight + 1, $this->aColor['black']);
00266 
00267         $empty_field = array(
00268                'terrain'  => 0,
00269                'fow'      => 1,
00270                'border'   => 0,
00271                'building' => 0,
00272                'street'   => 0,
00273                'unit'     => 0 );
00274 
00275         $strFilter = '';
00276         if( $this->oUser->intLimitView > 0 )
00277         {
00278             // user has not full view
00279             $strFilter .= ' AND m.x BETWEEN '.( $this->oUser->intHomeX - $this->oUser->intLimitView).' AND '.($this->oUser->intHomeX + $this->oUser->intLimitView);
00280             $strFilter .= ' AND m.y BETWEEN '.( $this->oUser->intHomeY - $this->oUser->intLimitView).' AND '.($this->oUser->intHomeY + $this->oUser->intLimitView);
00281         }
00282 
00283         $result = $this->oDB->query("SELECT * ".
00284                                     "FROM ".$this->oDB->tblMapData." m ".
00285                                     "WHERE x BETWEEN ".$xx0." AND ".$xx1." AND y BETWEEN ".$yy0." AND ".$yy1.$strFilter);
00286 
00287         //Schreibe Karteninfos in Array
00288         $mapdata = array();
00289         while($aRow = $this->oDB->fetch_assoc($result))
00290         {
00291             $mapdata[$aRow['x']][$aRow['y']] = $aRow;
00292         }
00293 
00294         // get terrain
00295         $result = $this->oDB->query("SELECT * ".
00296                                     "FROM ".$this->oDB->tblMap." m ".
00297                                     "WHERE x BETWEEN ".$xx0." AND ".$xx1." AND y BETWEEN ".$yy0." AND ".$yy1.$strFilter);
00298 
00299         //Schreibe Karteninfos in Array
00300         while($aRow = $this->oDB->fetch_assoc($result))
00301         {
00302             if( !isset( $mapdata[$aRow['x']][$aRow['y']] ) )
00303             {
00304                 $mapdata[$aRow['x']][$aRow['y']] = $empty_field;
00305             }
00306             $mapdata[$aRow['x']][$aRow['y']]['terrain'] = $aRow['terrain'];
00307         }
00308 
00309         $intFieldHeight_p1 = $intFieldHeight + 1;
00310         $intFieldWidth_p1  = $intFieldWidth  + 1;
00311         $intFieldHeight_d2 = $intFieldHeight / 2;
00312         $intFieldWidth_d2  = $intFieldWidth  / 2;
00313         for( $x = $xx0; $x <= $xx1; $x++ )
00314         {
00315             for( $y = $yy0; $y <= $yy1; $y++ )
00316             {
00317                 $px_top    = ($y - $yy0) * ($intFieldHeight_p1) + 1;
00318                 $px_left   = ($x - $xx0) * ($intFieldWidth_p1)  + 1;
00319                 $px_right  = ($x - $xx0) * ($intFieldWidth_p1)  + $intFieldWidth; //  * 2;
00320                 $px_bottom = ($y - $yy0) * ($intFieldHeight_p1) + $intFieldHeight; // * 2;
00321                 $field     = isset($mapdata[$x][$y]) ? $mapdata[$x][$y] : $empty_field;
00322 
00323                 if( $intFieldWidth >= 17 && $GLOBALS['booDetailedMap'] )
00324                 {
00325                     ImageCopy( $img, $aTerrainImages[$field['terrain']], $px_left, $px_top, 0, 0, 18, 18 );
00326                 }
00327                 elseif( $intFieldWidth >= 14 && $GLOBALS['booDetailedMap'] )
00328                 {
00329                     ImageCopy( $img, $aTerrainImages[$field['terrain']], $px_left, $px_top, 0, 0, 14, 14 );
00330                 }
00331                 elseif( $intFieldWidth >= 11 && $GLOBALS['booDetailedMap'] )
00332                 {
00333                     ImageCopy( $img, $aTerrainImages[$field['terrain']], $px_left, $px_top, 0, 0, 12, 12 );
00334                 }
00335                 else
00336                 {
00337                     if( !isset( $this->aTerrainColor[$field['terrain']] ) )
00338                     {
00339                         $field['terrain'] = 0;
00340                     }
00341                     ImageFilledRectangle( $img, $px_left, $px_top, $px_right, $px_bottom, $this->aTerrainColor[$field['terrain']] );
00342                 }
00343 
00344                 // --------------------------------------------
00345                 // Strassen nur zeichnen, wenn kein Wasser oder Berg
00346                 if( $field['street'] != 0 )
00347                 {
00348                     // Strasse oben
00349                     if($field['street'] & 1)
00350                     {
00351                         ImageFilledRectangle($img, $px_left+$strasse_x, $px_top-1, $px_right-$strasse_x, $px_bottom-$strasse_y, $this->aColor['strasse']);
00352                     }
00353                     // Strasse rechts
00354                     if($field['street'] & 4)
00355                     {
00356                         ImageFilledRectangle($img, $px_left+$strasse_x, $px_top+$strasse_y,$px_right+1, $px_bottom-$strasse_y, $this->aColor['strasse']);
00357                     }
00358                     // Strasse unten
00359                     if($field['street'] & 16)
00360                     {
00361                         ImageFilledRectangle($img, $px_left+$strasse_x, $px_top+$strasse_y,$px_right-$strasse_x, $px_bottom+1, $this->aColor['strasse']);
00362                     }
00363                     // Strasse links
00364                     if($field['street'] & 64)
00365                     {
00366                         ImageFilledRectangle($img, $px_left-1, $px_top+$strasse_y,$px_right-$strasse_x, $px_bottom-$strasse_y, $this->aColor['strasse']);
00367                     }
00368                 }
00369 
00370                 // --------------------------------------------
00371                 // Border
00372                 if( $field['border']!=0 )
00373                 {
00374                     // Grenzfarbe
00375                     $color = ( $field['border'] &  16 ) ? $this->aColor['e_grenze'] : $this->aColor['grenze'];
00376 
00377                     // Grenze oben
00378                     if( $field['border'] &  1 )
00379                     {
00380                         ImageLine($img, $px_left-1, $px_top,   $px_right+1, $px_top,  $color);
00381                         ImageLine($img, $px_left-1, $px_top-1, $px_right+1, $px_top-1,$color);
00382                     }
00383 
00384                     // Grenze rechts
00385                     if($field['border'] &  2)
00386                     {
00387                         ImageLine($img, $px_right,   $px_top-1, $px_right,   $px_bottom+1, $color);
00388                         ImageLine($img, $px_right+1, $px_top-1, $px_right+1, $px_bottom+1, $color);
00389                     }
00390 
00391                     // Grenze unten
00392                     if($field['border'] &  4)
00393                     {
00394                         ImageLine($img, $px_left-1, $px_bottom,   $px_right+1, $px_bottom, $color);
00395                         ImageLine($img, $px_left-1, $px_bottom+1, $px_right+1, $px_bottom+1, $color);
00396                     }
00397 
00398                     // Grenze links
00399                     if($field['border'] &  8)
00400                     {
00401                         ImageLine($img, $px_left,   $px_top-1, $px_left,   $px_bottom+1, $color);
00402                         ImageLine($img, $px_left-1, $px_top-1, $px_left-1, $px_bottom+1, $color);
00403                     }
00404 
00405                 }
00406 
00407                 // --------------------------------------------
00408                 // Fog of War
00409                 if($field['fow'] && $booShowFog)
00410                 {
00411                     ImageCopyMerge($img, $fow, $px_left-1, $px_top-1, 0, 0, $intFieldWidth_p1, $intFieldHeight_p1, $intFogPercent );
00412                 }
00413 
00414                 // --------------------------------------------
00415                 // Gebäude zeichnen
00416                 if( $field['building'] == -11 )
00417                 {
00418                     // geplantes Dorf
00419                     ImageFilledEllipse( $img, $px_left+floor($intFieldWidth/2), $px_top+floor($intFieldWidth/2), $intFieldWidth-1, $intFieldHeight-1, $this->aColor['dorf2'] );
00420                 }
00421                 elseif( $field['building'] == -2 )
00422                 {
00423                     // Stadt Dummy
00424                     ImageFilledRectangle($img, $px_left+1, $px_top+1, $px_right-1, $px_bottom-1, $this->aColor['stadt3']);
00425                 }
00426                 elseif( $field['building'] == -1 )
00427                 {
00428                     // Stadt Dummy
00429                     ImageFilledRectangle($img, $px_left+1, $px_top+1, $px_right-1, $px_bottom-1, $this->aColor['stadt2']);
00430                 }
00431                 elseif( isset( $GLOBALS['aTowns'][$field['building']] ) )
00432                 {
00433                     // Stadt
00434                     ImageFilledRectangle($img, $px_left+1, $px_top+1,$px_right-1, $px_bottom-1, $this->aColor['stadt']);
00435                 }
00436                 elseif( $field['building'] >= 93 && $field['building'] <= 96 )
00437                 {
00438                     // Dorf
00439                     ImageFilledRectangle($img, $px_left+3, $px_top+3, $px_right-3,$px_bottom-3, $this->aColor['dorf']);
00440                 }
00441                 elseif( $field['building'] >= 85 && $field['building'] < 92 )
00442                 {
00443                     // Aussenposten / Grenzwachturm
00444                     ImageFilledEllipse($img, $px_left+($intFieldWidth_d2),$px_top+($intFieldHeight_d2), 7, 7, $this->aColor['wachturm']);
00445                 }
00446 
00447                 // --------------------------------------------
00448                 // Units
00449                 if($field['unit'] > 0)
00450                 {
00451                     //Zeitpunkt der Anzeige (Sekunden seit 0:00:00 January 1, 1970 GMT)
00452                     $show_time = time();
00453                     //Zeitpunkt des Imports (Sekunden seit 0:00:00 January 1, 1970 GMT)
00454                     $import_time = $field['last_update'];
00455 
00456                     //Abstand zwischen Import und Anzeige in Sekunden
00457                     $time_gone = $show_time - $import_time;
00458 
00459                     //Erlaubter Zeit-Abstand
00460                     $time_allowed = $this->oUser->intUnit*60*60;
00461 
00462                     if($time_gone <= $time_allowed)
00463                     {
00464                         ImageFilledEllipse($img, $px_left+($intFieldWidth/2), $px_top+($intFieldHeight/2), 5, 5, $this->aColor['einheit']);
00465                     }
00466                 }
00467 
00468             } // end for y
00469         } // end for x
00470 
00471         // Zeichne Wegpunkte
00472         if( $intXs>0 && $intYs>0 && $strWaytext!='' )
00473         {
00474             $pathx = $intXs;
00475             $pathy = $intYs;
00476             $path  = preg_split( "//", $strWaytext );
00477 
00478             $px2 = (($pathx - $xx0) * ($intFieldWidth_p1))  + ($intFieldWidth/2);
00479             $py2 = (($pathy - $yy0) * ($intFieldHeight_p1)) + ($intFieldHeight/2);
00480             $px1 = $px2;
00481             $py1 = $py2;
00482 
00483             ImageFilledEllipse($img, $px2, $py2, 5, 5, $this->aColor['path']);
00484 
00485             foreach($path as $p)
00486             {
00487                 if($p==1 || $p==2 || $p==3) $pathy++;
00488                 if($p==1 || $p==4 || $p==7) $pathx--;
00489                 if($p==9 || $p==6 || $p==3) $pathx++;
00490                 if($p==7 || $p==8 || $p==9) $pathy--;
00491 
00492                 $px2 = (($pathx - $xx0) * ($intFieldWidth_p1))  + ($intFieldWidth/2);
00493                 $py2 = (($pathy - $yy0) * ($intFieldHeight_p1)) + ($intFieldHeight/2);
00494 
00495                 ImageFilledEllipse($img, $px2, $py2, 5, 5, $this->aColor['path']);
00496                 ImageLine($img, $px1, $py1, $px2, $py2, $this->aColor['path']);
00497 
00498                 $px1 = $px2;
00499                 $py1 = $py2;
00500             }
00501         }
00502 
00503         $result = $this->oDB->query("SELECT m.x, m.y, m.sight, g.diplomacy, p.name, g.tag, md.building ".
00504                                   "FROM ".$this->oDB->tblTown." m ".
00505                                   "LEFT JOIN ".$this->oDB->tblPlayer." p USING (player_id) ".
00506                                   "LEFT JOIN ".$this->oDB->tblGuild." g  USING (guild_id) ".
00507                                   "LEFT JOIN ".$this->oDB->tblMapData." md ON m.x=md.x and m.y=md.y ".
00508                                   "WHERE m.x BETWEEN ".($xx0-$this->oUser->intTownSight)." AND ".($xx1+$this->oUser->intTownSight)." AND ".
00509                                   "m.y BETWEEN ".($yy0-$this->oUser->intTownSight)." AND ".($yy1+$this->oUser->intTownSight).$strFilter.
00510                                   " ORDER BY m.y, m.x");
00511         $aTowns = array();
00512         while( $aRow = $this->oDB->fetch_assoc($result) )
00513         {
00514             $aTowns[] = $aRow;
00515         }
00516 
00517         /* --------------------------------------------------------------------------------
00518          * town sight
00519          * --------------------------------------------------------------------------------
00520          */
00521         if( $this->oUser->intTownSight > 0 )
00522         {
00523             for( $j=0; $j<count( $aTowns ); ++$j )
00524             {
00525                 $field =& $aTowns[$j];
00526                 if( $field['sight'] > $this->oUser->intTownSight || $field['sight']==0 ) continue;
00527 
00528                 $px_left   = ($field['x'] - $xx0 - $field['sight']) * ($intFieldWidth_p1);
00529                 $px_top    = ($field['y'] - $yy0 - $field['sight']) * ($intFieldHeight_p1);
00530                 $px_right  = ($field['x'] - $xx0 + $field['sight']) * ($intFieldWidth_p1)  + $intFieldWidth;
00531                 $px_bottom = ($field['y'] - $yy0 + $field['sight']) * ($intFieldHeight_p1) + $intFieldHeight;
00532 
00533                 if( $this->oUser->intTownFill > 0 )
00534                 {
00535                     ImageCopyMerge($img, $druid, $px_left, $px_top, 0, 0, $intFieldWidth_p1*$field['sight']*2+$intFieldWidth_p1, $intFieldHeight_p1*$field['sight']*2+$intFieldHeight_p1, 30);
00536                 }
00537 /*
00538                 $aStyle = array();
00539                 for( $i=0; $i<=$intFieldWidth/2; $i++ )
00540                 {
00541                     $aStyle[] = $this->aColor['dborder'];
00542                     $aStyle[] = $this->aColor['dborder'];
00543                 }
00544                 for( $i=0; $i<=$intFieldWidth/2; $i++ )
00545                 {
00546                     $aStyle[] = $this->aColor['black'];
00547                     $aStyle[] = $this->aColor['black'];
00548                 }
00549 
00550                 imagesetstyle( $img, $aStyle );*/
00551                 imagesetthickness( $img, 2);
00552                 imagerectangle( $img, $px_left, $px_top, $px_right+1, $px_bottom+1, $this->aColor['dborder'] );
00553                 imagesetthickness( $img, 1);
00554             }
00555         }
00556 
00557         // Text in Grafik zeichnen
00558         for( $i=0; $i<count( $aTowns ); ++$i )
00559         {
00560             $field =& $aTowns[$i];
00561             if( $field['building'] < -10 ) continue;
00562             if( trim( $field['name'] ) == '' ) continue;
00563             $text = (($field['tag']!='') ? '['. $field['tag'] . ']' : '' ). $field['name'];
00564             $px_x = ($field['x'] - $xx0) * ($intFieldWidth_p1) + ($intFieldWidth_d2);
00565             $px_y = ($field['y'] - $yy0) * ($intFieldHeight_p1) + ($intFieldHeight_d2);
00566             $px_x -= (strlen($text) * ImageFontWidth(5) / 2);
00567             // pschange: Schatten
00568             ImageString($img, 5, $px_x+1, $px_y+$intFieldHeight_d2+1, $text, $this->aColor['black']);
00569             ImageString($img, 5, $px_x, $px_y+$intFieldHeight_d2, $text, $this->aColor['text1']);
00570         }
00571 
00572         if( $strEffort )
00573         {
00574            ImageString($img, 5, 11, 11, sprintf("%4.2f WP", $strEffort ), $this->aColor['black']);
00575            ImageString($img, 5, 10, 10, sprintf("%4.2f WP", $strEffort ), $this->aColor['text2']);
00576         }
00577 
00578         // Graphik ausgeben
00579         header('Content-type: image/png');
00580 
00581         header("Cache-Control: no-store, no-cache, must-revalidate");   // HTTP/1.1
00582         header("Cache-Control: post-check=0, pre-check=0", false);
00583 
00584         header("Pragma: no-cache");                     // HTTP/1.0
00585 
00586         imagepng($img);
00587         imagedestroy($img);
00588         imagedestroy($fow);
00589     }
00590 }

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