From 9047b6cc43aa4a0611b7fa9b32979e88d8c651b8 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 4 Sep 2016 20:04:57 +0200 Subject: Add item subtype (weapon/ammunition type) constants Signed-off-by: Haru --- src/map/script.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src') diff --git a/src/map/script.c b/src/map/script.c index 8722fcdbe..ff6263b4b 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -24480,6 +24480,43 @@ void script_hardcoded_constants(void) script->set_constant("DATATYPE_VAR", DATATYPE_VAR, false, false); script->set_constant("DATATYPE_LABEL", DATATYPE_LABEL, false, false); + script->constdb_comment("Item Subtypes (Weapon types)"); + script->set_constant("W_FIST", W_FIST, false, false); + script->set_constant("W_DAGGER", W_DAGGER, false, false); + script->set_constant("W_1HSWORD", W_1HSWORD, false, false); + script->set_constant("W_2HSWORD", W_2HSWORD, false, false); + script->set_constant("W_1HSPEAR", W_1HSPEAR, false, false); + script->set_constant("W_2HSPEAR", W_2HSPEAR, false, false); + script->set_constant("W_1HAXE", W_1HAXE, false, false); + script->set_constant("W_2HAXE", W_2HAXE, false, false); + script->set_constant("W_MACE", W_MACE, false, false); + script->set_constant("W_2HMACE", W_2HMACE, false, false); + script->set_constant("W_STAFF", W_STAFF, false, false); + script->set_constant("W_BOW", W_BOW, false, false); + script->set_constant("W_KNUCKLE", W_KNUCKLE, false, false); + script->set_constant("W_MUSICAL", W_MUSICAL, false, false); + script->set_constant("W_WHIP", W_WHIP, false, false); + script->set_constant("W_BOOK", W_BOOK, false, false); + script->set_constant("W_KATAR", W_KATAR, false, false); + script->set_constant("W_REVOLVER", W_REVOLVER, false, false); + script->set_constant("W_RIFLE", W_RIFLE, false, false); + script->set_constant("W_GATLING", W_GATLING, false, false); + script->set_constant("W_SHOTGUN", W_SHOTGUN, false, false); + script->set_constant("W_GRENADE", W_GRENADE, false, false); + script->set_constant("W_HUUMA", W_HUUMA, false, false); + script->set_constant("W_2HSTAFF", W_2HSTAFF, false, false); + + script->constdb_comment("Item Subtypes (Ammunition types)"); + script->set_constant("A_ARROW", A_ARROW, false, false); + script->set_constant("A_DAGGER", A_DAGGER, false, false); + script->set_constant("A_BULLET", A_BULLET, false, false); + script->set_constant("A_SHELL", A_SHELL, false, false); + script->set_constant("A_GRENADE", A_GRENADE, false, false); + script->set_constant("A_SHURIKEN", A_SHURIKEN, false, false); + script->set_constant("A_KUNAI", A_KUNAI, false, false); + script->set_constant("A_CANNONBALL", A_CANNONBALL, false, false); + script->set_constant("A_THROWWEAPON", A_THROWWEAPON, false, false); + script->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); -- cgit v1.2.3-70-g09d2 From 00570591031eb6fc99c7c26ba58a2a7efb144e7f Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 5 Sep 2016 00:04:37 +0200 Subject: Reimplement getiteminfo/setiteminfo in a safer and more maintainable way Signed-off-by: Haru --- src/map/itemdb.h | 3 - src/map/script.c | 171 ++++++++++++++++++++++++++++++++++++------------------- 2 files changed, 113 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 35cd154cb..0ab6ef65b 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -454,7 +454,6 @@ struct item_data { uint16 nameid; char name[ITEM_NAME_LENGTH],jname[ITEM_NAME_LENGTH]; - //Do not add stuff between value_buy and view_id (see how getiteminfo works) int value_buy; int value_sell; int type; @@ -474,8 +473,6 @@ struct item_data { int elvmax;/* maximum level for this item */ int delay; -//Lupus: I rearranged order of these fields due to compatibility with ITEMINFO script command -// some script commands should be revised as well... uint64 class_base[3]; ///< Specifies if the base can wear this item (split in 3 indexes per type: 1-1, 2-1, 2-2) unsigned class_upper : 6; ///< Specifies if the upper-type can equip it (bitfield, 0x01: normal, 0x02: upper, 0x04: baby normal, 0x08: third normal, 0x10: third upper, 0x20: third baby) struct { diff --git a/src/map/script.c b/src/map/script.c index ff6263b4b..914bee75c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -13982,43 +13982,70 @@ BUILDIN(getitemslots) return true; } -// TODO: add matk here if needed/once we get rid of RENEWAL +// TODO: add matk here if needed /*========================================== * Returns some values of an item [Lupus] * Price, Weight, etc... - * getiteminfo(itemID,n), where n - * 0 value_buy; - * 1 value_sell; - * 2 type; - * 3 maxchance = Max drop chance of this item e.g. 1 = 0.01% , etc.. - * if = 0, then monsters don't drop it at all (rare or a quest item) - * if = -1, then this item is sold in NPC shops only - * 4 sex; - * 5 equip; - * 6 weight; - * 7 atk; - * 8 def; - * 9 range; - * 10 slot; - * 11 look; - * 12 elv; - * 13 wlv; - * 14 view id *------------------------------------------*/ BUILDIN(getiteminfo) { - int item_id,n; - struct item_data *i_data; + int item_id = script_getnum(st, 2); + int n = script_getnum(st, 3); + struct item_data *it = itemdb->exists(item_id); - item_id = script_getnum(st,2); - n = script_getnum(st,3); - i_data = itemdb->exists(item_id); + if (it == NULL) { + script_pushint(st, -1); + return true; + } - if (i_data && n>=0 && n<=14) { - int *item_arr = (int*)&i_data->value_buy; - script_pushint(st,item_arr[n]); - } else { + switch (n) { + case 0: + script_pushint(st, it->value_buy); + break; + case 1: + script_pushint(st, it->value_sell); + break; + case 2: + script_pushint(st, it->type); + break; + case 3: + script_pushint(st, it->maxchance); + break; + case 4: + script_pushint(st, it->sex); + break; + case 5: + script_pushint(st, it->equip); + break; + case 6: + script_pushint(st, it->weight); + break; + case 7: + script_pushint(st, it->atk); + break; + case 8: + script_pushint(st, it->def); + break; + case 9: + script_pushint(st, it->range); + break; + case 10: + script_pushint(st, it->slot); + break; + case 11: + script_pushint(st, it->look); + break; + case 12: + script_pushint(st, it->elv); + break; + case 13: + script_pushint(st, it->wlv); + break; + case 14: + script_pushint(st, it->view_id); + break; + default: script_pushint(st,-1); } return true; @@ -14211,43 +14238,71 @@ BUILDIN(setequipoption) /*========================================== * Set some values of an item [Lupus] * Price, Weight, etc... - * setiteminfo(itemID,n,Value), where n - * 0 value_buy; - * 1 value_sell; - * 2 type; - * 3 maxchance = Max drop chance of this item e.g. 1 = 0.01% , etc.. - * if = 0, then monsters don't drop it at all (rare or a quest item) - * if = -1, then this item is sold in NPC shops only - * 4 sex; - * 5 equip; - * 6 weight; - * 7 atk; - * 8 def; - * 9 range; - * 10 slot; - * 11 look; - * 12 elv; - * 13 wlv; - * 14 view id - * Returns Value or -1 if the wrong field's been set *------------------------------------------*/ BUILDIN(setiteminfo) { - int item_id,n,value; - struct item_data *i_data; + // TODO: Validate data in a similar way as during database load + int item_id = script_getnum(st, 2); + int n = script_getnum(st, 3); + int value = script_getnum(st,4); + struct item_data *it = itemdb->exists(item_id); - item_id = script_getnum(st,2); - n = script_getnum(st,3); - value = script_getnum(st,4); - i_data = itemdb->exists(item_id); + if (it == NULL) { + script_pushint(st, -1); + return true; + } - if (i_data && n>=0 && n<=14) { - int *item_arr = (int*)&i_data->value_buy; - item_arr[n] = value; - script_pushint(st,value); - } else { + switch (n) { + case 0: + it->value_buy = value; + break; + case 1: + it->value_sell = value; + break; + case 2: + it->type = value; + break; + case 3: + it->maxchance = value; + break; + case 4: + it->sex = value; + break; + case 5: + it->equip = value; + break; + case 6: + it->weight = value; + break; + case 7: + it->atk = value; + break; + case 8: + it->def = value; + break; + case 9: + it->range = value; + break; + case 10: + it->slot = value; + break; + case 11: + it->look = value; + break; + case 12: + it->elv = value; + break; + case 13: + it->wlv = value; + break; + case 14: + it->view_id = value; + break; + default: script_pushint(st,-1); + return true; } + script_pushint(st,value); return true; } -- cgit v1.2.3-70-g09d2 From a98b2d93f3727d18d8add5cb5c35830cbb171114 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 5 Sep 2016 00:07:08 +0200 Subject: Split 'View' in two different fields in the item database - The field was used both for sprite view IDs and for weapon or ammunition subtypes. Now the fields 'ViewSprite' and 'Subtype' are used respectively. Signed-off-by: Haru --- db/item_db2.conf | 3 +- db/pre-re/item_db.conf | 3 +- db/re/item_db.conf | 3 +- doc/item_db.txt | 10 +++-- doc/script_commands.txt | 4 +- src/common/mmo.h | 1 + src/map/battle.c | 9 ++--- src/map/clif.c | 4 +- src/map/itemdb.c | 43 ++++++++++++++++---- src/map/itemdb.h | 6 ++- src/map/pc.c | 105 ++++++++++++++++++++++++------------------------ src/map/script.c | 4 +- src/map/skill.c | 2 +- src/map/status.c | 2 +- src/plugins/db2sql.c | 10 +++-- 15 files changed, 124 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/db/item_db2.conf b/db/item_db2.conf index e6b467b58..3d388bf14 100644 --- a/db/item_db2.conf +++ b/db/item_db2.conf @@ -86,7 +86,8 @@ item_db: ( EquipLv: Equip required level (int, defaults to 0) EquipLv: [min, max] (alternative syntax with min / max level) Refine: Refineable (boolean, defaults to true) - View: View ID (int, defaults to 0) + Subtype: Item Subtype (int, defaults to 0) + ViewSprite: Sprite view ID (int, defaults to 0) BindOnEquip: true/false (boolean, defaults to false) ForceSerial: true/false (boolean, defaults to false) BuyingStore: true/false (boolean, defaults to false) diff --git a/db/pre-re/item_db.conf b/db/pre-re/item_db.conf index ee7166982..def5d692a 100644 --- a/db/pre-re/item_db.conf +++ b/db/pre-re/item_db.conf @@ -87,7 +87,8 @@ item_db: ( EquipLv: [min, max] (alternative syntax with min / max level) Refine: Refineable (boolean, defaults to true) DisableOptions: true/false (boolean, defaults to false !!for equipments only!!) [Smokexyz] - View: View ID (int, defaults to 0) + Subtype: Item Subtype (int, defaults to 0) + ViewSprite: Sprite view ID (int, defaults to 0) BindOnEquip: true/false (boolean, defaults to false) ForceSerial: true/false (boolean, defaults to false) BuyingStore: true/false (boolean, defaults to false) diff --git a/db/re/item_db.conf b/db/re/item_db.conf index 5b49f070f..b2268b909 100644 --- a/db/re/item_db.conf +++ b/db/re/item_db.conf @@ -87,7 +87,8 @@ item_db: ( EquipLv: [min, max] (alternative syntax with min / max level) Refine: Refineable (boolean, defaults to true) DisableOptions: true/false (boolean, defaults to false !!for equipments only!!) [Smokexyz] - View: View ID (int, defaults to 0) + Subtype: Item Subtype (int, defaults to 0) + ViewSprite: Sprite view ID (int, defaults to 0) BindOnEquip: true/false (boolean, defaults to false) ForceSerial: true/false (boolean, defaults to false) BuyingStore: true/false (boolean, defaults to false) diff --git a/doc/item_db.txt b/doc/item_db.txt index c43b5a69c..04f05fb4e 100644 --- a/doc/item_db.txt +++ b/doc/item_db.txt @@ -65,7 +65,8 @@ item_db: ( EquipLv: Equip required level (int, defaults to 0) EquipLv: [min, max] (alternative syntax with min / max level) Refine: Refineable (boolean, defaults to true) - View: View ID (int, defaults to 0) + Subtype: Item Subtype (int, defaults to 0) + ViewSprite: Sprite view ID (int, defaults to 0) BindOnEquip: true/false (boolean, defaults to false) ForceSerial: true/false (boolean, defaults to false) BuyingStore: true/false (boolean, defaults to false) @@ -239,9 +240,10 @@ EquipLv: Base level required to be able to equip. It is possible to specify Refineable: true if the item can be refined, false otherwise. If no value is specified, it defaults to true. -View: For normal items, defines a replacement view-sprite for the item (eg: - Making apples look like apple juice). The special case are weapons - and ammo where this value indicates the weapon-class of the item. +ViewSprite: Defines a replacement view-sprite for the item (eg: + Making apples look like apple juice). + +Subtype: For weapons and ammo, indicates the weapon-class of the item. For weapons, the types are: W_FIST 0: Bare fist diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 779cd271c..79d609125 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3186,7 +3186,7 @@ Valid types are: if = 0, then monsters don't drop it at all (rare or a quest item) if = 10000, then this item is sold in NPC shops only 4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range; - 10 - slot; 11 - look; 12 - elv; 13 - wlv; 14 - view id + 10 - slot; 11 - subtype; 12 - elv; 13 - wlv; 14 - view id If RENEWAL is defined, 15 - matk @@ -8251,7 +8251,7 @@ Valid types are: if = 0, then monsters don't drop it at all (rare or a quest item) if = 10000, then this item is sold in NPC shops only 4 - sex; 5 - equip; 6 - weight; 7 - atk; 8 - def; 9 - range; - 10 - slot; 11 - look; 12 - elv; 13 - wlv; 14 - view id + 10 - slot; 11 - subtype; 12 - elv; 13 - wlv; 14 - view id Example: diff --git a/src/common/mmo.h b/src/common/mmo.h index 9bb9837ab..7670a7ac8 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -1132,6 +1132,7 @@ enum ammo_type { A_KUNAI, //7 A_CANNONBALL, //8 A_THROWWEAPON, //9 + MAX_AMMO_TYPE }; enum e_char_server_type { diff --git a/src/map/battle.c b/src/map/battle.c index b5ad62407..9d67242a2 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -4575,8 +4575,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if(!skill_id) { //Skills ALWAYS use ONLY your right-hand weapon (tested on Aegis 10.2) - if (sd && sd->weapontype1 == 0 && sd->weapontype2 > 0) - { + if (sd && sd->weapontype1 == W_FIST && sd->weapontype2 != W_FIST) { flag.rh=0; flag.lh=1; } @@ -6102,7 +6101,7 @@ bool battle_check_arrows(struct map_session_data *sd) if (sd->inventory_data[index]) { switch (sd->status.weapon) { case W_BOW: - if (sd->inventory_data[index]->look != A_ARROW) { + if (sd->inventory_data[index]->subtype != A_ARROW) { clif->arrow_fail(sd, 0); return false; } @@ -6111,13 +6110,13 @@ bool battle_check_arrows(struct map_session_data *sd) case W_RIFLE: case W_GATLING: case W_SHOTGUN: - if (sd->inventory_data[index]->look != A_BULLET) { + if (sd->inventory_data[index]->subtype != A_BULLET) { clif->skill_fail(sd, 0, USESKILL_FAIL_NEED_MORE_BULLET, 0); return false; } break; case W_GRENADE: - if (sd->inventory_data[index]->look != A_GRENADE) { + if (sd->inventory_data[index]->subtype != A_GRENADE) { clif->skill_fail(sd, 0, USESKILL_FAIL_NEED_MORE_BULLET, 0); return false; } diff --git a/src/map/clif.c b/src/map/clif.c index 1731e88ca..3599640b9 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2597,7 +2597,7 @@ void clif_item_equip(short idx, struct EQUIPITEM_INFO *p, struct item *it, struc #endif #if PACKETVER >= 20100629 - p->wItemSpriteNumber = (id->equip&EQP_VISIBLE) ? id->look : 0; + p->wItemSpriteNumber = (id->equip&EQP_VISIBLE) ? id->view_sprite : 0; #endif #if PACKETVER >= 20120925 @@ -3527,7 +3527,7 @@ void clif_equipitemack(struct map_session_data *sd,int n,int pos,enum e_EQUIP_IT p.wearLocation = pos; #if PACKETVER >= 20100629 if (result == EIA_SUCCESS && sd->inventory_data[n]->equip&EQP_VISIBLE) - p.wItemSpriteNumber = sd->inventory_data[n]->look; + p.wItemSpriteNumber = sd->inventory_data[n]->view_sprite; else p.wItemSpriteNumber = 0; #endif diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 2b0847e1a..40dd9ab4f 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -1638,9 +1638,9 @@ int itemdb_gendercheck(struct item_data *id) return 1; if (id->nameid == WEDDING_RING_F) //Bride Ring return 0; - if (id->look == W_MUSICAL && id->type == IT_WEAPON) //Musical instruments are always male-only + if (id->subtype == W_MUSICAL && id->type == IT_WEAPON) //Musical instruments are always male-only return 1; - if (id->look == W_WHIP && id->type == IT_WEAPON) //Whips are always female-only + if (id->subtype == W_WHIP && id->type == IT_WEAPON) //Whips are always female-only return 0; return (battle_config.ignore_items_gender) ? 2 : id->sex; @@ -1788,10 +1788,14 @@ int itemdb_validate_entry(struct item_data *entry, int n, const char *source) { memset(&entry->stack, '\0', sizeof(entry->stack)); } - if (entry->type == IT_WEAPON && (entry->look < 0 || entry->look >= MAX_SINGLE_WEAPON_TYPE)) { - ShowWarning("itemdb_validate_entry: Invalid View for weapon items. View value %d for item %d (%s) in '%s', defaulting to 1.\n", - entry->look, entry->nameid, entry->jname, source); - entry->look = 1; + if (entry->type == IT_WEAPON && (entry->subtype <= 0 || entry->subtype >= MAX_SINGLE_WEAPON_TYPE)) { + ShowWarning("itemdb_validate_entry: Invalid View for weapon items. View value %d for item %d (%s) in '%s', defaulting to W_DAGGER.\n", + entry->subtype, entry->nameid, entry->jname, source); + entry->subtype = W_DAGGER; + } else if (entry->type == IT_AMMO && (entry->subtype <= 0 || entry->subtype >= MAX_AMMO_TYPE)) { + ShowWarning("itemdb_validate_entry: Invalid View for ammunition items. View value %d for item %d (%s) in '%s', defaulting to A_ARROW.\n", + entry->subtype, entry->nameid, entry->jname, source); + entry->subtype = A_ARROW; } entry->wlv = cap_value(entry->wlv, REFINE_TYPE_ARMOR, REFINE_TYPE_MAX); @@ -1986,6 +1990,14 @@ int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const char * else if( !inherit ) id.type = IT_ETC; + if (itemdb->lookup_const(it, "Subtype", &i32) && i32 >= 0) { + if (id.type == IT_WEAPON || id.type == IT_AMMO) + id.subtype = i32; + else + ShowWarning("itemdb_readdb_libconfig_sub: Field 'Subtype' is only allowed for IT_WEAPON or IT_AMMO (Item #%d: %s). Ignoring.\n", + id.nameid, id.name); + } + if( itemdb->lookup_const(it, "Buy", &i32) ) id.value_buy = i32; else if( !inherit ) @@ -2058,8 +2070,23 @@ int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const char * if ((t = libconfig->setting_get_member(it, "DisableOptions"))) id.flag.no_options = libconfig->setting_get_bool(t) ? 1 : 0; - if( itemdb->lookup_const(it, "View", &i32) && i32 >= 0 ) - id.look = i32; + if (itemdb->lookup_const(it, "ViewSprite", &i32) && i32 >= 0) + id.view_sprite = i32; + + if (itemdb->lookup_const(it, "View", &i32) && i32 >= 0) { // TODO: Remove (Deprecated - 2016-09-04 [Haru]) + if ((id.type == IT_WEAPON || id.type == IT_AMMO) && id.subtype == 0) { + ShowWarning("itemdb_readdb_libconfig_sub: The 'View' field is deprecated. Please rename it to 'Subtype' (or 'ViewSprite'). (Item #%d: %s)\n", + id.nameid, id.name); + id.subtype = i32; + } else if ((id.type != IT_WEAPON && id.type != IT_AMMO) && id.view_sprite == 0) { + ShowWarning("itemdb_readdb_libconfig_sub: The 'View' field is deprecated. Please rename it to 'ViewSprite' (or 'Subtype'). (Item #%d: %s)\n", + id.nameid, id.name); + id.view_sprite = i32; + } else { + ShowWarning("itemdb_readdb_libconfig_sub: The 'View' field is deprecated. Please rename it to 'Subtype' or 'ViewSprite'. (Item #%d: %s)\n", + id.nameid, id.name); + } + } if( (t = libconfig->setting_get_member(it, "BindOnEquip")) ) id.flag.bindonequip = libconfig->setting_get_bool(t) ? 1 : 0; diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 0ab6ef65b..8a1799fbd 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -457,6 +457,7 @@ struct item_data { int value_buy; int value_sell; int type; + int subtype; int maxchance; //For logs, for external game info, for scripts: Max drop chance of this item (e.g. 0.01% , etc.. if it = 0, then monsters don't drop it, -1 denotes items sold in shops only) [Lupus] int sex; int equip; @@ -465,7 +466,7 @@ struct item_data { int def; int range; int slot; - int look; + int view_sprite; int elv; int wlv; int view_id; @@ -521,7 +522,8 @@ struct item_data { #define itemdb_type(n) (itemdb->search(n)->type) #define itemdb_atk(n) (itemdb->search(n)->atk) #define itemdb_def(n) (itemdb->search(n)->def) -#define itemdb_look(n) (itemdb->search(n)->look) +#define itemdb_subtype(n) (itemdb->search(n)->subtype) +#define itemdb_sprite(n) (itemdb->search(n)->view_sprite) #define itemdb_weight(n) (itemdb->search(n)->weight) #define itemdb_equip(n) (itemdb->search(n)->equip) #define itemdb_usescript(n) (itemdb->search(n)->script) diff --git a/src/map/pc.c b/src/map/pc.c index f332feea8..904867f76 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -765,9 +765,9 @@ int pc_equippoint(struct map_session_data *sd,int n) return 0; //Not equippable by players. ep = sd->inventory_data[n]->equip; - if (sd->inventory_data[n]->look == W_DAGGER - || sd->inventory_data[n]->look == W_1HSWORD - || sd->inventory_data[n]->look == W_1HAXE + if (sd->inventory_data[n]->subtype == W_DAGGER + || sd->inventory_data[n]->subtype == W_1HSWORD + || sd->inventory_data[n]->subtype == W_1HAXE ) { if (pc->checkskill(sd,AS_LEFT) > 0 || (sd->job & MAPID_UPPERMASK) == MAPID_ASSASSIN @@ -794,9 +794,9 @@ int pc_item_equippoint(struct map_session_data *sd, struct item_data* id) return 0; //Not equippable by players. ep = id->equip; - if (id->look == W_DAGGER || - id->look == W_1HSWORD || - id->look == W_1HAXE) { + if (id->subtype == W_DAGGER || + id->subtype == W_1HSWORD || + id->subtype == W_1HAXE) { if (pc->checkskill(sd, AS_LEFT) > 0 || (sd->job & MAPID_UPPERMASK) == MAPID_ASSASSIN || (sd->job & MAPID_UPPERMASK) == MAPID_KAGEROUOBORO) { @@ -837,7 +837,7 @@ int pc_calcweapontype(struct map_session_data *sd) return 1; } // dual-wield - sd->status.weapon = 0; + sd->status.weapon = W_FIST; switch (sd->weapontype1){ case W_DAGGER: switch (sd->weapontype2) { @@ -861,7 +861,7 @@ int pc_calcweapontype(struct map_session_data *sd) } } // unknown, default to right hand type - if (!sd->status.weapon) + if (sd->status.weapon == W_FIST) sd->status.weapon = sd->weapontype1; return 2; @@ -884,20 +884,18 @@ int pc_setequipindex(struct map_session_data *sd) if(sd->status.inventory[i].equip & pc->equip_pos[j]) sd->equip_index[j] = i; - if(sd->status.inventory[i].equip & EQP_HAND_R) - { - if(sd->inventory_data[i]) - sd->weapontype1 = sd->inventory_data[i]->look; + if (sd->status.inventory[i].equip & EQP_HAND_R) { + if (sd->inventory_data[i]) + sd->weapontype1 = sd->inventory_data[i]->subtype; else - sd->weapontype1 = 0; + sd->weapontype1 = W_FIST; } - if( sd->status.inventory[i].equip & EQP_HAND_L ) - { - if( sd->inventory_data[i] && sd->inventory_data[i]->type == IT_WEAPON ) - sd->weapontype2 = sd->inventory_data[i]->look; + if (sd->status.inventory[i].equip & EQP_HAND_L) { + if (sd->inventory_data[i] != NULL && sd->inventory_data[i]->type == IT_WEAPON) + sd->weapontype2 = sd->inventory_data[i]->subtype; else - sd->weapontype2 = 0; + sd->weapontype2 = W_FIST; } } } @@ -1088,13 +1086,13 @@ int pc_isequip(struct map_session_data *sd,int n) return 1; //Can equip all helms if (sd->status.base_level > 96 && item->equip & EQP_ARMS && item->type == IT_WEAPON) - switch(item->look) { //In weapons, the look determines type of weapon. - case W_DAGGER: //Level 4 Knives are equippable.. this means all knives, I'd guess? - case W_1HSWORD: //All 1H swords - case W_1HAXE: //All 1H Axes - case W_MACE: //All 1H Maces - case W_STAFF: //All 1H Staves - return 1; + switch (item->subtype) { //In weapons, the look determines type of weapon. + case W_DAGGER: //Level 4 Knives are equippable.. this means all knives, I'd guess? + case W_1HSWORD: //All 1H swords + case W_1HAXE: //All 1H Axes + case W_MACE: //All 1H Maces + case W_STAFF: //All 1H Staves + return 1; } } } @@ -5942,7 +5940,7 @@ int pc_checkallowskill(struct map_session_data *sd) status_change_end(&sd->bl, scw_list[i], INVALID_TIMER); } - if(sd->sc.data[SC_STRUP] && sd->status.weapon) + if(sd->sc.data[SC_STRUP] && sd->status.weapon != W_FIST) // Spurt requires bare hands (feet, in fact xD) status_change_end(&sd->bl, SC_STRUP, INVALID_TIMER); @@ -9757,25 +9755,27 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, nullpo_retv(sd); if ((!map_no_view(sd->bl.m,EQP_SHADOW_WEAPON) && pos & EQP_SHADOW_WEAPON) || (pos & EQP_HAND_R)) { - if(id) - sd->weapontype1 = id->look; + if (id != NULL) + sd->weapontype1 = id->subtype; else - sd->weapontype1 = 0; + sd->weapontype1 = W_FIST; pc->calcweapontype(sd); clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); } if ((!map_no_view(sd->bl.m,EQP_SHADOW_SHIELD) && pos & EQP_SHADOW_SHIELD) || (pos & EQP_HAND_L)) { - if (id) { - if(id->type == IT_WEAPON) { + if (id != NULL) { + if (id->type == IT_WEAPON) { sd->status.shield = 0; - sd->weapontype2 = id->look; - } else if(id->type == IT_ARMOR) { - sd->status.shield = id->look; - sd->weapontype2 = 0; + sd->weapontype2 = id->subtype; + } else if (id->type == IT_ARMOR) { + sd->status.shield = id->view_sprite; + sd->weapontype2 = W_FIST; } - } else - sd->status.shield = sd->weapontype2 = 0; + } else { + sd->status.shield = 0; + sd->weapontype2 = W_FIST; + } pc->calcweapontype(sd); clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); } @@ -9783,42 +9783,42 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, //causes client to redraw item on top of itself. (suggested by Lupus) if (!map_no_view(sd->bl.m,EQP_HEAD_LOW) && pos & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) { if (id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))) - sd->status.head_bottom = id->look; + sd->status.head_bottom = id->view_sprite; else sd->status.head_bottom = 0; clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); } if (!map_no_view(sd->bl.m,EQP_HEAD_TOP) && pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) { if (id) - sd->status.head_top = id->look; + sd->status.head_top = id->view_sprite; else sd->status.head_top = 0; clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); } if (!map_no_view(sd->bl.m,EQP_HEAD_MID) && pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) { if (id && !(pos&EQP_HEAD_TOP)) - sd->status.head_mid = id->look; + sd->status.head_mid = id->view_sprite; else sd->status.head_mid = 0; clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); } if (!map_no_view(sd->bl.m,EQP_COSTUME_HEAD_TOP) && pos & EQP_COSTUME_HEAD_TOP) { if (id){ - sd->status.head_top = id->look; + sd->status.head_top = id->view_sprite; } else sd->status.head_top = 0; clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); } if (!map_no_view(sd->bl.m,EQP_COSTUME_HEAD_MID) && pos & EQP_COSTUME_HEAD_MID) { if(id && !(pos&EQP_HEAD_TOP)){ - sd->status.head_mid = id->look; + sd->status.head_mid = id->view_sprite; } else sd->status.head_mid = 0; clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); } if (!map_no_view(sd->bl.m,EQP_COSTUME_HEAD_LOW) && pos & EQP_COSTUME_HEAD_LOW) { if (id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))){ - sd->status.head_bottom = id->look; + sd->status.head_bottom = id->view_sprite; } else sd->status.head_bottom = 0; clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); @@ -9827,12 +9827,12 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, if (!map_no_view(sd->bl.m,EQP_SHOES) && pos & EQP_SHOES) clif->changelook(&sd->bl,LOOK_SHOES,0); if (!map_no_view(sd->bl.m,EQP_GARMENT) && pos&EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1) { - sd->status.robe = id ? id->look : 0; + sd->status.robe = id ? id->view_sprite : 0; clif->changelook(&sd->bl, LOOK_ROBE, sd->status.robe); } if (!map_no_view(sd->bl.m,EQP_COSTUME_GARMENT) && pos & EQP_COSTUME_GARMENT) { - sd->status.robe = id ? id->look : 0; + sd->status.robe = id ? id->view_sprite : 0; clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); } } @@ -9987,7 +9987,7 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) { nullpo_retv(sd); if (pos & EQP_HAND_R) { - sd->weapontype1 = 0; + sd->weapontype1 = W_FIST; sd->status.weapon = sd->weapontype2; pc->calcweapontype(sd); clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); @@ -9995,7 +9995,8 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) status_change_end(&sd->bl, SC_DANCING, INVALID_TIMER); // Unequipping => stop dancing. } if (pos & EQP_HAND_L) { - sd->status.shield = sd->weapontype2 = 0; + sd->status.shield = 0; + sd->weapontype2 = W_FIST; pc->calcweapontype(sd); clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); } @@ -10013,17 +10014,17 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) } if (pos & EQP_COSTUME_HEAD_TOP) { - sd->status.head_top = ( pc->checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_TOP)]->look : 0; + sd->status.head_top = ( pc->checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_TOP)]->view_sprite : 0; clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); } if (pos & EQP_COSTUME_HEAD_MID) { - sd->status.head_mid = ( pc->checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_MID)]->look : 0; + sd->status.head_mid = ( pc->checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_MID)]->view_sprite : 0; clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); } if (pos & EQP_COSTUME_HEAD_LOW) { - sd->status.head_bottom = ( pc->checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_LOW)]->look : 0; + sd->status.head_bottom = ( pc->checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_LOW)]->view_sprite : 0; clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); } @@ -10036,7 +10037,7 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) } if (pos & EQP_COSTUME_GARMENT) { - sd->status.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->look : 0; + sd->status.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->view_sprite : 0; clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); } } @@ -10091,7 +10092,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) clif->unequipitemack(sd, n, pos, UIA_SUCCESS); if ((pos & EQP_ARMS) && - sd->weapontype1 == 0 && sd->weapontype2 == 0 && (sd->sc.data[SC_TK_SEVENWIND] == 0 || sd->sc.data[SC_ASPERSIO])) //Check for seven wind (but not level seven!) + sd->weapontype1 == W_FIST && sd->weapontype2 == W_FIST && (sd->sc.data[SC_TK_SEVENWIND] == NULL || sd->sc.data[SC_ASPERSIO] != NULL)) //Check for seven wind (but not level seven!) skill->enchant_elemental_end(&sd->bl, -1); if (pos & EQP_ARMOR) { diff --git a/src/map/script.c b/src/map/script.c index 914bee75c..a919467cf 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -14034,7 +14034,7 @@ BUILDIN(getiteminfo) script_pushint(st, it->slot); break; case 11: - script_pushint(st, it->look); + script_pushint(st, it->subtype); break; case 12: script_pushint(st, it->elv); @@ -14287,7 +14287,7 @@ BUILDIN(setiteminfo) it->slot = value; break; case 11: - it->look = value; + it->subtype = value; break; case 12: it->elv = value; diff --git a/src/map/skill.c b/src/map/skill.c index e187b7e8b..1f510e6fe 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -14555,7 +14555,7 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id, clif->messagecolor_self(sd->fd, COLOR_RED, e_msg); return 0; } - if (!(require.ammo&1<inventory_data[i]->look)) { //Ammo type check. Send the "wrong weapon type" message + if (!(require.ammo&1<inventory_data[i]->subtype)) { //Ammo type check. Send the "wrong weapon type" message //which is the closest we have to wrong ammo type. [Skotlex] clif->arrow_fail(sd,0); //Haplo suggested we just send the equip-arrows message instead. [Skotlex] //clif->skill_fail(sd,skill_id,USESKILL_FAIL_THIS_WEAPON,0); diff --git a/src/map/status.c b/src/map/status.c index c98857736..0d2171eac 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -10747,7 +10747,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const } if (begin_spurt && sce->val1 >= 7 && DIFF_TICK(timer->gettick(), starttick) <= 1000 - && (!sd || (sd->weapontype1 == 0 && sd->weapontype2 == 0)) + && (!sd || (sd->weapontype1 == W_FIST && sd->weapontype2 == W_FIST)) ) sc_start(bl, bl,SC_STRUP,100,sce->val1,skill->get_time2(status->sc2skill(type), sce->val1)); } diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index 33a62757a..cb8660df9 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -255,6 +255,9 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) // type StrBuf->Printf(&buf, "'%d',", it->flag.delay_consume ? IT_DELAYCONSUME : it->type); + // subtype + StrBuf->Printf(&buf, "'%d',", it->subtype); + // price_buy StrBuf->Printf(&buf, "'%d',", it->value_buy); @@ -324,8 +327,8 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) // disable_options StrBuf->Printf(&buf, "'%d',", it->flag.no_options?1:0); - // view - StrBuf->Printf(&buf, "'%d',", it->look); + // view_sprite + StrBuf->Printf(&buf, "'%d',", it->view_sprite); // bindonequip StrBuf->Printf(&buf, "'%d',", it->flag.bindonequip?1:0); @@ -449,6 +452,7 @@ void itemdb2sql_tableheader(void) " `name_english` varchar(50) NOT NULL DEFAULT '',\n" " `name_japanese` varchar(50) NOT NULL DEFAULT '',\n" " `type` tinyint(2) UNSIGNED NOT NULL DEFAULT '0',\n" + " `subtype` tinyint(2) UNSIGNED DEFAULT NULL,\n" " `price_buy` mediumint(10) DEFAULT NULL,\n" " `price_sell` mediumint(10) DEFAULT NULL,\n" " `weight` smallint(5) UNSIGNED DEFAULT NULL,\n" @@ -466,7 +470,7 @@ void itemdb2sql_tableheader(void) " `equip_level_max` smallint(5) UNSIGNED DEFAULT NULL,\n" " `refineable` tinyint(1) UNSIGNED DEFAULT NULL,\n" " `disable_options` tinyint(1) UNSIGNED DEFAULT NULL,\n" - " `view` smallint(3) UNSIGNED DEFAULT NULL,\n" + " `view_sprite` smallint(3) UNSIGNED DEFAULT NULL,\n" " `bindonequip` tinyint(1) UNSIGNED DEFAULT NULL,\n" " `forceserial` tinyint(1) UNSIGNED DEFAULT NULL,\n" " `buyingstore` tinyint(1) UNSIGNED DEFAULT NULL,\n" -- cgit v1.2.3-70-g09d2 From a681d759cc887e8adccbd30d3b7a7ca355bbda96 Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 3 Dec 2016 03:41:08 +0100 Subject: Differentiate variables that hold a ViewSprite and a weapon Subtype `sd->status.weapon` is renamed to `sd->status.look.weapon` and only holds ViewSprite IDs. Its previous other meaning is now transferred to `sd->weapontype` (holding the currently equipped weapon type, considering both hands at once) Signed-off-by: Haru --- src/char/char.c | 10 +++++----- src/common/mmo.h | 4 +++- src/map/battle.c | 36 +++++++++++++++++------------------ src/map/clif.c | 4 ++-- src/map/pc.c | 58 +++++++++++++++++++++++++++++++------------------------- src/map/pc.h | 13 ++++++++++--- src/map/script.c | 2 +- src/map/skill.c | 10 +++++----- src/map/status.c | 39 ++++++++++++++++++------------------- 9 files changed, 94 insertions(+), 82 deletions(-) (limited to 'src') diff --git a/src/char/char.c b/src/char/char.c index 4687d4d6b..09aa8684b 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -460,7 +460,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) (p->int_ != cp->int_) || (p->dex != cp->dex) || (p->luk != cp->luk) || (p->option != cp->option) || (p->party_id != cp->party_id) || (p->guild_id != cp->guild_id) || - (p->pet_id != cp->pet_id) || (p->weapon != cp->weapon) || (p->hom_id != cp->hom_id) || + (p->pet_id != cp->pet_id) || (p->look.weapon != cp->look.weapon) || (p->hom_id != cp->hom_id) || (p->ele_id != cp->ele_id) || (p->shield != cp->shield) || (p->head_top != cp->head_top) || (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) || (p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->robe != cp->robe) || @@ -490,7 +490,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id, p->ele_id, - p->weapon, p->shield, p->head_top, p->head_mid, p->head_bottom, + p->look.weapon, p->shield, p->head_top, p->head_mid, p->head_bottom, mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y, mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename, (unsigned long)p->delete_date, // FIXME: platform-dependent size @@ -1094,7 +1094,7 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) || SQL_ERROR == SQL->StmtBindColumn(stmt, 25, SQLDT_SHORT, &p.hair_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_SHORT, &p.body, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.weapon, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.look.weapon, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.shield, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_top, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL) @@ -1208,7 +1208,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p->hair_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_SHORT, &p->body, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->weapon, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->look.weapon, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->shield, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->head_top, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL) @@ -1942,7 +1942,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { //When the weapon is sent and your option is riding, the client crashes on login!? // FIXME[Haru]: is OPTION_HANBOK intended to be part of this list? And if it is, should the list also include other OPTION_ costumes? - WBUFW(buf,56) = (p->option&(OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_HANBOK)) ? 0 : p->weapon; + WBUFW(buf,56) = (p->option&(OPTION_RIDING|OPTION_DRAGON|OPTION_WUG|OPTION_WUGRIDER|OPTION_MADOGEAR|OPTION_HANBOK)) ? 0 : p->look.weapon; WBUFW(buf,58) = p->base_level; WBUFW(buf,60) = min(p->skill_point, INT16_MAX); diff --git a/src/common/mmo.h b/src/common/mmo.h index 7670a7ac8..1ade0caa9 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -612,7 +612,9 @@ struct mmo_charstatus { int spear_faith, spear_calls; int sword_faith, sword_calls; - short weapon; // enum weapon_type + struct { + short weapon; ///< Weapon view sprite id. + } look; short shield; // view-id short head_top,head_mid,head_bottom; short robe; diff --git a/src/map/battle.c b/src/map/battle.c index 9d67242a2..2861599b8 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -875,7 +875,7 @@ int64 battle_calc_masteryfix(struct block_list *src, struct block_list *target, } #else if( skill_id != ASC_BREAKER && weapon ) // Adv Katar Mastery is does not applies to ASC_BREAKER, but other masteries DO apply >_> - if( sd->status.weapon == W_KATAR && (skill2_lv=pc->checkskill(sd,ASC_KATAR)) > 0 ) + if (sd->weapontype == W_KATAR && (skill2_lv=pc->checkskill(sd,ASC_KATAR)) > 0) damage += damage * (10 + 2 * skill2_lv) / 100; #endif @@ -2032,7 +2032,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block skillratio += 100 + 100 * skill_lv + 100 * (skill_lv / 2); break; case RG_BACKSTAP: - if( sd && sd->status.weapon == W_BOW && battle_config.backstab_bow_penalty ) + if (sd != NULL && sd->weapontype == W_BOW && battle_config.backstab_bow_penalty) skillratio += (200 + 40 * skill_lv) / 2; else skillratio += 200 + 40 * skill_lv; @@ -2053,10 +2053,10 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block case CR_HOLYCROSS: { int ratio = 35 * skill_lv; - #ifdef RENEWAL - if(sd && sd->status.weapon == W_2HSPEAR) - ratio *= 2; - #endif +#ifdef RENEWAL + if (sd != NULL && sd->weapontype == W_2HSPEAR) + ratio *= 2; +#endif skillratio += ratio; break; } @@ -2714,7 +2714,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block skillratio += 2*sc->data[SC_TRUESIGHT]->val1; if( sc->data[SC_LKCONCENTRATION] ) skillratio += sc->data[SC_LKCONCENTRATION]->val2; - if( sd && sd->status.weapon == W_KATAR && (i=pc->checkskill(sd,ASC_KATAR)) > 0 ) + if (sd != NULL && sd->weapontype == W_KATAR && (i=pc->checkskill(sd,ASC_KATAR)) > 0) skillratio += skillratio * (10 + 2 * i) / 100; #endif if( (!skill_id || skill_id == KN_AUTOCOUNTER) && sc->data[SC_CRUSHSTRIKE] ){ @@ -3023,7 +3023,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam status_change_end(bl,SC_DEEP_SLEEP,INVALID_TIMER); } if( s_sd && t_sd && sc->data[SC_COLD] && flag&BF_WEAPON ){ - switch(s_sd->status.weapon){ + switch (s_sd->weapontype) { case W_MACE: case W_2HMACE: case W_1HAXE: @@ -3165,7 +3165,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( (sce = sc->data[SC_STONEHARDSKIN]) && flag&(BF_SHORT|BF_WEAPON) && damage > 0 ) { sce->val2 -= (int)cap_value(damage,INT_MIN,INT_MAX); if( src->type == BL_PC ) { - if (s_sd && s_sd->status.weapon != W_BOW) + if (s_sd != NULL && s_sd->weapontype != W_BOW) skill->break_equip(src, EQP_WEAPON, 3000, BCT_SELF); } else skill->break_equip(src, EQP_WEAPON, 3000, BCT_SELF); @@ -4648,7 +4648,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list short cri = sstatus->cri; if (sd != NULL) { // if show_katar_crit_bonus is enabled, it already done the calculation in status.c - if (!battle_config.show_katar_crit_bonus && sd->status.weapon == W_KATAR) { + if (!battle_config.show_katar_crit_bonus && sd->weapontype == W_KATAR) { cri <<= 1; } @@ -4821,8 +4821,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if ((temp = pc->checkskill(sd,BS_WEAPONRESEARCH)) > 0) hitrate += hitrate * ( 2 * temp ) / 100; - if( (sd->status.weapon == W_1HSWORD || sd->status.weapon == W_DAGGER) && - (temp = pc->checkskill(sd, GN_TRAINING_SWORD))>0 ) + if ((sd->weapontype == W_1HSWORD || sd->weapontype == W_DAGGER) && (temp = pc->checkskill(sd, GN_TRAINING_SWORD)) > 0) hitrate += 3 * temp; } @@ -4956,7 +4955,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list (!skill_id && sc && sc->data[SC_HLIF_CHANGE]?4:0)| (sc && sc->data[SC_WEAPONPERFECT]?8:0); if (flag.arrow && sd) - switch(sd->status.weapon) { + switch (sd->weapontype) { case W_BOW: case W_REVOLVER: case W_GATLING: @@ -5582,7 +5581,8 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list if(wd.damage < 1) wd.damage = 1; if(wd.damage2 < 1) wd.damage2 = 1; #endif - } else if(sd->status.weapon == W_KATAR && !skill_id) { //Katars (offhand damage only applies to normal attacks, tested on Aegis 10.2) + } else if (sd->weapontype == W_KATAR && skill_id == 0) { + // Katars (offhand damage only applies to normal attacks, tested on Aegis 10.2) temp = pc->checkskill(sd,TF_DOUBLE); wd.damage2 = wd.damage * (1 + (temp * 2))/100; @@ -5701,7 +5701,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } //Reject Sword bugreport:4493 by Daegaladh if (wd.damage != 0 && tsc != NULL && tsc->data[SC_SWORDREJECT] != NULL - && (sd == NULL || sd->weapontype1 == W_DAGGER || sd->weapontype1 == W_1HSWORD || sd->status.weapon == W_2HSWORD) + && (sd == NULL || sd->weapontype1 == W_DAGGER || sd->weapontype1 == W_1HSWORD || sd->weapontype == W_2HSWORD) && rnd()%100 < tsc->data[SC_SWORDREJECT]->val2 ) { ATK_RATER(50); @@ -6099,7 +6099,7 @@ bool battle_check_arrows(struct map_session_data *sd) } //Ammo check by Ishizu-chan if (sd->inventory_data[index]) { - switch (sd->status.weapon) { + switch (sd->weapontype) { case W_BOW: if (sd->inventory_data[index]->subtype != A_ARROW) { clif->arrow_fail(sd, 0); @@ -6160,7 +6160,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t if (sd) { - sd->state.arrow_atk = (sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)); + sd->state.arrow_atk = (sd->weapontype == W_BOW || (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE)); if (sd->state.arrow_atk) { if (battle->check_arrows(sd) == false) @@ -6186,7 +6186,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t return ATK_BLOCK; } } - if( tsc && tsc->data[SC_BLADESTOP_WAIT] && !is_boss(src) && (src->type == BL_PC || tsd == NULL || distance_bl(src, target) <= (tsd->status.weapon == W_FIST ? 1 : 2)) ) + if( tsc && tsc->data[SC_BLADESTOP_WAIT] && !is_boss(src) && (src->type == BL_PC || tsd == NULL || distance_bl(src, target) <= (tsd->weapontype == W_FIST ? 1 : 2)) ) { uint16 skill_lv = tsc->data[SC_BLADESTOP_WAIT]->val1; int duration = skill->get_time2(MO_BLADESTOP,skill_lv); diff --git a/src/map/clif.c b/src/map/clif.c index 3599640b9..2962aaa8b 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -888,7 +888,7 @@ void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, un } #if PACKETVER < 4 - *rhand = sd->status.weapon; + *rhand = sd->status.look.weapon; *lhand = sd->status.shield; #else if (sd->equip_index[EQI_HAND_R] >= 0 && @@ -9449,7 +9449,7 @@ void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) { // Character Looks #if PACKETVER < 4 - clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); + clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon); clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); #else clif->changelook(&sd->bl,LOOK_WEAPON,0); diff --git a/src/map/pc.c b/src/map/pc.c index 904867f76..c30161a0c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -829,40 +829,40 @@ int pc_calcweapontype(struct map_session_data *sd) // single-hand if(sd->weapontype2 == W_FIST) { - sd->status.weapon = sd->weapontype1; + sd->weapontype = sd->weapontype1; return 1; } if(sd->weapontype1 == W_FIST) { - sd->status.weapon = sd->weapontype2; + sd->weapontype = sd->weapontype2; return 1; } // dual-wield - sd->status.weapon = W_FIST; + sd->weapontype = W_FIST; switch (sd->weapontype1){ case W_DAGGER: switch (sd->weapontype2) { - case W_DAGGER: sd->status.weapon = W_DOUBLE_DD; break; - case W_1HSWORD: sd->status.weapon = W_DOUBLE_DS; break; - case W_1HAXE: sd->status.weapon = W_DOUBLE_DA; break; + case W_DAGGER: sd->weapontype = W_DOUBLE_DD; break; + case W_1HSWORD: sd->weapontype = W_DOUBLE_DS; break; + case W_1HAXE: sd->weapontype = W_DOUBLE_DA; break; } break; case W_1HSWORD: switch (sd->weapontype2) { - case W_DAGGER: sd->status.weapon = W_DOUBLE_DS; break; - case W_1HSWORD: sd->status.weapon = W_DOUBLE_SS; break; - case W_1HAXE: sd->status.weapon = W_DOUBLE_SA; break; + case W_DAGGER: sd->weapontype = W_DOUBLE_DS; break; + case W_1HSWORD: sd->weapontype = W_DOUBLE_SS; break; + case W_1HAXE: sd->weapontype = W_DOUBLE_SA; break; } break; case W_1HAXE: switch (sd->weapontype2) { - case W_DAGGER: sd->status.weapon = W_DOUBLE_DA; break; - case W_1HSWORD: sd->status.weapon = W_DOUBLE_SA; break; - case W_1HAXE: sd->status.weapon = W_DOUBLE_AA; break; + case W_DAGGER: sd->weapontype = W_DOUBLE_DA; break; + case W_1HSWORD: sd->weapontype = W_DOUBLE_SA; break; + case W_1HAXE: sd->weapontype = W_DOUBLE_AA; break; } } // unknown, default to right hand type - if (sd->status.weapon == W_FIST) - sd->status.weapon = sd->weapontype1; + if (sd->weapontype == W_FIST) + sd->weapontype = sd->weapontype1; return 2; } @@ -885,10 +885,13 @@ int pc_setequipindex(struct map_session_data *sd) sd->equip_index[j] = i; if (sd->status.inventory[i].equip & EQP_HAND_R) { - if (sd->inventory_data[i]) + if (sd->inventory_data[i]) { sd->weapontype1 = sd->inventory_data[i]->subtype; - else + sd->status.look.weapon = sd->inventory_data[i]->view_sprite; + } else { sd->weapontype1 = W_FIST; + sd->status.look.weapon = 0; + } } if (sd->status.inventory[i].equip & EQP_HAND_L) { @@ -2486,7 +2489,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) { } switch (sd->state.lr_flag) { case 2: - switch (sd->status.weapon) { + switch (sd->weapontype) { case W_BOW: case W_REVOLVER: case W_RIFLE: @@ -2553,7 +2556,7 @@ int pc_bonus(struct map_session_data *sd,int type,int val) { case SP_ATTACKRANGE: switch (sd->state.lr_flag) { case 2: - switch (sd->status.weapon) { + switch (sd->weapontype) { case W_BOW: case W_REVOLVER: case W_RIFLE: @@ -5940,7 +5943,7 @@ int pc_checkallowskill(struct map_session_data *sd) status_change_end(&sd->bl, scw_list[i], INVALID_TIMER); } - if(sd->sc.data[SC_STRUP] && sd->status.weapon != W_FIST) + if(sd->sc.data[SC_STRUP] && sd->weapontype != W_FIST) // Spurt requires bare hands (feet, in fact xD) status_change_end(&sd->bl, SC_STRUP, INVALID_TIMER); @@ -8842,7 +8845,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) case LOOK_BASE: status->set_viewdata(&sd->bl, val); clif->changelook(&sd->bl, LOOK_BASE, sd->vd.class); - clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); + clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon); if (sd->vd.cloth_color) clif->changelook(&sd->bl,LOOK_CLOTHES_COLOR,sd->vd.cloth_color); if (sd->vd.body_style) @@ -8861,7 +8864,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) } break; case LOOK_WEAPON: - sd->status.weapon=val; + sd->status.look.weapon = val; break; case LOOK_HEAD_BOTTOM: sd->status.head_bottom=val; @@ -9755,12 +9758,15 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, nullpo_retv(sd); if ((!map_no_view(sd->bl.m,EQP_SHADOW_WEAPON) && pos & EQP_SHADOW_WEAPON) || (pos & EQP_HAND_R)) { - if (id != NULL) + if (id != NULL) { sd->weapontype1 = id->subtype; - else + sd->status.look.weapon = id->view_sprite; + } else { sd->weapontype1 = W_FIST; + sd->status.look.weapon = 0; + } pc->calcweapontype(sd); - clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); + clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon); } if ((!map_no_view(sd->bl.m,EQP_SHADOW_SHIELD) && pos & EQP_SHADOW_SHIELD) || (pos & EQP_HAND_L)) { @@ -9988,9 +9994,9 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) nullpo_retv(sd); if (pos & EQP_HAND_R) { sd->weapontype1 = W_FIST; - sd->status.weapon = sd->weapontype2; pc->calcweapontype(sd); - clif->changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon); + sd->status.look.weapon = 0; + clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon); if (!battle_config.dancing_weaponswitch_fix) status_change_end(&sd->bl, SC_DANCING, INVALID_TIMER); // Unequipping => stop dancing. } diff --git a/src/map/pc.h b/src/map/pc.h index c94ec6099..62129b5ae 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -308,7 +308,9 @@ struct map_session_data { short nameid; int64 tick; } item_delay[MAX_ITEMDELAYS]; // [Paradox924X] - short weapontype1,weapontype2; + int16 weapontype; ///< Weapon type considering both hands (@see enum weapon_type). + int16 weapontype1; ///< Weapon type in the right/primary hand (@see enum weapon_type). + int16 weapontype2; ///< Weapon type in the left/secondary hand (@see enum weapon_type). short disguise; // [Valaris] struct weapon_data right_weapon, left_weapon; @@ -685,8 +687,13 @@ END_ZEROED_BLOCK; #define pc_stop_attack(sd) (unit->stop_attack(&(sd)->bl)) //Weapon check considering dual wielding. -#define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_SINGLE_WEAPON_TYPE? \ - 1<<(sd)->status.weapon:(1<<(sd)->weapontype1)|(1<<(sd)->weapontype2)|(1<<(sd)->status.weapon))) +#define pc_check_weapontype(sd, type) ( \ + (type) & ( \ + (sd)->weapontype < MAX_SINGLE_WEAPON_TYPE ? \ + 1 << (sd)->weapontype : \ + (1 << (sd)->weapontype1) | (1 << (sd)->weapontype2) \ + ) \ + ) // clientside display macros (values to the left/right of the "+") #ifdef RENEWAL diff --git a/src/map/script.c b/src/map/script.c index a919467cf..58dd65173 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -15519,7 +15519,7 @@ BUILDIN(getlook) type=script_getnum(st,2); switch(type) { case LOOK_HAIR: val = sd->status.hair; break; //1 - case LOOK_WEAPON: val = sd->status.weapon; break; //2 + case LOOK_WEAPON: val = sd->status.look.weapon; break; //2 case LOOK_HEAD_BOTTOM: val = sd->status.head_bottom; break; //3 case LOOK_HEAD_TOP: val = sd->status.head_top; break; //4 case LOOK_HEAD_MID: val = sd->status.head_mid; break; //5 diff --git a/src/map/skill.c b/src/map/skill.c index 1f510e6fe..4649ace42 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -806,7 +806,7 @@ int skill_additional_effect(struct block_list* src, struct block_list *bl, uint1 break; // If a normal attack is a skill, it's splash damage. [Inkfish] if(sd) { // Automatic trigger of Blitz Beat - if (pc_isfalcon(sd) && sd->status.weapon == W_BOW && (temp=pc->checkskill(sd,HT_BLITZBEAT))>0 && + if (pc_isfalcon(sd) && sd->weapontype == W_BOW && (temp=pc->checkskill(sd,HT_BLITZBEAT))>0 && rnd()%1000 <= sstatus->luk*3 ) { rate = sd->status.job_level / 10 + 1; skill->castend_damage_id(src,bl,HT_BLITZBEAT,(tempcheckskill(sd,RA_WUGSTRIKE)) > 0 && rnd()%1000 <= sstatus->luk*3 ) skill->castend_damage_id(src,bl,RA_WUGSTRIKE,temp,tick,0); // Gank - if(dstmd && sd->status.weapon != W_BOW && + if(dstmd && sd->weapontype != W_BOW && (temp=pc->checkskill(sd,RG_SNATCHER)) > 0 && (temp*15 + 55) + pc->checkskill(sd,TF_STEAL)*10 > rnd()%1000) { if(pc->steal_item(sd,bl,pc->checkskill(sd,TF_STEAL))) @@ -2012,7 +2012,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in if (sd->bonus.unbreakable) rate -= rate*sd->bonus.unbreakable/100; if (where&EQP_WEAPON) { - switch (sd->status.weapon) { + switch (sd->weapontype) { case W_FIST: //Bare fists should not break :P case W_1HAXE: case W_2HAXE: @@ -5917,7 +5917,7 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin case SA_LIGHTNINGLOADER: case SA_SEISMICWEAPON: if (dstsd) { - if(dstsd->status.weapon == W_FIST || + if (dstsd->weapontype == W_FIST || (dstsd->sc.count && !dstsd->sc.data[type] && ( //Allow re-enchanting to lengthen time. [Skotlex] dstsd->sc.data[SC_PROPERTYFIRE] || @@ -13391,7 +13391,7 @@ int skill_isammotype (struct map_session_data *sd, int skill_id) nullpo_ret(sd); return ( battle_config.arrow_decrement==2 && - (sd->status.weapon == W_BOW || (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) && + (sd->weapontype == W_BOW || (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE)) && skill_id != HT_PHANTASMIC && skill->get_type(skill_id) == BF_WEAPON && !(skill->get_nk(skill_id)&NK_NO_DAMAGE) && diff --git a/src/map/status.c b/src/map/status.c index 0d2171eac..ed29e85be 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -2713,9 +2713,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) sd->left_weapon.atkmods[1] = status->dbs->atkmods[1][sd->weapontype2]; sd->left_weapon.atkmods[2] = status->dbs->atkmods[2][sd->weapontype2]; - if ((pc_isridingpeco(sd) || pc_isridingdragon(sd)) - && (sd->status.weapon==W_1HSPEAR || sd->status.weapon==W_2HSPEAR) - ) { + if ((pc_isridingpeco(sd) || pc_isridingdragon(sd)) && (sd->weapontype == W_1HSPEAR || sd->weapontype == W_2HSPEAR)) { //When Riding with spear, damage modifier to mid-class becomes //same as versus large size. sd->right_weapon.atkmods[1] = sd->right_weapon.atkmods[2]; @@ -2779,8 +2777,8 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) // Base batk value is set on status->calc_misc // weapon-type bonus (FIXME: Why is the weapon_atk bonus applied to base attack?) - if (sd->status.weapon < MAX_SINGLE_WEAPON_TYPE && sd->weapon_atk[sd->status.weapon]) - bstatus->batk += sd->weapon_atk[sd->status.weapon]; + if (sd->weapontype < MAX_SINGLE_WEAPON_TYPE && sd->weapon_atk[sd->weapontype]) + bstatus->batk += sd->weapon_atk[sd->weapontype]; // Absolute modifiers from passive skills #ifndef RENEWAL if((skill_lv=pc->checkskill(sd,BS_HILTBINDING))>0) // it doesn't work in RE. @@ -2928,10 +2926,10 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) #ifndef RENEWAL bstatus->hit += skill_lv; #endif - if(sd->status.weapon == W_BOW) + if (sd->weapontype == W_BOW) bstatus->rhw.range += skill_lv; } - if(sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE) { + if (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE) { if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0) bstatus->hit += 2*skill_lv; if((skill_lv=pc->checkskill(sd,GS_SNAKEEYE))>0) { @@ -2939,9 +2937,9 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) bstatus->rhw.range += skill_lv; } } - if( (sd->status.weapon == W_1HAXE || sd->status.weapon == W_2HAXE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0 ) + if ((sd->weapontype == W_1HAXE || sd->weapontype == W_2HAXE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0) bstatus->hit += 3*skill_lv; - if((sd->status.weapon == W_MACE || sd->status.weapon == W_2HMACE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0) + if ((sd->weapontype == W_MACE || sd->weapontype == W_2HMACE) && (skill_lv = pc->checkskill(sd,NC_TRAININGAXE)) > 0) bstatus->hit += 2*skill_lv; if (pc->checkskill(sd, SU_POWEROFLIFE) > 0) bstatus->hit += 20; @@ -3001,12 +2999,11 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt) // Relative modifiers from passive skills #ifndef RENEWAL_ASPD - if((skill_lv=pc->checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK) + if (sd->weapontype == W_BOOK && (skill_lv=pc->checkskill(sd,SA_ADVANCEDBOOK)) > 0) bstatus->aspd_rate -= 5*skill_lv; if((skill_lv = pc->checkskill(sd,SG_DEVIL)) > 0 && !pc->nextjobexp(sd)) bstatus->aspd_rate -= 30*skill_lv; - if((skill_lv=pc->checkskill(sd,GS_SINGLEACTION))>0 && - (sd->status.weapon >= W_REVOLVER && sd->status.weapon <= W_GRENADE)) + if (sd->weapontype >= W_REVOLVER && sd->weapontype <= W_GRENADE && (skill_lv=pc->checkskill(sd,GS_SINGLEACTION)) > 0) bstatus->aspd_rate -= ((skill_lv+1)/2) * 10; if (pc_isridingpeco(sd)) bstatus->aspd_rate += 500-100*pc->checkskill(sd,KN_CAVALIERMASTERY); @@ -3896,7 +3893,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) } else { st->cri = status->calc_critical(bl, sc, bst->cri + 3*(st->luk - bst->luk), true); } - if (battle_config.show_katar_crit_bonus && bl->type == BL_PC && BL_UCAST(BL_PC, bl)->status.weapon == W_KATAR) { + if (battle_config.show_katar_crit_bonus && bl->type == BL_PC && BL_UCAST(BL_PC, bl)->weapontype == W_KATAR) { st->cri *= 2; } } @@ -4327,11 +4324,11 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) nullpo_ret(st); amotion = status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype1]; - if ( sd->status.weapon > MAX_SINGLE_WEAPON_TYPE) + if (sd->weapontype > MAX_SINGLE_WEAPON_TYPE) amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype2] / 4; if ( sd->status.shield ) amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class)][MAX_SINGLE_WEAPON_TYPE]; - switch ( sd->status.weapon ) { + switch (sd->weapontype) { case W_BOW: case W_MUSICAL: case W_WHIP: @@ -4346,15 +4343,15 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) temp = st->dex * st->dex / 5.0f + st->agi * st->agi * 0.5f; } temp = (float)(sqrt(temp) * 0.25f) + 0xc4; - if ( (skill_lv = pc->checkskill(sd, SA_ADVANCEDBOOK)) > 0 && sd->status.weapon == W_BOOK ) + if (sd->weapontype == W_BOOK && (skill_lv = pc->checkskill(sd, SA_ADVANCEDBOOK)) > 0) val += (skill_lv - 1) / 2 + 1; if ( (skill_lv = pc->checkskill(sd, GS_SINGLEACTION)) > 0 ) val += ((skill_lv + 1) / 2); amotion = ((int)(temp + ((float)(status->calc_aspd(&sd->bl, &sd->sc, 1) + val) * st->agi / 200)) - min(amotion, 200)); #else // base weapon delay - amotion = (sd->status.weapon < MAX_SINGLE_WEAPON_TYPE) - ? (status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->status.weapon]) // single weapon + amotion = (sd->weapontype < MAX_SINGLE_WEAPON_TYPE) + ? (status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype]) // single weapon : (status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype1] + status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype2]) * 7 / 10; // dual-wield // percentual delay reduction from stats @@ -4381,7 +4378,7 @@ unsigned short status_base_atk(const struct block_list *bl, const struct status_ return 0; if (bl->type == BL_PC) { - switch (BL_UCCAST(BL_PC, bl)->status.weapon) { + switch (BL_UCCAST(BL_PC, bl)->weapontype) { case W_BOW: case W_MUSICAL: case W_WHIP: @@ -5942,7 +5939,7 @@ short status_calc_aspd(struct block_list *bl, struct status_change *sc, short fl if (bl->type != BL_PC) { bonus = sc->data[SC_ASSNCROS]->val2; } else { - switch (BL_UCCAST(BL_PC, bl)->status.weapon) { + switch (BL_UCCAST(BL_PC, bl)->weapontype) { case W_BOW: case W_REVOLVER: case W_RIFLE: @@ -6103,7 +6100,7 @@ short status_calc_aspd_rate(struct block_list *bl, struct status_change *sc, int if (bl->type != BL_PC) { max = sc->data[SC_ASSNCROS]->val2; } else { - switch (BL_UCCAST(BL_PC, bl)->status.weapon) { + switch (BL_UCCAST(BL_PC, bl)->weapontype) { case W_BOW: case W_REVOLVER: case W_RIFLE: -- cgit v1.2.3-70-g09d2 From 20caa41aeae6e49375aeb187c06dc077e330b414 Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 3 Dec 2016 06:19:35 +0100 Subject: Differentiate variables that hold a ViewSprite and a Subtype (part 2) `sd->status.shield` is renamed to `sd->status.look.shield` and only holds ViewSprite IDs. Its previous other meaning is now transferred to `sd->has_shield`, of boolean type (to detect the presence of a shield) Signed-off-by: Haru --- src/char/char.c | 10 +++++----- src/common/mmo.h | 2 +- src/map/clif.c | 4 ++-- src/map/pc.c | 35 ++++++++++++++++++++++++----------- src/map/pc.h | 1 + src/map/script.c | 2 +- src/map/skill.c | 2 +- src/map/status.c | 2 +- 8 files changed, 36 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/char/char.c b/src/char/char.c index 09aa8684b..c02ee33ef 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -461,7 +461,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) (p->option != cp->option) || (p->party_id != cp->party_id) || (p->guild_id != cp->guild_id) || (p->pet_id != cp->pet_id) || (p->look.weapon != cp->look.weapon) || (p->hom_id != cp->hom_id) || - (p->ele_id != cp->ele_id) || (p->shield != cp->shield) || (p->head_top != cp->head_top) || + (p->ele_id != cp->ele_id) || (p->look.shield != cp->look.shield) || (p->head_top != cp->head_top) || (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) || (p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->robe != cp->robe) || (p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font) || @@ -490,7 +490,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id, p->ele_id, - p->look.weapon, p->shield, p->head_top, p->head_mid, p->head_bottom, + p->look.weapon, p->look.shield, p->head_top, p->head_mid, p->head_bottom, mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y, mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename, (unsigned long)p->delete_date, // FIXME: platform-dependent size @@ -1095,7 +1095,7 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) || SQL_ERROR == SQL->StmtBindColumn(stmt, 26, SQLDT_SHORT, &p.clothes_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_SHORT, &p.body, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.look.weapon, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.shield, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.look.shield, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_top, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL) @@ -1209,7 +1209,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p->clothes_color, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_SHORT, &p->body, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->look.weapon, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->shield, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->look.shield, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->head_top, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL) @@ -1947,7 +1947,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { WBUFW(buf,58) = p->base_level; WBUFW(buf,60) = min(p->skill_point, INT16_MAX); WBUFW(buf,62) = p->head_bottom; - WBUFW(buf,64) = p->shield; + WBUFW(buf,64) = p->look.shield; WBUFW(buf,66) = p->head_top; WBUFW(buf,68) = p->head_mid; WBUFW(buf,70) = p->hair_color; diff --git a/src/common/mmo.h b/src/common/mmo.h index 1ade0caa9..4b120e812 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -614,8 +614,8 @@ struct mmo_charstatus { struct { short weapon; ///< Weapon view sprite id. + short shield; ///< Shield view sprite id. } look; - short shield; // view-id short head_top,head_mid,head_bottom; short robe; diff --git a/src/map/clif.c b/src/map/clif.c index 2962aaa8b..77e6d6055 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -889,7 +889,7 @@ void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, un #if PACKETVER < 4 *rhand = sd->status.look.weapon; - *lhand = sd->status.shield; + *lhand = sd->status.look.shield; #else if (sd->equip_index[EQI_HAND_R] >= 0 && sd->inventory_data[sd->equip_index[EQI_HAND_R]]) @@ -9450,7 +9450,7 @@ void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) { // Character Looks #if PACKETVER < 4 clif->changelook(&sd->bl, LOOK_WEAPON, sd->status.look.weapon); - clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); + clif->changelook(&sd->bl, LOOK_SHIELD, sd->status.look.shield); #else clif->changelook(&sd->bl,LOOK_WEAPON,0); #endif diff --git a/src/map/pc.c b/src/map/pc.c index c30161a0c..a8a715a70 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -895,10 +895,19 @@ int pc_setequipindex(struct map_session_data *sd) } if (sd->status.inventory[i].equip & EQP_HAND_L) { - if (sd->inventory_data[i] != NULL && sd->inventory_data[i]->type == IT_WEAPON) - sd->weapontype2 = sd->inventory_data[i]->subtype; - else + if (sd->inventory_data[i] != NULL) { + if (sd->inventory_data[i]->type == IT_WEAPON) + sd->weapontype2 = sd->inventory_data[i]->subtype; + else + sd->weapontype2 = W_FIST; + if (sd->inventory_data[i]->type == IT_ARMOR) + sd->has_shield = true; + else + sd->has_shield = false; + } else { sd->weapontype2 = W_FIST; + sd->has_shield = false; + } } } } @@ -5947,7 +5956,7 @@ int pc_checkallowskill(struct map_session_data *sd) // Spurt requires bare hands (feet, in fact xD) status_change_end(&sd->bl, SC_STRUP, INVALID_TIMER); - if(sd->status.shield <= 0) { // Skills requiring a shield + if (!sd->has_shield) { // Skills requiring a shield for (i = 0; i < ARRAYLENGTH(scs_list); i++) if(sd->sc.data[scs_list[i]]) status_change_end(&sd->bl, scs_list[i], INVALID_TIMER); @@ -8891,7 +8900,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) sd->status.clothes_color=val; break; case LOOK_SHIELD: - sd->status.shield=val; + sd->status.look.shield = val; break; case LOOK_SHOES: break; @@ -9772,18 +9781,21 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, (pos & EQP_HAND_L)) { if (id != NULL) { if (id->type == IT_WEAPON) { - sd->status.shield = 0; + sd->has_shield = false; + sd->status.look.shield = 0; sd->weapontype2 = id->subtype; } else if (id->type == IT_ARMOR) { - sd->status.shield = id->view_sprite; + sd->has_shield = true; + sd->status.look.shield = id->view_sprite; sd->weapontype2 = W_FIST; } } else { - sd->status.shield = 0; + sd->has_shield = false; + sd->status.look.shield = 0; sd->weapontype2 = W_FIST; } pc->calcweapontype(sd); - clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); + clif->changelook(&sd->bl, LOOK_SHIELD, sd->status.look.shield); } //Added check to prevent sending the same look on multiple slots -> //causes client to redraw item on top of itself. (suggested by Lupus) @@ -10001,10 +10013,11 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) status_change_end(&sd->bl, SC_DANCING, INVALID_TIMER); // Unequipping => stop dancing. } if (pos & EQP_HAND_L) { - sd->status.shield = 0; + sd->has_shield = false; + sd->status.look.shield = 0; sd->weapontype2 = W_FIST; pc->calcweapontype(sd); - clif->changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); + clif->changelook(&sd->bl, LOOK_SHIELD, sd->status.look.shield); } if (pos & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) { sd->status.head_bottom = 0; diff --git a/src/map/pc.h b/src/map/pc.h index 62129b5ae..8615f00f2 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -308,6 +308,7 @@ struct map_session_data { short nameid; int64 tick; } item_delay[MAX_ITEMDELAYS]; // [Paradox924X] + bool has_shield; ///< Whether the character is wearing a shield. int16 weapontype; ///< Weapon type considering both hands (@see enum weapon_type). int16 weapontype1; ///< Weapon type in the right/primary hand (@see enum weapon_type). int16 weapontype2; ///< Weapon type in the left/secondary hand (@see enum weapon_type). diff --git a/src/map/script.c b/src/map/script.c index 58dd65173..09f6377ef 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -15525,7 +15525,7 @@ BUILDIN(getlook) case LOOK_HEAD_MID: val = sd->status.head_mid; break; //5 case LOOK_HAIR_COLOR: val = sd->status.hair_color; break; //6 case LOOK_CLOTHES_COLOR: val = sd->status.clothes_color; break; //7 - case LOOK_SHIELD: val = sd->status.shield; break; //8 + case LOOK_SHIELD: val = sd->status.look.shield; break; //8 case LOOK_SHOES: break; //9 case LOOK_ROBE: val = sd->status.robe; break; //12 case LOOK_BODY2: val=sd->status.body; break; //13 diff --git a/src/map/skill.c b/src/map/skill.c index 4649ace42..25d85e746 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -14245,7 +14245,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id } break; case ST_SHIELD: - if(sd->status.shield <= 0) { + if (!sd->has_shield) { clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0); return 0; } diff --git a/src/map/status.c b/src/map/status.c index ed29e85be..733eb5f6f 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -4326,7 +4326,7 @@ int status_base_amotion_pc(struct map_session_data *sd, struct status_data *st) amotion = status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype1]; if (sd->weapontype > MAX_SINGLE_WEAPON_TYPE) amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class)][sd->weapontype2] / 4; - if ( sd->status.shield ) + if (sd->has_shield) amotion += status->dbs->aspd_base[pc->class2idx(sd->status.class)][MAX_SINGLE_WEAPON_TYPE]; switch (sd->weapontype) { case W_BOW: -- cgit v1.2.3-70-g09d2 From 2b5309e5e393cf3f5fb7678c7e7690aec0511f21 Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 3 Dec 2016 06:29:06 +0100 Subject: Move other view-related variables to `sd->status.look` The following variables are now moved to `sd->status.look` (from `sd->status`): `head_top`, `head_mid`, `head_bottom`, `robe` Signed-off-by: Haru --- src/char/char.c | 34 ++++++++++----------- src/common/mmo.h | 10 ++++--- src/map/clif.c | 8 ++--- src/map/pc.c | 90 ++++++++++++++++++++++++++++---------------------------- src/map/script.c | 8 ++--- src/map/status.c | 8 ++--- 6 files changed, 80 insertions(+), 78 deletions(-) (limited to 'src') diff --git a/src/char/char.c b/src/char/char.c index c02ee33ef..12dc2554a 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -461,9 +461,9 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) (p->option != cp->option) || (p->party_id != cp->party_id) || (p->guild_id != cp->guild_id) || (p->pet_id != cp->pet_id) || (p->look.weapon != cp->look.weapon) || (p->hom_id != cp->hom_id) || - (p->ele_id != cp->ele_id) || (p->look.shield != cp->look.shield) || (p->head_top != cp->head_top) || - (p->head_mid != cp->head_mid) || (p->head_bottom != cp->head_bottom) || (p->delete_date != cp->delete_date) || - (p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->robe != cp->robe) || + (p->ele_id != cp->ele_id) || (p->look.shield != cp->look.shield) || (p->look.head_top != cp->look.head_top) || + (p->look.head_mid != cp->look.head_mid) || (p->look.head_bottom != cp->look.head_bottom) || (p->delete_date != cp->delete_date) || + (p->rename != cp->rename) || (p->slotchange != cp->slotchange) || (p->look.robe != cp->look.robe) || (p->show_equip != cp->show_equip) || (p->allow_party != cp->allow_party) || (p->font != cp->font) || (p->uniqueitem_counter != cp->uniqueitem_counter) || (p->hotkey_rowshift != cp->hotkey_rowshift) ) { @@ -490,11 +490,11 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) p->max_hp, p->hp, p->max_sp, p->sp, p->status_point, p->skill_point, p->str, p->agi, p->vit, p->int_, p->dex, p->luk, p->option, p->party_id, p->guild_id, p->pet_id, p->hom_id, p->ele_id, - p->look.weapon, p->look.shield, p->head_top, p->head_mid, p->head_bottom, + p->look.weapon, p->look.shield, p->look.head_top, p->look.head_mid, p->look.head_bottom, mapindex_id2name(p->last_point.map), p->last_point.x, p->last_point.y, mapindex_id2name(p->save_point.map), p->save_point.x, p->save_point.y, p->rename, (unsigned long)p->delete_date, // FIXME: platform-dependent size - p->robe,p->slotchange,opt,p->font,p->uniqueitem_counter, + p->look.robe,p->slotchange,opt,p->font,p->uniqueitem_counter, p->hotkey_rowshift, p->account_id, p->char_id) ) { @@ -1096,13 +1096,13 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) || SQL_ERROR == SQL->StmtBindColumn(stmt, 27, SQLDT_SHORT, &p.body, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 28, SQLDT_SHORT, &p.look.weapon, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 29, SQLDT_SHORT, &p.look.shield, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.head_top, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.head_mid, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p.head_bottom, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 30, SQLDT_SHORT, &p.look.head_top, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 31, SQLDT_SHORT, &p.look.head_mid, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 32, SQLDT_SHORT, &p.look.head_bottom, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_USHORT, &p.rename, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_UINT32, &p.delete_date, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p.robe, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p.look.robe, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_USHORT, &p.slotchange, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_LONG, &unban_time, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 39, SQLDT_ENUM, &sex, sizeof(sex), NULL, NULL) @@ -1210,9 +1210,9 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || SQL_ERROR == SQL->StmtBindColumn(stmt, 33, SQLDT_SHORT, &p->body, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 34, SQLDT_SHORT, &p->look.weapon, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 35, SQLDT_SHORT, &p->look.shield, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->head_top, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->head_mid, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_SHORT, &p->head_bottom, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 36, SQLDT_SHORT, &p->look.head_top, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 37, SQLDT_SHORT, &p->look.head_mid, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 38, SQLDT_SHORT, &p->look.head_bottom, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 39, SQLDT_STRING, &last_map, sizeof(last_map), NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 40, SQLDT_SHORT, &p->last_point.x, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 41, SQLDT_SHORT, &p->last_point.y, 0, NULL, NULL) @@ -1226,7 +1226,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every || SQL_ERROR == SQL->StmtBindColumn(stmt, 49, SQLDT_INT, &p->fame, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 50, SQLDT_USHORT, &p->rename, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 51, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL) - || SQL_ERROR == SQL->StmtBindColumn(stmt, 52, SQLDT_SHORT, &p->robe, 0, NULL, NULL) + || SQL_ERROR == SQL->StmtBindColumn(stmt, 52, SQLDT_SHORT, &p->look.robe, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 53, SQLDT_USHORT, &p->slotchange, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 54, SQLDT_UINT, &opt, 0, NULL, NULL) || SQL_ERROR == SQL->StmtBindColumn(stmt, 55, SQLDT_UCHAR, &p->font, 0, NULL, NULL) @@ -1946,10 +1946,10 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { WBUFW(buf,58) = p->base_level; WBUFW(buf,60) = min(p->skill_point, INT16_MAX); - WBUFW(buf,62) = p->head_bottom; + WBUFW(buf,62) = p->look.head_bottom; WBUFW(buf,64) = p->look.shield; - WBUFW(buf,66) = p->head_top; - WBUFW(buf,68) = p->head_mid; + WBUFW(buf,66) = p->look.head_top; + WBUFW(buf,68) = p->look.head_mid; WBUFW(buf,70) = p->hair_color; WBUFW(buf,72) = p->clothes_color; memcpy(WBUFP(buf,74), p->name, NAME_LENGTH); @@ -1973,7 +1973,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { offset += 4; #endif #if PACKETVER >= 20110111 - WBUFL(buf,128) = p->robe; + WBUFL(buf,128) = p->look.robe; offset += 4; #endif #if PACKETVER != 20111116 //2011-11-16 wants 136, ask gravity. diff --git a/src/common/mmo.h b/src/common/mmo.h index 4b120e812..85e0a83ae 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -613,11 +613,13 @@ struct mmo_charstatus { int sword_faith, sword_calls; struct { - short weapon; ///< Weapon view sprite id. - short shield; ///< Shield view sprite id. + short weapon; ///< Weapon view sprite id. + short shield; ///< Shield view sprite id. + short head_top; ///< Top headgear view sprite id. + short head_mid; ///< Middle headgear view sprite id. + short head_bottom; ///< Bottom headgear view sprite id. + short robe; ///< Robe view sprite id. } look; - short head_top,head_mid,head_bottom; - short robe; char name[NAME_LENGTH]; int base_level, job_level; diff --git a/src/map/clif.c b/src/map/clif.c index 77e6d6055..07f394da4 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1491,8 +1491,8 @@ bool clif_spawn(struct block_list *bl) } if (sd->charm_type != CHARM_TYPE_NONE && sd->charm_count > 0) clif->spiritcharm(sd); - if (sd->status.robe) - clif->refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA); + if (sd->status.look.robe != 0) + clif->refreshlook(bl, bl->id, LOOK_ROBE, sd->status.look.robe, AREA); } break; case BL_MOB: @@ -4309,8 +4309,8 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { clif->specialeffect_single(bl,421,sd->fd); if (tsd->bg_id != 0 && map->list[tsd->bl.m].flag.battleground) clif->sendbgemblem_single(sd->fd,tsd); - if (tsd->status.robe) - clif->refreshlook(&sd->bl,bl->id,LOOK_ROBE,tsd->status.robe,SELF); + if (tsd->status.look.robe != 0) + clif->refreshlook(&sd->bl, bl->id, LOOK_ROBE, tsd->status.look.robe, SELF); } break; case BL_MER: // Devotion Effects diff --git a/src/map/pc.c b/src/map/pc.c index a8a715a70..5948a3cf7 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -8835,10 +8835,10 @@ int pc_equiplookall(struct map_session_data *sd) clif->changelook(&sd->bl,LOOK_WEAPON,0); clif->changelook(&sd->bl,LOOK_SHOES,0); - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); - clif->changelook(&sd->bl,LOOK_ROBE, sd->status.robe); + clif->changelook(&sd->bl, LOOK_HEAD_BOTTOM, sd->status.look.head_bottom); + clif->changelook(&sd->bl, LOOK_HEAD_TOP, sd->status.look.head_top); + clif->changelook(&sd->bl, LOOK_HEAD_MID, sd->status.look.head_mid); + clif->changelook(&sd->bl, LOOK_ROBE, sd->status.look.robe); return 0; } @@ -8876,13 +8876,13 @@ int pc_changelook(struct map_session_data *sd,int type,int val) sd->status.look.weapon = val; break; case LOOK_HEAD_BOTTOM: - sd->status.head_bottom=val; + sd->status.look.head_bottom = val; break; case LOOK_HEAD_TOP: - sd->status.head_top=val; + sd->status.look.head_top = val; break; case LOOK_HEAD_MID: - sd->status.head_mid=val; + sd->status.look.head_mid = val; break; case LOOK_HAIR_COLOR: //Use the battle_config limits! [Skotlex] val = cap_value(val, MIN_HAIR_COLOR, MAX_HAIR_COLOR); @@ -8905,7 +8905,7 @@ int pc_changelook(struct map_session_data *sd,int type,int val) case LOOK_SHOES: break; case LOOK_ROBE: - sd->status.robe = val; + sd->status.look.robe = val; break; case LOOK_BODY2: val = cap_value(val, MIN_BODY_STYLE, MAX_BODY_STYLE); @@ -9801,57 +9801,57 @@ void pc_equipitem_pos(struct map_session_data *sd, struct item_data *id, int n, //causes client to redraw item on top of itself. (suggested by Lupus) if (!map_no_view(sd->bl.m,EQP_HEAD_LOW) && pos & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) { if (id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))) - sd->status.head_bottom = id->view_sprite; + sd->status.look.head_bottom = id->view_sprite; else - sd->status.head_bottom = 0; - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); + sd->status.look.head_bottom = 0; + clif->changelook(&sd->bl, LOOK_HEAD_BOTTOM, sd->status.look.head_bottom); } if (!map_no_view(sd->bl.m,EQP_HEAD_TOP) && pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) { if (id) - sd->status.head_top = id->view_sprite; + sd->status.look.head_top = id->view_sprite; else - sd->status.head_top = 0; - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); + sd->status.look.head_top = 0; + clif->changelook(&sd->bl, LOOK_HEAD_TOP, sd->status.look.head_top); } if (!map_no_view(sd->bl.m,EQP_HEAD_MID) && pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) { if (id && !(pos&EQP_HEAD_TOP)) - sd->status.head_mid = id->view_sprite; + sd->status.look.head_mid = id->view_sprite; else - sd->status.head_mid = 0; - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); + sd->status.look.head_mid = 0; + clif->changelook(&sd->bl, LOOK_HEAD_MID, sd->status.look.head_mid); } if (!map_no_view(sd->bl.m,EQP_COSTUME_HEAD_TOP) && pos & EQP_COSTUME_HEAD_TOP) { if (id){ - sd->status.head_top = id->view_sprite; + sd->status.look.head_top = id->view_sprite; } else - sd->status.head_top = 0; - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); + sd->status.look.head_top = 0; + clif->changelook(&sd->bl, LOOK_HEAD_TOP, sd->status.look.head_top); } if (!map_no_view(sd->bl.m,EQP_COSTUME_HEAD_MID) && pos & EQP_COSTUME_HEAD_MID) { if(id && !(pos&EQP_HEAD_TOP)){ - sd->status.head_mid = id->view_sprite; + sd->status.look.head_mid = id->view_sprite; } else - sd->status.head_mid = 0; - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); + sd->status.look.head_mid = 0; + clif->changelook(&sd->bl, LOOK_HEAD_MID, sd->status.look.head_mid); } if (!map_no_view(sd->bl.m,EQP_COSTUME_HEAD_LOW) && pos & EQP_COSTUME_HEAD_LOW) { if (id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID))){ - sd->status.head_bottom = id->view_sprite; + sd->status.look.head_bottom = id->view_sprite; } else - sd->status.head_bottom = 0; - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); + sd->status.look.head_bottom = 0; + clif->changelook(&sd->bl, LOOK_HEAD_BOTTOM, sd->status.look.head_bottom); } if (!map_no_view(sd->bl.m,EQP_SHOES) && pos & EQP_SHOES) clif->changelook(&sd->bl,LOOK_SHOES,0); if (!map_no_view(sd->bl.m,EQP_GARMENT) && pos&EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1) { - sd->status.robe = id ? id->view_sprite : 0; - clif->changelook(&sd->bl, LOOK_ROBE, sd->status.robe); + sd->status.look.robe = id ? id->view_sprite : 0; + clif->changelook(&sd->bl, LOOK_ROBE, sd->status.look.robe); } if (!map_no_view(sd->bl.m,EQP_COSTUME_GARMENT) && pos & EQP_COSTUME_GARMENT) { - sd->status.robe = id ? id->view_sprite : 0; - clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); + sd->status.look.robe = id ? id->view_sprite : 0; + clif->changelook(&sd->bl, LOOK_ROBE, sd->status.look.robe); } } @@ -10020,44 +10020,44 @@ void pc_unequipitem_pos(struct map_session_data *sd, int n, int pos) clif->changelook(&sd->bl, LOOK_SHIELD, sd->status.look.shield); } if (pos & EQP_HEAD_LOW && pc->checkequip(sd,EQP_COSTUME_HEAD_LOW) == -1) { - sd->status.head_bottom = 0; - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); + sd->status.look.head_bottom = 0; + clif->changelook(&sd->bl, LOOK_HEAD_BOTTOM, sd->status.look.head_bottom); } if (pos & EQP_HEAD_TOP && pc->checkequip(sd,EQP_COSTUME_HEAD_TOP) == -1) { - sd->status.head_top = 0; - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); + sd->status.look.head_top = 0; + clif->changelook(&sd->bl, LOOK_HEAD_TOP, sd->status.look.head_top); } if (pos & EQP_HEAD_MID && pc->checkequip(sd,EQP_COSTUME_HEAD_MID) == -1) { - sd->status.head_mid = 0; - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); + sd->status.look.head_mid = 0; + clif->changelook(&sd->bl, LOOK_HEAD_MID, sd->status.look.head_mid); } if (pos & EQP_COSTUME_HEAD_TOP) { - sd->status.head_top = ( pc->checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_TOP)]->view_sprite : 0; - clif->changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); + sd->status.look.head_top = ( pc->checkequip(sd,EQP_HEAD_TOP) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_TOP)]->view_sprite : 0; + clif->changelook(&sd->bl, LOOK_HEAD_TOP, sd->status.look.head_top); } if (pos & EQP_COSTUME_HEAD_MID) { - sd->status.head_mid = ( pc->checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_MID)]->view_sprite : 0; - clif->changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); + sd->status.look.head_mid = ( pc->checkequip(sd,EQP_HEAD_MID) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_MID)]->view_sprite : 0; + clif->changelook(&sd->bl, LOOK_HEAD_MID, sd->status.look.head_mid); } if (pos & EQP_COSTUME_HEAD_LOW) { - sd->status.head_bottom = ( pc->checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_LOW)]->view_sprite : 0; - clif->changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); + sd->status.look.head_bottom = ( pc->checkequip(sd,EQP_HEAD_LOW) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_HEAD_LOW)]->view_sprite : 0; + clif->changelook(&sd->bl, LOOK_HEAD_BOTTOM, sd->status.look.head_bottom); } if (pos & EQP_SHOES) clif->changelook(&sd->bl,LOOK_SHOES,0); if (pos & EQP_GARMENT && pc->checkequip(sd,EQP_COSTUME_GARMENT) == -1) { - sd->status.robe = 0; + sd->status.look.robe = 0; clif->changelook(&sd->bl, LOOK_ROBE, 0); } if (pos & EQP_COSTUME_GARMENT) { - sd->status.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->view_sprite : 0; - clif->changelook(&sd->bl,LOOK_ROBE,sd->status.robe); + sd->status.look.robe = ( pc->checkequip(sd,EQP_GARMENT) >= 0 ) ? sd->inventory_data[pc->checkequip(sd,EQP_GARMENT)]->view_sprite : 0; + clif->changelook(&sd->bl, LOOK_ROBE, sd->status.look.robe); } } diff --git a/src/map/script.c b/src/map/script.c index 09f6377ef..5ce581db6 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -15520,14 +15520,14 @@ BUILDIN(getlook) switch(type) { case LOOK_HAIR: val = sd->status.hair; break; //1 case LOOK_WEAPON: val = sd->status.look.weapon; break; //2 - case LOOK_HEAD_BOTTOM: val = sd->status.head_bottom; break; //3 - case LOOK_HEAD_TOP: val = sd->status.head_top; break; //4 - case LOOK_HEAD_MID: val = sd->status.head_mid; break; //5 + case LOOK_HEAD_BOTTOM: val = sd->status.look.head_bottom; break; //3 + case LOOK_HEAD_TOP: val = sd->status.look.head_top; break; //4 + case LOOK_HEAD_MID: val = sd->status.look.head_mid; break; //5 case LOOK_HAIR_COLOR: val = sd->status.hair_color; break; //6 case LOOK_CLOTHES_COLOR: val = sd->status.clothes_color; break; //7 case LOOK_SHIELD: val = sd->status.look.shield; break; //8 case LOOK_SHOES: break; //9 - case LOOK_ROBE: val = sd->status.robe; break; //12 + case LOOK_ROBE: val = sd->status.look.robe; break; //12 case LOOK_BODY2: val=sd->status.body; break; //13 } diff --git a/src/map/status.c b/src/map/status.c index 733eb5f6f..e04769e3f 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -6864,13 +6864,13 @@ void status_set_viewdata(struct block_list *bl, int class_) } sd->vd.class = class_; clif->get_weapon_view(sd, &sd->vd.weapon, &sd->vd.shield); - sd->vd.head_top = sd->status.head_top; - sd->vd.head_mid = sd->status.head_mid; - sd->vd.head_bottom = sd->status.head_bottom; + sd->vd.head_top = sd->status.look.head_top; + sd->vd.head_mid = sd->status.look.head_mid; + sd->vd.head_bottom = sd->status.look.head_bottom; sd->vd.hair_style = cap_value(sd->status.hair,0,battle_config.max_hair_style); sd->vd.hair_color = cap_value(sd->status.hair_color,0,battle_config.max_hair_color); sd->vd.cloth_color = cap_value(sd->status.clothes_color,0,battle_config.max_cloth_color); - sd->vd.robe = sd->status.robe; + sd->vd.robe = sd->status.look.robe; sd->vd.body_style = sd->status.body; sd->vd.sex = sd->status.sex; -- cgit v1.2.3-70-g09d2 From fd610efdb3cd8f1583a3918d54a679eb02ec76cd Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 21 Aug 2017 20:41:17 +0200 Subject: Add support for parsing arrays of constants as bitmasks in the item_db Fields marked as constant bitmasks will support the following syntaxes: Field: 10 // Decimal value Field: 0xA // Hexadecimal value Field: "FOO" // Constant Field: [2, 8] // Array of decimal values Field: [0x2, 0x8] // Array of hexadecimal values Field: ["FOO", "BAR"] // Array of constants Signed-off-by: Haru --- src/map/itemdb.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++------ src/map/itemdb.h | 1 + 2 files changed, 64 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 40dd9ab4f..7a2c967fb 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2224,21 +2224,76 @@ int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const char * bool itemdb_lookup_const(const struct config_setting_t *it, const char *name, int *value) { + const char *str = NULL; + nullpo_retr(false, name); nullpo_retr(false, value); - if (libconfig->setting_lookup_int(it, name, value)) - { + + if (libconfig->setting_lookup_int(it, name, value)) { return true; } - else - { + + if (libconfig->setting_lookup_string(it, name, &str)) { + if (*str && script->get_constant(str, value)) + return true; + } + + return false; +} + +bool itemdb_lookup_const_mask(const struct config_setting_t *it, const char *name, int *value) +{ + const struct config_setting_t *t = NULL; + + nullpo_retr(false, it); + nullpo_retr(false, name); + nullpo_retr(false, value); + + if ((t = libconfig->setting_get_member(it, name)) == NULL) { + return false; + } + + if (config_setting_is_scalar(t)) { const char *str = NULL; - if (libconfig->setting_lookup_string(it, name, &str)) - { - if (*str && script->get_constant(str, value)) + + if (config_setting_is_number(t)) { + *value = libconfig->setting_get_int(t); + return true; + } + + if ((str = libconfig->setting_get_string(t)) != NULL) { + int i32 = -1; + if (script->get_constant(str, &i32) && i32 >= 0) { + *value = i32; return true; + } + } + + return false; + } + + if (config_setting_is_aggregate(t) && libconfig->setting_length(t) >= 1) { + const struct config_setting_t *elem = NULL; + int i = 0; + + *value = 0; + + while ((elem = libconfig->setting_get_elem(t, i++)) != NULL) { + const char *str = libconfig->setting_get_string(elem); + int i32 = -1; + + if (str == NULL) + return false; + + if (!script->get_constant(str, &i32) || i32 < 0) + return false; + + *value |= i32; } + + return true; } + return false; } @@ -2664,4 +2719,5 @@ void itemdb_defaults(void) { itemdb->id2combo = itemdb_id2combo; itemdb->is_item_usable = itemdb_is_item_usable; itemdb->lookup_const = itemdb_lookup_const; + itemdb->lookup_const_mask = itemdb_lookup_const_mask; } diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 8a1799fbd..980e8730e 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -647,6 +647,7 @@ struct itemdb_interface { struct item_combo * (*id2combo) (unsigned short id); bool (*is_item_usable) (struct item_data *item); bool (*lookup_const) (const struct config_setting_t *it, const char *name, int *value); + bool (*lookup_const_mask) (const struct config_setting_t *it, const char *name, int *value); }; #ifdef HERCULES_CORE -- cgit v1.2.3-70-g09d2 From 39cbf6038b769230aba1fc17b28893cefc147294 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 21 Aug 2017 20:47:02 +0200 Subject: HPM Hooks Update Signed-off-by: Haru --- src/plugins/HPMHooking/HPMHooking.Defs.inc | 2 ++ .../HPMHooking/HPMHooking_map.HPMHooksCore.inc | 4 ++++ .../HPMHooking/HPMHooking_map.HookingPoints.inc | 1 + src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 27 ++++++++++++++++++++++ 4 files changed, 34 insertions(+) (limited to 'src') diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index 3ec573b6f..5eb8ac24c 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -3510,6 +3510,8 @@ typedef bool (*HPMHOOK_pre_itemdb_is_item_usable) (struct item_data **item); typedef bool (*HPMHOOK_post_itemdb_is_item_usable) (bool retVal___, struct item_data *item); typedef bool (*HPMHOOK_pre_itemdb_lookup_const) (const struct config_setting_t **it, const char **name, int **value); typedef bool (*HPMHOOK_post_itemdb_lookup_const) (bool retVal___, const struct config_setting_t *it, const char *name, int *value); +typedef bool (*HPMHOOK_pre_itemdb_lookup_const_mask) (const struct config_setting_t **it, const char **name, int **value); +typedef bool (*HPMHOOK_post_itemdb_lookup_const_mask) (bool retVal___, const struct config_setting_t *it, const char *name, int *value); #endif // MAP_ITEMDB_H #ifdef LOGIN_LCLIF_H /* lclif */ typedef void (*HPMHOOK_pre_lclif_init) (void); diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index b7b161b6b..e2494067c 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -2874,6 +2874,8 @@ struct { struct HPMHookPoint *HP_itemdb_is_item_usable_post; struct HPMHookPoint *HP_itemdb_lookup_const_pre; struct HPMHookPoint *HP_itemdb_lookup_const_post; + struct HPMHookPoint *HP_itemdb_lookup_const_mask_pre; + struct HPMHookPoint *HP_itemdb_lookup_const_mask_post; struct HPMHookPoint *HP_libconfig_read_pre; struct HPMHookPoint *HP_libconfig_read_post; struct HPMHookPoint *HP_libconfig_write_pre; @@ -9069,6 +9071,8 @@ struct { int HP_itemdb_is_item_usable_post; int HP_itemdb_lookup_const_pre; int HP_itemdb_lookup_const_post; + int HP_itemdb_lookup_const_mask_pre; + int HP_itemdb_lookup_const_mask_post; int HP_libconfig_read_pre; int HP_libconfig_read_post; int HP_libconfig_write_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 37a3efb19..b094fa841 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -1474,6 +1474,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(itemdb->id2combo, HP_itemdb_id2combo) }, { HP_POP(itemdb->is_item_usable, HP_itemdb_is_item_usable) }, { HP_POP(itemdb->lookup_const, HP_itemdb_lookup_const) }, + { HP_POP(itemdb->lookup_const_mask, HP_itemdb_lookup_const_mask) }, /* libconfig_interface */ { HP_POP(libconfig->read, HP_libconfig_read) }, { HP_POP(libconfig->write, HP_libconfig_write) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index d16268841..f8e94ea65 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -37811,6 +37811,33 @@ bool HP_itemdb_lookup_const(const struct config_setting_t *it, const char *name, } return retVal___; } +bool HP_itemdb_lookup_const_mask(const struct config_setting_t *it, const char *name, int *value) { + int hIndex = 0; + bool retVal___ = false; + if (HPMHooks.count.HP_itemdb_lookup_const_mask_pre > 0) { + bool (*preHookFunc) (const struct config_setting_t **it, const char **name, int **value); + *HPMforce_return = false; + for (hIndex = 0; hIndex < HPMHooks.count.HP_itemdb_lookup_const_mask_pre; hIndex++) { + preHookFunc = HPMHooks.list.HP_itemdb_lookup_const_mask_pre[hIndex].func; + retVal___ = preHookFunc(&it, &name, &value); + } + if (*HPMforce_return) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.itemdb.lookup_const_mask(it, name, value); + } + if (HPMHooks.count.HP_itemdb_lookup_const_mask_post > 0) { + bool (*postHookFunc) (bool retVal___, const struct config_setting_t *it, const char *name, int *value); + for (hIndex = 0; hIndex < HPMHooks.count.HP_itemdb_lookup_const_mask_post; hIndex++) { + postHookFunc = HPMHooks.list.HP_itemdb_lookup_const_mask_post[hIndex].func; + retVal___ = postHookFunc(retVal___, it, name, value); + } + } + return retVal___; +} /* libconfig_interface */ int HP_libconfig_read(struct config_t *config, FILE *stream) { int hIndex = 0; -- cgit v1.2.3-70-g09d2 From 3745f1658aab4a5ffe504a5660b76402f2e2c6d6 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 21 Aug 2017 20:52:14 +0200 Subject: Fix a typo in the constant ITEMUPPER_THIRDUPPER Was: ITEMUPPER_THURDUPPER Signed-off-by: Haru --- src/map/itemdb.h | 2 +- src/map/pc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 980e8730e..d2d3b6c73 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -337,7 +337,7 @@ enum item_class_upper { ITEMUPPER_UPPER = 0x02, ITEMUPPER_BABY = 0x04, ITEMUPPER_THIRD = 0x08, - ITEMUPPER_THURDUPPER = 0x10, + ITEMUPPER_THIRDUPPER = 0x10, ITEMUPPER_THIRDBABY = 0x20, ITEMUPPER_ALL = 0x3f, // Sum of all the above }; diff --git a/src/map/pc.c b/src/map/pc.c index 5948a3cf7..609a4ec56 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5032,7 +5032,7 @@ int pc_isUseitem(struct map_session_data *sd,int n) break; } // Upper third classes - if ((item->class_upper & ITEMUPPER_THURDUPPER) != 0) { + if ((item->class_upper & ITEMUPPER_THIRDUPPER) != 0) { if ((sd->job & JOBL_THIRD) != 0 && (sd->job & JOBL_UPPER) != 0) break; } -- cgit v1.2.3-70-g09d2 From 926cff033bb9533ae3d8615f8b90e2e443d0525b Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 21 Aug 2017 20:58:36 +0200 Subject: Add support for bitmask arrays in the item_db Upper field Signed-off-by: Haru --- db/item_db2.conf | 2 +- db/pre-re/item_db.conf | 2 +- db/re/item_db.conf | 2 +- doc/item_db.txt | 20 ++++++++++---------- src/map/itemdb.c | 2 +- src/map/script.c | 10 ++++++++++ src/plugins/db2sql.c | 5 +++-- 7 files changed, 27 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/db/item_db2.conf b/db/item_db2.conf index c4bc83837..8abe34a38 100644 --- a/db/item_db2.conf +++ b/db/item_db2.conf @@ -79,7 +79,7 @@ item_db: ( Rebellion: true/false (boolean, defaults to false) } Job: Job mask (alternate format, int, defaults to all jobs = 0xFFFFFFFF) - Upper: Upper mask (int, defaults to any = 0x3f) + Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (int, defaults to both = 2) Loc: Equip location (int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) diff --git a/db/pre-re/item_db.conf b/db/pre-re/item_db.conf index 055d3962c..7153451c2 100644 --- a/db/pre-re/item_db.conf +++ b/db/pre-re/item_db.conf @@ -79,7 +79,7 @@ item_db: ( Rebellion: true/false (boolean, defaults to false) } Job: Job mask (alternate format, int, defaults to all jobs = 0xFFFFFFFF) - Upper: Upper mask (int, defaults to any = 0x3f) + Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (string, defaults to "SEX_ANY") Loc: Equip location (int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) diff --git a/db/re/item_db.conf b/db/re/item_db.conf index bb4d87a77..e0830f876 100644 --- a/db/re/item_db.conf +++ b/db/re/item_db.conf @@ -79,7 +79,7 @@ item_db: ( Rebellion: true/false (boolean, defaults to false) } Job: Job mask (alternate format, int, defaults to all jobs = 0xFFFFFFFF) - Upper: Upper mask (int, defaults to any = 0x3f) + Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (string, defaults to "SEX_ANY") Loc: Equip location (int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) diff --git a/doc/item_db.txt b/doc/item_db.txt index 8a33f9c35..d9ec96fc1 100644 --- a/doc/item_db.txt +++ b/doc/item_db.txt @@ -58,7 +58,7 @@ item_db: ( Summoner: true/false (boolean, defaults to false) } Job: Job mask (alternate synxtax, int, defaults to all jobs = 0xFFFFFFFF) - Upper: Upper mask (int, defaults to any = 0x3f) + Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (string, defaults to "SEX_ANY") Loc: Equip location (int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) @@ -188,17 +188,17 @@ Job: Job restrictions. If this block is omitted, item can be equipped by all cl All (default value): 0xFFFFFFFF Upper: Equippable upper-types. Uses the following bitmasks: - Normal jobs: 0x01 (1) - Upper jobs: 0x02 (2) - Baby jobs: 0x04 (4) - Third jobs: 0x08 (8) - Upper Third jobs: 0x10 (16) - Baby Third jobs: 0x20 (32) + Normal jobs: ITEMUPPER_NORMAL (0x01) + Upper jobs: ITEMUPPER_UPPER (0x02) + Baby jobs: ITEMUPPER_BABY (0x04) + Third jobs: ITEMUPPER_THIRD (0x08) + Upper Third jobs: ITEMUPPER_THIRDUPPER (0x10) + Baby Third jobs: ITEMUPPER_THIRDBABY (0x20) Under pre-re mode third classes are considered upper, making use of - the 8 and above masks is therefore not necessary unless in renewal - mode. When no value is specified, all classes (mask 0x3f) are able to - equip the item. + the ITEMUPPER_THIRD and above masks is therefore not necessary unless + in renewal mode. When no value is specified, all classes (mask + ITEMUPPER_ALL = 0x3f) are able to equip the item. Gender: Gender restriction. Available genders: diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 7a2c967fb..0ace20984 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2037,7 +2037,7 @@ int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const char * itemdb->jobmask2mapid(id.class_base, UINT64_MAX); } - if( itemdb->lookup_const(it, "Upper", &i32) && i32 >= 0 ) + if (itemdb->lookup_const_mask(it, "Upper", &i32) && i32 >= 0) id.class_upper = (unsigned int)i32; else if( !inherit ) id.class_upper = ITEMUPPER_ALL; diff --git a/src/map/script.c b/src/map/script.c index 5ce581db6..f29ce4104 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -24572,6 +24572,16 @@ void script_hardcoded_constants(void) script->set_constant("A_CANNONBALL", A_CANNONBALL, false, false); script->set_constant("A_THROWWEAPON", A_THROWWEAPON, false, false); + script->constdb_comment("Item Upper Masks"); + script->set_constant("ITEMUPPER_NONE", ITEMUPPER_NONE, false, false); + script->set_constant("ITEMUPPER_NORMAL", ITEMUPPER_NORMAL, false, false); + script->set_constant("ITEMUPPER_UPPER", ITEMUPPER_UPPER, false, false); + script->set_constant("ITEMUPPER_BABY", ITEMUPPER_BABY, false, false); + script->set_constant("ITEMUPPER_THIRD", ITEMUPPER_THIRD, false, false); + script->set_constant("ITEMUPPER_THIRDUPPER", ITEMUPPER_THIRDUPPER, false, false); + script->set_constant("ITEMUPPER_THIRDBABY", ITEMUPPER_THIRDBABY, false, false); + script->set_constant("ITEMUPPER_ALL", ITEMUPPER_ALL, false, false); + script->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c index cb8660df9..38e5ead5d 100644 --- a/src/plugins/db2sql.c +++ b/src/plugins/db2sql.c @@ -297,10 +297,11 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) StrBuf->Printf(&buf, "'%"PRIu64"',", ui64); // equip_upper - if (libconfig->setting_lookup_int(entry, "Upper", &i32) && i32 >= 0) + if (itemdb->lookup_const_mask(entry, "Upper", &i32) && i32 >= 0) ui32 = (uint32)i32; else ui32 = ITEMUPPER_ALL; + StrBuf->Printf(&buf, "'%u',", ui32); // equip_genders @@ -323,7 +324,7 @@ int itemdb2sql_sub(struct config_setting_t *entry, int n, const char *source) // refineable StrBuf->Printf(&buf, "'%d',", it->flag.no_refine?0:1); - + // disable_options StrBuf->Printf(&buf, "'%d',", it->flag.no_options?1:0); -- cgit v1.2.3-70-g09d2 From 78a007d2371dc0a46f5e66b776fdf57f04658447 Mon Sep 17 00:00:00 2001 From: Haru Date: Mon, 21 Aug 2017 22:46:05 +0200 Subject: Add support for bitmask arrays in the item_db Loc field Signed-off-by: Haru --- db/item_db2.conf | 2 +- db/pre-re/item_db.conf | 2 +- db/re/item_db.conf | 2 +- doc/item_db.txt | 52 ++++++++++++++++++++++++++++---------------------- src/map/itemdb.c | 2 +- src/map/script.c | 9 +++++++++ 6 files changed, 42 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/db/item_db2.conf b/db/item_db2.conf index 8abe34a38..b6c68d069 100644 --- a/db/item_db2.conf +++ b/db/item_db2.conf @@ -81,7 +81,7 @@ item_db: ( Job: Job mask (alternate format, int, defaults to all jobs = 0xFFFFFFFF) Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (int, defaults to both = 2) - Loc: Equip location (int, required value for equipment) + Loc: Equip location (bitmask array, string or int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) EquipLv: Equip required level (int, defaults to 0) EquipLv: [min, max] (alternative syntax with min / max level) diff --git a/db/pre-re/item_db.conf b/db/pre-re/item_db.conf index bea31f2a3..8b7fdf806 100644 --- a/db/pre-re/item_db.conf +++ b/db/pre-re/item_db.conf @@ -81,7 +81,7 @@ item_db: ( Job: Job mask (alternate format, int, defaults to all jobs = 0xFFFFFFFF) Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (string, defaults to "SEX_ANY") - Loc: Equip location (int, required value for equipment) + Loc: Equip location (bitmask array, string or int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) EquipLv: Equip required level (int, defaults to 0) EquipLv: [min, max] (alternative syntax with min / max level) diff --git a/db/re/item_db.conf b/db/re/item_db.conf index 26baa0868..e9c195c92 100644 --- a/db/re/item_db.conf +++ b/db/re/item_db.conf @@ -81,7 +81,7 @@ item_db: ( Job: Job mask (alternate format, int, defaults to all jobs = 0xFFFFFFFF) Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (string, defaults to "SEX_ANY") - Loc: Equip location (int, required value for equipment) + Loc: Equip location (bitmask array, string or int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) EquipLv: Equip required level (int, defaults to 0) EquipLv: [min, max] (alternative syntax with min / max level) diff --git a/doc/item_db.txt b/doc/item_db.txt index d9ec96fc1..913ab80e0 100644 --- a/doc/item_db.txt +++ b/doc/item_db.txt @@ -60,7 +60,7 @@ item_db: ( Job: Job mask (alternate synxtax, int, defaults to all jobs = 0xFFFFFFFF) Upper: Upper mask (bitmask array, string or int, defaults to "ITEMUPPER_ALL") Gender: Gender (string, defaults to "SEX_ANY") - Loc: Equip location (int, required value for equipment) + Loc: Equip location (bitmask array, string or int, required value for equipment) WeaponLv: Weapon Level (int, defaults to 0) EquipLv: Equip required level (int, defaults to 0) EquipLv: [min, max] (alternative syntax with min / max level) @@ -208,28 +208,34 @@ Gender: Gender restriction. When not specified, becomes "SEX_ANY". Loc: Equipment's placement. A value needs to be specified if the item is an - equipment piece. Values are: - - 2^0 001 = Lower Headgear - 2^1 002 = Weapon - 2^2 004 = Garment - 2^3 008 = Accessory 1 - 2^4 016 = Armor - 2^5 032 = Shield - 2^6 064 = Footgear - 2^7 128 = Accessory 2 - 2^8 256 = Upper Headgear - 2^9 512 = Middle Headgear - 2^10 1024 = Costume Top Headgear - 2^11 2048 = Costume Mid Headgear - 2^12 4096 = Costume Low Headgear - 2^13 8192 = Costume Garment/Robe - 2^16 65536 = Shadow Armor - 2^17 131072 = Shadow Weapon - 2^18 262144 = Shadow Shield - 2^18 524288 = Shadow Shoes - 2^20 1048576 = Shadow Accessory 2 - 2^21 2097152 = Shadow Accessory 1 + equipment piece. Values are (bitmask arrays are supported): + + Lower Headgear: EQP_HEAD_LOW (2^00 = 0x000001) + Weapon: EQP_HAND_R or EQP_WEAPON (2^01 = 0x000002) + Garment: EQP_GARMENT (2^02 = 0x000004) + Accessory 1: EQP_ACC_L (2^03 = 0x000008) + Armor: EQP_ARMOR (2^04 = 0x000010) + Shield: EQP_HAND_L or EQP_SHIELD (2^05 = 0x000020) + (Both Hands): EQP_ARMS (EQP_HAND_L | EQP_HAND_R = 0x000022) + Footgear: EQP_SHOES (2^06 = 0x000040) + Accessory 2: EQP_ACC_R (2^07 = 0x000080) + (Both Accessories): EQP_ACC (EQP_ACC_R | EQP_ACC_L = 0x000088) + Upper Headgear: EQP_HEAD_TOP (2^08 = 0x000100) + Middle Headgear: EQP_HEAD_MID (2^09 = 0x000200) + (T+M+B Headgear): EQP_HELM (EQP_HEAD_LOW | EQP_HEAD_MID | EQP_HEAD_TOP = 0x000301) + Costume Top Headgear: EQP_COSTUME_HEAD_TOP (2^10 = 0x000400) + Costume Mid Headgear: EQP_COSTUME_HEAD_MID (2^11 = 0x000800) + Costume Low Headgear: EQP_COSTUME_HEAD_LOW (2^12 = 0x001000) + Costume Garment/Robe: EQP_COSTUME_GARMENT (2^13 = 0x002000) + Ammunition: EQP_AMMO (2^15 = 0x008000) + Shadow Armor: EQP_SHADOW_ARMOR (2^16 = 0x010000) + Shadow Weapon: EQP_SHADOW_WEAPON (2^17 = 0x020000) + Shadow Shield: EQP_SHADOW_SHIELD (2^18 = 0x040000) + (Shadow 2H Weapon): EQP_SHADOW_ARMS (EQP_SHADOW_WEAPON | EQP_SHADOW_SHIELD = 0x060000) + Shadow Shoes: EQP_SHADOW_SHOES (2^19 = 0x080000) + Shadow Accessory 2: EQP_SHADOW_ACC_R (2^20 = 0x100000) + Shadow Accessory 1: EQP_SHADOW_ACC_L (2^21 = 0x200000) + (Shadow Accessories): EQP_SHADOW_ACC (EQP_SHADOW_ACC_R | EQP_SHADOW_ACC_L = 0x300000) WeaponLv: Weapon level. Becomes 0 when not specified. diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 0ace20984..96eced725 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2047,7 +2047,7 @@ int itemdb_readdb_libconfig_sub(struct config_setting_t *it, int n, const char * else if( !inherit ) id.sex = 2; - if( itemdb->lookup_const(it, "Loc", &i32) && i32 >= 0 ) + if (itemdb->lookup_const_mask(it, "Loc", &i32) && i32 >= 0) id.equip = i32; if( itemdb->lookup_const(it, "WeaponLv", &i32) && i32 >= 0 ) diff --git a/src/map/script.c b/src/map/script.c index f29ce4104..7dcebd6f6 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -24459,6 +24459,15 @@ void script_hardcoded_constants(void) script->set_constant("EQP_SHADOW_SHOES", EQP_SHADOW_SHOES, false, false); script->set_constant("EQP_SHADOW_ACC_R", EQP_SHADOW_ACC_R, false, false); script->set_constant("EQP_SHADOW_ACC_L", EQP_SHADOW_ACC_L, false, false); + // Synonyms and combined values + script->set_constant("EQP_WEAPON", EQP_WEAPON, false, false); + script->set_constant("EQP_SHIELD", EQP_SHIELD, false, false); + script->set_constant("EQP_ARMS", EQP_ARMS, false, false); + script->set_constant("EQP_HELM", EQP_HELM, false, false); + script->set_constant("EQP_ACC", EQP_ACC, false, false); + script->set_constant("EQP_COSTUME", EQP_COSTUME, false, false); + script->set_constant("EQP_SHADOW_ACC", EQP_SHADOW_ACC, false, false); + script->set_constant("EQP_SHADOW_ARMS", EQP_SHADOW_ARMS, false, false); script->constdb_comment("Item Option Types"); script->set_constant("IT_OPT_INDEX", IT_OPT_INDEX, false, false); -- cgit v1.2.3-70-g09d2