diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 5a3634f7..5cb01958 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -1697,8 +1697,7 @@ class Automation { $alldead=array(); $heroAttackDead=$dead11; //kill own defence - $q = "SELECT * FROM ".TB_PREFIX."units WHERE vref='".$data['to']."'"; - $unitlist = $database->query_return($q); + $unitlist = $database->getUnit($data['to']); $start = ($targettribe-1)*10+1; $end = ($targettribe*10); @@ -1713,7 +1712,7 @@ class Automation { } if($unitlist){ - $owndead[$i]=round($battlepart[2]*$unitlist[0]['u'.$i]); + $owndead[$i] = round($battlepart[2] * (isset($unitlist[0]) ? $unitlist[0]['u'.$i] : 0)); $unitModifications_units[] = $i; $unitModifications_amounts[] = $owndead[$i]; $unitModifications_modes[] = 0; @@ -2136,10 +2135,7 @@ class Automation { } } if ($herosend_att>0){ - $qh = "SELECT unit 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']; + $hero_unit = $database->getHeroField($from['owner'], 'unit'); $speeds[] = $GLOBALS['u'.$hero_unit]['speed']; } @@ -3349,7 +3345,7 @@ class Automation { ) { //don't reinforce, addunit instead $database->modifyUnit($data['to'],array("hero"),array(1),array(1)); - $heroid = $database->getHero($DefenderID,1); + $heroid = $database->getHeroField($DefenderID, 'heroid'); $database->modifyHero("wref",$data['to'],$heroid,0); $HeroTransfer = 1; } diff --git a/GameEngine/Database.php b/GameEngine/Database.php index 7affb0c5..d0fbbe10 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -5169,14 +5169,14 @@ class MYSQLi_DB implements IDbConnection { // first of all, check if we should be using cache and whether the field // required is already cached if ($use_cache && ($cachedValue = self::returnCachedContent(self::$heroFieldCache, $uid.$field)) && !is_null($cachedValue)) { - return $cachedValue; + return $cachedValue[$field]; } $q = "SELECT * FROM ".TB_PREFIX."hero WHERE uid = $uid AND dead = 0"; $result = mysqli_query($this->dblink,$q); self::$heroFieldCache[$uid.$field] = $this->mysqli_fetch_all($result); - return self::$heroFieldCache[$uid.$field]; + return self::$heroFieldCache[$uid.$field][$field]; } function modifyHero($column,$value,$heroid,$mode=0) { diff --git a/GameEngine/Units.php b/GameEngine/Units.php index 93481488..e6590d67 100755 --- a/GameEngine/Units.php +++ b/GameEngine/Units.php @@ -287,7 +287,7 @@ class Units { } } if( intval($enforce['hero']) > 0){ - $hero_unit = $database->getHeroField($from['owner'], 'unit')['unit']; + $hero_unit = $database->getHeroField($from['owner'], 'unit'); $speeds[] = $GLOBALS['u'.$hero_unit]['speed']; }else{ $enforce['hero']='0'; @@ -654,7 +654,7 @@ class Units { } if ( isset( $post['t11'] ) ) { if ( $post['t11'] != '' && $post['t11'] > 0 ) { - $hero_unit = $database->getHeroField($from['owner'], 'unit')['unit']; + $hero_unit = $database->getHeroField($from['owner'], 'unit'); $speeds[] = $GLOBALS[ 'u' . $hero_unit ]['speed']; } else { $post['t11'] = '0';