Player Database #39

Parent #37Owner #36Flags readSource RPG Core/rpgcore-patched.db

Aliases: Player Database, player_db, plyrdb, pdb

7 verbs · 14 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
loadthis none thisrxd#3939
checkthis none nonerxd#3918
init_for_corethis none thisrxd#395
availablethis none thisrxd#3916
suspend_restartthis none thisrxd#3916
why_bad_namethis none thisrxd#3926
insertthis none thisrxd#393

Properties

PropertyDefinerFlagsOwnerValue
stupid_names#39rc#36
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#39rc#360
reserved#39r#36{}
H#39r#36{"", "", {"Hacker", "housekeeper"}, {#36, #71}}
e#39r#36{"very", "", {"everyone", "Everyman"}, {#38, #38}}
n#39r#36{"o", "", {"noone", "no_one"}, {#38, #38}}
node_perms#37rc#36<clear>
data#37r#36<clear>
#37#36{"", "Hen", {"player", "Wizard"}, {#159, #2}}
key#1c#36<clear>
aliases#1rc#36{"Player Database", "player_db", "plyrdb", "pdb"}
description#1rc#36{"A database containing all player names and aliases. ", "See `help $player_db' for more information."}
object_size#1r#36{9983, -1090650497}
html#1rc#36<clear>

Ancestry

Ancestors (nearest first): #37 Generic Database#1 Root Class

Children: none

Call graph

calls n39_0 #39:load n42_0 #42:controls n39_0->n42_0 n37_12 #37:clearall n39_0->n37_12 n39_4 #39:suspend_restart n39_0->n39_4 n37_1 #37:find_exact n39_0->n37_1 n6_18 #6:tell n39_0->n6_18 n39_6 #39:insert n39_0->n39_6 n39_4->n39_0 n39_4->n6_18 n56_7 #56:running_out_of_time n39_4->n56_7 n80_34 #80:task_perms n39_4->n80_34 n32_3 #32:delete n39_6->n32_3 n37_6 #37:insert n39_6->n37_6 n39_1 #39:check n39_1->n6_18 n39_2 #39:init_for_core n39_2->n39_0 n1_28 #1:init_for_core n39_2->n1_28 n39_3 #39:available n39_3->n37_1 n52_3 #52:has_callable_verb n39_3->n52_3 n39_5 #39:why_bad_name n39_5->n37_1 n39_5->n52_3 n21_3 #21:parse_names n39_5->n21_3 n20_6 #20:english_list n39_5->n20_6

Source

load

Spec this none thisFlags rxdOwner #36Definer #39

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
24for a in (p.aliases)
25this:suspend_restart(p);
26if (index(a, " ") || index(a, "	"))
27"don't bother, space or tab";
28elseif (typeof(ao = this:find_exact(a)) == ERR)
29player:tell(a, ":  ", ao);
30return;
31elseif (!(valid(ao) && is_player(ao)))
32this:insert(a, p);
33elseif (ao != p)
34player:tell("alias `", a, "' for ", p.name, "(", p, ") used by ", ao.name, "(", ao, ").");
35endif
36endfor
37endif
38endfor
39this.frozen = 0;

check

Spec this none noneFlags rxdOwner #36Definer #39

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 #2Definer #39

Referenced by

none

Source

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

available

Spec this none thisFlags rxdOwner #36Definer #39

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 #2Definer #39

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 #2Definer #39

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

insert

Spec this none thisFlags rxdOwner #2Definer #39

Referenced by

Source

1((typeof(args[1]) == NUM) && (typeof(args[2]) == STR)) && (args[2] = $ansi_utils:delete(args[2]));
2(typeof(args[1]) == STR) && (args[1] = $ansi_utils:delete(args[1]));
3return pass(@args);