--- deliantra/server/ext/ipo.ext 2006/12/26 09:56:52 1.3 +++ deliantra/server/ext/ipo.ext 2007/04/18 17:32:06 1.6 @@ -54,7 +54,7 @@ # lets message player ingame: this is a NEW feature from the perl IPO :-) for (keys %sent_targets) { - if (my $player = cf::player::find $_) { + if (my $player = cf::player::find_active $_) { my $cnt = $sent_targets{$_}; if ($cnt == 1) { @@ -120,7 +120,7 @@ $mail->name_pl ("$type->[1]s F: $from T: " .$pl->name); $mail->msg ($msg); $mail->value (0); - $mail->insert_in_ob ($box); + $box->insert ($mail); } $cnt += @$mails; @@ -169,7 +169,7 @@ my ($cmd, $arguments) = split /\s+/, $msg, 2; $cmd = lc $cmd; - my $pl = cf::player::find $who->name; + my $pl = cf::player::find_active $who->name; my ($x, $y) = ($pl->ob->x, $pl->ob->y); if (my $pr = $prices{$cmd}) { @@ -186,25 +186,27 @@ } } elsif ($cmd eq 'receive') { - my $storage = cf::map::find ("/planes/IPO_storage"); - unless ($storage) { - $who->reply ($npc, "Sorry, our package delivery service is currently in strike. Please come back later."); - return 1; - } + cf::async { + my $storage = cf::map::find ("/planes/IPO_storage"); + unless ($storage) { + $who->reply ($npc, "Sorry, our package delivery service is currently in strike. Please come back later."); + return 1; + } - my $plname = $who->name; - my $cnt; - for ($storage->at (2, 2)) { - if ($_->name () =~ /^\S+ F: \S+ T: \Q$plname\E$/) { - $_->insert_in_ob ($who); - $cnt++; + my $plname = $who->name; + my $cnt; + for ($storage->at (2, 2)) { + if ($_->name () =~ /^\S+ F: \S+ T: \Q$plname\E$/) { + $who->insert ($_); + $cnt++; + } } - } - if ($cnt) { - $who->reply ($npc, $cnt == 1 ? "Here is your pakage." : "Here are your packages."); - } else { - $who->reply ($npc, "Sorry, no deliverys for you sir."); + if ($cnt) { + $who->reply ($npc, $cnt == 1 ? "Here is your pakage." : "Here are your packages."); + } else { + $who->reply ($npc, "Sorry, no deliverys for you sir."); + } } } elsif ($cmd eq 'send') { @@ -213,27 +215,29 @@ return 1; } - my $storage = cf::map::find ("/planes/IPO_storage"); - unless ($storage) { - $who->reply ($npc, "Sorry, our package delivery service is currently in strike. Please come back later."); - return 1; - } + cf::async { + my $storage = cf::map::find ("/planes/IPO_storage"); + unless ($storage) { + $who->reply ($npc, "Sorry, our package delivery service is currently in strike. Please come back later."); + return 1; + } - my $cnt; - for ($who->inv) { - if ($_->name () =~ /^(bag|package|carton) T: \Q$arguments\E F: (\S+)$/) { - $_->name ("$1 F: $2 T: $arguments"); - $_->teleport ($storage, 2, 2); - $cnt++; + my $cnt; + for ($who->inv) { + if ($_->name () =~ /^(bag|package|carton) T: \Q$arguments\E F: (\S+)$/) { + $_->name ("$1 F: $2 T: $arguments"); + $_->teleport ($storage, 2, 2); + $cnt++; + } } - } - if ($cnt) { - $who->reply ($npc, $cnt == 1 ? "Package sent to $arguments." : "Sent $cnt packages to $arguments\n"); - CFMail::send_mail (1, $arguments, $who->name, "You got $cnt packages from " . $who->name); - notify_players ($arguments => 1); - } else { - $who->reply ($npc, "Sorry, found no package to send to $arguments."); + if ($cnt) { + $who->reply ($npc, $cnt == 1 ? "Package sent to $arguments." : "Sent $cnt packages to $arguments\n"); + CFMail::send_mail (1, $arguments, $who->name, "You got $cnt packages from " . $who->name); + notify_players ($arguments => 1); + } else { + $who->reply ($npc, "Sorry, found no package to send to $arguments."); + } } } else { @@ -260,7 +264,7 @@ use POSIX qw/strftime/; use CFDB; -my $MAILDB = CFDB->new (db_file => cf::localdir . "/crossfiremail"); +my $MAILDB = CFDB->new (db_file => "$LOCALDIR/crossfiremail"); sub get_mail { my ($toname) = @_;