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.1 by root, Fri Feb 3 19:49:32 2006 UTC vs.
Revision 1.4 by root, Tue Feb 7 01:03:44 2006 UTC

87 87
88sub register_command { 88sub register_command {
89 my ($name, $time, $cb) = @_; 89 my ($name, $time, $cb) = @_;
90 90
91 my $caller = caller; 91 my $caller = caller;
92
93 warn "registering command '$name/$time' to '$caller'";
92 94
93 push @{ $command{$name} }, [$time, $cb, $caller]; 95 push @{ $command{$name} }, [$time, $cb, $caller];
94 $COMMAND{"$name\000"} = List::Util::max map $_->[0], @{ $command{$name} }; 96 $COMMAND{"$name\000"} = List::Util::max map $_->[0], @{ $command{$name} };
95} 97}
96 98
158 160
159sub load_extensions { 161sub load_extensions {
160 my $LIBDIR = maps_directory "perl"; 162 my $LIBDIR = maps_directory "perl";
161 163
162 for my $ext (<$LIBDIR/*.ext>) { 164 for my $ext (<$LIBDIR/*.ext>) {
165 next unless -r $ext;
166 eval {
163 load_extension $ext; 167 load_extension $ext;
168 1
169 } or warn "$ext not loaded: $@";
164 } 170 }
165} 171}
166 172
167register_command "perl-reload", 0, sub { 173register_command "perl-reload", 0, sub {
168 my ($who, $arg) = @_; 174 my ($who, $arg) = @_;
169 175
170 if ($who->flag (FLAG_WIZ)) { 176 if ($who->flag (FLAG_WIZ)) {
177 $who->message ("reloading...");
178
171 warn "reloading...\n"; 179 warn "reloading...\n";
180 eval {
172 unload_extension $_ for @exts; 181 unload_extension $_ for @exts;
173 @exts = 0; 182 delete $INC{"cf.pm"};
174 load_extensions; 183
184 # don't, removes xs symbols, too
185 #Symbol::delete_package $pkg;
186
187 require cf;
188 };
189 warn $@ if $@;
190 $who->message ($@) if $@;
175 warn "reloaded\n"; 191 warn "reloaded\n";
192
193 $who->message ("reloaded");
194 } else {
195 $who->message ("Intruder Alert!");
176 } 196 }
177}; 197};
178 198
179load_extensions; 199load_extensions;
180 200

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines