While reading some older posts, I found this topic (http://forum.outpost2.net/index.php?showtopic=4804) again. I remembered seeing something like that mentioned by AmIMeYet somewhere, so i searched the SDK and was surprised to actually find it:
// OP2Helper.h
#define MkXY(x,y) (LOCATION(x+31,y-1))
#define MkRect(x1,y1,x2,y2) (MAP_RECT(LOCATION(x1+31,y1-1),LOCATION(x2+31,y2-1)))
#define XYPos(x,y) x+31,y-1
#define RectPos(x1,y1,x2,y2) x1+31,y1-1,x2+31,y2-1
Maybe someone put it in there and forgot about it? However, AmIMeYet's suggestion to make it compatible for world maps is worth a thought. It could easily be done by replacing it by
#ifdef WORLDMAP
#define MkXY(x,y) (LOCATION(x-1,y-1))
#define MkRect(x1,y1,x2,y2) (MAP_RECT(LOCATION(x1-1,y1-1),LOCATION(x2-1,y2-1)))
#define XYPos(x,y) x-1,y-1
#define RectPos(x1,y1,x2,y2) x1-1,y1-1,x2-1,y2-1
#else
#define MkXY(x,y) (LOCATION(x+31,y-1))
#define MkRect(x1,y1,x2,y2) (MAP_RECT(LOCATION(x1+31,y1-1),LOCATION(x2+31,y2-1)))
#define XYPos(x,y) x+31,y-1
#define RectPos(x1,y1,x2,y2) x1+31,y1-1,x2+31,y2-1
#endif
Whew! I can hear Hoomans blood running cold.
Should rather do it that way:
#ifdef WORLDMAP
#define XOFFSET (-1)
#else
#define XOFFSET (31)
#endif
#define MkXY(x,y) (LOCATION(x+XOFFSET,y-1))
#define MkRect(x1,y1,x2,y2) (MAP_RECT(LOCATION(x1+XOFFSET,y1-1),LOCATION(x2+XOFFSET,y2-1)))
#define XYPos(x,y) x+XOFFSET,y-1
#define RectPos(x1,y1,x2,y2) x1+XOFFSET,y1-1,x2+XOFFSET,y2-1
One could also make XOFFSET a global variable that is automatically set when the map is loaded. But I'm not sure if the bigger generality justifies the additional overhead.
Thats good, I just wasn't sure since those offsets are commented out:
OP2Helper.h
// X and Y offset consts
//const int X_ = 31;
//const int Y_ = -1;