Completed
Push — trunk ( 5a98ee...c2d255 )
by SuperNova.WS
04:09
created
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 = classSupernova::$config->game_mode == GAME_BLITZ ? 'sys_blitz_page_disabled' : (
7 7
     !classSupernova::$config->game_blitz_register ? 'sys_blitz_registration_disabled' : ''
8 8
   );
9 9
 
10
-  if($error_message) {
10
+  if ($error_message) {
11 11
     messageBox($lang[$error_message], $lang['sys_error'], 'overview.php', 10);
12 12
     die();
13 13
   }
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 $current_round = intval(classSupernova::$config->db_loadItem('game_blitz_register_round'));
18 18
 $current_price = intval(classSupernova::$config->db_loadItem('game_blitz_register_price'));
19 19
 
20
-if(classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) {
20
+if (classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) {
21 21
   sn_db_transaction_start();
22 22
   $user = db_user_by_id($user['id'], true);
23 23
   $is_registered = doquery("SELECT `id` FROM {{blitz_registrations}} WHERE `user_id` = {$user['id']} AND `round_number` = {$current_round} FOR UPDATE;", true);
24
-  if(sys_get_param_str('register_me')) {
25
-    if(empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) {
24
+  if (sys_get_param_str('register_me')) {
25
+    if (empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) {
26 26
       doquery("INSERT IGNORE INTO {{blitz_registrations}} SET `user_id` = {$user['id']}, `round_number` = {$current_round};");
27 27
       //mm_points_change($user['id'], RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица");
28 28
       classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица");
@@ -43,17 +43,17 @@  discard block
 block discarded – undo
43 43
 $blitz_players = 0;
44 44
 $blitz_prize_dark_matter = 0;
45 45
 $blitz_prize_places = 0;
46
-if($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) {
47
-  if(sys_get_param_str('generate')) {
46
+if ($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) {
47
+  if (sys_get_param_str('generate')) {
48 48
     $next_id = 0;
49 49
     $query = doquery("SELECT `id` FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY RAND();");
50
-    while($row = db_fetch($query)) {
50
+    while ($row = db_fetch($query)) {
51 51
       $next_id++;
52 52
       $blitz_name = 'Игрок' . $next_id;
53 53
       $blitz_password = sys_random_string(8);
54 54
       doquery("UPDATE {{blitz_registrations}} SET blitz_name = '{$blitz_name}', blitz_password = '{$blitz_password}' WHERE `id` = {$row['id']} AND `round_number` = {$current_round};");
55 55
     }
56
-  } elseif(sys_get_param_str('import_generated')) {
56
+  } elseif (sys_get_param_str('import_generated')) {
57 57
     // ЭТО НА БЛИЦЕ!!!
58 58
     doquery("DELETE FROM {{users}} WHERE username like 'Игрок%';");
59 59
     doquery("DELETE FROM {{planets}} WHERE id_owner not in (SELECT `id` FROM {{users}});");
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     $system = $system_step;
76 76
     $planet = round(classSupernova::$config->game_maxPlanet / 2);
77 77
 
78
-    foreach($imported_string as &$string_data) {
78
+    foreach ($imported_string as &$string_data) {
79 79
       $string_data = explode(',', $string_data);
80 80
       $username_safe = $string_data[0];
81 81
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
       $moon_row = uni_create_moon($galaxy, $system, $planet, $user_new['id'], Universe::MOON_MAX_SIZE, false);
91 91
 
92
-      if(($system += $system_step) >= classSupernova::$config->game_maxSystem) {
92
+      if (($system += $system_step) >= classSupernova::$config->game_maxSystem) {
93 93
         $galaxy++;
94 94
         $system = $system_step;
95 95
       }
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
 
99 99
     classSupernova::$config->db_saveItem('users_amount', classSupernova::$config->users_amount + $new_players);
100 100
     // generated_string
101
-  } elseif(sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) {
101
+  } elseif (sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) {
102 102
     $blitz_result = explode(';', $blitz_result_string);
103 103
     $blitz_last_update = $blitz_result[0]; // Пока не используется
104 104
     unset($blitz_result[0]);
105
-    foreach($blitz_result as $blitz_result_data) {
105
+    foreach ($blitz_result as $blitz_result_data) {
106 106
       $blitz_result_data = explode(',', $blitz_result_data);
107
-      if(count($blitz_result_data) == 5) {
107
+      if (count($blitz_result_data) == 5) {
108 108
         $blitz_result_data[1] = db_escape($blitz_result_data[1]);
109 109
         doquery(
110 110
           "UPDATE `{{blitz_registrations}}` SET
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
     $blitz_result = array();
119 119
   }
120 120
 
121
-  if(classSupernova::$config->game_mode == GAME_BLITZ) {
121
+  if (classSupernova::$config->game_mode == GAME_BLITZ) {
122 122
     $blitz_result = array(classSupernova::$config->db_loadItem('var_stat_update'));
123 123
     $query = doquery("SELECT id, username, total_rank, total_points, onlinetime FROM {{users}} ORDER BY `id`;");
124
-    while($row = db_fetch($query)) {
124
+    while ($row = db_fetch($query)) {
125 125
       $blitz_result[] = "{$row['id']},{$row['username']},{$row['onlinetime']},{$row['total_rank']},{$row['total_points']}";
126 126
     }
127 127
   } else {
128 128
     $query = doquery("SELECT blitz_name, blitz_password, blitz_online FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `id`;");
129
-    while($row = db_fetch($query)) {
129
+    while ($row = db_fetch($query)) {
130 130
       $blitz_generated[] = "{$row['blitz_name']},{$row['blitz_password']}";
131 131
       $row['blitz_online'] ? $blitz_prize_players_active++ : false;
132 132
       $blitz_players++;
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
     'Игрок40'
142 142
     */
143 143
 
144
-    if(sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) {
144
+    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 145
       // $blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter');
146 146
       $blitz_prize_places_actual = sys_get_param_int('blitz_prize_places');
147 147
       sn_db_transaction_start();
148 148
       $query = doquery("SELECT * FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `blitz_place` FOR UPDATE;");
149
-      while($row = db_fetch($query)) {
150
-        if(!$row['blitz_place']) {
149
+      while ($row = db_fetch($query)) {
150
+        if (!$row['blitz_place']) {
151 151
           continue;
152 152
         }
153 153
 
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
         $blitz_prize_places_actual--;
156 156
 
157 157
         $reward = $blitz_prize_dark_matter_actual - $row['blitz_reward_dark_matter'];
158
-pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}",$row['id']);
159
-        if($reward) {
158
+pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}", $row['id']);
159
+        if ($reward) {
160 160
           rpg_points_change($row['user_id'], RPG_BLITZ, $reward, sprintf(
161 161
             $lang['sys_blitz_reward_log_message'], $row['blitz_place'], $row['blitz_name']
162 162
           ));
163 163
           doquery("UPDATE {{blitz_registrations}} SET blitz_reward_dark_matter = blitz_reward_dark_matter + ($reward) WHERE id = {$row['id']} AND `round_number` = {$current_round};");
164 164
         }
165 165
 
166
-        if(!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
166
+        if (!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) {
167 167
           break;
168 168
         }
169 169
       }
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
     JOIN {{users}} AS u ON u.id = br.user_id
184 184
   WHERE br.`round_number` = {$current_round}
185 185
   order by `blitz_place`, `timestamp`;");
186
-while($row = db_fetch($query)) {
186
+while ($row = db_fetch($query)) {
187 187
   $tpl_player_data = array(
188 188
     'NAME' => player_nick_render_to_html($row, array('icons' => true, 'color' => true, 'ally' => true)),
189 189
   );
190 190
 
191
-  if(classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) {
191
+  if (classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) {
192 192
     // Вот так хитро, что бы не было не единого шанса попадания на страницу данных об игроках Блиц-сервера до закрытия раунда
193 193
     $tpl_player_data = array_merge($tpl_player_data, array(
194 194
       'ID' => $row['id'],
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
   }
202 202
 
203 203
   $template->assign_block_vars('registrations', $tpl_player_data);
204
-  if($row['id'] == $user['id']) {
204
+  if ($row['id'] == $user['id']) {
205 205
     $player_registered = $row;
206 206
   }
207 207
 }
Please login to merge, or discard this patch.
includes/includes/art_artifact.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 {
5 5
   global $lang;
6 6
 
7
-  if(!in_array($unit_id, sn_get_groups('artifacts')))
7
+  if (!in_array($unit_id, sn_get_groups('artifacts')))
8 8
   {
9 9
     return;
10 10
   }
@@ -13,17 +13,17 @@  discard block
 block discarded – undo
13 13
   $user = db_user_by_id($user['id'], true);
14 14
 
15 15
   $unit_level = $artifact_level_old = mrc_get_level($user, array(), $unit_id, true);
16
-  if($unit_level > 0)
16
+  if ($unit_level > 0)
17 17
   {
18 18
     $db_changeset = array();
19
-    switch($unit_id)
19
+    switch ($unit_id)
20 20
     {
21 21
       case ART_LHC:
22 22
       case ART_HOOK_SMALL:
23 23
       case ART_HOOK_MEDIUM:
24 24
       case ART_HOOK_LARGE:
25 25
         $has_moon = DBStaticPlanet::db_planet_by_parent($planetrow['id'], true, '`id`');
26
-        if($planetrow['planet_type'] == PT_PLANET && !$has_moon['id'])
26
+        if ($planetrow['planet_type'] == PT_PLANET && !$has_moon['id'])
27 27
         {
28 28
           $unit_level--;
29 29
           switch ($unit_id) {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             break;
43 43
           }
44 44
 
45
-          if($moonSize)
45
+          if ($moonSize)
46 46
           {
47 47
             $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moonSize);
48 48
             $message = sprintf($lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), HelperString::numberFloorAndFormat($moonSize));
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
       case ART_RCD_MEDIUM:
64 64
       case ART_RCD_LARGE:
65 65
         $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true);
66
-        if($planetrow['planet_type'] != PT_PLANET)
66
+        if ($planetrow['planet_type'] != PT_PLANET)
67 67
         {
68 68
           $message = $lang['art_rcd_err_moon'];
69 69
           break;
70 70
         }
71 71
 
72 72
         $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, false);
73
-        if(!empty($que['items']))
73
+        if (!empty($que['items']))
74 74
         {
75 75
           $message = $lang['art_rcd_err_que'];
76 76
           break;
@@ -79,15 +79,15 @@  discard block
 block discarded – undo
79 79
         $artifact_deploy = get_unit_param($unit_id, P_DEPLOY);
80 80
 
81 81
         $sectors_used = 0;
82
-        foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level)
82
+        foreach ($artifact_deploy as $deploy_unit_id => $deploy_unit_level)
83 83
         {
84
-          if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true))))
84
+          if (!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true))))
85 85
             continue;
86 86
           $sectors_used += $levels_deployed;
87 87
           $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($deploy_unit_id, $levels_deployed, $user, $planetrow['id']);
88 88
         }
89 89
 
90
-        if($sectors_used == 0)
90
+        if ($sectors_used == 0)
91 91
         {
92 92
           $message = $lang['art_rcd_err_no_sense'];
93 93
           break;
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
         $que_item = null;
103 103
         $que = que_get($user['id'], $planetrow['id'], QUE_RESEARCH, true);
104 104
         $current_que = &$que['ques'][QUE_RESEARCH][$user['id']][0];
105
-        if(!empty($current_que))
105
+        if (!empty($current_que))
106 106
         {
107 107
           reset($current_que);
108 108
           $que_item = &$que['ques'][QUE_RESEARCH][$user['id']][0][key($current_que)];
109 109
         }
110 110
 
111
-        if(!empty($que_item) && $que_item['que_time_left'] > 60)
111
+        if (!empty($que_item) && $que_item['que_time_left'] > 60)
112 112
         {
113 113
           $unit_level--;
114 114
           $old_time = $que_item['que_time_left'];
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
         $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, true);
130 130
         $current_que = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']];
131 131
         // $que_item = &$que['que'][QUE_STRUCTURES][0];
132
-        if(!empty($current_que))
132
+        if (!empty($current_que))
133 133
         {
134 134
           reset($current_que);
135 135
           $que_item = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']][key($current_que)];
136 136
         }
137 137
 
138
-        if(isset($que_item) && $que_item['que_time_left'] > 60)
138
+        if (isset($que_item) && $que_item['que_time_left'] > 60)
139 139
         {
140 140
           $unit_level--;
141 141
           $old_time = $que_item['que_time_left'];
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
       break;
154 154
 
155 155
     }
156
-    if($unit_level != $artifact_level_old)
156
+    if ($unit_level != $artifact_level_old)
157 157
     {
158 158
       $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_level - $artifact_level_old, $user);
159 159
       OldDbChangeSet::db_changeset_apply($db_changeset);
Please login to merge, or discard this patch.
classes/Universe.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@  discard block
 block discarded – undo
8 8
   const MOON_MIN_SIZE = 1100;
9 9
   const MOON_MAX_SIZE = 8999;
10 10
 
11
-  const MOON_DEBRIS_MIN = 1000000;    // Minimum amount of debris to span a moon
12
-  const MOON_CHANCE_MIN_PERCENT = 1;  // Minimum chance to span a moon
11
+  const MOON_DEBRIS_MIN = 1000000; // Minimum amount of debris to span a moon
12
+  const MOON_CHANCE_MIN_PERCENT = 1; // Minimum chance to span a moon
13 13
   const MOON_CHANCE_MAX_PERCENT = 30; // Maximum chance to span a moon
14 14
 
15 15
   /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
    */
52 52
   public static function moonRollSize($debrisTotal) {
53 53
     $roll = mt_rand(1, 100);
54
-    if($roll <= static::moonCalcChanceFromDebris($debrisTotal)) {
54
+    if ($roll <= static::moonCalcChanceFromDebris($debrisTotal)) {
55 55
       $moonSize = Universe::moonRollSizeSecondary($roll);
56 56
     } else {
57 57
       $moonSize = 0;
Please login to merge, or discard this patch.