Pārlūkot izejas kodu

Fixed sell price calculation (#6775)

Fixes #6773
Additionally added some MAX_ZENY checks.

Thanks to @mazvi
Lemongrass3110 3 gadi atpakaļ
vecāks
revīzija
185344a252
1 mainītis faili ar 13 papildinājumiem un 3 dzēšanām
  1. 13 3
      src/map/itemdb.cpp

+ 13 - 3
src/map/itemdb.cpp

@@ -183,8 +183,10 @@ uint64 ItemDatabase::parseBodyNode(const ryml::NodeRef node) {
 			}
 
 			item->subtype = static_cast<e_card_type>(constant);
-		} else
+		} else {
 			this->invalidWarning(node["SubType"], "Item sub type is not supported for this item type.\n");
+			return 0;
+		}
 	} else {
 		if (!exists)
 			item->subtype = 0;
@@ -196,8 +198,12 @@ uint64 ItemDatabase::parseBodyNode(const ryml::NodeRef node) {
 		if (!this->asUInt32(node, "Buy", buy))
 			return 0;
 
+		if( buy > MAX_ZENY ){
+			this->invalidWarning( node["Buy"], "Buying price exceeds MAX_ZENY. Capping...\n" );
+			buy = MAX_ZENY;
+		}
+
 		item->value_buy = buy;
-		item->value_sell = 0;
 	} else {
 		if (!exists) {
 			item->value_buy = 0;
@@ -210,8 +216,12 @@ uint64 ItemDatabase::parseBodyNode(const ryml::NodeRef node) {
 		if (!this->asUInt32(node, "Sell", sell))
 			return 0;
 
+		if( sell > MAX_ZENY ){
+			this->invalidWarning( node["Sell"], "Sell price exceeds MAX_ZENY. Capping...\n" );
+			sell = MAX_ZENY;
+		}
+
 		item->value_sell = sell;
-		item->value_buy = 0;
 	} else {
 		if (!exists) {
 			item->value_sell = 0;