summaryrefslogtreecommitdiff
path: root/src/map/pc_groups.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-09-18 13:09:16 +0200
committerHaru <haru@dotalux.com>2015-09-25 12:55:36 +0200
commit1aea178ef7cdb76eda5600540b5fbd29fd54ff88 (patch)
tree855d4feafba212d7f36872c1b46814c1f1a85e75 /src/map/pc_groups.c
parente99bf73af31a8b1f09b9ce033c16832ee5cac51d (diff)
downloadhercules-1aea178ef7cdb76eda5600540b5fbd29fd54ff88.tar.gz
hercules-1aea178ef7cdb76eda5600540b5fbd29fd54ff88.tar.bz2
hercules-1aea178ef7cdb76eda5600540b5fbd29fd54ff88.tar.xz
hercules-1aea178ef7cdb76eda5600540b5fbd29fd54ff88.zip
More aggressive whitespace cleanup. Follow up to 51329e6
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/pc_groups.c')
-rw-r--r--src/map/pc_groups.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index 28bef6a85..7efcd7e26 100644
--- a/src/map/pc_groups.c
+++ b/src/map/pc_groups.c
@@ -51,7 +51,7 @@ static void read_config(void) {
config_setting_t *groups = NULL;
const char *config_filename = "conf/groups.conf"; // FIXME hardcoded name
int group_count = 0;
-
+
if (libconfig->read_file(&pc_group_config, config_filename))
return;
@@ -125,11 +125,10 @@ static void read_config(void) {
strdb_put(pcg->name_db, groupname, group_settings);
idb_put(pcg->db, id, group_settings);
-
}
group_count = libconfig->setting_length(groups); // Save number of groups
assert(group_count == db_size(pcg->db));
-
+
// Check if all commands and permissions exist
iter = db_iterator(pcg->db);
for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
@@ -182,7 +181,7 @@ static void read_config(void) {
*commands = group_settings->commands,
*permissions = group_settings->permissions;
int j, inherit_count = 0, done = 0;
-
+
if (group_settings->inheritance_done) // group already processed
continue;
@@ -192,7 +191,7 @@ static void read_config(void) {
group_settings->inheritance_done = true;
continue;
}
-
+
for (j = 0; j < inherit_count; ++j) {
GroupSettings *inherited_group = NULL;
const char *groupname = libconfig->setting_get_string_elem(inherit, j);
@@ -225,7 +224,7 @@ static void read_config(void) {
++done; // copied commands and permissions from one of inherited groups
}
-
+
if (done == inherit_count) { // copied commands from all of inherited groups
++i;
group_settings->inheritance_done = true; // we're done with this group
@@ -239,7 +238,7 @@ static void read_config(void) {
break;
}
} // while(i < group_count)
-
+
// Pack permissions into GroupSettings.e_permissions for faster checking
iter = db_iterator(pcg->db);
for (group_settings = dbi_first(iter); dbi_exists(iter); group_settings = dbi_next(iter)) {
@@ -365,28 +364,28 @@ int pc_group_get_idx(GroupSettings *group)
unsigned int pc_groups_add_permission(const char *name) {
uint64 key = 0x1;
unsigned char i;
-
+
for(i = 0; i < pcg->permission_count; i++) {
if( strcmpi(name,pcg->permissions[i].name) == 0 ) {
ShowError("pc_groups_add_permission(%s): failed! duplicate permission name!\n",name);
return 0;
}
}
-
+
if( i != 0 )
key = (uint64)pcg->permissions[i - 1].permission << 1;
-
+
if( key >= UINT_MAX ) {
ShowError("pc_groups_add_permission(%s): failed! not enough room, too many permissions!\n",name);
return 0;
}
-
+
i = pcg->permission_count;
RECREATE(pcg->permissions, struct pc_groups_permission_table, ++pcg->permission_count);
-
+
pcg->permissions[i].name = aStrdup(name);
pcg->permissions[i].permission = (unsigned int)key;
-
+
return (unsigned int)key;
}
/**
@@ -427,23 +426,23 @@ void do_init_pc_groups(void) {
{ "disable_skill_usage", PC_PERM_DISABLE_SKILL_USAGE },
};
unsigned char i, len = ARRAYLENGTH(pc_g_defaults);
-
+
for(i = 0; i < len; i++) {
unsigned int p;
if( ( p = pc_groups_add_permission(pc_g_defaults[i].name) ) != pc_g_defaults[i].permission )
ShowError("do_init_pc_groups: %s error : %d != %d\n",pc_g_defaults[i].name,p,pc_g_defaults[i].permission);
}
-
+
/**
* Handle plugin-provided permissions
**/
for(i = 0; i < pcg->HPMpermissions_count; i++) {
*pcg->HPMpermissions[i].mask = pc_groups_add_permission(pcg->HPMpermissions[i].name);
}
-
+
pcg->db = idb_alloc(DB_OPT_RELEASE_DATA);
pcg->name_db = stridb_alloc(DB_OPT_DUP_KEY, 0);
-
+
read_config();
}
@@ -468,7 +467,7 @@ void do_final_pc_groups(void)
pcg->db->destroy(pcg->db, group_db_clear_sub);
if (pcg->name_db != NULL)
db_destroy(pcg->name_db);
-
+
if(pcg->permissions != NULL) {
unsigned char i;
for(i = 0; i < pcg->permission_count; i++)
@@ -490,7 +489,7 @@ void pc_groups_reload(void) {
pcg->final();
pcg->init();
-
+
/* refresh online users permissions */
iter = mapit_getallusers();
for (sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter)) {
@@ -508,7 +507,6 @@ void pc_groups_reload(void) {
**/
void pc_groups_defaults(void) {
pcg = &pcg_s;
-
/* */
pcg->db = NULL;
pcg->name_db = NULL;