summaryrefslogtreecommitdiff
path: root/src/map/pc.h
diff options
context:
space:
mode:
authorPiotr HaƂaczkiewicz <piotr.halaczkiewicz@gmail.com>2013-07-24 12:41:50 +0200
committerPiotr HaƂaczkiewicz <piotr.halaczkiewicz@gmail.com>2013-07-29 21:51:08 +0200
commite7750ecfff5bf856ecc9f38ea327c6b6cc535761 (patch)
tree163859983acdced47483f0d4fb480377da5b5be2 /src/map/pc.h
parent640c66779d8da4baa8af6bd0fee2583ec2b6143c (diff)
downloadhercules-e7750ecfff5bf856ecc9f38ea327c6b6cc535761.tar.gz
hercules-e7750ecfff5bf856ecc9f38ea327c6b6cc535761.tar.bz2
hercules-e7750ecfff5bf856ecc9f38ea327c6b6cc535761.tar.xz
hercules-e7750ecfff5bf856ecc9f38ea327c6b6cc535761.zip
Permission cache overhaul
* Reworked group permission caching in session data (follow-up to cd45c30ab2dcc44bfbfac283d15bb09b3d4644bc) * Removed duplicated information from session data in favor of direct pointer to group settings. * Added getters for all group data required to process permissions and related stuff. * Added new functions to PC interface and updated calls everywhere. * Extracted function to set new group for a player (used at login, group config reload, manual adjustment of group). * Moved command permission config parsing to atcommand module. * Improved dummy map session handling. * Since it's required for all map sessions to have a valid group, dummy sessions are now created by a designated function. * Updated related code that uses dummy sessions (console `gm use` and script `atcommand`, `useatcmd`). * Various minor improvements and cleanups. * Eliminated some global variables related to loading atcommand permissions for group by passing them directly to function. * Moved definition of global array holding PC permission names from header file to source file. * Streamlined destuction of atcommands database to use DBApply helper function instead of DBIterator. * Replaced hardcoded position of console dummy session with defines from mapindex.h (thx Haruna for pointing it out). * Removed fixed length restriction on group names.
Diffstat (limited to 'src/map/pc.h')
-rw-r--r--src/map/pc.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/map/pc.h b/src/map/pc.h
index 8544650a3..ab6de114e 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -12,15 +12,16 @@
#include "battleground.h"
#include "buyingstore.h" // struct s_buyingstore
#include "itemdb.h"
+#include "log.h"
#include "map.h" // RC_MAX
+#include "mob.h"
+#include "pc_groups.h"
#include "script.h" // struct script_reg, struct script_regstr
#include "searchstore.h" // struct s_search_store_info
#include "status.h" // OPTION_*, struct weapon_atk
#include "unit.h" // unit_stop_attack(), unit_stop_walking()
#include "vending.h" // struct s_vending
-#include "mob.h"
-#include "log.h"
-#include "pc_groups.h"
+
#define MAX_PC_BONUS 10
#define MAX_PC_SKILL_REQUIRE 5
@@ -181,9 +182,11 @@ struct map_session_data {
} special_state;
int login_id1, login_id2;
unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex]
- int group_id, group_pos, group_level;
- unsigned int permissions;/* group permissions */
- bool group_log_command;
+
+ /// Groups & permissions
+ int group_id;
+ GroupSettings *group;
+ unsigned int extra_temp_permissions; /* permissions from @addperm */
struct mmo_charstatus status;
struct registry save_reg;
@@ -685,9 +688,6 @@ enum equip_pos {
#define pc_get_group_id(sd) ( (sd)->group_id )
-#define pc_has_permission(sd, permission) ( ((sd)->permissions&permission) != 0 )
-#define pc_should_log_commands(sd) ( (sd)->group_log_command != false )
-
#define pc_checkoverhp(sd) ((sd)->battle_status.hp == (sd)->battle_status.max_hp)
#define pc_checkoversp(sd) ((sd)->battle_status.sp == (sd)->battle_status.max_sp)
@@ -751,13 +751,17 @@ struct pc_interface {
/* funcs */
+ struct map_session_data* (*get_dummy_sd) (void);
int (*class2idx) (int class_);
int (*get_group_level) (struct map_session_data *sd);
//int (*getrefinebonus) (int lv,int type); FIXME: This function does not exist, nor it is ever called
bool (*can_give_items) (struct map_session_data *sd);
bool (*can_use_command) (struct map_session_data *sd, const char *command);
-
+ bool (*has_permission) (struct map_session_data *sd, enum e_pc_permission permission);
+ int (*set_group) (struct map_session_data *sd, int group_id);
+ bool (*should_log_commands) (struct map_session_data *sd);
+
int (*setrestartvalue) (struct map_session_data *sd,int type);
int (*makesavestatus) (struct map_session_data *);
void (*respawn) (struct map_session_data* sd, clr_type clrtype);