extern coord xabs(struct natstr *np, coord relx);
extern coord yabs(struct natstr *np, coord rely);
extern int sctoff(coord x, coord y);
+extern void sctoff2xy(coord *, coord *, int);
extern coord xnorm(coord x);
extern coord ynorm(coord y);
extern int xyinrange(coord x, coord y, struct range *rp);
* filetable.c: Empire game data file descriptions.
*
* Known contributors to this file:
- * Markus Armbruster, 2005-2012
+ * Markus Armbruster, 2005-2013
*/
#include <config.h>
{
struct sctstr *sp = (struct sctstr *)ptr;
- sp->sct_y = sp->sct_uid * 2 / WORLD_X;
- sp->sct_x = sp->sct_uid * 2 % WORLD_X + sp->sct_y % 2;
+ sctoff2xy(&sp->sct_x, &sp->sct_y, sp->sct_uid);
sp->sct_dist_x = sp->sct_x;
sp->sct_dist_y = sp->sct_y;
sp->sct_newtype = sp->sct_type = SCT_WATER;
*
* Known contributors to this file:
* Dave Pare, 1989
- * Markus Armbruster, 2004-2011
+ * Markus Armbruster, 2004-2013
*/
#include <config.h>
return XYOFFSET(XNORM(x), YNORM(y));
}
+void sctoff2xy(coord *x, coord *y, int off)
+{
+ *y = off * 2 / WORLD_X;
+ *x = off * 2 % WORLD_X + *y % 2;
+}
+
coord
xnorm(coord x)
{