Skip to content

Commit

Permalink
DummyPlayer: remove improper references
Browse files Browse the repository at this point in the history
  • Loading branch information
hemberger committed Apr 25, 2021
1 parent 73195a6 commit 69aa33b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/engine/Default/combat_simulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
8 changes: 3 additions & 5 deletions src/lib/Default/DummyPlayer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit 69aa33b

Please sign in to comment.