[7393] Implement access to client side holiday ids. Author: VladimirMangos

* src/game/GameEvent.* renamed to src/game/GameEventMgr.* for consistence
    * `game_event` now have new `holiday` field for store client side holiday id associated with game event
    * Added new enum HolidayIds with existed at this moment holiday ids.
    * New function "bool IsHolidayActive(HolidayIds id)" added accessabel from scripts for active holidays check.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-06 19:36:47 -06:00
parent 0d53225fdc
commit 417c7c8319
20 changed files with 103 additions and 1812 deletions
+2 -2
View File
@@ -21,10 +21,10 @@
#include "Player.h"
#include "WorldPacket.h"
#include "Database/DBCEnums.h"
#include "GameEventMgr.h"
#include "ObjectMgr.h"
#include "Guild.h"
#include "Database/DatabaseEnv.h"
#include "GameEvent.h"
#include "World.h"
#include "SpellMgr.h"
#include "ArenaTeam.h"
@@ -607,7 +607,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
if(Player::GetDrunkenstateByValue(GetPlayer()->GetDrunkValue()) != DRUNKEN_SMASHED)
continue;
// TODO: hardcoding eventid is bad, it can differ from DB to DB - maye implement something using HolidayNames.dbc?
if(!gameeventmgr.IsActiveEvent(26))
if(!IsHolidayActive(HOLIDAY_BREWFEST))
continue;
}
// miscvalue1 is the ingame fallheight*100 as stored in dbc
+1 -1
View File
@@ -46,7 +46,7 @@
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
#include "OutdoorPvPMgr.h"
#include "GameEvent.h"
#include "GameEventMgr.h"
#include "PossessedAI.h"
#include "CreatureGroups.h"
// apply implementation of the singletons
File diff suppressed because it is too large Load Diff
-166
View File
@@ -1,166 +0,0 @@
/*
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TRINITY_GAMEEVENT_H
#define TRINITY_GAMEEVENT_H
#include "Platform/Define.h"
#include "Creature.h"
#include "GameObject.h"
#define max_ge_check_delay 86400 // 1 day in seconds
enum GameEventState
{
GAMEEVENT_NORMAL = 0, // standard game events
GAMEEVENT_WORLD_INACTIVE, // not yet started
GAMEEVENT_WORLD_CONDITIONS, // condition matching phase
GAMEEVENT_WORLD_NEXTPHASE, // conditions are met, now 'lenght' timer to start next event
GAMEEVENT_WORLD_FINISHED // next events are started, unapply this one
};
struct GameEventFinishCondition
{
float reqNum; // required number // use float, since some events use percent
float done; // done number
uint32 max_world_state; // max resource count world state update id
uint32 done_world_state; // done resource count world state update id
};
struct GameEventQuestToEventConditionNum
{
uint16 event_id;
uint32 condition;
float num;
};
struct GameEventData
{
GameEventData() : start(1),end(0),nextstart(0),occurence(0),length(0),state(GAMEEVENT_NORMAL) {}
time_t start; // occurs after this time
time_t end; // occurs before this time
time_t nextstart; // after this time the follow-up events count this phase completed
uint32 occurence; // time between end and start
uint32 length; // length of the event (minutes) after finishing all conditions
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
std::set<uint16 /*gameevent id*/> prerequisite_events; // events that must be completed before starting this event
std::string description;
bool isValid() const { return ((length > 0) || (state > GAMEEVENT_NORMAL)); }
};
struct ModelEquip
{
uint32 modelid;
uint32 equipment_id;
uint32 modelid_prev;
uint32 equipement_id_prev;
};
struct NPCVendorEntry
{
uint32 entry; // creature entry
uint32 item; // item id
uint32 maxcount; // 0 for infinite
uint32 incrtime; // time for restore items amount if maxcount != 0
uint32 ExtendedCost;
};
class Player;
class GameEvent
{
public:
GameEvent();
~GameEvent() {};
typedef std::set<uint16> ActiveEvents;
typedef std::vector<GameEventData> GameEventDataMap;
ActiveEvents const& GetActiveEventList() const { return m_ActiveEvents; }
GameEventDataMap const& GetEventMap() const { return mGameEvent; }
bool CheckOneGameEvent(uint16 entry) const;
uint32 NextCheck(uint16 entry) const;
void LoadFromDB();
uint32 Update();
bool IsActiveEvent(uint16 event_id) { return ( m_ActiveEvents.find(event_id)!=m_ActiveEvents.end()); }
uint32 Initialize();
bool StartEvent(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 HandleWorldEventGossip(Player * plr, Creature * c);
uint32 GetNPCFlag(Creature * cr);
uint32 GetNpcTextId(uint32 guid);
private:
void SendWorldStateUpdate(Player * plr, uint16 event_id);
void AddActiveEvent(uint16 event_id) { m_ActiveEvents.insert(event_id); }
void RemoveActiveEvent(uint16 event_id) { m_ActiveEvents.erase(event_id); }
void ApplyNewEvent(uint16 event_id);
void UnApplyEvent(uint16 event_id);
void GameEventSpawn(int16 event_id);
void GameEventUnspawn(int16 event_id);
void ChangeEquipOrModel(int16 event_id, bool activate);
void UpdateEventQuests(uint16 event_id, bool Activate);
void UpdateEventNPCFlags(uint16 event_id);
void UpdateEventNPCVendor(uint16 event_id, bool activate);
void UpdateBattleGroundSettings();
bool CheckOneGameEventConditions(uint16 event_id);
void SaveWorldEventStateToDB(uint16 event_id);
bool hasCreatureQuestActiveEventExcept(uint32 quest_id, uint16 event_id);
bool hasGameObjectQuestActiveEventExcept(uint32 quest_id, uint16 event_id);
bool hasCreatureActiveEventExcept(uint32 creature_guid, uint16 event_id);
bool hasGameObjectActiveEventExcept(uint32 go_guid, uint16 event_id);
protected:
typedef std::list<uint32> GuidList;
typedef std::list<uint16> IdList;
typedef std::vector<GuidList> GameEventGuidMap;
typedef std::vector<IdList> GameEventIdMap;
typedef std::pair<uint32, ModelEquip> ModelEquipPair;
typedef std::list<ModelEquipPair> ModelEquipList;
typedef std::vector<ModelEquipList> GameEventModelEquipMap;
typedef std::pair<uint32, uint32> QuestRelation;
typedef std::list<QuestRelation> QuestRelList;
typedef std::vector<QuestRelList> GameEventQuestMap;
typedef std::list<NPCVendorEntry> NPCVendorList;
typedef std::vector<NPCVendorList> GameEventNPCVendorMap;
typedef std::map<uint32 /*quest id*/, GameEventQuestToEventConditionNum> QuestIdToEventConditionMap;
typedef std::pair<uint32 /*guid*/, uint32 /*npcflag*/> GuidNPCFlagPair;
typedef std::list<GuidNPCFlagPair> NPCFlagList;
typedef std::vector<NPCFlagList> GameEventNPCFlagMap;
typedef std::pair<uint16 /*event id*/, uint32 /*gossip id*/> EventNPCGossipIdPair;
typedef std::map<uint32 /*guid*/, EventNPCGossipIdPair> GuidEventNpcGossipIdMap;
typedef std::vector<uint32> GameEventBitmask;
GameEventQuestMap mGameEventCreatureQuests;
GameEventQuestMap mGameEventGameObjectQuests;
GameEventNPCVendorMap mGameEventVendors;
GameEventModelEquipMap mGameEventModelEquip;
GameEventGuidMap mGameEventCreatureGuids;
GameEventGuidMap mGameEventGameobjectGuids;
GameEventIdMap mGameEventPoolIds;
GameEventDataMap mGameEvent;
GameEventBitmask mGameEventBattleGroundHolidays;
QuestIdToEventConditionMap mQuestToEventConditions;
GameEventNPCFlagMap mGameEventNPCFlags;
GuidEventNpcGossipIdMap mNPCGossipIds;
ActiveEvents m_ActiveEvents;
bool isSystemInit;
};
#define gameeventmgr Trinity::Singleton<GameEvent>::Instance()
#endif
+14 -14
View File
@@ -33,7 +33,7 @@
#include "MapManager.h"
#include "Language.h"
#include "World.h"
#include "GameEvent.h"
#include "GameEventMgr.h"
#include "SpellMgr.h"
#include "PoolHandler.h"
#include "AccountMgr.h"
@@ -164,7 +164,7 @@ bool ChatHandler::HandleTargetObjectCommand(const char* args)
{
Player* pl = m_session->GetPlayer();
QueryResult *result;
GameEvent::ActiveEvents const& activeEventsList = gameeventmgr.GetActiveEventList();
GameEventMgr::ActiveEvents const& activeEventsList = gameeventmgr.GetActiveEventList();
if(*args)
{
int32 id = atoi((char*)args);
@@ -187,7 +187,7 @@ bool ChatHandler::HandleTargetObjectCommand(const char* args)
eventFilter << " AND (event IS NULL ";
bool initString = true;
for (GameEvent::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
for (GameEventMgr::ActiveEvents::const_iterator itr = activeEventsList.begin(); itr != activeEventsList.end(); ++itr)
{
if (initString)
{
@@ -3509,8 +3509,8 @@ bool ChatHandler::HandleLookupEventCommand(const char* args)
uint32 counter = 0;
GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap();
GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList();
GameEventMgr::GameEventDataMap const& events = gameeventmgr.GetEventMap();
GameEventMgr::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList();
for(uint32 id = 0; id < events.size(); ++id )
{
@@ -3543,12 +3543,12 @@ bool ChatHandler::HandleEventActiveListCommand(const char* args)
{
uint32 counter = 0;
GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap();
GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList();
GameEventMgr::GameEventDataMap const& events = gameeventmgr.GetEventMap();
GameEventMgr::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList();
char const* active = GetTrinityString(LANG_ACTIVE);
for(GameEvent::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr )
for(GameEventMgr::ActiveEvents::const_iterator itr = activeEvents.begin(); itr != activeEvents.end(); ++itr )
{
uint32 event_id = *itr;
GameEventData const& eventData = events[event_id];
@@ -3579,7 +3579,7 @@ bool ChatHandler::HandleEventInfoCommand(const char* args)
uint32 event_id = atoi(cId);
GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap();
GameEventMgr::GameEventDataMap const& events = gameeventmgr.GetEventMap();
if(event_id >=events.size())
{
@@ -3596,7 +3596,7 @@ bool ChatHandler::HandleEventInfoCommand(const char* args)
return false;
}
GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList();
GameEventMgr::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList();
bool active = activeEvents.find(event_id) != activeEvents.end();
char const* activeStr = active ? GetTrinityString(LANG_ACTIVE) : "";
@@ -3628,7 +3628,7 @@ bool ChatHandler::HandleEventStartCommand(const char* args)
int32 event_id = atoi(cId);
GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap();
GameEventMgr::GameEventDataMap const& events = gameeventmgr.GetEventMap();
if(event_id < 1 || event_id >=events.size())
{
@@ -3645,7 +3645,7 @@ bool ChatHandler::HandleEventStartCommand(const char* args)
return false;
}
GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList();
GameEventMgr::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList();
if(activeEvents.find(event_id) != activeEvents.end())
{
PSendSysMessage(LANG_EVENT_ALREADY_ACTIVE,event_id);
@@ -3669,7 +3669,7 @@ bool ChatHandler::HandleEventStopCommand(const char* args)
int32 event_id = atoi(cId);
GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap();
GameEventMgr::GameEventDataMap const& events = gameeventmgr.GetEventMap();
if(event_id < 1 || event_id >=events.size())
{
@@ -3686,7 +3686,7 @@ bool ChatHandler::HandleEventStopCommand(const char* args)
return false;
}
GameEvent::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList();
GameEventMgr::ActiveEvents const& activeEvents = gameeventmgr.GetActiveEventList();
if(activeEvents.find(event_id) == activeEvents.end())
{
+2 -2
View File
@@ -115,8 +115,8 @@ libmangosgame_a_SOURCES = \
FleeingMovementGenerator.cpp \
FleeingMovementGenerator.h \
Formulas.h \
GameEvent.cpp \
GameEvent.h \
GameEventMgr.cpp \
GameEventMgr.h \
GameObject.cpp \
GameObject.h \
GlobalEvents.cpp \
+2 -2
View File
@@ -37,7 +37,7 @@
#include "Transports.h"
#include "ProgressBar.h"
#include "Language.h"
#include "GameEvent.h"
#include "GameEventMgr.h"
#include "Spell.h"
#include "Chat.h"
#include "AccountMgr.h"
@@ -6944,7 +6944,7 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val
}
case CONDITION_ACTIVE_EVENT:
{
GameEvent::GameEventDataMap const& events = gameeventmgr.GetEventMap();
GameEventMgr::GameEventDataMap const& events = gameeventmgr.GetEventMap();
if(value1 >=events.size() || !events[value1].isValid())
{
sLog.outErrorDb("Active event condition requires existed event id (%u), skipped", value1);
+1 -1
View File
@@ -63,7 +63,7 @@
#include "Database/DatabaseImpl.h"
#include "Spell.h"
#include "SocialMgr.h"
#include "GameEvent.h"
#include "GameEventMgr.h"
#include "AchievementMgr.h"
#include <cmath>
+25
View File
@@ -1672,6 +1672,31 @@ enum CreatureEliteType
CREATURE_UNKNOWN = 5 // found in 2.2.3 for 2 mobs
};
// values based at Holidays.dbc
enum HolidayIds
{
HOLIDAY_FIREWORKS_SPECTACULAR = 62,
HOLIDAY_FEAST_OF_WINTER_VEIL = 141,
HOLIDAY_NOBLEGARDEN = 181,
HOLIDAY_CHILDRENS_WEEK = 201,
HOLIDAY_CALL_TO_ARMS_AV = 283,
HOLIDAY_CALL_TO_ARMS_WG = 284,
HOLIDAY_CALL_TO_ARMS_AB = 285,
HOLIDAY_FISHING_EXTRAVAGANZA = 301,
HOLIDAY_HARVEST_FESTIVAL = 321,
HOLIDAY_HALLOWS_END = 324,
HOLIDAY_LUNAR_FESTIVAL = 327,
HOLIDAY_LOVE_IS_IN_THE_AIR = 335,
HOLIDAY_FIRE_FESTIVAL = 341,
HOLIDAY_CALL_TO_ARMS_ES = 353,
HOLIDAY_BREWFEST = 372,
HOLIDAY_DARKMOON_FAIRE_ELWYNN = 374,
HOLIDAY_DARKMOON_FAIRE_THUNDER = 375,
HOLIDAY_DARKMOON_FAIRE_SHATTRATH = 376,
HOLIDAY_CALL_TO_ARMS_SA = 400,
HOLIDAY_WOTLK_LAUNCH = 406
};
// values based at QuestInfo.dbc
enum QuestTypes
{
+1 -1
View File
@@ -56,7 +56,7 @@
#include "WaypointMovementGenerator.h"
#include "VMapFactory.h"
#include "GlobalEvents.h"
#include "GameEvent.h"
#include "GameEventMgr.h"
#include "PoolHandler.h"
#include "Database/DatabaseImpl.h"
#include "GridNotifiersImpl.h"
+3 -1
View File
@@ -77,6 +77,7 @@ DBCStorage <GtOCTRegenHPEntry> sGtOCTRegenHPStore(GtOCTRegenHPfmt);
//DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore(GtOCTRegenMPfmt); -- not used currently
DBCStorage <GtRegenHPPerSptEntry> sGtRegenHPPerSptStore(GtRegenHPPerSptfmt);
DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore(GtRegenMPPerSptfmt);
DBCStorage <HolidaysEntry> sHolidaysStore(Holidaysfmt);
DBCStorage <ItemEntry> sItemStore(Itemfmt);
//DBCStorage <ItemCondExtCostsEntry> sItemCondExtCostsStore(ItemCondExtCostsEntryfmt);
//DBCStorage <ItemDisplayInfoEntry> sItemDisplayInfoStore(ItemDisplayTemplateEntryfmt); -- not used currently
@@ -195,7 +196,7 @@ void LoadDBCStores(const std::string& dataPath)
{
std::string dbcPath = dataPath+"dbc/";
const uint32 DBCFilesCount = 72;
const uint32 DBCFilesCount = 73;
barGoLink bar( DBCFilesCount );
@@ -268,6 +269,7 @@ void LoadDBCStores(const std::string& dataPath)
//LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtOCTRegenMPStore, dbcPath,"gtOCTRegenMP.dbc"); -- not used currently
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtRegenHPPerSptStore, dbcPath,"gtRegenHPPerSpt.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGtRegenMPPerSptStore, dbcPath,"gtRegenMPPerSpt.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sHolidaysStore, dbcPath,"Holidays.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemStore, dbcPath,"Item.dbc");
//LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemDisplayInfoStore, dbcPath,"ItemDisplayInfo.dbc"); -- not used currently
//LoadDBC(availableDbcLocales,bar,bad_dbc_files,sItemCondExtCostsStore, dbcPath,"ItemCondExtCosts.dbc");
+1
View File
@@ -169,6 +169,7 @@ extern DBCStorage <GtOCTRegenHPEntry> sGtOCTRegenHPStore;
//extern DBCStorage <GtOCTRegenMPEntry> sGtOCTRegenMPStore; -- not used currently
extern DBCStorage <GtRegenHPPerSptEntry> sGtRegenHPPerSptStore;
extern DBCStorage <GtRegenMPPerSptEntry> sGtRegenMPPerSptStore;
extern DBCStorage <HolidaysEntry> sHolidaysStore;
extern DBCStorage <ItemEntry> sItemStore;
//extern DBCStorage <ItemDisplayInfoEntry> sItemDisplayInfoStore; -- not used currently
extern DBCStorage <ItemExtendedCostEntry> sItemExtendedCostStore;
+34
View File
@@ -861,6 +861,40 @@ struct GtRegenMPPerSptEntry
float ratio;
};
/* no used
struct HolidayDescriptionsEntry
{
uint32 ID; // 0, this is NOT holiday id
//char* name[16] // 1-16 m_name_lang
// 17 name flags
};
*/
/* no used
struct HolidayNamesEntry
{
uint32 ID; // 0, this is NOT holiday id
//char* name[16] // 1-16 m_name_lang
// 17 name flags
};
*/
struct HolidaysEntry
{
uint32 ID; // 0, holiday id
//uint32 unk1; // 1
//uint32 unk2; // 2
//uint32 unk3[8] // 3-10, empty fields
//uint32 unk11[13] // 11-23, some unknown data (bit strings?)
//uint32 unk11[13] // 24-36, some empty fields (continue prev?)
//uint32 unk11[12] // 37-48, counters?
//uint32 holidayNameId; // 49, id for HolidayNames.dbc
//uint32 holidayDescriptionId; // 50, id for HolidayDescriptions.dbc
//uint32 unk51; // 51
//uint32 unk52; // 52
//uint32 unk53; // 53
};
struct ItemEntry
{
uint32 ID; // 0
+1
View File
@@ -55,6 +55,7 @@ const char GtOCTRegenHPfmt[]="f";
//const char GtOCTRegenMPfmt[]="f";
const char GtRegenHPPerSptfmt[]="f";
const char GtRegenMPPerSptfmt[]="f";
const char Holidaysfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const char Itemfmt[]="nixiiiii";
//const char ItemDisplayTemplateEntryfmt[]="nxxxxxxxxxxixxxxxxxxxxx";
//const char ItemCondExtCostsEntryfmt[]="xiii";
+1 -1
View File
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "7392"
#define REVISION_NR "7393"
#endif // __REVISION_NR_H__