|
|
Модератор форума: Dimitro |
Форум TrinityCore Патчи / Моды / Фиксы для Trinity Патч на Календарь! (Патч в ядро TC на исправление Календаря.) |
Патч на Календарь! |
Добрый день. Выкладываю скрипт на исправление заполнения событий в календаре!
Многое сталкиваются с проблемой отображения, событий в календаре, после 2011-2012 года. Так вот это решение ваших проблем. Код diff --git a/src/server/game/Calendar/CalendarMgr.h b/src/server/game/Calendar/CalendarMgr.h index ed59037..dbb9c9a 100644 --- a/src/server/game/Calendar/CalendarMgr.h +++ b/src/server/game/Calendar/CalendarMgr.h @@ -262,6 +262,15 @@ struct TC_GAME_API CalendarEvent std::string _title; std::string _description; }; + +struct CalendarDatesData +{ + CalendarDatesData() : duration(0) { } + std::vector<time_t> start; + uint32 duration; +}; + +typedef std::unordered_map<uint32 /* eventId */, CalendarDatesData /* Date, Duration */> CalendarDatesContainer; typedef std::vector<CalendarInvite*> CalendarInviteStore; typedef std::set<CalendarEvent*> CalendarEventStore; typedef std::map<uint64 /* eventId */, CalendarInviteStore > CalendarEventInviteStore; @@ -274,6 +283,7 @@ class TC_GAME_API CalendarMgr CalendarEventStore _events; CalendarEventInviteStore _invites; + CalendarDatesContainer _eventDates; std::deque<uint64> _freeEventIds; std::deque<uint64> _freeInviteIds; @@ -293,6 +303,7 @@ class TC_GAME_API CalendarMgr CalendarEventInviteStore const& GetInvites() const { return _invites; } CalendarInviteStore const& GetEventInvites(uint64 eventId); CalendarInviteStore GetPlayerInvites(ObjectGuid guid); + CalendarDatesContainer const& GetCalendarDates() const { return _eventDates; } void FreeEventId(uint64 id); uint64 GetFreeEventId(); diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp index 4e86fdd..88811e4 100644 --- a/src/server/game/Calendar/CalendarMgr.cpp +++ b/src/server/game/Calendar/CalendarMgr.cpp @@ -23,6 +23,7 @@ #include "GuildMgr.h" #include "ObjectAccessor.h" #include "Opcodes.h" +#include "GameEventMgr.h" CalendarInvite::~CalendarInvite() { @@ -123,6 +124,22 @@ void CalendarMgr::LoadFromDB() for (uint64 i = 1; i < _maxInviteId; ++i) if (!GetInvite(i)) _freeInviteIds.push_back(i); + + GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); + for (auto eventData : events) + { + if (eventData.holiday_id == 0) + continue; + + CalendarDatesData& eventDates = _eventDates[eventData.holiday_id]; + uint64 startTime = eventData.start; + for (uint8 i = 1; i < 11; ++i) + { + eventDates.start.push_back(startTime); + startTime += eventData.occurence * 60; + } + eventDates.duration = eventData.length / 60; + } } void CalendarMgr::AddEvent(CalendarEvent* calendarEvent, CalendarSendEventType sendType) diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp index 8b31483..212aa94 100644 --- a/src/server/game/Handlers/CalendarHandler.cpp +++ b/src/server/game/Handlers/CalendarHandler.cpp @@ -147,29 +147,45 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/) data << uint32(boundCounter); data.append(dataBuffer); - /// @todo Fix this, how we do know how many and what holidays to send? - uint32 holidayCount = 0; - data << uint32(holidayCount); - for (uint32 i = 0; i < holidayCount; ++i) - { - HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(666); - - data << uint32(holiday->Id); // m_ID - data << uint32(holiday->Region); // m_region, might be looping - data << uint32(holiday->Looping); // m_looping, might be region - data << uint32(holiday->Priority); // m_priority - data << uint32(holiday->CalendarFilterType); // m_calendarFilterType + uint32 holidayCount = 15; - for (uint8 j = 0; j < MAX_HOLIDAY_DATES; ++j) - data << uint32(holiday->Date[j]); // 26 * m_date -- WritePackedTime ? - - for (uint8 j = 0; j < MAX_HOLIDAY_DURATIONS; ++j) - data << uint32(holiday->Duration[j]); // 10 * m_duration - - for (uint8 j = 0; j < MAX_HOLIDAY_FLAGS; ++j) - data << uint32(holiday->CalendarFlags[j]); // 10 * m_calendarFlags + data << uint32(holidayCount); - data << holiday->TextureFilename; // m_textureFilename (holiday name) + CalendarDatesContainer const& calendarDates = sCalendarMgr->GetCalendarDates(); + for (CalendarDatesContainer::value_type const& holidayData : calendarDates) + { + HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(holidayData.first); + if (!holiday) + continue; + data << uint32(holiday->Id); + data << uint32(holiday->Region); + data << uint32(holiday->Looping); + data << uint32(holiday->Priority); + data << uint32(holiday->CalendarFilterType); + + uint8 j = 0; + for (uint32 startTime : holidayData.second.start) + { + ++j; + if (j > MAX_HOLIDAY_DATES) + break; + data.AppendPackedTime(startTime); + } + // Fill gap + for (; j < MAX_HOLIDAY_DATES; ++j) + data << uint32(0); + + data << uint32(holidayData.second.duration); + data << uint32(0); + for (uint8 j = 2; j < MAX_HOLIDAY_DURATIONS; ++j) + data << uint32(0); + + data << uint32(3); + data << uint32(0); + for (uint8 j = 2; j < MAX_HOLIDAY_FLAGS; ++j) + data << uint32(0); + data << holiday->TextureFilename; + ++boundCounter; } SendPacket(&data); Всем удачи, и развития проектов! |
Патч не работает. Ошибка при компиляции.
Код [ 26%] Building CXX object src/server/game/CMakeFiles/game.dir/Handlers/CalendarHandler.cpp.o In file included from /opt/wow/03_razrab_rabvers/c/src/server/game/Handlers/CalendarHandler.cpp:43:0: /opt/wow/03_razrab_rabvers/c/src/server/game/Calendar/CalendarMgr.h:286:9: error: ‘CalendarDatesContainer’ does not name a type CalendarDatesContainer _eventDates; ^ /opt/wow/03_razrab_rabvers/c/src/server/game/Calendar/CalendarMgr.h:306:9: error: ‘CalendarDatesContainer’ does not name a type CalendarDatesContainer const& GetCalendarDates() const { return _eventDates; } ^ [ 26%] Building CXX object src/server/scripts/CMakeFiles/scripts.dir/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_anetheron.cpp.o /opt/wow/03_razrab_rabvers/c/src/server/game/Handlers/CalendarHandler.cpp: In member function ‘void WorldSession::HandleCalendarGetCalendar(WorldPacket&)’: /opt/wow/03_razrab_rabvers/c/src/server/game/Handlers/CalendarHandler.cpp:153:5: error: ‘CalendarDatesContainer’ was not declared in this scope CalendarDatesContainer const& calendarDates = sCalendarMgr->GetCalendarDates(); ^ /opt/wow/03_razrab_rabvers/c/src/server/game/Handlers/CalendarHandler.cpp:154:10: error: ‘CalendarDatesContainer’ is not a class, namespace, or enumeration for (CalendarDatesContainer::value_type const& holidayData : calendarDates) ^ /opt/wow/03_razrab_rabvers/c/src/server/game/Handlers/CalendarHandler.cpp:190:21: error: could not convert ‘WorldSession::SendPacket(((const WorldPacket*)(& data)))’ from ‘void’ to ‘bool’ SendPacket(&data); ^ /opt/wow/03_razrab_rabvers/c/src/server/game/Handlers/CalendarHandler.cpp:191:1: error: expected primary-expression before ‘}’ token } ^ /opt/wow/03_razrab_rabvers/c/src/server/game/Handlers/CalendarHandler.cpp:191:1: error: expected ‘)’ before ‘}’ token /opt/wow/03_razrab_rabvers/c/src/server/game/Handlers/CalendarHandler.cpp:191:1: error: expected primary-expression before ‘}’ token [ 26%] Building CXX object src/server/scripts/CMakeFiles/scripts.dir/Kalimdor/CavernsOfTime/BattleForMountHyjal/hyjalAI.cpp.o src/server/game/CMakeFiles/game.dir/build.make:721: ошибка выполнения рецепта для цели «src/server/game/CMakeFiles/game.dir/Handlers/CalendarHandler.cpp.o» make[2]: *** [src/server/game/CMakeFiles/game.dir/Handlers/CalendarHandler.cpp.o] Ошибка 1 CMakeFiles/Makefile2:1133: ошибка выполнения рецепта для цели «src/server/game/CMakeFiles/game.dir/all» make[1]: *** [src/server/game/CMakeFiles/game.dir/all] Ошибка 2 make[1]: *** Ожидание завершения заданий… [ 26%] Building CXX object src/server/scripts/CMakeFiles/scripts.dir/Kalimdor/CavernsOfTime/BattleForMountHyjal/boss_archimonde.cpp.o |
| |||
| |||