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.192 by root, Wed Jan 24 01:43:01 2007 UTC vs.
Revision 1.196 by root, Sat Jan 27 23:59:29 2007 UTC

8use Storable; 8use Storable;
9use Opcode; 9use Opcode;
10use Safe; 10use Safe;
11use Safe::Hole; 11use Safe::Hole;
12 12
13use Coro 3.4 (); 13use Coro 3.5 ();
14use Coro::Event; 14use Coro::Event;
15use Coro::Timer; 15use Coro::Timer;
16use Coro::Signal; 16use Coro::Signal;
17use Coro::Semaphore; 17use Coro::Semaphore;
18use Coro::AIO; 18use Coro::AIO;
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}
1748 return if UNIVERSAL::isa $self->map, "ext::map_link"; 1750 return if UNIVERSAL::isa $self->map, "ext::map_link";
1749 1751
1750 $self->{_link_pos} ||= [$self->map->{path}, $self->x, $self->y] 1752 $self->{_link_pos} ||= [$self->map->{path}, $self->x, $self->y]
1751 if $self->map; 1753 if $self->map;
1752 1754
1753 $self->enter_map ($LINK_MAP || link_map, 20, 20); 1755 $self->enter_map ($LINK_MAP || link_map, 10, 10);
1754} 1756}
1755 1757
1756sub cf::object::player::leave_link { 1758sub cf::object::player::leave_link {
1757 my ($self, $map, $x, $y) = @_; 1759 my ($self, $map, $x, $y) = @_;
1758 1760
1899sub cf::object::player::enter_exit { 1901sub cf::object::player::enter_exit {
1900 my ($self, $exit) = @_; 1902 my ($self, $exit) = @_;
1901 1903
1902 return unless $self->type == cf::PLAYER; 1904 return unless $self->type == cf::PLAYER;
1903 1905
1906 if ($exit->slaying eq "/!") {
1907 #TODO: this should de-fi-ni-te-ly not be a sync-job
1908 cf::sync_job { prepare_random_map $exit };
1909 }
1910
1911 my $slaying = cf::map::normalise $exit->slaying, $exit->map && $exit->map->path;
1912 my $hp = $exit->stats->hp;
1913 my $sp = $exit->stats->sp;
1914
1904 $self->enter_link; 1915 $self->enter_link;
1905 1916
1906 (async { 1917 (async {
1907 $self->deactivate_recursive; # just to be sure 1918 $self->deactivate_recursive; # just to be sure
1908 unless (eval { 1919 unless (eval {
1909 prepare_random_map $exit 1920 $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 1921
1915 1; 1922 1;
1916 }) { 1923 }) {
1917 $self->message ("Something went wrong deep within the crossfire server. " 1924 $self->message ("Something went wrong deep within the crossfire server. "
1918 . "I'll try to bring you back to the map you were before. " 1925 . "I'll try to bring you back to the map you were before. "

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines