--- deliantra/server/lib/cf.pm 2006/08/25 15:31:44 1.42 +++ deliantra/server/lib/cf.pm 2006/08/25 17:11:53 1.43 @@ -354,7 +354,7 @@ delete $extcmd{$name}; } - if (my $cb = $pkg->can ("on_unload")) { + if (my $cb = $pkg->can ("unload")) { eval { $cb->($pkg); 1 @@ -468,23 +468,25 @@ # extcmd framework, basically convert ext # into pkg::->on_extcmd_arg1 (...) while shortcutting a few -sub on_extcmd { - my ($pl, $buf) = @_; - - my $msg = eval { from_json $buf }; - - if (ref $msg) { - if (my $cb = $extcmd{$msg->{msgtype}}) { - if (my %reply = $cb->[0]->($pl, $msg)) { - $pl->ext_reply ($msg->{msgid}, %reply); +attach_global + on_extcmd => sub { + my ($pl, $buf) = @_; + + my $msg = eval { from_json $buf }; + + if (ref $msg) { + if (my $cb = $extcmd{$msg->{msgtype}}) { + if (my %reply = $cb->[0]->($pl, $msg)) { + $pl->ext_reply ($msg->{msgid}, %reply); + } } + } else { + warn "player " . ($pl->ob->name) . " sent unparseable ext message: <$buf>\n"; } - } else { - warn "player " . ($pl->ob->name) . " sent unparseable ext message: <$buf>\n"; - } - 1 -} + cf::override; + }, +; ############################################################################# # load/save/clean perl data associated with a map