aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp10
-rw-r--r--src/server/game/Entities/Player/Player.cpp9
-rw-r--r--src/server/game/Entities/Transport/Transport.cpp66
-rw-r--r--src/server/game/Entities/Transport/Transport.h3
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp12
-rw-r--r--src/server/game/Globals/ObjectMgr.h1
-rw-r--r--src/server/game/Instances/InstanceScript.h4
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp4
-rw-r--r--src/server/game/Scripting/ScriptMgr.h4
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp18
10 files changed, 91 insertions, 40 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index a9404046175..52205572ac9 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -153,6 +153,14 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
SetPhaseMask(phaseMask,false);
+ SetZoneScript();
+ if (m_zoneScript)
+ {
+ name_id = m_zoneScript->GetGameObjectEntry(guidlow, name_id);
+ if (!name_id)
+ return false;
+ }
+
GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(name_id);
if (!goinfo)
{
@@ -211,8 +219,6 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa
break;
}
- SetZoneScript();
-
LastUsedScriptID = GetGOInfo()->ScriptId;
return true;
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 74d7d493c32..da73db377be 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -16066,10 +16066,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
// currently we do not support transport in bg
else if (transGUID)
{
- // There are no transports on instances
- instanceId = 0;
-
- m_movementInfo.t_guid = MAKE_NEW_GUID(transGUID, 0, HIGHGUID_TRANSPORT);
+ m_movementInfo.t_guid = MAKE_NEW_GUID(transGUID, 0, HIGHGUID_MO_TRANSPORT);
m_movementInfo.t_pos.Relocate(fields[26].GetFloat(), fields[27].GetFloat(), fields[28].GetFloat(), fields[29].GetFloat());
if (!Trinity::IsValidMapCoord(
@@ -16078,7 +16075,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
// transport size limited
m_movementInfo.t_pos.m_positionX > 250 || m_movementInfo.t_pos.m_positionY > 250 || m_movementInfo.t_pos.m_positionZ > 250)
{
- sLog.outError("Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.",
+ sLog.outError("Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to bind location.",
guid,GetPositionX()+m_movementInfo.t_pos.m_positionX,GetPositionY()+m_movementInfo.t_pos.m_positionY,
GetPositionZ()+m_movementInfo.t_pos.m_positionZ,GetOrientation()+m_movementInfo.t_pos.m_orientation);
@@ -16098,7 +16095,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
}
if (!m_transport)
{
- sLog.outError("Player (guidlow %d) have problems with transport guid (%u). Teleport to default race/class locations.",
+ sLog.outError("Player (guidlow %d) have problems with transport guid (%u). Teleport to bind location.",
guid,transGUID);
RelocateToHomebind();
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index 66e6a89328c..fe4b0b09a7e 100644
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -31,7 +31,7 @@
void MapManager::LoadTransports()
{
- QueryResult_AutoPtr result = WorldDatabase.Query("SELECT entry, name, period, ScriptName FROM transports");
+ QueryResult_AutoPtr result = WorldDatabase.Query("SELECT guid, entry, name, period, ScriptName FROM transports");
uint32 count = 0;
@@ -52,10 +52,11 @@ void MapManager::LoadTransports()
bar.step();
Field *fields = result->Fetch();
- uint32 entry = fields[0].GetUInt32();
- std::string name = fields[1].GetCppString();
- uint32 period = fields[2].GetUInt32();
- uint32 scriptId = sObjectMgr.GetScriptId(fields[3].GetString());
+ uint32 lowguid = fields[0].GetUInt32();
+ uint32 entry = fields[1].GetUInt32();
+ std::string name = fields[2].GetCppString();
+ uint32 period = fields[3].GetUInt32();
+ uint32 scriptId = sObjectMgr.GetScriptId(fields[4].GetString());
Transport *t = new Transport(period, scriptId);
@@ -87,12 +88,14 @@ void MapManager::LoadTransports()
continue;
}
- float x, y, z, o;
- uint32 mapid;
- x = t->m_WayPoints[0].x; y = t->m_WayPoints[0].y; z = t->m_WayPoints[0].z; mapid = t->m_WayPoints[0].mapid; o = 1;
+ float x = t->m_WayPoints[0].x;
+ float y = t->m_WayPoints[0].y;
+ float z = t->m_WayPoints[0].z;
+ uint32 mapid = t->m_WayPoints[0].mapid;
+ float o = 1.0f;
// creates the Gameobject
- if (!t->Create(entry, mapid, x, y, z, o, 100, 0))
+ if (!t->Create(lowguid, entry, mapid, x, y, z, o, 100, 0))
{
delete t;
continue;
@@ -184,7 +187,23 @@ Transport::Transport(uint32 period, uint32 script) : GameObject(), m_period(peri
m_updateFlag = (UPDATEFLAG_TRANSPORT | UPDATEFLAG_HIGHGUID | UPDATEFLAG_HAS_POSITION | UPDATEFLAG_ROTATION);
}
-bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags)
+Transport::~Transport()
+{
+ std::set<uint64>::iterator it2;
+ for (std::set<uint64>::iterator itr = m_NPCPassengerSet.begin(); itr != m_NPCPassengerSet.end();)
+ {
+ it2 = itr;
+ ++itr;
+ if (Creature *npc = Creature::GetCreature(*this, *it2))
+ npc->AddObjectToRemoveList();
+ }
+ m_NPCPassengerSet.clear();
+
+ m_WayPoints.clear();
+ m_passengers.clear();
+}
+
+bool Transport::Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags)
{
Relocate(x,y,z,ang);
// instance id and phaseMask isn't set to values different from std.
@@ -198,7 +217,7 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z,
Object::_Create(guidlow, 0, HIGHGUID_MO_TRANSPORT);
- GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(guidlow);
+ GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(entry);
if (!goinfo)
{
@@ -227,6 +246,8 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z,
SetName(goinfo->name);
+ SetZoneScript();
+
return true;
}
@@ -486,9 +507,8 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
++itr;
if (plr->isDead() && !plr->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
- {
- plr->ResurrectPlayer(1.0);
- }
+ plr->ResurrectPlayer(1.0f);
+
plr->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT);
}
@@ -571,7 +591,7 @@ void Transport::Update(uint32 p_diff)
UpdateNPCPositions(); // COME BACK MARKER
}
- sScriptMgr.OnRelocate(this, m_curr->second.mapid, m_curr->second.x, m_curr->second.y, m_curr->second.z);
+ sScriptMgr.OnRelocate(this, m_curr->first, m_curr->second.mapid, m_curr->second.x, m_curr->second.y, m_curr->second.z);
m_nextNodeTime = m_curr->first;
@@ -624,19 +644,21 @@ void Transport::DoEventIfAny(WayPointMap::value_type const& node, bool departure
{
sLog.outDebug("Taxi %s event %u of node %u of %s path", departure ? "departure" : "arrival", eventid, node.first, GetName());
GetMap()->ScriptsStart(sEventScripts, eventid, this, this);
+ EventInform(eventid);
}
}
void Transport::BuildStartMovePacket(Map const* targetMap)
{
- SetByteValue(GAMEOBJECT_FLAGS ,0,41);
- SetByteValue(GAMEOBJECT_BYTES_1, 0, GO_STATE_ACTIVE);
+ SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
+ SetGoState(GO_STATE_ACTIVE);
UpdateForMap(targetMap);
}
void Transport::BuildStopMovePacket(Map const* targetMap)
{
- SetByteValue(GAMEOBJECT_FLAGS ,0,40);
+ RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_IN_USE);
+ SetGoState(GO_STATE_READY);
UpdateForMap(targetMap);
}
@@ -645,7 +667,7 @@ uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y,
Map* map = GetMap();
Creature* pCreature = new Creature;
- if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), GetMap(), this->GetPhaseMask(), entry, 0, (uint32)(this->GetGOInfo()->faction), 0, 0, 0, 0))
+ if (!pCreature->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_UNIT), GetMap(), GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0))
{
delete pCreature;
return 0;
@@ -657,11 +679,11 @@ uint32 Transport::AddNPCPassenger(uint32 tguid, uint32 entry, float x, float y,
pCreature->m_movementInfo.t_pos.Relocate(x, y, z, o);
pCreature->setActive(true);
- if (anim > 0)
- pCreature->SetUInt32Value(UNIT_NPC_EMOTESTATE,anim);
+ if (anim)
+ pCreature->SetUInt32Value(UNIT_NPC_EMOTESTATE, anim);
pCreature->Relocate(
- GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + M_PI)),
+ GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))),
GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())),
z + GetPositionZ() ,
o + GetOrientation());
diff --git a/src/server/game/Entities/Transport/Transport.h b/src/server/game/Entities/Transport/Transport.h
index 1bde8d2af67..86fb798da84 100644
--- a/src/server/game/Entities/Transport/Transport.h
+++ b/src/server/game/Entities/Transport/Transport.h
@@ -43,8 +43,9 @@ class Transport : public GameObject
{
public:
Transport(uint32 period, uint32 script);
+ ~Transport();
- bool Create(uint32 guidlow, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags);
+ bool Create(uint32 guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress, uint32 dynflags);
bool GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids);
void Update(uint32 p_time);
bool AddPassenger(Player* passenger);
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index eee64145ada..44a6b110759 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -261,6 +261,7 @@ ObjectMgr::ObjectMgr()
m_hiCorpseGuid = 1;
m_hiPetNumber = 1;
m_hiGroupGuid = 1;
+ m_hiMoTransGuid = 1;
m_ItemTextId = 1;
m_mailid = 1;
m_equipmentSetGuid = 1;
@@ -6119,6 +6120,10 @@ void ObjectMgr::SetHighestGuids()
if (result)
m_hiGoGuid = (*result)[0].GetUInt32()+1;
+ result = WorldDatabase.Query("SELECT MAX(guid) FROM transports");
+ if (result)
+ m_hiMoTransGuid = (*result)[0].GetUInt32()+1;
+
result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse");
if (result)
m_auctionid = (*result)[0].GetUInt32()+1;
@@ -6265,6 +6270,13 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
World::StopNow(ERROR_EXIT_CODE);
}
return m_hiGroupGuid++;
+ case HIGHGUID_MO_TRANSPORT:
+ if (m_hiMoTransGuid >= 0xFFFFFFFE)
+ {
+ sLog.outError("MO Transport guid overflow!! Can't continue, shutting down server. ");
+ World::StopNow(ERROR_EXIT_CODE);
+ }
+ return m_hiMoTransGuid++;
default:
ASSERT(0);
}
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index 515289502ad..26009e60a02 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -982,6 +982,7 @@ class ObjectMgr
uint32 m_hiDoGuid;
uint32 m_hiCorpseGuid;
uint32 m_hiGroupGuid;
+ uint32 m_hiMoTransGuid;
QuestMap mQuestTemplates;
diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h
index 223a3a9413c..d93fdf6ce08 100644
--- a/src/server/game/Instances/InstanceScript.h
+++ b/src/server/game/Instances/InstanceScript.h
@@ -146,8 +146,8 @@ class InstanceScript : public ZoneScript
virtual void OnPlayerEnter(Player *) {}
//Handle open / close objects
- //use HandleGameObject(NULL,boolen,GO); in OnObjectCreate in instance scripts
- //use HandleGameObject(GUID,boolen,NULL); in any other script
+ //use HandleGameObject(0, boolen, GO); in OnObjectCreate in instance scripts
+ //use HandleGameObject(GUID, boolen, NULL); in any other script
void HandleGameObject(uint64 GUID, bool open, GameObject *go = NULL);
//change active state of doors or buttons
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 9c19b0a20c0..47c67c2bb80 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -1047,10 +1047,10 @@ void ScriptMgr::OnTransportUpdate(Transport* transport, uint32 diff)
tmpscript->OnUpdate(transport, diff);
}
-void ScriptMgr::OnRelocate(Transport* transport, uint32 mapId, float x, float y, float z)
+void ScriptMgr::OnRelocate(Transport* transport, uint32 waypointId, uint32 mapId, float x, float y, float z)
{
GET_SCRIPT(TransportScript, transport->GetScriptId(), tmpscript);
- tmpscript->OnRelocate(transport, mapId, x, y, z);
+ tmpscript->OnRelocate(transport, waypointId, mapId, x, y, z);
}
void ScriptMgr::OnStartup()
diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
index 50168dbf6da..c55e9a9385f 100644
--- a/src/server/game/Scripting/ScriptMgr.h
+++ b/src/server/game/Scripting/ScriptMgr.h
@@ -623,7 +623,7 @@ class TransportScript : public ScriptObject, public UpdatableScript<Transport>
virtual void OnRemovePassenger(Transport* /*transport*/, Player* /*player*/) { }
// Called when a transport moves.
- virtual void OnRelocate(Transport* /*transport*/, uint32 /*mapId*/, float /*x*/, float /*y*/, float /*z*/) { }
+ virtual void OnRelocate(Transport* /*transport*/, uint32 /*waypointId*/, uint32 /*mapId*/, float /*x*/, float /*y*/, float /*z*/) { }
};
class AchievementCriteriaScript : public ScriptObject
@@ -870,7 +870,7 @@ class ScriptMgr
void OnAddCreaturePassenger(Transport* transport, Creature* creature);
void OnRemovePassenger(Transport* transport, Player* player);
void OnTransportUpdate(Transport* transport, uint32 diff);
- void OnRelocate(Transport* transport, uint32 mapId, float x, float y, float z);
+ void OnRelocate(Transport* transport, uint32 waypointId, uint32 mapId, float x, float y, float z);
public: /* AchievementCriteriaScript */
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp
index bb4645615ce..c8c9254d404 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp
@@ -537,6 +537,10 @@ class npc_high_overlord_saurfang_icc : public CreatureScript
{
if (action == ACTION_START_EVENT)
{
+ // Prevent crashes
+ if (events.GetPhaseMask() & PHASE_INTRO_MASK)
+ return;
+
GetCreatureListWithEntryInGrid(guardList, me, NPC_SE_KOR_KRON_REAVER, 20.0f);
guardList.sort(Trinity::ObjectDistanceOrderPred(me));
uint32 x = 1;
@@ -695,8 +699,10 @@ class npc_high_overlord_saurfang_icc : public CreatureScript
return true;
}
- bool OnGossipSelect(Player* /*pPlayer*/, Creature* pCreature, uint32 /*sender*/, uint32 action)
+ bool OnGossipSelect(Player* player, Creature* pCreature, uint32 /*sender*/, uint32 action)
{
+ player->PlayerTalkClass->ClearMenus();
+ player->CLOSE_GOSSIP_MENU();
if (action == -ACTION_START_EVENT)
pCreature->AI()->DoAction(ACTION_START_EVENT);
@@ -730,6 +736,11 @@ class npc_muradin_bronzebeard_icc : public CreatureScript
{
if (action == ACTION_START_EVENT)
{
+ // Prevent crashes
+ if (events.GetPhaseMask() & PHASE_INTRO_MASK)
+ return;
+
+ events.SetPhase(PHASE_INTRO_A);
GetCreatureListWithEntryInGrid(guardList, me, NPC_SE_SKYBREAKER_MARINE, 20.0f);
guardList.sort(Trinity::ObjectDistanceOrderPred(me));
uint32 x = 1;
@@ -739,7 +750,6 @@ class npc_muradin_bronzebeard_icc : public CreatureScript
me->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
DoScriptText(SAY_INTRO_ALLIANCE_1, me);
events.ScheduleEvent(EVENT_INTRO_ALLIANCE_4, 2500+17500+9500, 0, PHASE_INTRO_A);
- events.SetPhase(PHASE_INTRO_A);
if (pInstance)
{
uiDeathbringerSaurfangGUID = pInstance->GetData64(DATA_DEATHBRINGER_SAURFANG);
@@ -825,8 +835,10 @@ class npc_muradin_bronzebeard_icc : public CreatureScript
return true;
}
- bool OnGossipSelect(Player* /*pPlayer*/, Creature* pCreature, uint32 /*sender*/, uint32 action)
+ bool OnGossipSelect(Player* player, Creature* pCreature, uint32 /*sender*/, uint32 action)
{
+ player->PlayerTalkClass->ClearMenus();
+ player->CLOSE_GOSSIP_MENU();
if (action == -ACTION_START_EVENT+1)
pCreature->AI()->DoAction(ACTION_START_EVENT);