From cb8af6e7bf5f6e70fc9722d36448213c719e83c8 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Thu, 19 May 2016 16:47:06 -0400 Subject: implement more of dunnet --- src/userdb.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/userdb.c') diff --git a/src/userdb.c b/src/userdb.c index 0ebe159..14e9fd8 100644 --- a/src/userdb.c +++ b/src/userdb.c @@ -26,6 +26,7 @@ #include "server.h" #include "server_reqs.h" #include "userdb.h" +#include "world.h" static void *map = NULL; static char *db_file = NULL; @@ -101,6 +102,10 @@ void userdb_init(const char *file) } } + /* now we read in the world module's data, if possible */ + if(netcosm_read_userdata_cb) + data->userdata = netcosm_read_userdata_cb(fd); + hash_insert(map, data->username, data); } @@ -124,8 +129,10 @@ bool userdb_write(const char *file) if(!user) break; + /* dump structure */ write(fd, user, sizeof(*user)); + /* now go back and write what the pointers are pointing at */ size_t n_objects; if(user->objects) n_objects = obj_count_noalias(user->objects); @@ -158,6 +165,12 @@ bool userdb_write(const char *file) } } } + + /* write world module's data, if possible */ + if(netcosm_write_userdata_cb) + { + netcosm_write_userdata_cb(fd, user->userdata); + } } close(fd); -- cgit v1.1