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.42 by root, Fri Aug 25 15:31:44 2006 UTC vs.
Revision 1.44 by root, Sat Aug 26 08:44:06 2006 UTC

90my %ext_pkg; 90my %ext_pkg;
91my @exts; 91my @exts;
92my @hook; 92my @hook;
93my %command; 93my %command;
94my %extcmd; 94my %extcmd;
95
96#############################################################################
97# object support
98
99sub reattach {
100 warn "reattach<@_>\n";
101}
102
103sub instantiate {
104 warn "instantiate<@_>\n";
105}
106
107sub clone {
108 warn "clone<@_>\n";
109}
95 110
96############################################################################# 111#############################################################################
97# "new" plug-in system 112# "new" plug-in system
98 113
99=item cf::object::attach ... # NYI 114=item cf::object::attach ... # NYI
352 # remove extcmds 367 # remove extcmds
353 for my $name (grep $extcmd{$_}[1] eq $pkg, keys %extcmd) { 368 for my $name (grep $extcmd{$_}[1] eq $pkg, keys %extcmd) {
354 delete $extcmd{$name}; 369 delete $extcmd{$name};
355 } 370 }
356 371
357 if (my $cb = $pkg->can ("on_unload")) { 372 if (my $cb = $pkg->can ("unload")) {
358 eval { 373 eval {
359 $cb->($pkg); 374 $cb->($pkg);
360 1 375 1
361 } or warn "$pkg unloaded, but with errors: $@"; 376 } or warn "$pkg unloaded, but with errors: $@";
362 } 377 }
466 481
467############################################################################# 482#############################################################################
468# extcmd framework, basically convert ext <msg> 483# extcmd framework, basically convert ext <msg>
469# into pkg::->on_extcmd_arg1 (...) while shortcutting a few 484# into pkg::->on_extcmd_arg1 (...) while shortcutting a few
470 485
471sub on_extcmd { 486attach_to_players
487 on_extcmd => sub {
472 my ($pl, $buf) = @_; 488 my ($pl, $buf) = @_;
473 489
474 my $msg = eval { from_json $buf }; 490 my $msg = eval { from_json $buf };
475 491
476 if (ref $msg) { 492 if (ref $msg) {
477 if (my $cb = $extcmd{$msg->{msgtype}}) { 493 if (my $cb = $extcmd{$msg->{msgtype}}) {
478 if (my %reply = $cb->[0]->($pl, $msg)) { 494 if (my %reply = $cb->[0]->($pl, $msg)) {
479 $pl->ext_reply ($msg->{msgid}, %reply); 495 $pl->ext_reply ($msg->{msgid}, %reply);
496 }
480 } 497 }
498 } else {
499 warn "player " . ($pl->ob->name) . " sent unparseable ext message: <$buf>\n";
481 } 500 }
482 } else { 501
483 warn "player " . ($pl->ob->name) . " sent unparseable ext message: <$buf>\n"; 502 cf::override;
484 } 503 },
485 504;
486 1
487}
488 505
489############################################################################# 506#############################################################################
490# load/save/clean perl data associated with a map 507# load/save/clean perl data associated with a map
491 508
492*cf::mapsupport::on_clean = sub { 509*cf::mapsupport::on_clean = sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines