Пример #1
0
int main(object me, string arg)
{
        object user;
	string srcstr, dststr;
	string status;

	status = wizhood(me);
	if( me!=this_player(1) || wiz_level(me) < wiz_level(status) )
		return notify_fail("你没有权力使用这个指令。\n");
	
	if (!arg) return 0;
        if (sscanf(arg, "%s %s", srcstr, dststr)!=2) return 0;

	// login data

        seteuid(getuid());
	user = new(LOGIN_OB);
	if( (string)user->set("id", srcstr) != srcstr ) 
		return notify_fail("Failed setting user name.\n");
	if (! user->restore())	return notify_fail("没有这个玩家。\n");
	export_uid(user);

	if( (string)user->set("id", dststr) != dststr ) 
		return notify_fail("Failed setting user name.\n");
        if (!user->save()) return notify_fail("存档失败!\n");
	destruct(user);

        tell_object(me, 
		"玩家 "+srcstr+" 数据成功转换至玩家 "+dststr+" !\n");
	return 1;
}	
Пример #2
0
void restore_autoload() {
        int i;
        object ob;
        string file, param, err; 
        if(!pointerp(autoload)) {
                return;
        }
        for(i=0; i<sizeof(autoload); i++) {
                if( sscanf(autoload[i], "%s:%s", file, param)!=2 ) {
                        file = autoload[i];
                   param = 0;
                }
                err = catch(ob = new(file));
                if( err || !objectp(ob) ) {
                        write("你觉得似乎失落了什麽重要的东西,最好通知一下巫师。\n");
                        log_file("AUTOLOAD", sprintf("Fail to autoload %s of %s, error %s\n",
                                file, this_object()->query("name"), err));
                        continue;
                }
                export_uid(ob);
                ob->move(this_object());
                ob->autoload(param);
        }
        clean_up_autoload();            // To save memory.
} 
Пример #3
0
void restore_autoload()
{
  int i;
  object ob;
  string file, *autodir, param, err;

  if( !pointerp(autoload) ) return;

  for(i=0; i<sizeof(autoload); i++) {
    printf ("autoload %d = %s\n", i+1, autoload[i]);
    if( sscanf(autoload[i], "%s:%s", file, param)!=2 ) {
      file = autoload[i];
      param = 0;
    }
    autodir = explode (file, "/");
#ifndef SAVEEQ
    if (autodir[0] != "obj" &&
        (autodir[0] != "data" || autodir[1] != "autoload")) {
      write ("你有一个自动载入的物件没放在该放的地方:"+file+"\n");
      continue;
    }
#endif
    err = catch(ob = new(file));
    if( err || !ob ) {
      write("你觉得似乎失落了什么重要的东西,最好通知一下巫师。\n");
      log_file("AUTOLOAD", sprintf("Fail to autoload %s of %s, error %s\n",
        file, this_object()->query("name"), err));
      continue;
    }
    export_uid(ob);
    ob->move(this_object());
    ob->autoload(param);
  }
  clean_up_autoload();    // To save memory.
}
Пример #4
0
object restore_data(string name) {
    object link;

    if (find_player(name) && interactive(find_player(name))) {
	return (object)find_player(name)->query_link();
    }

    link = new(CONNECTION);

    seteuid(name);
    export_uid(link);
    seteuid(ROOT_UID);

    link->set("name", name);
    if (link->restore()) {
	return link;
    }

