Completed
Push — work-fleets ( 3f92e6...b16c77 )
by SuperNova.WS
07:09
created
classes/Fleet.php 1 patch
Doc Comments   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
   /**
1000 1000
    * Set current resource list from array of units
1001 1001
    *
1002
-   * @param array $resource_list
1002
+   * @param integer[] $resource_list
1003 1003
    */
1004 1004
   public function resourcesSet($resource_list) {
1005 1005
     if (!empty($this->propertiesAdjusted['resource_list'])) {
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
   }
1048 1048
 
1049 1049
   /**
1050
-   * @param array $rate
1050
+   * @param integer[] $rate
1051 1051
    *
1052 1052
    * @return float
1053 1053
    */
@@ -1078,8 +1078,6 @@  discard block
 block discarded – undo
1078 1078
    * Restores fleet or resources to planet
1079 1079
    *
1080 1080
    * @param bool $start
1081
-   * @param bool $only_resources
1082
-   * @param int  $result
1083 1081
    */
1084 1082
   public function resourcesUnload($start = true) {
1085 1083
     sn_db_transaction_check(true);
@@ -1243,6 +1241,9 @@  discard block
 block discarded – undo
1243 1241
   }
1244 1242
 
1245 1243
 
1244
+  /**
1245
+   * @param integer $missionStartTimeStamp
1246
+   */
1246 1247
   protected function renderFleetCoordinates($missionStartTimeStamp = SN_TIME_NOW, $timeMissionJob = 0) {
1247 1248
     $timeToReturn = $this->travelData['duration'] * 2 + $timeMissionJob;
1248 1249
 
Please login to merge, or discard this patch.
includes/includes/flt_flying_fleet_handler2.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,6 @@
 block discarded – undo
14 14
  *
15 15
  * @param Fleet $objFleet
16 16
  * @param bool  $start
17
- * @param null  $result
18 17
  *
19 18
  * @return mixed
20 19
  */
Please login to merge, or discard this patch.
Spacing   +8 added lines, -12 removed lines patch added patch discarded remove patch
@@ -23,15 +23,11 @@  discard block
 block discarded – undo
23 23
 // ------------------------------------------------------------------
24 24
 function flt_flyingFleetsSort($a, $b) {
25 25
   // Сравниваем время флотов - кто раньше, тот и первый обрабатывается
26
-  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 :
27
-    // Если время - одинаковое, сравниваем события флотов
26
+  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов
28 27
     // Если события - одинаковые, то флоты равны
29
-    ($a['fleet_event'] == $b['fleet_event'] ? 0 :
30
-      // Если события разные - первыми считаем прибывающие флоты
31
-      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 :
32
-        // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
33
-        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 :
34
-          // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
28
+    ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты
29
+      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
30
+        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
35 31
           // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска
36 32
           (
37 33
           0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий
@@ -49,13 +45,13 @@  discard block
 block discarded – undo
49 45
     $handler = fopen('event.log', 'a+');
50 46
   }
51 47
 
52
-  fwrite($handler, date(FMT_DATE_TIME_SQL, time()) . ' ' . $msg . "\r\n");
48
+  fwrite($handler, date(FMT_DATE_TIME_SQL, time()).' '.$msg."\r\n");
53 49
 }
54 50
 
55 51
 // ------------------------------------------------------------------
56 52
 function flt_flying_fleet_handler($skip_fleet_update = false) {
57 53
   if (true) {
58
-    if(!defined('IN_AJAX')) {
54
+    if (!defined('IN_AJAX')) {
59 55
       print('<div style="color: red; font-size: 300%">Fleet handler is disabled</div>');
60 56
       pdump('Fleet handler is disabled');
61 57
     }
@@ -181,7 +177,7 @@  discard block
 block discarded – undo
181 177
     MT_EXPLORE   => 'flt_mission_explore',
182 178
   );
183 179
   foreach ($missions_used as $mission_id => $cork) {
184
-    require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX);
180
+    require_once(SN_ROOT_PHYSICAL."includes/includes/{$mission_files[$mission_id]}".DOT_PHP_EX);
185 181
   }
186 182
 
187 183
 //log_file('Обработка миссий');
@@ -248,7 +244,7 @@  discard block
 block discarded – undo
248 244
     $objMission->fleet_event = $fleet_event['fleet_event'];
249 245
 
250 246
     // Fleet that have planet destination is returned
251
-    if($mission_data['dst_planet'] && empty($objMission->dst_planet['id_owner'])) {
247
+    if ($mission_data['dst_planet'] && empty($objMission->dst_planet['id_owner'])) {
252 248
       $objFleet->markReturnedAndSave();
253 249
       sn_db_transaction_commit();
254 250
       continue;
Please login to merge, or discard this patch.
includes/includes/flt_mission_attack.php 1 patch
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 
10 10
 /**
11 11
  * @param Mission $objMission
12
- * @param array   $mission_data
13 12
  */
14 13
 function flt_mission_attack($objMission) {
15 14
   $objFleet = $objMission->fleet;
Please login to merge, or discard this patch.
includes/includes/flt_mission_spy.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
  */
16 16
 // ----------------------------------------------------------------------------------------------------------------
17 17
 function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array()) {
18
-  foreach($unit_group as $unit_id) {
19
-    if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
18
+  foreach ($unit_group as $unit_id) {
19
+    if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
20 20
       $compress_data[$unit_id] = $unit_count;
21 21
     }
22 22
   }
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
   $classLocale = classLocale::$lang;
27 27
 
28 28
   $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>";
29
-  foreach(sn_get_groups($group_name) as $unit_id) {
30
-    if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
29
+  foreach (sn_get_groups($group_name) as $unit_id) {
30
+    if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0) {
31 31
       $result .= "<tr><td align=\"left\" colspan=\"3\">{$classLocale['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>";
32 32
     }
33 33
 
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 
57 57
   $objFleet = $mission_data->fleet;
58 58
 
59
-  if(empty($target_user_row['id']) || empty($spying_user_row['id'])) {
59
+  if (empty($target_user_row['id']) || empty($spying_user_row['id'])) {
60 60
     $objFleet->markReturnedAndSave();
61 61
 
62 62
     return;
63 63
   }
64 64
 
65 65
   $spy_probes = $objFleet->shipsGetTotalById(SHIP_SPY);
66
-  if($spy_probes > 0) {
66
+  if ($spy_probes > 0) {
67 67
     $TargetSpyLvl = GetSpyLevel($target_user_row);
68 68
     $CurrentSpyLvl = GetSpyLevel($spying_user_row);
69 69
     $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl;
@@ -81,26 +81,26 @@  discard block
 block discarded – undo
81 81
     $spy_message .= " ({$classLocale['Player_']} '{$target_user_row['username']}') {$classLocale['On_']} ";
82 82
     $spy_message .= date(FMT_DATE_TIME, $objFleet->time_arrive_to_target);
83 83
     $spy_message .= "</td></tr><tr>";
84
-    $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>" . pretty_number($target_planet_row['metal']) . "</td>";
85
-    $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>" . pretty_number($target_planet_row['crystal']) . "</td>";
84
+    $spy_message .= "<td width=220>{$classLocale['sys_metal']}</td><td width=220 align=right>".pretty_number($target_planet_row['metal'])."</td>";
85
+    $spy_message .= "<td width=220>{$classLocale['sys_crystal']}</td></td><td width=220 align=right>".pretty_number($target_planet_row['crystal'])."</td>";
86 86
     $spy_message .= "</tr><tr>";
87
-    $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>";
88
-    $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>";
87
+    $spy_message .= "<td width=220>{$classLocale['sys_deuterium']}</td><td width=220 align=right>".pretty_number($target_planet_row['deuterium'])."</td>";
88
+    $spy_message .= "<td width=220>{$classLocale['sys_energy']}</td><td width=220 align=right>".pretty_number($target_planet_row['energy_max'])."</td>";
89 89
     $spy_message .= "</tr>";
90
-    if($spy_diff >= 2) {
91
-      $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row) . "</div>";
90
+    if ($spy_diff >= 2) {
91
+      $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'fleet', classLocale::$lang['tech'][UNIT_SHIPS], $target_user_row)."</div>";
92 92
       coe_compress_add_units(Fleet::$snGroupFleet, $target_planet_row, $combat_pack[0]);
93 93
     }
94
-    if($spy_diff >= 3) {
95
-      $spy_message .= "<div class='spy_medium'>" . flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row) . "</div>";
94
+    if ($spy_diff >= 3) {
95
+      $spy_message .= "<div class='spy_medium'>".flt_spy_scan($target_planet_row, 'defense', classLocale::$lang['tech'][UNIT_DEFENCE], $target_user_row)."</div>";
96 96
       coe_compress_add_units(sn_get_groups('defense_active'), $target_planet_row, $combat_pack[0]);
97 97
     }
98
-    if($spy_diff >= 5) {
99
-      $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>";
98
+    if ($spy_diff >= 5) {
99
+      $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'structures', classLocale::$lang['tech'][UNIT_STRUCTURES], $target_user_row)."</div>";
100 100
     }
101 101
 
102
-    if($spy_diff_empire >= 0) {
103
-      $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>";
102
+    if ($spy_diff_empire >= 0) {
103
+      $spy_message .= "<div class='spy_long'>".flt_spy_scan($target_planet_row, 'tech', classLocale::$lang['tech'][UNIT_TECHNOLOGIES], $target_user_row)."</div>";
104 104
       coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row);
105 105
     }
106 106
     // TODO: Наемники, губернаторы, артефакты и прочее имперское
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
     $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D');
109 109
 
110 110
     $target_unit_list = 0;
111
-    foreach(Fleet::$snGroupFleet as $unit_id) {
111
+    foreach (Fleet::$snGroupFleet as $unit_id) {
112 112
       $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true));
113 113
     }
114 114
 
115 115
     $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl);
116 116
 
117
-    if(mt_rand(0, 99) > $spy_detected) {
117
+    if (mt_rand(0, 99) > $spy_detected) {
118 118
       $spy_outcome_str = sprintf(classLocale::$lang['sys_mess_spy_detect_chance'], $spy_detected);
119 119
       $spy_detected = false;
120 120
     } else {
@@ -131,10 +131,10 @@  discard block
 block discarded – undo
131 131
 
132 132
     DBStaticMessages::msg_send_simple_message($spying_user_row['id'], '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_qg'], classLocale::$lang['sys_mess_spy_report'], $spy_message);
133 133
 
134
-    $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} " . uni_render_coordinates_href($spying_planet_row, '', 3);
135
-    $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} " . uni_render_coordinates($target_planet_row);
134
+    $target_message = "{$classLocale['sys_mess_spy_ennemyfleet']} {$spying_planet_row['name']} ".uni_render_coordinates_href($spying_planet_row, '', 3);
135
+    $target_message .= " {$classLocale['sys_mess_spy_seen_at']} {$target_planet_row['name']} ".uni_render_coordinates($target_planet_row);
136 136
 
137
-    if($spy_detected) {
137
+    if ($spy_detected) {
138 138
       $debris_planet_id = $target_planet_row['planet_type'] == PT_PLANET ? $target_planet_row['id'] : $target_planet_row['parent_planet'];
139 139
 
140 140
       $spy_cost = get_unit_param(SHIP_SPY, P_COST);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     DBStaticMessages::msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, classLocale::$lang['sys_mess_spy_control'], classLocale::$lang['sys_mess_spy_activity'], $target_message);
157 157
   }
158 158
 
159
-  if($spy_detected) {
159
+  if ($spy_detected) {
160 160
     $objFleet->dbDelete();
161 161
   } else {
162 162
     $objFleet->markReturnedAndSave();
Please login to merge, or discard this patch.
includes/includes/flt_mission_recycle.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
   $RecyclerCapacity = 0;
17 17
   $OtherFleetCapacity = 0;
18 18
 
19
-  foreach($objFleet->shipsIterator() as $unit_id => $unit) {
20
-    if(in_array($unit_id, Fleet::$snGroupFleet)) {
19
+  foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
20
+    if (in_array($unit_id, Fleet::$snGroupFleet)) {
21 21
       $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit->count;
22
-      if(in_array($unit_id, Fleet::$snGroupRecyclers)) {
22
+      if (in_array($unit_id, Fleet::$snGroupRecyclers)) {
23 23
         $RecyclerCapacity += $capacity;
24 24
       } else {
25 25
         $OtherFleetCapacity += $capacity;
@@ -28,33 +28,33 @@  discard block
 block discarded – undo
28 28
   }
29 29
 
30 30
   $fleet_resources_amount = $objFleet->resourcesGetTotal();
31
-  if($fleet_resources_amount > $OtherFleetCapacity) {
31
+  if ($fleet_resources_amount > $OtherFleetCapacity) {
32 32
     // Если во флоте есть другие корабли И количество ресурсов больше, чем их ёмкость трюмов - значит часть этих ресурсов лежит в трюмах переработчиков
33 33
     // Уменьшаем ёмкость переработчиков на указанную величину
34 34
     $RecyclerCapacity -= ($fleet_resources_amount - $OtherFleetCapacity);
35 35
   }
36 36
 
37 37
   $resources_recycled = array();
38
-  if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
38
+  if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
39 39
     $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
40 40
     $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
41 41
   } else {
42
-    if(($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
42
+    if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
43 43
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2)
44 44
     ) {
45 45
       $resources_recycled[RES_METAL] = $RecyclerCapacity / 2;
46 46
       $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity / 2;
47 47
     } else {
48
-      if($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
48
+      if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
49 49
         $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
50
-        if($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
50
+        if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
51 51
           $resources_recycled[RES_METAL] = $RecyclerCapacity - $resources_recycled[RES_CRYSTAL];
52 52
         } else {
53 53
           $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
54 54
         }
55 55
       } else {
56 56
         $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
57
-        if($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
57
+        if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
58 58
           $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity - $resources_recycled[RES_METAL];
59 59
         } else {
60 60
           $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
Please login to merge, or discard this patch.
includes/includes/flt_mission_relocate.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 function flt_mission_relocate($mission_data) {
13 13
   $objFleet = $mission_data->fleet;
14 14
   $destination_planet = &$mission_data->dst_planet;
15
-  if($objFleet->playerOwnerId != $destination_planet['id_owner']) {
15
+  if ($objFleet->playerOwnerId != $destination_planet['id_owner']) {
16 16
     $objFleet->markReturnedAndSave();
17 17
 
18 18
     return;
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
       $fleet_resources[RES_METAL], classLocale::$lang['Metal'],
26 26
       $fleet_resources[RES_CRYSTAL], classLocale::$lang['Crystal'],
27 27
       $fleet_resources[RES_DEUTERIUM], classLocale::$lang['Deuterium']
28
-    ) . '<br />' . classLocale::$lang['sys_relocate_mess_user'];
29
-  foreach($objFleet->shipsIterator() as $ship_id => $ship) {
30
-    $Message .= classLocale::$lang['tech'][$ship_id] . ' - ' . $ship->count . '<br />';
28
+    ).'<br />'.classLocale::$lang['sys_relocate_mess_user'];
29
+  foreach ($objFleet->shipsIterator() as $ship_id => $ship) {
30
+    $Message .= classLocale::$lang['tech'][$ship_id].' - '.$ship->count.'<br />';
31 31
   }
32 32
   DBStaticMessages::msg_send_simple_message(
33 33
     $objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, classLocale::$lang['sys_mess_qg'], classLocale::$lang['sys_stay_mess_stay'], $Message
Please login to merge, or discard this patch.