• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ WaypointBehavior类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Cleanup

void WaypointManager::Load()
{
    Cleanup();

    uint32 total_paths = 0;
    uint32 total_nodes = 0;
    uint32 total_behaviors = 0;

    QueryResult *result = WorldDatabase.Query("SELECT id, COUNT(point) FROM creature_movement GROUP BY id");
    if(result)
    {
        total_paths = result->GetRowCount();
        barGoLink bar( total_paths );
        do
        {
            Field *fields = result->Fetch();
            uint32 id    = fields[0].GetUInt32();
            uint32 count = fields[1].GetUInt32();
            m_pathMap[id].resize(count);

            total_nodes += count;
            bar.step();
        } while( result->NextRow() );
        delete result;
    }

    result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2, waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id, point FROM creature_movement");
    if(result)
    {
        barGoLink bar( result->GetRowCount() );
        do
        {
            Field *fields = result->Fetch();
            uint32 point        = fields[15].GetUInt32();
            uint32 id           = fields[14].GetUInt32();

            WaypointPath &path  = m_pathMap[id];
            // the cleanup queries make sure the following is true
            assert(point >= 1 && point <= path.size());
            WaypointNode &node  = path[point-1];

            node.x              = fields[0].GetFloat();
            node.y              = fields[1].GetFloat();
            node.z              = fields[2].GetFloat();
            node.orientation    = fields[3].GetFloat();
            node.delay          = fields[6].GetUInt16();

            // prevent using invalid coordinates
            if(!MaNGOS::IsValidMapCoord(node.x, node.y, node.z, node.orientation))
            {
                QueryResult *result1 = WorldDatabase.PQuery("SELECT id, map FROM creature WHERE guid = '%u'", id);
                if(result1)
                    sLog.outErrorDb("ERROR: Creature (guidlow %d, entry %d) have invalid coordinates in his waypoint %d (X: %f, Y: %f).",
                        id, result1->Fetch()[0].GetUInt32(), point, node.x, node.y);
                else
                    sLog.outErrorDb("ERROR: Waypoint path %d, have invalid coordinates in his waypoint %d (X: %f, Y: %f).",
                        id, point, node.x, node.y);

                MaNGOS::NormalizeMapCoord(node.x);
                MaNGOS::NormalizeMapCoord(node.y);
                if(result1)
                {
                    node.z = MapManager::Instance ().GetBaseMap(result1->Fetch()[1].GetUInt32())->GetHeight(node.x, node.y, node.z);
                    delete result1;
                }
                WorldDatabase.PExecute("UPDATE creature_movement SET position_x = '%f', position_y = '%f', position_z = '%f' WHERE id = '%u' AND point = '%u'", node.x, node.y, node.z, id, point);
            }

            WaypointBehavior be;
            be.model1           = fields[4].GetUInt32();
            be.model2           = fields[5].GetUInt32();
            be.emote            = fields[7].GetUInt32();
            be.spell            = fields[8].GetUInt32();

            for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i)
            {
                be.textid[i]        = fields[9+i].GetUInt32();
                if(be.textid[i])
                {
                    if (be.textid[i] < MIN_DB_SCRIPT_STRING_ID || be.textid[i] >= MAX_DB_SCRIPT_STRING_ID)
                    {
                        sLog.outErrorDb( "Table `db_script_string` not have string id  %u", be.textid[i]);
                        continue;
                    }
                }
            }

            // save memory by not storing empty behaviors
            if(!be.isEmpty())
            {
                node.behavior   = new WaypointBehavior(be);
                ++total_behaviors;
            }
            else
                node.behavior   = NULL;
            bar.step();
        } while( result->NextRow() );
        delete result;
    }
    sLog.outString( ">> Loaded %u paths, %u nodes and %u behaviors", total_paths, total_nodes, total_behaviors);
//.........这里部分代码省略.........
开发者ID:Anderss,项目名称:mangos,代码行数:101,代码来源:WaypointManager.cpp


示例2: Cleanup


//.........这里部分代码省略.........
                QueryResult* result1 = WorldDatabase.PQuery("SELECT id, map FROM creature WHERE guid = '%u'", id);
                if (result1)
                    sLog.outErrorDb("Creature (guidlow %d, entry %d) have invalid coordinates in his waypoint %d (X: %f, Y: %f).",
                                    id, result1->Fetch()[0].GetUInt32(), point, node.x, node.y);
                else
                    sLog.outErrorDb("Waypoint path %d, have invalid coordinates in his waypoint %d (X: %f, Y: %f).",
                                    id, point, node.x, node.y);

                MaNGOS::NormalizeMapCoord(node.x);
                MaNGOS::NormalizeMapCoord(node.y);

                if (result1)
                {
                    node.z = sTerrainMgr.LoadTerrain(result1->Fetch()[1].GetUInt32())->GetHeightStatic(node.x, node.y, node.z);
                    delete result1;
                }

                WorldDatabase.PExecute("UPDATE creature_movement SET position_x = '%f', position_y = '%f', position_z = '%f' WHERE id = '%u' AND point = '%u'", node.x, node.y, node.z, id, point);
            }

            if (node.script_id)
            {
                if (sCreatureMovementScripts.second.find(node.script_id) == sCreatureMovementScripts.second.end())
                {
                    sLog.outErrorDb("Table creature_movement for id %u, point %u have script_id %u that does not exist in `dbscripts_on_creature_movement`, ignoring", id, point, node.script_id);
                    continue;
                }

                movementScriptSet.erase(node.script_id);
            }

            // WaypointBehavior can be dropped in time. Script_id added may 2010 and can handle all the below behavior.

            WaypointBehavior be;
            be.model1           = fields[15].GetUInt32();
            be.model2           = fields[16].GetUInt32();
            be.emote            = fields[12].GetUInt32();
            be.spell            = fields[13].GetUInt32();

            for (int i = 0; i < MAX_WAYPOINT_TEXT; ++i)
            {
                be.textid[i]    = fields[7 + i].GetInt32();

                if (be.textid[i])
                {
                    if (be.textid[i] < MIN_DB_SCRIPT_STRING_ID || be.textid[i] >= MAX_DB_SCRIPT_STRING_ID)
                    {
                        sLog.outErrorDb("Table `creature_movement` Id %u, point %u has textid%u has value %d out of range. Must be in %u-%u", id, point, i + 1, be.textid[i], MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID - 1);
                        be.textid[i] = 0;
                    }
                }
            }

            if (be.spell && ! sSpellStore.LookupEntry(be.spell))
            {
                sLog.outErrorDb("Table creature_movement references unknown spellid %u. Skipping id %u with point %u.", be.spell, id, point);
                be.spell = 0;
            }

            if (be.emote)
            {
                if (!sEmotesStore.LookupEntry(be.emote))
                    sLog.outErrorDb("Waypoint path %u (Point %u) are using emote %u, but emote does not exist.", id, point, be.emote);
            }

            // save memory by not storing empty behaviors
