*Add game event type GAMEEVENT_INTERNAL which can only be started by scripts.
--HG-- branch : trunk
This commit is contained in:
+36
-13
@@ -34,17 +34,30 @@
|
|||||||
INSTANTIATE_SINGLETON_1(GameEventMgr);
|
INSTANTIATE_SINGLETON_1(GameEventMgr);
|
||||||
|
|
||||||
bool GameEventMgr::CheckOneGameEvent(uint16 entry) const
|
bool GameEventMgr::CheckOneGameEvent(uint16 entry) const
|
||||||
|
{
|
||||||
|
switch(mGameEvent[entry].state)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case GAMEEVENT_NORMAL:
|
||||||
{
|
{
|
||||||
time_t currenttime = time(NULL);
|
time_t currenttime = time(NULL);
|
||||||
|
// Get the event information
|
||||||
|
return mGameEvent[entry].start < currenttime
|
||||||
|
&& currenttime < mGameEvent[entry].end
|
||||||
|
&& (currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * MINUTE) < mGameEvent[entry].length * MINUTE;
|
||||||
|
}
|
||||||
// if the state is conditions or nextphase, then the event should be active
|
// if the state is conditions or nextphase, then the event should be active
|
||||||
if (mGameEvent[entry].state == GAMEEVENT_WORLD_CONDITIONS || mGameEvent[entry].state == GAMEEVENT_WORLD_NEXTPHASE)
|
case GAMEEVENT_WORLD_CONDITIONS:
|
||||||
|
case GAMEEVENT_WORLD_NEXTPHASE:
|
||||||
return true;
|
return true;
|
||||||
// finished world events are inactive
|
// finished world events are inactive
|
||||||
else if (mGameEvent[entry].state == GAMEEVENT_WORLD_FINISHED)
|
case GAMEEVENT_WORLD_FINISHED:
|
||||||
|
case GAMEEVENT_INTERNAL:
|
||||||
return false;
|
return false;
|
||||||
// if inactive world event, check the prerequisite events
|
// if inactive world event, check the prerequisite events
|
||||||
else if (mGameEvent[entry].state == GAMEEVENT_WORLD_INACTIVE)
|
case GAMEEVENT_WORLD_INACTIVE:
|
||||||
{
|
{
|
||||||
|
time_t currenttime = time(NULL);
|
||||||
for(std::set<uint16>::const_iterator itr = mGameEvent[entry].prerequisite_events.begin(); itr != mGameEvent[entry].prerequisite_events.end(); ++itr)
|
for(std::set<uint16>::const_iterator itr = mGameEvent[entry].prerequisite_events.begin(); itr != mGameEvent[entry].prerequisite_events.end(); ++itr)
|
||||||
{
|
{
|
||||||
if( (mGameEvent[*itr].state != GAMEEVENT_WORLD_NEXTPHASE && mGameEvent[*itr].state != GAMEEVENT_WORLD_FINISHED) || // if prereq not in nextphase or finished state, then can't start this one
|
if( (mGameEvent[*itr].state != GAMEEVENT_WORLD_NEXTPHASE && mGameEvent[*itr].state != GAMEEVENT_WORLD_FINISHED) || // if prereq not in nextphase or finished state, then can't start this one
|
||||||
@@ -55,12 +68,7 @@ bool GameEventMgr::CheckOneGameEvent(uint16 entry) const
|
|||||||
// but if there are no prerequisites, this can be only activated through gm command
|
// but if there are no prerequisites, this can be only activated through gm command
|
||||||
return !(mGameEvent[entry].prerequisite_events.empty());
|
return !(mGameEvent[entry].prerequisite_events.empty());
|
||||||
}
|
}
|
||||||
// Get the event information
|
}
|
||||||
if( mGameEvent[entry].start < currenttime && currenttime < mGameEvent[entry].end &&
|
|
||||||
((currenttime - mGameEvent[entry].start) % (mGameEvent[entry].occurence * MINUTE)) < (mGameEvent[entry].length * MINUTE) )
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 GameEventMgr::NextCheck(uint16 entry) const
|
uint32 GameEventMgr::NextCheck(uint16 entry) const
|
||||||
@@ -97,9 +105,24 @@ uint32 GameEventMgr::NextCheck(uint16 entry) const
|
|||||||
return delay;
|
return delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameEventMgr::StartInternalEvent(uint16 event_id)
|
||||||
|
{
|
||||||
|
if(event_id < 1 || event_id >= mGameEvent.size())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!mGameEvent[event_id].isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(m_ActiveEvents.find(event_id) != m_ActiveEvents.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
StartEvent(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)
|
if(mGameEvent[event_id].state == GAMEEVENT_NORMAL
|
||||||
|
|| mGameEvent[event_id].state == GAMEEVENT_INTERNAL)
|
||||||
{
|
{
|
||||||
AddActiveEvent(event_id);
|
AddActiveEvent(event_id);
|
||||||
ApplyNewEvent(event_id);
|
ApplyNewEvent(event_id);
|
||||||
@@ -138,7 +161,7 @@ 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;
|
bool serverwide_evt = mGameEvent[event_id].state != GAMEEVENT_NORMAL && mGameEvent[event_id].state != GAMEEVENT_INTERNAL;
|
||||||
|
|
||||||
RemoveActiveEvent(event_id);
|
RemoveActiveEvent(event_id);
|
||||||
UnApplyEvent(event_id);
|
UnApplyEvent(event_id);
|
||||||
@@ -281,7 +304,7 @@ void GameEventMgr::LoadFromDB()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mGameEvent[event_id].state != GAMEEVENT_NORMAL)
|
if(mGameEvent[event_id].state != GAMEEVENT_NORMAL && mGameEvent[event_id].state != GAMEEVENT_INTERNAL)
|
||||||
{
|
{
|
||||||
mGameEvent[event_id].state = (GameEventState)(fields[1].GetUInt8());
|
mGameEvent[event_id].state = (GameEventState)(fields[1].GetUInt8());
|
||||||
mGameEvent[event_id].nextstart = time_t(fields[2].GetUInt64());
|
mGameEvent[event_id].nextstart = time_t(fields[2].GetUInt64());
|
||||||
@@ -329,7 +352,7 @@ void GameEventMgr::LoadFromDB()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(mGameEvent[event_id].state != GAMEEVENT_NORMAL)
|
if(mGameEvent[event_id].state != GAMEEVENT_NORMAL && mGameEvent[event_id].state != GAMEEVENT_INTERNAL)
|
||||||
{
|
{
|
||||||
uint16 prerequisite_event = fields[1].GetUInt16();
|
uint16 prerequisite_event = fields[1].GetUInt16();
|
||||||
if(prerequisite_event >= mGameEvent.size())
|
if(prerequisite_event >= mGameEvent.size())
|
||||||
|
|||||||
+11
-6
@@ -31,10 +31,11 @@
|
|||||||
enum GameEventState
|
enum GameEventState
|
||||||
{
|
{
|
||||||
GAMEEVENT_NORMAL = 0, // standard game events
|
GAMEEVENT_NORMAL = 0, // standard game events
|
||||||
GAMEEVENT_WORLD_INACTIVE, // not yet started
|
GAMEEVENT_WORLD_INACTIVE = 1, // not yet started
|
||||||
GAMEEVENT_WORLD_CONDITIONS, // condition matching phase
|
GAMEEVENT_WORLD_CONDITIONS = 2, // condition matching phase
|
||||||
GAMEEVENT_WORLD_NEXTPHASE, // conditions are met, now 'lenght' timer to start next event
|
GAMEEVENT_WORLD_NEXTPHASE = 3, // conditions are met, now 'lenght' timer to start next event
|
||||||
GAMEEVENT_WORLD_FINISHED // next events are started, unapply this one
|
GAMEEVENT_WORLD_FINISHED = 4, // next events are started, unapply this one
|
||||||
|
GAMEEVENT_INTERNAL = 5, // never handled in update
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GameEventFinishCondition
|
struct GameEventFinishCondition
|
||||||
@@ -104,6 +105,7 @@ class GameEventMgr
|
|||||||
uint32 Update();
|
uint32 Update();
|
||||||
bool IsActiveEvent(uint16 event_id) { return ( m_ActiveEvents.find(event_id)!=m_ActiveEvents.end()); }
|
bool IsActiveEvent(uint16 event_id) { return ( m_ActiveEvents.find(event_id)!=m_ActiveEvents.end()); }
|
||||||
uint32 Initialize();
|
uint32 Initialize();
|
||||||
|
void StartInternalEvent(uint16 event_id);
|
||||||
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
|
||||||
@@ -153,8 +155,8 @@ class GameEventMgr
|
|||||||
GameEventQuestMap mGameEventGameObjectQuests;
|
GameEventQuestMap mGameEventGameObjectQuests;
|
||||||
GameEventNPCVendorMap mGameEventVendors;
|
GameEventNPCVendorMap mGameEventVendors;
|
||||||
GameEventModelEquipMap mGameEventModelEquip;
|
GameEventModelEquipMap mGameEventModelEquip;
|
||||||
GameEventGuidMap mGameEventCreatureGuids;
|
//GameEventGuidMap mGameEventCreatureGuids;
|
||||||
GameEventGuidMap mGameEventGameobjectGuids;
|
//GameEventGuidMap mGameEventGameobjectGuids;
|
||||||
GameEventIdMap mGameEventPoolIds;
|
GameEventIdMap mGameEventPoolIds;
|
||||||
GameEventDataMap mGameEvent;
|
GameEventDataMap mGameEvent;
|
||||||
GameEventBitmask mGameEventBattleGroundHolidays;
|
GameEventBitmask mGameEventBattleGroundHolidays;
|
||||||
@@ -163,6 +165,9 @@ class GameEventMgr
|
|||||||
GuidEventNpcGossipIdMap mNPCGossipIds;
|
GuidEventNpcGossipIdMap mNPCGossipIds;
|
||||||
ActiveEvents m_ActiveEvents;
|
ActiveEvents m_ActiveEvents;
|
||||||
bool isSystemInit;
|
bool isSystemInit;
|
||||||
|
public:
|
||||||
|
GameEventGuidMap mGameEventCreatureGuids;
|
||||||
|
GameEventGuidMap mGameEventGameobjectGuids;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define gameeventmgr Trinity::Singleton<GameEventMgr>::Instance()
|
#define gameeventmgr Trinity::Singleton<GameEventMgr>::Instance()
|
||||||
|
|||||||
Reference in New Issue
Block a user