Core/GameEvent: Minor code optimization. (Also cosmetic changes in other unrelated files)
This commit is contained in:
@@ -167,42 +167,42 @@ bool Condition::Meets(Player* player, Unit* invoker)
|
|||||||
condMeets = !player->HasItemCount(mConditionValue1, 1, mConditionValue2 ? true : false);
|
condMeets = !player->HasItemCount(mConditionValue1, 1, mConditionValue2 ? true : false);
|
||||||
break;
|
break;
|
||||||
case CONDITION_LEVEL:
|
case CONDITION_LEVEL:
|
||||||
|
{
|
||||||
|
switch (mConditionValue2)
|
||||||
{
|
{
|
||||||
switch (mConditionValue2)
|
case LVL_COND_EQ:
|
||||||
{
|
condMeets = player->getLevel() == mConditionValue1;
|
||||||
case LVL_COND_EQ:
|
break;
|
||||||
condMeets = player->getLevel() == mConditionValue1;
|
case LVL_COND_HIGH:
|
||||||
break;
|
condMeets = player->getLevel() > mConditionValue1;
|
||||||
case LVL_COND_HIGH:
|
break;
|
||||||
condMeets = player->getLevel() > mConditionValue1;
|
case LVL_COND_LOW:
|
||||||
break;
|
condMeets = player->getLevel() < mConditionValue1;
|
||||||
case LVL_COND_LOW:
|
break;
|
||||||
condMeets = player->getLevel() < mConditionValue1;
|
case LVL_COND_HIGH_EQ:
|
||||||
break;
|
condMeets = player->getLevel() >= mConditionValue1;
|
||||||
case LVL_COND_HIGH_EQ:
|
break;
|
||||||
condMeets = player->getLevel() >= mConditionValue1;
|
case LVL_COND_LOW_EQ:
|
||||||
break;
|
condMeets = player->getLevel() <= mConditionValue1;
|
||||||
case LVL_COND_LOW_EQ:
|
break;
|
||||||
condMeets = player->getLevel() <= mConditionValue1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CONDITION_DRUNKENSTATE:
|
case CONDITION_DRUNKENSTATE:
|
||||||
{
|
{
|
||||||
condMeets = (uint32)Player::GetDrunkenstateByValue(player->GetDrunkValue()) >= mConditionValue1;
|
condMeets = (uint32)Player::GetDrunkenstateByValue(player->GetDrunkValue()) >= mConditionValue1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CONDITION_NEAR_CREATURE:
|
case CONDITION_NEAR_CREATURE:
|
||||||
{
|
{
|
||||||
condMeets = GetClosestCreatureWithEntry(player, mConditionValue1, (float)mConditionValue2) ? true : false;
|
condMeets = GetClosestCreatureWithEntry(player, mConditionValue1, (float)mConditionValue2) ? true : false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CONDITION_NEAR_GAMEOBJECT:
|
case CONDITION_NEAR_GAMEOBJECT:
|
||||||
{
|
{
|
||||||
condMeets = GetClosestGameObjectWithEntry(player, mConditionValue1, (float)mConditionValue2) ? true : false;
|
condMeets = GetClosestGameObjectWithEntry(player, mConditionValue1, (float)mConditionValue2) ? true : false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
condMeets = false;
|
condMeets = false;
|
||||||
refId = 0;
|
refId = 0;
|
||||||
@@ -382,7 +382,7 @@ void ConditionMgr::LoadConditions(bool isReload)
|
|||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
sLog->outErrorDb(">> Loaded 0 conditions. DB table `groups` is empty!");
|
sLog->outErrorDb(">> Loaded 0 conditions. DB table `conditions` is empty!");
|
||||||
sLog->outString();
|
sLog->outString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -979,40 +979,32 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CONDITION_SOURCE_TYPE_QUEST_ACCEPT:
|
case CONDITION_SOURCE_TYPE_QUEST_ACCEPT:
|
||||||
|
if (!sObjectMgr->GetQuestTemplate(cond->mSourceEntry))
|
||||||
{
|
{
|
||||||
Quest const *Quest = sObjectMgr->GetQuestTemplate(cond->mSourceEntry);
|
sLog->outErrorDb("CONDITION_SOURCE_TYPE_QUEST_ACCEPT specifies non-existing quest (%u), skipped", cond->mSourceEntry);
|
||||||
if (!Quest)
|
return false;
|
||||||
{
|
|
||||||
sLog->outErrorDb("CONDITION_SOURCE_TYPE_QUEST_ACCEPT specifies non-existing quest (%u), skipped", cond->mSourceEntry);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK:
|
case CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK:
|
||||||
|
if (!sObjectMgr->GetQuestTemplate(cond->mSourceEntry))
|
||||||
{
|
{
|
||||||
Quest const *Quest = sObjectMgr->GetQuestTemplate(cond->mSourceEntry);
|
sLog->outErrorDb("CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK specifies non-existing quest (%u), skipped", cond->mSourceEntry);
|
||||||
if (!Quest)
|
return false;
|
||||||
{
|
|
||||||
sLog->outErrorDb("CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK specifies non-existing quest (%u), skipped", cond->mSourceEntry);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONDITION_SOURCE_TYPE_VEHICLE_SPELL:
|
case CONDITION_SOURCE_TYPE_VEHICLE_SPELL:
|
||||||
|
if (!sObjectMgr->GetCreatureTemplate(cond->mSourceGroup))
|
||||||
{
|
{
|
||||||
if (!sObjectMgr->GetCreatureTemplate(cond->mSourceGroup))
|
sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `creature_template`, ignoring.", cond->mSourceGroup);
|
||||||
{
|
return false;
|
||||||
sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `creature_template`, ignoring.", cond->mSourceGroup);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cond->mSourceEntry);
|
|
||||||
if (!spellProto)
|
|
||||||
{
|
|
||||||
sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->mSourceEntry);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!sSpellMgr->GetSpellInfo(cond->mSourceEntry))
|
||||||
|
{
|
||||||
|
sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->mSourceEntry);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
|
case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
|
||||||
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
|
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
|
||||||
case CONDITION_SOURCE_TYPE_NONE:
|
case CONDITION_SOURCE_TYPE_NONE:
|
||||||
@@ -1138,8 +1130,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
|
|||||||
case CONDITION_QUEST_NONE:
|
case CONDITION_QUEST_NONE:
|
||||||
case CONDITION_QUEST_COMPLETE:
|
case CONDITION_QUEST_COMPLETE:
|
||||||
{
|
{
|
||||||
Quest const *Quest = sObjectMgr->GetQuestTemplate(cond->mConditionValue1);
|
if (!sObjectMgr->GetQuestTemplate(cond->mConditionValue1))
|
||||||
if (!Quest)
|
|
||||||
{
|
{
|
||||||
sLog->outErrorDb("Quest condition specifies non-existing quest (%u), skipped", cond->mConditionValue1);
|
sLog->outErrorDb("Quest condition specifies non-existing quest (%u), skipped", cond->mConditionValue1);
|
||||||
return false;
|
return false;
|
||||||
@@ -1341,23 +1332,23 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CONDITION_LEVEL:
|
case CONDITION_LEVEL:
|
||||||
|
{
|
||||||
|
if (cond->mConditionValue2 >= LVL_COND_MAX)
|
||||||
{
|
{
|
||||||
if (cond->mConditionValue2 >= LVL_COND_MAX)
|
sLog->outErrorDb("Level condition has invalid option (%u), skipped", cond->mConditionValue2);
|
||||||
{
|
return false;
|
||||||
sLog->outErrorDb("Level condition has invalid option (%u), skipped", cond->mConditionValue2);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CONDITION_DRUNKENSTATE:
|
case CONDITION_DRUNKENSTATE:
|
||||||
|
{
|
||||||
|
if (cond->mConditionValue1 > DRUNKEN_SMASHED)
|
||||||
{
|
{
|
||||||
if (cond->mConditionValue1 > DRUNKEN_SMASHED)
|
sLog->outErrorDb("DrunkState condition has invalid state (%u), skipped", cond->mConditionValue1);
|
||||||
{
|
return false;
|
||||||
sLog->outErrorDb("DrunkState condition has invalid state (%u), skipped", cond->mConditionValue1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CONDITION_NEAR_CREATURE:
|
case CONDITION_NEAR_CREATURE:
|
||||||
{
|
{
|
||||||
if (!sObjectMgr->GetCreatureTemplate(cond->mConditionValue1))
|
if (!sObjectMgr->GetCreatureTemplate(cond->mConditionValue1))
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#define TRINITY_CONDITIONMGR_H
|
#define TRINITY_CONDITIONMGR_H
|
||||||
|
|
||||||
#include "LootMgr.h"
|
#include "LootMgr.h"
|
||||||
|
#include <ace/Singleton.h>
|
||||||
|
|
||||||
class Player;
|
class Player;
|
||||||
class Unit;
|
class Unit;
|
||||||
@@ -63,12 +64,12 @@ enum ConditionType
|
|||||||
|
|
||||||
enum LevelConditionType
|
enum LevelConditionType
|
||||||
{
|
{
|
||||||
LVL_COND_EQ = 0,
|
LVL_COND_EQ,
|
||||||
LVL_COND_HIGH = 1,
|
LVL_COND_HIGH,
|
||||||
LVL_COND_LOW = 2,
|
LVL_COND_LOW,
|
||||||
LVL_COND_HIGH_EQ = 3,
|
LVL_COND_HIGH_EQ,
|
||||||
LVL_COND_LOW_EQ = 4,
|
LVL_COND_LOW_EQ,
|
||||||
LVL_COND_MAX = 5,
|
LVL_COND_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ConditionSourceType
|
enum ConditionSourceType
|
||||||
@@ -141,11 +142,12 @@ typedef std::map<uint32, ConditionList > ConditionReferenceMap;//only used for r
|
|||||||
class ConditionMgr
|
class ConditionMgr
|
||||||
{
|
{
|
||||||
friend class ACE_Singleton<ConditionMgr, ACE_Null_Mutex>;
|
friend class ACE_Singleton<ConditionMgr, ACE_Null_Mutex>;
|
||||||
ConditionMgr();
|
|
||||||
~ConditionMgr();
|
private:
|
||||||
|
ConditionMgr();
|
||||||
|
~ConditionMgr();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void LoadConditions(bool isReload = false);
|
void LoadConditions(bool isReload = false);
|
||||||
bool isConditionTypeValid(Condition* cond);
|
bool isConditionTypeValid(Condition* cond);
|
||||||
ConditionList GetConditionReferences(uint32 refId);
|
ConditionList GetConditionReferences(uint32 refId);
|
||||||
@@ -154,14 +156,7 @@ class ConditionMgr
|
|||||||
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sType, uint32 uEntry);
|
ConditionList GetConditionsForNotGroupedEntry(ConditionSourceType sType, uint32 uEntry);
|
||||||
ConditionList GetConditionsForVehicleSpell(uint32 creatureID, uint32 spellID);
|
ConditionList GetConditionsForVehicleSpell(uint32 creatureID, uint32 spellID);
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
ConditionMap m_ConditionMap;
|
|
||||||
ConditionReferenceMap m_ConditionReferenceMap;
|
|
||||||
VehicleSpellConditionMap m_VehicleSpellConditions;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool isSourceTypeValid(Condition* cond);
|
bool isSourceTypeValid(Condition* cond);
|
||||||
bool addToLootTemplate(Condition* cond, LootTemplate* loot);
|
bool addToLootTemplate(Condition* cond, LootTemplate* loot);
|
||||||
bool addToGossipMenus(Condition* cond);
|
bool addToGossipMenus(Condition* cond);
|
||||||
@@ -189,6 +184,10 @@ class ConditionMgr
|
|||||||
|
|
||||||
void Clean(); // free up resources
|
void Clean(); // free up resources
|
||||||
std::list<Condition*> m_AllocatedMemory; // some garbage collection :)
|
std::list<Condition*> m_AllocatedMemory; // some garbage collection :)
|
||||||
|
|
||||||
|
ConditionMap m_ConditionMap;
|
||||||
|
ConditionReferenceMap m_ConditionReferenceMap;
|
||||||
|
VehicleSpellConditionMap m_VehicleSpellConditions;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define sConditionMgr ACE_Singleton<ConditionMgr, ACE_Null_Mutex>::instance()
|
#define sConditionMgr ACE_Singleton<ConditionMgr, ACE_Null_Mutex>::instance()
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SpellMgr.h"
|
|
||||||
#include "ObjectMgr.h"
|
|
||||||
#include "DisableMgr.h"
|
#include "DisableMgr.h"
|
||||||
|
#include "ObjectMgr.h"
|
||||||
#include "OutdoorPvP.h"
|
#include "OutdoorPvP.h"
|
||||||
|
#include "SpellMgr.h"
|
||||||
#include "VMapManager2.h"
|
#include "VMapManager2.h"
|
||||||
|
|
||||||
DisableMgr::DisableMgr()
|
DisableMgr::DisableMgr()
|
||||||
@@ -77,7 +77,6 @@ void DisableMgr::LoadDisables()
|
|||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case DISABLE_TYPE_SPELL:
|
case DISABLE_TYPE_SPELL:
|
||||||
{
|
|
||||||
if (!(sSpellMgr->GetSpellInfo(entry) || flags & SPELL_DISABLE_DEPRECATED_SPELL))
|
if (!(sSpellMgr->GetSpellInfo(entry) || flags & SPELL_DISABLE_DEPRECATED_SPELL))
|
||||||
{
|
{
|
||||||
sLog->outErrorDb("Spell entry %u from `disables` doesn't exist in dbc, skipped.", entry);
|
sLog->outErrorDb("Spell entry %u from `disables` doesn't exist in dbc, skipped.", entry);
|
||||||
@@ -104,7 +103,7 @@ void DisableMgr::LoadDisables()
|
|||||||
data.params[1].insert(atoi(tokens[i++]));
|
data.params[1].insert(atoi(tokens[i++]));
|
||||||
}
|
}
|
||||||
|
|
||||||
} break;
|
break;
|
||||||
// checked later
|
// checked later
|
||||||
case DISABLE_TYPE_QUEST:
|
case DISABLE_TYPE_QUEST:
|
||||||
break;
|
break;
|
||||||
@@ -217,7 +216,7 @@ void DisableMgr::LoadDisables()
|
|||||||
|
|
||||||
m_DisableMap[type].insert(DisableTypeMap::value_type(entry, data));
|
m_DisableMap[type].insert(DisableTypeMap::value_type(entry, data));
|
||||||
++total_count;
|
++total_count;
|
||||||
}
|
}
|
||||||
while (result->NextRow());
|
while (result->NextRow());
|
||||||
|
|
||||||
sLog->outString(">> Loaded %u disables in %u ms", total_count, GetMSTimeDiffToNow(oldMSTime));
|
sLog->outString(">> Loaded %u disables in %u ms", total_count, GetMSTimeDiffToNow(oldMSTime));
|
||||||
@@ -313,7 +312,7 @@ bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* unit,
|
|||||||
uint8 disabledModes = itr->second.flags;
|
uint8 disabledModes = itr->second.flags;
|
||||||
Difficulty targetDifficulty = player->GetDifficulty(mapEntry->IsRaid());
|
Difficulty targetDifficulty = player->GetDifficulty(mapEntry->IsRaid());
|
||||||
GetDownscaledMapDifficultyData(entry, targetDifficulty);
|
GetDownscaledMapDifficultyData(entry, targetDifficulty);
|
||||||
switch(targetDifficulty)
|
switch (targetDifficulty)
|
||||||
{
|
{
|
||||||
case DUNGEON_DIFFICULTY_NORMAL:
|
case DUNGEON_DIFFICULTY_NORMAL:
|
||||||
return disabledModes & DUNGEON_STATUSFLAG_NORMAL;
|
return disabledModes & DUNGEON_STATUSFLAG_NORMAL;
|
||||||
|
|||||||
@@ -121,24 +121,24 @@ void GameEventMgr::StartInternalEvent(uint16 event_id)
|
|||||||
|
|
||||||
bool GameEventMgr::StartEvent(uint16 event_id, bool overwrite)
|
bool GameEventMgr::StartEvent(uint16 event_id, bool overwrite)
|
||||||
{
|
{
|
||||||
if (mGameEvent[event_id].state == GAMEEVENT_NORMAL
|
GameEventData &data = mGameEvent[event_id];
|
||||||
|| mGameEvent[event_id].state == GAMEEVENT_INTERNAL)
|
if (data.state == GAMEEVENT_NORMAL || data.state == GAMEEVENT_INTERNAL)
|
||||||
{
|
{
|
||||||
AddActiveEvent(event_id);
|
AddActiveEvent(event_id);
|
||||||
ApplyNewEvent(event_id);
|
ApplyNewEvent(event_id);
|
||||||
if (overwrite)
|
if (overwrite)
|
||||||
{
|
{
|
||||||
mGameEvent[event_id].start = time(NULL);
|
mGameEvent[event_id].start = time(NULL);
|
||||||
if (mGameEvent[event_id].end <= mGameEvent[event_id].start)
|
if (data.end <= data.start)
|
||||||
mGameEvent[event_id].end = mGameEvent[event_id].start+mGameEvent[event_id].length;
|
data.end = data.start + data.length;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mGameEvent[event_id].state == GAMEEVENT_WORLD_INACTIVE)
|
if (data.state == GAMEEVENT_WORLD_INACTIVE)
|
||||||
// set to conditions phase
|
// set to conditions phase
|
||||||
mGameEvent[event_id].state = GAMEEVENT_WORLD_CONDITIONS;
|
data.state = GAMEEVENT_WORLD_CONDITIONS;
|
||||||
|
|
||||||
// add to active events
|
// add to active events
|
||||||
AddActiveEvent(event_id);
|
AddActiveEvent(event_id);
|
||||||
@@ -161,27 +161,28 @@ bool GameEventMgr::StartEvent(uint16 event_id, bool overwrite)
|
|||||||
|
|
||||||
void GameEventMgr::StopEvent(uint16 event_id, bool overwrite)
|
void GameEventMgr::StopEvent(uint16 event_id, bool overwrite)
|
||||||
{
|
{
|
||||||
bool serverwide_evt = mGameEvent[event_id].state != GAMEEVENT_NORMAL && mGameEvent[event_id].state != GAMEEVENT_INTERNAL;
|
GameEventData &data = mGameEvent[event_id];
|
||||||
|
bool serverwide_evt = data.state != GAMEEVENT_NORMAL && data.state != GAMEEVENT_INTERNAL;
|
||||||
|
|
||||||
RemoveActiveEvent(event_id);
|
RemoveActiveEvent(event_id);
|
||||||
UnApplyEvent(event_id);
|
UnApplyEvent(event_id);
|
||||||
|
|
||||||
if (overwrite && !serverwide_evt)
|
if (overwrite && !serverwide_evt)
|
||||||
{
|
{
|
||||||
mGameEvent[event_id].start = time(NULL) - mGameEvent[event_id].length * MINUTE;
|
data.start = time(NULL) - data.length * MINUTE;
|
||||||
if (mGameEvent[event_id].end <= mGameEvent[event_id].start)
|
if (data.end <= data.start)
|
||||||
mGameEvent[event_id].end = mGameEvent[event_id].start+mGameEvent[event_id].length;
|
data.end = data.start + data.length;
|
||||||
}
|
}
|
||||||
else if (serverwide_evt)
|
else if (serverwide_evt)
|
||||||
{
|
{
|
||||||
// if finished world event, then only gm command can stop it
|
// if finished world event, then only gm command can stop it
|
||||||
if (overwrite || mGameEvent[event_id].state != GAMEEVENT_WORLD_FINISHED)
|
if (overwrite || data.state != GAMEEVENT_WORLD_FINISHED)
|
||||||
{
|
{
|
||||||
// reset conditions
|
// reset conditions
|
||||||
mGameEvent[event_id].nextstart = 0;
|
data.nextstart = 0;
|
||||||
mGameEvent[event_id].state = GAMEEVENT_WORLD_INACTIVE;
|
data.state = GAMEEVENT_WORLD_INACTIVE;
|
||||||
std::map<uint32 /*condition id*/, GameEventFinishCondition>::iterator itr;
|
GameEventConditionMap::iterator itr;
|
||||||
for (itr = mGameEvent[event_id].conditions.begin(); itr != mGameEvent[event_id].conditions.end(); ++itr)
|
for (itr = data.conditions.begin(); itr != data.conditions.end(); ++itr)
|
||||||
itr->second.done = 0;
|
itr->second.done = 0;
|
||||||
|
|
||||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||||
@@ -696,7 +697,7 @@ void GameEventMgr::LoadFromDB()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<uint32, GameEventFinishCondition>::iterator itr = mGameEvent[event_id].conditions.find(condition);
|
GameEventConditionMap::iterator itr = mGameEvent[event_id].conditions.find(condition);
|
||||||
if (itr != mGameEvent[event_id].conditions.end())
|
if (itr != mGameEvent[event_id].conditions.end())
|
||||||
{
|
{
|
||||||
itr->second.done = fields[2].GetFloat();
|
itr->second.done = fields[2].GetFloat();
|
||||||
@@ -962,20 +963,26 @@ uint32 GameEventMgr::StartSystem() // return the next
|
|||||||
|
|
||||||
void GameEventMgr::StartArenaSeason()
|
void GameEventMgr::StartArenaSeason()
|
||||||
{
|
{
|
||||||
QueryResult result = WorldDatabase.PQuery("SELECT eventEntry FROM game_event_arena_seasons WHERE season = '%i'", sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID));
|
uint8 season = sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID);
|
||||||
|
QueryResult result = WorldDatabase.PQuery("SELECT eventEntry FROM game_event_arena_seasons WHERE season = '%i'", season);
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
sLog->outError("ArenaSeason (%i) must be an existant Arena Season", sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID));
|
sLog->outError("ArenaSeason (%u) must be an existant Arena Season", season);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
|
|
||||||
uint16 eventId = fields[0].GetUInt16();
|
uint16 eventId = fields[0].GetUInt16();
|
||||||
|
|
||||||
|
if (eventId >= mGameEvent.size())
|
||||||
|
{
|
||||||
|
sLog->outError("EventEntry %u for ArenaSeason (%u) does not exists", eventId, season);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
StartEvent(eventId, true);
|
StartEvent(eventId, true);
|
||||||
sLog->outString("Arena Season %i started...", sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID));
|
sLog->outString("Arena Season %u started...", season);
|
||||||
sLog->outString();
|
sLog->outString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1512,7 +1519,7 @@ void GameEventMgr::HandleQuestComplete(uint32 quest_id)
|
|||||||
// not in correct phase, return
|
// not in correct phase, return
|
||||||
if (mGameEvent[event_id].state != GAMEEVENT_WORLD_CONDITIONS)
|
if (mGameEvent[event_id].state != GAMEEVENT_WORLD_CONDITIONS)
|
||||||
return;
|
return;
|
||||||
std::map<uint32, GameEventFinishCondition>::iterator citr = mGameEvent[event_id].conditions.find(condition);
|
GameEventConditionMap::iterator citr = mGameEvent[event_id].conditions.find(condition);
|
||||||
// condition is registered
|
// condition is registered
|
||||||
if (citr != mGameEvent[event_id].conditions.end())
|
if (citr != mGameEvent[event_id].conditions.end())
|
||||||
{
|
{
|
||||||
@@ -1552,7 +1559,7 @@ void GameEventMgr::HandleQuestComplete(uint32 quest_id)
|
|||||||
|
|
||||||
bool GameEventMgr::CheckOneGameEventConditions(uint16 event_id)
|
bool GameEventMgr::CheckOneGameEventConditions(uint16 event_id)
|
||||||
{
|
{
|
||||||
for (std::map<uint32, GameEventFinishCondition>::iterator itr = mGameEvent[event_id].conditions.begin(); itr != mGameEvent[event_id].conditions.end(); ++itr)
|
for (GameEventConditionMap::const_iterator itr = mGameEvent[event_id].conditions.begin(); itr != mGameEvent[event_id].conditions.end(); ++itr)
|
||||||
if (itr->second.done < itr->second.reqNum)
|
if (itr->second.done < itr->second.reqNum)
|
||||||
// return false if a condition doesn't match
|
// return false if a condition doesn't match
|
||||||
return false;
|
return false;
|
||||||
@@ -1585,7 +1592,7 @@ void GameEventMgr::SaveWorldEventStateToDB(uint16 event_id)
|
|||||||
|
|
||||||
void GameEventMgr::SendWorldStateUpdate(Player* plr, uint16 event_id)
|
void GameEventMgr::SendWorldStateUpdate(Player* plr, uint16 event_id)
|
||||||
{
|
{
|
||||||
std::map<uint32, GameEventFinishCondition>::iterator itr;
|
GameEventConditionMap::const_iterator itr;
|
||||||
for (itr = mGameEvent[event_id].conditions.begin(); itr !=mGameEvent[event_id].conditions.end(); ++itr)
|
for (itr = mGameEvent[event_id].conditions.begin(); itr !=mGameEvent[event_id].conditions.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (itr->second.done_world_state)
|
if (itr->second.done_world_state)
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ struct GameEventQuestToEventConditionNum
|
|||||||
float num;
|
float num;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef std::map<uint32 /*condition id*/, GameEventFinishCondition> GameEventConditionMap;
|
||||||
|
|
||||||
struct GameEventData
|
struct GameEventData
|
||||||
{
|
{
|
||||||
GameEventData() : start(1), end(0), nextstart(0), occurence(0), length(0), holiday_id(HOLIDAY_NONE), state(GAMEEVENT_NORMAL) {}
|
GameEventData() : start(1), end(0), nextstart(0), occurence(0), length(0), holiday_id(HOLIDAY_NONE), state(GAMEEVENT_NORMAL) {}
|
||||||
@@ -61,7 +63,7 @@ struct GameEventData
|
|||||||
uint32 length; // length of the event (minutes) after finishing all conditions
|
uint32 length; // length of the event (minutes) after finishing all conditions
|
||||||
HolidayIds holiday_id;
|
HolidayIds holiday_id;
|
||||||
GameEventState state; // state of the game event, these are saved into the game_event table on change!
|
GameEventState state; // state of the game event, these are saved into the game_event table on change!
|
||||||
std::map<uint32 /*condition id*/, GameEventFinishCondition> conditions; // conditions to finish
|
GameEventConditionMap conditions; // conditions to finish
|
||||||
std::set<uint16 /*gameevent id*/> prerequisite_events; // events that must be completed before starting this event
|
std::set<uint16 /*gameevent id*/> prerequisite_events; // events that must be completed before starting this event
|
||||||
std::string description;
|
std::string description;
|
||||||
|
|
||||||
@@ -91,10 +93,12 @@ class Creature;
|
|||||||
class GameEventMgr
|
class GameEventMgr
|
||||||
{
|
{
|
||||||
friend class ACE_Singleton<GameEventMgr, ACE_Null_Mutex>;
|
friend class ACE_Singleton<GameEventMgr, ACE_Null_Mutex>;
|
||||||
GameEventMgr();
|
|
||||||
public:
|
private:
|
||||||
|
GameEventMgr();
|
||||||
~GameEventMgr() {};
|
~GameEventMgr() {};
|
||||||
|
|
||||||
|
public:
|
||||||
typedef std::set<uint16> ActiveEvents;
|
typedef std::set<uint16> ActiveEvents;
|
||||||
typedef std::vector<GameEventData> GameEventDataMap;
|
typedef std::vector<GameEventData> GameEventDataMap;
|
||||||
ActiveEvents const& GetActiveEventList() const { return m_ActiveEvents; }
|
ActiveEvents const& GetActiveEventList() const { return m_ActiveEvents; }
|
||||||
@@ -134,7 +138,7 @@ class GameEventMgr
|
|||||||
bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id);
|
bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id);
|
||||||
bool hasCreatureActiveEventExcept(uint32 creature_guid, uint16 event_id);
|
bool hasCreatureActiveEventExcept(uint32 creature_guid, uint16 event_id);
|
||||||
bool hasGameObjectActiveEventExcept(uint32 go_guid, uint16 event_id);
|
bool hasGameObjectActiveEventExcept(uint32 go_guid, uint16 event_id);
|
||||||
protected:
|
|
||||||
typedef std::list<uint32> GuidList;
|
typedef std::list<uint32> GuidList;
|
||||||
typedef std::list<uint32> IdList;
|
typedef std::list<uint32> IdList;
|
||||||
typedef std::vector<GuidList> GameEventGuidMap;
|
typedef std::vector<GuidList> GameEventGuidMap;
|
||||||
|
|||||||
Reference in New Issue
Block a user