Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -r c442c036446d src/game/Level2.cpp
- --- a/src/game/Level2.cpp Thu Jun 10 20:32:08 2010 +0200
- +++ b/src/game/Level2.cpp Thu Jun 10 20:33:31 2010 +0200
- @@ -42,6 +42,7 @@
- #include <map>
- #include "GlobalEvents.h"
- #include "OutdoorPvPMgr.h"
- +#include "Transports.h"
- #include "TargetedMovementGenerator.h" // for HandleNpcUnFollowCommand
- #include "CreatureGroups.h"
- @@ -1005,6 +1006,13 @@
- float o = chr->GetOrientation();
- Map *map = chr->GetMap();
- + if(chr->GetTransport())
- + {
- + chr->GetTransport()->AddNpcPassager(id, chr->GetTransOffsetX(),chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
- + WorldDatabase.PQuery("INSERT INTO creature_transport (entry, npc_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO) values (%u, %u, %f, %f, %f, %f)", chr->GetTransport()->GetEntry(), id, chr->GetTransOffsetX(), chr->GetTransOffsetY(), chr->GetTransOffsetZ(), chr->GetTransOffsetO());
- + return true;
- + }
- +
- Creature* pCreature = new Creature;
- if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, (uint32)teamval, x, y, z, o))
- {
- diff -r c442c036446d src/game/Transports.cpp
- --- a/src/game/Transports.cpp Thu Jun 10 20:32:08 2010 +0200
- +++ b/src/game/Transports.cpp Thu Jun 10 20:33:31 2010 +0200
- @@ -108,6 +108,17 @@
- //If we someday decide to use the grid to track transports, here:
- t->SetMap(MapManager::Instance().CreateMap(mapid, t, 0));
- + // On spawn les npc lié au transport
- + QueryResult_AutoPtr npc_transport = WorldDatabase.PQuery("SELECT npc_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO FROM creature_transport WHERE entry = '%u'", entry);
- + if(npc_transport)
- + {
- + do
- + {
- + Field *fields = npc_transport->Fetch();
- + t->AddNpcPassager(fields[0].GetUInt32(), fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat());
- + } while( npc_transport->NextRow() );
- + }
- +
- //t->GetMap()->Add<GameObject>((GameObject *)t);
- ++count;
- } while (result->NextRow());
- @@ -458,6 +469,19 @@
- //correct me if I'm wrong O.o
- //yes, you're right
- + for(std::set<uint64>::iterator itr = m_NpcPassagerSet.begin(); itr != m_NpcPassagerSet.end();)
- + {
- + std::set<uint64>::iterator it2 = itr;
- + ++itr;
- +
- + uint64 guid = (*it2);
- + if(Creature* npc = Creature::GetCreature(*this,guid))
- + {
- + npc->AddObjectToRemoveList();
- + }
- + }
- + m_NpcPassagerSet.clear();
- +
- ResetMap();
- Map * newMap = MapManager::Instance().CreateMap(newMapid, this, 0);
- SetMap(newMap);
- @@ -468,6 +492,17 @@
- UpdateForMap(oldMap);
- UpdateForMap(newMap);
- }
- +
- + // On spawn les npc lié au transport
- + QueryResult_AutoPtr npc_transport = WorldDatabase.PQuery("SELECT npc_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO FROM creature_transport WHERE entry = '%u'", GetGUIDLow());
- + if(npc_transport)
- + {
- + do
- + {
- + Field *fields = npc_transport->Fetch();
- + AddNpcPassager(fields[0].GetUInt32(), fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat());
- + } while( npc_transport->NextRow() );
- + }
- }
- bool Transport::AddPassenger(Player* passenger)
- @@ -509,8 +544,49 @@
- }
- else
- {
- + SetOrientation(GetAngle(m_next->second.x,m_next->second.y)+3.1415926f);
- Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z);
- - }
- + if(m_NpcPassagerSet.size()>0)
- + {
- + // On update les positions des npcs
- + for(std::set<uint64>::iterator itr = m_NpcPassagerSet.begin(); itr != m_NpcPassagerSet.end();)
- + {
- + std::set<uint64>::iterator it2 = itr;
- + ++itr;
- +
- + uint64 guid = (*it2);
- + if(Creature* npc = Creature::GetCreature(*this,guid))
- + {
- + float x, y, z, o;
- + o = GetOrientation() + npc->m_movementInfo.t_o;
- + x = GetPositionX() + (npc->m_movementInfo.t_x*cos(GetOrientation()) + npc->m_movementInfo.t_y*sin(GetOrientation()+3.14159f));
- + y = GetPositionY() + (npc->m_movementInfo.t_y*cos(GetOrientation()) + npc->m_movementInfo.t_x*sin(GetOrientation()));
- + z = GetPositionZ() + npc->m_movementInfo.t_z;
- + npc->Relocate(x, y, z,o);
- + npc->SetHomePosition(x,y,z,o);
- + npc->SetPosition(x,y,z,o,true) ;
- + npc->GetMap()->CreatureRelocation(npc, x, y, z, o);
- + }
- + /*else if(Pet* npc = sObjectAccessor.GetPetInWorld(guid))
- + {
- + float x, y, z, o;
- + x = GetPositionX() + pCreature->m_movementInfo.t_x;
- + y = GetPositionY() + pCreature->m_movementInfo.t_y;
- + z = GetPositionY() + pCreature->m_movementInfo.t_z;
- + o = GetOrientation() + pCreature->m_movementInfo.t_o;
- + npc->Relocate(x, y, z);
- + }*/
- + else
- + {
- + m_NpcPassagerSet.erase(guid);
- + continue;
- + }
- + }
- + }
- +
- + }
- +
- +
- /*
- if (m_curr->second.delayed)
- {
- @@ -548,7 +624,7 @@
- if ((sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES) == 0)
- sLog.outDetail("%s moved to %d %f %f %f %d", this->m_name.c_str(), m_curr->second.id, m_curr->second.x, m_curr->second.y, m_curr->second.z, m_curr->second.mapid);
- -
- +
- //Transport Event System
- CheckForEvent(this->GetEntry(), m_curr->second.id);
- }
- @@ -587,3 +663,35 @@
- }
- }
- +void Transport::AddNpcPassager(uint32 entry, float x, float y, float z, float o)
- +{
- + Map* map = GetMap();
- + Creature* pCreature = new Creature;
- + if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), GetMap(), this->GetPhaseMask(), entry, 0,(uint32)this->GetGOInfo()->faction,0,0,0,0))
- + {
- + delete pCreature;
- + return;
- + }
- + pCreature->SetTransport(this);
- + pCreature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
- + pCreature->m_movementInfo.guid = GetGUID();
- + pCreature->m_movementInfo.t_x = x;
- + pCreature->m_movementInfo.t_y = y;
- + pCreature->m_movementInfo.t_z = z;
- + pCreature->m_movementInfo.t_o = o;
- + pCreature->setActive(true);
- + pCreature->Relocate(x + GetPositionX(), y + GetPositionY(), z + GetPositionZ() , o + GetOrientation());
- +
- + if(!pCreature->IsPositionValid())
- + {
- + sLog.outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
- + delete pCreature;
- + return;
- + }
- +
- + pCreature->AIM_Initialize();
- +
- + map->Add(pCreature);
- + m_NpcPassagerSet.insert(pCreature->GetGUID());
- +}
- +
- diff -r c442c036446d src/game/Transports.h
- --- a/src/game/Transports.h Thu Jun 10 20:32:08 2010 +0200
- +++ b/src/game/Transports.h Thu Jun 10 20:33:31 2010 +0200
- @@ -71,6 +71,8 @@
- typedef std::set<Player*> PlayerSet;
- PlayerSet const& GetPassengers() const { return m_passengers; }
- + mutable std::set<uint64> m_NpcPassagerSet;
- + void AddNpcPassager(uint32 entry, float x, float y, float z, float o);
- private:
- struct WayPoint
- {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement