@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | // Compare function to sort fleet in time order |
4 | 4 | function tpl_assign_fleet_compare($a, $b) { |
5 | - if($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
6 | - if($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
5 | + if ($a['fleet']['OV_THIS_PLANET'] == $b['fleet']['OV_THIS_PLANET']) { |
|
6 | + if ($a['fleet']['OV_LEFT'] == $b['fleet']['OV_LEFT']) { |
|
7 | 7 | return 0; |
8 | 8 | } |
9 | 9 | |
@@ -19,17 +19,17 @@ discard block |
||
19 | 19 | * @param string $js_name |
20 | 20 | */ |
21 | 21 | function tpl_assign_fleet(&$template, $fleets, $js_name = 'fleets') { |
22 | - if(!$fleets) { |
|
22 | + if (!$fleets) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
26 | 26 | usort($fleets, 'tpl_assign_fleet_compare'); |
27 | 27 | |
28 | - foreach($fleets as $fleet_data) { |
|
28 | + foreach ($fleets as $fleet_data) { |
|
29 | 29 | $template->assign_block_vars($js_name, $fleet_data['fleet']); |
30 | 30 | |
31 | - if($fleet_data['ships']) { |
|
32 | - foreach($fleet_data['ships'] as $ship_data) { |
|
31 | + if ($fleet_data['ships']) { |
|
32 | + foreach ($fleet_data['ships'] as $ship_data) { |
|
33 | 33 | $template->assign_block_vars("{$js_name}.ships", $ship_data); |
34 | 34 | } |
35 | 35 | } |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | 'DEUTERIUM' => $fleet[RES_DEUTERIUM], |
51 | 51 | ); |
52 | 52 | |
53 | - foreach($fleet as $ship_id => $ship_amount) { |
|
54 | - if(in_array($ship_id, sn_get_groups('fleet'))) { |
|
53 | + foreach ($fleet as $ship_id => $ship_amount) { |
|
54 | + if (in_array($ship_id, sn_get_groups('fleet'))) { |
|
55 | 55 | $single_ship_data = get_ship_data($ship_id, $user_data); |
56 | 56 | $return['ships'][$ship_id] = array( |
57 | 57 | 'ID' => $ship_id, |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | |
91 | 91 | $result = array(); |
92 | 92 | |
93 | - if(!$user_data) { |
|
93 | + if (!$user_data) { |
|
94 | 94 | $user_data = $user; |
95 | 95 | } |
96 | 96 | |
97 | - if(!$objFleet->isReturning() && $objFleet->mission_type == MT_AKS) { |
|
97 | + if (!$objFleet->isReturning() && $objFleet->mission_type == MT_AKS) { |
|
98 | 98 | $aks = db_acs_get_by_group_id($objFleet->group_id); |
99 | 99 | } |
100 | 100 | |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | 'STAY_LEFT' => floor($objFleet->time_mission_job_complete + 1 - SN_TIME_NOW), |
136 | 136 | ); |
137 | 137 | |
138 | - if(property_exists($objFleet, 'fleet_start_name')) { |
|
138 | + if (property_exists($objFleet, 'fleet_start_name')) { |
|
139 | 139 | $result['START_NAME'] = $objFleet->fleet_start_name; |
140 | 140 | } |
141 | - if(property_exists($objFleet, 'fleet_end_name')) { |
|
141 | + if (property_exists($objFleet, 'fleet_end_name')) { |
|
142 | 142 | $result['END_NAME'] = $objFleet->fleet_end_name; |
143 | 143 | } |
144 | 144 | |
145 | - if(property_exists($objFleet, 'event_time')) { |
|
145 | + if (property_exists($objFleet, 'event_time')) { |
|
146 | 146 | $result['fleet'] = array_merge($result['fleet'], array( |
147 | 147 | 'OV_LABEL' => $objFleet->ov_label, |
148 | 148 | 'EVENT_TIME_TEXT' => property_exists($objFleet, 'event_time') ? date(FMT_DATE_TIME, $objFleet->event_time + SN_CLIENT_TIME_DIFF) : '', |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | $ship_list_fully_parsed = $objFleet->shipsGetArray(); |
155 | 155 | |
156 | 156 | $ship_id = 0; |
157 | - if($spy_level >= 6) { |
|
158 | - foreach($ship_list_fully_parsed as $ship_sn_id => $ship_amount) { |
|
159 | - if($spy_level >= 10) { |
|
157 | + if ($spy_level >= 6) { |
|
158 | + foreach ($ship_list_fully_parsed as $ship_sn_id => $ship_amount) { |
|
159 | + if ($spy_level >= 10) { |
|
160 | 160 | $single_ship_data = get_ship_data($ship_sn_id, $user_data); |
161 | 161 | $result['ships'][$ship_sn_id] = array( |
162 | 162 | 'ID' => $ship_sn_id, |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | function tpl_parse_planet_que($que, $planet, $que_id) { |
189 | 189 | $hangar_que = array(); |
190 | 190 | $que_hangar = $que['ques'][$que_id][$planet['id_owner']][$planet['id']]; |
191 | - if(!empty($que_hangar)) { |
|
192 | - foreach($que_hangar as $que_item) { |
|
191 | + if (!empty($que_hangar)) { |
|
192 | + foreach ($que_hangar as $que_item) { |
|
193 | 193 | $hangar_que['que'][] = array('id' => $que_item['que_unit_id'], 'count' => $que_item['que_unit_amount']); |
194 | 194 | $hangar_que[$que_item['que_unit_id']] += $que_item['que_unit_amount']; |
195 | 195 | } |
@@ -252,10 +252,10 @@ discard block |
||
252 | 252 | 'PLANET_GOVERNOR_LEVEL_MAX' => get_unit_param($planet['PLANET_GOVERNOR_ID'], P_MAX_STACK), |
253 | 253 | ); |
254 | 254 | |
255 | - if(!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
255 | + if (!empty($que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']])) { |
|
256 | 256 | $result['building_que'] = array(); |
257 | 257 | $building_que = &$que['ques'][QUE_STRUCTURES][$planet['id_owner']][$planet['id']]; |
258 | - foreach($building_que as $que_element) { |
|
258 | + foreach ($building_que as $que_element) { |
|
259 | 259 | $result['building_que'][] = que_tpl_parse_element($que_element); |
260 | 260 | } |
261 | 261 | } |
@@ -271,19 +271,19 @@ discard block |
||
271 | 271 | function flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet) { |
272 | 272 | global $user; |
273 | 273 | |
274 | - if(empty($array_of_Fleet)) { |
|
274 | + if (empty($array_of_Fleet)) { |
|
275 | 275 | return false; |
276 | 276 | } |
277 | 277 | |
278 | 278 | $fleet_list = array(); |
279 | - foreach($array_of_Fleet as $fleet) { |
|
280 | - if($fleet->playerOwnerId == $user['id']) { |
|
281 | - if($fleet->mission_type == MT_MISSILE) { |
|
279 | + foreach ($array_of_Fleet as $fleet) { |
|
280 | + if ($fleet->playerOwnerId == $user['id']) { |
|
281 | + if ($fleet->mission_type == MT_MISSILE) { |
|
282 | 282 | continue; |
283 | 283 | } |
284 | 284 | $fleet_ownage = 'own'; |
285 | 285 | } else { |
286 | - switch($fleet->mission_type) { |
|
286 | + switch ($fleet->mission_type) { |
|
287 | 287 | case MT_ATTACK: |
288 | 288 | case MT_AKS: |
289 | 289 | case MT_DESTROY: |
@@ -300,10 +300,10 @@ discard block |
||
300 | 300 | |
301 | 301 | $fleet_list[$fleet_ownage]['fleets'][$fleet->dbId] = $fleet; |
302 | 302 | |
303 | - if($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
303 | + if ($fleet->isReturning() || (!$fleet->isReturning() && $fleet->mission_type == MT_RELOCATE) || ($fleet->target_owner_id != $user['id'])) { |
|
304 | 304 | $fleet_sn = $fleet->shipsGetArray(); |
305 | - foreach($fleet_sn as $ship_id => $ship_amount) { |
|
306 | - if(in_array($ship_id, sn_get_groups('fleet'))) { |
|
305 | + foreach ($fleet_sn as $ship_id => $ship_amount) { |
|
306 | + if (in_array($ship_id, sn_get_groups('fleet'))) { |
|
307 | 307 | $fleet_list[$fleet_ownage]['total'][$ship_id] += $ship_amount; |
308 | 308 | } |
309 | 309 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | return $fleet_list; |
321 | 321 | } |
322 | 322 | |
323 | -function tpl_set_resource_info(template &$template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
323 | +function tpl_set_resource_info(template & $template, $planet_row, $fleets_to_planet = array(), $round = 0) { |
|
324 | 324 | $template->assign_vars(array( |
325 | 325 | 'RESOURCE_ROUNDING' => $round, |
326 | 326 |
@@ -6,26 +6,26 @@ discard block |
||
6 | 6 | $fleet_events = array(); |
7 | 7 | $fleet_number = 0; |
8 | 8 | |
9 | - if($objFleetList->count() <= 0) { |
|
9 | + if ($objFleetList->count() <= 0) { |
|
10 | 10 | return; |
11 | 11 | } |
12 | 12 | |
13 | - foreach($objFleetList->_container as $objFleet) { |
|
13 | + foreach ($objFleetList->_container as $objFleet) { |
|
14 | 14 | $planet_start_type = $objFleet->fleet_start_type == PT_MOON ? PT_MOON : PT_PLANET; |
15 | 15 | $planet_start = db_planet_by_gspt($objFleet->fleet_start_galaxy, $objFleet->fleet_start_system, $objFleet->fleet_start_planet, $planet_start_type, false, 'name'); |
16 | 16 | $objFleet->fleet_start_name = $planet_start['name']; |
17 | 17 | |
18 | 18 | $planet_end_type = $objFleet->fleet_end_type == PT_MOON ? PT_MOON : PT_PLANET; |
19 | - if($objFleet->fleet_end_planet > $config->game_maxPlanet) { |
|
19 | + if ($objFleet->fleet_end_planet > $config->game_maxPlanet) { |
|
20 | 20 | $objFleet->fleet_end_name = $lang['ov_fleet_exploration']; |
21 | - } elseif($objFleet->mission_type == MT_COLONIZE) { |
|
21 | + } elseif ($objFleet->mission_type == MT_COLONIZE) { |
|
22 | 22 | $objFleet->fleet_end_name = $lang['ov_fleet_colonization']; |
23 | 23 | } else { |
24 | 24 | $planet_end = db_planet_by_gspt($objFleet->fleet_end_galaxy, $objFleet->fleet_end_system, $objFleet->fleet_end_planet, $planet_end_type, false, 'name'); |
25 | 25 | $objFleet->fleet_end_name = $planet_end['name']; |
26 | 26 | } |
27 | 27 | |
28 | - if($objFleet->time_arrive_to_target > SN_TIME_NOW && !$objFleet->isReturning() && $objFleet->mission_type != MT_MISSILE && |
|
28 | + if ($objFleet->time_arrive_to_target > SN_TIME_NOW && !$objFleet->isReturning() && $objFleet->mission_type != MT_MISSILE && |
|
29 | 29 | ($planet_scanned === false |
30 | 30 | || |
31 | 31 | ( |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | $fleet_events[] = flt_register_event_objFleet($objFleet, 0, $planet_end_type); |
40 | 40 | } |
41 | 41 | |
42 | - if($objFleet->time_mission_job_complete > SN_TIME_NOW && !$objFleet->isReturning() && $planet_scanned === false && $objFleet->mission_type != MT_MISSILE) { |
|
42 | + if ($objFleet->time_mission_job_complete > SN_TIME_NOW && !$objFleet->isReturning() && $planet_scanned === false && $objFleet->mission_type != MT_MISSILE) { |
|
43 | 43 | $fleet_events[] = flt_register_event_objFleet($objFleet, 1, $planet_end_type); |
44 | 44 | } |
45 | 45 | |
46 | - if( |
|
46 | + if ( |
|
47 | 47 | $objFleet->time_return_to_source > SN_TIME_NOW && $objFleet->mission_type != MT_MISSILE && ($objFleet->isReturning() || ($objFleet->mission_type != MT_RELOCATE && $objFleet->mission_type != MT_COLONIZE)) && |
48 | 48 | ( |
49 | 49 | ($planet_scanned === false && $objFleet->playerOwnerId == $user['id']) |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $fleet_events[] = flt_register_event_objFleet($objFleet, 2, $planet_end_type); |
60 | 60 | } |
61 | 61 | |
62 | - if($objFleet->mission_type == MT_MISSILE) { |
|
62 | + if ($objFleet->mission_type == MT_MISSILE) { |
|
63 | 63 | $fleet_events[] = flt_register_event_objFleet($objFleet, 3, $planet_end_type); |
64 | 64 | } |
65 | 65 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | $is_this_planet = false; |
81 | 81 | |
82 | - switch($objFleet->ov_label = $ov_label) { |
|
82 | + switch ($objFleet->ov_label = $ov_label) { |
|
83 | 83 | case 0: |
84 | 84 | $objFleet->event_time = $objFleet->time_arrive_to_target; |
85 | 85 | $is_this_planet = ( |
@@ -110,9 +110,9 @@ discard block |
||
110 | 110 | |
111 | 111 | } |
112 | 112 | |
113 | - $objFleet->ov_this_planet = $is_this_planet;// || $planet_scanned != false; |
|
113 | + $objFleet->ov_this_planet = $is_this_planet; // || $planet_scanned != false; |
|
114 | 114 | |
115 | - if($objFleet->playerOwnerId == $user['id']) { |
|
115 | + if ($objFleet->playerOwnerId == $user['id']) { |
|
116 | 116 | $user_data = $user; |
117 | 117 | } else { |
118 | 118 | $user_data = db_user_by_id($objFleet->playerOwnerId); |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | $uni_system = sys_get_param_int('system', $planetrow['system']); |
19 | 19 | $planet = sys_get_param_int('planet', $planetrow['planet']); |
20 | 20 | |
21 | -if($mode == 'name') { |
|
21 | +if ($mode == 'name') { |
|
22 | 22 | require_once('includes/includes/uni_rename.php'); |
23 | 23 | } |
24 | 24 | |
@@ -39,8 +39,8 @@ discard block |
||
39 | 39 | |
40 | 40 | $flying_fleet_count = FleetList::fleet_count_flying($user['id']); |
41 | 41 | |
42 | -if($mode == 1) { |
|
43 | -} elseif($mode == 2 || $mode == 3) { |
|
42 | +if ($mode == 1) { |
|
43 | +} elseif ($mode == 2 || $mode == 3) { |
|
44 | 44 | $planet = $planetrow['planet']; |
45 | 45 | } else { |
46 | 46 | $uni_galaxy = $planetrow['galaxy']; |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | $PhalanxRange = GetPhalanxRange($HavePhalanx); |
67 | 67 | |
68 | 68 | $planet_precache_query = db_planet_list_in_system($uni_galaxy, $uni_system); |
69 | -if(!empty($planet_precache_query)) { |
|
70 | - foreach($planet_precache_query as $planet_row) { |
|
69 | +if (!empty($planet_precache_query)) { |
|
70 | + foreach ($planet_precache_query as $planet_row) { |
|
71 | 71 | $planet_list[$planet_row['planet']][$planet_row['planet_type']] = $planet_row; |
72 | 72 | } |
73 | 73 | } |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * @var Fleet[][][] $fleet_list |
86 | 86 | */ |
87 | 87 | $fleet_list = array(); |
88 | -foreach($system_fleet_list->_container as $objFleetSystem) { |
|
89 | - if(!$objFleetSystem->isReturning()) { |
|
88 | +foreach ($system_fleet_list->_container as $objFleetSystem) { |
|
89 | + if (!$objFleetSystem->isReturning()) { |
|
90 | 90 | $fleet_planet = $objFleetSystem->fleet_end_planet; |
91 | 91 | $fleet_type = $objFleetSystem->fleet_end_type; |
92 | 92 | } else { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $recycler_info = array(); |
102 | 102 | $planet_recyclers_orbiting = 0; |
103 | 103 | $recyclers_fleet = array(); |
104 | -foreach(sn_get_groups('flt_recyclers') as $recycler_id) { |
|
104 | +foreach (sn_get_groups('flt_recyclers') as $recycler_id) { |
|
105 | 105 | $recycler_info[$recycler_id] = get_ship_data($recycler_id, $user); |
106 | 106 | $recyclers_fleet[$recycler_id] = mrc_get_level($user, $planetrow, $recycler_id); |
107 | 107 | $planet_recyclers_orbiting += $recyclers_fleet[$recycler_id]; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $fleet_id = 1; |
112 | 112 | $fleets = array(); |
113 | 113 | $config_game_max_planet = $config->game_maxPlanet + 1; |
114 | -for($Planet = 1; $Planet < $config_game_max_planet; $Planet++) { |
|
114 | +for ($Planet = 1; $Planet < $config_game_max_planet; $Planet++) { |
|
115 | 115 | unset($uni_galaxyRowPlanet); |
116 | 116 | unset($uni_galaxyRowMoon); |
117 | 117 | unset($uni_galaxyRowUser); |
@@ -121,27 +121,27 @@ discard block |
||
121 | 121 | $uni_galaxyRowPlanet = $planet_list[$Planet][PT_PLANET]; |
122 | 122 | |
123 | 123 | $planet_fleet_id = 0; |
124 | - if($uni_galaxyRowPlanet['destruyed']) { |
|
124 | + if ($uni_galaxyRowPlanet['destruyed']) { |
|
125 | 125 | CheckAbandonPlanetState($uni_galaxyRowPlanet); |
126 | - } elseif($uni_galaxyRowPlanet['id']) { |
|
127 | - if($cached['users'][$uni_galaxyRowPlanet['id_owner']]) { |
|
126 | + } elseif ($uni_galaxyRowPlanet['id']) { |
|
127 | + if ($cached['users'][$uni_galaxyRowPlanet['id_owner']]) { |
|
128 | 128 | $uni_galaxyRowUser = $cached['users'][$uni_galaxyRowPlanet['id_owner']]; |
129 | 129 | } else { |
130 | 130 | $uni_galaxyRowUser = db_user_by_id($uni_galaxyRowPlanet['id_owner']); |
131 | 131 | $cached['users'][$uni_galaxyRowUser['id']] = $uni_galaxyRowUser; |
132 | 132 | } |
133 | 133 | |
134 | - if(!$uni_galaxyRowUser['id']) { |
|
134 | + if (!$uni_galaxyRowUser['id']) { |
|
135 | 135 | $debug->warning("Planet '{$uni_galaxyRowPlanet['name']}' [{$uni_galaxy}:{$uni_system}:{$Planet}] has no owner!", 'Userless planet', 503); |
136 | 136 | $uni_galaxyRowPlanet['destruyed'] = SN_TIME_NOW + 60 * 60 * 24; |
137 | 137 | $uni_galaxyRowPlanet['id_owner'] = 0; |
138 | 138 | db_planet_set_by_id($uni_galaxyRowPlanet['id'], "id_owner = 0, destruyed = {$uni_galaxyRowPlanet['destruyed']}"); |
139 | 139 | } |
140 | 140 | |
141 | - if($uni_galaxyRowUser['id']) { |
|
141 | + if ($uni_galaxyRowUser['id']) { |
|
142 | 142 | $planetcount++; |
143 | - if($uni_galaxyRowUser['ally_id']) { |
|
144 | - if($cached['allies'][$uni_galaxyRowUser['ally_id']]) { |
|
143 | + if ($uni_galaxyRowUser['ally_id']) { |
|
144 | + if ($cached['allies'][$uni_galaxyRowUser['ally_id']]) { |
|
145 | 145 | $allyquery = $cached['allies'][$uni_galaxyRowUser['ally_id']]; |
146 | 146 | } else { |
147 | 147 | $allyquery = db_ally_get_by_id($uni_galaxyRowUser['ally_id']); |
@@ -150,19 +150,19 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_PLANET]); |
153 | - if(!empty($fleets_to_planet['own']['count'])) { |
|
153 | + if (!empty($fleets_to_planet['own']['count'])) { |
|
154 | 154 | $planet_fleet_id = $fleet_id; |
155 | 155 | $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id); |
156 | 156 | $fleet_id++; |
157 | 157 | } |
158 | 158 | |
159 | 159 | $uni_galaxyRowMoon = $planet_list[$Planet][PT_MOON]; |
160 | - if($uni_galaxyRowMoon['destruyed']) { |
|
160 | + if ($uni_galaxyRowMoon['destruyed']) { |
|
161 | 161 | CheckAbandonPlanetState($uni_galaxyRowMoon); |
162 | 162 | } else { |
163 | 163 | $moon_fleet_id = 0; |
164 | 164 | $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_MOON]); |
165 | - if(!empty($fleets_to_planet['own']['count'])) { |
|
165 | + if (!empty($fleets_to_planet['own']['count'])) { |
|
166 | 166 | $moon_fleet_id = $fleet_id; |
167 | 167 | $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id); |
168 | 168 | $fleet_id++; |
@@ -173,10 +173,10 @@ discard block |
||
173 | 173 | |
174 | 174 | $recyclers_incoming_capacity = 0; |
175 | 175 | $uni_galaxyRowPlanet['debris'] = $uni_galaxyRowPlanet['debris_metal'] + $uni_galaxyRowPlanet['debris_crystal']; |
176 | - if($uni_galaxyRowPlanet['debris']) { |
|
177 | - if(!empty($fleet_list[$Planet][PT_DEBRIS])) { |
|
178 | - foreach($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) { |
|
179 | - if($objFleetToDebris->playerOwnerId == $user['id']) { |
|
176 | + if ($uni_galaxyRowPlanet['debris']) { |
|
177 | + if (!empty($fleet_list[$Planet][PT_DEBRIS])) { |
|
178 | + foreach ($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) { |
|
179 | + if ($objFleetToDebris->playerOwnerId == $user['id']) { |
|
180 | 180 | $recyclers_incoming_capacity += $objFleetToDebris->shipsGetCapacityRecyclers($recycler_info); |
181 | 181 | } |
182 | 182 | } |
@@ -253,21 +253,21 @@ discard block |
||
253 | 253 | |
254 | 254 | tpl_assign_fleet($template, $fleets); |
255 | 255 | |
256 | -foreach(sn_get_groups('defense_active') as $unit_id) { |
|
256 | +foreach (sn_get_groups('defense_active') as $unit_id) { |
|
257 | 257 | $template->assign_block_vars('defense_active', array( |
258 | 258 | 'ID' => $unit_id, |
259 | 259 | 'NAME' => $lang['tech'][$unit_id], |
260 | 260 | )); |
261 | 261 | } |
262 | 262 | |
263 | -foreach($cached['users'] as $PlanetUser) { |
|
264 | - if(!$PlanetUser) { |
|
263 | +foreach ($cached['users'] as $PlanetUser) { |
|
264 | + if (!$PlanetUser) { |
|
265 | 265 | continue; |
266 | 266 | } |
267 | 267 | |
268 | 268 | $user_ally = $cached['allies'][$PlanetUser['ally_id']]; |
269 | - if(isset($user_ally)) { |
|
270 | - if($PlanetUser['id'] == $user_ally['ally_owner']) { |
|
269 | + if (isset($user_ally)) { |
|
270 | + if ($PlanetUser['id'] == $user_ally['ally_owner']) { |
|
271 | 271 | $user_rank_title = $user_ally['ally_owner_range']; |
272 | 272 | } else { |
273 | 273 | $ally_ranks = explode(';', $user_ally['ranklist']); |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | )); |
291 | 291 | } |
292 | 292 | |
293 | -foreach($cached['allies'] as $PlanetAlly) { |
|
294 | - if($PlanetAlly) { |
|
293 | +foreach ($cached['allies'] as $PlanetAlly) { |
|
294 | + if ($PlanetAlly) { |
|
295 | 295 | $template->assign_block_vars('alliances', array( |
296 | 296 | 'ID' => $PlanetAlly['id'], |
297 | 297 | 'NAME_JS' => js_safe_string($PlanetAlly['ally_name']), |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | public function dbInsert() { |
284 | 284 | // WARNING! MISSION TIMES MUST BE SET WITH set_times() method! |
285 | 285 | // TODO - more checks! |
286 | - if(empty($this->_time_launch)) { |
|
286 | + if (empty($this->_time_launch)) { |
|
287 | 287 | die('Fleet time not set!'); |
288 | 288 | } |
289 | 289 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | // Записываем изменения в БД |
364 | 364 | $this->dbSave(); |
365 | 365 | |
366 | - if($this->_group_id) { |
|
366 | + if ($this->_group_id) { |
|
367 | 367 | // TODO: Make here to delete only one AKS - by adding aks_fleet_count to AKS table |
368 | 368 | db_fleet_aks_purge(); |
369 | 369 | } |
@@ -434,15 +434,15 @@ discard block |
||
434 | 434 | */ |
435 | 435 | // TODO - separate shipList and unitList |
436 | 436 | public function unitsSetFromArray($unit_array) { |
437 | - foreach($unit_array as $unit_id => $unit_count) { |
|
437 | + foreach ($unit_array as $unit_id => $unit_count) { |
|
438 | 438 | $unit_count = floatval($unit_count); |
439 | - if(!$unit_count) { |
|
439 | + if (!$unit_count) { |
|
440 | 440 | continue; |
441 | 441 | } |
442 | 442 | |
443 | - if($this->isShip($unit_id)) { |
|
443 | + if ($this->isShip($unit_id)) { |
|
444 | 444 | $this->unitList->unitSetCount($unit_id, $unit_count); |
445 | - } elseif($this->isResource($unit_id)) { |
|
445 | + } elseif ($this->isResource($unit_id)) { |
|
446 | 446 | $this->resource_list[$unit_id] = $unit_count; |
447 | 447 | } else { |
448 | 448 | throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR); |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | public function parse_missile_db_row($missile_db_row) { |
472 | 472 | // $this->_reset(); |
473 | 473 | |
474 | - if(empty($missile_db_row) || !is_array($missile_db_row)) { |
|
474 | + if (empty($missile_db_row) || !is_array($missile_db_row)) { |
|
475 | 475 | return; |
476 | 476 | } |
477 | 477 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | public function shipsGetCapacityRecyclers(array $recycler_info) { |
608 | 608 | $recyclers_incoming_capacity = 0; |
609 | 609 | $fleet_data = $this->shipsGetArray(); |
610 | - foreach($recycler_info as $recycler_id => $recycler_data) { |
|
610 | + foreach ($recycler_info as $recycler_id => $recycler_data) { |
|
611 | 611 | $recyclers_incoming_capacity += $fleet_data[$recycler_id] * $recycler_data['capacity']; |
612 | 612 | } |
613 | 613 | |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | sn_db_transaction_check(true); |
628 | 628 | |
629 | 629 | // Если флот уже обработан - не существует или возращается - тогда ничего не делаем |
630 | - if($this->isEmpty()) { |
|
630 | + if ($this->isEmpty()) { |
|
631 | 631 | return $result; |
632 | 632 | } |
633 | 633 | |
@@ -649,18 +649,18 @@ discard block |
||
649 | 649 | // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом |
650 | 650 | // Флот, который возвращается на захваченную планету, пропадает |
651 | 651 | // Ship landing is possible only to fleet owner's planet |
652 | - if($this->getPlayerOwnerId() == $planet_arrival['id_owner']) { |
|
652 | + if ($this->getPlayerOwnerId() == $planet_arrival['id_owner']) { |
|
653 | 653 | $db_changeset = array(); |
654 | 654 | |
655 | 655 | $fleet_array = $this->shipsGetArray(); |
656 | - foreach($fleet_array as $ship_id => $ship_count) { |
|
657 | - if($ship_count) { |
|
656 | + foreach ($fleet_array as $ship_id => $ship_count) { |
|
657 | + if ($ship_count) { |
|
658 | 658 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, $ship_count, $user, $planet_arrival['id']); |
659 | 659 | } |
660 | 660 | } |
661 | 661 | |
662 | 662 | // Adjusting ship amount on planet |
663 | - if(!empty($db_changeset)) { |
|
663 | + if (!empty($db_changeset)) { |
|
664 | 664 | db_changeset_apply($db_changeset); |
665 | 665 | } |
666 | 666 | |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | * @param array $resource_list |
709 | 709 | */ |
710 | 710 | public function resourcesSet($resource_list) { |
711 | - if(!empty($this->propertiesAdjusted['resource_list'])) { |
|
711 | + if (!empty($this->propertiesAdjusted['resource_list'])) { |
|
712 | 712 | throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR); |
713 | 713 | } |
714 | 714 | $this->resourcesAdjust($resource_list, true); |
@@ -722,13 +722,13 @@ discard block |
||
722 | 722 | public function resourcesAdjust($resource_delta_list, $replace_value = false) { |
723 | 723 | !is_array($resource_delta_list) ? $resource_delta_list = array() : false; |
724 | 724 | |
725 | - foreach($resource_delta_list as $resource_id => $unit_delta) { |
|
726 | - if(!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) { |
|
725 | + foreach ($resource_delta_list as $resource_id => $unit_delta) { |
|
726 | + if (!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) { |
|
727 | 727 | // Not a resource or no resources - continuing |
728 | 728 | continue; |
729 | 729 | } |
730 | 730 | |
731 | - if($replace_value) { |
|
731 | + if ($replace_value) { |
|
732 | 732 | $this->resource_list[$resource_id] = $unit_delta; |
733 | 733 | } else { |
734 | 734 | $this->resource_list[$resource_id] += $unit_delta; |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | } |
739 | 739 | |
740 | 740 | // Check for negative unit value |
741 | - if($this->resource_list[$resource_id] < 0) { |
|
741 | + if ($this->resource_list[$resource_id] < 0) { |
|
742 | 742 | // TODO |
743 | 743 | throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR); |
744 | 744 | } |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | sn_db_transaction_check(true); |
791 | 791 | |
792 | 792 | // Если флот уже обработан - не существует или возращается - тогда ничего не делаем |
793 | - if(!$this->resourcesGetTotal()) { |
|
793 | + if (!$this->resourcesGetTotal()) { |
|
794 | 794 | return $result; |
795 | 795 | } |
796 | 796 | |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом |
811 | 811 | |
812 | 812 | // Restoring resources to planet |
813 | - if($this->resourcesGetTotal()) { |
|
813 | + if ($this->resourcesGetTotal()) { |
|
814 | 814 | $fleet_resources = $this->resourcesGetList(); |
815 | 815 | db_planet_set_by_id($planet_arrival['id'], |
816 | 816 | "`metal` = `metal` + '{$fleet_resources[RES_METAL]}', `crystal` = `crystal` + '{$fleet_resources[RES_CRYSTAL]}', `deuterium` = `deuterium` + '{$fleet_resources[RES_DEUTERIUM]}'"); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param Unit $value |
89 | 89 | */ |
90 | 90 | public function offsetSet($offset, $value) { |
91 | - if(isset($this->mapUnitIdToDb[$value->unitId])) { |
|
91 | + if (isset($this->mapUnitIdToDb[$value->unitId])) { |
|
92 | 92 | classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId ' . $value->unitId . ' already exists'); |
93 | 93 | } |
94 | 94 | $this->mapUnitIdToDb[$value->unitId] = $value; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | public function offsetUnset($offset) { |
99 | - if(!empty($this[$offset]->unitId)) { |
|
99 | + if (!empty($this[$offset]->unitId)) { |
|
100 | 100 | // $unit_id = $this[$offset]->unitId; |
101 | 101 | // $this->mapUnitIdToDb[$unit_id] = null; |
102 | 102 | // unset($this->mapUnitIdToDb[$unit_id]); |
@@ -118,20 +118,20 @@ discard block |
||
118 | 118 | public function dbLoad($dbId) { |
119 | 119 | // $this->_reset(); |
120 | 120 | |
121 | - if($dbId <= 0) { |
|
121 | + if ($dbId <= 0) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
125 | - if(!is_object($this->locatedAt)) { |
|
125 | + if (!is_object($this->locatedAt)) { |
|
126 | 126 | classSupernova::$debug->error('UnitList::dbLoad have no locatedAt field set'); |
127 | 127 | } |
128 | 128 | |
129 | 129 | $unit_array = classSupernova::db_get_unit_list_by_location(0, $this->getLocationType(), $this->getLocationDbId()); |
130 | - if(!is_array($unit_array)) { |
|
130 | + if (!is_array($unit_array)) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | - foreach($unit_array as $unit_db_row) { |
|
134 | + foreach ($unit_array as $unit_db_row) { |
|
135 | 135 | $unit = $this->_createElement(); |
136 | 136 | $unit->setLocatedAt($this); |
137 | 137 | $unit->dbRowParse($unit_db_row); |
@@ -147,25 +147,25 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | public function dbSave() { |
150 | - if(!is_object($this->locatedAt)) { |
|
150 | + if (!is_object($this->locatedAt)) { |
|
151 | 151 | classSupernova::$debug->error('UnitList::dbSave have no locatedAt field set'); |
152 | 152 | } |
153 | 153 | |
154 | - foreach($this->mapUnitIdToDb as $unit) { |
|
154 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
155 | 155 | $unit_db_id = $unit->dbId; |
156 | 156 | $unit->dbSave(); |
157 | 157 | |
158 | - if($unit->isEmpty()) { |
|
158 | + if ($unit->isEmpty()) { |
|
159 | 159 | // Removing unit object |
160 | 160 | // TODO - change when there will be common bus for all objects |
161 | 161 | // ...or should I? If COUNT is empty - it means that object does not exists in DB. So it should be deleted from PHP memory and cache too |
162 | 162 | unset($this[$unit_db_id]); |
163 | 163 | } else { |
164 | - if($unit->dbId <= 0) { |
|
164 | + if ($unit->dbId <= 0) { |
|
165 | 165 | classSupernova::$debug->error('Error writing unit to DB'); |
166 | 166 | } |
167 | 167 | // If unit is new then putting unit object to container |
168 | - if(empty($this->_container[$unit->dbId])) { |
|
168 | + if (empty($this->_container[$unit->dbId])) { |
|
169 | 169 | $this->_container[$unit->dbId] = $unit; |
170 | 170 | } |
171 | 171 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | public function unitGetCount($unit_id) { |
203 | - if(empty($this->mapUnitIdToDb[$unit_id])) { |
|
203 | + if (empty($this->mapUnitIdToDb[$unit_id])) { |
|
204 | 204 | throw new Exception('Unit [' . $unit_id . '] is not exists in UnitList'); |
205 | 205 | } |
206 | 206 | return $this->mapUnitIdToDb[$unit_id]->count; |
@@ -215,14 +215,14 @@ discard block |
||
215 | 215 | * @param bool $replace_value |
216 | 216 | */ |
217 | 217 | public function unitAdjustCount($unit_id, $unit_count = 0, $replace_value = false) { |
218 | - if(empty($this->mapUnitIdToDb[$unit_id])) { |
|
218 | + if (empty($this->mapUnitIdToDb[$unit_id])) { |
|
219 | 219 | // If unit not exists - creating one and setting all attributes |
220 | 220 | $this->mapUnitIdToDb[$unit_id] = $this->_createElement(); |
221 | 221 | $this->mapUnitIdToDb[$unit_id]->setUnitId($unit_id); |
222 | 222 | $this->mapUnitIdToDb[$unit_id]->setLocatedAt($this); |
223 | 223 | } |
224 | 224 | |
225 | - if($replace_value) { |
|
225 | + if ($replace_value) { |
|
226 | 226 | $this->mapUnitIdToDb[$unit_id]->count = $unit_count; |
227 | 227 | } else { |
228 | 228 | $this->mapUnitIdToDb[$unit_id]->adjustCount($unit_count); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | */ |
237 | 237 | public function unitsGetArray() { |
238 | 238 | $result = array(); |
239 | - foreach($this->mapUnitIdToDb as $unit) { |
|
239 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
240 | 240 | $result[$unit->unitId] = $unit->count; |
241 | 241 | } |
242 | 242 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | } |
245 | 245 | |
246 | 246 | public function unitsCountApplyLossMultiplier($ships_lost_multiplier) { |
247 | - foreach($this->mapUnitIdToDb as $unit_id => $unit) { |
|
247 | + foreach ($this->mapUnitIdToDb as $unit_id => $unit) { |
|
248 | 248 | $unit->count = floor($unit->count * $ships_lost_multiplier); |
249 | 249 | } |
250 | 250 | } |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | |
271 | 271 | public function unitsPropertySumById($unit_id = 0, $propertyName = 'count') { |
272 | 272 | $result = 0; |
273 | - foreach($this->mapUnitIdToDb as $unit) { |
|
274 | - if(!$unit_id || $unit->unitId == $unit_id) { |
|
273 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
274 | + if (!$unit_id || $unit->unitId == $unit_id) { |
|
275 | 275 | $result += $unit->$propertyName; |
276 | 276 | } |
277 | 277 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | print('</tr>'); |
354 | 354 | |
355 | - foreach($this->mapUnitIdToDb as $unit) { |
|
355 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
356 | 356 | print('<tr>'); |
357 | 357 | |
358 | 358 | print('<td>'); |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | |
404 | 404 | |
405 | 405 | public function unitZeroDbId() { |
406 | - foreach($this->mapUnitIdToDb as $unit) { |
|
406 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
407 | 407 | $unit->zeroDbId(); |
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
411 | 411 | |
412 | 412 | public function unitZeroCount() { |
413 | - foreach($this->mapUnitIdToDb as $unit) { |
|
413 | + foreach ($this->mapUnitIdToDb as $unit) { |
|
414 | 414 | $unit->count = 0; |
415 | 415 | } |
416 | 416 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | function db_change_units_perform($query, $tablename, $object_id) { |
13 | 13 | $query = implode(',', $query); |
14 | - if($query && $object_id) { |
|
14 | + if ($query && $object_id) { |
|
15 | 15 | return classSupernova::db_upd_record_by_id($tablename == 'users' ? LOC_USER : LOC_PLANET, $object_id, $query); |
16 | 16 | // return doquery("UPDATE {{{$tablename}}} SET {$query} WHERE `id` = '{$object_id}' LIMIT 1;"); |
17 | 17 | } |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | |
29 | 29 | $group = sn_get_groups('resources_loot'); |
30 | 30 | |
31 | - foreach($unit_list as $unit_id => $unit_amount) { |
|
32 | - if(!in_array($unit_id, $group)) { |
|
31 | + foreach ($unit_list as $unit_id => $unit_amount) { |
|
32 | + if (!in_array($unit_id, $group)) { |
|
33 | 33 | // TODO - remove later |
34 | 34 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_units() вызван для не-ресурсов!</h1>'); |
35 | 35 | pdump(debug_backtrace()); |
36 | 36 | die('db_change_units() вызван для не-ресурсов!'); |
37 | 37 | } |
38 | 38 | |
39 | - if(!$unit_amount) { |
|
39 | + if (!$unit_amount) { |
|
40 | 40 | continue; |
41 | 41 | } |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $unit_location = sys_get_unit_location($user, $planet, $unit_id); |
46 | 46 | |
47 | 47 | // Changing value in object |
48 | - switch($unit_location) { |
|
48 | + switch ($unit_location) { |
|
49 | 49 | case LOC_USER: |
50 | 50 | $user[$unit_db_name] += $unit_amount; |
51 | 51 | break; |
@@ -67,23 +67,23 @@ discard block |
||
67 | 67 | $field_set = ''; |
68 | 68 | $value_set = ''; |
69 | 69 | |
70 | - switch($type) { |
|
70 | + switch ($type) { |
|
71 | 71 | case 'delete': |
72 | 72 | $query = 'DELETE FROM'; |
73 | 73 | break; |
74 | 74 | |
75 | 75 | case 'insert': |
76 | 76 | $query = 'INSERT INTO'; |
77 | - if(isset($options['__multi'])) { |
|
77 | + if (isset($options['__multi'])) { |
|
78 | 78 | // Here we generate mass-insert set |
79 | 79 | break; |
80 | 80 | } |
81 | 81 | case 'update': |
82 | - if(!$query) { |
|
82 | + if (!$query) { |
|
83 | 83 | $query = 'UPDATE'; |
84 | 84 | } |
85 | 85 | |
86 | - foreach($values as $field => &$value) { |
|
86 | + foreach ($values as $field => &$value) { |
|
87 | 87 | $value_type = gettype($value); |
88 | 88 | if ($value_type == 'string') { |
89 | 89 | $value = "'" . db_escape($value) . "'"; |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | $field_set['__IS_SAFE'] = true; |
112 | 112 | } |
113 | 113 | function sn_db_field_set_make_safe($field_set, $serialize = false) { |
114 | - if(!is_array($field_set)) { |
|
114 | + if (!is_array($field_set)) { |
|
115 | 115 | die('$field_set is not an array!'); |
116 | 116 | } |
117 | 117 | |
118 | 118 | $result = array(); |
119 | - foreach($field_set as $field => $value) { |
|
119 | + foreach ($field_set as $field => $value) { |
|
120 | 120 | $field = db_escape(trim($field)); |
121 | 121 | switch (true) { |
122 | 122 | case is_int($value): |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | function log_file($message, $ident_change = 0) { |
51 | 51 | static $ident = 0; |
52 | 52 | |
53 | - if(!defined('SN_DEBUG_LOG')) { |
|
53 | + if (!defined('SN_DEBUG_LOG')) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - if($this->log_file_handler === null) { |
|
57 | + if ($this->log_file_handler === null) { |
|
58 | 58 | $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
59 | 59 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
60 | 60 | } |
61 | 61 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
62 | - if($this->log_file_handler) { |
|
62 | + if ($this->log_file_handler) { |
|
63 | 63 | @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
64 | 64 | } |
65 | 65 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | $result = array(); |
91 | 91 | $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++; |
92 | 92 | $result[] = "tID {$transaction_id}"; |
93 | - foreach($backtrace as $a_trace) { |
|
94 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
93 | + foreach ($backtrace as $a_trace) { |
|
94 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | $function = |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | // $result[] = "{$function} ({$a_trace['line']})'{$file}'"; |
109 | 109 | $result[] = "{$function} - '{$file}' Line {$a_trace['line']}"; |
110 | 110 | |
111 | - if(!$long_comment) { |
|
111 | + if (!$long_comment) { |
|
112 | 112 | break; |
113 | 113 | } |
114 | 114 | } |
@@ -120,26 +120,26 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | function dump($dump = false, $force_base = false, $deadlock = false) { |
123 | - if($dump === false) { |
|
123 | + if ($dump === false) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | 127 | $error_backtrace = array(); |
128 | 128 | $base_dump = false; |
129 | 129 | |
130 | - if($force_base === true) { |
|
130 | + if ($force_base === true) { |
|
131 | 131 | $base_dump = true; |
132 | 132 | } |
133 | 133 | |
134 | - if($dump === true) { |
|
134 | + if ($dump === true) { |
|
135 | 135 | $base_dump = true; |
136 | 136 | } else { |
137 | - if(!is_array($dump)) { |
|
137 | + if (!is_array($dump)) { |
|
138 | 138 | $dump = array('var' => $dump); |
139 | 139 | } |
140 | 140 | |
141 | - foreach($dump as $dump_var_name => $dump_var) { |
|
142 | - if($dump_var_name == 'base_dump') { |
|
141 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
142 | + if ($dump_var_name == 'base_dump') { |
|
143 | 143 | $base_dump = $dump_var; |
144 | 144 | } else { |
145 | 145 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -148,26 +148,25 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | // if($deadlock && ($q = db_fetch(classSupernova::$db->__db_query('SHOW ENGINE INNODB STATUS')))) { |
151 | - if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
151 | + if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
152 | 152 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
153 | 153 | $error_backtrace['locks'] = classSupernova::$locks; |
154 | 154 | $error_backtrace['cSN_data'] = classSupernova::$data; |
155 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
156 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
155 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
156 | + foreach ($location as $location_id => &$location_data) // $location_data = $location_id; |
|
157 | 157 | { |
158 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
159 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
158 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
160 | 159 | } |
161 | 160 | } |
162 | 161 | $error_backtrace['cSN_queries'] = classSupernova::$queries; |
163 | 162 | } |
164 | 163 | |
165 | - if($base_dump) { |
|
166 | - if(is_array($this->log_array) && count($this->log_array) > 0) { |
|
164 | + if ($base_dump) { |
|
165 | + if (is_array($this->log_array) && count($this->log_array) > 0) { |
|
167 | 166 | // ; |
168 | 167 | // } |
169 | 168 | // { |
170 | - foreach($this->log_array as $log) { |
|
169 | + foreach ($this->log_array as $log) { |
|
171 | 170 | $error_backtrace['queries'][] = $log; |
172 | 171 | } |
173 | 172 | } |
@@ -198,14 +197,14 @@ discard block |
||
198 | 197 | function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
199 | 198 | global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user; |
200 | 199 | |
201 | - if(empty(classSupernova::$db->connected)) { |
|
200 | + if (empty(classSupernova::$db->connected)) { |
|
202 | 201 | // TODO - писать ошибку в файл |
203 | 202 | die('SQL server currently unavailable. Please contact Administration...'); |
204 | 203 | } |
205 | 204 | |
206 | 205 | sn_db_transaction_rollback(); |
207 | 206 | |
208 | - if($config->debug == 1) { |
|
207 | + if ($config->debug == 1) { |
|
209 | 208 | echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>"; |
210 | 209 | echo "<table>{$this->log}</table>"; |
211 | 210 | } |
@@ -215,7 +214,7 @@ discard block |
||
215 | 214 | $error_text = db_escape($message); |
216 | 215 | $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false); |
217 | 216 | |
218 | - if(!$sys_log_disabled) { |
|
217 | + if (!$sys_log_disabled) { |
|
219 | 218 | $query = "INSERT INTO `{{logs}}` SET |
220 | 219 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($user['id']) . "', |
221 | 220 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -233,7 +232,7 @@ discard block |
||
233 | 232 | ob_start(); |
234 | 233 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
235 | 234 | |
236 | - foreach($error_backtrace as $name => $value) { |
|
235 | + foreach ($error_backtrace as $name => $value) { |
|
237 | 236 | print(__DEBUG_LINE); |
238 | 237 | pdump($value, $name); |
239 | 238 | } |
@@ -245,14 +244,14 @@ discard block |
||
245 | 244 | function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
246 | 245 | global $user, $lang, $sys_log_disabled; |
247 | 246 | |
248 | - if(empty(classSupernova::$db->connected)) { |
|
247 | + if (empty(classSupernova::$db->connected)) { |
|
249 | 248 | // TODO - писать ошибку в файл |
250 | 249 | die('SQL server currently unavailable. Please contact Administration...'); |
251 | 250 | } |
252 | 251 | |
253 | 252 | $error_backtrace = $this->dump($dump, false); |
254 | 253 | |
255 | - if(!$sys_log_disabled) { |
|
254 | + if (!$sys_log_disabled) { |
|
256 | 255 | $query = "INSERT INTO `{{logs}}` SET |
257 | 256 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($user['id']) . "', |
258 | 257 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -270,11 +269,11 @@ discard block |
||
270 | 269 | // Dump variables nicer then var_dump() |
271 | 270 | |
272 | 271 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
273 | - if(isset($varname)) { |
|
272 | + if (isset($varname)) { |
|
274 | 273 | $varname .= " = "; |
275 | 274 | } |
276 | 275 | |
277 | - if($level == -1) { |
|
276 | + if ($level == -1) { |
|
278 | 277 | $trans[' '] = '∴'; |
279 | 278 | $trans["\t"] = '⇒'; |
280 | 279 | $trans["\n"] = '¶;'; |
@@ -283,7 +282,7 @@ discard block |
||
283 | 282 | |
284 | 283 | return strtr(htmlspecialchars($value), $trans); |
285 | 284 | } |
286 | - if($level == 0) { |
|
285 | + if ($level == 0) { |
|
287 | 286 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
288 | 287 | $dumper = mt_rand(10, 99) . '|' . $varname; |
289 | 288 | } |
@@ -291,22 +290,22 @@ discard block |
||
291 | 290 | $type = gettype($value); |
292 | 291 | $dumper .= $type; |
293 | 292 | |
294 | - if($type == 'string') { |
|
293 | + if ($type == 'string') { |
|
295 | 294 | $dumper .= '(' . strlen($value) . ')'; |
296 | 295 | $value = dump($value, '', -1); |
297 | - } elseif($type == 'boolean') { |
|
296 | + } elseif ($type == 'boolean') { |
|
298 | 297 | $value = ($value ? 'true' : 'false'); |
299 | - } elseif($type == 'object') { |
|
298 | + } elseif ($type == 'object') { |
|
300 | 299 | $props = get_class_vars(get_class($value)); |
301 | 300 | $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
302 | - foreach($props as $key => $val) { |
|
301 | + foreach ($props as $key => $val) { |
|
303 | 302 | $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
304 | 303 | $dumper .= dump($value->$key, '', $level + 1); |
305 | 304 | } |
306 | 305 | $value = ''; |
307 | - } elseif($type == 'array') { |
|
306 | + } elseif ($type == 'array') { |
|
308 | 307 | $dumper .= '(' . count($value) . ')'; |
309 | - foreach($value as $key => $val) { |
|
308 | + foreach ($value as $key => $val) { |
|
310 | 309 | $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
311 | 310 | $dumper .= dump($val, '', $level + 1); |
312 | 311 | } |
@@ -326,7 +325,7 @@ discard block |
||
326 | 325 | // $backtrace = $backtrace[1]; |
327 | 326 | |
328 | 327 | $caller = ''; |
329 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
328 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
330 | 329 | $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
331 | 330 | (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
332 | 331 | $backtrace[1]['function'] . |
@@ -353,7 +352,7 @@ discard block |
||
353 | 352 | } |
354 | 353 | |
355 | 354 | function pr($prePrint = false) { |
356 | - if($prePrint) { |
|
355 | + if ($prePrint) { |
|
357 | 356 | print(__DEBUG_CRLF); |
358 | 357 | } |
359 | 358 | print(mt_rand() . __DEBUG_CRLF); |
@@ -363,7 +362,7 @@ discard block |
||
363 | 362 | global $_PRINT_COUNT_VALUE; |
364 | 363 | $_PRINT_COUNT_VALUE++; |
365 | 364 | |
366 | - if($prePrint) { |
|
365 | + if ($prePrint) { |
|
367 | 366 | print(__DEBUG_CRLF); |
368 | 367 | } |
369 | 368 | print($_PRINT_COUNT_VALUE . __DEBUG_CRLF); |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | 'shield' => 10, |
36 | 36 | 'armor' => 400, |
37 | 37 | 'attack' => 5, |
38 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
38 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
39 | 39 | ), |
40 | 40 | SHIP_CARGO_BIG => array( |
41 | 41 | 'name' => 'big_ship_cargo', |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'shield' => 25, |
56 | 56 | 'armor' => 1200, |
57 | 57 | 'attack' => 5, |
58 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
58 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
59 | 59 | 'engine' => array( |
60 | 60 | array( |
61 | 61 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | 'shield' => 50, |
84 | 84 | 'armor' => 3000, |
85 | 85 | 'attack' => 10, |
86 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
86 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
87 | 87 | 'engine' => array( |
88 | 88 | array( |
89 | 89 | 'tech' => TECH_ENGINE_ION, |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'shield' => 200, |
112 | 112 | 'armor' => 70000, |
113 | 113 | 'attack' => 50, |
114 | - 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ), |
|
114 | + 'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,), |
|
115 | 115 | 'engine' => array( |
116 | 116 | array( |
117 | 117 | 'tech' => TECH_ENGINE_HYPER, |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | 'shield' => 100, |
141 | 141 | 'armor' => 3000, |
142 | 142 | 'attack' => 50, |
143 | - 'amplify' => array(SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21, ), |
|
143 | + 'amplify' => array(SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21,), |
|
144 | 144 | 'engine' => array( |
145 | 145 | array( |
146 | 146 | 'tech' => TECH_ENGINE_ION, |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | 'shield' => 10, |
169 | 169 | 'armor' => 1600, |
170 | 170 | 'attack' => 1, |
171 | - 'amplify' => array(SHIP_SPY => 500.05, SHIP_SATTELITE_SOLAR => 1050, ), |
|
171 | + 'amplify' => array(SHIP_SPY => 500.05, SHIP_SATTELITE_SOLAR => 1050,), |
|
172 | 172 | 'engine' => array( |
173 | 173 | array( |
174 | 174 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | 'shield' => 0.01, |
197 | 197 | 'armor' => 100, |
198 | 198 | 'attack' => 0.01, |
199 | - 'amplify' => array( SHIP_SPY => 1,), |
|
199 | + 'amplify' => array(SHIP_SPY => 1,), |
|
200 | 200 | 'engine' => array( |
201 | 201 | array( |
202 | 202 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | 'factor' => 1, |
221 | 221 | ), |
222 | 222 | P_UNIT_PRODUCTION => array( |
223 | - RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor);}, |
|
223 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor); }, |
|
224 | 224 | ), |
225 | 225 | P_MINING_IS_MANAGED => true, |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | 'shield' => 10, |
230 | 230 | 'armor' => 200, |
231 | 231 | 'attack' => 1, |
232 | - 'amplify' => array(SHIP_SPY => 1, ), |
|
232 | + 'amplify' => array(SHIP_SPY => 1,), |
|
233 | 233 | 'engine' => array( |
234 | 234 | array( |
235 | 235 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | 'shield' => 10, |
262 | 262 | 'armor' => 400, |
263 | 263 | 'attack' => 50, |
264 | - 'amplify' => array(SHIP_CARGO_SMALL => 16.4, SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21, ), |
|
264 | + 'amplify' => array(SHIP_CARGO_SMALL => 16.4, SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21,), |
|
265 | 265 | 'engine' => array( |
266 | 266 | array( |
267 | 267 | 'tech' => TECH_ENGINE_CHEMICAL, |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | 'shield' => 25, |
291 | 291 | 'armor' => 1000, |
292 | 292 | 'attack' => 150, |
293 | - 'amplify' => array(SHIP_CARGO_SMALL => 8.2, SHIP_SPY => 3.33367, SHIP_SATTELITE_SOLAR => 7, ), |
|
293 | + 'amplify' => array(SHIP_CARGO_SMALL => 8.2, SHIP_SPY => 3.33367, SHIP_SATTELITE_SOLAR => 7,), |
|
294 | 294 | 'engine' => array( |
295 | 295 | array( |
296 | 296 | 'tech' => TECH_ENGINE_ION, |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | 'shield' => 50, |
350 | 350 | 'armor' => 2700, |
351 | 351 | 'attack' => 400, |
352 | - 'amplify' => array(SHIP_SMALL_FIGHTER_LIGHT => 6.15, SHIP_SPY => 1.25013, SHIP_SATTELITE_SOLAR => 2.625, UNIT_DEF_TURRET_MISSILE => 5.5, ), |
|
352 | + 'amplify' => array(SHIP_SMALL_FIGHTER_LIGHT => 6.15, SHIP_SPY => 1.25013, SHIP_SATTELITE_SOLAR => 2.625, UNIT_DEF_TURRET_MISSILE => 5.5,), |
|
353 | 353 | 'engine' => array( |
354 | 354 | array( |
355 | 355 | 'tech' => TECH_ENGINE_ION, |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | 'shield' => 200, |
409 | 409 | 'armor' => 6000, |
410 | 410 | 'attack' => 1000, |
411 | - 'amplify' => array(SHIP_SPY => 0.50005, SHIP_SATTELITE_SOLAR => 1.05, UNIT_DEF_TURRET_MISSILE => 1.76, ), |
|
411 | + 'amplify' => array(SHIP_SPY => 0.50005, SHIP_SATTELITE_SOLAR => 1.05, UNIT_DEF_TURRET_MISSILE => 1.76,), |
|
412 | 412 | 'engine' => array( |
413 | 413 | array( |
414 | 414 | 'tech' => TECH_ENGINE_HYPER, |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | 'shield' => 500, |
505 | 505 | 'armor' => 11000, |
506 | 506 | 'attack' => 2000, |
507 | - 'amplify' => array(SHIP_SPY => 0.25003, SHIP_SATTELITE_SOLAR => 0.525, SHIP_LARGE_BATTLESHIP => 7.4, UNIT_DEF_TURRET_LASER_SMALL => 1.125, ), |
|
507 | + 'amplify' => array(SHIP_SPY => 0.25003, SHIP_SATTELITE_SOLAR => 0.525, SHIP_LARGE_BATTLESHIP => 7.4, UNIT_DEF_TURRET_LASER_SMALL => 1.125,), |
|
508 | 508 | 'engine' => array( |
509 | 509 | array( |
510 | 510 | 'tech' => TECH_ENGINE_HYPER, |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | 'shield' => 20, |
609 | 609 | 'armor' => 200, |
610 | 610 | 'attack' => 80, |
611 | - 'amplify' => array(SHIP_SPY => 7, ), |
|
611 | + 'amplify' => array(SHIP_SPY => 7,), |
|
612 | 612 | ), |
613 | 613 | UNIT_DEF_TURRET_LASER_SMALL => array( |
614 | 614 | 'name' => 'small_laser', |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | 'shield' => 25, |
627 | 627 | 'armor' => 200, |
628 | 628 | 'attack' => 100, |
629 | - 'amplify' => array(SHIP_SPY => 5, ), |
|
629 | + 'amplify' => array(SHIP_SPY => 5,), |
|
630 | 630 | ), |
631 | 631 | UNIT_DEF_TURRET_LASER_BIG => array( |
632 | 632 | 'name' => 'big_laser', |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | 'shield' => 100, |
645 | 645 | 'armor' => 800, |
646 | 646 | 'attack' => 250, |
647 | - 'amplify' => array(SHIP_SPY => 2, ), |
|
647 | + 'amplify' => array(SHIP_SPY => 2,), |
|
648 | 648 | ), |
649 | 649 | UNIT_DEF_TURRET_GAUSS => array( |
650 | 650 | 'name' => 'gauss_canyon', |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | 'armor' => 3500, |
663 | 663 | 'shield' => 200, |
664 | 664 | 'attack' => 1100, |
665 | - 'amplify' => array(SHIP_SPY => 0.5, ), |
|
665 | + 'amplify' => array(SHIP_SPY => 0.5,), |
|
666 | 666 | ), |
667 | 667 | UNIT_DEF_TURRET_ION => array( |
668 | 668 | 'name' => 'ionic_canyon', |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | 'shield' => 500, |
681 | 681 | 'armor' => 800, |
682 | 682 | 'attack' => 150, |
683 | - 'amplify' => array(SHIP_SPY => 3.3, ), |
|
683 | + 'amplify' => array(SHIP_SPY => 3.3,), |
|
684 | 684 | ), |
685 | 685 | UNIT_DEF_TURRET_PLASMA => array( |
686 | 686 | 'name' => 'buster_canyon', |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | 'shield' => 300, |
699 | 699 | 'armor' => 10000, |
700 | 700 | 'attack' => 3000, |
701 | - 'amplify' => array(SHIP_SPY => 0.17, ), |
|
701 | + 'amplify' => array(SHIP_SPY => 0.17,), |
|
702 | 702 | ), |
703 | 703 | |
704 | 704 | UNIT_DEF_SHIELD_SMALL => array( |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | 'shield' => 2000, |
719 | 719 | 'armor' => 2000, |
720 | 720 | 'attack' => 1, |
721 | - 'amplify' => array(SHIP_SPY => 500, ), |
|
721 | + 'amplify' => array(SHIP_SPY => 500,), |
|
722 | 722 | ), |
723 | 723 | UNIT_DEF_SHIELD_BIG => array( |
724 | 724 | 'name' => 'big_protection_shield', |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | 'shield' => 2000, |
738 | 738 | 'armor' => 10000, |
739 | 739 | 'attack' => 1, |
740 | - 'amplify' => array(SHIP_SPY => 500, ), |
|
740 | + 'amplify' => array(SHIP_SPY => 500,), |
|
741 | 741 | ), |
742 | 742 | UNIT_DEF_SHIELD_PLANET => array( |
743 | 743 | 'name' => 'planet_protector', |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | // @version 1.0 |
4 | 4 | // @copyright 2008 by Chlorel for XNova |
5 | 5 | |
6 | -if(SN_IN_FLEET !== true) { |
|
6 | +if (SN_IN_FLEET !== true) { |
|
7 | 7 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
8 | 8 | } |
9 | 9 | |
@@ -19,25 +19,25 @@ discard block |
||
19 | 19 | |
20 | 20 | // Test de coherance de la destination (voir si elle se trouve dans les limites de l'univers connu |
21 | 21 | $errorlist = ''; |
22 | - if(!$galaxy || $galaxy > $config->game_maxGalaxy || $galaxy < 1) { |
|
22 | + if (!$galaxy || $galaxy > $config->game_maxGalaxy || $galaxy < 1) { |
|
23 | 23 | $errorlist .= $lang['fl_limit_galaxy']; |
24 | 24 | } |
25 | - if(!$system || $system > $config->game_maxSystem || $system < 1) { |
|
25 | + if (!$system || $system > $config->game_maxSystem || $system < 1) { |
|
26 | 26 | $errorlist .= $lang['fl_limit_system']; |
27 | 27 | } |
28 | - if(!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE)) { |
|
28 | + if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE)) { |
|
29 | 29 | $errorlist .= $lang['fl_limit_planet']; |
30 | 30 | } |
31 | - if($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) { |
|
31 | + if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) { |
|
32 | 32 | $errorlist .= $lang['fl_ownpl_err']; |
33 | 33 | } |
34 | - if(!$planet_type) { |
|
34 | + if (!$planet_type) { |
|
35 | 35 | $errorlist .= $lang['fl_no_planettype']; |
36 | 36 | } |
37 | - if($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) { |
|
37 | + if ($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) { |
|
38 | 38 | $errorlist .= $lang['fl_fleet_err_pl']; |
39 | 39 | } |
40 | - if(empty($missiontype[$target_mission])) { |
|
40 | + if (empty($missiontype[$target_mission])) { |
|
41 | 41 | $errorlist .= $lang['fl_bad_mission']; |
42 | 42 | } |
43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $TransDeuterium = max(0, sys_get_param_float('resource2')); |
47 | 47 | $StorageNeeded = $TransMetal + $TransCrystal + $TransDeuterium; |
48 | 48 | |
49 | - if(!$StorageNeeded && $target_mission == MT_TRANSPORT) { |
|
49 | + if (!$StorageNeeded && $target_mission == MT_TRANSPORT) { |
|
50 | 50 | $errorlist .= $lang['fl_noenoughtgoods']; |
51 | 51 | } |
52 | 52 | |
@@ -55,41 +55,41 @@ discard block |
||
55 | 55 | $user = db_user_by_id($user['id'], true); |
56 | 56 | $planetrow = db_planet_by_id($planetrow['id'], true); |
57 | 57 | |
58 | - if($target_mission == MT_EXPLORE) { |
|
59 | - if($MaxExpeditions == 0) { |
|
58 | + if ($target_mission == MT_EXPLORE) { |
|
59 | + if ($MaxExpeditions == 0) { |
|
60 | 60 | $errorlist .= $lang['fl_expe_notech']; |
61 | - } elseif($FlyingExpeditions >= $MaxExpeditions) { |
|
61 | + } elseif ($FlyingExpeditions >= $MaxExpeditions) { |
|
62 | 62 | $errorlist .= $lang['fl_expe_max']; |
63 | 63 | } |
64 | 64 | } else { |
65 | - if($TargetPlanet['id_owner']) { |
|
66 | - if($target_mission == MT_COLONIZE) { |
|
65 | + if ($TargetPlanet['id_owner']) { |
|
66 | + if ($target_mission == MT_COLONIZE) { |
|
67 | 67 | $errorlist .= $lang['fl_colonized']; |
68 | 68 | } |
69 | 69 | |
70 | - if($TargetPlanet['id_owner'] == $planetrow['id_owner']) { |
|
71 | - if($target_mission == MT_ATTACK) { |
|
70 | + if ($TargetPlanet['id_owner'] == $planetrow['id_owner']) { |
|
71 | + if ($target_mission == MT_ATTACK) { |
|
72 | 72 | $errorlist .= $lang['fl_no_self_attack']; |
73 | 73 | } |
74 | 74 | |
75 | - if($target_mission == MT_SPY) { |
|
75 | + if ($target_mission == MT_SPY) { |
|
76 | 76 | $errorlist .= $lang['fl_no_self_spy']; |
77 | 77 | } |
78 | 78 | } else { |
79 | - if($target_mission == MT_RELOCATE) { |
|
79 | + if ($target_mission == MT_RELOCATE) { |
|
80 | 80 | $errorlist .= $lang['fl_only_stay_at_home']; |
81 | 81 | } |
82 | 82 | } |
83 | 83 | } else { |
84 | - if($target_mission < MT_COLONIZE) { |
|
84 | + if ($target_mission < MT_COLONIZE) { |
|
85 | 85 | $errorlist .= $lang['fl_unknow_target']; |
86 | 86 | } else { |
87 | - if($target_mission == MT_DESTROY) { |
|
87 | + if ($target_mission == MT_DESTROY) { |
|
88 | 88 | $errorlist .= $lang['fl_nomoon']; |
89 | 89 | } |
90 | 90 | |
91 | - if($target_mission == MT_RECYCLE) { |
|
92 | - if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) { |
|
91 | + if ($target_mission == MT_RECYCLE) { |
|
92 | + if ($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) { |
|
93 | 93 | $errorlist .= $lang['fl_nodebris']; |
94 | 94 | } |
95 | 95 | } |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | |
101 | - if(sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) { |
|
101 | + if (sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) { |
|
102 | 102 | $captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id']); |
103 | 103 | // mrc_get_level($user, $planetrow, UNIT_CAPTAIN, true); |
104 | - if(!$captain) { |
|
104 | + if (!$captain) { |
|
105 | 105 | $errorlist .= $lang['module_unit_captain_error_no_captain']; |
106 | - } elseif($captain['unit_location_type'] == LOC_PLANET) { |
|
107 | - if($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { |
|
106 | + } elseif ($captain['unit_location_type'] == LOC_PLANET) { |
|
107 | + if ($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) { |
|
108 | 108 | $errorlist .= $lang['module_unit_captain_error_captain_already_bound']; |
109 | 109 | } |
110 | 110 | } else { |
@@ -112,14 +112,14 @@ discard block |
||
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - if($errorlist) { |
|
115 | + if ($errorlist) { |
|
116 | 116 | sn_db_transaction_rollback(); |
117 | 117 | message("<span class='error'><ul>{$errorlist}</ul></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, false); |
118 | 118 | } |
119 | 119 | |
120 | 120 | // On verifie s'il y a assez de vaisseaux sur la planete ! |
121 | - foreach($fleetarray as $Ship => $Count) { |
|
122 | - if($Count > mrc_get_level($user, $planetrow, $Ship)) { |
|
121 | + foreach ($fleetarray as $Ship => $Count) { |
|
122 | + if ($Count > mrc_get_level($user, $planetrow, $Ship)) { |
|
123 | 123 | message("<span class='error'><b>{$lang['fl_fleet_err']}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
124 | 124 | } |
125 | 125 | } |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | //But is it acs?? |
131 | 131 | //Well all acs fleets must have a fleet code. |
132 | 132 | //The co-ords must be the same as where the acs fleet is going. |
133 | - if($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") { |
|
133 | + if ($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") { |
|
134 | 134 | //ACS attack must exist (if acs fleet has arrived this will also return false (2 checks in 1!!!) |
135 | 135 | $aks = db_acs_get_by_group_id($fleet_group); |
136 | - if(!$aks) { |
|
136 | + if (!$aks) { |
|
137 | 137 | $fleet_group = 0; |
138 | 138 | } else { |
139 | 139 | //Also it must be mission type 2 |
@@ -144,31 +144,31 @@ discard block |
||
144 | 144 | $planet = $aks['planet']; |
145 | 145 | $planet_type = $aks['planet_type']; |
146 | 146 | } |
147 | - } elseif($target_mission == MT_AKS) { |
|
147 | + } elseif ($target_mission == MT_AKS) { |
|
148 | 148 | //Check that a failed acs attack isn't being sent, if it is, make it an attack fleet. |
149 | 149 | $target_mission = MT_ATTACK; |
150 | 150 | } |
151 | 151 | |
152 | - if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
152 | + if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) { |
|
153 | 153 | $TargetPlanet = array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'id_owner' => 0); |
154 | 154 | } |
155 | 155 | $options = array('fleet_speed_percent' => $speed_percent, 'fleet_group' => $fleet_group, 'resources' => $StorageNeeded); |
156 | 156 | $cant_attack = flt_can_attack($planetrow, $TargetPlanet, $fleetarray, $target_mission, $options); |
157 | 157 | |
158 | - if($cant_attack !== ATTACK_ALLOWED) { |
|
158 | + if ($cant_attack !== ATTACK_ALLOWED) { |
|
159 | 159 | message("<span class='error'><b>{$lang['fl_attack_error'][$cant_attack]}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 99); |
160 | 160 | } |
161 | 161 | |
162 | 162 | $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1); |
163 | - if(!in_array($speed_percent, $speed_possible)) { |
|
163 | + if (!in_array($speed_percent, $speed_possible)) { |
|
164 | 164 | message("<span class='error'><b>" . $lang['fl_cheat_speed'] . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
165 | 165 | } |
166 | 166 | |
167 | 167 | $mission_time_in_seconds = 0; |
168 | 168 | $arrival_time = SN_TIME_NOW + $time_to_travel; |
169 | - if($target_mission == MT_AKS && $aks) { |
|
169 | + if ($target_mission == MT_AKS && $aks) { |
|
170 | 170 | // if($fleet_start_time > $aks['ankunft']) { |
171 | - if($arrival_time > $aks['ankunft']) { |
|
171 | + if ($arrival_time > $aks['ankunft']) { |
|
172 | 172 | message($lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME, $arrival_time) . " AKS arrival: " . date(FMT_DATE_TIME, $aks['ankunft']), $lang['fl_error']); |
173 | 173 | } |
174 | 174 | $group_sync_delta_time = $aks['ankunft'] - $arrival_time; |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | // Set return time to ACS return time + fleet's time to travel |
178 | 178 | $return_time = $aks['ankunft'] + $time_to_travel; |
179 | 179 | } else { |
180 | - if($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) { |
|
180 | + if ($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) { |
|
181 | 181 | $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : ($target_mission == MT_HOLD ? 12 : 0); |
182 | - if($max_duration) { |
|
182 | + if ($max_duration) { |
|
183 | 183 | $mission_time_in_hours = sys_get_param_id('missiontime'); |
184 | - if($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) { |
|
184 | + if ($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) { |
|
185 | 185 | $debug->warning('Supplying wrong mission time', 'Hack attempt', 302, array('base_dump' => true)); |
186 | 186 | die(); |
187 | 187 | } |
@@ -195,19 +195,19 @@ discard block |
||
195 | 195 | $FleetStorage = 0; |
196 | 196 | |
197 | 197 | $db_changeset = array(); |
198 | - foreach($fleetarray as $Ship => $Count) { |
|
198 | + foreach ($fleetarray as $Ship => $Count) { |
|
199 | 199 | $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count; |
200 | 200 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($Ship, -$Count, $user, $planetrow['id']); |
201 | 201 | } |
202 | 202 | $FleetStorage -= $consumption; |
203 | 203 | |
204 | - if($StorageNeeded > $FleetStorage) { |
|
204 | + if ($StorageNeeded > $FleetStorage) { |
|
205 | 205 | message("<span class='error'><b>" . $lang['fl_nostoragespa'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
206 | 206 | } |
207 | - if($planetrow['deuterium'] < $TransDeuterium + $consumption) { |
|
207 | + if ($planetrow['deuterium'] < $TransDeuterium + $consumption) { |
|
208 | 208 | message("<font color=\"red\"><b>" . $lang['fl_no_deuterium'] . pretty_number($TransDeuterium + $consumption - $planetrow['deuterium']) . "</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
209 | 209 | } |
210 | - if(($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) { |
|
210 | + if (($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) { |
|
211 | 211 | message("<font color=\"red\"><b>" . $lang['fl_no_resources'] . "</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2); |
212 | 212 | } |
213 | 213 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | $template = gettemplate('fleet3', true); |
239 | 239 | |
240 | - if(is_array($captain)) { |
|
240 | + if (is_array($captain)) { |
|
241 | 241 | db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$objFleet->dbId}"); |
242 | 242 | } |
243 | 243 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | 'START_LEFT' => floor($return_time + 1 - SN_TIME_NOW), |
251 | 251 | ); |
252 | 252 | |
253 | - if(!empty($TargetPlanet)) { |
|
253 | + if (!empty($TargetPlanet)) { |
|
254 | 254 | $template_route += array( |
255 | 255 | 'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']], |
256 | 256 | 'END_COORDS' => uni_render_coordinates($TargetPlanet), |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | $template->assign_block_vars('fleets', $template_route); |
264 | 264 | |
265 | 265 | $sn_groups_fleet = sn_get_groups('fleet'); |
266 | - foreach($fleetarray as $ship_id => $ship_count) { |
|
267 | - if(in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
266 | + foreach ($fleetarray as $ship_id => $ship_count) { |
|
267 | + if (in_array($ship_id, $sn_groups_fleet) && $ship_count) { |
|
268 | 268 | // $ship_base_data = get_ship_data($ship_id, $user); |
269 | 269 | $template->assign_block_vars('fleets.ships', array( |
270 | 270 | 'ID' => $ship_id, |