mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +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:
parent
7154d5b841
commit
40edefa6f4
@ -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);
|
int days = int(timer_length / 86400000);
|
||||||
timer_length %= 86400000;
|
timer_length %= 86400000;
|
||||||
int hours = int(timer_length / 3600);
|
int hours = int(timer_length / 3600);
|
||||||
|
|||||||
@ -45,7 +45,10 @@ std::vector<std::string> wrap(std::vector<std::string> &src, std::string charact
|
|||||||
std::string implode(std::string glue, std::vector<std::string> src);
|
std::string implode(std::string glue, std::vector<std::string> src);
|
||||||
std::string convert2digit(int n, std::string suffix);
|
std::string convert2digit(int n, std::string suffix);
|
||||||
std::string numberToWords(unsigned long long int n);
|
std::string numberToWords(unsigned long long int n);
|
||||||
std::string ConvertSecondsToTime(int duration);
|
std::string ConvertSecondsToTime(int duration, bool is_milliseconds = false);
|
||||||
|
inline std::string ConvertMillisecondsToTime(int duration) {
|
||||||
|
return ConvertSecondsToTime(duration, true);
|
||||||
|
}
|
||||||
|
|
||||||
// For converstion of numerics into English
|
// For converstion of numerics into English
|
||||||
// Used for grid nodes, as NPC names remove numerals.
|
// Used for grid nodes, as NPC names remove numerals.
|
||||||
|
|||||||
@ -51,7 +51,7 @@ ZSList::~ZSList() {
|
|||||||
|
|
||||||
void ZSList::ShowUpTime(WorldTCPConnection* con, const char* adminname) {
|
void ZSList::ShowUpTime(WorldTCPConnection* con, const char* adminname) {
|
||||||
uint32 ms = Timer::GetCurrentTime();
|
uint32 ms = Timer::GetCurrentTime();
|
||||||
std::string time_string = ConvertSecondsToTime(ms);
|
std::string time_string = ConvertMillisecondsToTime(ms);
|
||||||
con->SendEmoteMessage(
|
con->SendEmoteMessage(
|
||||||
adminname,
|
adminname,
|
||||||
0,
|
0,
|
||||||
|
|||||||
@ -133,7 +133,7 @@ int command_init(void)
|
|||||||
command_add("bot", "- Type \"#bot help\" or \"^help\" to the see the list of available commands for bots.", AccountStatus::Player, command_bot) ||
|
command_add("bot", "- Type \"#bot help\" or \"^help\" to the see the list of available commands for bots.", AccountStatus::Player, command_bot) ||
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
command_add("camerashake", "Shakes the camera on everyone's screen globally.", AccountStatus::QuestTroupe, command_camerashake) ||
|
command_add("camerashake", "[Duration (Milliseconds)] [Intensity (1-10)] - Shakes the camera on everyone's screen globally.", AccountStatus::QuestTroupe, command_camerashake) ||
|
||||||
command_add("castspell", "[Spell ID] [Instant (0 = False, 1 = True, Default is 1 if Unused)] - Cast a spell", AccountStatus::Guide, command_castspell) ||
|
command_add("castspell", "[Spell ID] [Instant (0 = False, 1 = True, Default is 1 if Unused)] - Cast a spell", AccountStatus::Guide, command_castspell) ||
|
||||||
command_add("chat", "[channel num] [message] - Send a channel message to all zones", AccountStatus::GMMgmt, command_chat) ||
|
command_add("chat", "[channel num] [message] - Send a channel message to all zones", AccountStatus::GMMgmt, command_chat) ||
|
||||||
command_add("checklos", "- Check for line of sight to your target", AccountStatus::Guide, command_checklos) ||
|
command_add("checklos", "- Check for line of sight to your target", AccountStatus::Guide, command_checklos) ||
|
||||||
|
|||||||
@ -5,20 +5,29 @@ extern WorldServer worldserver;
|
|||||||
|
|
||||||
void command_camerashake(Client *c, const Seperator *sep)
|
void command_camerashake(Client *c, const Seperator *sep)
|
||||||
{
|
{
|
||||||
if (c) {
|
int arguments = sep->argnum;
|
||||||
if (sep->arg[1][0] && sep->arg[2][0]) {
|
if (!arguments || !sep->IsNumber(1) || !sep->IsNumber(2)) {
|
||||||
auto pack = new ServerPacket(ServerOP_CameraShake, sizeof(ServerCameraShake_Struct));
|
c->Message(Chat::Red, "Usage: #camerashake [Duration (Milliseconds)] [Intensity (1-10)]");
|
||||||
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])");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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()
|
target->GetID()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
ConvertSecondsToTime(duration)
|
ConvertMillisecondsToTime(duration)
|
||||||
) :
|
) :
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"You unstunned {}.",
|
"You unstunned {}.",
|
||||||
|
|||||||
@ -826,7 +826,7 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
|||||||
}
|
}
|
||||||
ServerUptime_Struct* sus = (ServerUptime_Struct*)pack->pBuffer;
|
ServerUptime_Struct* sus = (ServerUptime_Struct*)pack->pBuffer;
|
||||||
uint32 ms = Timer::GetCurrentTime();
|
uint32 ms = Timer::GetCurrentTime();
|
||||||
std::string time_string = ConvertSecondsToTime(ms);
|
std::string time_string = ConvertMillisecondsToTime(ms);
|
||||||
SendEmoteMessage(
|
SendEmoteMessage(
|
||||||
sus->adminname,
|
sus->adminname,
|
||||||
0,
|
0,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user