mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 00:46:46 +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:
@@ -5,20 +5,29 @@ extern WorldServer worldserver;
|
||||
|
||||
void command_camerashake(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (c) {
|
||||
if (sep->arg[1][0] && sep->arg[2][0]) {
|
||||
auto pack = new ServerPacket(ServerOP_CameraShake, sizeof(ServerCameraShake_Struct));
|
||||
ServerCameraShake_Struct *scss = (ServerCameraShake_Struct *) pack->pBuffer;
|
||||
scss->duration = atoi(sep->arg[1]);
|
||||
scss->intensity = atoi(sep->arg[2]);
|
||||
worldserver.SendPacket(pack);
|
||||
c->Message(Chat::Red, "Successfully sent the packet to world! Shake it, world, shake it!");
|
||||
safe_delete(pack);
|
||||
}
|
||||
else {
|
||||
c->Message(Chat::Red, "Usage -- #camerashake [duration], [intensity [1-10])");
|
||||
}
|
||||
int arguments = sep->argnum;
|
||||
if (!arguments || !sep->IsNumber(1) || !sep->IsNumber(2)) {
|
||||
c->Message(Chat::Red, "Usage: #camerashake [Duration (Milliseconds)] [Intensity (1-10)]");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
auto duration = std::stoi(sep->arg[1]);
|
||||
auto intensity = std::stoi(sep->arg[2]);
|
||||
|
||||
auto pack = new ServerPacket(ServerOP_CameraShake, sizeof(ServerCameraShake_Struct));
|
||||
ServerCameraShake_Struct *camera_shake = (ServerCameraShake_Struct *) pack->pBuffer;
|
||||
camera_shake->duration = duration;
|
||||
camera_shake->intensity = intensity;
|
||||
worldserver.SendPacket(pack);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Sending camera shake to world with a duration of {} ({}) and an intensity of {}.",
|
||||
ConvertMillisecondsToTime(duration),
|
||||
duration,
|
||||
intensity
|
||||
).c_str()
|
||||
);
|
||||
safe_delete(pack);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ void command_stun(Client *c, const Seperator *sep)
|
||||
target->GetID()
|
||||
)
|
||||
),
|
||||
ConvertSecondsToTime(duration)
|
||||
ConvertMillisecondsToTime(duration)
|
||||
) :
|
||||
fmt::format(
|
||||
"You unstunned {}.",
|
||||
|
||||
Reference in New Issue
Block a user