浏览代码

Apply suggestions from code review

Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Cydh Ramdh 3 年之前
父节点
当前提交
98cf69206a
共有 4 个文件被更改,包括 17 次插入20 次删除
  1. 3 3
      conf/import-tmpl/tax.yml
  2. 4 4
      conf/tax.yml
  3. 6 9
      src/map/buyingstore.cpp
  4. 4 4
      src/map/tax.cpp

+ 3 - 3
conf/import-tmpl/tax.yml

@@ -16,7 +16,7 @@
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 #
 ###########################################################################
-# Import Tax Database
+# Tax Database
 ###########################################################################
 #
 # Tax Settings
@@ -24,10 +24,10 @@
 ###########################################################################
 # Type                Tax type. Valid types are TAX_SELLING for vending and TAX_BUYING for buyingstore.
 #   InTotal           Tax applied for total transaction. Supports unlimited entries.
-#     - MinimalValue  Amount of Zeny before Tax is applied. (Default: 0)
+#     - MinimalValue  Minimum Zeny value before Tax is applied. (Default: 0)
 #       Tax           Tax percentage applied to MinimalValue. (Default: 0)
 #   EachEntry         Tax by selling entry. Supports unlimited entries.
-#     - MinimalValue  Amount of Zeny before Tax is applied. (Default: 0)
+#     - MinimalValue  Minimum Zeny value before Tax is applied. (Default: 0)
 #       Tax           Tax percentage applied to MinimalValue. (Default: 0)
 ###########################################################################
 

+ 4 - 4
conf/tax.yml

@@ -1,5 +1,5 @@
 # This file is a part of rAthena.
-#   Copyright(C) 2019 rAthena Development Team
+#   Copyright(C) 2022 rAthena Development Team
 #   https://rathena.org - https://github.com/rathena
 #
 # This program is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 #
 ###########################################################################
-# Import Tax Database
+# Tax Database
 ###########################################################################
 #
 # Tax Settings
@@ -24,10 +24,10 @@
 ###########################################################################
 # Type                Tax type. Valid types are TAX_SELLING for vending and TAX_BUYING for buyingstore.
 #   InTotal           Tax applied for total transaction. Supports unlimited entries.
-#     - MinimalValue  Amount of Zeny before Tax is applied. (Default: 0)
+#     - MinimalValue  Minimum Zeny value before Tax is applied. (Default: 0)
 #       Tax           Tax percentage applied to MinimalValue. (Default: 0)
 #   EachEntry         Tax by selling entry. Supports unlimited entries.
-#     - MinimalValue  Amount of Zeny before Tax is applied. (Default: 0)
+#     - MinimalValue  Minimum Zeny value before Tax is applied. (Default: 0)
 #       Tax           Tax percentage applied to MinimalValue. (Default: 0)
 ###########################################################################
 

+ 6 - 9
src/map/buyingstore.cpp

@@ -337,21 +337,18 @@ static unsigned short buyinstore_tax_intotal(struct map_session_data* sd, const
 		return 0;
 
 	for (i = 0; i < count; i++) {
-		unsigned short nameid, amount, listidx;
-		int index;
-
-		index = RBUFW(itemlist, i * 6 + 0) - 2;
-		nameid = RBUFW(itemlist, i * 6 + 2);
-		amount = RBUFW(itemlist, i * 6 + 4);
+		const struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub* item = &itemlist[i];
 
-		if (amount <= 0)
+		if (item->amount <= 0)
 			continue;
 
-		ARR_FIND(0, sd->buyingstore.slots, listidx, sd->buyingstore.items[listidx].nameid == nameid);
+		int listidx;
+
+		ARR_FIND(0, sd->buyingstore.slots, listidx, sd->buyingstore.items[listidx].nameid == item->itemId);
 		if (listidx == sd->buyingstore.slots || sd->buyingstore.items[listidx].amount == 0)
 			continue;
 
-		total += ((double)sd->buyingstore.items[listidx].price * amount);
+		total += ((double)sd->buyingstore.items[listidx].price * item->amount);
 	}
 
 	return tax->taxPercentage(tax->total, total);

+ 4 - 4
src/map/tax.cpp

@@ -65,12 +65,12 @@ uint64 TaxDatabase::parseBodyNode(const YAML::Node &node) {
 			s_tax_entry entry = {};
 
 			if (!this->asUInt64(taxNode, "MinimalValue", entry.minimal)) {
-				this->invalidWarning(taxNode["MinimalValue"], "Invalid value, defaulting to 0.");
+				this->invalidWarning(taxNode["MinimalValue"], "Invalid value, defaulting to 0.\n");
 				entry.minimal = 0;
 			}
 
 			if (!this->asUInt16(taxNode, "Tax", entry.tax)) {
-				this->invalidWarning(taxNode["Tax"], "Invalid value, defaulting to 0.");
+				this->invalidWarning(taxNode["Tax"], "Invalid value, defaulting to 0.\n");
 				entry.tax = 0;
 			}
 
@@ -91,12 +91,12 @@ uint64 TaxDatabase::parseBodyNode(const YAML::Node &node) {
 			s_tax_entry entry = { 0 };
 
 			if (!this->asUInt64(taxNode, "MinimalValue", entry.minimal)) {
-				this->invalidWarning(taxNode["MinimalValue"], "Invalid value, defaulting to 0.");
+				this->invalidWarning(taxNode["MinimalValue"], "Invalid value, defaulting to 0.\n");
 				entry.minimal = 0;
 			}
 
 			if (!this->asUInt16(taxNode, "Tax", entry.tax)) {
-				this->invalidWarning(taxNode["Tax"], "Invalid value, defaulting to 0.");
+				this->invalidWarning(taxNode["Tax"], "Invalid value, defaulting to 0.\n");
 				entry.tax = 0;
 			}