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

Comparing deliantra/server/ext/player-scheduler.ext (file contents):
Revision 1.2 by root, Tue Sep 30 10:09:51 2008 UTC vs.
Revision 1.7 by root, Sat Aug 13 20:20:30 2011 UTC

7 7
8our $SCHEDULER = cf::async_ext { 8our $SCHEDULER = cf::async_ext {
9 $Coro::current->{desc} = "player scheduler"; 9 $Coro::current->{desc} = "player scheduler";
10 10
11 while () { 11 while () {
12 Coro::EV::timer_once $SCHEDULE_INTERVAL; 12 Coro::AnyEvent::sleep $SCHEDULE_INTERVAL;
13 13
14 # this weird form of iteration over values is used because 14 # this weird form of iteration over values is used because
15 # the hash changes underneath us frequently, and for 15 # the hash changes underneath us frequently, and for
16 # keeps a direct reference to the value without (in 5.8 perls) 16 # keeps a direct reference to the value without (in 5.8 perls)
17 # keeping a reference, so this is prone to crashes or worse. 17 # keeping a reference, so this is prone to crashes or worse.
31 31
32 my $pl_ref = $pl->refcnt_cnt; 32 my $pl_ref = $pl->refcnt_cnt;
33 my $ob_ref = $ob->refcnt_cnt; 33 my $ob_ref = $ob->refcnt_cnt;
34 34
35 ## pl_ref == (P)$pl + (P)%cf::PLAYER + (C)ob->contr 35 ## pl_ref == (P)$pl + (P)%cf::PLAYER + (C)ob->contr
36 ## ob_ref == (P)$ob + (C)pl->observe + (C)simply being an object 36 ## ob_ref == (P)$ob + (C)pl->observe + (C)pl->viewpoint + (C)simply being an object
37 ## !$pl->ns ensures that ob == viewpoint == observe
37 if ($pl_ref == 3 && $ob_ref == 3) { 38 if ($pl_ref == 3 && $ob_ref == 4) {
38 warn "player-scheduler destroy ", $ob->name;#d# 39 cf::trace "player-scheduler destroy ", $ob->name;#d#
39 40
40 # remove from sight and get fresh "copies" 41 # remove from sight and get fresh "copies"
41 $pl = delete $cf::PLAYER{$ob->name}; 42 $pl = delete $cf::PLAYER{$ob->name};
42 $ob = $pl->ob; 43 $ob = $pl->ob;
43 44
44 $pl->destroy; # destroys $ob 45 $pl->destroy; # destroys $ob
45 } else { 46 } else {
46 my $a_ = $pl->refcnt;#d# 47 my $a_ = $pl->refcnt;#d#
47 my $b_ = $ob->refcnt;#d# 48 my $b_ = $ob->refcnt;#d#
48 49
49 warn "player-scheduler refcnt ", $ob->name, " pl $pl_ref/3 ob $ob_ref/3 (C pl $a_/1 ob $b_/2)\n";#d# 50 cf::debug "player-scheduler refcnt ", $ob->name, " pl $pl_ref/3 ob $ob_ref/3 (C pl $a_/1 ob $b_/2)\n";#d#
50 } 51 }
51 } 52 }
52 } 53 }
53 }; 54 };
54 warn $@ if $@; 55 cf::error $@ if $@;
56
55 cf::cede_to_tick; 57 cf::cede_to_tick;
56 }; 58 };
57 } 59 }
58}; 60};
59 61

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines