From f48c10f46eab1c11827516a0610f7cd71d74bdad Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 30 Jul 2017 14:15:15 -0400 Subject: Add tile create and access timestamps --- server.c | 6 ++++-- torus.h | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server.c b/server.c index 7b16f33..e96d3dd 100755 --- a/server.c +++ b/server.c @@ -18,6 +18,7 @@ exec cc -Wall -Wextra -pedantic $@ -o server $0 #include #include #include +#include #include #include "torus.h" @@ -37,11 +38,12 @@ static void tilesMap(void) { static struct Tile *tileGet(uint32_t tileX, uint32_t tileY) { struct Tile *tile = &tiles[tileY * TILE_ROWS + tileX]; - if (!tile->present) { + if (!tile->create) { memset(tile->cells, ' ', CELLS_SIZE); memset(tile->colors, COLOR_WHITE, CELLS_SIZE); - tile->present = true; + tile->create = time(NULL); } + tile->access = time(NULL); return tile; } diff --git a/torus.h b/torus.h index bb012f2..968c9f6 100644 --- a/torus.h +++ b/torus.h @@ -2,6 +2,7 @@ #include #include #include +#include #define ALIGNED(x) __attribute__((aligned(x))) @@ -25,7 +26,8 @@ enum { #define CELL_INIT_Y (CELL_ROWS / 2) struct Tile { - bool present; + time_t create; + time_t access; char cells[CELL_ROWS][CELL_COLS] ALIGNED(16); uint8_t colors[CELL_ROWS][CELL_COLS] ALIGNED(16); } ALIGNED(4096); -- cgit 1.4.1