Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #131 from mys/master
Browse files Browse the repository at this point in the history
CleanerCronjob and returning attack of deleted planets
  • Loading branch information
mys authored Apr 22, 2018
2 parents 60f5e28 + 7e008e8 commit 86636f6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
48 changes: 27 additions & 21 deletions includes/classes/cronjob/CleanerCronjob.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ function run()
$sql = 'DELETE FROM %%FLEETS_EVENT%% WHERE fleetID NOT IN (SELECT fleet_id FROM %%FLEETS%%);';
Database::get()->delete($sql);

$sql = 'DELETE FROM %%LOG_FLEETS%% WHERE `start_time` < :time;';
Database::get()->delete($sql, array(
':time' => $del_before
));

$sql = 'UPDATE %%USERS%% SET `email_2` = `email` WHERE `setmail` < :time;';
Database::get()->update($sql, array(
':time' => TIMESTAMP
Expand All @@ -79,27 +84,28 @@ function run()
}
}

foreach($unis as $uni)
{
$sql = 'SELECT units FROM %%TOPKB%% WHERE `universe` = :universe ORDER BY units DESC LIMIT 99,1;';

$battleHallLowest = Database::get()->selectSingle($sql, array(
':universe' => $uni
),'units');

if(!is_null($battleHallLowest))
{
$sql = 'DELETE %%TOPKB%%, %%TOPKB_USERS%%
FROM %%TOPKB%%
INNER JOIN %%TOPKB_USERS%% USING (rid)
WHERE `universe` = :universe AND `units` < :battleHallLowest;';

Database::get()->delete($sql, array(
':universe' => $uni,
':battleHallLowest' => $battleHallLowest
));
}
}
// do not delete hall of fame
// foreach($unis as $uni)
// {
// $sql = 'SELECT units FROM %%TOPKB%% WHERE `universe` = :universe ORDER BY units DESC LIMIT 99,1;';

// $battleHallLowest = Database::get()->selectSingle($sql, array(
// ':universe' => $uni
// ),'units');

// if(!is_null($battleHallLowest))
// {
// $sql = 'DELETE %%TOPKB%%, %%TOPKB_USERS%%
// FROM %%TOPKB%%
// INNER JOIN %%TOPKB_USERS%% USING (rid)
// WHERE `universe` = :universe AND `units` < :battleHallLowest;';

// Database::get()->delete($sql, array(
// ':universe' => $uni,
// ':battleHallLowest' => $battleHallLowest
// ));
// }
// }

// do not delete combat reports
// $sql = 'DELETE FROM %%RW%% WHERE `time` < :time AND `rid` NOT IN (SELECT `rid` FROM %%TOPKB%%);';
Expand Down
9 changes: 9 additions & 0 deletions includes/classes/missions/MissionCaseAttack.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ function TargetEvent()
':planetId' => $this->_fleet['fleet_end_id']
));

// return fleet if target planet deleted
if($targetPlanet == false)
{
error_log('DEBUG planet does not exist!');
$this->setState(FLEET_RETURN);
$this->SaveFleet();
return;
}

$sql = "SELECT * FROM %%USERS%% WHERE id = :userId;";
$targetUser = $db->selectSingle($sql, array(
':userId' => $targetPlanet['id_owner']
Expand Down

0 comments on commit 86636f6

Please sign in to comment.