… | |
… | |
90 | } |
90 | } |
91 | |
91 | |
92 | sub prepare_random_map { |
92 | sub prepare_random_map { |
93 | my ($exit) = @_; |
93 | my ($exit) = @_; |
94 | |
94 | |
95 | # all this does is basically rpelace the /! path by |
95 | # all this does is basically replace the /! path by |
96 | # a new random map path (?random/...) with a seed |
96 | # a new random map path (?random/...) with a seed |
97 | # that depends on the exit object |
97 | # that depends on the exit object |
98 | |
98 | |
99 | my $rmp = parse_random_map_params $exit->msg; |
99 | my $rmp = parse_random_map_params $exit->msg; |
100 | |
100 | |
… | |
… | |
103 | $rmp->{origin_map} = $exit->map->path; |
103 | $rmp->{origin_map} = $exit->map->path; |
104 | $rmp->{origin_x} = $exit->x; |
104 | $rmp->{origin_x} = $exit->x; |
105 | $rmp->{origin_y} = $exit->y; |
105 | $rmp->{origin_y} = $exit->y; |
106 | } |
106 | } |
107 | |
107 | |
108 | $rmp->{random_seed} = $exit->random_seed; |
108 | $rmp->{random_seed} ||= $exit->random_seed; |
109 | |
109 | |
110 | $exit->slaying ("?random/" . cf::to_json $rmp); |
110 | my $data = cf::to_json $rmp; |
|
|
111 | my $md5 = Digest::MD5::md5_hex $data; |
|
|
112 | |
|
|
113 | if (my $fh = aio_open "$cf::RANDOM_MAPS/$md5.meta", O_WRONLY | O_CREAT, 0666) { |
|
|
114 | aio_write $fh, 0, (length $data), $data, 0; |
|
|
115 | |
|
|
116 | $exit->slaying ("?random/$md5"); |
111 | $exit->msg (undef); |
117 | $exit->msg (undef); |
|
|
118 | } |
112 | } |
119 | } |
113 | |
120 | |
114 | # and all this just because we cannot iterate over |
121 | # and all this just because we cannot iterate over |
115 | # all maps in C++... |
122 | # all maps in C++... |
116 | sub cf::map::change_all_map_light { |
123 | sub cf::map::change_all_map_light { |