mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 03:15:41 +00:00
feat(Core/Common): add new helpers for time utility (#10207)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user