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


C++ World::GetOlcManager方法代码示例

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


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

示例1: InitializeStaticObjectOlcs

//initialize olcs.
BOOL InitializeStaticObjectOlcs()
{
    World* world = World::GetPtr();
    OlcManager* omanager = world->GetOlcManager();
    OlcGroup* sgroup = new OlcGroup();

    sgroup->SetInheritance(omanager->GetGroup(OLCGROUP::BaseObject));
    sgroup->AddEntry(new OlcStringEntry<StaticObject>("short", "the title of the object seen in rooms", OF_NORMAL, OLCDT::STRING,
                     std::bind(&StaticObject::GetShort, std::placeholders::_1),
                     std::bind(&StaticObject::SetShort, std::placeholders::_1, std::placeholders::_2)));
    sgroup->AddEntry(new OlcStringEntry<StaticObject>("plural", "Sets the plural of the object", OF_NORMAL, OLCDT::STRING,
                     std::bind(&StaticObject::GetPlural, std::placeholders::_1),
                     std::bind(&StaticObject::SetPlural, std::placeholders::_1, std::placeholders::_2)));
    omanager->AddGroup(OLCGROUP::STATIC, sgroup);
    return true;
}
开发者ID:renokun,项目名称:Aspen,代码行数:17,代码来源:staticObject.cpp

示例2: Execute

BOOL CMDOlcSet::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    World* world = World::GetPtr();
    OlcManager* omanager = world->GetOlcManager();
    OlcGroup* group = NULL;
    IOlcEntry* entry = NULL;
    VNUM vnum = 0;
    size_t dotpos = 0;
    std::string component;
    Component* ocomponent = NULL;
    ComponentMeta* meta = NULL;
    std::vector<std::string>::iterator it;
    std::string name;
    std::string value;

    union
    {
        Room* r;
        StaticObject* o;
        Npc* n;
    } o;
    o.o = NULL;

    if (args.size() == 0)
        {
            mobile->Message(MSG_ERROR, "Syntax: "+verb+" <vnum>[.component] [field] [value].");
            return false;
        }

//we see if there was a component attached to the object number.
    dotpos = args[0].find('.');
    if(dotpos == std::string::npos) //no component iidentifier found
        {
            if (subcmd == COS_ROOM && args[0]  == "here")
                {
                    vnum = mobile->GetLocation()->GetOnum();
                }
            else
                {
                    try
                        {
                            vnum = (VNUM)boost::lexical_cast<unsigned int>(args[0]);
                        }
                    catch (boost::bad_lexical_cast e)
                        {
                            mobile->Message(MSG_ERROR, "Invalid vnum.");
                            return false;
                        }
                }
        }
    else //there was a component attached.
        {
            if (subcmd == COS_ROOM && args[0].substr(0,dotpos) == "here")
                {
                    vnum = mobile->GetLocation()->GetOnum();
                }
            else
                {
                    try
                        {
                            vnum = boost::lexical_cast<unsigned int>(args[0].substr(0, dotpos));
                        }
                    catch (boost::bad_lexical_cast e)
                        {
                            mobile->Message(MSG_ERROR, "Invalid vnum.");
                            return false;
                        }
                }
            component = args[0].erase(0, dotpos + 1);
        }
    if (vnum < 1)
        {
            mobile->Message(MSG_ERROR, "Invalid vnum.");
            return false;
        }

//now we need to get the object we're actually editing.
    switch(subcmd)
        {
        case COS_OBJECT:
            o.o = world->GetVirtual(vnum);
            if (!component.length())
                {
                    group = omanager->GetGroup(OLCGROUP::STATIC);
                    if (!group)
                        {
                            mobile->Message(MSG_ERROR, "That group does not exist.");
                            return false;
                        }
                    break;
                }
            else
                {
                    ocomponent = o.o->GetComponent(component);
                    if (!ocomponent)
                        {
                            mobile->Message(MSG_ERROR, "That component does not exist.");
                            return false;
                        }
                    meta = ocomponent->GetMeta();
//.........这里部分代码省略.........
开发者ID:wdgrusse,项目名称:Aspen,代码行数:101,代码来源:olc.cpp


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