From: Marius Gavrilescu Date: Sat, 15 Aug 2015 15:47:38 +0000 (+0300) Subject: Don't push/shift on array references X-Git-Tag: 0.001002~5 X-Git-Url: http://git.ieval.ro/?p=mafia.git;a=commitdiff_plain;h=52b3d86957b5e07c54378a0fe96e666a00e9b2ec Don't push/shift on array references --- diff --git a/lib/Mafia.pm b/lib/Mafia.pm index d12b3ee..ada67d2 100644 --- a/lib/Mafia.pm +++ b/lib/Mafia.pm @@ -176,7 +176,7 @@ sub putaction { if (exists $args{target} && exists $args{source} && $players{$args{target}}{faction} eq mafia && $players{$args{source}}{weak}) { putaction($delay, ACT_KILL, target => $args{source}, reason => 'targeted scum'); } - push $actions[$delay]->{$type}, \%args + push @{$actions[$delay]->{$type}}, \%args } sub doaction { @@ -187,9 +187,9 @@ sub doaction { if (defined $source && defined $target) { # Watcher and tracker variables $tplayers{$source}{targets} //= []; - push $tplayers{$source}{targets}, $target; + push @{$tplayers{$source}{targets}}, $target; $tplayers{$target}{sources} //= []; - push $tplayers{$target}{sources}, $source; + push @{$tplayers{$target}{sources}}, $source; # Copy this action to everybody hiding behind $target if (exists $tplayers{$target}{hiders}) { @@ -219,7 +219,7 @@ sub doaction { if ($tplayers{$target}{guard_count} && defined $source) { $tplayers{$target}{guard_count}--; # Copy this action to the first guard - $args{target} = shift $tplayers{$target}{guards}; + $args{target} = shift @{$tplayers{$target}{guards}}; @_ = ($type, %args); goto &doaction; } @@ -234,7 +234,7 @@ sub doaction { when(ACT_LYNCH){ if ($tplayers{$target}{guard_count}) { $tplayers{$target}{guard_count}--; - $args{target} = shift $tplayers{$target}{guards}; + $args{target} = shift @{$tplayers{$target}{guards}}; $target=$args{target}; } if ($tplayers{$target}{protection}) { @@ -271,7 +271,7 @@ sub doaction { when(ACT_GUARD){ $tplayers{$target}{guard_count}++; $tplayers{$target}{guards} //= []; - push $tplayers{$target}{guards}, $source; + push @{$tplayers{$target}{guards}}, $source; } when(ACT_ROLECOP){ @@ -290,7 +290,7 @@ sub doaction { when(ACT_HIDE){ $tplayers{$source}{hidden} = 1; $tplayers{$target}{hiders} //= []; - push $tplayers{$target}{hiders}, $source + push @{$tplayers{$target}{hiders}}, $source } } }