Quellcode durchsuchen

- Cleaned up some the code of pc_equipitem and clif_parse_EquipItem

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@10045 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex vor 18 Jahren
Ursprung
Commit
161ee3ac50
2 geänderte Dateien mit 31 neuen und 36 gelöschten Zeilen
  1. 14 10
      src/map/clif.c
  2. 17 26
      src/map/pc.c

+ 14 - 10
src/map/clif.c

@@ -9237,20 +9237,24 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd)
 	if(sd->sc.data[SC_BLADESTOP].timer!=-1 || sd->sc.data[SC_BERSERK].timer!=-1 )
 		return;
 
-	if(!sd->status.inventory[index].identify) {		// 未鑑定
+	if(!sd->status.inventory[index].identify) {
 		clif_equipitemack(sd,index,0,0);	// fail
 		return;
 	}
-	//ペット用装備であるかないか
-	if(sd->inventory_data[index]) {
-		if(sd->inventory_data[index]->type != IT_PETARMOR){
-			if(sd->inventory_data[index]->type == IT_AMMO)
-				pc_equipitem(sd,index,EQP_AMMO); //Client doesn't sends the position.
-			else
-				pc_equipitem(sd,index,RFIFOW(fd,4));
-		} else
-			pet_equipitem(sd,index);
+
+	if(!sd->inventory_data[index])
+		return;
+
+	if(sd->inventory_data[index]->type == IT_PETARMOR){
+		pet_equipitem(sd,index);
+		return;
 	}
+	
+	//Client doesn't sends the position for ammo.
+	if(sd->inventory_data[index]->type == IT_AMMO)
+		pc_equipitem(sd,index,EQP_AMMO);
+	else
+		pc_equipitem(sd,index,RFIFOW(fd,4));
 }
 
 /*==========================================

+ 17 - 26
src/map/pc.c

@@ -6419,25 +6419,25 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
 	sd->status.inventory[n].equip=pos;
 
 	if(pos & EQP_HAND_R) {
-		if(sd->inventory_data[n])
-			sd->weapontype1 = sd->inventory_data[n]->look;
+		if(id)
+			sd->weapontype1 = id->look;
 		else
 			sd->weapontype1 = 0;
 		pc_calcweapontype(sd);
 		clif_changelook(&sd->bl,LOOK_WEAPON,sd->status.weapon);
 	}
 	if(pos & EQP_HAND_L) {
-		if(sd->inventory_data[n]) {
-			if(sd->inventory_data[n]->type == IT_WEAPON) {
+		if(id) {
+			if(id->type == IT_WEAPON) {
 				sd->status.shield = 0;
 				if(sd->status.inventory[n].equip == EQP_HAND_L)
-					sd->weapontype2 = sd->inventory_data[n]->look;
+					sd->weapontype2 = id->look;
 				else
 					sd->weapontype2 = 0;
 			}
 			else
-			if(sd->inventory_data[n]->type == IT_ARMOR) {
-				sd->status.shield = sd->inventory_data[n]->look;
+			if(id->type == IT_ARMOR) {
+				sd->status.shield = id->look;
 				sd->weapontype2 = 0;
 			}
 		}
@@ -6449,22 +6449,22 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
 	//Added check to prevent sending the same look on multiple slots ->
 	//causes client to redraw item on top of itself. (suggested by Lupus)
 	if(pos & EQP_HEAD_LOW) {
-		if(sd->inventory_data[n] && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID)))
-			sd->status.head_bottom = sd->inventory_data[n]->look;
+		if(id && !(pos&(EQP_HEAD_TOP|EQP_HEAD_MID)))
+			sd->status.head_bottom = id->look;
 		else
 			sd->status.head_bottom = 0;
 		clif_changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom);
 	}
 	if(pos & EQP_HEAD_TOP) {
-		if(sd->inventory_data[n])
-			sd->status.head_top = sd->inventory_data[n]->look;
+		if(id)
+			sd->status.head_top = id->look;
 		else
 			sd->status.head_top = 0;
 		clif_changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top);
 	}
 	if(pos & EQP_HEAD_MID) {
-		if(sd->inventory_data[n] && !(pos&EQP_HEAD_TOP))
-			sd->status.head_mid = sd->inventory_data[n]->look;
+		if(id && !(pos&EQP_HEAD_TOP))
+			sd->status.head_mid = id->look;
 		else
 			sd->status.head_mid = 0;
 		clif_changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid);
@@ -6475,29 +6475,20 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
 	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=EQP_AMMO;
-	}
-*/
 	status_calc_pc(sd,0);
 	if (flag) //Update skill data
 		clif_skillinfoblock(sd);
 
 	//OnEquip script [Skotlex]
-	if (sd->inventory_data[n]) {
+	if (id) {
 		int i;
 		struct item_data *data;
-		if (sd->inventory_data[n]->equip_script)
-			run_script(sd->inventory_data[n]->equip_script,0,sd->bl.id,fake_nd->bl.id);
+		if (id->equip_script)
+			run_script(id->equip_script,0,sd->bl.id,fake_nd->bl.id);
 		if(itemdb_isspecial(sd->status.inventory[n].card[0]))
 			; //No cards
 		else
-		for(i=0;i<sd->inventory_data[n]->slot; i++)
+		for(i=0;i<id->slot; i++)
 		{
 			if (!sd->status.inventory[n].card[i])
 				continue;