… | |
… | |
281 | my ($class, $path, $base) = @_; |
281 | my ($class, $path, $base) = @_; |
282 | |
282 | |
283 | my $self = bless { }, $class; |
283 | my $self = bless { }, $class; |
284 | |
284 | |
285 | if ($path =~ s{^\?random/}{}) { |
285 | if ($path =~ s{^\?random/}{}) { |
|
|
286 | Coro::AIO::aio_load "$cf::RANDOM_MAPS/$path.meta", my $data; |
286 | $self->{random} = cf::from_json $path; |
287 | $self->{random} = cf::from_json $data; |
287 | } else { |
288 | } else { |
288 | if ($path =~ s{^~([^/]+)?}{}) { |
289 | if ($path =~ s{^~([^/]+)?}{}) { |
289 | $self->{user_rel} = 1; |
290 | $self->{user_rel} = 1; |
290 | |
291 | |
291 | if (defined $1) { |
292 | if (defined $1) { |
… | |
… | |
324 | |
325 | |
325 | # the displayed name, this is a one way mapping |
326 | # the displayed name, this is a one way mapping |
326 | sub visible_name { |
327 | sub visible_name { |
327 | my ($self) = @_; |
328 | my ($self) = @_; |
328 | |
329 | |
329 | $self->{random} ? "?random/$self->{random}{origin_map}+$self->{random}{origin_x}+$self->{random}{origin_y}/$self->{random}{dungeon_level}" |
330 | # if (my $rmp = $self->{random}) { |
330 | : $self->as_string |
331 | # # todo: be more intelligent about this |
|
|
332 | # "?random/$rmp->{origin_map}+$rmp->{origin_x}+$rmp->{origin_y}/$rmp->{dungeon_level}" |
|
|
333 | # } else { |
|
|
334 | $self->as_string |
|
|
335 | # } |
331 | } |
336 | } |
332 | |
337 | |
333 | # escape the /'s in the path |
338 | # escape the /'s in the path |
334 | sub _escaped_path { |
339 | sub _escaped_path { |
335 | # ∕ is U+2215 |
340 | # ∕ is U+2215 |
… | |
… | |
347 | # the temporary/swap location |
352 | # the temporary/swap location |
348 | sub save_path { |
353 | sub save_path { |
349 | my ($self) = @_; |
354 | my ($self) = @_; |
350 | |
355 | |
351 | $self->{user_rel} ? sprintf "%s/%s/%s/%s", cf::localdir, cf::playerdir, $self->{user}, $self->_escaped_path |
356 | $self->{user_rel} ? sprintf "%s/%s/%s/%s", cf::localdir, cf::playerdir, $self->{user}, $self->_escaped_path |
352 | : $self->{random} ? sprintf "%s/%s", $RANDOM_MAPS, Digest::MD5::md5_hex $self->{path} |
357 | : $self->{random} ? sprintf "%s/%s", $RANDOM_MAPS, $self->{path} |
353 | : sprintf "%s/%s/%s", cf::localdir, cf::tmpdir, $self->_escaped_path |
358 | : sprintf "%s/%s/%s", cf::localdir, cf::tmpdir, $self->_escaped_path |
354 | } |
359 | } |
355 | |
360 | |
356 | # the unique path, might be eq to save_path |
361 | # the unique path, might be eq to save_path |
357 | sub uniq_path { |
362 | sub uniq_path { |