소스 검색

- Rewrote pc_payzeny to not use doubles, it may more accurately prevent charging a player more zeny than they can withhold.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@8072 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 년 전
부모
커밋
ed76d50157
3개의 변경된 파일11개의 추가작업 그리고 7개의 파일을 삭제
  1. 2 0
      Changelog-Trunk.txt
  2. 6 5
      src/map/pc.c
  3. 3 2
      src/map/unit.c

+ 2 - 0
Changelog-Trunk.txt

@@ -4,6 +4,8 @@ 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/08/02
+	* Rewrote pc_payzeny to not use doubles, it may more accurately prevent
+	  charging a player more zeny than they can withhold. [Skotlex]
 	* Fixed failing to create Deadly Poison Bottles damaging 50% of your max
 	  life instead of 25% [Skotlex]
 	* Added the missing status-change flags to SC_FREEZE to signal it should

+ 6 - 5
src/map/pc.c

@@ -2516,16 +2516,17 @@ int pc_inventoryblank(struct map_session_data *sd)
  */
 int pc_payzeny(struct map_session_data *sd,int zeny)
 {
-	double z;
-
 	nullpo_retr(0, sd);
 
 	if(sd->state.finalsave)
 		return 1;
 
-	z = (double)sd->status.zeny;
-	if(sd->status.zeny<zeny || z - (double)zeny > MAX_ZENY)
-		return 1;
+	if (zeny > 0 && sd->status.zeny < zeny)
+		return 1; //Not enough.
+
+	if (zeny < 0 && sd->status.zeny > MAX_ZENY +zeny)
+		return 1; //Overflow
+
 	sd->status.zeny-=zeny;
 	clif_updatestatus(sd,SP_ZENY);
 

+ 3 - 2
src/map/unit.c

@@ -1724,9 +1724,10 @@ int unit_free(struct block_list *bl) {
 		}
 	} else if(bl->type == BL_MOB) {
 		struct mob_data *md = (struct mob_data*)bl;
-		if(md->deletetimer!=-1)
+		if(md->deletetimer!=-1) {
 			delete_timer(md->deletetimer,mob_timer_delete);
-		md->deletetimer=-1;
+			md->deletetimer=-1;
+		}
 		if(md->lootitem) {
 			aFree(md->lootitem);
 			md->lootitem=NULL;