Phalanx bug

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

    • Phalanx bug

      Hi,
      I think I found new bug on 2moons. I search 2moons github, and I have the same code. That mean the but is in engine.
      Check on your own game.


      When we send recyclers directly from galaxy page would collect wrackage, and use phalanx on planet where is the wrackage. Then we see recyclers on the phalanx. And we shouldn't
      Because we're using phalanx on a scrap planet


      Someone tip for fix it?

      PHP Source Code: FlyingFleetTable

      1. <?php
      2. class FlyingFleetsTable
      3. {
      4. protected $Mode = null;
      5. protected $userId = null;
      6. protected $planetId = null;
      7. protected $IsPhalanx = false;
      8. protected $missions = false;
      9. public function __construct() {
      10. }
      11. public function setUser($userId) {
      12. $this->userId = $userId;
      13. }
      14. public function setPlanet($planetId) {
      15. $this->planetId = $planetId;
      16. }
      17. public function setPhalanxMode() {
      18. $this->IsPhalanx = true;
      19. }
      20. public function setMissions($missions) {
      21. $this->missions = implode(',', array_filter(explode(',', $missions), 'is_numeric'));
      22. }
      23. private function getFleets($acsID = false) {
      24. if($this->IsPhalanx) {
      25. $where = '(fleet_start_id = :planetId AND fleet_start_type = 1 AND fleet_mission != 4) OR
      26. (fleet_end_id = :planetId AND fleet_end_type = 1 AND fleet_mess IN (0, 2))';
      27. $param = array(
      28. ':planetId' => $this->planetId
      29. );
      30. } elseif(!empty($acsID)) {
      31. $where = 'fleet_group = :acsId';
      32. $param = array(
      33. ':acsId' => $acsID
      34. );
      35. } elseif($this->missions) {
      36. $where = '(fleet_owner = :userId OR fleet_target_owner = :userId) AND fleet_mission IN ('.$this->missions.')';
      37. $param = array(
      38. ':userId' => $this->userId
      39. );
      40. } else {
      41. $where = 'fleet_owner = :userId OR (fleet_target_owner = :userId AND fleet_mission != 8)';
      42. $param = array(
      43. ':userId' => $this->userId,
      44. );
      45. }
      46. $sql = 'SELECT DISTINCT fleet.*, ownuser.username as own_username, targetuser.username as target_username,
      47. ownplanet.name as own_planetname, targetplanet.name as target_planetname
      48. FROM %%FLEETS%% fleet
      49. LEFT JOIN %%USERS%% ownuser ON (ownuser.id = fleet.fleet_owner)
      50. LEFT JOIN %%USERS%% targetuser ON (targetuser.id = fleet.fleet_target_owner)
      51. LEFT JOIN %%PLANETS%% ownplanet ON (ownplanet.id = fleet.fleet_start_id)
      52. LEFT JOIN %%PLANETS%% targetplanet ON (targetplanet.id = fleet.fleet_end_id)
      53. WHERE '.$where.';';
      54. return Database::get()->select($sql, $param);
      55. }
      56. public function renderTable()
      57. {
      58. $fleetResult = $this->getFleets();
      59. $ACSDone = array();
      60. $FleetData = array();
      61. foreach($fleetResult as $fleetRow)
      62. {
      63. if ($fleetRow['fleet_mess'] == 0 && $fleetRow['fleet_start_time'] > TIMESTAMP && ($fleetRow['fleet_group'] == 0 || !isset($ACSDone[$fleetRow['fleet_group']])))
      64. {
      65. $ACSDone[$fleetRow['fleet_group']] = true;
      66. $FleetData[$fleetRow['fleet_start_time'].$fleetRow['fleet_id']] = $this->BuildFleetEventTable($fleetRow, 0);
      67. }
      68. if ($fleetRow['fleet_mission'] == 10 || ($fleetRow['fleet_mission'] == 4 && $fleetRow['fleet_mess'] == 0))
      69. continue;
      70. if ($fleetRow['fleet_end_stay'] != $fleetRow['fleet_start_time'] && $fleetRow['fleet_end_stay'] > TIMESTAMP && ($this->IsPhalanx && $fleetRow['fleet_end_id'] == $this->planetId))
      71. $FleetData[$fleetRow['fleet_end_stay'].$fleetRow['fleet_id']] = $this->BuildFleetEventTable($fleetRow, 2);
      72. $MissionsOK = 5;
      73. if ($fleetRow['fleet_end_stay'] > TIMESTAMP && $fleetRow['fleet_mission'] == $MissionsOK )
      74. $FleetData[$fleetRow['fleet_end_stay'].$fleetRow['fleet_id']] = $this->BuildFleetEventTable($fleetRow, 2);
      75. if ($fleetRow['fleet_owner'] != $this->userId)
      76. continue;
      77. if ($fleetRow['fleet_end_time'] > TIMESTAMP)
      78. $FleetData[$fleetRow['fleet_end_time'].$fleetRow['fleet_id']] = $this->BuildFleetEventTable($fleetRow, 1);
      79. }
      80. ksort($FleetData);
      81. return $FleetData;
      82. }
      83. private function BuildFleetEventTable($fleetRow, $FleetState)
      84. {
      85. $Time = 0;
      86. $Rest = 0;
      87. if ($FleetState == 0 && !$this->IsPhalanx && $fleetRow['fleet_group'] != 0)
      88. {
      89. $acsResult = $this->getFleets($fleetRow['fleet_group']);
      90. $EventString = '';
      91. foreach($acsResult as $acsRow)
      92. {
      93. $Return = $this->getEventData($acsRow, $FleetState);
      94. $Rest = $Return[0];
      95. $EventString .= $Return[1].'<br><br>';
      96. $Time = $Return[2];
      97. }
      98. $EventString = substr($EventString, 0, -8);
      99. }
      100. else
      101. {
      102. list($Rest, $EventString, $Time) = $this->getEventData($fleetRow, $FleetState);
      103. }
      104. return array(
      105. 'text' => $EventString,
      106. 'returntime' => $Time,
      107. 'resttime' => $Rest
      108. );
      109. }
      110. public function getEventData($fleetRow, $Status)
      111. {
      112. global $LNG;
      113. $Owner = $fleetRow['fleet_owner'] == $this->userId;
      114. $FleetStyle = array (
      115. 1 => 'attack',
      116. 2 => 'federation',
      117. 3 => 'transport',
      118. 4 => 'deploy',
      119. 5 => 'hold',
      120. 6 => 'espionage',
      121. 7 => 'colony',
      122. 8 => 'harvest',
      123. 9 => 'destroy',
      124. 10 => 'missile',
      125. 11 => 'transport',
      126. 15 => 'transport',
      127. );
      128. $GoodMissions = array(3, 5);
      129. $MissionType = $fleetRow['fleet_mission'];
      130. $FleetPrefix = ($Owner == true) ? 'own' : '';
      131. $FleetType = $FleetPrefix.$FleetStyle[$MissionType];
      132. $FleetName = (!$Owner && ($MissionType == 1 || $MissionType == 2) && $Status == FLEET_OUTWARD && $fleetRow['fleet_target_owner'] != $this->userId) ? $LNG['cff_acs_fleet'] : $LNG['ov_fleet'];
      133. $FleetContent = $this->CreateFleetPopupedFleetLink($fleetRow, $FleetName, $FleetPrefix.$FleetStyle[$MissionType]);
      134. $FleetCapacity = $this->CreateFleetPopupedMissionLink($fleetRow, $LNG['type_mission_'.$MissionType], $FleetPrefix.$FleetStyle[$MissionType]);
      135. $FleetStatus = array(0 => 'flight', 1 => 'return' , 2 => 'holding');
      136. $StartType = $LNG['type_planet_'.$fleetRow['fleet_start_type']];
      137. $TargetType = $LNG['type_planet_'.$fleetRow['fleet_end_type']];
      138. if ($MissionType == 8) {
      139. if ($Status == FLEET_OUTWARD)
      140. $EventString = sprintf($LNG['cff_mission_own_recy_0'], $FleetContent, $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), GetTargetAddressLink($fleetRow, $FleetType), $FleetCapacity);
      141. else
      142. $EventString = sprintf($LNG['cff_mission_own_recy_1'], $FleetContent, GetTargetAddressLink($fleetRow, $FleetType), $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $FleetCapacity);
      143. } elseif ($MissionType == 10) {
      144. if ($Owner)
      145. $EventString = sprintf($LNG['cff_mission_own_mip'], $fleetRow['fleet_amount'], $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $TargetType, $fleetRow['target_planetname'], GetTargetAddressLink($fleetRow, $FleetType));
      146. else
      147. $EventString = sprintf($LNG['cff_mission_target_mip'], $fleetRow['fleet_amount'], $this->BuildHostileFleetPlayerLink($fleetRow), $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $TargetType, $fleetRow['target_planetname'], GetTargetAddressLink($fleetRow, $FleetType));
      148. } elseif ($MissionType == 11 || $MissionType == 15) {
      149. if ($Status == FLEET_OUTWARD)
      150. $EventString = sprintf($LNG['cff_mission_own_expo_0'], $FleetContent, $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), GetTargetAddressLink($fleetRow, $FleetType), $FleetCapacity);
      151. elseif ($Status == FLEET_HOLD)
      152. $EventString = sprintf($LNG['cff_mission_own_expo_2'], $FleetContent, $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), GetTargetAddressLink($fleetRow, $FleetType), $FleetCapacity);
      153. else
      154. $EventString = sprintf($LNG['cff_mission_own_expo_1'], $FleetContent, GetTargetAddressLink($fleetRow, $FleetType), $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $FleetCapacity);
      155. } else {
      156. if ($Owner == true) {
      157. if ($Status == FLEET_OUTWARD) {
      158. if (!$Owner && ($MissionType == 1 || $MissionType == 2))
      159. $Message = $LNG['cff_mission_acs'] ;
      160. else
      161. $Message = $LNG['cff_mission_own_0'];
      162. $EventString = sprintf($Message, $FleetContent, $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $TargetType, $fleetRow['target_planetname'], GetTargetAddressLink($fleetRow, $FleetType), $FleetCapacity);
      163. } elseif($Status == FLEET_RETURN)
      164. $EventString = sprintf($LNG['cff_mission_own_1'], $FleetContent, $TargetType, $fleetRow['target_planetname'], GetTargetAddressLink($fleetRow, $FleetType), $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $FleetCapacity);
      165. else
      166. $EventString = sprintf($LNG['cff_mission_own_2'], $FleetContent, $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $TargetType, $fleetRow['target_planetname'], GetTargetAddressLink($fleetRow, $FleetType), $FleetCapacity);
      167. } else {
      168. if ($Status == FLEET_HOLD)
      169. $Message = $LNG['cff_mission_target_stay'];
      170. elseif(in_array($MissionType, $GoodMissions))
      171. $Message = $LNG['cff_mission_target_good'];
      172. else
      173. $Message = $LNG['cff_mission_target_bad'];
      174. $EventString = sprintf($Message, $FleetContent, $this->BuildHostileFleetPlayerLink($fleetRow), $StartType, $fleetRow['own_planetname'], GetStartAddressLink($fleetRow, $FleetType), $TargetType, $fleetRow['target_planetname'], GetTargetAddressLink($fleetRow, $FleetType), $FleetCapacity);
      175. }
      176. }
      177. $EventString = '<span class="'.$FleetStatus[$Status].' '.$FleetType.'">'.$EventString.'</span>';
      178. if ($Status == FLEET_OUTWARD)
      179. $Time = $fleetRow['fleet_start_time'];
      180. elseif ($Status == FLEET_RETURN)
      181. $Time = $fleetRow['fleet_end_time'];
      182. elseif ($Status == FLEET_HOLD)
      183. $Time = $fleetRow['fleet_end_stay'];
      184. else
      185. $Time = TIMESTAMP;
      186. $Rest = $Time - TIMESTAMP;
      187. return array($Rest, $EventString, $Time);
      188. }
      189. ...
      190. ...
      Display All
    • New

      La cosa esta aca
      1. $where = '(fleet_start_id = :planetId AND fleet_start_type = 1 AND fleet_mission != 4) OR
      2. (fleet_end_id = :planetId AND fleet_end_type = 1 AND fleet_mess IN (0, 2))';