… | |
… | |
5 | use Storable; |
5 | use Storable; |
6 | use Opcode; |
6 | use Opcode; |
7 | use Safe; |
7 | use Safe; |
8 | use Safe::Hole; |
8 | use Safe::Hole; |
9 | |
9 | |
|
|
10 | use YAML::Syck (); |
10 | use Time::HiRes; |
11 | use Time::HiRes; |
11 | use Event; |
12 | use Event; |
12 | $Event::Eval = 1; # no idea why this is required, but it is |
13 | $Event::Eval = 1; # no idea why this is required, but it is |
|
|
14 | |
|
|
15 | # work around bug in YAML::Syck - bad news for perl6, will it be as broken wrt. unicode? |
|
|
16 | $YAML::Syck::ImplicitUnicode = 1; |
13 | |
17 | |
14 | use strict; |
18 | use strict; |
15 | |
19 | |
16 | _init_vars; |
20 | _init_vars; |
17 | |
21 | |
… | |
… | |
766 | sub cf::player::exists($) { |
770 | sub cf::player::exists($) { |
767 | cf::player::find $_[0] |
771 | cf::player::find $_[0] |
768 | or -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2; |
772 | or -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2; |
769 | } |
773 | } |
770 | |
774 | |
771 | =item $player->reply ($npc, $msg[, $flags]) |
775 | =item $object->reply ($npc, $msg[, $flags]) |
772 | |
776 | |
773 | Sends a message to the player, as if the npc C<$npc> replied. C<$npc> |
777 | Sends a message to the player, as if the npc C<$npc> replied. C<$npc> |
774 | can be C<undef>. Does the right thing when the player is currently in a |
778 | can be C<undef>. Does the right thing when the player is currently in a |
775 | dialogue with the given NPC character. |
779 | dialogue with the given NPC character. |
776 | |
780 | |
… | |
… | |
1025 | } |
1029 | } |
1026 | |
1030 | |
1027 | ############################################################################# |
1031 | ############################################################################# |
1028 | # the server's main() |
1032 | # the server's main() |
1029 | |
1033 | |
|
|
1034 | sub cfg_load { |
|
|
1035 | open my $fh, "<:utf8", cf::confdir . "/config" |
|
|
1036 | or return; |
|
|
1037 | |
|
|
1038 | local $/; |
|
|
1039 | *CFG = YAML::Syck::Load <$fh>; |
|
|
1040 | } |
|
|
1041 | |
1030 | sub main { |
1042 | sub main { |
|
|
1043 | cfg_load; |
1031 | db_load; |
1044 | db_load; |
1032 | load_extensions; |
1045 | load_extensions; |
1033 | Event::loop; |
1046 | Event::loop; |
1034 | } |
1047 | } |
1035 | |
1048 | |
… | |
… | |
1087 | |
1100 | |
1088 | # reload cf.pm |
1101 | # reload cf.pm |
1089 | $msg->("reloading cf.pm"); |
1102 | $msg->("reloading cf.pm"); |
1090 | require cf; |
1103 | require cf; |
1091 | |
1104 | |
1092 | # load database again |
1105 | # load config and database again |
|
|
1106 | cf::cfg_load; |
1093 | cf::db_load; |
1107 | cf::db_load; |
1094 | |
1108 | |
1095 | # load extensions |
1109 | # load extensions |
1096 | $msg->("load extensions"); |
1110 | $msg->("load extensions"); |
1097 | cf::load_extensions; |
1111 | cf::load_extensions; |