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.16 by root, Mon Jun 12 13:25:27 2006 UTC vs.
Revision 1.22 by root, Wed Jul 19 08:50:42 2006 UTC

1package cf; 1package cf;
2 2
3use Symbol; 3use Symbol;
4use List::Util; 4use List::Util;
5use Storable; 5use Storable;
6
7use Event;
8$Event::Eval = 1; # no idea why this is required, but it is
6 9
7use strict; 10use strict;
8 11
9our %COMMAND; 12our %COMMAND;
10our @EVENT; 13our @EVENT;
60 63
61# guessed hierarchies 64# guessed hierarchies
62 65
63@cf::object::player::ISA = 'cf::object'; 66@cf::object::player::ISA = 'cf::object';
64@cf::object::map::ISA = 'cf::object'; 67@cf::object::map::ISA = 'cf::object';
68
69$Event::DIED = sub {
70 warn "error in event callback: @_";
71};
65 72
66my %ext_pkg; 73my %ext_pkg;
67my @exts; 74my @exts;
68my @hook; 75my @hook;
69my %command; 76my %command;
162 169
163sub unload_extension { 170sub unload_extension {
164 my ($pkg) = @_; 171 my ($pkg) = @_;
165 172
166 warn "removing extension $pkg\n"; 173 warn "removing extension $pkg\n";
174
175 if (my $cb = $pkg->can ("on_unload")) {
176 $cb->($pkg);
177 }
167 178
168 # remove hooks 179 # remove hooks
169 for my $idx (0 .. $#EVENT) { 180 for my $idx (0 .. $#EVENT) {
170 delete $hook[$idx]{$pkg}; 181 delete $hook[$idx]{$pkg};
171 } 182 }
209 if ($who->flag (FLAG_WIZ)) { 220 if ($who->flag (FLAG_WIZ)) {
210 $who->message ("reloading..."); 221 $who->message ("reloading...");
211 222
212 warn "reloading...\n"; 223 warn "reloading...\n";
213 eval { 224 eval {
225 $_->cancel for Event::all_watchers;
226
214 unload_extension $_ for @exts; 227 unload_extension $_ for @exts;
215 delete $INC{"cf.pm"}; 228 delete $INC{"cf.pm"};
216 229
217 # don't, removes xs symbols, too 230 # don't, removes xs symbols, too
218 #Symbol::delete_package $pkg; 231 #Symbol::delete_package __PACKAGE__;
219 232
220 require cf; 233 require cf;
221 }; 234 };
222 warn $@ if $@; 235 warn $@ if $@;
223 $who->message ($@) if $@; 236 $who->message ($@) if $@;
334 for grep %$_, $ob, $ob->inv; 347 for grep %$_, $ob, $ob->inv;
335 348
336 unlink "$path.cfperl";#d##TODO#remove 349 unlink "$path.cfperl";#d##TODO#remove
337}; 350};
338 351
352#############################################################################
353# core extensions - in perl
354
355# rough implementation of a future "reply" method that works
356# with dialog boxes.
357sub cf::object::player::reply($$;$) {
358 my ($self, $msg, $flags) = @_;
359
360 $flags = cf::NDI_WHITE unless @_ >= 3;
361
362 $self->message ($msg, $flags);
363}
364
365#############################################################################
366# initialisation
367
339register "<global>", __PACKAGE__; 368register "<global>", __PACKAGE__;
340 369
370unshift @INC, maps_directory "perl";
371
341load_extensions; 372load_extensions;
342 373
3431 3741
344 375

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines