mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 17:51:28 +00:00
[Bug Fix] Data Bucket Permanent Duration String (#2624)
# Notes - "F" or "f" weren't handled in this method, so they weren't working properly. - Most people don't provide this parameter when setting a permanent data bucket, so wasn't noticed in testing.
This commit is contained in:
parent
f7fb1c9fe1
commit
88e8b25fa1
@ -685,32 +685,37 @@ uint32 Strings::TimeToSeconds(std::string time_string)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 duration = 0;
|
time_string = Strings::ToLower(time_string);
|
||||||
|
|
||||||
std::transform(time_string.begin(), time_string.end(), time_string.begin(), ::tolower);
|
if (time_string == "f") {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
std::string time_unit = time_string;
|
std::string time_unit = time_string;
|
||||||
time_unit.erase(remove_if(time_unit.begin(), time_unit.end(), [](char c) { return !isdigit(c); }), time_unit.end());
|
|
||||||
|
time_unit.erase(
|
||||||
|
remove_if(
|
||||||
|
time_unit.begin(),
|
||||||
|
time_unit.end(),
|
||||||
|
[](char c) {
|
||||||
|
return !isdigit(c);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
time_unit.end()
|
||||||
|
);
|
||||||
|
|
||||||
auto unit = std::stoul(time_unit);
|
auto unit = std::stoul(time_unit);
|
||||||
|
uint32 duration = 0;
|
||||||
|
|
||||||
if (time_string.find('s') != std::string::npos) {
|
if (Strings::Contains(time_string, "s")) {
|
||||||
duration = unit;
|
duration = unit;
|
||||||
}
|
} else if (Strings::Contains(time_string, "m")) {
|
||||||
|
|
||||||
if (time_string.find('m') != std::string::npos) {
|
|
||||||
duration = unit * 60;
|
duration = unit * 60;
|
||||||
}
|
} else if (Strings::Contains(time_string, "h")) {
|
||||||
|
|
||||||
if (time_string.find('h') != std::string::npos) {
|
|
||||||
duration = unit * 3600;
|
duration = unit * 3600;
|
||||||
}
|
} else if (Strings::Contains(time_string, "d")) {
|
||||||
|
|
||||||
if (time_string.find('d') != std::string::npos) {
|
|
||||||
duration = unit * 86400;
|
duration = unit * 86400;
|
||||||
}
|
} else if (Strings::Contains(time_string, "y")) {
|
||||||
|
|
||||||
if (time_string.find('y') != std::string::npos) {
|
|
||||||
duration = unit * 31556926;
|
duration = unit * 31556926;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user