Explorar el Código

- Fixed script engine allowing scripts to set a player's zeny to negative values.
- Fixed setting hide_woe_damage making even "miss" attacks seem to connect.
- Cleaned up pc_getzeny to not require doubles.
- When readjusting the fame-list, the last entry's id is also reset (may fix characters appearing more than once on it?)
- Some sign/unsigned comparison warning fixes.
- Some 'may be used unitialized' warning fixes.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@8273 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex hace 19 años
padre
commit
78475ffd1a
Se han modificado 8 ficheros con 35 adiciones y 40 borrados
  1. 7 0
      Changelog-Trunk.txt
  2. 3 1
      src/char/char.c
  3. 1 1
      src/char/int_party.c
  4. 3 1
      src/char_sql/char.c
  5. 1 1
      src/char_sql/int_party.c
  6. 4 4
      src/map/clif.c
  7. 15 31
      src/map/pc.c
  8. 1 1
      src/map/skill.c

+ 7 - 0
Changelog-Trunk.txt

@@ -3,6 +3,13 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2006/08/14
+	* Fixed script engine allowing scripts to set a player's zeny to negative
+	  values. [Skotlex]
+	* Fixed setting hide_woe_damage making even "miss" attacks seem to connect.
+	  [Skotlex]
+	* When readjusting the fame-list, the last entry's id is also reset (may
+	  fix characters appearing more than once on it?) [Skotlex]
 2006/08/13
 	* Removed @itemcheck as it was totally pointless. [Skotlex]
 	* Corrected states killer/killable being easily dispellable. [Skotlex]

+ 3 - 1
src/char/char.c

@@ -3064,7 +3064,9 @@ int parse_frommap(int fd) {
 					}
 					// If the player's already in the list, remove the entry and shift the following ones 1 step up
 					memmove(list+pos, list+pos+1, (size-pos-1) * sizeof(struct fame_list));
-					list[size-1].fame = 0; // At worst, the guy'll end up last (shouldn't happen if fame only goes up)
+					//Clear out last entry.
+					list[size-1].id = 0;
+					list[size-1].fame = 0;
 				}
 				// Find the position where the player has to be inserted
 				for(i = 0; i < size && fame < list[i].fame; i++);

+ 1 - 1
src/char/int_party.c

@@ -620,7 +620,7 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id) {
 	return 0;
 }
 
-int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id, unsigned short map, int online, int lv)
+int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv)
 {
 	struct party_data *p;
 	int i;

+ 3 - 1
src/char_sql/char.c

@@ -2918,7 +2918,9 @@ int parse_frommap(int fd) {
 					}
 					// If the player's already in the list, remove the entry and shift the following ones 1 step up
 					memmove(list+pos, list+pos+1, (size-pos-1) * sizeof(struct fame_list));
-					list[size-1].fame = 0; // At worst, the guy'll end up last (shouldn't happen if fame only goes up)
+					//Clear out last entry.
+					list[size-1].id = 0;
+					list[size-1].fame = 0;
 				}
 
 				// Find the position where the player has to be inserted

+ 1 - 1
src/char_sql/int_party.c

@@ -708,7 +708,7 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
 	return 0;
 }
 // When member goes to other map
