… | |
… | |
169 | |
169 | |
170 | sub unload_extension { |
170 | sub unload_extension { |
171 | my ($pkg) = @_; |
171 | my ($pkg) = @_; |
172 | |
172 | |
173 | warn "removing extension $pkg\n"; |
173 | warn "removing extension $pkg\n"; |
|
|
174 | |
|
|
175 | if (my $cb = $pkg->can ("on_unload")) { |
|
|
176 | $cb->($pkg); |
|
|
177 | } |
174 | |
178 | |
175 | # remove hooks |
179 | # remove hooks |
176 | for my $idx (0 .. $#EVENT) { |
180 | for my $idx (0 .. $#EVENT) { |
177 | delete $hook[$idx]{$pkg}; |
181 | delete $hook[$idx]{$pkg}; |
178 | } |
182 | } |
… | |
… | |
222 | |
226 | |
223 | unload_extension $_ for @exts; |
227 | unload_extension $_ for @exts; |
224 | delete $INC{"cf.pm"}; |
228 | delete $INC{"cf.pm"}; |
225 | |
229 | |
226 | # don't, removes xs symbols, too |
230 | # don't, removes xs symbols, too |
227 | #Symbol::delete_package $pkg; |
231 | #Symbol::delete_package __PACKAGE__; |
228 | |
232 | |
229 | require cf; |
233 | require cf; |
230 | }; |
234 | }; |
231 | warn $@ if $@; |
235 | warn $@ if $@; |
232 | $who->message ($@) if $@; |
236 | $who->message ($@) if $@; |
… | |
… | |
343 | for grep %$_, $ob, $ob->inv; |
347 | for grep %$_, $ob, $ob->inv; |
344 | |
348 | |
345 | unlink "$path.cfperl";#d##TODO#remove |
349 | unlink "$path.cfperl";#d##TODO#remove |
346 | }; |
350 | }; |
347 | |
351 | |
|
|
352 | ############################################################################# |
|
|
353 | # core extensions - in perl |
|
|
354 | |
|
|
355 | # rough implementation of a future "reply" method that works |
|
|
356 | # with dialog boxes. |
|
|
357 | sub 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 | |
348 | register "<global>", __PACKAGE__; |
368 | register "<global>", __PACKAGE__; |
349 | |
369 | |
350 | unshift @INC, maps_directory "perl"; |
370 | unshift @INC, maps_directory "perl"; |
351 | |
371 | |
352 | load_extensions; |
372 | load_extensions; |