mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-06-28 00:24:23 +00:00
Fixed a bug while reinforcing
+If you've already reinforced the target village, you'll troops will now be merged with the present troops
This commit is contained in:
+29
-43
@@ -3442,40 +3442,37 @@ class Automation {
|
||||
|
||||
if($data['t11'] != 0 || $troopsPresent) {
|
||||
$temphero=$data['t11'];
|
||||
if ($HeroTransfer) $data['t11']=0;
|
||||
if ($HeroTransfer) $data['t11'] = 0;
|
||||
//check if there is defence from town in to town
|
||||
$check=$database->getEnforce($data['to'],$data['from']);
|
||||
if (!isset($check['id'])){
|
||||
//no:
|
||||
$database->addEnforce($data);
|
||||
} else{
|
||||
$check = $database->getEnforce($data['to'], $data['from']);
|
||||
if (!isset($check['id'])) $database->addEnforce($data);
|
||||
else
|
||||
{
|
||||
//yes
|
||||
$start = ($owntribe-1)*10+1;
|
||||
$end = ($owntribe*10);
|
||||
$start = ($owntribe - 1) * 10 + 1;
|
||||
$end = ($owntribe * 10);
|
||||
|
||||
//add unit.
|
||||
$j='1';
|
||||
for($i=$start;$i<=$end;$i++){
|
||||
if (!isset($t_units)) {
|
||||
$t_units = '';
|
||||
}
|
||||
$t_units .= "u".$i."=u".$i." + ".$data['t'.$j].(($j > 9) ? '' : ', ');$j++;
|
||||
$t_units = '';
|
||||
for($i = $start, $j = 1; $i <= $end; $i++, $j++)
|
||||
{
|
||||
$t_units .= "u".$i." = u".$i." + ".$data['t'.$j].(($j > 9) ? '' : ', ');
|
||||
}
|
||||
|
||||
$q = "UPDATE ".TB_PREFIX."enforcement set $t_units where id =".(int) $check['id'];
|
||||
$database->query($q);
|
||||
$database->modifyEnforce($check['id'],'hero',$data['t11'],1);
|
||||
$database->modifyEnforce($check['id'], 'hero', $data['t11'], 1);
|
||||
}
|
||||
$data['t11']=$temphero;
|
||||
$data['t11'] = $temphero;
|
||||
}
|
||||
//send rapport
|
||||
$unitssend_att = ''.$data['t1'].','.$data['t2'].','.$data['t3'].','.$data['t4'].','.$data['t5'].','.$data['t6'].','.$data['t7'].','.$data['t8'].','.$data['t9'].','.$data['t10'].','.$data['t11'].'';
|
||||
$data_fail = ''.$from['wref'].','.$from['owner'].','.$owntribe.','.$unitssend_att.'';
|
||||
|
||||
|
||||
if($isoasis == 0){
|
||||
$to_name=$to['name'];
|
||||
}else{
|
||||
$to_name="Oasis ".$database->getVillageField($to['conqured'],"name");
|
||||
}
|
||||
if($isoasis == 0) $to_name = $to['name'];
|
||||
else $to_name = "Oasis ".$database->getVillageField($to['conqured'],"name");
|
||||
|
||||
$database->addNotice($from['owner'],$from['wref'],(isset($ownally) ? $ownally : 0),8,''.addslashes($from['name']).' reinforcement '.addslashes($to_name).'',$data_fail,(isset($AttackArrivalTime) ? $AttackArrivalTime : time()));
|
||||
if($from['owner'] != $to['owner']) {
|
||||
$database->addNotice($to['owner'],$to['wref'],(isset($targetally) ? $targetally : 0),8,''.addslashes($from['name']).' reinforcement '.addslashes($to_name).'',$data_fail,(isset($AttackArrivalTime) ? $AttackArrivalTime : time()));
|
||||
@@ -3499,7 +3496,7 @@ class Automation {
|
||||
|
||||
//check empty reinforcement in rally point
|
||||
$e_units='';
|
||||
for ($i=1;$i<=50;$i++) {
|
||||
for ($i=1; $i <= 50; $i++) {
|
||||
$e_units.='u'.$i.'=0 AND ';
|
||||
}
|
||||
$e_units.='hero=0';
|
||||
@@ -4145,34 +4142,23 @@ class Automation {
|
||||
$wood *= SPEED;
|
||||
return round($wood);
|
||||
}
|
||||
|
||||
private function bountyGetOWoodProd() {
|
||||
global $session;
|
||||
$wood = 0;
|
||||
$wood += 40;
|
||||
$wood *= SPEED;
|
||||
return round($wood);
|
||||
return round(SPEED * 40);
|
||||
}
|
||||
|
||||
private function bountyGetOClayProd() {
|
||||
global $session;
|
||||
$clay = 0;
|
||||
$clay += 40;
|
||||
$clay *= SPEED;
|
||||
return round($clay);
|
||||
}private function bountyGetOIronProd() {
|
||||
global $session;
|
||||
$iron = 0;
|
||||
$iron += 40;
|
||||
$iron *= SPEED;
|
||||
return round($iron);
|
||||
return round(SPEED * 40);
|
||||
}
|
||||
|
||||
private function bountyGetOIronProd() {
|
||||
return round(SPEED * 40);
|
||||
}
|
||||
|
||||
private function bountyGetOCropProd() {
|
||||
global $session;
|
||||
$crop = 0;
|
||||
$clay += 40;
|
||||
$crop *= SPEED;
|
||||
return round($crop);
|
||||
return round(SPEED * 40);
|
||||
}
|
||||
|
||||
private function bountyGetClayProd() {
|
||||
global $bid2,$bid6,$session;
|
||||
$clay = $brick = 0;
|
||||
|
||||
@@ -6170,7 +6170,7 @@ References: User ID/Message ID, Mode
|
||||
// first of all, check if we should be using cache and whether the field
|
||||
// required is already cached
|
||||
if ($use_cache && !$array_passed && isset(self::$villageFromReinforcementsCache[$vid[0].$from[0]]) && is_array(self::$villageFromReinforcementsCache[$vid[0].$from[0]]) && !count(self::$villageFromReinforcementsCache[$vid[0].$from[0]])) {
|
||||
return $cachedValue;
|
||||
return self::$villageFromReinforcementsCache[$vid[0].$from[0]];
|
||||
} else if ($use_cache && $array_passed) {
|
||||
// check what we can return from cache
|
||||
$newVIDs = [];
|
||||
@@ -6193,11 +6193,11 @@ References: User ID/Message ID, Mode
|
||||
} else if ($use_cache && !$array_passed && ($cachedValue = self::returnCachedContent(self::$villageFromReinforcementsCache, $vid[0].$from[0])) && !is_null($cachedValue)) {
|
||||
return $cachedValue;
|
||||
}
|
||||
|
||||
|
||||
// build SELECT pairs
|
||||
$pairs = [];
|
||||
foreach ($vid as $index => $vidValue) {
|
||||
$pairs[] = '(`from` = '.(int) $vidValue.' AND vref = '.(int) $from[$index].')';
|
||||
$pairs[] = '(`from` = '.(int) $from[$index].' AND vref = '.(int) $vidValue.')';
|
||||
}
|
||||
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "enforcement WHERE ".implode(' OR ', $pairs);
|
||||
@@ -6209,7 +6209,7 @@ References: User ID/Message ID, Mode
|
||||
} else {
|
||||
if ($result && count($result)) {
|
||||
foreach ( $result as $record ) {
|
||||
self::$villageFromReinforcementsCache[ $record['from'] . $record['vref'] ] = $record;
|
||||
self::$villageFromReinforcementsCache[$record['vref'].$record['from']] = $record;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user