Completed
Push — work-fleets ( 5b06a4...37e31f )
by SuperNova.WS
04:49
created
includes/classes/Player.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -229,8 +229,8 @@
 block discarded – undo
229 229
   public function calcColonyMaxCount($astrotech = -1) {
230 230
     global $config;
231 231
 
232
-    if($astrotech == -1) {
233
-      if(!isset($this->db_row[UNIT_PLAYER_COLONIES_MAX])) {
232
+    if ($astrotech == -1) {
233
+      if (!isset($this->db_row[UNIT_PLAYER_COLONIES_MAX])) {
234 234
 
235 235
         $expeditions = get_player_max_expeditons($this->db_row);
236 236
         $astrotech = mrc_get_level($this->db_row, false, TECH_ASTROTECH);
Please login to merge, or discard this patch.
includes/classes/PlayerList.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
    * @version 41a6.16
24 24
    */
25 25
   protected function db_load_player_by_id($player_id) {
26
-    if(isset($this[$player_id])) {
26
+    if (isset($this[$player_id])) {
27 27
       return;
28 28
     }
29 29
 
Please login to merge, or discard this patch.
includes/classes/db_mysql_v5.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
 
31 31
     static $need_keys = array('server', 'user', 'pass', 'name', 'prefix');
32 32
 
33
-    if($this->connected) {
33
+    if ($this->connected) {
34 34
       return true;
35 35
     }
36 36
 
37
-    if(empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) {
37
+    if (empty($settings) || !is_array($settings) || array_intersect($need_keys, array_keys($settings)) != $need_keys) {
38 38
       $debug->error_fatal('There is missconfiguration in your config.php. Check it again');
39 39
     }
40 40
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     return mysqli_real_escape_string($this->link, $unescaped_string);
91 91
   }
92 92
   function mysql_close_link() {
93
-    if(is_object($this->link)) {
93
+    if (is_object($this->link)) {
94 94
       $this->link->close();
95 95
       $this->connected = false;
96 96
       unset($this->link);
Please login to merge, or discard this patch.
blitz_register.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@  discard block
 block discarded – undo
2 2
 
3 3
 include('common.' . substr(strrchr(__FILE__, '.'), 1));
4 4
 
5
-if($user['authlevel'] < AUTH_LEVEL_DEVELOPER) {
5
+if ($user['authlevel'] < AUTH_LEVEL_DEVELOPER) {
6 6
   $error_message = $config->game_mode == GAME_BLITZ ? 'sys_blitz_page_disabled' : (
7 7
   !$config->game_blitz_register ? 'sys_blitz_registration_disabled' : ''
8 8
   );
9 9
 
10
-  if($error_message) {
10
+  if ($error_message) {
11 11
     message($lang[$error_message], $lang['sys_error'], 'overview.php', 10);
12 12
     die();
13 13
   }
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
 $current_round = intval($config->db_loadItem('game_blitz_register_round'));
27 27
 $current_price = intval($config->db_loadItem('game_blitz_register_price'));
28 28
 
29
-if($config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) {
29
+if ($config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) {
30 30
   sn_db_transaction_start();
31 31
   $user = db_user_by_id($user['id'], true);
32 32
   $is_registered = db_blitz_reg_get_id_by_player_and_round($user, $current_round);
33
-  if(sys_get_param_str('register_me')) {
34
-    if(empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) {
33
+  if (sys_get_param_str('register_me')) {
34
+    if (empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) {
35 35
       db_blitz_reg_insert($user, $current_round);
36 36
       classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица");
37 37
     }
38
-  } elseif(sys_get_param_str('register_me_not') && !empty($is_registered)) {
38
+  } elseif (sys_get_param_str('register_me_not') && !empty($is_registered)) {
39 39
     db_blitz_reg_delete($user, $current_round);
40 40
     classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION_CANCEL, $current_price, "Отмена регистрации в раунде {$current_round} Блица");
41 41
   }
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
 $blitz_players = 0;
51 51
 $blitz_prize_dark_matter = 0;
52 52
 $blitz_prize_places = 0;
53
-if($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) {
54
-  if(sys_get_param_str('generate')) {
53
+if ($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) {
54
+  if (sys_get_param_str('generate')) {
55 55
     $next_id = 0;
56 56
     $query = db_blitz_reg_get_random_id($current_round);
57
-    while($row = db_fetch($query)) {
57
+    while ($row = db_fetch($query)) {
58 58
       $next_id++;
59 59
       $blitz_name = 'Игрок' . $next_id;
60 60
       $blitz_password = sys_random_string(8);
61 61
       db_blitz_reg_update_with_name_and_password($blitz_name, $blitz_password, $row, $current_round);
62 62
     }
63
-  } elseif(sys_get_param_str('import_generated')) {
63
+  } elseif (sys_get_param_str('import_generated')) {
64 64
     // ЭТО НА БЛИЦЕ!!!
65 65
     db_player_list_blitz_delete_players();
66 66
     db_planets_purge();
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     $system = $system_step;
83 83
     $planet = round($config->game_maxPlanet / 2);
84 84
 
85
-    foreach($imported_string as &$string_data) {
85
+    foreach ($imported_string as &$string_data) {
86 86
       $string_data = explode(',', $string_data);
87 87
       $username_safe = $string_data[0];
88 88
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 
103 103
       $moon_row = uni_create_moon($galaxy, $system, $planet, $user_new['id'], 30, '', false);
104 104
 
105
-      if(($system += $system_step) >= $config->game_maxSystem) {
105
+      if (($system += $system_step) >= $config->game_maxSystem) {
106 106
         $galaxy++;
107 107
         $system = $system_step;
108 108
       }
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
     $config->db_saveItem('users_amount', $config->users_amount + $new_players);
113 113
     // pdump($imported_string);
114 114
     // generated_string
115
-  } elseif(sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) {
115
+  } elseif (sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) {
116 116
     $blitz_result = explode(';', $blitz_result_string);
117 117
     $blitz_last_update = $blitz_result[0]; // Пока не используется
118 118
     unset($blitz_result[0]);
119
-    foreach($blitz_result as $blitz_result_data) {
119
+    foreach ($blitz_result as $blitz_result_data) {
120 120
       $blitz_result_data = explode(',', $blitz_result_data);
121
-      if(count($blitz_result_data) == 5) {
121
+      if (count($blitz_result_data) == 5) {
122 122
         $blitz_result_data[1] = db_escape($blitz_result_data[1]);
123 123
         db_blitz_reg_update_results($blitz_result_data, $current_round);
124 124
       }
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
     $blitz_result = array();
127 127
   }
128 128
 
129
-  if($config->game_mode == GAME_BLITZ) {
129
+  if ($config->game_mode == GAME_BLITZ) {
130 130
     $blitz_result = array($config->db_loadItem('var_stat_update'));
131 131
     $query = db_player_list_export_blitz_info();
132
-    while($row = db_fetch($query)) {
132
+    while ($row = db_fetch($query)) {
133 133
       $blitz_result[] = "{$row['id']},{$row['username']},{$row['onlinetime']},{$row['total_rank']},{$row['total_points']}";
134 134
     }
135 135
   } else {
136 136
     $query = db_blitz_reg_get_player_list($current_round);
137
-    while($row = db_fetch($query)) {
137
+    while ($row = db_fetch($query)) {
138 138
       $blitz_generated[] = "{$row['blitz_name']},{$row['blitz_password']}";
139 139
       $row['blitz_online'] ? $blitz_prize_players_active++ : false;
140 140
       $blitz_players++;
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
     $blitz_prize_dark_matter = $blitz_prize_players_active * 20000;
143 143
     $blitz_prize_places = ceil($blitz_prize_players_active / 5);
144 144
 
145
-    if(sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) {
145
+    if (sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) {
146 146
       // $blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter');
147 147
       $blitz_prize_places_actual = sys_get_param_int('blitz_prize_places');
148 148
       sn_db_transaction_start();
149 149
       $query = db_blitz_reg_get_player_list_order_by_place($current_round);
150
-      while($row = db_fetch($query)) {
151
-        if(!$row['blitz_place']) {
150
+      while ($row = db_fetch($query)) {
151
+        if (!$row['blitz_place']) {
152 152
           continue;
153 153
         }
154 154
 
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 
158 158
         $reward = $blitz_prize_dark_matter_actual - $row['blitz_reward_dark_matter'];
159 159
         pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}", $row['id']);
160
-        if($reward) {
160
+        if ($reward) {
161 161
           rpg_points_change($row['user_id'], RPG_BLITZ, $reward, sprintf(
162 162
             $lang['sys_blitz_reward_log_message'], $row['blitz_place'], $row['blitz_name']
163 163
           ));
164 164
           db_blitz_reg_update_apply_results($reward, $row, $current_round);
165 165
         }
166 166
 
167
-        if(!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
167
+        if (!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
168 168
           break;
169 169
         }
170 170
       }
@@ -179,12 +179,12 @@  discard block
 block discarded – undo
179 179
 
180 180
 $player_registered = false;
181 181
 $query = db_blitz_reg_get_player_list_and_users($current_round);
182
-while($row = db_fetch($query)) {
182
+while ($row = db_fetch($query)) {
183 183
   $tpl_player_data = array(
184 184
     'NAME' => player_nick_render_to_html($row, array('icons' => true, 'color' => true, 'ally' => true)),
185 185
   );
186 186
 
187
-  if($config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) {
187
+  if ($config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) {
188 188
     // Вот так хитро, что бы не было не единого шанса попадания на страницу данных об игроках Блиц-сервера до закрытия раунда
189 189
     $tpl_player_data = array_merge($tpl_player_data, array(
190 190
       'ID'                       => $row['id'],
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
   }
198 198
 
199 199
   $template->assign_block_vars('registrations', $tpl_player_data);
200
-  if($row['id'] == $user['id']) {
200
+  if ($row['id'] == $user['id']) {
201 201
     $player_registered = $row;
202 202
   }
203 203
 }
Please login to merge, or discard this patch.
includes/init_secondary.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if($config->server_updater_check_auto && $config->server_updater_check_last + $config->server_updater_check_period <= SN_TIME_NOW) {
3
+if ($config->server_updater_check_auto && $config->server_updater_check_last + $config->server_updater_check_period <= SN_TIME_NOW) {
4 4
   include(SN_ROOT_PHYSICAL . 'ajax_version_check' . DOT_PHP_EX);
5 5
 }
6 6
 
7
-if($config->user_birthday_gift && SN_TIME_NOW - $config->user_birthday_celebrate > PERIOD_DAY) {
7
+if ($config->user_birthday_gift && SN_TIME_NOW - $config->user_birthday_celebrate > PERIOD_DAY) {
8 8
   require_once(SN_ROOT_PHYSICAL . "includes/includes/user_birthday_celebrate" . DOT_PHP_EX);
9 9
   sn_user_birthday_celebrate();
10 10
 }
11 11
 
12
-if(!$config->var_online_user_count || $config->var_online_user_time + 30 < SN_TIME_NOW) {
12
+if (!$config->var_online_user_count || $config->var_online_user_time + 30 < SN_TIME_NOW) {
13 13
   $config->db_saveItem('var_online_user_count', db_user_count(true));
14 14
   $config->db_saveItem('var_online_user_time', SN_TIME_NOW);
15
-  if($config->server_log_online) {
15
+  if ($config->server_log_online) {
16 16
     db_log_online_insert();
17 17
   }
18 18
 }
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id'];
43 43
 //pdump($template_result[F_ACCOUNT_IS_AUTHORIZED]);die();
44 44
 
45
-if(!empty($user['id'])) {
45
+if (!empty($user['id'])) {
46 46
   classSupernova::$user_options->user_change($user['id']);
47 47
 }
48 48
 
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
     : false
56 56
   );
57 57
 
58
-if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
59
-  $prohibited_characters = array_map(function ($value) {
58
+if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
59
+  $prohibited_characters = array_map(function($value) {
60 60
     return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
61 61
   }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
62 62
   $template_result[F_LOGIN_MESSAGE] .= implode(', ', $prohibited_characters);
63 63
 }
64 64
 
65 65
 
66
-if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
66
+if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
67 67
   pdump("Отключи отладку перед продакшном!");
68 68
 }
69 69
 
@@ -77,17 +77,17 @@  discard block
 block discarded – undo
77 77
   ? define('INSTALL_MODE', GAME_DISABLE_INSTALL)
78 78
   : false;
79 79
 
80
-if($template_result[F_GAME_DISABLE] = $config->game_disable) {
80
+if ($template_result[F_GAME_DISABLE] = $config->game_disable) {
81 81
   $template_result[F_GAME_DISABLE_REASON] = sys_bbcodeParse(
82 82
     $config->game_disable == GAME_DISABLE_REASON
83 83
       ? $config->game_disable_reason
84 84
       : $lang['sys_game_disable_reason'][$config->game_disable]
85 85
   );
86
-  if(defined('IN_API')) {
86
+  if (defined('IN_API')) {
87 87
     return;
88 88
   }
89 89
 
90
-  if(
90
+  if (
91 91
     ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN))
92 92
     &&
93 93
     !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT'))
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 
101 101
 // TODO ban
102 102
 // TODO $skip_ban_check
103
-if($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
104
-  if(defined('IN_API')) {
103
+if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
104
+  if (defined('IN_API')) {
105 105
     return;
106 106
   }
107 107
 
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 // pdump($allow_anonymous, '$allow_anonymous');
120 120
 // pdump($sys_user_logged_in, '$sys_user_logged_in');
121 121
 
122
-if($sys_user_logged_in && INITIAL_PAGE == 'login') {
122
+if ($sys_user_logged_in && INITIAL_PAGE == 'login') {
123 123
   sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
124
-} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
124
+} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
125 125
 //  pdump($sn_page_name);
126 126
 //  pdump(INITIAL_PAGE);
127 127
 //  die('{Тут должна быть ваша реклама. Точнее - ввод имени игрока}');
128
-} elseif(!$allow_anonymous && !$sys_user_logged_in) {
128
+} elseif (!$allow_anonymous && !$sys_user_logged_in) {
129 129
   // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
130 130
   sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
131 131
 }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 global $skip_fleet_update;
148 148
 $skip_fleet_update = $skip_fleet_update || $supernova->options['fleet_update_skip'] || defined('IN_ADMIN');
149
-if(
149
+if (
150 150
   !$skip_fleet_update
151 151
   && !(defined('IN_AJAX') && IN_AJAX === true)
152 152
   && SN_TIME_NOW - strtotime($config->fleet_update_last) > $config->fleet_update_interval
Please login to merge, or discard this patch.
includes/classes/Unit.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -154,15 +154,15 @@  discard block
 block discarded – undo
154 154
    * @param string $group_name
155 155
    */
156 156
   public static function _init($group_name = '') {
157
-    if(static::$_is_static_init) {
157
+    if (static::$_is_static_init) {
158 158
       return;
159 159
     }
160 160
 
161
-    if($group_name) {
161
+    if ($group_name) {
162 162
       static::$_sn_group_name = $group_name;
163 163
     }
164 164
 
165
-    if(static::$_sn_group_name) {
165
+    if (static::$_sn_group_name) {
166 166
       static::$_group_unit_id_list = sn_get_groups(static::$_sn_group_name);
167 167
       empty(static::$_group_unit_id_list) ? static::$_group_unit_id_list = array() : false;
168 168
     }
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     // TODO - Reset combat stats??
188 188
     $this->_unitId = $unitId;
189 189
 
190
-    if($this->_unitId) {
190
+    if ($this->_unitId) {
191 191
       $this->info = get_unit_param($this->_unitId);
192 192
       $this->_type = $this->info[P_UNIT_TYPE];
193 193
     } else {
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 
199 199
   protected function setCount($value) {
200 200
     // TODO - Reset combat stats??
201
-    if($value < 0) {
201
+    if ($value < 0) {
202 202
       classSupernova::$debug->error('Can not set Unit::$count to negative value');
203 203
     }
204 204
     $this->_count = $value;
Please login to merge, or discard this patch.
includes/classes/DBRow.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 
132 132
     // If method is not getter or setter OR property name not exists in $_properties - raising exception
133 133
     // Descendants can catch this Exception to make own __call magic
134
-    if(($left3 != 'get' && $left3 != 'set') || empty(static::$_properties[$propertyName])) {
134
+    if (($left3 != 'get' && $left3 != 'set') || empty(static::$_properties[$propertyName])) {
135 135
       throw new ExceptionPropertyNotExists('Property ' . $propertyName . ' not exists when calling getter/setter ' . get_called_class() . '::' . $name, ERR_ERROR);
136 136
     }
137 137
 
138 138
     // TODO check for read-only
139 139
 
140
-    if($left3 == 'set') {
141
-      if(!empty($this->propertiesAdjusted[$propertyName])) {
140
+    if ($left3 == 'set') {
141
+      if (!empty($this->propertiesAdjusted[$propertyName])) {
142 142
         throw new PropertyAccessException('Property ' . $propertyName . ' already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::' . $name, ERR_ERROR);
143 143
       }
144 144
       $this->propertiesChanged[$propertyName] = 1;
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
     // Now deciding - will we call a protected setter or will we work with protected property
148 148
 
149 149
     // If method exists - just calling it
150
-    if(method_exists($this, $name)) {
150
+    if (method_exists($this, $name)) {
151 151
       return call_user_func_array(array($this, $name), $arguments);
152 152
     }
153 153
     // No getter/setter exists - works directly with protected property
154 154
 
155 155
     // Is it getter?
156
-    if($left3 === 'get') {
156
+    if ($left3 === 'get') {
157 157
       return $this->{'_' . $propertyName};
158 158
     }
159 159
 
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 //    $this->_reset();
175 175
 
176 176
     $dbId = idval($dbId);
177
-    if($dbId <= 0) {
177
+    if ($dbId <= 0) {
178 178
       classSupernova::$debug->error(get_called_class() . '::dbLoad $dbId not positive = ' . $dbId);
179 179
 
180 180
       return;
181 181
     }
182 182
 
183 183
     $db_row = doquery("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $dbId . " LIMIT 1 FOR UPDATE;", true);
184
-    if(empty($db_row)) {
184
+    if (empty($db_row)) {
185 185
       return;
186 186
     }
187 187
 
@@ -197,26 +197,26 @@  discard block
 block discarded – undo
197 197
    */
198 198
   // TODO - perform operations only if properties was changed
199 199
   public function dbSave() {
200
-    if($this->isNew()) {
200
+    if ($this->isNew()) {
201 201
       // No DB_ID - new unit
202
-      if($this->isEmpty()) {
202
+      if ($this->isEmpty()) {
203 203
         classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave');
204 204
       }
205 205
       $this->dbInsert();
206 206
     } else {
207 207
       // DB_ID is present
208
-      if($this->isEmpty()) {
208
+      if ($this->isEmpty()) {
209 209
         $this->dbDelete();
210 210
       } else {
211
-        if(!sn_db_transaction_check(false)) {
211
+        if (!sn_db_transaction_check(false)) {
212 212
           classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate');
213 213
         }
214 214
         $this->dbUpdate();
215 215
       }
216 216
     }
217 217
 
218
-    if(!empty($this->triggerDbOperationOn)) {
219
-      foreach($this->triggerDbOperationOn as $item) {
218
+    if (!empty($this->triggerDbOperationOn)) {
219
+      foreach ($this->triggerDbOperationOn as $item) {
220 220
         $item->dbSave();
221 221
       }
222 222
     }
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
    * @return int|string
236 236
    */
237 237
   public function dbInsert() {
238
-    if(!$this->isNew()) {
238
+    if (!$this->isNew()) {
239 239
       classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert');
240 240
     }
241 241
     $this->_dbId = $this->db_field_set_create($this->dbMakeFieldSet());
242 242
 
243
-    if(empty($this->_dbId)) {
243
+    if (empty($this->_dbId)) {
244 244
       classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert');
245 245
     }
246 246
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
    */
253 253
   public function dbUpdate() {
254 254
     // TODO - Update
255
-    if($this->isNew()) {
255
+    if ($this->isNew()) {
256 256
       classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate');
257 257
     }
258 258
     $this->db_field_update($this->dbMakeFieldSet(true));
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
    * Deletes record from DB
263 263
    */
264 264
   public function dbDelete() {
265
-    if($this->isNew()) {
265
+    if ($this->isNew()) {
266 266
       classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete');
267 267
     }
268 268
     doquery("DELETE FROM {{" . static::$_table . "}} WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId);
@@ -304,18 +304,18 @@  discard block
 block discarded – undo
304 304
    * @param array $db_row
305 305
    */
306 306
   public function dbRowParse(array $db_row) {
307
-    foreach(static::$_properties as $property_name => &$property_data) {
307
+    foreach (static::$_properties as $property_name => &$property_data) {
308 308
       // Advanced values extraction procedure. Should be used when at least one of following rules is matched:
309 309
       // - one field should translate to several properties;
310 310
       // - one property should be filled according to several fields;
311 311
       // - property filling requires some lookup in object values;
312
-      if(!empty($property_data[P_METHOD_EXTRACT]) && is_callable(array($this, $property_data[P_METHOD_EXTRACT]))) {
312
+      if (!empty($property_data[P_METHOD_EXTRACT]) && is_callable(array($this, $property_data[P_METHOD_EXTRACT]))) {
313 313
         call_user_func_array(array($this, $property_data[P_METHOD_EXTRACT]), array(&$db_row));
314 314
         continue;
315 315
       }
316 316
 
317 317
       // If property is read-only - doing nothing
318
-      if(!empty($property_data[P_READ_ONLY])) {
318
+      if (!empty($property_data[P_READ_ONLY])) {
319 319
         continue;
320 320
       }
321 321
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
       !empty($property_data[P_FUNC_INPUT]) && is_callable($property_data[P_FUNC_INPUT]) ? $value = call_user_func($property_data[P_FUNC_INPUT], $value) : false;
327 327
 
328 328
       // If there is setter for this field - using it. Setters is always a methods of $THIS
329
-      if(!empty($property_data[P_METHOD_SET]) && is_callable(array($this, $property_data[P_METHOD_SET]))) {
329
+      if (!empty($property_data[P_METHOD_SET]) && is_callable(array($this, $property_data[P_METHOD_SET]))) {
330 330
         call_user_func(array($this, $property_data[P_METHOD_SET]), $value);
331 331
       } else {
332 332
         $this->{$property_name} = $value;
@@ -342,21 +342,21 @@  discard block
 block discarded – undo
342 342
   protected function dbMakeFieldSet($isUpdate = false) {
343 343
     $array = array();
344 344
 
345
-    foreach(static::$_properties as $property_name => &$property_data) {
345
+    foreach (static::$_properties as $property_name => &$property_data) {
346 346
       // TODO - on isUpdate add only changed/adjusted properties
347 347
 
348
-      if(!empty($property_data[P_METHOD_INJECT]) && is_callable(array($this, $property_data[P_METHOD_INJECT]))) {
348
+      if (!empty($property_data[P_METHOD_INJECT]) && is_callable(array($this, $property_data[P_METHOD_INJECT]))) {
349 349
         call_user_func_array(array($this, $property_data[P_METHOD_INJECT]), array(&$array));
350 350
         continue;
351 351
       }
352 352
 
353 353
       // Skipping properties which have no corresponding field in DB
354
-      if(empty($property_data[P_DB_FIELD])) {
354
+      if (empty($property_data[P_DB_FIELD])) {
355 355
         continue;
356 356
       }
357 357
 
358 358
       // Checking - is property was adjusted or changed
359
-      if($isUpdate && array_key_exists($property_name, $this->propertiesAdjusted)) {
359
+      if ($isUpdate && array_key_exists($property_name, $this->propertiesAdjusted)) {
360 360
         // For adjusted property - take value from propertiesAdjusted array
361 361
         // TODO - differ how treated conversion to string for changed and adjusted properties
362 362
         $value = $this->propertiesAdjusted[$property_name];
@@ -386,17 +386,17 @@  discard block
 block discarded – undo
386 386
    */
387 387
   protected function isFieldChanged($fieldName) {
388 388
     $isFieldChanged = false;
389
-    foreach($this->propertiesChanged as $propertyName => $cork) {
389
+    foreach ($this->propertiesChanged as $propertyName => $cork) {
390 390
       $propertyScheme = static::$_properties[$propertyName];
391
-      if(!empty($propertyScheme[P_DB_FIELDS_LINKED])) {
392
-        foreach($propertyScheme[P_DB_FIELDS_LINKED] as $linkedFieldName) {
393
-          if($linkedFieldName == $fieldName) {
391
+      if (!empty($propertyScheme[P_DB_FIELDS_LINKED])) {
392
+        foreach ($propertyScheme[P_DB_FIELDS_LINKED] as $linkedFieldName) {
393
+          if ($linkedFieldName == $fieldName) {
394 394
             $isFieldChanged = $propertyName;
395 395
             break 2;
396 396
           }
397 397
         }
398 398
       }
399
-      if(!empty($propertyScheme[P_DB_FIELD]) && $propertyScheme[P_DB_FIELD] == $fieldName) {
399
+      if (!empty($propertyScheme[P_DB_FIELD]) && $propertyScheme[P_DB_FIELD] == $fieldName) {
400 400
         $isFieldChanged = $propertyName;
401 401
         break;
402 402
       }
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
     $fields = implode(',', array_keys($field_set));
419 419
 
420 420
     $result = 0;
421
-    if(classSupernova::db_query("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) {
421
+    if (classSupernova::db_query("INSERT INTO `{{" . static::$_table . "}}` ({$fields}) VALUES ({$values});")) {
422 422
       $result = db_insert_id();
423 423
     }
424 424
 
@@ -436,13 +436,13 @@  discard block
 block discarded – undo
436 436
     sn_db_field_set_safe_flag_clear($field_set);
437 437
 
438 438
     $set = array();
439
-    foreach($field_set as $fieldName => $value) {
440
-      if(!($changedProperty = $this->isFieldChanged($fieldName))) {
439
+    foreach ($field_set as $fieldName => $value) {
440
+      if (!($changedProperty = $this->isFieldChanged($fieldName))) {
441 441
         continue;
442 442
       }
443 443
 
444 444
       // TODO - separate sets from adjusts
445
-      if(array_key_exists($changedProperty, $this->propertiesAdjusted)) {
445
+      if (array_key_exists($changedProperty, $this->propertiesAdjusted)) {
446 446
         $value = "`{$fieldName}` + ($value)"; // braces for negative values
447 447
       }
448 448
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -411,7 +411,7 @@
 block discarded – undo
411 411
   /**
412 412
    * @param array $field_set
413 413
    *
414
-   * @return int|string
414
+   * @return integer
415 415
    */
416 416
   protected function db_field_set_create(array $field_set) {
417 417
     !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set) : false;
Please login to merge, or discard this patch.
includes/includes/flt_flying_fleet_handler2.php 2 patches
Spacing   +22 added lines, -26 removed lines patch added patch discarded remove patch
@@ -38,15 +38,11 @@  discard block
 block discarded – undo
38 38
 // ------------------------------------------------------------------
39 39
 function flt_flyingFleetsSort($a, $b) {
40 40
   // Сравниваем время флотов - кто раньше, тот и первый обрабатывается
41
-  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 :
42
-    // Если время - одинаковое, сравниваем события флотов
41
+  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов
43 42
     // Если события - одинаковые, то флоты равны
44
-    ($a['fleet_event'] == $b['fleet_event'] ? 0 :
45
-      // Если события разные - первыми считаем прибывающие флоты
46
-      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 :
47
-        // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
48
-        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 :
49
-          // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
43
+    ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты
44
+      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
45
+        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
50 46
           // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска
51 47
           (
52 48
           0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий
@@ -60,7 +56,7 @@  discard block
 block discarded – undo
60 56
 function log_file($msg) {
61 57
   static $handler;
62 58
 
63
-  if(!$handler) {
59
+  if (!$handler) {
64 60
     $handler = fopen('event.log', 'a+');
65 61
   }
66 62
 
@@ -100,12 +96,12 @@  discard block
 block discarded – undo
100 96
   */
101 97
   global $config, $debug;
102 98
 
103
-  if($config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) {
99
+  if ($config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) {
104 100
     return;
105 101
   }
106 102
 
107 103
   sn_db_transaction_start();
108
-  if($config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime($config->db_loadItem('fleet_update_last')) <= $config->fleet_update_interval) {
104
+  if ($config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime($config->db_loadItem('fleet_update_last')) <= $config->fleet_update_interval) {
109 105
     sn_db_transaction_rollback();
110 106
 
111 107
     return;
@@ -113,14 +109,14 @@  discard block
 block discarded – undo
113 109
 
114 110
 
115 111
   // Watchdog timer
116
-  if($config->db_loadItem('fleet_update_lock')) {
117
-    if(defined('DEBUG_FLYING_FLEETS')) {
112
+  if ($config->db_loadItem('fleet_update_lock')) {
113
+    if (defined('DEBUG_FLYING_FLEETS')) {
118 114
       $random = 0;
119 115
     } else {
120 116
       $random = mt_rand(240, 300);
121 117
     }
122 118
 
123
-    if(SN_TIME_NOW - strtotime($config->fleet_update_lock) <= $random) {
119
+    if (SN_TIME_NOW - strtotime($config->fleet_update_lock) <= $random) {
124 120
       sn_db_transaction_rollback();
125 121
 
126 122
       return;
@@ -144,11 +140,11 @@  discard block
 block discarded – undo
144 140
   $missions_used = array();
145 141
 
146 142
   $objFleetList = FleetList::dbGetFleetListCurrentTick();
147
-  foreach($objFleetList->_container as $objFleet) {
143
+  foreach ($objFleetList->_container as $objFleet) {
148 144
     set_time_limit(15);
149 145
     // TODO - Унифицировать код с темплейтным разбором эвентов на планете!
150 146
     $missions_used[$objFleet->mission_type] = 1;
151
-    if($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) {
147
+    if ($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) {
152 148
       $fleet_event_list[] = array(
153 149
         'object'      => $objFleet,
154 150
         'fleet_time'  => $objFleet->time_arrive_to_target,
@@ -156,7 +152,7 @@  discard block
 block discarded – undo
156 152
       );
157 153
     }
158 154
 
159
-    if($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) {
155
+    if ($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) {
160 156
       $fleet_event_list[] = array(
161 157
         'object'      => $objFleet,
162 158
         'fleet_time'  => $objFleet->time_mission_job_complete,
@@ -164,7 +160,7 @@  discard block
 block discarded – undo
164 160
       );
165 161
     }
166 162
 
167
-    if($objFleet->time_return_to_source <= SN_TIME_NOW) {
163
+    if ($objFleet->time_return_to_source <= SN_TIME_NOW) {
168 164
       $fleet_event_list[] = array(
169 165
         'object'      => $objFleet,
170 166
         'fleet_time'  => $objFleet->time_return_to_source,
@@ -190,17 +186,17 @@  discard block
 block discarded – undo
190 186
 //    MT_MISSILE => 'flt_mission_missile.php',
191 187
     MT_EXPLORE   => 'flt_mission_explore',
192 188
   );
193
-  foreach($missions_used as $mission_id => $cork) {
189
+  foreach ($missions_used as $mission_id => $cork) {
194 190
     require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX);
195 191
   }
196 192
 
197 193
 //log_file('Обработка миссий');
198 194
   $sn_groups_mission = sn_get_groups('missions');
199
-  foreach($fleet_event_list as $fleet_event) {
195
+  foreach ($fleet_event_list as $fleet_event) {
200 196
     // TODO: Указатель тут потом сделать
201 197
     // TODO: СЕЙЧАС НАДО ПРОВЕРЯТЬ ПО БАЗЕ - А ЖИВОЙ ЛИ ФЛОТ?!
202 198
     $fleet_row = $fleet_event['fleet_row'];
203
-    if(empty($fleet_event['object'])) {
199
+    if (empty($fleet_event['object'])) {
204 200
       // Fleet was destroyed in course of previous actions
205 201
       continue;
206 202
     }
@@ -224,20 +220,20 @@  discard block
 block discarded – undo
224 220
 
225 221
     $objFleet->dbLoad($objFleet->dbId);
226 222
 
227
-    if(!$objFleet->dbId) {
223
+    if (!$objFleet->dbId) {
228 224
       // Fleet was destroyed in course of previous actions
229 225
       sn_db_transaction_commit();
230 226
       continue;
231 227
     }
232 228
 
233
-    if($fleet_event['fleet_event'] == EVENT_FLT_RETURN) {
229
+    if ($fleet_event['fleet_event'] == EVENT_FLT_RETURN) {
234 230
       // Fleet returns to planet
235 231
       $objFleet->RestoreFleetToPlanet(true, false);
236 232
       sn_db_transaction_commit();
237 233
       continue;
238 234
     }
239 235
 
240
-    if($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) {
236
+    if ($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) {
241 237
       // При событии EVENT_FLT_ARRIVE флот всегда должен иметь fleet_mess == 0
242 238
       // В противном случае это означает, что флот уже был обработан ранее - например, при САБе
243 239
       sn_db_transaction_commit();
@@ -257,13 +253,13 @@  discard block
 block discarded – undo
257 253
     $objMission->dst_planet = $mission_data['dst_planet'] ? db_planet_by_vector($objFleet->target_coordinates_typed(), '', true, '`id`, `id_owner`, `name`') : null;
258 254
     $objMission->fleet_event = $fleet_event['fleet_event'];
259 255
 
260
-    if($objMission->dst_planet && $objMission->dst_planet['id_owner']) {
256
+    if ($objMission->dst_planet && $objMission->dst_planet['id_owner']) {
261 257
       $update_result = sys_o_get_updated($objMission->dst_planet['id_owner'], $objMission->dst_planet['id'], $objFleet->time_arrive_to_target);
262 258
       $objMission->dst_user = !empty($objMission->dst_user) ? $update_result['user'] : null;
263 259
       $objMission->dst_planet = $update_result['planet'];
264 260
     }
265 261
 
266
-    switch($objFleet->mission_type) {
262
+    switch ($objFleet->mission_type) {
267 263
       // Для боевых атак нужно обновлять по САБу и по холду - таки надо возвращать данные из обработчика миссий!
268 264
       case MT_AKS:
269 265
       case MT_ATTACK:
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
  *
11 11
  * @param Fleet $objFleet
12 12
  * @param bool  $start
13
- * @param null  $result
13
+ * @param integer  $result
14 14
  *
15 15
  * @return mixed
16 16
  */
Please login to merge, or discard this patch.
includes/includes/flt_mission_colonize.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
   $TargetAddress = sprintf($lang['sys_adress_planet'], $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet']);
21 21
 
22 22
   $TheMessage = $lang['sys_colo_no_colonizer'];
23
-  if($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) {
23
+  if ($objFleet->shipsGetTotalById(SHIP_COLONIZER) >= 1) {
24 24
     $TheMessage = $lang['sys_colo_notfree'];
25
-    if(empty($mission_data->dst_planet)) {
25
+    if (empty($mission_data->dst_planet)) {
26 26
       $iPlanetCount = get_player_current_colonies($src_user_row);
27 27
 
28 28
       // Can we colonize more planets?
29 29
       $TheMessage = $lang['sys_colo_maxcolo'];
30
-      if($iPlanetCount < get_player_max_colonies($src_user_row)) {
30
+      if ($iPlanetCount < get_player_max_colonies($src_user_row)) {
31 31
         // Yes, we can colonize
32 32
         $TheMessage = $lang['sys_colo_badpos'];
33 33
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
           $fleet_end_coordinates['galaxy'], $fleet_end_coordinates['system'], $fleet_end_coordinates['planet'],
36 36
           $objFleet->playerOwnerId, "{$lang['sys_colo_defaultname']} {$iPlanetCount}", false,
37 37
           array('user_row' => $src_user_row));
38
-        if($NewOwnerPlanet) {
38
+        if ($NewOwnerPlanet) {
39 39
           $TheMessage = $lang['sys_colo_arrival'] . $TargetAddress . $lang['sys_colo_allisok'];
40 40
           msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_SPY, $lang['sys_colo_mess_from'], $lang['sys_colo_mess_report'], $TheMessage);
41 41
 
Please login to merge, or discard this patch.