From: Anders R. <ma...@us...> - 2006-08-06 22:02:28
|
Update of /cvsroot/planeshift/planeshift/www/serverconsole/waypoints In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10471/www/serverconsole/waypoints Added Files: waypoints_draw.php waypoints_map.php Log Message: - Added new db tables for waypoints sc_waypoints and sc_waypoint_lists => BUMPED DB VERSION - Added view of DB waypoints to server console. => This require GD (http://www.boutell.com/gd/) support by PHP. - Fixed compiler error in workmanager.cpp. --- NEW FILE: waypoints_draw.php --- <? function waypoints_draw(){ include('util.php'); checkAccess('listnpc', '', 'read'); header("Content-type: image/gif"); $sector = $_GET['sector']; $image_name = $sector.".gif"; $data = getDataFromArea($sector); $sectors = $data[0]; $centerx = $data[1]; $centery = $data[2]; $scalefactor = $data[3]; $im = imagecreatefromgif($image_name); $orange = imagecolorallocate($im, 220, 210, 60); $query = $query . " select id from sc_waypoints where " . $sectors; //echo $query; $res = mysql_query2($query); $i=0; while ($line = mysql_fetch_array($res, MYSQL_NUM)){ $id = $line[0]; #imagestring($im,3,0,$i*9,$id,$orange);$i++; $query2 = "select wp1.x,wp1.y,wp1.z,wp2.x,wp2.y,wp2.z,l.flags from sc_waypoint_links l, sc_waypoints wp1, sc_waypoints wp2 where l.wp1 = wp1.id and l.wp2 = wp2.id and wp1.id = ".$id; $res2=mysql_query2($query2); while ($line2 = mysql_fetch_array($res2, MYSQL_NUM)){ $x1 = $line2[0]; $y1 = $line2[1]; $z1 = $line2[2]; $x2 = $line2[3]; $y2 = $line2[4]; $z2 = $line2[5]; $flags = $line2[6]; #imagestring($im,3,0,$i*9,"Link: ".$x1." ".$y1." ".$z1,$orange);$i++; $ix1 = $centerx+($x1*$scalefactor); $iy1 = $centery-($z1*$scalefactor); $ix2 = $centerx+($x2*$scalefactor); $iy2 = $centery-($z2*$scalefactor); #imagestring($im,3,0,$i*9,"Link: ".$ix1." ".$iy1." ".$ix2." ".$iy2." ".$flags,$orange);$i++; imageline($im,$ix1,$iy1,$ix2,$iy2 , $orange); if (stristr($flags, 'ONEWAY') != FALSE) { $cx = ($ix1+$ix2)/2; $cy = ($iy1+$iy2)/2; $a = atan2($iy1-$iy2,$ix1-$ix2); $dx = 10*cos($a+0.6); $dy = 10*sin($a+0.6); imageline($im,$cx,$cy,$cx+$dx,$cy+$dy,$orange); $dx = 10*cos($a-0.6); $dy = 10*sin($a-0.6); imageline($im,$cx,$cy,$cx+$dx,$cy+$dy,$orange); #imagestring($im,3,0,$i*9,"Oneway",$orange);$i++; } } } imagegif($im); imagedestroy($im); } ?> --- NEW FILE: waypoints_map.php --- <? function waypoints_map(){ include('util.php'); checkAccess('listnpc', '', 'read'); $sector = $_POST['sector']; if ($sector!=null and $sector!="") { ?> <script language="JavaScript"> <!-- function MM_reloadPage(init) { //reloads the window if Nav4 resized if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); } MM_reloadPage(true); // --> </script> <style type="text/css"> #dhtmltooltip{ position: absolute; width: 150px; border: 2px solid black; padding: 2px; background-color: lightyellow; visibility: hidden; z-index: 100; /*Remove below line to remove shadow. Below line should always appear last within this CSS*/ filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135); } </style> </head> <body bgcolor="#FFFFFF" text="#000000"> <div id="dhtmltooltip"></div> <script type="text/javascript"> /*********************************************** * Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code ***********************************************/ var offsetxpoint=-60 //Customize x offset of tooltip var offsetypoint=20 //Customize y offset of tooltip var ie=document.all var ns6=document.getElementById && !document.all var enabletip=false if (ie||ns6) var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : "" function ietruebody(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } function ddrivetip(thetext, thecolor, thewidth){ if (ns6||ie){ if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px" if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor tipobj.innerHTML=thetext enabletip=true return false } } function positiontip(e){ if (enabletip){ var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft; var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop; //Find out how close the mouse is to the corner of the window var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20 var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20 var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000 //if the horizontal distance isn't enough to accomodate the width of the context menu if (rightedge<tipobj.offsetWidth) //move the horizontal position of the menu to the left by it's width tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px" else if (curX<leftedge) tipobj.style.left="5px" else //position the horizontal position of the menu where the mouse is positioned tipobj.style.left=curX+offsetxpoint+"px" //same concept with the vertical position if (bottomedge<tipobj.offsetHeight) tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px" else tipobj.style.top=curY+offsetypoint+"px" tipobj.style.visibility="visible" } } function hideddrivetip(){ if (ns6||ie){ enabletip=false tipobj.style.visibility="hidden" tipobj.style.left="-1000px" tipobj.style.backgroundColor='' tipobj.style.width='' } } document.onmousemove=positiontip; </script> <?PHP echo "<h1>Waypoint Map View $sector</h1>"; echo "<div id=Layer2 style=\"position:absolute; width:1968px; height:954px; z-index:1; left:0px; top:90px\"><img src=\"index.php?page=waypoints_draw§or=".$sector."\" >"; //echo "<layer name=Layer2 left=10 top=87px><img src=psworld.jpg width=500 height=500></layer>"; $data = getDataFromArea($sector); $sectors = $data[0]; $query = $query . " select id,x,y,z, radius, flags, name from sc_waypoints where " . $sectors; //echo $query; $res = mysql_query2($query); $i=0; while ($line = mysql_fetch_array($res, MYSQL_NUM)){ $elem = $line[0] . "|N:" . $line[6] . " R:".$line[4]." F:".$line[5]."|x|" . $line[1] . "|" . $line[2]."|".$line[3]; $result .= $elem . "\n"; } // get each line $tok = strtok($result, "\n"); while ($tok) { $peoples[]=$tok; $tok = strtok("\n"); } echo "$peoples"; // get all info for each line foreach( $peoples as $people ) { // skips commented lines $pos = strstr($people, "#"); if ($pos=="0") { $tok2 = strtok($people, "|"); $infos[] = ""; $count = 1; while ($tok2) { $tok2 = str_replace("\n", "", $tok2); $tok2 = str_replace("\r", "", $tok2); $infos[$count]=$tok2; $tok2 = strtok("|"); $count++; } $centerx = $data[1]; $centery = $data[2]; $scalefactor = $data[3]; $x= $centerx+($infos[4]*$scalefactor); $y= $centery-($infos[6]*$scalefactor); if ($infos[6]=="Y") { $ball = "ball01m.gif"; echo "<div id=Layer1 onMouseover=\"ddrivetip('$infos[2]')\"; onMouseout=\"hideddrivetip()\" style=\"position:absolute; offsetTop:20px; width:10px; height:10px; z-index:2; left:".$x."px; top:".$y."px\">"; echo "<A HREF=index.php?page=listwaypoints><img border=0 src=$ball width=8 height=8></a></div>\n"; } else { $ball = "ball04m.gif"; echo "<div id=Layer1 onMouseover=\"ddrivetip('$infos[2]')\"; onMouseout=\"hideddrivetip()\" style=\"position:absolute; offsetTop:20px; width:10px; height:10px; z-index:2; left:".$x."px; top:".$y."px\">"; echo "<A HREF=index.php?page=listwaypoints><img border=0 src=$ball width=10 height=10></a></div>\n"; } } } } echo " <FORM action=\"index.php?page=waypoints_map\" METHOD=POST>"; echo " <b>Select one area:</b> <br><br> Area: "; SelectAreas("","sector"); echo " <br><br><INPUT type=submit value=view><br><br>"; echo "</FORM>"; } ?> |