mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-12 23:56:08 +00:00
+11
-8
@@ -928,6 +928,8 @@ class Building {
|
||||
$buildcount = ($this->buildArray ? count($this->buildArray) : 0);
|
||||
// will be true if the job was successfully finished
|
||||
$jobFinishSuccess = false;
|
||||
// IDs of successful jobs to delete
|
||||
$deletIDs = [];
|
||||
|
||||
foreach ($this->buildArray as $jobs) {
|
||||
if ($jobs['wid']==$village->wid) {
|
||||
@@ -959,18 +961,16 @@ class Building {
|
||||
// we need to subtract resources for this, if another 2 jobs are active,
|
||||
// as we'd never subtract those otherwise
|
||||
if ( $buildcount > 2 ) {
|
||||
$database->setVillageField( $jobs['wid'], 'wood', ( $villwood - $buildwood ) );
|
||||
$database->setVillageField( $jobs['wid'], 'clay', ( $villclay - $buildclay ) );
|
||||
$database->setVillageField( $jobs['wid'], 'iron', ( $villiron - $buildiron ) );
|
||||
$database->setVillageField( $jobs['wid'], 'crop', ( $villcrop - $buildcrop ) );
|
||||
$database->setVillageField( $jobs['wid'],
|
||||
['wood', 'clay', 'iron', 'crop'],
|
||||
[( $villwood - $buildwood ), ( $villclay - $buildclay ), ( $villiron - $buildiron ), ( $villcrop - $buildcrop )]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if we only have 2 gold, we need to cancel this job, as there will never
|
||||
// be enough gold now in our account to finish this up
|
||||
$exclude_master = true;
|
||||
$q = "DELETE FROM " . TB_PREFIX . "bdata WHERE id = " . (int) $jobs['id'];
|
||||
$database->query( $q );
|
||||
$deletIDs[] = (int) $jobs['id'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -987,8 +987,7 @@ class Building {
|
||||
if (!isset($exclude_master) && $database->query($q) && ($enought_res == 1 or $jobs['master'] == 0)) {
|
||||
$database->modifyPop($jobs['wid'],$resource['pop'],0);
|
||||
$database->addCP($jobs['wid'],$resource['cp']);
|
||||
$q = "DELETE FROM ".TB_PREFIX."bdata where id = ".(int) $jobs['id'];
|
||||
$database->query($q);
|
||||
$deletIDs[] = (int) $jobs['id'];
|
||||
if($jobs['type'] == 18) {
|
||||
$owner = $database->getVillageField($jobs['wid'],"owner");
|
||||
$max = $bid18[$level]['attri'];
|
||||
@@ -1008,6 +1007,10 @@ class Building {
|
||||
$jobFinishSuccess = false;
|
||||
}
|
||||
|
||||
if (count($deletIDs)) {
|
||||
$database->query("DELETE FROM " . TB_PREFIX . "bdata WHERE id IN(" . implode(', ', $deletIDs) . ")");
|
||||
}
|
||||
|
||||
$demolition = $database->finishDemolition($village->wid);
|
||||
$tech = $technology->finishTech();
|
||||
if ($demolition > 0 || $tech > 0) {
|
||||
|
||||
+18
-7
@@ -2427,18 +2427,26 @@ class MYSQLi_DB implements IDbConnection {
|
||||
$result = mysqli_query($this->dblink,$q2);
|
||||
if (!empty($result)) {
|
||||
$array=$this->mysqli_fetch_all($result);
|
||||
$toDelete = [];
|
||||
foreach($array as $ss) {
|
||||
$this->DeleteSurvey($ss['id']);
|
||||
$toDelete[] = $ss['id'];
|
||||
}
|
||||
$this->DeleteSurvey($toDelete);
|
||||
}
|
||||
mysqli_query($this->dblink,$qs);
|
||||
return mysqli_query($this->dblink,$q);
|
||||
}
|
||||
|
||||
function DeleteSurvey($id) {
|
||||
list($id) = $this->escape_input($id);
|
||||
if (!is_array($id)) {
|
||||
$id = [$id];
|
||||
}
|
||||
|
||||
$qs = "DELETE from " . TB_PREFIX . "forum_survey where topic = '$id'";
|
||||
foreach ($id as $index => $idValue) {
|
||||
$id[$index] = (int) $idValue;
|
||||
}
|
||||
|
||||
$qs = "DELETE from " . TB_PREFIX . "forum_survey where topic IN(".implode(', ', $id).")";
|
||||
return mysqli_query($this->dblink,$qs);
|
||||
}
|
||||
|
||||
@@ -4306,9 +4314,10 @@ class MYSQLi_DB implements IDbConnection {
|
||||
// already checks if there are no more people other than the owner
|
||||
// present before the demolition is allowed.
|
||||
if ($demolition) {
|
||||
$evicts = [];
|
||||
foreach ($members as $member) {
|
||||
// evict the player from the alliance
|
||||
mysqli_query($this->dblink, 'UPDATE '.TB_PREFIX.'users SET alliance = 0 WHERE id = '.$member['id']);
|
||||
$evicts[] = $member['id'];
|
||||
|
||||
// notify them via in-game messaging
|
||||
$this->sendMessage(
|
||||
@@ -4329,6 +4338,8 @@ class MYSQLi_DB implements IDbConnection {
|
||||
0,
|
||||
true);
|
||||
}
|
||||
|
||||
mysqli_query($this->dblink, 'UPDATE '.TB_PREFIX.'users SET alliance = 0 WHERE id IN('.implode(',', $evicts).")");
|
||||
} else {
|
||||
// we come from a battle result, therefore we need to check
|
||||
// for the first player in the alliance who has a sufficient
|
||||
@@ -6517,9 +6528,9 @@ class MYSQLi_DB implements IDbConnection {
|
||||
$result = $this->query_return($q);
|
||||
$attack = 0;
|
||||
foreach($result as $general) {
|
||||
if(date("j. M",$time) == date("j. M",$general['time'])){
|
||||
$attack += 1;
|
||||
}
|
||||
if(date("j. M",$time) == date("j. M",$general['time'])){
|
||||
$attack += 1;
|
||||
}
|
||||
}
|
||||
return $attack;
|
||||
}
|
||||
|
||||
+32
-32
@@ -251,38 +251,38 @@ class Village {
|
||||
$crop = $clay = $wood = $iron = 0;
|
||||
if (!empty($this->oasisowned)) {
|
||||
foreach ($this->oasisowned as $oasis) {
|
||||
switch($oasis['type']) {
|
||||
case 1:
|
||||
case 2:
|
||||
$wood += 1;
|
||||
break;
|
||||
case 3:
|
||||
$wood += 1;
|
||||
$crop += 1;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
$clay += 1;
|
||||
break;
|
||||
case 6:
|
||||
$clay += 1;
|
||||
$crop += 1;
|
||||
break;
|
||||
case 7:
|
||||
case 8:
|
||||
$iron += 1;
|
||||
break;
|
||||
case 9:
|
||||
$iron += 1;
|
||||
$crop += 1;
|
||||
break;
|
||||
case 10:
|
||||
case 11:
|
||||
$crop += 1;
|
||||
break;
|
||||
case 12:
|
||||
$crop += 2;
|
||||
break;
|
||||
switch ( $oasis['type'] ) {
|
||||
case 1:
|
||||
case 2:
|
||||
$wood += 1;
|
||||
break;
|
||||
case 3:
|
||||
$wood += 1;
|
||||
$crop += 1;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
$clay += 1;
|
||||
break;
|
||||
case 6:
|
||||
$clay += 1;
|
||||
$crop += 1;
|
||||
break;
|
||||
case 7:
|
||||
case 8:
|
||||
$iron += 1;
|
||||
break;
|
||||
case 9:
|
||||
$iron += 1;
|
||||
$crop += 1;
|
||||
break;
|
||||
case 10:
|
||||
case 11:
|
||||
$crop += 1;
|
||||
break;
|
||||
case 12:
|
||||
$crop += 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user