about summary refs log tree commit diff homepage
path: root/server.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2017-08-29 18:33:59 -0400
committerJune McEnroe <june@causal.agency>2017-08-29 18:33:59 -0400
commitaf645c09089d1ed8e99c760f05234ac3df402901 (patch)
tree34d0e446f96cd3c9944b651ad98cf07dfe7a3df7 /server.c
parentAdd respawning (diff)
downloadtorus-af645c09089d1ed8e99c760f05234ac3df402901.tar.gz
torus-af645c09089d1ed8e99c760f05234ac3df402901.zip
Add four additional spawns
Diffstat (limited to 'server.c')
-rw-r--r--server.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/server.c b/server.c
index a22046f..3836f5d 100644
--- a/server.c
+++ b/server.c
@@ -224,10 +224,11 @@ static bool clientUpdate(struct Client *client, struct Client *old) {
     return true;
 }
 
-static bool clientSpawn(struct Client *client) {
+static bool clientSpawn(struct Client *client, uint8_t spawn) {
+    if (spawn >= SPAWN_COUNT) return false;
     struct Client old = *client;
-    client->tileX = TILE_INIT_X;
-    client->tileY = TILE_INIT_Y;
+    client->tileX = SPAWN[spawn].tileX;
+    client->tileY = SPAWN[spawn].tileY;
     client->cellX = CELL_INIT_X;
     client->cellY = CELL_INIT_Y;
     return clientUpdate(client, &old);
@@ -333,7 +334,7 @@ int main() {
             } else if (msg.type == CLIENT_PUT) {
                 success = clientPut(client, msg.data.p.color, msg.data.p.cell);
             } else if (msg.type == CLIENT_SPAWN) {
-                success = clientSpawn(client);
+                success = clientSpawn(client, msg.data.s.spawn);
             }
             if (!success) clientRemove(client);
 
@@ -359,6 +360,6 @@ int main() {
         nevents = kevent(kq, &event, 1, NULL, 0, NULL);
         if (nevents < 0) err(EX_OSERR, "kevent");
 
-        if (!clientSpawn(client)) clientRemove(client);
+        if (!clientSpawn(client, 0)) clientRemove(client);
     }
 }