--- deliantra/server/ext/map-scheduler.ext 2007/01/02 21:13:22 1.7 +++ deliantra/server/ext/map-scheduler.ext 2007/01/03 12:33:33 1.9 @@ -13,7 +13,16 @@ while () { Coro::Timer::sleep $SCHEDULE_INTERVAL; - for my $map (values %cf::MAP) { + # this weird form of iteration over values is used because + # the hash changes underneath us frequently, and for + # keeps a direct reference to the value without (in 5.8 perls) + # keeping a reference, so this is prone to crashes or worse. + my @maps = keys %cf::MAP; + for (@maps) { + my $map = $cf::MAP{$_} + or next; + $map->valid or next; + eval { # not yet, because maps might become visible to players nearby # we need to remove the map from %cf::MAP and all tiled map links @@ -35,7 +44,7 @@ }; warn $@ if $@; Coro::cede; - } + }; } };