[Bug Fix] Fixed the discrepacy with time using command #time and in quests. (#3767)

* [BUG] Fixed the discrepacy with time using command #time and in quests. https://github.com/EQEmu/Server/issues/3700

* removed comments and paratheses from previous commit.

* fixed typos.

* made some adjustment so #time, /time, scripting, and log all match.

* Update lua_general.cpp
This commit is contained in:
regneq 2023-12-16 20:40:40 -08:00 committed by GitHub
parent 9739c1c8ef
commit 7e651877c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 19 deletions

View File

@ -434,7 +434,7 @@ int main(int argc, char **argv)
tod.year, tod.year,
tod.month, tod.month,
tod.day, tod.day,
tod.hour, tod.hour - 1,
tod.minute tod.minute
); );
} }

View File

@ -9,17 +9,11 @@ void SetTime(Client *c, const Seperator *sep)
TimeOfDay_Struct world_time{}; TimeOfDay_Struct world_time{};
zone->zone_time.GetCurrentEQTimeOfDay(time(0), &world_time); zone->zone_time.GetCurrentEQTimeOfDay(time(0), &world_time);
auto time_string = fmt::format(
"{} (Timezone: {})",
Strings::ZoneTime(world_time.hour, world_time.minute),
Strings::ZoneTime(zone->zone_time.getEQTimeZoneHr(), zone->zone_time.getEQTimeZoneHr())
);
c->Message( c->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
"It is currently {}.", "It is currently {}.",
time_string Strings::ZoneTime(world_time.hour - 1, world_time.minute)
).c_str() ).c_str()
); );
@ -27,15 +21,15 @@ void SetTime(Client *c, const Seperator *sep)
} }
uint8 minutes = 0; uint8 minutes = 0;
uint8 hours = Strings::ToUnsignedInt(sep->arg[2]) + 1; uint8 hours = Strings::ToUnsignedInt(sep->arg[2]);
if (hours > 24) { if (hours > 24) {
hours = 24; hours = 24;
} }
uint8 real_hours = ( uint8 real_hours = (
(hours - 1) > 0 ? hours > 0 ?
(hours - 1) : hours :
0 0
); );
@ -47,21 +41,20 @@ void SetTime(Client *c, const Seperator *sep)
} }
} }
c->Message( c->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
"Setting world time to {} (Timezone: {}).", "Setting world time to {}.",
Strings::ZoneTime(hours, minutes), Strings::ZoneTime(hours, minutes)
Strings::ZoneTime(zone->zone_time.getEQTimeZoneHr(), zone->zone_time.getEQTimeZoneHr())
).c_str() ).c_str()
); );
zone->SetTime(real_hours, minutes); zone->SetTime(real_hours, minutes);
LogInfo( LogInfo(
"{} :: Setting world time to {} (Timezone: {})", "{} :: Setting world time to {}.",
c->GetCleanName(), c->GetCleanName(),
Strings::ZoneTime(hours, minutes), Strings::ZoneTime(hours, minutes)
Strings::ZoneTime(zone->zone_time.getEQTimeZoneHr(), zone->zone_time.getEQTimeZoneHr())
); );
} }

View File

@ -1526,7 +1526,7 @@ void QuestManager::CreateGuild(const char *guild_name, const char *leader) {
void QuestManager::settime(uint8 new_hour, uint8 new_min, bool update_world /*= true*/) void QuestManager::settime(uint8 new_hour, uint8 new_min, bool update_world /*= true*/)
{ {
if (zone) if (zone)
zone->SetTime(new_hour + 1, new_min, update_world); zone->SetTime(new_hour, new_min, update_world);
} }
void QuestManager::itemlink(int item_id) { void QuestManager::itemlink(int item_id) {

View File

@ -1941,7 +1941,7 @@ void Zone::SetTime(uint8 hour, uint8 minute, bool update_world /*= true*/)
zone_time.GetCurrentEQTimeOfDay(time(0), &eq_time_of_day->start_eqtime); zone_time.GetCurrentEQTimeOfDay(time(0), &eq_time_of_day->start_eqtime);
eq_time_of_day->start_eqtime.minute = minute; eq_time_of_day->start_eqtime.minute = minute;
eq_time_of_day->start_eqtime.hour = hour; eq_time_of_day->start_eqtime.hour = hour + 1;
eq_time_of_day->start_realtime = time(0); eq_time_of_day->start_realtime = time(0);
/* By Default we update worlds time, but we can optionally no update world which updates the rest of the zone servers */ /* By Default we update worlds time, but we can optionally no update world which updates the rest of the zone servers */