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.13 by root, Fri Mar 31 22:09:36 2006 UTC vs.
Revision 1.15 by root, Sun Jun 11 15:02:16 2006 UTC

65 65
66my %ext_pkg; 66my %ext_pkg;
67my @exts; 67my @exts;
68my @hook; 68my @hook;
69my %command; 69my %command;
70my %extcmd;
70 71
71sub inject_event { 72sub inject_event {
72 my ($data) = @_; 73 my $extension = shift;
74 my $event_code = shift;
73 75
74 my $cb = $hook[$data->{event_code}]{$data->{extension}} 76 my $cb = $hook[$event_code]{$extension}
75 or return; 77 or return;
76 78
77 $cb->($data) 79 &$cb
78} 80}
79 81
80sub inject_global_event { 82sub inject_global_event {
81 my $event = shift; 83 my $event = shift;
82 84
171 delete $command{$name}; 173 delete $command{$name};
172 delete $COMMAND{"$name\000"}; 174 delete $COMMAND{"$name\000"};
173 } 175 }
174 } 176 }
175 177
178 # remove extcmds
179 for my $name (keys %command) {
180 my @cb = grep $_->[2] ne $pkg, @{ $command{$name} };
181
182 if (@cb) {
183 $command{$name} = \@cb;
184 $COMMAND{"$name\000"} = List::Util::max map $_->[0], @cb;
185 } else {
186 delete $command{$name};
187 delete $COMMAND{"$name\000"};
188 }
189 }
190
191
176 Symbol::delete_package $pkg; 192 Symbol::delete_package $pkg;
177} 193}
178 194
179sub load_extensions { 195sub load_extensions {
180 my $LIBDIR = maps_directory "perl"; 196 my $LIBDIR = maps_directory "perl";
213 $who->message ("Intruder Alert!"); 229 $who->message ("Intruder Alert!");
214 } 230 }
215}; 231};
216 232
217############################################################################# 233#############################################################################
234# extcmd framework, basically convert ext <id> <pkg> arg1 args
235# into pkg::->on_extcmd_arg1 (...) while shortcutting a few
236
237sub on_extcmd {
238 my ($pl, $buf) = @_;
239
240 my ($id, $pkg, $name, $data) = split / /, $buf, 4;
241
242 if (my $method = "cf::ext::$pkg"->can ("on_extcmd_$name")) {
243 $method->($pl, $id, $buf);
244 }
245}
246
247#############################################################################
218# load/save/clean perl data associated with a map 248# load/save/clean perl data associated with a map
219 249
220*on_mapclean = sub { 250*on_mapclean = sub {
221 my ($map) = @_; 251 my ($map) = @_;
222 252

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines