コード例 #1
0
ファイル: TransporterHandler.cpp プロジェクト: armm77/AscEmu
Transporter* ObjectMgr::LoadTransportInInstance(MapMgr *instance, uint32 goEntry, uint32 period)
{
    auto gameobject_info = sMySQLStore.getGameObjectProperties(goEntry);
    if (gameobject_info == nullptr)
    {
        LOG_ERROR("Transport ID:%u, will not be loaded, gameobject_properties missing", goEntry);
        return NULL;
    }

    if (gameobject_info->type != GAMEOBJECT_TYPE_MO_TRANSPORT)
    {
        LOG_ERROR("Transport ID:%u, Name: %s, will not be loaded, gameobject_properties type wrong", goEntry, gameobject_info->name.c_str());
        return NULL;
    }

    std::set<uint32> mapsUsed;

    Transporter* t = new Transporter((uint64)HIGHGUID_TYPE_TRANSPORTER << 32 | goEntry);

    // Generate waypoints
    if (!t->GenerateWaypoints(gameobject_info->mo_transport.taxi_path_id))
    {
        LOG_ERROR("Transport ID:%u, Name: %s, failed to create waypoints", gameobject_info->entry, gameobject_info->name.c_str());
        delete t;
        return NULL;
    }

    // Create Transporter
    if (!t->Create(goEntry, period))
    {
        delete t;
        return NULL;
    }

    m_Transporters.insert(t);
    m_TransportersByInstanceIdMap[instance->GetInstanceID()].insert(t);
    AddTransport(t);

    // AddObject To World
    t->AddToWorld(instance);

    // correct incorrect instance id's
    t->SetInstanceID(instance->GetInstanceID());
    t->SetMapId(t->GetMapId());

    t->BuildStartMovePacket(instance);
    t->BuildStopMovePacket(instance);
    t->m_WayPoints.clear(); // Make transport stopped at server-side, movement will be handled by scripts

    LogDetail("Transport Handler : Spawned Transport Entry %u, map %u, instance id %u", goEntry, t->GetMapId(), t->GetInstanceID());
    return t;
}