From a0fbfc248b9ea92e1b95472b41d42a322b89b47b Mon Sep 17 00:00:00 2001 From: wish Date: Sun, 26 Nov 2023 19:21:31 +1100 Subject: [PATCH] fix TimeWeekX inconsistencies & limit MezFes duration --- config.json | 1 + config/config.go | 1 + server/channelserver/handlers.go | 4 ++-- server/channelserver/sys_time.go | 7 +++++-- server/signserver/dsgn_resp.go | 3 ++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/config.json b/config.json index 2a9b06e6f..e945f8d33 100644 --- a/config.json +++ b/config.json @@ -65,6 +65,7 @@ "MaterialMultiplier": 1.00, "ExtraCarves": 0, "DisableHunterNavi": false, + "MezFesDuration": 172800, "EnableKaijiEvent": false, "EnableHiganjimaEvent": false, "EnableNierEvent": false, diff --git a/config/config.go b/config/config.go index 09991c84f..4d74accce 100644 --- a/config/config.go +++ b/config/config.go @@ -151,6 +151,7 @@ type GameplayOptions struct { MaterialMultiplier float32 // Adjusts the multiplier of Monster Materials rewarded for quest completion ExtraCarves uint16 // Grant n extra chances to carve ALL carcasses DisableHunterNavi bool // Disables the Hunter Navi + MezFesDuration int // Seconds that MezFes will last for weekly (from 12AM Mon backwards) EnableKaijiEvent bool // Enables the Kaiji event in the Rasta Bar EnableHiganjimaEvent bool // Enables the Higanjima event in the Rasta Bar EnableNierEvent bool // Enables the Nier event in the Rasta Bar diff --git a/server/channelserver/handlers.go b/server/channelserver/handlers.go index 154dbc100..e0d162b03 100644 --- a/server/channelserver/handlers.go +++ b/server/channelserver/handlers.go @@ -988,8 +988,8 @@ func handleMsgMhfKickExportForce(s *Session, p mhfpacket.MHFPacket) {} func handleMsgMhfGetEarthStatus(s *Session, p mhfpacket.MHFPacket) { pkt := p.(*mhfpacket.MsgMhfGetEarthStatus) bf := byteframe.NewByteFrame() - bf.WriteUint32(uint32(TimeWeekStart().Add(time.Hour * -24).Unix())) // Start - bf.WriteUint32(uint32(TimeWeekNext().Add(time.Hour * 24).Unix())) // End + bf.WriteUint32(uint32(TimeWeekStart().Unix())) // Start + bf.WriteUint32(uint32(TimeWeekNext().Unix())) // End bf.WriteInt32(s.server.erupeConfig.DevModeOptions.EarthStatusOverride) bf.WriteInt32(s.server.erupeConfig.DevModeOptions.EarthIDOverride) bf.WriteInt32(s.server.erupeConfig.DevModeOptions.EarthMonsterOverride) diff --git a/server/channelserver/sys_time.go b/server/channelserver/sys_time.go index a41b18b2e..bae61a1c6 100644 --- a/server/channelserver/sys_time.go +++ b/server/channelserver/sys_time.go @@ -16,8 +16,11 @@ func TimeMidnight() time.Time { func TimeWeekStart() time.Time { midnight := TimeMidnight() - offset := (int(midnight.Weekday()) - 1) * -24 - return midnight.Add(time.Hour * time.Duration(offset)) + offset := int(midnight.Weekday()) - int(time.Monday) + if offset < 0 { + offset += 7 + } + return midnight.Add(-time.Duration(offset) * 24 * time.Hour) } func TimeWeekNext() time.Time { diff --git a/server/signserver/dsgn_resp.go b/server/signserver/dsgn_resp.go index 77ac6468d..450dc7fc7 100644 --- a/server/signserver/dsgn_resp.go +++ b/server/signserver/dsgn_resp.go @@ -9,6 +9,7 @@ import ( "fmt" "go.uber.org/zap" "strings" + "time" ) func (s *Session) makeSignResponse(uid uint32) []byte { @@ -160,7 +161,7 @@ func (s *Session) makeSignResponse(uid uint32) []byte { // We can just use the start timestamp as the event ID bf.WriteUint32(uint32(channelserver.TimeWeekStart().Unix())) // Start time - bf.WriteUint32(uint32(channelserver.TimeWeekStart().Unix())) + bf.WriteUint32(uint32(channelserver.TimeWeekNext().Add(-time.Duration(s.server.erupeConfig.GameplayOptions.MezFesDuration) * time.Second).Unix())) // End time bf.WriteUint32(uint32(channelserver.TimeWeekNext().Unix())) bf.WriteUint8(2) // Unk