summaryrefslogtreecommitdiff
path: root/src/map/pc_groups.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/pc_groups.h')
-rw-r--r--src/map/pc_groups.h82
1 files changed, 56 insertions, 26 deletions
diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h
index 8f350c2b6..5c03f999f 100644
--- a/src/map/pc_groups.h
+++ b/src/map/pc_groups.h
@@ -2,8 +2,8 @@
// See the LICENSE file
// Portions Copyright (c) Athena Dev Teams
-#ifndef _PC_GROUPS_H_
-#define _PC_GROUPS_H_
+#ifndef _MAP_PC_GROUPS_H_
+#define _MAP_PC_GROUPS_H_
/// PC permissions
enum e_pc_permission {
@@ -30,36 +30,66 @@ enum e_pc_permission {
PC_PERM_DISABLE_PVP = 0x080000, // #20
PC_PERM_DISABLE_CMD_DEAD = 0x100000,
PC_PERM_HCHSYS_ADMIN = 0x200000,
+ PC_PERM_TRADE_BOUND = 0x400000,
};
-/// 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
+// 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.[]
+};
+
+typedef struct GroupSettings GroupSettings;
-struct pc_permission_name_table {
- const char *name;
- enum e_pc_permission permission;
+struct pc_groups_permission_table {
+ char *name;
+ unsigned int permission;
};
-/// Name <-> enum table for PC permissions
-extern const struct pc_permission_name_table pc_g_permission_name[NUM_PC_PERM];
+/* used by plugins to list permissions */
+struct pc_groups_new_permission {
+ unsigned int pID;/* plugin identity (for the future unload during runtime support) */
+ char *name;/* aStrdup' of the permission name */
+ unsigned int *mask;/* pointer to the plugin val that will store the value of the mask */
+};
-typedef struct GroupSettings GroupSettings;
+struct pc_groups_interface {
+ /* */
+ DBMap* db; // id -> GroupSettings
+ DBMap* name_db; // name -> GroupSettings
+ /* */
+ struct pc_groups_permission_table *permissions;
+ unsigned char permission_count;
+ /* */
+ struct pc_groups_new_permission *HPMpermissions;
+ unsigned char HPMpermissions_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);
+};
-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 *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_
+#endif /* _MAP_PC_GROUPS_H_ */