fix: generate planet pictures at the first universe tick
This commit is contained in:
parent
958348551e
commit
c9642f2a68
2 changed files with 15 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue