ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.71 by root, Sun Oct 1 10:59:30 2006 UTC vs.
Revision 1.76 by root, Mon Oct 2 15:28:36 2006 UTC

5use Storable; 5use Storable;
6use Opcode; 6use Opcode;
7use Safe; 7use Safe;
8use Safe::Hole; 8use Safe::Hole;
9 9
10use YAML::Syck ();
10use Time::HiRes; 11use Time::HiRes;
11use Event; 12use 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
13 14
15# work around bug in YAML::Syck - bad news for perl6, will it be as broken wrt. unicode?
16$YAML::Syck::ImplicitUnicode = 1;
17
14use strict; 18use strict;
15 19
16_init_vars; 20_init_vars;
17 21
18our %COMMAND = (); 22our %COMMAND = ();
22our $TICK = MAX_TIME * 1e-6; 26our $TICK = MAX_TIME * 1e-6;
23our $TICK_WATCHER; 27our $TICK_WATCHER;
24our $NEXT_TICK; 28our $NEXT_TICK;
25 29
26our %CFG; 30our %CFG;
31
32our $uptime;
33
34$uptime ||= time;
27 35
28############################################################################# 36#############################################################################
29 37
30=head2 GLOBAL VARIABLES 38=head2 GLOBAL VARIABLES
31 39
766sub cf::player::exists($) { 774sub cf::player::exists($) {
767 cf::player::find $_[0] 775 cf::player::find $_[0]
768 or -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2; 776 or -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2;
769} 777}
770 778
771=item $player->reply ($npc, $msg[, $flags]) 779=item $object->reply ($npc, $msg[, $flags])
772 780
773Sends a message to the player, as if the npc C<$npc> replied. C<$npc> 781Sends a message to the player, as if the npc C<$npc> replied. C<$npc>
774can be C<undef>. Does the right thing when the player is currently in a 782can be C<undef>. Does the right thing when the player is currently in a
775dialogue with the given NPC character. 783dialogue with the given NPC character.
776 784
1025} 1033}
1026 1034
1027############################################################################# 1035#############################################################################
1028# the server's main() 1036# the server's main()
1029 1037
1038sub cfg_load {
1039 open my $fh, "<:utf8", cf::confdir . "/config"
1040 or return;
1041
1042 local $/;
1043 *CFG = YAML::Syck::Load <$fh>;
1044}
1045
1030sub main { 1046sub main {
1047 cfg_load;
1031 db_load; 1048 db_load;
1032 load_extensions; 1049 load_extensions;
1033 Event::loop; 1050 Event::loop;
1034} 1051}
1035 1052
1087 1104
1088 # reload cf.pm 1105 # reload cf.pm
1089 $msg->("reloading cf.pm"); 1106 $msg->("reloading cf.pm");
1090 require cf; 1107 require cf;
1091 1108
1092 # load database again 1109 # load config and database again
1110 cf::cfg_load;
1093 cf::db_load; 1111 cf::db_load;
1094 1112
1095 # load extensions 1113 # load extensions
1096 $msg->("load extensions"); 1114 $msg->("load extensions");
1097 cf::load_extensions; 1115 cf::load_extensions;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines