Skip to content

Commit

Permalink
[core] Set m_TimeType at server startup, call TOTD change on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSolstice8 committed Feb 18, 2025
1 parent 8adfa5a commit ed4d844
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/common/vana_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <ctime>

#include "utils/zoneutils.h"
#include "vana_time.h"

CVanaTime::CVanaTime()
Expand Down Expand Up @@ -214,6 +215,53 @@ void CVanaTime::setCustomEpoch(int32 epoch)
{
m_customEpoch = epoch;
m_TimeType = SyncTime();

if (m_TimeType == TIME_NONE) // SyncTime wasn't on an exact hour, calculate current m_TimeType
{
switch(m_vHour + 1 % 24u)
{
case 23:
case 22:
case 21:
case 20:
m_TimeType = TIME_NIGHT;
break;
case 19:
case 18:
m_TimeType = TIME_EVENING;
break;
case 17:
m_TimeType = TIME_DUSK;
break;
case 16:
case 15:
case 14:
case 13:
case 12:
case 11:
case 10:
case 9:
case 8:
case 7:
m_TimeType = TIME_DAY;
break;
case 6:
m_TimeType = TIME_DAWN;
break;
case 5:
case 4:
m_TimeType = TIME_NEWDAY;
break;
case 3:
case 2:
case 1:
case 0:
m_TimeType = TIME_MIDNIGHT;
break;
}
}

zoneutils::TOTDChange(m_TimeType); // This tells the zones to spawn stuff based on time of day conditions (such as undead at night)
}

TIMETYPE CVanaTime::GetCurrentTOTD()
Expand Down

0 comments on commit ed4d844

Please sign in to comment.