@@ -56,8 +56,7 @@ discard block |
||
| 56 | 56 | sprintf($lang['buddy_msg_accept_text'], $user['username'])); |
| 57 | 57 | sn_db_transaction_commit(); |
| 58 | 58 | throw new exception('buddy_err_accept_none', ERR_NONE); |
| 59 | - } |
|
| 60 | - else |
|
| 59 | + } else |
|
| 61 | 60 | { |
| 62 | 61 | throw new exception('buddy_err_accept_internal', ERR_ERROR); |
| 63 | 62 | } |
@@ -69,9 +68,11 @@ discard block |
||
| 69 | 68 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
| 70 | 69 | } |
| 71 | 70 | |
| 72 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
| 71 | + if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
| 72 | + // Existing friendship |
|
| 73 | 73 | { |
| 74 | 74 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
| 75 | + } |
|
| 75 | 76 | |
| 76 | 77 | msg_send_simple_message($ex_friend_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_unfriend_title'], |
| 77 | 78 | sprintf($lang['buddy_msg_unfriend_text'], $user['username'])); |
@@ -79,17 +80,19 @@ discard block |
||
| 79 | 80 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 80 | 81 | sn_db_transaction_commit(); |
| 81 | 82 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
| 82 | - } |
|
| 83 | - elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
| 83 | + } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
| 84 | + // Player's outcoming request - either denied or waiting |
|
| 84 | 85 | { |
| 85 | 86 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 87 | + } |
|
| 86 | 88 | sn_db_transaction_commit(); |
| 87 | 89 | throw new exception('buddy_err_delete_own', ERR_NONE); |
| 88 | - } |
|
| 89 | - elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
| 90 | + } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) { |
|
| 91 | + // Deny incoming request |
|
| 90 | 92 | { |
| 91 | 93 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
| 92 | 94 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
| 95 | + } |
|
| 93 | 96 | |
| 94 | 97 | doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_DENIED . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
| 95 | 98 | sn_db_transaction_commit(); |
@@ -104,8 +107,7 @@ discard block |
||
| 104 | 107 | if($new_friend_id = sys_get_param_id('request_user_id')) |
| 105 | 108 | { |
| 106 | 109 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
| 107 | - } |
|
| 108 | - elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 110 | + } elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
| 109 | 111 | { |
| 110 | 112 | $new_friend_row = db_user_by_username($new_friend_name); |
| 111 | 113 | $new_friend_name = db_escape($new_friend_name); |
@@ -138,8 +140,7 @@ discard block |
||
| 138 | 140 | sn_db_transaction_commit(); |
| 139 | 141 | throw new exception('buddy_err_adding_none', ERR_NONE); |
| 140 | 142 | } |
| 141 | -} |
|
| 142 | -catch(exception $e) |
|
| 143 | +} catch(exception $e) |
|
| 143 | 144 | { |
| 144 | 145 | $result[] = array( |
| 145 | 146 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -6,8 +6,7 @@ discard block |
||
| 6 | 6 | require_once('db_queries_fleet.php'); |
| 7 | 7 | |
| 8 | 8 | |
| 9 | -function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) |
|
| 10 | -{ |
|
| 9 | +function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) { |
|
| 11 | 10 | return doquery( |
| 12 | 11 | "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') . |
| 13 | 12 | " FROM {{planets}} AS p |
@@ -16,8 +15,7 @@ discard block |
||
| 16 | 15 | " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
| 17 | 16 | } |
| 18 | 17 | |
| 19 | -function db_planet_list_search($searchtext) |
|
| 20 | -{ |
|
| 18 | +function db_planet_list_search($searchtext) { |
|
| 21 | 19 | return doquery( |
| 22 | 20 | "SELECT |
| 23 | 21 | p.galaxy, p.system, p.planet, p.planet_type, p.name as planet_name, |
@@ -37,8 +35,7 @@ discard block |
||
| 37 | 35 | |
| 38 | 36 | |
| 39 | 37 | |
| 40 | -function db_user_list_search($searchtext) |
|
| 41 | -{ |
|
| 38 | +function db_user_list_search($searchtext) { |
|
| 42 | 39 | return doquery( |
| 43 | 40 | "SELECT |
| 44 | 41 | pn.player_name, u.id as uid, u.username, u.ally_id, u.id_planet, u.total_points, u.total_rank, |
@@ -56,8 +53,7 @@ discard block |
||
| 56 | 53 | ); |
| 57 | 54 | } |
| 58 | 55 | |
| 59 | -function db_buddy_list_by_user($user_id) |
|
| 60 | -{ |
|
| 56 | +function db_buddy_list_by_user($user_id) { |
|
| 61 | 57 | // return ($user_id = intval($user_id)) ? doquery( |
| 62 | 58 | return ($user_id = idval($user_id)) ? doquery( |
| 63 | 59 | "SELECT |
@@ -87,8 +83,7 @@ discard block |
||
| 87 | 83 | |
| 88 | 84 | |
| 89 | 85 | |
| 90 | -function db_unit_records_sum($unit_id, $user_skip_list_unit) |
|
| 91 | -{ |
|
| 86 | +function db_unit_records_sum($unit_id, $user_skip_list_unit) { |
|
| 92 | 87 | return doquery ( |
| 93 | 88 | "SELECT unit_player_id, username, sum(unit_level) as unit_level |
| 94 | 89 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
@@ -99,8 +94,7 @@ discard block |
||
| 99 | 94 | , true); |
| 100 | 95 | } |
| 101 | 96 | |
| 102 | -function db_unit_records_plain($unit_id, $user_skip_list_unit) |
|
| 103 | -{ |
|
| 97 | +function db_unit_records_plain($unit_id, $user_skip_list_unit) { |
|
| 104 | 98 | return doquery ( |
| 105 | 99 | "SELECT unit_player_id, username, unit_level |
| 106 | 100 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
@@ -184,15 +178,13 @@ discard block |
||
| 184 | 178 | } |
| 185 | 179 | |
| 186 | 180 | |
| 187 | -function db_stat_list_delete_ally_player() |
|
| 188 | -{ |
|
| 181 | +function db_stat_list_delete_ally_player() { |
|
| 189 | 182 | 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'); |
| 190 | 183 | } |
| 191 | 184 | |
| 192 | 185 | |
| 193 | 186 | |
| 194 | -function db_chat_player_list_online($chat_refresh_rate, $ally_add) |
|
| 195 | -{ |
|
| 187 | +function db_chat_player_list_online($chat_refresh_rate, $ally_add) { |
|
| 196 | 188 | $sql_date = SN_TIME_NOW - $chat_refresh_rate * 2; |
| 197 | 189 | |
| 198 | 190 | return doquery( |
@@ -206,13 +198,11 @@ discard block |
||
| 206 | 198 | ORDER BY authlevel DESC, `username`"); |
| 207 | 199 | } |
| 208 | 200 | |
| 209 | -function db_referrals_list_by_id($user_id) |
|
| 210 | -{ |
|
| 201 | +function db_referrals_list_by_id($user_id) { |
|
| 211 | 202 | 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}"); |
| 212 | 203 | } |
| 213 | 204 | |
| 214 | -function db_message_list_admin_by_type($int_type_selected, $StartRec) |
|
| 215 | -{ |
|
| 205 | +function db_message_list_admin_by_type($int_type_selected, $StartRec) { |
|
| 216 | 206 | return doquery("SELECT |
| 217 | 207 | message_id as `ID`, |
| 218 | 208 | message_from as `FROM`, |
@@ -231,8 +221,7 @@ discard block |
||
| 231 | 221 | } |
| 232 | 222 | |
| 233 | 223 | |
| 234 | -function db_message_insert_all($message_type, $from, $subject, $text) |
|
| 235 | -{ |
|
| 224 | +function db_message_insert_all($message_type, $from, $subject, $text) { |
|
| 236 | 225 | return doquery($QryInsertMessage = 'INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
| 237 | 226 | "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}"); |
| 238 | 227 | } |
@@ -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'); |