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.48 by root, Sun Aug 27 15:24:22 2006 UTC vs.
Revision 1.69 by root, Mon Sep 18 01:10:35 2006 UTC

11use Event; 11use Event;
12$Event::Eval = 1; # no idea why this is required, but it is 12$Event::Eval = 1; # no idea why this is required, but it is
13 13
14use strict; 14use strict;
15 15
16_reload_1; 16_init_vars;
17 17
18our %COMMAND = (); 18our %COMMAND = ();
19our @EVENT; 19our @EVENT;
20our %PROP_TYPE;
21our %PROP_IDX;
22our $LIBDIR = maps_directory "perl"; 20our $LIBDIR = maps_directory "perl";
23 21
24our $TICK = MAX_TIME * 1e-6; 22our $TICK = MAX_TIME * 1e-6;
25our $TICK_WATCHER; 23our $TICK_WATCHER;
26our $NEXT_TICK; 24our $NEXT_TICK;
34 print STDERR "cfperl: $msg"; 32 print STDERR "cfperl: $msg";
35 LOG llevError, "cfperl: $msg"; 33 LOG llevError, "cfperl: $msg";
36 }; 34 };
37} 35}
38 36
39my %ignore_set = (MAP_PROP_PATH => 1); # I hate the plug-in api. Deeply!
40
41# generate property mutators
42sub prop_gen {
43 my ($prefix, $class) = @_;
44
45 no strict 'refs';
46
47 for my $prop (keys %PROP_TYPE) {
48 $prop =~ /^\Q$prefix\E_(.*$)/ or next;
49 my $sub = lc $1;
50
51 my $type = $PROP_TYPE{$prop};
52 my $idx = $PROP_IDX {$prop};
53
54 *{"$class\::get_$sub"} = *{"$class\::$sub"} = sub {
55 $_[0]->get_property ($type, $idx)
56 };
57
58 *{"$class\::set_$sub"} = sub {
59 $_[0]->set_property ($type, $idx, $_[1]);
60 } unless $ignore_set{$prop};
61 }
62}
63
64# auto-generate most of the API
65
66prop_gen OBJECT_PROP => "cf::object";
67# CFAPI_OBJECT_ANIMATION?
68prop_gen PLAYER_PROP => "cf::object::player";
69
70prop_gen MAP_PROP => "cf::map";
71prop_gen ARCH_PROP => "cf::arch";
72
73@safe::cf::object::player::ISA = @cf::object::player::ISA = 'cf::object'; 37@safe::cf::object::player::ISA = @cf::object::player::ISA = 'cf::object';
74 38
75# we bless all objects into (empty) derived classes to force a method lookup 39# we bless all objects into (empty) derived classes to force a method lookup
76# within the Safe compartment. 40# within the Safe compartment.
77for my $pkg (qw(cf::object cf::object::player cf::player cf::map cf::party cf::region cf::arch)) { 41for my $pkg (qw(cf::object cf::object::player cf::player cf::map cf::party cf::region cf::arch cf::living)) {
78 no strict 'refs'; 42 no strict 'refs';
79 @{"safe::$pkg\::wrap::ISA"} = @{"$pkg\::wrap::ISA"} = $pkg; 43 @{"safe::$pkg\::wrap::ISA"} = @{"$pkg\::wrap::ISA"} = $pkg;
80} 44}
81 45
82$Event::DIED = sub { 46$Event::DIED = sub {
105} 69}
106 70
107############################################################################# 71#############################################################################
108# "new" plug-in system 72# "new" plug-in system
109 73
74=head3 EVENTS AND OBJECT ATTACHMENTS
75
76=over 4
77
110=item $object->attach ($attachment, key => $value...) 78=item $object->attach ($attachment, key => $value...)
111 79
80=item $object->detach ($attachment)
81
112Attach a pre-registered attachment to an object. 82Attach/detach a pre-registered attachment to an object.
113 83
114=item $player->attach ($attachment, key => $value...) 84=item $player->attach ($attachment, key => $value...)
115 85
86=item $player->detach ($attachment)
87
116Attach a pre-registered attachment to a player. 88Attach/detach a pre-registered attachment to a player.
117 89
118=item $map->attach ($attachment, key => $value...) # not yet persistent 90=item $map->attach ($attachment, key => $value...)
119 91
92=item $map->detach ($attachment)
93
120Attach a pre-registered attachment to a map. 94Attach/detach a pre-registered attachment to a map.
95
96=item $bool = $object->attached ($name)
97
98=item $bool = $player->attached ($name)
99
100=item $bool = $map->attached ($name)
101
102Checks wether the named attachment is currently attached to the object.
121 103
122=item cf::attach_global ... 104=item cf::attach_global ...
123 105
124Attach handlers for global events. 106Attach handlers for global events.
125 107
173=item cf::attach_to_maps ... 155=item cf::attach_to_maps ...
174 156
175Attach handlers to all maps. 157Attach handlers to all maps.
176 158
177=item cf:register_attachment $name, ... 159=item cf:register_attachment $name, ...
160
161Register an attachment by name through which objects can refer to this
162attachment.
163
164=item cf:register_player_attachment $name, ...
165
166Register an attachment by name through which players can refer to this
167attachment.
168
169=item cf:register_map_attachment $name, ...
170
171Register an attachment by name through which maps can refer to this
172attachment.
178 173
179=cut 174=cut
180 175
181# the following variables are defined in .xs and must not be re-created 176# the following variables are defined in .xs and must not be re-created
182our @CB_GLOBAL = (); # registry for all global events 177our @CB_GLOBAL = (); # registry for all global events
247} 242}
248 243
249sub _attach_attachment { 244sub _attach_attachment {
250 my ($obj, $name, %arg) = @_; 245 my ($obj, $name, %arg) = @_;
251 246
247 return if exists $obj->{_attachment}{$name};
248
252 my $res; 249 my $res;
253 250
254 if (my $attach = $attachment{$name}) { 251 if (my $attach = $attachment{$name}) {
255 my $registry = $obj->registry; 252 my $registry = $obj->registry;
256 253
262 $obj->{$name} = \%arg; 259 $obj->{$name} = \%arg;
263 } else { 260 } else {
264 warn "object uses attachment '$name' that is not available, postponing.\n"; 261 warn "object uses attachment '$name' that is not available, postponing.\n";
265 } 262 }
266 263
267 push @{$obj->{_attachment}}, $name; 264 $obj->{_attachment}{$name} = undef;
268 265
269 $res->{attachment} = $name; 266 $res->{attachment} = $name;
270 $res 267 $res
271} 268}
272 269
273sub cf::object::attach { 270*cf::object::attach =
271*cf::player::attach =
272*cf::map::attach = sub {
274 my ($obj, $name, %arg) = @_; 273 my ($obj, $name, %arg) = @_;
275 274
276 _attach_attachment $obj, $name, %arg; 275 _attach_attachment $obj, $name, %arg;
277} 276};
278 277
278# all those should be optimised
279*cf::object::detach =
279sub cf::player::attach { 280*cf::player::detach =
281*cf::map::detach = sub {
280 my ($obj, $name, %arg) = @_; 282 my ($obj, $name) = @_;
281 283
282 _attach_attachment KLASS_PLAYER, $obj, $name, %arg; 284 delete $obj->{_attachment}{$name};
283} 285 reattach ($obj);
286};
284 287
285sub cf::map::attach { 288*cf::object::attached =
289*cf::player::attached =
290*cf::map::attached = sub {
286 my ($obj, $name, %arg) = @_; 291 my ($obj, $name) = @_;
287 292
288 _attach_attachment KLASS_MAP, $obj, $name, %arg; 293 exists $obj->{_attachment}{$name}
289} 294};
290 295
291sub attach_global { 296sub attach_global {
292 _attach @CB_GLOBAL, KLASS_GLOBAL, @_ 297 _attach @CB_GLOBAL, KLASS_GLOBAL, @_
293} 298}
294 299
315 my $name = shift; 320 my $name = shift;
316 321
317 $attachment{$name} = [[KLASS_OBJECT, @_]]; 322 $attachment{$name} = [[KLASS_OBJECT, @_]];
318} 323}
319 324
325sub register_player_attachment {
326 my $name = shift;
327
328 $attachment{$name} = [[KLASS_PLAYER, @_]];
329}
330
331sub register_map_attachment {
332 my $name = shift;
333
334 $attachment{$name} = [[KLASS_MAP, @_]];
335}
336
320our $override; 337our $override;
321our @invoke_results = (); # referenced from .xs code. TODO: play tricks with reify and mortals? 338our @invoke_results = (); # referenced from .xs code. TODO: play tricks with reify and mortals?
322 339
323sub override { 340sub override {
324 $override = 1; 341 $override = 1;
336 for (@$callbacks) { 353 for (@$callbacks) {
337 eval { &{$_->[1]} }; 354 eval { &{$_->[1]} };
338 355
339 if ($@) { 356 if ($@) {
340 warn "$@"; 357 warn "$@";
341 warn "... while processing $EVENT[$event][0] event, skipping processing altogether.\n"; 358 warn "... while processing $EVENT[$event][0](@_) event, skipping processing altogether.\n";
342 override; 359 override;
343 } 360 }
344 361
345 return 1 if $override; 362 return 1 if $override;
346 } 363 }
347 364
348 0 365 0
349} 366}
367
368=item $bool = cf::invoke EVENT_GLOBAL_XXX, ...
369
370=item $bool = $object->invoke (EVENT_OBJECT_XXX, ...)
371
372=item $bool = $player->invoke (EVENT_PLAYER_XXX, ...)
373
374=item $bool = $map->invoke (EVENT_MAP_XXX, ...)
375
376Generate a global/object/player/map-specific event with the given arguments.
377
378This API is preliminary (most likely, the EVENT_KLASS_xxx prefix will be
379removed in future versions), and there is no public API to access override
380results (if you must, access C<@cf::invoke_results> directly).
381
382=back
383
384=head2 methods valid for all pointers
385
386=over 4
387
388=item $object->valid
389
390=item $player->valid
391
392=item $map->valid
393
394Just because you have a perl object does not mean that the corresponding
395C-level object still exists. If you try to access an object that has no
396valid C counterpart anymore you get an exception at runtime. This method
397can be used to test for existence of the C object part without causing an
398exception.
399
400=back
401
402=cut
403
404*cf::object::valid =
405*cf::player::valid =
406*cf::map::valid = \&cf::_valid;
350 407
351############################################################################# 408#############################################################################
352# object support 409# object support
353 410
354sub instantiate { 411sub instantiate {
356 413
357 $data = from_json $data; 414 $data = from_json $data;
358 415
359 for (@$data) { 416 for (@$data) {
360 my ($name, $args) = @$_; 417 my ($name, $args) = @$_;
418
361 attach $obj, $name, %{$args || {} }; 419 $obj->attach ($name, %{$args || {} });
362 } 420 }
363} 421}
364 422
365# basically do the same as instantiate, without calling instantiate 423# basically do the same as instantiate, without calling instantiate
366sub reattach { 424sub reattach {
367 my ($obj) = @_; 425 my ($obj) = @_;
368 my $registry = $obj->registry; 426 my $registry = $obj->registry;
369 427
370 @$registry = (); 428 @$registry = ();
371 429
430 delete $obj->{_attachment} unless scalar keys %{ $obj->{_attachment} || {} };
431
372 for my $name (@{ $obj->{_attachment} }) { 432 for my $name (keys %{ $obj->{_attachment} || {} }) {
373 if (my $attach = $attachment{$name}) { 433 if (my $attach = $attachment{$name}) {
374 for (@$attach) { 434 for (@$attach) {
375 my ($klass, @attach) = @$_; 435 my ($klass, @attach) = @$_;
376 _attach @$registry, $klass, @attach; 436 _attach @$registry, $klass, @attach;
377 } 437 }
380 } 440 }
381 } 441 }
382} 442}
383 443
384sub object_freezer_save { 444sub object_freezer_save {
385 my ($filename, $objs) = @_; 445 my ($filename, $rdata, $objs) = @_;
386 446
387 $filename .= ".pst"; 447 if (length $$rdata) {
448 warn sprintf "saving %s (%d,%d)\n",
449 $filename, length $$rdata, scalar @$objs;
388 450
389 if (@$objs) {
390 open my $fh, ">:raw", "$filename~"; 451 if (open my $fh, ">:raw", "$filename~") {
391 chmod $fh, SAVE_MODE; 452 chmod SAVE_MODE, $fh;
453 syswrite $fh, $$rdata;
454 close $fh;
455
456 if (@$objs && open my $fh, ">:raw", "$filename.pst~") {
457 chmod SAVE_MODE, $fh;
392 syswrite $fh, Storable::nfreeze { version => 1, objs => $objs }; 458 syswrite $fh, Storable::nfreeze { version => 1, objs => $objs };
393 close $fh; 459 close $fh;
460 rename "$filename.pst~", "$filename.pst";
461 } else {
462 unlink "$filename.pst";
463 }
464
394 rename "$filename~", $filename; 465 rename "$filename~", $filename;
466 } else {
467 warn "FATAL: $filename~: $!\n";
468 }
395 } else { 469 } else {
396 unlink $filename; 470 unlink $filename;
471 unlink "$filename.pst";
397 } 472 }
398} 473}
399 474
400sub object_thawer_load { 475sub object_thawer_load {
401 my ($filename) = @_; 476 my ($filename) = @_;
402 477
478 local $/;
479
480 my $av;
481
482 #TODO: use sysread etc.
483 if (open my $data, "<:raw:perlio", $filename) {
484 $data = <$data>;
403 open my $fh, "<:raw:perlio", "$filename.pst" 485 if (open my $pst, "<:raw:perlio", "$filename.pst") {
404 or return; 486 $av = eval { (Storable::thaw <$pst>)->{objs} };
487 }
488 return ($data, $av);
489 }
405 490
406 eval { local $/; (Storable::thaw <$fh>)->{objs} } 491 ()
407} 492}
408 493
409attach_to_objects 494attach_to_objects
410 prio => -1000000, 495 prio => -1000000,
411 on_clone => sub { 496 on_clone => sub {
413 498
414 @{$dst->registry} = @{$src->registry}; 499 @{$dst->registry} = @{$src->registry};
415 500
416 %$dst = %$src; 501 %$dst = %$src;
417 502
418 $dst->{_attachment} = [@{ $src->{_attachment} }] 503 %{$dst->{_attachment}} = %{$src->{_attachment}}
419 if exists $src->{_attachment}; 504 if exists $src->{_attachment};
420 }, 505 },
421; 506;
422 507
423############################################################################# 508#############################################################################
557 load_extension $ext; 642 load_extension $ext;
558 1 643 1
559 } or warn "$ext not loaded: $@"; 644 } or warn "$ext not loaded: $@";
560 } 645 }
561} 646}
562
563sub _perl_reload(&) {
564 my ($msg) = @_;
565
566 $msg->("reloading...");
567
568 eval {
569 # 1. cancel all watchers
570 $_->cancel for Event::all_watchers;
571
572 # 2. unload all extensions
573 for (@exts) {
574 $msg->("unloading <$_>");
575 unload_extension $_;
576 }
577
578 # 3. unload all modules loaded from $LIBDIR
579 while (my ($k, $v) = each %INC) {
580 next unless $v =~ /^\Q$LIBDIR\E\/.*\.pm$/;
581
582 $msg->("removing <$k>");
583 delete $INC{$k};
584
585 $k =~ s/\.pm$//;
586 $k =~ s/\//::/g;
587
588 if (my $cb = $k->can ("unload_module")) {
589 $cb->();
590 }
591
592 Symbol::delete_package $k;
593 }
594
595 # 4. get rid of safe::, as good as possible
596 Symbol::delete_package "safe::$_"
597 for qw(cf::object cf::object::player cf::player cf::map cf::party cf::region);
598
599 # 5. remove register_script_function callbacks
600 # TODO
601
602 # 6. unload cf.pm "a bit"
603 delete $INC{"cf.pm"};
604
605 # don't, removes xs symbols, too,
606 # and global variables created in xs
607 #Symbol::delete_package __PACKAGE__;
608
609 # 7. reload cf.pm
610 $msg->("reloading cf.pm");
611 require cf;
612 };
613 $msg->($@) if $@;
614
615 $msg->("reloaded");
616};
617
618sub perl_reload() {
619 _perl_reload {
620 warn $_[0];
621 print "$_[0]\n";
622 };
623}
624
625register_command "perl-reload", 0, sub {
626 my ($who, $arg) = @_;
627
628 if ($who->flag (FLAG_WIZ)) {
629 _perl_reload {
630 warn $_[0];
631 $who->message ($_[0]);
632 };
633 }
634};
635 647
636############################################################################# 648#############################################################################
637# extcmd framework, basically convert ext <msg> 649# extcmd framework, basically convert ext <msg>
638# into pkg::->on_extcmd_arg1 (...) while shortcutting a few 650# into pkg::->on_extcmd_arg1 (...) while shortcutting a few
639 651
664 my ($map) = @_; 676 my ($map) = @_;
665 677
666 my $path = $map->tmpname; 678 my $path = $map->tmpname;
667 defined $path or return; 679 defined $path or return;
668 680
669 unlink "$path.cfperl";
670 unlink "$path.pst"; 681 unlink "$path.pst";
671}; 682};
672 683
673*cf::mapsupport::on_swapin =
674*cf::mapsupport::on_load = sub {
675 my ($map) = @_;
676
677 my $path = $map->tmpname;
678 $path = $map->path unless defined $path;
679
680 open my $fh, "<:raw", "$path.cfperl"
681 or return; # no perl data
682
683 my $data = Storable::thaw do { local $/; <$fh> };
684
685 $data->{version} <= 1
686 or return; # too new
687
688 $map->_set_obs ($data->{obs});
689};
690
691attach_to_maps prio => -10000, package => cf::mapsupport::; 684attach_to_maps prio => -10000, package => cf::mapsupport::;
692 685
693############################################################################# 686#############################################################################
694# load/save perl data associated with player->ob objects 687# load/save perl data associated with player->ob objects
695 688
696sub all_objects(@) { 689sub all_objects(@) {
697 @_, map all_objects ($_->inv), @_ 690 @_, map all_objects ($_->inv), @_
698} 691}
699 692
693# TODO: compatibility cruft, remove when no longer needed
700attach_to_players 694attach_to_players
701 on_load => sub { 695 on_load => sub {
702 my ($pl, $path) = @_; 696 my ($pl, $path) = @_;
703 697
704 for my $o (all_objects $pl->ob) { 698 for my $o (all_objects $pl->ob) {
814 } 808 }
815 809
816 wantarray ? @res : $res[0] 810 wantarray ? @res : $res[0]
817} 811}
818 812
813=item cf::register_script_function $function => $cb
814
815Register a function that can be called from within map/npc scripts. The
816function should be reasonably secure and should be put into a package name
817like the extension.
818
819Example: register a function that gets called whenever a map script calls
820C<rent::overview>, as used by the C<rent> extension.
821
822 cf::register_script_function "rent::overview" => sub {
823 ...
824 };
825
826=cut
827
819sub register_script_function { 828sub register_script_function {
820 my ($fun, $cb) = @_; 829 my ($fun, $cb) = @_;
821 830
822 no strict 'refs'; 831 no strict 'refs';
823 *{"safe::$fun"} = $safe_hole->wrap ($cb); 832 *{"safe::$fun"} = $safe_hole->wrap ($cb);
824} 833}
825 834
826############################################################################# 835#############################################################################
836
837=head2 EXTENSION DATABASE SUPPORT
838
839Crossfire maintains a very simple database for extension use. It can
840currently store anything that can be serialised using Storable, which
841excludes objects.
842
843The parameter C<$family> should best start with the name of the extension
844using it, it should be unique.
845
846=over 4
847
848=item $hashref = cf::db_get $family
849
850Return a hashref for use by the extension C<$family>, which can be
851modified. After modifications, you have to call C<cf::db_dirty> or
852C<cf::db_sync>.
853
854=item $value = cf::db_get $family => $key
855
856Returns a single value from the database
857
858=item cf::db_put $family => $hashref
859
860Stores the given family hashref into the database. Updates are delayed, if
861you want the data to be synced to disk immediately, use C<cf::db_sync>.
862
863=item cf::db_put $family => $key => $value
864
865Stores the given C<$value> in the family hash. Updates are delayed, if you
866want the data to be synced to disk immediately, use C<cf::db_sync>.
867
868=item cf::db_dirty
869
870Marks the database as dirty, to be updated at a later time.
871
872=item cf::db_sync
873
874Immediately write the database to disk I<if it is dirty>.
875
876=cut
877
878{
879 my $db;
880 my $path = cf::localdir . "/database.pst";
881
882 sub db_load() {
883 warn "loading database $path\n";#d# remove later
884 $db = stat $path ? Storable::retrieve $path : { };
885 }
886
887 my $pid;
888
889 sub db_save() {
890 warn "saving database $path\n";#d# remove later
891 waitpid $pid, 0 if $pid;
892 if (0 == ($pid = fork)) {
893 $db->{_meta}{version} = 1;
894 Storable::nstore $db, "$path~";
895 rename "$path~", $path;
896 cf::_exit 0 if defined $pid;
897 }
898 }
899
900 my $dirty;
901
902 sub db_sync() {
903 db_save if $dirty;
904 undef $dirty;
905 }
906
907 my $idle = Event->idle (min => $TICK * 2.8, max => 10, repeat => 0, cb => sub {
908 db_sync;
909 });
910
911 sub db_dirty() {
912 $dirty = 1;
913 $idle->start;
914 }
915
916 sub db_get($;$) {
917 @_ >= 2
918 ? $db->{$_[0]}{$_[1]}
919 : ($db->{$_[0]} ||= { })
920 }
921
922 sub db_put($$;$) {
923 if (@_ >= 3) {
924 $db->{$_[0]}{$_[1]} = $_[2];
925 } else {
926 $db->{$_[0]} = $_[1];
927 }
928 db_dirty;
929 }
930
931 attach_global
932 prio => 10000,
933 on_cleanup => sub {
934 db_sync;
935 },
936 ;
937}
938
939#############################################################################
827# the server's main() 940# the server's main()
828 941
829sub main { 942sub main {
943 db_load;
944 load_extensions;
830 Event::loop; 945 Event::loop;
831} 946}
832 947
833############################################################################# 948#############################################################################
834# initialisation 949# initialisation
835 950
951sub _perl_reload(&) {
952 my ($msg) = @_;
953
954 $msg->("reloading...");
955
956 eval {
957 # cancel all watchers
958 $_->cancel for Event::all_watchers;
959
960 # unload all extensions
961 for (@exts) {
962 $msg->("unloading <$_>");
963 unload_extension $_;
964 }
965
966 # unload all modules loaded from $LIBDIR
967 while (my ($k, $v) = each %INC) {
968 next unless $v =~ /^\Q$LIBDIR\E\/.*\.pm$/;
969
970 $msg->("removing <$k>");
971 delete $INC{$k};
972
973 $k =~ s/\.pm$//;
974 $k =~ s/\//::/g;
975
976 if (my $cb = $k->can ("unload_module")) {
977 $cb->();
978 }
979
980 Symbol::delete_package $k;
981 }
982
983 # sync database to disk
984 cf::db_sync;
985
986 # get rid of safe::, as good as possible
987 Symbol::delete_package "safe::$_"
988 for qw(cf::object cf::object::player cf::player cf::map cf::party cf::region);
989
990 # remove register_script_function callbacks
991 # TODO
992
993 # unload cf.pm "a bit"
994 delete $INC{"cf.pm"};
995
996 # don't, removes xs symbols, too,
997 # and global variables created in xs
998 #Symbol::delete_package __PACKAGE__;
999
1000 # reload cf.pm
1001 $msg->("reloading cf.pm");
1002 require cf;
1003
1004 # load database again
1005 cf::db_load;
1006
1007 # load extensions
1008 $msg->("load extensions");
1009 cf::load_extensions;
1010
1011 # reattach attachments to objects
1012 $msg->("reattach");
1013 _global_reattach;
1014 };
1015 $msg->($@) if $@;
1016
1017 $msg->("reloaded");
1018};
1019
1020sub perl_reload() {
1021 _perl_reload {
1022 warn $_[0];
1023 print "$_[0]\n";
1024 };
1025}
1026
1027register_command "perl-reload", 0, sub {
1028 my ($who, $arg) = @_;
1029
1030 if ($who->flag (FLAG_WIZ)) {
1031 _perl_reload {
1032 warn $_[0];
1033 $who->message ($_[0]);
1034 };
1035 }
1036};
1037
836register "<global>", __PACKAGE__; 1038register "<global>", __PACKAGE__;
837 1039
838unshift @INC, $LIBDIR; 1040unshift @INC, $LIBDIR;
839
840load_extensions;
841 1041
842$TICK_WATCHER = Event->timer ( 1042$TICK_WATCHER = Event->timer (
843 prio => 1, 1043 prio => 1,
844 at => $NEXT_TICK || 1, 1044 at => $NEXT_TICK || 1,
845 cb => sub { 1045 cb => sub {
854 $TICK_WATCHER->at ($NEXT_TICK); 1054 $TICK_WATCHER->at ($NEXT_TICK);
855 $TICK_WATCHER->start; 1055 $TICK_WATCHER->start;
856 }, 1056 },
857); 1057);
858 1058
859_reload_2;
860
8611 10591
862 1060

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines