mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 07:18:37 +00:00
[Commands] Add #setaltcurrency Command. (#1850)
* [Commands] Add #setaltcurrency Command. - Add #setaltcurrency [Currency ID] [Amount] command to allow you to set a specific alternate currency to a value. - Add Zone::GetCurrencyID() and Zone::GetCurrencyItemID() helper methods. - Cleanup loops through zone->AlternateCurrencies. - Utilize helper methods where necessary. - Convert old methods parameters and return values from int to uint32 where necessary. * Typo.
This commit is contained in:
+33
-4
@@ -2421,10 +2421,9 @@ void Zone::LoadAlternateCurrencies()
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
{
|
||||
current_currency.id = atoi(row[0]);
|
||||
current_currency.item_id = atoi(row[1]);
|
||||
for (auto row : results) {
|
||||
current_currency.id = std::stoul(row[0]);
|
||||
current_currency.item_id = std::stoul(row[1]);
|
||||
AlternateCurrencies.push_back(current_currency);
|
||||
}
|
||||
|
||||
@@ -2744,3 +2743,33 @@ DynamicZone* Zone::GetDynamicZone()
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32 Zone::GetCurrencyID(uint32 item_id)
|
||||
{
|
||||
if (!item_id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (const auto& alternate_currency : AlternateCurrencies) {
|
||||
if (item_id == alternate_currency.item_id) {
|
||||
return alternate_currency.id;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 Zone::GetCurrencyItemID(uint32 currency_id)
|
||||
{
|
||||
if (!currency_id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (const auto& alternate_currency : AlternateCurrencies) {
|
||||
if (currency_id == alternate_currency.id) {
|
||||
return alternate_currency.item_id;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user