@@ -55,11 +55,10 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function db_planet_by_vector($vector, $prefix = '', $for_update = false, $fields = '*') { |
58 | - $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0; |
|
59 | - $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0; |
|
60 | - $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0; |
|
61 | - $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : |
|
62 | - (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0); |
|
58 | + $galaxy = isset($vector[$prefix.'galaxy']) ? intval($vector[$prefix.'galaxy']) : 0; |
|
59 | + $system = isset($vector[$prefix.'system']) ? intval($vector[$prefix.'system']) : 0; |
|
60 | + $planet = isset($vector[$prefix.'planet']) ? intval($vector[$prefix.'planet']) : 0; |
|
61 | + $planet_type = isset($vector[$prefix.'planet_type']) ? intval($vector[$prefix.'planet_type']) : (isset($vector[$prefix.'type']) ? intval($vector[$prefix.'type']) : 0); |
|
63 | 62 | $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type; |
64 | 63 | |
65 | 64 | return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields); |
@@ -85,7 +84,7 @@ discard block |
||
85 | 84 | } |
86 | 85 | |
87 | 86 | return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, |
88 | - "`parent_planet` = {$parent_id} AND `planet_type` = " . PT_MOON, true); |
|
87 | + "`parent_planet` = {$parent_id} AND `planet_type` = ".PT_MOON, true); |
|
89 | 88 | } |
90 | 89 | |
91 | 90 | public static function db_planet_by_id_and_owner($planet_id, $owner_id, $for_update = false, $fields = '*') { |
@@ -106,7 +105,7 @@ discard block |
||
106 | 105 | } |
107 | 106 | |
108 | 107 | return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, |
109 | - "`planet_type` = " . PT_MOON . " AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}"); |
|
108 | + "`planet_type` = ".PT_MOON." AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}"); |
|
110 | 109 | } |
111 | 110 | |
112 | 111 | public static function db_planet_list_in_system($galaxy, $system) { |
@@ -132,7 +131,7 @@ discard block |
||
132 | 131 | ); |
133 | 132 | $order_by = classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT]; |
134 | 133 | empty($sort_orders[$order_by]) ? $order_by = SORT_ID : false; |
135 | - $order_by = $sort_orders[$order_by] . ' ' . (classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC'); |
|
134 | + $order_by = $sort_orders[$order_by].' '.(classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC'); |
|
136 | 135 | |
137 | 136 | // Compilating query |
138 | 137 | return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET, |
@@ -160,7 +159,7 @@ discard block |
||
160 | 159 | foreach ($planetRowFieldChanges as $resourceId => $value) { |
161 | 160 | $fields[pname_resource_name($resourceId)] = $value; |
162 | 161 | } |
163 | - if(!empty($fields)) { |
|
162 | + if (!empty($fields)) { |
|
164 | 163 | classSupernova::$gc->db->doUpdateRowAdjust( |
165 | 164 | TABLE_PLANETS, |
166 | 165 | array(), |
@@ -197,7 +196,7 @@ discard block |
||
197 | 196 | 'system' => $ui_system, |
198 | 197 | 'planet' => $ui_planet, |
199 | 198 | ); |
200 | - if(intval($ui_planet_type)) { |
|
199 | + if (intval($ui_planet_type)) { |
|
201 | 200 | $where['planet_type'] = $ui_planet_type; |
202 | 201 | } |
203 | 202 | classSupernova::$gc->cacheOperator->db_upd_record_list( |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | $query = $this->db->doSelect( |
199 | 199 | "SELECT |
200 | 200 | distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
201 | - FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
202 | - ($filter ? ' WHERE ' . $filter : '') . |
|
201 | + FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
202 | + ($filter ? ' WHERE '.$filter : ''). |
|
203 | 203 | ($fetch ? ' LIMIT 1' : '')); |
204 | 204 | while ($row = db_fetch($query)) { |
205 | 205 | // Исключаем из списка родительских ИД уже заблокированные записи |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | if ($indexes_str = implode(',', $parent_id_list)) { |
213 | 213 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
214 | 214 | classSupernova::$gc->cacheOperator->db_get_record_list($owner_location_type, |
215 | - $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
215 | + $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | 220 | $query = $this->db->doSelect( |
221 | - "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
221 | + "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
222 | 222 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
223 | 223 | . " FOR UPDATE" |
224 | 224 | ); |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | public function db_lock_tables($tables) { |
427 | 427 | $tables = is_array($tables) ? $tables : array($tables => ''); |
428 | 428 | foreach ($tables as $table_name => $condition) { |
429 | - $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
429 | + $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
430 | 430 | } |
431 | 431 | } |
432 | 432 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | if (classSupernova::$gc->snCache->isUnitLocatorNotSet($location_type, $location_id)) { |
27 | - $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions()); |
|
27 | + $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions()); |
|
28 | 28 | if (!empty($got_data) && is_array($got_data)) { |
29 | 29 | foreach ($got_data as $unit_id => $unit_data) { |
30 | 30 | classSupernova::$gc->snCache->setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data); |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | |
60 | 60 | public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) { |
61 | 61 | $query = classSupernova::$db->doSelect( |
62 | - "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} " . |
|
63 | - ($unit_type ? "AND `unit_type` = {$unit_type} " : '') . |
|
64 | - ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') . |
|
62 | + "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} ". |
|
63 | + ($unit_type ? "AND `unit_type` = {$unit_type} " : ''). |
|
64 | + ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : ''). |
|
65 | 65 | 'GROUP BY `unit_snid`' |
66 | 66 | ); |
67 | 67 | $result = array(); |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | WHERE |
82 | 82 | f.fleet_owner = {$user_id} AND |
83 | 83 | (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id}) |
84 | - AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() . |
|
85 | - " LIMIT 1" . |
|
84 | + AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions(). |
|
85 | + " LIMIT 1". |
|
86 | 86 | ($for_update ? ' FOR UPDATE' : '')); |
87 | 87 | } |
88 | 88 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public static function db_unit_list_laboratories($user_id) { |
91 | 91 | return classSupernova::$db->doSelect("SELECT DISTINCT unit_location_id AS `id` |
92 | 92 | FROM {{unit}} |
93 | - WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");"); |
|
93 | + WHERE unit_player_id = {$user_id} AND unit_location_type = ".LOC_PLANET." AND unit_level > 0 AND unit_snid IN (".STRUC_LABORATORY.", ".STRUC_LABORATORY_NANO.");"); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | return classSupernova::$db->doSelect( |
137 | 137 | "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount |
138 | 138 | FROM `{{unit}}` |
139 | - WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() . |
|
139 | + WHERE unit_level > 0 AND " . self::db_unit_time_restrictions(). |
|
140 | 140 | " GROUP BY unit_player_id, unit_type, unit_snid, unit_level" |
141 | 141 | ); |
142 | 142 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | public static function db_unit_list_admin_delete_mercenaries_finished() { |
160 | 160 | return classSupernova::$db->doDeleteDeprecated(TABLE_UNIT, array( |
161 | 161 | 'unit_time_finish IS NOT NULL', |
162 | - "unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ")", |
|
162 | + "unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.")", |
|
163 | 163 | 'unit_type' => UNIT_MERCENARIES, |
164 | 164 | )); |
165 | 165 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
200 | 200 | if (!empty($temp['unit_id'])) { |
201 | - $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
|
201 | + $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
|
202 | 202 | LOC_UNIT, |
203 | 203 | $temp['unit_id'], |
204 | 204 | array(), |
@@ -209,15 +209,15 @@ discard block |
||
209 | 209 | } else { |
210 | 210 | $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id; |
211 | 211 | $unitType = get_unit_param($unit_id, P_UNIT_TYPE); |
212 | - $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record( |
|
212 | + $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record( |
|
213 | 213 | LOC_UNIT, |
214 | 214 | array( |
215 | 215 | 'unit_player_id' => $user['id'], |
216 | - 'unit_location_type' => (int)$unit_location, |
|
216 | + 'unit_location_type' => (int) $unit_location, |
|
217 | 217 | 'unit_location_id' => $locationIdRendered, |
218 | - 'unit_type' => (int)$unitType, |
|
219 | - 'unit_snid' => (int)$unit_id, |
|
220 | - 'unit_level' => (float)$unit_value, |
|
218 | + 'unit_type' => (int) $unitType, |
|
219 | + 'unit_snid' => (int) $unit_id, |
|
220 | + 'unit_level' => (float) $unit_value, |
|
221 | 221 | ) |
222 | 222 | ); |
223 | 223 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $this->players->db_load_player_by_id($player_id, UBE_PLAYER_IS_DEFENDER); |
148 | 148 | |
149 | 149 | $player_db_row = $this->players[$player_id]->getDbRow(); |
150 | - if($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) { |
|
150 | + if ($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) { |
|
151 | 151 | $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $fortifier_level); |
152 | 152 | } |
153 | 153 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $this->rounds[0] = new UBERound(0); |
179 | 179 | $this->rounds[0]->make_snapshot($this->fleet_list); |
180 | 180 | |
181 | - for($round = 1; $round <= 10; $round++) { |
|
181 | + for ($round = 1; $round <= 10; $round++) { |
|
182 | 182 | // Проводим раунд |
183 | 183 | defined('DEBUG_UBE') ? print("Round {$round}<br>") : false; |
184 | 184 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | // Анализируем итоги текущего раунда и готовим данные для следующего |
193 | 193 | $this->combat_result = $this->fleet_list->ubeAnalyzeFleetOutcome($round); |
194 | - if($this->combat_result != UBE_COMBAT_RESULT_DRAW) { |
|
194 | + if ($this->combat_result != UBE_COMBAT_RESULT_DRAW) { |
|
195 | 195 | break; |
196 | 196 | } |
197 | 197 | |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | // Генерируем результат боя |
221 | 221 | $this->fleet_list->ube_analyze_fleets($this->is_simulator, $this->debris, $this->resource_exchange_rates); |
222 | 222 | |
223 | - if(!$this->is_ube_loaded) { |
|
223 | + if (!$this->is_ube_loaded) { |
|
224 | 224 | $this->moon_calculator->calculate_moon($this); |
225 | 225 | |
226 | 226 | // Лутаем ресурсы - если аттакер выиграл |
227 | - if($this->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
227 | + if ($this->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
228 | 228 | $this->sn_ube_combat_analyze_loot(); |
229 | 229 | } |
230 | 230 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | RES_DEUTERIUM => 0, |
245 | 245 | ); |
246 | 246 | |
247 | - if( |
|
247 | + if ( |
|
248 | 248 | (($planet_resource_total = $this->fleet_list[0]->get_resources_amount()) > 0) |
249 | 249 | && |
250 | 250 | (($total_capacity = $this->fleet_list->ube_get_capacity_attackers()) > 0) |
@@ -256,9 +256,9 @@ discard block |
||
256 | 256 | $planet_lootable_percent = $planet_lootable / $planet_resource_total; |
257 | 257 | |
258 | 258 | // Вычисляем сколько ресурсов вывезено |
259 | - foreach($this->fleet_list->_container as $fleet_id => $fleet) { |
|
259 | + foreach ($this->fleet_list->_container as $fleet_id => $fleet) { |
|
260 | 260 | $looted_in_metal = 0; |
261 | - foreach($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) { |
|
261 | + foreach ($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) { |
|
262 | 262 | // Вычисляем какой процент общей емкости трюмов атакующих будет задействован |
263 | 263 | $fleet_lootable_percent = $fleet->fleet_capacity / $total_capacity; |
264 | 264 | $looted = floor($resource_amount * $planet_lootable_percent * $fleet_lootable_percent); |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $destination_user_id = $this->fleet_list[0]->owner_id; |
324 | 324 | |
325 | 325 | // Обновляем поле обломков на планете |
326 | - if(!$this->is_admin_in_combat && $this->debris->debris_total() > 0) { |
|
326 | + if (!$this->is_admin_in_combat && $this->debris->debris_total() > 0) { |
|
327 | 327 | DBStaticPlanet::db_planet_update_by_gspt( |
328 | 328 | $this->ube_planet_info[PLANET_GALAXY], $this->ube_planet_info[PLANET_SYSTEM], $this->ube_planet_info[PLANET_PLANET], PT_PLANET, |
329 | 329 | array(), |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | ); |
335 | 335 | } |
336 | 336 | |
337 | - foreach($this->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
337 | + foreach ($this->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
338 | 338 | $ship_count_lost = $UBEFleet->unit_list->unitCountLost(); |
339 | 339 | |
340 | - if($fleet_id) { |
|
340 | + if ($fleet_id) { |
|
341 | 341 | // Флот |
342 | 342 | $UBEFleet->db_save_combat_result_fleet($this->is_small_fleet_recce, $this->moon_calculator->get_reapers_status()); |
343 | 343 | } else { |
@@ -345,18 +345,18 @@ discard block |
||
345 | 345 | |
346 | 346 | // Сохраняем изменения ресурсов - если они есть |
347 | 347 | $resource_delta = $UBEFleet->ube_combat_result_calculate_resources(); |
348 | - if(!empty($resource_delta)) { |
|
348 | + if (!empty($resource_delta)) { |
|
349 | 349 | $temp = array(); |
350 | - foreach($resource_delta as $resource_id => $resource_amount) { |
|
350 | + foreach ($resource_delta as $resource_id => $resource_amount) { |
|
351 | 351 | $resource_db_name = pname_resource_name($resource_id); |
352 | 352 | $temp[] = "`{$resource_db_name}` = `{$resource_db_name}` + ({$resource_amount})"; |
353 | 353 | } |
354 | 354 | DBStaticPlanet::db_planet_update_set_by_id_DEPRECATED($this->ube_planet_info[PLANET_ID], implode(',', $temp)); |
355 | 355 | } |
356 | 356 | |
357 | - if($ship_count_lost) { |
|
357 | + if ($ship_count_lost) { |
|
358 | 358 | $planet_row_cache = $this->players[$destination_user_id]->getDbRow(); |
359 | - foreach($UBEFleet->unit_list->_container as $UBEUnit) { |
|
359 | + foreach ($UBEFleet->unit_list->_container as $UBEUnit) { |
|
360 | 360 | DBStaticUnit::dbUpdateOrInsertUnit($UBEUnit->unitId, -$UBEUnit->units_lost, $planet_row_cache, $this->ube_planet_info[PLANET_ID]); |
361 | 361 | } |
362 | 362 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL |
367 | 367 | // Для САБов |
368 | 368 | $fleet_group_id_list = $this->fleet_list->ube_get_groups(); |
369 | - if(!empty($fleet_group_id_list)) { |
|
369 | + if (!empty($fleet_group_id_list)) { |
|
370 | 370 | $fleet_group_id_list = implode(',', $fleet_group_id_list); |
371 | 371 | DBStaticFleetACS::db_acs_delete_by_list($fleet_group_id_list); |
372 | 372 | } |
@@ -375,19 +375,19 @@ discard block |
||
375 | 375 | |
376 | 376 | $bashing_list = array(); |
377 | 377 | $players_sides = $this->players->get_player_sides(); |
378 | - foreach($players_sides as $player_id => $player_side) { |
|
379 | - if($player_side != UBE_PLAYER_IS_ATTACKER) { |
|
378 | + foreach ($players_sides as $player_id => $player_side) { |
|
379 | + if ($player_side != UBE_PLAYER_IS_ATTACKER) { |
|
380 | 380 | continue; |
381 | 381 | } |
382 | - if($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) { |
|
382 | + if ($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) { |
|
383 | 383 | $bashing_list[] = "({$player_id}, {$this->ube_planet_info[PLANET_ID]}, {$this->combat_timestamp})"; |
384 | 384 | } |
385 | - if($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) { |
|
385 | + if ($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) { |
|
386 | 386 | $str_loose_or_win = $this->combat_result == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose'; |
387 | 387 | DBStaticUser::db_user_set_by_id_DEPRECATED($player_id, "`xpraid` = `xpraid` + 1, `raids` = `raids` + 1, `{$str_loose_or_win}` = `{$str_loose_or_win}` + 1"); |
388 | 388 | } |
389 | 389 | } |
390 | - if(!empty($bashing_list)) { |
|
390 | + if (!empty($bashing_list)) { |
|
391 | 391 | DBStaticFleetBashing::db_bashing_insert($bashing_list); |
392 | 392 | } |
393 | 393 | |
@@ -413,20 +413,19 @@ discard block |
||
413 | 413 | $planet_info[PLANET_SYSTEM], |
414 | 414 | $planet_info[PLANET_PLANET], |
415 | 415 | htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'), |
416 | - classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : |
|
417 | - ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')] |
|
416 | + classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')] |
|
418 | 417 | ); |
419 | 418 | |
420 | 419 | $text_defender = ''; |
421 | 420 | $debris = $this->debris->get_debris(); |
422 | - foreach($debris as $resource_id => $resource_amount) { |
|
423 | - if($resource_id == RES_DEUTERIUM) { |
|
421 | + foreach ($debris as $resource_id => $resource_amount) { |
|
422 | + if ($resource_id == RES_DEUTERIUM) { |
|
424 | 423 | continue; |
425 | 424 | } |
426 | 425 | |
427 | - $text_defender .= "{$classLocale['tech'][$resource_id]}: " . pretty_number($resource_amount) . '<br />'; |
|
426 | + $text_defender .= "{$classLocale['tech'][$resource_id]}: ".pretty_number($resource_amount).'<br />'; |
|
428 | 427 | } |
429 | - if($text_defender) { |
|
428 | + if ($text_defender) { |
|
430 | 429 | $text_defender = "{$classLocale['ube_report_msg_body_debris']}{$text_defender}<br />"; |
431 | 430 | } |
432 | 431 | |
@@ -436,8 +435,8 @@ discard block |
||
436 | 435 | |
437 | 436 | // TODO: Оптимизировать отсылку сообщений - отсылать пакетами |
438 | 437 | $player_sides = $this->players->get_player_sides(); |
439 | - foreach($player_sides as $player_id => $player_side) { |
|
440 | - $message = $text_common . ($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender); |
|
438 | + foreach ($player_sides as $player_id => $player_side) { |
|
439 | + $message = $text_common.($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender); |
|
441 | 440 | DBStaticMessages::msg_send_simple_message($player_id, '', $this->combat_timestamp, MSG_TYPE_COMBAT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_attack_report'], $message); |
442 | 441 | } |
443 | 442 | |
@@ -472,11 +471,11 @@ discard block |
||
472 | 471 | $player_id = $player_id == -1 ? $this->players->count() : $player_id; |
473 | 472 | $fleet_id = $player_id; // FOR SIMULATOR! |
474 | 473 | |
475 | - if(empty($this->players[$player_id])) { |
|
474 | + if (empty($this->players[$player_id])) { |
|
476 | 475 | $this->players[$player_id] = new UBEPlayer(); |
477 | 476 | } |
478 | 477 | |
479 | - foreach($side_info as $fleet_data) { |
|
478 | + foreach ($side_info as $fleet_data) { |
|
480 | 479 | $this->players[$player_id]->name = $player_id; |
481 | 480 | $this->players[$player_id]->setSide($attacker); |
482 | 481 | |
@@ -484,32 +483,32 @@ discard block |
||
484 | 483 | $this->fleet_list[$fleet_id] = $objFleet; |
485 | 484 | |
486 | 485 | $this->fleet_list[$fleet_id]->owner_id = $player_id; |
487 | - foreach($fleet_data as $unit_id => $unit_count) { |
|
488 | - if(!$unit_count) { |
|
486 | + foreach ($fleet_data as $unit_id => $unit_count) { |
|
487 | + if (!$unit_count) { |
|
489 | 488 | continue; |
490 | 489 | } |
491 | 490 | |
492 | 491 | $unit_type = get_unit_param($unit_id, P_UNIT_TYPE); |
493 | 492 | |
494 | - if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
493 | + if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) { |
|
495 | 494 | $this->fleet_list[$fleet_id]->unit_list->unitAdjustCount($unit_id, $unit_count); |
496 | - } elseif($unit_type == UNIT_RESOURCES) { |
|
495 | + } elseif ($unit_type == UNIT_RESOURCES) { |
|
497 | 496 | $this->fleet_list[$fleet_id]->resource_list[$unit_id] = $unit_count; |
498 | - } elseif($unit_type == UNIT_TECHNOLOGIES) { |
|
499 | - if($unit_id == TECH_WEAPON) { |
|
497 | + } elseif ($unit_type == UNIT_TECHNOLOGIES) { |
|
498 | + if ($unit_id == TECH_WEAPON) { |
|
500 | 499 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_WEAPON, $unit_count); |
501 | - } elseif($unit_id == TECH_SHIELD) { |
|
500 | + } elseif ($unit_id == TECH_SHIELD) { |
|
502 | 501 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_SHIELD, $unit_count); |
503 | - } elseif($unit_id == TECH_ARMOR) { |
|
502 | + } elseif ($unit_id == TECH_ARMOR) { |
|
504 | 503 | $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_ARMOR, $unit_count); |
505 | 504 | } |
506 | - } elseif($unit_type == UNIT_GOVERNORS) { |
|
507 | - if($unit_id == MRC_FORTIFIER) { |
|
505 | + } elseif ($unit_type == UNIT_GOVERNORS) { |
|
506 | + if ($unit_id == MRC_FORTIFIER) { |
|
508 | 507 | // Фортифаер даёт бонус ко всему |
509 | 508 | $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $unit_count); |
510 | 509 | } |
511 | - } elseif($unit_type == UNIT_MERCENARIES) { |
|
512 | - if($unit_id == MRC_ADMIRAL) { |
|
510 | + } elseif ($unit_type == UNIT_MERCENARIES) { |
|
511 | + if ($unit_id == MRC_ADMIRAL) { |
|
513 | 512 | $this->players[$player_id]->player_bonus->add_unit_by_snid(MRC_ADMIRAL, $unit_count); |
514 | 513 | } |
515 | 514 | } |
@@ -563,7 +562,7 @@ discard block |
||
563 | 562 | |
564 | 563 | $ube->sn_ube_message_send(); |
565 | 564 | |
566 | - defined('DEBUG_UBE') ? die('DIE at ' . __FILE__ . ' ' . __LINE__) : false; |
|
565 | + defined('DEBUG_UBE') ? die('DIE at '.__FILE__.' '.__LINE__) : false; |
|
567 | 566 | |
568 | 567 | return false; |
569 | 568 | } |
@@ -578,7 +577,7 @@ discard block |
||
578 | 577 | |
579 | 578 | $ube_report = new UBEReport(); |
580 | 579 | $ube = $ube_report->sn_ube_report_load(sys_get_param_str('cypher')); |
581 | - if($ube != UBE_REPORT_NOT_FOUND) { |
|
580 | + if ($ube != UBE_REPORT_NOT_FOUND) { |
|
582 | 581 | $ube_report->sn_ube_report_generate($ube, $template_result); |
583 | 582 | |
584 | 583 | $template = gettemplate('ube_combat_report', $template); |
@@ -606,9 +605,9 @@ discard block |
||
606 | 605 | $ube->sn_ube_combat(); |
607 | 606 | $ube_report = new UBEReport(); |
608 | 607 | |
609 | - if(sys_get_param_str('reload')) { |
|
608 | + if (sys_get_param_str('reload')) { |
|
610 | 609 | $ube_new = $ube_report->sn_ube_report_load($ube->get_cypher()); // $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]); |
611 | - if($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) { |
|
610 | + if ($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) { |
|
612 | 611 | $ube = $ube_new; |
613 | 612 | } |
614 | 613 | } |
@@ -656,7 +655,7 @@ discard block |
||
656 | 655 | $this->debris->load_from_report_row($report_row); |
657 | 656 | |
658 | 657 | $query = classSupernova::$db->doSelect("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}"); |
659 | - while($player_row = db_fetch($query)) { |
|
658 | + while ($player_row = db_fetch($query)) { |
|
660 | 659 | $this->players->init_player_from_report_info($player_row); |
661 | 660 | } |
662 | 661 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ->where('`user_as_ally` IS NULL') |
24 | 24 | ->orderBy(array('`id` DESC')); |
25 | 25 | |
26 | - return (string)$query->selectValue(); |
|
26 | + return (string) $query->selectValue(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | static::buildDBQ() |
49 | 49 | ->field('id') |
50 | 50 | ->where("`user_as_ally` IS NULL") |
51 | - ->where("`user_bot` = " . USER_BOT_PLAYER) |
|
51 | + ->where("`user_bot` = ".USER_BOT_PLAYER) |
|
52 | 52 | ->setForUpdate(); |
53 | 53 | |
54 | 54 | return $query->selectIterator(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) { |
58 | - $query = "SELECT 1 FROM `{{users}}` WHERE `id` = " . idval($user['id']) . |
|
59 | - (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '') |
|
58 | + $query = "SELECT 1 FROM `{{users}}` WHERE `id` = ".idval($user['id']). |
|
59 | + (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : '') |
|
60 | 60 | . " FOR UPDATE"; |
61 | 61 | |
62 | 62 | static::getDb()->doSelect($query); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | FROM `{{users}}` |
74 | 74 | WHERE |
75 | 75 | `user_as_ally` IS NULL" . |
76 | - ($online ? ' AND `onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '') |
|
76 | + ($online ? ' AND `onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '') |
|
77 | 77 | )); |
78 | 78 | } |
79 | 79 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ->fieldCount('r.id', 'referral_count') |
96 | 96 | ->fieldSingleFunction('sum', 'r.dark_matter', 'referral_dm') |
97 | 97 | ->join('LEFT JOIN {{referrals}} as r on r.id_partner = u.id') |
98 | - ->where($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL') |
|
98 | + ->where($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL') |
|
99 | 99 | ->groupBy('u.id') |
100 | 100 | ->orderBy("user_as_ally, {$sort} ASC"); |
101 | 101 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | ->where('(`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE)') |
114 | 114 | ->where('`user_as_ally` IS NULL') |
115 | 115 | ->having('`days_after_birthday` >= 0') |
116 | - ->having('`days_after_birthday` < ' . intval($config_user_birthday_range)) |
|
116 | + ->having('`days_after_birthday` < '.intval($config_user_birthday_range)) |
|
117 | 117 | ->setForUpdate(); |
118 | 118 | |
119 | 119 | $result = $query->selectIterator(); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет |
218 | 218 | |
219 | 219 | $user = classSupernova::$db->doSelectFetch( |
220 | - "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'" |
|
220 | + "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'" |
|
221 | 221 | . " FOR UPDATE" |
222 | 222 | ); |
223 | 223 | classSupernova::$gc->snCache->cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | public static function db_user_list_set_mass_mail(&$owners_list, $adjust) { |
281 | 281 | $where = array(); |
282 | 282 | if (!empty($owners_list)) { |
283 | - $where[] = '`id` IN (' . implode(',', $owners_list) . ')'; |
|
283 | + $where[] = '`id` IN ('.implode(',', $owners_list).')'; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | // Danger - 'cause if IN clause |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | * @param array $playerArray |
338 | 338 | */ |
339 | 339 | public static function renderNameAndCoordinates($playerArray) { |
340 | - return "{$playerArray['username']} " . uni_render_coordinates($playerArray); |
|
340 | + return "{$playerArray['username']} ".uni_render_coordinates($playerArray); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | foreach ($playerRowFieldChanges as $resourceId => $value) { |
372 | 372 | $fields[pname_resource_name($resourceId)] = $value; |
373 | 373 | } |
374 | - if(!empty($fields)) { |
|
374 | + if (!empty($fields)) { |
|
375 | 375 | classSupernova::$gc->db->doUpdateRowAdjust( |
376 | 376 | TABLE_USERS, |
377 | 377 | array(), |