There is this function in mangos:
bool Map2ZoneCoordinates(float& x,float& y,uint32 zone)
{
WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone);
// if not listed then map coordinates (instance)
if (!maEntry || maEntry->x2 == maEntry->x1 || maEntry->y2 == maEntry->y1)
return false;
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
return true;
}
If you put in the X and Y world co-ords (such as from .gps) and the zone ID, it will give you the 0-100 co-ords like in the client. This is also outputed when you use .gps (I think it says zone co-ords or something similar.)
Basically, in WorldMapArea.dbc is a list of zones and their boundaries in x1, x2, y1, y2. To convert world co-ordinates into zone co-ordinates, take them, subtract the first boundary co-ordinate, then divide it by the second bounary subtracted by the first boundary, then divide by 100, then swap the X and Y.
For example, let's say you are are at co-ordinates (90, 50) in the world and the zone's bounaries are x1: 100 x2 10 y1 60 y2 0, then you would do
x = (x - x1) / ((x2 - x1) / 100)
y = (y - y1) / ((y2 - y1) / 100)
x = (90 - 100) / ((10 - 100) / 100)
y = (50 - 60) / ((0 - 60) / 100)
x = (-10) / ((-90) / 100)
y = (-10) / ((-60) / 100)
x = (-10) / (-0.9)
y = (-10) / (-0.6)
x = 11.11
y = 16.67
then swap these 2
x = 16.67, y = 11.11
Note that x1 and y1 are always bigger than x2 and y2.