当前位置: 首页>>代码示例>>C++>>正文


C++ Transport::GenerateWaypoints方法代码示例

本文整理汇总了C++中Transport::GenerateWaypoints方法的典型用法代码示例。如果您正苦于以下问题:C++ Transport::GenerateWaypoints方法的具体用法?C++ Transport::GenerateWaypoints怎么用?C++ Transport::GenerateWaypoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transport的用法示例。


在下文中一共展示了Transport::GenerateWaypoints方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MakeTransport

Transport* BattlegroundIC::MakeTransport(uint32 gobentry,uint32 period,std::string nametransport)
{
    Transport *t = new Transport(period,0);

        uint32 entry = gobentry;
        std::string name = nametransport;

        const GameObjectInfo *goinfo = sObjectMgr.GetGameObjectInfo(entry);

        if (!goinfo)
        {
            sLog.outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template missing", entry, name.c_str());
            delete t;
            return NULL;
        }
        std::set<uint32> mapsUsed;

        if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed))
            // skip transports with empty waypoints list
        {
            sLog.outErrorDb("Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO data0 field.",goinfo->moTransport.taxiPathId);
            delete t;
            return NULL;
        }

        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;

         // creates the Gameobject
        if (!t->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT),entry, mapid, x, y, z, o, 100, 0))
        {
            delete t;
            return NULL;
        }

        //If we someday decide to use the grid to track transports, here:
        t->SetMap(GetBgMap());

        // On spawn les npc li? au transport
        QueryResult npc_transport = WorldDatabase.PQuery("SELECT guid, npc_entry, transport_entry, TransOffsetX, TransOffsetY, TransOffsetZ, TransOffsetO, emote FROM creature_transport");
        if(npc_transport)
        {
            do
            {
                Field *fields = npc_transport->Fetch();
                t->AddNPCPassenger(fields[0].GetUInt32(), fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat(), fields[4].GetFloat(),fields[5].GetUInt32(),fields[6].GetUInt32());
            } while( npc_transport->NextRow() );
        }
		
        return t;
}
开发者ID:sensibob,项目名称:tempestcore,代码行数:52,代码来源:BattlegroundIC.cpp

示例2: CreateTransport

Transport* BattlegroundIC::CreateTransport(uint32 goEntry, uint32 period)
{
    Transport* t = new Transport(period, 0);

    GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(goEntry);

    if (!goinfo)
    {
        sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Transport ID: %u will not be loaded, gameobject_template missing", goEntry);
        delete t;
        return NULL;
    }

    std::set<uint32> mapsUsed;

    if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed))
        // Skip transports with empty waypoints list
    {
        sLog->outInfo(LOG_FILTER_SERVER_LOADING, "Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO data0 field.", goinfo->moTransport.taxiPathId);
        delete t;
        return NULL;
    }

    uint32 mapid = t->m_WayPoints[0].mapid;

    float x = t->m_WayPoints[0].x;
    float y = t->m_WayPoints[0].y;
    float z = t->m_WayPoints[0].z;
    float o = 1;

    // Creates the Gameobject
    if (!t->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_MO_TRANSPORT), goEntry, mapid, x, y, z, o, 255, 0))
    {
        delete t;
        return NULL;
    }

    sMapMgr->m_Transports.insert(t);

    // If we someday decide to use the grid to track transports, here:
    t->SetMap(GetBgMap());

    for (uint8 i = 0; i < 5; i++)
        t->AddNPCPassenger(0, (goEntry == GO_HORDE_GUNSHIP ? NPC_HORDE_GUNSHIP_CANNON : NPC_ALLIANCE_GUNSHIP_CANNON), (goEntry == GO_HORDE_GUNSHIP ? hordeGunshipPassengers[i].GetPositionX() : allianceGunshipPassengers[i].GetPositionX()), (goEntry == GO_HORDE_GUNSHIP ? hordeGunshipPassengers[i].GetPositionY() : allianceGunshipPassengers[i].GetPositionY()), (goEntry == GO_HORDE_GUNSHIP ? hordeGunshipPassengers[i].GetPositionZ() : allianceGunshipPassengers[i].GetPositionZ()), (goEntry == GO_HORDE_GUNSHIP ? hordeGunshipPassengers[i].GetOrientation() : allianceGunshipPassengers[i].GetOrientation()));

    return t;
}
开发者ID:Expery,项目名称:Core,代码行数:47,代码来源:BattlegroundIC.cpp

