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.157 by root, Wed Jan 10 01:16:54 2007 UTC vs.
Revision 1.158 by root, Wed Jan 10 19:52:43 2007 UTC

367 367
368############################################################################# 368#############################################################################
369 369
370package cf::path; 370package cf::path;
371 371
372use overload
373 '""' => \&as_string;
374
372# used to convert map paths into valid unix filenames by repalcing / by ∕ 375# used to convert map paths into valid unix filenames by repalcing / by ∕
373our $PATH_SEP = "∕"; # U+2215, chosen purely for visual reasons 376our $PATH_SEP = "∕"; # U+2215, chosen purely for visual reasons
374 377
375sub new { 378sub new {
376 my ($class, $path, $base) = @_; 379 my ($class, $path, $base) = @_;
384 # ?random/... random maps 387 # ?random/... random maps
385 # /! non-realised random map exit 388 # /! non-realised random map exit
386 # /... normal maps 389 # /... normal maps
387 # ~/... per-player maps without a specific player (DO NOT USE) 390 # ~/... per-player maps without a specific player (DO NOT USE)
388 # ~user/... per-player map of a specific user 391 # ~user/... per-player map of a specific user
392
393 $path =~ s/$PATH_SEP/\//go;
389 394
390 if ($path =~ /^{/) { 395 if ($path =~ /^{/) {
391 # fine as it is 396 # fine as it is
392 } elsif ($path =~ s{^\?random/}{}) { 397 } elsif ($path =~ s{^\?random/}{}) {
393 Coro::AIO::aio_load "$cf::RANDOM_MAPS/$path.meta", my $data; 398 Coro::AIO::aio_load "$cf::RANDOM_MAPS/$path.meta", my $data;
1240 my @paths; 1245 my @paths;
1241 1246
1242 for (@$files) { 1247 for (@$files) {
1243 utf8::decode $_; 1248 utf8::decode $_;
1244 next if /\.(?:pl|pst)$/; 1249 next if /\.(?:pl|pst)$/;
1245 next unless /^$PATH_SEP/; 1250 next unless /^$PATH_SEP/o;
1246 1251
1247 s/$PATH_SEP/\//g;
1248 push @paths, new cf::path "~" . $pl->ob->name . "/" . $_; 1252 push @paths, new cf::path "~" . $pl->ob->name . "/" . $_;
1249 } 1253 }
1250 1254
1251 \@paths 1255 \@paths
1252} 1256}
1632 } 1636 }
1633 1637
1634 $map 1638 $map
1635} 1639}
1636 1640
1641=item cf::map::unique_maps
1642
1643Returns an arrayref of cf::path's of all shared maps that have
1644instantiated unique items. May block.
1645
1646=cut
1647
1648sub unique_maps() {
1649 my $files = aio_readdir cf::localdir . "/" . cf::uniquedir
1650 or return;
1651
1652 my @paths;
1653
1654 for (@$files) {
1655 utf8::decode $_;
1656 next if /\.pst$/;
1657 next unless /^$PATH_SEP/o;
1658
1659 push @paths, new cf::path $_;
1660 }
1661
1662 \@paths
1663}
1664
1637package cf; 1665package cf;
1638 1666
1639=back 1667=back
1640 1668
1641=head3 cf::object 1669=head3 cf::object
1810 1838
1811sub cf::object::player::goto { 1839sub cf::object::player::goto {
1812 my ($self, $path, $x, $y) = @_; 1840 my ($self, $path, $x, $y) = @_;
1813 1841
1814 $path = new cf::path $path; 1842 $path = new cf::path $path;
1815 $path ne "/" or Carp::cluck ("oy");#d#
1816 1843
1817 $self->enter_link; 1844 $self->enter_link;
1818 1845
1819 (async { 1846 (async {
1820 my $map = cf::map::find $path->as_string; 1847 my $map = cf::map::find $path->as_string;
1897 1924
1898 1; 1925 1;
1899 }) { 1926 }) {
1900 $self->message ("Something went wrong deep within the crossfire server. " 1927 $self->message ("Something went wrong deep within the crossfire server. "
1901 . "I'll try to bring you back to the map you were before. " 1928 . "I'll try to bring you back to the map you were before. "
1902 . "Please report this to the dungeon master", 1929 . "Please report this to the dungeon master!",
1903 cf::NDI_UNIQUE | cf::NDI_RED); 1930 cf::NDI_UNIQUE | cf::NDI_RED);
1904 1931
1905 warn "ERROR in enter_exit: $@"; 1932 warn "ERROR in enter_exit: $@";
1906 $self->leave_link; 1933 $self->leave_link;
1907 } 1934 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines