From f6daed397dee844234cacd90d395c0b74c404598 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sun, 15 Dec 2013 19:28:03 -0200 Subject: Replaced pc->pc_has_permission/can_give_items/can_give_bound_items with equivalent macros Because 2/3 jumps to perform such a operation is just awful Signed-off-by: shennetsind --- src/map/atcommand.c | 68 +++++++++++++++++++++++++-------------------------- src/map/battle.c | 4 +-- src/map/buyingstore.c | 8 +++--- src/map/chat.c | 4 +-- src/map/clif.c | 24 +++++++++--------- src/map/intif.c | 2 +- src/map/mail.c | 6 ++--- src/map/party.c | 2 +- src/map/pc.c | 45 +++++++--------------------------- src/map/pc.h | 5 +++- src/map/pet.c | 2 +- src/map/script.c | 2 +- src/map/skill.c | 10 ++++---- src/map/storage.c | 8 +++--- src/map/trade.c | 4 +-- src/map/vending.c | 4 +-- 16 files changed, 87 insertions(+), 111 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 66f4a4a75..953f1a0dc 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -404,11 +404,11 @@ ACMD(mapmove) { 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; } @@ -559,7 +559,7 @@ ACMD(who) { 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 @@ -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; } @@ -2680,11 +2680,11 @@ ACMD(recall) { 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; } @@ -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; } @@ -3363,7 +3363,7 @@ ACMD(recallall) 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; } @@ -3424,7 +3424,7 @@ ACMD(guildrecall) 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)) 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; } @@ -3480,7 +3480,7 @@ ACMD(partyrecall) 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)) 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); @@ -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; } @@ -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> ) @@ -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; @@ -9892,7 +9892,7 @@ 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; } diff --git a/src/map/battle.c b/src/map/battle.c index 802d2ec02..3b8064278 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -5830,11 +5830,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 */ diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index fc43df5bd..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)); @@ -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 9e507c57f..6a55ad344 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1811,7 +1811,7 @@ void clif_selllist(struct map_session_data *sd) 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); @@ -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; } @@ -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,7 +14579,7 @@ 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)); @@ -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)) ) { + (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); diff --git a/src/map/intif.c b/src/map/intif.c index 4cfcc3f91..b9d4d1746 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -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*); diff --git a/src/map/mail.c b/src/map/mail.c index 020d92383..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 || + 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)) ) + (sd->status.inventory[idx].bound && !pc_can_give_bound_items(sd)) ) return 1; sd->mail.index = idx; 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 0c5c59e13..9a0760d61 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -92,14 +92,6 @@ int pc_set_group(struct map_session_data *sd, int group_id) return 0; } -/** - * 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. */ @@ -551,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. *------------------------------------------*/ @@ -920,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) @@ -1442,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) { /** @@ -1638,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); @@ -4530,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? */ @@ -5112,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; } @@ -6309,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 ) @@ -6342,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;idb[i].nameid ) { @@ -8057,9 +8033,9 @@ 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))); } @@ -10463,11 +10439,8 @@ void pc_defaults(void) { pc->get_dummy_sd = pc_get_dummy_sd; pc->class2idx = pc_class2idx; - 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 0cad4f5c6..5264fa557 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -684,7 +684,11 @@ 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; @@ -761,7 +765,6 @@ struct pc_interface { 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 bc150b6ee..aa8ac7f63 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -9489,7 +9489,7 @@ BUILDIN(getusersname) 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..6893a9f57 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. diff --git a/src/map/storage.c b/src/map/storage.c index 859bfcb9e..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; @@ -141,7 +141,7 @@ int storage_additem(struct map_session_data* sd, struct item* item_data, int amo 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; } @@ -441,7 +441,7 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto 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 f772c5faf..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 @@ -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 dc22499dd..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,7 +257,7 @@ 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 + || (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; -- cgit v1.2.3-60-g2f50