Completed
Push — work-fleets ( 4117d7...03d1ea )
by SuperNova.WS
05:11
created
includes/classes/Player.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
    * @return int|mixed
229 229
    */
230 230
   public function calcColonyMaxCount($astrotech = -1) {
231
-    if($astrotech == -1) {
232
-      if(!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) {
231
+    if ($astrotech == -1) {
232
+      if (!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) {
233 233
 
234 234
         $expeditions = get_player_max_expeditons($this->_dbRow);
235 235
         $astrotech = mrc_get_level($this->_dbRow, null, TECH_ASTROTECH);
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
 
304 304
   public function expeditionsMax() {
305
-    if($this->expeditionsMax === null) {
305
+    if ($this->expeditionsMax === null) {
306 306
       $this->expeditionsMax = get_player_max_expeditons($this->_dbRow);
307 307
     }
308 308
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
   }
311 311
 
312 312
   public function expeditionsFlying() {
313
-    if($this->expeditionsFlying === null) {
313
+    if ($this->expeditionsFlying === null) {
314 314
       $this->expeditionsFlying = FleetList::fleet_count_flying($this->_dbId, MT_EXPLORE);
315 315
     }
316 316
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 
320 320
 
321 321
   public function fleetsMax() {
322
-    if($this->fleetMax === null) {
322
+    if ($this->fleetMax === null) {
323 323
       $this->fleetMax = GetMaxFleets($this->_dbRow);
324 324
     }
325 325
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
   }
328 328
 
329 329
   public function fleetsFlying() {
330
-    if($this->fleetFlying === null) {
330
+    if ($this->fleetFlying === null) {
331 331
       $this->fleetFlying = FleetList::fleet_count_flying($this->_dbId);
332 332
     }
333 333
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 
338 338
   public function coloniesMax() {
339
-    if($this->coloniesMax === null) {
339
+    if ($this->coloniesMax === null) {
340 340
       $this->coloniesMax = get_player_max_colonies($this->_dbRow);
341 341
     }
342 342
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
   }
345 345
 
346 346
   public function coloniesCurrent() {
347
-    if($this->coloniesCurrent === null) {
347
+    if ($this->coloniesCurrent === null) {
348 348
       $this->coloniesCurrent = get_player_current_colonies($this->_dbRow);
349 349
     }
350 350
 
Please login to merge, or discard this patch.
galaxy.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 $uni_system = sys_get_param_int('system', $planetrow['system']);
17 17
 $planet = sys_get_param_int('planet', $planetrow['planet']);
18 18
 
19
-if($mode == 'name') {
19
+if ($mode == 'name') {
20 20
   require_once('includes/includes/uni_rename.php');
21 21
 }
22 22
 
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 
38 38
 $flying_fleet_count = FleetList::fleet_count_flying($user['id']);
39 39
 
40
-if($mode == 1) {
41
-} elseif($mode == 2 || $mode == 3) {
40
+if ($mode == 1) {
41
+} elseif ($mode == 2 || $mode == 3) {
42 42
   $planet = $planetrow['planet'];
43 43
 } else {
44 44
   $uni_galaxy = $planetrow['galaxy'];
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
   $planet = $planetrow['planet'];
47 47
 }
48 48
 
49
-$uni_galaxy = $uni_galaxy < 1 ? 1 : ($uni_galaxy > Vector::$knownGalaxies? Vector::$knownGalaxies: $uni_galaxy);
49
+$uni_galaxy = $uni_galaxy < 1 ? 1 : ($uni_galaxy > Vector::$knownGalaxies ? Vector::$knownGalaxies : $uni_galaxy);
50 50
 $uni_system = $uni_system < 1 ? 1 : ($uni_system > Vector::$knownSystems ? Vector::$knownSystems : $uni_system);
51 51
 $planet = $planet < 1 ? 1 : ($planet > Vector::$knownPlanets + 1 ? Vector::$knownPlanets + 1 : $planet);
52 52
 
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 $PhalanxRange = GetPhalanxRange($HavePhalanx);
65 65
 
66 66
 $planet_precache_query = db_planet_list_in_system($uni_galaxy, $uni_system);
67
-if(!empty($planet_precache_query)) {
68
-  foreach($planet_precache_query as $planet_row) {
67
+if (!empty($planet_precache_query)) {
68
+  foreach ($planet_precache_query as $planet_row) {
69 69
     $planet_list[$planet_row['planet']][$planet_row['planet_type']] = $planet_row;
70 70
   }
71 71
 }
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
  * @var Fleet[][][] $fleet_list
84 84
  */
85 85
 $fleet_list = array();
86
-foreach($system_fleet_list->_container as $objFleetSystem) {
87
-  if(!$objFleetSystem->isReturning()) {
86
+foreach ($system_fleet_list->_container as $objFleetSystem) {
87
+  if (!$objFleetSystem->isReturning()) {
88 88
     $fleet_planet = $objFleetSystem->fleet_end_planet;
89 89
     $fleet_type = $objFleetSystem->fleet_end_type;
90 90
   } else {
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 $recycler_info = array();
100 100
 $planet_recyclers_orbiting = 0;
101 101
 $recyclers_fleet = array();
102
-foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
102
+foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
103 103
   $recycler_info[$recycler_id] = get_ship_data($recycler_id, $user);
104 104
   $recyclers_fleet[$recycler_id] = mrc_get_level($user, $planetrow, $recycler_id);
105 105
   $planet_recyclers_orbiting += $recyclers_fleet[$recycler_id];
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 $fleet_id = 1;
110 110
 $fleets = array();
111 111
 $config_game_max_planet = Vector::$knownPlanets + 1;
112
-for($Planet = 1; $Planet < $config_game_max_planet; $Planet++) {
112
+for ($Planet = 1; $Planet < $config_game_max_planet; $Planet++) {
113 113
   unset($uni_galaxyRowPlanet);
114 114
   unset($uni_galaxyRowMoon);
115 115
   unset($uni_galaxyRowUser);
@@ -119,27 +119,27 @@  discard block
 block discarded – undo
119 119
   $uni_galaxyRowPlanet = $planet_list[$Planet][PT_PLANET];
120 120
 
121 121
   $planet_fleet_id = 0;
122
-  if($uni_galaxyRowPlanet['destruyed']) {
122
+  if ($uni_galaxyRowPlanet['destruyed']) {
123 123
     CheckAbandonPlanetState($uni_galaxyRowPlanet);
124
-  } elseif($uni_galaxyRowPlanet['id']) {
125
-    if($cached['users'][$uni_galaxyRowPlanet['id_owner']]) {
124
+  } elseif ($uni_galaxyRowPlanet['id']) {
125
+    if ($cached['users'][$uni_galaxyRowPlanet['id_owner']]) {
126 126
       $uni_galaxyRowUser = $cached['users'][$uni_galaxyRowPlanet['id_owner']];
127 127
     } else {
128 128
       $uni_galaxyRowUser = db_user_by_id($uni_galaxyRowPlanet['id_owner']);
129 129
       $cached['users'][$uni_galaxyRowUser['id']] = $uni_galaxyRowUser;
130 130
     }
131 131
 
132
-    if(!$uni_galaxyRowUser['id']) {
132
+    if (!$uni_galaxyRowUser['id']) {
133 133
       $debug->warning("Planet '{$uni_galaxyRowPlanet['name']}' [{$uni_galaxy}:{$uni_system}:{$Planet}] has no owner!", 'Userless planet', 503);
134 134
       $uni_galaxyRowPlanet['destruyed'] = SN_TIME_NOW + 60 * 60 * 24;
135 135
       $uni_galaxyRowPlanet['id_owner'] = 0;
136 136
       db_planet_set_by_id($uni_galaxyRowPlanet['id'], "id_owner = 0, destruyed = {$uni_galaxyRowPlanet['destruyed']}");
137 137
     }
138 138
 
139
-    if($uni_galaxyRowUser['id']) {
139
+    if ($uni_galaxyRowUser['id']) {
140 140
       $planetcount++;
141
-      if($uni_galaxyRowUser['ally_id']) {
142
-        if($cached['allies'][$uni_galaxyRowUser['ally_id']]) {
141
+      if ($uni_galaxyRowUser['ally_id']) {
142
+        if ($cached['allies'][$uni_galaxyRowUser['ally_id']]) {
143 143
           $allyquery = $cached['allies'][$uni_galaxyRowUser['ally_id']];
144 144
         } else {
145 145
           $allyquery = db_ally_get_by_id($uni_galaxyRowUser['ally_id']);
@@ -148,19 +148,19 @@  discard block
 block discarded – undo
148 148
       }
149 149
 
150 150
       $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_PLANET]);
151
-      if(!empty($fleets_to_planet['own']['count'])) {
151
+      if (!empty($fleets_to_planet['own']['count'])) {
152 152
         $planet_fleet_id = $fleet_id;
153 153
         $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id);
154 154
         $fleet_id++;
155 155
       }
156 156
 
157 157
       $uni_galaxyRowMoon = $planet_list[$Planet][PT_MOON];
158
-      if($uni_galaxyRowMoon['destruyed']) {
158
+      if ($uni_galaxyRowMoon['destruyed']) {
159 159
         CheckAbandonPlanetState($uni_galaxyRowMoon);
160 160
       } else {
161 161
         $moon_fleet_id = 0;
162 162
         $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_MOON]);
163
-        if(!empty($fleets_to_planet['own']['count'])) {
163
+        if (!empty($fleets_to_planet['own']['count'])) {
164 164
           $moon_fleet_id = $fleet_id;
165 165
           $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id);
166 166
           $fleet_id++;
@@ -171,10 +171,10 @@  discard block
 block discarded – undo
171 171
 
172 172
   $recyclers_incoming_capacity = 0;
173 173
   $uni_galaxyRowPlanet['debris'] = $uni_galaxyRowPlanet['debris_metal'] + $uni_galaxyRowPlanet['debris_crystal'];
174
-  if($uni_galaxyRowPlanet['debris']) {
175
-    if(!empty($fleet_list[$Planet][PT_DEBRIS])) {
176
-      foreach($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) {
177
-        if($objFleetToDebris->playerOwnerId == $user['id']) {
174
+  if ($uni_galaxyRowPlanet['debris']) {
175
+    if (!empty($fleet_list[$Planet][PT_DEBRIS])) {
176
+      foreach ($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) {
177
+        if ($objFleetToDebris->playerOwnerId == $user['id']) {
178 178
           $recyclers_incoming_capacity += $objFleetToDebris->shipsGetCapacityRecyclers($recycler_info);
179 179
         }
180 180
       }
@@ -251,21 +251,21 @@  discard block
 block discarded – undo
251 251
 
252 252
 tpl_assign_fleet($template, $fleets);
253 253
 
254
-foreach(sn_get_groups('defense_active') as $unit_id) {
254
+foreach (sn_get_groups('defense_active') as $unit_id) {
255 255
   $template->assign_block_vars('defense_active', array(
256 256
     'ID'   => $unit_id,
257 257
     'NAME' => classLocale::$lang['tech'][$unit_id],
258 258
   ));
259 259
 }
260 260
 
261
-foreach($cached['users'] as $PlanetUser) {
262
-  if(!$PlanetUser) {
261
+foreach ($cached['users'] as $PlanetUser) {
262
+  if (!$PlanetUser) {
263 263
     continue;
264 264
   }
265 265
 
266 266
   $user_ally = $cached['allies'][$PlanetUser['ally_id']];
267
-  if(isset($user_ally)) {
268
-    if($PlanetUser['id'] == $user_ally['ally_owner']) {
267
+  if (isset($user_ally)) {
268
+    if ($PlanetUser['id'] == $user_ally['ally_owner']) {
269 269
       $user_rank_title = $user_ally['ally_owner_range'];
270 270
     } else {
271 271
       $ally_ranks = explode(';', $user_ally['ranklist']);
@@ -288,8 +288,8 @@  discard block
 block discarded – undo
288 288
   ));
289 289
 }
290 290
 
291
-foreach($cached['allies'] as $PlanetAlly) {
292
-  if($PlanetAlly) {
291
+foreach ($cached['allies'] as $PlanetAlly) {
292
+  if ($PlanetAlly) {
293 293
     $template->assign_block_vars('alliances', array(
294 294
       'ID'      => $PlanetAlly['id'],
295 295
       'NAME_JS' => js_safe_string($PlanetAlly['ally_name']),
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 = 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'] == FLIGHT_ALLOWED) {
163
+  foreach ($planet_list as $planet_id => $planet_data) {
164
+    if ($planet_data['RESULT'] == FLIGHT_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'] = classLocale::$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'] == FLIGHT_ALLOWED) {
172
-      foreach($planet_data['FLEET'] as $unit_id => $amount) {
171
+    if (!empty($planet_data['FLEET']) && $planet_data['RESULT'] == FLIGHT_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'   => classLocale::$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']) : classLocale::$lang['flt_no_fuel'];
187 187
   $template->assign_block_vars('colonies', $planet_data);
188 188
 }
Please login to merge, or discard this patch.
includes/constants.php 1 patch
Spacing   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 
39 39
 // Game type constants starts with GAME_
40 40
 define('GAME_SUPERNOVA', 0);
41
-define('GAME_OGAME'    , 1);
42
-define('GAME_BLITZ'    , 2);
41
+define('GAME_OGAME', 1);
42
+define('GAME_BLITZ', 2);
43 43
 
44 44
 // Date & time range constants
45 45
 define('DATE_FOREVER', 2000000000);
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 define('PERIOD_YEAR', PERIOD_DAY * 365);
53 53
 define('PERIOD_FOREVER', PERIOD_YEAR * 100);
54 54
 
55
-define('PERIOD_MINUTE_2' , PERIOD_MINUTE * 2);
56
-define('PERIOD_MINUTE_3' , PERIOD_MINUTE * 3);
57
-define('PERIOD_MINUTE_5' , PERIOD_MINUTE * 5);
55
+define('PERIOD_MINUTE_2', PERIOD_MINUTE * 2);
56
+define('PERIOD_MINUTE_3', PERIOD_MINUTE * 3);
57
+define('PERIOD_MINUTE_5', PERIOD_MINUTE * 5);
58 58
 define('PERIOD_MINUTE_10', PERIOD_MINUTE * 10);
59
-define('PERIOD_DAY_3'    , PERIOD_DAY * 3);
60
-define('PERIOD_WEEK_2'   , PERIOD_WEEK * 2);
61
-define('PERIOD_MONTH_2'  , PERIOD_MONTH * 2);
62
-define('PERIOD_MONTH_3'  , PERIOD_MONTH * 3);
59
+define('PERIOD_DAY_3', PERIOD_DAY * 3);
60
+define('PERIOD_WEEK_2', PERIOD_WEEK * 2);
61
+define('PERIOD_MONTH_2', PERIOD_MONTH * 2);
62
+define('PERIOD_MONTH_3', PERIOD_MONTH * 3);
63 63
 
64 64
 define('FONT_SIZE_PERCENT_MIN', 56.25);
65 65
 define('FONT_SIZE_PERCENT_DEFAULT', 68.75);
@@ -112,100 +112,100 @@  discard block
 block discarded – undo
112 112
 define('SN_SYS_SEC_CHARS_ALLOWED', 'ABCDEFGHJKLMNPQRSTUVWXYZabcdefghkmnpqrstuvwxyz0123456789');
113 113
 
114 114
 // Mot qui sont interdit a la saisie !
115
-$ListCensure = array ( '/</', '/>/', '/script/i', '/doquery/i', '/http/i', '/javascript/i');
115
+$ListCensure = array('/</', '/>/', '/script/i', '/doquery/i', '/http/i', '/javascript/i');
116 116
 
117 117
 // Confirmation record types
118
-define('CONFIRM_REGISTRATION'  , 1);
118
+define('CONFIRM_REGISTRATION', 1);
119 119
 define('CONFIRM_PASSWORD_RESET', 2);
120
-define('CONFIRM_DELETE'        , 3);
120
+define('CONFIRM_DELETE', 3);
121 121
 
122 122
 define('AFFILIATE_MM_TO_REFERRAL_DM', 2);
123 123
 
124 124
 // Ally diplomacy statuses
125
-define('ALLY_DIPLOMACY_SELF'         , 'self');
126
-define('ALLY_DIPLOMACY_NEUTRAL'      , 'neutral');
127
-define('ALLY_DIPLOMACY_WAR'          , 'war');
128
-define('ALLY_DIPLOMACY_PEACE'        , 'peace');
125
+define('ALLY_DIPLOMACY_SELF', 'self');
126
+define('ALLY_DIPLOMACY_NEUTRAL', 'neutral');
127
+define('ALLY_DIPLOMACY_WAR', 'war');
128
+define('ALLY_DIPLOMACY_PEACE', 'peace');
129 129
 define('ALLY_DIPLOMACY_CONFEDERATION', 'confederation');
130
-define('ALLY_DIPLOMACY_FEDERATION'   , 'federation');
131
-define('ALLY_DIPLOMACY_UNION'        , 'union');
132
-define('ALLY_DIPLOMACY_MASTER'       , 'master');
133
-define('ALLY_DIPLOMACY_SLAVE'        , 'slave');
130
+define('ALLY_DIPLOMACY_FEDERATION', 'federation');
131
+define('ALLY_DIPLOMACY_UNION', 'union');
132
+define('ALLY_DIPLOMACY_MASTER', 'master');
133
+define('ALLY_DIPLOMACY_SLAVE', 'slave');
134 134
 
135 135
 define('ALLY_PROPOSE_SEND', 0);
136 136
 
137 137
 // Quest types
138
-define('QUEST_TYPE_BUILD'   , 1);
138
+define('QUEST_TYPE_BUILD', 1);
139 139
 define('QUEST_TYPE_RESEARCH', 2);
140
-define('QUEST_TYPE_COMBAT'  , 3);
140
+define('QUEST_TYPE_COMBAT', 3);
141 141
 
142
-define('QUEST_STATUS_NOT_STARTED' , 0);
143
-define('QUEST_STATUS_STARTED'     , 1);
144
-define('QUEST_STATUS_COMPLETE'    , 2);
142
+define('QUEST_STATUS_NOT_STARTED', 0);
143
+define('QUEST_STATUS_STARTED', 1);
144
+define('QUEST_STATUS_COMPLETE', 2);
145 145
 
146 146
 // *** Combat-related constants
147 147
 // *** Mission Type constants starts with MT_
148
-define('MT_NONE'     ,  0);
149
-define('MT_ATTACK'   ,  1);
150
-define('MT_ACS'      ,  2);
151
-define('MT_TRANSPORT',  3);
152
-define('MT_RELOCATE' ,  4);
153
-define('MT_HOLD'     ,  5);
154
-define('MT_SPY'      ,  6);
155
-define('MT_COLONIZE' ,  7);
156
-define('MT_RECYCLE'  ,  8);
157
-define('MT_DESTROY'  ,  9);
158
-define('MT_MISSILE'  , 10);
159
-define('MT_EXPLORE'  , 15);
148
+define('MT_NONE', 0);
149
+define('MT_ATTACK', 1);
150
+define('MT_ACS', 2);
151
+define('MT_TRANSPORT', 3);
152
+define('MT_RELOCATE', 4);
153
+define('MT_HOLD', 5);
154
+define('MT_SPY', 6);
155
+define('MT_COLONIZE', 7);
156
+define('MT_RECYCLE', 8);
157
+define('MT_DESTROY', 9);
158
+define('MT_MISSILE', 10);
159
+define('MT_EXPLORE', 15);
160 160
 
161 161
 // *** Planet Target constants starts with PT_
162 162
 define('PT_NONE', 0);
163 163
 define('PT_ALL', 0);
164 164
 define('PT_PLANET', 1);
165 165
 define('PT_DEBRIS', 2);
166
-define('PT_MOON'  , 3);
166
+define('PT_MOON', 3);
167 167
 
168 168
 // *** Unit locations - shows db table where unit belong
169 169
 // Also cache indexes
170
-define('LOC_NONE',    -1);
170
+define('LOC_NONE', -1);
171 171
 define('LOC_UNIVERSE', 0);
172
-define('LOC_PLANET',   1);
173
-define('LOC_DEBRIS',   2); // Translates to `planets` table planet_type = 1, `debris_*` fields
174
-define('LOC_MOON',     3); // Translates to `planets` table planet_type = 3
175
-define('LOC_USER',     4);
176
-define('LOC_FLEET',    5);
177
-define('LOC_ALLY',     6);
178
-define('LOC_UNIT_NUMERIC',     7);
179
-define('LOC_UNIT_LIST',     8);
172
+define('LOC_PLANET', 1);
173
+define('LOC_DEBRIS', 2); // Translates to `planets` table planet_type = 1, `debris_*` fields
174
+define('LOC_MOON', 3); // Translates to `planets` table planet_type = 3
175
+define('LOC_USER', 4);
176
+define('LOC_FLEET', 5);
177
+define('LOC_ALLY', 6);
178
+define('LOC_UNIT_NUMERIC', 7);
179
+define('LOC_UNIT_LIST', 8);
180 180
 
181 181
 // ТОЛЬКО ВНУТРЕНЕЕ!!!
182
-define('LOC_UNIT',    'LOC_UNIT');
183
-define('LOC_QUE',     'LOC_QUE');
184
-define('LOC_LOCATION','LOC_LOCATION');
185
-define('LOC_LOCKS','LOC_LOCKS');
182
+define('LOC_UNIT', 'LOC_UNIT');
183
+define('LOC_QUE', 'LOC_QUE');
184
+define('LOC_LOCATION', 'LOC_LOCATION');
185
+define('LOC_LOCKS', 'LOC_LOCKS');
186 186
 
187 187
 // *** Caching masks
188
-define('CACHE_NOTHING'    ,  0);
189
-define('CACHE_FLEET'      ,  1);
190
-define('CACHE_PLANET'     ,  2);
191
-define('CACHE_USER'       ,  4);
192
-define('CACHE_SOURCE'     ,  8);
188
+define('CACHE_NOTHING', 0);
189
+define('CACHE_FLEET', 1);
190
+define('CACHE_PLANET', 2);
191
+define('CACHE_USER', 4);
192
+define('CACHE_SOURCE', 8);
193 193
 define('CACHE_DESTINATION', 16);
194
-define('CACHE_EVENT'      , 32);
194
+define('CACHE_EVENT', 32);
195 195
 
196
-define('CACHE_USER_SRC'  , CACHE_USER | CACHE_SOURCE);
197
-define('CACHE_USER_DST'  , CACHE_USER | CACHE_DESTINATION);
196
+define('CACHE_USER_SRC', CACHE_USER | CACHE_SOURCE);
197
+define('CACHE_USER_DST', CACHE_USER | CACHE_DESTINATION);
198 198
 define('CACHE_PLANET_SRC', CACHE_PLANET | CACHE_SOURCE);
199 199
 define('CACHE_PLANET_DST', CACHE_PLANET | CACHE_DESTINATION);
200
-define('CACHE_COMBAT'    , CACHE_FLEET | CACHE_PLANET | CACHE_USER | CACHE_SOURCE | CACHE_DESTINATION);
200
+define('CACHE_COMBAT', CACHE_FLEET | CACHE_PLANET | CACHE_USER | CACHE_SOURCE | CACHE_DESTINATION);
201 201
 
202
-define('CACHE_ALL'       , CACHE_FLEET | CACHE_PLANET | CACHE_USER | CACHE_SOURCE | CACHE_DESTINATION | CACHE_EVENT);
202
+define('CACHE_ALL', CACHE_FLEET | CACHE_PLANET | CACHE_USER | CACHE_SOURCE | CACHE_DESTINATION | CACHE_EVENT);
203 203
 
204
-define('CACHE_NONE'      , CACHE_NOTHING); // Alias for me
204
+define('CACHE_NONE', CACHE_NOTHING); // Alias for me
205 205
 
206 206
 // *** Event types
207 207
 define('EVENT_FLEET_ARRIVE', 1);
208
-define('EVENT_FLEET_STAY'  , 2);
208
+define('EVENT_FLEET_STAY', 2);
209 209
 define('EVENT_FLEET_RETURN', 3);
210 210
 
211 211
 // *** Constants for changing DM
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 
259 259
 
260 260
 // Operation error status HARDCODE!
261
-define('ERR_NONE'               , 0); // No error
262
-define('ERR_WARNING'            , 1); // There is warning - something altering normal operation process
263
-define('ERR_ERROR'              , 2); // There is error - something permits operation from process
264
-define('ERR_HACK'               , 4); // Operation is qualified as hack attempt
261
+define('ERR_NONE', 0); // No error
262
+define('ERR_WARNING', 1); // There is warning - something altering normal operation process
263
+define('ERR_ERROR', 2); // There is error - something permits operation from process
264
+define('ERR_HACK', 4); // Operation is qualified as hack attempt
265 265
 // New GLOBAL operation results
266 266
 //define('RESULT_DEFAULT' , 0); // Default result - all went OK or result really doesn't matter
267 267
 //define('RESULT_WARNING' , 1);
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 define('SN_PAYMENT_REQUEST_OK', 0);
282 282
 define('SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT', 1);
283 283
 define('SN_PAYMENT_REQUEST_ERROR_PAYLINK_UNSUPPORTED', 2);
284
-define('SN_PAYMENT_REQUEST_IP_WRONG', 3);  // Неправильный IP входящей системы - обычно хак
284
+define('SN_PAYMENT_REQUEST_IP_WRONG', 3); // Неправильный IP входящей системы - обычно хак
285 285
 define('SN_PAYMENT_REQUEST_COMMAND_UNSUPPORTED', 4); // Неподдерживаемая команда - обычно хак
286 286
 define('SN_PAYMENT_REQUEST_SIGNATURE_INVALID', 5); // Неправильная подпись или не сошлась контрольная сумма - обычно хак
287 287
 define('SN_MODULE_DISABLED', 6); // Модуль отключен // УНИВЕРСАЛЬНЫЙ ОТВЕТ!
@@ -554,16 +554,16 @@  discard block
 block discarded – undo
554 554
 //define('F_DEVICE_ID',     'F_DEVICE_ID');
555 555
 //define('F_DEVICE_CYPHER', 'F_DEVICE_CYPHER');
556 556
 
557
-define('F_PROVIDER_ID',   'F_PROVIDER_ID');
557
+define('F_PROVIDER_ID', 'F_PROVIDER_ID');
558 558
 // define('F_PROVIDER_LIST', 'F_PROVIDER_LIST');
559 559
 
560 560
 define('F_IMPERSONATE_STATUS', 'F_IMPERSONATE_STATUS');
561 561
 define('F_IMPERSONATE_OPERATOR', 'F_IMPERSONATE_OPERATOR');
562 562
 
563
-define('F_LOGIN_STATUS',  'F_LOGIN_STATUS');
563
+define('F_LOGIN_STATUS', 'F_LOGIN_STATUS');
564 564
 define('F_LOGIN_MESSAGE', 'F_LOGIN_MESSAGE');
565 565
 
566
-define('F_PLAYER_REGISTER_STATUS',  'F_PLAYER_REGISTER_STATUS');
566
+define('F_PLAYER_REGISTER_STATUS', 'F_PLAYER_REGISTER_STATUS');
567 567
 define('F_PLAYER_REGISTER_MESSAGE', 'F_PLAYER_REGISTER_MESSAGE');
568 568
 
569 569
 define('F_USER_ID', 'F_USER_ID');
@@ -607,66 +607,66 @@  discard block
 block discarded – undo
607 607
 
608 608
 
609 609
 // Option groups
610
-define('OPT_ALL',      0);
611
-define('OPT_MESSAGE',  1);
610
+define('OPT_ALL', 0);
611
+define('OPT_MESSAGE', 1);
612 612
 define('OPT_UNIVERSE', 2);
613 613
 define('OPT_INTERFACE', 3);
614 614
 
615 615
 // Message classes
616
-define('MSG_TYPE_OUTBOX'   ,  -1);
617
-define('MSG_TYPE_SPY'      ,   0);
618
-define('MSG_TYPE_PLAYER'   ,   1);
619
-define('MSG_TYPE_ALLIANCE' ,   2);
620
-define('MSG_TYPE_COMBAT'   ,   3);
621
-define('MSG_TYPE_RECYCLE'  ,   4);
622
-define('MSG_TYPE_TRANSPORT',   5);
623
-define('MSG_TYPE_ADMIN'    ,   6);
624
-define('MSG_TYPE_EXPLORE'  ,  15);
625
-define('MSG_TYPE_QUE'      ,  99);
626
-define('MSG_TYPE_NEW'      , 100);
616
+define('MSG_TYPE_OUTBOX', -1);
617
+define('MSG_TYPE_SPY', 0);
618
+define('MSG_TYPE_PLAYER', 1);
619
+define('MSG_TYPE_ALLIANCE', 2);
620
+define('MSG_TYPE_COMBAT', 3);
621
+define('MSG_TYPE_RECYCLE', 4);
622
+define('MSG_TYPE_TRANSPORT', 5);
623
+define('MSG_TYPE_ADMIN', 6);
624
+define('MSG_TYPE_EXPLORE', 15);
625
+define('MSG_TYPE_QUE', 99);
626
+define('MSG_TYPE_NEW', 100);
627 627
 
628 628
 // Attack verification statuses
629
-define('FLIGHT_ALLOWED'           ,  0);
630
-define('FLIGHT_VECTOR_NO_TARGET'         ,  1);
631
-define('FLIGHT_PLAYER_OWN'               ,  2);
632
-define('FLIGHT_MISSION_IMPOSSIBLE'     ,  3);
633
-define('FLIGHT_MISSION_HOLD_NO_ALLY_DEPOSIT'   ,  4);
634
-define('FLIGHT_MISSION_RECYCLE_NO_DEBRIS'         ,  5);
635
-define('FLIGHT_PLAYER_VACATION'          ,  6);
636
-define('FLIGHT_PLAYER_SAME_IP'           ,  7);
637
-define('FLIGHT_PLAYER_BUFFING'           ,  8);
638
-define('FLIGHT_PLAYER_ADMIN'             ,  9);
639
-define('FLIGHT_PLAYER_NOOB'              , 10);
640
-define('FLIGHT_PLAYER_VACATION_OWN'      , 11);
641
-define('FLIGHT_MISSION_MISSILE_NO_SILO'           , 12);
642
-define('FLIGHT_MISSION_MISSILE_NO_MISSILES'        , 13);
643
-define('FLIGHT_SHIPS_NO_SHIPS'          , 14);
644
-define('FLIGHT_FLEET_NO_SLOTS'          , 15);
645
-define('FLIGHT_SHIPS_NOT_ENOUGH_OR_RESOURCES'          , 16);
646
-define('FLIGHT_SHIPS_NO_RECYCLERS'      , 17);
647
-define('FLIGHT_MISSION_SPY_NO_SPIES'          , 18);
648
-define('FLIGHT_SHIPS_NO_COLONIZER'      , 19);
649
-define('FLIGHT_MISSION_MISSILE_TOO_FAR'   , 20);
650
-define('FLIGHT_MISSION_MISSILE_WRONG_STRUCTURE'   , 21);
651
-define('FLIGHT_RESOURCES_FUEL_NOT_ENOUGH'           , 22);
652
-define('FLIGHT_RESOURCES_NOT_ENOUGH'      , 23);
653
-define('FLIGHT_MISSION_ACS_NOT_EXISTS'            , 24);
654
-define('FLIGHT_MISSION_ACS_MISSTARGET'    , 25);
655
-define('FLIGHT_FLEET_SPEED_WRONG'       , 26);
656
-define('FLIGHT_MISSION_ACS_TOO_LATE'      , 27);
657
-define('FLIGHT_MISSION_ATTACK_BASHING'           , 28);
658
-define('FLIGHT_MISSION_ATTACK_BASHING_WAR_DELAY' , 29);
659
-define('FLIGHT_MISSION_ACS_WRONG_TARGET'  , 30);
660
-define('FLIGHT_VECTOR_SAME_SOURCE'              , 31);
629
+define('FLIGHT_ALLOWED', 0);
630
+define('FLIGHT_VECTOR_NO_TARGET', 1);
631
+define('FLIGHT_PLAYER_OWN', 2);
632
+define('FLIGHT_MISSION_IMPOSSIBLE', 3);
633
+define('FLIGHT_MISSION_HOLD_NO_ALLY_DEPOSIT', 4);
634
+define('FLIGHT_MISSION_RECYCLE_NO_DEBRIS', 5);
635
+define('FLIGHT_PLAYER_VACATION', 6);
636
+define('FLIGHT_PLAYER_SAME_IP', 7);
637
+define('FLIGHT_PLAYER_BUFFING', 8);
638
+define('FLIGHT_PLAYER_ADMIN', 9);
639
+define('FLIGHT_PLAYER_NOOB', 10);
640
+define('FLIGHT_PLAYER_VACATION_OWN', 11);
641
+define('FLIGHT_MISSION_MISSILE_NO_SILO', 12);
642
+define('FLIGHT_MISSION_MISSILE_NO_MISSILES', 13);
643
+define('FLIGHT_SHIPS_NO_SHIPS', 14);
644
+define('FLIGHT_FLEET_NO_SLOTS', 15);
645
+define('FLIGHT_SHIPS_NOT_ENOUGH_OR_RESOURCES', 16);
646
+define('FLIGHT_SHIPS_NO_RECYCLERS', 17);
647
+define('FLIGHT_MISSION_SPY_NO_SPIES', 18);
648
+define('FLIGHT_SHIPS_NO_COLONIZER', 19);
649
+define('FLIGHT_MISSION_MISSILE_TOO_FAR', 20);
650
+define('FLIGHT_MISSION_MISSILE_WRONG_STRUCTURE', 21);
651
+define('FLIGHT_RESOURCES_FUEL_NOT_ENOUGH', 22);
652
+define('FLIGHT_RESOURCES_NOT_ENOUGH', 23);
653
+define('FLIGHT_MISSION_ACS_NOT_EXISTS', 24);
654
+define('FLIGHT_MISSION_ACS_MISSTARGET', 25);
655
+define('FLIGHT_FLEET_SPEED_WRONG', 26);
656
+define('FLIGHT_MISSION_ACS_TOO_LATE', 27);
657
+define('FLIGHT_MISSION_ATTACK_BASHING', 28);
658
+define('FLIGHT_MISSION_ATTACK_BASHING_WAR_DELAY', 29);
659
+define('FLIGHT_MISSION_ACS_WRONG_TARGET', 30);
660
+define('FLIGHT_VECTOR_SAME_SOURCE', 31);
661 661
 define('FLIGHT_RESOURCES_FORBIDDEN', 32);
662
-define('FLIGHT_RESOURCES_EMPTY'   , 33);
663
-define('FLIGHT_SHIPS_NOT_ONLY_SPIES'       , 34);
664
-define('FLIGHT_FLEET_TOO_FAR'           , 35);
665
-define('FLIGHT_FLEET_OVERLOAD'        , 36);
666
-define('FLIGHT_MISSION_UNKNOWN'    , 37);
667
-define('FLIGHT_SHIPS_UNIT_WRONG'        , 38);
668
-define('FLIGHT_SHIPS_UNMOVABLE'        , 39);
669
-define('FLIGHT_SHIPS_NEGATIVE'  , 40);
662
+define('FLIGHT_RESOURCES_EMPTY', 33);
663
+define('FLIGHT_SHIPS_NOT_ONLY_SPIES', 34);
664
+define('FLIGHT_FLEET_TOO_FAR', 35);
665
+define('FLIGHT_FLEET_OVERLOAD', 36);
666
+define('FLIGHT_MISSION_UNKNOWN', 37);
667
+define('FLIGHT_SHIPS_UNIT_WRONG', 38);
668
+define('FLIGHT_SHIPS_UNMOVABLE', 39);
669
+define('FLIGHT_SHIPS_NEGATIVE', 40);
670 670
 define('FLIGHT_RESOURCES_NEGATIVE', 41);
671 671
 define('FLIGHT_MISSION_MORATORIUM', 42);
672 672
 define('FLIGHT_PLAYER_CHILD_PROTECTION', 43);
@@ -681,12 +681,12 @@  discard block
 block discarded – undo
681 681
 
682 682
 
683 683
 // *** Races - Homeworlds
684
-define('RACE_NONE'    , 0);
685
-define('RACE_EARTH'   , 1);
686
-define('RACE_MOON'    , 2);
687
-define('RACE_MERCURY' , 3);
688
-define('RACE_VENUS'   , 4);
689
-define('RACE_MARS'    , 5);
684
+define('RACE_NONE', 0);
685
+define('RACE_EARTH', 1);
686
+define('RACE_MOON', 2);
687
+define('RACE_MERCURY', 3);
688
+define('RACE_VENUS', 4);
689
+define('RACE_MARS', 5);
690 690
 define('RACE_ASTEROID', 6);
691 691
 // define('MARKET_INFO'         , 7);
692 692
 
@@ -694,114 +694,114 @@  discard block
 block discarded – undo
694 694
 
695 695
 // *** Market variables
696 696
 // === Market blocks
697
-define('MARKET_ENTRY'        , 0);
698
-define('MARKET_RESOURCES'    , 1);
699
-define('MARKET_SCRAPPER'     , 2);
700
-define('MARKET_STOCKMAN'     , 3);
701
-define('MARKET_EXCHANGE'     , 4);
702
-define('MARKET_BANKER'       , 5);
703
-define('MARKET_PAWNSHOP'     , 6);
704
-define('MARKET_INFO'         , 7);
697
+define('MARKET_ENTRY', 0);
698
+define('MARKET_RESOURCES', 1);
699
+define('MARKET_SCRAPPER', 2);
700
+define('MARKET_STOCKMAN', 3);
701
+define('MARKET_EXCHANGE', 4);
702
+define('MARKET_BANKER', 5);
703
+define('MARKET_PAWNSHOP', 6);
704
+define('MARKET_INFO', 7);
705 705
 
706 706
 // === Market error statuses
707
-define('MARKET_NOTHING'              ,  0);
708
-define('MARKET_DEAL'                 ,  1);
709
-define('MARKET_DEAL_TRADE'           ,  2);
710
-define('MARKET_NO_DM'                ,  3);
711
-define('MARKET_NO_RESOURCES'         ,  4);
712
-define('MARKET_ZERO_DEAL'            ,  5);
713
-define('MARKET_NO_SHIPS'             ,  6);
714
-define('MARKET_NOT_A_SHIP'           ,  7);
715
-define('MARKET_NO_STOCK'             ,  8);
716
-define('MARKET_ZERO_RES_STOCK'       ,  9);
717
-define('MARKET_NEGATIVE_SHIPS'       , 10);
718
-
719
-define('MARKET_INFO_PLAYER'          , 12);
720
-define('MARKET_INFO_WRONG'           , 11);
707
+define('MARKET_NOTHING', 0);
708
+define('MARKET_DEAL', 1);
709
+define('MARKET_DEAL_TRADE', 2);
710
+define('MARKET_NO_DM', 3);
711
+define('MARKET_NO_RESOURCES', 4);
712
+define('MARKET_ZERO_DEAL', 5);
713
+define('MARKET_NO_SHIPS', 6);
714
+define('MARKET_NOT_A_SHIP', 7);
715
+define('MARKET_NO_STOCK', 8);
716
+define('MARKET_ZERO_RES_STOCK', 9);
717
+define('MARKET_NEGATIVE_SHIPS', 10);
718
+
719
+define('MARKET_INFO_PLAYER', 12);
720
+define('MARKET_INFO_WRONG', 11);
721 721
 define('MARKET_INFO_PLAYER_NOT_FOUND', 13);
722
-define('MARKET_INFO_PLAYER_WRONG'    , 14);
723
-define('MARKET_INFO_PLAYER_SAME'     , 15);
722
+define('MARKET_INFO_PLAYER_WRONG', 14);
723
+define('MARKET_INFO_PLAYER_SAME', 15);
724 724
 
725 725
 
726 726
 
727 727
 
728 728
 // *** Mercenary/talent bonus types
729
-define('BONUS_NONE'    ,            0);  // No bonus
730
-define('BONUS_PERCENT' ,            1);  // Percent on base value
731
-define('BONUS_ADD'     ,            2);  // Add
732
-define('BONUS_ABILITY' ,            3);  // Some ability
733
-define('BONUS_MULTIPLY',            4);  // Multiply by value
734
-define('BONUS_PERCENT_CUMULATIVE' , 5);  // Cumulative percent on base value
735
-define('BONUS_PERCENT_DEGRADED' ,   6);  // Bonus amount degraded with increase as pow(bonus, level) (?)
736
-define('BONUS_SPEED',               7);  // Speed bonus
729
+define('BONUS_NONE', 0); // No bonus
730
+define('BONUS_PERCENT', 1); // Percent on base value
731
+define('BONUS_ADD', 2); // Add
732
+define('BONUS_ABILITY', 3); // Some ability
733
+define('BONUS_MULTIPLY', 4); // Multiply by value
734
+define('BONUS_PERCENT_CUMULATIVE', 5); // Cumulative percent on base value
735
+define('BONUS_PERCENT_DEGRADED', 6); // Bonus amount degraded with increase as pow(bonus, level) (?)
736
+define('BONUS_SPEED', 7); // Speed bonus
737 737
 
738 738
 // *** Action constant (build should be replaced with ACTION)
739
-define('BUILD_CREATE' ,  1);
739
+define('BUILD_CREATE', 1);
740 740
 define('BUILD_DESTROY', -1);
741 741
 define('BUILD_AUTOCONVERT', 2);
742 742
 
743
-define('ACTION_SELL'       , -1);
744
-define('ACTION_NOTHING'    ,  0);
745
-define('ACTION_BUY'        ,  1);
746
-define('ACTION_USE'        ,  2);
747
-define('ACTION_DELETE'     ,  3);
743
+define('ACTION_SELL', -1);
744
+define('ACTION_NOTHING', 0);
745
+define('ACTION_BUY', 1);
746
+define('ACTION_USE', 2);
747
+define('ACTION_DELETE', 3);
748 748
 
749 749
 // *** Check unit availability codes
750
-define('BUILD_ALLOWED'         , 0); // HARDCODED! DO NOT CHANGE!
750
+define('BUILD_ALLOWED', 0); // HARDCODED! DO NOT CHANGE!
751 751
 define('BUILD_REQUIRE_NOT_MEET', 1);
752
-define('BUILD_AMOUNT_WRONG'    , 2);
753
-define('BUILD_QUE_WRONG'       , 3);
754
-define('BUILD_QUE_UNIT_WRONG'  , 4);
755
-define('BUILD_INDESTRUCTABLE'  , 5);
756
-define('BUILD_NO_RESOURCES'    , 6);
757
-define('BUILD_NO_UNITS'        , 7);
758
-define('BUILD_UNIT_BUSY'       , 8);
759
-define('BUILD_QUE_FULL'        , 9);
760
-define('BUILD_SILO_FULL'       ,10);
761
-define('BUILD_MAX_REACHED'     ,11);
762
-define('BUILD_SECTORS_NONE'    ,12);
752
+define('BUILD_AMOUNT_WRONG', 2);
753
+define('BUILD_QUE_WRONG', 3);
754
+define('BUILD_QUE_UNIT_WRONG', 4);
755
+define('BUILD_INDESTRUCTABLE', 5);
756
+define('BUILD_NO_RESOURCES', 6);
757
+define('BUILD_NO_UNITS', 7);
758
+define('BUILD_UNIT_BUSY', 8);
759
+define('BUILD_QUE_FULL', 9);
760
+define('BUILD_SILO_FULL', 10);
761
+define('BUILD_MAX_REACHED', 11);
762
+define('BUILD_SECTORS_NONE', 12);
763 763
 define('BUILD_AUTOCONVERT_AVAILABLE', 13);
764 764
 
765 765
 
766 766
 // *** Que types
767 767
 define('QUE_STRUCTURES', 1);
768
-define('QUE_HANGAR'    , 4);
769
-define('QUE_RESEARCH'  , 7);
770
-define('QUE_MERCENARY' , 600); // UNIT_MERCENARIES
768
+define('QUE_HANGAR', 4);
769
+define('QUE_RESEARCH', 7);
770
+define('QUE_MERCENARY', 600); // UNIT_MERCENARIES
771 771
 // *** Subque types
772
-define('SUBQUE_PLANET'  , 1);
773
-define('SUBQUE_MOON'    , 3);
774
-define('SUBQUE_FLEET'   , 4);
775
-define('SUBQUE_DEFENSE' , 6);
772
+define('SUBQUE_PLANET', 1);
773
+define('SUBQUE_MOON', 3);
774
+define('SUBQUE_FLEET', 4);
775
+define('SUBQUE_DEFENSE', 6);
776 776
 define('SUBQUE_RESEARCH', 7);
777 777
 
778 778
 // *** Que items
779
-define('QI_UNIT_ID'   , 0);
780
-define('QI_AMOUNT'    , 1);
781
-define('QI_TIME'      , 2);
782
-define('QI_MODE'      , 3);
783
-define('QI_QUE_ID'    , 4);
784
-define('QI_QUE_TYPE'  , 4);
785
-define('QI_PLANET_ID' , 5);
779
+define('QI_UNIT_ID', 0);
780
+define('QI_AMOUNT', 1);
781
+define('QI_TIME', 2);
782
+define('QI_MODE', 3);
783
+define('QI_QUE_ID', 4);
784
+define('QI_QUE_TYPE', 4);
785
+define('QI_PLANET_ID', 5);
786 786
 
787 787
 
788 788
 // *** Units
789 789
 
790 790
 // *** Sort options
791
-define('SORT_ASCENDING' , 0);
791
+define('SORT_ASCENDING', 0);
792 792
 define('SORT_DESCENDING', 1);
793 793
 
794
-define('SORT_ID'             , 0);
795
-define('SORT_LOCATION'       , 1);
796
-define('SORT_NAME'           , 2);
797
-define('SORT_SIZE'           , 3);
798
-define('SORT_EMAIL'          , 4);
799
-define('SORT_IP'             , 5);
794
+define('SORT_ID', 0);
795
+define('SORT_LOCATION', 1);
796
+define('SORT_NAME', 2);
797
+define('SORT_SIZE', 3);
798
+define('SORT_EMAIL', 4);
799
+define('SORT_IP', 5);
800 800
 define('SORT_TIME_REGISTERED', 6);
801 801
 define('SORT_TIME_LAST_VISIT', 7);
802
-define('SORT_TIME_BAN_UNTIL' , 8);
803
-define('SORT_REFERRAL_COUNT' , 9);
804
-define('SORT_REFERRAL_DM'    , 10);
802
+define('SORT_TIME_BAN_UNTIL', 8);
803
+define('SORT_REFERRAL_COUNT', 9);
804
+define('SORT_REFERRAL_DM', 10);
805 805
 
806 806
 
807 807
 define('HULL_SIZE_TINY', 1);
@@ -944,10 +944,10 @@  discard block
 block discarded – undo
944 944
 
945 945
 // === Artifacts
946 946
 define('UNIT_ARTIFACTS', 1000);
947
-define('ART_LHC', 1001);      // Additional moon chance
948
-define('ART_RCD_SMALL', 1002);   // Rapid Colony Deployment - Set of buildings up to 10th level - 10/14/ 3/0 -   405 DM
949
-define('ART_RCD_MEDIUM', 1003);  // Rapid Colony Deployment - Set of buildings up to 15th level - 15/20/ 8/0 -  4704 DM
950
-define('ART_RCD_LARGE', 1004);   // Rapid Colony Deployment - Set of buildings up to 20th level - 20/25/10/1 - 39790 DM
947
+define('ART_LHC', 1001); // Additional moon chance
948
+define('ART_RCD_SMALL', 1002); // Rapid Colony Deployment - Set of buildings up to 10th level - 10/14/ 3/0 -   405 DM
949
+define('ART_RCD_MEDIUM', 1003); // Rapid Colony Deployment - Set of buildings up to 15th level - 15/20/ 8/0 -  4704 DM
950
+define('ART_RCD_LARGE', 1004); // Rapid Colony Deployment - Set of buildings up to 20th level - 20/25/10/1 - 39790 DM
951 951
 define('ART_HEURISTIC_CHIP', 1005); // Speed up research
952 952
 define('ART_NANO_BUILDER', 1006); // Speed up building
953 953
 define('ART_NANO_CONSTRUCTOR', 1007); // RESERVED Speed up hangar constructions
@@ -1018,18 +1018,18 @@  discard block
 block discarded – undo
1018 1018
 define('UNIT_AWARD_MEDAL_BLITZ_R0_PLACE1', 2201); // Блиц-сервер, участник 0-го раунда, 1-е место
1019 1019
 define('UNIT_AWARD_MEDAL_BLITZ_R0_PLACE2', 2202); // Блиц-сервер, участник 0-го раунда, 2-е место
1020 1020
 define('UNIT_AWARD_MEDAL_BLITZ_R0_PLACE3', 2203); // Блиц-сервер, участник 0-го раунда, 3-е место
1021
-define('UNIT_AWARD_MEDAL_2016_WOMEN_DAY_BEST', 2204);  // Медаль Лучшему Кавалеру за максимум потраченной ММ/максимум одаренных женщин Женщине от Мужчины во время ивента 8 марта 2016 года
1021
+define('UNIT_AWARD_MEDAL_2016_WOMEN_DAY_BEST', 2204); // Медаль Лучшему Кавалеру за максимум потраченной ММ/максимум одаренных женщин Женщине от Мужчины во время ивента 8 марта 2016 года
1022 1022
 
1023 1023
 define('UNIT_AWARD_MEMORY', 2300); // Памятные знаки за существование и участие - например "4 года в игре". "Был онлайн в новогоднюю ночь 2013". итд
1024
-define('UNIT_AWARD_MEMORY_IMMORTAL', 2301);  // Бессмертный
1025
-define('UNIT_AWARD_MEMORY_2015_WOMEN_DAY', 2302);  // Значек за подарок Женщине от Мужчины во время ивента 8 марта 2015 года
1024
+define('UNIT_AWARD_MEMORY_IMMORTAL', 2301); // Бессмертный
1025
+define('UNIT_AWARD_MEMORY_2015_WOMEN_DAY', 2302); // Значек за подарок Женщине от Мужчины во время ивента 8 марта 2015 года
1026 1026
 define('UNIT_AWARD_MEMORY_BLITZ_R0', 2303); // Блиц-сервер, участник 0-го раунда
1027 1027
 define('UNIT_AWARD_MEMORY_SUPER_BORN_2015_SIMPLE', 2304); // День Рождения СН
1028 1028
 define('UNIT_AWARD_MEMORY_SUPER_BORN_2015_BRONZE', 2305); // День Рождения СН
1029 1029
 define('UNIT_AWARD_MEMORY_SUPER_BORN_2015_SILVER', 2306); // День Рождения СН
1030 1030
 define('UNIT_AWARD_MEMORY_SUPER_BORN_2015_GOLD', 2307); // День Рождения СН
1031 1031
 define('UNIT_AWARD_MEMORY_SUPER_BORN_2015_PLATINUM', 2308); // День Рождения СН
1032
-define('UNIT_AWARD_MEMORY_2016_WOMEN_DAY', 2309);  // Значек за подарок Женщине от Мужчины во время ивента 8 марта 2016 года
1032
+define('UNIT_AWARD_MEMORY_2016_WOMEN_DAY', 2309); // Значек за подарок Женщине от Мужчины во время ивента 8 марта 2016 года
1033 1033
 
1034 1034
 define('UNIT_AWARD_PENNANT', 2400); // Переходящий вымпел - индикация статуса на сервере: "Топ-1", "Топ", "Сабтоп", "Самый большой флот" итд
1035 1035
 define('UNIT_AWARD_BADGE', 2600); // Бейджики/значки за ачивки - например, "Построил 1000 кораблей"
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 
1127 1127
 define('UNIT_NEXT', 4000); // !!! Next unit start on 4000 !!!
1128 1128
 
1129
-define('GROUP_PART',         800000);
1129
+define('GROUP_PART', 800000);
1130 1130
 // Зарезервировано для запчастей: 800.001 - 899.999
1131 1131
 // define('GROUP_PART_HULL',    801000); // Корпуса - 1000 штук
1132 1132
 // define('GROUP_PART_ARMOR',   802000); // Броня - 1000 штук
@@ -1383,32 +1383,32 @@  discard block
 block discarded – undo
1383 1383
 
1384 1384
 
1385 1385
 // define('NICK_ID',               -1);
1386
-define('NICK_HTML',              0);
1387
-
1388
-define('NICK_FIRST',             1);
1389
-define('NICK_RACE',           1000);
1390
-define('NICK_GENDER',         2000);
1391
-define('NICK_AWARD',          3000);
1392
-define('NICK_VACATION',       3500);
1393
-define('NICK_BIRTHSDAY',      4000);
1394
-define('NICK_PREMIUM',        5000);
1395
-define('NICK_AUTH_LEVEL',     6000);
1396
-
1397
-define('NICK_HIGHLIGHT',      6300);
1398
-define('NICK_CLASS',          6450);
1399
-
1400
-define('NICK_NICK_CLASS',     6600);
1401
-define('NICK_NICK',           7000);
1386
+define('NICK_HTML', 0);
1387
+
1388
+define('NICK_FIRST', 1);
1389
+define('NICK_RACE', 1000);
1390
+define('NICK_GENDER', 2000);
1391
+define('NICK_AWARD', 3000);
1392
+define('NICK_VACATION', 3500);
1393
+define('NICK_BIRTHSDAY', 4000);
1394
+define('NICK_PREMIUM', 5000);
1395
+define('NICK_AUTH_LEVEL', 6000);
1396
+
1397
+define('NICK_HIGHLIGHT', 6300);
1398
+define('NICK_CLASS', 6450);
1399
+
1400
+define('NICK_NICK_CLASS', 6600);
1401
+define('NICK_NICK', 7000);
1402 1402
 define('NICK_NICK_CLASS_END', 7300);
1403 1403
 
1404
-define('NICK_ALLY_CLASS',     7600);
1405
-define('NICK_ALLY',           8000);
1404
+define('NICK_ALLY_CLASS', 7600);
1405
+define('NICK_ALLY', 8000);
1406 1406
 define('NICK_ALLY_CLASS_END', 8300);
1407 1407
 
1408
-define('NICK_CLASS_END',      8450);
1409
-define('NICK_HIGHLIGHT_END',  8600);
1408
+define('NICK_CLASS_END', 8450);
1409
+define('NICK_HIGHLIGHT_END', 8600);
1410 1410
 
1411
-define('NICK_LAST',           9999);
1411
+define('NICK_LAST', 9999);
1412 1412
 
1413 1413
 // Настройки игрока
1414 1414
 define('PLAYER_OPTION_MENU_SORT', 1);
@@ -1501,8 +1501,8 @@  discard block
 block discarded – undo
1501 1501
 define('LOG_ONLIINE_AGGREGATE_PERIOD_MINUTE_10', 1);
1502 1502
 
1503 1503
 define('BLITZ_REGISTER_DISABLED', 0);
1504
-define('BLITZ_REGISTER_OPEN'    , 1);
1505
-define('BLITZ_REGISTER_CLOSED'  , 2);
1504
+define('BLITZ_REGISTER_OPEN', 1);
1505
+define('BLITZ_REGISTER_CLOSED', 2);
1506 1506
 define('BLITZ_REGISTER_SHOW_LOGIN', 3);
1507 1507
 define('BLITZ_REGISTER_DISCLOSURE_NAMES', 4);
1508 1508
 
Please login to merge, or discard this patch.
blitz_register.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@  discard block
 block discarded – undo
2 2
 
3 3
 include('common.' . substr(strrchr(__FILE__, '.'), 1));
4 4
 
5
-if($user['authlevel'] < AUTH_LEVEL_DEVELOPER) {
5
+if ($user['authlevel'] < AUTH_LEVEL_DEVELOPER) {
6 6
   $error_message = classSupernova::$config->game_mode == GAME_BLITZ ? 'sys_blitz_page_disabled' : (
7 7
   !classSupernova::$config->game_blitz_register ? 'sys_blitz_registration_disabled' : ''
8 8
   );
9 9
 
10
-  if($error_message) {
10
+  if ($error_message) {
11 11
     message(classLocale::$lang[$error_message], classLocale::$lang['sys_error'], 'overview.php', 10);
12 12
     die();
13 13
   }
@@ -16,16 +16,16 @@  discard block
 block discarded – undo
16 16
 $current_round = intval(classSupernova::$config->db_loadItem('game_blitz_register_round'));
17 17
 $current_price = intval(classSupernova::$config->db_loadItem('game_blitz_register_price'));
18 18
 
19
-if(classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) {
19
+if (classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) {
20 20
   sn_db_transaction_start();
21 21
   $user = db_user_by_id($user['id'], true);
22 22
   $is_registered = db_blitz_reg_get_id_by_player_and_round($user, $current_round);
23
-  if(sys_get_param_str('register_me')) {
24
-    if(empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) {
23
+  if (sys_get_param_str('register_me')) {
24
+    if (empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) {
25 25
       db_blitz_reg_insert($user, $current_round);
26 26
       classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица");
27 27
     }
28
-  } elseif(sys_get_param_str('register_me_not') && !empty($is_registered)) {
28
+  } elseif (sys_get_param_str('register_me_not') && !empty($is_registered)) {
29 29
     db_blitz_reg_delete($user, $current_round);
30 30
     classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION_CANCEL, $current_price, "Отмена регистрации в раунде {$current_round} Блица");
31 31
   }
@@ -40,17 +40,17 @@  discard block
 block discarded – undo
40 40
 $blitz_players = 0;
41 41
 $blitz_prize_dark_matter = 0;
42 42
 $blitz_prize_places = 0;
43
-if($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) {
44
-  if(sys_get_param_str('generate')) {
43
+if ($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) {
44
+  if (sys_get_param_str('generate')) {
45 45
     $next_id = 0;
46 46
     $query = db_blitz_reg_get_random_id($current_round);
47
-    while($row = db_fetch($query)) {
47
+    while ($row = db_fetch($query)) {
48 48
       $next_id++;
49 49
       $blitz_name = 'Игрок' . $next_id;
50 50
       $blitz_password = sys_random_string(8);
51 51
       db_blitz_reg_update_with_name_and_password($blitz_name, $blitz_password, $row, $current_round);
52 52
     }
53
-  } elseif(sys_get_param_str('import_generated')) {
53
+  } elseif (sys_get_param_str('import_generated')) {
54 54
     // ЭТО НА БЛИЦЕ!!!
55 55
     db_player_list_blitz_delete_players();
56 56
     db_planets_purge();
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     $system = $system_step;
73 73
     $planet = round(Vector::$knownPlanets / 2);
74 74
 
75
-    foreach($imported_string as &$string_data) {
75
+    foreach ($imported_string as &$string_data) {
76 76
       $string_data = explode(',', $string_data);
77 77
       $username_safe = $string_data[0];
78 78
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
       $moon_row = uni_create_moon($galaxy, $system, $planet, $user_new['id'], 30, '', false);
94 94
 
95
-      if(($system += $system_step) >= Vector::$knownSystems) {
95
+      if (($system += $system_step) >= Vector::$knownSystems) {
96 96
         $galaxy++;
97 97
         $system = $system_step;
98 98
       }
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
     classSupernova::$config->db_saveItem('users_amount', classSupernova::$config->users_amount + $new_players);
103 103
     // pdump($imported_string);
104 104
     // generated_string
105
-  } elseif(sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) {
105
+  } elseif (sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) {
106 106
     $blitz_result = explode(';', $blitz_result_string);
107 107
     $blitz_last_update = $blitz_result[0]; // Пока не используется
108 108
     unset($blitz_result[0]);
109
-    foreach($blitz_result as $blitz_result_data) {
109
+    foreach ($blitz_result as $blitz_result_data) {
110 110
       $blitz_result_data = explode(',', $blitz_result_data);
111
-      if(count($blitz_result_data) == 5) {
111
+      if (count($blitz_result_data) == 5) {
112 112
         $blitz_result_data[1] = db_escape($blitz_result_data[1]);
113 113
         db_blitz_reg_update_results($blitz_result_data, $current_round);
114 114
       }
@@ -116,15 +116,15 @@  discard block
 block discarded – undo
116 116
     $blitz_result = array();
117 117
   }
118 118
 
119
-  if(classSupernova::$config->game_mode == GAME_BLITZ) {
119
+  if (classSupernova::$config->game_mode == GAME_BLITZ) {
120 120
     $blitz_result = array(classSupernova::$config->db_loadItem('var_stat_update'));
121 121
     $query = db_player_list_export_blitz_info();
122
-    while($row = db_fetch($query)) {
122
+    while ($row = db_fetch($query)) {
123 123
       $blitz_result[] = "{$row['id']},{$row['username']},{$row['onlinetime']},{$row['total_rank']},{$row['total_points']}";
124 124
     }
125 125
   } else {
126 126
     $query = db_blitz_reg_get_player_list($current_round);
127
-    while($row = db_fetch($query)) {
127
+    while ($row = db_fetch($query)) {
128 128
       $blitz_generated[] = "{$row['blitz_name']},{$row['blitz_password']}";
129 129
       $row['blitz_online'] ? $blitz_prize_players_active++ : false;
130 130
       $blitz_players++;
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
     $blitz_prize_dark_matter = $blitz_prize_players_active * 20000;
133 133
     $blitz_prize_places = ceil($blitz_prize_players_active / 5);
134 134
 
135
-    if(sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) {
135
+    if (sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) {
136 136
       // $blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter');
137 137
       $blitz_prize_places_actual = sys_get_param_int('blitz_prize_places');
138 138
       sn_db_transaction_start();
139 139
       $query = db_blitz_reg_get_player_list_order_by_place($current_round);
140
-      while($row = db_fetch($query)) {
141
-        if(!$row['blitz_place']) {
140
+      while ($row = db_fetch($query)) {
141
+        if (!$row['blitz_place']) {
142 142
           continue;
143 143
         }
144 144
 
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
 
148 148
         $reward = $blitz_prize_dark_matter_actual - $row['blitz_reward_dark_matter'];
149 149
         pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}", $row['id']);
150
-        if($reward) {
150
+        if ($reward) {
151 151
           rpg_points_change($row['user_id'], RPG_BLITZ, $reward, sprintf(
152 152
             classLocale::$lang['sys_blitz_reward_log_message'], $row['blitz_place'], $row['blitz_name']
153 153
           ));
154 154
           db_blitz_reg_update_apply_results($reward, $row, $current_round);
155 155
         }
156 156
 
157
-        if(!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
157
+        if (!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
158 158
           break;
159 159
         }
160 160
       }
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
 
170 170
 $player_registered = false;
171 171
 $query = db_blitz_reg_get_player_list_and_users($current_round);
172
-while($row = db_fetch($query)) {
172
+while ($row = db_fetch($query)) {
173 173
   $tpl_player_data = array(
174 174
     'NAME' => player_nick_render_to_html($row, array('icons' => true, 'color' => true, 'ally' => true)),
175 175
   );
176 176
 
177
-  if(classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) {
177
+  if (classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) {
178 178
     // Вот так хитро, что бы не было не единого шанса попадания на страницу данных об игроках Блиц-сервера до закрытия раунда
179 179
     $tpl_player_data = array_merge($tpl_player_data, array(
180 180
       'ID'                       => $row['id'],
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
   }
188 188
 
189 189
   $template->assign_block_vars('registrations', $tpl_player_data);
190
-  if($row['id'] == $user['id']) {
190
+  if ($row['id'] == $user['id']) {
191 191
     $player_registered = $row;
192 192
   }
193 193
 }
Please login to merge, or discard this patch.
flotenajax.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
   $target_mission = sys_get_param_int('mission');
40 40
   $sn_group_missions = sn_get_groups('missions');
41
-  if(empty($sn_group_missions[$target_mission]['AJAX'])) {
41
+  if (empty($sn_group_missions[$target_mission]['AJAX'])) {
42 42
     die(classLocale::$lang['gs_c00']);
43 43
   }
44 44
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
   );
54 54
   // fleet_ajax now can send fleets only to existing planets/moons
55 55
   // TODO - sending colonization and expeditions in 1 click
56
-  if(!uni_coordinates_valid($target_coord)) {
56
+  if (!uni_coordinates_valid($target_coord)) {
57 57
     die(classLocale::$lang['gs_c02']);
58 58
   }
59 59
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 
65 65
   // TODO - DEADLOCK CAN BE HERE!!!! We should lock SOURCE and TARGET owners in one query
66 66
   $target_row = db_planet_by_vector($target_coord);
67
-  if(empty($target_row)) {
67
+  if (empty($target_row)) {
68 68
     $target_row = $target_coord;
69 69
     $target_row['id_owner'] = 0;
70 70
     // If fleet destination is PT_DEBRIS - then it's actually destination is PT_PLANET // TODO - REMOVE! Debris should be valid DESTINATION planet_type!
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
   }
76 76
 
77 77
   $fleet_array = array();
78
-  switch($target_mission) {
78
+  switch ($target_mission) {
79 79
     case MT_SPY:
80 80
       $fleet_array[SHIP_SPY] = min(mrc_get_level($user, $planetrow, SHIP_SPY), abs(classSupernova::$user_options[PLAYER_OPTION_FLEET_SPY_DEFAULT]));
81 81
       $unit_group = 'flt_spies';
82 82
     break;
83 83
 
84 84
     case MT_RECYCLE:
85
-      foreach(sn_get_groups('flt_recyclers') as $unit_id) {
86
-        if($unit_count = mrc_get_level($user, $planetrow, $unit_id)) {
85
+      foreach (sn_get_groups('flt_recyclers') as $unit_id) {
86
+        if ($unit_count = mrc_get_level($user, $planetrow, $unit_id)) {
87 87
           $fleet_array[$unit_id] = $unit_count;
88 88
         }
89 89
       }
@@ -108,16 +108,16 @@  discard block
 block discarded – undo
108 108
       'target_structure' => $target_structure = sys_get_param_int('structures'),
109 109
     )
110 110
   );
111
-  if($isAttackAllowed != FLIGHT_ALLOWED) {
111
+  if ($isAttackAllowed != FLIGHT_ALLOWED) {
112 112
     die(classLocale::$lang['fl_attack_error'][$isAttackAllowed]);
113 113
   }
114 114
 
115 115
   $db_changeset = array();
116
-  foreach($fleet_array as $unit_id => $unit_count) {
116
+  foreach ($fleet_array as $unit_id => $unit_count) {
117 117
     $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, -$unit_count, $user, $planetrow);
118 118
   }
119 119
 
120
-  if($target_mission == MT_MISSILE) {
120
+  if ($target_mission == MT_MISSILE) {
121 121
     $distance = abs($target_coord['system'] - $planetrow['system']);
122 122
     $duration = round((30 + (60 * $distance)) / flt_server_flight_speed_multiplier());
123 123
     $arrival = SN_TIME_NOW + $duration;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
   } else {
128 128
     $travel_data = flt_travel_data($user, $planetrow, $target_coord, $fleet_array, 10);
129 129
 
130
-    if($planetrow['deuterium'] < $travel_data['consumption']) {
130
+    if ($planetrow['deuterium'] < $travel_data['consumption']) {
131 131
       die(classLocale::$lang['gs_c13']);
132 132
     }
133 133
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
   $ships_sent = array();
150 150
   $ships_sent_js = 0;
151
-  foreach($fleet_array as $unit_id => $unit_count) {
151
+  foreach ($fleet_array as $unit_id => $unit_count) {
152 152
     $ships_sent[] = "{$unit_count} {$classLocale['tech'][$unit_id]}";
153 153
     $ships_sent_js += mrc_get_level($user, $planetrow, $unit_id, false, true);
154 154
   }
Please login to merge, or discard this patch.
includes/classes/UnitList.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -324,6 +324,10 @@
 block discarded – undo
324 324
    * @return int|mixed
325 325
    */
326 326
   // TODO - REDO!!!!
327
+
328
+  /**
329
+   * @return double
330
+   */
327 331
   function flt_fleet_speed($user) {
328 332
     $speeds = array();
329 333
     if(!empty($this->mapUnitIdToDb)) {
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
    * @param Unit  $value
89 89
    */
90 90
   public function offsetSet($offset, $value) {
91
-    if(isset($this->mapUnitIdToDb[$value->unitId])) {
91
+    if (isset($this->mapUnitIdToDb[$value->unitId])) {
92 92
       classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId ' . $value->unitId . ' already exists');
93 93
     }
94 94
     $this->mapUnitIdToDb[$value->unitId] = $value;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
   }
97 97
 
98 98
   public function offsetUnset($offset) {
99
-    if(!empty($this[$offset]->unitId)) {
99
+    if (!empty($this[$offset]->unitId)) {
100 100
 //      $unit_id = $this[$offset]->unitId;
101 101
 //      $this->mapUnitIdToDb[$unit_id] = null;
102 102
 //      unset($this->mapUnitIdToDb[$unit_id]);
@@ -117,20 +117,20 @@  discard block
 block discarded – undo
117 117
   public function dbLoad($dbId, $lockSkip = false) {
118 118
 //    $this->_reset();
119 119
 
120
-    if($dbId <= 0) {
120
+    if ($dbId <= 0) {
121 121
       return;
122 122
     }
123 123
 
124
-    if(!is_object($this->locatedAt)) {
124
+    if (!is_object($this->locatedAt)) {
125 125
       classSupernova::$debug->error('UnitList::dbLoad have no locatedAt field set');
126 126
     }
127 127
 
128 128
     $unit_array = classSupernova::db_get_unit_list_by_location(0, $this->getLocationType(), $this->getLocationDbId());
129
-    if(!is_array($unit_array)) {
129
+    if (!is_array($unit_array)) {
130 130
       return;
131 131
     }
132 132
 
133
-    foreach($unit_array as $unit_db_row) {
133
+    foreach ($unit_array as $unit_db_row) {
134 134
       $unit = $this->_createElement();
135 135
       $unit->dbRowParse($unit_db_row);
136 136
 
@@ -145,25 +145,25 @@  discard block
 block discarded – undo
145 145
   }
146 146
 
147 147
   public function dbSave() {
148
-    if(!is_object($this->locatedAt)) {
148
+    if (!is_object($this->locatedAt)) {
149 149
       classSupernova::$debug->error('UnitList::dbSave have no locatedAt field set');
150 150
     }
151 151
 
152
-    foreach($this->mapUnitIdToDb as $unit) {
152
+    foreach ($this->mapUnitIdToDb as $unit) {
153 153
       $unit_db_id = $unit->dbId;
154 154
       $unit->dbSave();
155 155
 
156
-      if($unit->isEmpty()) {
156
+      if ($unit->isEmpty()) {
157 157
         // Removing unit object
158 158
         // TODO - change when there will be common bus for all objects
159 159
         // ...or should I? If COUNT is empty - it means that object does not exists in DB. So it should be deleted from PHP memory and cache too
160 160
         unset($this[$unit_db_id]);
161 161
       } else {
162
-        if($unit->dbId <= 0) {
162
+        if ($unit->dbId <= 0) {
163 163
           classSupernova::$debug->error('Error writing unit to DB');
164 164
         }
165 165
         // If unit is new then putting unit object to container
166
-        if(empty($this->_container[$unit->dbId])) {
166
+        if (empty($this->_container[$unit->dbId])) {
167 167
           $this->_container[$unit->dbId] = $unit;
168 168
         }
169 169
       }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
   }
202 202
 
203 203
   public function unitGetCount($unit_id) {
204
-    if(empty($this->mapUnitIdToDb[$unit_id])) {
204
+    if (empty($this->mapUnitIdToDb[$unit_id])) {
205 205
       throw new Exception('Unit [' . $unit_id . '] is not exists in UnitList');
206 206
     }
207 207
     return $this->mapUnitIdToDb[$unit_id]->count;
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
    * @param bool $replace_value
217 217
    */
218 218
   public function unitAdjustCount($unit_id, $unit_count = 0, $replace_value = false) {
219
-    if(empty($this->mapUnitIdToDb[$unit_id])) {
219
+    if (empty($this->mapUnitIdToDb[$unit_id])) {
220 220
       // If unit not exists - creating one and setting all attributes
221 221
       $this->mapUnitIdToDb[$unit_id] = $this->_createElement();
222 222
       $this->mapUnitIdToDb[$unit_id]->setUnitId($unit_id);
223 223
       $this->mapUnitIdToDb[$unit_id]->setLocatedAt($this);
224 224
     }
225 225
 
226
-    if($replace_value) {
226
+    if ($replace_value) {
227 227
       $this->mapUnitIdToDb[$unit_id]->count = $unit_count;
228 228
     } else {
229 229
       $this->mapUnitIdToDb[$unit_id]->adjustCount($unit_count);
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
    */
238 238
   public function unitsGetArray() {
239 239
     $result = array();
240
-    foreach($this->mapUnitIdToDb as $unit) {
240
+    foreach ($this->mapUnitIdToDb as $unit) {
241 241
       $result[$unit->unitId] = $unit->count;
242 242
     }
243 243
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
   }
246 246
 
247 247
   public function unitsCountApplyLossMultiplier($ships_lost_multiplier) {
248
-    foreach($this->mapUnitIdToDb as $unit_id => $unit) {
248
+    foreach ($this->mapUnitIdToDb as $unit_id => $unit) {
249 249
       $unit->count = floor($unit->count * $ships_lost_multiplier);
250 250
     }
251 251
   }
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 
268 268
   public function unitsPropertySumById($unit_id = 0, $propertyName = 'count') {
269 269
     $result = 0;
270
-    foreach($this->mapUnitIdToDb as $unit) {
271
-      if(!$unit_id || $unit->unitId == $unit_id) {
270
+    foreach ($this->mapUnitIdToDb as $unit) {
271
+      if (!$unit_id || $unit->unitId == $unit_id) {
272 272
         $result += $unit->$propertyName;
273 273
       }
274 274
     }
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
   // TODO - WRONG FOR STRUCTURES
285 285
   public function shipsPoolPropertySumById($unit_id = 0, $propertyName = 'count') {
286 286
     $result = 0;
287
-    foreach($this->mapUnitIdToDb as $unit) {
288
-      if(!$unit_id || $unit->unitId == $unit_id) {
287
+    foreach ($this->mapUnitIdToDb as $unit) {
288
+      if (!$unit_id || $unit->unitId == $unit_id) {
289 289
         $result += $unit->$propertyName * $unit->count;
290 290
       }
291 291
     }
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
 
296 296
   public function shipsIsEnoughOnPlanet($dbPlanetRow) {
297 297
     $player = null;
298
-    foreach($this->mapUnitIdToDb as $unitId => $unit) {
299
-      if($unit->count < mrc_get_level($player, $dbPlanetRow, $unit->unitId)) {
298
+    foreach ($this->mapUnitIdToDb as $unitId => $unit) {
299
+      if ($unit->count < mrc_get_level($player, $dbPlanetRow, $unit->unitId)) {
300 300
         return false;
301 301
       }
302 302
     }
@@ -313,15 +313,15 @@  discard block
 block discarded – undo
313 313
      * @var Fleet $objFleet
314 314
      */
315 315
     $objFleet = $this->getLocatedAt();
316
-    if(empty($objFleet)) {
316
+    if (empty($objFleet)) {
317 317
       throw new Exception('No fleet owner on UnitList::unitsRender() in ' . __FILE__ . '@' . __LINE__);
318 318
     }
319 319
 
320 320
     $tplShips = array();
321
-    foreach($this->mapUnitIdToDb as $unit) {
321
+    foreach ($this->mapUnitIdToDb as $unit) {
322 322
       $ship_id = $unit->unitId;
323 323
       $ship_count = $unit->count;
324
-      if(!UnitShip::is_in_group($ship_id) || $ship_count <= 0) {
324
+      if (!UnitShip::is_in_group($ship_id) || $ship_count <= 0) {
325 325
         continue;
326 326
       }
327 327
 
@@ -349,9 +349,9 @@  discard block
 block discarded – undo
349 349
   // TODO - REDO!!!!
350 350
   public function shipsSpeedMin($user) {
351 351
     $speeds = array();
352
-    if(!empty($this->mapUnitIdToDb)) {
353
-      foreach($this->mapUnitIdToDb as $ship_id => $unit) {
354
-        if($unit->getCount() > 0 && in_array($unit->unitId, sn_get_groups(array('fleet', 'missile')))) {
352
+    if (!empty($this->mapUnitIdToDb)) {
353
+      foreach ($this->mapUnitIdToDb as $ship_id => $unit) {
354
+        if ($unit->getCount() > 0 && in_array($unit->unitId, sn_get_groups(array('fleet', 'missile')))) {
355 355
           $single_ship_data = get_ship_data($unit->unitId, $user);
356 356
           $speeds[] = $single_ship_data['speed'];
357 357
         }
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
     $fleet_speed = $this->shipsSpeedMin($dbOwnerRow);
375 375
     $real_speed = $speed_percent * sqrt($fleet_speed);
376 376
 
377
-    if($fleet_speed && $game_fleet_speed) {
377
+    if ($fleet_speed && $game_fleet_speed) {
378 378
       $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed));
379 379
 
380
-      foreach($this->mapUnitIdToDb as $ship_id => $unit) {
381
-        if(!$unit->unitId || $unit->getCount() <= 0) {
380
+      foreach ($this->mapUnitIdToDb as $ship_id => $unit) {
381
+        if (!$unit->unitId || $unit->getCount() <= 0) {
382 382
           continue;
383 383
         }
384 384
 
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
    * @return bool
410 410
    */
411 411
   public function unitsInGroup($group) {
412
-    foreach($this->mapUnitIdToDb as $unitId => $unit) {
413
-      if(!in_array($unitId, $group)) {
412
+    foreach ($this->mapUnitIdToDb as $unitId => $unit) {
413
+      if (!in_array($unitId, $group)) {
414 414
         return false;
415 415
       }
416 416
     }
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
   }
420 420
 
421 421
   public function unitsIsAllMovable($dbOwnerRow) {
422
-    foreach($this->mapUnitIdToDb as $unitId => $unit) {
422
+    foreach ($this->mapUnitIdToDb as $unitId => $unit) {
423 423
       $single_ship_data = get_ship_data($unit->unitId, $dbOwnerRow);
424
-      if($single_ship_data['speed'] <= 0) {
424
+      if ($single_ship_data['speed'] <= 0) {
425 425
         return false;
426 426
       }
427 427
     }
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
   }
431 431
 
432 432
   public function unitsPositive() {
433
-    foreach($this->mapUnitIdToDb as $unitId => $unit) {
434
-      if($unit->count < 1) {
433
+    foreach ($this->mapUnitIdToDb as $unitId => $unit) {
434
+      if ($unit->count < 1) {
435 435
         return false;
436 436
       }
437 437
     }
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 
492 492
     print('</tr>');
493 493
 
494
-    foreach($this->mapUnitIdToDb as $unit) {
494
+    foreach ($this->mapUnitIdToDb as $unit) {
495 495
       print('<tr>');
496 496
 
497 497
       print('<td>');
@@ -540,12 +540,12 @@  discard block
 block discarded – undo
540 540
     print('</table>');
541 541
   }
542 542
   public function unitZeroDbId() {
543
-    foreach($this->mapUnitIdToDb as $unit) {
543
+    foreach ($this->mapUnitIdToDb as $unit) {
544 544
       $unit->zeroDbId();
545 545
     }
546 546
   }
547 547
   public function unitZeroCount() {
548
-    foreach($this->mapUnitIdToDb as $unit) {
548
+    foreach ($this->mapUnitIdToDb as $unit) {
549 549
       $unit->count = 0;
550 550
     }
551 551
   }
Please login to merge, or discard this patch.
includes/general.php 2 patches
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -14,24 +14,24 @@  discard block
 block discarded – undo
14 14
 function sn_function_call($func_name, $func_arg = array()) {
15 15
   // All data in classSupernova::$functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>')
16 16
 
17
-  if(is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) {
17
+  if (is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) {
18 18
     // Chain-callable functions should be made as following:
19 19
     // 1. Never use incomplete calls with parameters "by default"
20 20
     // 2. Reserve last parameter for cumulative result
21 21
     // 3. Use same format for original value and cumulative result (if there is original value)
22 22
     // 4. Honor cumulative result
23 23
     // 5. Return cumulative result
24
-    foreach(classSupernova::$functions[$func_name] as $func_chain_name) {
24
+    foreach (classSupernova::$functions[$func_name] as $func_chain_name) {
25 25
       // По идее - это уже тут не нужно, потому что оно все должно быть callable к этому моменту
26 26
       // Но для старых модулей...
27
-      if(is_callable($func_chain_name)) {
27
+      if (is_callable($func_chain_name)) {
28 28
         $result = call_user_func_array($func_chain_name, $func_arg);
29 29
       }
30 30
     }
31 31
   } else {
32 32
     // TODO: This is left for backward compatibility. Appropriate code should be rewrote!
33 33
     $func_name = isset(classSupernova::$functions[$func_name]) && is_callable(classSupernova::$functions[$func_name]) ? classSupernova::$functions[$func_name] : ('sn_' . $func_name);
34
-    if(is_callable($func_name)) {
34
+    if (is_callable($func_name)) {
35 35
       $result = call_user_func_array($func_name, $func_arg);
36 36
     }
37 37
   }
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
  * @param string $page_name - имя страницы, для которого должен был быть выполнен хук
47 47
  */
48 48
 function execute_hooks(&$hook_list, &$template, $hook_type = null, $page_name = null) {
49
-  if(!empty($hook_list)) {
50
-    foreach($hook_list as $hook) {
51
-      if(is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) {
49
+  if (!empty($hook_list)) {
50
+    foreach ($hook_list as $hook) {
51
+      if (is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) {
52 52
         $template = call_user_func($hook_call, $template, $hook_type, $page_name);
53 53
       }
54 54
     }
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
  */
148 148
 function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) {
149 149
   $n = floatval($n);
150
-  if(is_int($floor)) {
150
+  if (is_int($floor)) {
151 151
     $n = round($n, $floor); // , PHP_ROUND_HALF_DOWN
152
-  } elseif($floor === true) {
152
+  } elseif ($floor === true) {
153 153
     $n = floor($n);
154 154
     $floor = 0;
155 155
   } else {
@@ -159,14 +159,14 @@  discard block
 block discarded – undo
159 159
   $ret = $n;
160 160
 
161 161
   $suffix = '';
162
-  if($limit) {
163
-    if($ret > 0) {
164
-      while($ret > $limit) {
162
+  if ($limit) {
163
+    if ($ret > 0) {
164
+      while ($ret > $limit) {
165 165
         $suffix .= 'k';
166 166
         $ret = round($ret / 1000);
167 167
       }
168 168
     } else {
169
-      while($ret < -$limit) {
169
+      while ($ret < -$limit) {
170 170
         $suffix .= 'k';
171 171
         $ret = round($ret / 1000);
172 172
       }
@@ -176,16 +176,16 @@  discard block
 block discarded – undo
176 176
   $ret = number_format($ret, $floor, ',', '.');
177 177
   $ret .= $suffix;
178 178
 
179
-  if($color !== false) {
180
-    if($color === true) {
179
+  if ($color !== false) {
180
+    if ($color === true) {
181 181
       $class = $n == 0 ? 'zero' : ($n > 0 ? 'positive' : 'negative');
182
-    } elseif($color >= 0) {
182
+    } elseif ($color >= 0) {
183 183
       $class = $n == $color ? 'zero' : ($n < $color ? 'positive' : 'negative');
184 184
     } else {
185 185
       $class = ($n == -$color) ? 'zero' : ($n < -$color ? 'negative' : 'positive');
186 186
     }
187 187
 
188
-    if(!isset($style)) {
188
+    if (!isset($style)) {
189 189
       $ret = "<span class='{$class}'>{$ret}</span>";
190 190
     } else {
191 191
       $ret = $style ? $ret = $class : $ret = array('text' => $ret, 'class' => $class);
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
 
315 315
 function sys_get_param_phone($param_name, $default = '') {
316 316
   $phone_raw = sys_get_param_str_unsafe($param_name, $default = '');
317
-  if($phone_raw) {
317
+  if ($phone_raw) {
318 318
     $phone = $phone_raw[0] == '+' ? '+' : '';
319
-    for($i = 0; $i < strlen($phone_raw); $i++) {
319
+    for ($i = 0; $i < strlen($phone_raw); $i++) {
320 320
       $ord = ord($phone_raw[$i]);
321
-      if($ord >= 48 && $ord <= 57) {
321
+      if ($ord >= 48 && $ord <= 57) {
322 322
         $phone .= $phone_raw[$i];
323 323
       }
324 324
     }
@@ -335,14 +335,14 @@  discard block
 block discarded – undo
335 335
 }
336 336
 
337 337
 function CheckAbandonPlanetState(&$planet) {
338
-  if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) {
338
+  if ($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) {
339 339
     db_planet_delete_by_id($planet['id']);
340 340
   }
341 341
 }
342 342
 
343 343
 function eco_get_total_cost($unit_id, $unit_level) {
344 344
   static $rate, $sn_group_resources_all, $sn_group_resources_loot;
345
-  if(!$rate) {
345
+  if (!$rate) {
346 346
     $sn_group_resources_all = sn_get_groups('resources_all');
347 347
     $sn_group_resources_loot = sn_get_groups('resources_loot');
348 348
 
@@ -352,19 +352,19 @@  discard block
 block discarded – undo
352 352
   }
353 353
 
354 354
   $unit_cost_data = get_unit_param($unit_id, 'cost');
355
-  if(!is_array($unit_cost_data)) {
355
+  if (!is_array($unit_cost_data)) {
356 356
     return array('total' => 0);
357 357
   }
358 358
   $factor = isset($unit_cost_data['factor']) ? $unit_cost_data['factor'] : 1;
359 359
   $cost_array = array(BUILD_CREATE => array(), 'total' => 0);
360 360
   $unit_level = $unit_level > 0 ? $unit_level : 0;
361
-  foreach($unit_cost_data as $resource_id => $resource_amount) {
362
-    if(!in_array($resource_id, $sn_group_resources_all)) {
361
+  foreach ($unit_cost_data as $resource_id => $resource_amount) {
362
+    if (!in_array($resource_id, $sn_group_resources_all)) {
363 363
       continue;
364 364
     }
365 365
 //    $cost_array[BUILD_CREATE][$resource_id] = $resource_amount * ($factor == 1 ? $unit_level : ((pow($factor, $unit_level) - $factor) / ($factor - 1)));
366 366
     $cost_array[BUILD_CREATE][$resource_id] = round($resource_amount * ($factor == 1 ? $unit_level : ((1 - pow($factor, $unit_level)) / (1 - $factor))));
367
-    if(in_array($resource_id, $sn_group_resources_loot)) {
367
+    if (in_array($resource_id, $sn_group_resources_loot)) {
368 368
       $cost_array['total'] += $cost_array[BUILD_CREATE][$resource_id] * $rate[$resource_id];
369 369
     }
370 370
   }
@@ -448,19 +448,19 @@  discard block
 block discarded – undo
448 448
   $mercenary_level = 0;
449 449
   $unit_db_name = pname_resource_name($unit_id);
450 450
 
451
-  if(in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) {
451
+  if (in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) {
452 452
     $unit = classSupernova::db_get_unit_by_location($user['id'], LOC_USER, $user['id'], $unit_id);
453 453
     $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0;
454
-  } elseif(in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) {
454
+  } elseif (in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) {
455 455
     $unit = classSupernova::db_get_unit_by_location(is_array($user) ? $user['id'] : $planet['id_owner'], LOC_PLANET, $planet['id'], $unit_id);
456 456
     $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0;
457
-  } elseif(in_array($unit_id, sn_get_groups('governors'))) {
457
+  } elseif (in_array($unit_id, sn_get_groups('governors'))) {
458 458
     $mercenary_level = $unit_id == $planet['PLANET_GOVERNOR_ID'] ? $planet['PLANET_GOVERNOR_LEVEL'] : 0;
459
-  } elseif($unit_id == RES_DARK_MATTER) {
459
+  } elseif ($unit_id == RES_DARK_MATTER) {
460 460
     $mercenary_level = $user[$unit_db_name] + ($plain || $user['user_as_ally'] ? 0 : classSupernova::$auth->account->account_metamatter);
461
-  } elseif($unit_id == RES_METAMATTER) {
461
+  } elseif ($unit_id == RES_METAMATTER) {
462 462
     $mercenary_level = classSupernova::$auth->account->account_metamatter; //$user[$unit_db_name];
463
-  } elseif(in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) {
463
+  } elseif (in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) {
464 464
     $mercenary_level = !empty($planet) ? $planet[$unit_db_name] : $user[$unit_db_name];
465 465
   }
466 466
 
@@ -470,19 +470,19 @@  discard block
 block discarded – undo
470 470
 function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) { return sn_function_call(__FUNCTION__, array(&$user, $planet, $mercenaries, $value)); }
471 471
 
472 472
 function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) {
473
-  if(!is_array($mercenaries)) {
473
+  if (!is_array($mercenaries)) {
474 474
     $mercenaries = array($mercenaries);
475 475
   }
476 476
 
477 477
   $base_value = isset($base_value) ? $base_value : $value;
478 478
 
479
-  foreach($mercenaries as $mercenary_id) {
479
+  foreach ($mercenaries as $mercenary_id) {
480 480
     $mercenary_level = mrc_get_level($user, $planet, $mercenary_id);
481 481
 
482 482
     $mercenary = get_unit_param($mercenary_id);
483 483
     $mercenary_bonus = $mercenary['bonus'];
484 484
 
485
-    switch($mercenary['bonus_type']) {
485
+    switch ($mercenary['bonus_type']) {
486 486
       case BONUS_PERCENT_CUMULATIVE:
487 487
         $value *= 1 + $mercenary_level * $mercenary_bonus / 100;
488 488
       break;
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
   $allowed_length = strlen($allowed_chars);
514 514
 
515 515
   $random_string = '';
516
-  for($i = 0; $i < $length; $i++) {
516
+  for ($i = 0; $i < $length; $i++) {
517 517
     $random_string .= $allowed_chars[mt_rand(0, $allowed_length - 1)];
518 518
   }
519 519
 
@@ -533,12 +533,12 @@  discard block
 block discarded – undo
533 533
 
534 534
   $options = '';
535 535
   $option_list = array();
536
-  foreach($user_option_list as $option_group_id => $option_group) {
536
+  foreach ($user_option_list as $option_group_id => $option_group) {
537 537
     $option_list[$option_group_id] = array();
538
-    foreach($option_group as $option_name => $option_value) {
539
-      if(!isset($user[$option_name])) {
538
+    foreach ($option_group as $option_name => $option_value) {
539
+      if (!isset($user[$option_name])) {
540 540
         $user[$option_name] = $option_value;
541
-      } elseif($user[$option_name] == '') {
541
+      } elseif ($user[$option_name] == '') {
542 542
         $user[$option_name] = 0;
543 543
       }
544 544
       $options .= "{$option_name}^{$user[$option_name]}|";
@@ -558,16 +558,16 @@  discard block
 block discarded – undo
558 558
   $option_list = array();
559 559
   $option_string_list = explode('|', $user['options']);
560 560
 
561
-  foreach($option_string_list as $option_string) {
561
+  foreach ($option_string_list as $option_string) {
562 562
     list($option_name, $option_value) = explode('^', $option_string);
563 563
     $option_list[$option_name] = $option_value;
564 564
   }
565 565
 
566 566
   $final_list = array();
567
-  foreach($user_option_list as $option_group_id => $option_group) {
567
+  foreach ($user_option_list as $option_group_id => $option_group) {
568 568
     $final_list[$option_group_id] = array();
569
-    foreach($option_group as $option_name => $option_value) {
570
-      if(!isset($option_list[$option_name])) {
569
+    foreach ($option_group as $option_name => $option_value) {
570
+      if (!isset($option_list[$option_name])) {
571 571
         $option_list[$option_name] = $option_value;
572 572
       }
573 573
       $user[$option_name] = $final_list[$option_group_id][$option_name] = $option_list[$option_name];
@@ -581,12 +581,12 @@  discard block
 block discarded – undo
581 581
 
582 582
 function sys_unit_str2arr($fleet_string) {
583 583
   $fleet_array = array();
584
-  if(!empty($fleet_string)) {
584
+  if (!empty($fleet_string)) {
585 585
     $arrTemp = explode(';', $fleet_string);
586
-    foreach($arrTemp as $temp) {
587
-      if($temp) {
586
+    foreach ($arrTemp as $temp) {
587
+      if ($temp) {
588 588
         $temp = explode(',', $temp);
589
-        if(!empty($temp[0]) && !empty($temp[1])) {
589
+        if (!empty($temp[0]) && !empty($temp[1])) {
590 590
           $fleet_array[$temp[0]] += $temp[1];
591 591
         }
592 592
       }
@@ -598,13 +598,13 @@  discard block
 block discarded – undo
598 598
 
599 599
 function sys_unit_arr2str($unit_list) {
600 600
   $fleet_string = array();
601
-  if(isset($unit_list)) {
602
-    if(!is_array($unit_list)) {
601
+  if (isset($unit_list)) {
602
+    if (!is_array($unit_list)) {
603 603
       $unit_list = array($unit_list => 1);
604 604
     }
605 605
 
606
-    foreach($unit_list as $unit_id => $unit_count) {
607
-      if($unit_id && $unit_count) {
606
+    foreach ($unit_list as $unit_id => $unit_count) {
607
+      if ($unit_id && $unit_count) {
608 608
         $fleet_string[] = "{$unit_id},{$unit_count}";
609 609
       }
610 610
     }
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
   $body = str_replace("\r\n", "\n", $body);
631 631
   $body = str_replace("\n", "\r\n", $body);
632 632
 
633
-  if($html) {
633
+  if ($html) {
634 634
     $body = '<html><head><base href="' . SN_ROOT_VIRTUAL . '"></head><body>' . nl2br($body) . '</body></html>';
635 635
   }
636 636
 
@@ -674,21 +674,21 @@  discard block
 block discarded – undo
674 674
 }
675 675
 
676 676
 function sn_ali_fill_user_ally(&$user) {
677
-  if(!$user['ally_id']) {
677
+  if (!$user['ally_id']) {
678 678
     return;
679 679
   }
680 680
 
681
-  if(!isset($user['ally'])) {
681
+  if (!isset($user['ally'])) {
682 682
     $user['ally'] = db_ally_get_by_id($user['ally_id']);
683 683
   }
684 684
 
685
-  if(!isset($user['ally']['player'])) {
685
+  if (!isset($user['ally']['player'])) {
686 686
     $user['ally']['player'] = db_user_by_id($user['ally']['ally_user_id'], true, '*', false);
687 687
   }
688 688
 }
689 689
 
690 690
 function sn_get_url_contents($url) {
691
-  if(function_exists('curl_init')) {
691
+  if (function_exists('curl_init')) {
692 692
     $crl = curl_init();
693 693
     $timeout = 5;
694 694
     curl_setopt($crl, CURLOPT_URL, $url);
@@ -723,10 +723,10 @@  discard block
 block discarded – undo
723 723
 
724 724
 function get_ship_data($ship_id, $user) {
725 725
   $ship_data = array();
726
-  if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) {
727
-    foreach(get_unit_param($ship_id, 'engine') as $engine_info) {
726
+  if (in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) {
727
+    foreach (get_unit_param($ship_id, 'engine') as $engine_info) {
728 728
       $tech_level = intval(mrc_get_level($user, null, $engine_info['tech']));
729
-      if(empty($ship_data) || $tech_level >= $engine_info['min_level']) {
729
+      if (empty($ship_data) || $tech_level >= $engine_info['min_level']) {
730 730
         $ship_data = $engine_info;
731 731
         $ship_data['tech_level'] = $tech_level;
732 732
       }
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
   return $ship_data;
739 739
 }
740 740
 
741
-if(!function_exists('strptime')) {
741
+if (!function_exists('strptime')) {
742 742
   function strptime($date, $format) {
743 743
     $masks = array(
744 744
       '%d' => '(?P<d>[0-9]{2})',
@@ -751,12 +751,12 @@  discard block
 block discarded – undo
751 751
     );
752 752
 
753 753
     $rexep = "#" . strtr(preg_quote($format), $masks) . "#";
754
-    if(preg_match($rexep, $date, $out)) {
754
+    if (preg_match($rexep, $date, $out)) {
755 755
       $ret = array(
756
-        "tm_sec"  => (int)$out['S'],
757
-        "tm_min"  => (int)$out['M'],
758
-        "tm_hour" => (int)$out['H'],
759
-        "tm_mday" => (int)$out['d'],
756
+        "tm_sec"  => (int) $out['S'],
757
+        "tm_min"  => (int) $out['M'],
758
+        "tm_hour" => (int) $out['H'],
759
+        "tm_mday" => (int) $out['d'],
760 760
         "tm_mon"  => $out['m'] ? $out['m'] - 1 : 0,
761 761
         "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0,
762 762
       );
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 function sn_sys_sector_buy($redirect = 'overview.php') {
772 772
   global $user, $planetrow;
773 773
 
774
-  if(!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) {
774
+  if (!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) {
775 775
     return;
776 776
   }
777 777
 
@@ -784,9 +784,9 @@  discard block
 block discarded – undo
784 784
 //  $planetrow = $planetrow['planet'];
785 785
   $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true);
786 786
   $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER];
787
-  if($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) {
787
+  if ($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) {
788 788
     $planet_name_text = uni_render_planet($planetrow);
789
-    if(rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'],
789
+    if (rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'],
790 790
         $user['username'], $user['id'], $planet_name_text, classLocale::$lang['sys_planet_type'][$planetrow['planet_type']], $planetrow['id'], $sector_cost)
791 791
     )) {
792 792
       $sector_db_name = pname_resource_name(UNIT_SECTOR);
@@ -801,30 +801,30 @@  discard block
 block discarded – undo
801 801
 }
802 802
 
803 803
 function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') {
804
-  if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) {
805
-    foreach($handler_list as $function_name => $function_data) {
806
-      if(is_string($function_data)) {
804
+  if (isset($handler_list) && is_array($handler_list) && !empty($handler_list)) {
805
+    foreach ($handler_list as $function_name => $function_data) {
806
+      if (is_string($function_data)) {
807 807
         $override_with = &$function_data;
808
-      } elseif(isset($function_data['callable'])) {
808
+      } elseif (isset($function_data['callable'])) {
809 809
         $override_with = &$function_data['callable'];
810 810
       }
811 811
 
812 812
       $overwrite = $override_with[0] == '*';
813
-      if($overwrite) {
813
+      if ($overwrite) {
814 814
         $override_with = substr($override_with, 1);
815 815
       }
816 816
 
817
-      if(($point_position = strpos($override_with, '.')) === false && $class_module_name) {
817
+      if (($point_position = strpos($override_with, '.')) === false && $class_module_name) {
818 818
         $override_with = array($class_module_name, $override_with);
819
-      } elseif($point_position == 0) {
819
+      } elseif ($point_position == 0) {
820 820
         $override_with = substr($override_with, 1);
821
-      } elseif($point_position > 0) {
821
+      } elseif ($point_position > 0) {
822 822
         $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1));
823 823
       }
824 824
 
825
-      if($overwrite) {
825
+      if ($overwrite) {
826 826
         $functions[$function_name] = array();
827
-      } elseif(!isset($functions[$function_name])) {
827
+      } elseif (!isset($functions[$function_name])) {
828 828
         $functions[$function_name] = array();
829 829
         $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : '');
830 830
         $functions[$function_name][] = $sn_function_name;
@@ -840,15 +840,15 @@  discard block
 block discarded – undo
840 840
 function player_nick_render_to_html($result, $options = false) {
841 841
   // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string
842 842
 
843
-  if(is_string($result) && strpos($result, ':{i:')) {
843
+  if (is_string($result) && strpos($result, ':{i:')) {
844 844
     $result = player_nick_uncompact($result);
845 845
   }
846 846
 
847
-  if(is_array($result)) {
848
-    if(isset($result['id'])) {
847
+  if (is_array($result)) {
848
+    if (isset($result['id'])) {
849 849
       $result = player_nick_render_current_to_array($result, $options);
850 850
     }
851
-    if(!isset($result[NICK_HTML])) {
851
+    if (!isset($result[NICK_HTML])) {
852 852
       $result = player_nick_render_array_to_html($result);
853 853
     }
854 854
     unset($result[NICK_HTML]);
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
   try {
872 872
     $result = unserialize($nick_string);
873 873
     // ksort($result); // Всегда ksort-ый в player_nick_compact()
874
-  } catch(exception $e) {
874
+  } catch (exception $e) {
875 875
     $result = strpos($nick_string, ':{i:') ? null : $nick_string; // fallback if it is already string - for old chat strings, for example
876 876
   }
877 877
 
@@ -884,20 +884,20 @@  discard block
 block discarded – undo
884 884
   global $user;
885 885
 
886 886
   // ALL STRING ARE UNSAFE!!!
887
-  if(isset($nick_array[NICK_BIRTHSDAY])) {
887
+  if (isset($nick_array[NICK_BIRTHSDAY])) {
888 888
     $result[NICK_BIRTHSDAY] = '<img src="design/images/birthday.png" />';
889 889
   }
890 890
 
891
-  if(isset($nick_array[NICK_VACATION])) {
891
+  if (isset($nick_array[NICK_VACATION])) {
892 892
     $result[NICK_VACATION] = '<img src="design/images/icon_vacation.png" />';
893 893
   }
894 894
 
895
-  if(isset($nick_array[NICK_GENDER])) {
895
+  if (isset($nick_array[NICK_GENDER])) {
896 896
     $result[NICK_GENDER] = '<img src="' . ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH) . 'images/gender_' . $nick_array[NICK_GENDER] . '.png" />';
897 897
   }
898 898
 
899
-  if(isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) {
900
-    switch($nick_array[NICK_AUTH_LEVEL]) {
899
+  if (isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) {
900
+    switch ($nick_array[NICK_AUTH_LEVEL]) {
901 901
       case 4:
902 902
         $highlight = classSupernova::$config->chat_highlight_developer;
903 903
       break;
@@ -918,20 +918,20 @@  discard block
 block discarded – undo
918 918
         $highlight = isset($nick_array[NICK_PREMIUM]) ? classSupernova::$config->chat_highlight_premium : '';
919 919
     }
920 920
 
921
-    if($highlight) {
921
+    if ($highlight) {
922 922
       list($result[NICK_HIGHLIGHT], $result[NICK_HIGHLIGHT_END]) = explode('$1', $highlight);
923 923
     }
924 924
     // $result = preg_replace("#(.+)#", $highlight, $result);
925 925
   }
926 926
 
927
-  if(isset($nick_array[NICK_CLASS])) {
927
+  if (isset($nick_array[NICK_CLASS])) {
928 928
     $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] . '>';
929 929
     $result[NICK_CLASS_END] = '</span>';
930 930
   }
931 931
 
932 932
   $result[NICK_NICK] = sys_safe_output($nick_array[NICK_NICK]);
933 933
 
934
-  if(isset($nick_array[NICK_ALLY])) {
934
+  if (isset($nick_array[NICK_ALLY])) {
935 935
     $result[NICK_ALLY] = '[' . sys_safe_output($nick_array[NICK_ALLY]) . ']';
936 936
   }
937 937
 
@@ -955,32 +955,32 @@  discard block
 block discarded – undo
955 955
   */
956 956
 
957 957
 
958
-  if($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) {
958
+  if ($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) {
959 959
     $result[NICK_BIRTHSDAY] = '';
960 960
   }
961 961
 
962
-  if($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) {
962
+  if ($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) {
963 963
     $result[NICK_GENDER] = $render_user['gender'] == GENDER_UNKNOWN ? 'unknown' : ($render_user['gender'] == GENDER_FEMALE ? 'female' : 'male');
964 964
   }
965 965
 
966
-  if(($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) {
966
+  if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) {
967 967
     $result[NICK_VACATION] = $render_user['vacation'];
968 968
   }
969 969
 
970
-  if($options === true || (isset($options['color']) && $options['color'])) {
971
-    if($user_auth_level = $render_user['authlevel']) {
970
+  if ($options === true || (isset($options['color']) && $options['color'])) {
971
+    if ($user_auth_level = $render_user['authlevel']) {
972 972
       $result[NICK_AUTH_LEVEL] = $user_auth_level;
973 973
     }
974
-    if($user_premium = mrc_get_level($render_user, null, UNIT_PREMIUM)) {
974
+    if ($user_premium = mrc_get_level($render_user, null, UNIT_PREMIUM)) {
975 975
       $result[NICK_PREMIUM] = $user_premium;
976 976
     }
977 977
   }
978 978
 
979
-  if((isset($options['class']) && $options['class'])) {
979
+  if ((isset($options['class']) && $options['class'])) {
980 980
     $result[NICK_CLASS] = (isset($result_options[NICK_CLASS]) ? ' ' . $result_options[NICK_CLASS] : '') . $options['class'];
981 981
   }
982 982
 
983
-  if($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) {
983
+  if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) {
984 984
     $result[NICK_ALLY] = $render_user['ally_tag'];
985 985
   }
986 986
 
@@ -996,25 +996,25 @@  discard block
 block discarded – undo
996 996
 
997 997
   $user_skip_list = array();
998 998
 
999
-  if(classSupernova::$config->stats_hide_admins) {
999
+  if (classSupernova::$config->stats_hide_admins) {
1000 1000
     $user_skip_list[] = '`authlevel` > 0';
1001 1001
   }
1002 1002
 
1003
-  if(classSupernova::$config->stats_hide_player_list) {
1003
+  if (classSupernova::$config->stats_hide_player_list) {
1004 1004
     $temp = explode(',', classSupernova::$config->stats_hide_player_list);
1005
-    foreach($temp as $user_id) {
1005
+    foreach ($temp as $user_id) {
1006 1006
       $user_id = floatval($user_id);
1007
-      if($user_id) {
1007
+      if ($user_id) {
1008 1008
         $user_skip_list[] = '`id` = ' . $user_id;
1009 1009
       }
1010 1010
     }
1011 1011
   }
1012 1012
 
1013
-  if(!empty($user_skip_list)) {
1013
+  if (!empty($user_skip_list)) {
1014 1014
     $user_skip_list = implode(' OR ', $user_skip_list);
1015 1015
     $user_skip_query = db_user_list($user_skip_list);
1016
-    if(!empty($user_skip_query)) {
1017
-      foreach($user_skip_query as $user_skip_row) {
1016
+    if (!empty($user_skip_query)) {
1017
+      foreach ($user_skip_query as $user_skip_row) {
1018 1018
         $result[$user_skip_row['id']] = $user_skip_row['id'];
1019 1019
       }
1020 1020
     }
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 
1046 1046
 function sn_sn_get_groups($groups, &$result) {
1047 1047
   $result = is_array($result) ? $result : array();
1048
-  foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) {
1048
+  foreach ($groups = is_array($groups) ? $groups : array($groups) as $group_name) {
1049 1049
     $result += is_array($a_group = get_unit_param(UNIT_GROUP, $group_name)) ? $a_group : array();
1050 1050
   }
1051 1051
 
@@ -1071,8 +1071,8 @@  discard block
 block discarded – undo
1071 1071
   $sn_data_unit = get_unit_param($unit_id);
1072 1072
 
1073 1073
   $result = is_array($result) ? $result : array();
1074
-  if($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) {
1075
-    foreach($sn_data_unit[$field] as $require_id => $require_level) {
1074
+  if ($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) {
1075
+    foreach ($sn_data_unit[$field] as $require_id => $require_level) {
1076 1076
       $level_got = mrc_get_level($user, $planetrow, $require_id);
1077 1077
       $level_basic = mrc_get_level($user, $planetrow, $require_id, false, true);
1078 1078
       $result[] = array(
@@ -1096,16 +1096,16 @@  discard block
 block discarded – undo
1096 1096
 
1097 1097
   $ranks = array();
1098 1098
 
1099
-  if($ally['ranklist']) {
1099
+  if ($ally['ranklist']) {
1100 1100
     $str_ranks = explode(';', $ally['ranklist']);
1101
-    foreach($str_ranks as $str_rank) {
1102
-      if(!$str_rank) {
1101
+    foreach ($str_ranks as $str_rank) {
1102
+      if (!$str_rank) {
1103 1103
         continue;
1104 1104
       }
1105 1105
 
1106 1106
       $tmp = explode(',', $str_rank);
1107 1107
       $rank_id = count($ranks);
1108
-      foreach($ally_rights as $key => $value) {
1108
+      foreach ($ally_rights as $key => $value) {
1109 1109
         $ranks[$rank_id][$value] = $tmp[$key];
1110 1110
       }
1111 1111
     }
@@ -1121,8 +1121,8 @@  discard block
 block discarded – undo
1121 1121
 }
1122 1122
 
1123 1123
 function array_merge_recursive_numeric($array1, $array2) {
1124
-  if(!empty($array2) && is_array($array2)) {
1125
-    foreach($array2 as $key => $value) {
1124
+  if (!empty($array2) && is_array($array2)) {
1125
+    foreach ($array2 as $key => $value) {
1126 1126
 //    if(!isset($array1[$key]) || !is_array($array1[$key])) {
1127 1127
 //      $array1[$key] = $value;
1128 1128
 //    } else {
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 
1138 1138
 function sn_sys_array_cumulative_sum(&$array) {
1139 1139
   $accum = 0;
1140
-  foreach($array as &$value) {
1140
+  foreach ($array as &$value) {
1141 1141
     $accum += $value;
1142 1142
     $value = $accum;
1143 1143
   }
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
   $sn_data_density = sn_get_groups('planet_density');
1148 1148
   $density_price_chart = array();
1149 1149
 
1150
-  foreach($sn_data_density as $density_id => $density_data) {
1150
+  foreach ($sn_data_density as $density_id => $density_data) {
1151 1151
     // Отсекаем записи с RARITY = 0 - служебные записи и супер-ядра
1152 1152
     $density_data[UNIT_PLANET_DENSITY_RARITY] ? $density_price_chart[$density_id] = $density_data[UNIT_PLANET_DENSITY_RARITY] : false;
1153 1153
   }
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 
1156 1156
   $total_rarity = array_sum($density_price_chart);
1157 1157
 
1158
-  foreach($density_price_chart as &$density_data) {
1158
+  foreach ($density_price_chart as &$density_data) {
1159 1159
     $density_data = ceil($total_rarity / $density_data * $planet_row['field_max'] * PLANET_DENSITY_TO_DARK_MATTER_RATE);
1160 1160
   }
1161 1161
 
@@ -1163,16 +1163,16 @@  discard block
 block discarded – undo
1163 1163
 }
1164 1164
 
1165 1165
 function sn_sys_planet_core_transmute(&$user, &$planetrow) {
1166
-  if(!sys_get_param_str('transmute')) {
1166
+  if (!sys_get_param_str('transmute')) {
1167 1167
     return array();
1168 1168
   }
1169 1169
 
1170 1170
   try {
1171
-    if($planetrow['planet_type'] != PT_PLANET) {
1171
+    if ($planetrow['planet_type'] != PT_PLANET) {
1172 1172
       throw new exception(classLocale::$lang['ov_core_err_not_a_planet'], ERR_ERROR);
1173 1173
     }
1174 1174
 
1175
-    if($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) {
1175
+    if ($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) {
1176 1176
       throw new exception(classLocale::$lang['ov_core_err_same_density'], ERR_WARNING);
1177 1177
     }
1178 1178
 
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
     $planet_density_index = $planetrow['density_index'];
1187 1187
 
1188 1188
     $density_price_chart = planet_density_price_chart($planetrow);
1189
-    if(!isset($density_price_chart[$new_density_index])) {
1189
+    if (!isset($density_price_chart[$new_density_index])) {
1190 1190
       // Hack attempt
1191 1191
       throw new exception(classLocale::$lang['ov_core_err_denisty_type_wrong'], ERR_ERROR);
1192 1192
     }
@@ -1195,13 +1195,13 @@  discard block
 block discarded – undo
1195 1195
     // $transmute_cost = get_unit_param(UNIT_PLANET_DENSITY, 'cost');
1196 1196
     // $transmute_cost = $transmute_cost[RES_DARK_MATTER] * $density_price_chart[$new_density_index];
1197 1197
     $transmute_cost = $density_price_chart[$new_density_index];
1198
-    if($user_dark_matter < $transmute_cost) {
1198
+    if ($user_dark_matter < $transmute_cost) {
1199 1199
       throw new exception(classLocale::$lang['ov_core_err_no_dark_matter'], ERR_ERROR);
1200 1200
     }
1201 1201
 
1202 1202
     $sn_data_planet_density = sn_get_groups('planet_density');
1203
-    foreach($sn_data_planet_density as $key => $value) {
1204
-      if($key == $new_density_index) {
1203
+    foreach ($sn_data_planet_density as $key => $value) {
1204
+      if ($key == $new_density_index) {
1205 1205
         break;
1206 1206
       }
1207 1207
       $prev_density_index = $key;
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
       'STATUS'  => ERR_NONE,
1233 1233
       'MESSAGE' => sprintf(classLocale::$lang['ov_core_err_none'], classLocale::$lang['uni_planet_density_types'][$planet_density_index], classLocale::$lang['uni_planet_density_types'][$new_density_index], $new_density),
1234 1234
     );
1235
-  } catch(exception $e) {
1235
+  } catch (exception $e) {
1236 1236
     sn_db_transaction_rollback();
1237 1237
     $result = array(
1238 1238
       'STATUS'  => $e->getCode(),
@@ -1245,8 +1245,8 @@  discard block
 block discarded – undo
1245 1245
 
1246 1246
 function sn_module_get_active_count($group = '*') {
1247 1247
   $active_modules = 0;
1248
-  if(isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) {
1249
-    foreach(sn_module::$sn_module_list[$group] as $payment_module) {
1248
+  if (isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) {
1249
+    foreach (sn_module::$sn_module_list[$group] as $payment_module) {
1250 1250
       $active_modules += $payment_module->manifest['active'];
1251 1251
     }
1252 1252
   }
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
 function get_resource_exchange() {
1258 1258
   static $rates;
1259 1259
 
1260
-  if(!$rates) {
1260
+  if (!$rates) {
1261 1261
     $rates = array(
1262 1262
       RES_METAL       => 'rpg_exchange_metal',
1263 1263
       RES_CRYSTAL     => 'rpg_exchange_crystal',
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
       RES_DARK_MATTER => 'rpg_exchange_darkMatter',
1266 1266
     );
1267 1267
 
1268
-    foreach($rates as &$rate) {
1268
+    foreach ($rates as &$rate) {
1269 1269
       $rate = classSupernova::$config->$rate;
1270 1270
     }
1271 1271
   }
@@ -1276,12 +1276,12 @@  discard block
 block discarded – undo
1276 1276
 function get_unit_cost_in(&$cost, $in_resource = RES_METAL) {
1277 1277
   static $rates;
1278 1278
 
1279
-  if(!$rates) {
1279
+  if (!$rates) {
1280 1280
     $rates = get_resource_exchange();
1281 1281
   }
1282 1282
 
1283 1283
   $metal_cost = 0;
1284
-  foreach($cost as $resource_id => $resource_value) {
1284
+  foreach ($cost as $resource_id => $resource_value) {
1285 1285
     $metal_cost += $rates[$resource_id] * $resource_value;
1286 1286
   }
1287 1287
 
@@ -1291,8 +1291,8 @@  discard block
 block discarded – undo
1291 1291
 function get_player_max_expeditons(&$user, $astrotech = -1) { return sn_function_call(__FUNCTION__, array(&$user, $astrotech, &$result)); }
1292 1292
 
1293 1293
 function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) {
1294
-  if($astrotech == -1) {
1295
-    if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) {
1294
+  if ($astrotech == -1) {
1295
+    if (!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) {
1296 1296
       $astrotech = mrc_get_level($user, null, TECH_ASTROTECH);
1297 1297
       $user[UNIT_PLAYER_EXPEDITIONS_MAX] = $astrotech >= 1 ? floor(sqrt($astrotech - 1)) : 0;
1298 1298
     }
@@ -1308,8 +1308,8 @@  discard block
 block discarded – undo
1308 1308
 }
1309 1309
 
1310 1310
 function get_player_max_colonies(&$user, $astrotech = -1) {
1311
-  if($astrotech == -1) {
1312
-    if(!isset($user[UNIT_PLAYER_COLONIES_MAX])) {
1311
+  if ($astrotech == -1) {
1312
+    if (!isset($user[UNIT_PLAYER_COLONIES_MAX])) {
1313 1313
 
1314 1314
       $expeditions = get_player_max_expeditons($user);
1315 1315
       $astrotech = mrc_get_level($user, null, TECH_ASTROTECH);
@@ -1354,10 +1354,10 @@  discard block
 block discarded – undo
1354 1354
 
1355 1355
   // pdump($powerup_unit, '$powerup_unit');
1356 1356
   $level_current = $term_original = $time_left = 0;
1357
-  if($is_upgrade) {
1357
+  if ($is_upgrade) {
1358 1358
     $time_finish = strtotime($powerup_unit['unit_time_finish']);
1359 1359
     $time_left = max(0, $time_finish - SN_TIME_NOW);
1360
-    if($time_left > 0) {
1360
+    if ($time_left > 0) {
1361 1361
       $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']);
1362 1362
       $level_current = $powerup_unit['unit_level'];
1363 1363
     }
@@ -1365,22 +1365,22 @@  discard block
 block discarded – undo
1365 1365
 
1366 1366
   $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK];
1367 1367
   $original_cost = 0;
1368
-  for($i = 1; $i <= $level_max; $i++) {
1368
+  for ($i = 1; $i <= $level_max; $i++) {
1369 1369
     $base_cost = eco_get_total_cost($powerup_id, $i);
1370 1370
     $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER];
1371
-    foreach($sn_powerup_buy_discounts as $period => $discount) {
1371
+    foreach ($sn_powerup_buy_discounts as $period => $discount) {
1372 1372
       $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH);
1373 1373
       $result[$i][$period] = $upgrade_price;
1374 1374
       $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost;
1375 1375
     }
1376 1376
   }
1377 1377
 
1378
-  if($is_upgrade && $time_left) {
1378
+  if ($is_upgrade && $time_left) {
1379 1379
     $term_original = round($term_original / PERIOD_DAY);
1380 1380
     $time_left = min(floor($time_left / PERIOD_DAY), $term_original);
1381 1381
     $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0;
1382 1382
 
1383
-    array_walk_recursive($result, function (&$value) use ($cost_left) {
1383
+    array_walk_recursive($result, function(&$value) use ($cost_left) {
1384 1384
       $value -= $cost_left;
1385 1385
     });
1386 1386
   }
@@ -1436,7 +1436,7 @@  discard block
 block discarded – undo
1436 1436
 
1437 1437
 function print_rr($var, $capture = false) {
1438 1438
   $print = '<pre>' . htmlspecialchars(print_r($var, true)) . '</pre>';
1439
-  if($capture) {
1439
+  if ($capture) {
1440 1440
     return $print;
1441 1441
   } else {
1442 1442
     print($print);
@@ -1515,8 +1515,8 @@  discard block
 block discarded – undo
1515 1515
  * @return mixed
1516 1516
  */
1517 1517
 function sortUnitRenderedList(&$ListToSort, $sort_option, $sort_option_inverse) {
1518
-  if($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) {
1519
-    switch($sort_option) {
1518
+  if ($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) {
1519
+    switch ($sort_option) {
1520 1520
       case PLAYER_OPTION_SORT_NAME:
1521 1521
         $sort_option_field = 'NAME';
1522 1522
       break;
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
       break;
1538 1538
     }
1539 1539
     $sort_option_inverse_closure = $sort_option_inverse ? -1 : 1;
1540
-    usort($ListToSort, function ($a, $b) use ($sort_option_field, $sort_option_inverse_closure) {
1540
+    usort($ListToSort, function($a, $b) use ($sort_option_field, $sort_option_inverse_closure) {
1541 1541
       return $a[$sort_option_field] < $b[$sort_option_field] ? -1 * $sort_option_inverse_closure : (
1542 1542
       $a[$sort_option_field] > $b[$sort_option_field] ? 1 * $sort_option_inverse_closure : 0
1543 1543
       );
Please login to merge, or discard this patch.
Doc Comments   +27 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 require_once('general_pname.php');
13 13
 
14 14
 /**
15
- * @param       $func_name
15
+ * @param       string $func_name
16 16
  * @param array $func_arg
17 17
  *
18 18
  * @return mixed
@@ -63,6 +63,9 @@  discard block
 block discarded – undo
63 63
 
64 64
 // ----------------------------------------------------------------------------------------------------------------
65 65
 // Fonction de lecture / ecriture / exploitation de templates
66
+/**
67
+ * @param string $filename
68
+ */
66 69
 function sys_file_read($filename) {
67 70
   return @file_get_contents($filename);
68 71
 }
@@ -105,7 +108,7 @@  discard block
 block discarded – undo
105 108
 /**
106 109
  * Получение курса обмены валюты в серверную валюту
107 110
  *
108
- * @param $currency_symbol
111
+ * @param string $currency_symbol
109 112
  *
110 113
  * @return float
111 114
  */
@@ -146,7 +149,7 @@  discard block
 block discarded – undo
146 149
  * @param float     $n
147 150
  * @param int|bool  $floor
148 151
  * @param int|bool  $color
149
- * @param int|bool  $limit
152
+ * @param boolean  $limit
150 153
  * @param bool|null $style
151 154
  *
152 155
  * @return array|float|string
@@ -247,6 +250,9 @@  discard block
 block discarded – undo
247 250
   return preg_replace($ListCensure, '*', $String);
248 251
 }
249 252
 
253
+/**
254
+ * @param string $email
255
+ */
250 256
 function is_email($email) {
251 257
   return (preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email));
252 258
 }
@@ -283,6 +289,9 @@  discard block
 block discarded – undo
283 289
   return floatval(sys_get_param($param_name, $default));
284 290
 }
285 291
 
292
+/**
293
+ * @param string $param_name
294
+ */
286 295
 function sys_get_param_escaped($param_name, $default = '') {
287 296
   return db_escape(sys_get_param($param_name, $default));
288 297
 }
@@ -515,6 +524,9 @@  discard block
 block discarded – undo
515 524
 }
516 525
 
517 526
 // Generates random string of $length symbols from $allowed_chars charset
527
+/**
528
+ * @param string $allowed_chars
529
+ */
518 530
 function sys_random_string($length = 16, $allowed_chars = SN_SYS_SEC_CHARS_ALLOWED) {
519 531
   $allowed_length = strlen($allowed_chars);
520 532
 
@@ -619,6 +631,9 @@  discard block
 block discarded – undo
619 631
   return implode(';', $fleet_string);
620 632
 }
621 633
 
634
+/**
635
+ * @param string $body
636
+ */
622 637
 function mymail($email_unsafe, $title, $body, $from = '', $html = false) {
623 638
   $from = trim($from ? $from : classSupernova::$config->game_adminEmail);
624 639
 
@@ -873,6 +888,9 @@  discard block
 block discarded – undo
873 888
   return serialize($nick_array);
874 889
 }
875 890
 
891
+/**
892
+ * @param string $nick_string
893
+ */
876 894
 function player_nick_uncompact($nick_string) {
877 895
   try {
878 896
     $result = unserialize($nick_string);
@@ -1120,6 +1138,9 @@  discard block
 block discarded – undo
1120 1138
   return $ranks;
1121 1139
 }
1122 1140
 
1141
+/**
1142
+ * @param boolean $planet_id
1143
+ */
1123 1144
 function sys_player_new_adjust($user_id, $planet_id) { return sn_function_call(__FUNCTION__, array($user_id, $planet_id, &$result)); }
1124 1145
 
1125 1146
 function sn_sys_player_new_adjust($user_id, $planet_id, &$result) {
@@ -1430,6 +1451,9 @@  discard block
 block discarded – undo
1430 1451
   return version_compare(sn_version_compare_extra($ver1), sn_version_compare_extra($ver2));
1431 1452
 }
1432 1453
 
1454
+/**
1455
+ * @param string $name
1456
+ */
1433 1457
 function sn_setcookie($name, $value = null, $expire = null, $path = SN_ROOT_RELATIVE, $domain = null, $secure = null, $httponly = null) {
1434 1458
   $_COOKIE[$name] = $value;
1435 1459
 
Please login to merge, or discard this patch.
includes/includes/eco_bld_structures.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
   global $template_result;
20 20
   $classLocale = classLocale::$lang;
21 21
 
22
-  if($ally_id = sys_get_param_id('ally_id')) {
22
+  if ($ally_id = sys_get_param_id('ally_id')) {
23 23
     define('SN_IN_ALLY', true);
24 24
     $ranks = ally_get_ranks($auser['ally']);
25
-    if($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) {
25
+    if ($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) {
26 26
       $user = &$auser['ally']['player'];
27 27
       $planet = array(
28 28
         'metal'     => $user['metal'],
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
     }
33 33
   }
34 34
 
35
-  if(!$user) {
35
+  if (!$user) {
36 36
     $user = &$auser;
37 37
   }
38 38
 
39
-  switch($action = sys_get_param_escaped('action')) {
39
+  switch ($action = sys_get_param_escaped('action')) {
40 40
     case 'create': // Add unit to que for build
41 41
     case 'create_autoconvert': // Add unit to que for build
42 42
     case 'destroy': // Add unit to que for remove
@@ -53,28 +53,28 @@  discard block
 block discarded – undo
53 53
 
54 54
   $group_missile = sn_get_groups('missile');
55 55
   $silo_capacity_free = 0;
56
-  if($que_type == QUE_STRUCTURES) {
56
+  if ($que_type == QUE_STRUCTURES) {
57 57
     $build_unit_list = sn_get_groups('build_allow');
58 58
     $build_unit_list = $build_unit_list[$planet['planet_type']];
59 59
     $artifact_id = ART_NANO_BUILDER;
60 60
     $page_header = classLocale::$lang['tech'][UNIT_STRUCTURES];
61
-  } elseif($que_type == QUE_RESEARCH) {
62
-    if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) {
61
+  } elseif ($que_type == QUE_RESEARCH) {
62
+    if (!mrc_get_level($user, $planet, STRUC_LABORATORY)) {
63 63
       message(classLocale::$lang['no_laboratory'], classLocale::$lang['tech'][UNIT_TECHNOLOGIES]);
64 64
     }
65 65
 
66
-    if(eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) {
66
+    if (eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) {
67 67
       message(classLocale::$lang['eco_bld_msg_err_laboratory_upgrading'], classLocale::$lang['tech'][UNIT_TECHNOLOGIES]);
68 68
     }
69 69
     $build_unit_list = sn_get_groups('tech');
70 70
     $artifact_id = ART_HEURISTIC_CHIP;
71 71
     $page_header = classLocale::$lang['tech'][UNIT_TECHNOLOGIES] . ($user['user_as_ally'] ? "&nbsp;{$classLocale['sys_of_ally']}&nbsp;{$user['username']}" : '');
72
-  } elseif($que_type == QUE_MERCENARY) {
72
+  } elseif ($que_type == QUE_MERCENARY) {
73 73
     $build_unit_list = sn_get_groups('mercenaries');
74 74
     $artifact_id = 0;
75 75
     $page_header = classLocale::$lang['tech'][UNIT_MERCENARIES] . ($user['user_as_ally'] ? "&nbsp;{$classLocale['sys_of_ally']}&nbsp;{$user['username']}" : '');
76 76
   } else {
77
-    if(mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) {
77
+    if (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) {
78 78
       message(classLocale::$lang['need_hangar'], classLocale::$lang['tech'][STRUC_FACTORY_HANGAR]);
79 79
     }
80 80
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     $artifact_id = 0;
84 84
 
85 85
     $silo_capacity_free = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY);
86
-    foreach($group_missile as $unit_id) {
86
+    foreach ($group_missile as $unit_id) {
87 87
       $silo_capacity_free -= (mrc_get_level($user, $planet, $unit_id, false, true) + (isset($in_que[$unit_id]) && $in_que[$unit_id] ? $in_que[$unit_id] : 0)) * get_unit_param($unit_id, P_UNIT_SIZE);
88 88
     }
89 89
     $silo_capacity_free = max(0, $silo_capacity_free);
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
   $config_resource_multiplier_plain = game_resource_multiplier(true);
95 95
 
96 96
   $template = gettemplate('buildings_builds', true);
97
-  if(!empty($operation_result)) {
97
+  if (!empty($operation_result)) {
98 98
     $template_result['.']['result'][] = $operation_result;
99 99
   }
100 100
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
   $record_index = 0;
126 126
 
127
-  foreach($build_unit_list as $unit_id) {
127
+  foreach ($build_unit_list as $unit_id) {
128 128
     $level_base = mrc_get_level($user, $planet, $unit_id, false, true);
129 129
     $level_effective = mrc_get_level($user, $planet, $unit_id);
130 130
     $level_in_que = $in_que[$unit_id];
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
     $can_build = $unit_info[P_MAX_STACK] ? max(0, $unit_info[P_MAX_STACK] - $level_in_que - $level_effective) : $build_data['CAN'][BUILD_CREATE];
148 148
     // Restricting $can_build by free silo capacity
149 149
     $can_build = ($unit_is_missile = in_array($unit_id, $group_missile)) ? min($can_build, floor($silo_capacity_free / $unit_info[P_UNIT_SIZE])) : $can_build;
150
-    if(!$can_build) {
151
-      if(!$build_data['CAN'][BUILD_CREATE]) {
150
+    if (!$can_build) {
151
+      if (!$build_data['CAN'][BUILD_CREATE]) {
152 152
         $build_data['RESULT'][BUILD_CREATE] = BUILD_NO_RESOURCES;
153
-      } elseif($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) {
153
+      } elseif ($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) {
154 154
         $build_data['RESULT'][BUILD_CREATE] = BUILD_SILO_FULL;
155
-      } elseif($unit_info[P_MAX_STACK]) {
155
+      } elseif ($unit_info[P_MAX_STACK]) {
156 156
         $build_data['RESULT'][BUILD_CREATE] = BUILD_MAX_REACHED;
157 157
       }
158 158
     }
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
       'MAP_IS_RESOURCE' => !empty($unit_info[P_UNIT_PRODUCTION]),
220 220
     );
221 221
 
222
-    if($unit_stackable) {
222
+    if ($unit_stackable) {
223 223
       $level_production_base = array(
224 224
         'ACTUAL_SHIELD' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_info['shield'])),
225 225
         'ACTUAL_ARMOR'  => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_info['armor'])),
226 226
         'ACTUAL_WEAPON' => pretty_number(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_info['attack'])),
227 227
       );
228 228
 
229
-      if($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) {
229
+      if ($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) {
230 230
         $ship_data = get_ship_data($unit_id, $user);
231 231
 
232 232
         $level_production_base += array(
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
         );
237 237
       }
238 238
 
239
-      if($unit_info[P_UNIT_PRODUCTION]) {
240
-        foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
241
-          if($resource_income =
239
+      if ($unit_info[P_UNIT_PRODUCTION]) {
240
+        foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
241
+          if ($resource_income =
242 242
             floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc(1, 10, $user, $planet)
243 243
               * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)
244 244
               * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
         }
249 249
       }
250 250
       $production['.']['resource'][] = $level_production_base;
251
-    } elseif($unit_info[P_UNIT_PRODUCTION]) {
251
+    } elseif ($unit_info[P_UNIT_PRODUCTION]) {
252 252
       $level_production_base = array();
253 253
       $element_level_start = $level_effective + $in_que[$unit_id];
254
-      foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
255
-        if($resource_income =
254
+      foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
255
+        if ($resource_income =
256 256
           floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($element_level_start, 10, $user, $planet)
257 257
             * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)
258 258
             * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
       }
263 263
 
264 264
       $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1;
265
-      for($i = 0; $i < 6; $i++) {
265
+      for ($i = 0; $i < 6; $i++) {
266 266
         $level_production = array('LEVEL' => $level_start + $i);
267
-        foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
268
-          if(
267
+        foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) {
268
+          if (
269 269
           $resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($level_start + $i, 10, $user, $planet)
270 270
             * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier)
271 271
             * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1)))
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         }
277 277
         $production['.']['resource'][] = $level_production;
278 278
       }
279
-    } elseif($unit_id == TECH_ASTROTECH) {
279
+    } elseif ($unit_id == TECH_ASTROTECH) {
280 280
       $element_level_start = $level_effective + $in_que[$unit_id];
281 281
       $level_production_base = array(
282 282
         UNIT_PLAYER_EXPEDITIONS_MAX => get_player_max_expeditons($user, $element_level_start),
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
       );
285 285
 
286 286
       $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1;
287
-      for($i = 0; $i < 6; $i++) {
287
+      for ($i = 0; $i < 6; $i++) {
288 288
         $level_production = array('LEVEL' => $level_start + $i);
289 289
         $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i);
290 290
         $level_production['D' . UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX];
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
     $template_result['.']['production'][] = $production;
306 306
   }
307 307
 
308
-  foreach(classLocale::$lang['player_option_building_sort'] as $sort_id => $sort_text) {
308
+  foreach (classLocale::$lang['player_option_building_sort'] as $sort_id => $sort_text) {
309 309
     $template->assign_block_vars('sort_values', array(
310 310
       'VALUE' => $sort_id,
311 311
       'TEXT'  => $sort_text,
Please login to merge, or discard this patch.