问题在于,在 do_drop 函数中,如果 obj 是复制品(clonep(obj) 为真),则直接销毁这个物品,但是没有考虑到临时属性的处理。如果这个物品有临时属性,丢弃后临时属性并没有被删除,这就可能导致一些潜在的问题。

下面是修复这个问题的代码:

int do_drop(object me, object obj, int raw) { mixed no_drop; object riding;

if (obj == (riding = me->query_temp("is_riding")))
{
    message_vision("$N从$n背上飞身跳下。\n", me, riding);
    me->delete_temp("is_riding");
    obj->delete_temp("is_rided_by");
    obj->move(environment(me));
    return 1;
}

if (!clonep(obj))
{
    // 如果不是复制品,直接移动到环境中
    if (obj->move(environment(me)))
    {
        if (obj->is_character() && obj->query_weight() > 20000)
            message_vision("$N将$n从背上放了下来,躺在地上。\n", me, obj);
        else
        {
            if (!raw)
                message_vision(sprintf(NOR"$N丢下%s%s$n。"NOR"\n",
                                        obj->query_amount()?CHINESE_D->chinese_number(obj->query_amount()):"一",
                                       obj->query_amount()?obj->query("base_unit"):obj->query("unit")), me, obj);
            else
                write(NOR"你丢下了"+(obj->query_amount()?CHINESE_D->chinese_number(obj->query_amount()):"一" )+
                        NOR+ (obj->query_amount()?obj->query("base_unit"):obj->query("unit"))+NOR +  obj->name() + "\n");

            if (! obj->is_character() && ! obj->query("value") && ! obj->value())
            {
                //write("因为这样东西没有具体价值,所以人们并不会注意到它的存在。\n");
                write(obj->query("name")+"掉地上消失了。\n");
                destruct(obj);
            }
        }
        return 1;
    }
    return 0;
}

// 如果是复制品,先保存临时属性
mapping tmp_data = obj->query_entire_dbase();
string *tmp_props = keys(tmp_data);

if (obj->move(environment(me)))
{
    // 如果成功移动到环境中,就把临时属性删除
    foreach (string prop in tmp_props)
    {
        obj->delete(prop);
    }

    if (obj->is_character() && obj->query_weight() > 20000)
        message_vision("$N将$n从背上放了下来,躺在地上。\n", me, obj);
    else
    {
        if (!raw)
            message_vision(sprintf(NOR"$N丢下%s%s$n。"NOR"\n",
                                    obj->query_amount()?CHINESE_D->chinese_number(obj->query_amount()):"一",
                                   obj->query_amount()?obj->query("base_unit"):obj->query("unit")), me, obj);
        else
            write(NOR"你丢下了"+(obj->query_amount()?CHINESE_D->chinese_number(obj->query_amount()):"一" )+
                    NOR+ (obj->query_amount()?obj->query("base_unit"):obj->query("unit"))+NOR +  obj->name() + "\n");

        if (! obj->is_character() && ! obj->query("value") && ! obj->value())
        {
            //write("因为这样东西没有具体价值,所以人们并不会注意到它的存在。\n");
            write(obj->query("name")+"掉地上消失了。\n");
            destruct(obj);
        }
    }
    return 1;
}

// 如果移动失败,就把临时属性恢复
foreach (string prop in tmp_props)
{
    obj->set(prop, tmp_data[prop]);
}

return 0;

}

临时属性增加了但是被销毁的时候没有减掉的bug 要具体的代码#include confighinherit F_CLEAN_UP;int do_dropobject me object obj int raw;void create seteuidgetuid; int mainobject me string arg	object obj inv obj2;	int i amount;	mix

原文地址: https://www.cveoy.top/t/topic/bAcx 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录