ES2 MUD LIB :: 東方故事二(ES2) 天朝帝國 mudlib 瀏覽展示
/feature/user/autoload.c
// autoload.c
string *autoload;
void clean_up_autoload() { autoload = 0; }
void save_autoload()
{
object *inv;
int i, j;
mixed param;
inv = all_inventory();
autoload = allocate(sizeof(inv));
for(i=0, j=0; i
if( !(param = inv[i]->query_autoload()) ) continue;
autoload[j] = base_name(inv[i]);
if( stringp(param) ) autoload[j] += ":" + param;
j++;
}
autoload = autoload[0..j-1];
}
void restore_autoload()
{
int i;
object ob;
string file, param, err;
if( !pointerp(autoload) ) return;
for(i=0; i
if( sscanf(autoload[i], "%s:%s", file, param)!=2 ) {
file = autoload[i];
param = 0;
}
err = catch(ob = new(file, this_object()));
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.
}