示例#1
0
void do_tests() {
    write_file("/sf.o", "#empty\n", 1);
    setup();
    restore_object("/sf");
    ASSERT(!var1);
    ASSERT(var2 == 2);
    ASSERT(!var3);
    ASSERT(!var4);

    setup();
    restore_object("/sf", 1);
    ASSERT(var1 == 1);
    ASSERT(var2 == 2);
    ASSERT(var3 == 3);
    ASSERT(var4 == 4);

    write_file("/sf.o", "var1 2\nvar2 4\nvar3 6\nvar4 8\n", 1);
    setup();
    restore_object("/sf", 1);
    ASSERT(var1 == 2);
    ASSERT(var2 == 2);
    ASSERT(var3 == 6);
    ASSERT(var4 == 8);

    write_file("/sf.o", "var4 1\nvar2 9\nvar1 3\nvar3 4\n", 1);
    setup();
    restore_object("/sf", 1);
    ASSERT(var1 == 3);
    ASSERT(var2 == 2);
    ASSERT(var3 == 4);
    ASSERT(var4 == 1);
}
示例#2
0
int restore() {

	int success ;

   if( !name || geteuid( previous_object() ) != ROOT_UID ) return 0;
// printf( "Debug: PO is %O\n", previous_object() );
// printf( "Debug: geteuid(PO) is %O\n",  geteuid( previous_object() ) );
// printf( "Debug: getuid(PO) is %O\n",  getuid( previous_object() ) );
//    printf("Debug: Euid is %s.\n", geteuid());
// seteuid(name);
// Removed by Blue.  It appears to have no effect. 940425.
//    printf("Debug: Euid is %s.\n", geteuid());
#if 0
	return restore_object(user_data_file(this_object()));
#else
// Log data files which don't load...don't exist? wrong permissions at
// Unix level?
        if (catch(success = restore_object(user_data_file(this_object())+__SAVE_EXTENSION__))) {
                log_file("restore_err",
                sprintf("[%s] Unable to restore_object(\"%s\")\n", name,
                      user_data_file(this_object())+__SAVE_EXTENSION__ ));
                      success = 0;
        }
        return success;
#endif
}
示例#3
0
void create()
{
    if(file_exists(ACCOUNT_DATA)) {
        restore_object(ACCOUNT_DATA);
    }
    save_object(ACCOUNT_DATA);
}
示例#4
0
文件: _convert.c 项目: ehershey/pd
int cmd_convert(string str) {
    int i, x;
    string *dir, name, tmp;
    mapping m;

    if(!str || str != "ok") return 0;
    if(!GUILD_D->valid_master(this_player()->query_name())) return 0;
    m=([]);
    write("Converting .o files to master.o\n");
    dir=get_dir("/d/guilds/save/");
    i=sizeof(dir);
    while(i--) {
	if(file_exists("/d/guilds/save/"+dir[i])) {
	    restore_object("/d/guilds/save/"+dir[i]);
	    name=lower_case(dir[i][0..sizeof(dir[i])-3]);
	    x=sizeof(member);
	    while(x--) {
		m[member[x]]=name;
	    }
	    x=sizeof(squire);
	    while(x--) {
		m[squire[x]]=name;
	    }
	    x=sizeof(council);
	    while(x--) {
		m[council[x]]=name;
	    }
	    x=sizeof(leader);
	    while(x--) {
		m[leader[x]]=name;
	    }
	}
    }
示例#5
0
void create() {
    seteuid(getuid());
  if (!restore_object(DB_NAME)) {
    domains=(["/d/":1]);
    exits=([]);
    targets=([]);
  }
示例#6
0
int restore()
{
        string file;
        if( stringp(file = this_object()->query_save_file()) && file_size(file + __SAVE_EXTENSION__) > 0 )
                return restore_object(file);
        return 0;
}
示例#7
0
void create() {
    ::create();
    restore_object(GSAVEPATH);
    set_name("Darksoul Ring");
    set_type("ring");
    set_short("darksoul ring");
    set_long("This is a ring of the Darksoul guild.");
    set_id(({ "guild ring", "ring", "darksoul ring"}));
示例#8
0
文件: save.c 项目: mudchina/nitan3
int restore()
{
	string file;

	if (stringp(file = this_object()->query_save_file()))
		return restore_object(file);
	return 0;
}
示例#9
0
void create() {
  seteuid(getuid(this_object()));
  if (!restore_object(NEWSPATH+"GroupList"))
    grouplist=m_allocate(0,G_MESSAGES);
  else
    grouplist=saveload;
  // ersten reset sobald wie moeglich. ;-)
  set_next_reset(1);
}
示例#10
0
void load_students() {
   string err;
 
   err = catch( restore_object(SAVE_FILE) );

   if(err)  log_file(ERROR_LOG, "[" + extract(ctime(time()),4,15) +
		     "]  Error in load_students()\n  " + err + "\n");

}
示例#11
0
void create() {
    int i;
    string *files;
    seteuid((string)"/secure/master"->creator_file(file_name(this_object())));
    if (!restore_object(SAVE_FILE)) {
        soul_data = ([ ]);
        files = get_dir(SOUL_DEF_DIR+"/");
        for (i = 0; i < sizeof(files); i ++) {
            compile(files[i]);
        }
    }
load_player() {
    loaded = 1;
    if (!restore_object(NAME + this_player()->query_real_name()) ||
      messages == "" || messages == 0) {
	arr_messages = 0;
	messages = "";
	return;
    }
    if (new_mail) {
	new_mail = 0;
	save_object(NAME + this_player()->query_real_name());
    }
    arr_messages = explode(messages, "\n**\n");
}
示例#13
0
void create() {
    ::create();
    set("short", "Primal Darkness referendum room");
    set_property("light", 2);
    set_property("indoors", 1);
    set("long",
      "This is the referendum room of Primal Darkness.  Players come here to vote "
      "on issues that the wizards desire input on.  The current voting "
      "question is posted on the wall <read question> will display it."); 
    set_exits( (["down" : "/d/nopk/tirun/pubstart"]) );
    vote=([]);
    seteuid(UID_VOTESAVE);
    restore_object(DIR_VOTES+"/question");
    seteuid(getuid());
}
示例#14
0
int cmd_board(string arg) {
   object ob;

	seteuid( getuid( environment( this_player() ) ) );

	write( "EUID: " + geteuid( this_object() ) + "\n" );
	if( !ob = present( "board", environment( this_player() ) ) ) {
		notify_fail( "No board here.\n" );
		return 0;
	}

	write( ob -> query_save_file() + "\n" );
  write( restore_object( (string) ob -> query_save_file() ) + "\n" );
	write( sizeof( messages ) + "\n" );
   return 1;
}
示例#15
0
create() {
   int x;
   string check_name;

   check_name = SAVE_NAME + ".o";

   x = exists(check_name);
 
 
   if(x == 1) {
      restore_object(SAVE_NAME);
   } else {
      change("blank");
   write("Type 'change <message>' to change your t-shirt!\n");
   }
}
示例#16
0
int test_password(string name, string pass) 
{
  string tmp;
  string account_name;

  account_name = find_player(name)->query_account_name();

  if (!stringp(name) || strlen(name) < 2 || sscanf(name, "%s %s", tmp, tmp)
    || name[0] == '.' || sscanf(name, "%s..%s", tmp,tmp))
    return 0;
  
  // now with accounts, neverbot 12/2010  
  // if (!restore_object("/save/players/"+name[0..0]+"/"+name,1))
  if (!restore_object("/save/accounts/"+account_name[0..0]+"/"+account_name))
    return 0;
    
  return crypt(pass, password) == password;
} /* test_password() */
示例#17
0
mapping check_for_mail( string mudname ) {
  init_queue();
  
  if( !file_exists( SAVE_FILE( mudname ) + SAVE_EXTENSION ) )
    return 0;
  
  if( !restore_object( SAVE_FILE( mudname ) ) ) {
    rm( SAVE_FILE( mudname ) + SAVE_EXTENSION );
    return 0;
  }
  
  if( !out_queue )
    init_queue();
  
  if( sizeof( out_queue ) )
    return out_queue[0];
  
  return 0;
}
示例#18
0
文件: netmail.c 项目: gongfuPanada/jy
mapping check_for_mail( string mudname ) {
  init_queue();
  
  if( !file_exists( SAVE_FILE( mudname ) + SAVE_EXTENSION ) )
    return 0;
  
  if( !restore_object( SAVE_FILE( mudname ) ) ) {
    log_file( "netmail", "Could not restore " + SAVE_FILE( mudname ) +
      SAVE_EXTENSION + "\n" );
    return 0;
  }
  
  if( !out_queue )
    init_queue();
  
  if( sizeof( out_queue ) )
    return out_queue[0];
  
  return 0;
}
示例#19
0
文件: merlin.c 项目: Kebap/mg-mudlib
void create()
{
  string s;
  seteuid(ROOTID);
  if (file_size("/etc/maxusers")<=0)
    maxusers=0;
  else
  {
    s=read_file("/etc/maxusers",0,1);
    sscanf(s,"%d",maxusers);
  }
  set_living_name("merlin");
  enable_commands();
  call_out("wandern",25);
  move("/gilden/abenteurer",0);
  MBanishListe = m_allocate(0,2);
  restore_object(SAVEFILE);
  EVENTD->RegisterEvent(EVT_LIB_PLAYER_CREATION, "player_change", ME);
  EVENTD->RegisterEvent(EVT_LIB_LOGIN, "player_change", ME);
  // absichtlich kein EVT_LIB_LOGOUT, s. Kommentar zu notify_player_leave().
}
示例#20
0
文件: netmail.c 项目: gongfuPanada/jy
int pop_mud( string mudname ) {
  init_queue();
  
  if( !file_exists( SAVE_FILE( mudname ) + SAVE_EXTENSION ) )
    return 0;
  
  if( !restore_object( SAVE_FILE( mudname ) ) ) {
    log_file( "mail_q", "Could not restore " + SAVE_FILE( mudname ) +
      SAVE_EXTENSION + "\n" );
    return 0;
  }
  
  if( !out_queue )
    init_queue();
  
  out_queue = exclude_array( out_queue, 0 );

  if( !sizeof( out_queue ) ) 
     rm( SAVE_FILE( mudname ) + SAVE_EXTENSION );
  else
     save_object( SAVE_FILE( mudname ) );
  return 1;
}
示例#21
0
int pop_mud( string mudname ) {
  init_queue();
  
  if( !file_exists( SAVE_FILE( mudname ) + SAVE_EXTENSION ) )
    return 0;
  
  if( !restore_object( SAVE_FILE( mudname ) ) ) {
    rm( SAVE_FILE( mudname ) + SAVE_EXTENSION );
    return 0;
  }
  
  if( !out_queue )
    init_queue();
  
TELL( sizeof(out_queue) );
  out_queue = out_queue[1..<1];
TELL(sizeof(out_queue ) );
  
  if( !sizeof( out_queue ) )
    rm( SAVE_FILE( mudname ) + SAVE_EXTENSION );
  else
    save_object( SAVE_FILE( mudname ) );
  return 1;
}
示例#22
0
static void restore() {
   seteuid(UID_DAEMONSAVE);
   restore_object(SAVE_FILE);
   seteuid(getuid());
}
示例#23
0
void create() {
  seteuid(getuid(this_object()));
  restore_object(GUILD_SAVEFILE);
  if (!pointerp(valid_guilds)) 
    valid_guilds=({});
示例#24
0
/*
    Functions.
*/
void load_quests() {
  restore_object(SAVE_FILE);
}
示例#25
0
create()
{
  seteuid(getuid());
  if (!restore_object(SAVEFILE))
    data=([]);
}
示例#26
0
int restore_me() {
  restore_object("/wiz/b/bart/save/notepad");
  return 1;
}
示例#27
0
/// Loads the file security data from disk.
void load_self() {
   write("Loading file_security object...\n");
   restore_object( FILE_SECURITY_DATA );
}
示例#28
0
int cmd_pay(string str)
{
    int year;
    int mo;
    string month;
    string guild;
    int error;
    
    if( !this_player()->query_guild() )
        return 0;
    
    if( this_player()->query_guild_position() != "leader" &&
        this_player()->query_guild_position() != "main" )
    {
        return 0;
    }
    
    if( !str || str != "dues" )
        return notify_fail("Pay what?\n");
    
    seteuid(UID_DAEMONSAVE);
    restore_object(SAVE_FILE);
    seteuid(getuid());
    
    year = EVENTS_D->query_year(time());
    mo = EVENTS_D->query_month(time()) - 1;
    month = MONTHS[mo];
    guild = (string)(environment(this_player())->query_guild());
    
    if( !sizeof(guild) )
        return notify_fail("You must be in your treasury to do that.\n");
    
    if( !payments )
        payments = ([]);
    
    if( !payments[guild] )
        payments[guild] = ([]);
    
    if( !payments[guild][year] )
        payments[guild][year] = ([]);
    
    if( !payments[guild][year][mo] )
    {
        error = TREASURY_D->withdraw(this_player()->query_name(), guild,
                DUES_AMOUNT, "gold");
        switch( error )
        {
            case INSF:
                return notify_fail("You need at least " + DUES_AMOUNT
                    + " gold in your treasury.\n");
                break;
            case NO_ACCOUNT:
                return notify_fail("Your guild doesn't have a treasury!\n");
                break;
            case BAD_ACCESS:
                return notify_fail("You don't have access to the guild's " +
                        "treasury!\n");
                break;
            case TRANSACTION_OK:
                payments[guild][year][mo] = DUES_AMOUNT;
                message("info", "You have paid your dues for " +
                        capitalize(month) + ".", this_player());
                seteuid(UID_DAEMONSAVE);
                save_object(SAVE_FILE);
                seteuid(getuid());
                TREASURY_D->update_summary(
                        this_player()->query_original_guild(),
                        "Guild dues", "gold", DUES_AMOUNT);
                environment(this_player())->do_scroll_write(
                        capitalize(this_player()->query_name()) + " (dues)",
                        WITHDRAW, DUES_AMOUNT, "gold");
                return 1;
                break;                
            default:
                /* Edit eventually to log the error */
                return notify_fail("An error occured; please contact an " +
                        "Admin.\n");
                break;
        }
    }
    else
    {
        return notify_fail("Your dues have already been paid for this month.\n");
    }
    
    // Should never get here, but just in case
    return 0;
}
示例#29
0
static void restore() { restore_object(SAVE_MULTI); }
示例#30
0
文件: point.c 项目: shentino/simud
void create() {
   if( file_exists("/daemon/point.o") )
      restore_object( "/daemon/point" );
   // Every hour...
   call_out( "point_decay", 3600 );
}