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.120 by root, Tue Jan 2 11:08:36 2007 UTC vs.
Revision 1.126 by root, Tue Jan 2 23:12:47 2007 UTC

1153# and all this just because we cannot iterate over 1153# and all this just because we cannot iterate over
1154# all maps in C++... 1154# all maps in C++...
1155sub change_all_map_light { 1155sub change_all_map_light {
1156 my ($change) = @_; 1156 my ($change) = @_;
1157 1157
1158 $_->change_map_light ($change) for values %cf::MAP; 1158 $_->change_map_light ($change)
1159 for grep $_->outdoor, values %cf::MAP;
1159} 1160}
1160 1161
1161sub try_load_header($) { 1162sub try_load_header($) {
1162 my ($path) = @_; 1163 my ($path) = @_;
1163 1164
1174 $map->{load_path} = $path; 1175 $map->{load_path} = $path;
1175 1176
1176 $map 1177 $map
1177} 1178}
1178 1179
1180sub find_map;
1179sub find_map { 1181sub find_map {
1180 my ($path, $origin) = @_; 1182 my ($path, $origin) = @_;
1181 1183
1182 #warn "find_map<$path,$origin>\n";#d# 1184 #warn "find_map<$path,$origin>\n";#d#
1183 1185
1210 $map->instantiate; 1212 $map->instantiate;
1211 1213
1212 # per-player maps become, after loading, normal maps 1214 # per-player maps become, after loading, normal maps
1213 $map->per_player (0) if $path->{user_rel}; 1215 $map->per_player (0) if $path->{user_rel};
1214 } 1216 }
1215 #Coro::Timer::sleep 1;#d#
1216 1217
1217 $map->path ($key); 1218 $map->path ($key);
1218 $map->{path} = $path; 1219 $map->{path} = $path;
1219 $map->{last_save} = $cf::RUNTIME; 1220 $map->{last_save} = $cf::RUNTIME;
1220 $map->last_access ($cf::RUNTIME); 1221 $map->last_access ($cf::RUNTIME);
1221 1222
1222 if ($map->should_reset) { 1223 if ($map->should_reset) {
1223 $map->reset; 1224 $map->reset;
1225 undef $guard;
1224 $map = find_map $path; 1226 $map = find_map $path
1227 or return;
1225 } 1228 }
1226 1229
1227 $cf::MAP{$key} = $map 1230 $cf::MAP{$key} = $map
1228 } 1231 }
1229} 1232}
1914 1917
1915{ 1918{
1916 my $path = cf::localdir . "/database.pst"; 1919 my $path = cf::localdir . "/database.pst";
1917 1920
1918 sub db_load() { 1921 sub db_load() {
1919 warn "loading database $path\n";#d# remove later
1920 $DB = stat $path ? Storable::retrieve $path : { }; 1922 $DB = stat $path ? Storable::retrieve $path : { };
1921 } 1923 }
1922 1924
1923 my $pid; 1925 my $pid;
1924 1926
1925 sub db_save() { 1927 sub db_save() {
1926 warn "saving database $path\n";#d# remove later
1927 waitpid $pid, 0 if $pid; 1928 waitpid $pid, 0 if $pid;
1928 if (0 == ($pid = fork)) { 1929 if (0 == ($pid = fork)) {
1929 $DB->{_meta}{version} = 1; 1930 $DB->{_meta}{version} = 1;
1930 Storable::nstore $DB, "$path~"; 1931 Storable::nstore $DB, "$path~";
1931 rename "$path~", $path; 1932 rename "$path~", $path;
2191 or warn "ERROR: unable to write runtime file: $!"; 2192 or warn "ERROR: unable to write runtime file: $!";
2192 })->(); 2193 })->();
2193 }, 2194 },
2194); 2195);
2195 2196
2197END { cf::emergency_save }
2198
21961 21991
2197 2200

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines