Skip to content

Commit

Permalink
Removed unused Macros
Browse files Browse the repository at this point in the history
Moved Time vars to Common file
  • Loading branch information
Zyres committed Jul 14, 2019
1 parent 1f5290d commit 3a7149b
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 89 deletions.
4 changes: 2 additions & 2 deletions src/scripts/Battlegrounds/ArathiBasin.cpp
Expand Up @@ -921,7 +921,7 @@ void ArathiBasin::AssaultControlPoint(Player* pPlayer, uint32 Id)
}
}
}
sEventMgr.AddEvent(this, &ArathiBasin::CaptureControlPoint, Id, Team, EVENT_AB_CAPTURE_CP_1 + Id, MSTIME_MINUTE, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
sEventMgr.AddEvent(this, &ArathiBasin::CaptureControlPoint, Id, Team, EVENT_AB_CAPTURE_CP_1 + Id, TimeVarsMs::Minute, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
pPlayer->m_bgScore.MiscData[BG_SCORE_AB_BASES_ASSAULTED]++;
UpdatePvPData();
}
Expand All @@ -931,7 +931,7 @@ void ArathiBasin::AssaultControlPoint(Player* pPlayer, uint32 Id)
SendChatMessage(Team ? CHAT_MSG_BG_EVENT_HORDE : CHAT_MSG_BG_EVENT_ALLIANCE, pPlayer->getGuid(), "$N claims the %s! If left unchallenged, the %s will control it in 1 minute!", ControlPointNames[Id],
Team ? "Horde" : "Alliance");
PlaySoundToAll(8192);
sEventMgr.AddEvent(this, &ArathiBasin::CaptureControlPoint, Id, Team, EVENT_AB_CAPTURE_CP_1 + Id, MSTIME_MINUTE, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
sEventMgr.AddEvent(this, &ArathiBasin::CaptureControlPoint, Id, Team, EVENT_AB_CAPTURE_CP_1 + Id, TimeVarsMs::Minute, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/Battlegrounds/EyeOfTheStorm.cpp
Expand Up @@ -347,7 +347,7 @@ void EyeOfTheStorm::HookOnAreaTrigger(Player* plr, uint32 id)
// Remove player from battleground.
this->RemovePlayer(plr, false);
// Kick player from server.
plr->Kick(MSTIME_6SECONDS);
plr->Kick(TimeVarsMs::Second * 6);
return;
}
#endif
Expand Down
10 changes: 5 additions & 5 deletions src/scripts/Battlegrounds/StrandOfTheAncient.cpp
Expand Up @@ -598,8 +598,8 @@ void StrandOfTheAncient::HookFlagStand(Player* /*plr*/, GameObject* /*obj*/)
// time in seconds
void StrandOfTheAncient::SetTime(uint32 secs)
{
uint32 minutes = secs / TIME_MINUTE;
uint32 seconds = secs % TIME_MINUTE;
uint32 minutes = secs / TimeVars::Minute;
uint32 seconds = secs % TimeVars::Minute;
uint32 digits[3];
digits[0] = minutes;
digits[1] = seconds / 10;
Expand Down Expand Up @@ -782,7 +782,7 @@ void StrandOfTheAncient::PrepareRound()
p->castSpell(p, BG_PREPARATION, true);
}

sEventMgr.AddEvent(this, &StrandOfTheAncient::StartRound, EVENT_SOTA_START_ROUND, MSTIME_SECOND * 10, 1, 0);
sEventMgr.AddEvent(this, &StrandOfTheAncient::StartRound, EVENT_SOTA_START_ROUND, TimeVarsMs::Second * 10, 1, 0);
}
};

Expand All @@ -804,7 +804,7 @@ void StrandOfTheAncient::StartRound()

