aboutsummaryrefslogtreecommitdiff
path: root/src/userdb.c
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2016-05-19 16:47:06 -0400
committerFranklin Wei <git@fwei.tk>2016-05-19 16:47:06 -0400
commitcb8af6e7bf5f6e70fc9722d36448213c719e83c8 (patch)
treeec9f93d6e1256d62a49fb628d8d7a3a931b58330 /src/userdb.c
parent7f3ba14388a586a946d721a71eb3a9862f7f6c02 (diff)
downloadnetcosm-cb8af6e7bf5f6e70fc9722d36448213c719e83c8.zip
netcosm-cb8af6e7bf5f6e70fc9722d36448213c719e83c8.tar.gz
netcosm-cb8af6e7bf5f6e70fc9722d36448213c719e83c8.tar.bz2
netcosm-cb8af6e7bf5f6e70fc9722d36448213c719e83c8.tar.xz
implement more of dunnet
Diffstat (limited to 'src/userdb.c')
-rw-r--r--src/userdb.c13
1 files changed, 13 insertions, 0 deletions
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);