diff options
Diffstat (limited to '')
-rw-r--r-- | torus.h | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/torus.h b/torus.h index 41c662b..b9d842f 100644 --- a/torus.h +++ b/torus.h @@ -57,7 +57,7 @@ static const wchar_t CP437[256] = ( ); enum { - CellRows = 24, + CellRows = 25, CellCols = 80, }; static const size_t CellsSize = sizeof(uint8_t[CellRows][CellCols]); @@ -74,24 +74,50 @@ struct Meta { }; struct Tile { - alignas(4096) uint8_t cells[CellRows][CellCols]; - uint8_t colors[CellRows][CellCols]; - struct Meta meta; + alignas(4096) + time_t createTime; + time_t modifyTime; + alignas(16) uint8_t cells[CellRows][CellCols]; + alignas(16) uint8_t colors[CellRows][CellCols]; + uint32_t modifyCount; + uint32_t accessCount; + time_t accessTime; }; static_assert(4096 == sizeof(struct Tile), "struct Tile is page-sized"); +static inline struct Meta tileMeta(const struct Tile *tile) { + return (struct Meta) { + .createTime = tile->createTime, + .modifyTime = tile->modifyTime, + .accessTime = tile->accessTime, + .modifyCount = tile->modifyCount, + .accessCount = tile->accessCount, + }; +} + enum { - TileRows = 64, - TileCols = 64, + TileRows = 512, + TileCols = 512, }; static const size_t TilesSize = sizeof(struct Tile[TileRows][TileCols]); -static const uint32_t TileInitX = TileCols / 2; -static const uint32_t TileInitY = TileRows / 2; +static const uint32_t TileInitX = 0; +static const uint32_t TileInitY = 0; + +static const struct { + uint32_t tileX; + uint32_t tileY; +} Ports[] = { + { TileInitX, TileInitY }, + { TileCols * 3 / 4, TileRows * 3 / 4 }, // NW + { TileCols * 1 / 4, TileRows * 3 / 4 }, // NE + { TileCols * 1 / 4, TileRows * 1 / 4 }, // SE + { TileCols * 3 / 4, TileRows * 1 / 4 }, // SW +}; enum { - MapRows = 7, - MapCols = 7, + MapRows = 11, + MapCols = 11, }; struct Map { @@ -137,6 +163,7 @@ struct ClientMessage { ClientFlip, ClientPut, ClientMap, + ClientTele, } type; union { struct { @@ -147,5 +174,6 @@ struct ClientMessage { uint8_t color; uint8_t cell; } put; + uint8_t port; }; }; |