From 185344a2525dd6fa8a738bfd699b51fe19aea550 Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Sat, 2 Apr 2022 18:36:47 +0200 Subject: [PATCH] Fixed sell price calculation (#6775) Fixes #6773 Additionally added some MAX_ZENY checks. Thanks to @mazvi --- src/map/itemdb.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index 2e8d640fbc..6bbbfe82bc 100644 --- a/src/map/itemdb.cpp +++ b/src/map/itemdb.cpp @@ -183,8 +183,10 @@ uint64 ItemDatabase::parseBodyNode(const ryml::NodeRef node) { } item->subtype = static_cast(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;