@@ -19,15 +19,11 @@ discard block |
||
19 | 19 | // ------------------------------------------------------------------ |
20 | 20 | function flt_flyingFleetsSort($a, $b) { |
21 | 21 | // Сравниваем время флотов - кто раньше, тот и первый обрабатывается |
22 | - return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : |
|
23 | - // Если время - одинаковое, сравниваем события флотов |
|
22 | + return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов |
|
24 | 23 | // Если события - одинаковые, то флоты равны |
25 | - ($a['fleet_event'] == $b['fleet_event'] ? 0 : |
|
26 | - // Если события разные - первыми считаем прибывающие флоты |
|
27 | - ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : |
|
28 | - // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
29 | - ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : |
|
30 | - // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
24 | + ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты |
|
25 | + ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию |
|
26 | + ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой |
|
31 | 27 | // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска |
32 | 28 | ( |
33 | 29 | 0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий |
@@ -41,7 +37,7 @@ discard block |
||
41 | 37 | function log_file($msg) { |
42 | 38 | static $handler; |
43 | 39 | |
44 | - if(!$handler) { |
|
40 | + if (!$handler) { |
|
45 | 41 | $handler = fopen('event.log', 'a+'); |
46 | 42 | } |
47 | 43 | |
@@ -81,12 +77,12 @@ discard block |
||
81 | 77 | */ |
82 | 78 | global $debug; |
83 | 79 | |
84 | - if(classSupernova::$config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) { |
|
80 | + if (classSupernova::$config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) { |
|
85 | 81 | return; |
86 | 82 | } |
87 | 83 | |
88 | 84 | sn_db_transaction_start(); |
89 | - if(classSupernova::$config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('fleet_update_last')) <= classSupernova::$config->fleet_update_interval) { |
|
85 | + if (classSupernova::$config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('fleet_update_last')) <= classSupernova::$config->fleet_update_interval) { |
|
90 | 86 | sn_db_transaction_rollback(); |
91 | 87 | |
92 | 88 | return; |
@@ -94,14 +90,14 @@ discard block |
||
94 | 90 | |
95 | 91 | |
96 | 92 | // Watchdog timer |
97 | - if(classSupernova::$config->db_loadItem('fleet_update_lock')) { |
|
98 | - if(defined('DEBUG_FLYING_FLEETS')) { |
|
93 | + if (classSupernova::$config->db_loadItem('fleet_update_lock')) { |
|
94 | + if (defined('DEBUG_FLYING_FLEETS')) { |
|
99 | 95 | $random = 0; |
100 | 96 | } else { |
101 | 97 | $random = mt_rand(240, 300); |
102 | 98 | } |
103 | 99 | |
104 | - if(SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_lock) <= $random) { |
|
100 | + if (SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_lock) <= $random) { |
|
105 | 101 | sn_db_transaction_rollback(); |
106 | 102 | |
107 | 103 | return; |
@@ -125,11 +121,11 @@ discard block |
||
125 | 121 | $missions_used = array(); |
126 | 122 | |
127 | 123 | $objFleetList = FleetList::dbGetFleetListCurrentTick(); |
128 | - foreach($objFleetList->_container as $objFleet) { |
|
124 | + foreach ($objFleetList->_container as $objFleet) { |
|
129 | 125 | set_time_limit(15); |
130 | 126 | // TODO - Унифицировать код с темплейтным разбором эвентов на планете! |
131 | 127 | $missions_used[$objFleet->mission_type] = 1; |
132 | - if($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
128 | + if ($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
133 | 129 | $fleet_event_list[] = array( |
134 | 130 | 'object' => $objFleet, |
135 | 131 | 'fleet_time' => $objFleet->time_arrive_to_target, |
@@ -137,7 +133,7 @@ discard block |
||
137 | 133 | ); |
138 | 134 | } |
139 | 135 | |
140 | - if($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
136 | + if ($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) { |
|
141 | 137 | $fleet_event_list[] = array( |
142 | 138 | 'object' => $objFleet, |
143 | 139 | 'fleet_time' => $objFleet->time_mission_job_complete, |
@@ -145,7 +141,7 @@ discard block |
||
145 | 141 | ); |
146 | 142 | } |
147 | 143 | |
148 | - if($objFleet->time_return_to_source <= SN_TIME_NOW) { |
|
144 | + if ($objFleet->time_return_to_source <= SN_TIME_NOW) { |
|
149 | 145 | $fleet_event_list[] = array( |
150 | 146 | 'object' => $objFleet, |
151 | 147 | 'fleet_time' => $objFleet->time_return_to_source, |
@@ -171,17 +167,17 @@ discard block |
||
171 | 167 | // MT_MISSILE => 'flt_mission_missile.php', |
172 | 168 | MT_EXPLORE => 'flt_mission_explore', |
173 | 169 | ); |
174 | - foreach($missions_used as $mission_id => $cork) { |
|
170 | + foreach ($missions_used as $mission_id => $cork) { |
|
175 | 171 | require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX); |
176 | 172 | } |
177 | 173 | |
178 | 174 | //log_file('Обработка миссий'); |
179 | 175 | $sn_groups_mission = sn_get_groups('missions'); |
180 | - foreach($fleet_event_list as $fleet_event) { |
|
176 | + foreach ($fleet_event_list as $fleet_event) { |
|
181 | 177 | // TODO: Указатель тут потом сделать |
182 | 178 | // TODO: СЕЙЧАС НАДО ПРОВЕРЯТЬ ПО БАЗЕ - А ЖИВОЙ ЛИ ФЛОТ?! |
183 | 179 | $fleet_row = $fleet_event['fleet_row']; |
184 | - if(empty($fleet_event['object'])) { |
|
180 | + if (empty($fleet_event['object'])) { |
|
185 | 181 | // Fleet was destroyed in course of previous actions |
186 | 182 | continue; |
187 | 183 | } |
@@ -205,20 +201,20 @@ discard block |
||
205 | 201 | |
206 | 202 | $objFleet->dbLoad($objFleet->dbId); |
207 | 203 | |
208 | - if(!$objFleet->dbId) { |
|
204 | + if (!$objFleet->dbId) { |
|
209 | 205 | // Fleet was destroyed in course of previous actions |
210 | 206 | sn_db_transaction_commit(); |
211 | 207 | continue; |
212 | 208 | } |
213 | 209 | |
214 | - if($fleet_event['fleet_event'] == EVENT_FLT_RETURN) { |
|
210 | + if ($fleet_event['fleet_event'] == EVENT_FLT_RETURN) { |
|
215 | 211 | // Fleet returns to planet |
216 | 212 | $objFleet->shipsLand(true); |
217 | 213 | sn_db_transaction_commit(); |
218 | 214 | continue; |
219 | 215 | } |
220 | 216 | |
221 | - if($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) { |
|
217 | + if ($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) { |
|
222 | 218 | // При событии EVENT_FLT_ARRIVE флот всегда должен иметь fleet_mess == 0 |
223 | 219 | // В противном случае это означает, что флот уже был обработан ранее - например, при САБе |
224 | 220 | sn_db_transaction_commit(); |
@@ -238,13 +234,13 @@ discard block |
||
238 | 234 | $objMission->dst_planet = $mission_data['dst_planet'] ? db_planet_by_vector($objFleet->target_coordinates_typed(), '', true, '`id`, `id_owner`, `name`') : null; |
239 | 235 | $objMission->fleet_event = $fleet_event['fleet_event']; |
240 | 236 | |
241 | - if($objMission->dst_planet && $objMission->dst_planet['id_owner']) { |
|
237 | + if ($objMission->dst_planet && $objMission->dst_planet['id_owner']) { |
|
242 | 238 | $update_result = sys_o_get_updated($objMission->dst_planet['id_owner'], $objMission->dst_planet['id'], $objFleet->time_arrive_to_target); |
243 | 239 | $objMission->dst_user = !empty($objMission->dst_user) ? $update_result['user'] : null; |
244 | 240 | $objMission->dst_planet = $update_result['planet']; |
245 | 241 | } |
246 | 242 | |
247 | - switch($objFleet->mission_type) { |
|
243 | + switch ($objFleet->mission_type) { |
|
248 | 244 | // Для боевых атак нужно обновлять по САБу и по холду - таки надо возвращать данные из обработчика миссий! |
249 | 245 | case MT_AKS: |
250 | 246 | case MT_ATTACK: |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | // banner.php?id=<userid>&type=<banner|userbar>&format=<png> |
16 | 16 | $id = intval($id); |
17 | 17 | |
18 | - switch($type) { |
|
18 | + switch ($type) { |
|
19 | 19 | case 'banner': |
20 | 20 | $img_name = classSupernova::$config->int_banner_background; |
21 | 21 | break; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'info' => SN_ROOT_PHYSICAL . "design/fonts/" . classSupernova::$config->int_banner_fontInfo, |
49 | 49 | ); |
50 | 50 | |
51 | - if($id) { |
|
51 | + if ($id) { |
|
52 | 52 | // Querys |
53 | 53 | $user = db_user_by_id($id); |
54 | 54 | $planet_row = db_planet_by_id($user['id_planet']); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | } |
65 | 65 | |
66 | 66 | $b_univ = classSupernova::$config->game_name; |
67 | - switch($type) { |
|
67 | + switch ($type) { |
|
68 | 68 | case 'banner': |
69 | 69 | // Banner size 416 x 58 |
70 | 70 | $fsize = 15; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | imagettftext($image, 11, 0, 8, 26, $txt_shadow, $fonts['info'], $b_user); |
78 | 78 | imagettftext($image, 11, 0, 6, 23, $txt_color, $fonts['info'], $b_user); |
79 | 79 | |
80 | - if($id) { |
|
80 | + if ($id) { |
|
81 | 81 | // Player level - right-alligned |
82 | 82 | $is = imagettfbbox(11, 0, $fonts['info'], $b_lvl); |
83 | 83 | imagettftext($image, 11, 0, $size[0] - 4 - $is[2], 25, $txt_shadow, $fonts['info'], $b_lvl); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | imagettftext($image, 9, 0, 4, $size[1] - 4, $txt_shadow, $fonts['userbar'], $b_user); |
136 | 136 | imagettftext($image, 9, 0, 2, $size[1] - 6, $txt_color, $fonts['userbar'], $b_user); |
137 | 137 | |
138 | - if($id) { |
|
138 | + if ($id) { |
|
139 | 139 | // Player level - right-alligned |
140 | 140 | $isp = imagettfbbox(9, 0, $fonts['userbar'], $b_lvl); |
141 | 141 | imagettftext($image, 9, 0, $is - $isp[2] - 10, $size[1] - 4, $txt_shadow, $fonts['userbar'], $b_lvl); |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | function que_get_unit_que($unit_id) { |
4 | 4 | $que_type = false; |
5 | - foreach(sn_get_groups('ques') as $que_id => $que_data) { |
|
6 | - if(in_array($unit_id, $que_data['unit_list'])) { |
|
5 | + foreach (sn_get_groups('ques') as $que_id => $que_data) { |
|
6 | + if (in_array($unit_id, $que_data['unit_list'])) { |
|
7 | 7 | $que_type = $que_id; |
8 | 8 | break; |
9 | 9 | } |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | |
15 | 15 | |
16 | 16 | function que_get_max_que_length($user, $planet, $que_id, $que_data = null) { |
17 | - if(empty($que_data)) { |
|
17 | + if (empty($que_data)) { |
|
18 | 18 | $que_data = sn_get_groups('ques'); |
19 | 19 | $que_data = $que_data[$que_id]; |
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | 23 | $que_length = 1; |
24 | - switch($que_id) { |
|
24 | + switch ($que_id) { |
|
25 | 25 | case QUE_RESEARCH: |
26 | 26 | $que_length = classSupernova::$config->server_que_length_research + mrc_get_level($user, null, UNIT_PREMIUM); // TODO - вынести в модуль |
27 | 27 | break; |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | |
36 | 36 | function eco_que_str2arr($que_str) { |
37 | 37 | $que_arr = explode(';', $que_str); |
38 | - foreach($que_arr as $que_index => &$que_item) { |
|
39 | - if($que_item) { |
|
38 | + foreach ($que_arr as $que_index => &$que_item) { |
|
39 | + if ($que_item) { |
|
40 | 40 | $que_item = explode(',', $que_item); |
41 | 41 | } else { |
42 | 42 | unset($que_arr[$que_index]); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | function eco_que_arr2str($que_arr) { |
50 | - foreach($que_arr as &$que_item) { |
|
50 | + foreach ($que_arr as &$que_item) { |
|
51 | 51 | $que_item = implode(',', $que_item); |
52 | 52 | } |
53 | 53 | |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | $classLocale = classLocale::$lang; |
60 | 60 | |
61 | 61 | $is_autoconvert = false; |
62 | - if($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
62 | + if ($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
63 | 63 | $build_mode = BUILD_CREATE; |
64 | 64 | $is_autoconvert = true; |
65 | 65 | } |
66 | 66 | |
67 | 67 | $unit_amount_qued = 0; |
68 | 68 | try { |
69 | - if(!$user['id']) { |
|
69 | + if (!$user['id']) { |
|
70 | 70 | throw new exception('{Нет идентификатора пользователя - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
71 | 71 | } |
72 | 72 | |
@@ -77,16 +77,16 @@ discard block |
||
77 | 77 | foreach($unit_list as $unit_id => $unit_amount) if($unit_amount) break; |
78 | 78 | } |
79 | 79 | */ |
80 | - if(!$unit_id) { |
|
80 | + if (!$unit_id) { |
|
81 | 81 | throw new exception('{Нет идентификатора юнита - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
82 | 82 | } |
83 | 83 | |
84 | 84 | $que_id = que_get_unit_que($unit_id); |
85 | - if(!$que_id) { |
|
85 | + if (!$que_id) { |
|
86 | 86 | throw new exception('{Неправильный тип очереди - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
87 | 87 | } |
88 | 88 | |
89 | - if($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
89 | + if ($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
90 | 90 | throw new exception('{Уничтожать можно только здания на планете}', ERR_ERROR); // TODO EXCEPTION |
91 | 91 | } |
92 | 92 | |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | $que_data = $que_data[$que_id]; |
95 | 95 | |
96 | 96 | // TODO Переделать под подочереди |
97 | - if($que_id == QUE_STRUCTURES) { |
|
97 | + if ($que_id == QUE_STRUCTURES) { |
|
98 | 98 | $sn_groups_build_allow = sn_get_groups('build_allow'); |
99 | 99 | $que_data['unit_list'] = $sn_groups_build_allow[$planet['planet_type']]; |
100 | 100 | |
101 | - if(!isset($que_data['unit_list'][$unit_id])) { |
|
101 | + if (!isset($que_data['unit_list'][$unit_id])) { |
|
102 | 102 | throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION |
103 | 103 | } |
104 | 104 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | // Это нужно, что бы заблокировать пользователя и работу с очередями |
120 | 120 | $user = db_user_by_id($user['id']); |
121 | 121 | // Это нужно, что бы заблокировать планету от списания ресурсов |
122 | - if(isset($planet['id']) && $planet['id']) { |
|
122 | + if (isset($planet['id']) && $planet['id']) { |
|
123 | 123 | $planet = db_planet_by_id($planet['id'], true); |
124 | 124 | } else { |
125 | 125 | $planet['id'] = 0; |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | $in_que = &$que['in_que'][$que_id][$user['id']][$planet_id]; |
132 | 132 | $que_max_length = que_get_max_que_length($user, $planet, $que_id, $que_data); |
133 | 133 | // TODO Добавить вызовы функций проверок текущей и максимальной длин очередей |
134 | - if(count($in_que) >= $que_max_length) { |
|
134 | + if (count($in_que) >= $que_max_length) { |
|
135 | 135 | throw new exception('{Все слоты очереди заняты}', ERR_ERROR); // TODO EXCEPTION |
136 | 136 | } |
137 | 137 | |
138 | 138 | // TODO Отдельно посмотреть на уничтожение зданий - что бы можно было уничтожать их без планов |
139 | - switch(eco_can_build_unit($user, $planet, $unit_id)) { |
|
139 | + switch (eco_can_build_unit($user, $planet, $unit_id)) { |
|
140 | 140 | case BUILD_ALLOWED: |
141 | 141 | break; |
142 | 142 | case BUILD_UNIT_BUSY: |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading |
145 | 145 | // case BUILD_REQUIRE_NOT_MEET: |
146 | 146 | default: |
147 | - if($build_mode == BUILD_CREATE) { |
|
147 | + if ($build_mode == BUILD_CREATE) { |
|
148 | 148 | throw new exception('{Требования не удовлетворены}', ERR_ERROR); |
149 | 149 | } |
150 | 150 | break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | $unit_amount_qued = $unit_amount; |
155 | 155 | $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0; |
156 | 156 | $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued; |
157 | - if($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
158 | - if($unit_level >= $unit_max) { |
|
157 | + if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
158 | + if ($unit_level >= $unit_max) { |
|
159 | 159 | throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
160 | 160 | } |
161 | 161 | $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level)); |
162 | 162 | } |
163 | 163 | |
164 | - if($unit_amount < 1) { |
|
164 | + if ($unit_amount < 1) { |
|
165 | 165 | throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
166 | 166 | } |
167 | 167 | |
@@ -170,21 +170,21 @@ discard block |
||
170 | 170 | // { |
171 | 171 | // die('Unit busy'); // TODO EXCEPTION |
172 | 172 | // } |
173 | - if(get_unit_param($unit_id, P_STACKABLE)) { |
|
173 | + if (get_unit_param($unit_id, P_STACKABLE)) { |
|
174 | 174 | // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь |
175 | - if(in_array($unit_id, $group_missile = sn_get_groups('missile'))) { |
|
175 | + if (in_array($unit_id, $group_missile = sn_get_groups('missile'))) { |
|
176 | 176 | // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита |
177 | 177 | $used_silo = 0; |
178 | - foreach($group_missile as $missile_id) { |
|
178 | + foreach ($group_missile as $missile_id) { |
|
179 | 179 | $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0; |
180 | 180 | $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE); |
181 | 181 | } |
182 | 182 | $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo; |
183 | - if($free_silo <= 0) { |
|
183 | + if ($free_silo <= 0) { |
|
184 | 184 | throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
185 | 185 | } |
186 | 186 | $unit_size = get_unit_param($unit_id, P_UNIT_SIZE); |
187 | - if($free_silo < $unit_size) { |
|
187 | + if ($free_silo < $unit_size) { |
|
188 | 188 | throw new exception("{В ракетной шахте нет места для {$classLocale['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION |
189 | 189 | } |
190 | 190 | $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size))); |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | $unit_level = $new_unit_level = 0; |
193 | 193 | } else { |
194 | 194 | $unit_amount = 1; |
195 | - if($que_id == QUE_STRUCTURES) { |
|
195 | + if ($que_id == QUE_STRUCTURES) { |
|
196 | 196 | // if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $que['sectors'][$planet['id']] <= 0) |
197 | 197 | $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0; |
198 | - if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) { |
|
198 | + if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) { |
|
199 | 199 | throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION |
200 | 200 | } |
201 | 201 | // И что это я такое написал? Зачем? |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | |
213 | 213 | $exchange = array(); |
214 | 214 | $market_get_autoconvert_cost = market_get_autoconvert_cost(); |
215 | - if($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
215 | + if ($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
216 | 216 | $dark_matter = mrc_get_level($user, null, RES_DARK_MATTER); |
217 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
217 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
218 | 218 | throw new exception("{Нет хватает " . ($market_get_autoconvert_cost - $dark_matter) . "ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION |
219 | 219 | } |
220 | 220 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $resource_exchange_rates = array(); |
225 | 225 | $resource_diff = array(); |
226 | 226 | $all_positive = true; |
227 | - foreach($resources_loot as $resource_id) { |
|
227 | + foreach ($resources_loot as $resource_id) { |
|
228 | 228 | $resource_db_name = pname_resource_name($resource_id); |
229 | 229 | $resource_got[$resource_id] = floor(mrc_get_level($user, $planet, $resource_id)); |
230 | 230 | $resource_exchange_rates[$resource_id] = classSupernova::$config->__get("rpg_exchange_{$resource_db_name}"); |
@@ -232,15 +232,15 @@ discard block |
||
232 | 232 | $all_positive = $all_positive && ($resource_diff[$resource_id] > 0); |
233 | 233 | } |
234 | 234 | // Нужна автоконвертация |
235 | - if($all_positive) { |
|
235 | + if ($all_positive) { |
|
236 | 236 | $is_autoconvert = false; |
237 | 237 | } else { |
238 | - foreach($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
239 | - if($resource_diff_amount >= 0) { |
|
238 | + foreach ($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
239 | + if ($resource_diff_amount >= 0) { |
|
240 | 240 | continue; |
241 | 241 | } |
242 | - foreach($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
243 | - if($resource_got_amount <= 0) { |
|
242 | + foreach ($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
243 | + if ($resource_got_amount <= 0) { |
|
244 | 244 | continue; |
245 | 245 | } |
246 | 246 | $current_exchange = $resource_exchange_rates[$resource_got_id] / $resource_exchange_rates[$resource_diff_id]; |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | $is_autoconvert_ok = true; |
259 | - foreach($resource_diff as $resource_diff_amount2) { |
|
260 | - if($resource_diff_amount2 < 0) { |
|
259 | + foreach ($resource_diff as $resource_diff_amount2) { |
|
260 | + if ($resource_diff_amount2 < 0) { |
|
261 | 261 | $is_autoconvert_ok = false; |
262 | 262 | break; |
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | - if($is_autoconvert_ok) { |
|
266 | + if ($is_autoconvert_ok) { |
|
267 | 267 | $build_data['RESULT'][$build_mode] = BUILD_ALLOWED; |
268 | 268 | $build_data['CAN'][$build_mode] = $unit_amount; |
269 | 269 | } else { |
@@ -272,19 +272,19 @@ discard block |
||
272 | 272 | } |
273 | 273 | } |
274 | 274 | $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount); |
275 | - if($unit_amount <= 0) { |
|
275 | + if ($unit_amount <= 0) { |
|
276 | 276 | throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION |
277 | 277 | } |
278 | 278 | |
279 | - if($new_unit_level < 0) { |
|
279 | + if ($new_unit_level < 0) { |
|
280 | 280 | throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION |
281 | 281 | } |
282 | 282 | |
283 | - if($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
283 | + if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
284 | 284 | throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION |
285 | 285 | } |
286 | 286 | |
287 | - if($is_autoconvert) { |
|
287 | + if ($is_autoconvert) { |
|
288 | 288 | ksort($exchange); |
289 | 289 | ksort($resource_got); |
290 | 290 | db_change_units($user, $planet, array( |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | } |
300 | 300 | |
301 | 301 | $unit_amount_qued = 0; |
302 | - while($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
302 | + while ($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
303 | 303 | $place = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW); |
304 | 304 | que_add_unit($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode); |
305 | 305 | $unit_amount -= $place; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | sn_db_transaction_commit(); |
311 | 311 | |
312 | - if($redirect) { |
|
312 | + if ($redirect) { |
|
313 | 313 | sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id')); |
314 | 314 | die(); |
315 | 315 | } |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | 'STATUS' => ERR_NONE, |
319 | 319 | 'MESSAGE' => '{Строительство начато}', |
320 | 320 | ); |
321 | - } catch(exception $e) { |
|
321 | + } catch (exception $e) { |
|
322 | 322 | sn_db_transaction_rollback(); |
323 | 323 | $operation_result = array( |
324 | 324 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | ); |
327 | 327 | } |
328 | 328 | |
329 | - if(!empty($operation_result['MESSAGE'])) { |
|
329 | + if (!empty($operation_result['MESSAGE'])) { |
|
330 | 330 | $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . classLocale::$lang['tech'][$unit_id] . ']'; |
331 | 331 | } |
332 | 332 | |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | function que_recalculate($old_que) { |
338 | 338 | $new_que = array(); |
339 | 339 | |
340 | - if(!is_array($old_que['items'])) { |
|
340 | + if (!is_array($old_que['items'])) { |
|
341 | 341 | return $new_que; |
342 | 342 | } |
343 | - foreach($old_que['items'] as $row) { |
|
344 | - if(!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
343 | + foreach ($old_que['items'] as $row) { |
|
344 | + if (!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
345 | 345 | continue; |
346 | 346 | } |
347 | 347 | |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | |
353 | 353 | $last_id = count($new_que['items']) - 1; |
354 | 354 | |
355 | - if($row['que_planet_id']) { |
|
355 | + if ($row['que_planet_id']) { |
|
356 | 356 | $new_que['planets'][$row['que_planet_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
357 | - } elseif($row['que_type'] == QUE_RESEARCH) { |
|
357 | + } elseif ($row['que_type'] == QUE_RESEARCH) { |
|
358 | 358 | $new_que['players'][$row['que_player_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
359 | 359 | } |
360 | 360 | $new_que['ques'][$row['que_type']][$row['que_player_id']][intval($row['que_planet_id'])][] = &$new_que['items'][$last_id]; |
@@ -389,9 +389,9 @@ discard block |
||
389 | 389 | $que_type = que_get_unit_que($unit_id); |
390 | 390 | $planet_id_origin = $planet['id'] ? $planet['id'] : 'NULL'; |
391 | 391 | $planet_id = $que_type == QUE_RESEARCH ? 'NULL' : $planet_id_origin; |
392 | - if(is_numeric($planet_id)) { |
|
392 | + if (is_numeric($planet_id)) { |
|
393 | 393 | db_planet_set_by_id($planet_id, "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
394 | - } elseif(is_numeric($user['id'])) { |
|
394 | + } elseif (is_numeric($user['id'])) { |
|
395 | 395 | db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
396 | 396 | } |
397 | 397 | |
@@ -421,17 +421,17 @@ discard block |
||
421 | 421 | $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0; |
422 | 422 | $global_que = que_get($user['id'], $planet['id'], $que_type, true); |
423 | 423 | |
424 | - if(!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
424 | + if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
425 | 425 | $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]); |
426 | 426 | |
427 | - foreach($que as $que_item) { |
|
427 | + foreach ($que as $que_item) { |
|
428 | 428 | db_que_delete_by_id($que_item['que_id']); |
429 | 429 | |
430 | - if($que_item['que_planet_id_origin']) { |
|
430 | + if ($que_item['que_planet_id_origin']) { |
|
431 | 431 | $planet['id'] = $que_item['que_planet_id_origin']; |
432 | 432 | } |
433 | 433 | |
434 | - if(!isset($planets_locked[$planet['id']])) { |
|
434 | + if (!isset($planets_locked[$planet['id']])) { |
|
435 | 435 | $planets_locked[$planet['id']] = $planet['id'] ? db_planet_by_id($planet['id'], true) : $planet; |
436 | 436 | } |
437 | 437 | |
@@ -443,14 +443,14 @@ discard block |
||
443 | 443 | RES_DEUTERIUM => $build_data[RES_DEUTERIUM] * $que_item['que_unit_amount'], |
444 | 444 | )); |
445 | 445 | |
446 | - if(!$clear) { |
|
446 | + if (!$clear) { |
|
447 | 447 | break; |
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | - if(is_numeric($planet['id'])) { |
|
451 | + if (is_numeric($planet['id'])) { |
|
452 | 452 | db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
453 | - } elseif(is_numeric($user['id'])) { |
|
453 | + } elseif (is_numeric($user['id'])) { |
|
454 | 454 | db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
455 | 455 | } |
456 | 456 | |
@@ -498,21 +498,21 @@ discard block |
||
498 | 498 | // TODO: Переделать для $que_type === false |
499 | 499 | $planet['id'] = $planet['id'] ? $planet['id'] : 0; |
500 | 500 | |
501 | - if(!is_array($que)) { |
|
501 | + if (!is_array($que)) { |
|
502 | 502 | $que = que_get($user['id'], $planet['id'], $que_type); |
503 | 503 | } |
504 | 504 | |
505 | - if(is_array($que) && isset($que['items'])) { |
|
505 | + if (is_array($que) && isset($que['items'])) { |
|
506 | 506 | $que = $que['ques'][$que_type][$user['id']][$planet['id']]; |
507 | 507 | } |
508 | 508 | |
509 | - if($que) { |
|
510 | - foreach($que as $que_element) { |
|
509 | + if ($que) { |
|
510 | + foreach ($que as $que_element) { |
|
511 | 511 | $template->assign_block_vars('que', que_tpl_parse_element($que_element, $short_names)); |
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | - if($que_type == QUE_RESEARCH) { |
|
515 | + if ($que_type == QUE_RESEARCH) { |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | $user = db_user_by_id($user['id'], true); |
539 | 539 | |
540 | 540 | $time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']); |
541 | - if($planet === null && !$time_left[$user['id']][0]) { |
|
541 | + if ($planet === null && !$time_left[$user['id']][0]) { |
|
542 | 542 | // TODO |
543 | 543 | return $que; |
544 | 544 | } |
@@ -547,12 +547,12 @@ discard block |
||
547 | 547 | $que_type_id = $planet === null ? QUE_RESEARCH : false; |
548 | 548 | $planet = intval(is_array($planet) ? $planet['id'] : $planet); // В $planet у нас теперь только её ID или шаблон null/0/false |
549 | 549 | $que = que_get($user['id'], $planet, $que_type_id, true); |
550 | - if(empty($que['items'])) { |
|
550 | + if (empty($que['items'])) { |
|
551 | 551 | return $que; |
552 | 552 | } |
553 | 553 | |
554 | 554 | $planet_list = array(); |
555 | - if($planet !== null) { |
|
555 | + if ($planet !== null) { |
|
556 | 556 | // Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них |
557 | 557 | // TODO - от них не надо ничего, кроме ID и que_processed |
558 | 558 | $planet_row = db_planet_list_by_user_or_planet($user['id'], $planet); |
@@ -561,21 +561,21 @@ discard block |
||
561 | 561 | } |
562 | 562 | |
563 | 563 | // Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты |
564 | - if(array_sum($time_left[$user['id']]) == 0) { |
|
564 | + if (array_sum($time_left[$user['id']]) == 0) { |
|
565 | 565 | return $que; |
566 | 566 | } |
567 | 567 | |
568 | 568 | $db_changeset = array(); |
569 | 569 | $unit_changes = array(); |
570 | - foreach($que['items'] as &$que_item) { |
|
570 | + foreach ($que['items'] as &$que_item) { |
|
571 | 571 | $que_player_id = &$que_item['que_player_id']; |
572 | 572 | $que_planet_id = intval($que_item['que_planet_id']); |
573 | 573 | |
574 | 574 | $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']]; |
575 | - if(!isset($que_time_left)) { |
|
575 | + if (!isset($que_time_left)) { |
|
576 | 576 | $que_time_left = $time_left[$que_player_id][$que_planet_id]; |
577 | 577 | } |
578 | - if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
578 | + if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
579 | 579 | continue; |
580 | 580 | } |
581 | 581 | // Дальше мы идем, если только осталось время в очереди И юниты к постройке |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля |
589 | 589 | |
590 | 590 | // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит |
591 | - if($que_time_left >= $que_item['que_time_left']) { |
|
591 | + if ($que_time_left >= $que_item['que_time_left']) { |
|
592 | 592 | // Увеличиваем количество отстроенных юнитов |
593 | 593 | $unit_processed++; |
594 | 594 | // Вычитаем из времени очереди потраченное на постройку время |
@@ -601,12 +601,12 @@ discard block |
||
601 | 601 | $que_item['que_unit_amount'] -= $unit_processed; |
602 | 602 | |
603 | 603 | // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита |
604 | - if($que_item['que_unit_amount'] > 0) { |
|
604 | + if ($que_item['que_unit_amount'] > 0) { |
|
605 | 605 | $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left; |
606 | 606 | $que_time_left = 0; |
607 | 607 | } |
608 | 608 | |
609 | - if($que_item['que_unit_amount'] <= 0) { |
|
609 | + if ($que_item['que_unit_amount'] <= 0) { |
|
610 | 610 | $db_changeset['que'][] = array( |
611 | 611 | 'action' => SQL_OP_DELETE, |
612 | 612 | P_VERSION => 1, |
@@ -632,14 +632,14 @@ discard block |
||
632 | 632 | ); |
633 | 633 | } |
634 | 634 | |
635 | - if($unit_processed) { |
|
635 | + if ($unit_processed) { |
|
636 | 636 | $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1); |
637 | 637 | $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta; |
638 | 638 | } |
639 | 639 | } |
640 | 640 | |
641 | - foreach($time_left as $player_id => $planet_data) { |
|
642 | - foreach($planet_data as $planet_id => $time_on_planet) { |
|
641 | + foreach ($time_left as $player_id => $planet_data) { |
|
642 | + foreach ($planet_data as $planet_id => $time_on_planet) { |
|
643 | 643 | $table = $planet_id ? 'planets' : 'users'; |
644 | 644 | $id = $planet_id ? $planet_id : $player_id; |
645 | 645 | $db_changeset[$table][] = array( |
@@ -655,8 +655,8 @@ discard block |
||
655 | 655 | ), |
656 | 656 | ); |
657 | 657 | |
658 | - if(is_array($unit_changes[$player_id][$planet_id])) { |
|
659 | - foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
658 | + if (is_array($unit_changes[$player_id][$planet_id])) { |
|
659 | + foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
660 | 660 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null); |
661 | 661 | } |
662 | 662 | } |
@@ -666,38 +666,38 @@ discard block |
||
666 | 666 | $que = que_recalculate($que); |
667 | 667 | |
668 | 668 | // TODO: Re-enable quests for Alliances |
669 | - if(!empty($unit_changes) && !$user['user_as_ally']) { |
|
669 | + if (!empty($unit_changes) && !$user['user_as_ally']) { |
|
670 | 670 | $quest_list = qst_get_quests($user['id']); |
671 | 671 | $quest_triggers = qst_active_triggers($quest_list); |
672 | 672 | $quest_rewards = array(); |
673 | 673 | |
674 | 674 | |
675 | 675 | $xp_incoming = array(); |
676 | - foreach($unit_changes as $user_id => $planet_changes) { |
|
677 | - foreach($planet_changes as $planet_id => $changes) { |
|
676 | + foreach ($unit_changes as $user_id => $planet_changes) { |
|
677 | + foreach ($planet_changes as $planet_id => $changes) { |
|
678 | 678 | $planet_this = $planet_id ? classSupernova::db_get_record_by_id(LOC_PLANET, $planet_id) : array(); |
679 | - foreach($changes as $unit_id => $unit_value) { |
|
679 | + foreach ($changes as $unit_id => $unit_value) { |
|
680 | 680 | $que_id = que_get_unit_que($unit_id); |
681 | 681 | $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value; |
682 | - if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
682 | + if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
683 | 683 | $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1); |
684 | 684 | $build_data = $build_data[BUILD_CREATE]; |
685 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
685 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
686 | 686 | $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена |
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
690 | - if(is_array($quest_triggers)) { |
|
690 | + if (is_array($quest_triggers)) { |
|
691 | 691 | // TODO: Check mutiply condition quests |
692 | 692 | $quest_trigger_list = array_keys($quest_triggers, $unit_id); |
693 | - if(is_array($quest_trigger_list)) { |
|
694 | - foreach($quest_trigger_list as $quest_id) { |
|
693 | + if (is_array($quest_trigger_list)) { |
|
694 | + foreach ($quest_trigger_list as $quest_id) { |
|
695 | 695 | $quest_unit_level = $unit_level_new; |
696 | - if(get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) { |
|
696 | + if (get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) { |
|
697 | 697 | $quest_unit_level = db_unit_count_by_user_and_type_and_snid($user_id, 0, $unit_id); |
698 | 698 | $quest_unit_level = $quest_unit_level[$unit_id]['qty']; |
699 | 699 | } |
700 | - if($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) { |
|
700 | + if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) { |
|
701 | 701 | $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list']; |
702 | 702 | $quest_list[$quest_id]['quest_status_status'] = QUEST_STATUS_COMPLETE; |
703 | 703 | } |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч |
711 | 711 | qst_reward($user, $quest_rewards, $quest_list); |
712 | 712 | |
713 | - foreach($xp_incoming as $que_id => $xp) { |
|
713 | + foreach ($xp_incoming as $que_id => $xp) { |
|
714 | 714 | rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000); |
715 | 715 | } |
716 | 716 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
26 | 26 | false, 'id, username'); |
27 | 27 | // while ($u = db_fetch($query)) |
28 | - foreach($query as $u) { |
|
28 | + foreach ($query as $u) { |
|
29 | 29 | $sendList[] = $u['id']; |
30 | 30 | $list .= "<br>{$u['username']} "; |
31 | 31 | } |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | function msg_send_simple_message($owners, $sender, $timestamp, $message_type, $from, $subject, $text, $escaped = false, $force = false) { |
39 | 39 | global $user, $sn_message_class_list; |
40 | 40 | |
41 | - if(!$owners) { |
|
41 | + if (!$owners) { |
|
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
45 | 45 | $timestamp = $timestamp ? $timestamp : SN_TIME_NOW; |
46 | 46 | $sender = intval($sender); |
47 | - if(!is_array($owners)) { |
|
47 | + if (!is_array($owners)) { |
|
48 | 48 | $owners = array($owners); |
49 | 49 | } |
50 | 50 | |
51 | - if(!$escaped) { |
|
51 | + if (!$escaped) { |
|
52 | 52 | $from = db_escape($from); |
53 | 53 | $subject = db_escape($subject); |
54 | 54 | $text = db_escape($text); |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | |
64 | 64 | $message_class_name_total = $sn_message_class_list[MSG_TYPE_NEW]['name']; |
65 | 65 | |
66 | - if($owners[0] == '*') { |
|
67 | - if($user['authlevel'] < 3) { |
|
66 | + if ($owners[0] == '*') { |
|
67 | + if ($user['authlevel'] < 3) { |
|
68 | 68 | return false; |
69 | 69 | } |
70 | 70 | // TODO Добавить $timestamp - рассылка может быть и отсроченной |
@@ -75,24 +75,24 @@ discard block |
||
75 | 75 | $insert_values = array(); |
76 | 76 | $insert_template = "('%u'," . str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')"); |
77 | 77 | |
78 | - foreach($owners as $owner) { |
|
79 | - if($user['id'] != $owner) { |
|
78 | + foreach ($owners as $owner) { |
|
79 | + if ($user['id'] != $owner) { |
|
80 | 80 | $owner_row = db_user_by_id($owner); |
81 | 81 | } else { |
82 | 82 | $owner_row = $user; |
83 | 83 | } |
84 | 84 | sys_user_options_unpack($owner_row); |
85 | 85 | |
86 | - if($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) { |
|
86 | + if ($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) { |
|
87 | 87 | $insert_values[] = sprintf($insert_template, $owner); |
88 | 88 | } |
89 | 89 | |
90 | - if($message_class_email && classSupernova::$config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) { |
|
90 | + if ($message_class_email && classSupernova::$config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) { |
|
91 | 91 | @$result = mymail($owner_row['email'], $subject, $text_unescaped, '', true); |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - if(empty($insert_values)) { |
|
95 | + if (empty($insert_values)) { |
|
96 | 96 | return; |
97 | 97 | } |
98 | 98 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | } |
101 | 101 | db_user_list_set_mass_mail($owners, "`{$message_class_name}` = `{$message_class_name}` + 1, `{$message_class_name_total}` = `{$message_class_name_total}` + 1"); |
102 | 102 | |
103 | - if(in_array($user['id'], $owners) || $owners[0] == '*') { |
|
103 | + if (in_array($user['id'], $owners) || $owners[0] == '*') { |
|
104 | 104 | $user[$message_class_name]++; |
105 | 105 | $user[$message_class_name_total]++; |
106 | 106 | } |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | * @version 1.0 |
12 | 12 | */ |
13 | 13 | function eco_get_lab_max_effective_level(&$user, $lab_require) { |
14 | - if(!$user['user_as_ally'] && !isset($user['laboratories_active'])) { |
|
14 | + if (!$user['user_as_ally'] && !isset($user['laboratories_active'])) { |
|
15 | 15 | $user['laboratories_active'] = array(); |
16 | 16 | $query = db_unit_list_laboratories($user['id']); |
17 | - while($row = db_fetch($query)) { |
|
18 | - if(!eco_unit_busy($user, $row, UNIT_TECHNOLOGIES)) { |
|
17 | + while ($row = db_fetch($query)) { |
|
18 | + if (!eco_unit_busy($user, $row, UNIT_TECHNOLOGIES)) { |
|
19 | 19 | $row += array( |
20 | 20 | STRUC_LABORATORY => $level_lab = mrc_get_level($user, $row, STRUC_LABORATORY), |
21 | 21 | STRUC_LABORATORY_NANO => $level_lab_nano = mrc_get_level($user, $row, STRUC_LABORATORY_NANO), |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | uasort($user['laboratories_active'], 'eco_lab_sort_effectivness'); |
29 | 29 | } |
30 | 30 | |
31 | - if(!isset($user['research_effective_level'][$lab_require])) { |
|
32 | - if($user['user_as_ally']) { |
|
31 | + if (!isset($user['research_effective_level'][$lab_require])) { |
|
32 | + if ($user['user_as_ally']) { |
|
33 | 33 | $lab_level = db_ally_get_ally_count($user); |
34 | 34 | } else { |
35 | 35 | $tech_intergalactic = mrc_get_level($user, null, TECH_RESEARCH) + 1; |
36 | 36 | $lab_level['effective_level'] = 0; |
37 | 37 | |
38 | - foreach($user['laboratories_active'] as $data) { |
|
39 | - if($tech_intergalactic <= 0) { |
|
38 | + foreach ($user['laboratories_active'] as $data) { |
|
39 | + if ($tech_intergalactic <= 0) { |
|
40 | 40 | break; |
41 | 41 | } |
42 | - if($data[STRUC_LABORATORY] >= $lab_require) { |
|
42 | + if ($data[STRUC_LABORATORY] >= $lab_require) { |
|
43 | 43 | $lab_level['effective_level'] += $data['laboratory_effective_level']; |
44 | 44 | $tech_intergalactic--; |
45 | 45 | } |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | $time = 0; |
66 | 66 | $only_dark_matter = 0; |
67 | 67 | $cost_in_metal = 0; |
68 | - foreach($unit_data[P_COST] as $resource_id => $resource_amount) { |
|
69 | - if($resource_id === P_FACTOR || !($resource_cost = $resource_amount * $price_increase)) { |
|
68 | + foreach ($unit_data[P_COST] as $resource_id => $resource_amount) { |
|
69 | + if ($resource_id === P_FACTOR || !($resource_cost = $resource_amount * $price_increase)) { |
|
70 | 70 | continue; |
71 | 71 | } |
72 | 72 | |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | |
76 | 76 | $resource_db_name = pname_resource_name($resource_id); |
77 | 77 | $cost_in_metal += $cost[BUILD_CREATE][$resource_id] * classSupernova::$config->__get("rpg_exchange_{$resource_db_name}"); |
78 | - if(in_array($resource_id, sn_get_groups('resources_loot'))) { |
|
78 | + if (in_array($resource_id, sn_get_groups('resources_loot'))) { |
|
79 | 79 | $time += $resource_cost * classSupernova::$config->__get("rpg_exchange_{$resource_db_name}") / $rpg_exchange_deuterium; |
80 | 80 | $resource_got = mrc_get_level($user, $planet, $resource_id); |
81 | - } elseif($resource_id == RES_DARK_MATTER) { |
|
81 | + } elseif ($resource_id == RES_DARK_MATTER) { |
|
82 | 82 | $resource_got = mrc_get_level($user, null, $resource_id); |
83 | - } elseif($resource_id == RES_ENERGY) { |
|
83 | + } elseif ($resource_id == RES_ENERGY) { |
|
84 | 84 | $resource_got = max(0, $planet['energy_max'] - $planet['energy_used']); |
85 | 85 | } else { |
86 | 86 | $resource_got = 0; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | $resources_normalized = 0; |
95 | 95 | $resources_loot = sn_get_groups('resources_loot'); |
96 | - foreach($resources_loot as $resource_id) { |
|
96 | + foreach ($resources_loot as $resource_id) { |
|
97 | 97 | $resource_db_name = pname_resource_name($resource_id); |
98 | 98 | $resource_got = mrc_get_level($user, $planet, $resource_id); |
99 | 99 | $resources_normalized += floor($resource_got) * classSupernova::$config->__get("rpg_exchange_{$resource_db_name}"); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $cost[P_OPTIONS][P_TIME_RAW] = $time = $time * 60 * 60 / get_game_speed() / 2500; |
112 | 112 | |
113 | 113 | // TODO - Вынести в отдельную процедуру расчёт стоимости |
114 | - if($only_cost) { |
|
114 | + if ($only_cost) { |
|
115 | 115 | return $cost; |
116 | 116 | } |
117 | 117 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | $mercenary = 0; |
122 | 122 | $cost['RESULT'][BUILD_DESTROY] = BUILD_INDESTRUCTABLE; |
123 | - if(in_array($unit_id, sn_get_groups('structures'))) { |
|
123 | + if (in_array($unit_id, sn_get_groups('structures'))) { |
|
124 | 124 | $time = $time * pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_ROBOT) + 1); |
125 | 125 | $mercenary = MRC_ENGINEER; |
126 | 126 | $cost['RESULT'][BUILD_DESTROY] = |
@@ -130,23 +130,23 @@ discard block |
||
130 | 130 | : BUILD_NO_RESOURCES |
131 | 131 | ) |
132 | 132 | : BUILD_NO_UNITS; |
133 | - } elseif(in_array($unit_id, sn_get_groups('tech'))) { |
|
133 | + } elseif (in_array($unit_id, sn_get_groups('tech'))) { |
|
134 | 134 | $lab_level = eco_get_lab_max_effective_level($user, intval($unit_data['require'][STRUC_LABORATORY])); |
135 | 135 | $time = $time / $lab_level; |
136 | 136 | $mercenary = MRC_ACADEMIC; |
137 | - } elseif(in_array($unit_id, sn_get_groups('defense'))) { |
|
137 | + } elseif (in_array($unit_id, sn_get_groups('defense'))) { |
|
138 | 138 | $time = $time * pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1); |
139 | 139 | $mercenary = MRC_FORTIFIER; |
140 | - } elseif(in_array($unit_id, sn_get_groups('fleet'))) { |
|
140 | + } elseif (in_array($unit_id, sn_get_groups('fleet'))) { |
|
141 | 141 | $time = $time * pow(0.5, mrc_get_level($user, $planet, STRUC_FACTORY_NANO)) / (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) + 1); |
142 | 142 | $mercenary = MRC_ENGINEER; |
143 | 143 | } |
144 | 144 | |
145 | - if($mercenary) { |
|
145 | + if ($mercenary) { |
|
146 | 146 | $time = $time / mrc_modify_value($user, $planet, $mercenary, 1); |
147 | 147 | } |
148 | 148 | |
149 | - if(in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) { |
|
149 | + if (in_array($unit_id, sn_get_groups('governors')) || $only_dark_matter) { |
|
150 | 150 | $cost[RES_TIME][BUILD_CREATE] = $cost[RES_TIME][BUILD_DESTROY] = 0; |
151 | 151 | } else { |
152 | 152 | $cost[RES_TIME][BUILD_CREATE] = round($time >= 1 ? $time : 1); |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | $result = $result == BUILD_ALLOWED && eco_unit_busy($user, $planet, $unit_id) ? BUILD_UNIT_BUSY : $result; |
164 | 164 | |
165 | 165 | $unit_param = get_unit_param($unit_id); |
166 | - if($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !classSupernova::$config->empire_mercenary_temporary) { |
|
166 | + if ($unit_param[P_UNIT_TYPE] != UNIT_MERCENARIES || !classSupernova::$config->empire_mercenary_temporary) { |
|
167 | 167 | $requirement = &$unit_param[P_REQUIRE]; |
168 | - if($result == BUILD_ALLOWED && $requirement) { |
|
169 | - foreach($requirement as $require_id => $require_level) { |
|
170 | - if(mrc_get_level($user, $planet, $require_id) < $require_level) { |
|
168 | + if ($result == BUILD_ALLOWED && $requirement) { |
|
169 | + foreach ($requirement as $require_id => $require_level) { |
|
170 | + if (mrc_get_level($user, $planet, $require_id) < $require_level) { |
|
171 | 171 | $result = BUILD_REQUIRE_NOT_MEET; |
172 | 172 | break; |
173 | 173 | } |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | |
184 | 184 | $unit_list = is_array($unit_list) ? $unit_list : array($unit_list => $unit_list); |
185 | 185 | $planet_que = explode(';', $planet_que); |
186 | - foreach($planet_que as $planet_que_item) { |
|
187 | - if($planet_que_item) { |
|
186 | + foreach ($planet_que as $planet_que_item) { |
|
187 | + if ($planet_que_item) { |
|
188 | 188 | list($planet_que_item) = explode(',', $planet_que_item); |
189 | - if(in_array($planet_que_item, $unit_list)) { |
|
189 | + if (in_array($planet_que_item, $unit_list)) { |
|
190 | 190 | $eco_is_builds_in_que = true; |
191 | 191 | break; |
192 | 192 | } |
@@ -200,12 +200,12 @@ discard block |
||
200 | 200 | |
201 | 201 | function sn_eco_unit_busy(&$user, &$planet, $unit_id, &$result) { |
202 | 202 | $result = isset($result) ? $result : false; |
203 | - if(!$result) { |
|
204 | - if(($unit_id == STRUC_LABORATORY || $unit_id == STRUC_LABORATORY_NANO) && !classSupernova::$config->BuildLabWhileRun) { |
|
203 | + if (!$result) { |
|
204 | + if (($unit_id == STRUC_LABORATORY || $unit_id == STRUC_LABORATORY_NANO) && !classSupernova::$config->BuildLabWhileRun) { |
|
205 | 205 | $global_que = que_get($user['id'], $planet['id'], QUE_RESEARCH, false); |
206 | - if(is_array($global_que['ques'][QUE_RESEARCH][$user['id']])) { |
|
206 | + if (is_array($global_que['ques'][QUE_RESEARCH][$user['id']])) { |
|
207 | 207 | $first_element = reset($global_que['ques'][QUE_RESEARCH][$user['id']]); |
208 | - if(is_array($first_element)) { |
|
208 | + if (is_array($first_element)) { |
|
209 | 209 | $result = true; |
210 | 210 | } |
211 | 211 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | //{ |
214 | 214 | // $result = true; |
215 | 215 | //} |
216 | - } elseif(($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !classSupernova::$config->BuildLabWhileRun && $planet['que']) { |
|
216 | + } elseif (($unit_id == UNIT_TECHNOLOGIES || in_array($unit_id, sn_get_groups('tech'))) && !classSupernova::$config->BuildLabWhileRun && $planet['que']) { |
|
217 | 217 | $result = eco_is_builds_in_que($planet['que'], array(STRUC_LABORATORY, STRUC_LABORATORY_NANO)); |
218 | 218 | } |
219 | 219 | } |
@@ -29,28 +29,28 @@ discard block |
||
29 | 29 | function rpg_points_change($user_id, $change_type, $dark_matter, $comment = '', $already_changed = false) { |
30 | 30 | global $debug, $dm_change_legit, $user; |
31 | 31 | |
32 | - if(!$user_id) { |
|
32 | + if (!$user_id) { |
|
33 | 33 | return false; |
34 | 34 | } |
35 | 35 | |
36 | 36 | $dm_change_legit = true; |
37 | 37 | $sn_data_dark_matter_db_name = pname_resource_name(RES_DARK_MATTER); |
38 | 38 | |
39 | - if($already_changed) { |
|
39 | + if ($already_changed) { |
|
40 | 40 | $rows_affected = 1; |
41 | 41 | } else { |
42 | 42 | $changeset = array(); |
43 | 43 | $a_user = db_user_by_id($user_id, true); |
44 | - if($dark_matter < 0) { |
|
44 | + if ($dark_matter < 0) { |
|
45 | 45 | $dark_matter_exists = mrc_get_level($a_user, null, RES_DARK_MATTER, false, true); |
46 | 46 | $dark_matter_exists < 0 ? $dark_matter_exists = 0 : false; |
47 | 47 | $metamatter_to_reduce = -$dark_matter - $dark_matter_exists; |
48 | - if($metamatter_to_reduce > 0) { |
|
48 | + if ($metamatter_to_reduce > 0) { |
|
49 | 49 | $metamatter_exists = mrc_get_level($a_user, null, RES_METAMATTER); |
50 | - if($metamatter_exists < $metamatter_to_reduce) { |
|
50 | + if ($metamatter_exists < $metamatter_to_reduce) { |
|
51 | 51 | $debug->error('Ошибка снятия ТМ - ММ+ТМ меньше, чем сумма для снятия!', 'Ошибка снятия ТМ', LOG_ERR_INT_NOT_ENOUGH_DARK_MATTER); |
52 | 52 | } |
53 | - if(is_array($comment)) { |
|
53 | + if (is_array($comment)) { |
|
54 | 54 | $comment = call_user_func_array('sprintf', $comment); |
55 | 55 | } |
56 | 56 | // mm_points_change($user_id, $change_type, -$metamatter_to_reduce, 'ММ в ТМ: ' . (-$dark_matter) . ' ТМ = ' . $dark_matter_exists . ' ТМ + ' . $metamatter_to_reduce . ' ММ. ' . $comment); |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | $rows_affected = classSupernova::$db->db_affected_rows(); |
66 | 66 | } |
67 | 67 | |
68 | - if($rows_affected || !$dark_matter) { |
|
68 | + if ($rows_affected || !$dark_matter) { |
|
69 | 69 | $page_url = db_escape($_SERVER['SCRIPT_NAME']); |
70 | - if(is_array($comment)) { |
|
70 | + if (is_array($comment)) { |
|
71 | 71 | $comment = call_user_func_array('sprintf', $comment); |
72 | 72 | } |
73 | 73 | $comment = db_escape($comment); |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | $row['username'] = db_escape($row['username']); |
76 | 76 | db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment, $row, $page_url); |
77 | 77 | |
78 | - if($user['id'] == $user_id) { |
|
78 | + if ($user['id'] == $user_id) { |
|
79 | 79 | $user['dark_matter'] += $dark_matter; |
80 | 80 | } |
81 | 81 | |
82 | - if($dark_matter > 0) { |
|
82 | + if ($dark_matter > 0) { |
|
83 | 83 | $old_referral = db_referral_get_by_id($user_id); |
84 | - if($old_referral['id']) { |
|
84 | + if ($old_referral['id']) { |
|
85 | 85 | db_referral_update_dm($user_id, $dark_matter); |
86 | 86 | $new_referral = db_referral_get_by_id($user_id); |
87 | 87 | |
88 | 88 | $partner_bonus = floor($new_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) : 0); |
89 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
89 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) { |
|
90 | 90 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL, $partner_bonus, "Incoming From Referral ID {$user_id}"); |
91 | 91 | } |
92 | 92 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | function rpg_level_up(&$user, $type, $xp_to_add = 0) { |
104 | 104 | $q = 1.03; |
105 | 105 | |
106 | - switch($type) { |
|
106 | + switch ($type) { |
|
107 | 107 | case RPG_STRUCTURE: |
108 | 108 | $field_level = 'lvl_minier'; |
109 | 109 | $field_xp = 'xpminier'; |
@@ -140,17 +140,17 @@ discard block |
||
140 | 140 | |
141 | 141 | $xp = &$user[$field_xp]; |
142 | 142 | |
143 | - if($xp_to_add) { |
|
143 | + if ($xp_to_add) { |
|
144 | 144 | $xp += $xp_to_add; |
145 | 145 | db_user_set_by_id($user['id'], "`{$field_xp}` = `{$field_xp}` + '{$xp_to_add}'"); |
146 | 146 | } |
147 | 147 | |
148 | 148 | $level = $user[$field_level]; |
149 | - while($xp > rpg_xp_for_level($level + 1, $b1, $q)) { |
|
149 | + while ($xp > rpg_xp_for_level($level + 1, $b1, $q)) { |
|
150 | 150 | $level++; |
151 | 151 | } |
152 | 152 | $level -= $user[$field_level]; |
153 | - if($level > 0) { |
|
153 | + if ($level > 0) { |
|
154 | 154 | db_user_set_by_id($user['id'], "`{$field_level}` = `{$field_level}` + '{$level}'"); |
155 | 155 | rpg_points_change($user['id'], $type, $level * 1000, $comment); |
156 | 156 | $user[$field_level] += $level; |
@@ -11,38 +11,38 @@ discard block |
||
11 | 11 | |
12 | 12 | $in_admin = defined('IN_ADMIN') && IN_ADMIN === true; |
13 | 13 | |
14 | - if($in_admin) { |
|
14 | + if ($in_admin) { |
|
15 | 15 | $quest_id = sys_get_param_id('id'); |
16 | 16 | $quest_name = sys_get_param_str_unsafe('QUEST_NAME'); |
17 | - if(!empty($quest_name)) { |
|
17 | + if (!empty($quest_name)) { |
|
18 | 18 | $quest_description = sys_get_param_str_unsafe('QUEST_DESCRIPTION'); |
19 | 19 | try { |
20 | 20 | $quest_rewards_list = sys_get_param('QUEST_REWARDS_LIST'); |
21 | 21 | $quest_rewards = array(); |
22 | - foreach($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) { |
|
23 | - if(!in_array($quest_rewards_id, $quest_reward_allowed)) { |
|
22 | + foreach ($quest_rewards_list as $quest_rewards_id => $quest_rewards_amount) { |
|
23 | + if (!in_array($quest_rewards_id, $quest_reward_allowed)) { |
|
24 | 24 | throw new Exception(classLocale::$lang['qst_adm_err_reward_type']); |
25 | 25 | } |
26 | 26 | |
27 | - if($quest_rewards_amount < 0) { |
|
27 | + if ($quest_rewards_amount < 0) { |
|
28 | 28 | throw new Exception(classLocale::$lang['qst_adm_err_reward_amount']); |
29 | - } elseif($quest_rewards_amount > 0) { |
|
29 | + } elseif ($quest_rewards_amount > 0) { |
|
30 | 30 | $quest_rewards[] = "{$quest_rewards_id},{$quest_rewards_amount}"; |
31 | 31 | } |
32 | 32 | } |
33 | - if(empty($quest_rewards)) { |
|
33 | + if (empty($quest_rewards)) { |
|
34 | 34 | throw new Exception(classLocale::$lang['qst_adm_err_reward_empty']); |
35 | 35 | } |
36 | 36 | |
37 | 37 | $quest_rewards = implode(';', $quest_rewards); |
38 | 38 | |
39 | 39 | $quest_unit_id = sys_get_param_int('QUEST_UNIT_ID'); |
40 | - if(!in_array($quest_unit_id, $quest_units_allowed)) { |
|
40 | + if (!in_array($quest_unit_id, $quest_units_allowed)) { |
|
41 | 41 | throw new Exception(classLocale::$lang['qst_adm_err_unit_id']); |
42 | 42 | } |
43 | 43 | |
44 | 44 | $quest_unit_amount = sys_get_param_float('QUEST_UNIT_AMOUNT'); |
45 | - if($quest_unit_amount <= 0) { |
|
45 | + if ($quest_unit_amount <= 0) { |
|
46 | 46 | throw new Exception(classLocale::$lang['qst_adm_err_unit_amount']); |
47 | 47 | } |
48 | 48 | $quest_conditions = "{$quest_unit_id},{$quest_unit_amount}"; |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | // TODO: Change quest type |
51 | 51 | $quest_type = 0; |
52 | 52 | |
53 | - if($mode == 'edit') { |
|
53 | + if ($mode == 'edit') { |
|
54 | 54 | $quest_name = db_escape($quest_name); |
55 | 55 | $quest_description = db_escape($quest_description); |
56 | 56 | db_quest_update($quest_name, $quest_type, $quest_description, $quest_conditions, $quest_rewards, $quest_id); |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | // TODO: Add mass mail for new quests |
68 | - } catch(Exception $e) { |
|
68 | + } catch (Exception $e) { |
|
69 | 69 | message($e->getMessage(), classLocale::$lang['sys_error']); |
70 | 70 | } |
71 | 71 | |
72 | 72 | $mode = ''; |
73 | 73 | }; |
74 | 74 | |
75 | - switch($mode) { |
|
75 | + switch ($mode) { |
|
76 | 76 | case 'del': |
77 | 77 | db_quest_delete($quest_id); |
78 | 78 | $mode = ''; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | } |
88 | 88 | $query = db_quest_count(); |
89 | 89 | classSupernova::$config->db_saveItem('quest_total', $query['count']); |
90 | - } elseif(!$user_id) { |
|
90 | + } elseif (!$user_id) { |
|
91 | 91 | $user_id = $user['id']; |
92 | 92 | } |
93 | 93 | |
@@ -100,22 +100,22 @@ discard block |
||
100 | 100 | 'IN_ADMIN' => $in_admin, |
101 | 101 | )); |
102 | 102 | |
103 | - if($quest) { |
|
103 | + if ($quest) { |
|
104 | 104 | $quest_templatized = qst_templatize(qst_quest_parse($quest, false)); |
105 | 105 | } else { |
106 | 106 | $quest_templatized['quest_rewards_list'] = array(); |
107 | 107 | } |
108 | 108 | |
109 | - foreach($quest_reward_allowed as $unit_id) { |
|
109 | + foreach ($quest_reward_allowed as $unit_id) { |
|
110 | 110 | $found = false; |
111 | - foreach($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) { |
|
112 | - if($quest_templatized_reward['ID'] == $unit_id) { |
|
111 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_templatized_reward) { |
|
112 | + if ($quest_templatized_reward['ID'] == $unit_id) { |
|
113 | 113 | $found = true; |
114 | 114 | break; |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | - if(!$found) { |
|
118 | + if (!$found) { |
|
119 | 119 | $quest_templatized['quest_rewards_list'][$unit_id] = array( |
120 | 120 | 'ID' => $unit_id, |
121 | 121 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | |
127 | 127 | qst_assign_to_template($template, $quest_templatized); |
128 | 128 | |
129 | - foreach($quest_list as $quest_data) { |
|
129 | + foreach ($quest_list as $quest_data) { |
|
130 | 130 | qst_assign_to_template($template, qst_templatize($quest_data, true), 'quest'); |
131 | 131 | } |
132 | 132 | |
133 | - foreach($quest_units_allowed as $unit_id) { |
|
133 | + foreach ($quest_units_allowed as $unit_id) { |
|
134 | 134 | $template->assign_block_vars('allowed_unit', array( |
135 | 135 | 'ID' => $unit_id, |
136 | 136 | 'NAME' => classLocale::$lang['tech'][$unit_id], |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | function qst_get_quests($user_id = false, $status = false) { |
142 | 142 | $quest_list = array(); |
143 | 143 | |
144 | - if($user_id) { |
|
145 | - if($status !== false) { |
|
144 | + if ($user_id) { |
|
145 | + if ($status !== false) { |
|
146 | 146 | $query_add_where = "AND qs.quest_status_status "; |
147 | - if($status == null) { |
|
147 | + if ($status == null) { |
|
148 | 148 | $query_add_where .= "IS NULL"; |
149 | 149 | } else { |
150 | 150 | $query_add_where .= "= {$status}"; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | $query = db_quest_list_get($query_add_select, $query_add_from, $query_add_where); |
158 | 158 | |
159 | - while($quest = db_fetch($query)) { |
|
159 | + while ($quest = db_fetch($query)) { |
|
160 | 160 | $quest_list[$quest['quest_id']] = qst_quest_parse($quest); |
161 | 161 | } |
162 | 162 | |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | } |
165 | 165 | |
166 | 166 | function qst_assign_to_template(&$template, $quest_templatized, $block_name = false) { |
167 | - if($block_name) { |
|
167 | + if ($block_name) { |
|
168 | 168 | $template->assign_block_vars($block_name, $quest_templatized); |
169 | 169 | } else { |
170 | 170 | $template->assign_vars($quest_templatized); |
171 | - if(!empty($quest_templatized['quest_rewards_list'])) { |
|
172 | - foreach($quest_templatized['quest_rewards_list'] as $quest_reward) { |
|
171 | + if (!empty($quest_templatized['quest_rewards_list'])) { |
|
172 | + foreach ($quest_templatized['quest_rewards_list'] as $quest_reward) { |
|
173 | 173 | $template->assign_block_vars(($block_name ? $block_name . '.' : '') . 'quest_rewards_list', $quest_reward); |
174 | 174 | } |
175 | 175 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | function qst_templatize($quest, $for_display = true) { |
188 | 188 | $tmp = array(); |
189 | - foreach($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) { |
|
189 | + foreach ($quest['quest_rewards_list'] as $quest_reward_id => $quest_reward_amount) { |
|
190 | 190 | $tmp[] = array( |
191 | 191 | 'ID' => $quest_reward_id, |
192 | 192 | 'NAME' => $for_display ? str_replace(' ', ' ', classLocale::$lang['tech'][$quest_reward_id]) : classLocale::$lang['tech'][$quest_reward_id], |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | |
212 | 212 | function qst_active_triggers($quest_list) { |
213 | 213 | $quest_triggers = array(); |
214 | - foreach($quest_list as $quest_id => $quest) { |
|
215 | - if($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) { |
|
214 | + foreach ($quest_list as $quest_id => $quest) { |
|
215 | + if ($quest['quest_status_status'] != QUEST_STATUS_COMPLETE) { |
|
216 | 216 | list($quest_unit_id, $quest_unit_amount) = explode(',', $quest['quest_conditions']); |
217 | 217 | $quest_triggers[$quest_id] = $quest_unit_id; |
218 | 218 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | function qst_reward(&$user, &$rewards, &$quest_list) { |
225 | - if(empty($rewards)) { |
|
225 | + if (empty($rewards)) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | $total_rewards = array(); |
233 | 233 | $comment_dm = ''; |
234 | 234 | |
235 | - foreach($rewards as $quest_id => $user_data) { |
|
236 | - foreach($user_data as $user_id => $planet_data) { |
|
237 | - foreach($planet_data as $planet_id => $reward_list) { |
|
235 | + foreach ($rewards as $quest_id => $user_data) { |
|
236 | + foreach ($user_data as $user_id => $planet_data) { |
|
237 | + foreach ($planet_data as $planet_id => $reward_list) { |
|
238 | 238 | $comment = sprintf(classLocale::$lang['qst_msg_complete_body'], $quest_list[$quest_id]['quest_name']); |
239 | 239 | $comment_dm .= isset($reward_list[RES_DARK_MATTER]) ? $comment : ''; |
240 | 240 | |
241 | 241 | $comment_reward = array(); |
242 | - foreach($reward_list as $unit_id => $unit_amount) { |
|
242 | + foreach ($reward_list as $unit_id => $unit_amount) { |
|
243 | 243 | $comment_reward[] = $unit_amount . ' ' . classLocale::$lang['tech'][$unit_id]; |
244 | 244 | $total_rewards[$user_id][$planet_id][$unit_id] += $unit_amount; |
245 | 245 | } |
@@ -258,19 +258,19 @@ discard block |
||
258 | 258 | |
259 | 259 | $group_resources = sn_get_groups('resources_loot'); |
260 | 260 | $quest_rewards_allowed = sn_get_groups('quest_rewards'); |
261 | - if(!empty($total_rewards)) { |
|
262 | - foreach($total_rewards as $user_id => $planet_data) { |
|
261 | + if (!empty($total_rewards)) { |
|
262 | + foreach ($total_rewards as $user_id => $planet_data) { |
|
263 | 263 | $user_row = classSupernova::db_get_record_by_id(LOC_USER, $user_id); |
264 | - foreach($planet_data as $planet_id => $unit_data) { |
|
264 | + foreach ($planet_data as $planet_id => $unit_data) { |
|
265 | 265 | $local_changeset = array(); |
266 | - foreach($unit_data as $unit_id => $unit_amount) { |
|
267 | - if(!isset($quest_rewards_allowed[$unit_id])) { |
|
266 | + foreach ($unit_data as $unit_id => $unit_amount) { |
|
267 | + if (!isset($quest_rewards_allowed[$unit_id])) { |
|
268 | 268 | continue; |
269 | 269 | } |
270 | 270 | |
271 | - if($unit_id == RES_DARK_MATTER) { |
|
271 | + if ($unit_id == RES_DARK_MATTER) { |
|
272 | 272 | rpg_points_change($user['id'], RPG_QUEST, $unit_amount, $comment_dm); |
273 | - } elseif(isset($group_resources[$unit_id])) { |
|
273 | + } elseif (isset($group_resources[$unit_id])) { |
|
274 | 274 | $local_changeset[pname_resource_name($unit_id)] = array('delta' => $unit_amount); |
275 | 275 | } else // Проверим на юниты |
276 | 276 | { |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | // unit |
280 | 280 | } |
281 | 281 | |
282 | - if(!empty($local_changeset)) { |
|
282 | + if (!empty($local_changeset)) { |
|
283 | 283 | $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id; |
284 | 284 | $db_changeset[$planet_id ? 'planets' : 'users'][] = array( |
285 | 285 | 'action' => SQL_OP_UPDATE, |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | $language_new = sys_get_param_str('langer', $user['lang']); |
14 | 14 | |
15 | - if($language_new != $user['lang']) { |
|
15 | + if ($language_new != $user['lang']) { |
|
16 | 16 | classLocale::$lang->lng_switch($language_new); |
17 | 17 | } |
18 | 18 | |
@@ -21,35 +21,35 @@ discard block |
||
21 | 21 | |
22 | 22 | $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE); |
23 | 23 | |
24 | - if(sys_get_param_str('mode') == 'change') { |
|
25 | - if($user['authlevel'] > 0) { |
|
24 | + if (sys_get_param_str('mode') == 'change') { |
|
25 | + if ($user['authlevel'] > 0) { |
|
26 | 26 | $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0; |
27 | 27 | db_planet_set_by_owner($user['id'], "`id_level` = '{$planet_protection}'"); |
28 | 28 | db_user_set_by_id($user['id'], "`admin_protection` = '{$planet_protection}'"); |
29 | 29 | $user['admin_protection'] = $planet_protection; |
30 | 30 | } |
31 | 31 | |
32 | - if(sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) { |
|
32 | + if (sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) { |
|
33 | 33 | sn_db_transaction_start(); |
34 | - if($user['authlevel'] < 3) { |
|
35 | - if($user['vacation_next'] > SN_TIME_NOW) { |
|
34 | + if ($user['authlevel'] < 3) { |
|
35 | + if ($user['vacation_next'] > SN_TIME_NOW) { |
|
36 | 36 | message(classLocale::$lang['opt_vacation_err_timeout'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
37 | 37 | die(); |
38 | 38 | } |
39 | 39 | |
40 | - if(FleetList::fleet_count_flying($user['id'])) { |
|
40 | + if (FleetList::fleet_count_flying($user['id'])) { |
|
41 | 41 | message(classLocale::$lang['opt_vacation_err_your_fleet'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
42 | 42 | die(); |
43 | 43 | } |
44 | 44 | |
45 | 45 | $que = que_get($user['id'], false); |
46 | - if(!empty($que)) { |
|
46 | + if (!empty($que)) { |
|
47 | 47 | message(classLocale::$lang['opt_vacation_err_que'], classLocale::$lang['Error'], 'index.php?page=options', 5); |
48 | 48 | die(); |
49 | 49 | } |
50 | 50 | |
51 | 51 | $query = classSupernova::db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}"); |
52 | - foreach($query as $planet) { |
|
52 | + foreach ($query as $planet) { |
|
53 | 53 | // $planet = sys_o_get_updated($user, $planet, SN_TIME_NOW); |
54 | 54 | // $planet = $planet['planet']; |
55 | 55 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | sn_db_transaction_commit(); |
69 | 69 | } |
70 | 70 | |
71 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
72 | - foreach($option_group as $option_name => $option_value) { |
|
73 | - if($user[$option_name] !== null) { |
|
71 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
72 | + foreach ($option_group as $option_name => $option_value) { |
|
73 | + if ($user[$option_name] !== null) { |
|
74 | 74 | $user[$option_name] = sys_get_param_str($option_name); |
75 | 75 | } else { |
76 | 76 | $user[$option_name] = $option_value; |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | |
82 | 82 | |
83 | 83 | $player_options = sys_get_param('options'); |
84 | - if(!empty($player_options)) { |
|
85 | - array_walk($player_options, function (&$value) { |
|
84 | + if (!empty($player_options)) { |
|
85 | + array_walk($player_options, function(&$value) { |
|
86 | 86 | // TODO - Когда будет больше параметров - сделать больше проверок |
87 | 87 | $value = intval($value); |
88 | 88 | }); |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | |
94 | 94 | $username = substr(sys_get_param_str_unsafe('username'), 0, 32); |
95 | 95 | $username_safe = db_escape($username); |
96 | - if($username && $user['username'] != $username && classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
96 | + if ($username && $user['username'] != $username && classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
97 | 97 | // проверка на корректность |
98 | 98 | sn_db_transaction_start(); |
99 | 99 | $name_check = db_player_name_history_get_name_by_name($username_safe); |
100 | - if(!$name_check || $name_check['player_id'] == $user['id']) { |
|
100 | + if (!$name_check || $name_check['player_id'] == $user['id']) { |
|
101 | 101 | $user = db_user_by_id($user['id'], true); |
102 | - switch(classSupernova::$config->game_user_changename) { |
|
102 | + switch (classSupernova::$config->game_user_changename) { |
|
103 | 103 | case SERVER_PLAYER_NAME_CHANGE_PAY: |
104 | - if(mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) { |
|
104 | + if (mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) { |
|
105 | 105 | $template_result['.']['result'][] = array( |
106 | 106 | 'STATUS' => ERR_ERROR, |
107 | 107 | 'MESSAGE' => classLocale::$lang['opt_msg_name_change_err_no_dm'], |
@@ -131,18 +131,18 @@ discard block |
||
131 | 131 | sn_db_transaction_commit(); |
132 | 132 | } |
133 | 133 | |
134 | - if($new_password = sys_get_param('newpass1')) { |
|
134 | + if ($new_password = sys_get_param('newpass1')) { |
|
135 | 135 | try { |
136 | - if($new_password != sys_get_param('newpass2')) { |
|
136 | + if ($new_password != sys_get_param('newpass2')) { |
|
137 | 137 | throw new Exception(classLocale::$lang['opt_err_pass_unmatched'], ERR_WARNING); |
138 | 138 | } |
139 | 139 | |
140 | - if(!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { |
|
140 | + if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) { |
|
141 | 141 | throw new Exception(classLocale::$lang['opt_err_pass_wrong'], ERR_WARNING); |
142 | 142 | } |
143 | 143 | |
144 | 144 | throw new Exception(classLocale::$lang['opt_msg_pass_changed'], ERR_NONE); |
145 | - } catch(Exception $e) { |
|
145 | + } catch (Exception $e) { |
|
146 | 146 | $template_result['.']['result'][] = array( |
147 | 147 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
148 | 148 | 'MESSAGE' => $e->getMessage() |
@@ -164,12 +164,12 @@ discard block |
||
164 | 164 | $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender']; |
165 | 165 | |
166 | 166 | try { |
167 | - if($user['birthday']) { |
|
167 | + if ($user['birthday']) { |
|
168 | 168 | throw new exception(); |
169 | 169 | } |
170 | 170 | |
171 | 171 | $user_birthday = sys_get_param_str_unsafe('user_birthday'); |
172 | - if(!$user_birthday || $user_birthday == $FMT_DATE) { |
|
172 | + if (!$user_birthday || $user_birthday == $FMT_DATE) { |
|
173 | 173 | throw new exception(); |
174 | 174 | } |
175 | 175 | |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | $pos['Y'] = strpos(FMT_DATE, 'Y'); |
180 | 180 | asort($pos); |
181 | 181 | $i = 0; |
182 | - foreach($pos as &$position) { |
|
182 | + foreach ($pos as &$position) { |
|
183 | 183 | $position = ++$i; |
184 | 184 | } |
185 | 185 | |
186 | 186 | $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/"; |
187 | - if(!preg_match($regexp, $user_birthday, $match)) { |
|
187 | + if (!preg_match($regexp, $user_birthday, $match)) { |
|
188 | 188 | throw new exception(); |
189 | 189 | } |
190 | 190 | |
191 | - if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { |
|
191 | + if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) { |
|
192 | 192 | throw new exception(); |
193 | 193 | } |
194 | 194 | |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format |
197 | 197 | |
198 | 198 | $year = date('Y', SN_TIME_NOW); |
199 | - if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { |
|
199 | + if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) { |
|
200 | 200 | $year--; |
201 | 201 | } |
202 | 202 | $user['user_birthday_celebrated'] = db_escape("{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}"); |
203 | 203 | |
204 | 204 | $user_birthday = ", `user_birthday` = '{$user['user_birthday']}', `user_birthday_celebrated` = '{$user['user_birthday_celebrated']}'"; |
205 | - } catch(exception $e) { |
|
205 | + } catch (exception $e) { |
|
206 | 206 | $user_birthday = ''; |
207 | 207 | } |
208 | 208 | |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | $template_result['.']['result'][] = $avatar_upload_result; |
213 | 213 | |
214 | 214 | $user_time_diff = playerTimeDiff::user_time_diff_get(); |
215 | - if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { |
|
215 | + if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) { |
|
216 | 216 | playerTimeDiff::user_time_diff_set(array( |
217 | 217 | PLAYER_OPTION_TIME_DIFF => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'), |
218 | 218 | PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, |
219 | 219 | PLAYER_OPTION_TIME_DIFF_FORCED => 1, |
220 | 220 | PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL, |
221 | 221 | )); |
222 | - } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
222 | + } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) { |
|
223 | 223 | playerTimeDiff::user_time_diff_set(array( |
224 | 224 | PLAYER_OPTION_TIME_DIFF => '', |
225 | 225 | PLAYER_OPTION_TIME_DIFF_UTC_OFFSET => 0, |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | 'STATUS' => ERR_NONE, |
240 | 240 | 'MESSAGE' => classLocale::$lang['opt_msg_saved'] |
241 | 241 | ); |
242 | - } elseif(sys_get_param_str('result') == 'ok') { |
|
242 | + } elseif (sys_get_param_str('result') == 'ok') { |
|
243 | 243 | $template_result['.']['result'][] = array( |
244 | 244 | 'STATUS' => ERR_NONE, |
245 | 245 | 'MESSAGE' => classLocale::$lang['opt_msg_saved'] |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | $template = gettemplate('options', $template); |
264 | 264 | |
265 | 265 | $dir = dir(SN_ROOT_PHYSICAL . 'skins'); |
266 | - while(($entry = $dir->read()) !== false) { |
|
267 | - if(is_dir("skins/{$entry}") && $entry[0] != '.') { |
|
266 | + while (($entry = $dir->read()) !== false) { |
|
267 | + if (is_dir("skins/{$entry}") && $entry[0] != '.') { |
|
268 | 268 | $template_result['.']['skin_list'][] = array( |
269 | 269 | 'VALUE' => $entry, |
270 | 270 | 'NAME' => $entry, |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | } |
275 | 275 | $dir->close(); |
276 | 276 | |
277 | - foreach(classLocale::$lang['opt_planet_sort_options'] as $key => &$value) { |
|
277 | + foreach (classLocale::$lang['opt_planet_sort_options'] as $key => &$value) { |
|
278 | 278 | $template_result['.']['planet_sort_options'][] = array( |
279 | 279 | 'VALUE' => $key, |
280 | 280 | 'NAME' => $value, |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | ); |
283 | 283 | } |
284 | 284 | |
285 | - foreach(classLocale::$lang['sys_gender_list'] as $key => $value) { |
|
285 | + foreach (classLocale::$lang['sys_gender_list'] as $key => $value) { |
|
286 | 286 | $template_result['.']['gender_list'][] = array( |
287 | 287 | 'VALUE' => $key, |
288 | 288 | 'NAME' => $value, |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | } |
292 | 292 | |
293 | 293 | $lang_list = lng_get_list(); |
294 | - foreach($lang_list as $lang_id => $lang_data) { |
|
294 | + foreach ($lang_list as $lang_id => $lang_data) { |
|
295 | 295 | $template_result['.']['languages'][] = array( |
296 | 296 | 'VALUE' => $lang_id, |
297 | 297 | 'NAME' => $lang_data['LANG_NAME_NATIVE'], |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | |
303 | - if(isset(classLocale::$lang['menu_customize_show_hide_button_state'])) { |
|
304 | - foreach(classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) { |
|
303 | + if (isset(classLocale::$lang['menu_customize_show_hide_button_state'])) { |
|
304 | + foreach (classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) { |
|
305 | 305 | $template->assign_block_vars('menu_customize_show_hide_button_state', array( |
306 | 306 | 'ID' => $key, |
307 | 307 | 'NAME' => $value, |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | 'PAGE_HEADER' => classLocale::$lang['opt_header'], |
409 | 409 | )); |
410 | 410 | |
411 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
412 | - if($option_group_id == OPT_MESSAGE) { |
|
413 | - foreach($sn_message_class_list as $message_class_id => $message_class_data) { |
|
414 | - if($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) { |
|
411 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
412 | + if ($option_group_id == OPT_MESSAGE) { |
|
413 | + foreach ($sn_message_class_list as $message_class_id => $message_class_data) { |
|
414 | + if ($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) { |
|
415 | 415 | $option_name = $message_class_data['name']; |
416 | 416 | |
417 | 417 | $template->assign_block_vars("options_{$option_group_id}", array( |
@@ -423,8 +423,8 @@ discard block |
||
423 | 423 | } |
424 | 424 | } |
425 | 425 | } else { |
426 | - foreach($option_group as $option_name => $option_value) { |
|
427 | - if(array_key_exists($option_name, $user_option_types)) { |
|
426 | + foreach ($option_group as $option_name => $option_value) { |
|
427 | + if (array_key_exists($option_name, $user_option_types)) { |
|
428 | 428 | $option_type = $user_option_types[$option_name]; |
429 | 429 | } else { |
430 | 430 | $option_type = 'switch'; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS; |
37 | 37 | |
38 | 38 | $mode = sys_get_param_int('mode'); |
39 | - switch($mode) { |
|
39 | + switch ($mode) { |
|
40 | 40 | case CHAT_MODE_ALLY: |
41 | 41 | $template_result['ALLY'] = intval($user['ally_id']); |
42 | 42 | $page_title = classLocale::$lang['chat_ally']; |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | $template_result['.']['smiles'] = array(); |
52 | - foreach($supernova->design['smiles'] as $auth_level => $replaces) { |
|
53 | - if($auth_level > $user_auth_level) { |
|
52 | + foreach ($supernova->design['smiles'] as $auth_level => $replaces) { |
|
53 | + if ($auth_level > $user_auth_level) { |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | - foreach($replaces as $bbcode => $filename) { |
|
57 | + foreach ($replaces as $bbcode => $filename) { |
|
58 | 58 | $template_result['.']['smiles'][] = array( |
59 | 59 | 'BBCODE' => $bbcode, |
60 | 60 | 'FILENAME' => $filename, |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | define('IN_AJAX', true); |
78 | 78 | $skip_fleet_update = true; |
79 | 79 | |
80 | - if(classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
80 | + if (classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
81 | 81 | die(); |
82 | 82 | } |
83 | 83 | |
84 | - if(($message = sys_get_param_str('message')) && $user['username']) { |
|
84 | + if (($message = sys_get_param_str('message')) && $user['username']) { |
|
85 | 85 | $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0; |
86 | 86 | $nick = db_escape(player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id)))); |
87 | 87 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $skip_fleet_update = true; |
104 | 104 | |
105 | 105 | $history = sys_get_param_str('history'); |
106 | - if(!$history) { |
|
106 | + if (!$history) { |
|
107 | 107 | classSupernova::$config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO); |
108 | 108 | } |
109 | 109 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $last_message = ''; |
112 | 112 | $alliance = 0; |
113 | 113 | $template_result['.']['chat'] = array(); |
114 | - if(!$history && classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
114 | + if (!$history && classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) { |
|
115 | 115 | $result['disable'] = true; |
116 | 116 | $template_result['.']['chat'][] = array( |
117 | 117 | 'TIME' => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')), |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | |
125 | 125 | $where_add = ''; |
126 | 126 | $last_message = 0; |
127 | - if($history) { |
|
127 | + if ($history) { |
|
128 | 128 | $rows = db_chat_message_count_by_ally($alliance); |
129 | 129 | $page_count = ceil($rows['CNT'] / $page_limit); |
130 | 130 | |
131 | - for($i = 0; $i < $page_count; $i++) { |
|
131 | + for ($i = 0; $i < $page_count; $i++) { |
|
132 | 132 | $template_result['.']['page'][] = array( |
133 | 133 | 'NUMBER' => $i |
134 | 134 | ); |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | |
143 | 143 | $start_row = $page * $page_limit; |
144 | 144 | $query = db_chat_message_get_page($alliance, $where_add, $start_row, $page_limit); |
145 | - while($chat_row = db_fetch($query)) { |
|
145 | + while ($chat_row = db_fetch($query)) { |
|
146 | 146 | // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick |
147 | 147 | $chat_row['user'] = player_nick_render_to_html($chat_row['user']); |
148 | 148 | $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8'); |
149 | 149 | $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']); |
150 | - if(!$history) { |
|
150 | + if (!$history) { |
|
151 | 151 | $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>"; |
152 | 152 | } |
153 | 153 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $template = gettemplate('chat_messages', $template); |
173 | 173 | $template->assign_recursive($template_result); |
174 | 174 | |
175 | - if($history) { |
|
175 | + if ($history) { |
|
176 | 176 | display($template, "{$classLocale['chat_history']} - {$classLocale[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true); |
177 | 177 | } else { |
178 | 178 | $result['last_message'] = $last_message; |