From c9642f2a68e594f24b72cd2cdda334dd4ecb8027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20BENO=C3=8ET?= Date: Thu, 2 Jan 2025 15:10:40 +0100 Subject: [PATCH] fix: generate planet pictures at the first universe tick --- game/scripts/game/beta5/ticks/universe/library.inc | 13 ++++++++++++- .../scripts/game/main/library/requestGenPlanets.inc | 5 +++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/game/scripts/game/beta5/ticks/universe/library.inc b/game/scripts/game/beta5/ticks/universe/library.inc index fb77a16..17a87b9 100644 --- a/game/scripts/game/beta5/ticks/universe/library.inc +++ b/game/scripts/game/beta5/ticks/universe/library.inc @@ -103,7 +103,15 @@ class beta5_ticks_universe_library { $q = $this->db->query("SELECT MAX(id) FROM planet"); 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); } } @@ -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]}"); $this->planets->call('updateHappiness', $r[0]); } + + // Generate planet pictures + $this->main->call('requestGenPlanets', 1, count($ids) * 6); } diff --git a/game/scripts/game/main/library/requestGenPlanets.inc b/game/scripts/game/main/library/requestGenPlanets.inc index 94aad87..40e1c25 100644 --- a/game/scripts/game/main/library/requestGenPlanets.inc +++ b/game/scripts/game/main/library/requestGenPlanets.inc @@ -10,17 +10,18 @@ class main_requestGenPlanets { function run($first, $amount) { $dir = config::getParam('pgenreq'); $game = $this->lib->game->name; + l::debug("main::requestGenPlanets($game, $first, $amount) called"); if (!is_dir($dir)) { $base = dirname($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; } } $r = @touch("$dir/req-$game-$first-$amount"); 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; }