From fad0a74cd53f827e4c006b497b658baca2065a3d Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 22 Mar 2007 16:46:09 +0000 Subject: - Removed unused bIgnoreDefMob - Removed unneeded sd variables cart_max_weight and cart_max_num - Made ignore_mdef_ele/ignore_mdef_race/ignore_def_ele/ignore_def_race unsigned chars rather than ints. - Made pc_dropitem check for inventory_data, to guarantee that the item will be deleted from the inventory after dropping it. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10051 54d463be-8e91-2dee-dedb-b68131a5f0ec --- db/const.txt | 2 +- src/map/battle.c | 10 ++++------ src/map/clif.c | 4 ++-- src/map/map.h | 19 +++++++++---------- src/map/pc.c | 18 +++++++----------- src/map/status.c | 7 +++---- 6 files changed, 26 insertions(+), 34 deletions(-) diff --git a/db/const.txt b/db/const.txt index cbe5d3acd..637ae3c44 100644 --- a/db/const.txt +++ b/db/const.txt @@ -382,7 +382,7 @@ bSkillAtk 2018 bUnstripable 2019 bAddDamageByClass 2020 bSPGainValue 2021 -bIgnoreDefMob 2022 + bHPLossRate 2023 bAddRace2 2024 bHPGainValue 2025 diff --git a/src/map/battle.c b/src/map/battle.c index 133b7eed7..a6dfba50b 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -1375,8 +1375,8 @@ static struct Damage battle_calc_weapon_attack( break; case MC_CARTREVOLUTION: skillratio += 50; - if(sd && sd->cart_max_weight > 0 && sd->cart_weight > 0) - skillratio += 100*sd->cart_weight/sd->cart_max_weight; // +1% every 1% weight + if(sd && sd->cart_weight) + skillratio += 100*sd->cart_weight/battle_config.max_cart_weight; // +1% every 1% weight else if (!sd) skillratio += 150; //Max damage for non players. break; @@ -1499,8 +1499,8 @@ static struct Damage battle_calc_weapon_attack( i = 10 * (16 - skill_lv); if (i < 1) i = 1; //Preserve damage ratio when max cart weight is changed. - if(sd && sd->cart_weight && sd->cart_max_weight) - skillratio += sd->cart_weight/i * 80000/sd->cart_max_weight - 100; + if(sd && sd->cart_weight) + skillratio += sd->cart_weight/i * 80000/battle_config.max_cart_weight - 100; else if (!sd) skillratio += 80000 / i - 100; break; @@ -1669,7 +1669,6 @@ static struct Damage battle_calc_weapon_attack( if (skill_num != CR_GRANDCROSS && skill_num != NPC_GRANDDARKNESS) { //Ignore Defense? if (!flag.idef && ( - (target->type == BL_MOB && sd->right_weapon.ignore_def_mob & (is_boss(target)?2:1)) || sd->right_weapon.ignore_def_ele & (1<def_ele) || sd->right_weapon.ignore_def_race & (1<race) || sd->right_weapon.ignore_def_race & (is_boss(target)?1<type == BL_MOB && sd->left_weapon.ignore_def_mob & (is_boss(target)?2:1)) || sd->left_weapon.ignore_def_ele & (1<def_ele) || sd->left_weapon.ignore_def_race & (1<race) || sd->left_weapon.ignore_def_race & (is_boss(target)?1<cart_num; - WFIFOW(fd,4)=sd->cart_max_num; + WFIFOW(fd,4)=MAX_CART; WFIFOL(fd,6)=sd->cart_weight; - WFIFOL(fd,10)=sd->cart_max_weight; + WFIFOL(fd,10)=battle_config.max_cart_weight; len=14; break; diff --git a/src/map/map.h b/src/map/map.h index b267bef5a..561f6a7ab 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -441,16 +441,15 @@ struct weapon_data { // in status_calc_pc as well! All the following are automatically zero'ed. [Skotlex] int overrefine; int star; - int ignore_def_ele; - int ignore_def_race; - int def_ratio_atk_ele; - int def_ratio_atk_race; int addele[ELE_MAX]; int addrace[RC_MAX]; int addrace2[RC_MAX]; int addsize[3]; - short ignore_def_mob; + unsigned char ignore_def_ele; + unsigned char ignore_def_race; + unsigned char def_ratio_atk_ele; + unsigned char def_ratio_atk_race; struct drain_data { short rate; short per; @@ -630,7 +629,7 @@ struct map_session_data { struct item_data *inventory_data[MAX_INVENTORY]; short equip_index[11]; unsigned int weight,max_weight; - int cart_weight,cart_max_weight,cart_num,cart_max_num; + int cart_weight,cart_num; int fd; unsigned short mapindex; unsigned short prev_speed,prev_adelay; @@ -724,8 +723,6 @@ struct map_session_data { int critical_def,double_rate; int long_attack_atk_rate; //Long range atk rate, not weapon based. [Skotlex] int near_attack_def_rate,long_attack_def_rate,magic_def_rate,misc_def_rate; - int ignore_mdef_ele; - int ignore_mdef_race; int perfect_hit; int perfect_hit_add; int get_zeny_rate; @@ -757,6 +754,8 @@ struct map_session_data { short add_def_count,add_mdef_count; short add_dmg_count,add_mdmg_count; + unsigned char ignore_mdef_ele; + unsigned char ignore_mdef_race; // zeroed vars end here. int castrate,delayrate,hprate,sprate,dsprate; @@ -1200,14 +1199,13 @@ enum _sp { SP_HP_DRAIN_VALUE,SP_SP_DRAIN_VALUE, // 1079-1080 SP_WEAPON_ATK,SP_WEAPON_ATK_RATE, // 1081-1082 SP_DELAYRATE,SP_HP_DRAIN_RATE_RACE,SP_SP_DRAIN_RATE_RACE, // 1083-1085 - SP_RESTART_FULL_RECOVER=2000,SP_NO_CASTCANCEL,SP_NO_SIZEFIX,SP_NO_MAGIC_DAMAGE,SP_NO_WEAPON_DAMAGE,SP_NO_GEMSTONE, // 2000-2005 SP_NO_CASTCANCEL2,SP_NO_MISC_DAMAGE,SP_UNBREAKABLE_WEAPON,SP_UNBREAKABLE_ARMOR, SP_UNBREAKABLE_HELM, // 2006-2010 SP_UNBREAKABLE_SHIELD, SP_LONG_ATK_RATE, // 2011-2012 SP_CRIT_ATK_RATE, SP_CRITICAL_ADDRACE, SP_NO_REGEN, SP_ADDEFF_WHENHIT, SP_AUTOSPELL_WHENHIT, // 2013-2017 SP_SKILL_ATK, SP_UNSTRIPABLE, SP_ADD_DAMAGE_BY_CLASS, // 2018-2020 - SP_SP_GAIN_VALUE, SP_IGNORE_DEF_MOB, SP_HP_LOSS_RATE, SP_ADDRACE2, SP_HP_GAIN_VALUE, // 2021-2025 + SP_SP_GAIN_VALUE, SP_FREE, SP_HP_LOSS_RATE, SP_ADDRACE2, SP_HP_GAIN_VALUE, // 2021-2025 SP_SUBSIZE, SP_HP_DRAIN_VALUE_RACE, SP_ADD_ITEM_HEAL_RATE, SP_SP_DRAIN_VALUE_RACE, SP_EXP_ADDRACE, // 2026-2030 SP_SP_GAIN_RACE, SP_SUBRACE2, SP_ADDEFF_WHENHIT_SHORT, // 2031-2033 SP_UNSTRIPABLE_WEAPON,SP_UNSTRIPABLE_ARMOR,SP_UNSTRIPABLE_HELM,SP_UNSTRIPABLE_SHIELD, // 2034-2037 @@ -1215,6 +1213,7 @@ enum _sp { SP_ADD_SKILL_BLOW, SP_SP_VANISH_RATE //2041 //Before adding another, note that these are free: //1024 (SP_FREE2, previous matk) + //2022 (SP_FREE, previous bDefIgnoreMob) }; enum _look { diff --git a/src/map/pc.c b/src/map/pc.c index 1f90b52f5..4c057d849 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1865,12 +1865,6 @@ int pc_bonus(struct map_session_data *sd,int type,int val) if(!sd->state.lr_flag) sd->sp_gain_value += val; break; - case SP_IGNORE_DEF_MOB: // 0:normal monsters only, 1:affects boss monsters as well - if(!sd->state.lr_flag) - sd->right_weapon.ignore_def_mob |= 1<state.lr_flag == 1) - sd->left_weapon.ignore_def_mob |= 1<state.lr_flag) sd->hp_gain_value += val; @@ -2796,10 +2790,12 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) if(amount <= 0) return 0; - if (sd->status.inventory[n].nameid <= 0 || - sd->status.inventory[n].amount < amount || - sd->trade_partner != 0 || sd->vender_id != 0 || - sd->status.inventory[n].amount <= 0) + if(sd->status.inventory[n].nameid <= 0 || + sd->status.inventory[n].amount < amount || + sd->trade_partner != 0 || sd->vender_id != 0 || + sd->status.inventory[n].amount <= 0 || + !sd->inventory_data[n] //pc_delitem would fail on this case. + ) return 0; if (map[sd->bl.m].flag.nodrop) { @@ -3060,7 +3056,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun return 1; } - if((w=data->weight*amount) + sd->cart_weight > sd->cart_max_weight) + if((w=data->weight*amount) + sd->cart_weight > battle_config.max_cart_weight) return 1; i=MAX_CART; diff --git a/src/map/status.c b/src/map/status.c index e2452ad93..58e696f37 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1566,9 +1566,7 @@ int status_calc_pc(struct map_session_data* sd,int first) continue; sd->weight += sd->inventory_data[i]->weight*sd->status.inventory[i].amount; } - sd->cart_max_weight=battle_config.max_cart_weight; sd->cart_weight=0; - sd->cart_max_num=MAX_CART; sd->cart_num=0; for(i=0;istatus.cart[i].nameid==0) @@ -1675,8 +1673,6 @@ int status_calc_pc(struct map_session_data* sd,int first) + sizeof(sd->long_attack_def_rate) + sizeof(sd->magic_def_rate) + sizeof(sd->misc_def_rate) - + sizeof(sd->ignore_mdef_ele) - + sizeof(sd->ignore_mdef_race) + sizeof(sd->perfect_hit) + sizeof(sd->perfect_hit_add) + sizeof(sd->get_zeny_rate) @@ -1716,6 +1712,9 @@ int status_calc_pc(struct map_session_data* sd,int first) + sizeof(sd->add_mdef_count) + sizeof(sd->add_dmg_count) + sizeof(sd->add_mdmg_count) + // chars + + sizeof(sd->ignore_mdef_ele) + + sizeof(sd->ignore_mdef_race) ); // Parse equipment. -- cgit v1.2.3-60-g2f50