/* * deep_inventory() * * This function returns the recursive inventory of an object. The returned * array of objects is flat, ie there is no structure reflecting the * internal containment relations. * */ struct vector * deep_inventory(struct object *ob, int take_top) { struct vector *dinv, *ainv, *sinv, *tinv; int il; ainv = all_inventory(ob); if (take_top) { sinv = allocate_array(1); sinv->item[0].type = T_OBJECT; add_ref(ob,"deep_inventory"); sinv->item[0].u.ob = ob; dinv = add_array(sinv, ainv); free_vector(sinv); free_vector(ainv); ainv = dinv; } sinv = ainv; for (il = take_top ? 1 : 0 ; il < ainv->size ; il++) { if (ainv->item[il].u.ob->contains) { dinv = deep_inventory(ainv->item[il].u.ob,0); tinv = add_array(sinv, dinv); if (sinv != ainv) free_vector(sinv); sinv = tinv; free_vector(dinv); } } if (ainv != sinv) free_vector(ainv); return sinv; }
void do_post_about_str(string str) { object brd = 0; foreach (object ob in deep_inventory(environment(this_body()))) { if ((int)ob->is_bulletin_board()) brd = ob; } brd->do_post(str); }
void do_post_wrd_to_wrd(string wrd1, string wrd2) { object brd = 0; int id; foreach (object ob in deep_inventory(environment(this_body()))) { if ((int)ob->is_bulletin_board()) brd = ob; } sscanf(wrd2, "%d", id); brd->do_followup(id); }
int query_carrying(object who, mixed thing){ if(objectp(thing)) thing = base_name(thing); if(last(thing,2) == ".c") truncate(thing,2); if(!file_exists(thing+".c")) return 0; foreach(object ob in deep_inventory(who)){ if(base_name(ob) == thing) return 1; } return 0; }
void do_remove_wrd(string wrd) { object brd = 0; int id; foreach (object ob in deep_inventory(environment(this_body()))) { if ((int)ob->is_bulletin_board()) brd = ob; } sscanf(wrd, "%d", id); brd->do_remove(id); }
void dest_me() { object *obs; int i; obs = deep_inventory(this_object()); for (i = 0; i < sizeof(obs); i++) if (obs[i]) obs[i]->dest_me(); movement::dest_me(); }
void done(object me) { int i; object *inv; inv = deep_inventory(me); for(i=0; i<sizeof(inv); i++) { if (inv[i]->query("done")) destruct(inv[i]); } message_vision( HIC "只见$N驱真气于药材之上,不多会药材便消失了。\n" NOR,me); me->start_busy(1); return; }
int cmd_locate(string str) { object *inv; object ob; string obid; int num; int found = 0; if (!str) return notify_fail("Find what?\n"); inv = deep_inventory(this_player()); foreach (ob in inv) { if (member_array(str, ob->query_id()) != -1) { // We've found an object. Our next objective is to figure out where // it is located. // if ob's environment is bag if (environment(ob)->is_bag()) { // Get id of ob's environment obid = environment(ob)->query_id()[0]; // loop through each item of obid num = 1; while(present(obid+" "+num, this_player())) { if (present(obid+" "+num, this_player()) == environment(ob)) { write(ob->query_short()+" was found in "+environment(ob)->query_short()+" "+num+""); } num++; } found = 1; } else { write(ob->query_short()+" was found in your inventory."); found = 1; } } } if (!found){ return notify_fail("No "+str+" was found.\n"); } return 1; }
mixed can_post_about_str(string str) { object brd = 0; mixed res; foreach (object ob in deep_inventory(environment(this_body()))) { if ((int)ob->is_bulletin_board()) { if (!brd) brd = ob; else return "Please specify on which board you want to post.\n"; } } if (res = brd->indirect_post_on_obj_about_str(str, brd)) return res; return default_checks(); }
int dest_all(object act_ob, int silent) { int s; object *ob; ob = deep_inventory(act_ob); s = sizeof(ob); cnt += s; while (s--) { if (!ob[s]) continue; if (!silent) write("Desting: " + identify(ob[s]) + "\n"); if (!(ob[s]->is_player() && interactive(ob[s]))) { if (adminp(geteuid(previous_object()))) { catch(ob[s]->remove()); if(ob[s]) destruct(ob[s]); } else write("Not allowed to remove players, Bad !\n"); } }
int dest_all(object act_ob, int silent) { int s; object *ob; ob = deep_inventory(act_ob); s = sizeof(ob); cnt += s; while (s--) { if (!ob[s]) continue; if (!silent) write("Desting: " + identify(ob[s]) + "\n"); if (!(ob[s]->is_player() && interactive(ob[s]))) { catch(ob[s]->remove()); if(ob[s]) destruct(ob[s]); } } return 1 ; }
mixed can_remove_wrd(string wrd) { object brd = 0; mixed res; foreach (object ob in deep_inventory(environment(this_body()))) { if ((int)ob->is_bulletin_board()) { if (!brd) brd = ob; else return "Please specify on which board you want to " "remove a note.\n"; } } if (!brd) return "There's nothing here to remove notes from.\n"; if ((res = brd->direct_remove_wrd_from_obj(wrd, brd)) != 1) return res; return default_checks(); }
/* Followups are posted using 'post followup to <id>' */ mixed can_post_wrd_to_wrd(string wrd1, string wrd2) { object brd = 0; mixed res; if (wrd1 != "followup") return 0; foreach (object ob in deep_inventory(environment(this_body()))) { if ((int)ob->is_bulletin_board()) if (!brd) brd = ob; else return "Please specify the board you want to post on.\n"; } if (!brd) return "There is nothing here to post on.\n"; if ((res = brd->direct_post_wrd_to_wrd_on_obj(wrd1, wrd2, brd)) != 1) return res; return default_checks(); }
int cmd_sc( string a ) { mixed ob; object obj; int i; seteuid( geteuid( previous_object() ) ); if( !a ) a = "here"; ob = ref_ob( a ); if( !objectp( ob ) ) { notify_fail( wrap( "Could not identify " + identify( ob ) + " as an object." ) ); return 0; } write( wrap( "Deep Scanning: " + identify( ob ) + " EUID(" + geteuid( ob ) + ") UID(" + getuid( ob ) + ")" ) ); sc_object( ob, " " ); set_ref( "default", ob ); set_ref( "sc", deep_inventory( ob ) ); return 1; }
int CanReceive(object ob){ int ret, level; level = ob->GetLevel(); if((creatorp(ob) && !archp(ob)) || (userp(ob) && level > 20)){ write("Sorry. This area is for normal players."); return 0; } ret = room::CanReceive(ob); if(ret){ object *inv = deep_inventory(ob); foreach(object element in inv){ string name = base_name(element); level = element->GetLevel(); if(creatorp(element) && !archp(element) || (userp(element) && level > 20)){ write("Sorry. This is a player-only area."); return 0; } if(!strsrch(name,"/realms/") || !strsrch(name,"/open/")){ element->eventMove(ROOM_FURNACE); } } }
mixed cmd(string args) { object array obs, items, users; object ob; if( !args || args == "" ) { ob = environment(previous_object()); } else { ob = get_object(args); } if( !ob ) { return "No " + args + " found."; } previous_object()->eventPrint(sprintf("Cleaning %O", ob), MSG_SYSTEM); say(this_player()->GetName()+" cleans "+ob->GetShort()+"."); obs = deep_inventory(ob); users = filter(obs, (: userp :)); items = obs - users; foreach(object user in users) { object tmp = user; while( tmp = environment(tmp) ) { items -= ({ tmp }); }
int really_quit() { object *ob, money; object frog, frog2; int i; int secure; string aux; aux = ""; secure = 0; // quit_destination added by neverbot, 03/09 while (environment(this_object()) && (aux = environment(this_object())->query_quit_destination()) && (secure < 10)) { if (load_object(aux)) this_object()->move(aux); secure++; } if (secure != 0) { tell_object(this_object(), "En tu localización previa no es posible salir, "+ "has sido movido a la más cercana (vuelve a intentarlo aquí si aún "+ "deseas desconectar).\n"); this_object()->do_look(); this_object()->save_me(); return 1; } traverse_timed_properties(); last_log_on = time(); this_object()->adjust_online_time(time() - ontime); // This should send the time the player was on to an object which keeps // track of total hours played (non-immortal) Anirudh - March 17, 1996 // if (!this_object()->query_coder()) TIMEKEEPER->add_time(time() - ontime); if (this_object()->query_name() != DEF_NAME) { if (this_object()->query_property(GUEST_PROP)) log_file("enter", sprintf("Exit : %-15s %s (guest) [%s]\n", name, ctime(time(),4), query_ip_number(this_object())+" ("+query_ip_name(this_object())+")")); else log_file("enter", sprintf("Exit : %-15s %s [%s]\n", name, ctime(time(),4), query_ip_number(this_object())+" ("+query_ip_name(this_object())+")")); } // TODO editor // catch(editor_check_do_quit()); // TODO social // if (query_race_ob()) // catch(query_race_ob()->player_quit(this_object())); // if (query_guild_ob()) // catch(query_guild_ob()->player_quit(this_object())); // if (query_class_ob()) // catch(query_class_ob()->player_quit(this_object())); // if (query_deity_ob()) // catch(query_deity_ob()->player_quit(this_object())); // if (query_group_ob()) // catch(query_group_ob()->player_quit(this_object())); // if (query_race_group_ob()) // catch(query_race_group_ob()->player_quit(this_object())); // if (query_job_ob()) // catch(query_job_ob()->player_quit(this_object())); // if (query_city_ob()) // catch(query_city_ob()->player_quit(this_object())); // curses_quit(); // Antes del save_me, movemos todos los objetos que no vamos a grabar a // la room del jugador if (environment(this_object())) { ob = deep_inventory(this_object()); for(i = 0; i < sizeof(ob); i++) { if (ob[i]->query_no_save_object()) { ob[i]->move(environment(this_object())); tell_object(this_object(), "Dejas tu "+ob[i]->short()+".\n"); } } }