Player Database #32

Parent #30Owner #29Flags readSource hellcore/hellcore.db

Aliases: player_db, plyrdb, pdb

6 verbs · 18 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
loadthis none thisrxd#3245
checkthis none nonerxd#3218
init_for_corethis none thisrxd#325
availablethis none thisrxd#3216
suspend_restartthis none thisrxd#3216
why_bad_namethis none thisrxd#3226

Properties

PropertyDefinerFlagsOwnerValue
stupid_names#32rc#29
list of 28{"with", "using", "at", "to", "in", "into", "on", "onto", "upon", "out", "from", "inside", "over", "through", "under", "underneath", "beneath", "behind", "beside", "for", "about", "is", "as", "off", "of", "me", "you", "here"}
frozen#32rc#290
reserved#32r#29{}
player_alts#32rc#361
list of 17{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
H#32r#29{"", "", {"Hench-Creator", "Hacker", "housekeeper"}, {#329, #29, #65}}
node_perms#30rc#29<clear>
data#30r#29<clear>
#30#29{"", "H", {"someone", "Wizard"}, {#31, #361}}
aliases#1rc#29{"player_db", "plyrdb", "pdb"}
description#1rc#29{"A database containing all player names and aliases. ", "See `help $player_db' for more information."}
object_size#1r#29{677901, 1298433815}
hidden_verbs#1rc#29<clear>
phelp_msg#1rc#29<clear>
weight#1rc#29<clear>
owner_verbs#1rc#29<clear>
plural_name#1rc#29<clear>
client_image#1rc#29<clear>
listening#1rc#29<clear>

Ancestry

Ancestors (nearest first): #30 Generic Database Tree#1 root

Children: none

Call graph

calls n32_0 #32:load n42_0 #42:controls n32_0->n42_0 n30_12 #30:clearall n32_0->n30_12 n32_4 #32:suspend_restart n32_0->n32_4 n30_1 #30:find_exact n32_0->n30_1 n107_43 #107:tell n32_0->n107_43 n30_6 #30:insert n32_0->n30_6 n20_39 #20:words n32_0->n20_39 n122_8 #122:strip n32_0->n122_8 n32_4->n32_0 n32_4->n107_43 n48_7 #48:running_out_of_time n32_4->n48_7 n75_34 #75:task_perms n32_4->n75_34 n32_1 #32:check n32_1->n107_43 n32_2 #32:init_for_core n32_2->n32_0 n1_22 #1:init_for_core n32_2->n1_22 n32_3 #32:available n32_3->n30_1 n45_3 #45:has_callable_verb n32_3->n45_3 n32_5 #32:why_bad_name n32_5->n30_1 n32_5->n45_3 n21_4 #21:parse_names n32_5->n21_4 n20_6 #20:english_list n32_5->n20_6

Source

load

Spec this none thisFlags rxdOwner #29Definer #32

Referenced by

Source

1":load() -- reloads the player_db with the names of all existing players.";
2"This routine calls suspend() if it runs out of time.";
3".frozen is set to 1 while the load is in progress so that other routines are warned and don't try to do any updates.  Sometimes, an update is unavoidable (e.g., player gets recycled) in which case the offending routine should set .frozen to 2, causing the load to start over at the beginning.";
4if ((caller != this) && (!$perm_utils:controls(caller_perms(), this)))
5return E_PERM;
6endif
7"...N.B. clearall suspends, therefore we put the .frozen mark on FIRST...";
8this.frozen = 1;
9this:clearall();
10for p in (players())
11this:suspend_restart(p);
12"... note that if a player is recycled or toaded during the suspension,...";
13"... it won't be removed from the for loop iteration; thus this test:     ";
14if (valid(p) && is_player(p))
15if (typeof(po = this:find_exact(p.name)) == ERR)
16player:tell(p.name, ":  ", po);
17return;
18elseif (po != p)
19if (valid(po) && is_player(po))
20player:tell("name `", p.name, "' for ", p, " subsumes alias for ", po.name, "(", po, ").");
21endif
22this:insert(p.name, p);
23endif
24aliases = p.aliases;
25if (p.obscured)
26for a in ($su:words($ansi:strip(p.code_name)))
27aliases = setremove(aliases, a);
28endfor
29endif
30for a in (aliases)
31this:suspend_restart(p);
32if (index(a, " ") || index(a, "	"))
33"don't bother, space or tab";
34elseif (typeof(ao = this:find_exact(a)) == ERR)
35player:tell(a, ":  ", ao);
36return;
37elseif (!(valid(ao) && is_player(ao)))
38this:insert(a, p);
39elseif (ao != p)
40player:tell("alias `", a, "' for ", p.name, "(", p, ") used by ", ao.name, "(", ao, ").");
41endif
42endfor
43endif
44endfor
45this.frozen = 0;

check

Spec this none noneFlags rxdOwner #29Definer #32

Referenced by

none

Source

1":check() -- checks for recycled and toaded players that managed not to get expunged from the db.";
2for p in (properties($player_db))
3if ((ticks_left() < 500) || (seconds_left() < 2))
4player:tell("...", p);
5suspend(0);
6endif
7if (p[1] == " ")
8nlist = this.(p)[3];
9olist = this.(p)[4];
10for i in [1..length(nlist)]
11if (valid(olist[i]) && (is_player(olist[i]) && (nlist[i] in olist[i].aliases)))
12else
13player:tell(".", p[2..$], " <- ", nlist[i], " ", olist[i]);
14endif
15endfor
16endif
17endfor
18player:tell("done.");

init_for_core

Spec this none thisFlags rxdOwner #29Definer #32

Referenced by

none

Source

1if (caller_perms().wizard)
2pass();
3this.reserved = {};
4this:load();
5endif

available

Spec this none thisFlags rxdOwner #29Definer #32

Referenced by

Source

1":available(name,who) => 1 if a name is available for use, or the object id of whoever is currently using it, or 0 if the name is otherwise forbidden.";
2"If $player_db is not .frozen and :available returns 1, then $player:set_name will succeed.";
3{name, ?target = valid(caller) ? caller | player} = args;
4if ((name in this.stupid_names) || (name in this.reserved))
5return 0;
6elseif (((((!name) || index(name, " ")) || index(name, "\\")) || index(name, "\"")) || index(name, "	"))
7return 0;
8elseif (index("*#()", name[1]))
9return 0;
10elseif (valid(who = this:find_exact(name)) && is_player(who))
11return who;
12elseif ($object_utils:has_callable_verb($local, "legal_name") && (!$local:legal_name(name, target)))
13return 0;
14else
15return 1;
16endif

suspend_restart

Spec this none thisFlags rxdOwner #361Definer #32

Referenced by

Source

1"used during :load to do the usual out-of-time check.";
2"if someone makes a modification during the suspension (indicated by this.frozen being set to 2), we have to restart the entire load.";
3if (caller != this)
4return E_PERM;
5elseif ($command_utils:running_out_of_time())
6player:tell("...", args[1]);
7set_task_perms($byte_quota_utils:task_perms());
8suspend(0);
9if (this.frozen != 1)
10player:tell("...argh... restarting $player_db:load...");
11fork (0)
12this:load();
13endfork
14kill_task(task_id());
15endif
16endif

why_bad_name

Spec this none thisFlags rxdOwner #361Definer #32

Referenced by

Source

1":why_bad_name(player, namespec) => Returns a message explaining why a player name change is invalid.  Stolen from APHiD's #15411:name_okay.";
2who = args[1];
3name = $building_utils:parse_names(args[2])[1];
4si = index(name, " ");
5qi = index(name, "\"");
6bi = index(name, "\\");
7ti = index(name, "	");
8if ((si || qi) || bi)
9return tostr("You may not use a name containing ", $string_utils:english_list({@si ? {"spaces"} | {}, @qi ? {"quotation marks"} | {}, @bi ? {"backslashes"} | {}, @ti ? {"tabs"} | {}}, "ERROR", " or "), ".  Try \"", strsub(strsub(strsub(name, " ", "_"), "\"", "'"), "\\", "/"), "\" instead.");
10elseif (name == "")
11return tostr("You may not use a blank name.");
12elseif (i = index("*#()", name[1]))
13return tostr("You may not begin a name with the \"", "*#()"[i], "\" character.");
14elseif (name in $player_db.stupid_names)
15return tostr("The name \"", name, "\" would probably cause problems in command parsing or similar usage.");
16elseif (name in $player_db.reserved)
17return tostr("The name \"", name, "\" is reserved.");
18elseif (length(name) > $login.max_player_name)
19return tostr("The name \"", name, "\" is too long.  Maximum name length is ", $login.max_player_name, " characters.");
20elseif ((valid(match = $player_db:find_exact(name)) && is_player(match)) && (who != match))
21return tostr("The name \"", name, "\" is already being used by ", match.name, "(", match, ").");
22elseif ($player_db.frozen)
23return tostr("$player_db is not accepting new changes at the moment.");
24elseif ($object_utils:has_callable_verb($local, "legal_name") && (!$local:legal_name(name, who)))
25return "That name is reserved.";
26endif