From bdd3bfd41cc422c856fd360c8d8c970c6fbb2f0a Mon Sep 17 00:00:00 2001 From: iopietro Date: Wed, 16 May 2018 16:49:25 +0200 Subject: [PATCH] Farmlist improvements and fixes +Troops while adding/editing a raid lists are now inside of a table, this is a graphic enhancement +Reduced the X and Y textboxes size while adding/editing a raid list +Fixed a bug that didn't permit to add a raid list +Fixed a bug that did permit to insert spies in raid lists +The farmlists graphic is now more clear, "Add raid" and "Start raid" are now two general buttons, instead of having two buttons for raid list +"Select all" checkbox, will select all raid without refreshing the page (through JS) +Moved the function "getDistance" to Database.php +Removed a lot of redundant code from crop_finder.php +Removed rams, catapults, chiefs and settlers from the raid list, because the first three can't even loot resources +Removed trooplist2.tpl because of a more general unique template file (trooplist.tpl) +Some minor improvements and bug fixing IMPORTANT NOTE: if you don't want to reinstal the whole server, you can simply run this little query (where "s1_" is the prefix of your server): ALTER TABLE `s1_raidlist` DROP `t7`, DROP `t8`, DROP `t9`, DROP `t10`; --- GameEngine/Battle.php | 2 +- GameEngine/Database.php | 81 +++++--- GameEngine/Lang/en.php | 3 + GameEngine/Units.php | 136 ++++++------- Templates/Build/27_1.tpl | 65 +++--- Templates/goldClub/farmlist.tpl | 231 ++++++---------------- Templates/goldClub/farmlist_add.tpl | 2 +- Templates/goldClub/farmlist_addraid.tpl | 72 +++---- Templates/goldClub/farmlist_editraid.tpl | 75 +++---- Templates/goldClub/trooplist.tpl | 169 +++------------- Templates/goldClub/trooplist2.tpl | 141 ------------- crop_finder.php | 214 ++++---------------- dorf1.php | 2 +- gpack/travian_default/lang/en/compact.css | 3 + sql_updates.txt | 3 + var/db/struct.sql | 4 - 16 files changed, 340 insertions(+), 863 deletions(-) delete mode 100644 Templates/goldClub/trooplist2.tpl diff --git a/GameEngine/Battle.php b/GameEngine/Battle.php index c2a90cb7..25bf1398 100755 --- a/GameEngine/Battle.php +++ b/GameEngine/Battle.php @@ -250,7 +250,7 @@ class Battle { //dp = Infantry defense points //rap = Result attack points //rdp = Result defense points - //detected = Detected or not by enemy spies + //detected = Detected or not by defender spies $cap = $ap = $dp = $cdp = $rap = $rdp = 0; $detected = false; diff --git a/GameEngine/Database.php b/GameEngine/Database.php index ec77a1cf..c57efa4a 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -1470,6 +1470,27 @@ class MYSQLi_DB implements IDbConnection { return self::$oasisTroopsCountCache[$vref]; } + /** + * Calculates the distance from a village to another + * + * @param int $coorx1 X coordinate of the first village + * @param int $coory1 Y coordinate of the second village + * @param int $coorx2 X coordinate of the first village + * @param int $coory2 Y coordinate of the second village + * @return int Returns the calculated distance + */ + + public function getDistance($coorx1, $coory1, $coorx2, $coory2) { + $max = 2 * WORLD_MAX + 1; + $x1 = intval($coorx1); + $y1 = intval($coory1); + $x2 = intval($coorx2); + $y2 = intval($coory2); + $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); + $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); + return round(sqrt(pow($distanceX, 2) + pow($distanceY, 2)), 1); + } + public function canConquerOasis($vref, $wref, $use_cache = true) { list($vref,$wref) = $this->escape_input($vref,$wref); @@ -1592,7 +1613,7 @@ class MYSQLi_DB implements IDbConnection { } /***************************************** - Function to retrieve if is ocuped via ID + Function to retrieve if is occupied via ID References: Village ID *****************************************/ function getVillageState($wref, $use_cache = true) { @@ -2460,15 +2481,6 @@ class MYSQLi_DB implements IDbConnection { return $this->getVillageByWorldID($wref, $use_cache)['oasistype']; } - // no need to cache this method - function getFLData($id) { - list($id) = $this->escape_input((int) $id); - - $q = "SELECT * FROM " . TB_PREFIX . "farmlist where id = $id LIMIT 1"; - $result = mysqli_query($this->dblink,$q); - return mysqli_fetch_array($result); - } - // no need to cache this method function checkVilExist($wref) { list($wref) = $this->escape_input((int) $wref); @@ -7493,18 +7505,13 @@ References: User ID/Message ID, Mode } // no need to cache this method - function getVilFarmlist($wref) { - list($wref) = $this->escape_input((int) $wref); - $q = 'SELECT * FROM ' . TB_PREFIX . 'farmlist WHERE wref = ' . $wref . ' ORDER BY wref ASC LIMIT 1'; + function getVilFarmlist($uid) { + list($uid) = $this->escape_input((int) $uid); + + $q = 'SELECT * FROM ' . TB_PREFIX . 'farmlist WHERE owner = '.$uid.' ORDER BY wref ASC LIMIT 1'; $result = mysqli_query($this->dblink,$q); $dbarray = mysqli_fetch_array($result); - - if($dbarray['id']!=0) { - return true; - } else { - return false; - } - + return $dbarray['id'] > 0; } // no need to cache this method @@ -7512,15 +7519,35 @@ References: User ID/Message ID, Mode list($id) = $this->escape_input((int) $id); $q = "SELECT * FROM " . TB_PREFIX . "raidlist WHERE id = ".$id." LIMIT 1"; + $result = mysqli_query($this->dblink, $q); + return mysqli_fetch_array($result); + } + + /** + * Get all informations about a farm list + * + * @param int $id The farmlist ID + * @return array Returns the seleted farm list informations + */ + + function getFLData($id) { + list($id) = $this->escape_input((int) $id); + + $q = "SELECT * FROM " . TB_PREFIX . "farmlist where id = $id LIMIT 1"; $result = mysqli_query($this->dblink,$q); return mysqli_fetch_array($result); } + function delFarmList($id, $owner) { list($id, $owner) = $this->escape_input((int) $id, (int) $owner); $q = "DELETE FROM " . TB_PREFIX . "farmlist where id = $id and owner = $owner"; - return mysqli_query($this->dblink,$q); + if(mysqli_query($this->dblink, $q) && mysqli_affected_rows($this->dblink) > 0){ + $q = "DELETE FROM " . TB_PREFIX . "raidlist where lid = $id"; + return mysqli_query($this->dblink, $q); + } + return false; } function delSlotFarm($id, $owner, $lid) { @@ -7537,17 +7564,17 @@ References: User ID/Message ID, Mode return mysqli_query($this->dblink,$q); } - function addSlotFarm($lid, $owner, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) { - list($lid, $owner, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->escape_input($lid, $owner, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10); + function addSlotFarm($lid, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6) { + list($lid, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6) = $this->escape_input($lid, $towref, $x, $y, $distance, $t1, $t2, $t3, $t4, $t5, $t6); - $q = "INSERT INTO " . TB_PREFIX . "raidlist (`lid`, `towref`, `x`, `y`, `distance`, `t1`, `t2`, `t3`, `t4`, `t5`, `t6`, `t7`, `t8`, `t9`, `t10`) SELECT '$lid', '$towref', '$x', '$y', '$distance', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6', '$t7', '$t8', '$t9', '$t10' WHERE EXISTS(SELECT 1 FROM " . TB_PREFIX . "farmlist WHERE id = $lid AND owner = $owner)"; + $q = "INSERT INTO " . TB_PREFIX . "raidlist (`lid`, `towref`, `x`, `y`, `distance`, `t1`, `t2`, `t3`, `t4`, `t5`, `t6`) VALUES ('$lid', '$towref', '$x', '$y', '$distance', '$t1', '$t2', '$t3', '$t4', '$t5', '$t6')"; return mysqli_query($this->dblink,$q); } - function editSlotFarm($eid, $lid, $oldLid, $owner, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) { - list($eid, $lid, $oldLid, $owner, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10) = $this->escape_input((int) $eid, $lid, $oldLid, $owner, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10); + function editSlotFarm($eid, $lid, $oldLid, $owner, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6) { + list($eid, $lid, $oldLid, $owner, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6) = $this->escape_input((int) $eid, $lid, $oldLid, $owner, $wref, $x, $y, $dist, $t1, $t2, $t3, $t4, $t5, $t6); - $q = "UPDATE " . TB_PREFIX . "raidlist SET lid = '$lid', towref = '$wref', x = '$x', y = '$y', t1 = '$t1', t2 = '$t2', t3 = '$t3', t4 = '$t4', t5 = '$t5', t6 = '$t6', t7 = '$t7', t8 = '$t8', t9 = '$t9', t10 = '$t10' WHERE id = $eid AND lid = $oldLid AND EXISTS(SELECT 1 FROM " . TB_PREFIX . "farmlist WHERE id = $lid AND owner = $owner) AND EXISTS(SELECT 1 FROM " . TB_PREFIX . "farmlist WHERE id = $oldLid AND owner = $owner)"; + $q = "UPDATE " . TB_PREFIX . "raidlist SET lid = '$lid', towref = '$wref', x = '$x', y = '$y', t1 = '$t1', t2 = '$t2', t3 = '$t3', t4 = '$t4', t5 = '$t5', t6 = '$t6' WHERE id = $eid AND lid = $oldLid AND EXISTS(SELECT 1 FROM " . TB_PREFIX . "farmlist WHERE id = $lid AND owner = $owner) AND EXISTS(SELECT 1 FROM " . TB_PREFIX . "farmlist WHERE id = $oldLid AND owner = $owner)"; return mysqli_query($this->dblink,$q); } diff --git a/GameEngine/Lang/en.php b/GameEngine/Lang/en.php index 5c3a05ba..f16472c9 100755 --- a/GameEngine/Lang/en.php +++ b/GameEngine/Lang/en.php @@ -677,6 +677,8 @@ define("NOTROOP","no troops"); //map define("DETAIL","Details"); define("ABANDVALLEY","Abandoned valley"); +define("OCCUPIED","Occupied"); +define("UNOCCUPIED","Unoccupied"); define("UNOCCUOASIS","Unoccupied oasis"); define("OCCUOASIS","Occupied oasis"); define("THERENOINFO","There is no
information available."); @@ -708,6 +710,7 @@ define("WEST","West"); define("VILLAGE","Village"); define("OASIS","Oasis"); define("NO_OASIS", "You do not own any oases."); +define("NO_VILLAGES", "There are no villages."); define("PLAYER","Player"); //LOGIN.php diff --git a/GameEngine/Units.php b/GameEngine/Units.php index 7d0c096b..3b300b25 100755 --- a/GameEngine/Units.php +++ b/GameEngine/Units.php @@ -776,97 +776,83 @@ class Units { global $database, $generator, $session; $slots = $post['slot']; - $lid = $post['lid']; + if(empty($slots)){ + header("Location: build.php?id=39&t=99"); + exit(); + } + $tribe = $session->tribe; - $getFLData = $database->getFLData($lid); - - if($getFLData['owner'] != $session->uid) { - header("Location: build.php?id=39&t=99"); - exit(); - } - - $sql = "SELECT id, towref, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10 FROM " . TB_PREFIX . "raidlist WHERE lid = ".$database->escape((int)$lid)." order by id asc"; - $array = $database->query_return($sql); - foreach($array as $row){ - $sql1 = mysqli_fetch_array(mysqli_query($database->dblink, "SELECT * FROM " . TB_PREFIX . "units WHERE vref = ".(int)$getFLData['wref'])); - $sid = $row['id']; - $wref = $row['towref']; - - for($i = 1; $i <= 10; $i++) ${'t'.$i} = $row['t'.$i]; + + foreach($slots as $slot){ + $raidList = $database->getRaidList($slot); + $getFLData = $database->getFLData($raidList['lid']); + + //Check if we're trying to start our raidlists or other players raidlist + if($getFLData['owner'] != $session->uid) continue; - $t11 = 0; + //Get the units in the village + $villageUnits = $database->getUnit($getFLData['wref'], false); + + $sid = $raidList['id']; + $wref = $raidList['towref']; + + for($i = 1; $i <= 6; $i++) ${'t'.$i} = $raidList['t'.$i]; + $villageOwner = $database->getVillageField($wref, 'owner'); $userAccess = $database->getUserField($villageOwner, 'access', 0); $userID = $database->getUserField($villageOwner, 'id', 0); if($userAccess != 0 && !($userAccess == MULTIHUNTER && $userID == 5) && ($userAccess != ADMIN || (ADMIN_ALLOW_INCOMING_RAIDS && $userAccess == ADMIN))){ - if($tribe == 1){ - $uname = "u"; - $uname1 = "u1"; - $uname2 = ""; - }elseif($tribe == 2){ - $uname = "u1"; - $uname1 = "u2"; - $uname2 = "1"; - }elseif($tribe == 3){ - $uname = "u2"; - $uname1 = "u3"; - $uname2 = "2"; - }elseif($tribe == 4){ - $uname = "u3"; - $uname1 = "u4"; - $uname2 = "3"; - }else{ - $uname = "u4"; - $uname1 = "u5"; - $uname2 = "4"; - } - if($sql1[$uname.'1'] >= $t1 && $sql1[$uname.'2'] >= $t2 && $sql1[$uname.'3'] >= $t3 && $sql1[$uname.'4'] >= $t4 && $sql1[$uname.'5'] >= $t5 && $sql1[$uname.'6'] >= $t6 && $sql1[$uname.'7'] >= $t7 && $sql1[$uname.'8'] >= $t8 && $sql1[$uname.'9'] >= $t9 && $sql1[$uname1.'0'] >= $t10 && $sql1['hero'] >= $t11){ - if($post['slot'.$sid] == 'on'){ - $ckey = $generator->generateRandStr(6); - $time_now = time(); - $id = $database->addA2b($ckey, $time_now, $wref, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, 4); - $data = $database->getA2b($ckey, $time_now); - - $troopsTime = $this->getWalkingTroopsTime($getFLData['wref'], $data['to_vid'], $session->uid, $session->tribe, $data, 1, 'u'); - $time = $database->getArtifactsValueInfluence($getFLData['owner'], $getFLData['wref'], 2, $troopsTime); - - $ctar1 = $ctar2 = 0; - $abdata = $database->getABTech($getFLData['wref']); - $reference = $database->addAttack(($getFLData['wref']), $data['u1'], $data['u2'], $data['u3'], $data['u4'], $data['u5'], $data['u6'], $data['u7'], $data['u8'], $data['u9'], $data['u10'], $data['u11'], $data['type'], $ctar1, $ctar2, 0, $abdata['b1'], $abdata['b2'], $abdata['b3'], $abdata['b4'], $abdata['b5'], $abdata['b6'], $abdata['b7'], $abdata['b8']); - - $troops = []; - $amounts = []; - $modes = []; - - for($u = 1; $u <= 10; $u++){ - if($tribe == 1) $unitKey = $uname2 . $u; - else $unitKey = $uname2.($u < 10 ? $u : 0); - - $troops[] = $unitKey; - $amounts[] = $data['u'.$u]; - $modes[] = 0; - } - - $troops[] = 'hero'; - $amounts[] = $data['u11']; - $modes[] = 0; - - $database->modifyUnit($getFLData['wref'], $troops, $amounts, $modes); - $database->addMovement(3, $getFLData['wref'], $data['to_vid'], $reference, time(), ($time + time())); - - // prevent re-use of the same attack via re-POSTing the same data - $database->remA2b($id); + //Start = the first troop of the player's tribe + //End = the last selectable troop of the player's tribe + $start = ($session->tribe - 1) * 10 + 1; + $end = $start + 5; + + //Check if we've enough troops + $canSend = true; + for($i = $start; $i <= $end; $i++){ + if($villageUnits['u'.$i] < ${'t'.($i - $start + 1)}){ + $canSend = false; + break; } } + + //Send the attack + if($canSend){ + $ckey = $generator->generateRandStr(6); + $time_now = time(); + $id = $database->addA2b($ckey, $time_now, $wref, $t1, $t2, $t3, $t4, $t5, $t6, 0, 0, 0, 0, 0, 4); + $data = $database->getA2b($ckey, $time_now); + + $troopsTime = $this->getWalkingTroopsTime($getFLData['wref'], $data['to_vid'], $session->uid, $session->tribe, $data, 1, 'u'); + $time = $database->getArtifactsValueInfluence($getFLData['owner'], $getFLData['wref'], 2, $troopsTime); + + $abdata = $database->getABTech($getFLData['wref']); + $reference = $database->addAttack(($getFLData['wref']), $data['u1'], $data['u2'], $data['u3'], $data['u4'], $data['u5'], $data['u6'], 0, 0, 0, 0, 0, $data['type'], 0, 0, 0, $abdata['b1'], $abdata['b2'], $abdata['b3'], $abdata['b4'], $abdata['b5'], $abdata['b6'], $abdata['b7'], $abdata['b8']); + + $troops = []; + $amounts = []; + $modes = []; + + for($u = $start; $u <= $end; $u++){ + $troops[] = $u; + $amounts[] = $data['u'.($u - $start + 1)]; + $modes[] = 0; + } + + $database->modifyUnit($getFLData['wref'], $troops, $amounts, $modes); + $database->addMovement(3, $getFLData['wref'], $data['to_vid'], $reference, time(), ($time + time())); + + //Prevent re-use of the same attack via re-POSTing the same data + $database->remA2b($id); + } } } header("Location: build.php?id=39&t=99"); exit(); } }; - $units = new Units; ?> diff --git a/Templates/Build/27_1.tpl b/Templates/Build/27_1.tpl index 43f3dfd2..05cf54a4 100644 --- a/Templates/Build/27_1.tpl +++ b/Templates/Build/27_1.tpl @@ -2,17 +2,6 @@ $artefact1 = $database->getOwnArtefactInfo3($session->uid); $wref = $village->wid; $coor = $database->getCoor($wref); -function getDistance($coorx1, $coory1, $coorx2, $coory2) { - $max = 2 * WORLD_MAX + 1; - $x1 = intval($coorx1); - $y1 = intval($coory1); - $x2 = intval($coorx2); - $y2 = intval($coory2); - $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); - $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); - $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); - return round($dist, 1); - } ?>
@@ -107,40 +96,32 @@ if($count == 0) { $rows = array(); while($row = mysqli_fetch_array($arts)) { $query = mysqli_query($database->dblink,'SELECT x, y FROM `' . TB_PREFIX . 'wdata` WHERE `id` = ' . (int) $row['vref']); - $coor2 = mysqli_fetch_assoc($query); - - - $dist = round(getDistance($coor['x'], $coor['y'], $coor2['x'], $coor2['y']),1); - - $rows[$dist] = $row; - + $coor2 = mysqli_fetch_assoc($query); + $dist = $database->getDistance($coor['x'], $coor['y'], $coor2['x'], $coor2['y']); + $rows[$dist] = $row; } ksort($rows); foreach($rows as $row) { - $wref = $village->wid; - $coor = $database->getCoor($wref); - $wref2 = $row['vref']; - $coor2 = $database->getCoor($wref2); - echo ''; - echo ''; - echo ''; - echo '' . $row['name'] . ' ' . $row['effect'] . ''; - echo '
'; - if($row['size'] == 1 && $row['type'] != 11){ - $reqlvl = 10; - $effect = VILLAGE; - }else{ - if($row['type'] != 11){ - $reqlvl = 20; - }else{ - $reqlvl = 10; - } -$effect = ACCOUNT; -} - echo '
'.TREASURY.' ' . $reqlvl . ', '.EFFECT.' ' . $effect . ''; - echo '
' . $database->getUserField($row['owner'], "username", 0) . ''; - echo ''.getDistance($coor['x'], $coor['y'], $coor2['x'], $coor2['y']).''; - echo ''; + $wref = $village->wid; + $coor = $database->getCoor($wref); + $wref2 = $row['vref']; + $coor2 = $database->getCoor($wref2); + echo ''; + echo ''; + echo ''; + echo '' . $row['name'] . ' ' . $row['effect'] . ''; + echo '
'; + if($row['size'] == 1 && $row['type'] != 11){ + $reqlvl = 10; + $effect = VILLAGE; + }else{ + $reqlvl = $row['type'] != 11 ? 20 : 10; + $effect = ACCOUNT; + } + echo '
'.TREASURY.' ' . $reqlvl . ', '.EFFECT.' ' . $effect . ''; + echo '
' . $database->getUserField($row['owner'], "username", 0) . ''; + echo ''.$database->getDistance($coor['x'], $coor['y'], $coor2['x'], $coor2['y']).''; + echo ''; } } diff --git a/Templates/goldClub/farmlist.tpl b/Templates/goldClub/farmlist.tpl index 2a9a86c8..93dffb1e 100644 --- a/Templates/goldClub/farmlist.tpl +++ b/Templates/goldClub/farmlist.tpl @@ -9,6 +9,10 @@ if(isset($_GET['t']) == 99 && isset($_POST['action']) == 'addList' && !empty($_P exit; } +?> +
+ +dblink,"SELECT id, name, owner, wref FROM ".TB_PREFIX."farmlist WHERE owner = ".(int) $session->uid." ORDER BY wref DESC"); $query = mysqli_num_rows($sql); while($row = mysqli_fetch_array($sql)){ @@ -17,34 +21,26 @@ while($row = mysqli_fetch_array($sql)){ $lowner = $row["owner"]; $lwref = $row["wref"]; $lvname = $database->getVillageField($row["wref"], 'name'); - if($lwref == $village->wid){ ?> - - - - - -
delete - - Loading...
-
+
- - - - - - - + + + + + + + @@ -52,49 +48,41 @@ while($row = mysqli_fetch_array($sql)){ dblink,"SELECT * FROM ".TB_PREFIX."raidlist WHERE lid = ".(int) $lid." ORDER BY distance ASC"); $query2 = mysqli_num_rows($sql2); -if(!$query2) { - echo ''; -}else{ -while($row = mysqli_fetch_array($sql2)){ -$id = $row['id']; -$lid = $row['lid']; -$towref = $row['towref']; -$x = $row['x']; -$y = $row['y']; - -if($village->wid == $towref) $distance = '0'; -else $distance = $row['distance']; - -for($i = 1; $i <= 10; $i++) ${'t'.$i} = $row['t'.$i]; - -$vdata = $database->getVillage($towref); - +if(!$query2) echo ''; +else +{ + while($row = mysqli_fetch_array($sql2)){ + $id = $row['id']; + $lid = $row['lid']; + $towref = $row['towref']; + $x = $row['x']; + $y = $row['y']; + $distance = $row['distance']; + + for($i = 1; $i <= 6; $i++) ${'t'.$i} = $row['t'.$i]; + + $vdata = $database->getVillage($towref); ?> +
VillagePopDistanceTroopsLast raidVillagePopDistanceTroopsLast raid
There are no village.'.NO_VILLAGES.'
- - - - - + getMovement(3, $towref, 1); - if (($inc_atts = count($incoming_attacks)) > 0) { - foreach($incoming_attacks as $attack){ - if($attack['attack_type'] != 4) $inc_atts -= 1; + $attacks = $database->getMovement(3, $towref, 1); + if (($attacksCount = count($attacks)) > 0) { + foreach($attacks as $attack){ + if($attack['attack_type'] != 4) $attacksCount -= 1; } - if($inc_atts > 0) echo ''; + if($attacksCount > 0) echo ''; } - ?> + ?> dblink,"SELECT ntype, data, time, id FROM ".TB_PREFIX."ndata WHERE $limits AND toWref = ".(int) $towref." AND uid = ".(int) $session->uid." ORDER BY time DESC Limit 1"); if(mysqli_num_rows($getnotice) > 0){ while($row2 = mysqli_fetch_array($getnotice)){ @@ -136,8 +127,8 @@ while($row2 = mysqli_fetch_array($getnotice)){ $type2 = $row2['ntype']; echo " "; - $allres = $dataarray[25] + $dataarray[26] + $dataarray[27] + $dataarray[28]; - $carry = $dataarray[29]; + $allres = $dataarray[23] + $dataarray[24] + $dataarray[25] + $dataarray[26]; + $carry = $dataarray[27]; echo ""; @@ -159,137 +150,31 @@ while($row2 = mysqli_fetch_array($getnotice)){
-
- - - - - - -
- -

- - -
- -


+

-tribe-1)*10+1; -$end = ($session->tribe*10); -$un = 1; -for($i=$start;$i<=$end;$i++){ - echo ' - - 0 - '; -} -*/ -?> -
+
+ + + +getVilFarmlist($session->uid)){ ?> +
+ + +

+
+ + +

- - - -
-
-
- delete - - - Loading... -
-
Details
-
-
-
-
-
- + getUnit($village->wid); - -if($session->tribe==1){ - $unit1 = $getUnit['u1'];$unit2 = $getUnit['u2'];$unit3 = $getUnit['u3'];$unit4 = $getUnit['u4'];$unit5 = $getUnit['u5']; - $unit6 = $getUnit['u6'];$unit7 = $getUnit['u7'];$unit8 = $getUnit['u8'];$unit9 = $getUnit['u9'];$unit10 = $getUnit['u10']; -}elseif($session->tribe==2){ - $unit1 = $getUnit['u11'];$unit2 = $getUnit['u12'];$unit3 = $getUnit['u13'];$unit4 = $getUnit['u14'];$unit5 = $getUnit['u15']; - $unit6 = $getUnit['u16'];$unit7 = $getUnit['u17'];$unit8 = $getUnit['u18'];$unit9 = $getUnit['u19'];$unit10 = $getUnit['u20']; -}elseif($session->tribe==3){ - $unit1 = $getUnit['u21'];$unit2 = $getUnit['u22'];$unit3 = $getUnit['u23'];$unit4 = $getUnit['u24'];$unit5 = $getUnit['u25']; - $unit6 = $getUnit['u26'];$unit7 = $getUnit['u27'];$unit8 = $getUnit['u28'];$unit9 = $getUnit['u29'];$unit10 = $getUnit['u30']; -} -?> - -getVilFarmlist($village->wid)){ -?> - - - - - - villages); $i++){ - if($session->villages[$i-1] == $village->wid) $select = 'selected="selected"'; + if($session->villages[$i - 1] == $village->wid) $select = 'selected="selected"'; else $select = ''; echo ""; diff --git a/Templates/goldClub/farmlist_addraid.tpl b/Templates/goldClub/farmlist_addraid.tpl index 8fc32860..5adfcdbc 100644 --- a/Templates/goldClub/farmlist_addraid.tpl +++ b/Templates/goldClub/farmlist_addraid.tpl @@ -1,8 +1,16 @@ getVilFarmlist($session->uid)){ + header("Location: build.php?id=39&t=99"); + exit; +} + +if(isset($_POST['action']) && $_POST['action'] == 'addSlot' && isset($_POST['lid']) && $database->getFLData($_POST['lid'])['owner'] == $session->uid) { + + $troops = 0; + for($i = 1; $i <= 6; $i++){ + if(!in_array($i + ($session->tribe - 1) * 10, [4, 14, 23])) $troops += $_POST['t'.$i]; + } if(!empty($_POST['target_id'])){ $Wref = $_POST['target_id']; @@ -40,23 +48,10 @@ if(isset($_POST['action']) == 'addSlot' && $_POST['lid']) { $WrefY = $_POST['y']; } - $coor = $database->getCoor($village->wid); - - function getDistance($coorx1, $coory1, $coorx2, $coory2) { - $max = 2 * WORLD_MAX + 1; - $x1 = intval($coorx1); - $y1 = intval($coory1); - $x2 = intval($coorx2); - $y2 = intval($coory2); - $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); - $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); - $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); - return round($dist, 1); - } - - $distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY); - $database->addSlotFarm($_POST['lid'], $session->uid, $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']); - + $coor = $database->getCoor($village->wid); + $distance = $database->getDistance($coor['x'], $coor['y'], $WrefX, $WrefY); + $database->addSlotFarm($_POST['lid'], $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6']); + header("Location: build.php?id=39&t=99"); exit; } @@ -83,12 +78,8 @@ $sql = mysqli_query($database->dblink, "SELECT id, name, owner, wref FROM ".TB_P while($row = mysqli_fetch_array($sql)){ $lid = $row["id"]; $lname = $row["name"]; - $lowner = $row["owner"]; - $lwref = $row["wref"]; $lvname = $database->getVillageField($row["wref"], 'name'); - if($_GET['lid'] == $lid) $selected = 'selected=""'; - else $selected = ''; - echo ''; + echo ''; } ?> @@ -115,22 +106,21 @@ $sql = mysqli_query($database->dblink, "SELECT id, name, owner, wref FROM ".TB_P @@ -141,7 +131,7 @@ if(mysqli_num_rows(mysqli_query($database->dblink,$getwref)) != 0){
- +
diff --git a/Templates/goldClub/farmlist_editraid.tpl b/Templates/goldClub/farmlist_editraid.tpl index 87f79d9e..1ca54f80 100644 --- a/Templates/goldClub/farmlist_editraid.tpl +++ b/Templates/goldClub/farmlist_editraid.tpl @@ -3,8 +3,14 @@ if(isset($_GET['action']) == 'editSlot' && $_GET['eid']) { $eiddata = $database->getRaidList($_GET['eid']); $x = $eiddata['x']; $y = $eiddata['y']; - for($i = 1; $i <= 10; $i++) ${'t'.$i} = $eiddata['t'.$i]; + for($i = 1; $i <= 6; $i++) ${'t'.$i} = $eiddata['t'.$i]; $FLData = $database->getFLData($eiddata['lid']); + + //Check if we're editing one of ours raidlists + if($FLData['owner'] != $session->uid){ + header("Location: build.php?id=39&t=99"); + exit; + } } if(isset($_POST['action']) == 'editSlot' && isset($_GET['eid']) && !empty($_GET['eid']) && isset($_POST['lid']) && !empty($_POST['lid'])) { @@ -26,7 +32,9 @@ if(isset($_POST['action']) == 'editSlot' && isset($_GET['eid']) && !empty($_GET[ } $troops = 0; - for($i = 1; $i <= 10; $i++) $troops += $_POST['t'.$i]; + for($i = 1; $i <= 6; $i++){ + if(!in_array($i + ($session->tribe - 1) * 10, [4, 14, 23])) $troops += $_POST['t'.$i]; + } if(empty($_POST['x']) && empty($_POST['y']) && empty($_POST['target_id'])) $errormsg = "Enter coordinates."; elseif((empty($_POST['x']) || empty($_POST['y'])) && empty($_POST['target_id'])) $errormsg = "Enter the correct coordinates."; @@ -36,7 +44,6 @@ if(isset($_POST['action']) == 'editSlot' && isset($_GET['eid']) && !empty($_GET[ elseif($_POST['target_id'] == $village->wid || $vdata['wref'] == $village->wid) $errormsg = "You can't attack the same village you send troops from."; else { - if(!empty($_POST['target_id'])){ $Wref = $_POST['target_id']; $WrefCoor = $database->getCoor($Wref); @@ -47,28 +54,15 @@ if(isset($_POST['action']) == 'editSlot' && isset($_GET['eid']) && !empty($_GET[ $WrefX = $_POST['x']; $WrefY = $_POST['y']; } - $coor = $database->getCoor($village->wid); - - function getDistance($coorx1, $coory1, $coorx2, $coory2) { - $max = 2 * WORLD_MAX + 1; - $x1 = intval($coorx1); - $y1 = intval($coory1); - $x2 = intval($coorx2); - $y2 = intval($coory2); - $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); - $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); - $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); - return round($dist, 1); - } - $distance = getDistance($coor['x'], $coor['y'], $WrefX, $WrefY); - $database->editSlotFarm($_GET['eid'], $_POST['lid'], $database->getRaidList($_GET['eid'])['lid'], $session->uid, $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6'], $_POST['t7'], $_POST['t8'], $_POST['t9'], $_POST['t10']); + $coor = $database->getCoor($village->wid); + $distance = $database->getDistance($coor['x'], $coor['y'], $WrefX, $WrefY); + $database->editSlotFarm($_GET['eid'], $_POST['lid'], $database->getRaidList($_GET['eid'])['lid'], $session->uid, $Wref, $WrefX, $WrefY, $distance, $_POST['t1'], $_POST['t2'], $_POST['t3'], $_POST['t4'], $_POST['t5'], $_POST['t6']); header("Location: build.php?id=39&t=99"); exit; } } -if($FLData['owner'] == $session->uid){ ?>
@@ -95,8 +89,6 @@ $sql = mysqli_query($database->dblink,"SELECT id, name, owner, wref FROM ".TB_PR while($row = mysqli_fetch_array($sql)){ $lid = $row["id"]; $lname = $row["name"]; -$lowner = $row["owner"]; -$lwref = $row["wref"]; $lvname = $database->getVillageField($row["wref"], 'name'); if($lid == $lid2) $selected = 'selected=""'; @@ -127,26 +119,25 @@ $lvname = $database->getVillageField($row["wref"], 'name');
@@ -162,10 +153,4 @@ if(mysqli_num_rows(mysqli_query($database->dblink, $getwref)) != 0){   - - \ No newline at end of file + \ No newline at end of file diff --git a/Templates/goldClub/trooplist.tpl b/Templates/goldClub/trooplist.tpl index 2db26535..88758d0a 100644 --- a/Templates/goldClub/trooplist.tpl +++ b/Templates/goldClub/trooplist.tpl @@ -1,141 +1,30 @@ -tribe == 1){ +tribe - 1) * 10 + 1; +$end = $start + 5; ?> -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-tribe == 2){ ?> -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-tribe == 3){ ?> -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
- \ No newline at end of file + + + + + + + + + + + +
+ +
+ +
diff --git a/Templates/goldClub/trooplist2.tpl b/Templates/goldClub/trooplist2.tpl deleted file mode 100644 index 019c9b7d..00000000 --- a/Templates/goldClub/trooplist2.tpl +++ /dev/null @@ -1,141 +0,0 @@ -tribe == 1){ -?> -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-tribe == 2){ ?> -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-tribe == 3){ ?> -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
- \ No newline at end of file diff --git a/crop_finder.php b/crop_finder.php index 18929580..d367102f 100644 --- a/crop_finder.php +++ b/crop_finder.php @@ -92,17 +92,14 @@ $start_timer = $generator->pageLoadTimeStart(); ?>
wid; - $coor2 = $database->getCoor($wref2); - } - +include ("Templates/menu.tpl"); +if(is_numeric($_GET['x']) && is_numeric($_GET['y'])) { + $coor2['x'] = preg_replace("/[^a-zA-Z0-9_-]/","",$_GET['x']); + $coor2['y'] = preg_replace("/[^a-zA-Z0-9_-]/","",$_GET['y']); +} else { + $wref2 = $village->wid; + $coor2 = $database->getCoor($wref2); +} ?>
@@ -117,9 +114,9 @@ $start_timer = $generator->pageLoadTimeStart(); Search for: - /> 15 crop - /> 9 crop - /> both
+ /> 15 crop + /> 9 crop + /> both
@@ -127,140 +124,24 @@ $start_timer = $generator->pageLoadTimeStart(); x: y: - + dblink,"SELECT id, x, y, occupied, fieldtype FROM ".TB_PREFIX."wdata WHERE $fieldType"); - define('PREFIX', TB_PREFIX); - $type15 = mysqli_query($database->dblink,"SELECT id,x,y,occupied FROM ".PREFIX."wdata WHERE fieldtype = 6"); - $type9 = mysqli_query($database->dblink,"SELECT id,x,y,occupied FROM ".PREFIX."wdata WHERE fieldtype = 1"); - $type_both = mysqli_query($database->dblink,"SELECT id,x,y,occupied,fieldtype FROM ".PREFIX."wdata WHERE fieldtype = 1 OR fieldtype = 6"); - - if(is_numeric($_GET['x']) AND is_numeric($_GET['y'])) { - $coor['x'] = $_GET['x']; - $coor['y'] = $_GET['y']; - } else { - $wref = $village->wid; - $coor = $database->getCoor($wref); - } - - function getDistance($coorx1, $coory1, $coorx2, $coory2) { - $max = 2 * WORLD_MAX + 1; - $x1 = intval($coorx1); - $y1 = intval($coory1); - $x2 = intval($coorx2); - $y2 = intval($coory2); - $distanceX = min(abs($x2 - $x1), abs($max - abs($x2 - $x1))); - $distanceY = min(abs($y2 - $y1), abs($max - abs($y2 - $y1))); - $dist = sqrt(pow($distanceX, 2) + pow($distanceY, 2)); - return round($dist, 1); - } - - if($_GET['s'] == 1) { - -?> - - - - - - - - - - - - - - - $row) { - - echo ""; - echo ""; - if($row['occupied'] == 0) { - echo ""; - echo ""; - echo ""; - } else { - echo ""; - echo ""; - echo ""; - } - echo ""; - } - -?> - -
Crop Finder - 15c
TypeCoordinatesOwnerOccupiedDistance
15cgetMapCheck($row['id'])."\">".$database->getVillageField($row['id'], "name")." (".$row['x']."|".$row['y'].")-UnoccupiedgetMapCheck($row['id'])."\">".$database->getVillageField($row['id'], "name")." (".$row['x']."|".$row['y'].")getVillageField($row['id'], "owner")."\">".$database->getUserField($database->getVillageField($row['id'], "owner"), "username", 0)."Occupied
".getDistance($coor['x'], $coor['y'], $row['x'], $row['y'])."
- - - - - - - - - - - - - - - - - $row) { - - - echo ""; - echo ""; - if($row['occupied'] == 0) { - echo ""; - echo ""; - echo ""; - } else { - echo ""; - echo ""; - echo ""; - } - echo ""; - } - -?> - -
Crop Finder - 9c
TypeCoordinatesOwnerOccupiedDistance
9cgetMapCheck($row['id'])."\">".$database->getVillageField($row['id'], "name")." (".$row['x']."|".$row['y'].")-UnoccupiedgetMapCheck($row['id'])."\">".$database->getVillageField($row['id'], "name")." (".$row['x']."|".$row['y'].")getVillageField($row['id'], "owner")."\">".$database->getUserField($database->getVillageField($row['id'], "owner"), "username", 0)."Occupied
".getDistance($coor['x'], $coor['y'], $row['x'], $row['y'])."
- -wid; + $coor = $database->getCoor($wref); +} +if($_GET['s'] >= 1 && $_GET['s'] <= 3) { ?> @@ -277,37 +158,26 @@ $start_timer = $generator->pageLoadTimeStart(); $row) { - - if($row['fieldtype'] == 1) { - $field = '9c'; - } elseif($row['fieldtype'] == 6) { - $field = '15c'; - } - - echo ""; - echo ""; - if($row['occupied'] == 0) { - echo ""; - echo ""; - echo ""; - } else { - echo ""; - echo ""; - echo ""; - } - echo ""; - } - +while($row = mysqli_fetch_array($type)) { + $dist = $database->getDistance($coor['x'], $coor['y'], $row['x'], $row['y']); + $rows[$dist] = $row; +} +ksort($rows); +foreach($rows as $row) { + $field = $row['fieldtype'] == 1 ? '9c' : '15c'; + + echo ""; + if($row['occupied'] == 0) { + echo ""; + echo ""; + echo ""; + } else { + echo ""; + echo ""; + echo ""; + } + echo ""; +} ?>
" . $field . "getMapCheck($row['id'])."\">".$database->getVillageField($row['id'], "name")." (".$row['x']."|".$row['y'].")-UnoccupiedgetMapCheck($row['id'])."\">".$database->getVillageField($row['id'], "name")." (".$row['x']."|".$row['y'].")getVillageField($row['id'], "owner")."\">".$database->getUserField($database->getVillageField($row['id'], "owner"), "username", 0)."Occupied
".getDistance($coor['x'], $coor['y'], $row['x'], $row['y'])."
" . $field . "getMapCheck($row['id'])."\">".ABANDVALLEY." (".$row['x']."|".$row['y'].")-".UNOCCUPIED."getMapCheck($row['id'])."\">".$database->getVillageField($row['id'], "name")." (".$row['x']."|".$row['y'].")getVillageField($row['id'], "owner")."\">".$database->getUserField($database->getVillageField($row['id'], "owner"), "username", 0)."".OCCUPIED."
".$database->getDistance($coor['x'], $coor['y'], $row['x'], $row['y'])."
diff --git a/dorf1.php b/dorf1.php index be6b16a0..05a029a7 100644 --- a/dorf1.php +++ b/dorf1.php @@ -40,7 +40,7 @@ else $building->procBuild($_GET); - + gpack == null || GP_ENABLE == false) { diff --git a/gpack/travian_default/lang/en/compact.css b/gpack/travian_default/lang/en/compact.css index 1b9d883b..9e7aaa3e 100644 --- a/gpack/travian_default/lang/en/compact.css +++ b/gpack/travian_default/lang/en/compact.css @@ -6400,6 +6400,9 @@ div#build.gid16 table#raidList thead a { color: black; font-weight: normal; } +div#build.gid16 table#raidList input.text{ + width: 75px; +} div.map table#raidFavs thead a { color: black; font-weight: normal; diff --git a/sql_updates.txt b/sql_updates.txt index 61183197..32ef8671 100644 --- a/sql_updates.txt +++ b/sql_updates.txt @@ -1,3 +1,6 @@ +-- 16.05.2018 -> dropped four columns +ALTER TABLE `s1_raidlist` DROP `t7`, DROP `t8`, DROP `t9`, DROP `t10`; + -- 23.04.2018 -> new table CREATE TABLE IF NOT EXISTS `s1_artefacts_chrono` ( `id` int(11) NOT NULL AUTO_INCREMENT, diff --git a/var/db/struct.sql b/var/db/struct.sql index c7dbd466..21f6e17b 100644 --- a/var/db/struct.sql +++ b/var/db/struct.sql @@ -1257,10 +1257,6 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%raidlist` ( `t4` int(11) NULL, `t5` int(11) NULL, `t6` int(11) NULL, - `t7` int(11) NULL, - `t8` int(11) NULL, - `t9` int(11) NULL, - `t10` int(11) NULL, PRIMARY KEY (`id`), KEY `lid-distance` (`lid`, `distance`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;