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.175 by root, Sun Jan 14 21:20:51 2007 UTC vs.
Revision 1.178 by root, Thu Jan 18 00:06:55 2007 UTC

1121our $MAX_RESET = 3600; 1121our $MAX_RESET = 3600;
1122our $DEFAULT_RESET = 3000; 1122our $DEFAULT_RESET = 3000;
1123 1123
1124sub generate_random_map { 1124sub generate_random_map {
1125 my ($self, $rmp) = @_; 1125 my ($self, $rmp) = @_;
1126
1127 # mit "rum" bekleckern, nicht 1126 # mit "rum" bekleckern, nicht
1128 $self->_create_random_map ( 1127 $self->_create_random_map (
1129 $rmp->{wallstyle}, $rmp->{wall_name}, $rmp->{floorstyle}, $rmp->{monsterstyle}, 1128 $rmp->{wallstyle}, $rmp->{wall_name}, $rmp->{floorstyle}, $rmp->{monsterstyle},
1130 $rmp->{treasurestyle}, $rmp->{layoutstyle}, $rmp->{doorstyle}, $rmp->{decorstyle}, 1129 $rmp->{treasurestyle}, $rmp->{layoutstyle}, $rmp->{doorstyle}, $rmp->{decorstyle},
1131 $rmp->{origin_map}, $rmp->{final_map}, $rmp->{exitstyle}, $rmp->{this_map}, 1130 $rmp->{origin_map}, $rmp->{final_map}, $rmp->{exitstyle}, $rmp->{this_map},
1813 1812
1814sub parse_random_map_params { 1813sub parse_random_map_params {
1815 my ($spec) = @_; 1814 my ($spec) = @_;
1816 1815
1817 my $rmp = { # defaults 1816 my $rmp = { # defaults
1818 xsize => 10, 1817 xsize => -1,
1819 ysize => 10, 1818 ysize => -1,
1820 }; 1819 };
1821 1820
1822 for (split /\n/, $spec) { 1821 for (split /\n/, $spec) {
1823 my ($k, $v) = split /\s+/, $_, 2; 1822 my ($k, $v) = split /\s+/, $_, 2;
1824 1823
1846 1845
1847 $rmp->{random_seed} ||= $exit->random_seed; 1846 $rmp->{random_seed} ||= $exit->random_seed;
1848 1847
1849 my $data = cf::to_json $rmp; 1848 my $data = cf::to_json $rmp;
1850 my $md5 = Digest::MD5::md5_hex $data; 1849 my $md5 = Digest::MD5::md5_hex $data;
1850 my $meta = "$cf::RANDOM_MAPS/$md5.meta";
1851 1851
1852 if (my $fh = aio_open "$cf::RANDOM_MAPS/$md5.meta", O_WRONLY | O_CREAT, 0666) { 1852 if (my $fh = aio_open "$meta~", O_WRONLY | O_CREAT, 0666) {
1853 aio_write $fh, 0, (length $data), $data, 0; 1853 aio_write $fh, 0, (length $data), $data, 0;
1854 undef $fh;
1855 aio_rename "$meta~", $meta;
1854 1856
1855 $exit->slaying ("?random/$md5"); 1857 $exit->slaying ("?random/$md5");
1856 $exit->msg (undef); 1858 $exit->msg (undef);
1857 } 1859 }
1858} 1860}
2229sub main { 2231sub main {
2230 # we must not ever block the main coroutine 2232 # we must not ever block the main coroutine
2231 local $Coro::idle = sub { 2233 local $Coro::idle = sub {
2232 Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d# 2234 Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d#
2233 (async { 2235 (async {
2234 warn "BP1\n";#d#
2235 Event::one_event; 2236 Event::one_event;
2236 warn "BP2\n";#d#
2237 })->prio (Coro::PRIO_MAX); 2237 })->prio (Coro::PRIO_MAX);
2238 }; 2238 };
2239 2239
2240 cfg_load; 2240 cfg_load;
2241 db_load; 2241 db_load;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines