Completed
Push — work-fleets ( 22b5bc...08ace7 )
by SuperNova.WS
06:13
created

overview.php (9 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * index.php - overview.php
4
 *
5
 * 2.4 - copyright (c) 2010 by Gorlum for http://supernova.ws
6
 *     [-] Removed News frame
7
 *     [-] Time & Usersonline moved to Top-Frame
8
 * 2.3 - copyright (c) 2010 by Gorlum for http://supernova.ws
9
 *     [*] Complying with PCG
10
 * 2.2 - copyright (c) 2010 by Gorlum for http://supernova.ws
11
 *     [+] Redo flying fleet list
12
 * 2.1 - copyright (c) 2010 by Gorlum for http://supernova.ws
13
 *     [+] Planets on planet list now have indication of planet fill
14
 *     [+] Planets on planet list now have indication when there is enemy fleet flying to planet
15
 * 2.0 - copyright (c) 2010 by Gorlum for http://supernova.ws
16
 *     [+] Now there is full planet list on right side of screen a-la oGame
17
 *     [+] Planet list now include icons for buildings/tech/fleet on progress
18
 * 1.5 - copyright (c) 2010 by Gorlum for http://supernova.ws
19
 *     [*] Subplanet timers now use sn_timer.js library
20
 * 1.4 - copyright (c) 2010 by Gorlum for http://supernova.ws
21
 *     [*] All mainplanet timers now use new sn_timer.js library
22
 * 1.3 - copyright (c) 2010 by Gorlum for http://supernova.ws
23
 *     [*] Adjusted layouts of player infos
24
 * 1.2 - copyright (c) 2010 by Gorlum for http://supernova.ws
25
 *     [*] Adjusted layouts of planet infos
26
 * 1.1 - Security checks by Gorlum for http://supernova.ws
27
 * @version 1
28
 * @copyright 2008 By Chlorel for XNova
29
 */
30
31
//define('SN_RENDER_NAVBAR_PLANET', false);
32
33
include('common.' . substr(strrchr(__FILE__, '.'), 1));
34
35
//$ccc = 0;
36
//foreach(DBStaticUser::db_user_list_non_bots() as $ip) {
37
//  $ccc++;
38
//}
39
//pdump($ccc);
40
//
41
//foreach(DBStaticUser::db_user_list_non_bots() as $ip) {
42
//  pdump($ip['id']);
43
//  $ccc++;
44
//}
45
//
46
//pdump(DBStaticUser::db_user_list_non_bots());
47
48
lng_include('overview');
49
50
$result = array();
51
52
switch($mode = sys_get_param_str('mode')) {
53
  case 'manage':
54
    sn_sys_sector_buy('overview.php?mode=manage');
55
56
    $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
57
    $result[] = sn_sys_planet_core_transmute($user, $planetrow);
58
59
    $template  = gettemplate('planet_manage', true);
60
    $planet_id = sys_get_param_id('planet_id');
61
62
    if(sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) {
63
      $planetrow['name'] = $new_name;
64
//      $new_name = db_escape($new_name);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
65
      DBStaticPlanet::db_planet_update_set_by_id_DEPRECATED($planetrow['id'], "`name` = '{$new_name}'");
0 ignored issues
show
Deprecated Code introduced by
The method DBStaticPlanet::db_plane..._set_by_id_DEPRECATED() has been deprecated.

This method has been deprecated.

Loading history...
66
    } elseif(sys_get_param_str('action') == 'make_capital') {
67
      try {
68
        sn_db_transaction_start();
69
        $user = DBStaticUser::db_user_by_id($user['id'], true, '*');
70
        $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true, '*');
71
//        $global_data = sys_o_get_updated($user, $planetrow['id'], SN_TIME_NOW);
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
72
//        $user = $global_data['user'];
73
//        $planetrow = $global_data['planet'];
74
75 View Code Duplication
        if($planetrow['planet_type'] != PT_PLANET) {
76
          throw new exception(classLocale::$lang['ov_capital_err_not_a_planet'], ERR_ERROR);
77
        }
78
79
        if($planetrow['id'] == $user['id_planet']) {
80
          throw new exception(classLocale::$lang['ov_capital_err_capital_already'], ERR_ERROR);
81
        }
82
83
        if($user_dark_matter < classSupernova::$config->planet_capital_cost) {
84
          throw new exception(classLocale::$lang['ov_capital_err_no_dark_matter'], ERR_ERROR);
85
        }
86
87
        rpg_points_change($user['id'], RPG_CAPITAL, -classSupernova::$config->planet_capital_cost,
88
          array('Planet %s ID %d at coordinates %s now become Empire Capital', $planetrow['name'], $planetrow['id'], uni_render_coordinates($planetrow))
89
        );
90
91
        DBStaticUser::db_user_set_by_id_DEPRECATED($user['id'], "id_planet = {$planetrow['id']}, galaxy = {$planetrow['galaxy']}, system = {$planetrow['system']}, planet = {$planetrow['planet']}");
0 ignored issues
show
Deprecated Code introduced by
The method DBStaticUser::db_user_set_by_id_DEPRECATED() has been deprecated.

This method has been deprecated.

Loading history...
92
93
        $user['id_planet'] = $planetrow['id'];
94
        $result[] = array(
95
          'STATUS'  => ERR_NONE,
96
          'MESSAGE' => classLocale::$lang['ov_capital_err_none'],
97
        );
98
        sn_db_transaction_commit();
99
        sys_redirect('overview.php?mode=manage');
100
      } catch(exception $e) {
101
        sn_db_transaction_rollback();
102
        $result[] = array(
103
          'STATUS'  => $e->getCode(),
104
          'MESSAGE' => $e->getMessage(),
105
        );
106
      }
107
    } elseif(sys_get_param_str('action') == 'planet_teleport') {
108
      try {
109
        if(!uni_coordinates_valid($new_coordinates = array(
110
          'galaxy' => sys_get_param_int('new_galaxy'),
111
          'system' => sys_get_param_int('new_system'),
112
          'planet' => sys_get_param_int('new_planet')))
113
        ) {
114
          throw new exception(classLocale::$lang['ov_teleport_err_wrong_coordinates'], ERR_ERROR);
115
        }
116
117
        sn_db_transaction_start();
118
        // При телепорте обновлять данные не надо - просто получить текущие данные и залочить их
119
        $user = DBStaticUser::db_user_by_id($user['id'], true, '*');
120
        $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true, '*');
121
//        $global_data = sys_o_get_updated($user, $planetrow['id'], SN_TIME_NOW);
122
//        $user = $global_data['user'];
123
//        $planetrow = $global_data['planet'];
124
125
        $can_teleport = uni_planet_teleport_check($user, $planetrow, $new_coordinates);
126
        if($can_teleport['result'] != ERR_NONE) {
127
          throw new exception($can_teleport['message'], $can_teleport['result']);
128
        }
129
130
        rpg_points_change($user['id'], RPG_TELEPORT, -classSupernova::$config->planet_teleport_cost,
131
          array(&classLocale::$lang['ov_teleport_log_record'], $planetrow['name'], $planetrow['id'], uni_render_coordinates($planetrow), uni_render_coordinates($new_coordinates))
132
        );
133
        $planet_teleport_next = SN_TIME_NOW + classSupernova::$config->planet_teleport_timeout;
134
        DBStaticPlanet::db_planet_update_by_gspt(
135
          $planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], PT_ALL,
136
          array(
137
            'galaxy'               => $new_coordinates['galaxy'],
138
            'system'               => $new_coordinates['system'],
139
            'planet'               => $new_coordinates['planet'],
140
            'planet_teleport_next' => $planet_teleport_next,
141
          ),
142
          array()
143
        );
144
145
        if($planetrow['id'] == $user['id_planet']) {
146
          DBStaticUser::db_user_set_by_id_DEPRECATED($user['id'], "galaxy = {$new_coordinates['galaxy']}, system = {$new_coordinates['system']}, planet = {$new_coordinates['planet']}");
0 ignored issues
show
Deprecated Code introduced by
The method DBStaticUser::db_user_set_by_id_DEPRECATED() has been deprecated.

This method has been deprecated.

Loading history...
147
        }
148
149
        // $global_data = sys_o_get_updated($user, $planetrow['id'], SN_TIME_NOW);
150
        sn_db_transaction_commit();
151
        $user = DBStaticUser::db_user_by_id($user['id'], true, '*');
152
        $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true, '*');
153
        $result[] = array(
154
          'STATUS'  => ERR_NONE,
155
          'MESSAGE' => classLocale::$lang['ov_teleport_err_none'],
156
        );
157
        sys_redirect('overview.php?mode=manage');
158
      } catch(exception $e) {
159
        sn_db_transaction_rollback();
160
        $result[] = array(
161
          'STATUS'  => $e->getCode(),
162
          'MESSAGE' => $e->getMessage(),
163
        );
164
      }
165
    } elseif(sys_get_param_str('action') == 'planet_abandon') {
166
      // if(sec_password_check($user['id'], sys_get_param('abandon_confirm'))) {
167
      if(classSupernova::$auth->password_check(sys_get_param('abandon_confirm'))) {
168
        if($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) {
169
          $destroyed = SN_TIME_NOW + 60 * 60 * 24;
170
          DBStaticPlanet::db_planet_update_set_by_id_DEPRECATED($user['current_planet'], "`destruyed`='{$destroyed}', `id_owner`=0");
0 ignored issues
show
Deprecated Code introduced by
The method DBStaticPlanet::db_plane..._set_by_id_DEPRECATED() has been deprecated.

This method has been deprecated.

Loading history...
171
          DBStaticPlanet::db_planet_set_by_parent(
172
            $user['current_planet'],
173
            array(
174
              'destruyed' => $destroyed,
175
              'id_owner'  => 0,
176
            )
177
          );
178
          DBStaticUser::db_user_set_by_id_DEPRECATED($user['id'], '`current_planet` = `id_planet`');
0 ignored issues
show
Deprecated Code introduced by
The method DBStaticUser::db_user_set_by_id_DEPRECATED() has been deprecated.

This method has been deprecated.

Loading history...
179
          message(classLocale::$lang['ov_delete_ok'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
180
        } else {
181
          message(classLocale::$lang['ov_delete_wrong_planet'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
182
        }
183
      } else {
184
        message(classLocale::$lang['ov_delete_wrong_pass'] , classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
185
      }
186
    } elseif(
187
      ($hire = sys_get_param_int('hire')) && in_array($hire, sn_get_groups('governors'))
188
      && (
189
        !get_unit_param($hire, P_MAX_STACK) ||
190
        ($planetrow['PLANET_GOVERNOR_ID'] != $hire) ||
191
        (
192
          $planetrow['PLANET_GOVERNOR_ID'] == $hire &&
193
          $planetrow['PLANET_GOVERNOR_LEVEL'] < get_unit_param($hire, P_MAX_STACK)
194
        )
195
      )
196
    ) {
197
      sn_db_transaction_start();
198
      $user = DBStaticUser::db_user_by_id($user['id'], true);
199
      $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true);
200
      $build_data = eco_get_build_data($user, $planetrow, $hire, $planetrow['PLANET_GOVERNOR_ID'] == $hire ? $planetrow['PLANET_GOVERNOR_LEVEL'] : 0);
201
      if($build_data['CAN'][BUILD_CREATE]) {
202
        if($planetrow['PLANET_GOVERNOR_ID'] == $hire) {
203
          $planetrow['PLANET_GOVERNOR_LEVEL']++;
204
          $query = '`PLANET_GOVERNOR_LEVEL` + 1';
205
        } else {
206
          $planetrow['PLANET_GOVERNOR_LEVEL'] = 1;
207
          $planetrow['PLANET_GOVERNOR_ID'] = $hire;
208
          $query = '1';
209
        }
210
        DBStaticPlanet::db_planet_update_set_by_id_DEPRECATED($planetrow['id'], "`PLANET_GOVERNOR_ID` = {$hire}, `PLANET_GOVERNOR_LEVEL` = {$query}");
0 ignored issues
show
Deprecated Code introduced by
The method DBStaticPlanet::db_plane..._set_by_id_DEPRECATED() has been deprecated.

This method has been deprecated.

Loading history...
211
        rpg_points_change(
212
          $user['id'],
213
          RPG_GOVERNOR,
214
          -$build_data[BUILD_CREATE][RES_DARK_MATTER],
215
          sprintf(classLocale::$lang['ov_governor_purchase'], classLocale::$lang['tech'][$hire], $hire, $planetrow['PLANET_GOVERNOR_LEVEL'], uni_render_planet_full($planetrow, '', false, true))
216
        );
217
218
        //  => 'Игрок купил Губернатора %1$s ID %2$d уровня %3$d на планету %4$s',
219
        // die();
220
      }
221
      sn_db_transaction_commit();
222
      sys_redirect('overview.php?mode=manage');
223
      die();
224
    }
225
226
    lng_include('mrc_mercenary');
227
    int_planet_pretemplate($planetrow, $template);
228
    foreach(sn_get_groups('governors') as $governor_id) {
229
      if($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) {
230
        continue;
231
      }
232
233
      $governor_level = $planetrow['PLANET_GOVERNOR_ID'] == $governor_id ? $planetrow['PLANET_GOVERNOR_LEVEL'] : 0;
234
      $build_data = eco_get_build_data($user, $planetrow, $governor_id, $governor_level);
235
      $template->assign_block_vars('governors', array(
236
        'ID'         => $governor_id,
237
        'NAME'       => classLocale::$lang['tech'][$governor_id],
238
        'COST'       => $build_data[BUILD_CREATE][RES_DARK_MATTER],
239
        'MAX'        => get_unit_param($governor_id, P_MAX_STACK),
240
        'LEVEL'      => $governor_level,
241
        'LEVEL_PLUS' => mrc_get_level($user, $planetrow, $governor_id) - $governor_level,
242
      ));
243
    }
244
245
    $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
246
    $planet_density_index = $planetrow['density_index'];
247
    $density_price_chart = planet_density_price_chart($planetrow);
248
    tpl_planet_density_info($template, $density_price_chart, $user_dark_matter);
249
250
    $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true);
251
    $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER];
252
    $planet_fill = floor($planetrow['field_current'] / eco_planet_fields_max($planetrow) * 100);
253
    $planet_fill = $planet_fill > 100 ? 100 : $planet_fill;
254
    $can_teleport = uni_planet_teleport_check($user, $planetrow);
255
    $template->assign_vars(array(
256
      'DARK_MATTER'           => $user_dark_matter,
257
258
      'PLANET_FILL'           => floor($planetrow['field_current'] / eco_planet_fields_max($planetrow) * 100),
259
      'PLANET_FILL_BAR'       => $planet_fill,
260
      'SECTOR_CAN_BUY'        => $sector_cost <= $user_dark_matter,
261
      'SECTOR_COST'           => $sector_cost,
262
      'SECTOR_COST_TEXT'      => pretty_number($sector_cost),
263
      'planet_field_current'  => $planetrow['field_current'],
264
      'planet_field_max'      => eco_planet_fields_max($planetrow),
265
266
      'CAN_TELEPORT'          => $can_teleport['result'] == ERR_NONE,
267
      'CAN_NOT_TELEPORT_MSG'  => $can_teleport['message'],
268
      'TELEPORT_COST_TEXT'    => pretty_number(classSupernova::$config->planet_teleport_cost, true, $user_dark_matter),
269
270
      'CAN_CAPITAL'           => $user_dark_matter >= classSupernova::$config->planet_capital_cost,
271
      'CAPITAL_COST_TEXT'     => pretty_number(classSupernova::$config->planet_capital_cost, true, $user_dark_matter),
272
273
      'PLANET_DENSITY_INDEX'  => $planet_density_index,
274
      'PLANET_CORE_TEXT'      => classLocale::$lang['uni_planet_density_types'][$planet_density_index],
275
276
      'IS_CAPITAL'            => $planetrow['id'] == $user['id_planet'],
277
278
      'PAGE_HINT'   => classLocale::$lang['ov_manage_page_hint'],
279
    ));
280
281
    foreach($result as &$a_result) {
282
      $template->assign_block_vars('result', $a_result);
283
    }
284
285
    display($template, classLocale::$lang['rename_and_abandon_planet']);
286
  break;
287
288
  default:
289
    sn_sys_sector_buy();
290
291
    if(sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) {
292
      $planetrow['name'] = $new_name;
293
      $new_name_safe = db_escape($new_name);
294
      DBStaticPlanet::db_planet_update_set_by_id_DEPRECATED($planetrow['id'], "`name` = '{$new_name_safe}'");
0 ignored issues
show
Deprecated Code introduced by
The method DBStaticPlanet::db_plane..._set_by_id_DEPRECATED() has been deprecated.

This method has been deprecated.

Loading history...
295
    }
296
297
    $result[] = sn_sys_planet_core_transmute($user, $planetrow);
298
299
    $template = gettemplate('planet_overview', true);
300
301
    $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
302
303
    $planet_density_index = $planetrow['density_index'];
304
    $density_price_chart = planet_density_price_chart($planetrow);
305
    tpl_planet_density_info($template, $density_price_chart, $user_dark_matter);
306
307
    rpg_level_up($user, RPG_STRUCTURE);
308
    rpg_level_up($user, RPG_RAID);
309
    rpg_level_up($user, RPG_TECH);
310
    rpg_level_up($user, RPG_EXPLORE);
311
312
    $fleet_id = 1;
313
314
//    $fleet_and_missiles_list = FleetList::fleet_and_missiles_list_incoming($user['id']);
315
//    $fleets = flt_parse_fleets_to_events($fleet_and_missiles_list);
316
    $fleet_and_missiles_list = FleetList::dbGetFleetListAndMissileINCOMING($user['id']);
317
    $fleets = flt_parse_objFleetList_to_events($fleet_and_missiles_list);
318
319
    $planet_count = 0;
320
    $planets_query = DBStaticPlanet::db_planet_list_sorted($user, false, '*');
321
    foreach($planets_query as $an_id => $UserPlanet) {
322
      sn_db_transaction_start();
323
      $UserPlanet = sys_o_get_updated($user, $UserPlanet['id'], SN_TIME_NOW, false, true);
324
      sn_db_transaction_commit();
325
      $list_planet_que = $UserPlanet['que'];
326
      $UserPlanet = $UserPlanet['planet'];
327
328
      $template_planet = tpl_parse_planet($UserPlanet);
329
330
      $planet_fleet_id = 0;
331
      $fleet_list = $template_planet['fleet_list'];
332 View Code Duplication
      if($fleet_list['own']['count']) {
333
        $planet_fleet_id = "p{$UserPlanet['id']}";
334
        $fleets_to_planet[$UserPlanet['id']] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id);
335
//        $fleet_id++;tpl_parse_fleet_sn
336
      }
337
      if($UserPlanet['planet_type'] == PT_MOON) {
338
        continue;
339
      }
340
      $moon = DBStaticPlanet::db_planet_by_parent($UserPlanet['id']);
341
      if($moon) {
342
        $moon_fill = min(100, floor($moon['field_current'] / eco_planet_fields_max($moon) * 100));
343
      } else {
344
        $moon_fill = 0;
345
      }
346
347
//      $moon_fleets = flt_get_fleets_to_planet($moon);
348
      $moon_fleets = FleetList::EMULATE_flt_get_fleets_to_planet($moon);
349
//      $moon_fleets = array();
350
//      $fleet_db_list = FleetList::dbGetFleetListAndMissileByCoordinates($moon);
351
//      /**
352
//       * @var Fleet[] $array_of_Fleet
353
//       */
354
//      $array_of_Fleet = array();
355
//      if(!empty($fleet_db_list) && $fleet_db_list->count()) {
356
//        foreach($fleet_db_list->_container as $fleet_id => $objFleet) {
357
//          $array_of_Fleet[$fleet_id] = $objFleet;
358
//        }
359
//        $moon_fleets = flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet);
360
//      }
361
362
      $template->assign_block_vars('planet', array_merge($template_planet, array(
363
        'PLANET_FLEET_ID'  => $planet_fleet_id,
364
365
        'MOON_ID'      => $moon['id'],
366
        'MOON_NAME'    => $moon['name'],
367
        'MOON_IMG'     => $moon['image'],
368
        'MOON_FILL'    => min(100, $moon_fill),
369
        'MOON_ENEMY'   => !empty($moon_fleets['enemy']['count']) ? $moon_fleets['enemy']['count'] : 0,
370
371
        'MOON_PLANET'  => $moon['parent_planet'],
372
      )));
373
374
      $planet_count++;
375
    }
376
377
    tpl_assign_fleet($template, $fleets_to_planet);
378
    tpl_assign_fleet($template, $fleets);
379
380
    $lune = $planetrow['planet_type'] == PT_PLANET ? DBStaticPlanet::db_planet_by_parent($planetrow['id']) : DBStaticPlanet::db_planet_by_id($planetrow['parent_planet']);
381
    if($lune) {
382
      $template->assign_vars(array(
383
        'MOON_ID' => $lune['id'],
384
        'MOON_IMG' => $lune['image'],
385
        'MOON_NAME' => $lune['name'],
386
      ));
387
    }
388
389
    $planet_fill = floor($planetrow['field_current'] / eco_planet_fields_max($planetrow) * 100);
390
    $planet_fill = $planet_fill > 100 ? 100 : $planet_fill;
391
392
    $planet_recyclers_orbiting = 0;
393
    foreach(Fleet::$snGroupRecyclers as $recycler_id) {
394
      $planet_recyclers_orbiting += mrc_get_level($user, $planetrow, $recycler_id);
395
    }
396
397
    int_planet_pretemplate($planetrow, $template);
398
399
    $sn_group_ques = sn_get_groups('ques');
400
    if(!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) {
401
      foreach(array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) {
402
        $this_que = $que['ques'][$que_id][$user['id']][$planetrow['id']];
403
        $template->assign_block_vars('ques', array(
404
          'ID'     => $que_id,
405
          'NAME'   => classLocale::$lang['sys_ques'][$que_id],
406
          'LENGTH' => empty($this_que) ? 0 : count($this_que),
407
        ));
408
409
        if(!empty($this_que)) {
410
          foreach($this_que as $que_item) {
411
            $template->assign_block_vars('que', que_tpl_parse_element($que_item));
412
          }
413
        }
414
      }
415
    }
416
417
    $que_hangar_length = tpl_assign_hangar($template, $planetrow, SUBQUE_FLEET);
418
    $template->assign_block_vars('ques', array(
419
      'ID'     => QUE_HANGAR,
420
      'NAME'   => classLocale::$lang['sys_ques'][QUE_HANGAR],
421
      'LENGTH' => $que_hangar_length,
422
    ));
423
424
    if(!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) {
425
      $que_hangar_length = tpl_assign_hangar($template, $planetrow, SUBQUE_DEFENSE);
426
      $template->assign_block_vars('ques', array(
427
        'ID'     => SUBQUE_DEFENSE,
428
        'NAME'   => classLocale::$lang['sys_ques'][SUBQUE_DEFENSE],
429
        'LENGTH' => $que_hangar_length,
430
      ));
431
    }
432
433
    $overview_planet_rows = $user['opt_int_overview_planet_rows'];
434
    $overview_planet_columns = $user['opt_int_overview_planet_columns'];
435
436
    if($overview_planet_rows <= 0 && $overview_planet_columns <= 0) {
437
      $overview_planet_rows = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_rows'];
438
      $overview_planet_columns = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_columns'];
439
    }
440
441
    if($overview_planet_rows > 0 && $overview_planet_columns <= 0) {
442
      $overview_planet_columns = ceil($planet_count / $overview_planet_rows);
443
    }
444
445
    $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true);