SetWorldState(WORLDSTATE_SOTA_TIMER_MINS, 10);
SetTime(ROUND_LENGTH);
sEventMgr.AddEvent(this, &StrandOfTheAncient::TimeTick, EVENT_SOTA_TIMER, MSTIME_SECOND * 1, 0, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
sEventMgr.AddEvent(this, &StrandOfTheAncient::TimeTick, EVENT_SOTA_TIMER, TimeVarsMs::Second * 1, 0, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
UpdatePvPData();
}

Expand Down Expand Up @@ -835,7 +835,7 @@ void StrandOfTheAncient::FinishRound()
void StrandOfTheAncient::Finish(uint32 winningteam)
{
sEventMgr.RemoveEvents(this);
sEventMgr.AddEvent(static_cast< CBattleground* >(this), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, MSTIME_SECOND * 120, 1, 0);
sEventMgr.AddEvent(static_cast< CBattleground* >(this), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, TimeVarsMs::Second * 120, 1, 0);
this->EndBattleground(winningteam == TEAM_ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE);
}

Expand Down
18 changes: 0 additions & 18 deletions src/shared/Common.Legacy.h
Expand Up @@ -20,24 +20,6 @@
#ifndef _COMMON_H
#define _COMMON_H

enum TimeVariables
{
TIME_SECOND = 1,
TIME_MINUTE = TIME_SECOND * 60,
TIME_HOUR = TIME_MINUTE * 60,
TIME_DAY = TIME_HOUR * 24,
TIME_MONTH = TIME_DAY * 30,
TIME_YEAR = TIME_MONTH * 12
};

enum MsTimeVariables
{
MSTIME_SECOND = 1000,
MSTIME_6SECONDS = MSTIME_SECOND * 6,
MSTIME_MINUTE = MSTIME_SECOND * 60,
MSTIME_HOUR = MSTIME_MINUTE * 60,
MSTIME_DAY = MSTIME_HOUR * 24
};

#include "AscemuServerDefines.hpp"

Expand Down
69 changes: 63 additions & 6 deletions src/shared/Common.hpp.in
Expand Up @@ -7,12 +7,6 @@ This file is released under the MIT license. See README-MIT for more information

#include "Common.Legacy.h"

#ifdef WIN32
#define RIGHT_MODE "rb"
#else
#define RIGHT_MODE "r"
#endif

#ifdef WIN32
#define LIBMASK ".dll";
#else
Expand All @@ -23,3 +17,66 @@ This file is released under the MIT license. See README-MIT for more information
#endif
#endif

// Time Variables
namespace TimeVars
{
enum
{
Second = 1,
Minute = Second * 60,
Hour = Minute * 60,
Day = Hour * 24,
Month = Day * 30,
Year = Month * 12
};
}

namespace TimeVarsMs
{
enum
{
Second = 1000,
Minute = Second * 60,
Hour = Minute * 60,
Day = Hour * 24
};
}

namespace TimeBitmask
{
enum
{
Minute = 0x0000003F,
Hour = 0x000007C0,
Weekday = 0x00003800,
Day = 0x000FC000,
Month = 0x00F00000,
Year = 0x1F000000
};
}

namespace TimeShiftmask
{
enum
{
Minute = 0,
Hour = 6,
Weekday = 11,
Day = 14,
Month = 20,
Year = 24
};
}

//\ brief: C++17 filesystem. It is currently experimental.
// On MSVC it is included wit <filesystem> (which includes <experimental/filesystem>
// On GCC and Clang you have to include <experimental/filesystem> and set the
// compilerflag =stdc++17 and link stdc++fs.
// We use the namespace fs to simplify it. On GCC it is v1.
#if (WIN32 || _WIN64)
#include <filesystem>
namespace fs = std::experimental::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem::v1;
#endif
10 changes: 5 additions & 5 deletions src/shared/Util.cpp
Expand Up @@ -279,15 +279,15 @@ namespace Util
Util::StringToLowerCase(time_var);

if (time_var.compare("y") == 0)
multiplier = TIME_YEAR;
multiplier = TimeVars::Year;
else if (time_var.compare("m") == 0)
multiplier = TIME_MONTH;
multiplier = TimeVars::Month;
else if (time_var.compare("d") == 0)
multiplier = TIME_DAY;
multiplier = TimeVars::Day;
else if (time_var.compare("h") == 0)
multiplier = TIME_HOUR;
multiplier = TimeVars::Hour;
else
multiplier = TIME_MINUTE;
multiplier = TimeVars::Minute;

time_period = (multiplier * time_period);

Expand Down
38 changes: 0 additions & 38 deletions src/shared/Util.hpp
Expand Up @@ -9,44 +9,6 @@ This file is released under the MIT license. See README-MIT for more information
#include <chrono>
#include <iomanip>

//\ brief: C++17 filesystem. It is currently experimental.
// On MSVC it is included wit <filesystem> (which includes <experimental/filesystem>
// On GCC and Clang you have to include <experimental/filesystem> and set the
// compilerflag =stdc++17 and link stdc++fs.
// We use the namespace fs to simplify it. On GCC it is v1.
#if (WIN32 || _WIN64)
#include <filesystem>
namespace fs = std::experimental::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem::v1;
#endif

namespace TimeBitmask
{
enum
{
Minute = 0x0000003F,
Hour = 0x000007C0,
Weekday = 0x00003800,
Day = 0x000FC000,
Month = 0x00F00000,
Year = 0x1F000000
};
}

namespace TimeShiftmask
{
enum
{
Minute = 0,
Hour = 6,
Weekday = 11,
Day = 14,
Month = 20,
Year = 24
};
}

namespace Util
{
Expand Down
2 changes: 1 addition & 1 deletion src/world/Management/MailMgr.cpp
Expand Up @@ -139,7 +139,7 @@ void MailSystem::SendAutomatedMessage(uint32 type, uint64 sender, uint64 receive

// 30 days expiration time for unread mail + possible delivery delay.
if (!sMailSystem.MailOption(MAIL_FLAG_NO_EXPIRY))
msg.expire_time = (uint32)UNIXTIME + deliverdelay + (TIME_DAY * MAIL_DEFAULT_EXPIRATION_TIME);
msg.expire_time = (uint32)UNIXTIME + deliverdelay + (TimeVars::Day * MAIL_DEFAULT_EXPIRATION_TIME);
else
msg.expire_time = 0;

Expand Down
14 changes: 7 additions & 7 deletions src/world/Map/WorldCreator.cpp
Expand Up @@ -464,33 +464,33 @@ uint32 InstanceMgr::PreTeleport(uint32 mapid, Player* plr, uint32 instanceid)
if (worldConfig.instance.isRelativeExpirationEnabled)
{
if (inf->type == INSTANCE_MULTIMODE && in->m_difficulty == MODE_HEROIC)
in->m_expiration = UNIXTIME + TIME_DAY;
in->m_expiration = UNIXTIME + TimeVars::Day;
else
in->m_expiration = (inf->type == INSTANCE_NONRAID || (inf->type == INSTANCE_MULTIMODE && in->m_difficulty == MODE_NORMAL)) ? 0 : UNIXTIME + inf->cooldown;
}
else
{
if (inf->type == INSTANCE_MULTIMODE && in->m_difficulty >= MODE_HEROIC)
{
in->m_expiration = UNIXTIME - (UNIXTIME % TIME_DAY) + ((UNIXTIME % TIME_DAY) > (worldConfig.instance.relativeDailyHeroicInstanceResetHour * TIME_HOUR) ? 82800 : -3600) + ((worldConfig.instance.relativeDailyHeroicInstanceResetHour - worldConfig.server.gmtTimeZone) * TIME_HOUR);
in->m_expiration = UNIXTIME - (UNIXTIME % TimeVars::Day) + ((UNIXTIME % TimeVars::Day) > (worldConfig.instance.relativeDailyHeroicInstanceResetHour * TimeVars::Hour) ? 82800 : -3600) + ((worldConfig.instance.relativeDailyHeroicInstanceResetHour - worldConfig.server.gmtTimeZone) * TimeVars::Hour);
}
else if (IS_PERSISTENT_INSTANCE(in))
{
if (m_nextInstanceReset[in->m_mapId] == 0)
{
m_nextInstanceReset[in->m_mapId] = UNIXTIME - (UNIXTIME % TIME_DAY) - ((worldConfig.server.gmtTimeZone + 1) * TIME_HOUR) + (in->m_mapInfo->cooldown == 0 ? TIME_DAY : in->m_mapInfo->cooldown);
m_nextInstanceReset[in->m_mapId] = UNIXTIME - (UNIXTIME % TimeVars::Day) - ((worldConfig.server.gmtTimeZone + 1) * TimeVars::Hour) + (in->m_mapInfo->cooldown == 0 ? TimeVars::Day : in->m_mapInfo->cooldown);
CharacterDatabase.Execute("DELETE FROM server_settings WHERE setting_id LIKE 'next_instance_reset_%u';", in->m_mapId);
CharacterDatabase.Execute("INSERT INTO server_settings VALUES ('next_instance_reset_%u', '%u')", in->m_mapId, m_nextInstanceReset[in->m_mapId]);
}
if (m_nextInstanceReset[in->m_mapId] + (TIME_MINUTE * 15) < UNIXTIME)
if (m_nextInstanceReset[in->m_mapId] + (TimeVars::Minute * 15) < UNIXTIME)
{
do
{
time_t tmp = m_nextInstanceReset[in->m_mapId];
if (tmp + (TIME_MINUTE * 15) < UNIXTIME)
m_nextInstanceReset[in->m_mapId] = tmp + (in->m_mapInfo->cooldown == 0 ? TIME_DAY : in->m_mapInfo->cooldown);
if (tmp + (TimeVars::Minute * 15) < UNIXTIME)
m_nextInstanceReset[in->m_mapId] = tmp + (in->m_mapInfo->cooldown == 0 ? TimeVars::Day : in->m_mapInfo->cooldown);
}
while (m_nextInstanceReset[in->m_mapId] + (TIME_MINUTE * 15) < UNIXTIME);
while (m_nextInstanceReset[in->m_mapId] + (TimeVars::Minute * 15) < UNIXTIME);
CharacterDatabase.Execute("DELETE FROM server_settings WHERE setting_id LIKE 'next_instance_reset_%u';", in->m_mapId);
CharacterDatabase.Execute("INSERT INTO server_settings VALUES ('next_instance_reset_%u', '%u')", in->m_mapId, m_nextInstanceReset[in->m_mapId]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/world/Server/Packets/Handlers/MailHandler.cpp
Expand Up @@ -38,7 +38,7 @@ void WorldSession::handleMarkAsReadOpcode(WorldPacket& recvPacket)
mailMessage->checked_flag |= MAIL_CHECK_MASK_READ;

if (!sMailSystem.MailOption(MAIL_FLAG_NO_EXPIRY))
mailMessage->expire_time = static_cast<uint32_t>(UNIXTIME) + (TIME_DAY * 30);
mailMessage->expire_time = static_cast<uint32_t>(UNIXTIME) + (TimeVars::Day * 30);

CharacterDatabase.WaitExecute("UPDATE mailbox SET checked_flag = %u, expiry_time = %u WHERE message_id = %u",
mailMessage->checked_flag, mailMessage->expire_time, mailMessage->message_id);
Expand Down Expand Up @@ -542,7 +542,7 @@ void WorldSession::handleSendMailOpcode(WorldPacket& recvPacket)
msg.body = srlPacket.body;

if (!sMailSystem.MailOption(MAIL_FLAG_NO_EXPIRY))
msg.expire_time = static_cast<uint32_t>(UNIXTIME) + (TIME_DAY * MAIL_DEFAULT_EXPIRATION_TIME);
msg.expire_time = static_cast<uint32_t>(UNIXTIME) + (TimeVars::Day * MAIL_DEFAULT_EXPIRATION_TIME);
else
msg.expire_time = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/world/Spell/SpellAuras.Legacy.cpp
Expand Up @@ -3059,14 +3059,14 @@ void Aura::SpellAuraModStealth(bool apply)
case 31665:
case 31666:
{
tmp_duration = MSTIME_6SECONDS;
tmp_duration = TimeVarsMs::Second * 6;
} break;

//SPELL_HASH_OVERKILL
case 58426:
case 58427:
{
tmp_duration = MSTIME_SECOND * 20;
tmp_duration = TimeVarsMs::Second * 20;
} break;
}

Expand Down
2 changes: 1 addition & 1 deletion src/world/Spell/SpellProc_ClassScripts.cpp
Expand Up @@ -427,7 +427,7 @@ class CutToTheChaseSpellProc : public SpellProc
if (aura)
{
// Duration of 5 combo maximum
int32 dur = 21 * MSTIME_SECOND;
int32 dur = 21 * TimeVarsMs::Second;

spellModFlatIntValue(mTarget->SM_FDur, &dur, aura->GetSpellInfo()->getSpellFamilyFlags());
spellModPercentageIntValue(mTarget->SM_PDur, &dur, aura->GetSpellInfo()->getSpellFamilyFlags());
Expand Down
2 changes: 1 addition & 1 deletion src/world/Units/Summons/TotemSummon.cpp
Expand Up @@ -125,6 +125,6 @@ void TotemSummon::SetupSpells()
EnableAI();
m_aiInterface->totemspell = totemSpell;
m_aiInterface->m_totemspelltimer = 0;
m_aiInterface->m_totemspelltime = 3 * MSTIME_SECOND;
m_aiInterface->m_totemspelltime = 3 * TimeVarsMs::Second;
}
}

0 comments on commit 3a7149b

Please sign in to comment.