about summary refs log tree commit diff homepage
path: root/server.c
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2017-08-29 18:33:59 -0400
committerJune McEnroe <programble@gmail.com>2017-08-29 18:33:59 -0400
commit931289b9c11fbf1ba61442f83b3199e44bebaaf2 (patch)
tree277a960369d79e64a0b783b22b52c51220d2587a /server.c
parentAdd respawning (diff)
downloadtorus-931289b9c11fbf1ba61442f83b3199e44bebaaf2.tar.gz
torus-931289b9c11fbf1ba61442f83b3199e44bebaaf2.zip
Add four additional spawns
Diffstat (limited to '')
-rw-r--r--server.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/server.c b/server.c
index 50a9e9c..6992dc5 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);
     }
 }