    // If this fails, then let's clean up afterwards...
    link->remove();
    // Some names like .foo weren't getting away.
    if(link) destruct(link);
    if(link) log_file("fingerdest",sprintf("Connection of %s not dested"+
	    " by finger daemon, on %s.\n", name, ctime(time())));
    return 0;
}
Пример #5
0
static int fail_test(string dir, string what, int when, int flag) {
   string name;
 
   //	Parse off the user's name ...

   if(!what || !file_exists(dir + what) || 
      sscanf(what, "%s" + __SAVE_EXTENSION__, name) != 1)  return 0;
 
   //	Reset the link's properties for the next user.
 
   reload_object(link);
 
   seteuid(name);
   export_uid(link);
   seteuid(ROOT_UID);
 
   link->set("name", name);
 
   if(!link->restore())  return 0;
 
   if(!flag && (int)link->query("wizard"))  return 0;

   if(to_int((int)link->query("last_on")) < when)  return 1;

return 0; }
Пример #6
0
int restore_body() {
	if (geteuid(previous_object()) != ROOT_UID) return 0;
	if (!name || !body) return 0;
	seteuid(name);
	if(catch( body_ob = new(body) ))  return 0;
	export_uid(body_ob);
	if (!body_ob) {
		write("Could not create a " + body + " for you to log into.\n");
		return 0;
	}
	return (int) body_ob->restore_body();
}
Пример #7
0
int switch_body() {

   if((geteuid(previous_object()) != ROOT_UID && 
       previous_object() != body_ob) || !tmp_body)  return 0;
 
   if(interactive(tmp_body) || !interactive(body_ob) ||
      !exec(tmp_body, body_ob))  return 0;
 
   body_ob = tmp_body;
   export_uid(body_ob);
   tmp_body = 0;
 
   body_ob->set_link(this_object());
   body_ob->restore_body();

return 1; }
Пример #8
0
object restore_body(string name) {
    object body;

    if (find_player(name) && interactive(find_player(name))) {
	return find_player(name);
    }

    body = new(USER_OB);

    seteuid(name);
    export_uid(body);
    if (!body->restore_body()) return 0;

    seteuid(ROOT_UID);
    return body;
}
Пример #9
0
/** A more generic function than exec_call, this one actually lets you
 * execute any piece of code (more than just a simple function call).
 * It automatically wraps the snippet in a function.
 *
 * \param code The code to execute.
 */
