Completed
Push — trunk ( 0d0bfe...e6cc80 )
by SuperNova.WS
03:47
created
includes/functions/eco_get_build_data.php 2 patches
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function eco_lab_sort_effectivness($a, $b)
4
-{
3
+function eco_lab_sort_effectivness($a, $b) {
5 4
   return $a['laboratory_effective_level'] > $b['laboratory_effective_level'] ? -1 : ($a['laboratory_effective_level'] < $b['laboratory_effective_level'] ? 1 : 0);
6 5
 }
7 6
 
@@ -11,8 +10,7 @@  discard block
 block discarded – undo
11 10
  * 1.0 - copyright (c) 2010 by Gorlum for http://supernova.ws
12 11
  * @version 1.0
13 12
  */
14
-function eco_get_lab_max_effective_level(&$user, $lab_require)
15
-{
13
+function eco_get_lab_max_effective_level(&$user, $lab_require) {
16 14
   if(!$user['user_as_ally'] && !isset($user['laboratories_active']))
17 15
   {
18 16
     $user['laboratories_active'] = array();
@@ -38,8 +36,7 @@  discard block
 block discarded – undo
38 36
     if($user['user_as_ally'])
39 37
     {
40 38
       $lab_level = doquery("SELECT ally_members AS effective_level FROM {{alliance}} WHERE id = {$user['user_as_ally']} LIMIT 1", true);
41
-    }
42
-    else
39
+    } else
43 40
     {
44 41
       $tech_intergalactic = mrc_get_level($user, false, TECH_RESEARCH) + 1;
45 42
       $lab_level['effective_level'] = 0;
@@ -193,8 +190,7 @@  discard block
 block discarded – undo
193 190
   return $result;
194 191
 }
195 192
 
196
-function eco_is_builds_in_que($planet_que, $unit_list)
197
-{
193
+function eco_is_builds_in_que($planet_que, $unit_list) {
198 194
   $eco_is_builds_in_que = false;
199 195
 
200 196
   $unit_list = is_array($unit_list) ? $unit_list : array($unit_list => $unit_list);
@@ -216,8 +212,7 @@  discard block
 block discarded – undo
216 212
 }
217 213
 
218 214
 function eco_unit_busy(&$user, &$planet, $unit_id){return sn_function_call('eco_unit_busy', array(&$user, &$planet, $unit_id, &$result));}
219
-function sn_eco_unit_busy(&$user, &$planet, $unit_id, &$result)
220
-{
215
+function sn_eco_unit_busy(&$user, &$planet, $unit_id, &$result) {
221 216
   global $config;
222 217
 
223 218
   $result = isset($result) ? $result : false;
@@ -238,8 +233,7 @@  discard block
 block discarded – undo
238 233
       //{
239 234
       //  $result = true;
240 235
       //}
241
-    }
242
-    elseif(($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que'])
236
+    } elseif(($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que'])
243 237
     {
244 238
       $result = eco_is_builds_in_que($planet['que'], array(STRUC_LABORATORY, STRUC_LABORATORY_NANO));
245 239
     }
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function eco_get_lab_max_effective_level(&$user, $lab_require)
15 15
 {
16
-  if(!$user['user_as_ally'] && !isset($user['laboratories_active']))
16
+  if (!$user['user_as_ally'] && !isset($user['laboratories_active']))
17 17
   {
18 18
     $user['laboratories_active'] = array();
19 19
     $query = DBStaticUnit::db_unit_list_laboratories($user['id']);
20
-    while($row = db_fetch($query))
20
+    while ($row = db_fetch($query))
21 21
     {
22
-      if(!eco_unit_busy($user, $row, UNIT_TECHNOLOGIES))
22
+      if (!eco_unit_busy($user, $row, UNIT_TECHNOLOGIES))
23 23
       {
24 24
         $row += array(
25 25
           STRUC_LABORATORY => $level_lab = mrc_get_level($user, $row, STRUC_LABORATORY),
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
     uasort($user['laboratories_active'], 'eco_lab_sort_effectivness');
34 34
   }
35 35
 
36
-  if(!isset($user['research_effective_level'][$lab_require]))
36
+  if (!isset($user['research_effective_level'][$lab_require]))
37 37
   {
38
-    if($user['user_as_ally'])
38
+    if ($user['user_as_ally'])
39 39
     {
40 40
       $lab_level = doquery("SELECT ally_members AS effective_level FROM {{alliance}} WHERE id = {$user['user_as_ally']} LIMIT 1", true);
41 41
     }
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
       $tech_intergalactic = mrc_get_level($user, false, TECH_RESEARCH) + 1;
45 45
       $lab_level['effective_level'] = 0;
46 46
 
47
-      foreach($user['laboratories_active'] as $data)
47
+      foreach ($user['laboratories_active'] as $data)
48 48
       {
49
-        if($tech_intergalactic <= 0)
49
+        if ($tech_intergalactic <= 0)
50 50
         {
51 51
           break;
52 52
         }
53
-        if($data[STRUC_LABORATORY] >= $lab_require)
53
+        if ($data[STRUC_LABORATORY] >= $lab_require)
54 54
         {
55 55
           $lab_level['effective_level'] += $data['laboratory_effective_level'];
56 56
           $tech_intergalactic--;
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
   $cost[P_OPTIONS][P_TIME_RAW] = 0;
91 91
   $only_dark_matter = 0;
92 92
   $cost_in_metal = 0;
93
-  foreach($unit_data[P_COST] as $resource_id => $resource_amount) {
94
-    if($resource_id === P_FACTOR || !($resource_cost = $resource_amount * $price_increase)) {
93
+  foreach ($unit_data[P_COST] as $resource_id => $resource_amount) {
94
+    if ($resource_id === P_FACTOR || !($resource_cost = $resource_amount * $price_increase)) {
95 95
       continue;
96 96
     }
97 97
 
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 
103 103
     $cost_in_metal += $cost[BUILD_CREATE][$resource_id] * $currentResourceExchange;
104 104
 
105
-    if(in_array($resource_id, $resources_loot)) {
105
+    if (in_array($resource_id, $resources_loot)) {
106 106
       $cost[P_OPTIONS][P_TIME_RAW] += $resource_cost * $currentResourceExchange / $rpg_exchange_deuterium;
107 107
       $resource_got = mrc_get_level($user, $planet, $resource_id);
108
-    } elseif($resource_id == RES_DARK_MATTER) {
108
+    } elseif ($resource_id == RES_DARK_MATTER) {
109 109
       $resource_got = mrc_get_level($user, null, $resource_id);
110
-    } elseif($resource_id == RES_ENERGY) {
110
+    } elseif ($resource_id == RES_ENERGY) {
111 111
       $resource_got = max(0, $planet['energy_max'] - $planet['energy_used']);
112 112
     } else {
113 113
       $resource_got = 0;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
   }
120 120
 
121 121
   $resources_normalized = 0;
122
-  foreach($resources_loot as $resource_id) {
122
+  foreach ($resources_loot as $resource_id) {
123 123
     $resources_normalized += floor(mrc_get_level($user, $planet, $resource_id)) * $config->__get('rpg_exchange_' . pname_resource_name($resource_id));
124 124
   }
125 125
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
   $cost[P_OPTIONS][P_TIME_RAW] = $cost[P_OPTIONS][P_TIME_RAW] * 60 * 60 / get_game_speed() / 2500;
136 136
 
137 137
   // TODO - Вынести в отдельную процедуру расчёт стоимости
138
-  if($only_cost) {
138
+  if ($only_cost) {
139 139
     return $cost;
140 140
   }
141 141
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
   $cost['RESULT'][BUILD_DESTROY] = BUILD_INDESTRUCTABLE;
148 148
 
149 149
   $mercenary = 0;
150
-  if(in_array($unit_id, sn_get_groups('structures'))) {
150
+  if (in_array($unit_id, sn_get_groups('structures'))) {
151 151
     $cost[RES_TIME][BUILD_CREATE] *= pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_ROBOT) + 1);
152 152
     $cost['RESULT'][BUILD_DESTROY] =
153 153
       mrc_get_level($user, $planet, $unit_id, false, true)
@@ -157,23 +157,23 @@  discard block
 block discarded – undo
157 157
           )
158 158
         : BUILD_NO_UNITS;
159 159
     $mercenary = MRC_ENGINEER;
160
-  } elseif(in_array($unit_id, sn_get_groups('tech'))) {
160
+  } elseif (in_array($unit_id, sn_get_groups('tech'))) {
161 161
     $lab_level = eco_get_lab_max_effective_level($user, intval($unit_data['require'][STRUC_LABORATORY]));
162 162
     $cost[RES_TIME][BUILD_CREATE] /= $lab_level;
163 163
     $mercenary = MRC_ACADEMIC;
164
-  } elseif(in_array($unit_id, sn_get_groups('defense'))) {
165
-    $cost[RES_TIME][BUILD_CREATE] *= pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1) ;
164
+  } elseif (in_array($unit_id, sn_get_groups('defense'))) {
165
+    $cost[RES_TIME][BUILD_CREATE] *= pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1);
166 166
     $mercenary = MRC_FORTIFIER;
167
-  } elseif(in_array($unit_id, sn_get_groups('fleet'))) {
167
+  } elseif (in_array($unit_id, sn_get_groups('fleet'))) {
168 168
     $cost[RES_TIME][BUILD_CREATE] *= pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1);
169 169
     $mercenary = MRC_ENGINEER;
170 170
   }
171 171
 
172
-  if($mercenary) {
172
+  if ($mercenary) {
173 173
     $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_CREATE] / mrc_modify_value($user, $planet, $mercenary, 1);
174 174
   }
175 175
 
176
-  if(in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) {
176
+  if (in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) {
177 177
     $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_DESTROY] = 0;
178 178
   } else {
179 179
     $cost[RES_TIME][BUILD_CREATE]  = round($cost[RES_TIME][BUILD_CREATE] > 1 ? $cost[RES_TIME][BUILD_CREATE] : 1);
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
   return $cost;
184 184
 }
185 185
 
186
-function eco_can_build_unit($user, $planet, $unit_id){return sn_function_call('eco_can_build_unit', array($user, $planet, $unit_id, &$result));}
186
+function eco_can_build_unit($user, $planet, $unit_id) {return sn_function_call('eco_can_build_unit', array($user, $planet, $unit_id, &$result)); }
187 187
 function sn_eco_can_build_unit($user, $planet, $unit_id, &$result) {
188 188
   global $config;
189 189
 
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
   $result = $result == BUILD_ALLOWED && eco_unit_busy($user, $planet, $unit_id) ? BUILD_UNIT_BUSY : $result;
192 192
 
193 193
   $unit_param = get_unit_param($unit_id);
194
-  if($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !$config->empire_mercenary_temporary) {
194
+  if ($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !$config->empire_mercenary_temporary) {
195 195
     $requirement = &$unit_param[P_REQUIRE];
196
-    if($result == BUILD_ALLOWED && $requirement) {
197
-      foreach($requirement as $require_id => $require_level) {
198
-        if(mrc_get_level($user, $planet, $require_id) < $require_level) {
196
+    if ($result == BUILD_ALLOWED && $requirement) {
197
+      foreach ($requirement as $require_id => $require_level) {
198
+        if (mrc_get_level($user, $planet, $require_id) < $require_level) {
199 199
           $result = BUILD_REQUIRE_NOT_MEET;
200 200
           break;
201 201
         }
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
 
213 213
   $unit_list = is_array($unit_list) ? $unit_list : array($unit_list => $unit_list);
214 214
   $planet_que = explode(';', $planet_que);
215
-  foreach($planet_que as $planet_que_item)
215
+  foreach ($planet_que as $planet_que_item)
216 216
   {
217
-    if($planet_que_item)
217
+    if ($planet_que_item)
218 218
     {
219 219
       list($planet_que_item) = explode(',', $planet_que_item);
220
-      if(in_array($planet_que_item, $unit_list))
220
+      if (in_array($planet_que_item, $unit_list))
221 221
       {
222 222
         $eco_is_builds_in_que = true;
223 223
         break;
@@ -228,21 +228,21 @@  discard block
 block discarded – undo
228 228
   return $eco_is_builds_in_que;
229 229
 }
230 230
 
231
-function eco_unit_busy(&$user, &$planet, $unit_id){return sn_function_call('eco_unit_busy', array(&$user, &$planet, $unit_id, &$result));}
231
+function eco_unit_busy(&$user, &$planet, $unit_id) {return sn_function_call('eco_unit_busy', array(&$user, &$planet, $unit_id, &$result)); }
232 232
 function sn_eco_unit_busy(&$user, &$planet, $unit_id, &$result)
233 233
 {
234 234
   global $config;
235 235
 
236 236
   $result = isset($result) ? $result : false;
237
-  if(!$result)
237
+  if (!$result)
238 238
   {
239
-    if(($unit_id == STRUC_LABORATORY || $unit_id == STRUC_LABORATORY_NANO) && !$config->BuildLabWhileRun)
239
+    if (($unit_id == STRUC_LABORATORY || $unit_id == STRUC_LABORATORY_NANO) && !$config->BuildLabWhileRun)
240 240
     {
241 241
       $global_que = que_get($user['id'], $planet['id'], QUE_RESEARCH, false);
242
-      if(is_array($global_que['ques'][QUE_RESEARCH][$user['id']]))
242
+      if (is_array($global_que['ques'][QUE_RESEARCH][$user['id']]))
243 243
       {
244 244
         $first_element = reset($global_que['ques'][QUE_RESEARCH][$user['id']]);
245
-        if(is_array($first_element))
245
+        if (is_array($first_element))
246 246
         {
247 247
           $result = true;
248 248
         }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
       //  $result = true;
253 253
       //}
254 254
     }
255
-    elseif(($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que'])
255
+    elseif (($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !$config->BuildLabWhileRun && $planet['que'])
256 256
     {
257 257
       $result = eco_is_builds_in_que($planet['que'], array(STRUC_LABORATORY, STRUC_LABORATORY_NANO));
258 258
     }
Please login to merge, or discard this patch.
includes/includes/flt_mission_hold.php 2 patches
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.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-function flt_mission_hold(&$mission_data)
4
-{
3
+function flt_mission_hold(&$mission_data) {
5 4
   if($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW)
6 5
   {
7 6
     fleet_send_back($mission_data['fleet']);
Please login to merge, or discard this patch.
includes/includes/flt_mission_recycle.php 3 patches
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
  * @copyright 2008 By Chlorel for XNova
8 8
  */
9 9
 
10
-function flt_mission_recycle(&$mission_data)
11
-{
10
+function flt_mission_recycle(&$mission_data) {
12 11
   $fleet_row          = &$mission_data['fleet'];
13 12
   $destination_planet = &$mission_data['dst_planet'];
14 13
 
@@ -37,8 +36,7 @@  discard block
 block discarded – undo
37 36
       if(in_array($unit_id, sn_get_groups('flt_recyclers')))
38 37
       {
39 38
         $RecyclerCapacity += $capacity;
40
-      }
41
-      else
39
+      } else
42 40
       {
43 41
         $OtherFleetCapacity += $capacity;
44 42
       }
@@ -55,16 +53,14 @@  discard block
 block discarded – undo
55 53
   {
56 54
     $RecycledGoods["metal"]   = $destination_planet["debris_metal"];
57 55
     $RecycledGoods["crystal"] = $destination_planet["debris_crystal"];
58
-  }
59
-  else
56
+  } else
60 57
   {
61 58
     if (($destination_planet["debris_metal"]   > $RecyclerCapacity / 2) AND
62 59
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2))
63 60
       {
64 61
       $RecycledGoods["metal"]   = $RecyclerCapacity / 2;
65 62
       $RecycledGoods["crystal"] = $RecyclerCapacity / 2;
66
-    }
67
-    else
63
+    } else
68 64
     {
69 65
       if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"])
70 66
       {
@@ -72,20 +68,17 @@  discard block
 block discarded – undo
72 68
         if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $RecycledGoods["crystal"]))
73 69
         {
74 70
           $RecycledGoods["metal"] = $RecyclerCapacity - $RecycledGoods["crystal"];
75
-        }
76
-        else
71
+        } else
77 72
         {
78 73
           $RecycledGoods["metal"] = $destination_planet["debris_metal"];
79 74
         }
80
-      }
81
-      else
75
+      } else
82 76
       {
83 77
         $RecycledGoods["metal"] = $destination_planet["debris_metal"];
84 78
         if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $RecycledGoods["metal"]))
85 79
         {
86 80
           $RecycledGoods["crystal"] = $RecyclerCapacity - $RecycledGoods["metal"];
87
-        }
88
-        else
81
+        } else
89 82
         {
90 83
           $RecycledGoods["crystal"] = $destination_planet["debris_crystal"];
91 84
         }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
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;
Please login to merge, or discard this 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
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     HelperString::numberFloorAndFormat($RecycledGoods["metal"]), $lang['Metal'],
106 106
     HelperString::numberFloorAndFormat($RecycledGoods["crystal"]), $lang['Crystal']
107 107
   );
108
-  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);
108
+  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);
109 109
 
110 110
 //  $QryUpdateFleet  = "UPDATE {{fleets}} SET `fleet_mess` = 1,`fleet_resource_metal` = '{$NewCargo['Metal']}',`fleet_resource_crystal` = '{$NewCargo['Crystal']}',`fleet_resource_deuterium` = '{$NewCargo['Deuterium']}' ";
111 111
 //  $QryUpdateFleet .= "WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;";
Please login to merge, or discard this patch.
includes/includes/flt_mission_relocate.php 2 patches
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.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@
 block discarded – undo
8 8
  * @version 1.1
9 9
  * @copyright 2008 by Chlorel for XNova
10 10
  */
11
-function flt_mission_relocate($mission_data)
12
-{
11
+function flt_mission_relocate($mission_data) {
13 12
   $fleet_row          = &$mission_data['fleet'];
14 13
   $destination_planet = &$mission_data['dst_planet'];
15 14
 
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/upd_helpers.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@
 block discarded – undo
170 170
 
171 171
 function upd_db_unit_by_location($user_id = 0, $location_type, $location_id, $unit_snid = 0, $for_update = false, $fields = '*') {
172 172
   return db_fetch(upd_do_query(
173
-    "SELECT {$fields}
173
+    "select {$fields}
174 174
     FROM {{unit}}
175 175
     WHERE
176 176
       `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions() .
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('IN_UPDATE')) {
3
+if (!defined('IN_UPDATE')) {
4 4
   die('Trying to call update helpers externally!');
5 5
 }
6 6
 
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
   global $update_tables;
9 9
 
10 10
   upd_add_more_time();
11
-  if(!$no_log) {
11
+  if (!$no_log) {
12 12
     upd_log_message("Performing query '{$query}'");
13 13
   }
14 14
 
15
-  if(strpos($query, '{{') !== false) {
16
-    foreach($update_tables as $tableName => $cork) {
15
+  if (strpos($query, '{{') !== false) {
16
+    foreach ($update_tables as $tableName => $cork) {
17 17
       $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query);
18 18
     }
19 19
   }
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
   global $config, $sys_log_disabled;
26 26
 
27 27
   $config->db_loadItem($key);
28
-  if($condition || !isset($config->$key)) {
28
+  if ($condition || !isset($config->$key)) {
29 29
     upd_add_more_time();
30
-    if(!$sys_log_disabled) {
30
+    if (!$sys_log_disabled) {
31 31
       upd_log_message("Updating config key '{$key}' with value '{$default_value}'");
32 32
     }
33 33
     $config->db_saveItem($key, $default_value);
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 function upd_log_message($message) {
56 56
   global $sys_log_disabled, $upd_log, $debug;
57 57
 
58
-  if($sys_log_disabled)
58
+  if ($sys_log_disabled)
59 59
   {
60 60
 //    print("{$message}<br />");
61 61
   } else {
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
 function upd_unset_table_info($table_name) {
68 68
   global $update_tables, $update_indexes, $update_foreigns;
69 69
 
70
-  if(isset($update_tables[$table_name])) {
70
+  if (isset($update_tables[$table_name])) {
71 71
     unset($update_tables[$table_name]);
72 72
   }
73 73
 
74
-  if(isset($update_indexes[$table_name])) {
74
+  if (isset($update_indexes[$table_name])) {
75 75
     unset($update_indexes[$table_name]);
76 76
   }
77 77
 
78
-  if(isset($update_foreigns[$table_name])) {
78
+  if (isset($update_foreigns[$table_name])) {
79 79
     unset($update_foreigns[$table_name]);
80 80
   }
81 81
 }
@@ -89,18 +89,18 @@  discard block
 block discarded – undo
89 89
   upd_unset_table_info($tableName);
90 90
 
91 91
   $q1 = upd_do_query("SHOW FULL COLUMNS FROM {$prefix_table_name};", true);
92
-  while($r1 = db_fetch($q1)) {
92
+  while ($r1 = db_fetch($q1)) {
93 93
     $update_tables[$tableName][$r1['Field']] = $r1;
94 94
   }
95 95
 
96 96
   $q1 = upd_do_query("SHOW INDEX FROM {$prefix_table_name};", true);
97
-  while($r1 = db_fetch($q1)) {
97
+  while ($r1 = db_fetch($q1)) {
98 98
     $update_indexes[$tableName][$r1['Key_name']] .= "{$r1['Column_name']},";
99 99
     $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1;
100 100
   }
101 101
 
102
-  $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name). "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true);
103
-  while($r1 = db_fetch($q1)) {
102
+  $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true);
103
+  while ($r1 = db_fetch($q1)) {
104 104
     $table_referenced = str_replace($config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']);
105 105
 
106 106
     $update_foreigns[$tableName][$r1['CONSTRAINT_NAME']] .= "{$r1['COLUMN_NAME']},{$table_referenced},{$r1['REFERENCED_COLUMN_NAME']};";
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 function upd_alter_table($table, $alters, $condition = true) {
111 111
   global $config, $update_tables;
112 112
 
113
-  if(!$condition) {
113
+  if (!$condition) {
114 114
     return;
115 115
   }
116 116
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
   $alters_print = is_array($alters) ? dump($alters) : $alters;
119 119
   upd_log_message("Altering table '{$table}' with alterations {$alters_print}");
120 120
 
121
-  if(!is_array($alters)) {
121
+  if (!is_array($alters)) {
122 122
     $alters = array($alters);
123 123
   }
124 124
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
   $result = upd_do_query($qry);
130 130
   $error = db_error();
131
-  if($error) {
131
+  if ($error) {
132 132
     die("Altering error for table `{$table}`: {$error}<br />{$alters_print}");
133 133
   }
134 134
 
@@ -155,19 +155,19 @@  discard block
 block discarded – undo
155 155
 function upd_create_table($table_name, $declaration, $tableOptions = '') {
156 156
   global $config, $update_tables;
157 157
 
158
-  if(!$update_tables[$table_name]) {
158
+  if (!$update_tables[$table_name]) {
159 159
     upd_do_query('set foreign_key_checks = 0;', true);
160 160
     $declaration = trim($declaration);
161
-    if(substr($declaration, 0, 1) != '(') {
161
+    if (substr($declaration, 0, 1) != '(') {
162 162
       $declaration = "($declaration)";
163 163
     }
164 164
     $tableOptions = trim($tableOptions);
165
-    if(!empty($tableOptions)) {
165
+    if (!empty($tableOptions)) {
166 166
       $declaration .= $tableOptions;
167 167
     }
168 168
     $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$config->db_prefix}{$table_name}` {$declaration}");
169 169
     $error = db_error();
170
-    if($error) {
170
+    if ($error) {
171 171
       die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration));
172 172
     }
173 173
     upd_do_query('set foreign_key_checks = 1;', true);
@@ -193,14 +193,14 @@  discard block
 block discarded – undo
193 193
 
194 194
 
195 195
 function upd_db_unit_changeset_prepare($unit_id, $unit_value, $user, $planet_id = null) {
196
-  if(!is_array($user)) {
196
+  if (!is_array($user)) {
197 197
     // TODO - remove later
198 198
     print('<h1>СООБЩИТЕ ЭТО АДМИНУ: upd_db_unit_changeset_prepare() - USER is not ARRAY</h1>');
199 199
     pdump(debug_backtrace());
200 200
     die('USER is not ARRAY');
201 201
   }
202 202
 
203
-  if(!isset($user['id']) || !$user['id']) {
203
+  if (!isset($user['id']) || !$user['id']) {
204 204
     // TODO - remove later
205 205
     print('<h1>СООБЩИТЕ ЭТО АДМИНУ: upd_db_unit_changeset_prepare() - USER[id] пустой</h1>');
206 206
     pdump($user);
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
   $db_changeset = array();
217 217
   $temp = upd_db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id');
218
-  if($temp['unit_id']) {
218
+  if ($temp['unit_id']) {
219 219
     // update
220 220
     $db_changeset = array(
221 221
       'action' => SQL_OP_UPDATE,
@@ -261,53 +261,53 @@  discard block
 block discarded – undo
261 261
 
262 262
 
263 263
 function upd_db_changeset_apply($db_changeset) {
264
-  if(!is_array($db_changeset) || empty($db_changeset)) {
264
+  if (!is_array($db_changeset) || empty($db_changeset)) {
265 265
     return;
266 266
   }
267 267
 
268
-  foreach($db_changeset as $table_name => $table_data) {
269
-    foreach($table_data as $record_id => $conditions) {
268
+  foreach ($db_changeset as $table_name => $table_data) {
269
+    foreach ($table_data as $record_id => $conditions) {
270 270
       $where = '';
271
-      if(!empty($conditions['where'])) {
271
+      if (!empty($conditions['where'])) {
272 272
         $where = 'WHERE ' . implode(' AND ', $conditions['where']);
273 273
       }
274 274
 
275 275
       $fields = array();
276
-      if($conditions['fields']) {
277
-        foreach($conditions['fields'] as $field_name => $field_data) {
276
+      if ($conditions['fields']) {
277
+        foreach ($conditions['fields'] as $field_name => $field_data) {
278 278
           $condition = "`{$field_name}` = ";
279 279
           $value = '';
280
-          if($field_data['delta']) {
280
+          if ($field_data['delta']) {
281 281
             $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta'];
282
-          } elseif($field_data['set']) {
283
-            $value = (is_string($field_data['set']) ? "'{$field_data['set']}'": $field_data['set']);
282
+          } elseif ($field_data['set']) {
283
+            $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']);
284 284
           }
285
-          if($value) {
285
+          if ($value) {
286 286
             $fields[] = $condition . $value;
287 287
           }
288 288
         }
289 289
       }
290 290
       $fields = implode(',', $fields);
291 291
 
292
-      switch($conditions['action']) {
292
+      switch ($conditions['action']) {
293 293
         case SQL_OP_DELETE:
294 294
           upd_do_query("DELETE FROM {{{$table_name}}} {$where}");
295 295
           break;
296 296
 
297 297
         case SQL_OP_UPDATE:
298
-          if($fields) {
298
+          if ($fields) {
299 299
             upd_do_query("UPDATE {{{$table_name}}} SET {$fields} {$where}");
300 300
           }
301 301
           break;
302 302
 
303 303
         case SQL_OP_INSERT:
304
-          if($fields) {
304
+          if ($fields) {
305 305
             upd_do_query("INSERT INTO {{{$table_name}}} SET {$fields}");
306 306
           }
307 307
           break;
308 308
 
309 309
         case SQL_OP_REPLACE:
310
-          if($fields) {
310
+          if ($fields) {
311 311
             upd_do_query("REPLACE INTO {{{$table_name}}} SET {$fields}");
312 312
           }
313 313
           break;
Please login to merge, or discard this patch.
includes/includes/flt_mission_transport.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
   $source_planet      = &$mission_data['src_planet'];
15 15
   $destination_planet = &$mission_data['dst_planet'];
16 16
 
17
-  if(!isset($destination_planet['id']) || !$destination_planet['id_owner'])
17
+  if (!isset($destination_planet['id']) || !$destination_planet['id_owner'])
18 18
   {
19 19
     // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;");
20 20
     fleet_send_back($fleet_row);
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
     $destination_planet['name'], uni_render_coordinates_href($fleet_row, 'fleet_end_', 3, ''),
28 28
     $fleet_row['fleet_resource_metal'], $lang['Metal'],
29 29
     $fleet_row['fleet_resource_crystal'], $lang['Crystal'],
30
-    $fleet_row['fleet_resource_deuterium'], $lang['Deuterium'] );
30
+    $fleet_row['fleet_resource_deuterium'], $lang['Deuterium']);
31 31
   msg_send_simple_message($fleet_row['fleet_target_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message);
32 32
 
33
-  if($fleet_row['fleet_target_owner'] <> $fleet_row['fleet_owner'])
33
+  if ($fleet_row['fleet_target_owner'] <> $fleet_row['fleet_owner'])
34 34
   {
35 35
     msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_start_time'], MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message);
36 36
   }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@
 block discarded – undo
8 8
  * @copyright 2008 By Chlorel for XNova
9 9
  */
10 10
 
11
-function flt_mission_transport(&$mission_data)
12
-{
11
+function flt_mission_transport(&$mission_data) {
13 12
   $fleet_row          = &$mission_data['fleet'];
14 13
   $source_planet      = &$mission_data['src_planet'];
15 14
   $destination_planet = &$mission_data['dst_planet'];
Please login to merge, or discard this patch.
index.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,14 +5,14 @@
 block discarded – undo
5 5
  */
6 6
 global $template;
7 7
 
8
-if(isset($sn_page_name) || ($sn_page_name = isset($_GET['page']) ? trim(strip_tags($_GET['page'])) : '')) {
8
+if (isset($sn_page_name) || ($sn_page_name = isset($_GET['page']) ? trim(strip_tags($_GET['page'])) : '')) {
9 9
   require_once('common.' . substr(strrchr(__FILE__, '.'), 1));
10
-  if($sn_page_name) {
10
+  if ($sn_page_name) {
11 11
     // Loading page-specific language files
12 12
 
13 13
     !empty($sn_mvc['model'][$sn_page_name]) and execute_hooks($sn_mvc['model'][$sn_page_name], $template, 'model', $sn_page_name);
14 14
     !empty($sn_mvc['view'][$sn_page_name]) and execute_hooks($sn_mvc['view'][$sn_page_name], $template, 'view', $sn_page_name);
15
-    if(!empty($template_result) && is_object($template)) {
15
+    if (!empty($template_result) && is_object($template)) {
16 16
       $template->assign_recursive($template_result);
17 17
     }
18 18
 
Please login to merge, or discard this patch.
classes/AjaxController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
     define('IN_AJAX', true);
23 23
 
24
-    if(!is_object($template)) {
24
+    if (!is_object($template)) {
25 25
       $template = gettemplate('_ajax', true);
26 26
     }
27 27
 
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
 
38 38
     $mode = sys_get_param_str('mode');
39 39
 
40
-    if(class_exists($className = 'Pages\\Page' . ucfirst($mode))) {
40
+    if (class_exists($className = 'Pages\\Page' . ucfirst($mode))) {
41 41
       /**
42 42
        * @var \Pages\IPage $page
43 43
        */
44 44
       $page = new $className();
45
-      if(method_exists($page, 'loadParams')) {
45
+      if (method_exists($page, 'loadParams')) {
46 46
         $page->loadParams();
47 47
       }
48 48
 
49
-      if(method_exists($page, $action = sys_get_param('action')) && $page->checkAction($action)) {
49
+      if (method_exists($page, $action = sys_get_param('action')) && $page->checkAction($action)) {
50 50
         $result = $page->$action();
51 51
         is_array($result) ? HelperArray::merge($template_result['AJAX'], $result) : false;
52 52
       }
Please login to merge, or discard this patch.