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

C++ dumb_ptr类代码示例

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

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



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

示例1: spell_instantiate

dumb_ptr<invocation> spell_instantiate(effect_set_t *effect_set, dumb_ptr<env_t> env)
{
    dumb_ptr<invocation> retval;
    retval.new_();
    dumb_ptr<block_list> caster;

    retval->env = env;

    retval->caster = env->VAR(VAR_CASTER).v.v_int;
    retval->spell = env->VAR(VAR_SPELL).v.v_spell;
    retval->stack_size = 0;
    retval->current_effect = effect_set->effect;
    retval->trigger_effect = effect_set->at_trigger;
    retval->end_effect = effect_set->at_end;

    caster = map_id2bl(retval->caster);    // must still exist
    retval->bl_id = map_addobject(retval);
    retval->bl_type = BL::SPELL;
    retval->bl_m = caster->bl_m;
    retval->bl_x = caster->bl_x;
    retval->bl_y = caster->bl_y;

    map_addblock(retval);
    set_env_invocation(VAR_INVOCATION, retval);

    return retval;
}
开发者ID:JaduJagat,项目名称:tmwa,代码行数:27,代码来源:magic-interpreter-base.cpp


示例2: spellguard_can_satisfy

static
int spellguard_can_satisfy(spellguard_check_t *check, dumb_ptr<map_session_data> caster,
        dumb_ptr<env_t> env, int *near_miss)
{
    tick_t tick = gettick();

    int retval = check_prerequisites(caster, check->catalysts);

    if (retval && near_miss)
        *near_miss = 1;         // close enough!

    retval = retval && caster->cast_tick <= tick    /* Hasn't cast a spell too recently */
        && check->mana <= caster->status.sp
        && check_prerequisites(caster, check->components);

    if (retval)
    {
        interval_t casttime = check->casttime;

        if (env->VAR(VAR_MIN_CASTTIME).ty == TYPE::INT)
            casttime = max(casttime, static_cast<interval_t>(env->VAR(VAR_MIN_CASTTIME).v.v_int));

        caster->cast_tick = tick + casttime;    /* Make sure not to cast too frequently */

        consume_components(caster, check->components);
        pc_heal(caster, 0, -check->mana);
    }

    return retval;
}
开发者ID:JaduJagat,项目名称:tmwa,代码行数:30,代码来源:magic-interpreter-base.cpp


示例3: skill_power_bl

int skill_power_bl(dumb_ptr<block_list> bl, SkillID skill)
{
    if (bl->bl_type == BL::PC)
        return skill_power(bl->is_player(), skill);
    else
        return 0;
}
开发者ID:GermanTMW2015,项目名称:tmwa,代码行数:7,代码来源:skill-pools.cpp


示例4: magic_free_env

void magic_free_env(dumb_ptr<env_t> env)
{
    for (int i = 0; i < env->base_env->varv.size(); i++)
        magic_clear_var(&env->varu[i]);
    // handled by std::unique_ptr now. Was a memory leak before.
    // delete[] env->vars;
    env.delete_();
}
开发者ID:JaduJagat,项目名称:tmwa,代码行数:8,代码来源:magic-interpreter-base.cpp


示例5: op_status_change

static
int op_status_change(dumb_ptr<env_t> env, const_array<val_t> args)
{
    dumb_ptr<block_list> subject = ARGENTITY(0);
    int invocation_id = env->VAR(VAR_INVOCATION).ty == TYPE::INVOCATION
        ? env->VAR(VAR_INVOCATION).v.v_int : 0;
    dumb_ptr<invocation> invocation_ = map_id_as_spell(invocation_id);

    assert (!ARGINT(3));
    assert (!ARGINT(4));
    assert (!ARGINT(5));
    skill_status_effect(subject, static_cast<StatusChange>(ARGINT(1)),
            ARGINT(2),
            static_cast<interval_t>(ARGINT(6)), invocation_id);

    if (invocation_ && subject->bl_type == BL::PC)
        record_status_change(invocation_, subject->bl_id, StatusChange(ARGINT(1)));

    return 0;
}
开发者ID:qiuhw,项目名称:tmwa,代码行数:20,代码来源:magic-stmt.cpp


示例6: op_instaheal

