From b8d1267a4a5bcf65c2839688e3e7851493d060c2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Jun 2012 16:07:57 +0300 Subject: [PATCH] fixed bugs of NarcisRO and more --- GameEngine/Automation.php | 126 ++++++++++++++++++++++++-- GameEngine/Building.php | 21 ++++- GameEngine/Units.php | 6 +- Templates/Build/17.tpl | 8 +- Templates/Notice/22.tpl | 23 ++++- gpack/travian_default/img/r/peace.gif | Bin 0 -> 174 bytes install/data/constant_format.tpl | 5 + install/templates/config.tpl | 7 +- 8 files changed, 180 insertions(+), 16 deletions(-) create mode 100644 gpack/travian_default/img/r/peace.gif diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index a0f51d13..ff0f82e4 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -939,7 +939,7 @@ class Automation { $stonemason = "1"; } - if(PEACE == False || $targettribe == 4 || $targettribe == 5){ + if(PEACE == 0 || $targettribe == 4 || $targettribe == 5){ $battlepart = $battle->calculateBattle($Attacker,$Defender,$def_wall,$att_tribe,$def_tribe,$residence,$attpop,$defpop,$type,$def_ab,$att_ab,$tblevel,$stonemason,$walllevel,$AttackerID,$DefenderID,$AttackerWref,$DefenderWref); //units attack string for battleraport @@ -1122,7 +1122,7 @@ class Automation { $troopsdead6 = $dead6; $troopsdead7 = $dead7; $troopsdead8 = $dead8; - $troopsdead9 = $dead9; + $troopsdead9 = $dead9-1; $troopsdead10 = $dead10; $troopsdead11 = $dead11; for($i=1;$i<=50;$i++) { @@ -1814,29 +1814,39 @@ class Automation { $database->setVillageField($data['to'],loyalty,($toF['loyalty']-$rand)); } else { //you took over the village + $villname = $database->getVillageField($data['to'],"name"); $artifact = $database->getOwnArtefactInfo($data['to']); - $info_chief = "".$chief_pic.",Inhabitants decided to join your empire."; + $info_chief = "".$chief_pic.",Inhabitants of ".$villname." village decided to join your empire."; if ($artifact['vref'] == $data['to']){ $database->claimArtefact($data['to'],$data['to'],$database->getVillageField($data['from'],"owner")); } - $database->setVillageField($data['to'],loyalty,100); + $database->setVillageField($data['to'],loyalty,0); $database->setVillageField($data['to'],owner,$database->getVillageField($data['from'],"owner")); //delete upgrades in armory and blacksmith - $q = "DELETE FROM ".TB_PREFIX."abdata WHERE vref=".$data['to']; + $q = "DELETE FROM ".TB_PREFIX."abdata WHERE vref = ".$data['to'].""; $database->query($q); $database->addABTech($data['to']); //delete researches in academy - $q = "DELETE FROM ".TB_PREFIX."tdata WHERE vref=".$data['to']; + $q = "DELETE FROM ".TB_PREFIX."tdata WHERE vref = ".$data['to'].""; $database->query($q); $database->addTech($data['to']); + //delete reinforcement + $q = "DELETE FROM ".TB_PREFIX."enforcement WHERE from = ".$data['to'],""; + $database->query($q); + // check buildings $pop1 = $database->getVillageField($data['from'],"pop"); $pop2 = $database->getVillageField($data['to'],"pop"); if($pop1 > $pop2){ $buildlevel = $database->getResourceLevel($data['to']); for ($i=1; $i<=39; $i++){ if($buildlevel['f'.$i]!=0){ + if($buildlevel['f'.$i."t"]!=35 && $buildlevel['f'.$i."t"]!=36 && $buildlevel['f'.$i."t"]!=41){ $leveldown = $buildlevel['f'.$i]-1; $database->setVillageLevel($data['to'],"f".$i,$leveldown); + }else{ + $database->setVillageLevel($data['to'],"f".$i,0); + $database->setVillageLevel($data['to'],"f".$i."t",0); + } } } if($buildlevel['f99']!=0){ @@ -2188,6 +2198,110 @@ $crannyimg = "getEnforceArray($post['ckey'],0); + $to = $database->getVillage($enforce['from']); + $Gtribe = ""; + if ($database->getUserField($to['owner'],'tribe',0) == '2'){ $Gtribe = "1"; } else if ($database->getUserField($to['owner'],'tribe',0) == '3'){ $Gtribe = "2"; } else if ($database->getUserField($to['owner'],'tribe',0) == '4'){ $Gtribe = "3"; }else if ($database->getUserField($to['owner'],'tribe',0) == '5'){ $Gtribe = "4"; } + + for($i=1; $i<10; $i++){ + if(isset($post['t'.$i])){ + if($i!=10){ + if ($post['t'.$i] > $enforce['u'.$Gtribe.$i]) + { + $form->addError("error","You can't send more units than you have"); + break; + } + + if($post['t'.$i]<0) + { + $form->addError("error","You can't send negative units."); + break; + } + } + } else { + $post['t'.$i.'']='0'; + } + } + if(isset($post['t11'])){ + if ($post['t11'] > $enforce['hero']) + { + $form->addError("error","You can't send more units than you have"); + break; + } + + if($post['t11']<0) + { + $form->addError("error","You can't send negative units."); + break; + } + } else { + $post['t11']='0'; + } + + if($form->returnErrors() > 0) { + $_SESSION['errorarray'] = $form->getErrors(); + $_SESSION['valuearray'] = $_POST; + header("Location: a2b.php"); + } else { + + //change units + $start = ($database->getUserField($to['owner'],'tribe',0)-1)*10+1; + $end = ($database->getUserField($to['owner'],'tribe',0)*10); + + $j='1'; + for($i=$start;$i<=$end;$i++){ + $database->modifyEnforce($post['ckey'],$i,$post['t'.$j.''],0); $j++; + } + + //get cord + $from = $database->getVillage($enforce['from']); + $fromcoor = $database->getCoor($enforce['from']); + $tocoor = $database->getCoor($enforce['vref']); + $fromCor = array('x'=>$tocoor['x'], 'y'=>$tocoor['y']); + $toCor = array('x'=>$fromcoor['x'], 'y'=>$fromcoor['y']); + + $speeds = array(); + + //find slowest unit. + for($i=1;$i<=10;$i++){ + if (isset($post['t'.$i])){ + if( $post['t'.$i] != '' && $post['t'.$i] > 0){ + if($unitarray) { reset($unitarray); } + $unitarray = $GLOBALS["u".(($session->tribe-1)*10+$i)]; + $speeds[] = $unitarray['speed']; + } else { + $post['t'.$i.'']='0'; + } + } else { + $post['t'.$i.'']='0'; + } + } + if (isset($post['t11'])){ + if( $post['t11'] != '' && $post['t11'] > 0){ + $qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".$from['owner'].""; + $resulth = mysql_query($qh); + $hero_f=mysql_fetch_array($resulth); + $hero_unit=$hero_f['unit']; + $speeds[] = $GLOBALS['u'.$hero_unit]['speed']; + } else { + $post['t11']='0'; + } + } else { + $post['t11']='0'; + } + $time = $generator->procDistanceTime($fromCor,$toCor,min($speeds),1); + $reference = $database->addAttack($enforce['from'],$post['t1'],$post['t2'],$post['t3'],$post['t4'],$post['t5'],$post['t6'],$post['t7'],$post['t8'],$post['t9'],$post['t10'],$post['t11'],2,0,0,0,0); + $database->addMovement(4,$village->wid,$enforce['from'],$reference,time(),($time+time())); + $technology->checkReinf($post['ckey']); + + header("Location: build.php?id=39"); + + } + } private function sendreinfunitsComplete() { global $bid23,$database,$battle; diff --git a/GameEngine/Building.php b/GameEngine/Building.php index bff630e3..56a31ad9 100644 --- a/GameEngine/Building.php +++ b/GameEngine/Building.php @@ -645,13 +645,28 @@ class Building { if($jobs['wid']==$village->wid){ $wwvillage = $database->getResourceLevel($jobs['wid']); if($wwvillage['f99t']!=40){ - $level = $database->getFieldLevel($jobs['wid'],$jobs['field']); - $level = ($level == -1) ? 0 : $level; + $level = $jobs['level']; if($jobs['type'] != 25 AND $jobs['type'] != 26 AND $jobs['type'] != 40) { $finish = 1; $resource = $this->resourceRequired($jobs['field'],$jobs['type']); + if($jobs['master'] == 0){ $q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid']; - if($database->query($q)) { + }else{ + $villwood = $database->getVillageField($jobs['wid'],'wood'); + $villclay = $database->getVillageField($jobs['wid'],'clay'); + $villiron = $database->getVillageField($jobs['wid'],'iron'); + $villcrop = $database->getVillageField($jobs['wid'],'crop'); + $type = $jobs['type']; + $buildarray = $GLOBALS["bid".$type]; + $buildwood = $buildarray[$level]['wood']; + $buildclay = $buildarray[$level]['clay']; + $buildiron = $buildarray[$level]['iron']; + $buildcrop = $buildarray[$level]['crop']; + if($buildwood < $villwood && $buildclay < $villclay && $buildiron < $villiron && $buildcrop < $villcrop){ + $q = "UPDATE ".TB_PREFIX."fdata set f".$jobs['field']." = ".$jobs['level'].", f".$jobs['field']."t = ".$jobs['type']." where vref = ".$jobs['wid']; + } + } + if($database->query($q)) { $database->modifyPop($jobs['wid'],$resource['pop'],0); $database->addCP($jobs['wid'],$resource['cp']); $q = "DELETE FROM ".TB_PREFIX."bdata where id = ".$jobs['id']; diff --git a/GameEngine/Units.php b/GameEngine/Units.php index 59dbefdf..8722164c 100644 --- a/GameEngine/Units.php +++ b/GameEngine/Units.php @@ -448,7 +448,8 @@ class Units { $total = count($database->getProfileVillages($session->uid)); $need_cps = ${'cp'.$mode}[$total]; $cps = $session->cp; - + $rallypoint = $database->getResourceLevel($village->wid); + if($rallypoint['f39'] > 0){ if($cps >= $need_cps) { $unit = ($session->tribe*10); @@ -465,6 +466,9 @@ class Units { } else { header("Location: build.php?id=39"); } + }else{ + header("Location: dorf1.php"); + } }else{ header("Location: banned.php"); } diff --git a/Templates/Build/17.tpl b/Templates/Build/17.tpl index cb4cc884..8a8c873a 100644 --- a/Templates/Build/17.tpl +++ b/Templates/Build/17.tpl @@ -195,7 +195,13 @@ $coor['y'] = "";
goldclub == 1){?>

go

- + + +

merchantAvail()) { echo "DISABLED"; }?>/>

readingNotice['data']); if(isset($dataarray[14]) and $dataarray[14]!=0){$colspan="11";}else{$colspan="10";} +if(PEACE == 1){ +$image = "peace"; +}else if(PEACE == 2){ +$image = "xmas"; +}else if(PEACE == 3){ +$image = "newy"; +}else{ +$image = "easter"; +} +if(PEACE == 1){ +$message1 = "".$database->getUserField($dataarray[0],"username",0)." visited ".$database->getUserField($dataarray[2],"username",0)."'s troops"; +}else if(PEACE == 2){ +$message1 = "".$database->getUserField($dataarray[0],"username",0)." wishes you Merry Christmas"; +}else if(PEACE == 3){ +$message1 = "".$database->getUserField($dataarray[0],"username",0)." wishes you Happy New Year"; +}else{ +$message1 = "".$database->getUserField($dataarray[0],"username",0)." wishes you Happy Easter"; +} ?> @@ -53,8 +70,8 @@ if(isset($dataarray[14]) and $dataarray[14]!=0){ ?>
Information - Peace - getUserField($dataarray[0],"username",0)." visited ".$database->getUserField($dataarray[2],"username",0)."'s troops" ?> + Peace +
\ No newline at end of file diff --git a/gpack/travian_default/img/r/peace.gif b/gpack/travian_default/img/r/peace.gif new file mode 100644 index 0000000000000000000000000000000000000000..7b1f6d30449c976f49a4ff4f55558156a7084732 GIT binary patch literal 174 zcmZ?wbhEHb3F2nzSlmGt}{tp7jjg5`} z|9}1eDNqRrDE?$&WMJT9&;fBkW-zcsU+|R7ntLO3**QsZu>uaJIn9DTj_MrhAC|2y zn^DM@#l<(@zDcWq`B+oyDaGR~0+SdoFXD`_(PqAxy<2o0Q>0^(jhH~$tb+>(~Mkip?iSJVUError creating constant.php Peace system: