Test Failed
Branch trunk (412648)
by SuperNova.WS
03:40
created
includes/general/math.php 1 patch
Braces   +20 added lines, -19 removed lines patch added patch discarded remove patch
@@ -4,16 +4,14 @@  discard block
 block discarded – undo
4 4
   return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1);
5 5
 }
6 6
 
7
-function sn_floor($value)
8
-{
7
+function sn_floor($value) {
9 8
   return $value >= 0 ? floor($value) : ceil($value);
10 9
 }
11 10
 
12 11
 // Эта функция выдает нормально распределенное случайное число с матожиднием $mu и стандартным отклонением $sigma
13 12
 // $strict - количество $sigma, по которым идет округление функции. Т.е. $strict = 3 означает, что диапазон значений обрезается по +-3 * $sigma
14 13
 // Используется http://ru.wikipedia.org/wiki/Преобразование_Бокса_—_Мюллера
15
-function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false)
16
-{
14
+function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) {
17 15
   // http://ru.wikipedia.org/wiki/Среднеквадратическое_отклонение
18 16
   // При $mu = 0 (график симметричный, цифры только для половины графика)
19 17
   // От 0 до $sigma ~ 34.1%
@@ -43,7 +41,7 @@  discard block
 block discarded – undo
43 41
  *
44 42
  * @return float|int
45 43
  */
46
-function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false)  {
44
+function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) {
47 45
   if($cut_extreme) {
48 46
     $range_start--;
49 47
     $range_end++;
@@ -56,8 +54,7 @@  discard block
 block discarded – undo
56 54
   return $result;
57 55
 }
58 56
 
59
-function median()
60
-{
57
+function median() {
61 58
   $args = func_get_args();
62 59
 
63 60
   switch(func_num_args())
@@ -86,8 +83,7 @@  discard block
 block discarded – undo
86 83
       if($n % 2 == 0)
87 84
       {
88 85
         $median = ($args[$h] + $args[$h-1]) / 2;
89
-      }
90
-      else
86
+      } else
91 87
       {
92 88
         $median = $args[$h];
93 89
       }
@@ -97,12 +93,10 @@  discard block
 block discarded – undo
97 93
 
98 94
   return $median;
99 95
 }
100
-function average($arr)
101
-{
96
+function average($arr) {
102 97
   return is_array($arr) && count($arr) ? array_sum($arr) / count($arr) : 0;
103 98
 }
104
-function linear_calc(&$linear, $from = 0, $debug = false)
105
-{
99
+function linear_calc(&$linear, $from = 0, $debug = false) {
106 100
   for($i = $from; $i < count($linear); $i++)
107 101
   {
108 102
     $eq = &$linear[$i];
@@ -111,7 +105,9 @@  discard block
 block discarded – undo
111 105
       $eq[$j] /= $eq[$from];
112 106
     }
113 107
   }
114
-  if($debug) pdump($linear, 'Нормализовано по х' . $from);
108
+  if($debug) {
109
+    pdump($linear, 'Нормализовано по х' . $from);
110
+  }
115 111
 
116 112
   for($i = $from + 1; $i < count($linear); $i++)
117 113
   {
@@ -121,7 +117,9 @@  discard block
 block discarded – undo
121 117
       $eq[$j] -= $linear[$from][$j];
122 118
     }
123 119
   }
124
-  if($debug) pdump($linear, 'Подставили х' . $from);
120
+  if($debug) {
121
+    pdump($linear, 'Подставили х' . $from);
122
+  }
125 123
 
126 124
   if($from < count($linear) - 1)
127 125
   {
@@ -138,11 +136,14 @@  discard block
 block discarded – undo
138 136
         $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j];
139 137
       }
140 138
     }
141
-    if($debug) pdump($linear, 'Подставили обратно х' . $from);
142
-  }
143
-  else
139
+    if($debug) {
140
+      pdump($linear, 'Подставили обратно х' . $from);
141
+    }
142
+  } else
144 143
   {
145
-    if($debug) pdump($linear, 'Результат' . $from);
144
+    if($debug) {
145
+      pdump($linear, 'Результат' . $from);
146
+    }
146 147
     foreach($linear as $index => &$eq)
147 148
     {
148 149
       pdump($eq[count($linear)], 'x' . $index);
Please login to merge, or discard this patch.
includes/db/db_queries.php 1 patch
Braces   +14 added lines, -28 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@  discard block
 block discarded – undo
7 7
 require_once('db_queries_fleet.php');
8 8
 
9 9
 
10
-function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type)
11
-{
10
+function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) {
12 11
   return doquery(
13 12
     "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') .
14 13
     " FROM {{planets}} AS p
@@ -17,8 +16,7 @@  discard block
 block discarded – undo
17 16
     " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}"));
18 17
 }
