*Merge with Trinity 768.
--HG-- branch : trunk
This commit is contained in:
@@ -595,6 +595,19 @@ namespace Trinity
|
||||
Unit const* i_funit;
|
||||
float i_range;
|
||||
};
|
||||
|
||||
class CreatureWithDbGUIDCheck
|
||||
{
|
||||
public:
|
||||
CreatureWithDbGUIDCheck(WorldObject const* obj, uint32 lowguid) : i_obj(obj), i_lowguid(lowguid) {}
|
||||
bool operator()(Creature* u)
|
||||
{
|
||||
return u->GetDBTableGUIDLow() == i_lowguid;
|
||||
}
|
||||
private:
|
||||
WorldObject const* i_obj;
|
||||
uint32 i_lowguid;
|
||||
};
|
||||
|
||||
class AnyFriendlyUnitInObjectRangeCheck
|
||||
{
|
||||
|
||||
@@ -7655,3 +7655,39 @@ ObjectMgr::ScriptNameMap & GetScriptNames()
|
||||
{
|
||||
return objmgr.GetScriptNames();
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadTransportEvents()
|
||||
{
|
||||
|
||||
QueryResult *result = WorldDatabase.Query("SELECT entry, waypoint_id, event_id FROM transport_events");
|
||||
|
||||
if( !result )
|
||||
{
|
||||
barGoLink bar1( 1 );
|
||||
bar1.step();
|
||||
sLog.outString( "\n>> Transport events table is empty \n" );
|
||||
return;
|
||||
}
|
||||
|
||||
barGoLink bar1( result->GetRowCount() );
|
||||
|
||||
do
|
||||
{
|
||||
bar1.step();
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
//Load event values
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint32 waypoint_id = fields[1].GetUInt32();
|
||||
uint32 event_id = fields[2].GetUInt32();
|
||||
|
||||
uint32 event_count = (entry*100)+waypoint_id;
|
||||
TransportEventMap[event_count] = event_id;
|
||||
}
|
||||
while(result->NextRow());
|
||||
|
||||
sLog.outString( "\n>> Loaded %u transport events \n", result->GetRowCount() );
|
||||
|
||||
delete result;
|
||||
}
|
||||
@@ -323,7 +323,9 @@ class ObjectMgr
|
||||
|
||||
typedef std::vector<std::string> ScriptNameMap;
|
||||
|
||||
Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);}
|
||||
UNORDERED_MAP<uint32, uint32> TransportEventMap;
|
||||
|
||||
Player* GetPlayer(const char* name) const { return ObjectAccessor::Instance().FindPlayerByName(name);}
|
||||
Player* GetPlayer(uint64 guid) const { return ObjectAccessor::FindPlayer(guid); }
|
||||
|
||||
static GameObjectInfo const *GetGameObjectInfo(uint32 id) { return sGOStorage.LookupEntry<GameObjectInfo>(id); }
|
||||
@@ -536,6 +538,8 @@ class ObjectMgr
|
||||
void LoadEventScripts();
|
||||
void LoadSpellScripts();
|
||||
void LoadWaypointScripts();
|
||||
|
||||
void LoadTransportEvents();
|
||||
|
||||
bool LoadTrinityStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value);
|
||||
bool LoadTrinityStrings() { return LoadTrinityStrings(WorldDatabase,"trinity_string",MIN_TRINITY_STRING_ID,MAX_TRINITY_STRING_ID); }
|
||||
@@ -592,7 +596,7 @@ class ObjectMgr
|
||||
void LoadVendors();
|
||||
void LoadTrainerSpell();
|
||||
void LoadCompletedAchievements();
|
||||
|
||||
|
||||
std::string GeneratePetName(uint32 entry);
|
||||
uint32 GetBaseXP(uint32 level);
|
||||
|
||||
|
||||
+21
-8
@@ -29,6 +29,8 @@
|
||||
#include "Database/DBCStores.h"
|
||||
#include "ProgressBar.h"
|
||||
|
||||
#include "World.h"
|
||||
|
||||
void MapManager::LoadTransports()
|
||||
{
|
||||
QueryResult *result = WorldDatabase.Query("SELECT entry, name, period FROM transports");
|
||||
@@ -317,7 +319,7 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
|
||||
if (keyFrames[keyFrames.size() - 1].mapid != keyFrames[0].mapid)
|
||||
teleport = true;
|
||||
|
||||
WayPoint pos(keyFrames[0].mapid, keyFrames[0].x, keyFrames[0].y, keyFrames[0].z, teleport);
|
||||
WayPoint pos(keyFrames[0].mapid, keyFrames[0].x, keyFrames[0].y, keyFrames[0].z, teleport, 0);
|
||||
m_WayPoints[0] = pos;
|
||||
t += keyFrames[0].delay * 1000;
|
||||
|
||||
@@ -351,7 +353,7 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
|
||||
}
|
||||
|
||||
// sLog.outString("T: %d, D: %f, x: %f, y: %f, z: %f", t, d, newX, newY, newZ);
|
||||
WayPoint pos(keyFrames[i].mapid, newX, newY, newZ, teleport);
|
||||
WayPoint pos(keyFrames[i].mapid, newX, newY, newZ, teleport, i);
|
||||
if (teleport)
|
||||
m_WayPoints[t] = pos;
|
||||
}
|
||||
@@ -397,13 +399,13 @@ bool Transport::GenerateWaypoints(uint32 pathid, std::set<uint32> &mapids)
|
||||
cM = keyFrames[i + 1].mapid;
|
||||
}
|
||||
|
||||
WayPoint pos(keyFrames[i + 1].mapid, keyFrames[i + 1].x, keyFrames[i + 1].y, keyFrames[i + 1].z, teleport);
|
||||
WayPoint pos(keyFrames[i + 1].mapid, keyFrames[i + 1].x, keyFrames[i + 1].y, keyFrames[i + 1].z, teleport, i);
|
||||
|
||||
// sLog.outString("T: %d, x: %f, y: %f, z: %f, t:%d", t, pos.x, pos.y, pos.z, teleport);
|
||||
|
||||
/*
|
||||
if(keyFrames[i+1].delay > 5)
|
||||
pos.delayed = true;
|
||||
|
||||
*/
|
||||
//if (teleport)
|
||||
m_WayPoints[t] = pos;
|
||||
|
||||
@@ -486,6 +488,13 @@ bool Transport::RemovePassenger(Player* passenger)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Transport::CheckForEvent(uint32 entry, uint32 wp_id)
|
||||
{
|
||||
uint32 key = entry*100+wp_id;
|
||||
if(objmgr.TransportEventMap.find(key) != objmgr.TransportEventMap.end())
|
||||
sWorld.ScriptsStart(sEventScripts, objmgr.TransportEventMap[key], this, NULL);
|
||||
}
|
||||
|
||||
void Transport::Update(uint32 /*p_time*/)
|
||||
{
|
||||
if (m_WayPoints.size() <= 1)
|
||||
@@ -507,7 +516,7 @@ void Transport::Update(uint32 /*p_time*/)
|
||||
//MapManager::Instance().GetMap(m_curr->second.mapid)->GameobjectRelocation((GameObject *)this, m_curr->second.x, m_curr->second.y, m_curr->second.z, this->m_orientation);
|
||||
Relocate(m_curr->second.x, m_curr->second.y, m_curr->second.z);
|
||||
}
|
||||
|
||||
/*
|
||||
if(m_curr->second.delayed)
|
||||
{
|
||||
switch (GetEntry())
|
||||
@@ -527,7 +536,7 @@ void Transport::Update(uint32 /*p_time*/)
|
||||
SendPlaySound(5154, false); break; // ShipDocked
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
for(PlayerSet::iterator itr = m_passengers.begin(); itr != m_passengers.end();)
|
||||
{
|
||||
@@ -548,5 +557,9 @@ void Transport::Update(uint32 /*p_time*/)
|
||||
|
||||
if ((sLog.getLogFilter() & LOG_FILTER_TRANSPORT_MOVES)==0)
|
||||
sLog.outDetail("%s moved to %f %f %f %d", this->m_name.c_str(), 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);
|
||||
sLog.outDetail("%s is at wp id: %u", this->m_name.c_str(), m_curr->second.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ class Transport : private GameObject
|
||||
void Update(uint32 p_time);
|
||||
bool AddPassenger(Player* passenger);
|
||||
bool RemovePassenger(Player* passenger);
|
||||
void CheckForEvent(uint32 entry, uint32 wp_id);
|
||||
|
||||
typedef std::set<Player*> PlayerSet;
|
||||
PlayerSet const& GetPassengers() const { return m_passengers; }
|
||||
@@ -86,15 +87,15 @@ class Transport : private GameObject
|
||||
private:
|
||||
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), delayed(false) {}
|
||||
WayPoint() : mapid(0), x(0), y(0), z(0), teleport(false), id(0) {}
|
||||
WayPoint(uint32 _mapid, float _x, float _y, float _z, bool _teleport, uint32 _id) :
|
||||
mapid(_mapid), x(_x), y(_y), z(_z), teleport(_teleport), id(_id) {}
|
||||
uint32 mapid;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
bool teleport;
|
||||
bool delayed;
|
||||
uint32 id;
|
||||
};
|
||||
|
||||
typedef std::map<uint32, WayPoint> WayPointMap;
|
||||
|
||||
+92
-4
@@ -63,6 +63,7 @@
|
||||
#include "Util.h"
|
||||
#include "Language.h"
|
||||
#include "CreatureGroups.h"
|
||||
#include "Transports.h"
|
||||
|
||||
INSTANTIATE_SINGLETON_1( World );
|
||||
|
||||
@@ -1398,6 +1399,9 @@ void World::SetInitialWorldSettings()
|
||||
//Not sure if this can be moved up in the sequence (with static data loading) as it uses MapManager
|
||||
sLog.outString( "Loading Transports..." );
|
||||
MapManager::Instance().LoadTransports();
|
||||
|
||||
sLog.outString( "Loading Transports Events..." );
|
||||
objmgr.LoadTransportEvents();
|
||||
|
||||
sLog.outString("Deleting expired bans..." );
|
||||
loginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
@@ -1656,7 +1660,7 @@ void World::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source,
|
||||
return;
|
||||
|
||||
// prepare static data
|
||||
uint64 sourceGUID = source->GetGUID();
|
||||
uint64 sourceGUID = source ? source->GetGUID() : (uint64)0; //some script commands doesn't have source
|
||||
uint64 targetGUID = target ? target->GetGUID() : (uint64)0;
|
||||
uint64 ownerGUID = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0;
|
||||
|
||||
@@ -1685,7 +1689,7 @@ void World::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* s
|
||||
// NOTE: script record _must_ exist until command executed
|
||||
|
||||
// prepare static data
|
||||
uint64 sourceGUID = source->GetGUID();
|
||||
uint64 sourceGUID = source ? source->GetGUID() : (uint64)0;
|
||||
uint64 targetGUID = target ? target->GetGUID() : (uint64)0;
|
||||
uint64 ownerGUID = (source->GetTypeId()==TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : (uint64)0;
|
||||
|
||||
@@ -1742,12 +1746,22 @@ void World::ScriptsProcess()
|
||||
source = HashMapHolder<Player>::Find(step.sourceGUID);
|
||||
break;
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
source = HashMapHolder<GameObject>::Find(step.sourceGUID);
|
||||
source = HashMapHolder<GameObject>::Find(step.sourceGUID);
|
||||
break;
|
||||
case HIGHGUID_CORPSE:
|
||||
source = HashMapHolder<Corpse>::Find(step.sourceGUID);
|
||||
break;
|
||||
default:
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
for (MapManager::TransportSet::iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter)
|
||||
{
|
||||
if((*iter)->GetGUID() == step.sourceGUID)
|
||||
{
|
||||
source = reinterpret_cast<Object*>(*iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sLog.outError("*_script source with unsupported high guid value %u",GUID_HIPART(step.sourceGUID));
|
||||
break;
|
||||
}
|
||||
@@ -2316,6 +2330,80 @@ void World::ScriptsProcess()
|
||||
break;
|
||||
}
|
||||
|
||||
case SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT:
|
||||
{
|
||||
if(!step.script->datalong || !step.script->datalong2)
|
||||
{
|
||||
sLog.outError("SCRIPT_COMMAND_CALLSCRIPT calls invallid db_script_id or lowguid not present: skipping.");
|
||||
break;
|
||||
}
|
||||
Creature* target = NULL;
|
||||
|
||||
if(source) //using grid searcher
|
||||
{
|
||||
CellPair p(Trinity::ComputeCellPair(((Unit*)source)->GetPositionX(), ((Unit*)source)->GetPositionY()));
|
||||
Cell cell(p);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
|
||||
//sLog.outDebug("Attempting to find Creature: Db GUID: %i", step.script->datalong);
|
||||
Trinity::CreatureWithDbGUIDCheck target_check(((Unit*)source), step.script->datalong);
|
||||
Trinity::CreatureSearcher<Trinity::CreatureWithDbGUIDCheck> checker(target,target_check);
|
||||
|
||||
TypeContainerVisitor<Trinity::CreatureSearcher <Trinity::CreatureWithDbGUIDCheck>, GridTypeMapContainer > unit_checker(checker);
|
||||
CellLock<GridReadGuard> cell_lock(cell, p);
|
||||
cell_lock->Visit(cell_lock, unit_checker, *(((Unit*)source)->GetMap()));
|
||||
}
|
||||
else //check hashmap holders
|
||||
{
|
||||
if(CreatureData const* data = objmgr.GetCreatureData(step.script->datalong))
|
||||
target = ObjectAccessor::GetObjectInWorld<Creature>(data->mapid, data->posX, data->posY, MAKE_NEW_GUID(step.script->datalong, data->id, HIGHGUID_UNIT), target);
|
||||
}
|
||||
|
||||
if(!target)
|
||||
break;
|
||||
|
||||
//Lets choose our ScriptMap map
|
||||
ScriptMapMap datamap;
|
||||
switch(step.script->dataint)
|
||||
{
|
||||
case 1:
|
||||
datamap = sQuestEndScripts;
|
||||
break;
|
||||
case 2:
|
||||
datamap = sQuestStartScripts;
|
||||
break;
|
||||
case 3:
|
||||
datamap = sSpellScripts;
|
||||
break;
|
||||
case 4:
|
||||
datamap = sGameObjectScripts;
|
||||
break;
|
||||
case 5:
|
||||
datamap = sEventScripts;
|
||||
break;
|
||||
case 6:
|
||||
datamap = sWaypointScripts;
|
||||
break;
|
||||
default:
|
||||
sLog.outError("SCRIPT_COMMAND_CALLSCRIPT ERROR: no scriptmap present... ignoring");
|
||||
m_scriptSchedule.erase(iter);
|
||||
return;
|
||||
}
|
||||
uint32 script_id = step.script->datalong2;
|
||||
m_scriptSchedule.erase(iter);
|
||||
ScriptsStart(datamap, script_id, target, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
case SCRIPT_COMMAND_PLAYSOUND:
|
||||
{
|
||||
if(!source)
|
||||
break;
|
||||
//datalong sound_id, datalong2 onlyself
|
||||
((WorldObject*)source)->SendPlaySound(step.script->datalong, step.script->datalong2);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
sLog.outError("Unknown script command %u called.",step.script->command);
|
||||
break;
|
||||
|
||||
@@ -333,6 +333,9 @@ enum RealmZone
|
||||
#define SCRIPT_COMMAND_REMOVE_AURA 14 // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id
|
||||
#define SCRIPT_COMMAND_CAST_SPELL 15 // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id
|
||||
#define SCRIPT_COMMAND_LOAD_PATH 16 // source = unit, path = datalong, repeatable datalong2
|
||||
#define SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT 17 // datalong scriptid, lowguid datalong2, dataint table
|
||||
#define SCRIPT_COMMAND_PLAYSOUND 18 // datalong soundid, datalong2 play only self
|
||||
|
||||
|
||||
/// Storage class for commands issued for delayed execution
|
||||
struct CliCommandHolder
|
||||
|
||||
Reference in New Issue
Block a user