mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-18 08:18:27 +00:00
[Quest API] Add commify to Perl/Lua. (#2099)
- Add quest::commify(number) to Perl. - Add eq.commify(number) to Lua.
This commit is contained in:
@@ -1265,3 +1265,24 @@ std::string ConvertMoneyToString(uint32 platinum, uint32 gold, uint32 silver, ui
|
||||
}
|
||||
return money_string;
|
||||
}
|
||||
|
||||
std::string commify(const std::string &number) {
|
||||
std::string temp_string;
|
||||
|
||||
auto string_length = static_cast<int>(number.length());
|
||||
|
||||
int i = 0;
|
||||
for (i = string_length - 3; i >= 0; i -= 3) {
|
||||
if (i > 0) {
|
||||
temp_string = "," + number.substr(static_cast<unsigned long>(i), 3) + temp_string;
|
||||
} else {
|
||||
temp_string = number.substr(static_cast<unsigned long>(i), 3) + temp_string;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < 0) {
|
||||
temp_string = number.substr(0, static_cast<unsigned long>(3 + i)) + temp_string;
|
||||
}
|
||||
|
||||
return temp_string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user