diff options
Diffstat (limited to 'src/map/pc.c')
-rw-r--r-- | src/map/pc.c | 82 |
1 files changed, 35 insertions, 47 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 52619bbea..88fdf8337 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1008,7 +1008,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim pc_setinventorydata(sd); pc_setequipindex(sd); - if( sd->status.option & OPTION_INVISIBLE && !pc_can_use_command(sd, "hide", COMMAND_ATCOMMAND) ) + if( sd->status.option & OPTION_INVISIBLE && !pc_can_use_command(sd, "@hide") ) sd->status.option &=~ OPTION_INVISIBLE; status_change_init(&sd->bl); @@ -3571,9 +3571,9 @@ int pc_insert_card(struct map_session_data* sd, int idx_card, int idx_equip) } else {// success - log_pick_pc(sd, LOG_TYPE_OTHER, -1, &sd->status.inventory[idx_equip]); + logs->pick_pc(sd, LOG_TYPE_OTHER, -1, &sd->status.inventory[idx_equip],sd->inventory_data[idx_equip]); sd->status.inventory[idx_equip].card[i] = nameid; - log_pick_pc(sd, LOG_TYPE_OTHER, 1, &sd->status.inventory[idx_equip]); + logs->pick_pc(sd, LOG_TYPE_OTHER, 1, &sd->status.inventory[idx_equip],sd->inventory_data[idx_equip]); clif->insert_card(sd,idx_equip,idx_card,0); } @@ -3692,7 +3692,7 @@ int pc_payzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type, clif->updatestatus(sd,SP_ZENY); if(!tsd) tsd = sd; - log_zeny(sd, type, tsd, -zeny); + logs->zeny(sd, type, tsd, -zeny); if( zeny > 0 && sd->state.showzeny ) { char output[255]; sprintf(output, "Removed %dz.", zeny); @@ -3820,7 +3820,7 @@ int pc_getzeny(struct map_session_data *sd,int zeny, enum e_log_pick_type type, clif->updatestatus(sd,SP_ZENY); if(!tsd) tsd = sd; - log_zeny(sd, type, tsd, zeny); + logs->zeny(sd, type, tsd, zeny); if( zeny > 0 && sd->state.showzeny ) { char output[255]; sprintf(output, "Gained %dz.", zeny); @@ -3915,7 +3915,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l if( !itemdb_isstackable2(data) && !item_data->unique_id ) sd->status.inventory[i].unique_id = itemdb_unique_id(0,0); #endif - log_pick_pc(sd, log_type, amount, &sd->status.inventory[i]); + logs->pick_pc(sd, log_type, amount, &sd->status.inventory[i],sd->inventory_data[i]); sd->weight += w; clif->updatestatus(sd,SP_WEIGHT); @@ -3955,7 +3955,7 @@ int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reas if(sd->status.inventory[n].nameid==0 || amount <= 0 || sd->status.inventory[n].amount<amount || sd->inventory_data[n] == NULL) return 1; - log_pick_pc(sd, log_type, -amount, &sd->status.inventory[n]); + logs->pick_pc(sd, log_type, -amount, &sd->status.inventory[n],sd->inventory_data[n]); sd->status.inventory[n].amount -= amount; sd->weight -= sd->inventory_data[n]->weight*amount ; @@ -4238,7 +4238,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) //Dead Branch & Bloody Branch & Porings Box // FIXME: outdated, use constants or database if( nameid == 604 || nameid == 12103 || nameid == 12109 ) - log_branch(sd); + logs->branch(sd); return 1; } @@ -4453,7 +4453,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun clif->cart_additem(sd,i,amount,0); } sd->status.cart[i].favorite = 0;/* clear */ - log_pick_pc(sd, log_type, amount, &sd->status.cart[i]); + logs->pick_pc(sd, log_type, amount, &sd->status.cart[i],data); sd->cart_weight += w; clif->updatestatus(sd,SP_CARTINFO); @@ -4467,18 +4467,17 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun * 0 = success * 1 = fail *------------------------------------------*/ -int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type) -{ +int pc_cart_delitem(struct map_session_data *sd,int n,int amount,int type,e_log_pick_type log_type) { + struct item_data * data; nullpo_retr(1, sd); - if(sd->status.cart[n].nameid==0 || - sd->status.cart[n].amount<amount) + if( sd->status.cart[n].nameid == 0 || sd->status.cart[n].amount < amount || !data ) return 1; - log_pick_pc(sd, log_type, -amount, &sd->status.cart[n]); + logs->pick_pc(sd, log_type, -amount, &sd->status.cart[n],data); sd->status.cart[n].amount -= amount; - sd->cart_weight -= itemdb_weight(sd->status.cart[n].nameid)*amount ; + sd->cart_weight -= data->weight*amount ; if(sd->status.cart[n].amount <= 0){ memset(&sd->status.cart[n],0,sizeof(sd->status.cart[0])); sd->cart_num--; @@ -4598,6 +4597,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil struct status_data *sd_status, *md_status; struct mob_data *md; struct item tmp_item; + struct item_data *data; if(!sd || !bl || bl->type!=BL_MOB) return 0; @@ -4629,7 +4629,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil // Try dropping one item, in the order from first to last possible slot. // Droprate is affected by the skill success rate. for( i = 0; i < MAX_STEAL_DROP; i++ ) - if( md->db->dropitem[i].nameid > 0 && itemdb_exists(md->db->dropitem[i].nameid) && rnd() % 10000 < md->db->dropitem[i].p * rate/100. ) + if( md->db->dropitem[i].nameid > 0 && (data = itemdb_exists(md->db->dropitem[i].nameid)) && rnd() % 10000 < md->db->dropitem[i].p * rate/100. ) break; if( i == MAX_STEAL_DROP ) return 0; @@ -4638,7 +4638,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil memset(&tmp_item,0,sizeof(tmp_item)); tmp_item.nameid = itemid; tmp_item.amount = 1; - tmp_item.identify = itemdb_isidentified(itemid); + tmp_item.identify = itemdb_isidentified2(data); flag = pc_additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER); //TODO: Should we disable stealing when the item you stole couldn't be added to your inventory? Perhaps players will figure out a way to exploit this behaviour otherwise? @@ -4653,14 +4653,12 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil party_foreachsamemap(pc_show_steal,sd,AREA_SIZE,sd,tmp_item.nameid); //Logs items, Stolen from mobs [Lupus] - log_pick_mob(md, LOG_TYPE_STEAL, -1, &tmp_item); + logs->pick_mob(md, LOG_TYPE_STEAL, -1, &tmp_item, data); //A Rare Steal Global Announce by Lupus if(md->db->dropitem[i].p<=battle_config.rare_drop_announce) { - struct item_data *i_data; char message[128]; - i_data = itemdb_search(itemid); - sprintf (message, msg_txt(542), (sd->status.name != NULL)?sd->status.name :"GM", md->db->jname, i_data->jname, (float)md->db->dropitem[i].p/100); + sprintf (message, msg_txt(542), (sd->status.name != NULL)?sd->status.name :"GM", md->db->jname, data->jname, (float)md->db->dropitem[i].p/100); //MSG: "'%s' stole %s's %s (chance: %0.02f%%)" intif_broadcast(message,strlen(message)+1,0); } @@ -4780,7 +4778,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y // make sure vending is allowed here if (sd->state.vending && map[m].flag.novending) { clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map" - vending_closevending(sd); + vending->close(sd); } if( hChSys.local && map[sd->bl.m].channel && idb_exists(map[sd->bl.m].channel->users, sd->status.char_id) ) { @@ -4831,7 +4829,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y if (sd->state.vending && map_getcell(m,x,y,CELL_CHKNOVENDING)) { clif->message (sd->fd, msg_txt(204)); // "You can't open a shop on this cell." - vending_closevending(sd); + vending->close(sd); } if(sd->bl.prev != NULL){ @@ -7110,7 +7108,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val) case SP_ZENY: if( val < 0 ) return 0;// can't set negative zeny - log_zeny(sd, LOG_TYPE_SCRIPT, sd, -(sd->status.zeny - cap_value(val, 0, MAX_ZENY))); + logs->zeny(sd, LOG_TYPE_SCRIPT, sd, -(sd->status.zeny - cap_value(val, 0, MAX_ZENY))); sd->status.zeny = cap_value(val, 0, MAX_ZENY); break; case SP_BASEEXP: @@ -7469,7 +7467,7 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) if (sd->ed) elemental_delete(sd->ed, 0); if (sd->state.vending) - vending_closevending(sd); + vending->close(sd); map_foreachinmap(jobchange_killclone, sd->bl.m, BL_MOB, sd->bl.id); @@ -9268,22 +9266,10 @@ bool pc_isautolooting(struct map_session_data *sd, int nameid) /** * 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 + * @param command Command name with @/# and without params */ -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 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)); +bool pc_can_use_command(struct map_session_data *sd, const char *command) { + return atcommand->can_use(sd,command); } static int pc_talisman_timer(int tid, unsigned int tick, int id, intptr_t data) @@ -9568,6 +9554,7 @@ static bool pc_readdb_levelpenalty(char* fields[], int columns, int current) int pc_readdb(void) { int i,j,k; + unsigned int count = 0; FILE *fp; char line[24000],*p; @@ -9611,7 +9598,7 @@ int pc_readdb(void) ShowWarning("pc_readdb: Specified max level %u for job %d is beyond server's limit (%u).\n ", maxlv, job_id, MAX_LEVEL); maxlv = MAX_LEVEL; } - + count++; job = jobs[0] = pc_class2idx(job_id); //We send one less and then one more because the last entry in the exp array should hold 0. max_level[job][type] = pc_split_atoui(split[3], exp_table[job][type],',',maxlv-1)+1; @@ -9654,8 +9641,8 @@ int pc_readdb(void) if (!max_level[j][1]) ShowWarning("Class %s (%d) does not has a job exp table.\n", job_name(i), i); } - ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n","exp.txt"); - + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,db_path,"exp.txt"); + count = 0; // Reset and read skilltree memset(skill_tree,0,sizeof(skill_tree)); sv_readdb(db_path, DBPATH"skill_tree.txt", ',', 3+MAX_PC_SKILL_REQUIRE*2, 4+MAX_PC_SKILL_REQUIRE*2, -1, &pc_readdb_skilltree); @@ -9706,7 +9693,7 @@ int pc_readdb(void) lv=atoi(split[0]); n=atoi(split[1]); - + count++; for(i=0;i<n && i<ELE_MAX;){ if( !fgets(line, sizeof(line), fp) ) break; @@ -9727,8 +9714,8 @@ int pc_readdb(void) } } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n","attr_fix.txt"); - + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,db_path,"attr_fix.txt"); + count = 0; // reset then read statspoint memset(statp,0,sizeof(statp)); i=1; @@ -9748,12 +9735,13 @@ int pc_readdb(void) stat=0; if (i > MAX_LEVEL) break; + count++; statp[i]=stat; i++; } fclose(fp); - ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n","statpoint.txt"); + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s/"DBPATH"%s"CL_RESET"'.\n",count,db_path,"statpoint.txt"); } // generate the remaining parts of the db if necessary k = battle_config.use_statpoint_table; //save setting |