Mud 代码修复:检测 bug 与逻辑优化
#include <config.h>
inherit F_CLEAN_UP;
int do_drop(object me, object obj, int raw);
void create() { seteuid(getuid()); }
int main(object me, string arg) { object obj, *inv, obj2; int i, amount; mixed info; string item;
if (! arg)
return notify_fail('你要丢下什么东西?\n');
if (sscanf(arg, "%d %s", amount, item) == 2)
{
if (! objectp(obj = present(item, me)))
return notify_fail('你身上没有这样东西。\n');
if (wiz_level(me) < 3 && (info = obj->query('no_drop')))
{
tell_object(me, stringp(info) ? info : obj->name() + '不能被丢弃。\n');
return 1;
}
if (! obj->query_amount())
return notify_fail( obj->name() + '不能被分开丢弃。\n');
if (amount < 1)
return notify_fail('东西的数量至少是一个。\n');
if (amount > obj->query_amount())
return notify_fail('你没有那么多的' + obj->name() + '。\n');
else if (amount == (int)obj->query_amount())
{
if (! do_drop(me, obj, 0))
{
obj->move(environment(me));
return 0;
}
return 1;
}
else
{
obj->set_amount((int)obj->query_amount() - amount);
obj2 = new(base_name(obj));
obj2->set_amount(amount);
if (! do_drop(me, obj2, 0))
{
obj2->move(environment(me));
return 0;
}
return 1;
}
}
}
原文地址: https://www.cveoy.top/t/topic/m5LF 著作权归作者所有。请勿转载和采集!