diff options
author | June McEnroe <programble@gmail.com> | 2017-07-30 15:40:31 -0400 |
---|---|---|
committer | June McEnroe <programble@gmail.com> | 2017-07-30 15:40:31 -0400 |
commit | 2093f255cd2874b6d9fb2545b28df074acbcc72e (patch) | |
tree | 93554e45454a71a8c51c7131266d465ec66a8d27 /server.c | |
parent | Add ostensible support for background colors (diff) | |
download | torus-2093f255cd2874b6d9fb2545b28df074acbcc72e.tar.gz torus-2093f255cd2874b6d9fb2545b28df074acbcc72e.zip |
Track color only client-side
Diffstat (limited to '')
-rwxr-xr-x | server.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/server.c b/server.c index e96d3dd..8892d2d 100755 --- a/server.c +++ b/server.c @@ -54,7 +54,6 @@ static struct Client { uint32_t tileY; uint8_t cellX; uint8_t cellY; - uint8_t color; struct Client *prev; struct Client *next; @@ -69,7 +68,6 @@ static struct Client *clientAdd(int fd) { client->tileY = TILE_INIT_Y; client->cellX = CELL_INIT_X; client->cellY = CELL_INIT_Y; - client->color = COLOR_WHITE; client->prev = NULL; if (clientHead) { @@ -161,15 +159,15 @@ static bool clientMove(struct Client *client, int8_t dx, uint8_t dy) { return true; } -static bool clientPut(struct Client *client, char cell) { +static bool clientPut(struct Client *client, uint8_t color, char cell) { struct Tile *tile = tileGet(client->tileX, client->tileY); - tile->colors[client->cellY][client->cellX] = client->color; + tile->colors[client->cellY][client->cellX] = color; tile->cells[client->cellY][client->cellX] = cell; struct ServerMessage msg = { .type = SERVER_PUT }; msg.data.p.cellX = client->cellX; msg.data.p.cellY = client->cellY; - msg.data.p.color = client->color; + msg.data.p.color = color; msg.data.p.cell = cell; return clientCast(client, &msg); } @@ -259,12 +257,8 @@ int main() { clientMove(client, msg.data.m.dx, msg.data.m.dy); break; - case CLIENT_COLOR: - client->color = msg.data.c; - break; - case CLIENT_PUT: - clientPut(client, msg.data.p); + clientPut(client, msg.data.p.color, msg.data.p.cell); break; default: |