mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-06-28 00:24:23 +00:00
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`;
This commit is contained in:
+61
-75
@@ -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;
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user