The #time command is off by an hour. If you use #time it will return the current time, but that's one hour behind /time. This is because the code for #time counts from 0 to 23 (like a military clock) but eqTime.hour returns 1 - 24 due to the way the rest of EQ handles time.
This also happens when you use #time to set the time. If you say #time 23 then the time is set to 10pm (when it should be 11pm).
It's not really a bug and I'm sure that most people who use it are pretty good at taking it into account. However, I suck at it. I have enough trouble adding and subtracting 12 to get PM time in military time =P.
So, after that diatribe, the fix follows.
in zone\command.cpp we need to modify the command_time function from:
Code:
void command_time(Client *c, const Seperator *sep)
{
// image - Redone by Scruffy
char timeMessage[255];
int minutes=0;
if(sep->IsNumber(1)) {
if(sep->IsNumber(2)) {
minutes=atoi(sep->arg[2]);
}
c->Message(13, "Setting world time to %s:%i (Timezone: 0)...", sep->arg[1], minutes);
zone->SetTime(atoi(sep->arg[1]), minutes);
}
else {
c->Message(13, "To set the Time: #time HH [MM]");
TimeOfDay_Struct eqTime;
zone->zone_time.getEQTimeOfDay( time(0), &eqTime);
sprintf(timeMessage,"%02d:%s%d %s (Timezone: %ih %im)",
(eqTime.hour % 12) == 0 ? 12 : (eqTime.hour % 12),
(eqTime.minute < 10) ? "0" : "",
eqTime.minute,
(eqTime.hour >= 12) ? "pm" : "am",
zone->zone_time.getEQTimeZoneHr(),
zone->zone_time.getEQTimeZoneMin()
);
c->Message(13, "It is now %s.", timeMessage);
#if EQDEBUG >= 11
LogFile->write(EQEMuLog::Debug,"Recieved timeMessage:%s", timeMessage);
#endif
}
}
To (changes in red):
Code:
void command_time(Client *c, const Seperator *sep)
{
// image - Redone by Scruffy
char timeMessage[255];
int minutes=0;
if(sep->IsNumber(1)) {
if(sep->IsNumber(2)) {
minutes=atoi(sep->arg[2]);
}
c->Message(13, "Setting world time to %s:%i (Timezone: 0)...", sep->arg[1], minutes);
zone->SetTime(atoi(sep->arg[1])+1, minutes);
}
else {
c->Message(13, "To set the Time: #time HH [MM]");
TimeOfDay_Struct eqTime;
zone->zone_time.getEQTimeOfDay( time(0), &eqTime);
sprintf(timeMessage,"%02d:%s%d %s (Timezone: %ih %im)",
((eqTime.hour - 1) % 12) == 0 ? 12 : ((eqTime.hour - 1) % 12),
(eqTime.minute < 10) ? "0" : "",
eqTime.minute,
(eqTime.hour >= 13) ? "pm" : "am",
zone->zone_time.getEQTimeZoneHr(),
zone->zone_time.getEQTimeZoneMin()
);
c->Message(13, "It is now %s.", timeMessage);
#if EQDEBUG >= 11
LogFile->write(EQEMuLog::Debug,"Recieved timeMessage:%s", timeMessage);
#endif
}
}
I know there's some duplication of this code in zone\worldserver.cpp, so I assume that it can be changed as well. However I didn't test it. The change would be:
Code:
sprintf(timeMessage,"EQTime [%02d:%s%d %s]",
(eqTime.hour % 12) == 0 ? 12 : (eqTime.hour % 12),
(eqTime.minute < 10) ? "0" : "",
eqTime.minute,
(eqTime.hour >= 12) ? "pm" : "am"
);
To:
Code:
sprintf(timeMessage,"EQTime [%02d:%s%d %s]",
((eqTime.hour - 1) % 12) == 0 ? 12 : ((eqTime.hour - 1) % 12),
(eqTime.minute < 10) ? "0" : "",
eqTime.minute,
(eqTime.hour >= 13) ? "pm" : "am"
);