Jump to content

Map coorts to zone ones


Recommended Posts

Posted

Hello there!

I'm gathering data on GOs all around the World of Warcraft on official servers. They are 100% precise coords (Map/X/Y/Z/Orientation). I want to create a gatherer database with those data, but not only (I want to create a free DB for all the developers of servers or addons, whatever).

The problem is that I can't seem to find a way to transform these coordinations into zones ones. I've extracted the WorldMapArea.dbc data and put it on a DB table. The problem is I can't get valid coords. I tried to make a sample code to get all the Durotar GOs spawns, and while they should all stay on the ground of Durotar, they're spread all around the map!!!

This is the PHP code:

<?php

/////////////////////////
// MySQL configuration //
/////////////////////////

$host           = "127.0.0.1";
$port           = 3306;
$username       = "me";
$password       = "justme";
$database       = "mydb";

$mysql = mysql_connect($host.":".$port,$username,$password);
mysql_select_db($database);

/////////////////////////
/////////////////////////

$sql = mysql_query("SELECT * FROM gatherer_worldmaparea WHERE ref_area=14 LIMIT 1");
$row = mysql_fetch_array($sql);

$y_min = floatval($row['y_max']); // have to switch the name in the DB
$y_max = floatval($row['y_min']); // have to switch the name in the DB
$x_min = floatval($row['x_max']); // have to switch the name in the DB
$x_max = floatval($row['x_min']); // have to switch the name in the DB


$sql = mysql_query("SELECT * FROM gatherer_data");
$i=0;
while($row = mysql_fetch_array($sql)) {
       $x = floatval($row['x']);
       $y = floatval($row['y']);
       if($x >= $x_min && $x <= $x_max && $y >= $y_min && $y <= $y_max) {
               $vars[$i]['x'] = ($row['x']-$x_min)/(($x_max-$x_min)/100);
               $vars[$i]['y'] = ($row['y']-$y_min)/(($y_max-$y_min)/100);
               $i++;
       }
       else echo "X: ".$row['x']." ($x_min $x_max)\\tY: ".$row['y']." ($y_min $y_max)\\n";
}

mysql_close($mysql);

$wowhead = "http://www.wowhead.com/?maps=14:";
foreach($vars as $key) {
       $x = substr($key['x'],0,strpos($key['x'],".")+2);
       $x = str_replace(".","",$x);
       $y = substr($key['y'],0,strpos($key['y'],".")+2);
       $y = str_replace(".","",$y);

       $wowhead .= $x.$y;
}
echo $wowhead."\\n";
?>

The result ATM is:

