diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-06-28 22:08:54 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-06-30 02:32:10 +0300 |
commit | 7c21376f8dea2b438cb9470f74acc157a1929f06 (patch) | |
tree | 396829d37d642103dbd98e39b00bed7b8e875461 | |
parent | 48064104f599a2dfa57440a1fda861c27bd55401 (diff) | |
download | hercules-7c21376f8dea2b438cb9470f74acc157a1929f06.tar.gz hercules-7c21376f8dea2b438cb9470f74acc157a1929f06.tar.bz2 hercules-7c21376f8dea2b438cb9470f74acc157a1929f06.tar.xz hercules-7c21376f8dea2b438cb9470f74acc157a1929f06.zip |
Use item attribute as flags varible. Now only ATTR_BROKEN flag exists.
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | src/common/mmo.h | 5 | ||||
-rw-r--r-- | src/map/atcommand.c | 5 | ||||
-rw-r--r-- | src/map/clif.c | 8 | ||||
-rw-r--r-- | src/map/pc.c | 2 | ||||
-rw-r--r-- | src/map/script.c | 14 | ||||
-rw-r--r-- | src/map/skill.c | 9 | ||||
-rw-r--r-- | src/map/vending.c | 2 |
8 files changed, 28 insertions, 19 deletions
@@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac 2f61628. +# From configure.ac 690e18f. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69. # diff --git a/src/common/mmo.h b/src/common/mmo.h index ef87e2c7e..3d3360132 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -311,6 +311,11 @@ struct quest { enum quest_state state; ///< Current quest state }; +enum attribute_flag { + ATTR_NONE = 0, + ATTR_BROKEN = 1, +}; + struct item { int id; short nameid; diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 094e64e2a..858bfea1b 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -4137,8 +4137,9 @@ ACMD(repairall) count = 0; for (i = 0; i < MAX_INVENTORY; i++) { - if (sd->status.inventory[i].nameid && sd->status.inventory[i].attribute == 1) { - sd->status.inventory[i].attribute = 0; + if (sd->status.inventory[i].nameid && (sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { + sd->status.inventory[i].attribute |= ATTR_BROKEN; + sd->status.inventory[i].attribute ^= ATTR_BROKEN; clif->produce_effect(sd, 0, sd->status.inventory[i].nameid); count++; } diff --git a/src/map/clif.c b/src/map/clif.c index 13a7b0839..21c3c1c3e 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2397,7 +2397,7 @@ void clif_additem(struct map_session_data *sd, int n, int amount, int fail) { p.nameid = sd->status.inventory[n].nameid; p.IsIdentified = sd->status.inventory[n].identify ? 1 : 0; - p.IsDamaged = sd->status.inventory[n].attribute ? 1 : 0; + p.IsDamaged = (sd->status.inventory[n].attribute & ATTR_BROKEN) != 0 ? 1 : 0; p.refiningLevel =sd->status.inventory[n].refine; clif->addcards2(&p.slot.card[0], &sd->status.inventory[n]); p.location = pc->equippoint(sd,n); @@ -2512,7 +2512,7 @@ void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *i, struct p->location = eqp_pos; p->WearState = i->equip; #if PACKETVER < 20120925 - p->IsDamaged = i->attribute ? 1 : 0; + p->IsDamaged = (i->attribute & ATTR_BROKEN) != 0 ? 1 : 0; #endif p->RefiningLevel = i->refine; @@ -2532,7 +2532,7 @@ void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *i, struct #if PACKETVER >= 20120925 p->Flag.IsIdentified = i->identify ? 1 : 0; - p->Flag.IsDamaged = i->attribute ? 1 : 0; + p->Flag.IsDamaged = (i->attribute & ATTR_BROKEN) != 0 ? 1 : 0; p->Flag.PlaceETCTab = i->favorite ? 1 : 0; p->Flag.SpareBits = 0; #endif @@ -6020,7 +6020,7 @@ void clif_item_repair_list(struct map_session_data *sd,struct map_session_data * WFIFOW(fd,0)=0x1fc; for (i = c = 0; i < MAX_INVENTORY; i++) { int nameid = dstsd->status.inventory[i].nameid; - if (nameid > 0 && dstsd->status.inventory[i].attribute != 0) { // && skill_can_repair(sd,nameid)) { + if (nameid > 0 && (dstsd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { // && skill_can_repair(sd,nameid)) { WFIFOW(fd,c*13+4) = i; WFIFOW(fd,c*13+6) = nameid; WFIFOB(fd,c*13+8) = dstsd->status.inventory[i].refine; diff --git a/src/map/pc.c b/src/map/pc.c index 460f44f4a..0d851231d 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -9653,7 +9653,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos) if(battle_config.battle_log) ShowInfo("equip %d(%d) %x:%x\n", sd->status.inventory[n].nameid, n, (unsigned int)(id ? id->equip : 0), (unsigned int)req_pos); - if(!pc->isequip(sd,n) || !(pos&req_pos) || sd->status.inventory[n].equip != 0 || sd->status.inventory[n].attribute==1 ) { // [Valaris] + if(!pc->isequip(sd,n) || !(pos&req_pos) || sd->status.inventory[n].equip != 0 || (sd->status.inventory[n].attribute & ATTR_BROKEN) != 0 ) { // [Valaris] // FIXME: pc->isequip: equip level failure uses 2 instead of 0 clif->equipitemack(sd,n,0,EIA_FAIL); // fail return 0; diff --git a/src/map/script.c b/src/map/script.c index 64966f987..12f7dd43c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8604,7 +8604,7 @@ BUILDIN(getbrokenid) num=script_getnum(st,2); for(i=0; i<MAX_INVENTORY; i++) { - if(sd->status.inventory[i].attribute) { + if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { brokencounter++; if(num==brokencounter) { id=sd->status.inventory[i].nameid; @@ -8629,7 +8629,7 @@ BUILDIN(getbrokencount) return true; for (i = 0; i < MAX_INVENTORY; i++) { - if (sd->status.inventory[i].attribute) + if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) counter++; } @@ -8651,10 +8651,11 @@ BUILDIN(repair) num=script_getnum(st,2); for(i=0; i<MAX_INVENTORY; i++) { - if(sd->status.inventory[i].attribute) { + if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { repaircounter++; if(num==repaircounter) { - sd->status.inventory[i].attribute=0; + sd->status.inventory[i].attribute |= ATTR_BROKEN; + sd->status.inventory[i].attribute ^= ATTR_BROKEN; clif->equiplist(sd); clif->produce_effect(sd, 0, sd->status.inventory[i].nameid); clif->misceffect(&sd->bl, 3); @@ -8678,9 +8679,10 @@ BUILDIN(repairall) for(i = 0; i < MAX_INVENTORY; i++) { - if(sd->status.inventory[i].nameid && sd->status.inventory[i].attribute) + if (sd->status.inventory[i].nameid && (sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { - sd->status.inventory[i].attribute = 0; + sd->status.inventory[i].attribute |= ATTR_BROKEN; + sd->status.inventory[i].attribute ^= ATTR_BROKEN; clif->produce_effect(sd,0,sd->status.inventory[i].nameid); repaircounter++; } diff --git a/src/map/skill.c b/src/map/skill.c index 51d0792e3..af82cdbb4 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2005,7 +2005,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in if (sd) { for (i = 0; i < EQI_MAX; i++) { int j = sd->equip_index[i]; - if (j < 0 || sd->status.inventory[j].attribute == 1 || !sd->inventory_data[j]) + if (j < 0 || (sd->status.inventory[j].attribute & ATTR_BROKEN) != 0 || !sd->inventory_data[j]) continue; switch(i) { @@ -2031,7 +2031,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in continue; } if (flag) { - sd->status.inventory[j].attribute = 1; + sd->status.inventory[j].attribute |= ATTR_BROKEN; pc->unequipitem(sd, j, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); } } @@ -15222,7 +15222,7 @@ void skill_repairweapon (struct map_session_data *sd, int idx) { return; //Invalid index?? item = &target_sd->status.inventory[idx]; - if( item->nameid <= 0 || item->attribute == 0 ) + if( item->nameid <= 0 || (item->attribute & ATTR_BROKEN) == 0 ) return; //Again invalid item.... if( sd != target_sd && !battle->check_range(&sd->bl,&target_sd->bl, skill->get_range2(&sd->bl, sd->menuskill_id,sd->menuskill_val2) ) ){ @@ -15241,7 +15241,8 @@ void skill_repairweapon (struct map_session_data *sd, int idx) { clif->skill_nodamage(&sd->bl,&target_sd->bl,sd->menuskill_id,1,1); - item->attribute = 0;/* clear broken state */ + item->attribute |= ATTR_BROKEN; + item->attribute ^= ATTR_BROKEN; /* clear broken state */ clif->equiplist(target_sd); diff --git a/src/map/vending.c b/src/map/vending.c index e3a62bea7..3ae1017f8 100644 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -276,7 +276,7 @@ void vending_openvending(struct map_session_data* sd, const char* message, const || pc->cartitem_amount(sd, index, amount) < 0 // invalid item or insufficient quantity //NOTE: official server does not do any of the following checks! || !sd->status.cart[index].identify // unidentified item - || sd->status.cart[index].attribute == 1 // broken item + || (sd->status.cart[index].attribute & ATTR_BROKEN) != 0 // 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 || !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // untradeable item |