Stay/Spy mission bug

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Stay/Spy mission bug

      Hi mate ;)
      I have error with stay mission. If I send fleet to stay mission, and the fleet is in flight, and we send spy probes to planet on which we are going to stay - then you can see the fleet on the planet!
      Even though the fleet is in flightIs. This description understandable?

      my MissionCaseStay:

      pastebin.pl/view/ec840b90

      MissionCaseSpy:

      pastebin.pl/view/3df80920

      The post was edited 3 times, last by m4ti ().

    • EL error no se encuentra en esa misión si no en MissionCaseSpy.class.php
      Remplaza

      PHP Source Code: MissionCaseSpy.class.php

      1. <?php
      2. /**
      3. * 2Moons
      4. * by Jan-Otto Kröpke 2009-2016
      5. *
      6. * For the full copyright and license information, please view the LICENSE
      7. *
      8. * @package 2Moons
      9. * @author Jan-Otto Kröpke <slaver7@gmail.com>
      10. * @copyright 2009 Lucky
      11. * @copyright 2016 Jan-Otto Kröpke <slaver7@gmail.com>
      12. * @licence MIT
      13. * @version 1.8.0
      14. * @link https://github.com/jkroepke/2Moons
      15. */
      16. class MissionCaseSpy extends MissionFunctions implements Mission
      17. {
      18. function __construct($Fleet)
      19. {
      20. $this->_fleet = $Fleet;
      21. }
      22. function TargetEvent()
      23. {
      24. global $pricelist, $reslist, $resource;
      25. $db = Database::get();
      26. $sql = 'SELECT * FROM %%USERS%% WHERE id = :userId;';
      27. $senderUser = $db->selectSingle($sql, array(
      28. ':userId' => $this->_fleet['fleet_owner']
      29. ));
      30. $targetUser = $db->selectSingle($sql, array(
      31. ':userId' => $this->_fleet['fleet_target_owner']
      32. ));
      33. $sql = 'SELECT * FROM %%PLANETS%% WHERE id = :planetId;';
      34. $targetPlanet = $db->selectSingle($sql, array(
      35. ':planetId' => $this->_fleet['fleet_end_id']
      36. ));
      37. $sql = 'SELECT name FROM %%PLANETS%% WHERE id = :planetId;';
      38. $senderPlanetName = $db->selectSingle($sql, array(
      39. ':planetId' => $this->_fleet['fleet_start_id']
      40. ), 'name');
      41. $LNG = $this->getLanguage($senderUser['lang']);
      42. $senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']);
      43. $targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
      44. $planetUpdater = new ResourceUpdate();
      45. list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
      46. $sql = 'SELECT * FROM %%FLEETS%% WHERE fleet_end_id = :planetId
      47. AND fleet_mission = 5
      48. AND fleet_start_time <= :time
      49. AND fleet_end_stay >= :time;';
      50. $targetStayFleets = $db->select($sql, array(
      51. ':planetId' => $this->_fleet['fleet_end_id'],
      52. ':time' => TIMESTAMP,
      53. ));
      54. foreach($targetStayFleets as $fleetRow)
      55. {
      56. $fleetData = FleetFunctions::unserialize($fleetRow['fleet_array']);
      57. foreach($fleetData as $shipId => $shipAmount)
      58. {
      59. $targetPlanet[$resource[$shipId]] += $shipAmount;
      60. }
      61. }
      62. $fleetAmount = $this->_fleet['fleet_amount'] * (1 + $senderUser['factor']['SpyPower']);
      63. $senderSpyTech = max($senderUser['spy_tech'], 1);
      64. $targetSpyTech = max($targetUser['spy_tech'], 1);
      65. $techDifference = abs($senderSpyTech - $targetSpyTech);
      66. $MinAmount = ($senderSpyTech > $targetSpyTech ? -1 : 1) * pow($techDifference * SPY_DIFFENCE_FACTOR, 2);
      67. $SpyFleet = $fleetAmount >= $MinAmount;
      68. $SpyDef = $fleetAmount >= $MinAmount + 1 * SPY_VIEW_FACTOR;
      69. $SpyBuild = $fleetAmount >= $MinAmount + 3 * SPY_VIEW_FACTOR;
      70. $SpyTechno = $fleetAmount >= $MinAmount + 5 * SPY_VIEW_FACTOR;
      71. $SpyOffi = $fleetAmount >= $MinAmount + 12 * SPY_VIEW_FACTOR;
      72. $classIDs[900] = array_merge($reslist['resstype'][1], $reslist['resstype'][2]);
      73. if($SpyFleet)
      74. {
      75. $classIDs[200] = $reslist['fleet'];
      76. }
      77. if($SpyDef)
      78. {
      79. $classIDs[400] = array_merge($reslist['defense'], $reslist['missile']);
      80. }
      81. if($SpyBuild)
      82. {
      83. $classIDs[0] = $reslist['build'];
      84. }
      85. if($SpyTechno)
      86. {
      87. $classIDs[100] = $reslist['tech'];
      88. }
      89. if($SpyOffi)
      90. {
      91. $classIDs[600] = $reslist['officier'];
      92. }
      93. $targetChance = mt_rand(0, min(($fleetAmount/4) * ($targetSpyTech / $senderSpyTech), 100));
      94. $spyChance = mt_rand(0, 100);
      95. $spyData = array();
      96. foreach($classIDs as $classID => $elementIDs)
      97. {
      98. foreach($elementIDs as $elementID)
      99. {
      100. if(isset($targetUser[$resource[$elementID]]))
      101. {
      102. $spyData[$classID][$elementID] = $targetUser[$resource[$elementID]];
      103. }
      104. else
      105. {
      106. $spyData[$classID][$elementID] = $targetPlanet[$resource[$elementID]];
      107. }
      108. }
      109. if($senderUser['spyMessagesMode'] == 1)
      110. {
      111. $spyData[$classID] = array_filter($spyData[$classID]);
      112. }
      113. }
      114. // I'm use template class here, because i want to exclude HTML in PHP.
      115. require_once 'includes/classes/class.template.php';
      116. $template = new template;
      117. $template->caching = true;
      118. $template->compile_id = $senderUser['lang'];
      119. $template->loadFilter('output', 'trimwhitespace');
      120. list($tplDir) = $template->getTemplateDir();
      121. $template->setTemplateDir($tplDir.'game/');
      122. $template->assign_vars(array(
      123. 'spyData' => $spyData,
      124. 'targetPlanet' => $targetPlanet,
      125. 'targetChance' => $targetChance,
      126. 'spyChance' => $spyChance,
      127. 'isBattleSim' => ENABLE_SIMULATOR_LINK == true && isModuleAvailable(MODULE_SIMULATOR),
      128. //'title' => sprintf($LNG['sys_mess_head'], $targetPlanet['name'], $targetPlanet['galaxy'], $targetPlanet['system'], $targetPlanet['planet'], _date($LNG['php_tdformat'], $this->_fleet['fleet_end_time'], $targetUser['timezone'], $LNG)),
      129. 'title' => sprintf($LNG['sys_mess_head'], $targetPlanet['name'], $targetPlanet['galaxy'], $targetPlanet['system'], $targetPlanet['planet'], _date($LNG['php_tdformat'], $this->_fleet['fleet_end_time'], $senderUser['timezone'], $LNG)),
      130. ));
      131. $template->assign_vars(array(
      132. 'LNG' => $LNG
      133. ), false);
      134. $spyReport = $template->fetch('shared.mission.spyReport.tpl');
      135. PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_qg'], 0, $LNG['sys_mess_spy_report'],
      136. $spyReport, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
      137. $LNG = $this->getLanguage($targetUser['lang']);
      138. $targetMessage = $LNG['sys_mess_spy_ennemyfleet'] ." ". $senderPlanetName;
      139. if($this->_fleet['fleet_start_type'] == 3)
      140. {
      141. $targetMessage .= $LNG['sys_mess_spy_report_moon'].' ';
      142. }
      143. $text = '<a href="game.php?page=galaxy&galaxy=%1$s&system=%2$s">[%1$s:%2$s:%3$s]</a> %7$s
      144. %8$s <a href="game.php?page=galaxy&galaxy=%4$s&system=%5$s">[%4$s:%5$s:%6$s]</a> %9$s';
      145. $targetMessage .= sprintf($text,
      146. $this->_fleet['fleet_start_galaxy'],
      147. $this->_fleet['fleet_start_system'],
      148. $this->_fleet['fleet_start_planet'],
      149. $this->_fleet['fleet_end_galaxy'],
      150. $this->_fleet['fleet_end_system'],
      151. $this->_fleet['fleet_end_planet'],
      152. $LNG['sys_mess_spy_seen_at'],
      153. $targetPlanet['name'],
      154. $LNG['sys_mess_spy_seen_at2']
      155. );
      156. PlayerUtil::sendMessage($this->_fleet['fleet_target_owner'], 0, $LNG['sys_mess_spy_control'], 0,
      157. $LNG['sys_mess_spy_activity'], $targetMessage, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
      158. if ($targetChance >= $spyChance)
      159. {
      160. $config = Config::get($this->_fleet['fleet_universe']);
      161. $whereCol = $this->_fleet['fleet_end_type'] == 3 ? "id_luna" : "id";
      162. $sql = 'UPDATE %%PLANETS%% SET
      163. der_metal = der_metal + :metal,
      164. der_crystal = der_crystal + :crystal
      165. WHERE '.$whereCol.' = :planetId;';
      166. $db->update($sql, array(
      167. ':metal' => $fleetAmount * $pricelist[210]['cost'][901] * $config->Fleet_Cdr / 100,
      168. ':crystal' => $fleetAmount * $pricelist[210]['cost'][902] * $config->Fleet_Cdr / 100,
      169. ':planetId' => $this->_fleet['fleet_end_id']
      170. ));
      171. $this->KillFleet();
      172. }
      173. else
      174. {
      175. $this->setState(FLEET_RETURN);
      176. $this->SaveFleet();
      177. }
      178. }
      179. function EndStayEvent()
      180. {
      181. return;
      182. }
      183. function ReturnEvent()
      184. {
      185. $this->RestoreFleet();
      186. }
      187. }
      Display All
      VERY SAD :/ :/ :/ :/
    • yamilrh wrote:

      EL error no se encuentra en esa misión si no en MissionCaseSpy.class.php
      Remplaza

      PHP Source Code: MissionCaseSpy.class.php

      1. <?php
      2. /**
      3. * 2Moons
      4. * by Jan-Otto Kröpke 2009-2016
      5. *
      6. * For the full copyright and license information, please view the LICENSE
      7. *
      8. * @package 2Moons
      9. * @author Jan-Otto Kröpke <slaver7@gmail.com>
      10. * @copyright 2009 Lucky
      11. * @copyright 2016 Jan-Otto Kröpke <slaver7@gmail.com>
      12. * @licence MIT
      13. * @version 1.8.0
      14. * @link https://github.com/jkroepke/2Moons
      15. */
      16. class MissionCaseSpy extends MissionFunctions implements Mission
      17. {
      18. function __construct($Fleet)
      19. {
      20. $this->_fleet = $Fleet;
      21. }
      22. function TargetEvent()
      23. {
      24. global $pricelist, $reslist, $resource;
      25. $db = Database::get();
      26. $sql = 'SELECT * FROM %%USERS%% WHERE id = :userId;';
      27. $senderUser = $db->selectSingle($sql, array(
      28. ':userId' => $this->_fleet['fleet_owner']
      29. ));
      30. $targetUser = $db->selectSingle($sql, array(
      31. ':userId' => $this->_fleet['fleet_target_owner']
      32. ));
      33. $sql = 'SELECT * FROM %%PLANETS%% WHERE id = :planetId;';
      34. $targetPlanet = $db->selectSingle($sql, array(
      35. ':planetId' => $this->_fleet['fleet_end_id']
      36. ));
      37. $sql = 'SELECT name FROM %%PLANETS%% WHERE id = :planetId;';
      38. $senderPlanetName = $db->selectSingle($sql, array(
      39. ':planetId' => $this->_fleet['fleet_start_id']
      40. ), 'name');
      41. $LNG = $this->getLanguage($senderUser['lang']);
      42. $senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']);
      43. $targetUser['factor'] = getFactors($targetUser, 'basic', $this->_fleet['fleet_start_time']);
      44. $planetUpdater = new ResourceUpdate();
      45. list($targetUser, $targetPlanet) = $planetUpdater->CalcResource($targetUser, $targetPlanet, true, $this->_fleet['fleet_start_time']);
      46. $sql = 'SELECT * FROM %%FLEETS%% WHERE fleet_end_id = :planetId
      47. AND fleet_mission = 5
      48. AND fleet_start_time <= :time
      49. AND fleet_end_stay >= :time;';
      50. $targetStayFleets = $db->select($sql, array(
      51. ':planetId' => $this->_fleet['fleet_end_id'],
      52. ':time' => TIMESTAMP,
      53. ));
      54. foreach($targetStayFleets as $fleetRow)
      55. {
      56. $fleetData = FleetFunctions::unserialize($fleetRow['fleet_array']);
      57. foreach($fleetData as $shipId => $shipAmount)
      58. {
      59. $targetPlanet[$resource[$shipId]] += $shipAmount;
      60. }
      61. }
      62. $fleetAmount = $this->_fleet['fleet_amount'] * (1 + $senderUser['factor']['SpyPower']);
      63. $senderSpyTech = max($senderUser['spy_tech'], 1);
      64. $targetSpyTech = max($targetUser['spy_tech'], 1);
      65. $techDifference = abs($senderSpyTech - $targetSpyTech);
      66. $MinAmount = ($senderSpyTech > $targetSpyTech ? -1 : 1) * pow($techDifference * SPY_DIFFENCE_FACTOR, 2);
      67. $SpyFleet = $fleetAmount >= $MinAmount;
      68. $SpyDef = $fleetAmount >= $MinAmount + 1 * SPY_VIEW_FACTOR;
      69. $SpyBuild = $fleetAmount >= $MinAmount + 3 * SPY_VIEW_FACTOR;
      70. $SpyTechno = $fleetAmount >= $MinAmount + 5 * SPY_VIEW_FACTOR;
      71. $SpyOffi = $fleetAmount >= $MinAmount + 12 * SPY_VIEW_FACTOR;
      72. $classIDs[900] = array_merge($reslist['resstype'][1], $reslist['resstype'][2]);
      73. if($SpyFleet)
      74. {
      75. $classIDs[200] = $reslist['fleet'];
      76. }
      77. if($SpyDef)
      78. {
      79. $classIDs[400] = array_merge($reslist['defense'], $reslist['missile']);
      80. }
      81. if($SpyBuild)
      82. {
      83. $classIDs[0] = $reslist['build'];
      84. }
      85. if($SpyTechno)
      86. {
      87. $classIDs[100] = $reslist['tech'];
      88. }
      89. if($SpyOffi)
      90. {
      91. $classIDs[600] = $reslist['officier'];
      92. }
      93. $targetChance = mt_rand(0, min(($fleetAmount/4) * ($targetSpyTech / $senderSpyTech), 100));
      94. $spyChance = mt_rand(0, 100);
      95. $spyData = array();
      96. foreach($classIDs as $classID => $elementIDs)
      97. {
      98. foreach($elementIDs as $elementID)
      99. {
      100. if(isset($targetUser[$resource[$elementID]]))
      101. {
      102. $spyData[$classID][$elementID] = $targetUser[$resource[$elementID]];
      103. }
      104. else
      105. {
      106. $spyData[$classID][$elementID] = $targetPlanet[$resource[$elementID]];
      107. }
      108. }
      109. if($senderUser['spyMessagesMode'] == 1)
      110. {
      111. $spyData[$classID] = array_filter($spyData[$classID]);
      112. }
      113. }
      114. // I'm use template class here, because i want to exclude HTML in PHP.
      115. require_once 'includes/classes/class.template.php';
      116. $template = new template;
      117. $template->caching = true;
      118. $template->compile_id = $senderUser['lang'];
      119. $template->loadFilter('output', 'trimwhitespace');
      120. list($tplDir) = $template->getTemplateDir();
      121. $template->setTemplateDir($tplDir.'game/');
      122. $template->assign_vars(array(
      123. 'spyData' => $spyData,
      124. 'targetPlanet' => $targetPlanet,
      125. 'targetChance' => $targetChance,
      126. 'spyChance' => $spyChance,
      127. 'isBattleSim' => ENABLE_SIMULATOR_LINK == true && isModuleAvailable(MODULE_SIMULATOR),
      128. //'title' => sprintf($LNG['sys_mess_head'], $targetPlanet['name'], $targetPlanet['galaxy'], $targetPlanet['system'], $targetPlanet['planet'], _date($LNG['php_tdformat'], $this->_fleet['fleet_end_time'], $targetUser['timezone'], $LNG)),
      129. 'title' => sprintf($LNG['sys_mess_head'], $targetPlanet['name'], $targetPlanet['galaxy'], $targetPlanet['system'], $targetPlanet['planet'], _date($LNG['php_tdformat'], $this->_fleet['fleet_end_time'], $senderUser['timezone'], $LNG)),
      130. ));
      131. $template->assign_vars(array(
      132. 'LNG' => $LNG
      133. ), false);
      134. $spyReport = $template->fetch('shared.mission.spyReport.tpl');
      135. PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_mess_qg'], 0, $LNG['sys_mess_spy_report'],
      136. $spyReport, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
      137. $LNG = $this->getLanguage($targetUser['lang']);
      138. $targetMessage = $LNG['sys_mess_spy_ennemyfleet'] ." ". $senderPlanetName;
      139. if($this->_fleet['fleet_start_type'] == 3)
      140. {
      141. $targetMessage .= $LNG['sys_mess_spy_report_moon'].' ';
      142. }
      143. $text = '<a href="game.php?page=galaxy&galaxy=%1$s&system=%2$s">[%1$s:%2$s:%3$s]</a> %7$s
      144. %8$s <a href="game.php?page=galaxy&galaxy=%4$s&system=%5$s">[%4$s:%5$s:%6$s]</a> %9$s';
      145. $targetMessage .= sprintf($text,
      146. $this->_fleet['fleet_start_galaxy'],
      147. $this->_fleet['fleet_start_system'],
      148. $this->_fleet['fleet_start_planet'],
      149. $this->_fleet['fleet_end_galaxy'],
      150. $this->_fleet['fleet_end_system'],
      151. $this->_fleet['fleet_end_planet'],
      152. $LNG['sys_mess_spy_seen_at'],
      153. $targetPlanet['name'],
      154. $LNG['sys_mess_spy_seen_at2']
      155. );
      156. PlayerUtil::sendMessage($this->_fleet['fleet_target_owner'], 0, $LNG['sys_mess_spy_control'], 0,
      157. $LNG['sys_mess_spy_activity'], $targetMessage, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
      158. if ($targetChance >= $spyChance)
      159. {
      160. $config = Config::get($this->_fleet['fleet_universe']);
      161. $whereCol = $this->_fleet['fleet_end_type'] == 3 ? "id_luna" : "id";
      162. $sql = 'UPDATE %%PLANETS%% SET
      163. der_metal = der_metal + :metal,
      164. der_crystal = der_crystal + :crystal
      165. WHERE '.$whereCol.' = :planetId;';
      166. $db->update($sql, array(
      167. ':metal' => $fleetAmount * $pricelist[210]['cost'][901] * $config->Fleet_Cdr / 100,
      168. ':crystal' => $fleetAmount * $pricelist[210]['cost'][902] * $config->Fleet_Cdr / 100,
      169. ':planetId' => $this->_fleet['fleet_end_id']
      170. ));
      171. $this->KillFleet();
      172. }
      173. else
      174. {
      175. $this->setState(FLEET_RETURN);
      176. $this->SaveFleet();
      177. }
      178. }
      179. function EndStayEvent()
      180. {
      181. return;
      182. }
      183. function ReturnEvent()
      184. {
      185. $this->RestoreFleet();
      186. }
      187. }
      Display All
      I add your code and have error:


      Source Code

      1. Warning: Uncaught ErrorException: require_once(includes/classes/class.template.php): failed to open stream: No such file or directory in /home/xxxx/www/uni3/includes/classes/missions/MissionCaseSpy.class.php:145 Stack trace: #0 /home/xxx/www/uni3/includes/classes/missions/MissionCaseSpy.class.php(145): errorHandler(2, 'require_once(in...', '/home/xxx/www...', 145, Array) #1 /home/xxx/www/uni3/includes/classes/missions/MissionCaseSpy.class.php(145): require_once() #2 /home/xxx/www/uni3/includes/classes/FlyingFleetHandler.class.php(80): MissionCaseSpy->TargetEvent() #3 /home/xxx/www/uni3/includes/FleetHandler.php(29): FlyingFleetHandler->run() #4 /home/xxx/www/uni3/includes/common.php(112): require('/home/xxx/www...') #5 /home/xxx/www/uni3/game.php(24): require('/home/xxx/www...') #6 {main} thrown in /home/xxx/www/uni3/includes/classes/missions/MissionCaseSpy.class.php on line 145Fatal error: MissionCaseSpy::TargetEvent(): Failed opening required 'includes/classes/class.template.php' (include_path='/home/xxx/www/uni3/') in /home/xxx/www/uni3/includes/classes/missions/MissionCaseSpy.class.php on line 145