string exec_code(string code) {
   string buf, err;
   mixed ret;
   string fname;

   if( !this_player() )
      raise_error("exec_code must have a valid this_player() using it");

   fname = this_player()->make_path_absolute( EXEC_OBJ );

   if( ret = find_object(fname) ) destruct(ret);
   if( file_exists(fname + ".c") &&  !rm( fname + ".c" ) )
      return "Unable to remove file "+fname+" to execute call.";
   buf = HEADER +
         EXEC_MACROS +"\ndo_exec() {\n";

   buf += code + "\n}\n";


   write_file( fname + ".c", buf );
   err = catch(ret = load_object( fname ));
   if( err ) {
      msg("==> [Exec Error] "+err);
      return "<Invalid>";
   }

   seteuid( getuid(this_player()) );
   export_uid( ret );
   seteuid( getuid(this_object()) );
   ret = 0;
   err = catch(ret = fname->do_exec());
   if( err ) {
      msg("==> [Call Runtime Error] "+err);
      return "<Invalid>";
   }

   return as_lpc(ret);
}
Пример #10
0
int main(object me, string arg)
{
	object ob;
	mapping my;
	int flag = 0;
 
	seteuid(getuid(me));
 
	if(!arg || arg == me->query("id"))
		ob = me;
	else
		{
			ob = present(arg, environment(me));
			if (!ob) ob = find_player(arg);
			if (!ob) ob = find_living(arg);
			if (!ob)
			{
				ob = new(USER_OB);
				seteuid(arg);
				export_uid(ob);
				flag = 1;
				if (!ob->restore())
					return notify_fail("没有这个玩家。\n");
			}
		}

	if (!ob->is_character())
		return notify_fail("那不是活物。\n");

	my = ob->query_entire_dbase();
    printf(HIC"≡"HIY"──────────────────────────────"HIC"≡\n"NOR);
    printf(HIC"【 精 气 】 %s%4d/ %4d %s(%3d%)" HIC "   【 精 力 】 %s%4d / %4d (+%d)\n" NOR,
		status_color(my["jing"], my["eff_jing"]), my["jing"], my["eff_jing"],
		status_color(my["eff_jing"], my["max_jing"]),	my["eff_jing"] * 100 / my["max_jing"],
		status_color(my["jingli"], my["max_jingli"]),	my["jingli"], my["max_jingli"],
		my["jiajing"] );
    printf(HIC"【 气 血 】 %s%4d/ %4d %s(%3d%)" HIC "   【 内 力 】 %s%4d / %4d (+%d)\n" NOR,
		status_color(my["qi"], my["eff_qi"]), my["qi"], my["eff_qi"],
		status_color(my["eff_qi"], my["max_qi"]), my["eff_qi"] * 100 / my["max_qi"],
		status_color(my["neili"], my["max_neili"]), my["neili"], my["max_neili"],
		my["jiali"] );

	if (ob->query("shen") >=0)
		printf(HIR"【 正 气 】%8d" HIC "              【 体 力 】 %s%4d / %4d \n"NOR,
		ob->query("shen"), 
		status_color(my["tili"], my["max_tili"]), my["tili"], my["max_tili"]);
	else
		printf(HIG"【 戾 气 】%8d" HIC "              【 体 力 】 %s%4d / %4d \n"NOR,
		ob->query("shen"), 
		status_color(my["tili"], my["max_tili"]), my["tili"], my["max_tili"]);

	printf(HIW"【 食 物 】 %s%4d/ %4d      " HIW "     【 潜 能 】  %s%d\n" NOR,
		status_color(my["food"], ob->max_food_capacity()),
		my["food"], ob->max_food_capacity(), HIY,
		(int)ob->query("potential") - (int)ob->query("learned_points"));
	printf(HIW"【 饮 水 】 %s%4d/ %4d      " HIW "     【 经 验 】  %s%d\n" NOR,
		status_color(my["water"], ob->max_water_capacity()),
		my["water"], ob->max_water_capacity(), HIM,
		my["combat_exp"] );
	printf(HIC"≡"HIY"──────────────────────────────"HIC"≡\n"NOR);
	
	if (flag) {
		printf("该玩家目前不在线。\n");
		destruct(ob);
	}
	return 1;
}
Пример #11
0
int main(object me, string arg)
{
        object ob;

        string sp, add;
        int bug, bugp , flag;

        seteuid(getuid(me));

        if (! arg || !wizardp(me))
                ob = me;
        else
        if (wizardp(me) )
        {
                // 添加 bug 点数
                if (sscanf(arg, "%s %d", arg, bug) == 2)
                {
                        if (bug == 0)
 	                        return notify_fail("你到底是想添加还是"
                                                   "减少?\n");
                        if (! objectp(ob = find_player(arg)))
                                ob = LOGIN_D->find_body(arg);
                        if (! objectp(ob))
                        {
                            ob = new(USER_OB);
                            seteuid(arg);
                            export_uid(ob);
                            flag = 1;
                            if (!ob->restore())
                            {
                            	destruct(ob);
                            	return notify_fail("没有这个玩家。\n");
                            }
                        }
                        ob->add("bug", bug);
                        ob->add("bug_count",bug);
                        ob->save();
                        sp = sprintf("用户 " WHT "%s" NOR " 的报告点数"
                                     "增加了 " WHT "%d" NOR " 点,现为"
                                     WHT " %d " NOR "点。\n", arg, bug,
                                     ob->query("bug", 1));

                        if (bug > 0)
                        tell_object(ob, HIG + me->name() + "增加了你的 " +
                                        bug + " 点报告点数。\n" NOR);
                        else 
                        tell_object(ob, HIG + me->name() + "减少了你的 " +
                                        -bug + " 点报告点数。\n" NOR);
                        

                        log_file("static/bug", sprintf("[%s] wizard %s a"
                                 "dd   %d bug point to user %s.\n",
                                 ctime(time()), getuid(me), bug, getuid(ob)));

                        //UPDATE_D->global_destruct_player(ob);

                        tell_object(me, sp);
                        if (flag == 1) destruct(ob);
                        return 1;
                }
                
                ob = present(arg, environment(me));
                if (! ob || ! ob->is_character()) ob = find_player(arg);
                if (! ob || ! ob->is_character()) ob = LOGIN_D->find_body(arg);
                if (! objectp(ob))
                {
                   ob = new(USER_OB);
                   seteuid(arg);
                   export_uid(ob);
                   flag = 1;
                   if (!ob->restore())
                   {
                    	destruct(ob);
                     	return notify_fail("没有这个玩家。\n");
                    }
                 }
                if (base_name(ob)!=USER_OB)
                {
                	if (flag == 1) destruct(ob);
                    return notify_fail("只有玩家才具有此参数。\n");
                }
                        
        }
 
        bug = ob->query("bug", 1);

        if (! bug)
                sp = ((ob == me ? "你" : ob->name()) + "在" +
                         MUD_NAME + NOR "中尚无报告过任何错误。\n");
        else
                sp = ((ob == me ? "你" : ob->name()) + "在" +
                         MUD_NAME + NOR "中的错误报告积累点数为"
                         HIC + bug +"/"+ob->query("bug_count")+ NOR "点。\n");

        tell_object(me, sp);
        if (flag == 1) destruct(ob);
        return 1;
}
Пример #12
0
/** A highly unusual function that lets you generate and execute a snippet of code
 * that will execute. Just pass in the snippet. Warning: This can't handle recursive
 * calls; the old call will be trashed by the new.
 *
 * \return The return value of the call, converted to a string.
 */
string exec_call(string code) {
   string buf;
   string obj, func, func_name, err;
   mixed param, ret;
   string fname;

   if( !this_player() )
      raise_error("exec_call must have a valid this_player() using it");

   fname = this_player()->make_path_absolute( EXEC_OBJ );

   if( ret = find_object(fname) ) destruct(ret);
   if( file_exists(fname + ".c") && !rm( fname + ".c" ) )
      return "Unable to clear out the old "+fname+" to execute the call (uid="+getuid(this_object())+").";

   buf = HEADER + EXEC_MACROS + "\ndo_call() {\n";

   if( sscanf(code, "%s->%s", obj, func) == 2 ) {
      func_name = func;
      if( sscanf(func, "%~s(%~s)") != 2 ) {
         code = func;
         if( sscanf( code, "%s %d", func, param) == 2)
            func = (func_name = func) + "( " + param + " );";
         else
         if( sscanf( code, "%s %s", func, param) == 2)
            func = (func_name = func) + "( \"" + param + "\" );";
         else
            func = (func_name = code) + "();";
      }
      else sscanf( func_name, "%s(%~s)", func_name );
   }
   else if( sscanf(code, "%s %s(%s)%~s", obj, func, param) == 4 && member(func, ' ') < 0 )
      func = (func_name = func) + "( " + param +" );";
   else if( sscanf(code, "%s %s %d", obj, func, param) == 3 )
      func = (func_name = func) + "( " + param + " );";
   else if( sscanf(code, "%s %s %s", obj, func, param) == 3 )
      func = (func_name = func) + "( \"" + param + "\" );";
   else if( sscanf(code, "%s %s", obj, func) == 2 )
      func = (func_name = func) + "();";
   else raise_error("Ill formatted exec_call");

   if( !find_thing(obj) ) return "No such object: "+obj;
   if( !function_exists(func_name, find_thing(obj)) && !function_exists("catch_call", find_thing(obj)) )
      return "No such function: "+obj+"->"+func_name+"()";

//   if( sscanf(func, "%s(%s)%s", ret, ret, ret) != 3 ) func += "();";

   if( func[<1] != ';' ) func += ";";
   buf += "   object ob;\n";
   buf += "   ob = find_thing(\""+obj+"\");\n";
   buf += "   if( !ob ) return \"Could not find object "+obj+"!\";\n";
   buf += "   return ob->"+func+"\n}\n";

   write_file( fname + ".c", buf );
   err = catch(ret = load_object( fname ));
   if( err ) {
      msg("==> [Call Error] "+err);
      return "<Invalid>";
   }

   seteuid( getuid(this_player()) );
   export_uid( ret );
   seteuid( getuid(this_object()) );
   err = catch(ret = fname->do_call());
   if( err ) {
      msg("==> [Call Runtime Error] "+err);
      return "<Invalid>";
   }

   return as_lpc(ret);
}