Move xysize_range(), xydist_range() to xy.c and xy.h
Moved from snxtsct.c and prototypes.h next to the other struct range functions.
This commit is contained in:
parent
e7d7cfdc10
commit
40b6032a5d
4 changed files with 43 additions and 43 deletions
|
@ -648,8 +648,6 @@ extern void snxtitem_cargo(struct nstr_item *, int, int, int);
|
|||
/* snxtsct.c */
|
||||
extern int snxtsct(struct nstr_sect *, char *);
|
||||
extern void snxtsct_area(struct nstr_sect *, struct range *);
|
||||
extern void xydist_range(coord, coord, int, struct range *);
|
||||
extern void xysize_range(struct range *);
|
||||
extern void snxtsct_all(struct nstr_sect *);
|
||||
extern void snxtsct_rewind(struct nstr_sect *);
|
||||
extern void snxtsct_dist(struct nstr_sect *, coord, coord, int);
|
||||
|
|
|
@ -60,6 +60,8 @@ extern void xyrelrange(struct natstr *np, struct range *src,
|
|||
struct range *dst);
|
||||
extern void xyabsrange(struct natstr *np, struct range *src,
|
||||
struct range *dst);
|
||||
extern void xydist_range(coord, coord, int, struct range *);
|
||||
extern void xysize_range(struct range *);
|
||||
extern coord strtox(char *str, char **end);
|
||||
extern coord strtoy(char *str, char **end);
|
||||
extern coord xabs(struct natstr *np, coord relx);
|
||||
|
|
|
@ -107,6 +107,47 @@ xyabsrange(struct natstr *np, struct range *src, struct range *dst)
|
|||
dst->height = src->height;
|
||||
}
|
||||
|
||||
void
|
||||
xysize_range(struct range *rp)
|
||||
{
|
||||
if (rp->lx > rp->hx)
|
||||
rp->width = WORLD_X + rp->hx + 1 - rp->lx;
|
||||
else
|
||||
rp->width = rp->hx + 1 - rp->lx;
|
||||
if (CANT_HAPPEN(rp->width > WORLD_X))
|
||||
rp->width = WORLD_X;
|
||||
if (rp->ly > rp->hy)
|
||||
rp->height = WORLD_Y + rp->hy + 1 - rp->ly;
|
||||
else
|
||||
rp->height = rp->hy + 1 - rp->ly;
|
||||
if (CANT_HAPPEN(rp->height > WORLD_Y))
|
||||
rp->height = WORLD_Y;
|
||||
}
|
||||
|
||||
void
|
||||
xydist_range(coord x, coord y, int dist, struct range *rp)
|
||||
{
|
||||
if (4 * dist + 1 < WORLD_X) {
|
||||
rp->lx = xnorm(x - 2 * dist);
|
||||
rp->hx = xnorm(x + 2 * dist);
|
||||
rp->width = 4 * dist + 1;
|
||||
} else {
|
||||
rp->lx = xnorm(x - WORLD_X / 2);
|
||||
rp->hx = xnorm(rp->lx + WORLD_X - 1);
|
||||
rp->width = WORLD_X;
|
||||
}
|
||||
|
||||
if (2 * dist + 1 < WORLD_Y) {
|
||||
rp->ly = ynorm(y - dist);
|
||||
rp->hy = ynorm(y + dist);
|
||||
rp->height = 2 * dist + 1;
|
||||
} else {
|
||||
rp->ly = ynorm(y - WORLD_Y / 2);
|
||||
rp->hy = ynorm(rp->ly + WORLD_Y - 1);
|
||||
rp->height = WORLD_Y;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert initial part of STR to normalized x-coordinate.
|
||||
* Return -1 on error. This works, as normalized coordinates are
|
||||
|
|
|
@ -150,44 +150,3 @@ snxtsct_dist(struct nstr_sect *np, coord cx, coord cy, int dist)
|
|||
np->dx = -1;
|
||||
np->dy = 0;
|
||||
}
|
||||
|
||||
void
|
||||
xysize_range(struct range *rp)
|
||||
{
|
||||
if (rp->lx > rp->hx)
|
||||
rp->width = WORLD_X + rp->hx + 1 - rp->lx;
|
||||
else
|
||||
rp->width = rp->hx + 1 - rp->lx;
|
||||
if (CANT_HAPPEN(rp->width > WORLD_X))
|
||||
rp->width = WORLD_X;
|
||||
if (rp->ly > rp->hy)
|
||||
rp->height = WORLD_Y + rp->hy + 1 - rp->ly;
|
||||
else
|
||||
rp->height = rp->hy + 1 - rp->ly;
|
||||
if (CANT_HAPPEN(rp->height > WORLD_Y))
|
||||
rp->height = WORLD_Y;
|
||||
}
|
||||
|
||||
void
|
||||
xydist_range(coord x, coord y, int dist, struct range *rp)
|
||||
{
|
||||
if (4 * dist + 1 < WORLD_X) {
|
||||
rp->lx = xnorm(x - 2 * dist);
|
||||
rp->hx = xnorm(x + 2 * dist);
|
||||
rp->width = 4 * dist + 1;
|
||||
} else {
|
||||
rp->lx = xnorm(x - WORLD_X / 2);
|
||||
rp->hx = xnorm(rp->lx + WORLD_X - 1);
|
||||
rp->width = WORLD_X;
|
||||
}
|
||||
|
||||
if (2 * dist + 1 < WORLD_Y) {
|
||||
rp->ly = ynorm(y - dist);
|
||||
rp->hy = ynorm(y + dist);
|
||||
rp->height = 2 * dist + 1;
|
||||
} else {
|
||||
rp->ly = ynorm(y - WORLD_Y / 2);
|
||||
rp->hy = ynorm(rp->ly + WORLD_Y - 1);
|
||||
rp->height = WORLD_Y;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue