Преглед изворни кода

- 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://svn.code.sf.net/p/rathena/svn/trunk@7550 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex пре 19 година
родитељ
комит
31832cfdc7
13 измењених фајлова са 147 додато и 122 уклоњено
  1. 3 0
      Changelog-Trunk.txt
  2. 1 1
      conf-tmpl/map_athena.conf
  3. 1 1
      src/map/atcommand.c
  4. 14 14
      src/map/charcommand.c
  5. 2 4
      src/map/map.c
  6. 1 11
      src/map/map.h
  7. 68 72
      src/map/pc.c
  8. 37 0
      src/map/pc.h
  9. 1 1
      src/map/pet.c
  10. 1 1
      src/map/script.c
  11. 5 5
      src/map/skill.c
  12. 12 12
      src/map/status.c
  13. 1 0
      src/map/vending.c

+ 3 - 0
Changelog-Trunk.txt

@@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/07/06
+	* 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 (now, does the client actually does this?) [Skotlex]
 	* Fixed GrandCross and similar skills. [Skotlex]
 	* FogWall will now also affect the caster. [Skotlex]
 2006/07/05

+ 1 - 1
conf-tmpl/map_athena.conf

@@ -98,7 +98,7 @@ autosave_time: 60
 // Apart from the autosave_time, players will also get saved when involved
 // in the following (add as needed):
 // 1: after every successful trade
-// 2: after very vending transaction
+// 2: after every vending transaction
 // 4: after closing storage/guild storage.
 // 8: After hatching/returning to egg a pet.
 // NOTE: These settings decrease the chance of dupes/lost items when there's a

+ 1 - 1
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))

+ 14 - 14
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';

+ 2 - 4
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;

+ 1 - 11
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);

+ 68 - 72
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);
 	

+ 37 - 0
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)

+ 1 - 1
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);

+ 1 - 1
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

+ 5 - 5
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));

+ 12 - 12
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);

+ 1 - 0
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;