diff --git a/zone/command.cpp b/zone/command.cpp index eec6ff89c..01ab70256 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -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) || diff --git a/zone/gm_commands/date.cpp b/zone/gm_commands/date.cpp index 3e8aa2455..0154f233f 100755 --- a/zone/gm_commands/date.cpp +++ b/zone/gm_commands/date.cpp @@ -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(std::stoul(sep->arg[1])); + auto month = static_cast(std::stoul(sep->arg[2])); + auto day = static_cast(std::stoul(sep->arg[3])); + + auto hour = !sep->IsNumber(4) ? eq_time.hour : static_cast(std::stoul(sep->arg[4]) + 1); + auto minute = !sep->IsNumber(5) ? eq_time.minute : static_cast(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" + ) + ); }