diff --git a/src/common/kernel/plane.c b/src/common/kernel/plane.c index 770e90558..e74089bce 100644 --- a/src/common/kernel/plane.c +++ b/src/common/kernel/plane.c @@ -218,6 +218,26 @@ region_y(const region *r, const faction *f) return y; } +void +adjust_coordinates(const faction *f, int *x, int *y, const plane * pl, const region * r) +{ + int nx = *x - plane_center_x(pl); + int ny = *y - plane_center_y(pl); + if (f) { + int width = plane_width(pl); + int height = plane_height(pl); + int width_2 = width/2; + int height_2 = height/2; + + nx -= ursprung_x(f, pl, r); + if (nx>width_2) nx -= width; + ny -= ursprung_y(f, pl, r); + if (ny>height_2) ny -= height; + } + *x = nx; + *y = ny; +} + void set_ursprung(faction *f, int id, int x, int y) { diff --git a/src/common/kernel/plane.h b/src/common/kernel/plane.h index 417b67b01..00eb89ca7 100644 --- a/src/common/kernel/plane.h +++ b/src/common/kernel/plane.h @@ -81,6 +81,7 @@ extern void write_plane_reference(const plane * p, struct storage * store); extern int read_plane_reference(plane ** pp, struct storage * store); extern int plane_width(const plane * pl); extern int plane_height(const plane * pl); +void adjust_coordinates(const struct faction *f, int *x, int *y, const struct plane * pl, const struct region * r); #ifdef __cplusplus } #endif diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index a06545919..f85e2f5e8 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -1642,8 +1642,9 @@ f_regionid(const region * r, const faction * f, char * buffer, size_t size) } else { plane * pl = rplane(r); const char * name = pl?pl->name:0; - int nx = region_x(r, f), ny = region_y(r, f); + int nx = r->x, ny = r->y; pnormalize(&nx, &ny, pl); + adjust_coordinates(f, &nx, &ny, pl, r); strncpy(buffer, rname(r, f->locale), size); buffer[size-1]=0; sprintf(buffer+strlen(buffer), " (%d,%d%s%s)", nx, ny, name?",":"", (name)?name:"");