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.186 by root, Sat Jan 20 01:12:39 2007 UTC vs.
Revision 1.187 by root, Sat Jan 20 21:06:52 2007 UTC

1140 $rmp->{map_layout_style}, $rmp->{treasureoptions}, $rmp->{symmetry_used}, 1140 $rmp->{map_layout_style}, $rmp->{treasureoptions}, $rmp->{symmetry_used},
1141 (cf::region::find $rmp->{region}), $rmp->{custom} 1141 (cf::region::find $rmp->{region}), $rmp->{custom}
1142 ) 1142 )
1143} 1143}
1144 1144
1145=item cf::map->register ($regex, $prio)
1146
1147Register a handler for the map path matching the given regex at the
1148givne priority (higher is better, built-in handlers have priority 0, the
1149default).
1150
1151=cut
1152
1145sub register { 1153sub register {
1146 my (undef, $regex) = @_; 1154 my (undef, $regex, $prio) = @_;
1147 my $pkg = caller; 1155 my $pkg = caller;
1148 1156
1149 no strict; 1157 no strict;
1150 push @{"$pkg\::ISA"}, __PACKAGE__; 1158 push @{"$pkg\::ISA"}, __PACKAGE__;
1151 1159
1152 $EXT_MAP{$pkg} = qr<$regex>; 1160 $EXT_MAP{$pkg} = [$prio, qr<$regex>];
1153} 1161}
1154 1162
1155# also paths starting with '/' 1163# also paths starting with '/'
1156$EXT_MAP{"cf::map"} = qr{^(?=/)}; 1164$EXT_MAP{"cf::map"} = [0, qr{^(?=/)}];
1157 1165
1158sub thawer_merge { 1166sub thawer_merge {
1159 my ($self, $merge) = @_; 1167 my ($self, $merge) = @_;
1160 1168
1161 # we have to keep some variables in memory intact 1169 # we have to keep some variables in memory intact
1204 1212
1205 return $path if UNIVERSAL::isa $path, "cf::map"; # already a map object 1213 return $path if UNIVERSAL::isa $path, "cf::map"; # already a map object
1206 1214
1207 $path = normalise $path, $base; 1215 $path = normalise $path, $base;
1208 1216
1209 for my $pkg (keys %EXT_MAP) { 1217 for my $pkg (sort { $EXT_MAP{$b}[0] <=> $EXT_MAP{$a}[0] } keys %EXT_MAP) {
1210 if ($path =~ $EXT_MAP{$pkg}) { 1218 if ($path =~ $EXT_MAP{$pkg}[1]) {
1211 my $self = bless cf::map::new, $pkg; 1219 my $self = bless cf::map::new, $pkg;
1212 $self->{path} = $path; $self->path ($path); 1220 $self->{path} = $path; $self->path ($path);
1213 $self->init; # pass $1 etc. 1221 $self->init; # pass $1 etc.
1214 return $self; 1222 return $self;
1215 } 1223 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines