From af645c09089d1ed8e99c760f05234ac3df402901 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Tue, 29 Aug 2017 18:33:59 -0400 Subject: Add four additional spawns --- server.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'server.c') 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); } } -- cgit 1.4.1