about summary refs log tree commit diff homepage
path: root/server.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2017-07-30 15:40:31 -0400
committerJune McEnroe <june@causal.agency>2017-07-30 15:40:31 -0400
commitfe8ff9c8b368a5ae97ca3dea9472c13afe8e8eae (patch)
tree83b314142a05260c042819b65ba698dea6fbcd28 /server.c
parentAdd ostensible support for background colors (diff)
downloadtorus-fe8ff9c8b368a5ae97ca3dea9472c13afe8e8eae.tar.gz
torus-fe8ff9c8b368a5ae97ca3dea9472c13afe8e8eae.zip
Track color only client-side
Diffstat (limited to 'server.c')
-rwxr-xr-xserver.c14
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: