--- deliantra/server/ext/map-per-player.ext 2007/01/13 23:06:13 1.1 +++ deliantra/server/ext/map-per-player.ext 2007/06/11 21:38:13 1.11 @@ -1,28 +1,50 @@ -#! perl # MANDATORY +#! perl # mandatory -cf::map->register (qr{^~[^/]+/}); +cf::map->register (qr{^~([^/]+)(/.*)}); sub init { my ($self) = @_; - $self->{user} = $1; + $self->{user} = $1; + $self->{orig_path} = $2; } -sub as_string { +sub thawer_merge { + # we have to keep some variables in memory intact + local $_[0]{user}; + local $_[0]{orig_path}; + + $_[0]->SUPER::thawer_merge ($_[1]); +} + +sub load_path { my ($self) = @_; - "~$self->{user}$self->{path}" + "$cf::MAPDIR/$self->{orig_path}.map" } sub save_path { my ($self) = @_; - sprintf "%s/%s/%s/%s", cf::localdir, cf::playerdir, $self->{user}, $self->_escaped_path + (my $path = $_[0]{orig_path}) =~ s/\//$PATH_SEP/g; + "$cf::PLAYERDIR/$self->{user}/$path.map" } sub uniq_path { undef } +sub load_header { + my ($self) = @_; + + $self->SUPER::load_header + or return; + + # forcefully disable per_player flag + $self->per_player (0); + + 1 +} + 1