]> git.lizzy.rs Git - dragonblocks_alpha.git/blobdiff - src/servercommands.c
Redesign map handling
[dragonblocks_alpha.git] / src / servercommands.c
index 8975d6a39599d31cbec62dfe7d258d1b8ee262a0..f8b4dd762ce3df63a9b506cb798f7b4058f2684d 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include "mapgen.h"
 #include "server.h"
+#include "servermap.h"
 #include "util.h"
 
 static bool disconnect_handler(Client *client, bool good)
@@ -11,17 +11,6 @@ static bool disconnect_handler(Client *client, bool good)
        return true;
 }
 
-static bool send_map(Client *client)
-{
-       for (size_t s = 0; s < client->server->map->sectors.siz; s++) {
-               MapSector *sector = map_get_sector_raw(client->server->map, s);
-               for (size_t b = 0; b < sector->blocks.siz; b++)
-                       if (! (write_u32(client->fd, CC_BLOCK) && map_serialize_block(client->fd, map_get_block_raw(sector, b))))
-                               return false;
-       }
-       return true;
-}
-
 static bool auth_handler(Client *client, bool good)
 {
        char *name = read_string(client->fd, NAME_MAX);
@@ -41,13 +30,13 @@ static bool auth_handler(Client *client, bool good)
        if (success) {
                client->name = name;
                client->state = CS_ACTIVE;
-               mapgen_start_thread(client);
+               servermap_add_client(client);
        } else {
                free(name);
        }
 
        pthread_mutex_lock(&client->mtx);
-       bool ret = write_u32(client->fd, CC_AUTH) && write_u8(client->fd, success) && (success ? send_map(client) : true);
+       bool ret = write_u32(client->fd, CC_AUTH) && write_u8(client->fd, success);
        pthread_mutex_unlock(&client->mtx);
 
        return ret;