… | |
… | |
1210 | $map->instantiate; |
1210 | $map->instantiate; |
1211 | |
1211 | |
1212 | # per-player maps become, after loading, normal maps |
1212 | # per-player maps become, after loading, normal maps |
1213 | $map->per_player (0) if $path->{user_rel}; |
1213 | $map->per_player (0) if $path->{user_rel}; |
1214 | } |
1214 | } |
1215 | #Coro::Timer::sleep 1;#d# |
|
|
1216 | |
1215 | |
1217 | $map->path ($key); |
1216 | $map->path ($key); |
1218 | $map->{path} = $path; |
1217 | $map->{path} = $path; |
1219 | $map->{last_save} = $cf::RUNTIME; |
1218 | $map->{last_save} = $cf::RUNTIME; |
1220 | $map->last_access ($cf::RUNTIME); |
1219 | $map->last_access ($cf::RUNTIME); |
… | |
… | |
1914 | |
1913 | |
1915 | { |
1914 | { |
1916 | my $path = cf::localdir . "/database.pst"; |
1915 | my $path = cf::localdir . "/database.pst"; |
1917 | |
1916 | |
1918 | sub db_load() { |
1917 | sub db_load() { |
1919 | warn "loading database $path\n";#d# remove later |
|
|
1920 | $DB = stat $path ? Storable::retrieve $path : { }; |
1918 | $DB = stat $path ? Storable::retrieve $path : { }; |
1921 | } |
1919 | } |
1922 | |
1920 | |
1923 | my $pid; |
1921 | my $pid; |
1924 | |
1922 | |
1925 | sub db_save() { |
1923 | sub db_save() { |
1926 | warn "saving database $path\n";#d# remove later |
|
|
1927 | waitpid $pid, 0 if $pid; |
1924 | waitpid $pid, 0 if $pid; |
1928 | if (0 == ($pid = fork)) { |
1925 | if (0 == ($pid = fork)) { |
1929 | $DB->{_meta}{version} = 1; |
1926 | $DB->{_meta}{version} = 1; |
1930 | Storable::nstore $DB, "$path~"; |
1927 | Storable::nstore $DB, "$path~"; |
1931 | rename "$path~", $path; |
1928 | rename "$path~", $path; |