about summary refs log tree commit diff homepage
path: root/server.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-08-21 14:00:15 -0400
committerJune McEnroe <june@causal.agency>2018-08-21 14:00:59 -0400
commit9bd49e16c9f41b12887a314c6c0317b0c8e8f852 (patch)
treeea8d21a9ce3a391dc9d5aff3148b3a9863db9644 /server.c
parentRemove spawns (diff)
downloadtorus-9bd49e16c9f41b12887a314c6c0317b0c8e8f852.tar.gz
torus-9bd49e16c9f41b12887a314c6c0317b0c8e8f852.zip
Shrink the torus and rearrange struct Tile
Diffstat (limited to '')
-rw-r--r--server.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/server.c b/server.c
index 5b502ef..e565816 100644
--- a/server.c
+++ b/server.c
@@ -58,25 +58,25 @@ static void tilesMap(void) {
 
 static struct Tile *tileGet(uint32_t tileX, uint32_t tileY) {
 	struct Tile *tile = &tiles[tileY * TILE_ROWS + tileX];
-	if (!tile->createTime) {
+	if (!tile->meta.createTime) {
 		memset(tile->cells, ' ', CELLS_SIZE);
 		memset(tile->colors, COLOR_WHITE, CELLS_SIZE);
-		tile->createTime = time(NULL);
+		tile->meta.createTime = time(NULL);
 	}
 	return tile;
 }
 
 static struct Tile *tileAccess(uint32_t tileX, uint32_t tileY) {
 	struct Tile *tile = tileGet(tileX, tileY);
-	tile->accessTime = time(NULL);
-	tile->accessCount++;
+	tile->meta.accessTime = time(NULL);
+	tile->meta.accessCount++;
 	return tile;
 }
 
 static struct Tile *tileModify(uint32_t tileX, uint32_t tileY) {
 	struct Tile *tile = tileGet(tileX, tileY);
-	tile->modifyTime = time(NULL);
-	tile->modifyCount++;
+	tile->meta.modifyTime = time(NULL);
+	tile->meta.modifyCount++;
 	return tile;
 }
 
@@ -282,15 +282,7 @@ static bool clientMap(const struct Client *client) {
 		for (int32_t x = 0; x < MAP_COLS; ++x) {
 			uint32_t tileY = ((mapY + y) % TILE_ROWS + TILE_ROWS) % TILE_ROWS;
 			uint32_t tileX = ((mapX + x) % TILE_COLS + TILE_COLS) % TILE_COLS;
-
-			const struct Tile *tile = &tiles[tileY * TILE_ROWS + tileX];
-			map.tiles[y][x] = (struct MapTile) {
-				.createTime = tile->createTime,
-				.modifyTime = tile->modifyTime,
-				.accessTime = tile->accessTime,
-				.modifyCount = tile->modifyCount,
-				.accessCount = tile->accessCount,
-			};
+			map.meta[y][x] = tiles[tileY * TILE_ROWS + tileX].meta;
 		}
 	}