feat(Core/Events): update holiday code and remove misleading log (event date is the one from game_event) (#3365)

Cherry-picked https://github.com/TrinityCore/TrinityCore/commit/5b4287e6832da32539a49e68f6a5ab0ee55854b3

Co-authored-by: ariel- <ariel-@users.noreply.github.com>
Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
Stefano Borzì
2020-09-20 20:36:33 +02:00
committed by GitHub
parent a445cca4bc
commit 4e5440ad91
4 changed files with 96 additions and 73 deletions
@@ -24,7 +24,6 @@
#include "World.h" #include "World.h"
#include "Transport.h" #include "Transport.h"
#include "AccountMgr.h" #include "AccountMgr.h"
#ifdef ELUNA #ifdef ELUNA
#include "LuaEngine.h" #include "LuaEngine.h"
#endif #endif
@@ -72,7 +71,7 @@ GameObject::~GameObject()
} }
bool GameObject::AIM_Initialize() bool GameObject::AIM_Initialize()
{ {
if (m_AI) if (m_AI)
delete m_AI; delete m_AI;
@@ -86,12 +85,12 @@ bool GameObject::AIM_Initialize()
} }
std::string GameObject::GetAIName() const std::string GameObject::GetAIName() const
{ {
return sObjectMgr->GetGameObjectTemplate(GetEntry())->AIName; return sObjectMgr->GetGameObjectTemplate(GetEntry())->AIName;
} }
void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/) void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
{ {
if (GetTransport() && !ToTransport()) if (GetTransport() && !ToTransport())
{ {
GetTransport()->RemovePassenger(this); GetTransport()->RemovePassenger(this);
@@ -108,7 +107,7 @@ void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
} }
void GameObject::RemoveFromOwner() void GameObject::RemoveFromOwner()
{ {
uint64 ownerGUID = GetOwnerGUID(); uint64 ownerGUID = GetOwnerGUID();
if (!ownerGUID) if (!ownerGUID)
return; return;
@@ -133,7 +132,7 @@ void GameObject::RemoveFromOwner()
} }
void GameObject::AddToWorld() void GameObject::AddToWorld()
{ {
///- Register the gameobject for guid lookup ///- Register the gameobject for guid lookup
if (!IsInWorld()) if (!IsInWorld())
{ {
@@ -158,7 +157,7 @@ void GameObject::AddToWorld()
} }
void GameObject::RemoveFromWorld() void GameObject::RemoveFromWorld()
{ {
///- Remove the gameobject from the accessor ///- Remove the gameobject from the accessor
if (IsInWorld()) if (IsInWorld())
{ {
@@ -180,7 +179,7 @@ void GameObject::RemoveFromWorld()
} }
void GameObject::CheckRitualList() void GameObject::CheckRitualList()
{ {
if (m_unique_users.empty()) if (m_unique_users.empty())
return; return;
for (std::set<uint64>::iterator itr = m_unique_users.begin(); itr != m_unique_users.end();) for (std::set<uint64>::iterator itr = m_unique_users.begin(); itr != m_unique_users.end();)
@@ -204,7 +203,7 @@ void GameObject::CheckRitualList()
} }
void GameObject::ClearRitualList() void GameObject::ClearRitualList()
{ {
uint32 animSpell = GetGOInfo()->summoningRitual.animSpell; uint32 animSpell = GetGOInfo()->summoningRitual.animSpell;
if (!animSpell || m_unique_users.empty()) if (!animSpell || m_unique_users.empty())
return; return;
@@ -222,7 +221,7 @@ void GameObject::ClearRitualList()
} }
bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit) bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const& rotation, uint32 animprogress, GOState go_state, uint32 artKit)
{ {
ASSERT(map); ASSERT(map);
SetMap(map); SetMap(map);
@@ -273,7 +272,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map* map, uint32 phaseMa
SetWorldRotation(rotation); SetWorldRotation(rotation);
break; break;
default: default:
// xinef: hackfix - but make it possible to use original WorldRotation (using special gameobject addon data) // xinef: hackfix - but make it possible to use original WorldRotation (using special gameobject addon data)
// pussywizard: temporarily calculate WorldRotation from orientation, do so until values in db are correct // pussywizard: temporarily calculate WorldRotation from orientation, do so until values in db are correct
if (addon && addon->invisibilityType == INVISIBILITY_GENERAL && addon->InvisibilityValue == 0) if (addon && addon->invisibilityType == INVISIBILITY_GENERAL && addon->InvisibilityValue == 0)
SetWorldRotation(rotation); SetWorldRotation(rotation);
@@ -752,7 +751,7 @@ GameObjectTemplateAddon const* GameObject::GetTemplateAddon() const
} }
void GameObject::Refresh() void GameObject::Refresh()
{ {
// not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway) // not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway)
if (m_respawnTime > 0 && m_spawnedByDefault) if (m_respawnTime > 0 && m_spawnedByDefault)
return; return;
@@ -762,13 +761,13 @@ void GameObject::Refresh()
} }
void GameObject::AddUniqueUse(Player* player) void GameObject::AddUniqueUse(Player* player)
{ {
AddUse(); AddUse();
m_unique_users.insert(player->GetGUID()); m_unique_users.insert(player->GetGUID());
} }
void GameObject::Delete() void GameObject::Delete()
{ {
SetLootState(GO_NOT_READY); SetLootState(GO_NOT_READY);
RemoveFromOwner(); RemoveFromOwner();
@@ -791,7 +790,7 @@ void GameObject::Delete()
} }
void GameObject::getFishLoot(Loot* fishloot, Player* loot_owner) void GameObject::getFishLoot(Loot* fishloot, Player* loot_owner)
{ {
fishloot->clear(); fishloot->clear();
uint32 zone, subzone; uint32 zone, subzone;
@@ -804,7 +803,7 @@ void GameObject::getFishLoot(Loot* fishloot, Player* loot_owner)
{ {
//subzone no result,use zone loot //subzone no result,use zone loot
fishloot->FillLoot(zone, LootTemplates_Fishing, loot_owner, true, true); fishloot->FillLoot(zone, LootTemplates_Fishing, loot_owner, true, true);
//use zone 1 as default, somewhere fishing got nothing,becase subzone and zone not set, like Off the coast of Storm Peaks. //use zone 1 as default, somewhere fishing got nothing,becase subzone and zone not set, like Off the coast of Storm Peaks.
if (fishloot->empty()) if (fishloot->empty())
fishloot->FillLoot(defaultzone, LootTemplates_Fishing, loot_owner, true, true); fishloot->FillLoot(defaultzone, LootTemplates_Fishing, loot_owner, true, true);
} }
@@ -831,7 +830,7 @@ void GameObject::getFishLootJunk(Loot* fishloot, Player* loot_owner)
} }
void GameObject::SaveToDB() void GameObject::SaveToDB()
{ {
// this should only be used when the gameobject has already been loaded // this should only be used when the gameobject has already been loaded
// preferably after adding to map, because mapid may not be valid otherwise // preferably after adding to map, because mapid may not be valid otherwise
GameObjectData const* data = sObjectMgr->GetGOData(m_DBTableGuid); GameObjectData const* data = sObjectMgr->GetGOData(m_DBTableGuid);
@@ -845,7 +844,7 @@ void GameObject::SaveToDB()
} }
void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask) void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
{ {
const GameObjectTemplate* goI = GetGOInfo(); const GameObjectTemplate* goI = GetGOInfo();
if (!goI) if (!goI)
@@ -903,7 +902,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
} }
bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap) bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
{ {
GameObjectData const* data = sObjectMgr->GetGOData(guid); GameObjectData const* data = sObjectMgr->GetGOData(guid);
if (!data) if (!data)
@@ -969,7 +968,7 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
} }
void GameObject::DeleteFromDB() void GameObject::DeleteFromDB()
{ {
GetMap()->RemoveGORespawnTime(m_DBTableGuid); GetMap()->RemoveGORespawnTime(m_DBTableGuid);
sObjectMgr->DeleteGOData(m_DBTableGuid); sObjectMgr->DeleteGOData(m_DBTableGuid);
@@ -990,7 +989,7 @@ void GameObject::DeleteFromDB()
/*** QUEST SYSTEM ***/ /*** QUEST SYSTEM ***/
/*********************************************************/ /*********************************************************/
bool GameObject::hasQuest(uint32 quest_id) const bool GameObject::hasQuest(uint32 quest_id) const
{ {
QuestRelationBounds qr = sObjectMgr->GetGOQuestRelationBounds(GetEntry()); QuestRelationBounds qr = sObjectMgr->GetGOQuestRelationBounds(GetEntry());
for (QuestRelations::const_iterator itr = qr.first; itr != qr.second; ++itr) for (QuestRelations::const_iterator itr = qr.first; itr != qr.second; ++itr)
{ {
@@ -1001,7 +1000,7 @@ bool GameObject::hasQuest(uint32 quest_id) const
} }
bool GameObject::hasInvolvedQuest(uint32 quest_id) const bool GameObject::hasInvolvedQuest(uint32 quest_id) const
{ {
QuestRelationBounds qir = sObjectMgr->GetGOQuestInvolvedRelationBounds(GetEntry()); QuestRelationBounds qir = sObjectMgr->GetGOQuestInvolvedRelationBounds(GetEntry());
for (QuestRelations::const_iterator itr = qir.first; itr != qir.second; ++itr) for (QuestRelations::const_iterator itr = qir.first; itr != qir.second; ++itr)
{ {
@@ -1017,14 +1016,14 @@ bool GameObject::IsTransport() const
} }
bool GameObject::IsDestructibleBuilding() const bool GameObject::IsDestructibleBuilding() const
{ {
GameObjectTemplate const* gInfo = GetGOInfo(); GameObjectTemplate const* gInfo = GetGOInfo();
if (!gInfo) return false; if (!gInfo) return false;
return gInfo->type == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING; return gInfo->type == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING;
} }
Unit* GameObject::GetOwner() const Unit* GameObject::GetOwner() const
{ {
return ObjectAccessor::GetUnit(*this, GetOwnerGUID()); return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
} }
@@ -1046,7 +1045,7 @@ bool GameObject::IsNeverVisible() const
} }
bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const
{ {
if (WorldObject::IsAlwaysVisibleFor(seer)) if (WorldObject::IsAlwaysVisibleFor(seer))
return true; return true;
@@ -1074,7 +1073,7 @@ bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const
} }
bool GameObject::IsInvisibleDueToDespawn() const bool GameObject::IsInvisibleDueToDespawn() const
{ {
if (WorldObject::IsInvisibleDueToDespawn()) if (WorldObject::IsInvisibleDueToDespawn())
return true; return true;
@@ -1086,7 +1085,7 @@ bool GameObject::IsInvisibleDueToDespawn() const
} }
void GameObject::Respawn() void GameObject::Respawn()
{ {
if (m_spawnedByDefault && m_respawnTime > 0) if (m_spawnedByDefault && m_respawnTime > 0)
{ {
m_respawnTime = time(nullptr); m_respawnTime = time(nullptr);
@@ -1095,7 +1094,7 @@ void GameObject::Respawn()
} }
bool GameObject::ActivateToQuest(Player* target) const bool GameObject::ActivateToQuest(Player* target) const
{ {
if (target->HasQuestForGO(GetEntry())) if (target->HasQuestForGO(GetEntry()))
return true; return true;
@@ -1191,6 +1190,7 @@ GameObject* GameObject::LookupFishingHoleAround(float range)
{ {
GameObject* ok = nullptr; GameObject* ok = nullptr;
CellCoord p(acore::ComputeCellCoord(GetPositionX(), GetPositionY())); CellCoord p(acore::ComputeCellCoord(GetPositionX(), GetPositionY()));
Cell cell(p); Cell cell(p);
acore::NearestGameObjectFishingHole u_check(*this, range); acore::NearestGameObjectFishingHole u_check(*this, range);
@@ -1203,7 +1203,7 @@ GameObject* GameObject::LookupFishingHoleAround(float range)
} }
void GameObject::ResetDoorOrButton() void GameObject::ResetDoorOrButton()
{ {
if (m_lootState == GO_READY || m_lootState == GO_JUST_DEACTIVATED) if (m_lootState == GO_READY || m_lootState == GO_JUST_DEACTIVATED)
return; return;
@@ -1213,7 +1213,7 @@ void GameObject::ResetDoorOrButton()
} }
void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = false */, Unit* user /*=NULL*/) void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = false */, Unit* user /*=NULL*/)
{ {
if (m_lootState != GO_READY) if (m_lootState != GO_READY)
return; return;
@@ -1227,7 +1227,7 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore, bool alternative /* = f
} }
void GameObject::SetGoArtKit(uint8 kit) void GameObject::SetGoArtKit(uint8 kit)
{ {
SetByteValue(GAMEOBJECT_BYTES_1, 2, kit); SetByteValue(GAMEOBJECT_BYTES_1, 2, kit);
GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr->GetGOData(m_DBTableGuid)); GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr->GetGOData(m_DBTableGuid));
if (data) if (data)
@@ -1250,7 +1250,7 @@ void GameObject::SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid)
} }
void GameObject::SwitchDoorOrButton(bool activate, bool alternative /* = false */) void GameObject::SwitchDoorOrButton(bool activate, bool alternative /* = false */)
{ {
if (activate) if (activate)
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE); SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
else else
@@ -1479,14 +1479,14 @@ void GameObject::Use(Unit* user)
// this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389) // this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
if (info->goober.customAnim) if (info->goober.customAnim)
SendCustomAnim(GetGoAnimProgress()); SendCustomAnim(GetGoAnimProgress());
m_cooldownTime = World::GetGameTimeMS()+info->GetAutoCloseTime(); m_cooldownTime = World::GetGameTimeMS()+info->GetAutoCloseTime();
// cast this spell later if provided // cast this spell later if provided
spellId = info->goober.spellId; spellId = info->goober.spellId;
spellCaster = user; spellCaster = user;
tmpfish = true; tmpfish = true;
break; break;
} }
case GAMEOBJECT_TYPE_CAMERA: //13 case GAMEOBJECT_TYPE_CAMERA: //13
@@ -1574,7 +1574,7 @@ void GameObject::Use(Unit* user)
} }
else // else: junk else // else: junk
player->SendLoot(GetGUID(), LOOT_FISHING_JUNK); player->SendLoot(GetGUID(), LOOT_FISHING_JUNK);
tmpfish = true; tmpfish = true;
break; break;
} }
@@ -1848,7 +1848,7 @@ void GameObject::Use(Unit* user)
#endif #endif
return; return;
} }
if (Player* player = user->ToPlayer()) if (Player* player = user->ToPlayer())
sOutdoorPvPMgr->HandleCustomSpell(player, spellId, this); sOutdoorPvPMgr->HandleCustomSpell(player, spellId, this);
@@ -1859,7 +1859,7 @@ void GameObject::Use(Unit* user)
} }
void GameObject::CastSpell(Unit* target, uint32 spellId) void GameObject::CastSpell(Unit* target, uint32 spellId)
{ {
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo) if (!spellInfo)
return; return;
@@ -1919,7 +1919,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId)
} }
void GameObject::SendCustomAnim(uint32 anim) void GameObject::SendCustomAnim(uint32 anim)
{ {
WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4); WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8+4);
data << GetGUID(); data << GetGUID();
data << uint32(anim); data << uint32(anim);
@@ -1927,7 +1927,7 @@ void GameObject::SendCustomAnim(uint32 anim)
} }
bool GameObject::IsInRange(float x, float y, float z, float radius) const bool GameObject::IsInRange(float x, float y, float z, float radius) const
{ {
GameObjectDisplayInfoEntry const* info = sGameObjectDisplayInfoStore.LookupEntry(m_goInfo->displayId); GameObjectDisplayInfoEntry const* info = sGameObjectDisplayInfoStore.LookupEntry(m_goInfo->displayId);
if (!info) if (!info)
return IsWithinDist3d(x, y, z, radius); return IsWithinDist3d(x, y, z, radius);
@@ -1955,7 +1955,7 @@ bool GameObject::IsInRange(float x, float y, float z, float radius) const
// pussywizard! // pussywizard!
void GameObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*self*/, bool includeMargin, Player const* skipped_rcvr) void GameObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*self*/, bool includeMargin, Player const* skipped_rcvr)
{ {
dist += GetObjectSize(); dist += GetObjectSize();
if (includeMargin) if (includeMargin)
dist += VISIBILITY_COMPENSATION * 2.0f; // pussywizard: to ensure everyone receives all important packets dist += VISIBILITY_COMPENSATION * 2.0f; // pussywizard: to ensure everyone receives all important packets
@@ -1964,7 +1964,7 @@ void GameObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*s
} }
void GameObject::EventInform(uint32 eventId) void GameObject::EventInform(uint32 eventId)
{ {
if (!eventId) if (!eventId)
return; return;
@@ -2030,7 +2030,7 @@ void GameObject::SetWorldRotationAngles(float z_rot, float y_rot, float x_rot)
} }
void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= NULL*/, uint32 spellId /*= 0*/) void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= NULL*/, uint32 spellId /*= 0*/)
{ {
if (!IsDestructibleBuilding()) if (!IsDestructibleBuilding())
return; return;
@@ -2086,7 +2086,7 @@ void GameObject::ModifyHealth(int32 change, Unit* attackerOrHealer /*= NULL*/, u
} }
void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* eventInvoker /*= NULL*/, bool setHealth /*= false*/) void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player* eventInvoker /*= NULL*/, bool setHealth /*= false*/)
{ {
// the user calling this must know he is already operating on destructible gameobject // the user calling this must know he is already operating on destructible gameobject
ASSERT(GetGoType() == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING); ASSERT(GetGoType() == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING);
@@ -2190,7 +2190,7 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, Player*
} }
void GameObject::SetLootState(LootState state, Unit* unit) void GameObject::SetLootState(LootState state, Unit* unit)
{ {
m_lootState = state; m_lootState = state;
#ifdef ELUNA #ifdef ELUNA
sEluna->OnLootStateChanged(this, state); sEluna->OnLootStateChanged(this, state);
@@ -2198,7 +2198,7 @@ void GameObject::SetLootState(LootState state, Unit* unit)
AI()->OnStateChanged(state, unit); AI()->OnStateChanged(state, unit);
sScriptMgr->OnGameObjectLootStateChanged(this, state, unit); sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
// pussywizard: lootState has nothing to do with collision, it depends entirely on GOState. Loot state is for timed close/open door and respawning, which then sets GOState // pussywizard: lootState has nothing to do with collision, it depends entirely on GOState. Loot state is for timed close/open door and respawning, which then sets GOState
/*if (m_model) /*if (m_model)
{ {
// startOpen determines whether we are going to add or remove the LoS on activation // startOpen determines whether we are going to add or remove the LoS on activation
bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false); bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
@@ -2215,7 +2215,7 @@ void GameObject::SetLootState(LootState state, Unit* unit)
} }
void GameObject::SetGoState(GOState state) void GameObject::SetGoState(GOState state)
{ {
SetByteValue(GAMEOBJECT_BYTES_1, 0, state); SetByteValue(GAMEOBJECT_BYTES_1, 0, state);
#ifdef ELUNA #ifdef ELUNA
sEluna->OnGameObjectStateChanged(this, state); sEluna->OnGameObjectStateChanged(this, state);
@@ -2244,13 +2244,13 @@ void GameObject::SetGoState(GOState state)
} }
void GameObject::SetDisplayId(uint32 displayid) void GameObject::SetDisplayId(uint32 displayid)
{ {
SetUInt32Value(GAMEOBJECT_DISPLAYID, displayid); SetUInt32Value(GAMEOBJECT_DISPLAYID, displayid);
UpdateModel(); UpdateModel();
} }
void GameObject::SetPhaseMask(uint32 newPhaseMask, bool update) void GameObject::SetPhaseMask(uint32 newPhaseMask, bool update)
{ {
WorldObject::SetPhaseMask(newPhaseMask, update); WorldObject::SetPhaseMask(newPhaseMask, update);
if (m_model && m_model->isEnabled()) if (m_model && m_model->isEnabled())
@@ -2258,7 +2258,7 @@ void GameObject::SetPhaseMask(uint32 newPhaseMask, bool update)
} }
void GameObject::EnableCollision(bool enable) void GameObject::EnableCollision(bool enable)
{ {
if (!m_model) if (!m_model)
return; return;
@@ -2273,7 +2273,7 @@ void GameObject::EnableCollision(bool enable)
} }
void GameObject::UpdateModel() void GameObject::UpdateModel()
{ {
if (!IsInWorld()) if (!IsInWorld())
return; return;
if (m_model) if (m_model)
@@ -2286,21 +2286,21 @@ void GameObject::UpdateModel()
} }
Player* GameObject::GetLootRecipient() const Player* GameObject::GetLootRecipient() const
{ {
if (!m_lootRecipient) if (!m_lootRecipient)
return nullptr; return nullptr;
return ObjectAccessor::FindPlayerInOrOutOfWorld(m_lootRecipient); return ObjectAccessor::FindPlayerInOrOutOfWorld(m_lootRecipient);
} }
Group* GameObject::GetLootRecipientGroup() const Group* GameObject::GetLootRecipientGroup() const
{ {
if (!m_lootRecipientGroup) if (!m_lootRecipientGroup)
return nullptr; return nullptr;
return sGroupMgr->GetGroupByGUID(m_lootRecipientGroup); return sGroupMgr->GetGroupByGUID(m_lootRecipientGroup);
} }
void GameObject::SetLootRecipient(Unit* unit) void GameObject::SetLootRecipient(Unit* unit)
{ {
// set the player whose group should receive the right // set the player whose group should receive the right
// to loot the creature after it dies // to loot the creature after it dies
// should be set to NULL after the loot disappears // should be set to NULL after the loot disappears
@@ -2325,7 +2325,7 @@ void GameObject::SetLootRecipient(Unit* unit)
} }
bool GameObject::IsLootAllowedFor(Player const* player) const bool GameObject::IsLootAllowedFor(Player const* player) const
{ {
if (!m_lootRecipient && !m_lootRecipientGroup) if (!m_lootRecipient && !m_lootRecipientGroup)
return true; return true;
@@ -2343,7 +2343,7 @@ bool GameObject::IsLootAllowedFor(Player const* player) const
} }
void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) const void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) const
{ {
if (!target) if (!target)
return; return;
@@ -2438,7 +2438,7 @@ void GameObject::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* t
} }
void GameObject::GetRespawnPosition(float &x, float &y, float &z, float* ori /* = NULL*/) const void GameObject::GetRespawnPosition(float &x, float &y, float &z, float* ori /* = NULL*/) const
{ {
if (m_DBTableGuid) if (m_DBTableGuid)
{ {
if (GameObjectData const* data = sObjectMgr->GetGOData(GetDBTableGUIDLow())) if (GameObjectData const* data = sObjectMgr->GetGOData(GetDBTableGUIDLow()))
@@ -2460,7 +2460,7 @@ void GameObject::GetRespawnPosition(float &x, float &y, float &z, float* ori /*
} }
void GameObject::SetPosition(float x, float y, float z, float o) void GameObject::SetPosition(float x, float y, float z, float o)
{ {
// pussywizard: do not call for MotionTransport and other gobjects not in grid // pussywizard: do not call for MotionTransport and other gobjects not in grid
if (!acore::IsValidMapCoord(x, y, z, o)) if (!acore::IsValidMapCoord(x, y, z, o))
@@ -2470,7 +2470,7 @@ void GameObject::SetPosition(float x, float y, float z, float o)
} }
float GameObject::GetInteractionDistance() float GameObject::GetInteractionDistance()
{ {
switch (GetGoType()) switch (GetGoType())
{ {
/// @todo find out how the client calculates the maximal usage distance to spellless working /// @todo find out how the client calculates the maximal usage distance to spellless working
+36 -10
View File
@@ -23,6 +23,7 @@
#include "LuaEngine.h" #include "LuaEngine.h"
#endif #endif
#include <time.h> #include <time.h>
#include "Util.h"
GameEventMgr* GameEventMgr::instance() GameEventMgr* GameEventMgr::instance()
{ {
@@ -1015,7 +1016,12 @@ void GameEventMgr::LoadHolidayDates()
if (uint32 duration = fields[3].GetUInt32()) if (uint32 duration = fields[3].GetUInt32())
entry->Duration[0] = duration; entry->Duration[0] = duration;
modifiedHolidays.insert(entry->Id); auto itr = std::lower_bound(modifiedHolidays.begin(), modifiedHolidays.end(), entry->Id);
if (itr == modifiedHolidays.end() || *itr != entry->Id)
{
modifiedHolidays.insert(itr, entry->Id);
}
++count; ++count;
} while (result->NextRow()); } while (result->NextRow());
@@ -1753,8 +1759,10 @@ void GameEventMgr::SetHolidayEventTime(GameEventData& event)
event.length = holiday->Duration[stageIndex] * HOUR / MINUTE; event.length = holiday->Duration[stageIndex] * HOUR / MINUTE;
time_t stageOffset = 0; time_t stageOffset = 0;
for (int i = 0; i < stageIndex; ++i) for (uint8 i = 0; i < stageIndex; ++i)
{
stageOffset += holiday->Duration[i] * HOUR; stageOffset += holiday->Duration[i] * HOUR;
}
switch (holiday->CalendarFilterType) switch (holiday->CalendarFilterType)
{ {
@@ -1773,44 +1781,62 @@ void GameEventMgr::SetHolidayEventTime(GameEventData& event)
if (holiday->Looping) if (holiday->Looping)
{ {
event.occurence = 0; event.occurence = 0;
for (int i = 0; i < MAX_HOLIDAY_DURATIONS && holiday->Duration[i]; ++i) for (uint8 i = 0; i < MAX_HOLIDAY_DURATIONS && holiday->Duration[i]; ++i)
{
event.occurence += holiday->Duration[i] * HOUR / MINUTE; event.occurence += holiday->Duration[i] * HOUR / MINUTE;
}
} }
bool singleDate = ((holiday->Date[0] >> 24) & 0x1F) == 31; // Events with fixed date within year have - 1 bool singleDate = ((holiday->Date[0] >> 24) & 0x1F) == 31; // Events with fixed date within year have - 1
time_t curTime = time(nullptr); time_t curTime = time(nullptr);
for (int i = 0; i < MAX_HOLIDAY_DATES && holiday->Date[i]; ++i) for (uint8 i = 0; i < MAX_HOLIDAY_DATES && holiday->Date[i]; ++i)
{ {
uint32 date = holiday->Date[i]; uint32 date = holiday->Date[i];
tm timeInfo; tm timeInfo;
if (singleDate) if (singleDate)
timeInfo.tm_year = localtime(&curTime)->tm_year - 1; // First try last year (event active through New Year) {
localtime_r(&curTime, &timeInfo);
timeInfo.tm_year -= 1; // First try last year (event active through New Year)
}
else else
{
timeInfo.tm_year = ((date >> 24) & 0x1F) + 100; timeInfo.tm_year = ((date >> 24) & 0x1F) + 100;
}
timeInfo.tm_mon = (date >> 20) & 0xF; timeInfo.tm_mon = (date >> 20) & 0xF;
timeInfo.tm_mday = ((date >> 14) & 0x3F) + 1; timeInfo.tm_mday = ((date >> 14) & 0x3F) + 1;
timeInfo.tm_hour = (date >> 6) & 0x1F; timeInfo.tm_hour = (date >> 6) & 0x1F;
timeInfo.tm_min = date & 0x3F; timeInfo.tm_min = date & 0x3F;
timeInfo.tm_sec = 0; timeInfo.tm_sec = 0;
timeInfo.tm_isdst = -1; timeInfo.tm_isdst = -1;
tm tmCopy = timeInfo;
// try to get next start time (skip past dates)
time_t startTime = mktime(&timeInfo); time_t startTime = mktime(&timeInfo);
if (curTime < startTime + event.length * MINUTE) if (curTime < startTime + event.length * MINUTE)
{ {
event.start = startTime + stageOffset; event.start = startTime + stageOffset;
return; break;
} }
else if (singleDate) else if (singleDate)
{ {
tmCopy.tm_year = localtime(&curTime)->tm_year; // This year tm tmCopy;
localtime_r(&curTime, &tmCopy);
int year = tmCopy.tm_year; // This year
tmCopy = timeInfo;
tmCopy.tm_year = year;
event.start = mktime(&tmCopy) + stageOffset; event.start = mktime(&tmCopy) + stageOffset;
return; break;
} }
else
{
// date is due and not a singleDate event, try with next DBC date (modified by holiday_dates)
// if none is found we don't modify start date and use the one in game_event
}
} }
sLog->outString("No suitable start date found for holiday %u.", event.holiday_id);
} }
bool IsHolidayActive(HolidayIds id) bool IsHolidayActive(HolidayIds id)
+1 -3
View File
@@ -105,9 +105,7 @@ class GameEventMgr
bool StartEvent(uint16 event_id, bool overwrite = false); bool StartEvent(uint16 event_id, bool overwrite = false);
void StopEvent(uint16 event_id, bool overwrite = false); void StopEvent(uint16 event_id, bool overwrite = false);
void HandleQuestComplete(uint32 quest_id); // called on world event type quest completions void HandleQuestComplete(uint32 quest_id); // called on world event type quest completions
void HandleWorldEventGossip(Player* player, Creature* c);
uint32 GetNPCFlag(Creature* cr); uint32 GetNPCFlag(Creature* cr);
uint32 GetNpcTextId(uint32 guid);
private: private:
void SendWorldStateUpdate(Player* player, uint16 event_id); void SendWorldStateUpdate(Player* player, uint16 event_id);
void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); } void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); }
@@ -164,7 +162,7 @@ class GameEventMgr
public: public:
GameEventGuidMap mGameEventCreatureGuids; GameEventGuidMap mGameEventCreatureGuids;
GameEventGuidMap mGameEventGameobjectGuids; GameEventGuidMap mGameEventGameobjectGuids;
std::set<uint32> modifiedHolidays; std::vector<uint32> modifiedHolidays;
}; };
#define sGameEventMgr GameEventMgr::instance() #define sGameEventMgr GameEventMgr::instance()
+1 -2
View File
@@ -1075,7 +1075,7 @@ struct HolidaysEntry
//uint32 holidayDescriptionId; // 50 m_holidayDescriptionID (HolidayDescriptions.dbc) //uint32 holidayDescriptionId; // 50 m_holidayDescriptionID (HolidayDescriptions.dbc)
char* TextureFilename; // 51 m_textureFilename char* TextureFilename; // 51 m_textureFilename
uint32 Priority; // 52 m_priority uint32 Priority; // 52 m_priority
int32 CalendarFilterType; // 53 m_calendarFilterType (-1 = Fishing Contest, 0 = Unk, 1 = Darkmoon Festival, 2 = Yearly holiday) int32 CalendarFilterType; // 53 m_calendarFilterType (-1 = Fishing Contest, 0 = Unk, 1 = Darkmoon Festival, 2 = Yearly holiday)
//uint32 flags; // 54 m_flags (0 = Darkmoon Faire, Fishing Contest and Wotlk Launch, rest is 1) //uint32 flags; // 54 m_flags (0 = Darkmoon Faire, Fishing Contest and Wotlk Launch, rest is 1)
}; };
@@ -2129,4 +2129,3 @@ typedef std::vector<TaxiPathNodeList> TaxiPathNodesByPath;
#define TaxiMaskSize 14 #define TaxiMaskSize 14
typedef uint32 TaxiMask[TaxiMaskSize]; typedef uint32 TaxiMask[TaxiMaskSize];
#endif #endif