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.344 by root, Mon Aug 27 02:43:38 2007 UTC vs.
Revision 1.346 by root, Tue Aug 28 19:38:40 2007 UTC

575 if (1) { 575 if (1) {
576 $md5 = 576 $md5 =
577 join "\x00", 577 join "\x00",
578 $processversion, 578 $processversion,
579 map { 579 map {
580 Coro::cede; 580 cf::cede_to_tick;
581 ($src->[$_], Digest::MD5::md5_hex $data[$_]) 581 ($src->[$_], Digest::MD5::md5_hex $data[$_])
582 } 0.. $#$src; 582 } 0.. $#$src;
583 583
584 584
585 my $dbmd5 = db_get cache => "$id/md5"; 585 my $dbmd5 = db_get cache => "$id/md5";
1322 1322
1323 aio_mkdir playerdir $pl, 0770; 1323 aio_mkdir playerdir $pl, 0770;
1324 $pl->{last_save} = $cf::RUNTIME; 1324 $pl->{last_save} = $cf::RUNTIME;
1325 1325
1326 $pl->save_pl ($path); 1326 $pl->save_pl ($path);
1327 Coro::cede; 1327 cf::cede_to_tick;
1328} 1328}
1329 1329
1330sub new($) { 1330sub new($) {
1331 my ($login) = @_; 1331 my ($login) = @_;
1332 1332
1849 local $self->{deny_reset} = 1; # loading can take a long time 1849 local $self->{deny_reset} = 1; # loading can take a long time
1850 1850
1851 my $path = $self->{path}; 1851 my $path = $self->{path};
1852 1852
1853 { 1853 {
1854 my $guard1 = cf::lock_acquire "map_data:$path";
1854 my $guard = cf::lock_acquire "map_load:$path"; 1855 my $guard2 = cf::lock_acquire "map_load:$path";
1855 1856
1856 return if $self->in_memory != cf::MAP_SWAPPED; 1857 return if $self->in_memory != cf::MAP_SWAPPED;
1857 1858
1858 $self->in_memory (cf::MAP_LOADING); 1859 $self->in_memory (cf::MAP_LOADING);
1859 1860
1860 $self->alloc; 1861 $self->alloc;
1861 1862
1862 $self->pre_load; 1863 $self->pre_load;
1863 Coro::cede; 1864 cf::cede_to_tick;
1864 1865
1865 $self->_load_objects ($self->{load_path}, 1) 1866 $self->_load_objects ($self->{load_path}, 1)
1866 or return; 1867 or return;
1867 1868
1868 $self->set_object_flag (cf::FLAG_OBJ_ORIGINAL, 1) 1869 $self->set_object_flag (cf::FLAG_OBJ_ORIGINAL, 1)
1874 $self->clear_unique_items; 1875 $self->clear_unique_items;
1875 $self->_load_objects ($uniq, 0); 1876 $self->_load_objects ($uniq, 0);
1876 } 1877 }
1877 } 1878 }
1878 1879
1879 Coro::cede; 1880 cf::cede_to_tick;
1880 # now do the right thing for maps 1881 # now do the right thing for maps
1881 $self->link_multipart_objects; 1882 $self->link_multipart_objects;
1882 $self->difficulty ($self->estimate_difficulty) 1883 $self->difficulty ($self->estimate_difficulty)
1883 unless $self->difficulty; 1884 unless $self->difficulty;
1884 Coro::cede; 1885 cf::cede_to_tick;
1885 1886
1886 unless ($self->{deny_activate}) { 1887 unless ($self->{deny_activate}) {
1887 $self->decay_objects; 1888 $self->decay_objects;
1888 $self->fix_auto_apply; 1889 $self->fix_auto_apply;
1889 $self->update_buttons; 1890 $self->update_buttons;
1890 Coro::cede; 1891 cf::cede_to_tick;
1891 $self->set_darkness_map; 1892 $self->set_darkness_map;
1892 Coro::cede; 1893 cf::cede_to_tick;
1893 $self->activate; 1894 $self->activate;
1894 } 1895 }
1895 1896
1896 $self->{last_save} = $cf::RUNTIME; 1897 $self->{last_save} = $cf::RUNTIME;
1897 $self->last_access ($cf::RUNTIME); 1898 $self->last_access ($cf::RUNTIME);
1987} 1988}
1988 1989
1989sub save { 1990sub save {
1990 my ($self) = @_; 1991 my ($self) = @_;
1991 1992
1992 my $lock = cf::lock_acquire "map_data:" . $self->path; 1993 my $lock = cf::lock_acquire "map_data:$self->{path}";
1993 1994
1994 $self->{last_save} = $cf::RUNTIME; 1995 $self->{last_save} = $cf::RUNTIME;
1995 1996
1996 return unless $self->dirty; 1997 return unless $self->dirty;
1997 1998
2020 my ($self) = @_; 2021 my ($self) = @_;
2021 2022
2022 # save first because save cedes 2023 # save first because save cedes
2023 $self->save; 2024 $self->save;
2024 2025
2025 my $lock = cf::lock_acquire "map_data:" . $self->path; 2026 my $lock = cf::lock_acquire "map_data:$self->{path}";
2026 2027
2027 return if $self->players; 2028 return if $self->players;
2028 return if $self->in_memory != cf::MAP_IN_MEMORY; 2029 return if $self->in_memory != cf::MAP_IN_MEMORY;
2029 return if $self->{deny_save}; 2030 return if $self->{deny_save};
2030 2031
2997 2998
2998sub init { 2999sub init {
2999 reload_resources; 3000 reload_resources;
3000} 3001}
3001 3002
3002sub cfg_load { 3003sub reload_config {
3003 open my $fh, "<:utf8", "$CONFDIR/config" 3004 open my $fh, "<:utf8", "$CONFDIR/config"
3004 or return; 3005 or return;
3005 3006
3006 local $/; 3007 local $/;
3007 *CFG = YAML::Syck::Load <$fh>; 3008 *CFG = YAML::Syck::Load <$fh>;
3027 (async { 3028 (async {
3028 Event::one_event; 3029 Event::one_event;
3029 })->prio (Coro::PRIO_MAX); 3030 })->prio (Coro::PRIO_MAX);
3030 }; 3031 };
3031 3032
3032 cfg_load; 3033 reload_config;
3033 db_init; 3034 db_init;
3034 load_extensions; 3035 load_extensions;
3035 3036
3036 $TICK_WATCHER->start; 3037 $TICK_WATCHER->start;
3037 Event::loop; 3038 Event::loop;
3230 warn "reloading cf.pm"; 3231 warn "reloading cf.pm";
3231 require cf; 3232 require cf;
3232 cf::_connect_to_perl; # nominally unnecessary, but cannot hurt 3233 cf::_connect_to_perl; # nominally unnecessary, but cannot hurt
3233 3234
3234 warn "loading config and database again"; 3235 warn "loading config and database again";
3235 cf::cfg_load; 3236 cf::reload_config;
3236 3237
3237 warn "loading extensions"; 3238 warn "loading extensions";
3238 cf::load_extensions; 3239 cf::load_extensions;
3239 3240
3240 warn "reattaching attachments to objects/players"; 3241 warn "reattaching attachments to objects/players";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines