diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index c762e15bb..8318f5389 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -1670,8 +1670,8 @@ struct TaxiPathNodeEntry float z; // 6 m_LocZ uint32 actionFlag; // 7 m_flags uint32 delay; // 8 m_delay - // 9 m_arrivalEventID - // 10 m_departureEventID + uint32 arrivalEventID; // 9 m_arrivalEventID + uint32 departureEventID; // 10 m_departureEventID }; struct TotemCategoryEntry diff --git a/src/game/DBCfmt.h b/src/game/DBCfmt.h index 8c2fc6757..d4c265164 100644 --- a/src/game/DBCfmt.h +++ b/src/game/DBCfmt.h @@ -102,7 +102,7 @@ const char TalentEntryfmt[]="niiiiiiiixxxxixxixxxxxx"; const char TalentTabEntryfmt[]="nxxxxxxxxxxxxxxxxxxxiiix"; const char TaxiNodesEntryfmt[]="nifffssssssssssssssssxii"; const char TaxiPathEntryfmt[]="niii"; -const char TaxiPathNodeEntryfmt[]="diiifffiixx"; +const char TaxiPathNodeEntryfmt[]="diiifffiiii"; const char TotemCategoryEntryfmt[]="nxxxxxxxxxxxxxxxxxii"; const char VehicleEntryfmt[]="niffffiiiiiiiifffffffffffffffssssfifixxx"; const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxx"; diff --git a/src/game/GameObject.h b/src/game/GameObject.h index bd98ae817..0e48cb722 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -503,6 +503,17 @@ struct GameObjectInfo default: return 0; } } + + uint32 GetEventScriptId() const + { + switch(type) + { + case GAMEOBJECT_TYPE_GOOBER: return goober.eventId; + case GAMEOBJECT_TYPE_CHEST: return chest.eventId; + case GAMEOBJECT_TYPE_CAMERA: return camera.eventID; + default: return 0; + } + } }; // GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index a4bede62b..6c94eb4fb 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -4508,30 +4508,13 @@ void ObjectMgr::LoadEventScripts() LoadScripts(sEventScripts, "event_scripts"); std::set evt_scripts; + // Load all possible script entries from gameobjects for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i) - { - GameObjectInfo const * goInfo = sGOStorage.LookupEntry(i); - if (goInfo) - { - switch(goInfo->type) - { - case GAMEOBJECT_TYPE_GOOBER: - if (goInfo->goober.eventId) - evt_scripts.insert(goInfo->goober.eventId); - break; - case GAMEOBJECT_TYPE_CHEST: - if (goInfo->chest.eventId) - evt_scripts.insert(goInfo->chest.eventId); - break; - case GAMEOBJECT_TYPE_CAMERA: - if (goInfo->camera.eventID) - evt_scripts.insert(goInfo->camera.eventID); - default: - break; - } - } - } + if (GameObjectInfo const * goInfo = sGOStorage.LookupEntry(i)) + if (uint32 eventId = goInfo->GetEventScriptId()) + evt_scripts.insert(eventId); + // Load all possible script entries from spells for(uint32 i = 1; i < sSpellStore.GetNumRows(); ++i) { @@ -4548,12 +4531,27 @@ void ObjectMgr::LoadEventScripts() } } } + + for(size_t path_idx = 0; path_idx < sTaxiPathNodesByPath.size(); ++path_idx) + { + for(size_t node_idx = 0; node_idx < sTaxiPathNodesByPath[path_idx].size(); ++node_idx) + { + TaxiPathNodeEntry const& node = sTaxiPathNodesByPath[path_idx][node_idx]; + + if (node.arrivalEventID) + evt_scripts.insert(node.arrivalEventID); + + if (node.departureEventID) + evt_scripts.insert(node.departureEventID); + } + } + // Then check if all scripts are in above list of possible script entries for(ScriptMapMap::const_iterator itr = sEventScripts.begin(); itr != sEventScripts.end(); ++itr) { std::set::const_iterator itr2 = evt_scripts.find(itr->first); if (itr2 == evt_scripts.end()) - sLog.outErrorDb("Table `event_scripts` has script (Id: %u) not referring to any gameobject_template type 10 data2 field, type 3 data6 field, type 13 data 2 field or any spell effect %u", + sLog.outErrorDb("Table `event_scripts` has script (Id: %u) not referring to any gameobject_template type 10 data2 field, type 3 data6 field, type 13 data 2 field or any spell effect %u or path taxi node data", itr->first, SPELL_EFFECT_SEND_EVENT); } } diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 9fa47d792..79e4c3708 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -310,7 +310,8 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set &mapids) if (keyFrames[keyFrames.size() - 1].node->mapid != keyFrames[0].node->mapid) teleport = true; - WayPoint pos(keyFrames[0].node->mapid, keyFrames[0].node->x, keyFrames[0].node->y, keyFrames[0].node->z, teleport); + WayPoint pos(keyFrames[0].node->mapid, keyFrames[0].node->x, keyFrames[0].node->y, keyFrames[0].node->z, teleport, + keyFrames[0].node->arrivalEventID, keyFrames[0].node->departureEventID); m_WayPoints[0] = pos; t += keyFrames[0].node->delay * 1000; @@ -390,7 +391,8 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set &mapids) cM = keyFrames[i + 1].node->mapid; } - WayPoint pos(keyFrames[i + 1].node->mapid, keyFrames[i + 1].node->x, keyFrames[i + 1].node->y, keyFrames[i + 1].node->z, teleport); + WayPoint pos(keyFrames[i + 1].node->mapid, keyFrames[i + 1].node->x, keyFrames[i + 1].node->y, keyFrames[i + 1].node->z, teleport, + keyFrames[i + 1].node->arrivalEventID, keyFrames[i + 1].node->departureEventID); // sLog.outString("T: %d, x: %f, y: %f, z: %f, t:%d", t, pos.x, pos.y, pos.z, teleport); @@ -490,9 +492,14 @@ void Transport::Update(time_t /*p_time*/) m_timer = getMSTime() % m_period; while (((m_timer - m_curr->first) % m_pathTime) > ((m_next->first - m_curr->first) % m_pathTime)) { + + DoEventIfAny(*m_curr,true); + m_curr = GetNextWayPoint(); m_next = GetNextWayPoint(); + DoEventIfAny(*m_curr,false); + // first check help in case client-server transport coordinates de-synchronization if (m_curr->second.mapid != GetMapId() || m_curr->second.teleport) { @@ -554,3 +561,12 @@ void Transport::UpdateForMap(Map const* targetMap) itr->getSource()->SendDirectMessage(&out_packet); } } + +void Transport::DoEventIfAny(WayPointMap::value_type const& node, bool departure) +{ + if (uint32 eventid = departure ? node.second.departureEventID : node.second.arrivalEventID) + { + DEBUG_LOG("Taxi %s event %u of node %u of %s (%s) path", departure ? "departure" : "arrival", eventid, node.first, GetName(), GetObjectGuid().GetString().c_str()); + GetMap()->ScriptsStart(sEventScripts, eventid, this, this); + } +} diff --git a/src/game/Transports.h b/src/game/Transports.h index 8925bd0e7..bbaffbcb7 100644 --- a/src/game/Transports.h +++ b/src/game/Transports.h @@ -43,13 +43,19 @@ class Transport : public GameObject struct WayPoint { WayPoint() : mapid(0), x(0), y(0), z(0), teleport(false) {} - WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport) : - mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport) {} + WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport, uint32 _arrivalEventID = 0, uint32 _departureEventID = 0) + : mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport), + arrivalEventID(_arrivalEventID), departureEventID(_departureEventID) + { + } + uint32 mapid; float x; float y; float z; bool teleport; + uint32 arrivalEventID; + uint32 departureEventID; }; typedef std::map WayPointMap; @@ -69,6 +75,7 @@ class Transport : public GameObject private: void TeleportTransport(uint32 newMapid, float x, float y, float z); void UpdateForMap(Map const* map); + void DoEventIfAny(WayPointMap::value_type const& node, bool departure); WayPointMap::const_iterator GetNextWayPoint(); }; #endif diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index b10120eb0..c5ff21c64 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -356,10 +356,14 @@ bool FlightPathMovementGenerator::Update(Player &player, const uint32 &diff) i_destinationHolder.ResetUpdate(FLIGHT_TRAVEL_UPDATE); if (i_destinationHolder.HasArrived()) { + DoEventIfAny(player,(*i_path)[i_currentNode],false); + uint32 curMap = (*i_path)[i_currentNode].mapid; ++i_currentNode; if (MovementInProgress()) { + DoEventIfAny(player,(*i_path)[i_currentNode],true); + DEBUG_LOG("loading node %u for player %s", i_currentNode, player.GetName()); if ((*i_path)[i_currentNode].mapid == curMap) { @@ -368,7 +372,6 @@ bool FlightPathMovementGenerator::Update(Player &player, const uint32 &diff) } return true; } - //else HasArrived() } else return true; @@ -398,6 +401,15 @@ void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport() } } +void FlightPathMovementGenerator::DoEventIfAny(Player& player, TaxiPathNodeEntry const& node, bool departure) +{ + if (uint32 eventid = departure ? node.departureEventID : node.arrivalEventID) + { + DEBUG_LOG("Taxi %s event %u of node %u of path %u for player %s", departure ? "departure" : "arrival", eventid, node.index, node.path, player.GetName()); + player.GetMap()->ScriptsStart(sEventScripts, eventid, &player, &player); + } +} + // // Unique1's ASTAR Pathfinding Code... For future use & reference... // diff --git a/src/game/WaypointMovementGenerator.h b/src/game/WaypointMovementGenerator.h index e852fdaf6..7f4e41275 100644 --- a/src/game/WaypointMovementGenerator.h +++ b/src/game/WaypointMovementGenerator.h @@ -130,6 +130,7 @@ public PathMovementBase bool HasArrived() const { return (i_currentNode >= i_path->size()); } void SetCurrentNodeAfterTeleport(); void SkipCurrentNode() { ++i_currentNode; } + void DoEventIfAny(Player& player, TaxiPathNodeEntry const& node, bool departure); // allow use for overwrite empty implementation bool GetDestination(float& x, float& y, float& z) const { return PathMovementBase::GetDestination(x,y,z); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index d945bc623..bdf65c164 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9829" + #define REVISION_NR "9830" #endif // __REVISION_NR_H__