feat(Core/Common): add new helpers for time utility (#10207)

This commit is contained in:
Kargatum
2022-01-19 12:01:59 +07:00
committed by GitHub
parent b5ab409614
commit 259b9133f6
60 changed files with 732 additions and 341 deletions
@@ -417,9 +417,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
return source->GetMapId() == map_id.mapId;
case ACHIEVEMENT_CRITERIA_DATA_TYPE_NTH_BIRTHDAY:
{
time_t birthday_start = time_t(sWorld->getIntConfig(CONFIG_BIRTHDAY_TIME));
tm birthday_tm;
localtime_r(&birthday_start, &birthday_tm);
tm birthday_tm = Acore::Time::TimeBreakdown(sWorld->getIntConfig(CONFIG_BIRTHDAY_TIME));
// exactly N birthday
birthday_tm.tm_year += birthday_login.nth_birthday;
+7 -11
View File
@@ -15,6 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Player.h"
#include "AccountMgr.h"
#include "AchievementMgr.h"
#include "ArenaSpectator.h"
@@ -31,11 +32,11 @@
#include "CharacterCache.h"
#include "CharacterDatabaseCleaner.h"
#include "Chat.h"
#include "Config.h"
#include "CombatLogPackets.h"
#include "Common.h"
#include "ConditionMgr.h"
#include "Config.h"
#include "CreatureAI.h"
#include "CombatLogPackets.h"
#include "DatabaseEnv.h"
#include "DisableMgr.h"
#include "Formulas.h"
@@ -50,8 +51,8 @@
#include "GuildMgr.h"
#include "InstanceSaveMgr.h"
#include "InstanceScript.h"
#include "Language.h"
#include "LFGMgr.h"
#include "Language.h"
#include "Log.h"
#include "LootItemStorage.h"
#include "MapMgr.h"
@@ -62,11 +63,10 @@
#include "OutdoorPvPMgr.h"
#include "Pet.h"
#include "PetitionMgr.h"
#include "Player.h"
#include "QuestDef.h"
#include "QueryHolder.h"
#include "ReputationMgr.h"
#include "QuestDef.h"
#include "Realm.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
#include "SocialMgr.h"
#include "Spell.h"
@@ -15172,11 +15172,7 @@ void Player::_LoadBrewOfTheMonth(PreparedQueryResult result)
lastEventId = fields[0].GetUInt32();
}
time_t curtime = time(nullptr);
tm localTime;
localtime_r(&curtime, &localTime);
uint16 month = uint16(localTime.tm_mon);
uint16 month = static_cast<uint16>(Acore::Time::GetMonth());
uint16 eventId = month;
if (eventId < 9)
eventId += 3;
+1 -1
View File
@@ -21,8 +21,8 @@
#include "ArenaTeam.h"
#include "Battleground.h"
#include "CharacterCache.h"
#include "DatabaseEnvFwd.h"
#include "DBCStores.h"
#include "DatabaseEnvFwd.h"
#include "GroupReference.h"
#include "InstanceSaveMgr.h"
#include "Item.h"
@@ -15,9 +15,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Tokenize.h"
#include "StringConvert.h"
#include "Player.h"
#include "StringConvert.h"
#include "Tokenize.h"
/*********************************************************/
/*** PLAYER SETTINGS SYSTEM ***/
+1 -1
View File
@@ -40,9 +40,9 @@
#include "InstanceScript.h"
#include "Log.h"
#include "MapMgr.h"
#include "MovementGenerator.h"
#include "MoveSpline.h"
#include "MoveSplineInit.h"
#include "MovementGenerator.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
+2 -3
View File
@@ -1849,7 +1849,7 @@ void GameEventMgr::SetHolidayEventTime(GameEventData& event)
tm timeInfo;
if (singleDate)
{
localtime_r(&curTime, &timeInfo);
timeInfo = Acore::Time::TimeBreakdown(curTime);
timeInfo.tm_year -= 1; // First try last year (event active through New Year)
}
else
@@ -1873,8 +1873,7 @@ void GameEventMgr::SetHolidayEventTime(GameEventData& event)
}
else if (singleDate)
{
tm tmCopy;
localtime_r(&curTime, &tmCopy);
tm tmCopy = Acore::Time::TimeBreakdown(curTime);
int year = tmCopy.tm_year; // This year
tmCopy = timeInfo;
tmCopy.tm_year = year;
+1 -1
View File
@@ -20,8 +20,8 @@
#include "Item.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "Optional.h"
#include "Player.h"
#include "World.h"
#include "WorldPacket.h"
#include <set>
+1 -1
View File
@@ -16,8 +16,8 @@
*/
#include "BankPackets.h"
#include "Item.h"
#include "DBCStores.h"
#include "Item.h"
#include "Log.h"
#include "Opcodes.h"
#include "Player.h"
@@ -15,8 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "Chat.h"
#include "ScriptMgr.h"
Acore::ChatCommands::ChatCommandTable ScriptMgr::GetChatCommands()
{
@@ -15,9 +15,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Player.h"
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"
#include "Player.h"
void ScriptMgr::OnGlobalItemDelFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
{
@@ -15,8 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "OutdoorPvPMgr.h"
#include "ScriptMgr.h"
OutdoorPvP* ScriptMgr::CreateOutdoorPvP(OutdoorPvPData const* data)
{
+3 -3
View File
@@ -16,11 +16,11 @@
*/
#include "ScriptMgr.h"
#include "InstanceScript.h"
#include "ScriptSystem.h"
#include "SmartAI.h"
#include "SpellMgr.h"
#include "UnitAI.h"
#include "SmartAI.h"
#include "ScriptSystem.h"
#include "InstanceScript.h"
namespace
{
+6 -6
View File
@@ -18,13 +18,13 @@
#ifndef AllPackets_h__
#define AllPackets_h__
#include "CombatLogPackets.h"
#include "ChatPackets.h"
#include "CharacterPackets.h"
#include "MiscPackets.h"
#include "WorldStatePackets.h"
#include "TotemPackets.h"
#include "BankPackets.h"
#include "CharacterPackets.h"
#include "ChatPackets.h"
#include "CombatLogPackets.h"
#include "GuildPackets.h"
#include "MiscPackets.h"
#include "TotemPackets.h"
#include "WorldStatePackets.h"
#endif // AllPackets_h__
+1 -1
View File
@@ -18,8 +18,8 @@
#ifndef BankPackets_h__
#define BankPackets_h__
#include "Packet.h"
#include "ObjectGuid.h"
#include "Packet.h"
namespace WorldPackets
{
+1 -1
View File
@@ -18,8 +18,8 @@
#ifndef ChatPackets_h__
#define ChatPackets_h__
#include "Packet.h"
#include "ObjectGuid.h"
#include "Packet.h"
namespace WorldPackets
{
@@ -17,12 +17,12 @@
#ifndef GuildPackets_h__
#define GuildPackets_h__
#include "Packet.h"
#include "Guild.h"
#include "ObjectGuid.h"
#include "Packet.h"
#include "PacketUtilities.h"
#include <boost/container/static_vector.hpp>
#include <array>
#include <boost/container/static_vector.hpp>
namespace WorldPackets
{
@@ -18,8 +18,8 @@
#ifndef TotemPackets_h__
#define TotemPackets_h__
#include "Packet.h"
#include "ObjectGuid.h"
#include "Packet.h"
namespace WorldPackets
{
+1 -1
View File
@@ -17,10 +17,10 @@
#include "Opcodes.h"
#include "Log.h"
#include "Packets/AllPackets.h"
#include "WorldSession.h"
#include <iomanip>
#include <sstream>
#include "Packets/AllPackets.h"
template<class PacketClass, void(WorldSession::* HandlerFunction)(PacketClass&)>
class PacketHandler : public ClientOpcodeHandler
+2 -5
View File
@@ -20,12 +20,12 @@
*/
#include "Weather.h"
#include "MiscPackets.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "Util.h"
#include "World.h"
#include "WorldPacket.h"
#include "MiscPackets.h"
/// Create the Weather object
Weather::Weather(uint32 zone, WeatherData const* weatherChances)
@@ -89,10 +89,7 @@ bool Weather::ReGenerate()
//78 days between January 1st and March 20nd; 365/4=91 days by season
// season source http://aa.usno.navy.mil/data/docs/EarthSeasons.html
time_t gtime = sWorld->GetGameTime();
struct tm ltime;
localtime_r(&gtime, &ltime);
uint32 season = ((ltime.tm_yday - 78 + 365) / 91) % 4;
uint32 season = ((Acore::Time::GetDayInYear() - 78 + 365) / 91) % 4;
static char const* seasonName[WEATHER_SEASONS] = { "spring", "summer", "fall", "winter" };
LOG_DEBUG("weather", "Generating a change in %s weather for zone %u.", seasonName[season], m_zone);
+1 -1
View File
@@ -21,12 +21,12 @@
#include "WeatherMgr.h"
#include "Log.h"
#include "MiscPackets.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "Weather.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "MiscPackets.h"
#include <memory>
namespace WeatherMgr
-2
View File
@@ -587,8 +587,6 @@ public:
[[nodiscard]] virtual uint32 GetCleaningFlags() const = 0;
virtual void SetCleaningFlags(uint32 flags) = 0;
virtual void ResetEventSeasonalQuests(uint16 event_id) = 0;
virtual time_t GetNextTimeWithDayAndHour(int8 dayOfWeek, int8 hour) = 0;
virtual time_t GetNextTimeWithMonthAndHour(int8 month, int8 hour) = 0;
[[nodiscard]] virtual std::string const& GetRealmName() const = 0;
virtual void SetRealmName(std::string name) = 0;
virtual void RemoveOldCorpses() = 0;
+12 -57
View File
@@ -75,6 +75,7 @@
#include "SkillExtraItems.h"
#include "SmartAI.h"
#include "SpellMgr.h"
#include "TaskScheduler.h"
#include "TicketMgr.h"
#include "Transport.h"
#include "TransportMgr.h"
@@ -89,7 +90,6 @@
#include "WhoListCacheMgr.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "TaskScheduler.h"
#include <boost/asio/ip/address.hpp>
#include <cmath>
@@ -3044,55 +3044,10 @@ void World::_UpdateRealmCharCount(PreparedQueryResult resultCharCount)
}
}
// int8 dayOfWeek: 0 (sunday) to 6 (saturday)
time_t World::GetNextTimeWithDayAndHour(int8 dayOfWeek, int8 hour)
{
if (hour < 0 || hour > 23)
hour = 0;
time_t curr = time(nullptr);
tm localTm;
localtime_r(&curr, &localTm);
localTm.tm_hour = hour;
localTm.tm_min = 0;
localTm.tm_sec = 0;
uint32 add;
if (dayOfWeek < 0 || dayOfWeek > 6)
dayOfWeek = (localTm.tm_wday + 1) % 7;
if (localTm.tm_wday >= dayOfWeek)
add = (7 - (localTm.tm_wday - dayOfWeek)) * DAY;
else
add = (dayOfWeek - localTm.tm_wday) * DAY;
return mktime(&localTm) + add;
}
// int8 month: 0 (january) to 11 (december)
time_t World::GetNextTimeWithMonthAndHour(int8 month, int8 hour)
{
if (hour < 0 || hour > 23)
hour = 0;
time_t curr = time(nullptr);
tm localTm;
localtime_r(&curr, &localTm);
localTm.tm_mday = 1;
localTm.tm_hour = hour;
localTm.tm_min = 0;
localTm.tm_sec = 0;
if (month < 0 || month > 11)
{
month = (localTm.tm_mon + 1) % 12;
if (month == 0)
localTm.tm_year += 1;
}
else if (localTm.tm_mon >= month)
localTm.tm_year += 1;
localTm.tm_mon = month;
return mktime(&localTm);
}
void World::InitWeeklyQuestResetTime()
{
time_t wstime = time_t(sWorld->getWorldState(WS_WEEKLY_QUEST_RESET_TIME));
m_NextWeeklyQuestReset = wstime ? wstime : GetNextTimeWithDayAndHour(4, 6);
m_NextWeeklyQuestReset = wstime ? wstime : Acore::Time::GetNextTimeWithDayAndHour(4, 6);
if (!wstime)
sWorld->setWorldState(WS_WEEKLY_QUEST_RESET_TIME, uint64(m_NextWeeklyQuestReset));
}
@@ -3100,7 +3055,7 @@ void World::InitWeeklyQuestResetTime()
void World::InitDailyQuestResetTime()
{
time_t wstime = time_t(sWorld->getWorldState(WS_DAILY_QUEST_RESET_TIME));
m_NextDailyQuestReset = wstime ? wstime : GetNextTimeWithDayAndHour(-1, 6);
m_NextDailyQuestReset = wstime ? wstime : Acore::Time::GetNextTimeWithDayAndHour(-1, 6);
if (!wstime)
sWorld->setWorldState(WS_DAILY_QUEST_RESET_TIME, uint64(m_NextDailyQuestReset));
}
@@ -3108,7 +3063,7 @@ void World::InitDailyQuestResetTime()
void World::InitMonthlyQuestResetTime()
{
time_t wstime = time_t(sWorld->getWorldState(WS_MONTHLY_QUEST_RESET_TIME));
m_NextMonthlyQuestReset = wstime ? wstime : GetNextTimeWithMonthAndHour(-1, 6);
m_NextMonthlyQuestReset = wstime ? wstime : Acore::Time::GetNextTimeWithMonthAndHour(-1, 6);
if (!wstime)
sWorld->setWorldState(WS_MONTHLY_QUEST_RESET_TIME, uint64(m_NextMonthlyQuestReset));
}
@@ -3116,7 +3071,7 @@ void World::InitMonthlyQuestResetTime()
void World::InitRandomBGResetTime()
{
time_t wstime = time_t(sWorld->getWorldState(WS_BG_DAILY_RESET_TIME));
m_NextRandomBGReset = wstime ? wstime : GetNextTimeWithDayAndHour(-1, 6);
m_NextRandomBGReset = wstime ? wstime : Acore::Time::GetNextTimeWithDayAndHour(-1, 6);
if (!wstime)
sWorld->setWorldState(WS_BG_DAILY_RESET_TIME, uint64(m_NextRandomBGReset));
}
@@ -3125,7 +3080,7 @@ void World::InitCalendarOldEventsDeletionTime()
{
time_t now = time(nullptr);
time_t currentDeletionTime = getWorldState(WS_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME);
time_t nextDeletionTime = currentDeletionTime ? currentDeletionTime : GetNextTimeWithDayAndHour(-1, getIntConfig(CONFIG_CALENDAR_DELETE_OLD_EVENTS_HOUR));
time_t nextDeletionTime = currentDeletionTime ? currentDeletionTime : Acore::Time::GetNextTimeWithDayAndHour(-1, getIntConfig(CONFIG_CALENDAR_DELETE_OLD_EVENTS_HOUR));
// If the reset time saved in the worldstate is before now it means the server was offline when the reset was supposed to occur.
// In this case we set the reset time in the past and next world update will do the reset and schedule next one in the future.
@@ -3141,7 +3096,7 @@ void World::InitCalendarOldEventsDeletionTime()
void World::InitGuildResetTime()
{
time_t wstime = time_t(getWorldState(WS_GUILD_DAILY_RESET_TIME));
m_NextGuildReset = wstime ? wstime : GetNextTimeWithDayAndHour(-1, 6);
m_NextGuildReset = wstime ? wstime : Acore::Time::GetNextTimeWithDayAndHour(-1, 6);
if (!wstime)
sWorld->setWorldState(WS_GUILD_DAILY_RESET_TIME, uint64(m_NextGuildReset));
}
@@ -3155,7 +3110,7 @@ void World::ResetDailyQuests()
if (itr->second->GetPlayer())
itr->second->GetPlayer()->ResetDailyQuestStatus();
m_NextDailyQuestReset = GetNextTimeWithDayAndHour(-1, 6);
m_NextDailyQuestReset = Acore::Time::GetNextTimeWithDayAndHour(-1, 6);
sWorld->setWorldState(WS_DAILY_QUEST_RESET_TIME, uint64(m_NextDailyQuestReset));
// change available dailies
@@ -3190,7 +3145,7 @@ void World::ResetWeeklyQuests()
if (itr->second->GetPlayer())
itr->second->GetPlayer()->ResetWeeklyQuestStatus();
m_NextWeeklyQuestReset = GetNextTimeWithDayAndHour(4, 6);
m_NextWeeklyQuestReset = Acore::Time::GetNextTimeWithDayAndHour(4, 6);
sWorld->setWorldState(WS_WEEKLY_QUEST_RESET_TIME, uint64(m_NextWeeklyQuestReset));
// change available weeklies
@@ -3208,7 +3163,7 @@ void World::ResetMonthlyQuests()
if (itr->second->GetPlayer())
itr->second->GetPlayer()->ResetMonthlyQuestStatus();
m_NextMonthlyQuestReset = GetNextTimeWithMonthAndHour(-1, 6);
m_NextMonthlyQuestReset = Acore::Time::GetNextTimeWithMonthAndHour(-1, 6);
sWorld->setWorldState(WS_MONTHLY_QUEST_RESET_TIME, uint64(m_NextMonthlyQuestReset));
}
@@ -3234,7 +3189,7 @@ void World::ResetRandomBG()
if (itr->second->GetPlayer())
itr->second->GetPlayer()->SetRandomWinner(false);
m_NextRandomBGReset = GetNextTimeWithDayAndHour(-1, 6);
m_NextRandomBGReset = Acore::Time::GetNextTimeWithDayAndHour(-1, 6);
sWorld->setWorldState(WS_BG_DAILY_RESET_TIME, uint64(m_NextRandomBGReset));
}
@@ -3251,7 +3206,7 @@ void World::ResetGuildCap()
{
LOG_INFO("server.worldserver", "Guild Daily Cap reset.");
m_NextGuildReset = GetNextTimeWithDayAndHour(-1, 6);
m_NextGuildReset = Acore::Time::GetNextTimeWithDayAndHour(-1, 6);
sWorld->setWorldState(WS_GUILD_DAILY_RESET_TIME, uint64(m_NextGuildReset));
sGuildMgr->ResetTimes();
-3
View File
@@ -365,9 +365,6 @@ public:
void SetCleaningFlags(uint32 flags) override { m_CleaningFlags = flags; }
void ResetEventSeasonalQuests(uint16 event_id) override;
time_t GetNextTimeWithDayAndHour(int8 dayOfWeek, int8 hour) override; // pussywizard
time_t GetNextTimeWithMonthAndHour(int8 month, int8 hour) override; // pussywizard
[[nodiscard]] std::string const& GetRealmName() const override { return _realmName; } // pussywizard
void SetRealmName(std::string name) override { _realmName = name; } // pussywizard
+6 -18
View File
@@ -474,9 +474,7 @@ public:
Field* fields2 = banInfo->Fetch();
do
{
time_t timeBan = time_t(fields2[0].GetUInt32());
tm tmBan;
localtime_r(&timeBan, &tmBan);
tm tmBan = Acore::Time::TimeBreakdown(fields2[0].GetUInt32());
if (fields2[0].GetUInt32() == fields2[1].GetUInt32())
{
@@ -486,9 +484,7 @@ public:
}
else
{
time_t timeUnban = time_t(fields2[1].GetUInt32());
tm tmUnban;
localtime_r(&timeUnban, &tmUnban);
tm tmUnban = Acore::Time::TimeBreakdown(fields2[1].GetUInt32());
handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
accountName.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min,
@@ -562,9 +558,7 @@ public:
Field* banFields = banInfo->Fetch();
do
{
time_t timeBan = time_t(banFields[0].GetUInt32());
tm tmBan;
localtime_r(&timeBan, &tmBan);
tm tmBan = Acore::Time::TimeBreakdown(banFields[0].GetUInt32());
if (banFields[0].GetUInt32() == banFields[1].GetUInt32())
{
@@ -574,9 +568,7 @@ public:
}
else
{
time_t timeUnban = time_t(banFields[1].GetUInt32());
tm tmUnban;
localtime_r(&timeUnban, &tmUnban);
tm tmUnban = Acore::Time::TimeBreakdown(banFields[1].GetUInt32());
handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
char_name.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min,
@@ -640,9 +632,7 @@ public:
{
handler->SendSysMessage("-------------------------------------------------------------------------------");
Field* fields = result->Fetch();
time_t timeBan = time_t(fields[1].GetUInt32());
tm tmBan;
localtime_r(&timeBan, &tmBan);
tm tmBan = Acore::Time::TimeBreakdown(fields[1].GetUInt32());
if (fields[1].GetUInt32() == fields[2].GetUInt32())
{
handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
@@ -651,9 +641,7 @@ public:
}
else
{
time_t timeUnban = time_t(fields[2].GetUInt32());
tm tmUnban;
localtime_r(&timeUnban, &tmUnban);
tm tmUnban = Acore::Time::TimeBreakdown(fields[2].GetUInt32());
handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
fields[0].GetCString(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min,
tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min,
+2 -1
View File
@@ -33,6 +33,7 @@ EndScriptData */
#include "PlayerDump.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
#include "Timer.h"
#include "World.h"
#include "WorldSession.h"
@@ -182,7 +183,7 @@ public:
for (DeletedInfoList::const_iterator itr = foundList.begin(); itr != foundList.end(); ++itr)
{
std::string dateStr = TimeToTimestampStr(itr->deleteDate);
std::string dateStr = Acore::Time::TimeToTimestampStr(Seconds(itr->deleteDate));
if (!handler->GetSession())
handler->PSendSysMessage(LANG_CHARACTER_DELETED_LIST_LINE_CONSOLE,
+4 -3
View File
@@ -27,6 +27,7 @@
#include "Language.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "Timer.h"
using namespace Acore::ChatCommands;
@@ -111,12 +112,12 @@ public:
bool active = activeEvents.find(eventId) != activeEvents.end();
char const* activeStr = active ? handler->GetAcoreString(LANG_ACTIVE) : "";
std::string startTimeStr = TimeToTimestampStr(eventData.start);
std::string endTimeStr = TimeToTimestampStr(eventData.end);
std::string startTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.start));
std::string endTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.end));
uint32 delay = sGameEventMgr->NextCheck(eventId);
time_t nextTime = time(nullptr) + delay;
std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? TimeToTimestampStr(time(nullptr) + delay) : "-";
std::string nextStr = nextTime >= eventData.start && nextTime < eventData.end ? Acore::Time::TimeToTimestampStr(Seconds(time(nullptr) + delay)) : "-";
std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE, true);
std::string lengthStr = secsToTimeString(eventData.length * MINUTE, true);
+1 -1
View File
@@ -15,11 +15,11 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "Chat.h"
#include "Language.h"
#include "Log.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "WorldSession.h"
using namespace Acore::ChatCommands;
+1 -1
View File
@@ -15,12 +15,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "Chat.h"
#include "DatabaseEnv.h"
#include "GroupMgr.h"
#include "Language.h"
#include "Player.h"
#include "ScriptMgr.h"
using namespace Acore::ChatCommands;
+1 -8
View File
@@ -231,14 +231,7 @@ public:
handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), guild->GetLeaderGUID().GetCounter()); // Guild Master
}
// Format creation date
char createdDateStr[20];
time_t createdDate = guild->GetCreatedDate();
tm localTm;
localtime_r(&createdDate, &localTm);
strftime(createdDateStr, 20, "%Y-%m-%d %H:%M:%S", &localTm);
handler->PSendSysMessage(LANG_GUILD_INFO_CREATION_DATE, createdDateStr); // Creation Date
handler->PSendSysMessage(LANG_GUILD_INFO_CREATION_DATE, Acore::Time::TimeToHumanReadable(Seconds(guild->GetCreatedDate())).c_str()); // Creation Date
handler->PSendSysMessage(LANG_GUILD_INFO_MEMBER_COUNT, guild->GetMemberCount()); // Number of Members
handler->PSendSysMessage(LANG_GUILD_INFO_BANK_GOLD, guild->GetTotalBankMoney() / 100 / 100); // Bank Gold (in gold coins)
handler->PSendSysMessage(LANG_GUILD_INFO_MOTD, guild->GetMOTD().c_str()); // Message of the day
+1 -1
View File
@@ -15,10 +15,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "Chat.h"
#include "Language.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "WorldSession.h"
constexpr std::array<const char*, MAX_ITEM_SUBCLASS_CONTAINER> bagSpecsToString =
+2 -2
View File
@@ -23,12 +23,12 @@ Category: commandscripts
EndScriptData */
#include "Chat.h"
#include "DatabaseEnv.h"
#include "DBCStores.h"
#include "DatabaseEnv.h"
#include "Language.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "Language.h"
using namespace Acore::ChatCommands;
+2 -12
View File
@@ -39,8 +39,8 @@
#include "ScriptMgr.h"
#include "SpellAuras.h"
#include "TargetedMovementGenerator.h"
#include "WeatherMgr.h"
#include "Tokenize.h"
#include "WeatherMgr.h"
// TODO: this import is not necessary for compilation and marked as unused by the IDE
// however, for some reasons removing it would cause a damn linking issue
@@ -2556,17 +2556,7 @@ public:
do
{
Field* fields = result->Fetch();
// we have to manually set the string for mutedate
time_t sqlTime = fields[0].GetUInt32();
tm timeInfo;
char buffer[80];
// set it to string
localtime_r(&sqlTime, &timeInfo);
strftime(buffer, sizeof(buffer), "%Y-%m-%d %I:%M%p", &timeInfo);
handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_OUTPUT, buffer, fields[1].GetUInt32(), fields[2].GetCString(), fields[3].GetCString());
handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_OUTPUT, Acore::Time::TimeToHumanReadable(Seconds(fields[0].GetUInt32())).c_str(), fields[1].GetUInt32(), fields[2].GetCString(), fields[3].GetCString());
} while (result->NextRow());
return true;
+2 -2
View File
@@ -15,15 +15,15 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "Chat.h"
#include "Language.h"
#include "Log.h"
#include "ObjectMgr.h"
#include "Pet.h"
#include "Player.h"
#include "SpellMgr.h"
#include "ScriptMgr.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
#include "WorldSession.h"
using namespace Acore::ChatCommands;
+1 -1
View File
@@ -15,7 +15,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "Chat.h"
#include "DatabaseEnv.h"
#include "Item.h"
@@ -24,6 +23,7 @@
#include "ObjectMgr.h"
#include "Pet.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "Tokenize.h"
using namespace Acore::ChatCommands;
+1 -1
View File
@@ -23,8 +23,8 @@ Category: commandscripts
EndScriptData */
#include "Chat.h"
#include "DatabaseEnv.h"
#include "DBCStores.h"
#include "DatabaseEnv.h"
#include "Group.h"
#include "Language.h"
#include "MapMgr.h"
@@ -15,9 +15,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "blackrock_depths.h"
#include "ScriptedCreature.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "blackrock_depths.h"
enum Spells
{
@@ -15,9 +15,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "blackrock_depths.h"
#include "ScriptedCreature.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "blackrock_depths.h"
enum Spells
{
@@ -15,9 +15,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "blackrock_depths.h"
#include "ScriptedCreature.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "blackrock_depths.h"
enum Spells
{
@@ -17,8 +17,8 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "blackrock_spire.h"
#include "TaskScheduler.h"
#include "blackrock_spire.h"
enum Texts
{
@@ -16,10 +16,10 @@
*/
#include "ScriptMgr.h"
#include "scholomance.h"
#include "ScriptedCreature.h"
#include "SpellScript.h"
#include "TaskScheduler.h"
#include "scholomance.h"
enum Spells
{
@@ -17,8 +17,8 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "stratholme.h"
#include "TaskScheduler.h"
#include "stratholme.h"
enum Texts
{
@@ -17,12 +17,12 @@
#include "Common.h"
#include "CreatureGroups.h"
#include "ScriptedCreature.h"
#include "ScriptedEscortAI.h"
#include "ScriptMgr.h"
#include "GameEventMgr.h"
#include "MotionMaster.h"
#include "ObjectAccessor.h"
#include "GameEventMgr.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedEscortAI.h"
enum COG_Paths
{
@@ -15,12 +15,12 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ObjectGuid.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "ScriptedEscortAI.h"
#include "ScriptedGossip.h"
#include "ObjectGuid.h"
/*######
## npc_ranger_lilatha
+2 -4
View File
@@ -532,11 +532,9 @@ struct npc_dark_iron_attack_generator : public ScriptedAI
bool AllowStart()
{
time_t curtime = time(nullptr);
tm strDate;
localtime_r(&curtime, &strDate);
auto minutes = Acore::Time::GetMinutes();
if (strDate.tm_min == 0 || strDate.tm_min == 30)
if (!minutes || minutes == 30)
return true;
return false;
@@ -17,8 +17,8 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "dire_maul.h"
#include "TaskScheduler.h"
#include "dire_maul.h"
enum Texts
{
@@ -22,8 +22,8 @@ SDComment: No model for submerging. Currently just invisible.
SDCategory: Temple of Ahn'Qiraj
EndScriptData */
#include "ScriptedCreature.h"
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "temple_of_ahnqiraj.h"
enum Spells
+1 -4
View File
@@ -1890,11 +1890,8 @@ public:
{
case EVENT_TIME:
{
// Get how many times it should ring
time_t t = time(nullptr);
tm local_tm;
tzset(); // set timezone for localtime_r() -> fix issues due to daylight time
localtime_r(&t, &local_tm);
tm local_tm = Acore::Time::TimeBreakdown();
uint8 _rings = (local_tm.tm_hour) % 12;
_rings = (_rings == 0) ? 12 : _rings; // 00:00 and 12:00
+4 -6
View File
@@ -119,9 +119,7 @@ public:
{
case EVENT_CLEARWATER_ANNOUNCE:
{
time_t curtime = time(nullptr);
tm strdate;
localtime_r(&curtime, &strdate);
tm strdate = Acore::Time::TimeBreakdown();
if (!preWarning && strdate.tm_hour == 13 && strdate.tm_min == 55)
{
@@ -268,14 +266,14 @@ public:
{
case EVENT_RIGGLE_ANNOUNCE:
{
time_t curtime = time(nullptr);
tm strdate;
localtime_r(&curtime, &strdate);
tm strdate = Acore::Time::TimeBreakdown();
if (!startWarning && strdate.tm_hour == 14 && strdate.tm_min == 0)
{
sCreatureTextMgr->SendChat(me, RIGGLE_SAY_START, 0, CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, TEXT_RANGE_ZONE);
startWarning = true;
}
if (!finishWarning && strdate.tm_hour == 16 && strdate.tm_min == 0)
{
sCreatureTextMgr->SendChat(me, RIGGLE_SAY_END, 0, CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, TEXT_RANGE_ZONE);
+2 -2
View File
@@ -19,6 +19,7 @@
#include "Errors.h"
#include "Log.h"
#include "MessageBuffer.h"
#include "Timer.h"
#include "Util.h"
#include <ctime>
#include <sstream>
@@ -136,8 +137,7 @@ void ByteBuffer::append(uint8 const* src, size_t cnt)
void ByteBuffer::AppendPackedTime(time_t time)
{
tm lt;
localtime_r(&time, &lt);
tm lt = Acore::Time::TimeBreakdown(time);
append<uint32>((lt.tm_year - 100) << 24 | lt.tm_mon << 20 | (lt.tm_mday - 1) << 14 | lt.tm_wday << 11 | lt.tm_hour << 6 | lt.tm_min);
}