summary refs log tree commit diff homepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--client.c2
-rw-r--r--server.c2
-rw-r--r--torus.h3
3 files changed, 4 insertions, 3 deletions
diff --git a/client.c b/client.c
index ee120e5..ea1f6f5 100644
--- a/client.c
+++ b/client.c
@@ -197,7 +197,7 @@ static void readInput(void) {
 
 		break; case 'q': endwin(); exit(EX_OK);
 		break; case 'Q': {
-			if ((input.color & 0x07) < SPAWNS_LEN) {
+			if ((input.color & 0x07) < ARRAY_LEN(SPAWNS)) {
 				clientSpawn(input.color & 0x07);
 			} else {
 				clientSpawn(0);
diff --git a/server.c b/server.c
index 3a27ad4..9d0af0e 100644
--- a/server.c
+++ b/server.c
@@ -218,7 +218,7 @@ static bool clientUpdate(const struct Client *client, const struct Client *old)
 }
 
 static bool clientSpawn(struct Client *client, uint8_t spawn) {
-	if (spawn >= SPAWNS_LEN) return false;
+	if (spawn >= ARRAY_LEN(SPAWNS)) return false;
 	struct Client old = *client;
 	client->tileX = SPAWNS[spawn].tileX;
 	client->tileY = SPAWNS[spawn].tileY;
diff --git a/torus.h b/torus.h
index 918a131..775df3c 100644
--- a/torus.h
+++ b/torus.h
@@ -24,6 +24,8 @@
 #define PACKED __attribute__((packed))
 #define ALIGNED(x) __attribute__((aligned(x)))
 
+#define ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0]))
+
 #undef COLOR_BLACK
 #undef COLOR_RED
 #undef COLOR_GREEN
@@ -86,7 +88,6 @@ static const struct {
 	{ TILE_COLS * 1 / 4, TILE_ROWS * 1 / 4 }, // SE
 	{ TILE_COLS * 3 / 4, TILE_ROWS * 1 / 4 }, // SW
 };
-static const size_t SPAWNS_LEN = sizeof(SPAWNS) / sizeof(SPAWNS[0]);
 
 enum {
 	MAP_ROWS = 11,
21-09-15 10:46:21 -0400'>2021-09-15Factor out common parts of downgrade messagesJune McEnroe 2021-09-14Add downgrade IRC botJune McEnroe 2021-09-14Sort by title if authors matchJune McEnroe 2021-09-13Swap-remove tags as they're foundJune McEnroe 2021-09-12Replace htagml regex with strncmpJune McEnroe 2021-09-11Also defer printing comment for lone close-parensJune McEnroe 2021-09-10Publish "git-comment"June McEnroe 2021-09-10Add git comment --pretty optionJune McEnroe 2021-09-08Defer printing comment if line is blank or closing braceJune McEnroe 2021-09-08Up default min-repeat to 30 linesJune McEnroe 2021-09-08Handle dirty lines in git-commentJune McEnroe 2021-09-08Document and install git-commentJune McEnroe 2021-09-08Add repeat and all options to git-commentJune McEnroe 2021-09-08Add group threshold to git-commentJune McEnroe