]> git.pond.sub.org Git - empserver/commitdiff
sctoff2xy(): New, factored out of sct_oninit()
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 27 Jan 2013 09:22:03 +0000 (10:22 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 6 Jun 2013 17:55:01 +0000 (19:55 +0200)
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
include/xy.h
src/lib/common/filetable.c
src/lib/common/xy.c

index c230c13b46ef69856c10c10425d54b21b650849e..9d19a4cb14c4a4a13e63c150acc51724ef5610bc 100644 (file)
@@ -65,6 +65,7 @@ extern coord strtoy(char *str, char **end);
 extern coord xabs(struct natstr *np, coord relx);
 extern coord yabs(struct natstr *np, coord rely);
 extern int sctoff(coord x, coord y);
 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);
 extern coord xnorm(coord x);
 extern coord ynorm(coord y);
 extern int xyinrange(coord x, coord y, struct range *rp);
index b38a270f5dbf80c4536fe660b0fac6e9938fe807..8e0f50433f1158efd0625eb30268138bdac1c596 100644 (file)
@@ -27,7 +27,7 @@
  *  filetable.c: Empire game data file descriptions.
  *
  *  Known contributors to this file:
  *  filetable.c: Empire game data file descriptions.
  *
  *  Known contributors to this file:
- *     Markus Armbruster, 2005-2012
+ *     Markus Armbruster, 2005-2013
  */
 
 #include <config.h>
  */
 
 #include <config.h>
@@ -281,8 +281,7 @@ sct_oninit(void *ptr)
 {
     struct sctstr *sp = (struct sctstr *)ptr;
 
 {
     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;
     sp->sct_dist_x = sp->sct_x;
     sp->sct_dist_y = sp->sct_y;
     sp->sct_newtype = sp->sct_type = SCT_WATER;
index 5bcdc407cfc870b9663ba007b451988bf6612237..ba34ccc60c1842ad80e3e775a150fab2df666a4c 100644 (file)
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Dave Pare, 1989
  *
  *  Known contributors to this file:
  *     Dave Pare, 1989
- *     Markus Armbruster, 2004-2011
+ *     Markus Armbruster, 2004-2013
  */
 
 #include <config.h>
  */
 
 #include <config.h>
@@ -208,6 +208,12 @@ sctoff(coord x, coord y)
     return XYOFFSET(XNORM(x), YNORM(y));
 }
 
     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)
 {
 coord
 xnorm(coord x)
 {