# HG changeset patch # User LordOfWar # Date 2009-11-11 03:05:19 # Node ID 16f1b9b211d7f3c4c76ec13cd3060dc488fd8e6d # Parent be36b7f5a0a6162be610e07fcfe8de2188c5d34e started the user manager, a lot of stuff to go... diff --git a/src/server/user_mgr.c b/src/server/user_mgr.c --- a/src/server/user_mgr.c +++ b/src/server/user_mgr.c @@ -18,3 +18,49 @@ */ #include "user_mgr.h" +#include "malloc.h" + +struct user_mgr_info +{ + struct user *user_array; + int current_users; +} user_mgr_info; + +int resize_user_array() +{ + int counter; + int counter2; + + // create array twice the size of the current amount of users + struct user *new_user_array = malloc(sizeof(struct user) * user_mgr_info.current_users * 2); + + // this copies the original user_array over to the new one + // using two counters allows the array to be resized at any time + // leaving exactly 1 open space between each user when it is done; + counter2 = 0; + for(counter = 0; counter < user_mgr_info.current_users; counter++) + { + if(user_mgr_info.user_array[counter].username != 0) + { + new_user_array[counter2*2] = user_mgr_info.user_array[counter]; + counter2++; + } + } + + // cleanup old array + free(user_mgr_info.user_array); + + // change the pointer to point to the new user array + user_mgr_info.user_array = new_user_array; + + return 1; +} + +int initialize_users() +{ + // pull data from XML file + + // if XML file is not found create new array of size 50 + + return 1; +} diff --git a/src/server/user_mgr.h b/src/server/user_mgr.h --- a/src/server/user_mgr.h +++ b/src/server/user_mgr.h @@ -25,6 +25,11 @@ #ifndef _DISTREN_USER_MGR_H #define _DISTREN_USER_MGR_H - +struct user +{ + char *username; + int render_power; + int last_job; +}; #endif