static
int op_instaheal(dumb_ptr<env_t> env, const_array<val_t> args)
{
    dumb_ptr<block_list> caster = (env->VAR(VAR_CASTER).ty == TYPE::ENTITY)
        ? map_id2bl(env->VAR(VAR_CASTER).v.v_int) : NULL;
    dumb_ptr<block_list> subject = ARGENTITY(0);
    if (!caster)
        caster = subject;

    if (caster->bl_type == BL::PC && subject->bl_type == BL::PC)
    {
        dumb_ptr<map_session_data> caster_pc = caster->as_player();
        dumb_ptr<map_session_data> subject_pc = subject->as_player();
        MAP_LOG_PC(caster_pc, "SPELLHEAL-INSTA PC%d FOR %d",
                    subject_pc->status.char_id, ARGINT(1));
    }

    battle_heal(caster, subject, ARGINT(1), ARGINT(2), 0);
    return 0;
}
开发者ID:qiuhw,项目名称:tmwa,代码行数:20,代码来源:magic-stmt.cpp


示例7: party_send_hp_check

// HP通知の必要性検査用(map_foreachinmoveareaから呼ばれる)
void party_send_hp_check(dumb_ptr<block_list> bl, int party_id, int *flag)
{
    dumb_ptr<map_session_data> sd;

    nullpo_retv(bl);
    sd = bl->is_player();

    if (sd->status.party_id == party_id)
    {
        *flag = 1;
        sd->party_hp = -1;
    }
}
开发者ID:JaduJagat,项目名称:tmwa,代码行数:14,代码来源:party.cpp


示例8: entity_warp

static
void entity_warp(dumb_ptr<block_list> target, map_local *destm, int destx, int desty)
{
    if (target->bl_type == BL::PC || target->bl_type == BL::MOB)
    {

        switch (target->bl_type)
        {
            case BL::PC:
            {
                dumb_ptr<map_session_data> character = target->as_player();
                clif_clearchar(character, BeingRemoveWhy::WARPED);
                map_delblock(character);
                character->bl_x = destx;
                character->bl_y = desty;
                character->bl_m = destm;

                pc_touch_all_relevant_npcs(character);

                // Note that touching NPCs may have triggered warping and thereby updated x and y:
                MapName map_name = character->bl_m->name_;

                // Warp part #1: update relevant data, interrupt trading etc.:
                pc_setpos(character, map_name, character->bl_x, character->bl_y, BeingRemoveWhy::GONE);
                // Warp part #2: now notify the client
                clif_changemap(character, map_name,
                        character->bl_x, character->bl_y);
                break;
            }
            case BL::MOB:
                target->bl_x = destx;
                target->bl_y = desty;
                target->bl_m = destm;
                clif_fixmobpos(target->as_mob());
                break;
        }
    }
}
开发者ID:qiuhw,项目名称:tmwa,代码行数:38,代码来源:magic-stmt.cpp


示例9: show_entity

static
FString show_entity(dumb_ptr<block_list> entity)
{
    switch (entity->bl_type)
    {
        case BL::PC:
            return entity->as_player()->status.name.to__actual();
        case BL::NPC:
            return entity->as_npc()->name;
        case BL::MOB:
            return entity->as_mob()->name;
        case BL::ITEM:
            assert (0 && "There is no way this code did what it was supposed to do!");
            /* Sorry about this one... */
            // WTF? item_data is a struct item, not a struct item_data
            // return ((struct item_data *) (&entity->as_item()->item_data))->name;
            abort();
        case BL::SPELL:
            return {"%invocation(ERROR:this-should-not-be-an-entity)"};
        default:
            return {"%unknown-entity"};
    }
}
开发者ID:cinderweb,项目名称:tmwa,代码行数:23,代码来源:magic-expr.cpp


示例10: free_area

static
void free_area(dumb_ptr<area_t> area)
{
    if (!area)
        return;

    switch (area->ty)
    {
        case AREA::UNION:
            free_area(area->a.a_union[0]);
            free_area(area->a.a_union[1]);
            break;
        default:
            break;
    }

    area.delete_();
}
开发者ID:cinderweb,项目名称:tmwa,代码行数:18,代码来源:magic-expr.cpp


示例11: op_override_attack

static
int op_override_attack(dumb_ptr<env_t> env, const_array<val_t> args)
{
    dumb_ptr<block_list> psubject = ARGENTITY(0);
    int charges = ARGINT(1);
    interval_t attack_delay = static_cast<interval_t>(ARGINT(2));
    int attack_range = ARGINT(3);
    StatusChange icon = StatusChange(ARGINT(4));
    int look = ARGINT(5);
    int stopattack = ARGINT(6);
    dumb_ptr<map_session_data> subject;

    if (psubject->bl_type != BL::PC)
        return 0;

    subject = psubject->as_player();

    if (subject->attack_spell_override)
    {
        dumb_ptr<invocation> old_invocation = map_id_as_spell(subject->attack_spell_override);
        if (old_invocation)
            spell_free_invocation(old_invocation);
    }

    subject->attack_spell_override =
        trigger_spell(subject->bl_id, env->VAR(VAR_INVOCATION).v.v_int);
    subject->attack_spell_charges = charges;

    if (subject->attack_spell_override)
    {
        dumb_ptr<invocation> attack_spell = map_id_as_spell(subject->attack_spell_override);
        if (attack_spell && stopattack)
            attack_spell->flags |= INVOCATION_FLAG::STOPATTACK;

        char_set_weapon_icon(subject, charges, icon, look);
        char_set_attack_info(subject, attack_delay, attack_range);
    }

    return 0;
}
开发者ID:qiuhw,项目名称:tmwa,代码行数:40,代码来源:magic-stmt.cpp


