mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-18 04:08:27 +00:00
[Commands] Cleanup #camerashake Command. (#1787)
- Cleanup message and logic. - Fix ConvertSecondsToTime logic for milliseconds. - Add ConvertMillisecondsToTime inline function.
This commit is contained in:
+19
-2
@@ -1021,9 +1021,26 @@ std::vector<std::string> GetBadWords()
|
||||
};
|
||||
}
|
||||
|
||||
std::string ConvertSecondsToTime(int duration)
|
||||
std::string ConvertSecondsToTime(int duration, bool is_milliseconds)
|
||||
{
|
||||
int timer_length = duration;
|
||||
if (duration <= 0) {
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
if (is_milliseconds && duration < 1000) {
|
||||
return fmt::format(
|
||||
"{} Millisecond{}",
|
||||
duration,
|
||||
duration != 1 ? "s" : ""
|
||||
);
|
||||
}
|
||||
|
||||
int timer_length = (
|
||||
is_milliseconds ?
|
||||
static_cast<int>(std::ceil(static_cast<float>(duration) / 1000.0f)) :
|
||||
duration
|
||||
);
|
||||
|
||||
int days = int(timer_length / 86400000);
|
||||
timer_length %= 86400000;
|
||||
int hours = int(timer_length / 3600);
|
||||
|
||||
Reference in New Issue
Block a user