diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-12-05 13:16:37 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-12-05 13:16:37 +0000 |
commit | 09a89593b983a9ade807175192fcf63971748f7c (patch) | |
tree | 155e93385dfbf0d649f9c4ea4b6ddc4dbddada30 | |
parent | 3a6eb585d49b8c9fadaecddd25ef4b667f814777 (diff) | |
download | hercules-09a89593b983a9ade807175192fcf63971748f7c.tar.gz hercules-09a89593b983a9ade807175192fcf63971748f7c.tar.bz2 hercules-09a89593b983a9ade807175192fcf63971748f7c.tar.xz hercules-09a89593b983a9ade807175192fcf63971748f7c.zip |
- Made the struct weapon_atk lhw in status_data a static member rather than a pointer as requested by Ultra Mage.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11858 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | src/map/battle.c | 12 | ||||
-rw-r--r-- | src/map/clif.c | 8 | ||||
-rw-r--r-- | src/map/map.h | 3 | ||||
-rw-r--r-- | src/map/mob.c | 55 | ||||
-rw-r--r-- | src/map/pc.c | 12 | ||||
-rw-r--r-- | src/map/status.c | 55 | ||||
-rw-r--r-- | src/map/status.h | 14 |
7 files changed, 66 insertions, 93 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index 8a4f24981..236a47504 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -705,7 +705,7 @@ static int battle_calc_base_damage(struct status_data *status, struct weapon_atk atkmin = atkmax; } else { //PCs atkmax = wa->atk; - type = (wa == status->lhw)?EQI_HAND_L:EQI_HAND_R; + type = (wa == &status->lhw)?EQI_HAND_L:EQI_HAND_R; if (!(flag&1) || (flag&2)) { //Normal attacks @@ -964,7 +964,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo s_ele = s_ele_ = skill_get_ele(skill_num, skill_lv); if (!skill_num || s_ele == -1) { //Take weapon's element s_ele = sstatus->rhw.ele; - s_ele_ = sstatus->lhw?sstatus->lhw->ele:0; + s_ele_ = sstatus->lhw.ele; if (flag.arrow && sd && sd->arrow_ele) s_ele = sd->arrow_ele; } else if (s_ele == -2) { //Use enchantment's element @@ -980,7 +980,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo flag.rh=0; flag.lh=1; } - if (sstatus->lhw && sstatus->lhw->atk) + if (sstatus->lhw.atk) flag.lh=1; } @@ -1234,7 +1234,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo } wd.damage = battle_calc_base_damage(sstatus, &sstatus->rhw, sc, tstatus->size, sd, i); if (flag.lh) - wd.damage2 = battle_calc_base_damage(sstatus, sstatus->lhw, sc, tstatus->size, sd, i); + wd.damage2 = battle_calc_base_damage(sstatus, &sstatus->lhw, sc, tstatus->size, sd, i); if (nk&NK_SPLASHSPLIT){ // Divide ATK among targets if(wflag>0) @@ -1737,9 +1737,9 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src,struct blo if (sd && flag.weapon && skill_num != MO_INVESTIGATE && skill_num != MO_EXTREMITYFIST) { if (skill_num == MO_FINGEROFFENSIVE) //Counts refine bonus multiple times { - ATK_ADD2(wd.div_*sstatus->rhw.atk2, wd.div_*sstatus->lhw->atk2); + ATK_ADD2(wd.div_*sstatus->rhw.atk2, wd.div_*sstatus->lhw.atk2); } else { - ATK_ADD2(sstatus->rhw.atk2, sstatus->lhw->atk2); + ATK_ADD2(sstatus->rhw.atk2, sstatus->lhw.atk2); } } diff --git a/src/map/clif.c b/src/map/clif.c index 1fec3b602..54b696db3 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2275,7 +2275,7 @@ int clif_updatestatus(struct map_session_data *sd,int type) WFIFOL(fd,4)=sd->battle_status.amotion; break; case SP_ATK1: - WFIFOL(fd,4)=sd->battle_status.batk +sd->battle_status.rhw.atk +sd->battle_status.lhw->atk; + WFIFOL(fd,4)=sd->battle_status.batk +sd->battle_status.rhw.atk +sd->battle_status.lhw.atk; break; case SP_DEF1: WFIFOL(fd,4)=sd->battle_status.def; @@ -2284,7 +2284,7 @@ int clif_updatestatus(struct map_session_data *sd,int type) WFIFOL(fd,4)=sd->battle_status.mdef; break; case SP_ATK2: - WFIFOL(fd,4)=sd->battle_status.rhw.atk2 + sd->battle_status.lhw->atk2; + WFIFOL(fd,4)=sd->battle_status.rhw.atk2 + sd->battle_status.lhw.atk2; break; case SP_DEF2: WFIFOL(fd,4)=sd->battle_status.def2; @@ -2614,8 +2614,8 @@ int clif_initialstatus(struct map_session_data *sd) WBUFB(buf,14)=min(sd->status.luk, UCHAR_MAX); WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK); - WBUFW(buf,16) = sd->battle_status.batk + sd->battle_status.rhw.atk + sd->battle_status.lhw->atk; - WBUFW(buf,18) = sd->battle_status.rhw.atk2 + sd->battle_status.lhw->atk2; //atk bonus + WBUFW(buf,16) = sd->battle_status.batk + sd->battle_status.rhw.atk + sd->battle_status.lhw.atk; + WBUFW(buf,18) = sd->battle_status.rhw.atk2 + sd->battle_status.lhw.atk2; //atk bonus WBUFW(buf,20) = sd->battle_status.matk_max; WBUFW(buf,22) = sd->battle_status.matk_min; WBUFW(buf,24) = sd->battle_status.def; // def diff --git a/src/map/map.h b/src/map/map.h index dcc2412d1..2608cee05 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -356,7 +356,7 @@ struct status_data { size, race; signed char def, mdef; - struct weapon_atk rhw, *lhw; //Right Hand/Left Hand Weapon. Only players have a lhw (hence it's a pointer) + struct weapon_atk rhw, lhw; //Right Hand/Left Hand Weapon. }; struct script_reg { @@ -512,7 +512,6 @@ struct map_session_data { struct unit_data ud; struct view_data vd; struct status_data base_status, battle_status; - struct weapon_atk base_lhw, battle_lhw; //Left-hand weapon atk data. struct status_change sc; struct regen_data regen; struct regen_data_sub sregen, ssregen; diff --git a/src/map/mob.c b/src/map/mob.c index 5f82b4b6a..7f4aa8ee1 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -2941,40 +2941,43 @@ int mob_clone_spawn(struct map_session_data *sd, int m, int x, int y, const char int i,j,inf,skill_id; struct mob_data *md; struct mob_skill *ms; - + struct mob_db* db; + struct status_data *status; + nullpo_retr(0, sd); ARR_FIND( MOB_CLONE_START, MOB_CLONE_END, class_, mob_db_data[class_] == NULL ); if(class_ >= MOB_CLONE_END) return 0; - mob_db_data[class_]=(struct mob_db*)aCalloc(1, sizeof(struct mob_db)); - sprintf(mob_db_data[class_]->sprite,sd->status.name); - sprintf(mob_db_data[class_]->name,sd->status.name); - sprintf(mob_db_data[class_]->jname,sd->status.name); - mob_db_data[class_]->lv=status_get_lv(&sd->bl); - memcpy(&mob_db_data[class_]->status, &sd->base_status, sizeof(struct status_data)); - mob_db_data[class_]->status.lhw = NULL; //Prevent dangling pointer if player quits. - mob_db_data[class_]->status.rhw.atk = - mob_db_data[class_]->status.rhw.atk2 = sd->base_status.dex; //Min ATK - mob_db_data[class_]->status.rhw.atk2+= - sd->base_status.rhw.atk + sd->base_status.rhw.atk2 + - sd->base_status.lhw->atk + sd->base_status.lhw->atk2; //Max ATK + db = mob_db_data[class_]=(struct mob_db*)aCalloc(1, sizeof(struct mob_db)); + status = &db->status; + sprintf(db->sprite,sd->status.name); + sprintf(db->name,sd->status.name); + sprintf(db->jname,sd->status.name); + db->lv=status_get_lv(&sd->bl); + memcpy(status, &sd->base_status, sizeof(struct status_data)); + status->rhw.atk2= status->dex + status->rhw.atk + status->rhw.atk2; //Max ATK + status->rhw.atk = status->dex; //Min ATK + if (status->lhw.atk) { + status->lhw.atk2= status->dex + status->lhw.atk + status->lhw.atk2; //Max ATK + status->lhw.atk = status->dex; //Min ATK + } if (mode) //User provided mode. - mob_db_data[class_]->status.mode = mode; + status->mode = mode; else if (flag&1) //Friendly Character, remove looting. - mob_db_data[class_]->status.mode &= ~MD_LOOTER; - mob_db_data[class_]->status.hp = mob_db_data[class_]->status.max_hp; - mob_db_data[class_]->status.sp = mob_db_data[class_]->status.max_sp; - memcpy(&mob_db_data[class_]->vd, &sd->vd, sizeof(struct view_data)); - mob_db_data[class_]->base_exp=1; - mob_db_data[class_]->job_exp=1; - mob_db_data[class_]->range2=AREA_SIZE; //Let them have the same view-range as players. - mob_db_data[class_]->range3=AREA_SIZE; //Min chase of a screen. - mob_db_data[class_]->option=sd->sc.option; + status->mode &= ~MD_LOOTER; + status->hp = status->max_hp; + status->sp = status->max_sp; + memcpy(&db->vd, &sd->vd, sizeof(struct view_data)); + db->base_exp=1; + db->job_exp=1; + db->range2=AREA_SIZE; //Let them have the same view-range as players. + db->range3=AREA_SIZE; //Min chase of a screen. + db->option=sd->sc.option; //Skill copy [Skotlex] - ms = &mob_db_data[class_]->skill[0]; + ms = &db->skill[0]; //Go Backwards to give better priority to advanced skills. for (i=0,j = MAX_SKILL_TREE-1;j>=0 && i< MAX_MOBSKILL ;j--) { skill_id = skill_tree[sd->status.class_][j].id; @@ -3057,7 +3060,7 @@ int mob_clone_spawn(struct map_session_data *sd, int m, int x, int y, const char if (i+1 < MAX_MOBSKILL) { //duplicate this so it also triggers on self. memcpy(&ms[i+1], &ms[i], sizeof(struct mob_skill)); - mob_db_data[class_]->maxskill = ++i; + db->maxskill = ++i; ms[i].target = MST_SELF; ms[i].cond1 = MSC_MYHPLTMAXRATE; } @@ -3081,7 +3084,7 @@ int mob_clone_spawn(struct map_session_data *sd, int m, int x, int y, const char if (battle_config.mob_skill_delay != 100) ms[i].delay = ms[i].delay*battle_config.mob_skill_delay/100; - mob_db_data[class_]->maxskill = ++i; + db->maxskill = ++i; } //Finally, spawn it. md = mob_once_spawn_sub(&sd->bl, m, x, y, "--en--",class_,event); diff --git a/src/map/pc.c b/src/map/pc.c index 2ccab3a5a..368f355f0 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1441,8 +1441,8 @@ int pc_bonus(struct map_session_data *sd,int type,int val) status->rhw.atk = cap_value(bonus, 0, USHRT_MAX); } else if(sd->state.lr_flag == 1) { - bonus = status->lhw->atk + val; - status->lhw->atk = cap_value(bonus, 0, USHRT_MAX); + bonus = status->lhw.atk + val; + status->lhw.atk = cap_value(bonus, 0, USHRT_MAX); } break; case SP_ATK2: @@ -1451,8 +1451,8 @@ int pc_bonus(struct map_session_data *sd,int type,int val) status->rhw.atk2 = cap_value(bonus, 0, USHRT_MAX); } else if(sd->state.lr_flag == 1) { - bonus = status->lhw->atk2 + val; - status->lhw->atk2 = cap_value(bonus, 0, USHRT_MAX); + bonus = status->lhw.atk2 + val; + status->lhw.atk2 = cap_value(bonus, 0, USHRT_MAX); } break; case SP_BASE_ATK: @@ -1535,7 +1535,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) } break; case 1: - status->lhw->ele=val; + status->lhw.ele=val; break; default: status->rhw.ele=val; @@ -1594,7 +1594,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) } break; case 1: - status->lhw->range += val; + status->lhw.range += val; break; default: status->rhw.range += val; diff --git a/src/map/status.c b/src/map/status.c index 1b8ce5dbc..204187402 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1598,7 +1598,6 @@ int status_calc_pc(struct map_session_data* sd,int first) { static int calculating = 0; //Check for recursive call preemption. [Skotlex] struct status_data b_status, *status; - struct weapon_atk b_lhw; struct skill b_skill[MAX_SKILL]; int b_weight,b_max_weight; @@ -1612,9 +1611,6 @@ int status_calc_pc(struct map_session_data* sd,int first) return -1; memcpy(&b_status, &sd->battle_status, sizeof(struct status_data)); - memcpy(&b_lhw, &sd->battle_lhw, sizeof(struct weapon_atk)); - b_status.lhw = &b_lhw; - memcpy(b_skill,&sd->status.skill,sizeof(b_skill)); b_weight = sd->weight; b_max_weight = sd->max_weight; @@ -1627,8 +1623,6 @@ int status_calc_pc(struct map_session_data* sd,int first) //Load Hp/SP from char-received data. sd->battle_status.hp = sd->status.hp; sd->battle_status.sp = sd->status.sp; - sd->battle_status.lhw = &sd->battle_lhw; - sd->base_status.lhw = &sd->base_lhw; sd->regen.sregen = &sd->sregen; sd->regen.ssregen = &sd->ssregen; sd->weight=0; @@ -1695,8 +1689,7 @@ int status_calc_pc(struct map_session_data* sd,int first) clif_status_load(&sd->bl, SI_INTRAVISION, 0); memset(&sd->special_state,0,sizeof(sd->special_state)); - memset(&status->max_hp, 0, sizeof(struct status_data)-(sizeof(status->hp)+sizeof(status->sp)+sizeof(status->lhw))); - memset(status->lhw, 0, sizeof(struct weapon_atk)); + memset(&status->max_hp, 0, sizeof(struct status_data)-(sizeof(status->hp)+sizeof(status->sp))); //FIXME: Most of these stuff should be calculated once, but how do I fix the memset above to do that? [Skotlex] status->speed = DEFAULT_WALK_SPEED; @@ -1818,7 +1811,7 @@ int status_calc_pc(struct map_session_data* sd,int first) wlv = MAX_REFINE_BONUS - 1; if(i == EQI_HAND_L && sd->status.inventory[index].equip == EQP_HAND_L) { wd = &sd->left_weapon; // Left-hand weapon - wa = status->lhw; + wa = &status->lhw; } else { wd = &sd->right_weapon; wa = &status->rhw; @@ -1945,9 +1938,9 @@ int status_calc_pc(struct map_session_data* sd,int first) //param_bonus now holds card bonuses. if(status->rhw.range < 1) status->rhw.range = 1; - if(status->lhw->range < 1) status->lhw->range = 1; - if(status->rhw.range < status->lhw->range) - status->rhw.range = status->lhw->range; + if(status->lhw.range < 1) status->lhw.range = 1; + if(status->rhw.range < status->lhw.range) + status->rhw.range = status->lhw.range; sd->double_rate += sd->double_add_rate; sd->perfect_hit += sd->perfect_hit_add; @@ -2362,13 +2355,13 @@ int status_calc_pc(struct map_session_data* sd,int first) if(b_status.amotion != status->amotion) clif_updatestatus(sd,SP_ASPD); if(b_status.rhw.atk != status->rhw.atk || - b_status.lhw->atk != status->lhw->atk || + b_status.lhw.atk != status->lhw.atk || b_status.batk != status->batk) clif_updatestatus(sd,SP_ATK1); if(b_status.def != status->def) clif_updatestatus(sd,SP_DEF1); if(b_status.rhw.atk2 != status->rhw.atk2 || - b_status.lhw->atk2 != status->lhw->atk2) + b_status.lhw.atk2 != status->lhw.atk2) clif_updatestatus(sd,SP_ATK2); if(b_status.def2 != status->def2) clif_updatestatus(sd,SP_DEF2); @@ -3009,14 +3002,14 @@ void status_calc_bl(struct block_list *bl, unsigned long flag) status->rhw.atk = status_calc_watk(bl, sc, b_status->rhw.atk); if (!sd) //Should not affect weapon refine bonus status->rhw.atk2 = status_calc_watk(bl, sc, b_status->rhw.atk2); - if(status->lhw && b_status->lhw && b_status->lhw->atk) { + if(b_status->lhw.atk) { if (sd) { sd->state.lr_flag = 1; - status->lhw->atk = status_calc_watk(bl, sc, b_status->lhw->atk); + status->lhw.atk = status_calc_watk(bl, sc, b_status->lhw.atk); sd->state.lr_flag = 0; } else { - status->lhw->atk = status_calc_watk(bl, sc, b_status->lhw->atk); - status->lhw->atk2= status_calc_watk(bl, sc, b_status->lhw->atk2); + status->lhw.atk = status_calc_watk(bl, sc, b_status->lhw.atk); + status->lhw.atk2= status_calc_watk(bl, sc, b_status->lhw.atk2); } } } @@ -3081,11 +3074,9 @@ void status_calc_bl(struct block_list *bl, unsigned long flag) if(flag&SCB_ATK_ELE) { status->rhw.ele = status_calc_attack_element(bl, sc, b_status->rhw.ele); - if(status->lhw && b_status->lhw) { - if (sd) sd->state.lr_flag = 1; - status->lhw->ele = status_calc_attack_element(bl, sc, b_status->lhw->ele); - if (sd) sd->state.lr_flag = 0; - } + if (sd) sd->state.lr_flag = 1; + status->lhw.ele = status_calc_attack_element(bl, sc, b_status->lhw.ele); + if (sd) sd->state.lr_flag = 0; } if(flag&SCB_DEF_ELE) { @@ -4098,18 +4089,6 @@ struct status_data *status_get_base_status(struct block_list *bl) } } -unsigned short status_get_lwatk(struct block_list *bl) -{ - struct status_data *status = status_get_status_data(bl); - return status->lhw?status->lhw->atk:0; -} - -unsigned short status_get_lwatk2(struct block_list *bl) -{ - struct status_data *status = status_get_status_data(bl); - return status->lhw?status->lhw->atk2:0; -} - signed char status_get_def(struct block_list *bl) { struct unit_data *ud; @@ -4128,12 +4107,6 @@ unsigned short status_get_speed(struct block_list *bl) return status_get_status_data(bl)->speed; } -unsigned char status_get_attack_lelement(struct block_list *bl) -{ - struct status_data *status = status_get_status_data(bl); - return status->lhw?status->lhw->ele:0; -} - int status_get_party_id(struct block_list *bl) { nullpo_retr(0, bl); diff --git a/src/map/status.h b/src/map/status.h index b21bdcbfe..0526bbd65 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -597,11 +597,9 @@ int status_set_sp(struct block_list *bl, unsigned int sp, int flag); int status_heal(struct block_list *bl,int hp,int sp, int flag); int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per_sp); -//Define for copying a status_data structure from b to a, without overwriting current Hp and Sp, nor messing the lhw pointer. -#define status_cpy(a, b) { \ - memcpy(&((a)->max_hp), &((b)->max_hp), sizeof(struct status_data)-(sizeof((a)->hp)+sizeof((a)->sp)+sizeof((a)->lhw))); \ - if ((a)->lhw && (b)->lhw) { memcpy((a)->lhw, (b)->lhw, sizeof(struct weapon_atk)); } \ -} +//Define for copying a status_data structure from b to a, without overwriting current Hp and Sp +#define status_cpy(a, b) \ + memcpy(&((a)->max_hp), &((b)->max_hp), sizeof(struct status_data)-(sizeof((a)->hp)+sizeof((a)->sp))) struct regen_data *status_get_regen_data(struct block_list *bl); struct status_data *status_get_status_data(struct block_list *bl); @@ -633,8 +631,8 @@ signed char status_get_def(struct block_list *bl); #define status_get_watk2(bl) status_get_status_data(bl)->rhw.atk2 #define status_get_matk_max(bl) status_get_status_data(bl)->matk_max #define status_get_matk_min(bl) status_get_status_data(bl)->matk_min -unsigned short status_get_lwatk(struct block_list *bl); -unsigned short status_get_lwatk2(struct block_list *bl); +#define status_get_lwatk(bl) status_get_status_data(bl)->lhw.atk +#define status_get_lwatk2(bl) status_get_status_data(bl)->lhw.atk2 unsigned short status_get_speed(struct block_list *bl); #define status_get_adelay(bl) status_get_status_data(bl)->adelay #define status_get_amotion(bl) status_get_status_data(bl)->amotion @@ -644,7 +642,7 @@ unsigned short status_get_speed(struct block_list *bl); unsigned char status_calc_attack_element(struct block_list *bl, struct status_change *sc, int element); #define status_get_attack_sc_element(bl, sc) status_calc_attack_element(bl, sc, 0) #define status_get_attack_element(bl) status_get_status_data(bl)->rhw.ele -unsigned char status_get_attack_lelement(struct block_list *bl); +#define status_get_attack_lelement(bl) status_get_status_data(bl)->lhw.ele #define status_get_race(bl) status_get_status_data(bl)->race #define status_get_size(bl) status_get_status_data(bl)->size #define status_get_mode(bl) status_get_status_data(bl)->mode |