Optimizations

-Removed the "sort_type" 6 from the movement table, looted resources
will now be saved in the "sort_type" 4 returing attack.
This reduces a lot the spam in the tables "send" and "movement" of the
database
-Removed some useless methods in Database.php and Message.php
+Optimized report loading, own report will be loaded only once (and not
twice at random) and allied reports aren't loaded anymore
+Minor improovements and better indentation
This commit is contained in:
iopietro
2018-05-05 17:54:34 +02:00
parent cf74514451
commit f7e05c9802
14 changed files with 437 additions and 624 deletions
+5 -16
View File
@@ -1,5 +1,5 @@
<?php
include_once ("GameEngine/Data/unitdata.php");
include_once("GameEngine/Data/unitdata.php");
$units = $database->getMovement(34, $village->wid, 1);
$total_for = count($units);
@@ -7,12 +7,6 @@ $send = $database->getMovement(1, $village->wid, 1);
$total_for2 = count($send);
$artifactsSum = $database->getArtifactsSumByKind($session->uid, $village->wid, 3);
for($y = 0; $y < $total_for; $y++){
for($i = 0; $i < $total_for2; $i++){
if($units[$y]['ref'] == $send[$i]['ref2']){
$res1 = mysqli_query($database->dblink, "SELECT wood, clay, iron, crop FROM ".TB_PREFIX."send where id = ".(int)$send[$i]['ref']."");
$res = mysqli_fetch_array($res1);
}
}
$session->timer++;
if($units[$y]['sort_type'] == 3){
if($units[$y]['attack_type'] == 2) $actionType = REINFORCEMENTFOR;
@@ -162,10 +156,8 @@ for($y = 0; $y < $total_for; $y++){
</tr>
</tbody>
<?php
if(isset($res)) $totalres = $res['wood'] + $res['clay'] + $res['iron'] + $res['crop'];
else $totalres = 0;
if($units[$y]['attack_type'] != 2 && $units[$y]['attack_type'] != 1 && !empty($totalres)){
$totalres = $units[$y]['wood'] + $units[$y]['clay'] + $units[$y]['iron'] + $units[$y]['crop'];
if($units[$y]['attack_type'] != 2 && $units[$y]['attack_type'] != 1 && $totalres > 0){
?>
<tbody class="goods">
<tr>
@@ -175,11 +167,9 @@ for($y = 0; $y < $total_for; $y++){
<?php
$totalcarry = 0;
for($i = 0; $i <= 9; $i++) $totalcarry += $units[$y]['t'.($i + 1)] * ${'u'.($start + $i)}['cap'];
echo "<div class=\"res\"><img class=\"r1\" src=\"img/x.gif\" alt=\"Lumber\" title=\"Lumber\" />".$res['wood']." | <img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"Clay\" />".$res['clay']." | <img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"Iron\" />".$res['iron']." | <img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"Crop\" />".$res['crop']."</div>";
echo "<div class=\"res\"><img class=\"r1\" src=\"img/x.gif\" alt=\"Lumber\" title=\"Lumber\" />".$units[$y]['wood']." | <img class=\"r2\" src=\"img/x.gif\" alt=\"Clay\" title=\"Clay\" />".$units[$y]['clay']." | <img class=\"r3\" src=\"img/x.gif\" alt=\"Iron\" title=\"Iron\" />".$units[$y]['iron']." | <img class=\"r4\" src=\"img/x.gif\" alt=\"Crop\" title=\"Crop\" />".$units[$y]['crop']."</div>";
echo "<div class=\"carry\"><img class=\"car\" src=\"img/x.gif\" alt=\"carry\" title=\"carry\"/>".$totalres."/".$totalcarry."</div>";
?>
?>
</tr>
</tbody>
<?php } ?>
@@ -202,7 +192,6 @@ for($y = 0; $y < $total_for; $y++){
</table>
<?php
}
unset($res, $res1);
}
$array = $database->getOasis($village->wid);
foreach($array as $conqured){
+30 -34
View File
@@ -1,5 +1,7 @@
<?php
$noticeClass = array("Scout Report","Won as attacker without losses","Won as attacker with losses","Lost as attacker with losses","Won as defender without losses","Won as defender with losses","Lost as defender with losses","Lost as defender without losses","Reinforcement arrived","","Wood Delivered","Clay Delivered","Iron Delivered","Crop Delivered","","Won as defender without losses","Won as defender with losses","Lost as defender with losses","Won scouting as attacker","Lost scouting as attacker","Won scouting as defender","Lost scouting as defender","Scout Report");
$noticeClass = ["Scout Report", "Won as attacker without losses", "Won as attacker with losses", "Lost as attacker with losses", "Won as defender without losses", "Won as defender with losses", "Lost as defender with losses", "Lost as defender without losses", "Reinforcement arrived", "",
"Wood Delivered", "Clay Delivered", "Iron Delivered", "Crop Delivered", "", "Won as defender without losses", "Won as defender with losses", "Lost as defender with losses", "Won scouting as attacker", "Lost scouting as attacker", "Won scouting as defender", "Lost scouting as defender",
"Scout Report"];
?>
<form method="post" action="berichte.php" name="msg">
<table cellpadding="1" cellspacing="1" id="overview"
@@ -55,41 +57,35 @@ $noticeClass = array("Scout Report","Won as attacker without losses","Won as att
<tbody>
<?php
if(isset($_GET['s'])) {
$s = $_GET['s'];
}
else {
$s = 0;
}
if(isset($_GET['s'])) $s = $_GET['s'];
else $s = 0;
$name = 1;
$count = 0;
for($i=(1+$s);$i<=(10+$s);$i++) {
if(count($message->noticearray) >= $i) {
echo "<tr><td class=\"sel\"><input class=\"check\" type=\"checkbox\" name=\"n".$name."\" value=\"".$message->noticearray[$i-1]['id']."\" /></td>
$name = 1;
$count = 0;
for($i = (1 + $s); $i <= (10 + $s); $i++){
if(count($message->noticearray) >= $i){
echo "<tr><td class=\"sel\"><input class=\"check\" type=\"checkbox\" name=\"n" . $name . "\" value=\"" . $message->noticearray[$i - 1]['id'] . "\" /></td>
<td class=\"sub\">";
$type = (isset($_GET['t']) && $_GET['t'] == 5)? $message->noticearray[$i-1]['archive'] : $message->noticearray[$i-1]['ntype'];
if($type == 23) $type = 22;
if($type >= 15 && $type <= 17){
$type = $type-11;
echo "<img src=\"img/x.gif\" class=\"iReport iReport$type\" alt=\"".$noticeClass[$type]."\" title=\"".$noticeClass[$type]."\" />";
}else if($type >= 18 && $type <= 22){
echo "<img src=\"gpack/travian_default/img/scouts/$type.gif\" alt=\"".$noticeClass[$type]."\" title=\"".$noticeClass[$type]."\" />";
}else{
echo "<img src=\"img/x.gif\" class=\"iReport iReport$type\" alt=\"".$noticeClass[$type]."\" title=\"".$noticeClass[$type]."\" />";
}
echo "<div><a href=\"berichte.php?id=".$message->noticearray[$i-1]['id']."\">".$message->noticearray[$i-1]['topic']."</a> ";
if($message->noticearray[$i-1]['viewed'] == 0) {
echo "(new)";
}
$date = $generator->procMtime($message->noticearray[$i-1]['time']);
echo "</div></td><td class=\"dat\">".$date[0]." ".$date[1]."</td></tr>";
}
$name++;
}
if(count($message->noticearray) == 0) {
echo "<td colspan=\"3\" class=\"none\">There are no reports available.</td></tr>";
}
$type = (isset($_GET['t']) && $_GET['t'] == 5) ? $message->noticearray[$i - 1]['archive'] : $message->noticearray[$i - 1]['ntype'];
if($type == 23) $type = 22;
if($type >= 15 && $type <= 17){
$type = $type - 11;
echo "<img src=\"img/x.gif\" class=\"iReport iReport$type\" alt=\"" . $noticeClass[$type] . "\" title=\"" . $noticeClass[$type] . "\" />";
}else if($type >= 18 && $type <= 22){
echo "<img src=\"gpack/travian_default/img/scouts/$type.gif\" alt=\"" . $noticeClass[$type] . "\" title=\"" . $noticeClass[$type] . "\" />";
}else{
echo "<img src=\"img/x.gif\" class=\"iReport iReport$type\" alt=\"" . $noticeClass[$type] . "\" title=\"" . $noticeClass[$type] . "\" />";
}
echo "<div><a href=\"berichte.php?id=" . $message->noticearray[$i - 1]['id'] . "\">" . $message->noticearray[$i - 1]['topic'] . "</a> ";
if($message->noticearray[$i - 1]['viewed'] == 0){
echo "(new)";
}
$date = $generator->procMtime($message->noticearray[$i - 1]['time']);
echo "</div></td><td class=\"dat\">" . $date[0] . " " . $date[1] . "</td></tr>";
}
$name++;
}
if(count($message->noticearray) == 0) echo "<td colspan=\"3\" class=\"none\">There are no reports available.</td></tr>";
?>
</tbody>