示例3: LoadTransportInMap

Transport* MapManager::LoadTransportInMap(Map* instance, uint32 goEntry, uint32 period)
{
    const GameObjectTemplate* goInfo = sObjectMgr->GetGameObjectTemplate(goEntry);

    if(!goInfo)
    {
        sLog->outErrorDb("Transport ID:%u, will not be loaded, gameobject_template missing", goEntry);
        return NULL;
    }

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

    Transport* t = new Transport(period, goInfo->ScriptId);
    std::set<uint32> mapsUsed;
    if(!t->GenerateWaypoints(goInfo->moTransport.taxiPathId, mapsUsed))
    {
        sLog->outErrorDb("Transport (path id %u) path size = 0. Transport ignored, check DBC files or the gameobject's data0 field.", goInfo->moTransport.taxiPathId);
        delete t;
        return NULL;
    }
    uint32 transportLowGuid = sObjectMgr->GenerateLowGuid(HIGHGUID_MO_TRANSPORT);

    if(!t->Create(transportLowGuid, goEntry, t->m_WayPoints[0].mapid, t->m_WayPoints[0].x, t->m_WayPoints[0].y, t->m_WayPoints[0].z-10, 0.0f, 0, 0))
    {
        delete t;
        return NULL;
    }

    m_Transports.insert(t);
    for(std::set<uint32>::const_iterator i = mapsUsed.begin(); i != mapsUsed.end(); ++i)
        m_TransportsByMap[*i].insert(t);
    t->SetMap(instance);
    t->AddToWorld();
    t->BuildStartMovePacket(instance);
    t->BuildStopMovePacket(instance);
    // Make transport realy stoppped at server-side. Movement will be handled by scripts
    t->m_WayPoints.clear();

    return t;
}
开发者ID:ahuraa,项目名称:ServerMythCore,代码行数:44,代码来源:Transport.cpp

示例4: CreateTransport

Transport* BattleGroundIC::CreateTransport(uint32 goEntry, uint32 period)
{
    Transport* t = new Transport;

    const GameObjectInfo* goinfo = sObjectMgr.GetGameObjectInfo(goEntry);

    if (!goinfo)
    {
        sLog.outErrorDb("Transport ID: %u will not be loaded, gameobject_template missing", goEntry);
        delete t;
        return NULL;
    }

    std::set<uint32> mapsUsed;
    t->m_period = period;

    if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed))
        // skip transports with empty waypoints list
    {
        sLog.outErrorDb("Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO data0 field.",goinfo->moTransport.taxiPathId);
        delete t;
        return NULL;
    }

    uint32 mapid = t->m_WayPoints[0].mapid;

    float x = t->m_WayPoints[0].x;
    float y = t->m_WayPoints[0].y;
    float z =  t->m_WayPoints[0].z;
    float o = 1;

    // creates the Gameobject
    if (!t->Create(goEntry, mapid, x, y, z, o, GO_ANIMPROGRESS_DEFAULT, 0))
    {
        delete t;
        return NULL;
    }

    t->SetMap(GetBgMap());

    return t;
}
开发者ID:Inquisitor,项目名称:mangos,代码行数:42,代码来源:BattleGroundIC.cpp

示例5: CreateTransportsOnMap

void MapManager::CreateTransportsOnMap(Map* map)
{
    // no transports on this map?
    if (m_TransportInfosByMap.find(map->GetId()) == m_TransportInfosByMap.end())
        return;

    for (auto ti : m_TransportInfosByMap[map->GetId()])
    {
        Transport* t = new Transport;
        t->m_period = ti->period;

        std::set<uint32> mapsUsed;

        // skip transports with empty waypoints list
        if (!t->GenerateWaypoints(ti->pathid, mapsUsed))
        {
            sLog.outErrorDb("Transport (path id %u) path size = 0. Transport not created, check DBC files or transport GO data0 field.", ti->pathid);
            delete t;
            continue;
        }

        // creates the Gameobject
        if (!t->Create(ti->entry, map->GetId(), ti->pos.x, ti->pos.y, ti->pos.z, ti->pos.o, GO_ANIMPROGRESS_DEFAULT, 0))
        {
            delete t;
            continue;
        }

        m_Transports.insert(t);

        for (uint32 i : mapsUsed)
            m_TransportsByMap[i].insert(t);

        // link transport to the map on which it spawns (its first waypoint)
        t->SetMap(map);

        // add the transport to world
        t->AddToWorld();
    }
}
开发者ID:michalpolko,项目名称:cmangos,代码行数:40,代码来源:Transports.cpp

示例6: LoadTransportInMap

Transport* MapManager::LoadTransportInMap(Map* instance, uint32 goEntry, uint32 period)
{
    const GameObjectTemplate* goInfo = sObjectMgr->GetGameObjectTemplate(goEntry);

    if (!goInfo)
    {
        return NULL;
    }

    if (goInfo->type != GAMEOBJECT_TYPE_MO_TRANSPORT)
    {
        return NULL;
    }

    Transport* t = new Transport(period, goInfo->ScriptId);
    std::set<uint32> mapsUsed;
    if (!t->GenerateWaypoints(goInfo->moTransport.taxiPathId, mapsUsed))
    {
        delete t;
        return NULL;
    }
    uint32 transportLowGuid = sObjectMgr->GenerateLowGuid(HIGHGUID_MO_TRANSPORT);

    if (!t->Create(transportLowGuid, goEntry, t->m_WayPoints[0].mapid, t->m_WayPoints[0].x, t->m_WayPoints[0].y, t->m_WayPoints[0].z-10, 0.0f, 0, 0))
    {
        delete t;
        return NULL;
    }

    m_Transports.insert(t);
    m_TransportsByInstanceIdMap[instance->GetInstanceId()].insert(t);
    t->SetMap(instance);
    t->AddToWorld();

    return t;
}
开发者ID:mynew2,项目名称:Gunship,代码行数:36,代码来源:Transport.cpp

示例7: LoadTransports

void MapManager::LoadTransports()
{
    QueryResult *result = WorldDatabase.Query("SELECT entry, name, period FROM transports");

    uint32 count = 0;

    if( !result )
    {
        BarGoLink bar(1);
        bar.step();

        sLog.outString();
        sLog.outString( ">> Loaded %u transports", count );
        return;
    }

    BarGoLink bar(result->GetRowCount());

    do
    {
        bar.step();

        Transport *t = new Transport;

        Field *fields = result->Fetch();

        uint32 entry = fields[0].GetUInt32();
        std::string name = fields[1].GetCppString();
        t->m_period = fields[2].GetUInt32();

        const GameObjectInfo *goinfo = ObjectMgr::GetGameObjectInfo(entry);

        if(!goinfo)
        {
            sLog.outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template missing", entry, name.c_str());
            delete t;
            continue;
        }

        if(goinfo->type != GAMEOBJECT_TYPE_MO_TRANSPORT)
        {
            sLog.outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template type wrong", entry, name.c_str());
            delete t;
            continue;
        }

        // setting mapID's, binded to transport GO
        if (goinfo->moTransport.mapID)
        {
            m_mapOnTransportGO.insert(std::make_pair(goinfo->moTransport.mapID,t));
            DEBUG_LOG("Loading transport %u between %s, %s map id %u", entry, name.c_str(), goinfo->name, goinfo->moTransport.mapID);
        }

        // sLog.outString("Loading transport %d between %s, %s", entry, name.c_str(), goinfo->name);

        std::set<uint32> mapsUsed;

        if(!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed))
            // skip transports with empty waypoints list
        {
            sLog.outErrorDb("Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO data0 field.",goinfo->moTransport.taxiPathId);
            delete t;
            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;

        //current code does not support transports in dungeon!
        const MapEntry* pMapInfo = sMapStore.LookupEntry(mapid);
        if(!pMapInfo || pMapInfo->Instanceable())
        {
            delete t;
            continue;
        }

        // creates the Gameobject
        if (!t->Create(entry, mapid, x, y, z, o, GO_ANIMPROGRESS_DEFAULT, 0))
        {
            delete t;
            continue;
        }

        m_Transports.insert(t);

        for (std::set<uint32>::const_iterator i = mapsUsed.begin(); i != mapsUsed.end(); ++i)
            m_TransportsByMap[*i].insert(t);

        //If we someday decide to use the grid to track transports, here:
        t->SetMap(sMapMgr.CreateMap(mapid, t));

        //t->GetMap()->Add<GameObject>((GameObject *)t);
        ++count;
    } while(result->NextRow());
    delete result;

    sLog.outString();
    sLog.outString( ">> Loaded %u transports", count );
    sLog.outString( ">> Loaded " SIZEFMTD " transports with mapID's", m_mapOnTransportGO.size() );
//.........这里部分代码省略.........
开发者ID:Splash,项目名称:mangos,代码行数:101,代码来源:Transports.cpp

示例8: LoadTransports

void MapManager::LoadTransports()
{
    uint32 oldMSTime = getMSTime();

    QueryResult result = WorldDatabase.Query("SELECT guid, entry, name, period, ScriptName FROM transports");

    if(!result)
    {
        sLog->outString(">> Loaded 0 transports. DB table `transports` is empty!");
        sLog->outString();
        return;
    }

    uint32 count = 0;

    do
    {
        Field* fields = result->Fetch();
        uint32 lowguid = fields[0].GetUInt32();
        uint32 entry = fields[1].GetUInt32();
        std::string name = fields[2].GetString();
        uint32 period = fields[3].GetUInt32();
        uint32 scriptId = sObjectMgr->GetScriptId(fields[4].GetCString());

        const GameObjectTemplate* goinfo = sObjectMgr->GetGameObjectTemplate(entry);

        if(!goinfo)
        {
            sLog->outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template missing", entry, name.c_str());
            continue;
        }

        if(goinfo->type != GAMEOBJECT_TYPE_MO_TRANSPORT)
        {
            sLog->outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template type wrong", entry, name.c_str());
            continue;
        }

        // sLog->outString("Loading transport %d between %s, %s", entry, name.c_str(), goinfo->name);

        std::set<uint32> mapsUsed;

        Transport* t = new Transport(period, scriptId);
        if(!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed))
            // skip transports with empty waypoints list
        {
            sLog->outErrorDb("Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO data0 field.", goinfo->moTransport.taxiPathId);
            delete t;
            continue;
        }

        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(lowguid, entry, mapid, x, y, z, o, 100, 0))
        {
            delete t;
            continue;
        }

        m_Transports.insert(t);

        for(std::set<uint32>::const_iterator i = mapsUsed.begin(); i != mapsUsed.end(); ++i)
            m_TransportsByMap[*i].insert(t);

        //If we someday decide to use the grid to track transports, here:
        t->SetMap(sMapMgr->CreateMap(mapid, t, 0));
        t->AddToWorld();

        ++count;
    }
    while(result->NextRow());

    // check transport data DB integrity
    result = WorldDatabase.Query("SELECT gameobject.guid, gameobject.id, transports.name FROM gameobject, transports WHERE gameobject.id = transports.entry");
    if(result)                                              // wrong data found
    {
        do
        {
            Field* fields = result->Fetch();

            uint32 guid  = fields[0].GetUInt32();
            uint32 entry = fields[1].GetUInt32();
            std::string name = fields[2].GetString();
            sLog->outErrorDb("Transport %u '%s' have record (GUID: %u) in `gameobject`. Transports must not have any records in `gameobject` or its behavior will be unpredictable/bugged.", entry, name.c_str(), guid);
        }
        while(result->NextRow());
    }

    sLog->outString(">> Loaded %u transports in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
    sLog->outString();
}
开发者ID:ahuraa,项目名称:ServerMythCore,代码行数:96,代码来源:Transport.cpp

示例9: LoadTransports

void MapManager::LoadTransports()
{
    QueryResult_AutoPtr result = WorldDatabase.Query("SELECT entry, name, period FROM transports");

    uint32 count = 0;

    if (!result)
    {
        sLog->outString();
        sLog->outString(">> Loaded %u transports", count);
        return;
    }

    do
    {
        Transport *t = new Transport;

        Field *fields = result->Fetch();

        uint32 entry = fields[0].GetUInt32();
        std::string name = fields[1].GetCppString();
        t->m_period = fields[2].GetUInt32();

        const GameObjectInfo *goinfo = sObjectMgr->GetGameObjectInfo(entry);

        if (!goinfo)
        {
            sLog->outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template missing", entry, name.c_str());
            delete t;
            continue;
        }

        if (goinfo->type != GAMEOBJECT_TYPE_MO_TRANSPORT)
        {
            sLog->outErrorDb("Transport ID:%u, Name: %s, will not be loaded, gameobject_template type wrong", entry, name.c_str());
            delete t;
            continue;
        }

        // sLog->outString("Loading transport %d between %s, %s", entry, name.c_str(), goinfo->name);

        std::set<uint32> mapsUsed;

        if (!t->GenerateWaypoints(goinfo->moTransport.taxiPathId, mapsUsed))
            // skip transports with empty waypoints list
        {
            sLog->outErrorDb("Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO data0 field.", goinfo->moTransport.taxiPathId);
            delete t;
            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;

        // creates the Gameobject
        if (!t->Create(entry, mapid, x, y, z, o, 100, 0))
        {
            delete t;
            continue;
        }

        m_Transports.insert(t);

        for (std::set<uint32>::iterator i = mapsUsed.begin(); i != mapsUsed.end(); ++i)
            m_TransportsByMap[*i].insert(t);

        //If we someday decide to use the grid to track transports, here:
        t->SetMap(sMapMgr->CreateMap(mapid, t, 0));

        //t->GetMap()->Add<GameObject>((GameObject *)t);

        ++count;
    } while (result->NextRow());

    sLog->outString();
    sLog->outString(">> Loaded %u transports", count);

    // check transport data DB integrity
    result = WorldDatabase.Query("SELECT gameobject.guid, gameobject.id, transports.name FROM gameobject, transports WHERE gameobject.id = transports.entry");
    if (result)                                              // wrong data found
    {
        do
        {
            Field *fields = result->Fetch();

            uint32 guid  = fields[0].GetUInt32();
            uint32 entry = fields[1].GetUInt32();
            std::string name = fields[2].GetCppString();
            sLog->outErrorDb("Transport %u '%s' has record (GUID: %u) in gameobject. Transports MUST NOT have any records in gameobject or its behavior will be unpredictable/bugged.", entry, name.c_str(), guid);
        }
        while (result->NextRow());
    }
}
开发者ID:Bootz,项目名称:SF1,代码行数:94,代码来源:Transport.cpp

示例10: LoadTransports

void MapManager::LoadTransports()
{
    QueryResult *result = sDatabase.Query("SELECT `entry`, `name`, `period` FROM transports");

    uint32 count = 0;

    if( !result )
    {
        barGoLink bar( 1 );
        bar.step();

        sLog.outString( "" );
        sLog.outString( ">> Loaded %u transports", count );
        return;
    }

    barGoLink bar( result->GetRowCount() );

    uint32 entry;
    string name;
    
    do {
        bar.step();

        Transport *t = new Transport;

        Field *fields = result->Fetch();
        
        entry = fields[0].GetUInt32();
        name = fields[1].GetString();
        t->m_period = fields[2].GetUInt32();

        const GameObjectInfo *goinfo = objmgr.GetGameObjectInfo(entry);
        
        //sLog.outString("Loading transport between %s, %s", name.c_str(), goinfo->name);

        vector<uint32> mapsUsed;


        if(!t->GenerateWaypoints(goinfo->sound0, mapsUsed))
        // skip transports with empty waypoints list
        {
            sLog.outErrorDb("ERROR: Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO sound0 field.",goinfo->sound0); 
            delete t;
            continue;
        }

        t->m_name = goinfo->name;

        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;
        
        t->Create(entry, goinfo->displayId, mapid, x, y, z, o, 100, 0);
        m_Transports.push_back(t);
        
        
        for (size_t i = 0; i < mapsUsed.size(); i++) {
            if (m_TransportsByMap.find(mapsUsed[i]) == m_TransportsByMap.end()) {
                vector<Transport *> tmp;
                m_TransportsByMap[t->m_WayPoints[i].mapid] = tmp;
            }
            vector<Transport *> *v = &(m_TransportsByMap[mapsUsed[i]]);
            if (find(v->begin(), v->end(), t) == v->end()) {
                v->push_back(t);
                //sLog.outString("%d ", mapsUsed[i]);
            }
        }
        
        //If we someday decide to use the grid to track transports, here:
        //MapManager::Instance().LoadGrid(mapid,x,y,true);
        //MapManager::Instance().GetMap(t->GetMapId())->Add<GameObject>((GameObject *)t);        
        ++count;
    } while(result->NextRow());
    delete result;

    sLog.outString( "" );
    sLog.outString( ">> Loaded %u transports", count );
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:79,代码来源:Transports.cpp

示例11: LoadTransports

void MapManager::LoadTransports()
{
    QueryResult *result = WorldDatabase.Query("SELECT `entry`, `name`, `period` FROM `transports`");

    uint32 count = 0;

    if( !result )
    {
        barGoLink bar( 1 );
        bar.step();

        sLog.outString();
        sLog.outString( ">> Loaded %u transports", count );
        return;
    }

    barGoLink bar( result->GetRowCount() );

    do
    {
        bar.step();

        Transport *t = new Transport( NULL );

        Field *fields = result->Fetch();

        uint32 entry = fields[0].GetUInt32();
        std::string name = fields[1].GetCppString();
        t->m_period = fields[2].GetUInt32();

        const GameObjectInfo *goinfo = objmgr.GetGameObjectInfo(entry);

        if(!goinfo)
        {
            sLog.outErrorDb("Transport ID:%u, Name: %s, will not be loaded gameobject_template Missing", entry, name.c_str());
            delete t;
            continue;
        }

        // sLog.outString("Loading transport %d between %s, %s", entry, name.c_str(), goinfo->name);

        std::set<uint32> mapsUsed;

        if(!t->GenerateWaypoints(goinfo->data0, mapsUsed))
            // skip transports with empty waypoints list
        {
            sLog.outErrorDb("Transport (path id %u) path size = 0. Transport ignored, check DBC files or transport GO data0 field.",goinfo->data0);
            delete t;
            continue;
        }

        t->m_name = goinfo->name;

        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;

                                                            // creates the Gameobject
        if(!t->Create(entry, goinfo->displayId, mapid, x, y, z, o, 100, 0))
        {
            delete t;
            continue;
        }

        m_Transports.insert(t);

        for (std::set<uint32>::iterator i = mapsUsed.begin(); i != mapsUsed.end(); ++i)
            m_TransportsByMap[*i].insert(t);

        //If we someday decide to use the grid to track transports, here:
        //MapManager::Instance().LoadGrid(mapid,x,y,true);
        //MapManager::Instance().GetMap(t->GetMapId())->Add<GameObject>((GameObject *)t);
        ++count;
    } while(result->NextRow());
    delete result;

    sLog.outString();
    sLog.outString( ">> Loaded %u transports", count );

    // check transport data DB integrity
    result = WorldDatabase.PQuery("SELECT `gameobject`.`guid`,`gameobject`.`id`,`transports`.`name` FROM `gameobject`,`transports` WHERE `gameobject`.`id` = `transports`.`entry`");
    if(result)                                              // wrong data found
    {
        do
        {
            Field *fields = result->Fetch();

            uint32 guid  = fields[0].GetUInt32();
            uint32 entry = fields[1].GetUInt32();
            std::string name = fields[2].GetCppString();
            sLog.outErrorDb("Transport %u '%s' have record (GUID: %u) in `gameobject`. Transports DON'T must have any records in `gameobject` or its behavior will be unpredictable/bugged.",entry,name.c_str(),guid);
        }
        while(result->NextRow());

        delete result;
    }
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:97,代码来源:Transports.cpp


注:本文中的Transport::GenerateWaypoints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。