--- deliantra/server/ext/commands.ext 2007/07/28 00:15:03 1.57 +++ deliantra/server/ext/commands.ext 2007/08/10 05:25:16 1.58 @@ -4,40 +4,6 @@ # miscellaneous commands -sub rename_to($$$) { - my ($ob, $from, $to) = @_; - - $to =~ /^[a-zA-Z0-9.,=#\/%$!^ ]*$/ - or return $ob->message ("rename: name must consist only of letters, digits, spaces and a few other things."); - - 127 >= length $to - or return $ob->message ("rename: new name must be <= 127 characters."); - - my $item; - - if (length $from) { - $item = $ob->find_best_object_match ($from) - or return $ob->message ("rename: could not find a matching item to rename."); - } else { - $item = $ob->find_marked_object - or return $ob->message ("rename: no from name and no marked item found to rename."); - } - - $item->custom_name (length $to ? $to : undef); - - if (length $to) { - $item->custom_name ($to); - $ob->message ("Your " . $item->base_name . " will now be called $to."); - } else { - $item->custom_name (undef); - $ob->message ("You stop calling your " . $item->base_name . " with weird names."); - } - - $ob->esrv_update_item (cf::UPD_NAME, $item); - - 1 -} - sub who_listing(;$$) { my ($privileged, $select) = @_; @@ -84,8 +50,6 @@ $ob->speed_left ($ob->speed_left - 4); $ob->reply (undef, (join "\n", who_listing $ob->may ("extended_who"), $arg), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE); - - 1 }; cf::register_command seen => sub { @@ -135,8 +99,6 @@ unless $ob->flag (cf::FLAG_USE_WEAPON); $ob->reply (undef, $reply); - - 1 }; cf::register_command mark => sub { @@ -157,8 +119,6 @@ ? (sprintf "%s %s * is marked.", $ob->name, $ob->title) : "You have no marked object."); } - - 1 }; for my $cmd ("run", "fire") { @@ -171,16 +131,12 @@ $ob->contr->$oncmd (1); $ob->move_player ($arg); - - 1 }; cf::register_command "${cmd}_stop" => sub { my ($ob) = @_; $ob->contr->$oncmd (0); - - 1 }; } @@ -196,8 +152,6 @@ (scalar $map->players), $map->difficulty, $map->width, $map->height, $map->enter_x, $map->enter_y, $map->timeout)) if $ob->flag (cf::FLAG_WIZ); $ob->reply (undef, $map->msg); - - 1 }; cf::register_command whereami => sub { @@ -205,8 +159,28 @@ my $reg = $ob->contr->observe->region; $ob->reply (undef, (sprintf "You are %s.\n%s", $reg->longname, $reg->msg)); +}; + +cf::register_command whereabouts => sub { + my ($ob, $arg) = @_; + + my %count; + + for my $pl (cf::player::list) { + ++$count{$pl->ob->region->longname}; + } + + my $msg = "In the world currently there are:\n\n" + . join "", map "$count{$_} player(s) in $_\n\n", sort keys %count; + + $ob->contr->ns->send_msg (log => $msg, cf::NDI_REPLY); +}; + +cf::register_command hiscore => sub { + my ($ob, $arg) = @_; - 1 + my $url = $cf::CFG->{hiscore_url}; + $ob->contr->ns->send_msg (log => "See $url", cf::NDI_REPLY); }; sub _set_mode($$$@) { @@ -228,32 +202,24 @@ my ($ob, $arg) = @_; _set_mode "applymode", $ob, $arg, unapply => qw(nochoice never always); - - 1 }; cf::register_command petmode => sub { my ($ob, $arg) = @_; _set_mode "petmode", $ob, $arg, petmode => qw(normal sad defend arena); - - 1 }; cf::register_command usekeys => sub { my ($ob, $arg) = @_; _set_mode "usekeys", $ob, $arg, usekeys => qw(inventory keyrings containers); - - 1 }; cf::register_command hintmode => sub { my ($ob, $arg) = @_; _set_mode "hintmode", $ob, $arg, hintmode => qw(show mark hide); - - 1 }; cf::register_command afk => sub { @@ -261,8 +227,6 @@ $ob->contr->ns->afk ($ob->contr->ns->afk ? 0 : 1); $ob->reply (undef, $ob->contr->ns->afk ? "You are now AFK" : "You are no longer AFK"); - - 1 }; cf::register_command sound => sub { @@ -270,8 +234,6 @@ $ob->contr->ns->sound ($ob->contr->ns->sound ? 0 : 1); $ob->reply (undef, $ob->contr->ns->sound ? "The sounds are enabled." : "Silence is golden..."); - - 1 }; cf::register_command brace => sub { @@ -279,8 +241,6 @@ $ob->contr->braced ($ob->contr->braced ? 0 : 1); $ob->reply (undef, $ob->contr->braced ? "You are braced." : "Not braced."); - - 1 }; cf::register_command 'output-rate' => sub { @@ -293,8 +253,6 @@ # maximum is 100k/s, this should be configurable $ob->contr->ns->max_rate ((List::Util::max 5000, List::Util::min 100000, $arg) * $cf::TICK); $ob->reply (undef, sprintf "Output rate now set to %dbps.", $ob->contr->ns->max_rate / $cf::TICK); - - 1 }; cf::register_command 'output-count' => sub { @@ -307,8 +265,6 @@ $ob->contr->outputs_count ($arg); $ob->reply (undef, "Output count now set to " . $ob->contr->outputs_count); - - 1 }; cf::register_command 'output-sync' => sub { @@ -321,8 +277,6 @@ $ob->contr->outputs_sync ($arg / $cf::TICK); $ob->reply (undef, sprintf "Output sync time now set to %.1fs", $ob->contr->outputs_sync * $cf::TICK); - - 1 }; # XXX: This has a bug. After one sets his wimpy level to 0 and resets it to @@ -339,8 +293,6 @@ if $arg =~ /^\d+$/ and $arg <= 100; $ob->reply (undef, "Incorrect parameters for wimpy: $arg"); - - 1 }; cf::register_command peaceful => sub { @@ -353,10 +305,42 @@ #$ob->contr->peaceful ($ob->contr->peaceful ? 0 : 1); #$ob->reply (undef, $ob->contr->peaceful ? "You will attack other players." : "You will not attack other players."); - - 1 }; +sub rename_to($$$) { + my ($ob, $from, $to) = @_; + + $to =~ /^[a-zA-Z0-9.,=#\/%$!^ ]*$/ + or return $ob->message ("rename: name must consist only of letters, digits, spaces and a few other things."); + + 127 >= length $to + or return $ob->message ("rename: new name must be <= 127 characters."); + + my $item; + + if (length $from) { + $item = $ob->find_best_object_match ($from) + or return $ob->message ("rename: could not find a matching item to rename."); + } else { + $item = $ob->find_marked_object + or return $ob->message ("rename: no from name and no marked item found to rename."); + } + + $item->custom_name (length $to ? $to : undef); + + if (length $to) { + $item->custom_name ($to); + $ob->message ("Your " . $item->base_name . " will now be called $to."); + } else { + $item->custom_name (undef); + $ob->message ("You stop calling your " . $item->base_name . " with weird names."); + } + + $ob->esrv_update_item (cf::UPD_NAME, $item); + + 1 +} + cf::register_command rename => sub { my ($ob, $arg) = @_; @@ -379,8 +363,6 @@ } else { $ob->reply (undef, 'Syntax error. Rename usage: rename ["oldname"] to "newname"'); } - - 1 }; cf::register_command uptime => sub { @@ -389,8 +371,6 @@ my $startup = POSIX::strftime "%Y-%m-%d %H:%M:%S %Z", localtime $cf::UPTIME; my $runtime = sprintf "%.1f", (time - $cf::UPTIME) / 86400; $ob->reply (undef, "server started $startup, uptime ${runtime}\d"); - - 1 }; my %IN_MEMORY = ( @@ -427,7 +407,5 @@ $map->visible_name), cf::NDI_BLACK | cf::NDI_UNIQUE); } - - 1 };