mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-16 08:11:00 +00:00
fix: hero training and revive got messed up
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user