fix: hero training and revive got messed up

This commit is contained in:
Martin Ambrus
2017-11-22 21:38:57 +01:00
parent 96663574ad
commit c06c62ba6a
4 changed files with 49 additions and 339 deletions
+4
View File
@@ -4635,6 +4635,10 @@ class Automation {
if($villunits['hero'] == 0 && $hdata['trainingtime'] < time() && $hdata['intraining'] == 1){
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = ".(int) $hdata['wref']);
$columns[] = 'dead';
$columnValues[] = 0;
$modes[] = null;
$columns[] = 'intraining';
$columnValues[] = 0;
$modes[] = null;
+1 -1
View File
@@ -7500,7 +7500,7 @@ References:
function getHeroDeadReviveOrInTraining($id) {
$id = (int) $id;
$q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = $id AND (dead = 0 OR inrevive = 1 OR intraining = 1)";
$q = "SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = $id AND dead = 0 AND inrevive = 0 AND intraining = 0";
$result = mysqli_fetch_array(mysqli_query($this->dblink,$q), MYSQLI_ASSOC);
if ($result['Total'] > 0) {
return true;
+8 -3
View File
@@ -208,7 +208,9 @@ class Session {
global $database,$link;
$villageIDs = implode(', ', $this->villages);
$hero = mysqli_fetch_array(
// check if hero unit for this player is present anywhere on the map
$heroUnitRegisters = mysqli_fetch_array(
mysqli_query($database->dblink, '
SELECT
IFNULL((SELECT SUM(hero) from '.TB_PREFIX.'enforcement where `from` IN('.$villageIDs.')), 0) +
@@ -220,9 +222,12 @@ class Session {
MYSQLI_ASSOC
)['herocount'];
$isHeroElsewhere = $database->getHeroDeadReviveOrInTraining($this->uid);
// check if the actual hero is alive or being trained/revived into a living state
$isHeroLivingOrRaising = $database->getHeroDeadReviveOrInTraining($this->uid);
if($isHeroElsewhere && !$hero) {
// if he doesn't register anywhere on the map but is marked as alive,
// we need to kill him
if(!$heroUnitRegisters && $isHeroLivingOrRaising) {
$database->KillMyHero($this->uid);
}
}