@@ -290,10 +290,12 @@ discard block |
||
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if ($fleet_id) // Не планета |
|
| 293 | + if ($fleet_id) { |
|
| 294 | + // Не планета |
|
| 294 | 295 | { |
| 295 | 296 | if ($fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS && $outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_DIED) { |
| 296 | 297 | $new_fleet_count = 0; |
| 298 | + } |
|
| 297 | 299 | } |
| 298 | 300 | |
| 299 | 301 | if ($new_fleet_count) { |
@@ -316,10 +318,12 @@ discard block |
||
| 316 | 318 | } |
| 317 | 319 | DBStaticPlanet::db_planet_set_by_id($planet_id, implode(',', $temp)); |
| 318 | 320 | } |
| 319 | - if (!empty($db_changeset)) // Сохраняем изменения юнитов на планете - если они есть |
|
| 321 | + if (!empty($db_changeset)) { |
|
| 322 | + // Сохраняем изменения юнитов на планете - если они есть |
|
| 320 | 323 | { |
| 321 | 324 | OldDbChangeSet::db_changeset_apply($db_changeset); |
| 322 | 325 | } |
| 326 | + } |
|
| 323 | 327 | } |
| 324 | 328 | } |
| 325 | 329 | |
@@ -236,9 +236,11 @@ |
||
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
| 239 | - if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
| 239 | + if (!isset($planet_row['id'])) { |
|
| 240 | + // || $planet_row['id'] != $user['current_planet'] |
|
| 240 | 241 | { |
| 241 | 242 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
| 243 | + } |
|
| 242 | 244 | // Если текущей планеты не существует - выставляем Столицу |
| 243 | 245 | if (!isset($planet_row['id'])) { |
| 244 | 246 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
@@ -24,7 +24,9 @@ |
||
| 24 | 24 | * DO NOT CHANGE |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -if (!defined('INSIDE')) die(); |
|
| 27 | +if (!defined('INSIDE')) { |
|
| 28 | + die(); |
|
| 29 | +} |
|
| 28 | 30 | |
| 29 | 31 | $a_lang_array = array( |
| 30 | 32 | 'built' => 'Построено', |
@@ -26,7 +26,9 @@ |
||
| 26 | 26 | * DO NOT CHANGE |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -if (!defined('INSIDE')) die(); |
|
| 29 | +if (!defined('INSIDE')) { |
|
| 30 | + die(); |
|
| 31 | +} |
|
| 30 | 32 | |
| 31 | 33 | |
| 32 | 34 | $a_lang_array = array( |
@@ -419,7 +419,8 @@ discard block |
||
| 419 | 419 | $location_info = &static::$location_info[$location_type]; |
| 420 | 420 | $id_field = $location_info[P_ID]; |
| 421 | 421 | $table_name = $location_info[P_TABLE_NAME]; |
| 422 | - if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
| 422 | + if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) { |
|
| 423 | + // TODO Как-то вернуть может быть LIMIT 1 ? |
|
| 423 | 424 | { |
| 424 | 425 | if (static::$db->db_affected_rows()) { |
| 425 | 426 | // Обновляем данные только если ряд был затронут |
@@ -427,6 +428,7 @@ discard block |
||
| 427 | 428 | |
| 428 | 429 | // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее |
| 429 | 430 | _SnCacheInternal::$data[$location_type][$record_id] = null; |
| 431 | + } |
|
| 430 | 432 | // Вытаскиваем обновленную запись |
| 431 | 433 | static::db_get_record_by_id($location_type, $record_id); |
| 432 | 434 | _SnCacheInternal::cache_clear($location_type, false); // Мягкий сброс - только $queries |
@@ -460,9 +462,11 @@ discard block |
||
| 460 | 462 | $set = trim($set); |
| 461 | 463 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
| 462 | 464 | if ($result = static::db_query_insert("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
| 463 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 465 | + if (static::$db->db_affected_rows()) { |
|
| 466 | + // Обновляем данные только если ряд был затронут |
|
| 464 | 467 | { |
| 465 | 468 | $record_id = db_insert_id(); |
| 469 | + } |
|
| 466 | 470 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
| 467 | 471 | $result = static::db_get_record_by_id($location_type, $record_id); |
| 468 | 472 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -483,10 +487,12 @@ discard block |
||
| 483 | 487 | $id_field = $location_info[P_ID]; |
| 484 | 488 | $table_name = $location_info[P_TABLE_NAME]; |
| 485 | 489 | if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) { |
| 486 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 490 | + if (static::$db->db_affected_rows()) { |
|
| 491 | + // Обновляем данные только если ряд был затронут |
|
| 487 | 492 | { |
| 488 | 493 | _SnCacheInternal::cache_unset($location_type, $safe_record_id); |
| 489 | 494 | } |
| 495 | + } |
|
| 490 | 496 | } |
| 491 | 497 | |
| 492 | 498 | return $result; |
@@ -500,11 +506,13 @@ discard block |
||
| 500 | 506 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
| 501 | 507 | |
| 502 | 508 | if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) { |
| 503 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 509 | + if (static::$db->db_affected_rows()) { |
|
| 510 | + // Обновляем данные только если ряд был затронут |
|
| 504 | 511 | { |
| 505 | 512 | // Обнуление кэша, потому что непонятно, что поменялось |
| 506 | 513 | _SnCacheInternal::cache_clear($location_type); |
| 507 | 514 | } |
| 515 | + } |
|
| 508 | 516 | } |
| 509 | 517 | |
| 510 | 518 | return $result; |
@@ -67,8 +67,7 @@ discard block |
||
| 67 | 67 | ->doInsert(); |
| 68 | 68 | |
| 69 | 69 | $accept_offer = false; |
| 70 | - } |
|
| 71 | - else |
|
| 70 | + } else |
|
| 72 | 71 | { |
| 73 | 72 | $accept_offer = true; |
| 74 | 73 | $autoAccept = true; |
@@ -80,8 +79,7 @@ discard block |
||
| 80 | 79 | 'alliance_negotiation_relation' => $alliance_negotiation_relation, |
| 81 | 80 | ); |
| 82 | 81 | } |
| 83 | -} |
|
| 84 | -else |
|
| 82 | +} else |
|
| 85 | 83 | { |
| 86 | 84 | $offer_id = sys_get_param_id('offer_id'); |
| 87 | 85 | if($offer_id) |
@@ -92,31 +90,26 @@ discard block |
||
| 92 | 90 | if(!$negotiation) |
| 93 | 91 | { |
| 94 | 92 | messageBox($lang['ali_dip_err_offer_none'], $page_title); |
| 95 | - } |
|
| 96 | - elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) |
|
| 93 | + } elseif($negotiation['alliance_negotiation_ally_id'] != $user['ally_id'] && $negotiation['alliance_negotiation_contr_ally_id'] != $user['ally_id']) |
|
| 97 | 94 | { |
| 98 | 95 | // TODO: Add log of hack attempt |
| 99 | 96 | messageBox($lang['ali_dip_err_offer_alien'], $page_title); |
| 100 | - } |
|
| 101 | - elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) |
|
| 97 | + } elseif($negotiation['alliance_negotiation_ally_id'] == $user['ally_id']) |
|
| 102 | 98 | { |
| 103 | 99 | if($offer_answer == 'accept') |
| 104 | 100 | { |
| 105 | 101 | // TODO: Add log of hack attempt |
| 106 | 102 | messageBox($lang['ali_dip_err_offer_accept_own'], $page_title); |
| 107 | - } |
|
| 108 | - elseif($offer_answer == 'deny') |
|
| 103 | + } elseif($offer_answer == 'deny') |
|
| 109 | 104 | { |
| 110 | 105 | doquery("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_id = {$offer_id} LIMIT 1;"); |
| 111 | 106 | } |
| 112 | - } |
|
| 113 | - else |
|
| 107 | + } else |
|
| 114 | 108 | { |
| 115 | 109 | if($offer_answer == 'accept') |
| 116 | 110 | { |
| 117 | 111 | $accept_offer = true; |
| 118 | - } |
|
| 119 | - elseif($offer_answer == 'deny') |
|
| 112 | + } elseif($offer_answer == 'deny') |
|
| 120 | 113 | { |
| 121 | 114 | DBStaticAlly::db_ally_negotiation_update_status_1($offer_id); |
| 122 | 115 | } |
@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | use DBAL\OldDbChangeSet; |
| 8 | 8 | use Planet\DBStaticPlanet; |
| 9 | 9 | |
| 10 | -function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') |
|
| 11 | -{ |
|
| 10 | +function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') { |
|
| 12 | 11 | // Here we select which part of defense should take damage: structure or shield |
| 13 | 12 | // $damageTo = P_SHIELD; |
| 14 | 13 | // $damageTo = P_STRUCTURE; |
@@ -37,8 +36,7 @@ discard block |
||
| 37 | 36 | $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] ); |
| 38 | 37 | $structures[$targetedStructure][0] -= $structsDestroyed; |
| 39 | 38 | $MIPDamage -= $structsDestroyed*$damageDone; |
| 40 | - } |
|
| 41 | - else |
|
| 39 | + } else |
|
| 42 | 40 | { |
| 43 | 41 | // REALLY random attack |
| 44 | 42 | $can_be_damaged = sn_get_groups('defense_active'); |
@@ -3,8 +3,7 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | use Planet\DBStaticPlanet; |
| 5 | 5 | |
| 6 | -function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false) |
|
| 7 | -{ |
|
| 6 | +function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false) { |
|
| 8 | 7 | global $config, $user, $fleet_number, $lang; |
| 9 | 8 | |
| 10 | 9 | $fleet_events = array(); |
@@ -25,12 +24,10 @@ discard block |
||
| 25 | 24 | if($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
| 26 | 25 | { |
| 27 | 26 | $fleet['fleet_end_name'] = $lang['ov_fleet_exploration']; |
| 28 | - } |
|
| 29 | - elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
| 27 | + } elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
| 30 | 28 | { |
| 31 | 29 | $fleet['fleet_end_name'] = $lang['ov_fleet_colonization']; |
| 32 | - } |
|
| 33 | - else |
|
| 30 | + } else |
|
| 34 | 31 | { |
| 35 | 32 | $planet_end = DBStaticPlanet::db_planet_by_gspt($fleet['fleet_end_galaxy'], $fleet['fleet_end_system'], $fleet['fleet_end_planet'], $planet_end_type, false, 'name'); |
| 36 | 33 | $fleet['fleet_end_name'] = $planet_end['name']; |
@@ -82,8 +79,7 @@ discard block |
||
| 82 | 79 | return $fleet_events; |
| 83 | 80 | } |
| 84 | 81 | |
| 85 | -function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) |
|
| 86 | -{ |
|
| 82 | +function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) { |
|
| 87 | 83 | global $user, $planetrow, $fleet_number; |
| 88 | 84 | |
| 89 | 85 | switch($fleet['ov_label'] = $ov_label) |
@@ -123,8 +119,7 @@ discard block |
||
| 123 | 119 | if($fleet['fleet_owner'] == $user['id']) |
| 124 | 120 | { |
| 125 | 121 | $user_data = $user; |
| 126 | - } |
|
| 127 | - else |
|
| 122 | + } else |
|
| 128 | 123 | { |
| 129 | 124 | $user_data = db_user_by_id($fleet['fleet_owner']); |
| 130 | 125 | } |
@@ -136,8 +131,7 @@ discard block |
||
| 136 | 131 | * @param array $planetrow |
| 137 | 132 | * @param template $template |
| 138 | 133 | */ |
| 139 | -function int_planet_pretemplate($planetrow, &$template) |
|
| 140 | -{ |
|
| 134 | +function int_planet_pretemplate($planetrow, &$template) { |
|
| 141 | 135 | global $lang, $user; |
| 142 | 136 | |
| 143 | 137 | $governor_id = $planetrow['PLANET_GOVERNOR_ID']; |
@@ -5,8 +5,7 @@ discard block |
||
| 5 | 5 | use Que\DBStaticQue; |
| 6 | 6 | use Universe\Universe; |
| 7 | 7 | |
| 8 | -function art_use(&$user, &$planetrow, $unit_id) |
|
| 9 | -{ |
|
| 8 | +function art_use(&$user, &$planetrow, $unit_id) { |
|
| 10 | 9 | global $lang; |
| 11 | 10 | |
| 12 | 11 | if(!in_array($unit_id, sn_get_groups('artifacts'))) |
@@ -53,14 +52,12 @@ discard block |
||
| 53 | 52 | { |
| 54 | 53 | $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moonSize, $updateDebris); |
| 55 | 54 | $message = sprintf($lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), HelperString::numberFloorAndFormat($moonSize)); |
| 56 | - } |
|
| 57 | - else |
|
| 55 | + } else |
|
| 58 | 56 | { |
| 59 | 57 | $message = $lang['art_lhc_moon_fail']; |
| 60 | 58 | } |
| 61 | 59 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_ADMIN, $lang['art_lhc_from'], $lang['art_lhc_subj'], $message); |
| 62 | - } |
|
| 63 | - else |
|
| 60 | + } else |
|
| 64 | 61 | { |
| 65 | 62 | $message = $lang['art_moon_exists']; |
| 66 | 63 | } |
@@ -88,8 +85,9 @@ discard block |
||
| 88 | 85 | $sectors_used = 0; |
| 89 | 86 | foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level) |
| 90 | 87 | { |
| 91 | - if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) |
|
| 92 | - continue; |
|
| 88 | + if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) { |
|
| 89 | + continue; |
|
| 90 | + } |
|
| 93 | 91 | $sectors_used += $levels_deployed; |
| 94 | 92 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($deploy_unit_id, $levels_deployed, $user, $planetrow['id']); |
| 95 | 93 | } |
@@ -123,8 +121,7 @@ discard block |
||
| 123 | 121 | DBStaticQue::db_que_set_time_left_by_id($que_item['que_id'], $que_item['que_time_left']); |
| 124 | 122 | $message = sprintf($lang['art_heurestic_chip_ok'], $lang['tech'][$que_item['que_unit_id']], $que_item['que_unit_level'], sys_time_human($old_time - $que_item['que_time_left'])); |
| 125 | 123 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_QUE, $lang['art_heurestic_chip_subj'], $lang['art_heurestic_chip_subj'], $message); |
| 126 | - } |
|
| 127 | - else |
|
| 124 | + } else |
|
| 128 | 125 | { |
| 129 | 126 | $message = $lang['art_heurestic_chip_no_research']; |
| 130 | 127 | } |
@@ -152,8 +149,7 @@ discard block |
||
| 152 | 149 | $lang['tech'][$que_item['que_unit_id']], $que_item['que_unit_level'], $planetrow['name'], uni_render_coordinates($planetrow), sys_time_human($old_time - $que_item['que_time_left']) |
| 153 | 150 | ); |
| 154 | 151 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_QUE, $lang['art_nano_builder_subj'], $lang['art_nano_builder_subj'], $message); |
| 155 | - } |
|
| 156 | - else |
|
| 152 | + } else |
|
| 157 | 153 | { |
| 158 | 154 | $message = $lang['art_nano_builder_no_que']; |
| 159 | 155 | } |
@@ -165,8 +161,7 @@ discard block |
||
| 165 | 161 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_level - $artifact_level_old, $user); |
| 166 | 162 | OldDbChangeSet::db_changeset_apply($db_changeset); |
| 167 | 163 | } |
| 168 | - } |
|
| 169 | - else |
|
| 164 | + } else |
|
| 170 | 165 | { |
| 171 | 166 | $message = $lang['art_err_no_artifact']; |
| 172 | 167 | } |