示例12: ladmin_itemfrob_c2

static
void ladmin_itemfrob_c2(dumb_ptr<block_list> bl, ItemNameId source_id, ItemNameId dest_id)
{
#define IFIX(v) if (v == source_id) {v = dest_id; }
#define FIX(item) ladmin_itemfrob_fix_item(source_id, dest_id, &item)

    if (!bl)
        return;

    switch (bl->bl_type)
    {
        case BL::PC:
        {
            dumb_ptr<map_session_data> pc = bl->is_player();

            for (IOff0 j : IOff0::iter())
                IFIX(pc->status.inventory[j].nameid);
            // cart is no longer supported
            // IFIX(pc->status.weapon);
            IFIX(pc->status.shield);
            IFIX(pc->status.head_top);
            IFIX(pc->status.head_mid);
            IFIX(pc->status.head_bottom);

            Option<P<Storage>> stor_ = account2storage2(pc->status_key.account_id);
            if OPTION_IS_SOME(stor, stor_)
            {
                for (SOff0 j : SOff0::iter())
                    FIX(stor->storage_[j]);
            }

            for (IOff0 j : IOff0::iter())
            {
                P<struct item_data> item = TRY_UNWRAP(pc->inventory_data[j], continue);
                if (item->nameid == source_id)
                {
                    item->nameid = dest_id;
                    if (bool(item->equip))
                        pc_unequipitem(pc, j, CalcStatus::NOW);
                    item->nameid = dest_id;
                }
            }

            break;
        }

        case BL::MOB:
        {
            dumb_ptr<mob_data> mob = bl->is_mob();
            for (Item& itm : mob->lootitemv)
                FIX(itm);
            break;
        }

        case BL::ITEM:
        {
            dumb_ptr<flooritem_data> item = bl->is_item();
            FIX(item->item_data);
            break;
        }
    }
#undef FIX
#undef IFIX
}
开发者ID:Rosalila,项目名称:tswa,代码行数:64,代码来源:chrif.cpp


示例13: find_entities_in_area_c

static
void find_entities_in_area_c(dumb_ptr<block_list> target,
        std::vector<int> *entities_vp,
        FOREACH_FILTER filter)
{
    switch (target->bl_type)
    {

        case BL::PC:
            if (filter == FOREACH_FILTER::PC
                || filter == FOREACH_FILTER::ENTITY
                || (filter == FOREACH_FILTER::TARGET
                    && target->bl_m->flag.pvp))
                break;
            else if (filter == FOREACH_FILTER::SPELL)
            {                   /* Check all spells bound to the caster */
                dumb_ptr<invocation> invoc = target->as_player()->active_spells;
                /* Add all spells locked onto thie PC */

                while (invoc)
                {
                    entities_vp->push_back(invoc->bl_id);
                    invoc = invoc->next_invocation;
                }
            }
            return;

        case BL::MOB:
            if (filter == FOREACH_FILTER::MOB
                || filter == FOREACH_FILTER::ENTITY
                || filter == FOREACH_FILTER::TARGET)
                break;
            else
                return;

        case BL::SPELL:
            if (filter == FOREACH_FILTER::SPELL)
            {
                dumb_ptr<invocation> invocation = target->as_spell();

                /* Check whether the spell is `bound'-- if so, we'll consider it iff we see the caster(case BL::PC). */
                if (bool(invocation->flags & INVOCATION_FLAG::BOUND))
                    return;
                else
                    break;      /* Add the spell */
            }
            else
                return;

        case BL::NPC:
            if (filter == FOREACH_FILTER::NPC)
                break;
            else
                return;

        default:
            return;
    }

    entities_vp->push_back(target->bl_id);
}
开发者ID:qiuhw,项目名称:tmwa,代码行数:61,代码来源:magic-stmt.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ duration类代码示例发布时间:2022-05-31
下一篇:
C++ dthread类代码示例发布时间: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