Skip to content

Commit

Permalink
SmrGalaxy: remove internal references
Browse files Browse the repository at this point in the history
  • Loading branch information
hemberger committed Mar 27, 2018
1 parent e5dc2ab commit 65ac798
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/Default/SmrGalaxy.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ class SmrGalaxy {
$galaxies = array();
while($db->nextRecord()) {
$galaxyID = $db->getField('galaxy_id');
$galaxies[$galaxyID] =& self::getGalaxy($gameID,$galaxyID,$forceUpdate);
$galaxies[$galaxyID] = self::getGalaxy($gameID,$galaxyID,$forceUpdate);
}
self::$CACHE_GAME_GALAXIES[$gameID] =& $galaxies;
self::$CACHE_GAME_GALAXIES[$gameID] = $galaxies;
}
return self::$CACHE_GAME_GALAXIES[$gameID];
}

public static function &getGalaxy($gameID,$galaxyID,$forceUpdate = false) {
if($forceUpdate || !isset(self::$CACHE_GALAXIES[$gameID][$galaxyID])) {
$g = new SmrGalaxy($gameID,$galaxyID);
self::$CACHE_GALAXIES[$gameID][$galaxyID] =& $g;
self::$CACHE_GALAXIES[$gameID][$galaxyID] = $g;
}
return self::$CACHE_GALAXIES[$gameID][$galaxyID];
}

public static function saveGalaxies() {
foreach(self::$CACHE_GALAXIES as &$gameGalaxies) {
foreach($gameGalaxies as &$galaxy) {
foreach(self::$CACHE_GALAXIES as $gameGalaxies) {
foreach($gameGalaxies as $galaxy) {
$galaxy->save();
}
}
Expand All @@ -51,7 +51,7 @@ class SmrGalaxy {
public static function &createGalaxy($gameID,$galaxyID) {
if(!isset(self::$CACHE_GALAXIES[$gameID][$galaxyID])) {
$g = new SmrGalaxy($gameID,$galaxyID,true);
self::$CACHE_GALAXIES[$gameID][$galaxyID] =& $g;
self::$CACHE_GALAXIES[$gameID][$galaxyID] = $g;
}
return self::$CACHE_GALAXIES[$gameID][$galaxyID];
}
Expand Down Expand Up @@ -160,7 +160,7 @@ class SmrGalaxy {
if($this->startSector === false) {
$this->startSector = 1;
if ($this->getGalaxyID() != 1) {
$galaxies =& SmrGalaxy::getGameGalaxies($this->getGameID());
$galaxies = SmrGalaxy::getGameGalaxies($this->getGameID());
for ($i=1;$i < $this->getGalaxyID();$i++) {
$this->startSector += $galaxies[$i]->getSize();
}
Expand Down Expand Up @@ -214,7 +214,7 @@ class SmrGalaxy {

$sectorID = $this->getStartSector();
for ($i = 0; $i < $this->getSize(); $i++) {
$sector =& SmrSector::createSector($this->gameID, $sectorID);
$sector = SmrSector::createSector($this->gameID, $sectorID);
$sector->setGalaxyID($this->getGalaxyID());
$sector->update(); //Have to save sectors after creating them
$sectorID++;
Expand All @@ -223,16 +223,16 @@ class SmrGalaxy {
while ($problem) {
$problem = false;

$galSectors =& SmrSector::getGalaxySectors($this->getGameID(),$this->getGalaxyID());
foreach($galSectors as &$galSector) {
$galSectors = SmrSector::getGalaxySectors($this->getGameID(),$this->getGalaxyID());
foreach($galSectors as $galSector) {
foreach($linkDirs as $linkDir) {
$galSector->disableLink($linkDir);
}
} unset($galSector);
}
$sectorID = $this->getStartSector();
for ($row = 1; $row <= $this->getHeight(); $row++) {
for ($col = 1; $col <= $this->getWidth(); $col++) {
$sector =& SmrSector::getSector($this->gameID,$sectorID);
$sector = SmrSector::getSector($this->gameID,$sectorID);
foreach($linkDirs as $linkDir) {
if (mt_rand(1,100) <= $connectivity) {
$sector->enableLink($linkDir);
Expand Down

0 comments on commit 65ac798

Please sign in to comment.