麻烦大师们,怎么改发呆超过时间。
#include <origin.h>#include <user.h>
#include <ansi.h>
inherit CHARACTER;
inherit F_AUTOLOAD;
inherit F_SAVE;
inherit F_BACKUP;
inherit F_XIULIAN;
nosave int last_age_set;
nomask mixed set(string prop, mixed data)
{
if ( objectp(previous_object()) )
{
if ( !SECURITY_D->valid_set( this_object(), previous_object()) )
return 0;
}
return ::set(prop,data);
}
nomask int delete(string prop)
{
if ( objectp(previous_object()) )
{
if ( !SECURITY_D->valid_set( this_object(), previous_object()) )
return 0;
}
return ::delete(prop);
}
nomask mapping query_entire_dbase()
{
if ( objectp(previous_object()) )
{
if ( !SECURITY_D->valid_set( this_object(), previous_object()) )
return 0;
}
return ::query_entire_dbase();
}
nomask mixed set_temp(string prop, mixed data)
{
if ( objectp(previous_object()) )
{
if ( !SECURITY_D->valid_set( this_object(), previous_object()) )
return 0;
}
return ::set_temp(prop,data);
}
nomask int delete_temp(string prop)
{
if ( objectp(previous_object()) )
{
if ( !SECURITY_D->valid_set( this_object(), previous_object()) )
return 0;
}
return ::delete_temp(prop);
}
nomask mapping query_entire_temp_dbase()
{
if ( objectp(previous_object()) )
{
if ( !SECURITY_D->valid_set( this_object(), previous_object()) )
return 0;
}
return ::query_entire_temp_dbase();
}
nomask mapping query_skills()
{
if ( objectp(previous_object()) )
{
if ( !SECURITY_D->valid_set( this_object(), previous_object()) )
return 0;
}
return ::query_skills();
}
nomask void set_skill(string skill, int val)
{
if ( objectp(previous_object()) )
{
if ( !SECURITY_D->valid_set( this_object(), previous_object()) )
return;
}
::set_skill(skill, val);
}
nomask int delete_skill(string skill)
{
if ( objectp(previous_object()) )
{
if ( !SECURITY_D->valid_set( this_object(), previous_object()) )
return 0;
}
return ::delete_skill(skill);
}
nomask varargs void improve_skill(string skill, int amount, int weak_mode)
{
if ( objectp(previous_object()) )
{
if ( !SECURITY_D->valid_set( this_object(), previous_object()) )
return;
}
::improve_skill(skill, amount, weak_mode);
}
nomask void die()
{
if ( objectp(previous_object()) )
{
if ( !SECURITY_D->valid_set( this_object(), previous_object()) )
return;
}
::die();
}
/*
nomask void clear_condition()
{
if ( objectp(previous_object()) )
{
if ( !SECURITY_D->valid_set( this_object(), previous_object()) )
return;
}
::clear_condition();
}
*/
void create()
{
::create();
set_name("使用者物件", ({ "user object", "user", "object" }) );
}
void terminal_type(string term_type)
{
set_temp("terminal_type", term_type);
message("system", "终端机型态设定为 " + term_type + "。\n", this_object());
}
void reset()
{
if ( (int)query("thief") > 0 )
add("thief", -1 );
}
string query_save_file()
{
string id;
id = geteuid();
if ( !id )
id = getuid();
if ( !stringp(id) )
return 0;
return sprintf(DATA_DIR "user/%c/%s", id, id);
}
int save()
{
int res;
save_autoload();
res = ::save();
clean_up_autoload();// To save memory
this_object()->set_temp("save_end_time", time()); // 存档时间
return res;
}
int backup()
{
int res;
save_autoload();
res = ::backup();
clean_up_autoload();
return res;
}
// This function updates player's age, called by heart_beat()
varargs void update_age(int type)
{
// Update the time we spend on mudding, using method from TMI-2 mudlib.
if ( !environment() )
return;
if ( !type && environment()->query("freeze") )
{
last_age_set = time();
return;
}
if ( !last_age_set )
last_age_set = time();
add("mud_age", time() - last_age_set);
last_age_set = time();
set("age", 14 + (int)query("age_modify") + ((int)query("mud_age") / 86400));
}
void setup()
{
// We want set age first before new player got initialized with
// random age.
update_age();
::setup();
restore_autoload();
}
protected void user_dump(int type)
{
switch(type)
{
case DUMP_NET_DEAD:
if( in_input(this_object()) || in_edit(this_object()) )
// remove_input_to(this_object());
tell_room( environment(), query("name") + "断线超过 " + NET_DEAD_TIMEOUT/60 + " 分钟,自动退出这个世界。\n");
command("quit");
break;
case DUMP_IDLE:
if( in_input(this_object()) || in_edit(this_object()) )
{
// remove_input_to(this_object());
tell_object( this_object(), HIY"\n您输入文字发呆的时间超过 "HIC + IDLE_TIMEOUT/60 + HIY" 分钟了,还是先想好了再说吧。\n"NOR);
command("quit");
break;
this_object()->write_prompt();
}
if ( wizardp(this_object()) || environment()->query("freeze") )
return;
tell_object( this_object(), "对不起,您已经发呆超过 " + IDLE_TIMEOUT/60 + " 分钟了,请下次再来。\n");
tell_room( environment(), "一阵风吹来,将发呆中的" + query("name") + "化为一堆飞灰,消失了。\n", ({this_object()}));
command("quit");
break;
default: return;
}
}
// net_dead: called by the gamedriver when an interactive player loses
// hir network connection to the mud.
protected void net_dead()
{
object link_ob, shadow_ob;
string name;
if ( objectp(link_ob = query_temp("link_ob")) )
destruct(link_ob);
// 清除 shadow_ob,也就是使远程登陆到的帐号也断线
if ( objectp(shadow_ob=this_object()->query_temp("query_shadowed")) )
shadow_ob->remove_shadow(this_object());
if ( !environment() )
{
command("quit");
return;
}
if ( !this_object()->query("lixian/biguan") )
{
if ( !this_object()->query_condition("killer") )
set_heart_beat(0);
}
// Stop fighting, we'll be back soon.
remove_all_enemy();
if ( !this_object()->query("lixian/biguan") )
set_temp("netdead", 1);
if ( userp(this_object()) )
{
if ( !this_object()->query("lixian/biguan") )
{
call_out("user_dump", NET_DEAD_TIMEOUT, DUMP_NET_DEAD);
tell_room(environment(), query("name") + "断线了。\n", this_object());
environment()->set("channel_id",environment()->query("short"));
CHANNEL_D->do_channel(environment(), "sys", query("name")+ "(" + capitalize(query("id")) + ")"+"断线了。");
if ( !wizardp(this_object()) )
this_object()->set("quit_time",time());
}
// 组队清除
if ( stringp(name = this_object()->query_temp("xyzx_team/name")) )
TEAMD->del_team_member(this_object());
}
}
// reconnect: called by the LOGIN_D when a netdead player reconnects.
void reconnect()
{
set_heart_beat(1);
if ( !this_object()->query("lixian/biguan") )
{
set_temp("netdead",0);
remove_call_out("user_dump");
}
tell_object(this_object(), "重新连线完毕。\n");
}
void kick()
{
if ( is_busy() || is_fighting() )
return;
command("quit");
}
int id(string str)
{
string *applied_id;
if ( geteuid(this_object()) != str )
return 0;
if ( pointerp(applied_id = query_temp("apply/id")) && sizeof(applied_id) )
{
if ( this_player() && !wizardp(this_player()) )
return 0;
}
if( this_player() && !this_player()->visible(this_object()) )
return 0;
return 1;
}
nomask int is_player()
{
return clonep();
}
nomask void reset_heart_beat(int i)
{
set_heart_beat(i);
}
nomask void save_item_call()
{
remove_call_out("save_my_items");
call_out("save_my_items", 1, this_object());
}
nomask void save_my_items(object ob)
{
if ( !objectp(ob) ) return;
auto_save_item(ob, 1);
}
nomask void del_pended_call()
{
remove_call_out("del_my_pended");
call_out("del_my_pended", 1, this_object());
}
nomask void del_my_pended(object ob)
{
if ( !objectp(ob) ) return;
ob->delete_temp("pended");
}
nomask void remove_save_item()
{
remove_call_out("save_my_items");
}
----------------------------------------------------------------------------------------------------------
这几天有在利用这个功能,人不在线。号也不能T下线。shutdown重起也没用。很烦恼
只能远程重起MUD
请大神们给个办法
再次感谢
北大侠客行MUD,中国最好的MUD mudos.log里面一直显示
locals were: clone/user/user#331477,0,0,0,0,0,0,0,0,0,0,88,0,0,1
' tell_object' in 'adm/obj/simul_efun.c' ('adm/obj/simul_efun') /adm/simul_efun/message.c:47
arguments were (clone/user/user#331477,"[1;33m
您输入文字发呆的时间超过[1;36m 五 [1;33m分钟了,还是先想好了再说吧。
[2;37;0m")
可是 玩家ID 并没有被T下线 移动这个玩家ID 也没用
MUD 就象卡死了一样 一堆代码看的头都大了 #include
#include
#include
inherit CHARACTER;
inherit F_AUTOLOAD;
inherit F_SAVE;
inherit F ...
rxoo 发表于 2013-5-13 04:22 PM http://pkuxkx.net/forum/images/common/back.gif
shutdown和远程重启有什么区别?你是说不能shutdown吗? mudos.log 里面只要出现一大堆的 您输入文字发呆的时间超过[1;36m 五 [1;33m分钟了,还是先想好了再说吧。
就开始出错了。 quit 不能用 shutdownreboot都无法重起MUD
捣乱的玩 显示 输入文字发呆中其他玩家也开始无心跳 无法使用quit下线
捣乱的玩ID 无法 kickout踢出游戏
只能 远程登录服务器手动重起机器 if( in_input(this_object()) || in_edit(this_object()) )
{
// remove_input_to(this_object());
tell_object( this_object(), HIY"\n您输入文字发呆的时间超过 "HIC + IDLE_TIMEOUT/60 + HIY" 分钟了,还是先想好了再说吧。\n"NOR);
command("quit");
break;
this_object()->write_prompt();
}
那你就把这段代码删除了试试。 jason大神 要是删了不就更没有限制了吗 bug显然来自这段代码。你就让他在编辑状态呆着呗。 if( in_input(this_object()) || in_edit(this_object()) )
{
...
jason 发表于 2013-5-15 01:43 PM http://pkuxkx.net/forum/images/common/back.gif
if( in_input(this_object()) || in_edit(this_object()) )
{
// remove_input_to(this_object());
tell_object( this_object(), HIY"\n您输入文字发呆的时间超过 "HIC + IDLE_TIMEOUT/60 + HIY" 分钟了,还是先想好了再说吧。\n"NOR);
command("quit"); //这里应该已经destruct(this_object())了。
break;
this_object()->write_prompt();//这里的this_object()哪里来的?况且上面都已经break了。如果要防止quit没有成功,至少要判断下当前物件有没有被成功摧毁吧 }
那你就把这段代码删除了试试。
页:
[1]