refactor: setMovementProc() to take one or multiple IDs for update

This commit is contained in:
Martin Ambrus
2017-11-08 18:21:30 +01:00
parent 21d6874325
commit 151553735d
2 changed files with 10 additions and 3 deletions
+6 -1
View File
@@ -982,14 +982,19 @@ class Automation {
}
$q1 = "SELECT send, moveid, `to`, wood, clay, iron, crop, `from` FROM ".TB_PREFIX."movement WHERE proc = 0 and sort_type = 2 and endtime < $time";
$dataarray1 = $database->query_return($q1);
$completedIDs = [];
foreach($dataarray1 as $data1) {
$database->setMovementProc($data1['moveid']);
$completedIDs[] = $data1['moveid'];
if($data1['send'] > 1){
$targettribe1 = $tribes[$data1['to']];
$send = $data1['send']-1;
$this->sendResource2($data1['wood'],$data1['clay'],$data1['iron'],$data1['crop'],$data1['to'],$data1['from'],$targettribe1,$send);
}
}
// updated processed records
$database->setMovementProc(implode(', ', $completedIDs));
if(file_exists("GameEngine/Prevention/market.txt")) {
unlink("GameEngine/Prevention/market.txt");
}