Test Failed
Branch trunk (c9c94d)
by SuperNova.WS
10:03 queued 05:45
created
includes/includes/flt_mission_hold.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 function flt_mission_hold(&$mission_data)
4 4
 {
5
-  if($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW)
5
+  if ($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW)
6 6
   {
7 7
     fleet_send_back($mission_data['fleet']);
8 8
     // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;");
Please login to merge, or discard this patch.
includes/includes/flt_page5.inc 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 *
13 13
 **/
14 14
 
15
-if(SN_IN_FLEET !== true) {
15
+if (SN_IN_FLEET !== true) {
16 16
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
17 17
 }
18 18
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
   $planet_list = array();
27 27
 
28
-  if(is_array($resources_taken))
28
+  if (is_array($resources_taken))
29 29
   {
30 30
     $query = implode(',', array_keys($resources_taken));
31 31
     $query = " AND `destruyed` = 0 AND `id` IN ({$query})";
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
     $query = '';
34 34
   }
35 35
 
36
-  foreach(sn_get_groups('flt_transports') as $transport_id) {
36
+  foreach (sn_get_groups('flt_transports') as $transport_id) {
37 37
     $transports[$transport_id] = get_unit_param($transport_id, P_CAPACITY);
38 38
   }
39 39
   arsort($transports);
40 40
 
41 41
   $planets_db_list = DBStaticPlanet::db_planet_list_sorted($user, $planetrow['id'], '*', $query);
42 42
   !is_array($planets_db_list) ? $planets_db_list = array() : false;
43
-  foreach($planets_db_list as $planet_db_data) {
43
+  foreach ($planets_db_list as $planet_db_data) {
44 44
   // begin planet loop
45
-    if(!$query) {
45
+    if (!$query) {
46 46
       $resources_taken[$planet_db_data['id']] = 1;
47 47
     }
48 48
     sn_db_transaction_start();
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
     $planet_id = $planet_db_data['id'];
55 55
 
56 56
     $planet_resources = 0;
57
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
58
-      if($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) {
57
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
58
+      if ($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) {
59 59
         $planet_resources += floor(mrc_get_level($user, $planet_db_data, $resource_id, true, true)); // $planet_db_data[get_unit_param($resource_id, P_NAME)]);
60 60
       }
61 61
     }
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
     $fleet_capacity = 0;
87 87
     $ship_loadout = array();
88 88
     $fleet = array();
89
-    foreach($transports as $ship_id => $ship_capacity) {
90
-      if($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) {
89
+    foreach ($transports as $ship_id => $ship_capacity) {
90
+      if ($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) {
91 91
         $ship_loadout[$ship_id]['capacity'] = $ship_count * $ship_capacity;
92 92
         $ship_loadout[$ship_id]['taken'] = 0;
93 93
         $fleet_capacity += $ship_loadout[$ship_id]['capacity'];
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 
99 99
     $will_take = min($planet_resources, $fleet_capacity);
100 100
 
101
-    foreach($ship_loadout as $ship_id => &$planet_ship) {
101
+    foreach ($ship_loadout as $ship_id => &$planet_ship) {
102 102
       $can_take = min($will_take, $planet_ship['capacity']);
103
-      if($can_take <= 0) {
103
+      if ($can_take <= 0) {
104 104
         continue;
105 105
       }
106 106
       $planet_ship['capacity'] -= $can_take;
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
       $fleet[$ship_id] = ceil($planet_ship['taken'] / $transports[$ship_id]);
109 109
 
110 110
       $will_take -= $can_take;
111
-      if($will_take <= 0) {
111
+      if ($will_take <= 0) {
112 112
         break;
113 113
       }
114 114
     }
115 115
 
116
-    if(!empty($fleet)) {
116
+    if (!empty($fleet)) {
117 117
       $travel_data = flt_travel_data($user, $planetrow, $planet_db_data, $fleet, 10);
118 118
       $planet_data['FLEET_SPEED'] = $travel_data['fleet_speed'];
119 119
       $planet_data['DISTANCE']    = $travel_data['distance'];
120 120
       $planet_data['DURATION']    = $travel_data['duration'];
121 121
       $planet_data['CONSUMPTION'] = $travel_data['consumption'];
122 122
 
123
-      if(floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) {
123
+      if (floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) {
124 124
         $will_take = min($planet_resources, $fleet_capacity) - $planet_data['CONSUMPTION'];
125 125
 
126
-        foreach(sn_get_groups('resources_loot') as $resource_id) {
127
-          if($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) {
126
+        foreach (sn_get_groups('resources_loot') as $resource_id) {
127
+          if ($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) {
128 128
             continue;
129 129
           }
130 130
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
           $fleet[$resource_id] = min($will_take, $resource_amount);
134 134
           $will_take -= $resource_amount;
135 135
 
136
-          if($will_take <= 0) {
136
+          if ($will_take <= 0) {
137 137
             break;
138 138
           }
139 139
         }
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
 
158 158
 $resources_taken = sys_get_param('resources');
159 159
 
160
-if(!empty($resources_taken))  { // begin processing parameters
160
+if (!empty($resources_taken)) { // begin processing parameters
161 161
   $planet_list = flt_build_gathering($resources_taken);
162 162
 
163
-  foreach($planet_list as $planet_id => $planet_data) {
164
-    if($planet_data['RESULT'] == ATTACK_ALLOWED) {
163
+  foreach ($planet_list as $planet_id => $planet_data) {
164
+    if ($planet_data['RESULT'] == ATTACK_ALLOWED) {
165 165
       $planet_data['RESULT'] = flt_t_send_fleet($user, $planet_data['PLANET_DB_DATA'], $planetrow, $planet_data['FLEET'], MT_TRANSPORT);
166 166
     }
167 167
 
168 168
     $planet_data['MESSAGE'] = $lang['fl_attack_error'][$planet_data['RESULT']];
169 169
 
170 170
     $template->assign_block_vars('results', $planet_data);
171
-    if(!empty($planet_data['FLEET']) && $planet_data['RESULT'] == ATTACK_ALLOWED) {
172
-      foreach($planet_data['FLEET'] as $unit_id => $amount) {
171
+    if (!empty($planet_data['FLEET']) && $planet_data['RESULT'] == ATTACK_ALLOWED) {
172
+      foreach ($planet_data['FLEET'] as $unit_id => $amount) {
173 173
         $template->assign_block_vars('results.units', array(
174 174
           'ID'     => $unit_id,
175 175
           'NAME'   => $lang['tech'][$unit_id],
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 // Building list of own planets & moons
184 184
 $planet_list = flt_build_gathering();
185
-foreach($planet_list as $planet_data) {
185
+foreach ($planet_list as $planet_data) {
186 186
   $planet_data['DURATION'] = $planet_data['DURATION'] ? pretty_time($planet_data['DURATION']) : $lang['flt_no_fuel'];
187 187
   $template->assign_block_vars('colonies', $planet_data);
188 188
 }
Please login to merge, or discard this patch.
includes/includes/flt_mission_spy.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 // ----------------------------------------------------------------------------------------------------------------
13 13
 function coe_compress_add_units($unit_group, $target_planet, &$compress_data, $target_user = array())
14 14
 {
15
-  foreach($unit_group as $unit_id)
15
+  foreach ($unit_group as $unit_id)
16 16
   {
17
-    if(($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0)
17
+    if (($unit_count = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0)
18 18
     {
19 19
       $compress_data[$unit_id] = $unit_count;
20 20
     }
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
   global $lang;
35 35
 
36 36
   $result = "<tr><td class=\"c\" colspan=\"4\">{$section_title}</td></tr>";
37
-  foreach(sn_get_groups($group_name) as $unit_id)
37
+  foreach (sn_get_groups($group_name) as $unit_id)
38 38
   {
39
-    if(($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0)
39
+    if (($unit_amount = mrc_get_level($target_user, $target_planet, $unit_id, false, true)) > 0)
40 40
     {
41 41
       $result .= "<tr><td align=\"left\" colspan=\"3\">{$lang['tech'][$unit_id]}</td><td align=\"right\">{$unit_amount}</td></tr>";
42 42
     }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
   $spying_user_row   = &$mission_data['src_user'];
64 64
   $spying_planet_row = &$mission_data['src_planet'];
65 65
 
66
-  if(!isset($target_user_row['id']) || !isset($target_planet_row['id']) || !isset($spying_user_row['id']))
66
+  if (!isset($target_user_row['id']) || !isset($target_planet_row['id']) || !isset($spying_user_row['id']))
67 67
   {
68 68
 //    doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;");
69 69
     fleet_send_back($fleet_row);
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
   }
72 72
 
73 73
   $fleet_array = sys_unit_str2arr($fleet_row['fleet_array']);
74
-  if($fleet_array[SHIP_SPY] > 0)
74
+  if ($fleet_array[SHIP_SPY] > 0)
75 75
   {
76 76
     $TargetSpyLvl      = GetSpyLevel($target_user_row);
77 77
     $CurrentSpyLvl     = GetSpyLevel($spying_user_row);
78 78
     $spy_diff_empire = $CurrentSpyLvl - $TargetSpyLvl;
79 79
 
80 80
     $spy_probes = $fleet_array[SHIP_SPY];
81
-    $spy_diff   = $spy_diff_empire + sqrt($spy_probes) - 1 ;
81
+    $spy_diff   = $spy_diff_empire + sqrt($spy_probes) - 1;
82 82
 
83 83
     $combat_pack[0] = array(
84 84
       RES_METAL => $target_planet_row['metal'],
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     $spy_message .= "<td width=220>{$lang['sys_metal']}</td><td width=220 align=right>" . pretty_number($target_planet_row['metal']) . "</td>";
95 95
     $spy_message .= "<td width=220>{$lang['sys_crystal']}</td></td><td width=220 align=right>" . pretty_number($target_planet_row['crystal']) . "</td>";
96 96
     $spy_message .= "</tr><tr>";
97
-    $spy_message .= "<td width=220>{$lang['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium'])  . "</td>";
97
+    $spy_message .= "<td width=220>{$lang['sys_deuterium']}</td><td width=220 align=right>" . pretty_number($target_planet_row['deuterium']) . "</td>";
98 98
     $spy_message .= "<td width=220>{$lang['sys_energy']}</td><td width=220 align=right>" . pretty_number($target_planet_row['energy_max']) . "</td>";
99 99
     $spy_message .= "</tr>";
100 100
     if ($spy_diff >= 2)
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
       $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'structures', $lang['tech'][UNIT_STRUCTURES], $target_user_row) . "</div>";
112 112
     }
113 113
 
114
-    if($spy_diff_empire >= 0)
114
+    if ($spy_diff_empire >= 0)
115 115
     {
116 116
       $spy_message .= "<div class='spy_long'>" . flt_spy_scan($target_planet_row, 'tech', $lang['tech'][UNIT_TECHNOLOGIES], $target_user_row) . "</div>";
117 117
       coe_compress_add_units(array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR), $target_planet_row, $combat_pack[0], $target_user_row);
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
     $simulator_link = sn_ube_simulator_encode_replay($combat_pack, 'D');
122 122
 
123 123
     $target_unit_list = 0;
124
-    foreach(sn_get_groups('fleet') as $unit_id)
124
+    foreach (sn_get_groups('fleet') as $unit_id)
125 125
     {
126 126
       $target_unit_list += max(0, mrc_get_level($target_user_row, $target_planet_row, $unit_id, false, true));
127 127
     }
128 128
 
129 129
     $spy_detected = $spy_probes * $target_unit_list / 4 * pow(2, $TargetSpyLvl - $CurrentSpyLvl);
130 130
 
131
-    if(mt_rand(0, 99) > $spy_detected)
131
+    if (mt_rand(0, 99) > $spy_detected)
132 132
     {
133 133
       $spy_outcome_str = sprintf($lang['sys_mess_spy_detect_chance'], $spy_detected);
134 134
       $spy_detected = false;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
     $target_user_id = $fleet_row['fleet_target_owner'];
155 155
 
156
-    if($spy_detected)
156
+    if ($spy_detected)
157 157
     {
158 158
 //      doquery("DELETE FROM {{fleets}} WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;");
159 159
       db_fleet_delete($fleet_row['fleet_id']);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
       $spy_cost = get_unit_param(SHIP_SPY, P_COST);
164 164
 
165 165
       DBStaticPlanet::db_planet_set_by_id($debris_planet_id,
166
-        "`debris_metal` = `debris_metal` + ". floor($spy_probes * $spy_cost[RES_METAL] * 0.3) .", `debris_crystal` = `debris_crystal` + ". floor($spy_probes * $spy_cost[RES_CRYSTAL] * 0.3));
166
+        "`debris_metal` = `debris_metal` + " . floor($spy_probes * $spy_cost[RES_METAL] * 0.3) . ", `debris_crystal` = `debris_crystal` + " . floor($spy_probes * $spy_cost[RES_CRYSTAL] * 0.3));
167 167
 
168 168
       $target_message .= "<br />{$lang['sys_mess_spy_destroyed_enemy']}";
169 169
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     msg_send_simple_message($target_user_id, '', $fleet_row['fleet_start_time'], MSG_TYPE_SPY, $lang['sys_mess_spy_control'], $lang['sys_mess_spy_activity'], $target_message);
177 177
   }
178 178
 
179
-  if(!$spy_detected)
179
+  if (!$spy_detected)
180 180
   {
181 181
 //    doquery("UPDATE {{fleets}} SET `fleet_mess` = '1' WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;");
182 182
     fleet_send_back($fleet_row);
Please login to merge, or discard this patch.
includes/includes/flt_page4.inc 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(SN_IN_FLEET !== true) {
3
+if (SN_IN_FLEET !== true) {
4 4
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
5 5
 }
6 6
 
7 7
 $fleetid = sys_get_param_id('fleetid');
8 8
 
9
-if(!is_numeric($fleetid) || empty($fleetid)) {
9
+if (!is_numeric($fleetid) || empty($fleetid)) {
10 10
   header("Location: fleet.php");
11 11
   exit();
12 12
 }
13 13
 
14 14
 $fleet = db_fleet_get($fleetid);
15
-if(!$fleet) {
15
+if (!$fleet) {
16 16
   message($lang['fl_fleet_not_exists'], $lang['fl_error']);
17 17
 }
18 18
 //$query = doquery("SELECT * FROM `{{fleets}}` WHERE fleet_id = '{$fleetid}'");
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
   message($lang['fl_isback'], $lang['fl_error']);
27 27
 }
28 28
 
29
-if($fleet['fleet_owner'] != $user['id']) {
30
-  $debug->warning($lang['fl_aks_hack_wrong_fleet'],'Wrong Fleet Owner',301);
29
+if ($fleet['fleet_owner'] != $user['id']) {
30
+  $debug->warning($lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301);
31 31
   message($lang['fl_aks_hack_wrong_fleet'], $lang['fl_error']);
32 32
 }
33 33
 
@@ -37,19 +37,19 @@  discard block
 block discarded – undo
37 37
 
38 38
 !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false;
39 39
 
40
-if($userToAdd_unsafe) {
40
+if ($userToAdd_unsafe) {
41 41
   $userToAdd = db_escape($userToAdd_unsafe);
42 42
   $userToAddID = db_user_by_username($userToAdd_unsafe, false, 'id', true, true);
43 43
   $userToAddID = $userToAddID['id'];
44 44
 
45
-  if($fleet['fleet_target_owner'] == $userToAddID) {
45
+  if ($fleet['fleet_target_owner'] == $userToAddID) {
46 46
     message($lang['flt_aks_player_same'], $lang['fl_error']);
47 47
   }
48 48
 
49
-  if($userToAddID) {
50
-    if(!$aks) {
49
+  if ($userToAddID) {
50
+    if (!$aks) {
51 51
       // No AСS exists - making one
52
-      if(!$fleet['fleet_group']) {
52
+      if (!$fleet['fleet_group']) {
53 53
         doquery("INSERT INTO {{aks}} SET
54 54
           `name` = '" . db_escape($lang['flt_acs_prefix'] . $fleetid) . "',
55 55
           `teilnehmer` = '" . $user['id'] . "',
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
           `planet` = '" . $fleet['fleet_end_planet'] . "',
61 61
           `planet_type` = '" . $fleet['fleet_end_type'] . "',
62 62
           `eingeladen` = '" . $user['id'] . "',
63
-          `fleet_end_time` = '" . $fleet['fleet_end_time']. "'");
63
+          `fleet_end_time` = '" . $fleet['fleet_end_time'] . "'");
64 64
 
65 65
         $aks = doquery("SELECT * FROM {{aks}} WHERE `flotten` = {$fleetid} LIMIT 1;", true);
66 66
 
@@ -78,26 +78,26 @@  discard block
 block discarded – undo
78 78
 
79 79
     $isUserExists = false;
80 80
     $invited_ar = explode(",", $aks['eingeladen']);
81
-    foreach($invited_ar as $inv) {
81
+    foreach ($invited_ar as $inv) {
82 82
       if ($userToAddID == $inv) {
83 83
         $isUserExists = true;
84 84
       }
85 85
     }
86 86
 
87
-    if(count($invited_ar) >= 5) {
87
+    if (count($invited_ar) >= 5) {
88 88
       message($lang['flt_aks_error_too_much_players'], $lang['fl_error']);
89 89
     }
90 90
 
91
-    if($isUserExists) {
91
+    if ($isUserExists) {
92 92
       $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf($lang['fl_aks_player_invited_already'], $userToAdd) : false;
93 93
     } else {
94 94
       $add_user_message_mr = sprintf($lang['fl_aks_player_invited'], $userToAdd);
95 95
       doquery("UPDATE `{{aks}}` SET `eingeladen` = concat(`eingeladen`, ',{$userToAddID}') WHERE `flotten` = {$fleetid};")
96
-        or die(sprintf($lang['fl_aks_adding_error'],db_error()));
96
+        or die(sprintf($lang['fl_aks_adding_error'], db_error()));
97 97
       $aks['eingeladen'] .= ',' . $userToAddID;
98 98
     }
99
-    msg_send_simple_message ( $userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
100
-      $lang['fl_aks_invite_message_header'], sprintf( $lang['fl_aks_invite_message'], $user['username']));
99
+    msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'],
100
+      $lang['fl_aks_invite_message_header'], sprintf($lang['fl_aks_invite_message'], $user['username']));
101 101
   } else {
102 102
     $add_user_message_mr = sprintf($lang['fl_aks_player_error'], $userToAdd);
103 103
   }
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
   'MISSION_NAME' => $lang['type_mission'][MT_AKS],
112 112
 ));
113 113
 
114
-if($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
115
-  foreach($members as $row) {
114
+if ($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
115
+  foreach ($members as $row) {
116 116
     $template->assign_block_vars('invited', array(
117 117
       'NAME' => $row['username'],
118 118
     ));
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
 $fleet_data = tpl_parse_fleet_db($fleet_row, $i, $user);
130 130
 $template->assign_block_vars('fleets', $fleet_data['fleet']);
131
-foreach($fleet_data['ships'] as $ship_data) {
131
+foreach ($fleet_data['ships'] as $ship_data) {
132 132
   $template->assign_block_vars('fleets.ships', $ship_data);
133 133
 }
134 134
 
Please login to merge, or discard this patch.
includes/includes/flt_mission_recycle.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
   $fleet_row          = &$mission_data['fleet'];
13 13
   $destination_planet = &$mission_data['dst_planet'];
14 14
 
15
-  if(!$fleet_row)
15
+  if (!$fleet_row)
16 16
   {
17 17
     return CACHE_NOTHING;
18 18
   }
19 19
 
20
-  if(!isset($destination_planet['id']))
20
+  if (!isset($destination_planet['id']))
21 21
   {
22 22
     // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;");
23 23
     fleet_send_back($mission_data['fleet']);
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
   $RecyclerCapacity    = 0;
30 30
   $OtherFleetCapacity  = 0;
31 31
   $fleet_array = sys_unit_str2arr($fleet_row['fleet_array']);
32
-  foreach($fleet_array as $unit_id => $unit_count)
32
+  foreach ($fleet_array as $unit_id => $unit_count)
33 33
   {
34
-    if(in_array($unit_id, sn_get_groups('fleet')))
34
+    if (in_array($unit_id, sn_get_groups('fleet')))
35 35
     {
36 36
       $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count;
37
-      if(in_array($unit_id, sn_get_groups('flt_recyclers')))
37
+      if (in_array($unit_id, sn_get_groups('flt_recyclers')))
38 38
       {
39 39
         $RecyclerCapacity += $capacity;
40 40
       }
@@ -46,19 +46,19 @@  discard block
 block discarded – undo
46 46
   }
47 47
 
48 48
   $IncomingFleetGoods = $fleet_row["fleet_resource_metal"] + $fleet_row["fleet_resource_crystal"] + $fleet_row["fleet_resource_deuterium"];
49
-  if($IncomingFleetGoods > $OtherFleetCapacity)
49
+  if ($IncomingFleetGoods > $OtherFleetCapacity)
50 50
   {
51 51
     $RecyclerCapacity -= ($IncomingFleetGoods - $OtherFleetCapacity);
52 52
   }
53 53
 
54
-  if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity)
54
+  if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity)
55 55
   {
56 56
     $RecycledGoods["metal"]   = $destination_planet["debris_metal"];
57 57
     $RecycledGoods["crystal"] = $destination_planet["debris_crystal"];
58 58
   }
59 59
   else
60 60
   {
61
-    if (($destination_planet["debris_metal"]   > $RecyclerCapacity / 2) AND
61
+    if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) AND
62 62
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2))
63 63
       {
64 64
       $RecycledGoods["metal"]   = $RecyclerCapacity / 2;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
       }
93 93
     }
94 94
   }
95
-  $NewCargo['Metal']     = $fleet_row["fleet_resource_metal"]   + $RecycledGoods["metal"];
95
+  $NewCargo['Metal']     = $fleet_row["fleet_resource_metal"] + $RecycledGoods["metal"];
96 96
   $NewCargo['Crystal']   = $fleet_row["fleet_resource_crystal"] + $RecycledGoods["crystal"];
97 97
   $NewCargo['Deuterium'] = $fleet_row["fleet_resource_deuterium"];
98 98
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
   );
102 102
 
103 103
   $Message = sprintf($lang['sys_recy_gotten'], pretty_number($RecycledGoods["metal"]), $lang['Metal'], pretty_number($RecycledGoods["crystal"]), $lang['Crystal']);
104
-  msg_send_simple_message ( $fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message);
104
+  msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_RECYCLE, $lang['sys_mess_spy_control'], $lang['sys_recy_report'], $Message);
105 105
 
106 106
 //  $QryUpdateFleet  = "UPDATE {{fleets}} SET `fleet_mess` = 1,`fleet_resource_metal` = '{$NewCargo['Metal']}',`fleet_resource_crystal` = '{$NewCargo['Crystal']}',`fleet_resource_deuterium` = '{$NewCargo['Deuterium']}' ";
107 107
 //  $QryUpdateFleet .= "WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;";
Please login to merge, or discard this patch.
includes/includes/flt_mission_explore.php 1 patch
Spacing   +37 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 
15 15
   $fleet_left = 1 - mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000;
16 16
   $fleet_lost = array();
17
-  foreach($fleet as $unit_id => &$unit_amount) {
17
+  foreach ($fleet as $unit_id => &$unit_amount) {
18 18
     $ships_left = floor($unit_amount * $fleet_left);
19 19
     $fleet_lost[$unit_id] = $unit_amount - $ships_left;
20 20
     $unit_amount = $ships_left;
21
-    if(!$unit_amount) {
21
+    if (!$unit_amount) {
22 22
       unset($fleet[$unit_id]);
23 23
     }
24 24
   }
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 //  $fleet = array();
32 32
 }
33 33
 
34
-function flt_mission_explore_addon(&$result){return sn_function_call('flt_mission_explore_addon', array(&$result));}
34
+function flt_mission_explore_addon(&$result) {return sn_function_call('flt_mission_explore_addon', array(&$result)); }
35 35
 function sn_flt_mission_explore_addon(&$result) {
36 36
   return $result;
37 37
 }
38 38
 
39 39
 
40 40
 function flt_mission_explore(&$mission_data) {
41
-  if(!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) {
41
+  if (!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) {
42 42
     return CACHE_NONE;
43 43
   }
44 44
 
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
   $outcome_list = &$result['$outcome_list'];
72 72
   $fleet_metal_points = &$result['$fleet_metal_points'];
73 73
 
74
-  if(!$ship_data) {
75
-    foreach(sn_get_groups('fleet') as $unit_id) {
74
+  if (!$ship_data) {
75
+    foreach (sn_get_groups('fleet') as $unit_id) {
76 76
       $unit_info = get_unit_param($unit_id);
77
-      if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) {
77
+      if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) {
78 78
         continue;
79 79
       }
80 80
       $ship_data[$unit_id][P_COST_METAL] = get_unit_cost_in($unit_info[P_COST]);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
   $fleet = sys_unit_str2arr($fleet_row['fleet_array']);
87 87
   $fleet_capacity = 0;
88 88
   $fleet_metal_points = 0;
89
-  foreach($fleet as $ship_id => $ship_amount) {
89
+  foreach ($fleet as $ship_id => $ship_amount) {
90 90
     $unit_info = get_unit_param($ship_id);
91 91
     $fleet_capacity += $ship_amount * $unit_info[P_CAPACITY];
92 92
     $fleet_metal_points += $ship_amount * $ship_data[$ship_id][P_COST_METAL];
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
   $flt_stay_hours = ($fleet_row['fleet_end_stay'] - $fleet_row['fleet_start_time']) / 3600 * ($config->game_speed_expedition ? $config->game_speed_expedition : 1);
97 97
 
98 98
   $outcome_list = sn_get_groups('mission_explore_outcome_list');
99
-  $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1/1.7));
99
+  $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7));
100 100
 
101 101
   $chance_max = 0;
102
-  foreach($outcome_list as $key => &$value) {
103
-    if(!$value['chance']) {
102
+  foreach ($outcome_list as $key => &$value) {
103
+    if (!$value['chance']) {
104 104
       unset($outcome_list[$key]);
105 105
       continue;
106 106
     }
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
   $outcome_value = mt_rand(0, $chance_max);
110 110
 // $outcome_value = 409;
111 111
   $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE];
112
-  foreach($outcome_list as $key => &$value) {
113
-    if(!$value['chance']) {
112
+  foreach ($outcome_list as $key => &$value) {
113
+    if (!$value['chance']) {
114 114
       continue;
115 115
     }
116 116
     $mission_outcome = $key;
117 117
     $outcome_description = $value;
118
-    if($outcome_value <= $outcome_description['value']) {
118
+    if ($outcome_value <= $outcome_description['value']) {
119 119
       break;
120 120
     }
121 121
   }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
   $found_dark_matter = 0;
132 132
 //  $outcome_mission_sub = -1;
133 133
 
134
-  switch($mission_outcome) {
134
+  switch ($mission_outcome) {
135 135
 //  switch(FLT_EXPEDITION_OUTCOME_LOST_FLEET) { // TODO DEBUG!
136 136
     case FLT_EXPEDITION_OUTCOME_LOST_FLEET:
137 137
       flt_mission_explore_outcome_lost_fleet($result);
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 
167 167
       // Рассчитываем стоимость самого дорого корабля в металле
168 168
       $max_metal_cost = 0;
169
-      foreach($fleet as $ship_id => $ship_amount) {
169
+      foreach ($fleet as $ship_id => $ship_amount) {
170 170
         $max_metal_cost = max($max_metal_cost, $ship_data[$ship_id]['metal_cost']);
171 171
       }
172 172
 
173 173
       // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля
174 174
       $can_be_found = array();
175
-      foreach($ship_data as $ship_id => $ship_info) {
176
-        if($ship_info['metal_cost'] < $max_metal_cost) {
175
+      foreach ($ship_data as $ship_id => $ship_info) {
176
+        if ($ship_info['metal_cost'] < $max_metal_cost) {
177 177
           $can_be_found[$ship_id] = $ship_info['metal_cost'];
178 178
         }
179 179
       }
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
       unset($can_be_found[SHIP_SPY]);
183 183
 
184 184
       $fleet_found = array();
185
-      while(count($can_be_found) && $found_in_metal >= max($can_be_found)) {
185
+      while (count($can_be_found) && $found_in_metal >= max($can_be_found)) {
186 186
         $found_index = mt_rand(1, count($can_be_found)) - 1;
187 187
         $found_ship = array_slice($can_be_found, $found_index, 1, true);
188 188
         $found_ship_cost = reset($found_ship);
189 189
         $found_ship_id = key($found_ship);
190 190
 
191
-        if($found_ship_cost > $found_in_metal) {
191
+        if ($found_ship_cost > $found_in_metal) {
192 192
           unset($can_be_found[$found_ship_id]);
193 193
         } else {
194 194
           $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost));
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
         }
198 198
       }
199 199
 
200
-      if(empty($fleet_found)) {
200
+      if (empty($fleet_found)) {
201 201
         $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
202 202
       } else {
203
-        foreach($fleet_found as $unit_id => $unit_amount) {
203
+        foreach ($fleet_found as $unit_id => $unit_amount) {
204 204
           $fleet[$unit_id] += $unit_amount;
205 205
         }
206 206
       }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
       $fleet_row['fleet_resource_crystal'] += $resources_found[RES_CRYSTAL];
227 227
       $fleet_row['fleet_resource_deuterium'] += $resources_found[RES_DEUTERIUM];
228 228
 
229
-      if(array_sum($resources_found) == 0) {
229
+      if (array_sum($resources_found) == 0) {
230 230
         $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
231 231
       }
232 232
     break;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
       // Рассчитываем количество найденной ТМ
238 238
       $found_dark_matter = floor(min($outcome_percent * $fleet_metal_points / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000);
239 239
 
240
-      if(!$found_dark_matter) {
240
+      if (!$found_dark_matter) {
241 241
         $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result'];
242 242
       }
243 243
     break;
@@ -251,31 +251,31 @@  discard block
 block discarded – undo
251 251
 
252 252
   flt_mission_explore_addon($result);
253 253
 
254
-  if($found_dark_matter) {
254
+  if ($found_dark_matter) {
255 255
     rpg_points_change($fleet_row['fleet_owner'], RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus');
256 256
     $msg_text_addon = sprintf($lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter);
257 257
   }
258 258
 
259
-  if(!empty($fleet_lost)) {
259
+  if (!empty($fleet_lost)) {
260 260
     $msg_text_addon = $lang['flt_mission_expedition']['lost_fleet'];
261
-    foreach($fleet_lost as $ship_id => $ship_amount) {
261
+    foreach ($fleet_lost as $ship_id => $ship_amount) {
262 262
       $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
263 263
     }
264 264
   }
265 265
 
266 266
   $fleet_row['fleet_amount'] = array_sum($fleet);
267
-  if(!empty($fleet) && $fleet_row['fleet_amount']) {
268
-    if(!empty($fleet_found)) {
267
+  if (!empty($fleet) && $fleet_row['fleet_amount']) {
268
+    if (!empty($fleet_found)) {
269 269
       $msg_text_addon = $lang['flt_mission_expedition']['found_fleet'];
270
-      foreach($fleet_found as $ship_id => $ship_amount) {
270
+      foreach ($fleet_found as $ship_id => $ship_amount) {
271 271
         $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
272 272
       }
273 273
     }
274 274
 
275 275
     $query_delta = array();
276
-    if(!empty($resources_found) && array_sum($resources_found) > 0) {
276
+    if (!empty($resources_found) && array_sum($resources_found) > 0) {
277 277
       $msg_text_addon = $lang['flt_mission_expedition']['found_resources'];
278
-      foreach($resources_found as $ship_id => $ship_amount) {
278
+      foreach ($resources_found as $ship_id => $ship_amount) {
279 279
         $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n";
280 280
       }
281 281
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
     }
289 289
 
290 290
     $query_data = array();
291
-    if(!empty($fleet_lost) || !empty($fleet_found)) {
291
+    if (!empty($fleet_lost) || !empty($fleet_found)) {
292 292
       $fleet_row['fleet_array'] = sys_unit_arr2str($fleet);
293 293
 
294 294
 //      $query_data[] = "`fleet_amount` = {$fleet_row['fleet_amount']}";
@@ -316,17 +316,16 @@  discard block
 block discarded – undo
316 316
 
317 317
   db_user_set_by_id($fleet_row['fleet_owner'], "`player_rpg_explore_xp` = `player_rpg_explore_xp` + 1");
318 318
 
319
-  if(!$msg_text) {
319
+  if (!$msg_text) {
320 320
     $messages = &$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages'];
321
-    if($outcome_mission_sub >= 0 && is_array($messages)) {
321
+    if ($outcome_mission_sub >= 0 && is_array($messages)) {
322 322
       $messages = &$messages[$outcome_mission_sub];
323 323
     }
324 324
 
325
-    $msg_text = is_string($messages) ? $messages :
326
-      (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '');
325
+    $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : '');
327 326
   }
328 327
   $msg_text = sprintf($msg_text, $fleet_row['fleet_id'], uni_render_coordinates($fleet_row, 'fleet_end_')) .
329
-    ($msg_text_addon ? "\r\n" . $msg_text_addon: '');
328
+    ($msg_text_addon ? "\r\n" . $msg_text_addon : '');
330 329
 
331 330
   msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_stay'], MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text);
332 331
 
Please login to merge, or discard this patch.
includes/includes/flt_mission_relocate.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
   $fleet_row          = &$mission_data['fleet'];
14 14
   $destination_planet = &$mission_data['dst_planet'];
15 15
 
16
-  if(!$destination_planet || !is_array($destination_planet) || $fleet_row['fleet_owner'] != $destination_planet['id_owner'])
16
+  if (!$destination_planet || !is_array($destination_planet) || $fleet_row['fleet_owner'] != $destination_planet['id_owner'])
17 17
   {
18 18
     // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;");
19 19
     fleet_send_back($mission_data['fleet']);
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
       $mission_data['src_planet']['name'], uni_render_coordinates_href($fleet_row, 'fleet_start_', 3, ''), $destination_planet['name'], uni_render_coordinates_href($fleet_row, 'fleet_end_', 3, ''),
27 27
     $fleet_row['fleet_resource_metal'], $lang['Metal'], $fleet_row['fleet_resource_crystal'], $lang['Crystal'], $fleet_row['fleet_resource_deuterium'], $lang['Deuterium']) .
28 28
   '<br />' . $lang['sys_relocate_mess_user'];
29
-  foreach(sys_unit_str2arr($fleet_row['fleet_array']) as $ship_id => $ship_count)
29
+  foreach (sys_unit_str2arr($fleet_row['fleet_array']) as $ship_id => $ship_count)
30 30
   {
31 31
     $Message .= $lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />';
32 32
   }
Please login to merge, or discard this patch.
includes/includes/flt_mission_destroy.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 function flt_mission_destroy($mission_data) {
9 9
   $fleet_row = $mission_data['fleet'];
10 10
   $destination_planet = $mission_data['dst_planet'];
11
-  if(!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) {
11
+  if (!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) {
12 12
     fleet_send_back($fleet_row);
13 13
 
14 14
     return CACHE_FLEET;
Please login to merge, or discard this patch.
includes/includes/uni_rename.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@  discard block
 block discarded – undo
6 6
     $uni_galaxy = sys_get_param_int('galaxy', $planetrow['galaxy']);
7 7
     $uni_system = sys_get_param_int('system');
8 8
 
9
-    if($uni_galaxy < 1 || $uni_galaxy > $config->game_maxGalaxy)
9
+    if ($uni_galaxy < 1 || $uni_galaxy > $config->game_maxGalaxy)
10 10
     {
11 11
       throw new exception($lang['uni_msg_error_wrong_galaxy'], ERR_ERROR);
12 12
     }
13 13
 
14
-    if($uni_system < 0 || $uni_system > $config->game_maxSystem)
14
+    if ($uni_system < 0 || $uni_system > $config->game_maxSystem)
15 15
     {
16 16
       throw new exception($lang['uni_msg_error_wrong_system'], ERR_ERROR);
17 17
     }
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
     $uni_row['universe_price'] += $uni_system ? $config->uni_price_system : $config->uni_price_galaxy;
21 21
     $uni_row['universe_name'] = strip_tags($uni_row['universe_name'] ? $uni_row['universe_name'] : ($uni_system ? "{$lang['sys_system']} [{$uni_galaxy}:{$uni_system}]" : "{$lang['sys_galaxy']} {$uni_galaxy}"));
22 22
 
23
-    if(sys_get_param_str('uni_name_submit'))
23
+    if (sys_get_param_str('uni_name_submit'))
24 24
     {
25 25
       $uni_row['universe_name'] = strip_tags(sys_get_param_str('uni_name'));
26 26
 
27 27
       $uni_price = sys_get_param_float('uni_price');
28
-      if($uni_price < $uni_row['universe_price'])
28
+      if ($uni_price < $uni_row['universe_price'])
29 29
       {
30 30
         throw new exception($lang['uni_msg_error_low_price'], ERR_ERROR);
31 31
       }
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
       sn_db_transaction_start();
35 35
       $user = db_user_by_id($user['id'], true);
36 36
       // if($user[get_unit_param(RES_DARK_MATTER, P_NAME)] < $uni_price)
37
-      if(mrc_get_level($user, null, RES_DARK_MATTER) < $uni_price)
37
+      if (mrc_get_level($user, null, RES_DARK_MATTER) < $uni_price)
38 38
       {
39 39
         throw new exception($lang['uni_msg_error_no_dm'], ERR_ERROR);
40 40
       }
41 41
 
42
-      if(!rpg_points_change($user['id'], RPG_RENAME, -$uni_price, "Renaming [{$uni_galaxy}:{$uni_system}] to " . sys_get_param_str_unsafe('uni_name')))
42
+      if (!rpg_points_change($user['id'], RPG_RENAME, -$uni_price, "Renaming [{$uni_galaxy}:{$uni_system}] to " . sys_get_param_str_unsafe('uni_name')))
43 43
       {
44 44
         throw new exception($lang['sys_msg_err_update_dm'], ERR_ERROR);
45 45
       }
Please login to merge, or discard this patch.