ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/map-per-player.ext
Revision: 1.4
Committed: Sun Jan 14 02:00:36 2007 UTC (17 years, 4 months ago) by root
Branch: MAIN
Changes since 1.3: +9 -0 lines
Log Message:
- introduce cf::attachable::thawer_merge, allowing classes
  to overwrite what happens when two objects get merged.
- protect some extension data with it
- make unlink_save blocking, so we do not get needless reset loops
  because of slow disk response.

File Contents

# Content
1 #! perl # MANDATORY
2
3 cf::map->register (qr{^~([^/]+)(/.*)});
4
5 sub init {
6 my ($self) = @_;
7
8 $self->{user} = $1;
9 $self->{orig_path} = $2;
10 $self->{deny_reset} = 1; #d# for now
11 }
12
13 sub thawer_merge {
14 # we have to keep some variables in memory intact
15 local $_[0]{user};
16 local $_[0]{orig_path};
17 local $_[0]{deny_reset};
18
19 $_[0]->SUPER::thawer_merge ($_[1]);
20 }
21
22 sub load_path {
23 my ($self) = @_;
24
25 sprintf "%s/%s/%s", cf::datadir, cf::mapdir, $self->{orig_path}
26 }
27
28 sub save_path {
29 my ($self) = @_;
30
31 (my $path = $_[0]{orig_path}) =~ s/\//$PATH_SEP/g;
32 sprintf "%s/%s/%s/%s", cf::localdir, cf::playerdir, $self->{user}, $path
33 }
34
35 sub uniq_path {
36 undef
37 }
38
39 sub load_header {
40 my ($self) = @_;
41
42 $self->SUPER::load_header
43 or return;
44
45 # forcefully disable per_player flag
46 $self->per_player (0);
47
48 1
49 }
50
51 1
52