summaryrefslogtreecommitdiff
path: root/src/map/pc_groups.h
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-11-06 21:23:31 -0200
committershennetsind <ind@henn.et>2013-11-06 21:23:31 -0200
commitd56017e3d1bf783cfdc67a702d2b70a0a27c8863 (patch)
treea47bd0ef6340ce1d011d198f430c7d96d620afe0 /src/map/pc_groups.h
parent5c94e76753c0cdb4ffb7dabbd6e135f1f7d42ef2 (diff)
parent3a3d2297068809d25ca43e19fd2977f97b2728f5 (diff)
downloadhercules-d56017e3d1bf783cfdc67a702d2b70a0a27c8863.tar.gz
hercules-d56017e3d1bf783cfdc67a702d2b70a0a27c8863.tar.bz2
hercules-d56017e3d1bf783cfdc67a702d2b70a0a27c8863.tar.xz
hercules-d56017e3d1bf783cfdc67a702d2b70a0a27c8863.zip
Merge remote-tracking branch 'upstream/master'
Signed-off-by: shennetsind <ind@henn.et> Conflicts: src/map/pc.c
Diffstat (limited to 'src/map/pc_groups.h')
-rw-r--r--src/map/pc_groups.h66
1 files changed, 43 insertions, 23 deletions
diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h
index 8f350c2b6..28c82d619 100644
--- a/src/map/pc_groups.h
+++ b/src/map/pc_groups.h
@@ -32,34 +32,54 @@ enum e_pc_permission {
PC_PERM_HCHSYS_ADMIN = 0x200000,
};
-/// Total number of PC permissions (without PC_PERM_NONE).
-/// This is manifest constant for the size of pc_g_permission_name array,
-/// so it's possible to apply sizeof to it [C-FAQ 1.24]
-/// Whenever adding new permission: 1. add enum entry above, 2. add entry into
-/// pc_g_permission_name (in pc.c), 3. increase NUM_PC_PERM below by 1.
-#define NUM_PC_PERM 22
-
-struct pc_permission_name_table {
- const char *name;
- enum e_pc_permission permission;
+// Cached config settings for quick lookup
+struct GroupSettings {
+ unsigned int id; // groups.[].id
+ int level; // groups.[].level
+ char *name; // copy of groups.[].name
+ unsigned int e_permissions; // packed groups.[].permissions
+ bool log_commands; // groups.[].log_commands
+ int index; // internal index of the group (contiguous range starting at 0) [Ind]
+ /// Following are used/available only during config reading
+ config_setting_t *commands; // groups.[].commands
+ config_setting_t *permissions; // groups.[].permissions
+ config_setting_t *inherit; // groups.[].inherit
+ bool inheritance_done; // have all inheritance rules been evaluated?
+ config_setting_t *root; // groups.[]
};
-/// Name <-> enum table for PC permissions
-extern const struct pc_permission_name_table pc_g_permission_name[NUM_PC_PERM];
+struct pc_groups_permission_table {
+ char *name;
+ unsigned int permission;
+};
typedef struct GroupSettings GroupSettings;
-GroupSettings* pc_group_get_dummy_group(void);
-bool pc_group_exists(int group_id);
-GroupSettings* pc_group_id2group(int group_id);
-bool pc_group_has_permission(GroupSettings *group, enum e_pc_permission permission);
-bool pc_group_should_log_commands(GroupSettings *group);
-const char* pc_group_get_name(GroupSettings *group);
-int pc_group_get_level(GroupSettings *group);
-int pc_group_get_idx(GroupSettings *group);
+struct pc_groups_interface {
+ /* */
+ DBMap* db; // id -> GroupSettings
+ DBMap* name_db; // name -> GroupSettings
+ /* */
+ struct pc_groups_permission_table *permissions;
+ unsigned char permission_count;
+ /* */
+ void (*init) (void);
+ void (*final) (void);
+ void (*reload) (void);
+ /* */
+ GroupSettings* (*get_dummy_group) (void);
+ bool (*exists) (int group_id);
+ GroupSettings* (*id2group) (int group_id);
+ bool (*has_permission) (GroupSettings *group, unsigned int permission);
+ bool (*should_log_commands) (GroupSettings *group);
+ const char* (*get_name) (GroupSettings *group);
+ int (*get_level) (GroupSettings *group);
+ int (*get_idx) (GroupSettings *group);
+ unsigned int (*add_permission) (const char *name);
+};
+
+struct pc_groups_interface *pcg;
-void do_init_pc_groups(void);
-void do_final_pc_groups(void);
-void pc_groups_reload(void);
+void pc_groups_defaults(void);
#endif // _PC_GROUPS_H_