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.476 by root, Wed Sep 2 16:54:20 2009 UTC vs.
Revision 1.513 by root, Mon Apr 12 05:22:38 2010 UTC

1# 1#
2# This file is part of Deliantra, the Roguelike Realtime MMORPG. 2# This file is part of Deliantra, the Roguelike Realtime MMORPG.
3# 3#
4# Copyright (©) 2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4# Copyright (©) 2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5# 5#
6# Deliantra is free software: you can redistribute it and/or modify 6# Deliantra is free software: you can redistribute it and/or modify it under
7# it under the terms of the GNU General Public License as published by 7# the terms of the Affero GNU General Public License as published by the
8# the Free Software Foundation, either version 3 of the License, or 8# Free Software Foundation, either version 3 of the License, or (at your
9# (at your option) any later version. 9# option) any later version.
10# 10#
11# This program is distributed in the hope that it will be useful, 11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details. 14# GNU General Public License for more details.
15# 15#
16# You should have received a copy of the GNU General Public License 16# You should have received a copy of the Affero GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>. 17# and the GNU General Public License along with this program. If not, see
18# <http://www.gnu.org/licenses/>.
18# 19#
19# The authors can be reached via e-mail to <support@deliantra.net> 20# The authors can be reached via e-mail to <support@deliantra.net>
20# 21#
21 22
22package cf; 23package cf;
23 24
24use 5.10.0; 25use 5.10.0;
25use utf8; 26use utf8;
31use EV; 32use EV;
32use Opcode; 33use Opcode;
33use Safe; 34use Safe;
34use Safe::Hole; 35use Safe::Hole;
35use Storable (); 36use Storable ();
37use Carp ();
36 38
37use Guard (); 39use Guard ();
38use Coro (); 40use Coro ();
39use Coro::State; 41use Coro::State;
40use Coro::Handle; 42use Coro::Handle;
51use Coro::Util (); 53use Coro::Util ();
52 54
53use JSON::XS 2.01 (); 55use JSON::XS 2.01 ();
54use BDB (); 56use BDB ();
55use Data::Dumper; 57use Data::Dumper;
56use Digest::MD5;
57use Fcntl; 58use Fcntl;
58use YAML (); 59use YAML::XS ();
59use IO::AIO (); 60use IO::AIO ();
60use Time::HiRes; 61use Time::HiRes;
61use Compress::LZF; 62use Compress::LZF;
62use Digest::MD5 (); 63use Digest::MD5 ();
63 64
88our %EXT_CORO = (); # coroutines bound to extensions 89our %EXT_CORO = (); # coroutines bound to extensions
89our %EXT_MAP = (); # pluggable maps 90our %EXT_MAP = (); # pluggable maps
90 91
91our $RELOAD; # number of reloads so far, non-zero while in reload 92our $RELOAD; # number of reloads so far, non-zero while in reload
92our @EVENT; 93our @EVENT;
94our @REFLECT; # set by XS
95our %REFLECT; # set by us
93 96
94our $CONFDIR = confdir; 97our $CONFDIR = confdir;
95our $DATADIR = datadir; 98our $DATADIR = datadir;
96our $LIBDIR = "$DATADIR/ext"; 99our $LIBDIR = "$DATADIR/ext";
97our $PODDIR = "$DATADIR/pod"; 100our $PODDIR = "$DATADIR/pod";
105our $PIDFILE = "$LOCALDIR/pid"; 108our $PIDFILE = "$LOCALDIR/pid";
106our $RUNTIMEFILE = "$LOCALDIR/runtime"; 109our $RUNTIMEFILE = "$LOCALDIR/runtime";
107 110
108our %RESOURCE; 111our %RESOURCE;
109 112
113our $OUTPUT_RATE_MIN = 4000;
114our $OUTPUT_RATE_MAX = 100000;
115
110our $TICK = MAX_TIME * 1e-6; # this is a CONSTANT(!) 116our $TICK = MAX_TIME * 1e-6; # this is a CONSTANT(!)
111our $NEXT_RUNTIME_WRITE; # when should the runtime file be written 117our $NEXT_RUNTIME_WRITE; # when should the runtime file be written
112our $NEXT_TICK; 118our $NEXT_TICK;
113our $USE_FSYNC = 1; # use fsync to write maps - default on 119our $USE_FSYNC = 1; # use fsync to write maps - default on
114 120
115our $BDB_DEADLOCK_WATCHER; 121our $BDB_DEADLOCK_WATCHER;
116our $BDB_CHECKPOINT_WATCHER; 122our $BDB_CHECKPOINT_WATCHER;
117our $BDB_TRICKLE_WATCHER; 123our $BDB_TRICKLE_WATCHER;
118our $DB_ENV; 124our $DB_ENV;
119 125
120our @EXTRA_MODULES = qw(pod mapscript); 126our @EXTRA_MODULES = qw(pod match mapscript);
121 127
122our %CFG; 128our %CFG;
123 129
124our $UPTIME; $UPTIME ||= time; 130our $UPTIME; $UPTIME ||= time;
125our $RUNTIME; 131our $RUNTIME;
161 167
162sub cf::map::normalise; 168sub cf::map::normalise;
163 169
164############################################################################# 170#############################################################################
165 171
172%REFLECT = ();
173for (@REFLECT) {
174 my $reflect = JSON::XS::decode_json $_;
175 $REFLECT{$reflect->{class}} = $reflect;
176}
177
178# this is decidedly evil
179$REFLECT{object}{flags} = { map +($_ => undef), grep $_, map /^FLAG_([A-Z0-9_]+)$/ && lc $1, keys %{"cf::"} };
180
181#############################################################################
182
166=head2 GLOBAL VARIABLES 183=head2 GLOBAL VARIABLES
167 184
168=over 4 185=over 4
169 186
170=item $cf::UPTIME 187=item $cf::UPTIME
214returns directly I<after> the tick processing (and consequently, can only wake one process 231returns directly I<after> the tick processing (and consequently, can only wake one process
215per tick), while cf::wait_for_tick wakes up all waiters after tick processing. 232per tick), while cf::wait_for_tick wakes up all waiters after tick processing.
216 233
217=item @cf::INVOKE_RESULTS 234=item @cf::INVOKE_RESULTS
218 235
219This array contains the results of the last C<invoke ()> call. When 236This array contains the results of the last C<invoke ()> call. When
220C<cf::override> is called C<@cf::INVOKE_RESULTS> is set to the parameters of 237C<cf::override> is called C<@cf::INVOKE_RESULTS> is set to the parameters of
221that call. 238that call.
222 239
240=item %cf::REFLECT
241
242Contains, for each (C++) class name, a hash reference with information
243about object members (methods, scalars, arrays and flags) and other
244metadata, which is useful for introspection.
245
223=back 246=back
224 247
225=cut 248=cut
226 249
227BEGIN { 250$Coro::State::WARNHOOK = sub {
228 *CORE::GLOBAL::warn = sub {
229 my $msg = join "", @_; 251 my $msg = join "", @_;
230 252
231 $msg .= "\n" 253 $msg .= "\n"
232 unless $msg =~ /\n$/; 254 unless $msg =~ /\n$/;
233 255
234 $msg =~ s/([\x00-\x08\x0b-\x1f])/sprintf "\\x%02x", ord $1/ge; 256 $msg =~ s/([\x00-\x08\x0b-\x1f])/sprintf "\\x%02x", ord $1/ge;
235 257
236 LOG llevError, $msg; 258 LOG llevError, $msg;
237 }; 259};
238}
239 260
240$Coro::State::DIEHOOK = sub { 261$Coro::State::DIEHOOK = sub {
241 return unless $^S eq 0; # "eq", not "==" 262 return unless $^S eq 0; # "eq", not "=="
263
264 warn Carp::longmess $_[0];
242 265
243 if ($Coro::current == $Coro::main) {#d# 266 if ($Coro::current == $Coro::main) {#d#
244 warn "DIEHOOK called in main context, Coro bug?\n";#d# 267 warn "DIEHOOK called in main context, Coro bug?\n";#d#
245 return;#d# 268 return;#d#
246 }#d# 269 }#d#
247 270
248 # kill coroutine otherwise 271 # kill coroutine otherwise
249 warn Carp::longmess $_[0];
250 Coro::terminate 272 Coro::terminate
251}; 273};
252
253$SIG{__DIE__} = sub { }; #d#?
254 274
255@safe::cf::global::ISA = @cf::global::ISA = 'cf::attachable'; 275@safe::cf::global::ISA = @cf::global::ISA = 'cf::attachable';
256@safe::cf::object::ISA = @cf::object::ISA = 'cf::attachable'; 276@safe::cf::object::ISA = @cf::object::ISA = 'cf::attachable';
257@safe::cf::player::ISA = @cf::player::ISA = 'cf::attachable'; 277@safe::cf::player::ISA = @cf::player::ISA = 'cf::attachable';
258@safe::cf::client::ISA = @cf::client::ISA = 'cf::attachable'; 278@safe::cf::client::ISA = @cf::client::ISA = 'cf::attachable';
272)) { 292)) {
273 @{"safe::$pkg\::wrap::ISA"} = @{"$pkg\::wrap::ISA"} = $pkg; 293 @{"safe::$pkg\::wrap::ISA"} = @{"$pkg\::wrap::ISA"} = $pkg;
274} 294}
275 295
276$EV::DIED = sub { 296$EV::DIED = sub {
277 warn "error in event callback: @_"; 297 Carp::cluck "error in event callback: @_";
278}; 298};
279 299
280############################################################################# 300#############################################################################
281 301
282=head2 UTILITY FUNCTIONS 302=head2 UTILITY FUNCTIONS
406 426
407=cut 427=cut
408 428
409our @SLOT_QUEUE; 429our @SLOT_QUEUE;
410our $SLOT_QUEUE; 430our $SLOT_QUEUE;
431our $SLOT_DECAY = 0.9;
411 432
412$SLOT_QUEUE->cancel if $SLOT_QUEUE; 433$SLOT_QUEUE->cancel if $SLOT_QUEUE;
413$SLOT_QUEUE = Coro::async { 434$SLOT_QUEUE = Coro::async {
414 $Coro::current->desc ("timeslot manager"); 435 $Coro::current->desc ("timeslot manager");
415 436
416 my $signal = new Coro::Signal; 437 my $signal = new Coro::Signal;
438 my $busy;
417 439
418 while () { 440 while () {
419 next_job: 441 next_job:
442
420 my $avail = cf::till_tick; 443 my $avail = cf::till_tick;
421 if ($avail > 0.01) { 444
422 for (0 .. $#SLOT_QUEUE) { 445 for (0 .. $#SLOT_QUEUE) {
423 if ($SLOT_QUEUE[$_][0] < $avail) { 446 if ($SLOT_QUEUE[$_][0] <= $avail) {
447 $busy = 0;
424 my $job = splice @SLOT_QUEUE, $_, 1, (); 448 my $job = splice @SLOT_QUEUE, $_, 1, ();
425 $job->[2]->send; 449 $job->[2]->send;
426 Coro::cede; 450 Coro::cede;
427 goto next_job; 451 goto next_job;
428 } 452 } else {
453 $SLOT_QUEUE[$_][0] *= $SLOT_DECAY;
429 } 454 }
430 } 455 }
431 456
432 if (@SLOT_QUEUE) { 457 if (@SLOT_QUEUE) {
433 # we do not use wait_for_tick() as it returns immediately when tick is inactive 458 # we do not use wait_for_tick() as it returns immediately when tick is inactive
434 push @cf::WAIT_FOR_TICK, $signal; 459 push @cf::WAIT_FOR_TICK, $signal;
435 $signal->wait; 460 $signal->wait;
436 } else { 461 } else {
462 $busy = 0;
437 Coro::schedule; 463 Coro::schedule;
438 } 464 }
439 } 465 }
440}; 466};
441 467
442sub get_slot($;$$) { 468sub get_slot($;$$) {
443 return if tick_inhibit || $Coro::current == $Coro::main; 469 return if tick_inhibit || $Coro::current == $Coro::main;
444 470
445 my ($time, $pri, $name) = @_; 471 my ($time, $pri, $name) = @_;
446 472
447 $time = $TICK * .6 if $time > $TICK * .6; 473 $time = clamp $time, 0.01, $TICK * .6;
474
448 my $sig = new Coro::Signal; 475 my $sig = new Coro::Signal;
449 476
450 push @SLOT_QUEUE, [$time, $pri, $sig, $name]; 477 push @SLOT_QUEUE, [$time, $pri, $sig, $name];
451 @SLOT_QUEUE = sort { $b->[1] <=> $a->[1] } @SLOT_QUEUE; 478 @SLOT_QUEUE = sort { $b->[1] <=> $a->[1] } @SLOT_QUEUE;
452 $SLOT_QUEUE->ready; 479 $SLOT_QUEUE->ready;
479 506
480sub sync_job(&) { 507sub sync_job(&) {
481 my ($job) = @_; 508 my ($job) = @_;
482 509
483 if ($Coro::current == $Coro::main) { 510 if ($Coro::current == $Coro::main) {
484 my $time = EV::time; 511 my $time = AE::time;
485 512
486 # this is the main coro, too bad, we have to block 513 # this is the main coro, too bad, we have to block
487 # till the operation succeeds, freezing the server :/ 514 # till the operation succeeds, freezing the server :/
488 515
489 LOG llevError, Carp::longmess "sync job";#d# 516 LOG llevError, Carp::longmess "sync job";#d#
506 } else { 533 } else {
507 EV::loop EV::LOOP_ONESHOT; 534 EV::loop EV::LOOP_ONESHOT;
508 } 535 }
509 } 536 }
510 537
511 my $time = EV::time - $time; 538 my $time = AE::time - $time;
512 539
513 $TICK_START += $time; # do not account sync jobs to server load 540 $TICK_START += $time; # do not account sync jobs to server load
514 541
515 wantarray ? @res : $res[0] 542 wantarray ? @res : $res[0]
516 } else { 543 } else {
1286} 1313}
1287 1314
1288use File::Glob (); 1315use File::Glob ();
1289 1316
1290cf::player->attach ( 1317cf::player->attach (
1291 on_command => sub { 1318 on_unknown_command => sub {
1292 my ($pl, $name, $params) = @_; 1319 my ($pl, $name, $params) = @_;
1293 1320
1294 my $cb = $COMMAND{$name} 1321 my $cb = $COMMAND{$name}
1295 or return; 1322 or return;
1296 1323
1375 . "\n};\n1"; 1402 . "\n};\n1";
1376 1403
1377 $todo{$base} = \%ext; 1404 $todo{$base} = \%ext;
1378 } 1405 }
1379 1406
1407 my $pass = 0;
1380 my %done; 1408 my %done;
1381 while (%todo) { 1409 while (%todo) {
1382 my $progress; 1410 my $progress;
1383 1411
1412 ++$pass;
1413
1414 ext:
1384 while (my ($k, $v) = each %todo) { 1415 while (my ($k, $v) = each %todo) {
1385 for (split /,\s*/, $v->{meta}{depends}) { 1416 for (split /,\s*/, $v->{meta}{depends}) {
1386 goto skip 1417 next ext
1387 unless exists $done{$_}; 1418 unless exists $done{$_};
1388 } 1419 }
1389 1420
1390 warn "... loading '$k' into '$v->{pkg}'\n"; 1421 warn "... pass $pass, loading '$k' into '$v->{pkg}'\n";
1391 1422
1392 unless (eval $v->{source}) { 1423 my $active = eval $v->{source};
1424
1425 if (length $@) {
1393 my $msg = $@ ? "$v->{path}: $@\n" 1426 warn "$v->{path}: $@\n";
1394 : "$v->{base}: extension inactive.\n";
1395 1427
1396 if (exists $v->{meta}{mandatory}) {
1397 warn $msg;
1398 cf::cleanup "mandatory extension failed to load, exiting."; 1428 cf::cleanup "mandatory extension '$k' failed to load, exiting."
1399 } 1429 if exists $v->{meta}{mandatory};
1400 1430 } else {
1401 warn $msg; 1431 $done{$k} = delete $todo{$k};
1432 push @EXTS, $v->{pkg};
1433 $progress = 1;
1434
1435 warn "$v->{base}: extension inactive.\n"
1436 unless $active;
1402 } 1437 }
1403
1404 $done{$k} = delete $todo{$k};
1405 push @EXTS, $v->{pkg};
1406 $progress = 1;
1407 } 1438 }
1408 1439
1409 skip: 1440 unless ($progress) {
1410 die "cannot load " . (join ", ", keys %todo) . ": unable to resolve dependencies\n" 1441 warn "cannot load " . (join ", ", keys %todo) . ": unable to resolve dependencies\n";
1411 unless $progress; 1442
1443 while (my ($k, $v) = each %todo) {
1444 cf::cleanup "mandatory extension '$k' has unresolved dependencies, exiting."
1445 if exists $v->{meta}{mandatory};
1446 }
1447 }
1412 } 1448 }
1413 }; 1449 };
1414} 1450}
1415 1451
1416############################################################################# 1452#############################################################################
1500 $cf::PLAYER{$login} = $pl 1536 $cf::PLAYER{$login} = $pl
1501 } 1537 }
1502 } 1538 }
1503} 1539}
1504 1540
1541cf::player->attach (
1542 on_load => sub {
1543 my ($pl, $path) = @_;
1544
1545 # restore slots saved in save, below
1546 my $slots = delete $pl->{_slots};
1547
1548 $pl->ob->current_weapon ($slots->[0]);
1549 $pl->combat_ob ($slots->[1]);
1550 $pl->ranged_ob ($slots->[2]);
1551 },
1552);
1553
1505sub save($) { 1554sub save($) {
1506 my ($pl) = @_; 1555 my ($pl) = @_;
1507 1556
1508 return if $pl->{deny_save}; 1557 return if $pl->{deny_save};
1509 1558
1514 1563
1515 aio_mkdir playerdir $pl, 0770; 1564 aio_mkdir playerdir $pl, 0770;
1516 $pl->{last_save} = $cf::RUNTIME; 1565 $pl->{last_save} = $cf::RUNTIME;
1517 1566
1518 cf::get_slot 0.01; 1567 cf::get_slot 0.01;
1568
1569 # save slots, to be restored later
1570 local $pl->{_slots} = [$pl->ob->current_weapon, $pl->combat_ob, $pl->ranged_ob];
1519 1571
1520 $pl->save_pl ($path); 1572 $pl->save_pl ($path);
1521 cf::cede_to_tick; 1573 cf::cede_to_tick;
1522} 1574}
1523 1575
1736 my $lock = cf::lock_acquire "generate_random_map"; # the random map generator is NOT reentrant ATM 1788 my $lock = cf::lock_acquire "generate_random_map"; # the random map generator is NOT reentrant ATM
1737 1789
1738 # mit "rum" bekleckern, nicht 1790 # mit "rum" bekleckern, nicht
1739 $self->_create_random_map ( 1791 $self->_create_random_map (
1740 $rmp->{wallstyle}, $rmp->{wall_name}, $rmp->{floorstyle}, $rmp->{monsterstyle}, 1792 $rmp->{wallstyle}, $rmp->{wall_name}, $rmp->{floorstyle}, $rmp->{monsterstyle},
1741 $rmp->{treasurestyle}, $rmp->{layoutstyle}, $rmp->{doorstyle}, $rmp->{decorstyle}, 1793 $rmp->{treasurestyle}, $rmp->{layoutstyle}, $rmp->{doorstyle}, $rmp->{decorstyle}, $rmp->{miningstyle},
1742 $rmp->{origin_map}, $rmp->{final_map}, $rmp->{exitstyle}, $rmp->{this_map}, 1794 $rmp->{origin_map}, $rmp->{final_map}, $rmp->{exitstyle}, $rmp->{this_map},
1743 $rmp->{exit_on_final_map}, 1795 $rmp->{exit_on_final_map},
1744 $rmp->{xsize}, $rmp->{ysize}, 1796 $rmp->{xsize}, $rmp->{ysize},
1745 $rmp->{expand2x}, $rmp->{layoutoptions1}, $rmp->{layoutoptions2}, $rmp->{layoutoptions3}, 1797 $rmp->{expand2x}, $rmp->{layoutoptions1}, $rmp->{layoutoptions2}, $rmp->{layoutoptions3},
1746 $rmp->{symmetry}, $rmp->{difficulty}, $rmp->{difficulty_given}, $rmp->{difficulty_increase}, 1798 $rmp->{symmetry}, $rmp->{difficulty}, $rmp->{difficulty_given}, $rmp->{difficulty_increase},
1992 2044
1993 $cf::MAP{$path} = $map 2045 $cf::MAP{$path} = $map
1994 } 2046 }
1995} 2047}
1996 2048
1997sub pre_load { } 2049sub pre_load { }
1998sub post_load { } 2050#sub post_load { } # XS
1999 2051
2000sub load { 2052sub load {
2001 my ($self) = @_; 2053 my ($self) = @_;
2002 2054
2003 local $self->{deny_reset} = 1; # loading can take a long time 2055 local $self->{deny_reset} = 1; # loading can take a long time
2060 } 2112 }
2061 2113
2062 $self->post_load; 2114 $self->post_load;
2063} 2115}
2064 2116
2117# customize the map for a given player, i.e.
2118# return the _real_ map. used by e.g. per-player
2119# maps to change the path to ~playername/mappath
2065sub customise_for { 2120sub customise_for {
2066 my ($self, $ob) = @_; 2121 my ($self, $ob) = @_;
2067 2122
2068 return find "~" . $ob->name . "/" . $self->{path} 2123 return find "~" . $ob->name . "/" . $self->{path}
2069 if $self->per_player; 2124 if $self->per_player;
2223 2278
2224 my $lock = cf::lock_acquire "map_data:$self->{path}"; 2279 my $lock = cf::lock_acquire "map_data:$self->{path}";
2225 2280
2226 return if $self->players; 2281 return if $self->players;
2227 2282
2228 warn "resetting map ", $self->path; 2283 warn "resetting map ", $self->path, "\n";
2229 2284
2230 $self->in_memory (cf::MAP_SWAPPED); 2285 $self->in_memory (cf::MAP_SWAPPED);
2231 2286
2232 # need to save uniques path 2287 # need to save uniques path
2233 unless ($self->{deny_save}) { 2288 unless ($self->{deny_save}) {
2324 : normalise $_ 2379 : normalise $_
2325 } @{ aio_readdir $UNIQUEDIR or [] } 2380 } @{ aio_readdir $UNIQUEDIR or [] }
2326 ] 2381 ]
2327} 2382}
2328 2383
2384=item cf::map::static_maps
2385
2386Returns an arrayref if paths of all static maps (all preinstalled F<.map>
2387file in the shared directory excluding F</styles> and F</editor>). May
2388block.
2389
2390=cut
2391
2392sub static_maps() {
2393 my @dirs = "";
2394 my @maps;
2395
2396 while (@dirs) {
2397 my $dir = shift @dirs;
2398
2399 next if $dir eq "/styles" || $dir eq "/editor";
2400
2401 my ($dirs, $files) = Coro::AIO::aio_scandir "$MAPDIR$dir", 2
2402 or return;
2403
2404 for (@$files) {
2405 s/\.map$// or next;
2406 utf8::decode $_;
2407 push @maps, "$dir/$_";
2408 }
2409
2410 push @dirs, map "$dir/$_", @$dirs;
2411 }
2412
2413 \@maps
2414}
2415
2329=back 2416=back
2330 2417
2331=head3 cf::object 2418=head3 cf::object
2332 2419
2333=cut 2420=cut
2528 ($x, $y) = (-1, -1) 2615 ($x, $y) = (-1, -1)
2529 unless (defined $x) && (defined $y); 2616 unless (defined $x) && (defined $y);
2530 2617
2531 # use -1 or undef as default coordinates, not 0, 0 2618 # use -1 or undef as default coordinates, not 0, 0
2532 ($x, $y) = ($map->enter_x, $map->enter_y) 2619 ($x, $y) = ($map->enter_x, $map->enter_y)
2533 if $x <=0 && $y <= 0; 2620 if $x <= 0 && $y <= 0;
2534 2621
2535 $map->load; 2622 $map->load;
2536 $map->load_neighbours; 2623 $map->load_neighbours;
2537 2624
2538 return unless $self->contr->active; 2625 return unless $self->contr->active;
2737 2824
2738 utf8::encode $text; 2825 utf8::encode $text;
2739 $self->send_packet (sprintf "drawinfo %d %s", $flags || cf::NDI_BLACK, $text); 2826 $self->send_packet (sprintf "drawinfo %d %s", $flags || cf::NDI_BLACK, $text);
2740} 2827}
2741 2828
2829=item $client->send_big_packet ($pkt)
2830
2831Like C<send_packet>, but tries to compress large packets, and fragments
2832them as required.
2833
2834=cut
2835
2836our $MAXFRAGSIZE = cf::MAXSOCKBUF - 64;
2837
2838sub cf::client::send_big_packet {
2839 my ($self, $pkt) = @_;
2840
2841 # try lzf for large packets
2842 $pkt = "lzf " . Compress::LZF::compress $pkt
2843 if 1024 <= length $pkt and $self->{can_lzf};
2844
2845 # split very large packets
2846 if ($MAXFRAGSIZE < length $pkt and $self->{can_lzf}) {
2847 $self->send_packet ("frag $_") for unpack "(a$MAXFRAGSIZE)*", $pkt;
2848 $pkt = "frag";
2849 }
2850
2851 $self->send_packet ($pkt);
2852}
2853
2742=item $client->send_msg ($channel, $msg, $color, [extra...]) 2854=item $client->send_msg ($channel, $msg, $color, [extra...])
2743 2855
2744Send a drawinfo or msg packet to the client, formatting the msg for the 2856Send a drawinfo or msg packet to the client, formatting the msg for the
2745client if neccessary. C<$type> should be a string identifying the type of 2857client if neccessary. C<$type> should be a string identifying the type of
2746the message, with C<log> being the default. If C<$color> is negative, suppress 2858the message, with C<log> being the default. If C<$color> is negative, suppress
2748 2860
2749=cut 2861=cut
2750 2862
2751# non-persistent channels (usually the info channel) 2863# non-persistent channels (usually the info channel)
2752our %CHANNEL = ( 2864our %CHANNEL = (
2865 "c/motd" => {
2866 id => "infobox",
2867 title => "MOTD",
2868 reply => undef,
2869 tooltip => "The message of the day",
2870 },
2753 "c/identify" => { 2871 "c/identify" => {
2754 id => "infobox", 2872 id => "infobox",
2755 title => "Identify", 2873 title => "Identify",
2756 reply => undef, 2874 reply => undef,
2757 tooltip => "Items recently identified", 2875 tooltip => "Items recently identified",
2759 "c/examine" => { 2877 "c/examine" => {
2760 id => "infobox", 2878 id => "infobox",
2761 title => "Examine", 2879 title => "Examine",
2762 reply => undef, 2880 reply => undef,
2763 tooltip => "Signs and other items you examined", 2881 tooltip => "Signs and other items you examined",
2882 },
2883 "c/shopinfo" => {
2884 id => "infobox",
2885 title => "Shop Info",
2886 reply => undef,
2887 tooltip => "What your bargaining skill tells you about the shop",
2764 }, 2888 },
2765 "c/book" => { 2889 "c/book" => {
2766 id => "infobox", 2890 id => "infobox",
2767 title => "Book", 2891 title => "Book",
2768 reply => undef, 2892 reply => undef,
2884 my $pkt = "msg " 3008 my $pkt = "msg "
2885 . $self->{json_coder}->encode ( 3009 . $self->{json_coder}->encode (
2886 [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra] 3010 [$color & cf::NDI_CLIENT_MASK, $channel, $msg, @extra]
2887 ); 3011 );
2888 3012
2889 # try lzf for large packets
2890 $pkt = "lzf " . Compress::LZF::compress $pkt
2891 if 1024 <= length $pkt and $self->{can_lzf};
2892
2893 # split very large packets
2894 if (8192 < length $pkt and $self->{can_lzf}) {
2895 $self->send_packet ("frag $_") for unpack "(a8192)*", $pkt;
2896 $pkt = "frag";
2897 }
2898
2899 $self->send_packet ($pkt); 3013 $self->send_big_packet ($pkt);
2900} 3014}
2901 3015
2902=item $client->ext_msg ($type, @msg) 3016=item $client->ext_msg ($type, @msg)
2903 3017
2904Sends an ext event to the client. 3018Sends an ext event to the client.
2907 3021
2908sub cf::client::ext_msg($$@) { 3022sub cf::client::ext_msg($$@) {
2909 my ($self, $type, @msg) = @_; 3023 my ($self, $type, @msg) = @_;
2910 3024
2911 if ($self->extcmd == 2) { 3025 if ($self->extcmd == 2) {
2912 $self->send_packet ("ext " . $self->{json_coder}->encode ([$type, @msg])); 3026 $self->send_big_packet ("ext " . $self->{json_coder}->encode ([$type, @msg]));
2913 } elsif ($self->extcmd == 1) { # TODO: remove 3027 } elsif ($self->extcmd == 1) { # TODO: remove
2914 push @msg, msgtype => "event_$type"; 3028 push @msg, msgtype => "event_$type";
2915 $self->send_packet ("ext " . $self->{json_coder}->encode ({@msg})); 3029 $self->send_big_packet ("ext " . $self->{json_coder}->encode ({@msg}));
2916 } 3030 }
2917} 3031}
2918 3032
2919=item $client->ext_reply ($msgid, @msg) 3033=item $client->ext_reply ($msgid, @msg)
2920 3034
2924 3038
2925sub cf::client::ext_reply($$@) { 3039sub cf::client::ext_reply($$@) {
2926 my ($self, $id, @msg) = @_; 3040 my ($self, $id, @msg) = @_;
2927 3041
2928 if ($self->extcmd == 2) { 3042 if ($self->extcmd == 2) {
2929 $self->send_packet ("ext " . $self->{json_coder}->encode (["reply-$id", @msg])); 3043 $self->send_big_packet ("ext " . $self->{json_coder}->encode (["reply-$id", @msg]));
2930 } elsif ($self->extcmd == 1) { 3044 } elsif ($self->extcmd == 1) {
2931 #TODO: version 1, remove 3045 #TODO: version 1, remove
2932 unshift @msg, msgtype => "reply", msgid => $id; 3046 unshift @msg, msgtype => "reply", msgid => $id;
2933 $self->send_packet ("ext " . $self->{json_coder}->encode ({@msg})); 3047 $self->send_big_packet ("ext " . $self->{json_coder}->encode ({@msg}));
2934 } 3048 }
2935} 3049}
2936 3050
2937=item $success = $client->query ($flags, "text", \&cb) 3051=item $success = $client->query ($flags, "text", \&cb)
2938 3052
3039 3153
3040 $coro 3154 $coro
3041} 3155}
3042 3156
3043cf::client->attach ( 3157cf::client->attach (
3044 on_destroy => sub { 3158 on_client_destroy => sub {
3045 my ($ns) = @_; 3159 my ($ns) = @_;
3046 3160
3047 $_->cancel for values %{ (delete $ns->{_coro}) || {} }; 3161 $_->cancel for values %{ (delete $ns->{_coro}) || {} };
3048 }, 3162 },
3049); 3163);
3065our $safe_hole = new Safe::Hole; 3179our $safe_hole = new Safe::Hole;
3066 3180
3067$SIG{FPE} = 'IGNORE'; 3181$SIG{FPE} = 'IGNORE';
3068 3182
3069$safe->permit_only (Opcode::opset qw( 3183$safe->permit_only (Opcode::opset qw(
3070 :base_core :base_mem :base_orig :base_math 3184 :base_core :base_mem :base_orig :base_math :base_loop
3071 grepstart grepwhile mapstart mapwhile 3185 grepstart grepwhile mapstart mapwhile
3072 sort time 3186 sort time
3073)); 3187));
3074 3188
3075# here we export the classes and methods available to script code 3189# here we export the classes and methods available to script code
3127 $qcode =~ s/"/‟/g; # not allowed in #line filenames 3241 $qcode =~ s/"/‟/g; # not allowed in #line filenames
3128 $qcode =~ s/\n/\\n/g; 3242 $qcode =~ s/\n/\\n/g;
3129 3243
3130 %vars = (_dummy => 0) unless %vars; 3244 %vars = (_dummy => 0) unless %vars;
3131 3245
3246 my @res;
3132 local $_; 3247 local $_;
3133 local @safe::cf::_safe_eval_args = values %vars;
3134 3248
3135 my $eval = 3249 my $eval =
3136 "do {\n" 3250 "do {\n"
3137 . "my (" . (join ",", map "\$$_", keys %vars) . ") = \@cf::_safe_eval_args;\n" 3251 . "my (" . (join ",", map "\$$_", keys %vars) . ") = \@cf::_safe_eval_args;\n"
3138 . "#line 0 \"{$qcode}\"\n" 3252 . "#line 0 \"{$qcode}\"\n"
3139 . $code 3253 . $code
3140 . "\n}" 3254 . "\n}"
3141 ; 3255 ;
3142 3256
3257 if ($CFG{safe_eval}) {
3143 sub_generation_inc; 3258 sub_generation_inc;
3259 local @safe::cf::_safe_eval_args = values %vars;
3144 my @res = wantarray ? $safe->reval ($eval) : scalar $safe->reval ($eval); 3260 @res = wantarray ? $safe->reval ($eval) : scalar $safe->reval ($eval);
3145 sub_generation_inc; 3261 sub_generation_inc;
3262 } else {
3263 local @cf::_safe_eval_args = values %vars;
3264 @res = wantarray ? eval eval : scalar eval $eval;
3265 }
3146 3266
3147 if ($@) { 3267 if ($@) {
3148 warn "$@"; 3268 warn "$@";
3149 warn "while executing safe code '$code'\n"; 3269 warn "while executing safe code '$code'\n";
3150 warn "with arguments " . (join " ", %vars) . "\n"; 3270 warn "with arguments " . (join " ", %vars) . "\n";
3169=cut 3289=cut
3170 3290
3171sub register_script_function { 3291sub register_script_function {
3172 my ($fun, $cb) = @_; 3292 my ($fun, $cb) = @_;
3173 3293
3174 no strict 'refs'; 3294 $fun = "safe::$fun" if $CFG{safe_eval};
3175 *{"safe::$fun"} = $safe_hole->wrap ($cb); 3295 *$fun = $safe_hole->wrap ($cb);
3176} 3296}
3177 3297
3178=back 3298=back
3179 3299
3180=cut 3300=cut
3201 3321
3202 $facedata->{version} == 2 3322 $facedata->{version} == 2
3203 or cf::cleanup "$path: version mismatch, cannot proceed."; 3323 or cf::cleanup "$path: version mismatch, cannot proceed.";
3204 3324
3205 # patch in the exptable 3325 # patch in the exptable
3326 my $exp_table = $enc->encode ([map cf::level_to_min_exp $_, 1 .. cf::settings->max_level]);
3206 $facedata->{resource}{"res/exp_table"} = { 3327 $facedata->{resource}{"res/exp_table"} = {
3207 type => FT_RSRC, 3328 type => FT_RSRC,
3208 data => $enc->encode ([map cf::level_to_min_exp $_, 1 .. cf::settings->max_level]), 3329 data => $exp_table,
3330 hash => (Digest::MD5::md5 $exp_table),
3209 }; 3331 };
3210 cf::cede_to_tick; 3332 cf::cede_to_tick;
3211 3333
3212 { 3334 {
3213 my $faces = $facedata->{faceinfo}; 3335 my $faces = $facedata->{faceinfo};
3215 while (my ($face, $info) = each %$faces) { 3337 while (my ($face, $info) = each %$faces) {
3216 my $idx = (cf::face::find $face) || cf::face::alloc $face; 3338 my $idx = (cf::face::find $face) || cf::face::alloc $face;
3217 3339
3218 cf::face::set_visibility $idx, $info->{visibility}; 3340 cf::face::set_visibility $idx, $info->{visibility};
3219 cf::face::set_magicmap $idx, $info->{magicmap}; 3341 cf::face::set_magicmap $idx, $info->{magicmap};
3220 cf::face::set_data $idx, 0, $info->{data32}, Digest::MD5::md5 $info->{data32}; 3342 cf::face::set_data $idx, 0, $info->{data32}, $info->{hash32};
3221 cf::face::set_data $idx, 1, $info->{data64}, Digest::MD5::md5 $info->{data64}; 3343 cf::face::set_data $idx, 1, $info->{data64}, $info->{hash64};
3222 3344
3223 cf::cede_to_tick; 3345 cf::cede_to_tick;
3224 } 3346 }
3225 3347
3226 while (my ($face, $info) = each %$faces) { 3348 while (my ($face, $info) = each %$faces) {
3250 3372
3251 cf::anim::invalidate_all; # d'oh 3373 cf::anim::invalidate_all; # d'oh
3252 } 3374 }
3253 3375
3254 { 3376 {
3255 # TODO: for gcfclient pleasure, we should give resources
3256 # that gcfclient doesn't grok a >10000 face index.
3257 my $res = $facedata->{resource}; 3377 my $res = $facedata->{resource};
3258 3378
3259 while (my ($name, $info) = each %$res) { 3379 while (my ($name, $info) = each %$res) {
3260 if (defined $info->{type}) { 3380 if (defined $info->{type}) {
3261 my $idx = (cf::face::find $name) || cf::face::alloc $name; 3381 my $idx = (cf::face::find $name) || cf::face::alloc $name;
3262 my $data;
3263 3382
3264 if ($info->{type} & 1) { 3383 cf::face::set_data $idx, 0, $info->{data}, $info->{hash};
3265 # prepend meta info
3266
3267 my $meta = $enc->encode ({
3268 name => $name,
3269 %{ $info->{meta} || {} },
3270 });
3271
3272 $data = pack "(w/a*)*", $meta, $info->{data};
3273 } else {
3274 $data = $info->{data};
3275 }
3276
3277 cf::face::set_data $idx, 0, $data, Digest::MD5::md5 $data;
3278 cf::face::set_type $idx, $info->{type}; 3384 cf::face::set_type $idx, $info->{type};
3279 } else { 3385 } else {
3280 $RESOURCE{$name} = $info; 3386 $RESOURCE{$name} = $info;
3281 } 3387 }
3282 3388
3366 3472
3367 warn "finished reloading resource files\n"; 3473 warn "finished reloading resource files\n";
3368} 3474}
3369 3475
3370sub reload_config { 3476sub reload_config {
3477 warn "reloading config file...\n";
3478
3371 open my $fh, "<:utf8", "$CONFDIR/config" 3479 open my $fh, "<:utf8", "$CONFDIR/config"
3372 or return; 3480 or return;
3373 3481
3374 local $/; 3482 local $/;
3375 *CFG = YAML::Load <$fh>; 3483 *CFG = YAML::XS::Load scalar <$fh>;
3376 3484
3377 $EMERGENCY_POSITION = $CFG{emergency_position} || ["/world/world_105_115", 5, 37]; 3485 $EMERGENCY_POSITION = $CFG{emergency_position} || ["/world/world_105_115", 5, 37];
3378 3486
3379 $cf::map::MAX_RESET = $CFG{map_max_reset} if exists $CFG{map_max_reset}; 3487 $cf::map::MAX_RESET = $CFG{map_max_reset} if exists $CFG{map_max_reset};
3380 $cf::map::DEFAULT_RESET = $CFG{map_default_reset} if exists $CFG{map_default_reset}; 3488 $cf::map::DEFAULT_RESET = $CFG{map_default_reset} if exists $CFG{map_default_reset};
3384 $CFG{mlockall} ? eval "mlockall()" : eval "munlockall()" 3492 $CFG{mlockall} ? eval "mlockall()" : eval "munlockall()"
3385 and die "WARNING: m(un)lockall failed: $!\n"; 3493 and die "WARNING: m(un)lockall failed: $!\n";
3386 }; 3494 };
3387 warn $@ if $@; 3495 warn $@ if $@;
3388 } 3496 }
3497
3498 warn "finished reloading resource files\n";
3389} 3499}
3390 3500
3391sub pidfile() { 3501sub pidfile() {
3392 sysopen my $fh, $PIDFILE, O_RDWR | O_CREAT 3502 sysopen my $fh, $PIDFILE, O_RDWR | O_CREAT
3393 or die "$PIDFILE: $!"; 3503 or die "$PIDFILE: $!";
3441 }; 3551 };
3442 3552
3443 evthread_start IO::AIO::poll_fileno; 3553 evthread_start IO::AIO::poll_fileno;
3444 3554
3445 cf::sync_job { 3555 cf::sync_job {
3556 cf::load_settings;
3557 cf::load_materials;
3558
3446 reload_resources; 3559 reload_resources;
3447 reload_config; 3560 reload_config;
3448 db_init; 3561 db_init;
3449 3562
3450 cf::load_settings;
3451 cf::load_materials;
3452 cf::init_uuid; 3563 cf::init_uuid;
3453 cf::init_signals; 3564 cf::init_signals;
3454 cf::init_commands;
3455 cf::init_skills; 3565 cf::init_skills;
3456 3566
3457 cf::init_beforeplay; 3567 cf::init_beforeplay;
3458 3568
3459 atomic; 3569 atomic;
3477 3587
3478# install some emergency cleanup handlers 3588# install some emergency cleanup handlers
3479BEGIN { 3589BEGIN {
3480 our %SIGWATCHER = (); 3590 our %SIGWATCHER = ();
3481 for my $signal (qw(INT HUP TERM)) { 3591 for my $signal (qw(INT HUP TERM)) {
3482 $SIGWATCHER{$signal} = EV::signal $signal, sub { 3592 $SIGWATCHER{$signal} = AE::signal $signal, sub {
3483 cf::cleanup "SIG$signal"; 3593 cf::cleanup "SIG$signal";
3484 }; 3594 };
3485 } 3595 }
3486} 3596}
3487 3597
3488sub write_runtime_sync { 3598sub write_runtime_sync {
3599 my $t0 = AE::time;
3600
3489 # first touch the runtime file to show we are still running: 3601 # first touch the runtime file to show we are still running:
3490 # the fsync below can take a very very long time. 3602 # the fsync below can take a very very long time.
3491 3603
3492 IO::AIO::aio_utime $RUNTIMEFILE, undef, undef; 3604 IO::AIO::aio_utime $RUNTIMEFILE, undef, undef;
3493 3605
3494 my $guard = cf::lock_acquire "write_runtime"; 3606 my $guard = cf::lock_acquire "write_runtime";
3495 3607
3496 my $fh = aio_open "$RUNTIMEFILE~", O_WRONLY | O_CREAT, 0644 3608 my $fh = aio_open "$RUNTIMEFILE~", O_WRONLY | O_CREAT | O_TRUNC, 0644
3497 or return; 3609 or return;
3498 3610
3499 my $value = $cf::RUNTIME + 90 + 10; 3611 my $value = $cf::RUNTIME + 90 + 10;
3500 # 10 is the runtime save interval, for a monotonic clock 3612 # 10 is the runtime save interval, for a monotonic clock
3501 # 60 allows for the watchdog to kill the server. 3613 # 60 allows for the watchdog to kill the server.
3514 or return; 3626 or return;
3515 3627
3516 aio_rename "$RUNTIMEFILE~", $RUNTIMEFILE 3628 aio_rename "$RUNTIMEFILE~", $RUNTIMEFILE
3517 and return; 3629 and return;
3518 3630
3519 warn "runtime file written.\n"; 3631 warn sprintf "runtime file written (%gs).\n", AE::time - $t0;
3520 3632
3521 1 3633 1
3522} 3634}
3523 3635
3524our $uuid_lock; 3636our $uuid_lock;
3662 return; 3774 return;
3663 } 3775 }
3664 3776
3665 return if $RELOAD++; 3777 return if $RELOAD++;
3666 3778
3667 my $t1 = EV::time; 3779 my $t1 = AE::time;
3668 3780
3669 while ($RELOAD) { 3781 while ($RELOAD) {
3670 warn "reloading..."; 3782 warn "reloading...";
3671 3783
3672 warn "entering sync_job"; 3784 warn "entering sync_job";
3743 3855
3744 warn "unload completed, starting to reload now"; 3856 warn "unload completed, starting to reload now";
3745 3857
3746 warn "reloading cf.pm"; 3858 warn "reloading cf.pm";
3747 require cf; 3859 require cf;
3748 cf::_connect_to_perl; # nominally unnecessary, but cannot hurt 3860 cf::_connect_to_perl_1;
3749 3861
3750 warn "loading config and database again"; 3862 warn "loading config and database again";
3751 cf::reload_config; 3863 cf::reload_config;
3752 3864
3753 warn "loading extensions"; 3865 warn "loading extensions";
3775 3887
3776 warn "reloaded"; 3888 warn "reloaded";
3777 --$RELOAD; 3889 --$RELOAD;
3778 } 3890 }
3779 3891
3780 $t1 = EV::time - $t1; 3892 $t1 = AE::time - $t1;
3781 warn "reload completed in ${t1}s\n"; 3893 warn "reload completed in ${t1}s\n";
3782}; 3894};
3783 3895
3784our $RELOAD_WATCHER; # used only during reload 3896our $RELOAD_WATCHER; # used only during reload
3785 3897
3788 # coro crashes during coro_state_free->destroy here. 3900 # coro crashes during coro_state_free->destroy here.
3789 3901
3790 $RELOAD_WATCHER ||= cf::async { 3902 $RELOAD_WATCHER ||= cf::async {
3791 Coro::AIO::aio_wait cache_extensions; 3903 Coro::AIO::aio_wait cache_extensions;
3792 3904
3793 $RELOAD_WATCHER = EV::timer $TICK * 1.5, 0, sub { 3905 $RELOAD_WATCHER = AE::timer $TICK * 1.5, 0, sub {
3794 do_reload_perl; 3906 do_reload_perl;
3795 undef $RELOAD_WATCHER; 3907 undef $RELOAD_WATCHER;
3796 }; 3908 };
3797 }; 3909 };
3798} 3910}
3815 3927
3816our @WAIT_FOR_TICK; 3928our @WAIT_FOR_TICK;
3817our @WAIT_FOR_TICK_BEGIN; 3929our @WAIT_FOR_TICK_BEGIN;
3818 3930
3819sub wait_for_tick { 3931sub wait_for_tick {
3820 return if tick_inhibit || $Coro::current == $Coro::main; 3932 return Coro::cede if tick_inhibit || $Coro::current == $Coro::main;
3821 3933
3822 my $signal = new Coro::Signal; 3934 my $signal = new Coro::Signal;
3823 push @WAIT_FOR_TICK, $signal; 3935 push @WAIT_FOR_TICK, $signal;
3824 $signal->wait; 3936 $signal->wait;
3825} 3937}
3826 3938
3827sub wait_for_tick_begin { 3939sub wait_for_tick_begin {
3828 return if tick_inhibit || $Coro::current == $Coro::main; 3940 return Coro::cede if tick_inhibit || $Coro::current == $Coro::main;
3829 3941
3830 my $signal = new Coro::Signal; 3942 my $signal = new Coro::Signal;
3831 push @WAIT_FOR_TICK_BEGIN, $signal; 3943 push @WAIT_FOR_TICK_BEGIN, $signal;
3832 $signal->wait; 3944 $signal->wait;
3833} 3945}
3838 unless ++$bug_warning > 10; 3950 unless ++$bug_warning > 10;
3839 return; 3951 return;
3840 } 3952 }
3841 3953
3842 cf::server_tick; # one server iteration 3954 cf::server_tick; # one server iteration
3955
3956 #for(1..3e6){} AE::now_update; $NOW=AE::now; # generate load #d#
3843 3957
3844 if ($NOW >= $NEXT_RUNTIME_WRITE) { 3958 if ($NOW >= $NEXT_RUNTIME_WRITE) {
3845 $NEXT_RUNTIME_WRITE = List::Util::max $NEXT_RUNTIME_WRITE + 10, $NOW + 5.; 3959 $NEXT_RUNTIME_WRITE = List::Util::max $NEXT_RUNTIME_WRITE + 10, $NOW + 5.;
3846 Coro::async_pool { 3960 Coro::async_pool {
3847 $Coro::current->{desc} = "runtime saver"; 3961 $Coro::current->{desc} = "runtime saver";
3870} 3984}
3871 3985
3872{ 3986{
3873 # configure BDB 3987 # configure BDB
3874 3988
3875 BDB::min_parallel 8; 3989 BDB::min_parallel 16;
3876 BDB::max_poll_reqs $TICK * 0.1; 3990 BDB::max_poll_reqs $TICK * 0.1;
3877 $AnyEvent::BDB::WATCHER->priority (1); 3991 $AnyEvent::BDB::WATCHER->priority (1);
3878 3992
3879 unless ($DB_ENV) { 3993 unless ($DB_ENV) {
3880 $DB_ENV = BDB::db_env_create; 3994 $DB_ENV = BDB::db_env_create;
3961 } 4075 }
3962} 4076}
3963 4077
3964# load additional modules 4078# load additional modules
3965require "cf/$_.pm" for @EXTRA_MODULES; 4079require "cf/$_.pm" for @EXTRA_MODULES;
4080cf::_connect_to_perl_2;
3966 4081
3967END { cf::emergency_save } 4082END { cf::emergency_save }
3968 4083
39691 40841
3970 4085

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines