diff options
Diffstat (limited to 'src/map/pc.c')
-rw-r--r-- | src/map/pc.c | 144 |
1 files changed, 71 insertions, 73 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 22f165374..94d505c15 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -37,6 +37,7 @@ #include "skill.h" #include "status.h" // struct status_data #include "pc.h" +#include "pc_groups.h" #include "quest.h" #include <stdio.h> @@ -81,9 +82,14 @@ int pc_class2idx(int class_) { return class_; } -int pc_isGM(struct map_session_data* sd) +int inline pc_get_group_id(struct map_session_data *sd) { - return sd->gmlevel; + return sd->group_id; +} + +int inline pc_get_group_level(struct map_session_data *sd) +{ + return pc_group_id2level(pc_get_group_id(sd)); } static int pc_invincible_timer(int tid, unsigned int tick, int id, intptr_t data) @@ -478,13 +484,12 @@ void pc_inventory_rental_add(struct map_session_data *sd, int seconds) sd->rental_timer = add_timer(gettick() + min(tick,3600000), pc_inventory_rental_end, sd->bl.id, 0); } -/*========================================== - Determines if the GM can give / drop / trade / vend items - Args: GM Level (current player GM level) - *------------------------------------------*/ -bool pc_can_give_items(int level) +/** + * Determines if player can give / drop / trade / vend items + */ +bool pc_can_give_items(struct map_session_data *sd) { - return( level < battle_config.gm_cant_drop_min_lv || level > battle_config.gm_cant_drop_max_lv ); + return pc_has_permission(sd, PC_PERM_TRADE); } /*========================================== @@ -815,7 +820,7 @@ int pc_isequip(struct map_session_data *sd,int n) item = sd->inventory_data[n]; - if( battle_config.gm_allequip>0 && pc_isGM(sd)>=battle_config.gm_allequip ) + if(pc_has_permission(sd, PC_PERM_USE_ALL_EQUIPMENT)) return 1; if(item == NULL) @@ -885,14 +890,14 @@ int pc_isequip(struct map_session_data *sd,int n) * session idに問題無し * char鯖から送られてきたステ?タスを設定 *------------------------------------------*/ -bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int gmlevel, struct mmo_charstatus *st, bool changing_mapservers) +bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers) { int i; unsigned long tick = gettick(); uint32 ip = session[sd->fd]->client_addr; sd->login_id2 = login_id2; - sd->gmlevel = gmlevel; + sd->group_id = group_id; memcpy(&sd->status, st, sizeof(*st)); if (st->sex != sd->status.sex) { @@ -975,7 +980,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim pc_setequipindex(sd); status_change_init(&sd->bl); - if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) && (pc_isGM(sd) >= get_atcommand_level("hide"))) + if (pc_can_use_command(sd, "hide", COMMAND_ATCOMMAND)) sd->status.option &= (OPTION_MASK | OPTION_INVISIBLE); else sd->status.option &= OPTION_MASK; @@ -1015,20 +1020,12 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim sd->die_counter=-1; //display login notice - if( sd->gmlevel >= battle_config.lowest_gm_level ) - ShowInfo("GM '"CL_WHITE"%s"CL_RESET"' logged in." - " (AID/CID: '"CL_WHITE"%d/%d"CL_RESET"'," - " Packet Ver: '"CL_WHITE"%d"CL_RESET"', IP: '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'," - " GM Level '"CL_WHITE"%d"CL_RESET"').\n", - sd->status.name, sd->status.account_id, sd->status.char_id, - sd->packet_ver, CONVIP(ip), sd->gmlevel); - else - ShowInfo("'"CL_WHITE"%s"CL_RESET"' logged in." - " (AID/CID: '"CL_WHITE"%d/%d"CL_RESET"'," - " Packet Ver: '"CL_WHITE"%d"CL_RESET"', IP: '"CL_WHITE"%d.%d.%d.%d"CL_RESET"').\n", - sd->status.name, sd->status.account_id, sd->status.char_id, - sd->packet_ver, CONVIP(ip)); - + ShowInfo("'"CL_WHITE"%s"CL_RESET"' logged in." + " (AID/CID: '"CL_WHITE"%d/%d"CL_RESET"'," + " Packet Ver: '"CL_WHITE"%d"CL_RESET"', IP: '"CL_WHITE"%d.%d.%d.%d"CL_RESET"'," + " Group '"CL_WHITE"%d"CL_RESET"').\n", + sd->status.name, sd->status.account_id, sd->status.char_id, + sd->packet_ver, CONVIP(ip), sd->group_id); // Send friends list clif_friendslist_send(sd); @@ -1280,7 +1277,7 @@ int pc_calc_skilltree(struct map_session_data *sd) } } - if( battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill ) { + if( pc_has_permission(sd, PC_PERM_ALL_SKILL) ) { for( i = 0; i < MAX_SKILL; i++ ) { switch(i) { /** @@ -4004,7 +4001,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun return 1; data = itemdb_search(item_data->nameid); - if( !itemdb_cancartstore(item_data, pc_isGM(sd)) ) + if( !itemdb_cancartstore(item_data, pc_get_group_level(sd)) ) { // Check item trade restrictions [Skotlex] clif_displaymessage (sd->fd, msg_txt(264)); return 1; @@ -4451,45 +4448,6 @@ int pc_randomwarp(struct map_session_data *sd, clr_type type) return 0; } - -/// Warps one player to another. -/// @param sd player to warp. -/// @param pl_sd player to warp to. -int pc_warpto(struct map_session_data* sd, struct map_session_data* pl_sd) -{ - if( map[sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) - { - return -2; - } - - if( map[pl_sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) - { - return -3; - } - - return pc_setpos(sd, pl_sd->mapindex, pl_sd->bl.x, pl_sd->bl.y, CLR_TELEPORT); -} - - -/// Recalls one player to another. -/// @param sd player to warp to. -/// @param pl_sd player to warp. -int pc_recall(struct map_session_data* sd, struct map_session_data* pl_sd) -{ - if( map[pl_sd->bl.m].flag.nowarp && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) - { - return -2; - } - - if( map[sd->bl.m].flag.nowarpto && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) - { - return -3; - } - - return pc_setpos(pl_sd, sd->mapindex, sd->bl.x, sd->bl.y, CLR_RESPAWN); -} - - /*========================================== * Records a memo point at sd's current position * pos - entry to replace, (-1: shift oldest entry out) @@ -4501,7 +4459,7 @@ int pc_memo(struct map_session_data* sd, int pos) nullpo_ret(sd); // check mapflags - if( sd->bl.m >= 0 && (map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto) && battle_config.any_warp_GM_min_level > pc_isGM(sd) ) { + if( sd->bl.m >= 0 && (map[sd->bl.m].flag.nomemo || map[sd->bl.m].flag.nowarpto) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE) ) { clif_skill_teleportmessage(sd, 1); // "Saved point cannot be memorized." return 0; } @@ -5586,7 +5544,7 @@ int pc_allskillup(struct map_session_data *sd) } //pc_calc_skilltree takes care of setting the ID to valid skills. [Skotlex] - if (battle_config.gm_allskill > 0 && pc_isGM(sd) >= battle_config.gm_allskill) + 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++){ @@ -5761,6 +5719,13 @@ int pc_resetstate(struct map_session_data* sd) clif_updatestatus(sd,SP_ULUK); // End Addition clif_updatestatus(sd,SP_STATUSPOINT); + + if( sd->mission_mobid ) { //bugreport:2200 + sd->mission_mobid = 0; + sd->mission_count = 0; + pc_setglobalreg(sd,"TK_MISSION_ID", 0); + } + status_calc_pc(sd,0); return 1; @@ -7026,14 +6991,13 @@ int pc_setriding(TBL_PC* sd, int flag) /*========================================== * アイテムドロップ可不可判定 *------------------------------------------*/ -int pc_candrop(struct map_session_data *sd,struct item *item) +int pc_candrop(struct map_session_data *sd, struct item *item) { - int level = pc_isGM(sd); if( item && item->expire_time ) return 0; - if( !pc_can_give_items(level) ) //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, level)); + return (itemdb_isdropable(item, pc_get_group_level(sd))); } /*========================================== @@ -8255,6 +8219,37 @@ bool pc_isautolooting(struct map_session_data *sd, int nameid) return (i != AUTOLOOTITEM_SIZE); } +/** + * Checks if player can use @/#command + * @param sd Player map session data + * @param command Command name without @/# and params + * @param type is it atcommand or charcommand + */ +bool pc_can_use_command(struct map_session_data *sd, const char *command, AtCommandType type) +{ + return pc_group_can_use_command(pc_get_group_id(sd), command, type); +} + +/** + * Checks if player has a permission + * @param sd Player map session data + * @param permission permission to check + */ +bool pc_has_permission(struct map_session_data *sd, int permission) +{ + return pc_group_has_permission(pc_get_group_id(sd), permission); +} + +/** + * Checks if commands used by a player should be logged + * according to their group setting. + * @param sd Player map session data + */ +bool pc_should_log_commands(struct map_session_data *sd) +{ + return pc_group_should_log_commands(pc_get_group_id(sd)); +} + int pc_split_str(char *str,char **val,int num) { int i; @@ -8628,6 +8623,7 @@ int pc_read_motd(void) *------------------------------------------*/ void do_final_pc(void) { + do_final_pc_groups(); return; } @@ -8665,5 +8661,7 @@ int do_init_pc(void) } } + do_init_pc_groups(); + return 0; } |