summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-06 18:47:11 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-06 18:47:11 +0000
commitf0fa9794bcdde0b1402bb7a7256265f59bbd7313 (patch)
tree7b63a598956cf1c3acf681c13112f5d6c4278e93 /src/map
parentb1b0860d1ca7e0f9ddb57756be9af11d9557d555 (diff)
downloadhercules-f0fa9794bcdde0b1402bb7a7256265f59bbd7313.tar.gz
hercules-f0fa9794bcdde0b1402bb7a7256265f59bbd7313.tar.bz2
hercules-f0fa9794bcdde0b1402bb7a7256265f59bbd7313.tar.xz
hercules-f0fa9794bcdde0b1402bb7a7256265f59bbd7313.zip
- Added EQP_/EQI_ constants in pc.h to identify equip position and equip indexes, makes equipping related code much easier to read.
- Also cleaned up pc_equipitem. When dual wielding or equipping accessories, if the client actually specifies one of the two positions, it will be taken into account. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7550 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c2
-rw-r--r--src/map/charcommand.c28
-rw-r--r--src/map/map.c6
-rw-r--r--src/map/map.h12
-rw-r--r--src/map/pc.c140
-rw-r--r--src/map/pc.h37
-rw-r--r--src/map/pet.c2
-rw-r--r--src/map/script.c2
-rw-r--r--src/map/skill.c10
-rw-r--r--src/map/status.c24
-rw-r--r--src/map/vending.c1
11 files changed, 143 insertions, 121 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index b3b7f42c6..2e1eab8ae 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -3772,7 +3772,7 @@ int atcommand_refine(
refine = 1;
count = 0;
- for (j = 0; j < 10; j++) {
+ for (j = 0; j < EQI_MAX-1; j++) {
if ((i = sd->equip_index[j]) < 0)
continue;
if(position && !(sd->status.inventory[i].equip & position))
diff --git a/src/map/charcommand.c b/src/map/charcommand.c
index 610d7880a..7abbda002 100644
--- a/src/map/charcommand.c
+++ b/src/map/charcommand.c
@@ -777,33 +777,33 @@ charcommand_itemlist(
}
if ((equip = i_item->equip)) {
strcpy(equipstr, "| equiped: ");
- if (equip & 4)
+ if (equip & EQP_GARMENT)
strcat(equipstr, "robe/gargment, ");
- if (equip & 8)
+ if (equip & EQP_ACC_L)
strcat(equipstr, "left accessory, ");
- if (equip & 16)
+ if (equip & EQP_ARMOR)
strcat(equipstr, "body/armor, ");
- if ((equip & 34) == 2)
+ if ((equip & EQP_WEAPON) == EQP_HAND_R)
strcat(equipstr, "right hand, ");
- if ((equip & 34) == 32)
+ if ((equip & EQP_WEAPON) == EQP_HAND_L)
strcat(equipstr, "left hand, ");
- if ((equip & 34) == 34)
+ if ((equip & EQP_WEAPON) == EQP_WEAPON)
strcat(equipstr, "both hands, ");
- if (equip & 64)
+ if (equip & EQP_SHOES)
strcat(equipstr, "feet, ");
- if (equip & 128)
+ if (equip & EQP_ACC_R)
strcat(equipstr, "right accessory, ");
- if ((equip & 769) == 1)
+ if ((equip & EQP_HELM) == EQP_HEAD_LOW)
strcat(equipstr, "lower head, ");
- if ((equip & 769) == 256)
+ if ((equip & EQP_HELM) == EQP_HEAD_TOP)
strcat(equipstr, "top head, ");
- if ((equip & 769) == 257)
+ if ((equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_TOP))
strcat(equipstr, "lower/top head, ");
- if ((equip & 769) == 512)
+ if ((equip & EQP_HELM) == EQP_HEAD_MID)
strcat(equipstr, "mid head, ");
- if ((equip & 769) == 512)
+ if ((equip & EQP_HELM) == (EQP_HEAD_LOW|EQP_HEAD_MID))
strcat(equipstr, "lower/mid head, ");
- if ((equip & 769) == 769)
+ if ((equip & EQP_HELM) == EQP_HELM)
strcat(equipstr, "lower/mid/top head, ");
// remove final ', '
equipstr[strlen(equipstr) - 2] = '\0';
diff --git a/src/map/map.c b/src/map/map.c
index a93b03257..c5a4bb314 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -290,15 +290,13 @@ int map_freeblock_lock (void)
* バッファにたまっていたblockを全部削除
*------------------------------------------
*/
-//Temporal debug function to figure out which unlock is causing already free'd pointer errors.
-int map_freeblock_unlock_sub(const char * file, int line)
+int map_freeblock_unlock (void)
{
if ((--block_free_lock) == 0) {
int i;
for (i = 0; i < block_free_count; i++)
{ //Directly calling aFree shouldn't be a leak, as Free remembers the size the original pointed to memory was allocated with? [Skotlex]
-// aFree(block_free[i]);
- _mfree(block_free[i], file, line, __func__);
+ aFree(block_free[i]);
block_free[i] = NULL;
}
block_free_count = 0;
diff --git a/src/map/map.h b/src/map/map.h
index 8745ce1e9..d7456b742 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -1017,14 +1017,6 @@ struct pet_data {
enum { ATK_LUCKY=1,ATK_FLEE,ATK_DEF}; // 囲まれペナルティ計算用
-// For equipment breaking/stripping effects
-enum {
- EQP_WEAPON = 1, // Both weapons
- EQP_ARMOR = 2, // Armor
- EQP_SHIELD = 4, // Shield
- EQP_HELM = 8, // Top-head headgear
-};
-
struct map_data {
char name[MAP_NAME_LENGTH];
unsigned short index; //Index is the map index used by the mapindex* functions.
@@ -1285,9 +1277,7 @@ int map_getusers(void);
// block削除関連
int map_freeblock(struct block_list *bl);
int map_freeblock_lock(void);
-//int map_freeblock_unlock(void);
-#define map_freeblock_unlock() map_freeblock_unlock_sub(__FILE__, __LINE__)
-int map_freeblock_unlock_sub(const char * file, int line);
+int map_freeblock_unlock(void);
// block関連
int map_addblock_sub(struct block_list *, int);
int map_delblock_sub(struct block_list *, int);
diff --git a/src/map/pc.c b/src/map/pc.c
index 935c3b3eb..f965fb6e3 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -57,7 +57,7 @@ struct fame_list smith_fame_list[MAX_FAME_LIST];
struct fame_list chemist_fame_list[MAX_FAME_LIST];
struct fame_list taekwon_fame_list[MAX_FAME_LIST];
-static unsigned int equip_pos[11]={0x0080,0x0008,0x0040,0x0004,0x0001,0x0200,0x0100,0x0010,0x0020,0x0002,0x8000};
+static unsigned short equip_pos[EQI_MAX]={EQP_ACC_L,EQP_ACC_R,EQP_SHOES,EQP_GARMENT,EQP_HEAD_LOW,EQP_HEAD_MID,EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_AMMO};
static struct gm_account *gm_account = NULL;
static int GM_num = 0;
@@ -391,8 +391,8 @@ int pc_equippoint(struct map_session_data *sd,int n)
if(sd->inventory_data[n]->look == W_DAGGER ||
sd->inventory_data[n]->look == W_1HSWORD ||
sd->inventory_data[n]->look == W_1HAXE) {
- if(ep == 2 && (pc_checkskill(sd,AS_LEFT) > 0 || (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN))
- return 34;
+ if(ep == EQP_HAND_R && (pc_checkskill(sd,AS_LEFT) > 0 || (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN))
+ return EQP_WEAPON;
}
}
return ep;
@@ -446,26 +446,26 @@ int pc_setequipindex(struct map_session_data *sd)
nullpo_retr(0, sd);
- for(i=0;i<11;i++)
+ for(i=0;i<EQI_MAX;i++)
sd->equip_index[i] = -1;
for(i=0;i<MAX_INVENTORY;i++) {
if(sd->status.inventory[i].nameid <= 0)
continue;
if(sd->status.inventory[i].equip) {
- for(j=0;j<11;j++)
+ for(j=0;j<EQI_MAX;j++)
if(sd->status.inventory[i].equip & equip_pos[j])
sd->equip_index[j] = i;
- if(sd->status.inventory[i].equip & 0x0002) {
+ if(sd->status.inventory[i].equip & EQP_HAND_R) {
if(sd->inventory_data[i])
sd->weapontype1 = sd->inventory_data[i]->look;
else
sd->weapontype1 = 0;
}
- if(sd->status.inventory[i].equip & 0x0020) {
+ if(sd->status.inventory[i].equip & EQP_HAND_L) {
if(sd->inventory_data[i]) {
if(sd->inventory_data[i]->type == 4) {
- if(sd->status.inventory[i].equip == 0x0020)
+ if(sd->status.inventory[i].equip == EQP_HAND_L)
sd->weapontype2 = sd->inventory_data[i]->look;
else
sd->weapontype2 = 0;
@@ -530,21 +530,21 @@ int pc_isequip(struct map_session_data *sd,int n)
return 0;
if (sd->sc.count) {
- if((item->equip & 0x0002 || item->equip & 0x0020) && item->type == 4 && sd->sc.data[SC_STRIPWEAPON].timer != -1) // Also works with left-hand weapons [DracoRPG]
+ if(item->equip & EQP_WEAPON && item->type == 4 && sd->sc.data[SC_STRIPWEAPON].timer != -1) // Also works with left-hand weapons [DracoRPG]
return 0;
- if(item->equip & 0x0020 && item->type == 5 && sd->sc.data[SC_STRIPSHIELD].timer != -1) // Also works with left-hand weapons [DracoRPG]
+ if(item->equip & EQP_SHIELD && item->type == 5 && sd->sc.data[SC_STRIPSHIELD].timer != -1)
return 0;
- if(item->equip & 0x0010 && sd->sc.data[SC_STRIPARMOR].timer != -1)
+ if(item->equip & EQP_ARMOR && sd->sc.data[SC_STRIPARMOR].timer != -1)
return 0;
- if(item->equip & 0x0100 && sd->sc.data[SC_STRIPHELM].timer != -1)
+ if(item->equip & EQP_HELM && sd->sc.data[SC_STRIPHELM].timer != -1)
return 0;
if (sd->sc.data[SC_SPIRIT].timer != -1 && sd->sc.data[SC_SPIRIT].val2 == SL_SUPERNOVICE) {
//Spirit of Super Novice equip bonuses. [Skotlex]
- if (sd->status.base_level > 90 && item->equip & 0x301)
+ if (sd->status.base_level > 90 && item->equip & EQP_HELM)
return 1; //Can equip all helms
- if (sd->status.base_level > 96 && item->equip & 0x022 && item->type == 4)
+ if (sd->status.base_level > 96 && item->equip & EQP_WEAPON && item->type == 4)
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
@@ -2389,7 +2389,7 @@ int pc_insert_card(struct map_session_data *sd,int idx_card,int idx_equip)
sd->status.inventory[idx_equip].card[0]==0x00fe ||
sd->status.inventory[idx_equip].card[0]==(short)0xff00 ||
!(sd->inventory_data[idx_equip]->equip&ep) || // ? 備個所違い
- (sd->inventory_data[idx_equip]->type==4 && ep==32) || // ? 手武器と盾カ?ド
+ (sd->inventory_data[idx_equip]->type==4 && ep==EQP_SHIELD) || // ? 手武器と盾カ?ド
sd->status.inventory[idx_equip].equip){
clif_insert_card(sd,idx_equip,idx_card,1);
@@ -3460,7 +3460,7 @@ int pc_checkequip(struct map_session_data *sd,int pos)
nullpo_retr(-1, sd);
- for(i=0;i<11;i++){
+ for(i=0;i<EQI_MAX;i++){
if(pos & equip_pos[i])
return sd->equip_index[i];
}
@@ -6108,20 +6108,19 @@ int pc_cleareventtimer(struct map_session_data *sd)
* アイテムを?備する
*------------------------------------------
*/
-int pc_equipitem(struct map_session_data *sd,int n,int pos)
+int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
{
- int i,nameid, arrow;
+ int i,pos;
struct item_data *id;
- //?生や養子の場合の元の職業を算出する
nullpo_retr(0, sd);
- nameid = sd->status.inventory[n].nameid;
id = sd->inventory_data[n];
- pos = pc_equippoint(sd,n);
+ pos = pc_equippoint(sd,n); //With a few exceptions, item should go in all specified slots.
+
if(battle_config.battle_log)
- ShowInfo("equip %d(%d) %x:%x\n",nameid,n,id->equip,pos);
- if(!pc_isequip(sd,n) || !pos || sd->status.inventory[n].attribute==1 ) { // [Valaris]
+ ShowInfo("equip %d(%d) %x:%x\n",sd->status.inventory[n].nameid,n,id->equip,req_pos);
+ if(!pc_isequip(sd,n) || !(pos&req_pos) || sd->status.inventory[n].attribute==1 ) { // [Valaris]
clif_equipitemack(sd,n,0,0); // fail
return 0;
}
@@ -6133,51 +6132,41 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos)
return 0;
}
- if(pos==0x88){ // アクセサリ用例外?理
- int epor=0;
- if(sd->equip_index[0] >= 0)
- epor |= sd->status.inventory[sd->equip_index[0]].equip;
- if(sd->equip_index[1] >= 0)
- epor |= sd->status.inventory[sd->equip_index[1]].equip;
- epor &= 0x88;
- pos = epor == 0x08 ? 0x80 : 0x08;
+ if(pos == EQP_ACC) { //Accesories should only go in one of the two,
+ pos = req_pos&EQP_ACC;
+ if (pos == EQP_ACC) //User specified both slots..
+ pos = sd->equip_index[EQI_ACC_L] >= 0 ? EQP_ACC_R : EQP_ACC_L;
}
- // 二刀流?理
- if ((pos==0x22) // 一?、?備要求箇所が二刀流武器かチェックする
- && (id->equip==2) // ? 手武器
- && (pc_checkskill(sd, AS_LEFT) > 0 || (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN) ) // 左手修?有
- {
- int tpos=0;
- if(sd->equip_index[8] >= 0)
- tpos |= sd->status.inventory[sd->equip_index[8]].equip;
- if(sd->equip_index[9] >= 0)
- tpos |= sd->status.inventory[sd->equip_index[9]].equip;
- tpos &= 0x02;
- pos = tpos == 0x02 ? 0x20 : 0x02;
+ if(pos == EQP_WEAPON && id->equip == EQP_HAND_R &&
+ (pc_checkskill(sd, AS_LEFT) > 0 ||
+ (sd->class_&MAPID_UPPERMASK) == MAPID_ASSASSIN)
+ ) { //Dual wield capable weapon.
+ pos = (req_pos&EQP_WEAPON);
+ if (pos == EQP_WEAPON) //User specified both slots, pick one for them.
+ pos = sd->equip_index[EQI_HAND_R] >= 0 ? EQP_HAND_L : EQP_HAND_R;
}
+
+ for(i=0;i<EQI_MAX;i++) {
- arrow=pc_search_inventory(sd,pc_checkequip(sd,9)); // Added by RoVeRT
- for(i=0;i<11;i++) {
- if(sd->equip_index[i] >= 0 && sd->status.inventory[sd->equip_index[i]].equip&pos) {
- pc_unequipitem(sd,sd->equip_index[i],2);
+ if(pos & equip_pos[i]) {
+ if(sd->equip_index[i] >= 0) //Slot taken, remove item from there.
+ pc_unequipitem(sd,sd->equip_index[i],2);
+
+ sd->equip_index[i] = n;
}
}
- // 弓矢?備
- if(pos==0x8000){
+
+ if(pos==EQP_AMMO){
clif_arrowequip(sd,n);
- clif_arrow_fail(sd,3); // 3=矢が?備できました
+ clif_arrow_fail(sd,3);
}
else
clif_equipitemack(sd,n,pos,1);
- for(i=0;i<11;i++) {
- if(pos & equip_pos[i])
- sd->equip_index[i] = n;
- }
sd->status.inventory[n].equip=pos;
- if(sd->status.inventory[n].equip & 0x0002) {
+ if(sd->status.inventory[n].equip & EQP_HAND_R) {
if(sd->inventory_data[n])
sd->weapontype1 = sd->inventory_data[n]->look;
else
@@ -6185,11 +6174,11 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos)
pc_calcweapontype(sd);
clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
}
- if(sd->status.inventory[n].equip & 0x0020) {
+ if(sd->status.inventory[n].equip & EQP_HAND_L) {
if(sd->inventory_data[n]) {
if(sd->inventory_data[n]->type == 4) {
sd->status.shield = 0;
- if(sd->status.inventory[n].equip == 0x0020)
+ if(sd->status.inventory[n].equip == EQP_HAND_L)
sd->weapontype2 = sd->inventory_data[n]->look;
else
sd->weapontype2 = 0;
@@ -6204,35 +6193,42 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos)
pc_calcweapontype(sd);
clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
}
- if(sd->status.inventory[n].equip & 0x0001) {
+ if(sd->status.inventory[n].equip & EQP_HEAD_LOW) {
if(sd->inventory_data[n])
sd->status.head_bottom = sd->inventory_data[n]->look;
else
sd->status.head_bottom = 0;
clif_changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
}
- if(sd->status.inventory[n].equip & 0x0100) {
+ if(sd->status.inventory[n].equip & EQP_HEAD_TOP) {
if(sd->inventory_data[n])
sd->status.head_top = sd->inventory_data[n]->look;
else
sd->status.head_top = 0;
clif_changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
}
- if(sd->status.inventory[n].equip & 0x0200) {
+ if(sd->status.inventory[n].equip & EQP_HEAD_MID) {
if(sd->inventory_data[n])
sd->status.head_mid = sd->inventory_data[n]->look;
else
sd->status.head_mid = 0;
clif_changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
}
- if(sd->status.inventory[n].equip & 0x0040)
+ if(sd->status.inventory[n].equip & EQP_SHOES)
clif_changelook(&sd->bl,LOOK_SHOES,0);
- pc_checkallowskill(sd); // ?備品でスキルか解除されるかチェック
- if (itemdb_look(sd->status.inventory[n].nameid) == 11 && (arrow >= 0)){ // Added by RoVeRT
+ pc_checkallowskill(sd); //Check if status changes should be halted.
+
+
+/* WTF? pc_checkequip returns an item index, pc_search_inventory expects a
+ * nameid as argument. This function is totally broken, so most (all?) of the
+ * time it would return arrow == -1 anyway...?? [Skotlex]
+ arrow=pc_search_inventory(sd,pc_checkequip(sd,EQI_AMMO)); // Added by RoVeRT
+ if (itemdb_look(sd->status.inventory[n].nameid) == W_BOW && (arrow >= 0)){ // Added by RoVeRT
clif_arrowequip(sd,arrow);
- sd->status.inventory[arrow].equip=32768;
+ sd->status.inventory[arrow].equip=EQP_AMMO;
}
+*/
status_calc_pc(sd,0);
//OnEquip script [Skotlex]
if (sd->inventory_data[n]) {
@@ -6284,12 +6280,12 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag)
clif_unequipitemack(sd,n,0,0);
return 0;
}
- for(i=0;i<11;i++) {
+ for(i=0;i<EQI_MAX;i++) {
if(sd->status.inventory[n].equip & equip_pos[i])
sd->equip_index[i] = -1;
}
- if(sd->status.inventory[n].equip & 0x0002) {
+ if(sd->status.inventory[n].equip & EQP_HAND_R) {
sd->weapontype1 = 0;
sd->status.weapon = sd->weapontype2;
pc_calcweapontype(sd);
@@ -6297,29 +6293,29 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag)
if(sd->sc.data[SC_DANCING].timer!=-1) //When unequipping, stop dancing. [Skotlex]
skill_stop_dancing(&sd->bl);
}
- if(sd->status.inventory[n].equip & 0x0020) {
+ if(sd->status.inventory[n].equip & EQP_HAND_L) {
sd->status.shield = sd->weapontype2 = 0;
pc_calcweapontype(sd);
clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield);
}
- if(sd->status.inventory[n].equip & 0x0001) {
+ if(sd->status.inventory[n].equip & EQP_HEAD_LOW) {
sd->status.head_bottom = 0;
clif_changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
}
- if(sd->status.inventory[n].equip & 0x0100) {
+ if(sd->status.inventory[n].equip & EQP_HEAD_TOP) {
sd->status.head_top = 0;
clif_changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
}
- if(sd->status.inventory[n].equip & 0x0200) {
+ if(sd->status.inventory[n].equip & EQP_HEAD_MID) {
sd->status.head_mid = 0;
clif_changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
}
- if(sd->status.inventory[n].equip & 0x0040)
+ if(sd->status.inventory[n].equip & EQP_SHOES)
clif_changelook(&sd->bl,LOOK_SHOES,0);
clif_unequipitemack(sd,n,sd->status.inventory[n].equip,1);
- if((sd->status.inventory[n].equip&0x0022) &&
+ if((sd->status.inventory[n].equip & EQP_WEAPON) &&
sd->weapontype1 == 0 && sd->weapontype2 == 0)
skill_enchant_elemental_end(&sd->bl,-1);
diff --git a/src/map/pc.h b/src/map/pc.h
index 94613d114..6cfb9f532 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -40,6 +40,43 @@ enum {
MAX_WEAPON_TYPE
} weapon_type;
+//Equip position constants
+enum {
+ EQP_HEAD_LOW = 0x0001,
+ EQP_HEAD_MID = 0x0200, //512
+ EQP_HEAD_TOP = 0x0100, //256
+ EQP_HAND_R = 0x0002,
+ EQP_HAND_L = 0x0020, //32
+ EQP_ARMOR = 0x0010, //16
+ EQP_SHOES = 0x0040, //64
+ EQP_GARMENT = 0x0004,
+ EQP_ACC_L = 0x0008,
+ EQP_ACC_R = 0x0080, //128
+ EQP_AMMO = 0x8000, //32768
+} equip_pos_enum;
+
+#define EQP_WEAPON (EQP_HAND_R|EQP_HAND_L)
+#define EQP_SHIELD EQP_HAND_L
+#define EQP_HELM (EQP_HEAD_LOW|EQP_HEAD_MID|EQP_HEAD_TOP)
+#define EQP_ACC (EQP_ACC_L|EQP_ACC_R)
+
+//Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index
+//where the arrows are equipped)
+enum {
+ EQI_ACC_L = 0,
+ EQI_ACC_R,
+ EQI_SHOES,
+ EQI_GARMENT,
+ EQI_HEAD_LOW,
+ EQI_HEAD_MID,
+ EQI_HEAD_TOP,
+ EQI_ARMOR,
+ EQI_HAND_L,
+ EQI_HAND_R,
+ EQI_AMMO,
+ EQI_MAX
+} equip_index_enum;
+
#define pc_setdead(sd) ((sd)->state.dead_sit = (sd)->vd.dead_sit = 1)
#define pc_setsit(sd) ((sd)->state.dead_sit = (sd)->vd.dead_sit = 2)
#define pc_isdead(sd) ((sd)->state.dead_sit == 1)
diff --git a/src/map/pet.c b/src/map/pet.c
index 0bde801ae8..4653ec814 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -451,7 +451,7 @@ int pet_birth_process(struct map_session_data *sd)
intif_save_petdata(sd->status.account_id,&sd->pet);
if (save_settings&8)
- chrif_save(sd,0); //FIXME: As before, is it REALLY Needed to save the char for hatching a pet? [Skotlex]
+ chrif_save(sd,0); //is it REALLY Needed to save the char for hatching a pet? [Skotlex]
map_addblock(&sd->pd->bl);
clif_spawn(&sd->pd->bl);
diff --git a/src/map/script.c b/src/map/script.c
index c666a7728..9244c00d3 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -4658,7 +4658,7 @@ int buildin_strcharinfo(struct script_state *st)
return 0;
}
-unsigned int equip[10]={0x0100,0x0010,0x0020,0x0002,0x0004,0x0040,0x0008,0x0080,0x0200,0x0001};
+unsigned int equip[10]={EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_GARMENT,EQP_SHOES,EQP_ACC_L,EQP_ACC_R,EQP_HEAD_MID,EQP_HEAD_LOW};
/*==========================================
* GetEquipID(Pos); Pos: 1-10
diff --git a/src/map/skill.c b/src/map/skill.c
index b87575768..8f16288c4 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -1609,20 +1609,20 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in
if (!where) //Nothing to break.
return 0;
if (sd) {
- for (i = 0; i < 11; i++) {
+ for (i = 0; i < EQI_MAX; i++) {
j = sd->equip_index[i];
if (j <= 0 || sd->status.inventory[j].attribute == 1 || !sd->inventory_data[j])
continue;
flag = 0;
switch(i) {
- case 6: //Upper Head
+ case EQI_HEAD_TOP: //Upper Head
flag = (where&EQP_HELM);
break;
- case 7: //Body
+ case EQI_ARMOR: //Body
flag = (where&EQP_ARMOR);
break;
- case 8: //Left/Right hands
- case 9:
+ case EQI_HAND_R: //Left/Right hands
+ case EQI_HAND_L:
flag = (
(where&EQP_WEAPON && sd->inventory_data[j]->type == 4) ||
(where&EQP_SHIELD && sd->inventory_data[j]->type == 5));
diff --git a/src/map/status.c b/src/map/status.c
index 8d7acaf93..09d6992b2 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -1618,15 +1618,15 @@ int status_calc_pc(struct map_session_data* sd,int first)
);
// Parse equipment.
- for(i=0;i<10;i++) {
+ for(i=0;i<EQI_MAX-1;i++) {
current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus]
if(index < 0)
continue;
- if(i == 9 && sd->equip_index[8] == index)
+ if(i == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index)
continue;
- if(i == 5 && sd->equip_index[4] == index)
+ if(i == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == index)
continue;
- if(i == 6 && (sd->equip_index[5] == index || sd->equip_index[4] == index))
+ if(i == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == index || sd->equip_index[EQI_HEAD_LOW] == index))
continue;
if(!sd->inventory_data[index])
continue;
@@ -1647,7 +1647,7 @@ int status_calc_pc(struct map_session_data* sd,int first)
if (wlv >= MAX_REFINE_BONUS)
wlv = MAX_REFINE_BONUS - 1;
- if(i == 8 && sd->status.inventory[index].equip == 0x20) {
+ if(i == EQI_HAND_L && sd->status.inventory[index].equip == EQP_HAND_L) {
wd = &sd->left_weapon; // Left-hand weapon
wa = status->lhw;
} else {
@@ -1692,8 +1692,8 @@ int status_calc_pc(struct map_session_data* sd,int first)
}
}
- if(sd->equip_index[10] >= 0){ // 矢
- index = sd->equip_index[10];
+ if(sd->equip_index[EQI_AMMO] >= 0){ // 矢
+ index = sd->equip_index[EQI_AMMO];
if(sd->inventory_data[index]){ // Arrows
sd->state.lr_flag = 2;
run_script(sd->inventory_data[index]->script,0,sd->bl.id,0);
@@ -1711,15 +1711,15 @@ int status_calc_pc(struct map_session_data* sd,int first)
status->def += (refinedef+50)/100;
//Parse Cards
- for(i=0;i<10;i++) {
+ for(i=0;i<EQI_MAX-1;i++) {
current_equip_item_index = index = sd->equip_index[i]; //We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus]
if(index < 0)
continue;
- if(i == 9 && sd->equip_index[8] == index)
+ if(i == EQI_HAND_R && sd->equip_index[EQI_HAND_L] == index)
continue;
- if(i == 5 && sd->equip_index[4] == index)
+ if(i == EQI_HEAD_MID && sd->equip_index[EQI_HEAD_LOW] == index)
continue;
- if(i == 6 && (sd->equip_index[5] == index || sd->equip_index[4] == index))
+ if(i == EQI_HEAD_TOP && (sd->equip_index[EQI_HEAD_MID] == index || sd->equip_index[EQI_HEAD_LOW] == index))
continue;
if(sd->inventory_data[index]) {
@@ -1754,7 +1754,7 @@ int status_calc_pc(struct map_session_data* sd,int first)
if(map_flag_gvg(sd->bl.m) && data->flag.no_equip&2)
continue;
}
- if(i == 8 && sd->status.inventory[index].equip == 0x20)
+ if(i == EQI_HAND_L && sd->status.inventory[index].equip == EQP_HAND_L)
{ //Left hand status.
sd->state.lr_flag = 1;
run_script(data->script,0,sd->bl.id,0);
diff --git a/src/map/vending.c b/src/map/vending.c
index 4a2de7ffc..6d26ef518 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -211,6 +211,7 @@ void vending_openvending(struct map_session_data *sd,int len,char *message,int f
clif_displaymessage (sd->fd, msg_txt(276));
return; //Can't vend in novending mapflag maps.
}
+
//check shopname len
if(message[0] == '\0')
return;