ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/map-world.ext
(Generate patch)

Comparing deliantra/server/ext/map-world.ext (file contents):
Revision 1.43 by root, Sat Apr 23 04:46:26 2011 UTC vs.
Revision 1.46 by root, Sun May 8 21:51:26 2011 UTC

1#! perl # mandatory 1#! perl # mandatory
2 2
3# manages the worldmap by directing to other handlers 3# manages the worldmap by directing to other handlers
4 4
5cf::map->register (qr{^/world/world_(-?\d+)_(-?\d+)(?:_(-?\d+))?$}, 100); 5cf::map->register (qr{^/world/world_(-?\d+)_(-?\d+)(?:([+\-]\d+))?$}, 100);
6 6
7# universal 7# universal
8our $TILE_W = 50; 8our $TILE_W = 50;
9our $TILE_H = 50; 9our $TILE_H = 50;
10 10
35} 35}
36 36
37sub format_xyz($$;$) { 37sub format_xyz($$;$) {
38 sprintf "/world/world_%03d_%03d%s", 38 sprintf "/world/world_%03d_%03d%s",
39 $_[0], $_[1], 39 $_[0], $_[1],
40 $_[2] ? sprintf "_%03d", $_[2] : ""; 40 $_[2] ? sprintf "%+04d", $_[2] : "";
41} 41}
42 42
43############################################################################# 43#############################################################################
44 44
45sub init { 45sub init {
59 59
60 bless $self, $meta->{pkg}; 60 bless $self, $meta->{pkg};
61 61
62 $self->init_worldmap ($meta); 62 $self->init_worldmap ($meta);
63 63
64 last; 64 goto done;
65 } 65 }
66
67 } 66 }
68 67
68 bless $self, ext::map_world::empty::;
69
70done:
69 $self->SUPER::init; 71 $self->SUPER::init;
70} 72}
71 73
72sub init_worldmap { 74sub init_worldmap {
73 # only for handlers 75 # only for handlers
85 $self->msg ("worldmap dynamically created by map-world extension"); 87 $self->msg ("worldmap dynamically created by map-world extension");
86 $self->outdoor ($self->{z} >= 0); 88 $self->outdoor ($self->{z} >= 0);
87 $self->default_region (cf::region::find "wilderness"); 89 $self->default_region (cf::region::find "wilderness");
88 90
89 # all possible worldmap tiles also exist 91 # all possible worldmap tiles also exist
90 $self->tile_path (0, format_xyz $x, $y - 1, $z); 92 $self->tile_path (cf::TILE_NORTH, format_xyz $x, $y - 1, $z);
91 $self->tile_path (1, format_xyz $x + 1, $y, $z);
92 $self->tile_path (2, format_xyz $x, $y + 1, $z); 93 $self->tile_path (cf::TILE_SOUTH, format_xyz $x, $y + 1, $z);
94 $self->tile_path (cf::TILE_EAST , format_xyz $x + 1, $y, $z);
93 $self->tile_path (3, format_xyz $x - 1, $y, $z); 95 $self->tile_path (cf::TILE_WEST , format_xyz $x - 1, $y, $z);
94 $self->tile_path (4, format_xyz $x, $y, $z + 1); 96 $self->tile_path (cf::TILE_UP , format_xyz $x, $y, $z + 1);
95 $self->tile_path (5, format_xyz $x, $y, $z - 1); 97 $self->tile_path (cf::TILE_DOWN , format_xyz $x, $y, $z - 1);
96 98
97 # an overlay always wins 99 # an overlay always wins
98 my $overlay = sprintf "%s/%s.map", $cf::MAPDIR, format_xyz $x, $y, $z; 100 my $overlay = sprintf "%s/%s.map", $cf::MAPDIR, format_xyz $x, $y, $z;
99 101
100 $self->{load_path} = $overlay 102 $self->{load_path} = $overlay
130# warn "fill $self\n";#d# 132# warn "fill $self\n";#d#
131# my $guard = cf::lock_acquire "map_data:$self->{path}"; 133# my $guard = cf::lock_acquire "map_data:$self->{path}";
132# 134#
133# $self->alloc; 135# $self->alloc;
134# $self->fill; 136# $self->fill;
135# $self->in_memory (cf::MAP_ACTIVE); 137# $self->state (cf::MAP_ACTIVE);
136# $self->activate; 138# $self->activate;
137# $self->post_load; 139# $self->post_load;
138# } 140# }
139#} 141#}
140 142
144 146
145 $self->create_region_treasure 147 $self->create_region_treasure
146 if delete $self->{need_create_treasure}; 148 if delete $self->{need_create_treasure};
147} 149}
148 150
151package ext::map_world::empty;
152
153our @ISA = ext::map_world::;
154
155sub post_load_original {
156 $_[0]->fill;
157}
158

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines