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.194 by root, Wed Jan 24 22:42:49 2007 UTC vs.
Revision 1.198 by root, Sun Jan 28 01:58:37 2007 UTC

1362 $map->{last_save} = $cf::RUNTIME; 1362 $map->{last_save} = $cf::RUNTIME;
1363 1363
1364 $map->load_header 1364 $map->load_header
1365 or return; 1365 or return;
1366 1366
1367 if ($map->should_reset) { 1367 if ($map->should_reset && 0) {#d#TODO# disabled, crashy (locking issue?)
1368 # doing this can freeze the server in a sync job, obviously 1368 # doing this can freeze the server in a sync job, obviously
1369 #$cf::WAIT_FOR_TICK->wait; 1369 #$cf::WAIT_FOR_TICK->wait;
1370 $map->reset; 1370 $map->reset;
1371 undef $guard; 1371 undef $guard;
1372 return find $path; 1372 return find $path;
1379sub pre_load { } 1379sub pre_load { }
1380sub post_load { } 1380sub post_load { }
1381 1381
1382sub load { 1382sub load {
1383 my ($self) = @_; 1383 my ($self) = @_;
1384
1385 local $self->{deny_reset} = 1; # loading can take a long time
1384 1386
1385 my $path = $self->{path}; 1387 my $path = $self->{path};
1386 my $guard = cf::lock_acquire "map_load:$path"; 1388 my $guard = cf::lock_acquire "map_load:$path";
1387 1389
1388 return if $self->in_memory != cf::MAP_SWAPPED; 1390 return if $self->in_memory != cf::MAP_SWAPPED;
1731=cut 1733=cut
1732 1734
1733sub link_map { 1735sub link_map {
1734 unless ($LINK_MAP) { 1736 unless ($LINK_MAP) {
1735 $LINK_MAP = cf::map::find "{link}" 1737 $LINK_MAP = cf::map::find "{link}"
1736 or do { warn "FATAL: unable to provide {link} map, exiting."; exit 1 }; 1738 or cf::cleanup "FATAL: unable to provide {link} map, exiting.";
1737 $LINK_MAP->load; 1739 $LINK_MAP->load;
1738 } 1740 }
1739 1741
1740 $LINK_MAP 1742 $LINK_MAP
1741} 1743}
1825 my ($self, $path, $x, $y) = @_; 1827 my ($self, $path, $x, $y) = @_;
1826 1828
1827 $self->enter_link; 1829 $self->enter_link;
1828 1830
1829 (async { 1831 (async {
1832 my $map = eval {
1830 my $map = cf::map::find $path; 1833 my $map = cf::map::find $path;
1831 $map = $map->customise_for ($self) if $map; 1834 $map = $map->customise_for ($self) if $map;
1832 1835 $map
1833# warn "entering ", $map->path, " at ($x, $y)\n" 1836 } or
1834# if $map;
1835
1836 $map or $self->message ("The exit to '" . ($path->visible_name) . "' is closed", cf::NDI_UNIQUE | cf::NDI_RED); 1837 $self->message ("The exit to '$path' is closed", cf::NDI_UNIQUE | cf::NDI_RED);
1837 1838
1838 $self->leave_link ($map, $x, $y); 1839 $self->leave_link ($map, $x, $y);
1839 })->prio (1); 1840 })->prio (1);
1840} 1841}
1841 1842
1872 # that depends on the exit object 1873 # that depends on the exit object
1873 1874
1874 my $rmp = parse_random_map_params $exit->msg; 1875 my $rmp = parse_random_map_params $exit->msg;
1875 1876
1876 if ($exit->map) { 1877 if ($exit->map) {
1877 $rmp->{region} = $exit->map->region_name; 1878 $rmp->{region} = $exit->region->name;
1878 $rmp->{origin_map} = $exit->map->path; 1879 $rmp->{origin_map} = $exit->map->path;
1879 $rmp->{origin_x} = $exit->x; 1880 $rmp->{origin_x} = $exit->x;
1880 $rmp->{origin_y} = $exit->y; 1881 $rmp->{origin_y} = $exit->y;
1881 } 1882 }
1882 1883
1899sub cf::object::player::enter_exit { 1900sub cf::object::player::enter_exit {
1900 my ($self, $exit) = @_; 1901 my ($self, $exit) = @_;
1901 1902
1902 return unless $self->type == cf::PLAYER; 1903 return unless $self->type == cf::PLAYER;
1903 1904
1905 if ($exit->slaying eq "/!") {
1906 #TODO: this should de-fi-ni-te-ly not be a sync-job
1907 cf::sync_job { prepare_random_map $exit };
1908 }
1909
1910 my $slaying = cf::map::normalise $exit->slaying, $exit->map && $exit->map->path;
1911 my $hp = $exit->stats->hp;
1912 my $sp = $exit->stats->sp;
1913
1904 $self->enter_link; 1914 $self->enter_link;
1905 1915
1906 (async { 1916 (async {
1907 $self->deactivate_recursive; # just to be sure 1917 $self->deactivate_recursive; # just to be sure
1908 unless (eval { 1918 unless (eval {
1909 prepare_random_map $exit 1919 $self->goto ($slaying, $hp, $sp);
1910 if $exit->slaying eq "/!";
1911
1912 my $path = new_from_path cf::map $exit->slaying, $exit->map && $exit->map->path;
1913 $self->goto ($path, $exit->stats->hp, $exit->stats->sp);
1914 1920
1915 1; 1921 1;
1916 }) { 1922 }) {
1917 $self->message ("Something went wrong deep within the crossfire server. " 1923 $self->message ("Something went wrong deep within the crossfire server. "
1918 . "I'll try to bring you back to the map you were before. " 1924 . "I'll try to bring you back to the map you were before. "

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines