forked from github/server
- fixed bug that caused coordinates in planes to be adjusted in the wrong way.
This commit is contained in:
parent
cb48e03ad2
commit
610f278461
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:"");
|
||||
|
|
Loading…
Reference in New Issue