@@ -58,8 +58,8 @@ |
||
58 | 58 | protected function bonusSort(BonusAtom $a, BonusAtom $b) { |
59 | 59 | static $bonusOrder = [BonusAtom::class, BonusAtomAbility::class, BonusAtomAdd::class, BonusAtomPercent::class, BonusAtomMultiply::class]; |
60 | 60 | |
61 | - $indexA = (int)array_search(get_class($a), $bonusOrder); |
|
62 | - $indexB = (int)array_search(get_class($b), $bonusOrder); |
|
61 | + $indexA = (int) array_search(get_class($a), $bonusOrder); |
|
62 | + $indexB = (int) array_search(get_class($b), $bonusOrder); |
|
63 | 63 | |
64 | 64 | return $indexA == $indexB ? 0 : ($indexA > $indexB ? +1 : -1); |
65 | 65 | } |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | } |
9 | 9 | |
10 | 10 | $speeds = array(); |
11 | - if(!empty($fleet)) |
|
11 | + if (!empty($fleet)) |
|
12 | 12 | { |
13 | 13 | foreach ($fleet as $ship_id => $amount) |
14 | 14 | { |
15 | - if($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) |
|
15 | + if ($amount && in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) |
|
16 | 16 | { |
17 | 17 | $single_ship_data = get_ship_data($ship_id, $user); |
18 | 18 | $speeds[] = $single_ship_data['speed']; |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | function flt_travel_distance($from, $to) { |
27 | 27 | global $config; |
28 | 28 | |
29 | - if($from['galaxy'] != $to['galaxy']) |
|
29 | + if ($from['galaxy'] != $to['galaxy']) |
|
30 | 30 | { |
31 | 31 | $distance = abs($from['galaxy'] - $to['galaxy']) * $config->uni_galaxy_distance; |
32 | 32 | } |
33 | - elseif($from['system'] != $to['system']) |
|
33 | + elseif ($from['system'] != $to['system']) |
|
34 | 34 | { |
35 | 35 | $distance = abs($from['system'] - $to['system']) * 5 * 19 + 2700; |
36 | 36 | } |
37 | - elseif($from['planet'] != $to['planet']) |
|
37 | + elseif ($from['planet'] != $to['planet']) |
|
38 | 38 | { |
39 | 39 | $distance = abs($from['planet'] - $to['planet']) * 5 + 1000; |
40 | 40 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | |
66 | 66 | $game_fleet_speed = flt_server_flight_speed_multiplier(); |
67 | 67 | $fleet_speed = flt_fleet_speed($user_row, $fleet_array); |
68 | - if(!empty($fleet_array) && $fleet_speed && $game_fleet_speed) |
|
68 | + if (!empty($fleet_array) && $fleet_speed && $game_fleet_speed) |
|
69 | 69 | { |
70 | 70 | $speed_percent = $speed_percent ? max(min($speed_percent, 10), 1) : 10; |
71 | 71 | $real_speed = $speed_percent * sqrt($fleet_speed); |
72 | 72 | |
73 | 73 | $duration = max(1, round((35000 / $speed_percent * sqrt($distance * 10 / $fleet_speed) + 10) / $game_fleet_speed)); |
74 | 74 | |
75 | - foreach($fleet_array as $ship_id => $ship_count) |
|
75 | + foreach ($fleet_array as $ship_id => $ship_count) |
|
76 | 76 | { |
77 | 77 | if (!$ship_id || !$ship_count) |
78 | 78 | { |
@@ -126,19 +126,19 @@ discard block |
||
126 | 126 | |
127 | 127 | $config_bashing_attacks = $config->fleet_bashing_attacks; |
128 | 128 | $config_bashing_interval = $config->fleet_bashing_interval; |
129 | - if(!$config_bashing_attacks) { |
|
129 | + if (!$config_bashing_attacks) { |
|
130 | 130 | // Bashing allowed - protection disabled |
131 | 131 | return ATTACK_ALLOWED; |
132 | 132 | } |
133 | 133 | |
134 | 134 | $bashing_result = ATTACK_BASHING; |
135 | - if($user['ally_id'] && $enemy['ally_id']) { |
|
135 | + if ($user['ally_id'] && $enemy['ally_id']) { |
|
136 | 136 | $relations = ali_relations($user['ally_id'], $enemy['ally_id']); |
137 | - if(!empty($relations)) { |
|
137 | + if (!empty($relations)) { |
|
138 | 138 | $relations = $relations[$enemy['ally_id']]; |
139 | - switch($relations['alliance_diplomacy_relation']) { |
|
139 | + switch ($relations['alliance_diplomacy_relation']) { |
|
140 | 140 | case ALLY_DIPLOMACY_WAR: |
141 | - if(SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= $config->fleet_bashing_war_delay) { |
|
141 | + if (SN_TIME_NOW - $relations['alliance_diplomacy_time'] <= $config->fleet_bashing_war_delay) { |
|
142 | 142 | $bashing_result = ATTACK_BASHING_WAR_DELAY; |
143 | 143 | } else { |
144 | 144 | return ATTACK_ALLOWED; |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | // } |
176 | 176 | // } |
177 | 177 | $bashing_fleet_list = fleet_list_bashing($user['id'], $planet_dst); |
178 | - foreach($bashing_fleet_list as $fleet_row) { |
|
178 | + foreach ($bashing_fleet_list as $fleet_row) { |
|
179 | 179 | // Checking for ACS - each ACS count only once |
180 | - if($fleet_row['fleet_group']) { |
|
180 | + if ($fleet_row['fleet_group']) { |
|
181 | 181 | $bashing_list["{$user['id']}_{$fleet_row['fleet_group']}"] = $fleet_row['fleet_start_time']; |
182 | 182 | } else { |
183 | 183 | $bashing_list[] = $fleet_row['fleet_start_time']; |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | // Check for joining to ACS - if there are already fleets in ACS no checks should be done |
188 | - if($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
188 | + if ($mission == MT_AKS && $bashing_list["{$user['id']}_{$fleet_group}"]) { |
|
189 | 189 | return ATTACK_ALLOWED; |
190 | 190 | } |
191 | 191 | |
192 | 192 | $query = doquery("SELECT bashing_time FROM {{bashing}} WHERE bashing_user_id = {$user['id']} AND bashing_planet_id = {$planet_dst['id']} AND bashing_time >= {$time_limit};"); |
193 | - while($bashing_row = db_fetch($query)) { |
|
193 | + while ($bashing_row = db_fetch($query)) { |
|
194 | 194 | $bashing_list[] = $bashing_row['bashing_time']; |
195 | 195 | } |
196 | 196 | |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | $last_attack = 0; |
200 | 200 | $wave = 0; |
201 | 201 | $attack = 1; |
202 | - foreach($bashing_list as &$bash_time) { |
|
202 | + foreach ($bashing_list as &$bash_time) { |
|
203 | 203 | $attack++; |
204 | - if($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
204 | + if ($bash_time - $last_attack > $config_bashing_interval || $attack > $config_bashing_attacks) { |
|
205 | 205 | $attack = 1; |
206 | 206 | $wave++; |
207 | 207 | } |
@@ -212,21 +212,21 @@ discard block |
||
212 | 212 | return ($wave > $config->fleet_bashing_waves ? $bashing_result : ATTACK_ALLOWED); |
213 | 213 | } |
214 | 214 | |
215 | -function flt_can_attack($planet_src, $planet_dst, $fleet = array(), $mission, $options = false){$result = null; return sn_function_call('flt_can_attack', array($planet_src, $planet_dst, $fleet, $mission, $options, &$result));} |
|
215 | +function flt_can_attack($planet_src, $planet_dst, $fleet = array(), $mission, $options = false) {$result = null; return sn_function_call('flt_can_attack', array($planet_src, $planet_dst, $fleet, $mission, $options, &$result)); } |
|
216 | 216 | function sn_flt_can_attack($planet_src, $planet_dst, $fleet = array(), $mission, $options = false, &$result) { |
217 | 217 | //TODO: try..catch |
218 | 218 | global $config, $user; |
219 | 219 | |
220 | - if($user['vacation']) { |
|
220 | + if ($user['vacation']) { |
|
221 | 221 | return $result = ATTACK_OWN_VACATION; |
222 | 222 | } |
223 | 223 | |
224 | - if(empty($fleet) || !is_array($fleet)) { |
|
224 | + if (empty($fleet) || !is_array($fleet)) { |
|
225 | 225 | return $result = ATTACK_NO_FLEET; |
226 | 226 | } |
227 | 227 | |
228 | 228 | $sn_groups_mission = sn_get_groups('missions'); |
229 | - if(!isset($sn_groups_mission[$mission])) { |
|
229 | + if (!isset($sn_groups_mission[$mission])) { |
|
230 | 230 | return $result = ATTACK_MISSION_ABSENT; |
231 | 231 | } |
232 | 232 | $sn_data_mission = $sn_groups_mission[$mission]; |
@@ -245,32 +245,32 @@ discard block |
||
245 | 245 | $resources = 0; |
246 | 246 | $ship_ids = sn_get_groups('fleet'); |
247 | 247 | $resource_ids = sn_get_groups('resources_loot'); |
248 | - foreach($fleet as $ship_id => $ship_count) { |
|
248 | + foreach ($fleet as $ship_id => $ship_count) { |
|
249 | 249 | $is_ship = in_array($ship_id, $ship_ids); |
250 | 250 | $is_resource = in_array($ship_id, $resource_ids); |
251 | - if(!$is_ship && !$is_resource) { |
|
251 | + if (!$is_ship && !$is_resource) { |
|
252 | 252 | // TODO Спецобработчик для Капитана и модулей |
253 | 253 | // return ATTACK_WRONG_UNIT; |
254 | 254 | } |
255 | 255 | |
256 | - if($ship_count < 0) { |
|
256 | + if ($ship_count < 0) { |
|
257 | 257 | return $result = $is_ship ? ATTACK_SHIP_COUNT_WRONG : ATTACK_RESOURCE_COUNT_WRONG; |
258 | 258 | } |
259 | 259 | |
260 | - if($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
260 | + if ($ship_count > mrc_get_level($user, $planet_src, $ship_id)) { |
|
261 | 261 | // TODO ATTACK_NO_MISSILE |
262 | 262 | return $result = $is_ship ? ATTACK_NO_SHIPS : ATTACK_NO_RESOURCES; |
263 | 263 | } |
264 | 264 | |
265 | - if($is_ship) { |
|
265 | + if ($is_ship) { |
|
266 | 266 | $single_ship_data = get_ship_data($ship_id, $user); |
267 | - if($single_ship_data[P_SPEED] <= 0) { |
|
267 | + if ($single_ship_data[P_SPEED] <= 0) { |
|
268 | 268 | return $result = ATTACK_ZERO_SPEED; |
269 | 269 | } |
270 | 270 | $ships += $ship_count; |
271 | 271 | $recyclers += in_array($ship_id, sn_get_groups('flt_recyclers')) ? $ship_count : 0; |
272 | 272 | $spies += $ship_id == SHIP_SPY ? $ship_count : 0; |
273 | - } elseif($is_resource) { |
|
273 | + } elseif ($is_resource) { |
|
274 | 274 | $resources += $ship_count; |
275 | 275 | } |
276 | 276 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | } |
282 | 282 | */ |
283 | 283 | |
284 | - if(isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
284 | + if (isset($options['resources']) && $options['resources'] > 0 && !(isset($sn_data_mission['transport']) && $sn_data_mission['transport'])) { |
|
285 | 285 | return $result = ATTACK_RESOURCE_FORBIDDEN; |
286 | 286 | } |
287 | 287 | |
@@ -293,35 +293,35 @@ discard block |
||
293 | 293 | */ |
294 | 294 | |
295 | 295 | $speed = $options['fleet_speed_percent']; |
296 | - if($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
296 | + if ($speed && ($speed != intval($speed) || $speed < 1 || $speed > 10)) { |
|
297 | 297 | return $result = ATTACK_WRONG_SPEED; |
298 | 298 | } |
299 | 299 | |
300 | 300 | $travel_data = flt_travel_data($user, $planet_src, $planet_dst, $fleet, $options['fleet_speed_percent']); |
301 | 301 | |
302 | 302 | |
303 | - if(mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
303 | + if (mrc_get_level($user, $planet_src, RES_DEUTERIUM) < $fleet[RES_DEUTERIUM] + $travel_data['consumption']) { |
|
304 | 304 | return $result = ATTACK_NO_FUEL; |
305 | 305 | } |
306 | 306 | |
307 | - if($travel_data['consumption'] > $travel_data['capacity']) { |
|
307 | + if ($travel_data['consumption'] > $travel_data['capacity']) { |
|
308 | 308 | return $result = ATTACK_TOO_FAR; |
309 | 309 | } |
310 | 310 | |
311 | - if($travel_data['hold'] < $resources) { |
|
311 | + if ($travel_data['hold'] < $resources) { |
|
312 | 312 | return $result = ATTACK_OVERLOADED; |
313 | 313 | } |
314 | 314 | |
315 | 315 | $fleet_start_time = SN_TIME_NOW + $travel_data['duration']; |
316 | 316 | |
317 | 317 | $fleet_group = $options['fleet_group']; |
318 | - if($fleet_group) { |
|
319 | - if($mission != MT_AKS) { |
|
318 | + if ($fleet_group) { |
|
319 | + if ($mission != MT_AKS) { |
|
320 | 320 | return $result = ATTACK_WRONG_MISSION; |
321 | 321 | }; |
322 | 322 | |
323 | 323 | $acs = doquery("SELECT * FROM {{aks}} WHERE id = '{$fleet_group}' LIMIT 1;", '', true); |
324 | - if(!$acs['id']) { |
|
324 | + if (!$acs['id']) { |
|
325 | 325 | return $result = ATTACK_NO_ACS; |
326 | 326 | } |
327 | 327 | |
@@ -329,70 +329,70 @@ discard block |
||
329 | 329 | return $result = ATTACK_ACS_WRONG_TARGET; |
330 | 330 | } |
331 | 331 | |
332 | - if ($fleet_start_time>$acs['ankunft']) { |
|
332 | + if ($fleet_start_time > $acs['ankunft']) { |
|
333 | 333 | return $result = ATTACK_ACS_TOO_LATE; |
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | 337 | $flying_fleets = $options['flying_fleets']; |
338 | - if(!$flying_fleets) { |
|
338 | + if (!$flying_fleets) { |
|
339 | 339 | // $flying_fleets = doquery("SELECT COUNT(fleet_id) AS `flying_fleets` FROM {{fleets}} WHERE `fleet_owner` = '{$user['id']}';", '', true); |
340 | 340 | // $flying_fleets = $flying_fleets['flying_fleets']; |
341 | 341 | $flying_fleets = fleet_count_flying($user['id']); |
342 | 342 | } |
343 | - if(GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
343 | + if (GetMaxFleets($user) <= $flying_fleets && $mission != MT_MISSILE) { |
|
344 | 344 | return $result = ATTACK_NO_SLOTS; |
345 | 345 | } |
346 | 346 | |
347 | 347 | // В одиночку шпионские зонды могут летать только в миссии Шпионаж, Передислокация и Транспорт |
348 | - if($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
348 | + if ($ships && $spies && $spies == $ships && !($mission == MT_SPY || $mission == MT_RELOCATE || $mission == MT_TRANSPORT)) { |
|
349 | 349 | return $result = ATTACK_SPIES_LONLY; |
350 | 350 | } |
351 | 351 | |
352 | 352 | // Checking for no planet |
353 | - if(!$planet_dst['id_owner']) { |
|
354 | - if($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
353 | + if (!$planet_dst['id_owner']) { |
|
354 | + if ($mission == MT_COLONIZE && !$fleet[SHIP_COLONIZER]) { |
|
355 | 355 | return $result = ATTACK_NO_COLONIZER; |
356 | 356 | } |
357 | 357 | |
358 | - if($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
358 | + if ($mission == MT_EXPLORE || $mission == MT_COLONIZE) { |
|
359 | 359 | return $result = ATTACK_ALLOWED; |
360 | 360 | } |
361 | 361 | return $result = ATTACK_NO_TARGET; |
362 | 362 | } |
363 | 363 | |
364 | - if($mission == MT_RECYCLE) { |
|
365 | - if($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
364 | + if ($mission == MT_RECYCLE) { |
|
365 | + if ($planet_dst['debris_metal'] + $planet_dst['debris_crystal'] <= 0) { |
|
366 | 366 | return $result = ATTACK_NO_DEBRIS; |
367 | 367 | } |
368 | - if($recyclers <= 0) { |
|
368 | + if ($recyclers <= 0) { |
|
369 | 369 | return $result = ATTACK_NO_RECYCLERS; |
370 | 370 | } |
371 | 371 | return $result = ATTACK_ALLOWED; |
372 | 372 | } |
373 | 373 | |
374 | 374 | // Got planet. Checking if it is ours |
375 | - if($planet_dst['id_owner'] == $user['id']) { |
|
376 | - if($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
375 | + if ($planet_dst['id_owner'] == $user['id']) { |
|
376 | + if ($mission == MT_TRANSPORT || $mission == MT_RELOCATE) { |
|
377 | 377 | return $result = ATTACK_ALLOWED; |
378 | 378 | } |
379 | 379 | return $planet_src['id'] == $planet_dst['id'] ? ATTACK_SAME : ATTACK_OWN; |
380 | 380 | } |
381 | 381 | |
382 | 382 | // No, planet not ours. Cutting mission that can't be send to not-ours planet |
383 | - if($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
383 | + if ($mission == MT_RELOCATE || $mission == MT_COLONIZE || $mission == MT_EXPLORE) { |
|
384 | 384 | return $result = ATTACK_WRONG_MISSION; |
385 | 385 | } |
386 | 386 | |
387 | 387 | $enemy = db_user_by_id($planet_dst['id_owner']); |
388 | 388 | // We cannot attack or send resource to users in VACATION mode |
389 | - if($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
389 | + if ($enemy['vacation'] && $mission != MT_RECYCLE) { |
|
390 | 390 | return $result = ATTACK_VACATION; |
391 | 391 | } |
392 | 392 | |
393 | 393 | // Multi IP protection |
394 | 394 | // TODO: Here we need a procedure to check proxies |
395 | - if(sys_is_multiaccount($user, $enemy)) { |
|
395 | + if (sys_is_multiaccount($user, $enemy)) { |
|
396 | 396 | return $result = ATTACK_SAME_IP; |
397 | 397 | } |
398 | 398 | |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | $enemy_points = $enemy['total_points']; |
401 | 401 | |
402 | 402 | // Is it transport? If yes - checking for buffing to prevent mega-alliance destroyer |
403 | - if($mission == MT_TRANSPORT) { |
|
404 | - if($user_points >= $enemy_points || $config->allow_buffing) { |
|
403 | + if ($mission == MT_TRANSPORT) { |
|
404 | + if ($user_points >= $enemy_points || $config->allow_buffing) { |
|
405 | 405 | return $result = ATTACK_ALLOWED; |
406 | 406 | } else { |
407 | 407 | return $result = ATTACK_BUFFING; |
@@ -411,65 +411,65 @@ discard block |
||
411 | 411 | // Only aggresive missions passed to this point. HOLD counts as passive but aggresive |
412 | 412 | |
413 | 413 | // Is it admin with planet protection? |
414 | - if($planet_dst['id_level'] > $user['authlevel']) { |
|
414 | + if ($planet_dst['id_level'] > $user['authlevel']) { |
|
415 | 415 | return $result = ATTACK_ADMIN; |
416 | 416 | } |
417 | 417 | |
418 | 418 | // Okay. Now skipping protection checks for inactive longer then 1 week |
419 | - if(!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60*60*24*7)) { |
|
420 | - if( |
|
419 | + if (!$enemy['onlinetime'] || $enemy['onlinetime'] >= (SN_TIME_NOW - 60 * 60 * 24 * 7)) { |
|
420 | + if ( |
|
421 | 421 | (classSupernova::$gc->general->playerIsNoobByPoints($enemy_points) && !classSupernova::$gc->general->playerIsNoobByPoints($user_points)) |
422 | 422 | || |
423 | 423 | (classSupernova::$gc->general->playerIs1stStrongerThen2nd($user_points, $enemy_points)) |
424 | 424 | ) { |
425 | - if($mission != MT_HOLD) { |
|
425 | + if ($mission != MT_HOLD) { |
|
426 | 426 | return $result = ATTACK_NOOB; |
427 | 427 | } |
428 | - if($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && $config->ally_help_weak)) { |
|
428 | + if ($mission == MT_HOLD && !($user['ally_id'] && $user['ally_id'] == $enemy['ally_id'] && $config->ally_help_weak)) { |
|
429 | 429 | return $result = ATTACK_NOOB; |
430 | 430 | } |
431 | 431 | } |
432 | 432 | } |
433 | 433 | |
434 | 434 | // Is it HOLD mission? If yes - there should be ally deposit |
435 | - if($mission == MT_HOLD) { |
|
436 | - if(mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
435 | + if ($mission == MT_HOLD) { |
|
436 | + if (mrc_get_level($user, $planet_dst, STRUC_ALLY_DEPOSIT)) { |
|
437 | 437 | return $result = ATTACK_ALLOWED; |
438 | 438 | } |
439 | 439 | return $result = ATTACK_NO_ALLY_DEPOSIT; |
440 | 440 | } |
441 | 441 | |
442 | - if($mission == MT_SPY) { |
|
442 | + if ($mission == MT_SPY) { |
|
443 | 443 | return $result = $spies >= 1 ? ATTACK_ALLOWED : ATTACK_NO_SPIES; |
444 | 444 | } |
445 | 445 | |
446 | 446 | // Is it MISSILE mission? |
447 | - if($mission == MT_MISSILE) { |
|
447 | + if ($mission == MT_MISSILE) { |
|
448 | 448 | $sn_data_mip = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); |
449 | - if(mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
449 | + if (mrc_get_level($user, $planet_src, STRUC_SILO) < $sn_data_mip[P_REQUIRE][STRUC_SILO]) { |
|
450 | 450 | return $result = ATTACK_NO_SILO; |
451 | 451 | } |
452 | 452 | |
453 | - if(!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
453 | + if (!$fleet[UNIT_DEF_MISSILE_INTERPLANET]) { |
|
454 | 454 | return $result = ATTACK_NO_MISSILE; |
455 | 455 | } |
456 | 456 | |
457 | 457 | $distance = abs($planet_dst['system'] - $planet_src['system']); |
458 | 458 | $mip_range = flt_get_missile_range($user); |
459 | - if($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
459 | + if ($distance > $mip_range || $planet_dst['galaxy'] != $planet_src['galaxy']) { |
|
460 | 460 | return $result = ATTACK_MISSILE_TOO_FAR; |
461 | 461 | } |
462 | 462 | |
463 | - if(isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
463 | + if (isset($options['target_structure']) && $options['target_structure'] && !in_array($options['target_structure'], sn_get_groups('defense_active'))) { |
|
464 | 464 | return $result = ATTACK_WRONG_STRUCTURE; |
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
468 | - if($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
468 | + if ($mission == MT_DESTROY && $planet_dst['planet_type'] != PT_MOON) { |
|
469 | 469 | return $result = ATTACK_WRONG_MISSION; |
470 | 470 | } |
471 | 471 | |
472 | - if($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) { |
|
472 | + if ($mission == MT_ATTACK || $mission == MT_AKS || $mission == MT_DESTROY) { |
|
473 | 473 | return $result = flt_bashing_check($user, $enemy, $planet_dst, $mission, $travel_data['duration'], $fleet_group); |
474 | 474 | } |
475 | 475 | |
@@ -495,18 +495,18 @@ discard block |
||
495 | 495 | $from = $from['planet']; |
496 | 496 | |
497 | 497 | $can_attack = flt_can_attack($from, $to, $fleet, $mission, $options); |
498 | - if($can_attack != ATTACK_ALLOWED) { |
|
498 | + if ($can_attack != ATTACK_ALLOWED) { |
|
499 | 499 | $internal_transaction ? sn_db_transaction_rollback() : false; |
500 | 500 | return $can_attack; |
501 | 501 | } |
502 | 502 | |
503 | 503 | $fleet_group = isset($options['fleet_group']) ? floatval($options['fleet_group']) : 0; |
504 | 504 | |
505 | - $travel_data = flt_travel_data($user, $from, $to, $fleet, $options['fleet_speed_percent']); |
|
505 | + $travel_data = flt_travel_data($user, $from, $to, $fleet, $options['fleet_speed_percent']); |
|
506 | 506 | |
507 | 507 | $fleet_start_time = SN_TIME_NOW + $travel_data['duration']; |
508 | 508 | |
509 | - if($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
509 | + if ($mission == MT_EXPLORE || $mission == MT_HOLD) { |
|
510 | 510 | $stay_duration = $options['stay_time'] * 3600; |
511 | 511 | $stay_time = $fleet_start_time + $stay_duration; |
512 | 512 | } else { |
@@ -519,20 +519,20 @@ discard block |
||
519 | 519 | $fleet_string = ''; |
520 | 520 | $db_changeset = array(); |
521 | 521 | $planet_fields = array(); |
522 | - foreach($fleet as $unit_id => $amount) |
|
522 | + foreach ($fleet as $unit_id => $amount) |
|
523 | 523 | { |
524 | - if(!$amount || !$unit_id) |
|
524 | + if (!$amount || !$unit_id) |
|
525 | 525 | { |
526 | 526 | continue; |
527 | 527 | } |
528 | 528 | |
529 | - if(in_array($unit_id, sn_get_groups('fleet'))) |
|
529 | + if (in_array($unit_id, sn_get_groups('fleet'))) |
|
530 | 530 | { |
531 | 531 | $fleet_ship_count += $amount; |
532 | 532 | $fleet_string .= "{$unit_id},{$amount};"; |
533 | 533 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, -$amount, $user, $from['id']); |
534 | 534 | } |
535 | - elseif(in_array($unit_id, sn_get_groups('resources_loot'))) |
|
535 | + elseif (in_array($unit_id, sn_get_groups('resources_loot'))) |
|
536 | 536 | { |
537 | 537 | $planet_fields[pname_resource_name($unit_id)]['delta'] -= $amount; |
538 | 538 | } |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | |
641 | 641 | $ship_data = array(); |
642 | 642 | $fleet_array = array(); |
643 | - foreach($ship_list as $transport_id => $cork) |
|
643 | + foreach ($ship_list as $transport_id => $cork) |
|
644 | 644 | { |
645 | 645 | $ship_data[$transport_id] = flt_travel_data($user, $from, $to, array($transport_id => 1), 10); |
646 | 646 | } |
@@ -649,10 +649,10 @@ discard block |
||
649 | 649 | $fleet_hold = 0; |
650 | 650 | $fleet_capacity = 0; |
651 | 651 | $fuel_total = $fuel_left = mrc_get_level($user, $from, RES_DEUTERIUM); |
652 | - foreach($ship_data as $transport_id => &$ship_info) |
|
652 | + foreach ($ship_data as $transport_id => &$ship_info) |
|
653 | 653 | { |
654 | 654 | $ship_loaded = min($ship_list[$transport_id], ceil($resource_amount / $ship_info['hold']), floor($fuel_left / $ship_info['consumption'])); |
655 | - if($ship_loaded) |
|
655 | + if ($ship_loaded) |
|
656 | 656 | { |
657 | 657 | $fleet_array[$transport_id] = $ship_loaded; |
658 | 658 | $resource_amount -= min($resource_amount, $ship_info['hold'] * $ship_loaded); |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | |
15 | 15 | $fleet_left = 1 - mt_rand(1, 3) * mt_rand(200000, 300000) / 1000000; |
16 | 16 | $fleet_lost = array(); |
17 | - foreach($fleet as $unit_id => &$unit_amount) { |
|
17 | + foreach ($fleet as $unit_id => &$unit_amount) { |
|
18 | 18 | $ships_left = floor($unit_amount * $fleet_left); |
19 | 19 | $fleet_lost[$unit_id] = $unit_amount - $ships_left; |
20 | 20 | $unit_amount = $ships_left; |
21 | - if(!$unit_amount) { |
|
21 | + if (!$unit_amount) { |
|
22 | 22 | unset($fleet[$unit_id]); |
23 | 23 | } |
24 | 24 | } |
@@ -31,14 +31,14 @@ discard block |
||
31 | 31 | // $fleet = array(); |
32 | 32 | } |
33 | 33 | |
34 | -function flt_mission_explore_addon(&$result){return sn_function_call('flt_mission_explore_addon', array(&$result));} |
|
34 | +function flt_mission_explore_addon(&$result) {return sn_function_call('flt_mission_explore_addon', array(&$result)); } |
|
35 | 35 | function sn_flt_mission_explore_addon(&$result) { |
36 | 36 | return $result; |
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | function flt_mission_explore(&$mission_data) { |
41 | - if(!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) { |
|
41 | + if (!isset($mission_data['fleet_event']) || $mission_data['fleet_event'] != EVENT_FLT_ACOMPLISH) { |
|
42 | 42 | return CACHE_NONE; |
43 | 43 | } |
44 | 44 | |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | $outcome_list = &$result['$outcome_list']; |
72 | 72 | $fleet_metal_points = &$result['$fleet_metal_points']; |
73 | 73 | |
74 | - if(!$ship_data) { |
|
75 | - foreach(sn_get_groups('fleet') as $unit_id) { |
|
74 | + if (!$ship_data) { |
|
75 | + foreach (sn_get_groups('fleet') as $unit_id) { |
|
76 | 76 | $unit_info = get_unit_param($unit_id); |
77 | - if($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
77 | + if ($unit_info[P_UNIT_TYPE] != UNIT_SHIPS || !isset($unit_info['engine'][0]['speed']) || !$unit_info['engine'][0]['speed']) { |
|
78 | 78 | continue; |
79 | 79 | } |
80 | 80 | $ship_data[$unit_id][P_COST_METAL] = get_unit_cost_in($unit_info[P_COST]); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $fleet = sys_unit_str2arr($fleet_row['fleet_array']); |
87 | 87 | $fleet_capacity = 0; |
88 | 88 | $fleet_metal_points = 0; |
89 | - foreach($fleet as $ship_id => $ship_amount) { |
|
89 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
90 | 90 | $unit_info = get_unit_param($ship_id); |
91 | 91 | $fleet_capacity += $ship_amount * $unit_info[P_CAPACITY]; |
92 | 92 | $fleet_metal_points += $ship_amount * $ship_data[$ship_id][P_COST_METAL]; |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | $flt_stay_hours = ($fleet_row['fleet_end_stay'] - $fleet_row['fleet_start_time']) / 3600 * ($config->game_speed_expedition ? $config->game_speed_expedition : 1); |
97 | 97 | |
98 | 98 | $outcome_list = sn_get_groups(GROUP_MISSION_EXPLORE_OUTCOMES); |
99 | - $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1/1.7)); |
|
99 | + $outcome_list[FLT_EXPEDITION_OUTCOME_NONE]['chance'] = ceil(200 / pow($flt_stay_hours, 1 / 1.7)); |
|
100 | 100 | |
101 | 101 | $chance_max = 0; |
102 | - foreach($outcome_list as $key => &$value) { |
|
103 | - if(!$value['chance']) { |
|
102 | + foreach ($outcome_list as $key => &$value) { |
|
103 | + if (!$value['chance']) { |
|
104 | 104 | unset($outcome_list[$key]); |
105 | 105 | continue; |
106 | 106 | } |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | $outcome_value = mt_rand(0, $chance_max); |
110 | 110 | // $outcome_value = 409; |
111 | 111 | $outcome_description = &$outcome_list[$mission_outcome = FLT_EXPEDITION_OUTCOME_NONE]; |
112 | - foreach($outcome_list as $key => &$value) { |
|
113 | - if(!$value['chance']) { |
|
112 | + foreach ($outcome_list as $key => &$value) { |
|
113 | + if (!$value['chance']) { |
|
114 | 114 | continue; |
115 | 115 | } |
116 | 116 | $mission_outcome = $key; |
117 | 117 | $outcome_description = $value; |
118 | - if($outcome_value <= $outcome_description['value']) { |
|
118 | + if ($outcome_value <= $outcome_description['value']) { |
|
119 | 119 | break; |
120 | 120 | } |
121 | 121 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $found_dark_matter = 0; |
132 | 132 | // $outcome_mission_sub = -1; |
133 | 133 | |
134 | - switch($mission_outcome) { |
|
134 | + switch ($mission_outcome) { |
|
135 | 135 | // switch(FLT_EXPEDITION_OUTCOME_LOST_FLEET) { // TODO DEBUG! |
136 | 136 | case FLT_EXPEDITION_OUTCOME_LOST_FLEET: |
137 | 137 | flt_mission_explore_outcome_lost_fleet($result); |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | |
167 | 167 | // Рассчитываем стоимость самого дорого корабля в металле |
168 | 168 | $max_metal_cost = 0; |
169 | - foreach($fleet as $ship_id => $ship_amount) { |
|
169 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
170 | 170 | $max_metal_cost = max($max_metal_cost, $ship_data[$ship_id]['metal_cost']); |
171 | 171 | } |
172 | 172 | |
173 | 173 | // Ограничиваем корабли только теми, чья стоимость в металле меньше или равно стоимости самого дорогого корабля |
174 | 174 | $can_be_found = array(); |
175 | - foreach($ship_data as $ship_id => $ship_info) { |
|
176 | - if($ship_info['metal_cost'] < $max_metal_cost) { |
|
175 | + foreach ($ship_data as $ship_id => $ship_info) { |
|
176 | + if ($ship_info['metal_cost'] < $max_metal_cost) { |
|
177 | 177 | $can_be_found[$ship_id] = $ship_info['metal_cost']; |
178 | 178 | } |
179 | 179 | } |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | unset($can_be_found[SHIP_SPY]); |
183 | 183 | |
184 | 184 | $fleet_found = array(); |
185 | - while(count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
185 | + while (count($can_be_found) && $found_in_metal >= max($can_be_found)) { |
|
186 | 186 | $found_index = mt_rand(1, count($can_be_found)) - 1; |
187 | 187 | $found_ship = array_slice($can_be_found, $found_index, 1, true); |
188 | 188 | $found_ship_cost = reset($found_ship); |
189 | 189 | $found_ship_id = key($found_ship); |
190 | 190 | |
191 | - if($found_ship_cost > $found_in_metal) { |
|
191 | + if ($found_ship_cost > $found_in_metal) { |
|
192 | 192 | unset($can_be_found[$found_ship_id]); |
193 | 193 | } else { |
194 | 194 | $found_ship_count = mt_rand(1, floor($found_in_metal / $found_ship_cost)); |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - if(empty($fleet_found)) { |
|
200 | + if (empty($fleet_found)) { |
|
201 | 201 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
202 | 202 | } else { |
203 | - foreach($fleet_found as $unit_id => $unit_amount) { |
|
203 | + foreach ($fleet_found as $unit_id => $unit_amount) { |
|
204 | 204 | $fleet[$unit_id] += $unit_amount; |
205 | 205 | } |
206 | 206 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $fleet_row['fleet_resource_crystal'] += $resources_found[RES_CRYSTAL]; |
227 | 227 | $fleet_row['fleet_resource_deuterium'] += $resources_found[RES_DEUTERIUM]; |
228 | 228 | |
229 | - if(array_sum($resources_found) == 0) { |
|
229 | + if (array_sum($resources_found) == 0) { |
|
230 | 230 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
231 | 231 | } |
232 | 232 | break; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | // Рассчитываем количество найденной ТМ |
238 | 238 | $found_dark_matter = floor(min($outcome_percent * $fleet_metal_points / $rates[RES_DARK_MATTER], 10000) * mt_rand(750000, 1000000) / 1000000); |
239 | 239 | |
240 | - if(!$found_dark_matter) { |
|
240 | + if (!$found_dark_matter) { |
|
241 | 241 | $msg_text_addon = $lang['flt_mission_expedition']['outcomes'][$mission_outcome]['no_result']; |
242 | 242 | } |
243 | 243 | break; |
@@ -251,31 +251,31 @@ discard block |
||
251 | 251 | |
252 | 252 | flt_mission_explore_addon($result); |
253 | 253 | |
254 | - if($found_dark_matter) { |
|
254 | + if ($found_dark_matter) { |
|
255 | 255 | rpg_points_change($fleet_row['fleet_owner'], RPG_EXPEDITION, $found_dark_matter, 'Expedition Bonus'); |
256 | 256 | $msg_text_addon = sprintf($lang['flt_mission_expedition']['found_dark_matter'], $found_dark_matter); |
257 | 257 | } |
258 | 258 | |
259 | - if(!empty($fleet_lost)) { |
|
259 | + if (!empty($fleet_lost)) { |
|
260 | 260 | $msg_text_addon = $lang['flt_mission_expedition']['lost_fleet']; |
261 | - foreach($fleet_lost as $ship_id => $ship_amount) { |
|
261 | + foreach ($fleet_lost as $ship_id => $ship_amount) { |
|
262 | 262 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | 266 | $fleet_row['fleet_amount'] = array_sum($fleet); |
267 | - if(!empty($fleet) && $fleet_row['fleet_amount']) { |
|
268 | - if(!empty($fleet_found)) { |
|
267 | + if (!empty($fleet) && $fleet_row['fleet_amount']) { |
|
268 | + if (!empty($fleet_found)) { |
|
269 | 269 | $msg_text_addon = $lang['flt_mission_expedition']['found_fleet']; |
270 | - foreach($fleet_found as $ship_id => $ship_amount) { |
|
270 | + foreach ($fleet_found as $ship_id => $ship_amount) { |
|
271 | 271 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
275 | 275 | $query_delta = array(); |
276 | - if(!empty($resources_found) && array_sum($resources_found) > 0) { |
|
276 | + if (!empty($resources_found) && array_sum($resources_found) > 0) { |
|
277 | 277 | $msg_text_addon = $lang['flt_mission_expedition']['found_resources']; |
278 | - foreach($resources_found as $ship_id => $ship_amount) { |
|
278 | + foreach ($resources_found as $ship_id => $ship_amount) { |
|
279 | 279 | $msg_text_addon .= $lang['tech'][$ship_id] . ' - ' . $ship_amount . "\r\n"; |
280 | 280 | } |
281 | 281 | |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | } |
289 | 289 | |
290 | 290 | $query_data = array(); |
291 | - if(!empty($fleet_lost) || !empty($fleet_found)) { |
|
291 | + if (!empty($fleet_lost) || !empty($fleet_found)) { |
|
292 | 292 | $fleet_row['fleet_array'] = sys_unit_arr2str($fleet); |
293 | 293 | |
294 | 294 | // $query_data[] = "`fleet_amount` = {$fleet_row['fleet_amount']}"; |
@@ -316,17 +316,16 @@ discard block |
||
316 | 316 | |
317 | 317 | db_user_set_by_id($fleet_row['fleet_owner'], "`player_rpg_explore_xp` = `player_rpg_explore_xp` + 1"); |
318 | 318 | |
319 | - if(!$msg_text) { |
|
319 | + if (!$msg_text) { |
|
320 | 320 | $messages = &$lang['flt_mission_expedition']['outcomes'][$mission_outcome]['messages']; |
321 | - if($outcome_mission_sub >= 0 && is_array($messages)) { |
|
321 | + if ($outcome_mission_sub >= 0 && is_array($messages)) { |
|
322 | 322 | $messages = &$messages[$outcome_mission_sub]; |
323 | 323 | } |
324 | 324 | |
325 | - $msg_text = is_string($messages) ? $messages : |
|
326 | - (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
325 | + $msg_text = is_string($messages) ? $messages : (is_array($messages) ? $messages[mt_rand(0, count($messages) - 1)] : ''); |
|
327 | 326 | } |
328 | 327 | $msg_text = sprintf($msg_text, $fleet_row['fleet_id'], uni_render_coordinates($fleet_row, 'fleet_end_')) . |
329 | - ($msg_text_addon ? "\r\n" . $msg_text_addon: ''); |
|
328 | + ($msg_text_addon ? "\r\n" . $msg_text_addon : ''); |
|
330 | 329 | |
331 | 330 | msg_send_simple_message($fleet_row['fleet_owner'], '', $fleet_row['fleet_end_stay'], MSG_TYPE_EXPLORE, $msg_sender, $msg_title, $msg_text); |
332 | 331 |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | displayP($page_item); |
284 | 284 | } |
285 | 285 | |
286 | - if(is_array($template_result[TEMPLATE_EXTRA_ARRAY]) && !empty($template_result[TEMPLATE_EXTRA_ARRAY])) { |
|
287 | - foreach($template_result[TEMPLATE_EXTRA_ARRAY] as $extraName => $extraTemplate) { |
|
286 | + if (is_array($template_result[TEMPLATE_EXTRA_ARRAY]) && !empty($template_result[TEMPLATE_EXTRA_ARRAY])) { |
|
287 | + foreach ($template_result[TEMPLATE_EXTRA_ARRAY] as $extraName => $extraTemplate) { |
|
288 | 288 | /** |
289 | 289 | * @var template $extraTemplate |
290 | 290 | */ |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | renderFooter(); |
298 | 298 | } |
299 | 299 | |
300 | - $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false;; |
|
300 | + $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false; ; |
|
301 | 301 | |
302 | 302 | sn_db_disconnect(); |
303 | 303 | |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | 'QUE_ID' => QUE_RESEARCH, |
680 | 680 | 'QUE_HTML' => 'topnav', |
681 | 681 | |
682 | - 'RESEARCH_ONGOING' => (boolean)$user['que'], |
|
682 | + 'RESEARCH_ONGOING' => (boolean) $user['que'], |
|
683 | 683 | |
684 | 684 | 'TIME_TEXT' => sprintf($str_date_format, $time_now_parsed['year'], $lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'], |
685 | 685 | $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds'] |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | 'LANG' => $language ? $language : '', |
973 | 973 | 'referral' => $id_ref ? '&id_ref=' . $id_ref : '', |
974 | 974 | |
975 | - 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '',// "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
975 | + 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '', // "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
976 | 976 | 'FILENAME' => basename($_SERVER['PHP_SELF']), |
977 | 977 | )); |
978 | 978 |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
113 | 113 | if (preg_match($rexep, $date, $out)) { |
114 | 114 | $ret = array( |
115 | - "tm_sec" => (int)$out['S'], |
|
116 | - "tm_min" => (int)$out['M'], |
|
117 | - "tm_hour" => (int)$out['H'], |
|
118 | - "tm_mday" => (int)$out['d'], |
|
115 | + "tm_sec" => (int) $out['S'], |
|
116 | + "tm_min" => (int) $out['M'], |
|
117 | + "tm_hour" => (int) $out['H'], |
|
118 | + "tm_mday" => (int) $out['d'], |
|
119 | 119 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
120 | 120 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
121 | 121 | ); |
@@ -150,5 +150,5 @@ discard block |
||
150 | 150 | * @return int |
151 | 151 | */ |
152 | 152 | function datePart($fullDate) { |
153 | - return (int)strtotime(date('Y-m-d', $fullDate)); |
|
153 | + return (int) strtotime(date('Y-m-d', $fullDate)); |
|
154 | 154 | } |
@@ -46,8 +46,7 @@ |
||
46 | 46 | 'ANNOUNCE' => classSupernova::$gc->bbCodeParser->expandBbCode($announce['strAnnounce'], intval($announce['authlevel'])), |
47 | 47 | 'DETAIL_URL' => $announce['detail_url'], |
48 | 48 | 'USER_NAME' => |
49 | - isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : |
|
50 | - js_safe_string($announce['user_name']), |
|
49 | + isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : js_safe_string($announce['user_name']), |
|
51 | 50 | 'NEW' => $announce['unix_time'] + $config->game_news_actual >= SN_TIME_NOW, |
52 | 51 | 'FUTURE' => $announce['unix_time'] > SN_TIME_NOW, |
53 | 52 | 'SURVEY_ID' => $announce['survey_id'], |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | $language_new = sys_get_param_str('langer', $user['lang']); |
13 | 13 | |
14 | - if($language_new != $user['lang']) { |
|
14 | + if ($language_new != $user['lang']) { |
|
15 | 15 | $lang->lng_switch($language_new); |
16 | 16 | } |
17 | 17 | |
@@ -20,35 +20,35 @@ discard block |
||
20 | 20 | |
21 | 21 | $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE); |
22 | 22 | |
23 | - if(sys_get_param_str('mode') == 'change') { |
|
24 | - if($user['authlevel'] > 0) { |
|
23 | + if (sys_get_param_str('mode') == 'change') { |
|
24 | + if ($user['authlevel'] > 0) { |
|
25 | 25 | $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0; |
26 | 26 | DBStaticPlanet::db_planet_set_by_owner($user['id'], "`id_level` = '{$planet_protection}'"); |
27 | 27 | db_user_set_by_id($user['id'], "`admin_protection` = '{$planet_protection}'"); |
28 | 28 | $user['admin_protection'] = $planet_protection; |
29 | 29 | } |
30 | 30 | |
31 | - if(sys_get_param_int('vacation') && !$config->user_vacation_disable) { |
|
31 | + if (sys_get_param_int('vacation') && !$config->user_vacation_disable) { |
|
32 | 32 | sn_db_transaction_start(); |
33 | - if($user['authlevel'] < 3) { |
|
34 | - if($user['vacation_next'] > SN_TIME_NOW) { |
|
33 | + if ($user['authlevel'] < 3) { |
|
34 | + if ($user['vacation_next'] > SN_TIME_NOW) { |
|
35 | 35 | messageBox($lang['opt_vacation_err_timeout'], $lang['Error'], 'index.php?page=options', 5); |
36 | 36 | die(); |
37 | 37 | } |
38 | 38 | |
39 | - if(fleet_count_flying($user['id'])) { |
|
39 | + if (fleet_count_flying($user['id'])) { |
|
40 | 40 | messageBox($lang['opt_vacation_err_your_fleet'], $lang['Error'], 'index.php?page=options', 5); |
41 | 41 | die(); |
42 | 42 | } |
43 | 43 | |
44 | 44 | $que = que_get($user['id'], false); |
45 | - if(!empty($que)) { |
|
45 | + if (!empty($que)) { |
|
46 | 46 | messageBox($lang['opt_vacation_err_que'], $lang['Error'], 'index.php?page=options', 5); |
47 | 47 | die(); |
48 | 48 | } |
49 | 49 | |
50 | 50 | $query = classSupernova::db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}"); |
51 | - foreach($query as $planet) { |
|
51 | + foreach ($query as $planet) { |
|
52 | 52 | DBStaticPlanet::db_planet_set_by_id($planet['id'], |
53 | 53 | "last_update = " . SN_TIME_NOW . ", energy_used = '0', energy_max = '0', |
54 | 54 | metal_perhour = '{$config->metal_basic_income}', crystal_perhour = '{$config->crystal_basic_income}', deuterium_perhour = '{$config->deuterium_basic_income}', |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | sn_db_transaction_commit(); |
64 | 64 | } |
65 | 65 | |
66 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
67 | - foreach($option_group as $option_name => $option_value) { |
|
68 | - if($user[$option_name] !== null) { |
|
66 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
67 | + foreach ($option_group as $option_name => $option_value) { |
|
68 | + if ($user[$option_name] !== null) { |
|
69 | 69 | $user[$option_name] = sys_get_param_str($option_name); |
70 | 70 | } else { |
71 | 71 | $user[$option_name] = $option_value; |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | |
77 | 77 | |
78 | 78 | $player_options = sys_get_param('options'); |
79 | - if(!empty($player_options)) { |
|
80 | - if($player_options[PLAYER_OPTION_TUTORIAL_CURRENT] == classSupernova::$config->tutorial_first_item) { |
|
79 | + if (!empty($player_options)) { |
|
80 | + if ($player_options[PLAYER_OPTION_TUTORIAL_CURRENT] == classSupernova::$config->tutorial_first_item) { |
|
81 | 81 | $player_options[PLAYER_OPTION_TUTORIAL_FINISHED] = 0; |
82 | 82 | } |
83 | 83 | |
84 | - array_walk($player_options, function (&$value) { |
|
84 | + array_walk($player_options, function(&$value) { |
|
85 | 85 | // TODO - Когда будет больше параметров - сделать больше проверок |
86 | 86 | $value = intval($value); |
87 | 87 | }); |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | |
91 | 91 | $username = substr(sys_get_param_str_unsafe('username'), 0, 32); |
92 | 92 | $username_safe = db_escape($username); |
93 | - if($username && $user['username'] != $username && $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
93 | + if ($username && $user['username'] != $username && $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
94 | 94 | // проверка на корректность |
95 | 95 | sn_db_transaction_start(); |
96 | 96 | $name_check = doquery("SELECT * FROM `{{player_name_history}}` WHERE `player_name` LIKE \"{$username_safe}\" LIMIT 1 FOR UPDATE;", true); |
97 | - if(!$name_check || $name_check['player_id'] == $user['id']) { |
|
97 | + if (!$name_check || $name_check['player_id'] == $user['id']) { |
|
98 | 98 | $user = db_user_by_id($user['id'], true); |
99 | - switch($config->game_user_changename) { |
|
99 | + switch ($config->game_user_changename) { |
|
100 | 100 | case SERVER_PLAYER_NAME_CHANGE_PAY: |
101 | - if(mrc_get_level($user, [], RES_DARK_MATTER) < $config->game_user_changename_cost) { |
|
101 | + if (mrc_get_level($user, [], RES_DARK_MATTER) < $config->game_user_changename_cost) { |
|
102 | 102 | $template_result['.']['result'][] = array( |
103 | 103 | 'STATUS' => ERR_ERROR, |
104 | 104 | 'MESSAGE' => $lang['opt_msg_name_change_err_no_dm'], |
@@ -128,18 +128,18 @@ discard block |
||
128 | 128 | sn_db_transaction_commit(); |
129 | 129 | } |
130 | 130 | |
131 | - if($new_password = sys_get_param('newpass1')) { |
|
131 | + if ($new_password = sys_get_param('newpass1')) { |
|
132 | 132 | try { |
133 | - if($new_password != sys_get_param('newpass2')) { |
|
133 | + if ($new_password != sys_get_param('newpass2')) { |
|
134 | 134 | throw new Exception($lang['opt_err_pass_unmatched'], ERR_WARNING); |
135 | 135 | } |
136 | 136 | |
137 | - if(!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { |
|
137 | + if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { |
|
138 | 138 | throw new Exception($lang['opt_err_pass_wrong'], ERR_WARNING); |
139 | 139 | } |
140 | 140 | |
141 | 141 | throw new Exception($lang['opt_msg_pass_changed'], ERR_NONE); |
142 | - } catch(Exception $e) { |
|
142 | + } catch (Exception $e) { |
|
143 | 143 | $template_result['.']['result'][] = array( |
144 | 144 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
145 | 145 | 'MESSAGE' => $e->getMessage() |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender']; |
161 | 161 | |
162 | 162 | try { |
163 | - if($user['birthday']) { |
|
163 | + if ($user['birthday']) { |
|
164 | 164 | throw new exception(); |
165 | 165 | } |
166 | 166 | |
167 | 167 | $user_birthday = sys_get_param_str_unsafe('user_birthday'); |
168 | - if(!$user_birthday || $user_birthday == $FMT_DATE) { |
|
168 | + if (!$user_birthday || $user_birthday == $FMT_DATE) { |
|
169 | 169 | throw new exception(); |
170 | 170 | } |
171 | 171 | |
@@ -175,16 +175,16 @@ discard block |
||
175 | 175 | $pos['Y'] = strpos(FMT_DATE, 'Y'); |
176 | 176 | asort($pos); |
177 | 177 | $i = 0; |
178 | - foreach($pos as &$position) { |
|
178 | + foreach ($pos as &$position) { |
|
179 | 179 | $position = ++$i; |
180 | 180 | } |
181 | 181 | |
182 | 182 | $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/"; |
183 | - if(!preg_match($regexp, $user_birthday, $match)) { |
|
183 | + if (!preg_match($regexp, $user_birthday, $match)) { |
|
184 | 184 | throw new exception(); |
185 | 185 | } |
186 | 186 | |
187 | - if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { |
|
187 | + if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { |
|
188 | 188 | throw new exception(); |
189 | 189 | } |
190 | 190 | |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format |
193 | 193 | |
194 | 194 | $year = date('Y', SN_TIME_NOW); |
195 | - if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { |
|
195 | + if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { |
|
196 | 196 | $year--; |
197 | 197 | } |
198 | 198 | $user['user_birthday_celebrated'] = db_escape("{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}"); |
199 | 199 | |
200 | 200 | $user_birthday = ", `user_birthday` = '{$user['user_birthday']}', `user_birthday_celebrated` = '{$user['user_birthday_celebrated']}'"; |
201 | - } catch(exception $e) { |
|
201 | + } catch (exception $e) { |
|
202 | 202 | $user_birthday = ''; |
203 | 203 | } |
204 | 204 | |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | $template_result['.']['result'][] = $avatar_upload_result; |
209 | 209 | |
210 | 210 | $user_time_diff = playerTimeDiff::user_time_diff_get(); |
211 | - if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { |
|
211 | + if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { |
|
212 | 212 | playerTimeDiff::user_time_diff_set(array( |
213 | 213 | PLAYER_OPTION_TIME_DIFF => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'), |
214 | 214 | PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, |
215 | 215 | PLAYER_OPTION_TIME_DIFF_FORCED => 1, |
216 | 216 | PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL, |
217 | 217 | )); |
218 | - } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
218 | + } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
219 | 219 | playerTimeDiff::user_time_diff_set(array( |
220 | 220 | PLAYER_OPTION_TIME_DIFF => '', |
221 | 221 | PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | 'STATUS' => ERR_NONE, |
236 | 236 | 'MESSAGE' => $lang['opt_msg_saved'] |
237 | 237 | ); |
238 | - } elseif(sys_get_param_str('result') == 'ok') { |
|
238 | + } elseif (sys_get_param_str('result') == 'ok') { |
|
239 | 239 | $template_result['.']['result'][] = array( |
240 | 240 | 'STATUS' => ERR_NONE, |
241 | 241 | 'MESSAGE' => $lang['opt_msg_saved'] |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | $template = gettemplate('options', $template); |
259 | 259 | |
260 | 260 | $dir = dir(SN_ROOT_PHYSICAL . 'skins'); |
261 | - while(($entry = $dir->read()) !== false) { |
|
262 | - if(is_dir("skins/{$entry}") && $entry[0] != '.') { |
|
261 | + while (($entry = $dir->read()) !== false) { |
|
262 | + if (is_dir("skins/{$entry}") && $entry[0] != '.') { |
|
263 | 263 | $template_result['.']['skin_list'][] = array( |
264 | 264 | 'VALUE' => $entry, |
265 | 265 | 'NAME' => $entry, |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | } |
270 | 270 | $dir->close(); |
271 | 271 | |
272 | - foreach($lang['opt_planet_sort_options'] as $key => &$value) { |
|
272 | + foreach ($lang['opt_planet_sort_options'] as $key => &$value) { |
|
273 | 273 | $template_result['.']['planet_sort_options'][] = array( |
274 | 274 | 'VALUE' => $key, |
275 | 275 | 'NAME' => $value, |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | ); |
278 | 278 | } |
279 | 279 | |
280 | - foreach($lang['sys_gender_list'] as $key => $value) { |
|
280 | + foreach ($lang['sys_gender_list'] as $key => $value) { |
|
281 | 281 | $template_result['.']['gender_list'][] = array( |
282 | 282 | 'VALUE' => $key, |
283 | 283 | 'NAME' => $value, |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } |
287 | 287 | |
288 | 288 | $lang_list = lng_get_list(); |
289 | - foreach($lang_list as $lang_id => $lang_data) { |
|
289 | + foreach ($lang_list as $lang_id => $lang_data) { |
|
290 | 290 | $template_result['.']['languages'][] = array( |
291 | 291 | 'VALUE' => $lang_id, |
292 | 292 | 'NAME' => $lang_data['LANG_NAME_NATIVE'], |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | |
298 | - if(isset($lang['menu_customize_show_hide_button_state'])) { |
|
299 | - foreach($lang['menu_customize_show_hide_button_state'] as $key => $value) { |
|
298 | + if (isset($lang['menu_customize_show_hide_button_state'])) { |
|
299 | + foreach ($lang['menu_customize_show_hide_button_state'] as $key => $value) { |
|
300 | 300 | $template->assign_block_vars('menu_customize_show_hide_button_state', array( |
301 | 301 | 'ID' => $key, |
302 | 302 | 'NAME' => $value, |
@@ -407,10 +407,10 @@ discard block |
||
407 | 407 | 'PAGE_HEADER' => $lang['opt_header'], |
408 | 408 | )); |
409 | 409 | |
410 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
411 | - if($option_group_id == OPT_MESSAGE) { |
|
412 | - foreach($sn_message_class_list as $message_class_id => $message_class_data) { |
|
413 | - if($message_class_data['switchable'] || ($message_class_data['email'] && $config->game_email_pm)) { |
|
410 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
411 | + if ($option_group_id == OPT_MESSAGE) { |
|
412 | + foreach ($sn_message_class_list as $message_class_id => $message_class_data) { |
|
413 | + if ($message_class_data['switchable'] || ($message_class_data['email'] && $config->game_email_pm)) { |
|
414 | 414 | $option_name = $message_class_data['name']; |
415 | 415 | |
416 | 416 | $template->assign_block_vars("options_{$option_group_id}", array( |
@@ -422,8 +422,8 @@ discard block |
||
422 | 422 | } |
423 | 423 | } |
424 | 424 | } else { |
425 | - foreach($option_group as $option_name => $option_value) { |
|
426 | - if(array_key_exists($option_name, $user_option_types)) { |
|
425 | + foreach ($option_group as $option_name => $option_value) { |
|
426 | + if (array_key_exists($option_name, $user_option_types)) { |
|
427 | 427 | $option_type = $user_option_types[$option_name]; |
428 | 428 | } else { |
429 | 429 | $option_type = 'switch'; |
@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | protected function initValues() { |
51 | - $this[UNIT_SERVER_SPEED_BUILDING] = function (ValueStorage $vs) { |
|
51 | + $this[UNIT_SERVER_SPEED_BUILDING] = function(ValueStorage $vs) { |
|
52 | 52 | return new ValueBonused(UNIT_SERVER_SPEED_BUILDING, floatval($vs->getGlobalContainer()->config->game_speed)); |
53 | 53 | }; |
54 | - $this[UNIT_SERVER_SPEED_MINING] = function (ValueStorage $vs) { |
|
54 | + $this[UNIT_SERVER_SPEED_MINING] = function(ValueStorage $vs) { |
|
55 | 55 | return new ValueBonused(UNIT_SERVER_SPEED_MINING, floatval($vs->getGlobalContainer()->config->resource_multiplier)); |
56 | 56 | }; |
57 | - $this[UNIT_SERVER_SPEED_FLEET] = function (ValueStorage $vs) { |
|
57 | + $this[UNIT_SERVER_SPEED_FLEET] = function(ValueStorage $vs) { |
|
58 | 58 | return new ValueBonused(UNIT_SERVER_SPEED_FLEET, floatval($vs->getGlobalContainer()->config->fleet_speed)); |
59 | 59 | }; |
60 | - $this[UNIT_SERVER_SPEED_EXPEDITION] = function (ValueStorage $vs) { |
|
60 | + $this[UNIT_SERVER_SPEED_EXPEDITION] = function(ValueStorage $vs) { |
|
61 | 61 | return new ValueBonused(UNIT_SERVER_SPEED_EXPEDITION, floatval(1)); |
62 | 62 | }; |
63 | 63 | |
64 | - $this[UNIT_SERVER_FLEET_NOOB_POINTS] = function (ValueStorage $vs) { |
|
64 | + $this[UNIT_SERVER_FLEET_NOOB_POINTS] = function(ValueStorage $vs) { |
|
65 | 65 | $config = $vs->getGlobalContainer()->config; |
66 | 66 | |
67 | 67 | return new ValueBonused( |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | floatval($config->game_noob_points * $vs->getBase(UNIT_SERVER_SPEED_MINING)) |
70 | 70 | ); |
71 | 71 | }; |
72 | - $this[UNIT_SERVER_FLEET_NOOB_FACTOR] = function (ValueStorage $vs) { |
|
72 | + $this[UNIT_SERVER_FLEET_NOOB_FACTOR] = function(ValueStorage $vs) { |
|
73 | 73 | return new ValueBonused(UNIT_SERVER_FLEET_NOOB_FACTOR, floatval($vs->getGlobalContainer()->config->game_noob_factor)); |
74 | 74 | }; |
75 | 75 | |
76 | - $this[UNIT_SERVER_PAYMENT_MM_PER_CURRENCY] = function (ValueStorage $vs) { |
|
76 | + $this[UNIT_SERVER_PAYMENT_MM_PER_CURRENCY] = function(ValueStorage $vs) { |
|
77 | 77 | return new ValueBonused(UNIT_SERVER_PAYMENT_MM_PER_CURRENCY, floatval($vs->getGlobalContainer()->config->payment_currency_exchange_mm_)); |
78 | 78 | }; |
79 | 79 | } |
@@ -105,7 +105,7 @@ |
||
105 | 105 | * @return int |
106 | 106 | */ |
107 | 107 | public function getMaxLevel() { |
108 | - $snId = $this->getSnId(); |
|
108 | + $snId = $this->getSnId(); |
|
109 | 109 | return !empty($snId) ? get_unit_param($snId, P_MAX_STACK) : 0; |
110 | 110 | } |
111 | 111 |