int rm_dir(string dir) { mixed *file; int count; int i; /* if (! is_root(previous_object())) return 0; */ count = 0; if (dir[strlen(dir) - 1] != '/') dir += "/"; file = get_dir(dir, -1); i = sizeof(file); while (i--) { reset_eval_cost(); if (file[i][1] != -2) if (rm(dir + file[i][0])) count++; } i = sizeof(file); while (i--) { reset_eval_cost(); if (file[i][1] == -2) count += rm_dir(dir + file[i][0]); } write (HIC "删除目录(" + dir + ")。\n" NOR); rmdir(dir); return count; }
int copy_dir(string src, string dst, int dir_existed) { mixed *file; int count; int i; /* if (! is_root(previous_object())) return 0; */ count = 0; if (src[strlen(src) - 1] != '/') src += "/"; if (dst[strlen(dst) - 1] != '/') dst += "/"; // assure dst existed if (! dir_existed) assure_file(dst); file = get_dir(src, -1); if (! sizeof(file)) return count; write (HIC "复制目录(" + src + ") -- > (" + dst + ")。\n" NOR); i = sizeof(file); while (i--) { reset_eval_cost(); if (file[i][1] != -2) { if ( file_size(dst) == -1 ) { mkdir(dst); write("创建目录" + dst + "成功。\n"); } if (cp(src + file[i][0], dst + file[i][0])) { write(src + file[i][0] + " --> "); write(dst + file[i][0] + "\n"); count++; } } } i = sizeof(file); while (i--) { reset_eval_cost(); if (file[i][1] == -2) { mkdir(dst + file[i][0]); count += copy_dir(src + file[i][0], dst + file[i][0], DIR_EXISTED); } } return count; }
int main(object me,string arg) { string *files; mixed *file; int i,j,w=0,col,total=0; int size; set_eval_limit(1); seteuid(getuid()); if(!arg || arg=="") return notify_fail("╕ё╩╜▓╗╢╘гб\n"); error = 0; if (arg == "-o") arg = "/daemon/"; else arg = "/daemon/class/"+arg+"/"; file = get_dir(arg, -1); reset_eval_cost(); if( !sizeof(file) ) {if (file_size(arg) == -2) return notify_fail("╬─╡╡╝╨╩╟┐╒╡─бг\n"); else return notify_fail("├╗╙╨╒т╕Ў╬─╡╡╝╨бг\n"); } write(HIW"╒¤╘┌╦є╤▓"+arg+"╬─╡╡╝╨гогого\n"NOR); i = sizeof(file); w = 0; while(i--) { if (file[i][1]==-2) { files = get_dir(arg+file[i][0]+"/"); reset_eval_cost(); // р┼гм╒т╕Ў╙ж╕├╩╟╢╘╙ж╡─skill╬─╡╡гм╥╗╞Ё▒р╥ы░╔ update_function(me,"/daemon/skill/"+file[i][0]); // is a directory , ╜Ў╫╖╦▌╥╗▓убг for(j=0; j<sizeof(files); j++) { size=sizeof(files[j]); if(files[j][(size-2)..size]==".c") { update_function(me,arg+file[i][0]+"/"+files[j]); total++; } } file[i][0] += "/"; } }
string rec_list( mixed *args, string path, int all, int lvl, int only_leaf, object pl ) { int i, sk, o_l; string str, tp, tmp; str = ""; for ( i = 0 ; i < sizeof( args ) ; i += SKILL_ARR_SIZE ) { o_l = 0; tp = path +"."+ args[ i ]; sk = (int)pl->query_skill( tp ); if(tp[0..14] != ".other.language" && tp[0..13] != "other.language") { sk = new_skill_value(sk); } reset_eval_cost(); if (lvl == 1 && SKILL_OB->query_only_leaf(tp)) o_l = 1; if (!(only_leaf || o_l) || (!sizeof(args[i+SKILL_BIT]) && (sk > 0 || all))) str += sprintf( "%*'| 's%*'.'-s %4d %4d\n", ( lvl-1 ) * 2, "", 20 - ( ( lvl - 1 ) * 2 ), args[ i ], sk, (int)new_skill_value(pl->query_skill_bonus( tp )) ); if ( sizeof( args[ i + SKILL_BIT ] ) && ( only_leaf || o_l || all || ( sk > 5 * lvl ) ) ) { tmp = rec_list( args[ i + SKILL_BIT ], path +"."+ args[i], all, lvl + 1, only_leaf || o_l, pl ); if ((only_leaf || o_l) && (tmp != "" || (!all && lvl == 1))) str += sprintf( "%*'| 's%*'.'-s - -\n", ( lvl-1 ) * 2, "", 20 - ( ( lvl - 1 ) * 2 ), args[ i ]) + tmp; else str += tmp; } } return str; } /* rec_list() */
int do_purge_all_players() { int i, j, ppl_cnt, count; string *dir, *ppls, name; mixed info; seteuid(getuid()); message("system", "\n*** 整理玩家储存档中,请稍候.... ***\n", users()); write("处理中:"); count = 0; ppl_cnt = 0; dir = get_dir(DATA_DIR + "login/"); for(i=0; i<sizeof(dir); i++) { reset_eval_cost(); write(dir[i]); ppls = get_dir(DATA_DIR + "login/" + dir[i] + "/"); ppl_cnt += sizeof(ppls); for(j=0; j<sizeof(ppls); j++) { if( sscanf(ppls[j], "%s.o", name)==1 ) if( (string)SECURITY_D->get_status(name)!="(player)" ) continue; info = stat(DATA_DIR + "login/" + dir[i] + "/" + ppls[j]); if( SECURITY_D->get_status(name) == "(player)" ) { rm(DATA_DIR + "login/" + dir[i] + "/" + ppls[j]); rm(DATA_DIR + "user/" + dir[i] + "/" + ppls[j]); count ++; } } } write("\n\n原来总共有 " + ppl_cnt + " 位使用者。\n"); write("现在总共有 " + (ppl_cnt - count) + " 位使用者。\n"); return 1; }
int main(object me,string arg) // arg should be /d/baiyun/ .... { string *files; int i,total=0; int size; set_eval_limit(1); seteuid(getuid()); if(!arg || arg=="") return notify_fail("╕ё╩╜▓╗╢╘гб\n"); error = 0; write(HIW"╒¤╘┌╦є╤▓"+arg+"╬─╡╡╝╨гогого\n"NOR); files= get_dir(arg); reset_eval_cost(); for(i=0; i<sizeof(files); i++) { size=sizeof(files[i]); if(files[i][(size-2)..size]==".c"){ if (files[i]=="updatep.c") continue; total++; update_function(me, arg+files[i]); } // me->ccommand(sprintf("update %s%s",arg,files[i])); } write(HIW"гогого"+arg+"╬─╡╡╝╨▒р╥ы═ъ│╔бг бббббб╣▓╦є╤▓╡╜"+total+"╕Ў╡╡░╕гм╞ф╓╨"+error+"╕Ў▒р╥ы╩з░▄бг\n"NOR); return 1; }
void nuke_mailboxes(string* names){ int i,j; string mbox; i = sizeof(names); while(i--){ reset_eval_cost(); mbox = user_mbox_file(names[i]) + __SAVE_EXTENSION__; j = sizeof(mailbox); while(j--){ MAILMESG_D->delete_mesg(mailbox[j]["idx"], names[i]); reset_eval_cost(); } rm(mbox); } rm(NUKE_FILE); }
void search_dir (int count, string *dir, int i, string address, object me) { object ob; int j; string *ppls, name, str, adr, s1, s2, s3, s4; string info; if (i == sizeof(dir)) { tell_object(me,"共有"+to_chinese(count)+"位使用者从这个地址上线。\n"); } else { ppls = get_dir(DATA_DIR + "login/" + dir[i] + "/"); for(j=0; j<sizeof(ppls); j++) { reset_eval_cost(); if (sscanf(ppls[j], "%s.o", str)==1) { // What are these for??? Where was "name" assigned? // if (name == str) // continue; ob = new(LOGIN_OB); ob->set("id", str); if (! ob->restore()) { destruct(ob); continue; } if (! ob->query("last_from")) { destruct(ob); continue; } adr = ob->query("last_from"); if (strsrch(adr, address)==-1) { destruct(ob); continue; } info = sprintf("%-10s%-14s%-11s%-6s%s\n", ob->query("id"), ob->query("name"), ctime(ob->query("last_on"))[0..10], ctime(ob->query("last_on"))[20..24], ob->query("last_from")); tell_object (me,info); destruct(ob); count ++; } } i++; call_out ("search_dir",0,count,dir,i,address,me); } }
int do_one_room(object room, int x, int y, int z) { mapping exits; string *directions; string dir; object nextroom; int j; if (room->query("coor")) return 1; reset_eval_cost(); room->set("coor/x", x); room->set("coor/y", y); room->set("coor/z", z); write("Finished room "+ base_name(room) +"\n"); exits = room->query("exits"); if(!mapp(exits) || !sizeof(exits)) return 1; directions = keys(exits); for(j=0;j<sizeof(directions);j++) { x=(int) room->query("coor/x"); y=(int) room->query("coor/y"); z=(int) room->query("coor/z"); dir = directions[j]; if(!objectp(nextroom=find_object(exits[dir]))) nextroom=load_object(exits[dir]); switch(dir) { case "north" : y+=100;do_one_room(nextroom,x,y,z);break; case "south" : y-=100;do_one_room(nextroom,x,y,z);break; case "east" : x+=100;do_one_room(nextroom,x,y,z);break; case "west" : x-=100;do_one_room(nextroom,x,y,z);break; case "northup" : y+=100;z+=10;do_one_room(nextroom,x,y,z);break; case "southup" : y-=100;z+=10;do_one_room(nextroom,x,y,z);break; case "eastup" : x+=100;z+=10;do_one_room(nextroom,x,y,z);break; case "westup" : x-=100;z+=10;do_one_room(nextroom,x,y,z);break; case "northdown" : y+=100;z-=10;do_one_room(nextroom,x,y,z);break; case "southdown" : y-=100;z-=10;do_one_room(nextroom,x,y,z);break; case "eastdown": x+=100;z-=10;do_one_room(nextroom,x,y,z);break; case "westdown": x-=100;z-=10;do_one_room(nextroom,x,y,z);break; case "northeast" : y+=100;x+=10;do_one_room(nextroom,x,y,z);break; case "northwest" : y+=100;x-=10;do_one_room(nextroom,x,y,z);break; case "southeast": y-=100;x+=10;do_one_room(nextroom,x,y,z);break; case "southwest": y-=100;x-=10;do_one_room(nextroom,x,y,z);break; case "up" : z+=10;do_one_room(nextroom,x,y,z);break; case "down" : z-=10;do_one_room(nextroom,x,y,z);break; } } return 1; }
int sort_user(object ob1, object ob2) { string name1, name2;; reset_eval_cost(); if( wiz_level(ob1) != wiz_level(ob2) ) return wiz_level(ob2) - wiz_level(ob1); name1 = ob1->query("family/family_name"); name2 = ob2->query("family/family_name"); if (intp(name1)) name1 = ""; if (intp(name2)) name2 = ""; if (name1 > name2) return -1; if (name1 < name2) return 1; return (int)ob2->query("combat_exp") - (int)ob1->query("combat_exp"); }
int update_files(object me, string *files, string parent, int count){ int i, size; string *files2; reset_eval_cost(); for(i=0; i<sizeof(files); i++) { if (parent + files[i] == "/cmds/adm/updatepartner3.c") continue; size=sizeof(files[i]); if(files[i][(size-2)..size]==".c") { update_single_file(me, parent+files[i]); // me->ccommand(sprintf("update %s%s",parent,files[i])); } else if (arrayp(get_dir(files[i]))) { if (count>1) { files2 = get_dir(parent+files[i]+"/"); update_files(me, files2, parent+files[i]+"/",count-1); } } }
int do_one_room(object room, string arg, string i) { string file; string old; old = room->query(arg); reset_eval_cost(); file = read_file(base_name(room)+".c"); file = replace_string(file," set(\""+arg+"\", "+old+");\n",""); file = replace_string(file," set(\""+arg+"\","+old+");\n",""); file = replace_string(file," set(\""+arg+"\", \""+old+"\");\n",""); file = replace_string(file," set(\""+arg+"\",\""+old+"\");\n",""); file = replace_string(file,"setup", sprintf("set(\"%s\", %s);\n setup",arg,i)); if (write_file(base_name(room)+".c",file,1)) write("Finished room "+ base_name(room) +"\n"); return 1; }
int rmDir(string file) { string tmp; if(flag>15) return 0; reset_eval_cost(); switch(file_size(file)) { case -1 : flag=16;//设置出错中断 write("部分文件无权删除,错误!\n"); return 0; break; case -2 : //删除此目录下的文件和目录 if(file[sizeof(file)]!='/') file=file+"/"; foreach(tmp in get_dir(file)) { if(!rmDir(file+tmp)) { flag=16;//中断,因为删除出错 return 0; } } if(!rmdir(file)) { flag=16;//中断,因为删除出错 return 0; } break; default : if(!rm(file)) { flag=16;//中断,因为删除出错 return 0; } break; } return 1; }
int do_purge_players(int day) { int i, j, ppl_cnt, count; string *dir, *ppls, name; mixed info; seteuid(getuid()); message("system", "\n*** 整理玩家储存档中,请稍候.... ***\n", users()); write("处理中:"); count = 0; ppl_cnt = 0; dir = get_dir(DATA_DIR + "login/"); for(i=0; i<sizeof(dir); i++) { reset_eval_cost(); write(dir[i]); ppls = get_dir(DATA_DIR + "login/" + dir[i] + "/"); ppl_cnt += sizeof(ppls); for(j=0; j<sizeof(ppls); j++) { if( sscanf(ppls[j], "%s.o", name)==1 ) if( (string)SECURITY_D->get_status(name)!="(player)" ) continue; info = stat(DATA_DIR + "login/" + dir[i] + "/" + ppls[j]); if( (time()-(int)info[1])/86400 >= day ) { rm(DATA_DIR + "login/" + dir[i] + "/" + ppls[j]); rm(DATA_DIR + "user/" + dir[i] + "/" + ppls[j]); count ++; } } } write("\n\n原来总共有 " + ppl_cnt + " 位使用者。\n"); write( count + " 个超过 " + day + " 天未上线的使用者被清除掉了。\n"); write("现在总共有 " + (ppl_cnt - count) + " 位使用者。\n"); log_file("static/PURGE", sprintf("[%s] %s cleaned up %d characters who didn't login for more than %d days\n" "\t\tResulting statistics: %d characters remaining.\n", ctime(time())[0..15], geteuid(this_player(1)), count, day, ppl_cnt - count)); return 1; }
int do_list() { int i; string list; mixed *names; if(!"/secure/master"->query_lord( geteuid( this_player() ) )) return 1; list = "These are the Discworld quests:\n\n"; names = (mixed *)QUEST_HANDLER->query_quest_names(); for ( i = 0; i < sizeof( names ); i++ ) { list += "Quest "+ ( i + 1 ) +" \""+ names[ i ] +"\", level "+ (int)QUEST_HANDLER->query_quest_level( names[ i ] ) +"\n title: "+ (string)QUEST_HANDLER->query_quest_title( names[ i ] ) +"\n story: "+ (string)QUEST_HANDLER->query_quest_story( names[ i ] ) +"\n"; if ( i < sizeof( names ) - 1 ) list += "\n"; } reset_eval_cost(); this_player()->more_string( list, "Quest List", 1 ); return 1; } /* do_list() */
int main(object me, string arg) { int lines; int i; string line; if (! SECURITY_D->valid_grant(me, "(admin)")) return 0; lines = file_lines(IP_FILE); write(HIR "正在转换...\n\n" NOR); for (i = 1; i <= lines; i++) { line = read_file(IP_FILE, i, 1); line = line[0..<2]; resolve_data(line); if (i % 100) reset_eval_cost(); } write(HIR "\n一共转换了 " + (i - 1) + " 条 IP 数据。\n" NOR); return 1; }
// mon 5/19/98 // for characters reset_eval_cost, so that total eval_cost // won't be too high. int command( string str ) { reset_eval_cost(); return efun::command(str); }
int main(object me, string arg) { object where = environment(me); string skillname; string base_skname; int skill, skill_basic, times, i; int c, r; int diff, improve; int t = time(); if (! where) return notify_fail("你目前的位置有问题,还是先找巫师解决吧!\n"); if (where->query("pigging")) return notify_fail("你还是专心拱猪吧!\n"); if (me->is_busy()) return notify_fail("你现在正忙着呢。\n"); if (t == me->query_temp("time/practice")) return notify_fail("你刚刚才练习过(如果你要连续练习,可以指明练习的次数)。\n"); if (me->is_fighting()) return notify_fail("你已经在战斗中了,学一点实战经验吧。\n"); if (environment(me)->query("no_fight") && // (me->query("doing") != "scheme" || this_player(1))) me->query("doing") != "scheme") return notify_fail("你无法在这个地方安心练习。\n"); if (! arg) return (__DIR__"enable")->main(me, arg); if ((sscanf(arg, "%s %d", base_skname, times) != 2)) { times = 1; base_skname = arg; } c = 200 + me->query_temp("apply/practice_times"); if (present("practice emblem", me)) c += 300; if (times < 1 || times > c) return notify_fail("练习次数必须大于一次,但不能超过" + chinese_number(c) + "次。\n"); if (! stringp(skillname = me->query_skill_mapped(base_skname))) return notify_fail("你只能练习用 enable 指定的特殊技能。\n"); skill_basic = me->query_skill(base_skname, 1); skill = me->query_skill(skillname, 1); if (skill < 1) return notify_fail("你好像还没有学过这项技能吧?最好先去请教别人。\n"); if (skill_basic < 1) return notify_fail("你对这方面的技能还是一窍不通,最好从先从基本学起。\n"); if (skill_basic <= skill) return notify_fail("你的" + to_chinese(base_skname) + "火候不够,难以继续提升你" + to_chinese(skillname) + "的水平。\n"); notify_fail("你现在不能练习这项技能。\n"); if (! SKILL_D(skillname)->valid_learn(me)) return 0; if (! XUE_CMD->can_learn(me, skillname)) return 0; notify_fail("你试着练习" + to_chinese(skillname) + ",但是并没有任何进步。\n"); if (! me->can_improve_skill(skillname)) return notify_fail("也许是缺乏实战经验,你的练习总没法进步。\n"); me->set_temp("time/practice", t); if (skill >= 2000) improve = skill_basic / 4; else if (skill >= 1000) improve = skill_basic / 2; else improve = skill_basic; if (intp(r = me->query_temp("apply/practice_effect"))) improve += improve * r / 100; diff = SKILLS_D->query_skill_difficult(skillname); if (! diff) diff = SKILL_D(skillname)->difficult_level(); improve = improve / (diff / 100 + 5) + 1; for (i = 0; i < times; i++) { reset_eval_cost(); if (SKILL_D(skillname)->practice_skill(me)) me->improve_skill(skillname, improve, skill_basic > skill? 0: 1); else break; } if (i > 0) write(HIC "你试着把" + to_chinese(skillname) + "练了" + chinese_number(i)+"趟。\n" NOR); if (i >= times) return 1; return 0; }
string process_input(string str) { string *args, cmd, argstr; int i, j, count, curr_time; if (userp(this_object()) && (this_object()->query_temp("block_msg/all") || !living(this_object()) ) ) return ""; notify_fail("什么?\n"); // default fail messages. // for both gb and big5 environment. // need to be set here. otherwise big5 // will not show it correctly. // mon 5/12/98 reset_eval_cost(); // added by mon 5/18/98 to clear up eval_counter. // it seems that if one input many commands in a raw, // then the eval_counter is not cleared in time, and // thus causing Too long evaluation error. str = CONVERT_D->input(str,this_object()); // by mon 7/19/97. command counting. cmd_cnt++; if(cmd_cnt>100) { //threshold for how many commands can be //input every few seconds.(determined below) curr_time=time(); if(curr_time-last_time<5) { if(cmd_cnt1==0){ cmd_cnt2=cmd_cnt/(curr_time-last_time+1); write("你一次输入太多命令了。\n"); } cmd_cnt1++; if(cmd_cnt1>30) cmd_cnt1=0; last_time=curr_time; //in case of flooding, has to wait a few //seconds without input to be able to //input again. return ""; //flooding detected. ignore input. } else { cmd_cnt2=cmd_cnt/(curr_time-last_time+1); last_time=curr_time; cmd_cnt=0; cmd_cnt1=0; } } // mon 10/10/98 removed the following checks // since it is easy to work around this and no // real effect. /* if( str==last_input && strlen(str)==0 ) { repeat_cnt++; if( repeat_cnt > MAX_REPEAT ) { tell_object( this_object(), "\n\n忽听一声惨叫,从你脑门上爬下一只害虫,飞也似地逃走了。\n"+ "\n一边跑一边恨恨地道:原来是个机器人,牙都给崩掉了...\n\n"); command("rumor 忽听一声惨叫,从"+this_player()->name()+ "脑门上爬下一只害虫,飞也似地逃走了。 "); command("rumor 害虫一边跑一边恨恨地道:原来是个机器人,牙都给崩掉了..."); this_player()->set("sen",-1); command("quit"); } } else { repeat_cnt = 0; last_input = str; } */ if( str[0]=='!' ) { if( pointerp(history) && sizeof(history) ) { if( sscanf(str, "!%d", i) ) { if(i<0) i=0; else i=i%HISTORY_BUFFER_SIZE; str = (string)history[(HISTORY_BUFFER_SIZE + last_cmd - i) % HISTORY_BUFFER_SIZE]; } else str = history[last_cmd]; if(!str) return ""; } else return ""; } else { if( !pointerp(history) ) history = allocate(HISTORY_BUFFER_SIZE); last_cmd = (last_cmd + 1) % HISTORY_BUFFER_SIZE; history[last_cmd] = str; } if( mapp(alias) ) { if( !undefinedp(alias[str]) ) return replace_string( alias[str], "$*", "" ); if( sscanf(str, "%s %s", cmd, argstr)==2 && !undefinedp(alias[cmd]) ) { cmd = replace_string( alias[cmd], "$*", argstr ); args = explode(argstr, " "); if( (j = sizeof(args)) ) for(i=0; i<j; i++) cmd = replace_string( cmd, "$" + (i+1), args[i] ); return cmd; } } return (string)ALIAS_D->process_global_alias(str); }