fix: generate planet pictures at the first universe tick

This commit is contained in:
Emmanuel BENOîT 2025-01-02 15:10:40 +01:00
parent 958348551e
commit c9642f2a68
Signed by: Emmanuel BENOîT
SSH key fingerprint: SHA256:l7PFUUF5TCDsvYeQC9OnTNz08dFY7Fvf4Hv3neIqYpg
2 changed files with 15 additions and 3 deletions

View file

@ -103,7 +103,15 @@ class beta5_ticks_universe_library {
$q = $this->db->query("SELECT MAX(id) FROM planet"); $q = $this->db->query("SELECT MAX(id) FROM planet");
list($idp) = dbFetchArray($q); list($idp) = dbFetchArray($q);
// Generate new planets // Generate planet pictures. We need to check the planets we just
// generated - if the game is being initialized, then these might
// be missing. In all cases we also generate planets for the next
// zone.
$dirPath = config::$main['staticdir'] . '/beta5/pics/pl/' .
$this->game->name . '/s';
if (!file_exists("$dirPath/$idp.png")) {
$this->main->call('requestGenPlanets', 1, $idp);
}
$this->main->call('requestGenPlanets', $idp + 1, ($w + 5) * $h * 6); $this->main->call('requestGenPlanets', $idp + 1, ($w + 5) * $h * 6);
} }
} }
@ -178,6 +186,9 @@ class beta5_ticks_universe_library {
$q = $this->db->query("UPDATE planet SET ifact=33, mfact=33, turrets=90 WHERE id = {$r[0]}"); $q = $this->db->query("UPDATE planet SET ifact=33, mfact=33, turrets=90 WHERE id = {$r[0]}");
$this->planets->call('updateHappiness', $r[0]); $this->planets->call('updateHappiness', $r[0]);
} }
// Generate planet pictures
$this->main->call('requestGenPlanets', 1, count($ids) * 6);
} }

View file

@ -10,17 +10,18 @@ class main_requestGenPlanets {
function run($first, $amount) { function run($first, $amount) {
$dir = config::getParam('pgenreq'); $dir = config::getParam('pgenreq');
$game = $this->lib->game->name; $game = $this->lib->game->name;
l::debug("main::requestGenPlanets($game, $first, $amount) called");
if (!is_dir($dir)) { if (!is_dir($dir)) {
$base = dirname($dir); $base = dirname($dir);
if (!(is_dir($base) && is_writable($base) && @mkdir($dir))) { if (!(is_dir($base) && is_writable($base) && @mkdir($dir))) {
logText("main::requestGenPlanets($game,$first,$amount): unable to create directory '$dir'", LOG_WARNING); l::warn("main::requestGenPlanets($game,$first,$amount): unable to create directory '$dir'");
return false; return false;
} }
} }
$r = @touch("$dir/req-$game-$first-$amount"); $r = @touch("$dir/req-$game-$first-$amount");
if (!$r) { if (!$r) {
logText("main::requestGenPlanets($game,$first,$amount): unable to create file 'req-$game-$first-$amount'", LOG_WARNING); l::warn("main::requestGenPlanets($game,$first,$amount): unable to create file 'req-$game-$first-$amount'");
} }
return $r; return $r;
} }