http://www.wowhead.com/?maps=14:547879545962542880579435559330584414591360559348545415584412526348579340580338562275527371553417547289594396539371551383542355531396550384563370539394574413562348540393603371530397573412564372561371539369598350543367553352543353597348531395557295551402603369550403554417580434545414553663445617555814568509470870604546454321630498441416461280594805358257550706492650408540414471484519309282575793611482617603629734438451454445428860571603612517411493438859498469479356523699399583504527630752549719589837617497434754623609628633429278458295557319322166326174328135315166315176329121314158585317484587295283575727583726520614591660541685614704478762505488406390398382437605458860494368411529470634485700446902611455577623586820481751504808470817502789483806405822627484451902643645605597473901507191512673442331485445434285465266314302629629639736493490532208471723407588589525599740596723605713504641488576537932458572457577483811312202469577316168428437580846530664593322350175365256315130327193378384041623162813032533912112972894021033213014406433311334257864467194767024265814165903944544878844493663964695377073092914158354608924985133943913944395995154994555577854893314511954842245235255235045758566028515733275788515878134898704745735509583804453743943864383774363754013674263793935408913251213251223251213251213251213251213251214575744885845011875519615319474918645448615913215349114677595747294727443162855095205332103784415746115037574888104214125295014778964745735499595778515232266165674187034817615565056077514615764744605439265449274535864705816104175368925006963551192932584347995242284575815015956054594057515377685569465439235519625534955726104432615352075275055085125439535853144378005726104865815349614615735893965513115333925704265263085762686113825884105433405624225273465294205862725532735479285419285429515469474855834839025629475339005459205539645549594837224997545097745027815056625286905027565036785096695266665349103271314875875398565329605499595329495429445409675339515289375409465419455289405289405349645279345249605319475289425369635319675329585309565339605339625299375479465279355439435259595299575299475319555289355329485239615329585299705339655329665339645279425339535339515359635409505309575329605319465289375469445399655289405409485429445279435279575459435389645539484362565624624805705679504875874885844865814825844845874898705878134615734575774575744585784585724615765853175479285469515459465539595439535559565539265489515309435419395559455569575499655419485519625338925438955823145913215783145923145943175853145863205923185893185933225953204705814805815339185499425429115419285479325439235339385579495339005368925379325539645469595408915489175468865319525299515509585629475329155589354695694535864895744805704805974785915357714885765733275797335222235673163271314875774695765733284895754765644378005349124744605893185589484695695329154695765439265449265459275823146165674765644432645468865419395238375429115539455923145228375579495339384875775369624745735539264805785863204895756184155372105438955329565275055559514803155489174074234825846194154895745589354034185352074805935559455489565419445797335569574805975499425299513281284803155624626732255085125499654785915579445357715319525349125479325468675309455399525349495349635449425409445389624432615489514744605953205469515673165559565539594805816165675222235459465943175299365534955419485379235338924815915499445469593122785398565783145569334803165309434585785409595339185733285349104805945923185409455478795459625428805794355593305844145913605593485454155844125263485793405803385622755273715534175472895943965393715513835423555313965503845633705393945744135623485403936033715303975734125643725613715393695983505433675533525433535973485313955572955514026033695504035544175804345454145536634456175558145685094708706045464543216304984414164612805948053582575507064926504085404144714845193092825757936114826176036297344384514544454288605716036125174114934388594984694793565236993995835045276307525497195898376174974347546236096286334292784582955573193221663261743281353151663151763291213141585853174845872952835757275837265206145916605416856147044787625054884063903983824376054588604943684115294706344857004469026114555776235868204817515048084708175027894838064058226274844519026436456055974739015071915126734423314854454342854652663143026296296397364934905322084717234075885895255997405967236057135046414885765379324585724575774838113122024695773161684284375808465306645933223501753652563151303271933783840416231628130325339121129728940210332130144064333113342578644671947670242658141659039445448788444936639646953770730929141583446089249851339439139443959951549945555778548933145119548422452352552350457585660285157332757885158781348987047457355095838044537439438643837743637540136742637939354089132512132512232512132512132512132512132512145757448858450118755196153194749186454486159132153491146775957472947274431628550952053321037844157461150375748881042141252950147789647457354995957785152322661656741870348176155650560775146157647446054392654492745358647058161041753689250069635511929325843479952422845758150159560545940575153776855694654392355196255349557261044326153520752750550851254395358531443780057261048658153496146157358939655131153339257042652630857626861138258841054334056242252734652942058627255327354792854192854295154694748558348390256294753390054592055396455495948372249975450977450278150566252869050275650367850966952666653491032713148758753985653296054995953294954294454096753395152893754094654194552894052894053496452793452496053194752894253696353196753295853095653396053396252993754794652793554394352595952995752994753195552893553294852396153295852997053396553296653396452794253395353395153596354095053095753296053194652893754694453996552894054094854294452794352795754594353896455394843625656246248057056795048758748858448658148258448458748987058781346157345757745757445857845857246157658531754792854695154594655395954395355595655392654895153094354193955594555695754996554194855196253389254389558231459132157831459231459431758531458632059231858931859332259532047058148058153391854994254291154192854793254392353393855794953390053689253793255396454695954089154891754688653195252995155095856294753291555893546956945358648957448057048059747859153577148857657332757973352222356731632713148757746957657332848957547656443780053491247446058931855894846956953291546957654392654492654592758231461656747656444326454688654193952383754291155394559231452283755794953393848757753696247457355392648057858632048957561841553721054389553295652750555595148031554891740742348258461941548957455893540341853520748059355594554895654194457973355695748059754994252995132812848031556246267322550851254996547859155794453577153195253491254793254686753094553995253494953496354494254094453896244326154895147446059532054695156731655595655395948058161656752222354594659431752993655349554194853792353389248159154994454695931227853985657831455693348031653094345857854095953391857332853491048059459231854094

What's wrong with it?

Format for the maps is: ?maps=ZONEID:XX(.)XYY(.)Y

There are about 1'163 spawns, while there should be around 560, is there something wrong with my code?

I'm also trying to transform these data into Gatherer valid one, but I have no idea on how to do it.

Thanks.

Posted

Where exactly is the problem? Are those zone coordinates calculated correctly and the conversion to that wowhead string fails?

I had a look at the mangos source and it says:

void Map2ZoneCoordinates(float& x,float& y,uint32 zone)

{

WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone);

// if not listed then map coordinates (instance)

if(!maEntry)

return;

x = (x-maEntry->x1)/((maEntry->x2-maEntry->x1)/100);

y = (y-maEntry->y1)/((maEntry->y2-maEntry->y1)/100); // client y coord from top to down

std::swap(x,y); // client have map coords swapped

}

Did you considered that swapping?
Posted

First problem is that you don't filter results based on map id, this will select spawns in that zone, but also from other maps (azeroth, kalimdor,..).

Second is that wow coords is X - up, Y - left. So you will need probably to do

$vars[$i]['x'] = ($row['y']-$y_min)/(($y_max-$y_min)/100);

$vars[$i]['y'] = ($row['x']-$x_min)/(($x_max-$x_min)/100);

or

$vars[$i]['x'] = 100 - ($row['y']-$y_min)/(($y_max-$y_min)/100);

$vars[$i]['y'] = 100 - ($row['x']-$x_min)/(($x_max-$x_min)/100);

(not sure)

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use