about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-03-05 12:55:18 -0500
committerJune McEnroe <june@causal.agency>2018-03-05 12:55:18 -0500
commite2033ccf64792e0f78363981ffcd56c78c41de9a (patch)
tree84fa1292ffedbefdb5d749c85b9bbe6e6312af74
parentRename Tile timestamps {create,modify,access}Time (diff)
downloadtorus-e2033ccf64792e0f78363981ffcd56c78c41de9a.tar.gz
torus-e2033ccf64792e0f78363981ffcd56c78c41de9a.zip
Clean up spawn constants
Diffstat (limited to '')
-rw-r--r--server.c16
-rw-r--r--torus.h8
2 files changed, 13 insertions, 11 deletions
diff --git a/server.c b/server.c
index ae60338..84ed24f 100644
--- a/server.c
+++ b/server.c
@@ -97,10 +97,10 @@ static struct Client *clientAdd(int fd) {
     if (!client) err(EX_OSERR, "malloc");
 
     client->fd = fd;
-    client->tileX = UINT32_MAX;
-    client->tileY = UINT32_MAX;
-    client->cellX = UINT8_MAX;
-    client->cellY = UINT8_MAX;
+    client->tileX = TILE_VOID_X;
+    client->tileY = TILE_VOID_Y;
+    client->cellX = CELL_INIT_X;
+    client->cellY = CELL_INIT_Y;
 
     client->prev = NULL;
     if (clientHead) {
@@ -211,17 +211,17 @@ static bool clientUpdate(struct Client *client, struct Client *old) {
                 .newCellX = client->cellX, .newCellY = client->cellY,
             },
         };
-        clientCast(client, &msg);
+        clientCast(client, msg);
     }
 
     return true;
 }
 
 static bool clientSpawn(struct Client *client, uint8_t spawn) {
-    if (spawn >= SPAWN_COUNT) return false;
+    if (spawn >= SPAWNS_LEN) return false;
     struct Client old = *client;
-    client->tileX = SPAWN[spawn].tileX;
-    client->tileY = SPAWN[spawn].tileY;
+    client->tileX = SPAWNS[spawn].tileX;
+    client->tileY = SPAWNS[spawn].tileY;
     client->cellX = CELL_INIT_X;
     client->cellY = CELL_INIT_Y;
     return clientUpdate(client, &old);
diff --git a/torus.h b/torus.h
index 26395a7..a1a085a 100644
--- a/torus.h
+++ b/torus.h
@@ -68,18 +68,20 @@ static_assert(2016 == offsetof(struct Tile, colors), "stable colors offset");
 #define TILE_COLS (512)
 #define TILES_SIZE (sizeof(struct Tile[TILE_ROWS][TILE_COLS]))
 
+#define TILE_VOID_X UINT32_MAX
+#define TILE_VOID_Y UINT32_MAX
+
 static const struct {
     uint32_t tileX;
     uint32_t tileY;
-} SPAWN[] = {
+} SPAWNS[] = {
     { 0, 0 },
     { TILE_COLS * 3 / 4, TILE_ROWS * 3 / 4 }, // NW
     { TILE_COLS * 1 / 4, TILE_ROWS * 3 / 4 }, // NE
     { TILE_COLS * 1 / 4, TILE_ROWS * 1 / 4 }, // SE
     { TILE_COLS * 3 / 4, TILE_ROWS * 1 / 4 }, // SW
 };
-
-#define SPAWN_COUNT (sizeof(SPAWN) / sizeof(SPAWN[0]))
+#define SPAWNS_LEN (sizeof(SPAWNS) / sizeof(SPAWNS[0]))
 
 struct ServerMessage {
     enum PACKED {
>2022-07-26Add -w to upJune McEnroe 2022-07-13Set push.autoSetupRemoteJune McEnroe 2022-07-08Remove TOURJune McEnroe There is not that much distinct stuff here anymore. 2022-07-03Add The Bone Shard EmperorJune McEnroe Suffers a little bit from middle book but I really enjoyed it. Read it faster than the first one too, despite its length. 2022-06-25Bump xterm font size to 12June McEnroe 2022-06-10Handle subshells (and functions) inside substitutionsJune McEnroe 2022-06-10Switch to jorts Install scriptJune McEnroe 2022-06-08Indicate if still reading or no resultsJune McEnroe 2022-06-08Add Maiden, Mother, CroneJune McEnroe Mixed bag like most collections of short stories. Some of them are pretty good. The author of the worst written story also has the worst written bio. 2022-06-05FIRST SHOW IN 2.5 YEARS BABEY!!!June McEnroe 2022-06-03Set line number on File linesJune McEnroe 2022-06-03Stop polling stdin after EOFJune McEnroe 2022-06-02Set TABSIZE=4June McEnroe Absolutely indiscriminately. 2022-06-02Do basic match highlightingJune McEnroe 2022-06-02Clean up parsing a littleJune McEnroe 2022-06-02Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe For some reason I haven't been able to figure out, trying to poll /dev/tty returns POLLNVAL (and this was using 100% CPU looping), but using stderr instead works fine. 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe