From 98cf69206adc2a3c0db78ebf73feec2d6ffcf4a9 Mon Sep 17 00:00:00 2001 From: Cydh Ramdh Date: Thu, 10 Feb 2022 08:03:36 +0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Aleos --- conf/import-tmpl/tax.yml | 6 +++--- conf/tax.yml | 8 ++++---- src/map/buyingstore.cpp | 15 ++++++--------- src/map/tax.cpp | 8 ++++---- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/conf/import-tmpl/tax.yml b/conf/import-tmpl/tax.yml index 636d75bdbd..49ba0b0c8d 100644 --- a/conf/import-tmpl/tax.yml +++ b/conf/import-tmpl/tax.yml @@ -16,7 +16,7 @@ # along with this program. If not, see . # ########################################################################### -# 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) ########################################################################### diff --git a/conf/tax.yml b/conf/tax.yml index aa78060a3f..1104ba2f8a 100644 --- a/conf/tax.yml +++ b/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 . # ########################################################################### -# 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) ########################################################################### diff --git a/src/map/buyingstore.cpp b/src/map/buyingstore.cpp index da98b58419..92f5d0d39a 100644 --- a/src/map/buyingstore.cpp +++ b/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; + const struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub* item = &itemlist[i]; - index = RBUFW(itemlist, i * 6 + 0) - 2; - nameid = RBUFW(itemlist, i * 6 + 2); - amount = RBUFW(itemlist, i * 6 + 4); - - 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); diff --git a/src/map/tax.cpp b/src/map/tax.cpp index 93191c60d1..42389edd27 100644 --- a/src/map/tax.cpp +++ b/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; }