about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xserver.c16
-rw-r--r--torus.h4
2 files changed, 17 insertions, 3 deletions
diff --git a/server.c b/server.c
index 97d4230..fc3b3d0 100755
--- a/server.c
+++ b/server.c
@@ -56,11 +56,23 @@ static struct Tile *tileGet(uint32_t tileX, uint32_t tileY) {
         memset(tile->colors, COLOR_WHITE, CELLS_SIZE);
         tile->create = time(NULL);
     }
+    return tile;
+}
+
+static struct Tile *tileAccess(uint32_t tileX, uint32_t tileY) {
+    struct Tile *tile = tileGet(tileX, tileY);
     tile->access = time(NULL);
     tile->accessCount++;
     return tile;
 }
 
+static struct Tile *tileModify(uint32_t tileX, uint32_t tileY) {
+    struct Tile *tile = tileGet(tileX, tileY);
+    tile->modify = time(NULL);
+    tile->modifyCount++;
+    return tile;
+}
+
 static struct Client {
     int fd;
 
@@ -102,7 +114,7 @@ static bool clientSend(const struct Client *client, const struct ServerMessage *
     if (len < 0) return false;
 
     if (msg->type == SERVER_TILE) {
-        struct Tile *tile = tileGet(client->tileX, client->tileY);
+        struct Tile *tile = tileAccess(client->tileX, client->tileY);
         len = send(client->fd, tile, sizeof(*tile), 0);
         if (len < 0) return false;
     }
@@ -227,7 +239,7 @@ static bool clientMove(struct Client *client, int8_t dx, int8_t dy) {
 }
 
 static bool clientPut(const struct Client *client, uint8_t color, char cell) {
-    struct Tile *tile = tileGet(client->tileX, client->tileY);
+    struct Tile *tile = tileModify(client->tileX, client->tileY);
     tile->colors[client->cellY][client->cellX] = color;
     tile->cells[client->cellY][client->cellX] = cell;
 
diff --git a/torus.h b/torus.h
index 9158ef7..6b28f8c 100644
--- a/torus.h
+++ b/torus.h
@@ -27,10 +27,12 @@ enum {
 
 struct Tile {
     time_t create;
-    time_t access;
+    time_t modify;
     char cells[CELL_ROWS][CELL_COLS] ALIGNED(16);
     uint8_t colors[CELL_ROWS][CELL_COLS] ALIGNED(16);
+    uint32_t modifyCount;
     uint32_t accessCount;
+    time_t access;
 } ALIGNED(4096);
 static_assert(sizeof(struct Tile) == 4096, "struct Tile is page-sized");
 static_assert(offsetof(struct Tile, cells) == 16, "stable cells offset");
ommit/www/photo.causal.agency/2024-08-29/lens?id=1134af7da7776a0631995094a9225ce3541a9518&follow=1'>Add August 29 picnic photosJune McEnroe 2024-09-08Apply some bold to trips renderingJune McEnroe This seems easier to visually scan. The only other thing I'd like is a nicer date rendering but JavaScript is useless for that. 2024-09-08Render trips hopefully more efficientlyJune McEnroe 2024-09-08Allow removing bodies and lensesJune McEnroe 2024-09-08Limit body width so it looks less silly on desktopJune McEnroe 2024-09-07Handle no film being loadedJune McEnroe 2024-09-07Fancy up the text a littleJune McEnroe