rewrite into SeasonOverride

This commit is contained in:
wish
2023-07-16 21:57:29 +10:00
parent 568fa5e116
commit a98ebf5d52
4 changed files with 10 additions and 9 deletions

View File

@@ -45,7 +45,7 @@ func handleMsgSysGetFile(s *Session, p mhfpacket.MHFPacket) {
)
}
if s.server.erupeConfig.DevModeOptions.DynamicSeasons && s.server.erupeConfig.DevMode {
if s.server.erupeConfig.GameplayOptions.SeasonOverride {
pkt.Filename = seasonConversion(s, pkt.Filename)
}
@@ -69,11 +69,7 @@ func seasonConversion(s *Session, questFile string) string {
timeSet = "n"
}
// Determine the current season based on a modulus of the current time
sid := int64(((s.server.ID & 0xFF00) - 4096) / 256)
season := ((TimeAdjusted().Unix() / 86400) + sid) % 3
filename := fmt.Sprintf("%s%s%d", questFile[:5], timeSet, season)
filename := fmt.Sprintf("%s%s%d", questFile[:5], timeSet, s.server.Season())
// Return original file if file doesn't exist
if _, err := os.Stat(filename); err == nil {

View File

@@ -405,3 +405,8 @@ func (s *Server) NextSemaphoreID() uint32 {
}
return s.semaphoreIndex
}
func (s *Server) Season() uint8 {
sid := int64(((s.ID & 0xFF00) - 4096) / 256)
return uint8(((TimeAdjusted().Unix() / 86400) + sid) % 3)
}