Apply suggestions from code review
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
This commit is contained in:
@@ -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)
|
||||
###########################################################################
|
||||
|
||||
|
||||
@@ -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)
|
||||
###########################################################################
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user