]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/xy.c
Update copyright notice
[empserver] / src / lib / common / xy.c
index 5bcdc407cfc870b9663ba007b451988bf6612237..de3ce12171a186a1a1e3f50e373e18c2393f7013 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Dave Pare, 1989
- *     Markus Armbruster, 2004-2011
+ *     Markus Armbruster, 2004-2013
  */
 
 #include <config.h>
@@ -36,7 +36,6 @@
 #include <errno.h>
 #include <stdarg.h>
 #include <stdio.h>
-#include "file.h"
 #include "misc.h"
 #include "nat.h"
 #include "optlist.h"
@@ -149,11 +148,11 @@ xydist_range(coord x, coord y, int dist, struct range *rp)
 }
 
 /*
- * Convert initial part of STR to normalized x-coordinate.
+ * Convert initial part of @str to normalized x-coordinate.
  * Return -1 on error.  This works, as normalized coordinates are
  * non-negative.
- * Assign pointer to first character after the coordinate to *END,
- * unless END is a null pointer.
+ * Assign pointer to first character after the coordinate to *@end,
+ * unless @end is a null pointer.
  */
 coord
 strtox(char *str, char **end)
@@ -168,11 +167,11 @@ strtox(char *str, char **end)
 }
 
 /*
- * Convert initial part of STR to normalized y-coordinate.
+ * Convert initial part of @str to normalized y-coordinate.
  * Return -1 on error.  This works, as normalized coordinates are
  * non-negative.
- * Assign pointer to first character after the coordinate to *END,
- * unless END is a null pointer.
+ * Assign pointer to first character after the coordinate to *@end,
+ * unless @end is a null pointer.
  */
 coord
 strtoy(char *str, char **end)
@@ -208,6 +207,12 @@ sctoff(coord x, coord 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)
 {