Artifacts update and optimizations

+Added the "Artifacts" section in the Admin Panel, which contains two
options: return a deleted artifact to the Natars and create new
Artifacts, assigned to a specified player
+Return to Natars coded, in the village section of the Admin Panel
+Moved a lot of functions and costants from Automation.php to the "new"
class Artifacts.php
+Optimized a lot the whole Natars creation process, decreased the number
of query of about 600
+Optimized a lot the function which deletes a player's account, it's now
executed almost instantly, even with players with a lot of villages
+Redesigned the map spawn system, using a more Travian-like village
distribution
+Fixed a bug that did show a broken village in the artifact chronology,
if that village was destroyed
+Reduced the amount of redundant code (about 230 lines) for
27_1.tpl/27_2.tpl and 27_3.tpl
+Fixed a bug that permitted to build the Great Granary and the Great
Warehouse in the whole account, with only a village effect artifact
+Fixed a bug in the Admin Panel map that didn't permit to show village
informations, if that village contained single quotes in its name
This commit is contained in:
iopietro
2018-07-24 03:04:25 +02:00
parent dc399437d0
commit 77136a9784
18 changed files with 1313 additions and 1195 deletions
+2 -2
View File
@@ -32,7 +32,7 @@ $artifactInfo = Artifacts::getArtifactInfo($artifact);
</tr>
<?php }else{ ?>
<tr>
<td><a href="?action=delArtifact&artid=<?php echo $artifact['id']; ?>" onClick="return del('arti', <?php echo $artifact['id']; ?>)"><img src="../img/admin/del.gif"></a></td>
<td><a href="?action=delArtifact&artid=<?php echo $artifact['id']; ?>&del=0" onClick="return del('arti', <?php echo $artifact['id']; ?>)"><img src="../img/admin/del.gif"></a></td>
<td class="icon"><img class="artefact_icon_<?php echo $artifact['type']; ?>" src="../img/x.gif"></td>
<td colspan="1"><div style="text-align: center"><?php echo $artifact['name']; ?></div></td>
<td colspan="1"><div style="text-align: center"><?php echo $artifactInfo['bonus']; ?></div></td>
@@ -48,6 +48,6 @@ $artifactInfo = Artifacts::getArtifactInfo($artifact);
</table>
<?php
if($village['owner'] != 3) echo '<a href="admin.php?action=returnArtifact&artid='.$artifact['id'].'">Return to Natars</a>';
if($village['owner'] != 3 && !empty($artifact)) echo '<a href="admin.php?action=returnArtifact&artid='.$artifact['id'].'">Return to Natars</a>';
?>
+129
View File
@@ -0,0 +1,129 @@
<?php
$deletedArtifacts = $database->getDeletedArtifacts();
?>
<link href="../<?php echo GP_LOCATE; ?>lang/en/lang.css?f4b7d" rel="stylesheet" type="text/css">
<link href="../<?php echo GP_LOCATE; ?>lang/en/compact.css?f4b7i" rel="stylesheet" type="text/css">
<h1>Artifacts</h1>
<form method="post" action="../Admin/admin.php?action=addArtifacts">
<table id="member">
<thead>
<tr>
<th colspan="4">Add artifact(s)</th>
</tr>
<tr>
<td class="ra"></td>
<td>Type</td>
<td>Quantity</td>
<td>Player id</td>
</tr>
</thead>
</tbody>
<tr>
<td class="icon"><img id="artifactImage" class="artefact_icon_1" src="../img/x.gif"></td>
<td>
<select name="selectedArtifact" id="selectedArtifact" onchange="changeArtifactImage()">
<?php
$artifactArrays = array_merge(Artifacts::NATARS_ARTIFACTS, Artifacts::NATARS_WW_BUILDING_PLANS);
foreach($artifactArrays as $desc => $artifactType){
foreach($artifactType as $artifact){
echo '
<option value="'.$artifact['type'].':'.$artifact['size'].':'.$desc.'">'.$artifact['name'].'</option>';
}
}
?>
</select>
</td>
<td><input type="number" value="1" min="1" max="999" name="artifactQuantity"></td>
<td><input type="text" value="<?php echo Artifacts::NATARS_UID; ?>" name="playerId"></td>
</tr>
<tr>
<td colspan="4"><div style="text-align: center"><button id="addArtifacts" class="trav_buttons" value="add" name="addArtifacts" onclick="this.disabled=true;this.form.submit();"> Add </button></div></td>
</tr>
</tbody>
</table>
</form>
<table id="member">
<thead>
<tr>
<th colspan="8">Deleted artifact(s)</th>
</tr>
<tr>
<td class="ra"></td>
<td class="ra"></td>
<td colspan="1">Name</td>
<td colspan="1">Bonus</td>
<td colspan="1">Area of effect</td>
<td colspan="1">Time of conquer</td>
<td colspan="1">Old owner</td>
<td colspan="1">Old village</td>
</tr>
</thead>
<tbody>
<?php
if(empty($deletedArtifacts)){
?>
<tr>
<td colspan="8"><div style="text-align: center"><?php echo NO_ARTIFACTS; ?></div></td>
</tr>
<?php }else{
foreach($deletedArtifacts as $artifact){
$artifactInfo = Artifacts::getArtifactInfo($artifact);
?>
<tr>
<td><a href="?action=returnArtifact&artid=<?php echo $artifact['id']; ?>&del=1" title="Return to Natars">
<img src="../../img/admin/acc.gif">
</a></td>
<td class="icon"><img class="artefact_icon_<?php echo $artifact['type']; ?>" src="../img/x.gif"></td>
<td colspan="1"><div style="text-align: center"><?php echo $artifact['name']; ?></div></td>
<td colspan="1"><div style="text-align: center"><?php echo $artifactInfo['bonus']; ?></div></td>
<td colspan="1"><div style="text-align: center"><?php echo $artifactInfo['effectInfluence']; ?></div></td>
<td colspan="1"><div style="text-align: center"><?php echo date("d.m.Y H:i:s", $artifact['conquered']); ?></div></td>
<td colspan="1"><div style="text-align: center">
<?php
$oldOwnerName = $database->getUserField($artifact['owner'], "username", 0);
if($oldOwnerName != "[?]"){
?>
<a href="?p=player&uid=<?php echo $artifact['owner']; ?>"><?php echo $oldOwnerName; ?></a>
<?php
}else{
?>
<span><font color="grey"><?php echo $oldOwnerName; ?></font></span>
<?php }?>
</div></td>
<td colspan="1"><div style="text-align: center">
<?php
$oldVillageName = $database->getVillageField($artifact['vref'], "name");
if($oldVillageName != "[?]"){
?>
<a href="?p=village&did=<?php echo $artifact['vref']; ?>"><?php echo $oldVillageName; ?></a>
<?php
}else{
?>
<span><font color="grey"><?php echo $oldVillageName; ?></font></span>
<?php }?>
</div></td>
<?php } ?>
</tr>
<?php
}
?>
</tbody>
</table>
<script type="text/javascript">
function changeArtifactImage(){
var selectedItem = document.getElementById("selectedArtifact").value.split(":")[0];
document.getElementById("artifactImage").className = "artefact_icon_" + selectedItem;
}
</script>
+10 -9
View File
@@ -96,21 +96,22 @@ if ($check1 == "" && $check2 == "" && $check3 == "") $criteria = "";
$player_info = $database->query_return($q);
foreach($player_info as $p_array) {
$p_name = $p_array['username'];
$p_village = mysqli_real_escape_string($database->dblink, $p_array['name']);
$p_name = htmlspecialchars(mysqli_escape_string($database->dblink, $p_array['username']));
$p_village = htmlspecialchars(mysqli_escape_string($database->dblink, $p_array['name']));
$p_coor = "(".$p_array['x']."|".$p_array['y'].")";
$p_pop = $p_array['pop'];
$p_tribe = $array_tribe[$p_array['tribe']];
$p_info ="<a href=\"?p=village&did=".$p_array['wref']."\" target=\"_blank\"><img src=\"../img/admin/map_".(isset($p_array['size']) ? "1".$p_array['size'] : ($p_array['access'] != ADMIN ? $p_array['tribe'] : 0)).".gif\" border=\"0\" onmouseout=\"med_closeDescription()\" onmousemove=\"med_mouseMoveHandler(arguments[0],'<ul class=\'p_info\'><li>Player name: <b>$p_name</b></li><li>Village name : <b>$p_village</b></li><li>Coordinate: <b>$p_coor</b></li><li>Population: <b>$p_pop</b></li><li>Tribe: <b>$p_tribe</b></li>".($check3 != "" && isset($p_array['size']) ? "<li>Artifact effect: <b>".$artifactsEffect[$p_array['size']]."</b></li>" : "")."</ul>')\"></a>";
//250px = 0
$xdiv = 250 / WORLD_MAX;
if($p_array['x'] < 0) $p_x = 250 - intval(abs($p_array['x']) * $xdiv); //-
elseif($p_array['x'] > 0) $p_x = 250 + intval(abs($p_array['x']) * $xdiv); //+
if($p_array['y'] < 0) $p_y = 250 + intval(abs($p_array['y']) * $xdiv); //-
elseif($p_array['y'] > 0) $p_y = 250 - intval(abs($p_array['y']) * $xdiv); //+
if($p_array['x'] == 0 && $p_array['y'] == 0) $p_x = $p_y = 250; //multihunter
//245px = 0
$pixelDiv = 245;
$xdiv = $pixelDiv / WORLD_MAX;
if($p_array['x'] <= 0) $p_x = $pixelDiv - intval(abs($p_array['x']) * $xdiv); //-x
elseif($p_array['x'] >= 0) $p_x = $pixelDiv + intval(abs($p_array['x']) * $xdiv); //+x
if($p_array['y'] <= 0) $p_y = $pixelDiv + intval(abs($p_array['y']) * $xdiv); //-y
elseif($p_array['y'] >= 0) $p_y = $pixelDiv - intval(abs($p_array['y']) * $xdiv); //+y
echo '<div style="left:'.$p_x.'px; top:'.$p_y.'px; position:absolute">'.$p_info.'</div>';
}
+7 -9
View File
@@ -23,6 +23,7 @@ include_once("../GameEngine/Database.php");
include_once ("../GameEngine/Lang/" . LANG . ".php");
include_once("../GameEngine/Admin/database.php");
include_once("../GameEngine/Data/buidata.php");
include_once("../GameEngine/Artifacts.php");
include('Templates/ver.tpl');
include('Templates/update_latest.tpl');
@@ -59,6 +60,10 @@ if (!empty($_GET['p'])) {
case 'map':
$subpage = 'Map';
break;
case 'artifacts':
$subpage = 'Artifacts';
break;
case 'search':
$subpage = 'General Search';
@@ -120,14 +125,6 @@ if (!empty($_GET['p'])) {
$subpage = 'Create Users';
break;
case 'natarend':
$subpage = 'Add WW Villages';
break;
case 'natarbuildingplan':
$subpage = 'Add WW Building Plan Villages';
break;
case 'admin_log':
$subpage = 'Admin Log';
break;
@@ -498,7 +495,7 @@ if (!empty($_GET['p'])) {
<li><a href="<?php echo HOMEPAGE; ?>">Server Homepage</a></li>
<li><a href="admin.php">Control Panel Home</a></li>
<li><a href="<?php echo rtrim(SERVER, '/'); ?>/dorf1.php">Return to the server</a></li>
<li><a href="?p=update"><font color="Red"><b>Server Update (<?php echo $up_avl; ?>)</font></b></a></li>
<li><a href="?p=update"><font color="Red"><b>Server Update (<?php echo $up_avl; ?>)</b></font></a></li>
<li><a href="?action=logout">Logout</a></li>
<li class="sub"><a href="#">Server Info</a>
<ul>
@@ -509,6 +506,7 @@ if (!empty($_GET['p'])) {
<li><a href="?p=report">Players Report</a></li>
<li><a href="?p=msg">Players Message</a></li>
<li><a href="?p=map">Map</a></li>
<li><a href="?p=artifacts">Artifacts</a></li>
</ul>
</li>
<li class="sub"><a href="#">Search</a>