void main(string str) { int pos, sz, total, verbose; mapping edges; string * users; edges = COMPILER_D->query_upqueue(); if(str && str == "-v") verbose = 1; rlimits( 250; -1 ) { if(edges) { if(edges["kernel"]) { write("User: kernel"); total += upgrade_uobj( edges["kernel"], verbose ); edges["kernel"] = nil; } users = map_indices( edges ); for( pos = 0, sz = sizeof( users ); pos < sz; pos++ ) { write("User: "******"A total of "+total+" objects was upgraded." ); }
nomask mixed * get_list(varargs string list) { if(KERNEL()) { if(ltable) { if(list) return ltable[list]; else return map_indices(ltable); } } }
void wander(void) { mixed *exits; int i; /* * It is quite normal that the 'master/blueprint' doesn't have an * environment. However, this should never happen with a clone. * Hence, error if this is a clone, ignore otherwise. */ if (!this_object()->query_environment()) { if (clone_num() != 0) { error("Wandering clone without environment"); } else { return; } } if (wander_count++ < MAX_WANDER) { /* Go ahead and set up the next call_out */ next_move = time() + random(movement_maxtime - movement_mintime) + movement_mintime; } else { stop_wander(); return; } /* Get a list of exits */ exits = map_indices(this_object()->query_environment()->query_exits()); /* try 3 times to find an exit that falls within our wander area. */ for (i = 0; i < 3; i++) { string exit; object exarea; exit = random_element(exits); exarea = this_object()->query_environment()->query_exit_room(exit); if (exarea && exit) { if (!wander_area || exarea->query_in_area(wander_area)) { this_object()->query_environment()->unsubscribe_event("body_enter"); this_object()->query_environment()->body_exit(this_object(), exit); this_object()->query_environment()->subscribe_event("body_enter"); return; /* success */ } } else if (!exit) { /* No exits - no need to keep wandering. */ stop_wander(); return; } } }
void do_sell(object player, string what) { string *objs; object obj; int i, found, value; objs = map_indices(stored_items); found = 0; for (i = 0; i < sizeof(objs); i++) { obj = clone_object(objs[i]); if (obj) { obj->move(this_object()); obj->setup(); /* Found the object */ if (obj->query_id() == what && found != 1) { value = obj->query_value(); if (stored_items[objs[i]] < 1) { /* Skip here, out of stock... */ } else { if (value <= player->query_total_money() ) { this_object()->other_action(this_object(), "$N $vgive $t $o", player, obj); value = -1 * value; player->add_money("ducat", value); obj->move(player); stored_items[objs[i]] = stored_items[objs[i]] - 1; found = 1; return; } else { write("You do not have enough money for that.\n"); obj->query_environment()->remove_object(obj); obj->destruct(); return; } } } else { obj->query_environment()->remove_object(obj); obj->destruct(); } } } if (found == 0) { player->message("That item is out of stock."); } }
void event( string name, varargs mixed args... ) { object *obs; int i; argcheck( name, 1, "string" ); if(!events[name]) return; obs = map_indices(events[name]); for( i = 0; i < sizeof( obs ); i++ ) { if( obs[i] ) call_other( obs[i], "event_" + name, args ); } }
int member_map( mixed item, mapping map ) { mixed *arr; argcheck( map, 2, "mapping" ); arr = map_indices( map ); if( member_array( item, arr ) > -1 ) return( 1 ); arr = map_values( map ); if( member_array( item, arr ) > -1 ) return( 1 ); return( 0 ); }
mixed cmd_score(string cmd, string str, object actor){ mapping stats; int i; string *attributes; stats = actor->query_stats(); attributes = map_indices(stats); i = sizeof(attributes); str = actor->query_Name() + "\n"; while(i--){ str += "%^BOLD%^%^CYAN%^"+pad(capitalize(attributes[i])+": ", 15)+"%^RESET%^"+stats[attributes[i]]+"\n"; } #ifdef ASTARIA_CLONE str += "hp "+actor->query_health()+" / "+actor->query_max_health()+"\n"; #else str += actor->query_diagram(); #endif actor->message(str); return 1; }
static string dump_value(mixed value, varargs mapping seen) { string str; int i, sz; mixed *indices, *values; if(!seen) seen = ([ ]); switch (typeof(value)) { case T_INT: case T_FLOAT: return (string) value; case T_STRING: str = value; if (sscanf(str, "%*s\\") != 0) { str = implode(explode("\\" + str + "\\", "\\"), "\\\\"); } if (sscanf(str, "%*s\"") != 0) { str = implode(explode("\"" + str + "\"", "\""), "\\\""); } if (sscanf(str, "%*s\n") != 0) { str = implode(explode("\n" + str + "\n", "\n"), "\\n"); } if (sscanf(str, "%*s\t") != 0) { str = implode(explode("\t" + str + "\t", "\t"), "\\t"); } return "\"" + str + "\""; case T_OBJECT: return "<" + object_name(value) + ">"; case T_ARRAY: if (seen[value]) { return "#" + (seen[value] - 1); } seen[value] = map_sizeof(seen) + 1; sz = sizeof(value); if (sz == 0) { return "({ })"; } str = "({ "; for (i = 0, --sz; i < sz; i++) { str += dump_value(value[i], seen) + ", "; } return str + dump_value(value[i], seen) + " })"; case T_MAPPING: if (seen[value]) { return "@" + (seen[value] - 1); } seen[value] = map_sizeof(seen) + 1; sz = map_sizeof(value); if (sz == 0) { return "([ ])"; } str = "([ "; indices = map_indices(value); values = map_values(value); for (i = 0, --sz; i < sz; i++) { str += dump_value(indices[i], seen) + ":" + dump_value(values[i], seen) + ", "; } return str + dump_value(indices[i], seen) + ":" + dump_value(values[i], seen) + " ])"; case T_NIL: return "<NIL>"; } }
static void save_me(void) { unguarded("save_object", "/sys/daemons/data/log_d.o"); } static void restore_me(void) { unguarded("restore_object", "/sys/daemons/data/log_d.o"); } string *show_log_levels(void) { string *logs, *keys; int x, max; logs = ({ "Log Levels:" }); logs += ({ "\tdefault: " + levels["default"] }); keys = map_indices(levels); max = sizeof(keys); for (x = 0; x < max; x++) { if (keys[x] != "default") { logs += ({ "\t" + keys[x] + ": " + levels[keys[x]] }); } } return logs; } static void create(void) { levels = ([ ]); levels["default"] = 1; restore_me();