Skip to content

Commit

Permalink
SmrPlanet: remove internal references
Browse files Browse the repository at this point in the history
  • Loading branch information
hemberger committed Mar 27, 2018
1 parent 98588e3 commit e7c88c9
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/Default/SmrPlanet.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class SmrPlanet {
}

public static function savePlanets() {
foreach(self::$CACHE_PLANETS as &$gamePlanets) {
foreach($gamePlanets as &$planet) {
foreach(self::$CACHE_PLANETS as $gamePlanets) {
foreach($gamePlanets as $planet) {
$planet->update();
}
}
Expand All @@ -68,7 +68,7 @@ class SmrPlanet {
public static function &getPlanet($gameID,$sectorID,$forceUpdate = false) {
if($forceUpdate || !isset(self::$CACHE_PLANETS[$gameID][$sectorID])) {
$p = new SmrPlanet($gameID,$sectorID);
self::$CACHE_PLANETS[$gameID][$sectorID] =& $p;
self::$CACHE_PLANETS[$gameID][$sectorID] = $p;
}
return self::$CACHE_PLANETS[$gameID][$sectorID];
}
Expand Down Expand Up @@ -682,7 +682,7 @@ class SmrPlanet {
while($this->db->nextRecord()) {
if($this->db->getInt('time_complete') <= TIME) {
$expGain = $this->getConstructionExp($this->db->getInt('construction_id'));
$player =& SmrPlayer::getPlayer($this->db->getInt('constructor_id'),$this->getGameID());
$player = SmrPlayer::getPlayer($this->db->getInt('constructor_id'),$this->getGameID());
$player->increaseHOF(1,array('Planet','Buildings','Built'), HOF_ALLIANCE);
$player->increaseExperience($expGain);
$player->increaseHOF($expGain,array('Planet','Buildings','Experience'), HOF_ALLIANCE);
Expand Down Expand Up @@ -942,7 +942,7 @@ class SmrPlanet {

function accuracy() {
if($this->hasWeapons()) {
$weapons =& $this->getWeapons();
$weapons = $this->getWeapons();
return $weapons[0]->getModifiedPlanetAccuracy($this);
}
return 0;
Expand All @@ -966,7 +966,7 @@ class SmrPlanet {
if($this->getBuilding($constructionID) >= $this->getMaxBuildings($constructionID)) {
return 'This planet has reached the maximum buildings of that type.';
}
$PLANET_BUILDINGS =& Globals::getPlanetBuildings();
$PLANET_BUILDINGS = Globals::getPlanetBuildings();
if($constructor->getCredits() < $PLANET_BUILDINGS[$constructionID]['Credit Cost'][$this->getTypeID()]) {
return 'You do not have enough credits.';
}
Expand Down Expand Up @@ -1004,7 +1004,7 @@ class SmrPlanet {
if(($message = $this->canBuild($constructor, $constructionID)) !== true) {
throw new Exception('Unable to start building: '.$message);
}
$PLANET_BUILDINGS =& Globals::getPlanetBuildings();
$PLANET_BUILDINGS = Globals::getPlanetBuildings();
$constructor->decreaseCredits($PLANET_BUILDINGS[$constructionID]['Credit Cost'][$this->getTypeID()]);
// take the goods that are needed
foreach($PLANET_BUILDINGS[$constructionID]['Goods'] as $goodID => $amount) {
Expand Down Expand Up @@ -1116,7 +1116,7 @@ class SmrPlanet {
$this->db->query('SELECT 1 FROM news WHERE type = \'BREAKING\' AND game_id = ' . $this->db->escapeNumber($trigger->getGameID()) . ' AND time > ' . $this->db->escapeNumber(TIME - self::TIME_BEFORE_REPLACING_BREAKING_NEWS) . ' LIMIT 1');
if ($this->db->getNumRows()==0) {
if (count($attackers) >= 5) {
$owner =& $this->getOwner();
$owner = $this->getOwner();
$text = count($attackers) . ' members of '.$trigger->getAllianceBBLink().' have been spotted attacking ' .
$this->getDisplayName() . ' in sector ' . Globals::getSectorBBLink($this->getSectorID()) . '. The planet is owned by ' . $owner->getBBLink();
if ($owner->hasAlliance()) {
Expand Down Expand Up @@ -1155,29 +1155,29 @@ class SmrPlanet {
public function hasEnemyTraders(AbstractSmrPlayer &$player) {
if(!$this->hasOtherTraders($player))
return false;
$otherPlayers =& $this->getOtherTraders($player);
foreach($otherPlayers as &$otherPlayer) {
$otherPlayers = $this->getOtherTraders($player);
foreach($otherPlayers as $otherPlayer) {
if(!$player->traderNAPAlliance($otherPlayer))
return true;
} unset($otherPlayer);
}
return false;
}

public function hasFriendlyTraders(AbstractSmrPlayer &$player) {
if(!$this->hasOtherTraders($player))
return false;
$otherPlayers =& $this->getOtherTraders($player);
foreach($otherPlayers as &$otherPlayer) {
$otherPlayers = $this->getOtherTraders($player);
foreach($otherPlayers as $otherPlayer) {
if($player->traderNAPAlliance($otherPlayer))
return true;
} unset($otherPlayer);
}
return false;
}

public function &getWeapons() {
$weapons = array();
for($i=0;$i<$this->getBuilding(PLANET_TURRET);++$i) {
$weapons[$i] =& SmrWeapon::getWeapon(Globals::getGameType($this->getGameID()),WEAPON_PLANET_TURRET);
$weapons[$i] = SmrWeapon::getWeapon(Globals::getGameType($this->getGameID()),WEAPON_PLANET_TURRET);
}
return $weapons;
}
Expand All @@ -1192,16 +1192,16 @@ class SmrPlanet {

public function &shootPlayers(array &$targetPlayers) {
$results = array('Planet' => &$this, 'TotalDamage' => 0, $results['TotalDamagePerTargetPlayer'] = array());
foreach($targetPlayers as &$targetPlayer) {
foreach($targetPlayers as $targetPlayer) {
$results['TotalDamagePerTargetPlayer'][$targetPlayer->getAccountID()] = 0;
} unset($targetPlayer);
}
if($this->isDestroyed()) {
$results['DeadBeforeShot'] = true;
return $results;
}
$results['DeadBeforeShot'] = false;
$weapons =& $this->getWeapons();
foreach($weapons as $orderID => &$weapon) {
$weapons = $this->getWeapons();
foreach($weapons as $orderID => $weapon) {
$results['Weapons'][$orderID] =& $weapon->shootPlayerAsPlanet($this, $targetPlayers[array_rand($targetPlayers)]);
if($results['Weapons'][$orderID]['Hit']) {
$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
Expand Down Expand Up @@ -1343,7 +1343,7 @@ class SmrPlanet {
//get all players involved for HoF
$this->db->query('SELECT account_id,level FROM player_attacks_planet WHERE game_id = ' . $this->db->escapeNumber($this->getGameID()) . ' AND sector_id = ' . $this->db->escapeNumber($this->getSectorID()) . ' AND time > ' . $this->db->escapeNumber(TIME - self::TIME_TO_CREDIT_BUST));
while ($this->db->nextRecord()) {
$currPlayer =& SmrPlayer::getPlayer($this->db->getInt('account_id'),$this->getGameID());
$currPlayer = SmrPlayer::getPlayer($this->db->getInt('account_id'),$this->getGameID());
$currPlayer->increaseHOF($this->db->getInt('level'),array('Combat','Planet','Levels'), HOF_PUBLIC);
$currPlayer->increaseHOF(1,array('Combat','Planet','Completed'), HOF_PUBLIC);
}
Expand Down

0 comments on commit e7c88c9

Please sign in to comment.