diff options
author | Piotr HaĆaczkiewicz <piotr.halaczkiewicz@gmail.com> | 2013-07-24 12:41:50 +0200 |
---|---|---|
committer | Piotr HaĆaczkiewicz <piotr.halaczkiewicz@gmail.com> | 2013-07-29 21:51:08 +0200 |
commit | e7750ecfff5bf856ecc9f38ea327c6b6cc535761 (patch) | |
tree | 163859983acdced47483f0d4fb480377da5b5be2 /src/map/map.c | |
parent | 640c66779d8da4baa8af6bd0fee2583ec2b6143c (diff) | |
download | hercules-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/map.c')
-rw-r--r-- | src/map/map.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/map/map.c b/src/map/map.c index dbada2e96..55ec5effa 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -134,6 +134,8 @@ char *map_cache_buffer = NULL; // Has the uncompressed gat data of all maps, so struct map_interface iMap_s; +struct map_session_data *cpsd; + /*========================================== * server player count (of all mapservers) *------------------------------------------*/ @@ -4901,6 +4903,7 @@ void do_final(void) ShowStatus("Terminating...\n"); hChSys.closing = true; HPM->event(HPET_FINAL); + if (cpsd) aFree(cpsd); //Ladies and babies first. iter = mapit_getallusers(); @@ -5076,7 +5079,7 @@ static bool map_arg_next_value(const char* option, int i, int argc) return true; } -struct map_session_data cpsd; + CPCMD(gm_position) { int x = 0, y = 0, m = 0; char map_name[25]; @@ -5097,9 +5100,9 @@ CPCMD(gm_position) { } ShowInfo("HCP: updated console's game position to '"CL_WHITE"%d %d %s"CL_RESET"'\n",x,y,map_name); - cpsd.bl.x = x; - cpsd.bl.y = y; - cpsd.bl.m = m; + cpsd->bl.x = x; + cpsd->bl.y = y; + cpsd->bl.m = m; } CPCMD(gm_use) { @@ -5107,23 +5110,23 @@ CPCMD(gm_use) { ShowError("gm:use invalid syntax. use '"CL_WHITE"gm:use @command <optional params>"CL_RESET"'\n"); return; } - cpsd.fd = -2; - if( !atcommand->parse(cpsd.fd, &cpsd, line, 0) ) + cpsd->fd = -2; + if( !atcommand->parse(cpsd->fd, cpsd, line, 0) ) ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' failed\n",line); else ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' was used\n",line); - cpsd.fd = 0; + cpsd->fd = 0; } /* Hercules Console Parser */ void map_cp_defaults(void) { #ifdef CONSOLE_INPUT /* default HCP data */ - memset(&cpsd, 0, sizeof(struct map_session_data)); - strcpy(cpsd.status.name, "Hercules Console"); - cpsd.bl.x = 150; - cpsd.bl.y = 150; - cpsd.bl.m = iMap->mapname2mapid("prontera"); + cpsd = pc->get_dummy_sd(); + strcpy(cpsd->status.name, "Hercules Console"); + cpsd->bl.x = MAP_DEFAULT_X; + cpsd->bl.y = MAP_DEFAULT_Y; + cpsd->bl.m = iMap->mapname2mapid(MAP_DEFAULT); console->addCommand("gm:info",CPCMD_A(gm_position)); console->addCommand("gm:use",CPCMD_A(gm_use)); |