Skip to content

Commit 84a1d3c

Browse files
committed
Start (client side) game clock at chosen Epoch (Unix) time at the same time each login
1 parent bced4b0 commit 84a1d3c

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

conf/mod-time_is_time.conf.dist

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ TimeIsTime.Announce = 1
2323
# Default: 1
2424
# Example: TimeIsTime.Enable = 1
2525
#####################################################################################################
26-
TimeIsTime.Enable = 1
26+
TimeIsTime.Enable = 1
2727

2828
# SpeedRate
2929
#####################################################################################################
@@ -41,3 +41,20 @@ TimeIsTime.Enable = 1
4141
# Example: TimeIsTime.SpeedRate = 1.0
4242
#####################################################################################################
4343
TimeIsTime.SpeedRate = 1.0
44+
45+
# TimeStart and HourOffset:
46+
#####################################################################################################
47+
# Start (client side) game clock at chosen Epoch (Unix) time at the same time each login
48+
# Default: 0 (Local Time)
49+
# Example: Based on the settings below, the GMT TimeStart and HourOffset would be:
50+
# TimeIsTime.TimeStart = 205364700
51+
# TimeIsTime.HourOffset = 5
52+
# City: Chicago, IL USA
53+
# Summer Solstice Date :: 06-20-2008
54+
# Sunrise = 05:15:27 :: 1213938927
55+
# Sunset = 20:29:01 :: 1213993741
56+
# Midday = 12:00:00 :: 1213963200
57+
# Midnight = 24:00:00 :: 1213920000
58+
#####################################################################################################
59+
TimeIsTime.TimeStart = 0
60+
TimeIsTime.HourOffset = 0

src/TimeIsTime.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
static bool stimeistime_enable,
1515
stimeistime_announce;
16-
static float stimeistime_speed_rate;
16+
static float stimeistime_speed_rate,
17+
stimeistime_hour_offset;
18+
static uint32 stimeistime_time_start;
1719

1820
class TimeIsTimeBeforeConfigLoad : public WorldScript {
1921
public:
@@ -24,6 +26,8 @@ class TimeIsTimeBeforeConfigLoad : public WorldScript {
2426
stimeistime_enable = sConfigMgr->GetBoolDefault("TimeIsTime.Enable", true);
2527
stimeistime_announce = sConfigMgr->GetBoolDefault("TimeIsTime.Announce", true);
2628
stimeistime_speed_rate = sConfigMgr->GetFloatDefault("TimeIsTime.SpeedRate", 1.0);
29+
stimeistime_hour_offset = sConfigMgr->GetFloatDefault("TimeIsTime.HourOffset", 1.0);
30+
stimeistime_time_start = sConfigMgr->GetIntDefault("TimeIsTime.TimeStart", 1.0);
2731
}
2832
};
2933

@@ -41,10 +45,17 @@ class TimeIsTime : public PlayerScript {
4145
if (!stimeistime_enable)
4246
return;
4347

44-
uint32 speed_time = ((sWorld->GetGameTime() - sWorld->GetUptime()) + (sWorld->GetUptime() * stimeistime_speed_rate));
48+
uint32 speed_time = ((sWorld->GetGameTime() - sWorld->GetUptime()) + (sWorld->GetUptime() * stimeistime_speed_rate));
49+
float hour_offset = stimeistime_hour_offset * 3600;
50+
uint32 time_start = stimeistime_time_start + hour_offset;
4551

4652
data.Initialize(SMSG_LOGIN_SETTIMESPEED, 4 + 4 + 4);
47-
data.AppendPackedTime(speed_time);
53+
if (stimeistime_time_start > 0) {
54+
data.AppendPackedTime(time_start);
55+
}
56+
else {
57+
data.AppendPackedTime(speed_time);
58+
}
4859
data << float(0.01666667f) * stimeistime_speed_rate;
4960
data << uint32(0);
5061

0 commit comments

Comments
 (0)