From 5ce949a135b31336f0792d03eafa724c0382a5c7 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 27 Nov 2017 11:18:55 +0100 Subject: [PATCH 1/9] feat: voting for travian.martinambrus.com --- Templates/menu.tpl | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Templates/menu.tpl b/Templates/menu.tpl index 1b2055d1..dfea5108 100644 --- a/Templates/menu.tpl +++ b/Templates/menu.tpl @@ -62,12 +62,26 @@ div.c1 {text-align: center} + ?> + ?>

+ + VOTE FOR US +

+ + + travian private servers

+ Travian Private Servers

+ Travian Private Server

+

+
Top Travian Private Servers
+ + +
+
isDeleting($session->uid); if($timestamp) { @@ -110,9 +124,9 @@ div.c1 {text-align: center} -
From 9f414943e036dc3a1a5dfc82b801b03b25a912e1 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 27 Nov 2017 11:27:22 +0100 Subject: [PATCH 2/9] feat: ads on side --- Templates/News/newsbox2.tpl | 63 ++++++------------------------------- 1 file changed, 10 insertions(+), 53 deletions(-) diff --git a/Templates/News/newsbox2.tpl b/Templates/News/newsbox2.tpl index 2787ee98..8b9f3419 100644 --- a/Templates/News/newsbox2.tpl +++ b/Templates/News/newsbox2.tpl @@ -1,55 +1,12 @@ -
newsbox 2
- ".(time() - (60*10))." AND tribe!=0 AND tribe!=4 AND tribe!=5"); - -?> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Online Users: users
Server Speed:
Troop Speed: x
Evasion Speed:
Map Size: x
Village Exp.:
Beginners Prot.: hrs
Medal Interval: = 86400){ echo ''.(MEDALINTERVAL/86400).' Days'; } else if(MEDALINTERVAL < 86400){ echo ''.(MEDALINTERVAL/3600).' Hours'; } ?>
Server Start:
+ + + +
From 646d1dedda61d1b464c916ec4cb3743e624c77ac Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 27 Nov 2017 11:31:26 +0100 Subject: [PATCH 3/9] feat: ads on side changed for text and graphics --- Templates/News/newsbox2.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Templates/News/newsbox2.tpl b/Templates/News/newsbox2.tpl index 8b9f3419..52dfc9ed 100644 --- a/Templates/News/newsbox2.tpl +++ b/Templates/News/newsbox2.tpl @@ -1,10 +1,10 @@
- + Date: Thu, 30 Nov 2017 20:12:59 +0100 Subject: [PATCH 7/9] catching up (#2) * fix: all languages added to installer * fix: all languages added to installer and Admin * fix: max crop/resources reset to level 1 value temporarily This happened when level 1 granary / warehouse was built because of a missing + sign in a formula. #374 * chore: some more badges and thanks to JetBrains :) * chore: one more badge :P * chore: cleanup * fix: Multihunter should have access to villages info * fix: troops duplicate for certain tribes via raid lists --- Admin/Templates/troopUpgrades.tpl | 2 +- Admin/Templates/troops.tpl | 2 +- Admin/Templates/village.tpl | 2 +- README.md | 16 +++- Templates/a2b/startRaid.tpl | 10 ++- cache/.htaccess | 4 - payment/.htaccess | 11 --- payment/c2p.php | 117 ------------------------------ 8 files changed, 24 insertions(+), 140 deletions(-) delete mode 100644 cache/.htaccess delete mode 100644 payment/.htaccess delete mode 100644 payment/c2p.php diff --git a/Admin/Templates/troopUpgrades.tpl b/Admin/Templates/troopUpgrades.tpl index c6b61c99..41152c70 100644 --- a/Admin/Templates/troopUpgrades.tpl +++ b/Admin/Templates/troopUpgrades.tpl @@ -1,5 +1,5 @@ diff --git a/Admin/Templates/troops.tpl b/Admin/Templates/troops.tpl index 8533977d..2836de67 100644 --- a/Admin/Templates/troops.tpl +++ b/Admin/Templates/troops.tpl @@ -108,7 +108,7 @@ else if($units['u49'] > 0){$u49 = ''.$units['u49'].'';} if($units['u50'] == 0){$u50 = ''.$units['u50'].'';} else if($units['u50'] > 0){$u50 = ''.$units['u50'].'';} - if($_SESSION['access'] == ADMIN) + if($_SESSION['access'] >= MULTIHUNTER) { if($user['tribe'] == 1) { diff --git a/Admin/Templates/village.tpl b/Admin/Templates/village.tpl index b3946cc3..f2f19e8b 100644 --- a/Admin/Templates/village.tpl +++ b/Admin/Templates/village.tpl @@ -10,7 +10,7 @@ ## Copyright: TravianZ (c) 2010-2014. All rights reserved. ## ## Improved: aggenkeech ## ################################################################################# -if($_SESSION['access'] < 9) die("Access Denied: You are not Admin!"); +if($_SESSION['access'] < 8) die("Access Denied: You are not Admin!"); error_reporting(0); $id = $_GET['did']; if(isset($id)) diff --git a/README.md b/README.md index 0c06b5a5..a08d9043 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,13 @@ [![Code Triagers Badge](https://www.codetriage.com/shadowss/travianz/badges/users.svg)](https://www.codetriage.com/shadowss/travianz) -[![Join the chat at https://gitter.im/TravianZ-V8/Lobby](https://badges.gitter.im/TravianZ-V8/Lobby.svg)](https://gitter.im/TravianZ-V8/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Gratipay User](https://img.shields.io/gratipay/user/martinambrus.svg?style=plastic)](https://gratipay.com/~martinambrus/) [![Maintenance](https://img.shields.io/maintenance/yes/2017.svg)]() +[![GitHub Release](https://img.shields.io/github/release/Shadowss/TravianZ/all.svg)]() +[![Github All Downloads](https://img.shields.io/github/downloads/Shadowss/TravianZ/total.svg)]() +[![GitHub contributors](https://img.shields.io/github/contributors/Shadowss/TravianZ.svg)]() +[![license](https://img.shields.io/github/license/Shadowss/TravianZ.svg)]() +[![GitHub last commit](https://img.shields.io/github/last-commit/Shadowss/TravianZ.svg)]() +[![Proudly Coded in PHPStorm](https://img.shields.io/badge/coded%20in-PHPStorm-BD5CF3.svg)](https://www.jetbrains.com/buy/opensource/?product=phpstorm) +[![Join the chat at https://gitter.im/TravianZ-V8/Lobby](https://badges.gitter.im/TravianZ-V8/Lobby.svg)](https://gitter.im/TravianZ-V8/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Donate to this project on LiberaPay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/martinambrus/donate) TravianZ Version **v.8.3.3 BETA b3** ====== @@ -48,4 +54,8 @@ runnign this game :) Also, our thanks go to all both, the original and occasional developers, especially [yi12345](https://github.com/yi12345/), [advocaite](https://github.com/advocaite/), [brainiacX](https://github.com/brainiacX/), [ronix](https://github.com/ronix/), [MisterX](https://github.com/MisterX/), [Elio](https://github.com/Elio/) and many others who were part of this -project's history. \ No newline at end of file +project's history. + +Last but not least, our thanks go to [JetBrains](https://www.jetbrains.com/) for lending us a one-year full-featured +[open-source PHPStorm](https://www.jetbrains.com/buy/opensource/?product=phpstorm) (and other products) license! +Thanks guys, you're awesome :) \ No newline at end of file diff --git a/Templates/a2b/startRaid.tpl b/Templates/a2b/startRaid.tpl index 982f29bb..c274fbe6 100644 --- a/Templates/a2b/startRaid.tpl +++ b/Templates/a2b/startRaid.tpl @@ -128,8 +128,14 @@ $modes = []; for ( $u = 1; $u <= 10; $u ++ ) { - $units[] = $uname2 . ($u < 10 ? $u : 0); - $amounts[] = $data[ 'u' . ($u < 10 ? $u : 0) ]; + if ($tribe == 1) { + $unitKey = $uname2 . $u; + } else { + $unitKey = $uname2 . ($u < 10 ? $u : 0); + } + + $units[] = $uname2 . $unitKey; + $amounts[] = $data[ 'u' . $unitKey ]; $modes[] = 0; } diff --git a/cache/.htaccess b/cache/.htaccess deleted file mode 100644 index d87fe95b..00000000 --- a/cache/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ - -Order allow,deny -Deny from all - \ No newline at end of file diff --git a/payment/.htaccess b/payment/.htaccess deleted file mode 100644 index 5a2d943e..00000000 --- a/payment/.htaccess +++ /dev/null @@ -1,11 +0,0 @@ - -Order deny,allow -Deny from all -Allow from service.micropayment.de -Allow from proxy.micropayment.de -Allow from access.micropayment.de -ErrorDocument 403 http://travian.shadowss.ro/403.php -ErrorDocument 404 http://travian.shadowss.ro/404.php -ErrorDocument 500 http://travian.shadowss.ro/500.php -Options -Indexes - \ No newline at end of file diff --git a/payment/c2p.php b/payment/c2p.php deleted file mode 100644 index 94221ff1..00000000 --- a/payment/c2p.php +++ /dev/null @@ -1,117 +0,0 @@ -Somethings wrong"; -} -if ($id1 == 199) { -$_SESSION['amount'] = $amount; -$trenner = "\n"; -$status = 'ok'; -$url = "http://" . $_SERVER['HOMEPAGE'] . "/a2b2.php"; // change to your own -$target = '_blank'; -$forward = 0; - -$response = 'status=' . $status; -$response.= $trenner; -$response.= 'url=' . $url; -$response.= $trenner; -$response.= 'target=' . $target; -$response.= $trenner; -$response.= 'forward=' . $forward; - - -echo $response; -} - -if ($id1 == 499) { -$_SESSION['amount'] = $amount; -$trenner = "\n"; -$status = 'ok'; -$url = "http://" . $_SERVER['HOMEPAGE'] . "/a2b2.php"; // change to your own -$target = '_blank'; -$forward = 1; - -$response = 'status=' . $status; -$response.= $trenner; -$response.= 'url=' . $url; -$response.= $trenner; -$response.= 'target=' . $target; -$response.= $trenner; -$response.= 'forward=' . $forward; - - -echo $response; -} -if ($id1 == 999) { -$_SESSION['amount'] = $amount; -$trenner = "\n"; -$status = 'ok'; -$url = "http://" . $_SERVER['HOMEPAGE'] . "/a2b2.php"; // change to your own -$target = '_blank'; -$forward = 1; - -$response = 'status=' . $status; -$response.= $trenner; -$response.= 'url=' . $url; -$response.= $trenner; -$response.= 'target=' . $target; -$response.= $trenner; -$response.= 'forward=' . $forward; - - -echo $response; -} -if ($id1 == 1999) { -$_SESSION['amount'] = $amount; -$trenner = "\n"; -$status = 'ok'; -$url = "http://" . $_SERVER['HOMEPAGE'] . "/a2b2.php"; // change to your own -$target = '_blank'; -$forward = 1; - -$response = 'status=' . $status; -$response.= $trenner; -$response.= 'url=' . $url; -$response.= $trenner; -$response.= 'target=' . $target; -$response.= $trenner; -$response.= 'forward=' . $forward; - - -echo $response; -} -if ($id1 == 4999) { -$_SESSION['amount'] = $amount; -$trenner = "\n"; -$status = 'ok'; -$url = "http://" . $_SERVER['HOMEPAGE'] . "/a2b2.php"; // change to your own -$target = '_blank'; -$forward = 1; - -$response = 'status=' . $status; -$response.= $trenner; -$response.= 'url=' . $url; -$response.= $trenner; -$response.= 'target=' . $target; -$response.= $trenner; -$response.= 'forward=' . $forward; - - -echo $response; -} -?> - From 23c0f4f8f758d77583508fbb97038b4836e5ed91 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Fri, 1 Dec 2017 11:10:00 +0100 Subject: [PATCH 8/9] catching up (#3) * fix: all languages added to installer * fix: all languages added to installer and Admin * fix: max crop/resources reset to level 1 value temporarily This happened when level 1 granary / warehouse was built because of a missing + sign in a formula. #374 * chore: some more badges and thanks to JetBrains :) * chore: one more badge :P * chore: cleanup * fix: Multihunter should have access to villages info * fix: troops duplicate for certain tribes via raid lists * fix: no need for WW Building Plan to start building a WW #337 * fix: natar WW villages created without units #392 * fix: sendunits.txt file could not be opened from Admin * fix: WW villages created via Admin do not have any units #392 * fix: WW building plans must be in player's village to start building WW #337 --- GameEngine/Admin/Mods/natarbuildingplan.php | 5 +---- GameEngine/Admin/Mods/natarend.php | 4 +--- GameEngine/Automation.php | 6 +++--- GameEngine/Building.php | 13 ++++++++++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/GameEngine/Admin/Mods/natarbuildingplan.php b/GameEngine/Admin/Mods/natarbuildingplan.php index 1928f904..f37b0726 100755 --- a/GameEngine/Admin/Mods/natarbuildingplan.php +++ b/GameEngine/Admin/Mods/natarbuildingplan.php @@ -27,7 +27,6 @@ include_once($autoprefix."GameEngine/Database.php"); $id = (int) $_POST['id']; $amt = (int) $_POST['vill_amount']; -$addUnitsWrefs = []; for($i=1;$i<=$amt;$i++) { @@ -41,7 +40,7 @@ $addUnitsWrefs = []; mysqli_query($GLOBALS["link"], $q); $pop = $automation->recountPop($wid); $cp = $automation->recountPop($wid); - $addUnitsWrefs[] = $wid; + $database->addUnits($wid); $database->addTech($wid); $database->addABTech($wid); $speed = NATARS_UNITS; @@ -51,8 +50,6 @@ $addUnitsWrefs = []; $database->addArtefact($wid, 3, 11, 1, PLAN, $desc, '', 'type1.gif'); } - $database->addUnits($addUnitsWrefs); - $myFile = "../../../Templates/text.tpl"; $fh = fopen($myFile, 'w') or die("


Can't open file: templates/text.tpl"); $text = file_get_contents("../../../Templates/text_format.tpl"); diff --git a/GameEngine/Admin/Mods/natarend.php b/GameEngine/Admin/Mods/natarend.php index 68497aa4..a3fd058f 100755 --- a/GameEngine/Admin/Mods/natarend.php +++ b/GameEngine/Admin/Mods/natarend.php @@ -27,7 +27,6 @@ include_once($autoprefix."GameEngine/Database.php"); $id = (int) $_POST['id']; $amt = (int) $_POST['vill_amount']; -$addUnitsWrefs = []; $addTechWrefs = []; $addABTechWrefs = []; @@ -44,17 +43,16 @@ for($i=1;$i<=$amt;$i++) { mysqli_query($GLOBALS["link"], $q); $pop = $automation->recountPop($wid); $cp = $automation->recountPop($wid); - $addUnitsWrefs[] = $wid; $addTechWrefs[] = $wid; $addABTechWrefs[] = $wid; $speed = NATARS_UNITS; //new with random amount of troops + $database->addUnits($wid); $q = "UPDATE " . TB_PREFIX . "units SET u41 = " . (rand(50, 1200) * $speed) . ", u42 = " . (rand(100, 1400) * $speed) . ", u43 = " . (rand(200, 1600) * $speed) . ", u44 = " . (rand(10, 50) * $speed) . ", u45 = " . (rand(48, 1700) * $speed) . ", u46 = " . (rand(60, 1800) * $speed) . ", u47 = " . (rand(200, 1600) * $speed) . ", u48 = " . (rand(40, 200) * $speed) . " , u49 = " . (rand(4, 20) * $speed) . ", u50 = " . (rand(5, 25) * $speed) . " WHERE vref = '".$wid."'"; mysqli_query($GLOBALS["link"], $q); } -$database->addUnits($addUnitsWrefs); $database->addTech($addTechWrefs); $database->addABTech($addABTechWrefs); diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 97f9086a..fcc2878e 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -1206,7 +1206,7 @@ class Automation { } $reload=false; - $ourFileHandle = fopen("GameEngine/Prevention/sendunits.txt", 'w'); + $ourFileHandle = fopen($autoprefix."GameEngine/Prevention/sendunits.txt", 'w'); fclose($ourFileHandle); $time = time(); $q = " @@ -3138,8 +3138,8 @@ class Automation { } } - if(file_exists("GameEngine/Prevention/sendunits.txt")) { - unlink("GameEngine/Prevention/sendunits.txt"); + if(file_exists($autoprefix."GameEngine/Prevention/sendunits.txt")) { + unlink($autoprefix."GameEngine/Prevention/sendunits.txt"); } if ($reload) header("Location: ".$_SERVER['PHP_SELF']); } diff --git a/GameEngine/Building.php b/GameEngine/Building.php index da5ac596..17e81ff6 100755 --- a/GameEngine/Building.php +++ b/GameEngine/Building.php @@ -87,19 +87,22 @@ class Building { // check if we should allow building the WW this high if ( $wwHighestLevelFound >= 50 ) { - $needed_plan = 1; + $needed_plan = 2; } else { - $needed_plan = 0; + $needed_plan = 1; } // count building plans if ( $needed_plan ) { $wwbuildingplan = 0; + $planFoundInOwnersVillage = false; $villages = $database->getVillagesID( $session->uid ); + foreach ( $villages as $village1 ) { $plan = count( $database->getOwnArtefactInfoByType2( $village1, 11 ) ); if ( $plan > 0 ) { $wwbuildingplan = 1; + $planFoundInOwnersVillage = true; } } @@ -118,7 +121,11 @@ class Building { } } - $cached = $wwbuildingplan > $needed_plan; + if ($needed_plan == 1) { + $cached = ($wwbuildingplan >= $needed_plan && $planFoundInOwnersVillage); + } else { + $cached = $wwbuildingplan >= $needed_plan; + } } else { // no need for building plans, we can still upgrade WW $cached = true; From a321906d41e07028a5e50e53d9f3378e971e6ad5 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Fri, 1 Dec 2017 19:57:57 +0100 Subject: [PATCH 9/9] catching up (#4) * fix: all languages added to installer * fix: all languages added to installer and Admin * fix: max crop/resources reset to level 1 value temporarily This happened when level 1 granary / warehouse was built because of a missing + sign in a formula. #374 * chore: some more badges and thanks to JetBrains :) * chore: one more badge :P * chore: cleanup * fix: Multihunter should have access to villages info * fix: troops duplicate for certain tribes via raid lists * fix: no need for WW Building Plan to start building a WW #337 * fix: natar WW villages created without units #392 * fix: sendunits.txt file could not be opened from Admin * fix: WW villages created via Admin do not have any units #392 * fix: WW building plans must be in player's village to start building WW #337 * fix: hero training and revival misbehaving * fix: spending hero points subtracts these from all player's heroes #341 * fix: 2nd row of catapults firing when not allowed #393 * fix: 2nd wave of catapults destroys targets and villages incorrectly #393 * fix: adding new village via Admin generates incorrect fields * chore: create default users with bcrypt enabled by default * fix: in-game Support login fails * fix: wrong password verify check allows for any login --- GameEngine/Account.php | 2 + GameEngine/Admin/database.php | 2 +- GameEngine/Automation.php | 96 ++++++++++++++++++------------- GameEngine/Database.php | 2 +- GameEngine/Session.php | 6 +- Templates/Build/37.tpl | 104 ++++++++++++++++++++-------------- Templates/Build/37_hero.tpl | 35 ++++++------ Templates/Build/37_revive.tpl | 1 - Templates/Build/37_train.tpl | 34 +++++------ var/db/struct.sql | 10 ++-- 10 files changed, 166 insertions(+), 126 deletions(-) diff --git a/GameEngine/Account.php b/GameEngine/Account.php index e498ee17..b730be41 100755 --- a/GameEngine/Account.php +++ b/GameEngine/Account.php @@ -218,6 +218,8 @@ class Account { if ( $activateData != "" ) { $form->addError( "activate", $_POST['user'] ); + } else { + $form->addError("pw",LOGIN_PW_ERROR); } } else { $form->addError("pw",LOGIN_PW_ERROR); diff --git a/GameEngine/Admin/database.php b/GameEngine/Admin/database.php index c3a08562..f47c4bdc 100755 --- a/GameEngine/Admin/database.php +++ b/GameEngine/Admin/database.php @@ -181,7 +181,7 @@ class adm_DB { $username = $database->getUserArray($uid,1); $username = $username['username']; $database->addVillage($wid,$uid,$username,'0'); - $database->addResourceFields($wid,$database->getVillageType($wid)); + $database->addResourceFields($wid,$database->getVillageType($wid, false)); $database->addUnits($wid); $database->addTech($wid); $database->addABTech($wid); diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index fcc2878e..95b437f9 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -1090,8 +1090,8 @@ class Automation { } // oasis cannot be destroyed + $pop=$this->recountPop($data['to'], false); if ($isoasis == 0) { - $pop=$this->recountPop($data['to'], false); if($pop==0 && $can_destroy==1){ $village_destroyed = 1; // this will ensure the right $info_cat text @@ -2267,6 +2267,9 @@ class Automation { else { // village stands, let's do the damage + /** + * FIRST CATAPULTS ROW + */ $basearray = $data['to']; $bdo = $database->getResourceLevel($basearray, false); $catapultTarget = $data['ctar1']; @@ -2277,15 +2280,12 @@ class Automation { $catapults2TargetRandom = ($catapults2WillNotShoot || $catapultTarget2 == 99); // we're manually targetting 1st and/or 2nd row of catapults - if (!$catapults1TargetRandom || !$catapults2TargetRandom) + if (!$catapults1TargetRandom) { $_catapultsTarget1Levels=array(); $__catapultsTarget1AltTargets=array(); - $_catapultsTarget2Levels=array(); - $__catapultsTarget2AltTargets=array(); - - // calculate targets for 1st and 2nd rows of catapults + // calculate targets for 1st rows of catapults $j=0; for ($i=1;$i<=41;$i++) { @@ -2298,13 +2298,6 @@ class Automation { $_catapultsTarget1Levels[$j]=$bdo['f'.$i]; $__catapultsTarget1AltTargets[$j]=$i; } - - // 2nd row of catapults pre-selected target calculations, if needed - if (!$catapults2TargetRandom && !$catapults2WillNotShoot && $bdo['f'.$i.'t'] == $catapultTarget2 && $bdo['f'.$i] > 0 && $catapultTarget2 != 31 && $catapultTarget2 != 32 && $catapultTarget2 != 33) - { - $_catapultsTarget2Levels[$j]=$bdo['f'.$i]; - $__catapultsTarget2AltTargets[$j]=$i; - } } // if we couldn't find a suitable target for 1st row of catapults, @@ -2321,6 +2314,54 @@ class Automation { $catapults1TargetRandom = true; } } + } + + // 1st row of catapults set to target randomly + if ($catapults1TargetRandom) + { + $list=array(); + for ($i=1;$i<=41;$i++) + { + if ($i==41) $i=99; + if ($bdo['f'.$i] > 0 && $catapultTarget != 31 && $catapultTarget != 32 && $catapultTarget != 33) + { + $list[]=$i; + } + } + $catapultTarget = $list[ rand(0, count($list) - 1) ]; + } + + /** + * resolve 1st row of catapults + */ + $village_destroyed = 0; + $this->resolveCatapultsDestruction($bdo, $battlepart, $info_cat, $data, $catapultTarget, !$catapults2WillNotShoot, false, $catp_pic, $can_destroy, $isoasis, $village_destroyed); + + /** + * SECOND CATAPULTS ROW + */ + // reload resource levels, since they've changed now + $bdo = $database->getResourceLevel($basearray, false); + + // we're manually targetting 2nd row of catapults + if (!$catapults2TargetRandom) + { + $_catapultsTarget2Levels=array(); + $__catapultsTarget2AltTargets=array(); + + // calculate targets for 2nd rows of catapults + $j=0; + for ($i=1;$i<=41;$i++) + { + if ($i==41) $i=99; + + // 2nd row of catapults pre-selected target calculations, if needed + if (!$catapults2TargetRandom && !$catapults2WillNotShoot && $bdo['f'.$i.'t'] == $catapultTarget2 && $bdo['f'.$i] > 0 && $catapultTarget2 != 31 && $catapultTarget2 != 32 && $catapultTarget2 != 33) + { + $_catapultsTarget2Levels[$j]=$bdo['f'.$i]; + $__catapultsTarget2AltTargets[$j]=$i; + } + } // if we couldn't find a suitable target for 2nd row of catapults, // select a random target instead @@ -2338,46 +2379,21 @@ class Automation { } } - // 1st row of catapults set to target randomly - if ($catapults1TargetRandom) - { - $list=array(); - $j = 1; - for ($i=1;$i<=41;$i++) - { - if ($i==41) $i=99; - if ($bdo['f'.$i] > 0 && $catapultTarget != 31 && $catapultTarget != 32 && $catapultTarget != 33) - { - $list[$j]=$i; - $j++; - } - } - $catapultTarget = $list[ rand(1, $j - 1) ]; - } - // 2nd row of catapults set to target randomly if ($catapults2TargetRandom && !$catapults2WillNotShoot) { $list=array(); - $j=1; for ($i=1;$i<=41;$i++) { if ($i==41) $i=99; if ($bdo['f'.$i] > 0) { - $j++; - $list[$j]=$i; + $list[]=$i; } } - $catapultTarget2 = $list[ rand(1, $j - 1) ]; + $catapultTarget2 = $list[ rand(0, count($list) - 1) ]; } - /** - * resolve 1st row of catapults - */ - $village_destroyed = 0; - $this->resolveCatapultsDestruction($bdo, $battlepart, $info_cat, $data, $catapultTarget, !$catapults2WillNotShoot, false, $catp_pic, $can_destroy, $isoasis, $village_destroyed); - /** * resolve 2nd row of catapults */ diff --git a/GameEngine/Database.php b/GameEngine/Database.php index eb46c265..f6ced345 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -5535,7 +5535,7 @@ References: User ID/Message ID, Mode $t11 = [$t11]; $type = [$type]; $ctar1 = [$ctar1]; - $ctar2 = [$ctar1]; + $ctar2 = [$ctar2]; $spy = [$spy]; $b1 = [$b1]; $b2 = [$b2]; diff --git a/GameEngine/Session.php b/GameEngine/Session.php index e66ed563..abff455c 100755 --- a/GameEngine/Session.php +++ b/GameEngine/Session.php @@ -180,7 +180,7 @@ class Session { if($user && ($admin || isset($_SESSION['sessid']))) { // check if this is not a support user, for who only messages and statistics are available - if ($user == 1) { + if ($user == 'Support') { $req_file = basename($_SERVER['PHP_SELF']); if (!in_array($req_file, ['nachrichten.php', 'logout.php', 'statistiken.php', 'rules.php', 'karte.php', 'karte2.php', 'spieler.php'])) { header('Location:nachrichten.php'); @@ -269,7 +269,9 @@ class Session { if($this->userarray['b4'] > $this->time) { $this->bonus4 = 1; } - $this->CheckHeroReal(); + if (!in_array($this->username, ['Support', 'Multihunter'])) { + $this->CheckHeroReal(); + } } private function SurfControl(){ diff --git a/Templates/Build/37.tpl b/Templates/Build/37.tpl index c9ac1231..c7abd466 100644 --- a/Templates/Build/37.tpl +++ b/Templates/Build/37.tpl @@ -8,7 +8,8 @@ | Copyright: TravianX Project All rights reserved | \*-------------------------------------------------------*/ - $hero_info = $units->Hero($session->uid, 0, true); + $hero_info = $units->Hero($session->uid); + $heroes = $units->Hero($session->uid, 1); $define['reset_level'] = 3; // Until which level you are able to reset your points ?> @@ -22,47 +23,70 @@

- getTimeFormat($hero_info['trainingtime'] - time()); + $include_training = true; + $include_revive = false; + foreach ($heroes as $hdata) { + if ($hdata['dead'] == 1) { + $include_revive = true; + } + + if ($hdata['inrevive'] == 1) { + $name1 = $hdata['name']; + $include_training = false; + } + } + + if($hero_info === false && $include_revive){ + include_once("37_revive.tpl"); + } + + if ($hero_info === false && $include_training) { + include_once("37_train.tpl"); + } else if($hero_info['intraining'] == 1) { + + $timeleft = $generator->getTimeFormat($hero_info['trainingtime'] - time()); ?>
@@ -85,9 +109,7 @@
escape($_POST['name']))."' where `uid`='".$database->escape($session->uid)."' AND dead = 0") or die("ERROR:".mysqli_error($database->dblink)); echo "".NAME_CHANGED.""; -} - $hero_info = $units->Hero($session->uid); +} ?> @@ -172,12 +171,12 @@ if (isset($_POST['name'])) { if($_GET['add'] == "reset") { if($hero_info['level'] <= 3){ if($hero_info['attack'] != 0 OR $hero_info['defence'] != 0 OR $hero_info['attackbonus'] != 0 OR $hero_info['defencebonus'] != 0 OR $hero_info['regeneration'] != 0){ - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = '".(($hero_info['level']*5)+5)."' WHERE `uid` = '" . $database->escape($session->uid) . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attack` = '0' WHERE `uid` = '" . $database->escape($session->uid) . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defence` = '0' WHERE `uid` = '" . $database->escape($session->uid) . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = '0' WHERE `uid` = '" . $database->escape($session->uid) . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = '0' WHERE `uid` = '" . $database->escape($session->uid) . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `regeneration` = '0' WHERE `uid` = '" . $database->escape($session->uid) . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = '".(($hero_info['level']*5)+5)."' WHERE `heroid` = " . $hero_info['heroid']); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attack` = '0' WHERE `heroid` = " . $hero_info['heroid']); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defence` = '0' WHERE `heroid` = " . $hero_info['heroid']); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = '0' WHERE `heroid` = " . $hero_info['heroid']); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = '0' WHERE `heroid` = " . $hero_info['heroid']); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `regeneration` = '0' WHERE `heroid` = " . $hero_info['heroid']); header("Location: build.php?id=".$id.""); exit; } @@ -185,40 +184,40 @@ if (isset($_POST['name'])) { } if($_GET['add'] == "off" && $hero_info['attack'] < 100) { if($hero_info['points'] > 0) { - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attack` = `attack` + 1 WHERE `uid` = '" . $database->escape($session->uid) . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $database->escape($session->uid) . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attack` = `attack` + 1 WHERE `heroid` = " . $hero_info['heroid']); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']); header("Location: build.php?id=".$id.""); exit; } } if($_GET['add'] == "deff" && $hero_info['defence'] < 100) { if($hero_info['points'] > 0) { - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defence` = `defence` + 1 WHERE `uid` = '" . $database->escape($session->uid) . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $database->escape($session->uid) . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defence` = `defence` + 1 WHERE `heroid` = " . $hero_info['heroid']); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']); header("Location: build.php?id=".$id.""); exit; } } if($_GET['add'] == "obonus" && $hero_info['attackbonus'] < 100) { if($hero_info['points'] > 0) { - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = `attackbonus` + 1 WHERE `uid` = '" . $database->escape($session->uid) . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $database->escape($session->uid) . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `attackbonus` = `attackbonus` + 1 WHERE `heroid` = " . $hero_info['heroid']); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']); header("Location: build.php?id=".$id.""); exit; } } if($_GET['add'] == "dbonus" && $hero_info['defencebonus'] < 100) { if($hero_info['points'] > 0) { - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = `defencebonus` + 1 WHERE `uid` = '" . $database->escape($session->uid) . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $database->escape($session->uid) . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `defencebonus` = `defencebonus` + 1 WHERE `heroid` = " . $hero_info['heroid']); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']); header("Location: build.php?id=".$id.""); exit; } } if($_GET['add'] == "reg" && $hero_info['regeneration'] < 100) { if($hero_info['points'] > 0) { - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `regeneration` = `regeneration` + 1 WHERE `uid` = '" . $database->escape($session->uid) . "'"); - mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `uid` = '" . $database->escape($session->uid) . "'"); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `regeneration` = `regeneration` + 1 WHERE `heroid` = " . $hero_info['heroid']); + mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET `points` = `points` - 1 WHERE `heroid` = " . $hero_info['heroid']); header("Location: build.php?id=".$id.""); exit; } diff --git a/Templates/Build/37_revive.tpl b/Templates/Build/37_revive.tpl index d8378058..fd9c8d1c 100644 --- a/Templates/Build/37_revive.tpl +++ b/Templates/Build/37_revive.tpl @@ -29,7 +29,6 @@ | Dzoki < dzoki.travian@gmail.com > | | Copyright: TravianX Project All rights reserved | \*-------------------------------------------------------*/ - $heroes = $units->Hero($session->uid, 1); // check if there is a hero in revive already $reviving = false; diff --git a/Templates/Build/37_train.tpl b/Templates/Build/37_train.tpl index 4806dc77..7c2c34bb 100644 --- a/Templates/Build/37_train.tpl +++ b/Templates/Build/37_train.tpl @@ -34,8 +34,8 @@ //check if there is unit needed in the village -$result = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."units WHERE `vref` = ".(int) $village->wid.""); -$units = mysqli_fetch_array($result); +$result = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."units WHERE `vref` = ".(int) $village->wid.""); +$units_array = mysqli_fetch_array($result); $count_hero = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = " . $database->escape($session->uid) . ""), MYSQLI_ASSOC); $count_hero = $count_hero['Total']; @@ -75,7 +75,7 @@ if($session->tribe == 1) { if($village->awood < $u1['wood'] || $village->aclay < $u1['clay'] || $village->airon < $u1['iron'] || $village->acrop < $u1['crop']) $output.="".NOT."".ENOUGH_RESOURCES.""; - elseif($units['u1'] == 0) + elseif( $units_array['u1'] == 0) $output.="".NOT_UNITS.""; else $output.="".TRAIN.""; @@ -112,7 +112,7 @@ if($session->tribe == 1) { if($village->awood < $u2['wood'] OR $village->aclay < $u2['clay'] OR $village->airon < $u2['iron'] OR $village->acrop < $u2['crop']) $output.="".NOT."".ENOUGH_RESOURCES.""; - elseif($units['u2'] == 0) + elseif( $units_array['u2'] == 0) $output.="".NOT_UNITS.""; else $output.="".TRAIN.""; @@ -150,7 +150,7 @@ if($session->tribe == 1) { if($village->awood < $u3['wood'] OR $village->aclay < $u3['clay'] OR $village->airon < $u3['iron'] OR $village->acrop < $u3['crop']) { $output.="".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u3'] == 0){ + }else if( $units_array['u3'] == 0){ $output.="".NOT_UNITS.""; }else { $output.="".TRAIN.""; @@ -187,7 +187,7 @@ if($session->tribe == 1) { if($village->awood < $u5['wood'] OR $village->aclay < $u5['clay'] OR $village->airon < $u5['iron'] OR $village->acrop < $u5['crop']) { $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u5'] == 0){ + }else if( $units_array['u5'] == 0){ $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; @@ -224,7 +224,7 @@ if($session->tribe == 1) { if($village->awood < $u6['wood'] OR $village->aclay < $u6['clay'] OR $village->airon < $u6['iron'] OR $village->acrop < $u6['crop']) { $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u6'] == 0){ + }else if( $units_array['u6'] == 0){ $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; @@ -264,7 +264,7 @@ $output.=" if($village->awood < $u11['wood'] OR $village->aclay < $u11['clay'] OR $village->airon < $u11['iron'] OR $village->acrop < $u11['crop']) { $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u11'] == 0){ + }else if( $units_array['u11'] == 0){ $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; @@ -301,7 +301,7 @@ $output.=" if($village->awood < $u12['wood'] OR $village->aclay < $u12['clay'] OR $village->airon < $u12['iron'] OR $village->acrop < $u12['crop']) { $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u12'] == 0){ + }else if( $units_array['u12'] == 0){ $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; @@ -340,7 +340,7 @@ $output.=" if($village->awood < $u13['wood'] OR $village->aclay < $u13['clay'] OR $village->airon < $u13['iron'] OR $village->acrop < $u13['crop']) { $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u13'] == 0){ + }else if( $units_array['u13'] == 0){ $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; @@ -377,7 +377,7 @@ $output.=" if($village->awood < $u15['wood'] OR $village->aclay < $u15['clay'] OR $village->airon < $u15['iron'] OR $village->acrop < $u15['crop']) { $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u15'] == 0){ + }else if( $units_array['u15'] == 0){ $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; @@ -415,7 +415,7 @@ $output.=" if($village->awood < $u16['wood'] OR $village->aclay < $u16['clay'] OR $village->airon < $u16['iron'] OR $village->acrop < $u16['crop']) { $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u16'] == 0){ + }else if( $units_array['u16'] == 0){ $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; @@ -455,7 +455,7 @@ $output.=" if($village->awood < $u21['wood'] OR $village->aclay < $u21['clay'] OR $village->airon < $u21['iron'] OR $village->acrop < $u21['crop']) { $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u21'] == 0){ + }else if( $units_array['u21'] == 0){ $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; @@ -492,7 +492,7 @@ $output.=" if($village->awood < $u22['wood'] OR $village->aclay < $u22['clay'] OR $village->airon < $u22['iron'] OR $village->acrop < $u22['crop']) { $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u22'] == 0){ + }else if( $units_array['u22'] == 0){ $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; @@ -530,7 +530,7 @@ $output.=" if($village->awood < $u24['wood'] OR $village->aclay < $u24['clay'] OR $village->airon < $u24['iron'] OR $village->acrop < $u24['crop']) { $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u24'] == 0){ + }else if( $units_array['u24'] == 0){ $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; @@ -567,7 +567,7 @@ $output.=" if($village->awood < $u25['wood'] OR $village->aclay < $u25['clay'] OR $village->airon < $u25['iron'] OR $village->acrop < $u25['crop']) { $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u25'] == 0){ + }else if( $units_array['u25'] == 0){ $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; @@ -605,7 +605,7 @@ $output.=" if($village->awood < $u26['wood'] OR $village->aclay < $u26['clay'] OR $village->airon < $u26['iron'] OR $village->acrop < $u26['crop']) { $output.= "".NOT."".ENOUGH_RESOURCES.""; - }else if($units['u26'] == 0){ + }else if( $units_array['u26'] == 0){ $output.= "".NOT_UNITS.""; }else { $output.= "".TRAIN.""; diff --git a/var/db/struct.sql b/var/db/struct.sql index bb472ef5..bcfb1f4b 100644 --- a/var/db/struct.sql +++ b/var/db/struct.sql @@ -1605,11 +1605,11 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%users` ( -- Dumping data for table `%prefix%users` -- -INSERT INTO `%PREFIX%users` (`id`, `username`, `password`, `email`, `tribe`, `access`, `gold`, `gender`, `birthday`, `location`, `desc1`, `desc2`, `plus`, `b1`, `b2`, `b3`, `b4`, `sit1`, `sit2`, `alliance`, `sessid`, `act`, `timestamp`, `ap`, `apall`, `dp`, `dpall`, `protect`, `quest`, `gpack`, `cp`, `lastupdate`, `RR`, `Rc`, `ok`) VALUES -(5, 'Multihunter', '', 'multihunter@travianz.game', 0, 9, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), -(1, 'Support', '', 'support@travianz.game', 0, 8, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), -(2, 'Nature', '', 'nature@travianz.game', 4, 2, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), -(4, 'Taskmaster', '', 'taskmaster@travianz.game', 0, 8, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0); +INSERT INTO `%PREFIX%users` (`id`, `username`, `password`, `email`, `tribe`, `access`, `gold`, `gender`, `birthday`, `location`, `desc1`, `desc2`, `plus`, `b1`, `b2`, `b3`, `b4`, `sit1`, `sit2`, `alliance`, `sessid`, `act`, `timestamp`, `ap`, `apall`, `dp`, `dpall`, `protect`, `quest`, `gpack`, `cp`, `lastupdate`, `RR`, `Rc`, `ok`, `is_bcrypt`) VALUES +(5, 'Multihunter', '', 'multihunter@travianz.game', 0, 9, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0, 1), +(1, 'Support', '', 'support@travianz.game', 0, 8, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0, 1), +(2, 'Nature', '', 'nature@travianz.game', 4, 2, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0, 1), +(4, 'Taskmaster', '', 'taskmaster@travianz.game', 0, 8, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0, 1); -- --------------------------------------------------------