]> iEval git - mafia.git/commitdiff
Don't push/shift on array references
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 15 Aug 2015 15:47:38 +0000 (18:47 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 15 Aug 2015 15:47:45 +0000 (18:47 +0300)
lib/Mafia.pm

index d12b3eeea0f646e74c5e1f56f0ad7b277b73a19e..ada67d210e7278ce4ee11500ae04243fa19bc857 100644 (file)
@@ -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
                }
        }
 }
This page took 0.030373 seconds and 4 git commands to generate.