- fixed bug that caused coordinates in planes to be adjusted in the wrong way.
This commit is contained in:
Enno Rehling 2010-01-20 06:34:35 +00:00
parent cb48e03ad2
commit 610f278461
3 changed files with 23 additions and 1 deletions

View File

@ -218,6 +218,26 @@ region_y(const region *r, const faction *f)
return y; 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 void
set_ursprung(faction *f, int id, int x, int y) set_ursprung(faction *f, int id, int x, int y)
{ {

View File

@ -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 read_plane_reference(plane ** pp, struct storage * store);
extern int plane_width(const plane * pl); extern int plane_width(const plane * pl);
extern int plane_height(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 #ifdef __cplusplus
} }
#endif #endif

View File

@ -1642,8 +1642,9 @@ f_regionid(const region * r, const faction * f, char * buffer, size_t size)
} else { } else {
plane * pl = rplane(r); plane * pl = rplane(r);
const char * name = pl?pl->name:0; 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); pnormalize(&nx, &ny, pl);
adjust_coordinates(f, &nx, &ny, pl, r);
strncpy(buffer, rname(r, f->locale), size); strncpy(buffer, rname(r, f->locale), size);
buffer[size-1]=0; buffer[size-1]=0;
sprintf(buffer+strlen(buffer), " (%d,%d%s%s)", nx, ny, name?",":"", (name)?name:""); sprintf(buffer+strlen(buffer), " (%d,%d%s%s)", nx, ny, name?",":"", (name)?name:"");