From 69aa33b1c100031dd9f0b1b458092eec6f8c6f99 Mon Sep 17 00:00:00 2001 From: Dan Hemberger Date: Fri, 23 Apr 2021 20:42:51 -0700 Subject: [PATCH] DummyPlayer: remove improper references See #317. --- src/engine/Default/combat_simulator.php | 8 ++++---- src/lib/Default/DummyPlayer.class.php | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/engine/Default/combat_simulator.php b/src/engine/Default/combat_simulator.php index 0215ce038..4b99623bf 100644 --- a/src/engine/Default/combat_simulator.php +++ b/src/engine/Default/combat_simulator.php @@ -21,9 +21,9 @@ continue; } $usedNames[$attackerName] = true; - $attackers[$i] =& DummyPlayer::getCachedDummyPlayer($attackerName); + $attackers[$i] = DummyPlayer::getCachedDummyPlayer($attackerName); $attackers[$i]->setAllianceID(1); - $realAttackers[$i] =& $attackers[$i]; + $realAttackers[$i] = $attackers[$i]; ++$i; } @@ -43,9 +43,9 @@ continue; } $usedNames[$defenderName] = true; - $defenders[$i] =& DummyPlayer::getCachedDummyPlayer($defenderName); + $defenders[$i] = DummyPlayer::getCachedDummyPlayer($defenderName); $defenders[$i]->setAllianceID(2); - $realDefenders[$i] =& $defenders[$i]; + $realDefenders[$i] = $defenders[$i]; ++$i; } diff --git a/src/lib/Default/DummyPlayer.class.php b/src/lib/Default/DummyPlayer.class.php index f7438f0ec..8839ac4b7 100644 --- a/src/lib/Default/DummyPlayer.class.php +++ b/src/lib/Default/DummyPlayer.class.php @@ -78,18 +78,16 @@ public function cacheDummyPlayer() { 'VALUES (\'DummyPlayer\', '.$db->escapeString($this->getPlayerName()).', '.$db->escapeObject($this).')'); } - public static function &getCachedDummyPlayer($name) { + public static function getCachedDummyPlayer($name) { $db = Smr\Database::getInstance(); $db->query('SELECT info FROM cached_dummys WHERE type = \'DummyPlayer\' AND id = ' . $db->escapeString($name) . ' LIMIT 1'); if($db->nextRecord()) { - $return = $db->getObject('info'); - return $return; + return $db->getObject('info'); } else { - $return = new DummyPlayer(); - return $return; + return new DummyPlayer(); } }