19 18
 
20
-function db_planet_list_search($searchtext)
21
-{
19
+function db_planet_list_search($searchtext) {
22 20
   return doquery(
23 21
     "SELECT
24 22
       p.galaxy, p.system, p.planet, p.planet_type, p.name as planet_name,
@@ -38,8 +36,7 @@  discard block
 block discarded – undo
38 36
 
39 37
 
40 38
 
41
-function db_user_list_search($searchtext)
42
-{
39
+function db_user_list_search($searchtext) {
43 40
   return doquery(
44 41
     "SELECT
45 42
       pn.player_name, u.id as uid, u.username, u.ally_id, u.id_planet, u.total_points, u.total_rank,
@@ -57,8 +54,7 @@  discard block
 block discarded – undo
57 54
   );
58 55
 }
59 56
 
60
-function db_buddy_list_by_user($user_id)
61
-{
57
+function db_buddy_list_by_user($user_id) {
62 58
 //  return ($user_id = intval($user_id)) ? doquery(
63 59
   return ($user_id = idval($user_id)) ? doquery(
64 60
     "SELECT
@@ -84,8 +80,7 @@  discard block
 block discarded – undo
84 80
 
85 81
 
86 82
 
87
-function db_message_list_outbox_by_user_id($user_id)
88
-{
83
+function db_message_list_outbox_by_user_id($user_id) {
89 84
   // return ($user_id = intval($user_id))
90 85
   return ($user_id = idval($user_id))
91 86
     ? doquery("SELECT {{messages}}.message_id, {{messages}}.message_owner, {{users}}.id AS message_sender, {{messages}}.message_time,
@@ -101,8 +96,7 @@  discard block
 block discarded – undo
101 96
 
102 97
 
103 98
 
104
-function db_unit_records_sum($unit_id, $user_skip_list_unit)
105
-{
99
+function db_unit_records_sum($unit_id, $user_skip_list_unit) {
106 100
   return doquery (
107 101
     "SELECT unit_player_id, username, sum(unit_level) as unit_level
108 102
           FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id
@@ -113,8 +107,7 @@  discard block
 block discarded – undo
113 107
     , true);
114 108
 }
115 109
 
116
-function db_unit_records_plain($unit_id, $user_skip_list_unit)
117
-{
110
+function db_unit_records_plain($unit_id, $user_skip_list_unit) {
118 111
   return doquery (
119 112
     "SELECT unit_player_id, username, unit_level
120 113
           FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id
@@ -198,25 +191,21 @@  discard block
 block discarded – undo
198 191
 }
199 192
 
200 193
 
201
-function db_stat_list_update_user_stats()
202
-{
194
+function db_stat_list_update_user_stats() {
203 195
   return doquery("UPDATE {{users}} AS u JOIN {{statpoints}} AS sp ON sp.id_owner = u.id AND sp.stat_code = 1 AND sp.stat_type = 1 SET u.total_rank = sp.total_rank, u.total_points = sp.total_points WHERE user_as_ally IS NULL;");
204 196
 }
205 197
 
206
-function db_stat_list_update_ally_stats()
207
-{
198
+function db_stat_list_update_ally_stats() {
208 199
   return doquery("UPDATE {{alliance}} AS a JOIN {{statpoints}} AS sp ON sp.id_ally = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;");
209 200
 }
210 201
 
211
-function db_stat_list_delete_ally_player()
212
-{
202
+function db_stat_list_delete_ally_player() {
213 203
   return doquery('DELETE s FROM {{statpoints}} AS s JOIN {{users}} AS u ON u.id = s.id_owner WHERE s.id_ally IS NULL AND u.user_as_ally IS NOT NULL');
214 204
 }
215 205
 
216 206
 
217 207
 
218
-function db_chat_player_list_online($chat_refresh_rate, $ally_add)
219
-{
208
+function db_chat_player_list_online($chat_refresh_rate, $ally_add) {
220 209
   $sql_date = SN_TIME_NOW - $chat_refresh_rate * 2;
221 210
 
222 211
   return doquery(
@@ -230,13 +219,11 @@  discard block
 block discarded – undo
230 219
     ORDER BY authlevel DESC, `username`");
231 220
 }
232 221
 
233
-function db_referrals_list_by_id($user_id)
234
-{
222
+function db_referrals_list_by_id($user_id) {
235 223
   return doquery("SELECT r.*, u.username, u.register_time FROM {{referrals}} AS r LEFT JOIN {{users}} AS u ON u.id = r.id WHERE id_partner = {$user_id}");
236 224
 }
237 225
 
238
-function db_message_list_admin_by_type($int_type_selected, $StartRec)
239
-{
226
+function db_message_list_admin_by_type($int_type_selected, $StartRec) {
240 227
   return doquery("SELECT
241 228
   message_id as `ID`,
242 229
   message_from as `FROM`,
@@ -255,8 +242,7 @@  discard block
 block discarded – undo
255 242
 }
256 243
 
257 244
 
258
-function db_message_insert_all($message_type, $from, $subject, $text)
259
-{
245
+function db_message_insert_all($message_type, $from, $subject, $text) {
260 246
   return doquery($QryInsertMessage = 'INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' .
261 247
     "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}");
262 248
 }
Please login to merge, or discard this patch.
includes/general_pname.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,12 +2,10 @@
 block discarded – undo
2 2
 
3 3
 // Эти функции будут переписаны по добавлению инфы в БД
4 4
 
5
-function pname_factory_production_field_name($factory_unit_id)
6
-{
5
+function pname_factory_production_field_name($factory_unit_id) {
7 6
   return get_unit_param($factory_unit_id, P_NAME) . '_porcent';
8 7
 }
9 8
 
10
-function pname_resource_name($resource_id)
11
-{
9
+function pname_resource_name($resource_id) {
12 10
   return get_unit_param($resource_id, P_NAME);
13 11
 }
14 12
\ No newline at end of file
Please login to merge, or discard this patch.
includes/functions/int_fleet_events.php 1 patch
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,8 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 
4
-function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false)
5
-{
4
+function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false) {
6 5
   global $config, $user, $fleet_number, $lang;
7 6
 
8 7
   $fleet_events = array();
@@ -23,12 +22,10 @@  discard block
 block discarded – undo
23 22
     if($fleet['fleet_end_planet'] > $config->game_maxPlanet)
24 23
     {
25 24
       $fleet['fleet_end_name'] = $lang['ov_fleet_exploration'];
26
-    }
27
-    elseif($fleet['fleet_mission'] == MT_COLONIZE)
25
+    } elseif($fleet['fleet_mission'] == MT_COLONIZE)
28 26
     {
29 27
       $fleet['fleet_end_name'] = $lang['ov_fleet_colonization'];
30
-    }
31
-    else
28
+    } else
32 29
     {
33 30
       $planet_end = DBStaticPlanet::db_planet_by_gspt($fleet['fleet_end_galaxy'], $fleet['fleet_end_system'], $fleet['fleet_end_planet'], $planet_end_type, false, 'name');
34 31
       $fleet['fleet_end_name'] = $planet_end['name'];
@@ -80,8 +77,7 @@  discard block
 block discarded – undo
80 77
   return $fleet_events;
81 78
 }
82 79
 
83
-function flt_register_fleet_event($fleet, $ov_label, $planet_end_type)
84
-{
80
+function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) {
85 81
   global $user, $planetrow, $fleet_number;
86 82
 
87 83
   switch($fleet['ov_label'] = $ov_label)
@@ -121,8 +117,7 @@  discard block
 block discarded – undo
121 117
   if($fleet['fleet_owner'] == $user['id'])
122 118
   {
123 119
     $user_data = $user;
124
-  }
125
-  else
120
+  } else
126 121
   {
127 122
     $user_data = db_user_by_id($fleet['fleet_owner']);
128 123
   }
@@ -130,8 +125,7 @@  discard block
 block discarded – undo
130 125
   return tpl_parse_fleet_db($fleet, ++$fleet_number, $user_data);
131 126
 }
132 127
 
133
-function int_planet_pretemplate($planetrow, &$template)
134
-{
128
+function int_planet_pretemplate($planetrow, &$template) {
135 129
   global $lang, $user;
136 130
 
137 131
   $governor_id = $planetrow['PLANET_GOVERNOR_ID'];
Please login to merge, or discard this patch.
includes/functions/ali_alliances.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function ali_rank_list_save($ranks)
4
-{
3
+function ali_rank_list_save($ranks) {
5 4
   global $user;
6 5
 
7 6
   if(!empty($ranks))
@@ -17,8 +16,7 @@  discard block
 block discarded – undo
17 16
   return $ranklist;
18 17
 }
19 18
 
20
-function ali_relations($ally_from, $ally_to = 0)
21
-{
19
+function ali_relations($ally_from, $ally_to = 0) {
22 20
   $ally_to = intval($ally_to);
23 21
   $ally_to = $ally_to ? " AND alliance_diplomacy_contr_ally_id = {$ally_to}" : '';
24 22
 
@@ -45,8 +43,7 @@  discard block
 block discarded – undo
45 43
   return $temp_array;
46 44
 }
47 45
 
48
-function ali_relation($ally_from, $ally_to)
49
-{
46
+function ali_relation($ally_from, $ally_to) {
50 47
   $relation = ali_relations($ally_from, $ally_to);
51 48
   return empty($relation) ? ALLY_DIPLOMACY_NEUTRAL : $relation[$ally_to]['alliance_diplomacy_relation'];
52 49
 }
Please login to merge, or discard this patch.
includes/functions/uni_functions.php 1 patch
Braces   +14 added lines, -23 removed lines patch added patch discarded remove patch
@@ -242,24 +242,24 @@  discard block
 block discarded – undo
242 242
  * 1 - copyright 2008 By Chlorel for XNova
243 243
  *
244 244
  */
245
-function SetSelectedPlanet(&$user)
246
-{
245
+function SetSelectedPlanet(&$user) {
247 246
   $planet_row['id'] = $user['current_planet'];
248 247
 
249 248
   // Пытаемся переключить на новую планету
250 249
   if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet'])
251 250
   {
252 251
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id');
253
-  }
254
-  else
252
+  } else
255 253
   {
256 254
     $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']);
257 255
   }
258 256
 
259 257
   // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету
260
-  if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
258
+  if(!isset($planet_row['id'])) {
259
+    // || $planet_row['id'] != $user['current_planet']
261 260
   {
262 261
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id');
262
+  }
263 263
     // Если текущей планеты не существует - выставляем Столицу
264 264
     if(!isset($planet_row['id']))
265 265
     {
@@ -284,25 +284,21 @@  discard block
 block discarded – undo
284 284
 }
285 285
 
286 286
 // ----------------------------------------------------------------------------------------------------------------
287
-function uni_render_coordinates($from, $prefix = '')
288
-{
287
+function uni_render_coordinates($from, $prefix = '') {
289 288
   return "[{$from[$prefix . 'galaxy']}:{$from[$prefix . 'system']}:{$from[$prefix . 'planet']}]";
290 289
 }
291 290
 
292
-function uni_render_planet($from)
293
-{
291
+function uni_render_planet($from) {
294 292
   return "{$from['name']} [{$from['galaxy']}:{$from['system']}:{$from['planet']}]";
295 293
 }
296 294
 
297
-function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false)
298
-{
295
+function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) {
299 296
   global $lang;
300 297
 
301 298
   if(!$from['id'])
302 299
   {
303 300
     $result = $lang['sys_planet_expedition'];
304
-  }
305
-  else
301
+  } else
306 302
   {
307 303
     $from_planet_id = $include_id ? (
308 304
       'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} '
@@ -318,30 +314,25 @@  discard block
 block discarded – undo
318 314
   return $result;
319 315
 }
320 316
 
321
-function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php')
322
-{
317
+function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') {
323 318
   return $page . (strpos($page, '?') === false ? '?' : '&') . "galaxy={$from[$prefix . 'galaxy']}&system={$from[$prefix . 'system']}&planet={$from[$prefix . 'planet']}";
324 319
 }
325 320
 
326
-function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '')
327
-{
321
+function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') {
328 322
   return '<a href="' . uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}") . '"' . ($fleet_type ? " {$fleet_type}" : '') . '>' . uni_render_coordinates($from, $prefix) . '</a>';
329 323
 }
330 324
 
331
-function uni_get_time_to_jump($moon_row)
332
-{
325
+function uni_get_time_to_jump($moon_row) {
333 326
   $jump_gate_level = mrc_get_level($user, $moon_row, STRUC_MOON_GATE);
334 327
   return $jump_gate_level ? max(0, $moon_row['last_jump_time'] + abs(60 * 60 / $jump_gate_level) - SN_TIME_NOW) : 0;
335 328
 }
336 329
 
337
-function uni_calculate_moon_chance($FleetDebris)
338
-{
330
+function uni_calculate_moon_chance($FleetDebris) {
339 331
   $MoonChance = $FleetDebris / 1000000;
340 332
   return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance);
341 333
 }
342 334
 
343
-function uni_coordinates_valid($coordinates, $prefix = '')
344
-{
335
+function uni_coordinates_valid($coordinates, $prefix = '') {
345 336
   global $config;
346 337
 
347 338
   // array_walk($coordinates, 'intval');
Please login to merge, or discard this patch.
includes/functions/flt_mission_missile.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@  discard block
 block discarded – undo
4 4
 // Open Source
5 5
 // V1
6 6
 //
7
-function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0')
8
-{
7
+function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') {
9 8
   // Here we select which part of defense should take damage: structure or shield
10 9
   // $damageTo = P_SHIELD;
11 10
   // $damageTo = P_STRUCTURE;
@@ -34,8 +33,7 @@  discard block
 block discarded – undo
34 33
     $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] );
35 34
     $structures[$targetedStructure][0] -= $structsDestroyed;
36 35
     $MIPDamage -= $structsDestroyed*$damageDone;
37
-  }
38
-  else
36
+  } else
39 37
   {
40 38
     // REALLY random attack
41 39
     $can_be_damaged = sn_get_groups('defense_active');
Please login to merge, or discard this patch.
includes/functions/rpg_points.php 1 patch
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -161,8 +161,7 @@  discard block
 block discarded – undo
161 161
   return $rows_affected;
162 162
 }
163 163
 
164
-function rpg_level_up(&$user, $type, $xp_to_add = 0)
165
-{
164
+function rpg_level_up(&$user, $type, $xp_to_add = 0) {
166 165
   $q = 1.03;
167 166
 
168 167
   switch($type)
@@ -223,27 +222,22 @@  discard block
 block discarded – undo
223 222
   }
224 223
 }
225 224
 
226
-function rpg_xp_for_level($level, $b1, $q)
227
-{
225
+function rpg_xp_for_level($level, $b1, $q) {
228 226
   return floor($b1 * (pow($q, $level) - 1)/($q - 1));
229 227
 }
230 228
 
231
-function rpg_get_miner_xp($level)
232
-{
229
+function rpg_get_miner_xp($level) {
233 230
   return rpg_xp_for_level($level, 50, 1.03);
234 231
 }
235 232
 
236
-function RPG_get_raider_xp($level)
237
-{
233
+function RPG_get_raider_xp($level) {
238 234
   return rpg_xp_for_level($level, 10, 1.03);
239 235
 }
240 236
 
241
-function rpg_get_tech_xp($level)
242
-{
237
+function rpg_get_tech_xp($level) {
243 238
   return rpg_xp_for_level($level, 50, 1.03);
244 239
 }
245 240
 
246
-function rpg_get_explore_xp($level)
247
-{
241
+function rpg_get_explore_xp($level) {
248 242
   return rpg_xp_for_level($level, 10, 1.05);
249 243
 }
Please login to merge, or discard this patch.
includes/functions/eco_queue.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -458,8 +458,7 @@
 block discarded – undo
458 458
 
459 459
     if(is_numeric($planet['id'])) {
460 460
       DBStaticPlanet::db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())");
461
-    }
462
-    elseif(is_numeric($user['id'])) {
461
+    } elseif(is_numeric($user['id'])) {
463 462
       db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())');
464 463
     }
465 464
 
Please login to merge, or discard this patch.