开发者ID:Celtus,项目名称:portalone,代码行数:67,代码来源:WaypointManager.cpp


示例3: Cleanup

void WaypointManager::Load()
{
    Cleanup();

    uint32 total_paths = 0;
    uint32 total_nodes = 0;
    uint32 total_behaviors = 0;

    QueryResult *result = WorldDatabase.Query("SELECT id, COUNT(point) FROM creature_movement GROUP BY id");

    if(!result)
    {
        barGoLink bar(1);
        bar.step();
        sLog.outString();
        sLog.outString( ">> Loaded 0 paths. DB table `creature_movement` is empty." );
        return;
    } else {
        total_paths = result->GetRowCount();
        barGoLink bar( total_paths );
        do
        {
            bar.step();
            Field *fields = result->Fetch();
            uint32 id    = fields[0].GetUInt32();
            uint32 count = fields[1].GetUInt32();
            m_pathMap[id].resize(count);
            total_nodes += count;
        } while( result->NextRow() );
        delete result;

        sLog.outString();
        sLog.outString( ">> Paths loaded" );
    }

    //                                   0           1           2           3            4       5
    result = WorldDatabase.Query("SELECT position_x, position_y, position_z, orientation, model1, model2,"
    //   6         7      8      9        10       11       12       13       14  15
        "waittime, emote, spell, textid1, textid2, textid3, textid4, textid5, id, point FROM creature_movement");

    barGoLink bar( result->GetRowCount() );
    do
    {
        bar.step();
        Field *fields = result->Fetch();
        uint32 point        = fields[15].GetUInt32();
        uint32 id           = fields[14].GetUInt32();
        if (!sObjectMgr.GetCreatureData(id))
        {
            sLog.outErrorDb("Table creature_movement references unknown creature %u. Deleted.", id);
			WorldDatabase.PExecute("DELETE FROM creature_movement where id=%u",id);
            continue;
        }

        WaypointPath &path  = m_pathMap[id];
        // the cleanup queries make sure the following is true
        ASSERT(point >= 1 && point <= path.size());
        WaypointNode &node  = path[point-1];

        node.x              = fields[0].GetFloat();
        node.y              = fields[1].GetFloat();
        node.z              = fields[2].GetFloat();
        node.orientation    = fields[3].GetFloat();
        node.delay          = fields[6].GetUInt32();

        // prevent using invalid coordinates
        if(!MaNGOS::IsValidMapCoord(node.x, node.y, node.z, node.orientation))
        {
            QueryResult *result1 = WorldDatabase.PQuery("SELECT id, map FROM creature WHERE guid = '%u'", id);
            if(result1)
                sLog.outErrorDb("Creature (guidlow %d, entry %d) have invalid coordinates in his waypoint %d (X: %f, Y: %f).",
                    id, result1->Fetch()[0].GetUInt32(), point, node.x, node.y);
            else
                sLog.outErrorDb("Waypoint path %d, have invalid coordinates in his waypoint %d (X: %f, Y: %f).",
                    id, point, node.x, node.y);

            MaNGOS::NormalizeMapCoord(node.x);
            MaNGOS::NormalizeMapCoord(node.y);
            if(result1)
            {
                node.z = MapManager::Instance ().CreateBaseMap(result1->Fetch()[1].GetUInt32())->GetHeight(node.x, node.y, node.z);
                delete result1;
            }
            WorldDatabase.PExecute("UPDATE creature_movement SET position_x = '%f', position_y = '%f', position_z = '%f' WHERE id = '%u' AND point = '%u'", node.x, node.y, node.z, id, point);
        }
        WaypointBehavior be;
        be.model1           = fields[4].GetUInt32();
        be.model2           = fields[5].GetUInt32();
        be.emote            = fields[7].GetUInt32();
        be.spell            = fields[8].GetUInt32();
        for(int i = 0; i < MAX_WAYPOINT_TEXT; ++i)
        {
            be.textid[i]        = fields[9+i].GetUInt32();
            if(be.textid[i])
            {
                if (be.textid[i] < MIN_DB_SCRIPT_STRING_ID || be.textid[i] >= MAX_DB_SCRIPT_STRING_ID)
                {
                    sLog.outErrorDb( "Table `db_script_string` not have string id  %u", be.textid[i]);
                    continue;
                }
//.........这里部分代码省略.........
开发者ID:AwkwardDev,项目名称:MangosFX,代码行数:101,代码来源:WaypointManager.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WaypointList类代码示例发布时间:2022-05-31
下一篇:
C++ Waypoint类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap