mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-06-28 00:24:23 +00:00
fix: hero dying and revival doesn't work correctly with multiple heroes
This commit is contained in:
@@ -618,7 +618,7 @@ class adm_DB {
|
||||
}
|
||||
|
||||
if( intval($enforce['hero']) > 0){
|
||||
$q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']."";
|
||||
$q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']." AND dead = 0";
|
||||
$result = mysqli_query($q);
|
||||
$hero_f=mysqli_fetch_array($result);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
|
||||
@@ -1884,7 +1884,7 @@ class Automation {
|
||||
}
|
||||
}
|
||||
if ($herosend_att>0){
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']."";
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']." AND dead = 0";
|
||||
$resulth = mysqli_query($GLOBALS['link'],$qh);
|
||||
$hero_f=mysqli_fetch_array($resulth);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
@@ -2804,7 +2804,7 @@ class Automation {
|
||||
}
|
||||
|
||||
if ($prisoner['t11']>0){
|
||||
$p_qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $p_owner."";
|
||||
$p_qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $p_owner." AND dead = 0";
|
||||
$p_resulth = $database->query($p_qh);
|
||||
$p_hero_f=mysqli_fetch_array($p_resulth);
|
||||
$p_hero_unit=$p_hero_f['unit'];
|
||||
@@ -2978,7 +2978,7 @@ class Automation {
|
||||
}
|
||||
}
|
||||
if ($herosend_att>0){
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']."";
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']." AND dead = 0";
|
||||
$resulth = mysqli_query($GLOBALS['link'],$qh);
|
||||
$hero_f=mysqli_fetch_array($resulth);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
@@ -3259,7 +3259,7 @@ class Automation {
|
||||
}
|
||||
if (isset($post['t11'])){
|
||||
if( $post['t11'] != '' && $post['t11'] > 0){
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']."";
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']." AND dead = 0";
|
||||
$resulth = mysqli_query($GLOBALS['link'],$qh);
|
||||
$hero_f=mysqli_fetch_array($resulth);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
@@ -4894,8 +4894,8 @@ class Automation {
|
||||
if($herodata[0]['trainingtime'] <= time()) {
|
||||
if($herodata[0]['trainingtime'] != 0) {
|
||||
if($herodata[0]['dead'] == 0) {
|
||||
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET trainingtime = '0' WHERE uid = " . (int) $session->uid . "");
|
||||
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".(int) $session->villages[0]."");
|
||||
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "hero SET trainingtime = '0' WHERE heroid = " . $herodata[0]['heroid']);
|
||||
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".(int) $session->villages[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+24
-15
@@ -3729,7 +3729,7 @@ class MYSQLi_DB implements IDbConnection {
|
||||
|
||||
function getHeroField($uid,$field) {
|
||||
list($uid,$field) = $this->escape_input((int) $uid,$field);
|
||||
$q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = $uid";
|
||||
$q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = $uid AND dead = 0";
|
||||
$result = mysqli_query($this->dblink,$q);
|
||||
return $this->mysqli_fetch_all($result);
|
||||
}
|
||||
@@ -3751,11 +3751,11 @@ class MYSQLi_DB implements IDbConnection {
|
||||
list($column,$value,$uid,$mode) = $this->escape_input($column,$value,(int) $uid,$mode);
|
||||
|
||||
if(!$mode) {
|
||||
$q = "UPDATE `".TB_PREFIX."hero` SET $column = '$value' WHERE uid = $uid";
|
||||
$q = "UPDATE `".TB_PREFIX."hero` SET $column = '$value' WHERE uid = $uid AND dead = 0";
|
||||
} elseif($mode=1) {
|
||||
$q = "UPDATE `".TB_PREFIX."hero` SET $column = $column + ". (int) $value ." WHERE uid = $uid";
|
||||
$q = "UPDATE `".TB_PREFIX."hero` SET $column = $column + ". (int) $value ." WHERE uid = $uid AND dead = 0";
|
||||
} else {
|
||||
$q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - ". (int) $value ." WHERE uid = $uid";
|
||||
$q = "UPDATE `".TB_PREFIX."hero` SET $column = $column - ". (int) $value ." WHERE uid = $uid AND dead = 0";
|
||||
}
|
||||
return mysqli_query($this->dblink,$q);
|
||||
}
|
||||
@@ -3763,7 +3763,7 @@ class MYSQLi_DB implements IDbConnection {
|
||||
function modifyHeroXp($column,$value,$heroid) {
|
||||
list($column,$value,$heroid) = $this->escape_input($column,(int) $value,(int) $heroid);
|
||||
|
||||
$q = "UPDATE ".TB_PREFIX."hero SET $column = $column + $value WHERE uid=$heroid";
|
||||
$q = "UPDATE ".TB_PREFIX."hero SET $column = $column + $value WHERE uid=$heroid AND dead = 0";
|
||||
return mysqli_query($this->dblink,$q);
|
||||
}
|
||||
|
||||
@@ -5121,10 +5121,13 @@ References:
|
||||
function getHeroDead($id) {
|
||||
list($id) = $this->escape_input((int) $id);
|
||||
|
||||
$q = "SELECT dead FROM " . TB_PREFIX . "hero WHERE `uid` = $id";
|
||||
$q = "SELECT dead FROM " . TB_PREFIX . "hero WHERE `uid` = $id WHERE dead = 0";
|
||||
$result = mysqli_query($this->dblink,$q);
|
||||
$notend= mysqli_fetch_array($result);
|
||||
return $notend['dead'];
|
||||
if (mysqli_num_rows($result) > 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/***************************
|
||||
@@ -5135,10 +5138,13 @@ References:
|
||||
function getHeroInRevive($id) {
|
||||
list($id) = $this->escape_input((int) $id);
|
||||
|
||||
$q = "SELECT inrevive FROM " . TB_PREFIX . "hero WHERE `uid` = $id";
|
||||
$q = "SELECT inrevive FROM " . TB_PREFIX . "hero WHERE `uid` = $id AND inrevive = 1";
|
||||
$result = mysqli_query($this->dblink,$q);
|
||||
$notend= mysqli_fetch_array($result);
|
||||
return $notend['inrevive'];
|
||||
if (mysqli_num_rows($result) > 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/***************************
|
||||
@@ -5149,10 +5155,13 @@ References:
|
||||
function getHeroInTraining($id) {
|
||||
list($id) = $this->escape_input((int) $id);
|
||||
|
||||
$q = "SELECT intraining FROM " . TB_PREFIX . "hero WHERE `uid` = $id";
|
||||
$q = "SELECT intraining FROM " . TB_PREFIX . "hero WHERE `uid` = $id AND intraining = 1";
|
||||
$result = mysqli_query($this->dblink,$q);
|
||||
$notend= mysqli_fetch_array($result);
|
||||
return $notend['intraining'];
|
||||
if (mysqli_num_rows($result) > 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/***************************
|
||||
@@ -5189,7 +5198,7 @@ References:
|
||||
function KillMyHero($id) {
|
||||
list($id) = $this->escape_input((int) $id);
|
||||
|
||||
$q = "UPDATE " . TB_PREFIX . "hero set dead = 1 where uid = ".$id;
|
||||
$q = "UPDATE " . TB_PREFIX . "hero set dead = 1 where uid = ".$id." AND dead = 0";
|
||||
return mysqli_query($this->dblink,$q);
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ class Units {
|
||||
}
|
||||
}
|
||||
if( intval($enforce['hero']) > 0){
|
||||
$q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']."";
|
||||
$q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']." AND dead = 0";
|
||||
$result = mysqli_query($GLOBALS['link'],$q);
|
||||
$hero_f=mysqli_fetch_array($result);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
@@ -616,7 +616,7 @@ if($session->access != BANNED){
|
||||
}
|
||||
if (isset($post['t11'])){
|
||||
if( $post['t11'] != '' && $post['t11'] > 0){
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']."";
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $from['owner']." AND dead = 0";
|
||||
$resulth = mysqli_query($GLOBALS['link'],$qh);
|
||||
$hero_f=mysqli_fetch_array($resulth);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
|
||||
+12
-15
@@ -14,13 +14,10 @@ global $database;
|
||||
|
||||
if (isset($_POST['name'])) {
|
||||
$_POST['name'] = stripslashes($_POST['name']);
|
||||
mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `name`='".($database->escape($_POST['name']))."' where `uid`='".$database->escape($session->uid)."'") or die("ERROR:".mysqli_error($database->dblink));
|
||||
$hero = mysqli_query($database->dblink,"SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = " . (int) $session->uid . "");
|
||||
$hero_info = mysqli_fetch_array($hero);
|
||||
echo "".NAME_CHANGED."";
|
||||
}
|
||||
|
||||
$hero = $units->Hero($session->uid);
|
||||
mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `name`='".($database->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);
|
||||
?>
|
||||
|
||||
<table id="distribution" cellpadding="1" cellspacing="1">
|
||||
@@ -37,8 +34,8 @@ if (isset($_POST['name'])) {
|
||||
</tr></thead>
|
||||
<tbody><tr>
|
||||
<th><?php echo OFFENCE; ?></th>
|
||||
<td class="val"><?php echo $hero['atk']; ?></td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo (2*$hero_info['attack'])+1; ?>px;" alt="<?php echo $hero['atk']; ?>" title="<?php echo $hero['atk']; ?>" /></td>
|
||||
<td class="val"><?php echo $hero_info['atk']; ?></td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo (2*$hero_info['attack'])+1; ?>px;" alt="<?php echo $hero_info['atk']; ?>" title="<?php echo $hero_info['atk']; ?>" /></td>
|
||||
<td class="up"><span class="none">
|
||||
<?php
|
||||
if($hero_info['points'] > 0 && $hero_info['attack'] < 100){
|
||||
@@ -57,8 +54,8 @@ if (isset($_POST['name'])) {
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo DEFENCE; ?></th>
|
||||
<td class="val"><?php echo $hero['di'] . "/" . $hero['dc']; ?></td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo (2*$hero_info['defence'])+1; ?>px;" alt="<?php echo ($hero['di']) . "/" . ($hero['dc']); ?>" title="<?php echo ($hero['di']) . "/" . ($hero['dc']); ?>" /></td>
|
||||
<td class="val"><?php echo $hero_info['di'] . "/" . $hero_info['dc']; ?></td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo (2*$hero_info['defence'])+1; ?>px;" alt="<?php echo ($hero_info['di']) . "/" . ($hero_info['dc']); ?>" title="<?php echo ($hero_info['di']) . "/" . ($hero_info['dc']); ?>" /></td>
|
||||
<td class="up"><span class="none">
|
||||
<?php
|
||||
if($hero_info['points'] > 0 && $hero_info['defence'] < 100){
|
||||
@@ -77,8 +74,8 @@ if (isset($_POST['name'])) {
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo OFF_BONUS; ?></th>
|
||||
<td class="val"><?php echo ($hero['ob']-1)*100; ?>%</td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero['ob']-1)*1000+1; ?>px;" alt="<?php echo ($hero['ob']-1)*100; ?>%" title="<?php echo ($hero['ob']-1)*100; ?>%" /></td>
|
||||
<td class="val"><?php echo ($hero_info['ob']-1)*100; ?>%</td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero_info['ob']-1)*1000+1; ?>px;" alt="<?php echo ($hero_info['ob']-1)*100; ?>%" title="<?php echo ($hero_info['ob']-1)*100; ?>%" /></td>
|
||||
<td class="up"><span class="none">
|
||||
<?php
|
||||
if($hero_info['points'] > 0 && $hero_info['attackbonus'] < 100){
|
||||
@@ -98,8 +95,8 @@ if (isset($_POST['name'])) {
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo DEF_BONUS; ?></th>
|
||||
<td class="val"><?php echo ($hero['db']-1)*100; ?>%</td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero['db']-1)*1000+1; ?>px;" alt="<?php echo ($hero['db']-1)*100; ?>%" title="<?php echo ($hero['db']-1)*100; ?>%" /></td>
|
||||
<td class="val"><?php echo ($hero_info['db']-1)*100; ?>%</td>
|
||||
<td class="xp"><img class="bar" src="img/x.gif" style="width:<?php echo ($hero_info['db']-1)*1000+1; ?>px;" alt="<?php echo ($hero_info['db']-1)*100; ?>%" title="<?php echo ($hero_info['db']-1)*100; ?>%" /></td>
|
||||
<td class="up"><span class="none">
|
||||
<?php
|
||||
if($hero_info['points'] > 0 && $hero_info['defencebonus'] < 100){
|
||||
|
||||
@@ -380,7 +380,7 @@ $end = ($tribe*10);
|
||||
else
|
||||
{
|
||||
//$uid
|
||||
$q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $uid;
|
||||
$q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $uid." AND dead = 0";
|
||||
$result = mysqli_query($GLOBALS['link'],$q);
|
||||
$hero_f=mysqli_fetch_array($result);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
|
||||
@@ -137,7 +137,7 @@ $tocoor = $database->getCoor($enforce['vref']);
|
||||
}
|
||||
}
|
||||
if ($enforce['hero']>0){
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']."";
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']." AND dead = 0";
|
||||
$resulth = mysqli_query($GLOBALS['link'],$qh);
|
||||
$hero_f=mysqli_fetch_array($resulth);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
|
||||
@@ -138,7 +138,7 @@ $tocoor = $database->getCoor($enforce['vref']);
|
||||
}
|
||||
}
|
||||
if ($enforce['hero']>0){
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']."";
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']." AND dead = 0";
|
||||
$resulth = mysqli_query($GLOBALS['link'],$qh);
|
||||
$hero_f=mysqli_fetch_array($resulth);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
|
||||
@@ -137,7 +137,7 @@ $tocoor = $database->getCoor($enforce['vref']);
|
||||
}
|
||||
}
|
||||
if ($enforce['hero']>0){
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']."";
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']." AND dead = 0";
|
||||
$resulth = mysqli_query($GLOBALS['link'],$qh);
|
||||
$hero_f=mysqli_fetch_array($resulth);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
|
||||
@@ -138,7 +138,7 @@ $tocoor = $database->getCoor($enforce['vref']);
|
||||
}
|
||||
}
|
||||
if ($enforce['hero']>0){
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']."";
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']." AND dead = 0";
|
||||
$resulth = mysqli_query($GLOBALS['link'],$qh);
|
||||
$hero_f=mysqli_fetch_array($resulth);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
|
||||
@@ -137,7 +137,7 @@ $tocoor = $database->getCoor($enforce['vref']);
|
||||
}
|
||||
}
|
||||
if ($enforce['hero']>0){
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']."";
|
||||
$qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']." AND dead = 0";
|
||||
$resulth = mysqli_query($GLOBALS['link'],$qh);
|
||||
$hero_f=mysqli_fetch_array($resulth);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
|
||||
@@ -193,7 +193,7 @@ if(isset($_GET['o'])) {
|
||||
}
|
||||
|
||||
if ($prisoner['t11']>0){
|
||||
$p_qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $p_owner."";
|
||||
$p_qh = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = ".(int) $p_owner." AND dead = 0";
|
||||
$p_resulth = mysqli_query($GLOBALS['link'],$p_qh);
|
||||
$p_hero_f=mysqli_fetch_array($p_resulth);
|
||||
$p_hero_unit=$p_hero_f['unit'];
|
||||
@@ -222,7 +222,7 @@ if(isset($_GET['o'])) {
|
||||
$troops = $prisoner['t1']+$prisoner['t2']+$prisoner['t3']+$prisoner['t4']+$prisoner['t5']+$prisoner['t6']+$prisoner['t7']+$prisoner['t8']+$prisoner['t9']+$prisoner['t10']+$prisoner['t11'];
|
||||
if($prisoner['t11'] > 0){
|
||||
$p_owner = $database->getVillageField($prisoner['from'],"owner");
|
||||
mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `dead` = '1', `health` = '0' WHERE `uid` = '".$p_owner."'");
|
||||
mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `dead` = '1', `health` = '0' WHERE `uid` = '".$p_owner."' AND dead = 0");
|
||||
}
|
||||
$database->modifyUnit($prisoner['wref'],array("99o"),array($troops),array(0));
|
||||
$database->deletePrisoners($prisoner['id']);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
ALTER TABLE `s1_hero` ADD INDEX(`lastupdate`);
|
||||
ALTER TABLE `s1_hero` DROP INDEX `uid`, ADD INDEX `uid` (`uid`, `dead`) USING BTREE;
|
||||
ALTER TABLE `s1_hero` ADD INDEX(`inrevive`);
|
||||
ALTER TABLE `s1_hero` ADD INDEX(`intraining`);
|
||||
|
||||
-- 31.10.2017 -> Embassy and alliance updates
|
||||
ALTER TABLE `s1_ali_permission` ADD INDEX(`alliance`);
|
||||
|
||||
+2
-1
@@ -916,7 +916,8 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%hero` (
|
||||
PRIMARY KEY (`heroid`),
|
||||
KEY `uid` (`uid`, `dead`) USING BTREE,
|
||||
KEY `lastupdate` (`lastupdate`),
|
||||
KEY `inrevive` (`inrevive`)
|
||||
KEY `inrevive` (`inrevive`),
|
||||
KEY `intraining` (`intraining`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
|
||||
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user