diff --git a/worldsrv/clock.go b/common/clock.go similarity index 77% rename from worldsrv/clock.go rename to common/clock.go index 63b3ea6..fc00b79 100644 --- a/worldsrv/clock.go +++ b/common/clock.go @@ -1,27 +1,26 @@ -package main +package common import ( "time" - "mongo.games.com/game/common" "mongo.games.com/goserver/core/module" ) -var ClockMgrSington = &ClockMgr{ +var ClockMgrSingleton = &ClockMgr{ LastHour: -1, LastDay: -1, Notifying: false, } const ( - CLOCK_EVENT_SECOND int = iota - CLOCK_EVENT_MINUTE - CLOCK_EVENT_HOUR - CLOCK_EVENT_DAY - CLOCK_EVENT_WEEK - CLOCK_EVENT_MONTH - CLOCK_EVENT_SHUTDOWN - CLOCK_EVENT_MAX + ClockEventSecond int = iota + ClockEventMinute + ClockEventHour + ClockEventDay + ClockEventWeek + ClockEventMonth + ClockEventShutdown + ClockEventMax ) type ClockSinker interface { @@ -38,7 +37,7 @@ type ClockSinker interface { type BaseClockSinker struct { } -func (s *BaseClockSinker) InterestClockEvent() int { return (1 << CLOCK_EVENT_MAX) - 1 } +func (s *BaseClockSinker) InterestClockEvent() int { return (1 << ClockEventMax) - 1 } func (s *BaseClockSinker) OnSecTimer() {} func (s *BaseClockSinker) OnMiniTimer() {} func (s *BaseClockSinker) OnHourTimer() {} @@ -48,7 +47,7 @@ func (s *BaseClockSinker) OnMonthTimer() {} func (s *BaseClockSinker) OnShutdown() {} type ClockMgr struct { - sinkers [CLOCK_EVENT_MAX][]ClockSinker + sinkers [ClockEventMax][]ClockSinker LastTickTime time.Time LastMonth time.Month LastWeek int @@ -60,9 +59,9 @@ type ClockMgr struct { LastFiveMin int } -func (this *ClockMgr) RegisteSinker(sinker ClockSinker) { +func (this *ClockMgr) RegisterSinker(sinker ClockSinker) { interest := sinker.InterestClockEvent() - for i := 0; i < CLOCK_EVENT_MAX; i++ { + for i := 0; i < ClockEventMax; i++ { if (1<