mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Commands] Cleanup #date Command. (#2228)
* [Commands] Cleanup #date Command. - Cleanup messages and logic. * Cleanup.
This commit is contained in:
parent
59f32b8d34
commit
57ac46d090
@ -112,7 +112,7 @@ int command_init(void)
|
||||
command_add("cvs", "Summary of client versions currently online.", AccountStatus::GMMgmt, command_cvs) ||
|
||||
command_add("damage", "[Amount] - Damage yourself or your target", AccountStatus::GMAdmin, command_damage) ||
|
||||
command_add("databuckets", "View|Delete [key] [limit]- View data buckets, limit 50 default or Delete databucket by key", AccountStatus::QuestTroupe, command_databuckets) ||
|
||||
command_add("date", "[yyyy] [mm] [dd] [HH] [MM] - Set EQ time", AccountStatus::EQSupport, command_date) ||
|
||||
command_add("date", "[Year] [Month] [Day] [Hour] [Minute] - Set EQ time (Hour and Minute are optional)", AccountStatus::EQSupport, command_date) ||
|
||||
command_add("dbspawn2", "[spawngroup] [respawn] [variance] - Spawn an NPC from a predefined row in the spawn2 table", AccountStatus::GMAdmin, command_dbspawn2) ||
|
||||
command_add("delacct", "[accountname] - Delete an account", AccountStatus::GMLeadAdmin, command_delacct) ||
|
||||
command_add("delpetition", "[petition number] - Delete a petition", AccountStatus::ApprenticeGuide, command_delpetition) ||
|
||||
|
||||
@ -2,28 +2,66 @@
|
||||
|
||||
void command_date(Client *c, const Seperator *sep)
|
||||
{
|
||||
//yyyy mm dd hh mm local
|
||||
if (sep->arg[3][0] == 0 || !sep->IsNumber(1) || !sep->IsNumber(2) || !sep->IsNumber(3)) {
|
||||
c->Message(Chat::Red, "Usage: #date yyyy mm dd [HH MM]");
|
||||
}
|
||||
else {
|
||||
int h = 0, m = 0;
|
||||
TimeOfDay_Struct eqTime;
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(time(0), &eqTime);
|
||||
if (!sep->IsNumber(4)) {
|
||||
h = eqTime.hour;
|
||||
}
|
||||
else {
|
||||
h = atoi(sep->arg[4]);
|
||||
}
|
||||
if (!sep->IsNumber(5)) {
|
||||
m = eqTime.minute;
|
||||
}
|
||||
else {
|
||||
m = atoi(sep->arg[5]);
|
||||
}
|
||||
c->Message(Chat::Red, "Setting world time to %s-%s-%s %i:%i...", sep->arg[1], sep->arg[2], sep->arg[3], h, m);
|
||||
zone->SetDate(atoi(sep->arg[1]), atoi(sep->arg[2]), atoi(sep->arg[3]), h, m);
|
||||
int arguments = sep->argnum;
|
||||
if (
|
||||
!arguments ||
|
||||
!sep->IsNumber(1) ||
|
||||
!sep->IsNumber(2) ||
|
||||
!sep->IsNumber(3)
|
||||
) {
|
||||
c->Message(Chat::White, "Usage: #date [Year] [Month] [Day] [Hour] [Minute]");
|
||||
return;
|
||||
}
|
||||
|
||||
TimeOfDay_Struct eq_time;
|
||||
zone->zone_time.GetCurrentEQTimeOfDay(time(0), &eq_time);
|
||||
|
||||
auto year = static_cast<uint16>(std::stoul(sep->arg[1]));
|
||||
auto month = static_cast<uint8>(std::stoul(sep->arg[2]));
|
||||
auto day = static_cast<uint8>(std::stoul(sep->arg[3]));
|
||||
|
||||
auto hour = !sep->IsNumber(4) ? eq_time.hour : static_cast<uint8>(std::stoul(sep->arg[4]) + 1);
|
||||
auto minute = !sep->IsNumber(5) ? eq_time.minute : static_cast<uint8>(std::stoul(sep->arg[5]));
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format("Setting world time to {}/{}/{} {:02}:{:02} {}.",
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
(
|
||||
(hour % 12) == 0 ?
|
||||
12 :
|
||||
(hour % 12)
|
||||
),
|
||||
minute,
|
||||
(
|
||||
hour >= 13 ?
|
||||
"PM" :
|
||||
"AM"
|
||||
)
|
||||
).c_str()
|
||||
);
|
||||
|
||||
zone->SetDate(year, month, day, hour, minute);
|
||||
|
||||
LogInfo(
|
||||
"{} :: Setting world time to {}/{}/{} {:02}:{:02} {}.",
|
||||
c->GetCleanName(),
|
||||
year,
|
||||
month,
|
||||
day,
|
||||
(
|
||||
(hour % 12) == 0 ?
|
||||
12 :
|
||||
(hour % 12)
|
||||
),
|
||||
minute,
|
||||
(
|
||||
hour >= 13 ?
|
||||
"PM" :
|
||||
"AM"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user