Skip to content

Commit

Permalink
SectorsFile.php: remove unintentional indentation (#1787)
Browse files Browse the repository at this point in the history
As a result of the indentation for the switch from engine pages to Page
classes in 5825816, literal multi-line strings were accidentally
prepended with tabs. This extra whitespace broke importing the SMR file
in MGU.

We remove the prepended whitespace here by avoiding literal multiline
strings.
  • Loading branch information
hemberger authored Feb 16, 2024
1 parent 89cf42f commit d1283de
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions src/lib/Smr/SectorsFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@ public static function create(int $gameID, ?AbstractPlayer $player, bool $adminC
// NOTE: If the format of this file is changed in an incompatible way,
// make sure to update the SMR_FILE_VERSION!

$file = ';SMR1.6 Sectors File v' . SMR_FILE_VERSION . '
; Created on ' . date(DEFAULT_DATE_TIME_FORMAT) . '
[Races]
; Name = ID' . EOL;
$file = ';SMR1.6 Sectors File v' . SMR_FILE_VERSION . EOL
. '; Created on ' . date(DEFAULT_DATE_TIME_FORMAT) . EOL
. '[Races]' . EOL
. '; Name = ID' . EOL;
foreach (Race::getAllNames() as $raceID => $raceName) {
$file .= inify($raceName) . '=' . $raceID . EOL;
}

$file .= '[Goods]
; ID = Name, BasePrice' . EOL;
$file .= '[Goods]' . EOL
. '; ID = Name, BasePrice' . EOL;
foreach (TradeGood::getAll() as $goodID => $good) {
$file .= $goodID . '=' . inify($good->name) . ',' . $good->basePrice . EOL;
}

$file .= '[Weapons]
; Weapon = Race,Cost,Shield,Armour,Accuracy,Power level,Restriction
; Restriction: 0=none, 1=good, 2=evil, 3=newbie, 4=port, 5=planet' . EOL;
$file .= '[Weapons]' . EOL
. '; Weapon = Race,Cost,Shield,Armour,Accuracy,Power level,Restriction' . EOL
. '; Restriction: 0=none, 1=good, 2=evil, 3=newbie, 4=port, 5=planet' . EOL;
foreach (WeaponType::getAllWeaponTypes() as $weapon) {
$file .= inify($weapon->getName()) . '=' . inify($weapon->getRaceName()) . ',' . $weapon->getCost() . ',' . $weapon->getShieldDamage() . ',' . $weapon->getArmourDamage() . ',' . $weapon->getAccuracy() . ',' . $weapon->getPowerLevel() . ',' . $weapon->getBuyerRestriction()->value . EOL;
}

$file .= '[ShipEquipment]
; Name = Cost' . EOL;
$file .= '[ShipEquipment]' . EOL
. '; Name = Cost' . EOL;
foreach (HardwareType::getAll() as $hardware) {
$file .= inify($hardware->name) . '=' . $hardware->cost . EOL;
}

$file .= '[Ships]
; Name = Race,Cost,TPH,Hardpoints,Power,Class,+Equipment (Optional),+Restrictions(Optional)
; Restrictions:Align(Integer)' . EOL;
$file .= '[Ships]' . EOL
. '; Name = Race,Cost,TPH,Hardpoints,Power,Class,+Equipment (Optional),+Restrictions(Optional)' . EOL
. '; Restrictions:Align(Integer)' . EOL;
foreach (ShipType::getAll() as $ship) {
$file .= inify($ship->getName()) . '=' . inify($ship->getRaceName()) . ',' . $ship->getCost() . ',' . $ship->getSpeed() . ',' . $ship->getHardpoints() . ',' . $ship->getMaxPower() . ',' . $ship->getClass()->name;
$shipEquip = [];
Expand All @@ -51,8 +51,8 @@ public static function create(int $gameID, ?AbstractPlayer $player, bool $adminC
$file .= EOL;
}

$file .= '[Locations]
; Name = +Sells' . EOL;
$file .= '[Locations]' . EOL
. '; Name = +Sells' . EOL;
foreach (Location::getAllLocations($gameID) as $location) {
$file .= inify($location->getName()) . '=';
$locSells = '';
Expand Down Expand Up @@ -100,12 +100,11 @@ public static function create(int $gameID, ?AbstractPlayer $player, bool $adminC

// Everything below here must be valid INI syntax (safe to parse)
$game = Game::getGame($gameID);
$file .= '[Metadata]
FileVersion=' . SMR_FILE_VERSION . '
[Game]
Name=' . inify($game->getName()) . '
[Galaxies]
';
$file .= '[Metadata]' . EOL
. 'FileVersion=' . SMR_FILE_VERSION . EOL
. '[Game]' . EOL
. 'Name=' . inify($game->getName()) . EOL
. '[Galaxies]' . EOL;
$galaxies = $game->getGalaxies();
foreach ($galaxies as $galaxy) {
$file .= $galaxy->getGalaxyID() . '=' . $galaxy->getWidth() . ',' . $galaxy->getHeight() . ',' . $galaxy->getGalaxyType() . ',' . inify($galaxy->getName()) . ',' . $galaxy->getMaxForceTime() . EOL;
Expand Down

0 comments on commit d1283de

Please sign in to comment.