mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-02 02:24:21 +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'];
|
||||
|
||||
Reference in New Issue
Block a user