Core/Events: announce event system improvement. (#1228)

* DB: update timestamps for #1187
This commit is contained in:
Viste(Кирилл)
2019-01-08 16:15:38 +03:00
committed by GitHub
parent 2f5653c24f
commit 31bce00b2a
3 changed files with 18 additions and 10 deletions

View File

@@ -0,0 +1,11 @@
INSERT INTO version_db_world (`sql_rev`) VALUES ('1546538959760274673');
ALTER TABLE `game_event`
ADD COLUMN `announce` tinyint(3) unsigned NOT NULL DEFAULT 2 COMMENT '0 dont announce, 1 announce, 2 value from config' AFTER `world_event`;
ALTER TABLE `game_event`
CHANGE `start_time` `start_time` TIMESTAMP NULL DEFAULT NULL COMMENT 'Absolute start date, the event will never start before',
CHANGE `end_time` `end_time` TIMESTAMP NULL DEFAULT NULL COMMENT 'Absolute end date, the event will never start after';
UPDATE `game_event` SET `start_time`=NULL WHERE `start_time`='0000-00-00 00:00:00';
UPDATE `game_event` SET `end_time`=NULL WHERE `end_time`='0000-00-00 00:00:00';

View File

@@ -209,8 +209,8 @@ void GameEventMgr::LoadFromDB()
{
{
uint32 oldMSTime = getMSTime();
// 1 2 3 4 5 6 7 8 9
QueryResult result = WorldDatabase.Query("SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, holidayStage, description, world_event FROM game_event");
// 1 2 3 4 5 6 7 8 9 10
QueryResult result = WorldDatabase.Query("SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, holidayStage, description, world_event, announce FROM game_event");
if (!result)
{
mGameEvent.clear();
@@ -243,6 +243,7 @@ void GameEventMgr::LoadFromDB()
pGameEvent.holidayStage = fields[6].GetUInt8();
pGameEvent.description = fields[7].GetString();
pGameEvent.state = (GameEventState)(fields[8].GetUInt8());
pGameEvent.announce = fields[9].GetUInt8();
pGameEvent.nextstart = 0;
++count;
@@ -1189,14 +1190,9 @@ void GameEventMgr::UnApplyEvent(uint16 event_id)
void GameEventMgr::ApplyNewEvent(uint16 event_id)
{
switch (sWorld->getIntConfig(CONFIG_EVENT_ANNOUNCE))
{
case 0: // disable
break;
case 1: // announce events
sWorld->SendWorldText(LANG_EVENTMESSAGE, mGameEvent[event_id].description.c_str());
break;
}
uint8 announce = mGameEvent[event_id].announce;
if (announce == 1 || (announce == 2 && sWorld->getIntConfig(CONFIG_EVENT_ANNOUNCE)))
sWorld->SendWorldText(LANG_EVENTMESSAGE, mGameEvent[event_id].description.c_str());
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDetail("GameEvent %u \"%s\" started.", event_id, mGameEvent[event_id].description.c_str());

View File

@@ -55,6 +55,7 @@ struct GameEventData
GameEventConditionMap conditions; // conditions to finish
std::set<uint16 /*gameevent id*/> prerequisite_events; // events that must be completed before starting this event
std::string description;
uint8 announce; // if 0 dont announce, if 1 announce, if 2 take config value
bool isValid() const { return length > 0 || state > GAMEEVENT_NORMAL; }
};