textdump
./CDC-1.0/textdump · 449.9 KB
From the archive CDC-1.0.tar.gz
Download the archive « Back to the archive contents
name integer 45
name file 8788
name parse 44
name buffer 1408
name gender_first_person_plural 2034
name false_lock_class 5
name http_interface 7969
name gender_plural 2036
name finger_daemon 7810
name event_handler 1139
name wrap_filter 1094
name note_editor 747
name logic_class 2485
name heap_class 1165
name connection 7792
name utilities 12
name http_file 8789
name messaged 1178
name user_db 3779
name filters 1093
name no_one 936
name daemon 7794
name place 2679
name exit 26
name body 28
name sys 0
name or 2489
name conference_parser 1432
name base_evaluator 9615
name and_lock_class 7
name or_lock_class 8
name login_watcher 888
name network_root 7791
name has_commands 16
name user_data 4309
name place_db 3778
name mail_db 3777
name world 2742
name false 2487
name user 30
name news 592
name log 2250
name programmer_interface 7459
name slate_connection 9508
name input_parser 2001
name has_settings 9398
name bad_commands 1140
name gender_male 1183
name environment 2786
name code_editor 758
name public 7261
name gender 40
name admin 33
name set 740
name not 2491
name realm_of_creation 2717
name notice_interface 9440
name not_lock_class 9
name generic_editor 1162
name command_parser 2000
name gender_neuter 1182
name verb_parser 2321
name programmer 32
name location 19
name arg_opts 310
name parsers 1431
name network 9153
name builder 31
name web_ui 9291
name login 4348
name guest 134
name note 7248
name http 8019
name dict 46
name code 51
name xor 2490
name db 790
name string 43
name data 7245
name small_first_heap_class 1166
name utility_objects 1170
name command_aliases 922
name contains_lock 2494
name lock_parser 10
name inside_lock 2495
name housekeeper 246
name event_class 1138
name verb_cache 35
name lock_class 3
name foundation 1377
name body_cave 247
name physical 1387
name http_log 8598
name gendered 1179
name editors 1388
name reaper 7232
name object 2451
name robot 5203
name named 2787
name true 2486
name text 1032
name root 1
name motd 4348
name and 2488
name gender_first_person 2032
name true_lock_class 4
name http_root_file 9292
name disk_readable 185
name login_daemon 7799
name display_opts 720
name settings_ui 9399
name interaction 86
name frob_class 2
name has_verbs 15
name dark_time 334
name nothing 984
name places 7523
name thing 24
name list 13
name time 333
name command_aliases_parser 2294
name connection_interface 7801
name located_location 25
name login_interface 7800
name wearable_class 1142
name old_connection 27
name movement_event 5205
name gender_female 1184
name http_daemon 7968
name antisocial 6099
name described 17
name registry 3775
name located 23
name english 48
name finger_interface 7811
name realms_class 1204
name object_lock 6
name null_parser 2622
name epic_filter 1095
name reaper_log 7292
name interfaces 664
name time_root 49
name scheduler 282
name eng_time 333
name creation 140
name channels 465
name nowhere 21
name slate 9552
name notes 522
name input 2337
name heart 5264
name void 22
name misc 675
name user_testperson 9688
object #1
var 1 manager #1
var 1 owners [#47]
var 1 writable [#1]
var 1 readable ['parameters, 'methods, 'code]
var 1 trusted []
var 1 owned []
var 1 child_index 3
var 1 fertile 0
var 1 inited 0
var 1 info ["The root object is the ultimate parent of all objects. It defines beahvior of all objects. It controls initialization, deinitialization, creation, destruction, and identification of objects, as well as permission checking, and ownership."]
var 1 quota 0
var 1 dbref 'root
method init_root
(> .perms(caller(), $root) <);
child_index = 0;
fertile = 0;
// for now set all the ownership stuff as this(), it can be reset later.
manager = this();
owned = [this()];
owners = [this()];
writable = [];
readable = ['parameters, 'methods, 'code];
.
method uninit_root
var obj, x, objs;
(> .perms(caller(), $root) <);
objs = [];
catch any {
for obj in (owned) {
if (obj == this())
continue;
catch any {
if ((obj.manager()) == this()) {
for x in (obj.owners()) {
if (valid(x) && (x != this()))
objs = [@objs, x];
}
obj.chown([$reaper, @objs]);
obj.set_manager($reaper);
}
} with handler {
// this is getting redundant, but there is a reason for it.
(| obj.chown([$reaper]) |);
(| obj.del_owner(this()) |);
$reaper_log.log(("$root.uninit_root(): Unable to give " + (obj.dbref())) + " an owner.");
}
}
for obj in (owners)
(| obj.del_owned_obj(this()) |);
} with handler {
$brandon.tell("Traceback from $root.uninit_root()");
$brandon.tell_traceback(traceback());
}
.
method initialize
disallow_overrides;
var ancestors, ancestor, method_name, pos;
if ((caller() != $sys) && (sender() != this()))
throw(~perm, "Caller is not $sys and sender is not this.");
if (inited)
throw(~perm, "Already initialized.");
ancestors = ancestors();
for pos in [0 .. listlen(ancestors) - 1] {
ancestor = ancestors[listlen(ancestors) - pos];
method_name = tosym("init_" + tostr(ancestor.dbref('symbol)));
catch ~methodnf {
if (find_method(method_name) != ancestor)
throw(~perm, ((("Initialization method for " + (ancestor.namef('ref))) + " in wrong place. Found on ") + (find_method(method_name).namef('ref))) + ".");
.(method_name)();
}
}
inited = 1;
.
method uninitialize
disallow_overrides;
var ancestor, owner, obj;
.perms(caller(), $root, $sys);
for ancestor in (ancestors())
(| .(tosym("uninit_" + tostr(ancestor.dbref('symbol))))() |);
.
method perms
disallow_overrides;
arg what, [args];
var obj, flag, second;
if (type(what) == 'dbref)
what = [what];
if (!args)
args = ['writer];
if (type(args[1]) == 'symbol) {
for flag in (args) {
switch (flag) {
case 'this:
for obj in (what) {
if ((obj != this()) && (!($sys.is_system(obj))))
throw(~perm, ("Permission Denied: " + (obj.dbref())) + " is not this.", obj);
}
case 'system:
for obj in (what) {
if (!($sys.is_system(obj)))
throw(~perm, ("Permission Denied: " + (obj.dbref())) + " is not of the system.", obj);
}
case 'manager:
for obj in (what) {
if (((.manager()) != obj) && (!($sys.is_system(obj))))
throw(~perm, ("Permission Denied: " + (obj.dbref())) + " is not the manager.", obj);
}
case 'trusts:
for obj in (what) {
if (!(.trusts(obj)))
throw(~perm, ("Permission Denied: " + (obj.dbref())) + " is not a trustee.", obj);
}
case 'parser:
// This should be removed sometime.
for obj in (what) {
if ((!(obj.has_ancestor($parsers))) && (obj != this()))
throw(~perm, ("Permission Denied: " + (obj.dbref())) + " is not a parser.", obj);
}
default:
for obj in (what) {
if (!(.is_writable_by(obj)))
throw(~perm, ("Permission Denied: " + (obj.dbref())) + " is not a writer.", obj);
}
}
}
} else {
for obj in (what) {
if (!(obj in args))
throw(~perm, ((obj.dbref()) + " is not one of: ") + ($list.to_english($list.map(args, 'namef, 'ref))), obj);
}
}
.
method _change_parents
disallow_overrides;
arg parents;
var old, init, uninit, ancestor, pos;
(> .perms(caller(), $root) <);
if (!parents)
throw(~noparents, "Objects must have at least 1 parent");
// Perform the actual change.
old = ancestors();
(> $sys.change_sender_parents(parents) <);
// Figure out new ancestors to initialize, and old ones to uninitialize.
init = [];
uninit = old;
for ancestor in (ancestors()) {
uninit = setremove(uninit, ancestor);
if (!(ancestor in old))
init = [@init, ancestor];
}
// Initialize the new ancestors.
catch any {
for ancestor in (init) {
catch ~methodnf {
.(tosym("init_" + tostr(ancestor.dbref('symbol))))();
}
}
} with handler {
// Initialization error; deinitialize parents we initialized, and fall
// back to old parents.
pos = ancestor in init;
for ancestor in (sublist(init, 1, pos))
(| .(tosym("uninit_" + tostr(ancestor.dbref('symbol))))() |);
$sys.change_sender_parents(old);
throw(~init, "Failed to initialize new ancestors.");
}
// Uninitialize the old ancestors.
$sys.change_sender_parents(setremove(old, this()));
for ancestor in (uninit)
(| .(tosym("uninit_" + tostr(ancestor.dbref('symbol))))() |);
$sys.change_sender_parents(parents);
.
method chparents
arg parents;
var parent;
if (!(| .perms(sender(), 'manager) |))
(> .perms(caller(), $root, $sys) <);
if (!parents)
throw(~noparents, "There must be at least 1 parent for each object.");
// Notify parents of impending change.
for parent in (parents)
(> parent.will_inherit(sender()) <);
// Everything's okay, go ahead and try it.
._change_parents(parents);
.
method will_inherit
arg obj;
// Throw an error if it's not okay for obj to inherit from us.
if ((!fertile) && ((!(.trusts(obj))) && (!(obj.has_ancestor(this())))))
throw(~perm, "Refuse to be parent of prospective child.");
.
method manager
disallow_overrides;
return manager;
.
method owners
disallow_overrides;
return owners;
.
method writers
disallow_overrides;
return writable + [manager, this()];
.
method trusted
return (trusted ? trusted | []) + [this()];
.
method is_writable_by
disallow_overrides;
arg obj;
return (| obj in (.writers()) |) || ($sys.is_system(obj));
.
method is_readable_by
disallow_overrides;
arg obj;
// will eventually get this working with lock frobs, for now
// ,readable is a simple list of what everyone can read:
// 'methods, 'parameters, 'code
if (.trusts(obj))
return ['methods, 'parameters, 'code];
else
return readable;
.
method trusts
arg obj;
return (| obj in (.trusted()) |) || ((.is_writable_by(obj)) || ($sys.is_system(obj)));
.
method fertile
disallow_overrides;
return fertile;
.
method set_fertile
arg val;
(> .perms(sender(), 'manager) <);
fertile = val ? 1 | 0;
.
method set_manager
disallow_overrides;
arg obj;
(> .perms(sender(), 'manager) <);
if (type(obj) != 'dbref)
throw(~type, "Managers must be given as a single dbref.");
manager = obj;
.
method set_writable
disallow_overrides;
arg what;
.perms(sender(), 'manager);
writable = what;
.
method add_writer
disallow_overrides;
arg what;
(> .perms(sender(), 'manager) <);
writable = [@writable, what];
.
method del_writer
disallow_overrides;
arg what;
(> .perms(sender(), 'manager) <);
writable = setremove(writable, what);
.
method set_readable
disallow_overrides;
arg what;
(> .perms(sender(), 'manager) <);
readable = what;
.
method set_trusted
disallow_overrides;
arg what;
(> .perms(sender(), 'manager) <);
trusted = what;
.
method add_trusted
disallow_overrides;
arg what;
(> .perms(sender(), 'manager) <);
trusted = [@trusted, what];
.
method del_trusted
disallow_overrides;
arg what;
(> .perms(sender(), 'manager) <);
trusted = setremove(trusted, what);
.
method as_this_run
arg obj, method, [args];
// run with this()'s perms -- unless they have changed .trusts,
// it should just check against writers.
if (!(.trusts(sender())))
throw(~perm, "Sender not allowed to gain access to object perms.");
return (> obj.(method)(@args) <);
.
method add_parent
arg parent;
(> .perms(sender(), 'manager) <);
if (parent in (.parents()))
throw(~parent, (((.dbref()) + " already has ") + (parent.namef('ref))) + " as a parent");
if (!valid(parent))
throw(~type, "Not a valid parent, must send a dbref or pointer");
.chparents((.parents()) + [parent]);
.
method del_parent
arg parent;
var parents;
(> .perms(sender(), 'manager) <);
if (!valid(parent))
throw(~type, "Not a valid parent, must send a dbref or pointer");
parents = .parents();
if (!(parent in parents))
throw(~parentnf, "No such parent as " + ($data.unparse(parent)));
parents = setremove(parents, parent);
(> .chparents(parents) <);
.
method spawn
arg [suffix];
var obj, tmp, dbref, owner, mngr, na;
// will later adjust this for .is_readable_by()
// use this rather than $string.non_alphanumeric because it doesn't
// have '_'
na = "!@#$%^&*()+-=~`'{}[]|/?\"\\,.<>;: ";
if ((!fertile) && (((.is_readable_by(sender())) != ['methods, 'parameters, 'code]) && (!($sys.is_system(sender())))))
throw(~perm, "Not fertile or readable.");
owner = sender();
// Figure out the suffix from the arguments and child index.
if (!(owner.quota_valid()))
throw(~quota, "Sender does not have the available quota");
if (suffix) {
suffix = suffix[1];
// so they dont confuse child_index:
if ($string.is_numeric(suffix))
throw(~perm, "Can't specify a numeric suffix.");
// so we get correct symbols & it is always lowercase:
suffix = $string.strip(suffix, na);
} else {
// make sure it doesn't exist already:
dbref = tostr(.dbref('symbol));
tmp = .dbref('symbol);
while ((| get_name(tmp) |)) {
child_index = child_index + 1;
tmp = tosym((dbref + "_") + tostr(child_index));
}
suffix = tostr(child_index);
}
// Ask the system object for a child.
obj = $sys.spawn_sender(suffix, owner);
return obj;
.
method destroy
disallow_overrides;
// This doesn't actually destroy us immediately, but we will go away when
// nothing is holding onto us any more.
(> .perms(sender(), 'manager) <);
(| .uninitialize() |);
$sys.destroy_sender();
.
method add_parameter
arg name, [args];
var tmp, kid;
// .add_parameter('name[, default-value, 'inherit])
// Add the given parameter to this object.
// if 'default-value' is included, initialize the variable to that value
// if 'inherit is given the value is initialized on all descendents
(> .perms(sender()) <);
(> add_parameter(name) <);
// The following code is a kludge as we can't send a default value to the
// primitive.
if (args) {
tmp = tosym((("__set_" + tostr(name)) + "_") + tostr(random(1000)));
catch any {
compile([((tostr(name) + " = ") + toliteral(args[1])) + ";"], tmp);
.(tmp)();
if ((listlen(args) > 1) && ((args[2]) == 'inherit)) {
for kid in (.descendants())
kid.(tmp)();
}
del_method(tmp);
} with handler {
del_method(tmp);
rethrow(error());
}
}
.
method parameters
(> .perms(sender(), 'this) <);
return parameters();
.
method del_parameter
arg name;
(> .perms(sender()) <);
(> del_parameter(name) <);
.
method del_method
arg name;
(> .perms(sender()) <);
(> del_method(name) <);
.
method methods
disallow_overrides;
if (!('methods in (.is_readable_by(sender()))))
throw(~perm, ((sender().dbref()) + " doesn't have permission to find methods on ") + (.dbref()));
return methods();
.
method parents
disallow_overrides;
return parents();
.
method children
disallow_overrides;
return children();
.
method ancestors
disallow_overrides;
return ancestors();
.
method find_method
disallow_overrides;
arg name;
if (!('methods in (.is_readable_by(sender()))))
throw(~perm, ((sender().dbref()) + " doesn't have permission to find methods on ") + (.dbref()));
return (> find_method(name) <);
.
method find_next_method
disallow_overrides;
arg name, after;
if (!('methods in (.is_readable_by(sender()))))
throw(~perm, ((sender().dbref()) + " doesn't have permission to find methods on ") + (.dbref()));
return (> find_next_method(name, after) <);
.
method list_method
arg [args];
if (!('code in (.is_readable_by(sender()))))
throw(~perm, (("Method code on " + (.namef('ref))) + " is not readable by ") + (sender().namef('ref)));
return (> list_method(@args) <);
.
method compile
arg code, name;
// allow overrides -- may be a problem...
(> .perms(sender()) <);
return compile(code, name);
.
method show
disallow_overrides;
var output, actor, data, parent, readable, m, p, x, line;
actor = sender();
readable = .is_readable_by(actor);
data = $sys.sender_data();
// the beginning.
output = ((("Object: " + (.namef('ref))) + " [") + tostr(.size())) + " bytes]";
output = [output, "Parents: " + ($data.unparse(parents()))];
// Methods
if ('methods in readable) {
output = output + ["Methods:"];
for m in (.method_info())
output = output + [(((" " + tostr(m[2])) + "(") + (m[3])) + ")"];
} else {
output = output + [" ** No permission to list Methods **"];
}
// Parameters
if ('parameters in readable) {
for parent in (data) {
// because the server is FKD we have to make sure your params
// all have valid parents:
if (valid(parent[1])) {
output = output + [((parent[1]).namef('xref)) + " Parameters:"];
if ('parameters in ((parent[1]).is_readable_by(actor))) {
for p in (parent[2]) {
line = ((" " + tostr(p[1])) + ": ") + ($data.unparse(p[2]));
output = output + [line];
}
} else {
output = output + [" ** Permission Denied **"];
}
} else {
output = output + ["(Invalid parent-object You cannot reference because it's broke) Parameters:"];
for p in (parent[2]) {
line = ((" " + tostr(p[1])) + ": ") + ($data.unparse(p[2]));
output = output + [line];
}
}
}
} else {
output = output + [" ** No permission to list Parameters **"];
}
// Return what we've got.
return output;
.
method has_ancestor
disallow_overrides;
arg obj;
return has_ancestor(obj);
.
method eval
disallow_overrides;
arg code, [dest];
var errors, result;
dest = dest ? dest[1] | this();
(> .perms(sender()) <);
// Compile the code.
errors = .compile(code, 'tmp_eval);
if (errors)
return ['errors, errors, 0, 0];
// Evaluate the expression. Be sure to remove it afterwards, so that no
// one else can call it.
catch any {
result = dest.tmp_eval();
} with handler {
del_method('tmp_eval);
rethrow(~methoderr);
}
del_method('tmp_eval);
return ['result, result];
.
method method_info
arg [args];
var filter, maxp, anc, ancs, method, methods_found;
// lists methods on objects which are ancestors of this and parents of args[1]
// method info items are of the form:
// [$definer, 'method, "args", "flags", "first comment/return value"]
if (!('methods in (.is_readable_by(sender()))))
throw(~perm, (("Method code on " + (.namef('ref))) + " is not readable by ") + (sender().namef('ref)));
if (args) {
maxp = args[1];
args = delete(args, 1);
}
if (listlen(args) >= 2) {
filter = sublist(args, 1, 2);
args = delete(delete(args, 1), 1);
} else {
filter = [$misc, '_null_method_filter];
}
methods_found = [];
ancs = .ancestors();
if (!(maxp in ancs)) {
maxp = this();
ancs = [this()];
}
for anc in (ancs) {
if (anc.has_ancestor(maxp)) {
for method in (anc.methods()) {
if ((filter[1]).(filter[2])(anc, method, @args))
methods_found = [@methods_found, ._get_method_info(anc, method)];
}
}
}
return methods_found;
.
method parameter_info
arg [args];
var data, pattern, max_parent, pparams, param;
// data() reformated as
// [[$parent,'param,val],...]
if (!('parameters in (.is_readable_by(sender()))))
throw(~perm, (("Parameters on " + (.dbref())) + " are not readable by ") + (sender().dbref()));
max_parent = [@args, this()][1];
data = [];
for pparams in ($list.reverse($sys.sender_data())) {
if (valid(pparams[1]) && ((pparams[1]).has_ancestor(max_parent))) {
for param in (pparams[2])
data = [@data, [pparams[1], @param]];
}
}
return data;
.
method data
var par, data, out;
if (!('parameters in (.is_readable_by(sender()))))
throw(~perm, ((sender().namef('ref)) + " is not allowed to read parameters on ") + (.namef('ref)));
data = $sys.sender_data();
out = #[];
for par in (data) {
// if the parent doesn't exist anymore, just let them see the data.
if ((!valid(par[1])) || ('parameters in ((par[1]).is_readable_by(sender()))))
out = dict_add(out, par[1], par[2]);
else
out = dict_add(out, par[1], ["*** Permission Denied ***"]);
}
return out;
.
method size
disallow_overrides;
arg [args];
args = [@args, 'int][1];
switch (args) {
case 'string:
return tostr(size());
case 'english:
return $int.to_english(size());
default:
return size();
}
.
method descendants
disallow_overrides;
var kid, kids;
// .descendants()
// -> Recursive list of all children of this object -- try not to use
kids = children();
for kid in (kids)
kids = union(kids, kid.descendants());
return kids;
.
method get_quota
disallow_overrides;
return quota;
.
method owned
disallow_overrides;
return owned;
.
method quota_valid
disallow_overrides;
// if (!.has_ancestor($user) && !$sys.is_admin(this()))
// return 0;
// will put quota checking in here
return 1;
.
method del_owned_obj
disallow_overrides;
arg obj;
(> .perms(caller(), $root) <);
owned = setremove(owned, obj);
.
method add_owned_obj
disallow_overrides;
arg obj;
(> .perms(caller(), $root, $sys) <);
if (obj in owned)
throw(~addowned, ((.namef('ref)) + " already owns ") + (obj.namef('ref)));
owned = [@owned, obj];
.
method match_children
arg string;
var children, child_names, c;
children = .children();
child_names = $list.map(children, 'namef);
// direct matches first.
for c in (child_names) {
if (c == string)
return children[c in child_names];
}
// ok, try partial matches
for c in (child_names) {
if (match_begin(c, string))
return children[c in child_names];
}
return 0;
.
method set_info
arg text;
(> .perms(sender(), 'manager) <);
info = text;
.
method info
return info;
.
method _display_descendants
arg [args];
var space, checked, c, anc, biguglylist, id, perms;
space = args ? args[1] | "";
checked = (listlen(args) > 1) ? args[2] | [];
perms = "";
if (fertile)
perms = "F";
for c in (.readable())
perms = perms + (tostr(c)[1]);
id = (space + (.namef(['dbref], " (", ['name], ")"))) + (perms ? (" [" + perms) + "]" | perms);
for anc in (checked) {
if (.has_ancestor(anc))
return [id + " (above)"];
}
if (listlen(.parents()) > 1)
id = id + " (MI)";
else
id = id + "";
biguglylist = [id];
space = space + " ";
// check children
for c in (.children()) {
biguglylist = biguglylist + (c._display_descendants(space, checked));
checked = setadd(checked, c);
pause();
}
return biguglylist;
.
method _display_ancestors
arg [args];
var space, checked, c, anc, biguglylist, id, perms;
space = args ? args[1] | "";
checked = (listlen(args) > 1) ? args[2] | [];
perms = "";
if (fertile)
perms = "F";
for c in (.readable())
perms = perms + (tostr(c)[1]);
id = (space + (.namef('ref))) + (perms ? (" [" + perms) + "]" | perms);
for anc in (checked) {
if (.has_ancestor(anc))
return [id + " (above)"];
}
if (listlen(.parents()) > 1)
id = id + " (MI)";
else
id = id + "";
biguglylist = [id];
space = space + " ";
// check children
for c in (.parents()) {
biguglylist = biguglylist + (c._display_ancestors(space, checked));
checked = setadd(checked, c);
pause();
}
return biguglylist;
.
method _get_method_info
disallow_overrides;
arg anc, method;
var code, lines, dis_flag, meth_args, first_comment;
code = anc.list_method(method);
lines = listlen(code);
if (lines > 5)
code = sublist(code, 1, 5);
dis_flag = 0;
if (code) {
if ("disallow_overrides;" == (code[1])) {
dis_flag = 1;
code = delete(code, 1);
}
if (code && ((code[1]) && (((code[1])[1]) == "a"))) {
meth_args = match_pattern("arg *;", code[1])[1];
code = delete(code, 1);
} else {
meth_args = "";
}
if (code && ((!(code[1])) || (((code[1])[1]) == "v")))
code = delete(code, 1);
if (code && ((!(code[1])) || (((code[1])[1]) == "v")))
code = delete(code, 1);
first_comment = code ? (code[1]) + " " | " ";
first_comment = (((first_comment[1]) == "/") || ((first_comment[1]) == "r")) ? first_comment | "";
} else {
meth_args = "";
first_comment = "";
}
return [anc, method, meth_args, dis_flag, lines, first_comment];
.
method namef
arg [args];
var output, type, part;
if (!args)
args = [['dbref]];
if (((args[1]) == 'ref) || ((args[1]) == 'xref))
args = [['dbref]];
// the actual switch, punctuation is treated oddly (parens specifically)
output = "";
for part in (args) {
type = type(part);
if (type == 'list)
output = output + ((| .(part[1])(@sublist(part, 2)) |) || "");
else if (type == 'string)
output = output + part;
}
return output;
.
method match_descendants
arg string;
var match, child;
match = .match_children(string);
if (match)
return match;
for child in (.children()) {
match = child.match_descendants(string);
if (match)
return match;
}
return 0;
.
method readable
return readable;
.
method chown
disallow_overrides;
arg new_owners;
var old_owners, obj, sofar, this;
// must be called to add/del/change any ownership.
(> .perms(sender(), .manager(), @$sys.system()) <);
// make sure the new owners list is legit.
if (type(new_owners) != 'list)
throw(~type, "New owners must be given as a list of objects");
if (!($sys.is_system(sender()))) {
for obj in (new_owners) {
if (!(obj.has_ancestor($user)))
throw(~perm, (obj.namef('ref)) + " is not a user object.");
}
}
// few basic (re)settings
old_owners = $list.flatten(owners);
new_owners = $list.flatten(new_owners);
owners = [];
this = this();
sofar = [];
// first make it so nobody owns it.
for obj in (old_owners)
(| obj.del_owned_obj(this) |);
// set all the new owners
for obj in (new_owners) {
catch any {
obj.add_owned_obj(this);
} with handler {
if (error() == ~addowned)
continue;
// didn't work out, set it back the way it was.
for obj in (sofar)
(| obj.del_owned_obj(this) |);
for obj in (old_owners) {
if ((| obj.add_owned_obj(this) |))
owners = [@owners, obj];
}
throw(~chown, "Unable to add %O as an owner, chown unsuccessful.", obj);
}
sofar = [@sofar, obj];
}
owners = new_owners;
.
method debug
arg [stuff];
var x, line, mngr;
line = (sender().namef(['id])) + " debug:";
for x in (stuff)
line = (line + " ") + ((type(x) == 'string) ? x | ($data.unparse(x)));
(| (.manager()).tell(line) |);
.
method set_quota
arg value;
(> .perms(caller(), $user, @$sys.system(), $root) <);
quota = value;
.
method dbref
arg [args];
args = [@args, 'string][1];
switch (args) {
case 'string:
return "$" + tostr(dbref);
case 'symbol:
return dbref;
default:
throw(~type, "args must be 'string or 'symbol.");
}
.
method set_dbref
arg new_dbref;
var old_dbref;
// Only accept calls from owners or admins.
if (!(.is_writable_by(sender())))
throw(~perm, "Sender not an owner.");
// Make sure first argument is a symbol.
if (type(new_dbref) != 'symbol)
throw(~type, "New dbref is not a symbol.");
// Do nothing if new_dbref isn't different.
if (new_dbref == dbref)
return;
// Make sure everything is lowercase.
new_dbref = tosym(lowercase(tostr(new_dbref)));
// Grab the new dbref
catch any {
$sys.assign_dbref(new_dbref);
old_dbref = dbref;
dbref = new_dbref;
// If we already had a dbref, get rid of the old one.
if (old_dbref)
$sys.deassign_dbref(old_dbref);
} with handler {
$brandon.tell_traceback(traceback(), "");
}
.
method name
arg [args];
return .dbref();
.
method del_owner
disallow_overrides;
arg owner;
(> .perms(caller(), $root) <);
if (listlen(owners) != 1)
owners = setremove(owners, owner);
else
.chown([$no_one]);
.
method add_owner
disallow_overrides;
arg owner;
(> .perms(caller(), $root) <);
owners = [@owners, owner];
.
method generate_html
arg [args];
var actor, readable, name, out, line, obj, col, colx, objs, x;
actor = sender();
readable = .is_readable_by(actor);
name = .namef('ref);
out = ["<head>", ("<title>" + name) + "</title>", "<center>"];
out = [@out, ("<h1>" + name) + "</h1>", "</center>"];
out = [@out, "<hr width=50% align=middle>", "<body>"];
line = ("<a href=\"/bin/show?" + tostr(.dbref('symbol))) + "\">";
out = [@out, ("<center>" + line) + "show this object.</a></center>"];
line = [];
for obj in (.parents())
line = [@line, $http.make_href_string(obj)];
out = [@out, "<P>Parent(s): " + ($list.to_english(line)), "<pre>"];
// duplicate the $code.generate_family_listing code because we
// want to put in hrefs.
objs = .children();
if (objs) {
out = [@out, "Children:"];
col = ((| sender().linelen() |) || 79) / 8;
colx = col * 3;
line = pad("Name", colx + 2) + pad(" Perms", col - 2);
out = [@out, (line + pad("Size ", -col)) + "Manager"];
for obj in (objs) {
name = obj.namef('xref);
line = $http.make_href_string(obj, pad(name, colx + 2));
line = line + pad($object.see_perms(obj), col - 2);
line = line + pad(tostr(obj.size()) + " ", -col);
x = obj.manager();
if (!valid(x))
name = pad(("** invalid object *(" + tostr(x)) + ") **", colx);
else
name = $http.make_href_string(x, pad(x.namef('xref), colx));
line = line + name;
out = [@out, line];
}
}
out = [@out, "</pre>"];
if (info) {
if (type(info) == 'frob)
out = [@out, info.translate_to("text/html")];
else
out = [@out, "<hr width=50% align=middle>", @info];
}
return out;
.
method show_in_html
disallow_overrides;
var out, actor, data, parent, readable, m, p, x, line;
// duplicating code in .show because I want it to be htmlified
actor = sender();
readable = .is_readable_by(actor);
data = $sys.sender_data();
// the beginning.
out = "Object: " + ($http.make_object_href(this(), .namef('ref)));
out = ((out + " [") + tostr(.size())) + " bytes]";
line = [];
for x in (.parents())
line = [@line, $http.make_object_href(x)];
out = [out, "Parent(s): " + ($list.to_english(line)), "<pre>"];
// Methods
if ('methods in readable) {
out = out + ["Methods:"];
for m in (.method_info())
out = out + [" " + ($http.make_method_href(m))];
} else {
out = out + [" ** No permission to list Methods **"];
}
// Parameters
if ('parameters in readable) {
for parent in (data) {
// because the server is FKD we have to make sure your params
// all have valid parents:
if (valid(parent[1])) {
out = out + [((parent[1]).namef('xref)) + " Parameters:"];
if ('parameters in ((parent[1]).is_readable_by(actor))) {
for p in (parent[2]) {
line = ((" " + tostr(p[1])) + ": ") + (($http.filter_text([$data.unparse(p[2])]))[1]);
out = out + [line];
}
} else {
out = out + [" ** Permission Denied **"];
}
} else {
out = out + ["(Invalid parent-object You cannot reference because it's broke) Parameters:"];
for p in (parent[2]) {
line = ((" " + tostr(p[1])) + ": ") + (($http.filter_text([$data.unparse(p[2])]))[1]);
out = out + [line];
}
}
}
} else {
out = out + [" ** No permission to list Parameters **"];
}
// Return what we've got.
return out;
.
parent #1
object #675
var 1 child_index 16
var 1 owners [#936]
var 1 owned []
var 1 fertile 1
var 1 inited 1
var 1 manager #675
var 1 writable [#675]
var 1 readable ['parameters, 'methods, 'code]
var 1 info ["$misc is the parent for all objects which do not fit anywhere else on the herarchy. It serves as a means of keeping $root from having too many children."]
var 1 dbref 'misc
method _null_method_filter
arg [args];
return 1;
.
method _display_filter
arg anc, method, includes, excludes;
var pat, ret, name;
name = tostr(method);
while (includes) {
if (match_pattern(includes[1], name) == 0)
return 0;
includes = delete(includes, 1);
}
while (excludes) {
if (match_pattern(excludes[1], name) != 0)
return 0;
excludes = delete(excludes, 1);
}
return 1;
.
parent #675
object #7791
var 1 dbref 'network_root
var 1 child_index 4
var 1 fertile 0
var 1 manager #7791
var 1 owned []
var 1 owners [#936]
var 1 writable []
var 1 readable ['parameters, 'methods, 'code]
var 1 inited 1
var 7791 buffer `[]
var 7791 ip ""
var 7791 hostname ""
var 7791 socket 0
var 7791 port 0
var 7791 active 0
method init_network_root
(> .perms(caller(), $root) <);
(> .reset_connection() <);
.
method uninit_network_root
(> .perms(caller(), $root) <);
(> .reset_connection() <);
.
method reset_connection
// reset parameters to their default values
(> .perms(caller(), $network_root) <);
disconnect();
buffer = `[];
ip = "";
hostname = "";
port = 0;
socket = 0;
active = 0;
.
method failed
arg socket;
// called by the server when unable to make a connection.
if ((sender() != 0) || (sender() != this()))
throw(~perm, "Sender is not the server");
.receive("CONNECTION FAILED; socket: " + tostr(socket), 'connection_failed);
// we weren't ever connected, but this will reset us.
(| .close() |);
.
method open
arg addr, port;
// open a connection to <addr> on <port>
(> .perms(sender()) <);
if (active)
throw(~engaged, (.namef('ref)) + " is currently engaged.");
// reset for good measure
(> .reset_connection() <);
// set the active bit.
.set_active(1);
// set the ip or addr, if children want they can redefine .set_*
// to check for hostname() or whatever.
if (toint(addr))
.set_ip(addr);
else
.set_hostname(addr);
.set_port(port);
// try to open it
(> $sys.connect(addr, port, this()) <);
.
method close
// close the connection
(> .perms(sender()) <);
(> .reset_connection() <);
.receive("Connection Closed.", 'connection_closed);
.
method connect
arg [args];
// called by the server when a successful connection is made
if (sender() != 0)
throw(~perm, "Sender is not the server");
.receive("CONNECTION ESTABLISHED; " + ($data.unparse(args)), 'connection_established);
// This is ugly, will be fixed when networking is fixed in the driver
if (type(args[1]) == 'integer) {
socket = args[1];
} else {
ip = args[1];
socket = args[2];
hostname = hostname(ip);
}
.
method disconnect
arg [args];
$brandon.debug(this(), args);
if ((sender() != 0) || (sender() != this()))
throw(~perm, "Sender is not the server");
(> .close() <);
.
method receive
arg line, status;
// receive a string, called by .parse()
.
method parse
arg incoming;
var lines, line;
// called by the server with an incoming buffer
if (sender() != 0)
throw(~perm, "Sender and caller are not the server");
lines = buffer_to_strings(buffer_append(buffer, incoming));
buffer = lines[listlen(lines)];
lines = sublist(lines, 1, listlen(lines) - 1);
for line in (lines)
.receive(line, 'external);
.
method send
arg what;
var line;
// send off a string or list of strings. Calls .echo()
if (type(what) == 'list) {
for line in (what)
.send(line);
} else {
.echo(what, 'string);
}
.
method echo
arg what, type;
// send off a string or buffer
(> .perms(sender()) <);
switch (type) {
case 'string:
(> echo(buffer_from_strings([what])) <);
case 'buffer:
(> echo(what) <);
}
.
method bind
arg port, receiver;
// bind to a port
(> .perms(sender(), 'this) <);
(> $sys.bind(port, receiver) <);
.
method unbind
arg port;
// unbind from a port
(> .perms(sender(), 'this) <);
(> $sys.unbind(port) <);
.
method ip
(> .perms(sender(), 'trusts) <);
return ip;
.
method hostname
(> .perms(sender(), 'trusts) <);
return hostname;
.
method port
(> .perms(sender(), 'trusts) <);
return port;
.
method socket
(> .perms(sender(), 'trusts) <);
return socket;
.
method active
(> .perms(sender(), 'trusts) <);
return active;
.
method set_ip
arg str;
(> .perms(sender(), 'this) <);
ip = str;
.
method set_hostname
arg str;
(> .perms(sender(), 'this) <);
hostname = str;
.
method set_port
arg int;
(> .perms(sender(), 'this) <);
port = int;
.
method set_socket
arg int;
(> .perms(sender(), 'this) <);
socket = int;
.
method set_active
arg bit;
(> .perms(sender(), 'this) <);
active = bit;
.
parent #7791
object #9508
var 1 dbref 'slate_connection
var 1 child_index 5
var 1 fertile 0
var 1 manager #37
var 1 owned []
var 1 owners [#37]
var 1 writable []
var 1 readable ['parameters, 'methods, 'code]
var 7791 buffer `[]
var 7791 ip ""
var 7791 hostname ""
var 7791 port 0
var 7791 socket 0
var 7791 active 0
var 1 inited 1
var 9508 receiver 0
method receive
arg line, status;
if (receiver)
receiver.receive(line, status);
.
method uninit_slate
(> .perms(caller(), $root) <);
(| receiver.slate_going_away() |);
.
method init_slate
(> .perms(caller(), $root) <);
receiver = 0;
.
method open
arg addr, port;
(> pass(addr, port) <);
receiver = sender();
.
method trusts
arg obj;
if (obj in ($network.valid_slate_callers()))
return 1;
return pass(obj);
.
method new_slate_connection
var new_obj;
(> .perms(caller(), 'trusts) <);
new_obj = .spawn();
new_obj.add_writer(sender());
new_obj.chown([sender()]);
new_obj.set_manager(sender());
return new_obj;
.
method close
(> pass() <);
(| slate.connection_ending() |);
(> .destroy() <);
.
parent #1
object #2
var 1 child_index 8
var 1 owners [#936]
var 1 fertile 1
var 1 inited 1
var 1 owned []
var 1 manager #2
var 1 writable [#2]
var 1 readable ['parameters, 'methods, 'code]
var 1 info ["$frob_class is the root of all frob objects. It defines .unparse, for displaying frobs (.unparse may be overriddent, but defaults to <$class, [rep] | #[rep]>."]
var 1 dbref 'frob_class
method unparse
arg rep;
return ((("<" + ($data.unparse(this()))) + ", ") + ($data.unparse(rep))) + ">";
.
method new
arg value;
return <this(), value>;
.
parent #2
object #2485
var 1 child_index 6
var 1 fertile 0
var 1 manager #2485
var 1 owners [#936]
var 1 writable [#2485]
var 1 readable ['parameters, 'methods, 'code]
var 1 trusted []
var 1 owned []
var 1 inited 1
var 1 dbref 'logic_class
method test
arg [args];
return 0;
.
parent #2485
object #3
var 1 owners [#936]
var 1 owned []
var 1 manager #3
var 1 writable [#3]
var 1 readable ['parameters, 'methods, 'code]
var 1 child_index 2
var 1 dbref 'lock_class
parent #3
object #2494
var 1 child_index 0
var 1 fertile 0
var 1 manager #2494
var 1 owners [#936]
var 1 writable [#2494]
var 1 readable ['parameters, 'methods, 'code]
var 1 trusted []
var 1 owned []
var 1 inited 1
var 1 dbref 'contains_lock
method test
arg objlist, testee, [args];
var x;
for x in (objlist) {
if (testee.contains(x))
return 1;
}
return 0;
.
parent #1
object #1170
var 1 child_index 7
var 1 owners [#936]
var 1 owned []
var 1 fertile 0
var 1 inited 1
var 1 manager #1170
var 1 writable [#1170]
var 1 readable ['parameters, 'methods, 'code]
var 1 info ["$utility_objects is the parent for all objects which are themsleves utilities, such as $scheduler. It does not define anything."]
var 1 dbref 'utility_objects
parent #1170
object #8019
var 1 dbref 'http
var 1 child_index 0
var 1 fertile 0
var 1 manager #8019
var 1 owned []
var 1 owners [#936]
var 1 writable []
var 1 readable ['parameters, 'methods, 'code]
var 1 inited 1
var 8019 errors #[[400, ["<head><title>400 Bad Request</title></head>", "<body>", "<center><h1>400 Bad Request</h1></center>", "%s", "</body>"]], [403, ["<head><title>403 Permission Denied</title></head>", "<body>", "<center><h1>403 Permission Denied</h1></center>", "%s", "</body>"]], [404, ["<head><title>404 Not Found</title></head>", "<center><h1>404 Not Found</h1></center>", "%s", "</body>"]]]
method set_error
arg error, lines;
(> .perms(sender(), 'manager) <);
errors = dict_add(errors, error, lines);
.
method del_error
arg error, lines;
(> .perms(sender(), 'manager) <);
errors = dict_del(errors, error);
.
method get_error
arg error, str;
var lines, x;
lines = (| errors[error] |) || ["Oops, server just broke."];
for x in [1 .. listlen(lines)]
lines = replace(lines, x, strsub(lines[x], "%s", str));
return lines;
.
method make_href_string
arg obj, [name];
var line;
if (!name)
name = [obj.dbref()];
line = ("<tt><a href=\"/objects/" + tostr(obj.dbref('symbol))) + "/\">";
return (line + (name[1])) + "</a></tt>";
.
method bin_show
arg [args];
var out, obj;
if (!args)
return .get_error(400, "Must specify an object");
obj = (| $object.to_dbref(args[1]) |);
if (!obj)
return .get_error(404, ("Unable to find object \"" + (args[1])) + "\"");
return ["<pre>", @obj.show_in_html(), "</pre>"];
.
method make_method_href
arg m;
return ((((((("<a href=\"/bin/list_method?" + ((m[1]).dbref())) + ".") + tostr(m[2])) + "()\">") + tostr(m[2])) + "(") + (m[3])) + ")</a>";
.
method make_object_href
arg obj, [name];
var line;
if (!name)
name = [obj.dbref()];
line = ("<tt><a href=\"/objects/" + tostr(obj.dbref('symbol))) + "/\">";
return (line + (name[1])) + "</a></tt>";
.
method bin_list_method
arg [args];
var ref, str_ref, name, obj, code, anc, out, line, x;
if (!args)
return .get_error(400, "Must specify a method reference");
catch any {
ref = $parse.reference(args[1]);
name = tosym(ref[2]);
obj = $object.to_dbref(ref[1]);
anc = obj.find_method(name);
code = anc.list_method(name);
code = .filter_text(code);
for x in [1 .. listlen(code)]
line = " " + (code[x]);
str_ref = (((obj.dbref()) + ".") + tostr(name)) + "()";
out = [("<head><title>" + str_ref) + "</title></head>"];
out = [@out, ("<body><center><h1>" + str_ref) + "</h1></center>"];
out = [@out, "<hr>", "<pre><code>", "@program " + str_ref];
out = [@out, @code, ".", "</code></pre>"];
} with handler {
switch (error()) {
case ~methodnf:
line = (((obj.dbref()) + ".") + tostr(name)) + "()";
out = $http.get_error(400, line + " not found.");
default:
out = $http.get_error(400, (traceback()[1])[2]);
}
}
return out;
.
method bin_who
arg [args];
var out, obj;
// will have to spiff this up later.
out = ["<head><title>Who is connected to the Cold Dark?</title></head>"];
out = [@out, "<body><pre>", @$code.generate_listing($user_db.connected())];
return out + ["</pre>"];
.
method filter_text
arg text;
var x, line;
// embed's characters ('>' becomes '>' etc)
for x in [1 .. listlen(text)] {
line = strsub(text[x], "&", "&");
line = strsub(line, "<", "<");
line = strsub(line, ">", ">");
text = replace(text, x, line);
}
return text;
.
parent #1
object #1377
var 1 child_index 4
var 1 fertile 0
var 1 manager #1377
var 1 owners [#1377]
var 1 writable [#1377, #47]
var 1 readable ['parameters, 'methods, 'code]
var 1 trusted []
var 1 owned []
var 1 inited 1
var 1 info ["$foundation is the root object of the world building blocks. All 'vr' objects are ultimately derived from the foundation object, as well as some of the non-vr helper objects."]
var 1 dbref 'foundation
parent #1377
object #1178
var 1 child_index 0
var 1 owners [#936]
var 1 owned []
var 1 fertile 1
var 1 inited 1
var 1 manager #1178
var 1 writable [#1178]
var 1 readable ['parameters, 'methods, 'code]
var 1178 messages 0
var 1 info ["$messaged stores messages for various objects. For example, $exit messages such as would be displayed when a being attempts to travers an exit, but fails would be stored in a $messaged parameter, but could be overridden on a particular exit."]
var 1 dbref 'messaged
method messages
.perms(sender(), 'this);
return messages || #[];
.
method all_messages
var msg, all;
// For message to call when inheriting, or something
.perms(sender(), 'this);
all = (| pass() |) || #[];
for msg in (.messages()) {
if (msg in dict_keys(all))
all = $dict.replace(all, msg, (.messages())[msg]);
else
all = dict_add(all, msg, (.messages())[msg]);
}
return all;
.
method message
arg id;
var ret;
ret = (| (.all_messages())[id] |);
if (type(ret) == 'error)
throw(~msgnf, "Message not found.");
return ret;
.
method add_message
arg id, msg;
.perms(sender());
if (.has_message(id))
throw(~msgexists, "Message already defined.");
messages = dict_add(messages, id, msg);
.
method set_message
arg id, msg;
.perms(sender());
if (.defines_msg(id))
messages = $dict.replace(messages, id, msg);
else
.add_message(id, msg);
.
method has_message
arg id;
return id in dict_keys(.all_messages());
.
method defines_msg
arg id;
return id in dict_keys(.messages());
.
method init_messaged
.perms(caller(), $root);
messages = #[];
.
parent #2
parent #1178
object #1138
var 1 child_index 0
var 1 owners [#936]
var 1 owned []
var 1 fertile 0
var 1 inited 1
var 1 manager #1138
var 1 writable [#1138]
var 1 readable ['parameters, 'methods, 'code]
var 1 dbref 'event_class
var 1138 type 'generic
var 1178 messages #[]
method new
arg [args];
.perms(caller(), $event_handler);
// we still don't know what we want
// if (type(location) != 'dbref)
// throw(~type, "The location must be given as a dbref");
// return <this(), #[['actor, sender()], ['action, action], ['what, what], ['where, location], ['direction, direction]]>;
return <this(), [sender(), @args]>;
.
method dispatch
arg dict;
.has_object_perms($event_handler, caller());
(dict['where]).event(<this(), dict>);
.
method set_event_type
arg newtype;
.perms(sender());
if (type(newtype) != 'symbol)
throw(~type, "New event types must be symbols.");
type = newtype;
.
method type
arg [args];
return type;
.
parent #1138
object #5205
var 1 dbref 'movement_event
var 1 child_index 0
var 1 fertile 0
var 1 manager #7232
var 1 owned []
var 1 owners [#7232, #1387, #1388]
var 1 writable []
var 1 readable ['parameters, 'methods, 'code]
var 1 inited 1
var 1138 type 'movement
method exit
arg rep;
return rep[2];
.
method new
arg which, who, [args];
(> .perms(caller(), $exit) <);
return <this(), [which, who, sender()]>;
.
method dest
arg args;
return (args[3]).dest();
.
method source
arg args;
return (args[3]).source();
.
parent #1377
object #16
var 16 commands []
var 16 shortcuts []
var 1 child_index 2
var 1 owners [#936]
var 1 fertile 0
var 1 inited 1
var 1 owned []
var 1 manager #16
var 1 writable [#16]
var 1 readable ['parameters, 'methods, 'code]
var 533 title "untitled"
var 533 brief ""
var 533 help_name ""
var 533 text []
var 533 footnotes []
var 533 references #[]
var 533 upnode #534
var 533 subnodes []
var 533 menu 0
var 1 dbref 'has_commands
method init_has_commands
if (caller() != $root)
throw(~perm, "Caller is not $root.");
commands = [];
shortcuts = [];
.
method uninit_has_commands
if (caller() != $root)
throw(~perm, "Caller is not $root.");
commands = 0;
shortcuts = 0;
.
method add_command
arg template, method;
if (!(.is_writable_by(sender())))
throw(~perm, "Sender is not an owner.");
if ((type(template) != 'string) || (type(method) != 'symbol))
throw(~type, "Template and method are not a string and symbol.");
commands = [@commands, [template, method]];
.
method del_command
arg match;
var command, x;
.perms(sender());
// so you can do both template or method
if (type(match) == 'symbol)
x = 2;
else if (type(match) == 'string)
x = 1;
else
throw(~type, "Type must either be a string or symbol (template or method).");
for command in (commands) {
if ((command[x]) == match) {
commands = setremove(commands, command);
return;
}
}
throw(~commandnf, "No command with match " + toliteral(match));
.
method add_shortcut
arg pattern, method, subs;
if (!(.is_writable_by(sender())))
throw(~perm, "Sender is not an owner.");
if ((type(pattern) != 'string) || ((type(method) != 'symbol) || (type(subs) != 'list)))
throw(~type, "Pattern, method, and subs are not a string, symbol, and list.");
shortcuts = [@shortcuts, [pattern, method, subs]];
.
method del_shortcut
arg method;
var shortcut;
if (!(.is_writable_by(sender())))
throw(~perm, "Sender is not an owner.");
for shortcut in (shortcuts) {
if ((shortcut[2]) == method) {
shortcuts = setremove(shortcuts, shortcut);
return;
}
}
throw(~shortcutnf, "No shortcut with method " + tostr(method));
.
method match_command
arg str;
var shortcut, cmd, fields;
// Try shortcuts.
for shortcut in (.all_shortcuts()) {
fields = match_pattern(shortcut[1], str);
if (fields)
return [shortcut[2], .sub_shortcut_fields(shortcut[3], fields)];
}
// Try commands.
for cmd in (.all_commands()) {
fields = match_template(cmd[1], str);
if (fields)
return [cmd[2], fields];
}
// Give up.
return 0;
.
method commands
return commands;
.
method all_commands
var p, cmdlist, pc;
// Collect complete command list from ancestors. Ancestors may not be
// command-handling objects, in which case (| p.commands() |) is
// ~methodnf.
cmdlist = [];
for p in (ancestors()) {
pc = (| p.commands() |);
if (pc)
cmdlist = cmdlist + pc;
if (p == definer())
break;
}
return cmdlist;
.
method shortcuts
return shortcuts;
.
method all_shortcuts
var ancestor, list, ancestor_shortcuts;
// Collect complete command list from ancestors. Ancestors may not be
// command-handling objects, in which case (| p.shortcuts() |) is
// ~methodnf.
list = [];
for ancestor in (ancestors()) {
ancestor_shortcuts = (| ancestor.shortcuts() |);
if (ancestor_shortcuts)
list = list + ancestor_shortcuts;
if (ancestor == definer())
break;
}
return list;
.
method sub_shortcut_fields
arg subs, fields;
var subbed_list, elem;
subbed_list = [];
for elem in (subs) {
if (type(elem) == 'string)
subbed_list = [@subbed_list, elem];
else if (type(elem) == 'integer)
subbed_list = [@subbed_list, (> fields[elem] <)];
else
throw(~type, "Substitution element is of wrong type.");
}
return subbed_list;
.
parent #16
object #664
var 1 child_index 11
var 1 owners [#936]
var 1 owned []
var 1 fertile 1
var 16 commands []
var 16 shortcuts []
var 1 inited 1
var 1 manager #664
var 1 writable [#664]
var 1 readable ['parameters, 'methods, 'code]
var 1 dbref 'interfaces
parent #664
object #7801
var 1 dbref 'connection_interface
var 1 child_index 3
var 1 fertile 0
var 1 manager #37
var 1 owned []
var 1 owners [#37]
var 1 writable []
var 1 readable ['parameters, 'methods, 'code]
var 16 commands []
var 16 shortcuts []
var 1 inited 1
var 7801 connection 0
method timeout
// the connection is asking the interface if it should timeout
// and close the connection.
return 1;
.
method parse_line
arg line;
var cmd;
// don't use the normal parsing system because it involves
// a bit of overhead.
catch any {
while (line && ((line[1]) == " "))
line = substr(line, 2);
if (!line) {
return .null_cmd(line);
} else {
cmd = .match_command(line);
if (cmd)
return .(cmd[1])(@cmd[2]);
else
return .invalid_cmd(line);
}
} with handler {
.send($parse.traceback(traceback()));
return 'disconnect;
}
.
method init_connection_interface
(> .perms(caller(), $root) <);
connection = 0;
.
method uninit_connection_interface
(> .perms(caller(), $root) <);
connection = 0;
.
method connection_going_away
(> .perms(caller(), $connection) <);
(> .perms(sender(), connection) <);
(> .destroy() <);
.
method linelen
return 79;
.
method new_connection
arg addr;
(> .perms(caller(), $connection) <);
connection = sender();
.
method send
arg what;
connection.send(what);
.
method null_cmd
arg line;
return 'disconnect;
.
method invalid_cmd
arg line;
return 'disconnect;
.
method connection
return connection;
.
method connection_starting
// called by connection.connect()
.
parent #7801
object #7969
var 1 dbref 'http_interface
var 1 child_index 696
var 1 fertile 1
var 1 manager #37
var 1 owned []
var 1 owners [#37]
var 1 writable []
var 1 readable ['parameters, 'methods, 'code]
var 16 commands [["GET *", 'get_cmd]]
var 16 shortcuts []
var 7801 connection 0
var 1 inited 1
var 7969 uri ""
var 7969 header #[]
var 7969 http_version ""
var 7969 method ""
var 7969 status 0
method init_http_interface
(> .perms(caller(), $root) <);
status = 0;
uri = "";
header = #[];
http_version = "";
method = "";
.
method get_cmd
arg cmd, line;
if (status == 0) {
if (!line) {
line = "Invalid use of method GET.";
.send_response($http.get_error(403, line));
return 'disconnect;
}
line = explode(line);
if (listlen(line) > 1)
http_version = line[2];
else
http_version = "HTTP/1.0";
uri = line[1];
method = "GET";
status = 1;
} else {
line = "Method GET already received!";
.send_response($http.get_error(400, line));
return 'disconnect;
}
.
method invalid_cmd
arg line;
var lines;
if (status == 1) {
// I had it set to be just ":" but I think spaces should be in them.
line = explode(line, ": ");
if (listlen(line) == 1)
line = [@line, ""];
else if (listlen(line) > 2)
line = [line[1], $list.to_string(sublist(line, 2))];
header = $dict.add_elem(header, line[1], line[2]);
} else {
line = ("Invalid method: \"" + line) + "\".";
.send_response($http.get_error(400, line));
return 'disconnect;
}
.
method send_response
arg body, [args];
var types, buffer, c;
types = [@args, "text/html"][1];
switch (type(body)) {
case 'list:
buffer = $list.to_buffer(body);
case 'buffer:
buffer = body;
}
c = .connection();
c.send("HTTP/1.0 200 OK");
c.send("Server: ColdWeb/0.1");
c.send("Content-type: " + types);
c.send("Content-length: " + tostr(buffer_len(buffer)));
c.send("");
c.echo(buffer, 'buffer);
.log_request(buffer_len(buffer));
.
method error
arg error, str;
var lines, x;
lines = (| errors[error] |) || ["Oops, server just broke."];
for x in (lines)
strsub(x, "%s", str).send_response(lines);
.
method uninit_http_interface
(> .perms(caller(), $root) <);
uri = "";
header = #[];
http_version = "";
method = "";
.
method null_cmd
arg line;
.process_http_method();
return (> pass(line) <);
.
method log_request
arg content_length;
var line, c, agent;
// was going to have this be like the standard logfile, but decided
// I didn't like that
c = .connection();
line = c.address();
agent = (| ((.header())["User-Agent"])[1] |) || "";
line = (((((((line + " \"") + method) + " ") + uri) + " ") + http_version) + "\" ") + agent;
$http_log.log(line);
.
method process_GET
var path, output, object, line, bin;
(> .perms(sender(), 'this) <);
// Ok, we are going to interpret the URI in funky ways.
path = explode(uri, "/");
if (!path) {
output = ($login.build_html()) + ($http_root_file.retrieve_html());
} else if (((path[1])[1]) == "~") {
object = (| $user_db.find(substr(path[1], 2)) |);
output = (| object.http_request(method, sublist(path, 2)) |);
} else if ((path[1]) == "objects") {
object = (| $object.to_dbref(path[2]) |);
output = (| object.generate_html(@sublist(path, 3)) |);
} else if (match_begin("bin", path[1])) {
if (listlen(path) > 2)
line = $list.to_string(sublist(path, 3));
if ("?" in (path[2])) {
line = substr(path[2], ("?" in (path[2])) + 1) + (line || "");
bin = substr(path[2], 1, ("?" in (path[2])) - 1);
} else {
bin = path[2];
}
output = (| $http.(tosym("bin_" + bin))(line) |);
} else {
object = $http_root_file.find_file([$http_root_file.filename(), @path]);
output = (| object.retrieve_html() |);
}
if (!output) {
line = ("Unable to find " + uri) + ".";
output = $http.get_error(404, line);
}
// intentionally add the tail here, we can slap tCD comments
// at the end.
output = output + ["<hr size=4><a href=\"/\"><b>the Cold Dark</b></a></body>"];
.send_response(output);
.
method process_http_method
(> .perms(sender(), 'this) <);
.(tosym("process_" + method))();
.
method header
return header;
.
parent #1377
object #2786
var 1 child_index 0
var 1 fertile 0
var 1 manager #2786
var 1 owned []
var 1 owners [#47]
var 1 writable []
var 1 readable ['parameters, 'methods, 'code]
var 1 inited 1
var 1 dbref 'environment
method environment
return [];
.
method match_environment
arg str;
var obj, env, found, match;
if (!str)
throw(~objnf, "No \"\" in environment.", str);
// Handle special cases.
if (str == "me") {
return this();
} else if ((str[1]) == "$") {
obj = (| get_name(tosym(substr(str, 2))) |);
if (!valid(obj))
throw(~objnf, "No such object " + str, str);
return obj;
} else {
env = .environment();
found = [];
if (str in ["it", "him", "her"]) {
match = (| sender().match_context(str) |);
if (!match) {
for obj in (env) {
if ((| obj.gender_context() |) == str)
found = [@found, [obj, 1]];
}
} else {
found = [[match, 1]];
}
} else {
for obj in (env) {
match = obj.match_name(str);
if (match)
found = found + [[obj, match]];
}
if (!found) {
for obj in (env) {
match = obj.match_name_aliases(str);
if (match)
found = found + [[obj, match]];
}
}
}
if (!found)
throw(~objnf, ("No \"" + str) + "\" in environment.", str);
if (listlen(found) == 1) {
return (found[1])[1];
} else {
match = $list.min(@$list.slice(found, 2));
if (($list.count(match, $list.slice(found, 2))) == 1)
return (found[match in ($list.slice(found, 2))])[1];
else
throw(~ambig, ("\"" + str) + "\" can match more than one object", [$list.slice(found, 1), str]);
}
}
.
method local_to_environment
arg obj;
return obj in (.environment());
.
parent #1
object #12
var 1 child_index 22
var 1 owners [#936]
var 1 fertile 1
var 1 inited 1
var 1 owned [#49, #45, #51, #48, #46, #47]
var 1 manager #12
var 1 writable [#12]
var 1 readable ['parameters, 'methods, 'code]
var 1 info ["$utilities is the parent of all utility objects storing classes of data-minimulating methods, such as $string and $list. It does not define anything, but merely serves as the parent to these objects."]
var 1 dbref 'utilities
parent #12
object #43
var 1 child_index 0
var 1 owners [#43, #0]
var 1 fertile 0
var 1 inited 1
var 43 alphabet "abcdefghijklmnopqrstuvwxyz"
var 43 numbers "1234567890"
var 43 non_alphanumeric "!@#$%^&*()_+-=~`'{}[]|/?\"\\,.<>;: "
var 1 owned [#43]
var 1 manager #43
var 1 writable [#43]
var 1 readable ['parameters, 'methods, 'code]
var 1 dbref 'string
method left
arg str, width, [fchar];
// will NOT chop off 'str' if it is longer than width, use pad() for that.
if (fchar)
return str + ((strlen(str) < width) ? pad("", width - strlen(str), fchar[1]) | "");
else
return str + ((strlen(str) < width) ? pad("", width - strlen(str)) | "");
.
method fill
arg n, [args];
var fill, x;
// same as pad("", n, [args]);
fill = [@args, " "][1];
return pad("", n, fill);
.
method center
arg text, len, [args];
var lfill, rfill, textlen, padlen;
// args[1] == string to center
// args[2] == integer of width to center in
// args[3] <op> == what to fill the left|right side with.
// args[4] <op> == what to fill the right side with.
lfill = ((listlen(args) >= 1) && (args[1])) || " ";
rfill = (listlen(args) >= 2) ? args[2] | ((lfill == " ") ? "" | lfill);
textlen = strlen(text);
padlen = (len - textlen) / 2;
if (textlen < len)
return ((.fill(padlen, lfill)) + text) + (rfill ? .fill(padlen, rfill) | "");
else
return (len > 0) ? text | pad(text, len);
.
method trim
arg string, [args];
var rl, chars, type;
// remove leading and trailing characters.
// if args includes a string, it takes that as the strip string.
// args can also include symbols of what edge to trim: 'left 'right (or both)
// left and right defaults on.
rl = [];
while (args) {
type = type(args[1]);
if (type == 'string)
chars = args[1];
else if (type == 'symbol)
rl = [@rl, args[1]];
args = sublist(args, 2);
}
if (!chars)
chars = " ";
if (!rl)
rl = ['left, 'right];
if ('left in rl) {
// strip from left
while (string && ((string[1]) in chars))
string = substr(string, 2);
}
if ('right in rl) {
// strip from right
while (string && ((string[strlen(string)]) in chars))
string = substr(string, 1, strlen(string) - 1);
}
return string;
.
method to_list
arg str, [sep];
var result, list;
// separate a string into a list of strings, breaking wherever 'sep' appears.
// if not provided, sep defaults to a comma.
// One word of warning. sep should not contain an asterisk. If it does,
// this routine will separate the string oddly, most likely losing bits.
if (!str)
return [];
sep = ("*" + (sep ? sep[1] | ",")) + "*";
list = [];
while (1) {
result = match_pattern(sep, str);
if (result) {
list = list + [result[1]];
str = result[2];
} else {
return list + [str];
}
}
.
method right
arg str, width, [fchar];
// will not chop off 'str' if it is longer than width (unlike pad())
if (fchar)
return pad("", width - strlen(str), fill_char[1]) + str;
else
return pad("", width - strlen(str)) + str;
.
method alphabet
return alphabet;
.
method numbers
return numbers;
.
method capitalize
arg string;
// Capitalizes the first character of a word.
return uppercase(string[1]) + substr(string, 2);
.
method is_numeric
arg string;
return toint(string) || (string == "0");
.
method a_or_an
arg string;
if (lowercase(string[1]) in "aeiou")
return "an";
return "a";
.
method strip
arg string, strip;
var new_str, char;
// strips all of "strip" characters from the string
// if "strip" is -1 it will use .non_alphanumeric()
if ((type(string) != 'string) || ((type(strip) != 'string) && (strip != (-1))))
throw(~type, "First argument must be a string, second can be -1");
new_str = "";
if (strip == (-1))
new_str = non_alphanumeric;
for char in [1 .. strlen(string)] {
if (!((string[char]) in strip))
new_str = new_str + (string[char]);
}
return new_str;
.
method non_alphanumeric
return non_alphanumeric;
.
method chop
arg str, len, [end];
// chops string off strlen(end) characters before len and appends len
end = [@end, "..."][1];
if (strlen(str) < len)
return str;
if (strlen(str) < strlen(end))
return str;
return pad(str, len - strlen(end)) + end;
.
method replace
arg string, replace, [char];
var new_str, character;
// replaces 'replace' with the character in 'char'
// if 'replace' is -1 will use .non_alphanumeric();
if ((type(string) != 'string) || ((type(replace) != 'string) && (strip != (-1))))
throw(~type, "First argument must be a string, second can be -1");
char = [@char, " "][1];
new_str = "";
if (replace == (-1))
new_str = non_alphanumeric;
for character in [1 .. strlen(string)] {
if (!((string[character]) in replace))
new_str = new_str + (string[character]);
else
new_str = new_str + char;
}
return new_str;
.
method explode_english_list
arg line, [opts];
var x, output, tmp;
// explodes an english list ("foo, bar and zoo").
line = explode(line, ",");
output = [];
for x in (line) {
x = .trim(x);
if ((| substr(x, 1, 3) |) == "and")
output = [@output, .trim(substr(x, 4))];
else
output = [@output, x];
}
// check the last element, if they didn't specify 'noand
if (!('noand in opts)) {
line = explode(output[listlen(output)]);
tmp = "";
for x in [1 .. listlen(line)] {
if ((line[x]) == "and") {
output = delete(output, listlen(output));
if (tmp)
output = [@output, tmp];
tmp = $list.to_string(sublist(line, x + 1));
if (tmp)
output = [@output, tmp];
// only bother with the first "and"
break;
}
tmp = (tmp + (tmp ? " " | "")) + (line[x]);
}
}
return output;
.
method explode_delimited
arg str, left, right;
var pattern, parsed, matched, match_num, match_result;
// parse str looking for anything surrounded by left and right
// ;$string.explode_delimited("foo%[bar]baz", "%[", "]")
// => [["foo", 1, "baz"], ["bar"]]
pattern = ((("*" + left) + "*") + right) + "*";
parsed = [];
matched = [];
match_num = 0;
while (str) {
match_result = match_pattern(pattern, str);
if (match_result) {
match_num = match_num + 1;
parsed = [@parsed, match_result[1], match_num];
matched = [@matched, match_result[2]];
str = match_result[3];
} else {
parsed = [@parsed, str];
str = "";
}
}
return [parsed, matched];
.
method wrap_line
arg string, length, [stuff];
var output, cutoff, firstline, prefix;
// takes string and wraps it by words, compared to length, returns a list.
prefix = [@stuff, ""][1];
firstline = [@stuff, 0, 0][2];
output = [];
length = length - strlen(prefix);
if (firstline)
string = prefix + string;
while (strlen(string) > length) {
cutoff = .rindex(substr(string, 1, length), " ");
output = [@output, substr(string, 1, cutoff - 1)];
string = prefix + substr(string, cutoff + 1);
}
return [@output, string];
.
method rindex
arg string, index;
var loc, rest;
// returns the first occurance of index starting from the end of the string,
// and moving to the beginning.
loc = index in string;
rest = loc && substr(string, loc + 1);
while (loc && (index in rest)) {
loc = loc + (index in rest);
rest = loc && substr(string, loc + 1);
}
return loc;
.
method match_sub_tag
arg string, tag;
var x, expl, output, match, matches;
// matches a string between 'tag' and " " in a larger string against
// the sender's environment. If a match is found it subs the match.name
// with the string, otherwize it lets it pass through with the tag, ie:
// .match_sub_tag("this test #of something #note or other");
// => "this test #of something Note of sorts or other"
// where the note is in the sender's environment.
expl = .explode_delimited(string + " ", tag, " ");
matches = expl[2];
expl = expl[1];
output = "";
for x in (expl) {
if (type(x) == 'integer) {
match = (| sender().match_environment(matches[x]) |);
if (match)
output = (output + (match.namef())) + " ";
else
output = ((output + tag) + (matches[x])) + " ";
} else {
output = output + x;
}
}
return substr(output, 1, strlen(output) - 1);
.
method search_pat
arg pat, text, [start_at];
var line, match_result, type;
line = 1;
type = [@start_at, 'pattern, 'pattern][2];
if (start_at) {
line = start_at[1];
start_at = [@start_at, 1, 1][2];
if (type == 'pattern)
match_result = match_pattern(pat, substr(text[line], line));
else
match_result = match_regexp(pat, substr(text[line], line));
if (match_result != 0) {
if (type == 'pattern) {
pat = $string.pat_sub(pat, match_result);
return [line, (start_at + pat) in substr(text[line], start_at)];
} else {
return [line, start_at + ((match_result[1])[1])];
}
}
line = line + 1;
}
while (line <= listlen(text)) {
if (type == 'pattern)
match_result = match_pattern(pat, text[line]);
else
match_result = match_regexp(pat, text[line]);
if (match_result != 0) {
if (type == 'pattern) {
pat = $string.pat_sub(pat, match_result);
return [line, pat in (text[line])];
} else {
return [line, (match_result[1])[1]];
}
}
line = line + 1;
}
throw(~strnf, "String not found in text.");
.
method pat_sub
arg pat, subs;
var wc_idx;
// wc_idx == wildcard index
while (subs) {
wc_idx = "*" in pat;
if (wc_idx == 1)
pat = (subs[1]) + substr(pat, 2);
else if (wc_idx == strlen(pat))
pat = substr(pat, 1, wc_idx - 1) + (subs[1]);
else
pat = (substr(pat, 1, wc_idx - 1) + (subs[1])) + substr(pat, wc_idx + 1);
subs = delete(subs, 1);
}
return pat;
.
method is_boolean
arg str;
if (match_begin("yes", str) || (match_begin("true", str) || (str == "1")))
return 1;
else if (match_begin("no", str) || (match_begin("false", str) || (str == "0")))
return 0;
else
return -1;
.
parent #7791
object #7792
var 1 dbref 'connection
var 1 child_index 0
var 1 fertile 1
var 1 manager #37
var 1 owned []
var 1 owners [#37]
var 1 writable []
var 1 readable ['parameters, 'methods, 'code]
var 7791 buffer `[]
var 7791 ip ""
var 7791 hostname ""
var 7791 port 0
var 7791 socket 0
var 7791 active 0
var 1 inited 1
var 7792 daemon 0
var 7792 interface 0
var 7792 receive_internal 0
var 7792 timeout 0
method receive
arg line, status;
(> .perms(sender(), this(), @$sys.system(), daemon) <);
if ((status != 'external) && (!receive_internal))
return;
if ((interface.parse_line(line)) == 'disconnect)
.close();
.
method init_inbound_connection
(> .perms(caller(), $root) <);
daemon = 0;
interface = 0;
.
method uninit_inbound_connection
(> .perms(caller(), $root) <);
daemon = 0;
interface = 0;
.
method initialize_connection
arg interface_parent, seconds;
var addr;
(> .perms(sender()) <);
// spawn this now, if they want to connect to a permanent interface
// the spawned one can do that (such as a user object)
addr = .address();
daemon = sender();
interface = interface_parent.spawn();
.add_writer(interface);
interface.new_connection(addr);
interface.set_manager(interface);
timeout = seconds;
.set_active(1);
.
method set_interface_object
arg obj;
// called by an interface object to change interfaces.
(> .perms(sender(), 'this) <);
interface = obj;
.
method close
(> pass() <);
(| daemon.connection_ending() |);
(> .destroy() <);
.
method init_connection
(> .perms(caller(), $root) <);
timeout = -1;
daemon = 0;
interface = 0;
.
method uninit_connection
(> .perms(caller(), $root) <);
timeout = -1;
daemon = 0;
(| interface.connection_going_away() |);
.
method connect
arg [args];
(> pass(@args) <);
daemon.connection_starting();
interface.connection_starting();
if (timeout >= 0)
(| $scheduler.add_task(timeout, 'timeout) |);
.
method disconnect
(> pass() <);
daemon.connection_ending();
.
method timeout
(> .perms(sender(), 'this) <);
if (interface.timeout()) {
.send(("Timeout (" + tostr(timeout)) + ").");
.close();
}
.
method address
var addr;
// return hostname or ip
if (!('parameters in (.is_readable_by(sender()))))
throw(~perm, "Sender does not have permission to get parameters.");
addr = .hostname();
if (!addr)
addr = .ip();
return addr;
.
method change_interface_object
arg obj;
var old_interface;
// called by an interface object to change interfaces.
(> .perms(sender(), interface) <);
old_interface = interface;
interface = obj;
old_interface.connection_going_away();
interface.new_connection(.address());
.
parent #1377
object #1139
var 1 child_index 0
var 1 owners [#936]
var 1 owned []
var 1 fertile 0
var 1 inited 1
var 1 manager #1139
var 1 writable [#1139]
var 1 readable ['parameters, 'methods, 'code]
var 17 prose #[]
var 15 verbs 0
var 1 dbref 'event_handler
method event
arg frob;
.
method announce_event
arg frob;
var x;
for x in (.environment())
(| x.event(frob) |);
.
parent #1377
object #15
var 15 verbs #[]
var 1 child_index 0
var 1 owners [#936]
var 1 fertile 1
var 1 inited 1
var 1 owned []
var 1 manager #15
var 1 writable [#15]
var 1 readable ['parameters, 'methods, 'code]
var 1 info ["$has_verbs defines all the functionality necessary for an object to have verbs, or methods activated by commands typed by a user object which is not this. Verbs are useful for making certain functionality only available when an object is present, and for allowing different objects to have identicle verbs with different internal meanings (turn alarm to 6am vs. turn safe to 10)."]
var 1 dbref 'has_verbs
method init_has_verbs
if (caller() != $root)
throw(~perm, "Caller is not $root.");
verbs = #[];
.
method uninit_has_verbs
var template;
if (caller() != $root)
throw(~perm, "Caller is not $root.");
verbs = 0;
for template in (dict_keys(verbs))
$verb_cache.object_undefined_verb(template);
.
method verb_templates
return dict_keys(verbs);
.
method add_verb
arg template, method, remote;
var words, pos;
if (!(.is_writable_by(sender())))
throw(~perm, "Sender is not an owner.");
// Check argument types.
if (type(template) != 'string)
throw(~type, "Template is not a string.");
if (type(method) != 'symbol)
throw(~type, "Method obj_name is not a symbol.");
if ((remote != 'remote) && (remote != 'noremote))
throw(~type, "Remote specifier is neither 'remote nor 'noremote");
// Make sure there's exactly one "%this" in the template, as a word by
// itself.
words = explode(template);
if (((words[1]) == "%this") || (((words[1]) == "*") || ((words[1]) == "*=*")))
throw(~template, "Template begins with wildcard.");
pos = "%this" in words;
if ((!pos) || ("%this" in sublist(words, pos + 1)))
throw(~template, "Template does not contain exactly one \"%this\".");
// Add the verbs to the dictionary, and notify $verb_cache.
verbs = dict_add(verbs, template, [method, remote]);
if (remote == 'remote)
$verb_cache.del_template(template);
.
method del_verb
arg template;
var verb_info;
if (!(.is_writable_by(sender())))
throw(~perm, "Sender is not an owner.");
catch ~keynf {
verb_info = verbs[template];
verbs = dict_del(verbs, template);
(| $verb_cache.del_template(template) |);
} with handler {
throw(~verbnf, ("No verb with template " + tostr(template)) + ".");
}
.
method verb_info
disallow_overrides;
arg template;
var verb_info, anc;
if (dict_contains(verbs, template))
return verbs[template];
for anc in (ancestors()) {
verb_info = (| anc.local_verb_info(template) |);
if (verb_info)
return verb_info;
}
throw(~verbnf, "No verb with template " + template);
.
method local_verb_info
disallow_overrides;
arg template;
catch ~keynf {
return verbs[template];
} with handler {
throw(~verbnf, "No verb with template " + template);
}
.
method verbs
return verbs;
.
method all_verbs
var p, vrblist, pv;
vrblist = #[];
for p in (.ancestors()) {
pv = (| p.verbs() |);
if (pv)
vrblist = $dict.union(vrblist, pv);
if (p == definer())
break;
}
return vrblist;
.
parent #1377
object #2787
var 1 child_index 0
var 1 fertile 1
var 1 manager #2787
var 1 owned []
var 1 owners [#47]
var 1 writable []
var 1 readable ['parameters, 'methods, 'code]
var 1 inited 1
var 1 dbref 'named
var 2787 name ['uniq, "Named Object"]
var 2787 name_aliases 0
method set_name
arg new_name, [args];
var proper;
// .set_name(new_name, ['proper|'unique]) (default proper).
// ['prop, "Name"] => proper, no indefinite/definite articles.
// ['uniq, "Name"] => unique, normal indefinite/definite articles.
.perms(sender());
if (type(new_name) != 'string)
throw(~type, "New name must be given as a string.");
// this will not catch them all, but we can try.
if ((" a " in new_name) || (" the " in new_name))
throw(~bad_name, "Do not include articles in a name");
//
proper = [@args, 'prop][1];
name = [proper, new_name];
.
method name_aliases
return name_aliases;
.
method add_name_alias
arg alias;
.perms(sender());
name_aliases = [@name_aliases, alias];
.
method del_name_alias
arg alias;
.perms(sender());
name_aliases = setremove(name_aliases, alias);
.
method init_named
var dbref;
.perms(caller(), $root);
dbref = tostr(dbref);
name = ['uniq, tostr(dbref)];
name_aliases = [];
.
method match_name
arg str;
return match_begin(.name('none), str);
.
method name
arg [article];
article = [@article, 'indef][1];
if ((name[1]) == 'uniq) {
switch (article) {
case 'indef:
return (($string.a_or_an(name[2])) + " ") + (name[2]);
case 'def:
return "the " + (name[2]);
}
}
return name[2];
.
method match_name_aliases
arg str;
return str in name_aliases;
.
method namef
arg [args];
if (!args)
args = [['name, 'def]];
if ((args[1]) == 'ref) {
if (.has_ancestor($named))
args = [['name], " (", ['dbref], ")"];
else
args = [['dbref]];
} else if ((args[1]) == 'xref) {
if (.has_ancestor($named))
args = [['dbref], " (", ['name], ")"];
else
args = [['dbref]];
}
return pass(@args);
.
parent #15
parent #2787
object #17
var 17 prose #[]
var 1 child_index 0
var 1 owners [#936]
var 1 fertile 0
var 15 verbs #[["l?ook at %this", ['look_vrb, 'noremote]], ["l?ook %this", ['look_vrb, 'noremote]], ["@examine|examine %this", ['examine_vrb, 'remote]]]
var 1 inited 1
var 1 owned []
var 1 manager #17
var 1 writable [#17]
var 1 readable ['parameters, 'methods, 'code]
var 1 dbref 'described
var 2787 name ['uniq, "Generic Described Object"]
var 2787 name_aliases []
method init_described
.perms($root, caller());
prose = #[];
.
method description
arg actor, [exclude];
var out;
// similar to MOO's :look_self()
// meant to be changed by descendants, if they so desire to.
return [.name('def), @.prose('short)];
.
method look_vrb
arg vrb, [args];
var actor;
actor = sender();
actor.tell(.description(actor, actor));
.
method prose
arg [type];
type = [@type, 'short][1];
switch (type) {
case 'literal:
return prose;
default:
return (| prose[type] |) || ((| prose['short] |) || ["You see nothing special."]);
}
.
method descriptionf
arg actor, exclude, [args];
var out, part, type;
// lists should be ['methodname, args for method]
// symbols are shortcuts, to be defined on descendants.
out = [];
for part in (args) {
type = type(part);
switch (type) {
case 'list:
out = out + ((| .(part[1])(@sublist(part, 2)) |) || []);
case 'symbol:
// ignore them, they should have been dealt with by now.
}
}
return out;
.
method set_prose
arg ptype, new_prose;
// ptype should be either 'short or 'long
// prose should be a list of strings
.perms(sender(), 'manager);
if (type(ptype) != 'symbol)
throw(~type, "Prose type can be either 'short or 'long.");
if (type(new_prose) != 'list)
throw(~type, "Prose must be given as a list of strings.");
prose = dict_add(prose, ptype, new_prose);
.
method examine_vrb
arg vrb, [args];
var actor;
actor = sender();
actor.tell(.name());
actor.tell(.prose('long));
.
parent #2787
object #1179
var 1 child_index 0
var 1 owners [#936]
var 1 owned []
var 1 fertile 0
var 15 verbs 0
var 1 inited 1
var 1179 gender 0
var 17 prose #[]
var 1 manager #1179
var 1 writable [#1179]
var 1 readable ['parameters, 'methods, 'code]
var 1 dbref 'gendered
var 2787 name ['uniq, "The Generic Gendered Object"]
var 2787 name_aliases []
method gender_context
return gender.pronoun('po);
.
method init_gendered
.perms($root, caller());
gender = $gender_neuter;
.
method set_gender
arg gendr;
.perms(sender(), 'manager);
if ((type(gendr) != 'dbref) && (!(gendr in ($gender.children()))))
throw(~invgender, ($data.unparse(gendr)) + " is not a valid gender object type.");
gender = gendr;
.
method gender
return gender;
.
parent #1178
parent #1139
parent #17
parent #1179
parent #2786
object #1387
var 1 child_index 0
var 1 fertile 0
var 1 manager #7232
var 1 owners [#7232, #1387]
var 1 writable [#1387, #37]
var 1 readable ['parameters, 'methods, 'code]
var 1 trusted []
var 1 owned [#1387, #1388, #4309, #4348, #5205, #7245, #7248, #7261]
var 15 verbs #[]
var 17 prose #[]
var 1 inited 1
var 1179 gender #1182
var 1387 visibility 0
var 1 dbref 'physical
var 2787 name ['uniq, "Generic Physical Object"]
var 2787 name_aliases []
method set_visibility
arg val;
.perms(sender(), 'manager);
if (!(type(val) == 'integer))
throw(~type, "Visibility must be set as a positive or negative integer.");
visibility = val;
.
method visibility
return visibility;
.
parent #1387
parent #16
object #19
var 19 contents []
var 1 child_index 0
var 1 owners [#936]
var 1 fertile 1
var 15 verbs #[]
var 1 inited 1
var 23 location #22
var 1 owned []
var 1179 gender #1182
var 17 prose #[]
var 1 manager #19
var 1 writable [#19]
var 1 readable ['parameters, 'methods, 'code]
var 16 commands []
var 16 shortcuts []
var 1 dbref 'location
var 2787 name ['uniq, "Generic Container Object"]
var 2787 name_aliases []
method init_location
.perms(caller(), $root);
contents = [];
.
method uninit_location
var obj;
.perms(caller(), $root);
for obj in (contents)
obj.move_to($nowhere);
.
method contents
return contents || [];
.
method contains
arg obj;
return (obj in (.contents())) ? 1 | 0;
.
method put
arg obj;
obj._move_to(this());
.
method take
arg obj;
if (!(obj in contents))
throw(~objnf, ("Object (" + toliteral(obj)) + ") not in contents.");
obj._move_to(sender());
.
method will_arrive
arg old_place;
if (caller() != $located)
throw(~perm, "Caller is not $located.");
.
method will_leave
arg place;
if (caller() != $located)
throw(~perm, "Caller is not $located.");
.
method did_arrive
arg place;
if (caller() != $located)
throw(~perm, "Caller is not $located.");
.
method did_leave
arg place;
if (caller() != $located)
throw(~perm, "Caller is not $located.");
.
method add_sender_to_contents
disallow_overrides;
if (caller() != $located)
throw(~perm, "Caller is not $located.");
if ((sender().location()) != this())
throw(~location, "Sorry, but you're not here.");
contents = setadd(.contents(), sender());
.
method del_sender_from_contents
disallow_overrides;
if (caller() != $located)
throw(~perm, "Caller not an agent of located protocol.");
contents = setremove(contents, sender());
.
method validate_contents
var obj, newcont;
if (!(.is_writable_by(sender())))
throw(~perm, "Must be an owner to validate contents");
newcont = [];
for obj in (contents) {
if (valid(obj) && (obj.has_ancestor($located)))
newcont = setadd(newcont, obj);
}
contents = newcont;
.
method environment
return [this()] + contents;
.
method add_to_contents
disallow_overrides;
arg what;
if (caller() != $located)
throw(~perm, "Caller is not $located.");
.
method contents_accept_mail
return 1;
.
method realm
arg [args];
var loc;
loc = "";
if ((| .location() |))
loc = (.location()).realm();
return ((loc + "[") + (.namef())) + "]";
.
method realm_name
return "";
.
method local_verb_templates
var obj, out;
out = [];
for obj in (.contents()) {
if (obj.has_ancestor($has_verbs))
out = out + dict_keys(obj.all_verbs());
}
return out;
.
parent #675
parent #15
object #7261
var 1 dbref 'public
var 1 child_index 0
var 1 fertile 1
var 1 manager #7232
var 1 owned []
var 1 owners [#7232, #1387, #1388]
var 1 writable []
var 1 readable ['parameters, 'methods, 'code]
var 1 inited 1
var 7261 public []
var 15 verbs #[["@public on %this is *", ['public_vrb, 'remote]]]
method init_public
.perms(caller(), $root);
public = ['readable];
.
method is_publicly
arg what;
return what in public;
.
method set_public
arg what;
var x, valid;
if (sender() != this())
.perms(sender(), 'manager);
if (type(what) == 'symbol) {
if (what in public)
return;
what = [@public, what];
}
if (type(what) != 'list)
throw(~type, toliteral(what) + " is an invalid type.");
public = what;
.
method public
return public;
.
method public_vrb
arg vrb, on, this, is, args;
var x, syn, p, who, opts;
.perms(sender(), 'manager);
syn = ((vrb + " on ") + this) + " <+/-[r|w]>";
who = sender();
if (!args)
$parse.tell_error(["Must specify either readable or writable.", ("Current Public permissions: " + ($list.to_english(public))) + "."], syn, who);
opts = #[["r", [1, 0]], ["w", [0, 0]]];
args = $parse.options(args, opts);
opts = args[2];
args = args[1];
if ((!((opt["r"])[1])) && ('readable in public))
.set_public(setremove(public, 'readable));
else if (((opt["r"])[1]) && (!('readable in public)))
.set_public(public + ['readable]);
if ((!((opt["w"])[1])) && ('writable in public))
.set_public(setremove(public, 'writable));
else if (((opt["w"])[1]) && (!('writable in public)))
.set_public(public + ['writable]);
sender().tell(("Public perms changed to: " + ($list.to_english(public))) + ".");
.
parent #19
parent #7261
object #2679
var 1 child_index 88
var 1 fertile 0
var 1 manager #37
var 1 owned []
var 1 owners [#47]
var 1 writable []
var 1 readable ['parameters, 'methods, 'code]
var 1 inited 1
var 1179 gender #1182
var 17 prose #[]
var 15 verbs #[]
var 16 commands [["l?ook", 'look_cmd]]
var 16 shortcuts []
var 1 dbref 'place
var 2787 name ['uniq, "place"]
var 2787 name_aliases []
var 2679 realm 0
var 2679 exits 0
var 2679 coordinates 0
var 7261 public ['readable]
method init_place
.perms($root, caller());
exits = [];
realm = $realm_of_creation.new();
coordinates = #[];
.set_public('location);
.
method uninit_place
var x;
.perms($root, caller());
for x in (exits)
(| x.destroy() |);
(| realm.place_destroyed(this()) |);
for x in (.area())
(| x.place_destroyed(this()) |);
(| $place_db.place_destroyed() |);
.
method environment
return pass() + exits;
.
method description
arg actor, [exclude];
var output, dark;
output = pass(actor, exclude);
output = output + (._desc_contents(actor, exclude));
output = output + (._desc_exits(actor, exclude));
return output;
.
method exits
return exits;
.
method add_exit
disallow_overrides;
arg coord1, coord2;
var exit;
// coordinates are not standard x/y, but radial/azimuth
.perms($exit, caller());
exit = sender();
(> ._add_exit(exit) <);
(> ._add_coordinate(exit, coord1, coord2) <);
(> ._add_coordinate(exit.dest(), coord1, coord2) <);
.
method _add_exit
disallow_overrides;
arg obj;
// use .add_exit()
.perms(sender(), 'this);
exits = [@exits, obj];
.
method _del_exit
disallow_overrides;
arg obj;
// use .del_exit()
.perms(sender(), 'this);
exits = setremove(exits, obj);
.
method del_exit
disallow_overrides;
var exit;
exit = sender();
.perms(caller(), $exit);
(| ._del_exit(exit) |);
(| ._del_coordinate(exit) |);
(| ._del_coordinate(exit.dest()) |);
.
method _add_coordinate
disallow_overrides;
arg obj, coord1, coord2;
.perms(sender(), 'this);
// should only be called from inside this object.
coordinates = dict_add(coordinates, obj, [coord1, coord2]);
.
method _del_coordinate
disallow_overrides;
arg obj;
.perms(sender(), 'this);
// should only be called from inside this object.
coordinates = dict_del(coordinates, obj);
.
method did_connect
if ((.visibility()) >= 0)
.announce((sender().namef()) + " has connected.", sender());
.
method did_disconnect
if ((.visibility()) >= 0)
.announce((sender().namef()) + " has disconnected.", sender());
.
method look_cmd
arg cmd;
var actor, text;
sender().tell(.description(sender(), sender()));
.
method realm
arg [args];
var tmp, r;
return realm;
.
method announce
arg str, [except];
var obj;
for obj in (.contents()) {
if (!(obj in except))
(| obj.tell(str) |);
}
.
method did_housekeep
arg who;
var message;
// catch ~msgnf {
catch any {
message = .get_message('housekeeper);
} with handler {
message = "The housekeeper hauls %N away";
}
// this will have to do until we get a correct action setup
.announce(strsub(message, "%N", who.namef()));
.
method set_name
arg [args];
var old_name;
old_name = .name();
(> pass(@args) <);
(| $place_db.room_changed_name(old_name) |);
.
method set_realm
arg frob_class, where;
.perms(sender());
if (!(frob_class.has_ancestor($frob_class)))
throw(~type, "Realm must be submitted as a frob class object.");
realm = frob_class.new([where]);
.
method examine_vrb
arg vrb, [args];
var actor, text;
actor = sender();
text = .description(actor, [actor], 'desc_name, 'long_description, '_desc_contents, '_desc_long_exits);
actor.tell(text);
.
method _desc_contents
arg actor, dont_show;
var users, objects, output, obj, line;
// called by .description
.perms(sender(), 'this);
users = [];
objects = [];
for obj in (.contents()) {
if ((!(obj in dont_show)) || (| !(obj.obvious()) |)) {
if (obj.has_ancestor($body))
users = [@users, obj.namef('nactivity)];
else
objects = [@objects, obj.namef()];
}
}
output = [];
// we will get these both using @options eventually.
if (users) {
line = ($list.to_english(users)) + " ";
line = (line + ((listlen(users) > 1) ? "are" | "is")) + " here.";
output = [@output, line];
}
if (objects) {
line = "You see ";
line = (line + ($list.to_english(objects))) + " here.";
output = [@output, line];
}
return output;
.
method _desc_exits
arg actor, mode;
.perms(sender(), 'this);
return .visible_exits_formatted(actor, 'verbose);
.
method visible_exits
var obv, exit;
obv = [];
for exit in (.exits()) {
if ((exit.visibility()) >= (.visibility()))
obv = [@obv, exit];
}
return obv;
.
method area
var out, x;
out = [];
for x in (dict_keys(coordinates)) {
if (x.has_ancestor($place))
out = out + [x];
}
return out;
.
method realm_name
return (((realm.name()) + " [") + (.name())) + "]";
.
method will_attach
arg type, obj;
// callable only from the methods on $exit, so don't worry too much.
switch (type) {
case 'source:
.perms(obj);
case 'dest:
if ((!(.is_publicly('location))) && (!(| .perms(obj) |)))
throw(~perm, ("Place refuses to link with " + (obj.namef('ref))) + ".");
}
.
method visible_exits_formatted
arg actor, how;
var output, ex, exits, line;
exits = .visible_exits();
switch (how) {
case 'none:
return [];
case 'brief:
if (!exits)
return [];
return ["Exits: " + ($list.to_english($list.map(exits, 'namef), "none"))];
case 'average:
output = [];
for ex in (exits) {
line = (ex.namef()) + " (";
line = line + ($list.to_english(ex.name_aliases(), "no aliases"));
output = [@output, line];
}
return output ? ["Exits: " + ($list.to_english(output))] | [];
case 'long:
output = [];
for ex in (exits)
output = [@output, (((" " + (ex.namef())) + " to: ") + ((ex.dest()).namef())) + "."];
return output ? ["Exits: ", @$list.lcolumnize(output, actor.linelen())] | [];
case 'verbose:
output = [];
for ex in (exits)
output = [@output, ex.description(actor, 'short)];
return output ? [$list.to_string(@output)] | [];
}
.
method place_destroyed
arg place;
// announces when a place is destroyed
.perms(caller(), $place, $realms_class);
(| ._del_coordinate(place) |);
.
parent #2679
object #247
var 1 child_index 0
var 1 owners [#936]
var 1 fertile 0
var 16 commands []
var 16 shortcuts []
var 15 verbs #[]
var 19 contents [#5203, #7232]
var 1 inited 1
var 1231 name_aliases []
var 1 owned []
var 1179 gender #1182
var 17 prose #[]
var 1 manager #247
var 1 writable [#247]
var 1 readable ['parameters, 'methods, 'code]
var 1 dbref 'body_cave
var 2787 name ['uniq, "Body Cave"]
var 2787 name_aliases []
var 2679 exits []
var 2679 realm <#2717, ['interior]>
var 2679 coordinates #[]
parent #675
object #1093
var 1 child_index 0
var 1 owners [#936]
var 1 owned []
var 1 fertile 0
var 1 inited 1
var 1 manager #1093
var 1 writable [#1093]
var 1 readable ['parameters, 'methods, 'code]
var 1 dbref 'filters
method compress
arg input;
var e, output;
// only goes 1 element deep--sorry, anybody sending anything past that will
// be Showing the first 100 KB of 449.9 KB. Download the archive for the full file.