446
    $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER];
447
    $governor_level = $planetrow['PLANET_GOVERNOR_ID'] ? mrc_get_level($user, $planetrow, $planetrow['PLANET_GOVERNOR_ID'], false, true) : 0;
448
    $template->assign_vars(array(
449
      'USER_ID'               => $user['id'],
450
      'user_username'         => $user['username'],
451
      'USER_AUTHLEVEL'        => $user['authlevel'],
452
453
      'NEW_MESSAGES'          => $user['new_message'],
454
      'NEW_LEVEL_MINER'       => $level_miner,
455
      'NEW_LEVEL_RAID'        => $level_raid,
456
457
      'planet_diameter'       => pretty_number($planetrow['diameter']),
458
      'planet_field_current'  => $planetrow['field_current'],
459
      'planet_field_max'      => eco_planet_fields_max($planetrow),
460
      'PLANET_FILL'           => floor($planetrow['field_current'] / eco_planet_fields_max($planetrow) * 100),
461
      'PLANET_FILL_BAR'       => $planet_fill,
462
      'metal_debris'          => pretty_number($planetrow['debris_metal']),
463
      'crystal_debris'        => pretty_number($planetrow['debris_crystal']),
464
      'PLANET_RECYCLERS'      => $planet_recyclers_orbiting,
465
      'planet_image'          => $planetrow['image'],
466
      'planet_temp_min'       => $planetrow['temp_min'],
467
      'planet_temp_avg'       => round(($planetrow['temp_min'] + $planetrow['temp_max']) / 2),
468
      'planet_temp_max'       => $planetrow['temp_max'],
469
      'planet_density'        => $planetrow['density'],
470
      'planet_density_index'  => $planetrow['density_index'],
471
      'planet_density_text'   => classLocale::$lang['uni_planet_density_types'][$planetrow['density_index']],
472
473
      'GATE_LEVEL'            => mrc_get_level($user, $planetrow, STRUC_MOON_GATE),
474
      'GATE_JUMP_REST_TIME'   => uni_get_time_to_jump($planetrow),
475
476
      'ADMIN_EMAIL'           => classSupernova::$config->game_adminEmail,
477
478
      'PLANET_GOVERNOR_ID'    => $planetrow['PLANET_GOVERNOR_ID'],
479
//      'PLANET_GOVERNOR_LEVEL' => $planetrow['PLANET_GOVERNOR_LEVEL'] mrc_get_level($user, $planetrow,),
480
      'PLANET_GOVERNOR_LEVEL' => $governor_level,
481
      'PLANET_GOVERNOR_LEVEL_PLUS' => mrc_get_level($user, $planetrow, $planetrow['PLANET_GOVERNOR_ID']) - $governor_level,
482
      'PLANET_GOVERNOR_NAME'  => classLocale::$lang['tech'][$planetrow['PLANET_GOVERNOR_ID']],
483
484
      'LIST_ROW_COUNT'        => $overview_planet_rows,
485
      'LIST_COLUMN_COUNT'     => $overview_planet_columns,
486
487
      'DARK_MATTER'           => $user_dark_matter,
488
489
      'PLANET_DENSITY_INDEX'  => $planet_density_index,
490
      'PLANET_CORE_TEXT'      => classLocale::$lang['uni_planet_density_types'][$planet_density_index],
491
492
      'SECTOR_CAN_BUY'        => $sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER),
493
      'SECTOR_COST'           => $sector_cost,
494
      'SECTOR_COST_TEXT'      => pretty_number($sector_cost),
495
    ));
496
    tpl_set_resource_info($template, $planetrow, $fleets_to_planet, 2);
497
498
    foreach($result as &$a_result) {
499
      $template->assign_block_vars('result', $a_result);
500
    }
501
502
    $classLocale = classLocale::$lang;
503
    display($template, "{$classLocale['ov_overview']} - {$classLocale['sys_planet_type'][$planetrow['planet_type']]} {$planetrow['name']} [{$planetrow['galaxy']}:{$planetrow['system']}:{$planetrow['planet']}]");
504
  break;
505
}
506