-int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id, unsigned short map, int online, int lv)
+int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv)
 {
 	struct party_data *p;
 	int i;

+ 4 - 4
src/map/clif.c

@@ -4019,7 +4019,7 @@ int clif_damage(struct block_list *src,struct block_list *dst,unsigned int tick,
 	WBUFL(buf,14)=sdelay;
 	WBUFL(buf,18)=ddelay;
 	if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
-		WBUFW(buf,22)=div;
+		WBUFW(buf,22)=damage?div:0;
 		WBUFW(buf,27)=damage2?div:0;
 	} else {
 		WBUFW(buf,22)=(damage > SHRT_MAX)?SHRT_MAX:damage;
@@ -4544,7 +4544,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,
 	WBUFL(buf,16)=sdelay;
 	WBUFL(buf,20)=ddelay;
 	if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
-		WBUFW(buf,24)=div;
+		WBUFW(buf,24)=damage?div:0;
 	} else {
 		WBUFW(buf,24)=damage;
 	}
@@ -4575,7 +4575,7 @@ int clif_skill_damage(struct block_list *src,struct block_list *dst,
 	WBUFL(buf,16)=sdelay;
 	WBUFL(buf,20)=ddelay;
 	if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
-		WBUFL(buf,24)=div;
+		WBUFL(buf,24)=damage?div:0;
 	} else {
 		WBUFL(buf,24)=damage;
 	}
@@ -4635,7 +4635,7 @@ int clif_skill_damage2(struct block_list *src,struct block_list *dst,
 	WBUFW(buf,24)=dst->x;
 	WBUFW(buf,26)=dst->y;
 	if (battle_config.hide_woe_damage && map_flag_gvg(src->m)) {
-		WBUFW(buf,28)=div;
+		WBUFW(buf,28)=damage?div:0;
 	} else {
 		WBUFW(buf,28)=damage;
 	}

+ 15 - 31
src/map/pc.c

@@ -2548,11 +2548,11 @@ int pc_payzeny(struct map_session_data *sd,int zeny)
 	if(sd->state.finalsave)
 		return 1;
 
-	if (zeny > 0 && sd->status.zeny < zeny)
-		return 1; //Not enough.
+	if (zeny < 0)
+	  	return pc_getzeny(sd, -zeny);
 
-	if (zeny < 0 && sd->status.zeny > MAX_ZENY +zeny)
-		return 1; //Overflow
+	if (sd->status.zeny < zeny)
+		return 1; //Not enough.
 
 	sd->status.zeny-=zeny;
 	clif_updatestatus(sd,SP_ZENY);
@@ -2566,23 +2566,25 @@ int pc_payzeny(struct map_session_data *sd,int zeny)
  */
 int pc_getzeny(struct map_session_data *sd,int zeny)
 {
-	double z;
-
 	nullpo_retr(0, sd);
 
-	z = (double)sd->status.zeny;
-	if(z + (double)zeny > MAX_ZENY) {
-		zeny = 0;
-		sd->status.zeny = MAX_ZENY;
-	}
+	if(sd->state.finalsave)
+		return 1;
+
+	if(zeny < 0)
+		return pc_payzeny(sd, -zeny);
+
+	if (sd->status.zeny > MAX_ZENY -zeny)
+		return 1; //Overflow
+
 	sd->status.zeny+=zeny;
 	clif_updatestatus(sd,SP_ZENY);
+
 	if(zeny > 0 && sd->state.showzeny){
 		char output[255];
 		sprintf(output, "Gained %dz.", zeny);
 		clif_disp_onlyself(sd,output,strlen(output));
 	}
-
 	return 0;
 }
 
@@ -5244,25 +5246,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val)
 		sd->status.status_point = val;
 		break;
 	case SP_ZENY:
-		if(val <= MAX_ZENY) {
-			// MAX_ZENY 以下なら代入
-			sd->status.zeny = val;
-		} else {
-			sd->status.zeny = MAX_ZENY;
-			/* Could someone explain the comments below? I have no idea what they are trying to do... 
-			 * if you want to give someone so much zeny, just set their zeny to the max. [Skotlex]
-			if(sd->status.zeny > val) {
-				// Zeny が減少しているなら代入
-				sd->status.zeny = val;
-			} else if(sd->status.zeny <= MAX_ZENY) {
-				// Zeny が増加していて、現在の値がMAX_ZENY 以下ならMAX_ZENY
-				sd->status.zeny = MAX_ZENY;
-			} else {
-				// Zeny が増加していて、現在の値がMAX_ZENY より下なら増加分を無視
-				;
-			}
-			*/
-		}
+		sd->status.zeny = cap_value(val, 0, MAX_ZENY);
 		break;
 	case SP_BASEEXP:
 		if(pc_nextbaseexp(sd) > 0) {

+ 1 - 1
src/map/skill.c

@@ -10038,7 +10038,7 @@ int skill_unit_move_sub (struct block_list *bl, va_list ap)
 	struct skill_unit_group *group;
 	struct block_list *target;
 	unsigned int tick,flag,result;
-	int skill_id,unit_id;
+	int skill_id,unit_id=0; //Set to 0 to shut-up compiler warnings.
 
 	target=va_arg(ap,struct block_list*);
 	tick = va_arg(ap,unsigned int);