diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/HPM.c | 69 | ||||
-rw-r--r-- | src/common/HPM.h | 11 | ||||
-rw-r--r-- | src/common/HPMi.h | 11 | ||||
-rw-r--r-- | src/common/db.c | 6 | ||||
-rw-r--r-- | src/common/ers.c | 4 | ||||
-rw-r--r-- | src/common/ers.h | 9 | ||||
-rw-r--r-- | src/common/malloc.c | 33 | ||||
-rw-r--r-- | src/common/malloc.h | 4 | ||||
-rw-r--r-- | src/map/atcommand.c | 122 | ||||
-rw-r--r-- | src/map/battle.c | 10 | ||||
-rw-r--r-- | src/map/buyingstore.c | 10 | ||||
-rw-r--r-- | src/map/chat.c | 4 | ||||
-rw-r--r-- | src/map/clif.c | 46 | ||||
-rw-r--r-- | src/map/intif.c | 12 | ||||
-rw-r--r-- | src/map/mail.c | 8 | ||||
-rw-r--r-- | src/map/map.c | 4 | ||||
-rw-r--r-- | src/map/mapreg_sql.c | 2 | ||||
-rw-r--r-- | src/map/mob.c | 3 | ||||
-rw-r--r-- | src/map/party.c | 2 | ||||
-rw-r--r-- | src/map/pc.c | 59 | ||||
-rw-r--r-- | src/map/pc.h | 8 | ||||
-rw-r--r-- | src/map/pet.c | 2 | ||||
-rw-r--r-- | src/map/script.c | 10 | ||||
-rw-r--r-- | src/map/skill.c | 19 | ||||
-rw-r--r-- | src/map/storage.c | 12 | ||||
-rw-r--r-- | src/map/trade.c | 8 | ||||
-rw-r--r-- | src/map/vending.c | 6 | ||||
-rw-r--r-- | src/plugins/sample.c | 13 |
28 files changed, 307 insertions, 200 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c index 005bc2ddc..426fac94a 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -215,6 +215,7 @@ struct hplugin *hplugin_load(const char* filename) { plugin->hpi->HookStop = HPM->import_symbol("HookStop",plugin->idx); plugin->hpi->HookStopped = HPM->import_symbol("HookStopped",plugin->idx); plugin->hpi->addArg = HPM->import_symbol("addArg",plugin->idx); + plugin->hpi->addConf = HPM->import_symbol("addConf",plugin->idx); /* server specific */ if( HPM->load_sub ) HPM->load_sub(plugin); @@ -532,6 +533,9 @@ void* HPM_calloc(size_t num, size_t size, const char *file, int line, const char void* HPM_realloc(void *p, size_t size, const char *file, int line, const char *func) { return iMalloc->realloc(p,size,HPM_file2ptr(file),line,func); } +void* HPM_reallocz(void *p, size_t size, const char *file, int line, const char *func) { + return iMalloc->reallocz(p,size,HPM_file2ptr(file),line,func); +} char* HPM_astrdup(const char *p, const char *file, int line, const char *func) { return iMalloc->astrdup(p,HPM_file2ptr(file),line,func); } @@ -602,6 +606,48 @@ bool hpm_add_arg(unsigned int pluginID, char *name, bool has_param, void (*func) return true; } +bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, char *name, void (*func) (const char *val)) { + struct HPConfListenStorage *conf; + unsigned int i; + + if( type >= HPCT_MAX ) { + ShowError("HPM->addConf:%s: unknown point '%u' specified for config '%s'\n",HPM->pid2name(pluginID),type,name); + return false; + } + + for(i = 0; i < HPM->confsc[type]; i++) { + if( !strcmpi(name,HPM->confs[type][i].key) ) { + ShowError("HPM->addConf:%s: duplicate '%s', already in use by '%s'!",HPM->pid2name(pluginID),name,HPM->pid2name(HPM->confs[type][i].pluginID)); + return false; + } + } + + RECREATE(HPM->confs[type], struct HPConfListenStorage, ++HPM->confsc[type]); + conf = &HPM->confs[type][HPM->confsc[type] - 1]; + + conf->pluginID = pluginID; + safestrncpy(conf->key, name, HPM_ADDCONF_LENGTH); + conf->func = func; + + return true; +} +bool hplugins_parse_conf(const char *w1, const char *w2, enum HPluginConfType point) { + unsigned int i; + + /* exists? */ + for(i = 0; i < HPM->confsc[point]; i++) { + if( !strcmpi(w1,HPM->confs[point][i].key) ) + break; + } + + /* trigger and we're set! */ + if( i != HPM->confsc[point] ) { + HPM->confs[point][i].func(w2); + return true; + } + + return false; +} void hplugins_share_defaults(void) { /* console */ @@ -617,6 +663,7 @@ void hplugins_share_defaults(void) { HPM->share(HPM_HookStop,"HookStop"); HPM->share(HPM_HookStopped,"HookStopped"); HPM->share(hpm_add_arg,"addArg"); + HPM->share(hplugins_addconf,"addConf"); /* core */ HPM->share(&runflag,"runflag"); HPM->share(arg_v,"arg_v"); @@ -661,6 +708,7 @@ void hpm_init(void) { HPMiMalloc->malloc = HPM_mmalloc; HPMiMalloc->calloc = HPM_calloc; HPMiMalloc->realloc = HPM_realloc; + HPMiMalloc->reallocz = HPM_reallocz; HPMiMalloc->astrdup = HPM_astrdup; sscanf(HPM_VERSION, "%u.%u", &HPM->version[0], &HPM->version[1]); @@ -728,6 +776,11 @@ void hpm_final(void) { aFree(HPM->packets[i]); } + for( i = 0; i < HPCT_MAX; i++ ) { + if( HPM->confsc[i] ) + aFree(HPM->confs[i]); + } + HPM->arg_db->destroy(HPM->arg_db,HPM->arg_db_clear_sub); /* HPM->fnames is cleared after the memory manager goes down */ @@ -736,13 +789,26 @@ void hpm_final(void) { return; } void hpm_defaults(void) { + unsigned int i; HPM = &HPM_s; HPM->fnames = NULL; HPM->fnamec = 0; HPM->force_return = false; HPM->hooking = false; - + /* */ + HPM->fnames = NULL; + HPM->fnamec = 0; + for(i = 0; i < hpPHP_MAX; i++) { + HPM->packets[i] = NULL; + HPM->packetsc[i] = 0; + } + for(i = 0; i < HPCT_MAX; i++) { + HPM->confs[i] = NULL; + HPM->confsc[i] = 0; + } + HPM->arg_db = NULL; + /* */ HPM->init = hpm_init; HPM->final = hpm_final; @@ -767,4 +833,5 @@ void hpm_defaults(void) { HPM->arg_help = hpm_arg_help; HPM->grabHPData = hplugins_grabHPData; HPM->grabHPDataSub = NULL; + HPM->parseConf = hplugins_parse_conf; } diff --git a/src/common/HPM.h b/src/common/HPM.h index d5a5cbb6a..1f2ba4648 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -88,6 +88,12 @@ struct HPDataOperationStorage { void **HPDataSRCPtr; unsigned int *hdatac; }; +/* */ +struct HPConfListenStorage { + unsigned int pluginID; + char key[HPM_ADDCONF_LENGTH]; + void (*func) (const char *val); +}; /* Hercules Plugin Manager Interface */ struct HPM_interface { @@ -108,6 +114,9 @@ struct HPM_interface { /* plugin file ptr caching */ struct HPMFileNameCache *fnames; unsigned int fnamec; + /* config listen */ + struct HPConfListenStorage *confs[HPCT_MAX]; + unsigned int confsc[HPCT_MAX]; /* --command-line */ DBMap *arg_db; /* funcs */ @@ -135,6 +144,8 @@ struct HPM_interface { void (*grabHPData) (struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr); /* for server-specific HPData e.g. map_session_data */ void (*grabHPDataSub) (struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr); + /* for custom config parsing */ + bool (*parseConf) (const char *w1, const char *w2, enum HPluginConfType point); } HPM_s; struct HPM_interface *HPM; diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 2cd1075c4..742132cde 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -36,6 +36,7 @@ struct map_session_data; #include "../common/showmsg.h" #define HPM_VERSION "1.0" +#define HPM_ADDCONF_LENGTH 40 struct hplugin_info { char* name; @@ -83,6 +84,12 @@ enum HPluginDataTypes { HPDT_NPCD, }; +/* used in macros and conf storage */ +enum HPluginConfType { + HPCT_BATTLE, /* battle-conf (map-server */ + HPCT_MAX, +}; + #define addHookPre(tname,hook) (HPMi->AddHook(HOOK_TYPE_PRE,(tname),(hook),HPMi->pid)) #define addHookPost(tname,hook) (HPMi->AddHook(HOOK_TYPE_POST,(tname),(hook),HPMi->pid)) /* need better names ;/ */ @@ -128,6 +135,8 @@ enum HPluginDataTypes { } /* HPMi->addPacket */ #define addPacket(cmd,len,receive,point) HPMi->addPacket(cmd,len,receive,point,HPMi->pid) +/* HPMi->addBattleConf */ +#define addBattleConf(bcname,funcname) HPMi->addConf(HPMi->pid,HPCT_BATTLE,bcname,funcname) /* Hercules Plugin Mananger Include Interface */ HPExport struct HPMi_interface { @@ -150,6 +159,8 @@ HPExport struct HPMi_interface { bool (*HookStopped) (void); /* program --arg/-a */ bool (*addArg) (unsigned int pluginID, char *name, bool has_param,void (*func) (char *param),void (*help) (void)); + /* battle-config recv param */ + bool (*addConf) (unsigned int pluginID, enum HPluginConfType type, char *name, void (*func) (const char *val)); } HPMi_s; #ifndef _HPM_H_ HPExport struct HPMi_interface *HPMi; diff --git a/src/common/db.c b/src/common/db.c index ba3fef97b..efe7ca8b2 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -2446,7 +2446,7 @@ DBMap* db_alloc(const char *file, const char *func, int line, DBType type, DBOpt db->free_lock = 0; /* Other */ snprintf(ers_name, 50, "db_alloc:nodes:%s:%s:%d",func,file,line); - db->nodes = ers_new(sizeof(struct dbn),ers_name,ERS_OPT_WAIT|ERS_OPT_FREE_NAME); + db->nodes = ers_new(sizeof(struct dbn),ers_name,ERS_OPT_WAIT|ERS_OPT_FREE_NAME|ERS_OPT_CLEAN); db->cmp = DB->default_cmp(type); db->hash = DB->default_hash(type); db->release = DB->default_release(type, options); @@ -2609,8 +2609,8 @@ void* db_data2ptr(DBData *data) * @see #db_final(void) */ void db_init(void) { - db_iterator_ers = ers_new(sizeof(struct DBIterator_impl),"db.c::db_iterator_ers",ERS_OPT_NONE); - db_alloc_ers = ers_new(sizeof(struct DBMap_impl),"db.c::db_alloc_ers",ERS_OPT_NONE); + db_iterator_ers = ers_new(sizeof(struct DBIterator_impl),"db.c::db_iterator_ers",ERS_OPT_CLEAN); + db_alloc_ers = ers_new(sizeof(struct DBMap_impl),"db.c::db_alloc_ers",ERS_OPT_CLEAN); ers_chunk_size(db_alloc_ers, 50); DB_COUNTSTAT(db_init); } diff --git a/src/common/ers.c b/src/common/ers.c index 22269a51f..a7dad49ab 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -40,6 +40,7 @@ * @see common#ers.h * \*****************************************************************************/ #include <stdlib.h> +#include <string.h> #include "../common/cbasetypes.h" #include "../common/malloc.h" // CREATE, RECREATE, aMalloc, aFree @@ -238,6 +239,9 @@ static void ers_obj_free_entry(ERS self, void *entry) return; } + if( instance->Options & ERS_OPT_CLEAN ) + memset((unsigned char*)reuse + sizeof(struct ers_list), 0, instance->Cache->ObjectSize - sizeof(struct ers_list)); + reuse->Next = instance->Cache->ReuseList; instance->Cache->ReuseList = reuse; instance->Count--; diff --git a/src/common/ers.h b/src/common/ers.h index 4ff2a6230..e63711b81 100644 --- a/src/common/ers.h +++ b/src/common/ers.h @@ -71,10 +71,11 @@ #endif /* not ERS_ALIGN_ENTRY */ enum ERSOptions { - ERS_OPT_NONE = 0x0, - ERS_OPT_CLEAR = 0x1,/* silently clears any entries left in the manager upon destruction */ - ERS_OPT_WAIT = 0x2,/* wait for entries to come in order to list! */ - ERS_OPT_FREE_NAME = 0x4,/* name is dynamic memory, and should be freed */ + ERS_OPT_NONE = 0x0, + ERS_OPT_CLEAR = 0x1,/* silently clears any entries left in the manager upon destruction */ + ERS_OPT_WAIT = 0x2,/* wait for entries to come in order to list! */ + ERS_OPT_FREE_NAME = 0x4,/* name is dynamic memory, and should be freed */ + ERS_OPT_CLEAN = 0x8,/* clears used memory upon ers_free so that its all new to be reused on the next alloc */ }; /** diff --git a/src/common/malloc.c b/src/common/malloc.c index 23e28a65f..875b87a15 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -369,6 +369,37 @@ void* _mrealloc(void *memblock, size_t size, const char *file, int line, const c } } +/* a _mrealloc clone with the difference it 'z'eroes the newly created memory */ +void* _mreallocz(void *memblock, size_t size, const char *file, int line, const char *func ) { + size_t old_size; + void *p = NULL; + + if(memblock == NULL) { + p = iMalloc->malloc(size,file,line,func); + memset(p,0,size); + return p; + } + + old_size = ((struct unit_head *)((char *)memblock - sizeof(struct unit_head) + sizeof(long)))->size; + if( old_size == 0 ) { + old_size = ((struct unit_head_large *)((char *)memblock - sizeof(struct unit_head_large) + sizeof(long)))->size; + } + if(old_size > size) { + // Size reduction - return> as it is (negligence) + return memblock; + } else { + // Size Large + p = iMalloc->malloc(size,file,line,func); + if(p != NULL) { + memcpy(p,memblock,old_size); + memset(p+old_size,0,size-old_size); + } + iMalloc->free(memblock,file,line,func); + return p; + } +} + + char* _mstrdup(const char *p, const char *file, int line, const char *func ) { if(p == NULL) { @@ -822,12 +853,14 @@ void malloc_defaults(void) { iMalloc->malloc = _mmalloc; iMalloc->calloc = _mcalloc; iMalloc->realloc = _mrealloc; + iMalloc->reallocz= _mreallocz; iMalloc->astrdup = _mstrdup; iMalloc->free = _mfree; #else iMalloc->malloc = aMalloc_; iMalloc->calloc = aCalloc_; iMalloc->realloc = aRealloc_; + iMalloc->reallocz= aRealloc_;/* not using memory manager huhum o.o perhaps we could still do something about */ iMalloc->astrdup = aStrdup_; iMalloc->free = aFree_; #endif diff --git a/src/common/malloc.h b/src/common/malloc.h index cd0ef238b..19b5213bb 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -33,6 +33,7 @@ # define aMalloc(n) (iMalloc->malloc((n),ALC_MARK)) # define aCalloc(m,n) (iMalloc->calloc((m),(n),ALC_MARK)) # define aRealloc(p,n) (iMalloc->realloc((p),(n),ALC_MARK)) +# define aReallocz(p,n) (iMalloc->reallocz((p),(n),ALC_MARK)) # define aStrdup(p) (iMalloc->astrdup((p),ALC_MARK)) # define aFree(p) (iMalloc->free((p),ALC_MARK)) @@ -54,7 +55,7 @@ ////////////// Others ////////////////////////// // should be merged with any of above later #define CREATE(result, type, number) ((result) = (type *) aCalloc((number), sizeof(type))) -#define RECREATE(result, type, number) ((result) = (type *) aRealloc((result), sizeof(type) * (number))) +#define RECREATE(result, type, number) ((result) = (type *) aReallocz((result), sizeof(type) * (number))) //////////////////////////////////////////////// @@ -73,6 +74,7 @@ struct malloc_interface { void* (*malloc )(size_t size, const char *file, int line, const char *func); void* (*calloc )(size_t num, size_t size, const char *file, int line, const char *func); void* (*realloc )(void *p, size_t size, const char *file, int line, const char *func); + void* (*reallocz)(void *p, size_t size, const char *file, int line, const char *func); char* (*astrdup )(const char *p, const char *file, int line, const char *func); void (*free )(void *p, const char *file, int line, const char *func); /* */ diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 51c447ed9..953f1a0dc 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -398,17 +398,17 @@ ACMD(mapmove) { return false; } - if ((x || y) && map->getcell(m, x, y, CELL_CHKNOPASS) && pc->get_group_level(sd) < battle_config.gm_ignore_warpable_area) { + if ((x || y) && map->getcell(m, x, y, CELL_CHKNOPASS) && pc_get_group_level(sd) < battle_config.gm_ignore_warpable_area) { //This is to prevent the pc->setpos call from printing an error. clif->message(fd, msg_txt(2)); if (!map->search_freecell(NULL, m, &x, &y, 10, 10, 1)) x = y = 0; //Invalid cell, use random spot. } - if (map->list[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (map->list[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; } - if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); return false; } @@ -437,7 +437,7 @@ ACMD(where) { pl_sd = map->nick2sd(atcmd_player_name); if (pl_sd == NULL || strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 || - (pc->has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc->get_group_level(pl_sd) > pc->get_group_level(sd) && !pc->has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) + (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) ) { clif->message(fd, msg_txt(3)); // Character not found. return false; @@ -465,12 +465,12 @@ ACMD(jumpto) { return false; } - if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); // You are not authorized to warp to this map. return false; } - if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } @@ -498,7 +498,7 @@ ACMD(jump) sscanf(message, "%hd %hd", &x, &y); - if (map->list[sd->bl.m].flag.noteleport && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (map->list[sd->bl.m].flag.noteleport && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } @@ -554,12 +554,12 @@ ACMD(who) { else if (stristr(info->command, "3") != NULL) display_type = 3; - level = pc->get_group_level(sd); + level = pc_get_group_level(sd); StrBuf->Init(&buf); iter = mapit_getallusers(); for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) { - if (!((pc->has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc->get_group_level(pl_sd) > level)) { // you can look only lower or same level + if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || (pl_sd->sc.option & OPTION_INVISIBLE)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive || (map_id >= 0 && pl_sd->bl.m != map_id)) continue; @@ -573,7 +573,7 @@ ACMD(who) { break; } case 3: { - if (pc->has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) + if (pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID)) StrBuf->Printf(&buf, msg_txt(912), pl_sd->status.char_id, pl_sd->status.account_id); // "(CID:%d/AID:%d) " StrBuf->Printf(&buf, msg_txt(343), pl_sd->status.name); // "Name: %s " if (pc_get_group_id(pl_sd) > 0) // Player title, if exists @@ -646,12 +646,12 @@ ACMD(whogm) match_text[j] = TOLOWER(match_text[j]); count = 0; - level = pc->get_group_level(sd); + level = pc_get_group_level(sd); iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { - pl_level = pc->get_group_level(pl_sd); + pl_level = pc_get_group_level(pl_sd); if (!pl_level) continue; @@ -729,11 +729,11 @@ ACMD(load) { int16 m; m = map->mapindex2mapid(sd->status.save_point.map); - if (m >= 0 && map->list[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (m >= 0 && map->list[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(249)); // You are not authorized to warp to your save map. return false; } - if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); // You are not authorized to warp from your current map. return false; } @@ -1859,11 +1859,11 @@ ACMD(go) if (town >= 0 && town < ARRAYLENGTH(data)) { m = map->mapname2mapid(data[town].map); - if (m >= 0 && map->list[m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (m >= 0 && map->list[m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(247)); return false; } - if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(248)); return false; } @@ -2674,17 +2674,17 @@ ACMD(recall) { return false; } - if ( pc->get_group_level(sd) < pc->get_group_level(pl_sd) ) + if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { clif->message(fd, msg_txt(81)); // Your GM level doesn't authorize you to preform this action on the specified player. return false; } - if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1019)); // You are not authorized to warp someone to this map. return false; } - if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1020)); // You are not authorized to warp this player from their map. return false; } @@ -2895,7 +2895,7 @@ ACMD(doom) iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { - if (pl_sd->fd != fd && pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) + if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { status_kill(&pl_sd->bl); clif->specialeffect(&pl_sd->bl,450,AREA); @@ -2920,7 +2920,7 @@ ACMD(doommap) iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { - if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) + if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { status_kill(&pl_sd->bl); clif->specialeffect(&pl_sd->bl,450,AREA); @@ -3002,7 +3002,7 @@ ACMD(kick) return false; } - if ( pc->get_group_level(sd) < pc->get_group_level(pl_sd) ) + if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. return false; @@ -3024,7 +3024,7 @@ ACMD(kickall) iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { - if (pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) { // you can kick only lower or same gm level + if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level if (sd->status.account_id != pl_sd->status.account_id) clif->GM_kick(NULL, pl_sd); } @@ -3352,7 +3352,7 @@ ACMD(recallall) memset(atcmd_output, '\0', sizeof(atcmd_output)); - if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. return false; } @@ -3360,10 +3360,10 @@ ACMD(recallall) count = 0; iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { - if (sd->status.account_id != pl_sd->status.account_id && pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) { + if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) continue; // Don't waste time warping the character to the same place. - if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else { if (pc_isdead(pl_sd)) { //Wake them up @@ -3404,7 +3404,7 @@ ACMD(guildrecall) return false; } - if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. return false; } @@ -3422,9 +3422,9 @@ ACMD(guildrecall) for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id) { - if (pc->get_group_level(pl_sd) > pc->get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)) + if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)) continue; // Skip GMs greater than you... or chars already on the cell - if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN); @@ -3461,7 +3461,7 @@ ACMD(partyrecall) return false; } - if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) { + if (sd->bl.m >= 0 && map->list[sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) { clif->message(fd, msg_txt(1032)); // You are not authorized to warp somenone to your current map. return false; } @@ -3478,9 +3478,9 @@ ACMD(partyrecall) iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id) { - if (pc->get_group_level(pl_sd) > pc->get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)) + if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)) continue; // Skip GMs greater than you... or chars already on the cell - if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE)) + if (pl_sd->bl.m >= 0 && map->list[pl_sd->bl.m].flag.nowarp && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) count++; else pc->setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN); @@ -4106,7 +4106,7 @@ ACMD(nuke) { } if ((pl_sd = map->nick2sd(atcmd_player_name)) != NULL) { - if (pc->get_group_level(sd) >= pc->get_group_level(pl_sd)) { // you can kill only lower or same GM level + if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level skill->castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, timer->gettick(), 0); clif->message(fd, msg_txt(109)); // Player has been nuked! } else { @@ -4390,7 +4390,7 @@ ACMD(jail) { return false; } - if (pc->get_group_level(sd) < pc->get_group_level(pl_sd)) + if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. return false; @@ -4441,7 +4441,7 @@ ACMD(unjail) { return false; } - if (pc->get_group_level(sd) < pc->get_group_level(pl_sd)) { // you can jail only lower or same GM + if (pc_get_group_level(sd) < pc_get_group_level(pl_sd)) { // you can jail only lower or same GM clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. return false; @@ -4519,7 +4519,7 @@ ACMD(jailfor) { return false; } - if (pc->get_group_level(pl_sd) > pc->get_group_level(sd)) { + if (pc_get_group_level(pl_sd) > pc_get_group_level(sd)) { clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. return false; } @@ -5263,7 +5263,7 @@ ACMD(useskill) { return false; } - if ( pc->get_group_level(sd) < pc->get_group_level(pl_sd) ) + if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. return false; @@ -6415,7 +6415,7 @@ ACMD(mute) { return false; } - if ( pc->get_group_level(sd) < pc->get_group_level(pl_sd) ) + if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { clif->message(fd, msg_txt(81)); // Your GM level don't authorise you to do this action on this player. return false; @@ -6665,7 +6665,7 @@ ACMD(showmobs) return true; } - if(mob->db(mob_id)->status.mode&MD_BOSS && !pc->has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs. + if(mob->db(mob_id)->status.mode&MD_BOSS && !pc_has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs. clif->message(fd, msg_txt(1251)); // Can't show boss mobs! return true; } @@ -7218,7 +7218,7 @@ int atcommand_mutearea_sub(struct block_list *bl,va_list ap) id = va_arg(ap, int); time = va_arg(ap, int); - if (id != bl->id && !pc->get_group_level(pl_sd)) { + if (id != bl->id && !pc_get_group_level(pl_sd)) { pl_sd->status.manner -= time; if (pl_sd->status.manner < 0) sc_start(&pl_sd->bl,SC_NOCHAT,100,0,0); @@ -7801,7 +7801,7 @@ ACMD(clone) { return true; } - if(pc->get_group_level(pl_sd) > pc->get_group_level(sd)) { + if(pc_get_group_level(pl_sd) > pc_get_group_level(sd)) { clif->message(fd, msg_txt(126)); // Cannot clone a player of higher GM level than yourself. return true; } @@ -8376,7 +8376,7 @@ ACMD(accinfo) { //remove const type safestrncpy(query, message, NAME_LENGTH); - intif->request_accinfo( sd->fd, sd->bl.id, pc->get_group_level(sd), query ); + intif->request_accinfo( sd->fd, sd->bl.id, pc_get_group_level(sd), query ); return true; } @@ -8660,7 +8660,7 @@ ACMD(join) { return false; } if( channel->pass[0] != '\0' && strcmp(channel->pass,pass) != 0 ) { - if( pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { sd->stealth = true; } else { sprintf(atcmd_output, msg_txt(1401),name,command); // '%s' Channel is password protected (usage: %s <#channel_name> <password>) @@ -8753,11 +8753,11 @@ ACMD(channel) { sub1[0] = sub2[0] = sub3[0] = '\0'; if( !message || !*message || sscanf(message, "%s %s %s %s", subcmd, sub1, sub2, sub3) < 1 ) { - atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) )); + atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) )); return true; } - if( strcmpi(subcmd,"create") == 0 && ( hChSys.allow_user_channel_creation || pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) ) { + if( strcmpi(subcmd,"create") == 0 && ( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) ) { if( sub1[0] != '#' ) { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; @@ -8806,7 +8806,7 @@ ACMD(channel) { } } else { DBIterator *iter = db_iterator(clif->channel_db); - bool show_all = pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ? true : false; + bool show_all = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ? true : false; clif->message(fd, msg_txt(1410)); // -- Public Channels if( hChSys.local ) { sprintf(atcmd_output, msg_txt(1409), hChSys.local_name, map->list[sd->bl.m].channel ? db_size(map->list[sd->bl.m].channel->users) : 0);// - #%s ( %d users ) @@ -8839,7 +8839,7 @@ ACMD(channel) { return false; } - if( channel->owner != sd->status.char_id && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; @@ -8931,7 +8931,7 @@ ACMD(channel) { return false; } - if( channel->owner != sd->status.char_id && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; @@ -8949,7 +8949,7 @@ ACMD(channel) { return false; } - if( pc->has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN) ) { + if( pc_has_permission(pl_sd, PC_PERM_HCHSYS_ADMIN) ) { clif->message(fd, msg_txt(1464)); // Ban failed, not possible to ban this user. return false; } @@ -8987,7 +8987,7 @@ ACMD(channel) { return false; } - if( channel->owner != sd->status.char_id && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; @@ -9032,7 +9032,7 @@ ACMD(channel) { return false; } - if( channel->owner != sd->status.char_id && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; @@ -9053,7 +9053,7 @@ ACMD(channel) { DBIterator *iter = NULL; DBKey key; DBData *data; - bool isA = pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN)?true:false; + bool isA = pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)?true:false; if( sub1[0] != '#' ) { clif->message(fd, msg_txt(1405));// Channel name must start with a '#' return false; @@ -9112,7 +9112,7 @@ ACMD(channel) { return false; } - if( channel->owner != sd->status.char_id && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->owner != sd->status.char_id && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { sprintf(atcmd_output, msg_txt(1412), sub1);// You're not the owner of channel '%s' clif->message(fd, atcmd_output); return false; @@ -9203,7 +9203,7 @@ ACMD(channel) { } } else { - atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) )); + atcmd_channel_help(fd,command,( hChSys.allow_user_channel_creation || pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) )); } return true; @@ -9770,7 +9770,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message // 1 = player invoked if ( type == 1) { //Commands are disabled on maps flagged as 'nocommand' - if ( map->list[sd->bl.m].nocommand && pc->get_group_level(sd) < map->list[sd->bl.m].nocommand ) { + if ( map->list[sd->bl.m].nocommand && pc_get_group_level(sd) < map->list[sd->bl.m].nocommand ) { clif->message(fd, msg_txt(143)); return false; } @@ -9805,7 +9805,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message break; } - if( !pc->get_group_level(sd) ) { + if( !pc_get_group_level(sd) ) { if( x >= 1 || y >= 1 ) { /* we have command */ info = atcommand->get_info_byname(atcommand->check_alias(command + 1)); if( !info || info->char_groups[pcg->get_idx(sd->group)] == 0 ) /* if we can't use or doesn't exist: don't even display the command failed message */ @@ -9848,8 +9848,8 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message if( binding != NULL && binding->npc_event[0] && ( - (*atcmd_msg == atcommand->at_symbol && pc->get_group_level(sd) >= binding->group_lv) - || (*atcmd_msg == atcommand->char_symbol && pc->get_group_level(sd) >= binding->group_lv_char) + (*atcmd_msg == atcommand->at_symbol && pc_get_group_level(sd) >= binding->group_lv) + || (*atcmd_msg == atcommand->char_symbol && pc_get_group_level(sd) >= binding->group_lv_char) ) ) { // Check if self or character invoking; if self == character invoked, then self invoke. @@ -9876,7 +9876,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message //Grab the command information and check for the proper GM level required to use it or if the command exists info = atcommand->get_info_byname(atcommand->check_alias(command + 1)); if (info == NULL) { - if( pc->get_group_level(sd) ) { // TODO: remove or replace with proper permission + if( pc_get_group_level(sd) ) { // TODO: remove or replace with proper permission sprintf(output, msg_txt(153), command); // "%s is Unknown Command." clif->message(fd, output); atcommand->get_suggestions(sd, command + 1, *message == atcommand->at_symbol); @@ -9892,13 +9892,13 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message (*command == atcommand->char_symbol && info->char_groups[pcg->get_idx(sd->group)] == 0) ) { return false; } - if( pc_isdead(sd) && pc->has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) { + if( pc_isdead(sd) && pc_has_permission(sd,PC_PERM_DISABLE_CMD_DEAD) ) { clif->message(fd, msg_txt(1393)); // You can't use commands while dead return true; } for(i = 0; i < map->list[sd->bl.m].zone->disabled_commands_count; i++) { if( info->func == map->list[sd->bl.m].zone->disabled_commands[i]->cmd ) { - if( pc->get_group_level(sd) < map->list[sd->bl.m].zone->disabled_commands[i]->group_lv ) { + if( pc_get_group_level(sd) < map->list[sd->bl.m].zone->disabled_commands[i]->group_lv ) { clif->colormes(sd->fd,COLOR_RED,"This command is disabled in this area"); return true; } else diff --git a/src/map/battle.c b/src/map/battle.c index 802d2ec02..b8143213a 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -12,6 +12,7 @@ #include "../common/socket.h" #include "../common/strlib.h" #include "../common/utils.h" +#include "../common/HPM.h" #include "map.h" #include "path.h" @@ -5830,11 +5831,11 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if ( s_bl->type == BL_PC ) { switch( t_bl->type ) { case BL_MOB: // Source => PC, Target => MOB - if (pc->has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVM) ) + if (pc_has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVM) ) return 0; break; case BL_PC: - if (pc->has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVP)) + if (pc_has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVP)) return 0; break; default:/* anything else goes */ @@ -6708,8 +6709,11 @@ int battle_set_value(const char* w1, const char* w2) int i; ARR_FIND(0, ARRAYLENGTH(battle_data), i, strcmpi(w1, battle_data[i].str) == 0); - if (i == ARRAYLENGTH(battle_data)) + if (i == ARRAYLENGTH(battle_data)) { + if( HPM->parseConf(w1,w2,HPCT_BATTLE) ) /* if plugin-owned, succeed */ + return 1; return 0; // not found + } if (val < battle_data[i].min || val > battle_data[i].max) { diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index a9f1412ed..2a15e66fc 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -76,7 +76,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha return; } - if( !pc->can_give_items(sd) ) + if( !pc_can_give_items(sd) ) {// custom: GM is not allowed to buy (give zeny) sd->buyingstore.slots = 0; clif->message(sd->fd, msg_txt(246)); @@ -123,7 +123,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha break; } - if( !id->flag.buyingstore || !itemdb->cantrade_sub(id, pc->get_group_level(sd), pc->get_group_level(sd)) || ( idx = pc->search_inventory(sd, nameid) ) == -1 ) + if( !id->flag.buyingstore || !itemdb->cantrade_sub(id, pc_get_group_level(sd), pc_get_group_level(sd)) || ( idx = pc->search_inventory(sd, nameid) ) == -1 ) {// restrictions: allowed, no character-bound items and at least one must be owned break; } @@ -197,7 +197,7 @@ void buyingstore_open(struct map_session_data* sd, int account_id) return; } - if( !pc->can_give_items(sd) ) + if( !pc_can_give_items(sd) ) {// custom: GM is not allowed to sell clif->message(sd->fd, msg_txt(246)); return; @@ -235,7 +235,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int return; } - if( !pc->can_give_items(sd) ) + if( !pc_can_give_items(sd) ) {// custom: GM is not allowed to sell clif->message(sd->fd, msg_txt(246)); clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0); @@ -290,7 +290,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int return; } - if( sd->status.inventory[index].expire_time || (sd->status.inventory[index].bound && !pc->can_give_bound_items(sd)) || !itemdb_cantrade(&sd->status.inventory[index], pc->get_group_level(sd), pc->get_group_level(pl_sd)) || memcmp(sd->status.inventory[index].card, buyingstore->blankslots, sizeof(buyingstore->blankslots)) ) + if( sd->status.inventory[index].expire_time || (sd->status.inventory[index].bound && !pc_can_give_bound_items(sd)) || !itemdb_cantrade(&sd->status.inventory[index], pc_get_group_level(sd), pc_get_group_level(pl_sd)) || memcmp(sd->status.inventory[index].card, buyingstore->blankslots, sizeof(buyingstore->blankslots)) ) {// non-tradable item clif->buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, nameid); return; diff --git a/src/map/chat.c b/src/map/chat.c index 858878430..52d7f246a 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -121,7 +121,7 @@ int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass) { return 0; } - if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !pc->has_permission(sd, PC_PERM_JOIN_ALL_CHAT) ) + if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !pc_has_permission(sd, PC_PERM_JOIN_ALL_CHAT) ) { clif->joinchatfail(sd,1); return 0; @@ -315,7 +315,7 @@ int chat_kickchat(struct map_session_data* sd, const char* kickusername) { if( i == cd->users ) return -1; - if (pc->has_permission(cd->usersd[i], PC_PERM_NO_CHAT_KICK)) + if (pc_has_permission(cd->usersd[i], PC_PERM_NO_CHAT_KICK)) return 0; //gm kick protection [Valaris] idb_put(cd->kick_list,cd->usersd[i]->status.char_id,(void*)1); diff --git a/src/map/clif.c b/src/map/clif.c index e51c59461..6a55ad344 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1805,13 +1805,13 @@ void clif_selllist(struct map_session_data *sd) { if( sd->status.inventory[i].nameid > 0 && sd->inventory_data[i] ) { - if( !itemdb_cansell(&sd->status.inventory[i], pc->get_group_level(sd)) ) + if( !itemdb_cansell(&sd->status.inventory[i], pc_get_group_level(sd)) ) continue; if( sd->status.inventory[i].expire_time ) continue; // Cannot Sell Rental Items - if( sd->status.inventory[i].bound && !pc->can_give_bound_items(sd)) + if( sd->status.inventory[i].bound && !pc_can_give_bound_items(sd)) continue; // Don't allow sale of bound items val=sd->inventory_data[i]->value_sell; @@ -2846,7 +2846,7 @@ int clif_hpmeter_sub(struct block_list *bl, va_list ap) { if( !tsd->fd || tsd == sd ) return 0; - if( !pc->has_permission(tsd, PC_PERM_VIEW_HPMETER) ) + if( !pc_has_permission(tsd, PC_PERM_VIEW_HPMETER) ) return 0; WFIFOHEAD(tsd->fd,packet_len(cmd)); WFIFOW(tsd->fd,0) = cmd; @@ -3663,7 +3663,7 @@ void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok) } void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data *sd, const char *msg) { - if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), timer->gettick()) > 0 && !pc->has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), timer->gettick()) > 0 && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { clif->colormes(sd->fd,COLOR_RED,msg_txt(1455)); return; } else { @@ -4232,7 +4232,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds } if( (sd->status.party_id && dstsd->status.party_id == sd->status.party_id) || //Party-mate, or hpdisp setting. (sd->bg_id && sd->bg_id == dstsd->bg_id) || //BattleGround - pc->has_permission(sd, PC_PERM_VIEW_HPMETER) + pc_has_permission(sd, PC_PERM_VIEW_HPMETER) ) clif->hpmeter_single(sd->fd, dstsd->bl.id, dstsd->battle_status.hp, dstsd->battle_status.max_hp); @@ -5855,7 +5855,7 @@ void clif_wis_message(int fd, const char* nick, const char* mes, size_t mes_len) WFIFOW(fd,0) = 0x97; WFIFOW(fd,2) = mes_len + NAME_LENGTH + 8; safestrncpy((char*)WFIFOP(fd,4), nick, NAME_LENGTH); - WFIFOL(fd,28) = (ssd && pc->get_group_level(ssd) == 99) ? 1 : 0; // isAdmin; if nonzero, also displays text above char + WFIFOL(fd,28) = (ssd && pc_get_group_level(ssd) == 99) ? 1 : 0; // isAdmin; if nonzero, also displays text above char safestrncpy((char*)WFIFOP(fd,32), mes, mes_len); WFIFOSET(fd,WFIFOW(fd,2)); #endif @@ -9267,7 +9267,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { instance->check_idle(map->list[sd->bl.m].instance_id); } - if( pc->has_permission(sd,PC_PERM_VIEW_HPMETER) ) { + if( pc_has_permission(sd,PC_PERM_VIEW_HPMETER) ) { map->list[sd->bl.m].hpmeter_visible++; sd->state.hpmeter_visible = 1; } @@ -9749,7 +9749,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) { sc = status->get_sc(bl); if (sc && sc->option&OPTION_INVISIBLE && !disguised(bl) && bl->type != BL_NPC && //Skip hidden NPCs which can be seen using Maya Purple - pc->get_group_level(sd) < battle_config.hack_info_GM_level + pc_get_group_level(sd) < battle_config.hack_info_GM_level ) { char gm_msg[256]; sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requested the name of an invisible target (id: %d).\n", sd->status.name, sd->status.account_id, id); @@ -10406,8 +10406,8 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) } // if player ignores everyone - if (dstsd->state.ignoreAll && pc->get_group_level(sd) <= pc->get_group_level(dstsd)) { - if (dstsd->sc.option & OPTION_INVISIBLE && pc->get_group_level(sd) < pc->get_group_level(dstsd)) + if (dstsd->state.ignoreAll && pc_get_group_level(sd) <= pc_get_group_level(dstsd)) { + if (dstsd->sc.option & OPTION_INVISIBLE && pc_get_group_level(sd) < pc_get_group_level(dstsd)) clif->wis_end(fd, 1); // 1: target character is not logged in else clif->wis_end(fd, 3); // 3: everyone ignored by target @@ -10422,7 +10422,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) return; } - if( pc->get_group_level(sd) <= pc->get_group_level(dstsd) ) { + if( pc_get_group_level(sd) <= pc_get_group_level(dstsd) ) { // if player ignores the source character ARR_FIND(0, MAX_IGNORE_LIST, i, dstsd->ignore[i].name[0] == '\0' || strcmp(dstsd->ignore[i].name, sd->status.name) == 0); if(i < MAX_IGNORE_LIST && dstsd->ignore[i].name[0] != '\0') { // source char present in ignore list @@ -13615,7 +13615,7 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) { if (type == 2) { if (!battle_config.client_accept_chatdori) return; - if (pc->get_group_level(sd) > 0 || sd->bl.id != id) + if (pc_get_group_level(sd) > 0 || sd->bl.id != id) return; value = battle_config.client_accept_chatdori; @@ -13626,7 +13626,7 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) { return; } - if (type == 2 || ( (pc->get_group_level(sd)) > pc->get_group_level(dstsd) && !pc->can_use_command(sd, "@mute"))) { + if (type == 2 || ( (pc_get_group_level(sd)) > pc_get_group_level(dstsd) && !pc->can_use_command(sd, "@mute"))) { clif->manner_message(sd, 0); clif->manner_message(dstsd, 5); @@ -13695,7 +13695,7 @@ void clif_parse_GMReqAccountName(int fd, struct map_session_data *sd) void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) { int x,y,type; - if (!pc->has_permission(sd, PC_PERM_USE_CHANGEMAPTYPE)) + if (!pc_has_permission(sd, PC_PERM_USE_CHANGEMAPTYPE)) return; x = RFIFOW(fd,2); @@ -14579,12 +14579,12 @@ void clif_parse_Check(int fd, struct map_session_data *sd) char charname[NAME_LENGTH]; struct map_session_data* pl_sd; - if(!pc->has_permission(sd, PC_PERM_USE_CHECK)) + if(!pc_has_permission(sd, PC_PERM_USE_CHECK)) return; safestrncpy(charname, (const char*)RFIFOP(fd,packet_db[RFIFOW(fd,0)].pos[0]), sizeof(charname)); - if( ( pl_sd = map->nick2sd(charname) ) == NULL || pc->get_group_level(sd) < pc->get_group_level(pl_sd) ) { + if( ( pl_sd = map->nick2sd(charname) ) == NULL || pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { return; } @@ -15171,10 +15171,10 @@ void clif_parse_Auction_setitem(int fd, struct map_session_data *sd) return; } - if( !pc->can_give_items(sd) || sd->status.inventory[idx].expire_time || + if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time || !sd->status.inventory[idx].identify || - !itemdb_canauction(&sd->status.inventory[idx],pc->get_group_level(sd)) || // Quest Item or something else - (sd->status.inventory[idx].bound && !pc->can_give_bound_items(sd)) ) { + !itemdb_canauction(&sd->status.inventory[idx],pc_get_group_level(sd)) || // Quest Item or something else + (sd->status.inventory[idx].bound && !pc_can_give_bound_items(sd)) ) { clif->auction_setitem(sd->fd, idx, true); return; } @@ -15282,7 +15282,7 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd) } // Auction checks... - if( sd->status.inventory[sd->auction.index].bound && !pc->can_give_bound_items(sd) ) { + if( sd->status.inventory[sd->auction.index].bound && !pc_can_give_bound_items(sd) ) { clif->message(sd->fd, msg_txt(293)); clif->auction_message(fd, 2); // The auction has been canceled return; @@ -15335,7 +15335,7 @@ void clif_parse_Auction_bid(int fd, struct map_session_data *sd) unsigned int auction_id = RFIFOL(fd,2); int bid = RFIFOL(fd,6); - if( !pc->can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish] + if( !pc_can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish] clif->message(sd->fd, msg_txt(246)); return; } @@ -15626,7 +15626,7 @@ void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) { if (!tsd) return; - if( tsd->status.show_equip || pc->has_permission(sd, PC_PERM_VIEW_EQUIPMENT) ) + if( tsd->status.show_equip || pc_has_permission(sd, PC_PERM_VIEW_EQUIPMENT) ) clif->viewequip_ack(sd, tsd); else clif->viewequip_fail(sd); @@ -17956,7 +17956,7 @@ void clif_parse_GMFullStrip(int fd, struct map_session_data *sd) { int i; /* TODO maybe this could be a new permission? using gm level in the meantime */ - if( !tsd || pc->get_group_level(tsd) >= pc->get_group_level(sd) ) + if( !tsd || pc_get_group_level(tsd) >= pc_get_group_level(sd) ) return; for( i = 0; i < EQI_MAX; i++ ) { diff --git a/src/map/intif.c b/src/map/intif.c index 75ca714c9..b9d4d1746 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -192,7 +192,7 @@ int intif_main_message(struct map_session_data* sd, const char* message) snprintf( output, sizeof(output), msg_txt(386), sd->status.name, message ); // send the message using the inter-server broadcast service - intif_broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 ); + intif->broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 ); // log the chat message logs->chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message ); @@ -893,7 +893,7 @@ int mapif_parse_WisToGM_sub(struct map_session_data* sd,va_list va) { char *message; int len; - if (!pc->has_permission(sd, permission)) + if (!pc_has_permission(sd, permission)) return 0; wisp_name = va_arg(va, char*); message = va_arg(va, char*); @@ -1559,7 +1559,7 @@ void intif_parse_MailDelete(int fd) { } if( sd->mail.inbox.full ) - intif_Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails + intif->Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails } clif->mail_delete(sd->fd, mail_id, failed); @@ -1600,7 +1600,7 @@ void intif_parse_MailReturn(int fd) { } if( sd->mail.inbox.full ) - intif_Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails + intif->Mail_requestinbox(sd->status.char_id, 1); // Free space is available for new mails } clif->mail_return(sd->fd, mail_id, fail); @@ -1797,7 +1797,7 @@ void intif_parse_AuctionClose(int fd) { if( result == 0 ) { // FIXME: Leeching off a parse function clif->pAuction_cancelreg(fd, sd); - intif_Auction_requestlist(sd->status.char_id, 6, 0, "", 1); + intif->Auction_requestlist(sd->status.char_id, 6, 0, "", 1); } } @@ -1834,7 +1834,7 @@ void intif_parse_AuctionBid(int fd) { } if( result == 1 ) { // To update the list, display your buy list clif->pAuction_cancelreg(fd, sd); - intif_Auction_requestlist(sd->status.char_id, 7, 0, "", 1); + intif->Auction_requestlist(sd->status.char_id, 7, 0, "", 1); } } diff --git a/src/map/mail.c b/src/map/mail.c index 007f7592d..371aa892f 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -64,7 +64,7 @@ unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) { return 1; if( idx == 0 ) { // Zeny Transfer - if( amount < 0 || !pc->can_give_items(sd) ) + if( amount < 0 || !pc_can_give_items(sd) ) return 1; if( amount > sd->status.zeny ) @@ -81,9 +81,9 @@ unsigned char mail_setitem(struct map_session_data *sd, int idx, int amount) { return 1; if( amount < 0 || amount > sd->status.inventory[idx].amount ) return 1; - if( !pc->can_give_items(sd) || sd->status.inventory[idx].expire_time || - !itemdb_canmail(&sd->status.inventory[idx],pc->get_group_level(sd)) || - (sd->status.inventory[idx].bound && !pc->can_give_bound_items(sd)) ) + if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time || + !itemdb_canmail(&sd->status.inventory[idx],pc_get_group_level(sd)) || + (sd->status.inventory[idx].bound && !pc_can_give_bound_items(sd)) ) return 1; sd->mail.index = idx; diff --git a/src/map/map.c b/src/map/map.c index 3a018828a..7ff4ebcc5 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5551,9 +5551,9 @@ int do_init(int argc, char *argv[]) map->iwall_db = strdb_alloc(DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1); // [Zephyrus] Invisible Walls map->zone_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, MAP_ZONE_NAME_LENGTH); - map->iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_NONE); + map->iterator_ers = ers_new(sizeof(struct s_mapiterator),"map.c::map_iterator_ers",ERS_OPT_CLEAN); - map->flooritem_ers = ers_new(sizeof(struct flooritem_data),"map.c::map_flooritem_ers",ERS_OPT_NONE); + map->flooritem_ers = ers_new(sizeof(struct flooritem_data),"map.c::map_flooritem_ers",ERS_OPT_CLEAN); ers_chunk_size(map->flooritem_ers, 100); if (!minimal) { diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c index c94e42d5d..6a13ef2a0 100644 --- a/src/map/mapreg_sql.c +++ b/src/map/mapreg_sql.c @@ -291,7 +291,7 @@ void mapreg_final(void) { void mapreg_init(void) { mapreg->db = idb_alloc(DB_OPT_BASE); mapreg->str_db = idb_alloc(DB_OPT_BASE); - mapreg->ers = ers_new(sizeof(struct mapreg_save), "mapreg_sql.c::mapreg_ers", ERS_OPT_NONE); + mapreg->ers = ers_new(sizeof(struct mapreg_save), "mapreg_sql.c::mapreg_ers", ERS_OPT_CLEAN); mapreg->load(); diff --git a/src/map/mob.c b/src/map/mob.c index 90a967d61..d919e7478 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1768,7 +1768,6 @@ int mob_ai_hard(int tid, int64 tick, int id, intptr_t data) { *------------------------------------------*/ struct item_drop* mob_setdropitem(int nameid, int qty, struct item_data *data) { struct item_drop *drop = ers_alloc(item_drop_ers, struct item_drop); - memset(&drop->item_data, 0, sizeof(struct item)); drop->item_data.nameid = nameid; drop->item_data.amount = qty; drop->item_data.identify = data ? itemdb->isidentified2(data) : itemdb->isidentified(nameid); @@ -4642,7 +4641,7 @@ int do_init_mob(bool minimal) { memset(mob->db_data,0,sizeof(mob->db_data)); //Clear the array mob->db_data[0] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns mob->makedummymobdb(0); //The first time this is invoked, it creates the dummy mob - item_drop_ers = ers_new(sizeof(struct item_drop),"mob.c::item_drop_ers",ERS_OPT_NONE); + item_drop_ers = ers_new(sizeof(struct item_drop),"mob.c::item_drop_ers",ERS_OPT_CLEAN); item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"mob.c::item_drop_list_ers",ERS_OPT_NONE); mob->load(minimal); diff --git a/src/map/party.c b/src/map/party.c index cab12548b..7af6acff5 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -333,7 +333,7 @@ int party_invite(struct map_session_data *sd,struct map_session_data *tsd) } // confirm whether the account has the ability to invite before checking the player - if( !pc->has_permission(sd, PC_PERM_PARTY) || (tsd && !pc->has_permission(tsd, PC_PERM_PARTY)) ) { + if( !pc_has_permission(sd, PC_PERM_PARTY) || (tsd && !pc_has_permission(tsd, PC_PERM_PARTY)) ) { clif->message(sd->fd, msg_txt(81)); // "Your GM level doesn't authorize you to preform this action on the specified player." return 0; } diff --git a/src/map/pc.c b/src/map/pc.c index 24b57c826..9a0760d61 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -77,15 +77,6 @@ struct map_session_data* pc_get_dummy_sd(void) } /** - * Gets player's group level. - * @see pc_group_get_level() - */ -int pc_get_group_level(struct map_session_data *sd) -{ - return pcg->get_level(sd->group); -} - -/** * Sets player's group. * Caller should handle error (preferably display message and disconnect). * @param group_id Group ID @@ -102,14 +93,6 @@ int pc_set_group(struct map_session_data *sd, int group_id) } /** - * Checks if player has permission to perform action. - */ -bool pc_has_permission(struct map_session_data *sd, unsigned int permission) -{ - return ((sd->extra_temp_permissions&permission) != 0 || pcg->has_permission(sd->group, permission)); -} - -/** * Checks if commands used by player should be logged. */ bool pc_should_log_commands(struct map_session_data *sd) @@ -560,22 +543,6 @@ void pc_inventory_rental_add(struct map_session_data *sd, int seconds) sd->rental_timer = timer->add(timer->gettick() + min(tick,3600000), pc->inventory_rental_end, sd->bl.id, 0); } -/** - * Determines if player can give / drop / trade / vend items - */ -bool pc_can_give_items(struct map_session_data *sd) -{ - return pc->has_permission(sd, PC_PERM_TRADE); -} - -/** - * Determines if player can give / drop / trade / vend bounded items - */ -bool pc_can_give_bound_items(struct map_session_data *sd) -{ - return pc->has_permission(sd, PC_PERM_TRADE_BOUND); -} - /*========================================== * prepares character for saving. *------------------------------------------*/ @@ -929,7 +896,7 @@ int pc_isequip(struct map_session_data *sd,int n) item = sd->inventory_data[n]; - if(pc->has_permission(sd, PC_PERM_USE_ALL_EQUIPMENT)) + if(pc_has_permission(sd, PC_PERM_USE_ALL_EQUIPMENT)) return 1; if(item == NULL) @@ -1451,7 +1418,7 @@ int pc_calc_skilltree(struct map_session_data *sd) } } - if( pc->has_permission(sd, PC_PERM_ALL_SKILL) ) { + if( pc_has_permission(sd, PC_PERM_ALL_SKILL) ) { for( i = 0; i < MAX_SKILL; i++ ) { switch(skill->db[i].nameid) { /** @@ -1647,7 +1614,7 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) int skill_point, novice_skills; int c = sd->class_; - if (!battle_config.skillup_limit || pc->has_permission(sd, PC_PERM_ALL_SKILL)) + if (!battle_config.skillup_limit || pc_has_permission(sd, PC_PERM_ALL_SKILL)) return c; skill_point = pc->calc_skillpoint(sd); @@ -4210,7 +4177,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) if( !item->script ) //if it has no script, you can't really consume it! return 0; - if( (item->item_usage.flag&NOUSE_SITTING) && (pc_issit(sd) == 1) && (pc->get_group_level(sd) < item->item_usage.override) ) { + if( (item->item_usage.flag&NOUSE_SITTING) && (pc_issit(sd) == 1) && (pc_get_group_level(sd) < item->item_usage.override) ) { clif->msgtable(sd->fd,0x297); //clif->colormes(sd->fd,COLOR_WHITE,msg_txt(1474)); return 0; // You cannot use this item while sitting. @@ -4539,7 +4506,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun return 1; } - if( !itemdb_cancartstore(item_data, pc->get_group_level(sd)) || (item_data->bound > IBT_ACCOUNT && !pc->can_give_bound_items(sd))) + if( !itemdb_cancartstore(item_data, pc_get_group_level(sd)) || (item_data->bound > IBT_ACCOUNT && !pc_can_give_bound_items(sd))) { // Check item trade restrictions [Skotlex] clif->message (sd->fd, msg_txt(264)); return 1;/* TODO: there is no official response to this? */ @@ -5121,7 +5088,7 @@ int pc_memo(struct map_session_data* sd, int pos) { nullpo_ret(sd); // check mapflags - if( sd->bl.m >= 0 && (map->list[sd->bl.m].flag.nomemo || map->list[sd->bl.m].flag.nowarpto) && !pc->has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { + if( sd->bl.m >= 0 && (map->list[sd->bl.m].flag.nomemo || map->list[sd->bl.m].flag.nowarpto) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { clif->skill_mapinfomessage(sd, 1); // "Saved point cannot be memorized." return 0; } @@ -6318,7 +6285,7 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { clif->updatestatus(sd,SP_SKILLPOINT); if( skill_id == GN_REMODELING_CART ) /* cart weight info was updated by status_calc_pc */ clif->updatestatus(sd,SP_CARTINFO); - if (!pc->has_permission(sd, PC_PERM_ALL_SKILL)) // may skill everything at any time anyways, and this would cause a huge slowdown + if (!pc_has_permission(sd, PC_PERM_ALL_SKILL)) // may skill everything at any time anyways, and this would cause a huge slowdown clif->skillinfoblock(sd); } else if( battle_config.skillup_limit ){ if( sd->sktree.second ) @@ -6351,7 +6318,7 @@ int pc_allskillup(struct map_session_data *sd) } } - if (pc->has_permission(sd, PC_PERM_ALL_SKILL)) { //Get ALL skills except npc/guild ones. [Skotlex] + if (pc_has_permission(sd, PC_PERM_ALL_SKILL)) { //Get ALL skills except npc/guild ones. [Skotlex] //and except SG_DEVIL [Komurka] and MO_TRIPLEATTACK and RG_SNATCHER [ultramage] for(i=0;i<MAX_SKILL;i++){ switch( skill->db[i].nameid ) { @@ -8066,11 +8033,11 @@ int pc_setmadogear(TBL_PC* sd, int flag) *------------------------------------------*/ int pc_candrop(struct map_session_data *sd, struct item *item) { - if( item && (item->expire_time || (item->bound && !pc->can_give_bound_items(sd))) ) + if( item && (item->expire_time || (item->bound && !pc_can_give_bound_items(sd))) ) return 0; - if( !pc->can_give_items(sd) ) //check if this GM level can drop items + if( !pc_can_give_items(sd) ) //check if this GM level can drop items return 0; - return (itemdb_isdropable(item, pc->get_group_level(sd))); + return (itemdb_isdropable(item, pc_get_group_level(sd))); } /*========================================== @@ -10472,12 +10439,8 @@ void pc_defaults(void) { pc->get_dummy_sd = pc_get_dummy_sd; pc->class2idx = pc_class2idx; - pc->get_group_level = pc_get_group_level; - pc->can_give_items = pc_can_give_items; - pc->can_give_bound_items = pc_can_give_bound_items; pc->can_use_command = pc_can_use_command; - pc->has_permission = pc_has_permission; pc->set_group = pc_set_group; pc->should_log_commands = pc_should_log_commands; diff --git a/src/map/pc.h b/src/map/pc.h index 3de1e35fe..5264fa557 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -684,6 +684,12 @@ enum equip_pos { #define pc_readaccountreg2str(sd,reg) (pc->readregistry_str((sd),(reg),1)) #define pc_setaccountreg2str(sd,reg,val) (pc->setregistry_str((sd),(reg),(val),1)) +/* pc_groups easy access */ +#define pc_get_group_level(sd) ( (sd)->group->level ) +#define pc_has_permission(sd,permission) ( ((sd)->extra_temp_permissions&(permission)) != 0 || ((sd)->group->e_permissions&(permission)) != 0 ) +#define pc_can_give_items(sd) ( pc_has_permission((sd),PC_PERM_TRADE) ) +#define pc_can_give_bound_items(sd) ( pc_has_permission((sd),PC_PERM_TRADE_BOUND) ) + struct skill_tree_entry { short id; unsigned short idx; @@ -754,13 +760,11 @@ struct pc_interface { 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_give_bound_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, unsigned int permission); int (*set_group) (struct map_session_data *sd, int group_id); bool (*should_log_commands) (struct map_session_data *sd); diff --git a/src/map/pet.c b/src/map/pet.c index 8cdc78e16..c04d9267a 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -872,7 +872,7 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, int64 tick } } - if(!target && pd->loot && pd->msd && pc->has_permission(pd->msd, PC_PERM_TRADE) && pd->loot->count < pd->loot->max && DIFF_TICK(tick,pd->ud.canact_tick)>0) { + if(!target && pd->loot && pd->msd && pc_has_permission(pd->msd, PC_PERM_TRADE) && pd->loot->count < pd->loot->max && DIFF_TICK(tick,pd->ud.canact_tick)>0) { //Use half the pet's range of sight. map->foreachinrange(pet->ai_sub_hard_lootsearch,&pd->bl, pd->db->range2/2, BL_ITEM,pd,&target); diff --git a/src/map/script.c b/src/map/script.c index 744825257..074348ef0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3685,7 +3685,7 @@ void run_script_main(struct script_state *st) { break; } if( !st->freeloop && cmdcount>0 && (--cmdcount)<=0 ){ - ShowError("run_script: infinity loop !\n"); + ShowError("run_script: too many opeartions being processed non-stop !\n"); script->reportsrc(st); st->state=END; } @@ -4012,7 +4012,7 @@ void do_init_script(bool minimal) { script->userfunc_db = strdb_alloc(DB_OPT_DUP_KEY,0); script->autobonus_db = strdb_alloc(DB_OPT_DUP_KEY,0); - script->st_ers = ers_new(sizeof(struct script_state), "script.c::st_ers", ERS_OPT_NONE); + script->st_ers = ers_new(sizeof(struct script_state), "script.c::st_ers", ERS_OPT_CLEAN); script->stack_ers = ers_new(sizeof(struct script_stack), "script.c::script_stack", ERS_OPT_NONE); ers_chunk_size(script->st_ers, 10); @@ -7990,7 +7990,7 @@ BUILDIN(getgmlevel) if( sd == NULL ) return true;// no player attached, report source - script_pushint(st, pc->get_group_level(sd)); + script_pushint(st, pc_get_group_level(sd)); return true; } @@ -9484,11 +9484,11 @@ BUILDIN(getusersname) sd = script->rid2sd(st); if (!sd) return true; - group_level = pc->get_group_level(sd); + group_level = pc_get_group_level(sd); iter = mapit_getallusers(); for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { - if (pc->has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc->get_group_level(pl_sd) > group_level) + if (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > group_level) continue; // skip hidden sessions /* Temporary fix for bugreport:1023. diff --git a/src/map/skill.c b/src/map/skill.c index 245df05e5..71e343db0 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -446,7 +446,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd) if (idx == 0) return 1; // invalid skill id - if (pc->has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL)) + if (pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL)) return 0; // can do any damn thing they want if( skill_id == AL_TELEPORT && sd->skillitem == skill_id && sd->skillitemlv > 2 ) @@ -6309,7 +6309,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case MC_VENDING: if(sd) { //Prevent vending of GMs with unnecessary Level to trade/drop. [Skotlex] - if ( !pc->can_give_items(sd) ) + if ( !pc_can_give_items(sd) ) clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); else { sd->state.prevend = sd->state.workinprogress = 3; @@ -12262,7 +12262,7 @@ int skill_check_pc_partner (struct map_session_data *sd, uint16 skill_id, uint16 int i; bool is_chorus = ( skill->get_inf2(skill_id)&INF2_CHORUS_SKILL ); - if (!battle_config.player_skill_partner_check || pc->has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL)) + if (!battle_config.player_skill_partner_check || pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL)) return is_chorus ? MAX_PARTY : 99; //As if there were infinite partners. if (cast_flag) { //Execute the skill on the partners. @@ -12358,7 +12358,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id if (sd->chatID) return 0; - if( pc->has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id ) + if( pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id ) { //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex] sd->state.arrow_atk = skill->get_ammotype(skill_id)?1:0; //Need to do arrow state check. sd->spiritball_old = sd->spiritball; //Need to do Spiritball check. @@ -13282,7 +13282,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, if( sd->chatID ) return 0; - if( pc->has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id ) { + if( pc_has_permission(sd, PC_PERM_SKILL_UNCONDITIONAL) && sd->skillitem != skill_id ) { //GMs don't override the skillItem check, otherwise they can use items without them being consumed! [Skotlex] sd->state.arrow_atk = skill->get_ammotype(skill_id)?1:0; //Need to do arrow state check. sd->spiritball_old = sd->spiritball; //Need to do Spiritball check. @@ -17141,10 +17141,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) if( !(cd = idb_get(skill->cd_db,sd->status.char_id)) ) {// create a new skill cooldown object for map storage cd = ers_alloc(skill->cd_ers, struct skill_cd); - - cd->cursor = 0; - memset(cd->entry, 0, sizeof(cd->entry)); - + idb_put( skill->cd_db, sd->status.char_id, cd ); } else { int i; @@ -18215,9 +18212,9 @@ int do_init_skill(bool minimal) { skill->cd_db = idb_alloc(DB_OPT_BASE); skill->usave_db = idb_alloc(DB_OPT_RELEASE_DATA); - skill->unit_ers = ers_new(sizeof(struct skill_unit_group),"skill.c::skill_unit_ers",ERS_OPT_NONE); + skill->unit_ers = ers_new(sizeof(struct skill_unit_group),"skill.c::skill_unit_ers",ERS_OPT_CLEAN); skill->timer_ers = ers_new(sizeof(struct skill_timerskill),"skill.c::skill_timer_ers",ERS_OPT_NONE); - skill->cd_ers = ers_new(sizeof(struct skill_cd),"skill.c::skill_cd_ers",ERS_OPT_CLEAR); + skill->cd_ers = ers_new(sizeof(struct skill_cd),"skill.c::skill_cd_ers",ERS_OPT_CLEAR|ERS_OPT_CLEAN); skill->cd_entry_ers = ers_new(sizeof(struct skill_cd_entry),"skill.c::skill_cd_entry_ers",ERS_OPT_CLEAR); ers_chunk_size(skill->cd_ers, 25); diff --git a/src/map/storage.c b/src/map/storage.c index db85b3c98..e65ed7b80 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -85,7 +85,7 @@ int storage_storageopen(struct map_session_data *sd) if(sd->state.storage_flag) return 1; //Already open? - if( !pc->can_give_items(sd) ) + if( !pc_can_give_items(sd) ) { //check is this GM level is allowed to put items to storage clif->message(sd->fd, msg_txt(246)); return 1; @@ -135,13 +135,13 @@ int storage_additem(struct map_session_data* sd, struct item* item_data, int amo return 1; } - if( !itemdb_canstore(item_data, pc->get_group_level(sd)) ) + if( !itemdb_canstore(item_data, pc_get_group_level(sd)) ) { //Check if item is storable. [Skotlex] clif->message (sd->fd, msg_txt(264)); return 1; } - if( item_data->bound > IBT_ACCOUNT && !pc->can_give_bound_items(sd) ) { + if( item_data->bound > IBT_ACCOUNT && !pc_can_give_bound_items(sd) ) { clif->message(sd->fd, msg_txt(294)); return 1; } @@ -387,7 +387,7 @@ int storage_guild_storageopen(struct map_session_data* sd) if(sd->state.storage_flag) return 1; //Can't open both storages at a time. - if( !pc->can_give_items(sd) ) { //check is this GM level can open guild storage and store items [Lupus] + if( !pc_can_give_items(sd) ) { //check is this GM level can open guild storage and store items [Lupus] clif->message(sd->fd, msg_txt(246)); return 1; } @@ -435,13 +435,13 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto return 1; } - if( !itemdb_canguildstore(item_data, pc->get_group_level(sd)) || item_data->expire_time ) + if( !itemdb_canguildstore(item_data, pc_get_group_level(sd)) || item_data->expire_time ) { //Check if item is storable. [Skotlex] clif->message (sd->fd, msg_txt(264)); return 1; } - if( item_data->bound && item_data->bound != IBT_GUILD && !pc->can_give_bound_items(sd) ) { + if( item_data->bound && item_data->bound != IBT_GUILD && !pc_can_give_bound_items(sd) ) { clif->message(sd->fd, msg_txt(294)); return 1; } diff --git a/src/map/trade.c b/src/map/trade.c index ffd1336f5..6f079bdd3 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -69,7 +69,7 @@ void trade_traderequest(struct map_session_data *sd, struct map_session_data *ta return; } - if (!pc->can_give_items(sd) || !pc->can_give_items(target_sd)) //check if both GMs are allowed to trade + if (!pc_can_give_items(sd) || !pc_can_give_items(target_sd)) //check if both GMs are allowed to trade { clif->message(sd->fd, msg_txt(246)); clif->tradestart(sd, 2); // GM is not allowed to trade @@ -348,8 +348,8 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount) return; item = &sd->status.inventory[index]; - src_lv = pc->get_group_level(sd); - dst_lv = pc->get_group_level(target_sd); + src_lv = pc_get_group_level(sd); + dst_lv = pc_get_group_level(target_sd); if( !itemdb_cantrade(item, src_lv, dst_lv) && //Can't trade (pc->get_partner(sd) != target_sd || !itemdb_canpartnertrade(item, src_lv, dst_lv)) ) //Can't partner-trade { @@ -368,7 +368,7 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount) if( item->bound && !( item->bound == IBT_GUILD && sd->status.guild_id == target_sd->status.guild_id ) && !( item->bound == IBT_PARTY && sd->status.party_id == target_sd->status.party_id ) - && !pc->can_give_bound_items(sd) ) { + && !pc_can_give_bound_items(sd) ) { clif->message(sd->fd, msg_txt(293)); clif->tradeitemok(sd, index+2, TIO_INDROCKS); return; diff --git a/src/map/vending.c b/src/map/vending.c index f16a208e4..7d248351c 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -53,7 +53,7 @@ void vending_vendinglistreq(struct map_session_data* sd, unsigned int id) { if( !vsd->state.vending ) return; // not vending - if (!pc->can_give_items(sd) || !pc->can_give_items(vsd)) { //check if both GMs are allowed to trade + if (!pc_can_give_items(sd) || !pc_can_give_items(vsd)) { //check if both GMs are allowed to trade // GM is not allowed to trade clif->message(sd->fd, msg_txt(246)); return; @@ -257,8 +257,8 @@ void vending_openvending(struct map_session_data* sd, const char* message, const || !sd->status.cart[index].identify // unidentified item || sd->status.cart[index].attribute == 1 // broken item || sd->status.cart[index].expire_time // It should not be in the cart but just in case - || (sd->status.cart[index].bound && !pc->can_give_bound_items(sd)) // can't trade bound items w/o permission - || !itemdb_cantrade(&sd->status.cart[index], pc->get_group_level(sd), pc->get_group_level(sd)) ) // untradeable item + || (sd->status.cart[index].bound && !pc_can_give_bound_items(sd)) // can't trade bound items w/o permission + || !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // untradeable item continue; sd->vending[i].index = index; diff --git a/src/plugins/sample.c b/src/plugins/sample.c index 552194e43..b3e2b570f 100644 --- a/src/plugins/sample.c +++ b/src/plugins/sample.c @@ -109,6 +109,10 @@ int my_pc_dropitem_post(int retVal, struct map_session_data *sd,int *n,int *amou } return 1; } +void parse_my_setting(const char *val) { + ShowDebug("Received 'my_setting:%s'\n",val); + /* do anything with the var e.g. config_switch(val) */ +} /* run when server starts */ HPExport void plugin_init (void) { char *server_type; @@ -168,7 +172,14 @@ HPExport void plugin_init (void) { /* if the original pc->dropitem was successful and the amount stored on my_pc_dropitem_storage is higher than 1, */ /* our posthook will display a message to the user about the cap */ /* - by checking whether it was successful (retVal value) it allows for the originals conditions to take place */ - addHookPost("pc->dropitem",my_pc_dropitem_post); + addHookPost("pc->dropitem",my_pc_dropitem_post); +} +/* triggered when server starts loading, before any server-specific data is set */ +HPExport void server_preinit (void) { + /* makes map server listen to mysetting:value in any "battleconf" file (including imported or custom ones) */ + /* value is not limited to numbers, its passed to our plugins handler (parse_my_setting) as const char *, + * and thus can be manipulated at will */ + addBattleConf("my_setting",parse_my_setting); } /* run when server is ready (online) */ HPExport void server_online (void) { |