supernova-ws /
SuperNova
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * jumpgate.php |
||
| 5 | * |
||
| 6 | * Jump Gate interface, I presume |
||
| 7 | * |
||
| 8 | * @version 1.0st Security checks & tests by Gorlum for http://supernova.ws |
||
| 9 | * @version 1 |
||
| 10 | * @copyright 2008 By Chlorel for XNova |
||
| 11 | */ |
||
| 12 | |||
| 13 | use DBAL\OldDbChangeSet; |
||
| 14 | use Planet\DBStaticPlanet; |
||
| 15 | |||
| 16 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
||
| 17 | |||
| 18 | lng_include('fleet'); |
||
| 19 | |||
| 20 | if($TargetPlanet = sys_get_param_id('jmpto')) |
||
| 21 | { |
||
| 22 | SN::db_transaction_start(); |
||
| 23 | db_user_by_id($user['id'], true, 'id'); |
||
| 24 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
||
| 25 | if(!($NextJumpTime = uni_get_time_to_jump($planetrow))) |
||
| 26 | { |
||
| 27 | $TargetGate = DBStaticPlanet::db_planet_by_id($TargetPlanet, true, '`id`, `last_jump_time`'); |
||
| 28 | if(mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0) |
||
| 29 | { |
||
| 30 | $NextDestTime = uni_get_time_to_jump ( $TargetGate ); |
||
| 31 | if(!$NextDestTime) |
||
| 32 | { |
||
| 33 | // $SubQueryOri = ""; |
||
| 34 | // $SubQueryDes = ""; |
||
| 35 | $ship_list = sys_get_param('ships'); |
||
| 36 | $db_changeset = array(); |
||
| 37 | foreach($ship_list as $ship_id => $ship_count) |
||
| 38 | { |
||
| 39 | if(!in_array($ship_id, sn_get_groups('fleet'))) |
||
| 40 | { |
||
| 41 | continue; |
||
| 42 | } |
||
| 43 | |||
| 44 | $ship_count = max(0, min(floor($ship_count), mrc_get_level($user, $planetrow, $ship_id))); |
||
| 45 | if($ship_count) |
||
| 46 | { |
||
| 47 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($ship_id, -$ship_count, $user, $planetrow['id']); |
||
| 48 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($ship_id, $ship_count, $user, $TargetGate['id']); |
||
| 49 | } |
||
| 50 | } |
||
| 51 | // Dit monsieur, y avait quelque chose a envoyer ??? |
||
| 52 | if(!empty($db_changeset)) |
||
| 53 | { |
||
| 54 | DBStaticPlanet::db_planet_set_by_id($TargetGate['id'], "`last_jump_time` = " . SN_TIME_NOW . ""); |
||
| 55 | DBStaticPlanet::db_planet_set_by_id($planetrow['id'], "`last_jump_time` = " . SN_TIME_NOW . ""); |
||
| 56 | OldDbChangeSet::db_changeset_apply($db_changeset); |
||
| 57 | |||
| 58 | db_user_set_by_id($user['id'], "`current_planet` = '{$TargetGate['id']}'"); |
||
| 59 | |||
| 60 | $planetrow['last_jump_time'] = SN_TIME_NOW; |
||
| 61 | $RetMessage = $lang['gate_jump_done'] ." - ". pretty_time(uni_get_time_to_jump($planetrow)); |
||
| 62 | } else { |
||
| 63 | $RetMessage = $lang['gate_wait_data']; |
||
| 64 | } |
||
| 65 | } else { |
||
| 66 | $RetMessage = $lang['gate_wait_dest'] ." - ". pretty_time($NextDestTime); |
||
| 67 | } |
||
| 68 | } else { |
||
| 69 | $RetMessage = $lang['gate_no_dest_g']; |
||
| 70 | } |
||
| 71 | } else { |
||
| 72 | $RetMessage = $lang['gate_wait_star'] ." - ". pretty_time($NextJumpTime); |
||
| 73 | } |
||
| 74 | SN::db_transaction_commit(); |
||
| 75 | SnTemplate::messageBox($RetMessage, $lang['tech'][STRUC_MOON_GATE], "jumpgate.php", 10); |
||
| 76 | } else { |
||
| 77 | $template = SnTemplate::gettemplate('jumpgate', true); |
||
| 78 | if(mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0) |
||
| 79 | { |
||
| 80 | $Combo = ''; |
||
| 81 | $MoonList = DBStaticPlanet::db_planet_list_moon_other($user['id'], $planetrow['id']); |
||
| 82 | // while($CurMoon = db_fetch($MoonList)) |
||
| 83 | foreach($MoonList as $CurMoon) |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 84 | { |
||
| 85 | if(mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1) |
||
| 86 | { |
||
| 87 | $NextJumpTime = uni_get_time_to_jump($CurMoon); |
||
| 88 | $template->assign_block_vars('moon', array( |
||
| 89 | 'ID' => $CurMoon['id'], |
||
| 90 | 'GALAXY' => $CurMoon['galaxy'], |
||
| 91 | 'SYSTEM' => $CurMoon['system'], |
||
| 92 | 'PLANET' => $CurMoon['planet'], |
||
| 93 | 'NAME' => $CurMoon['name'], |
||
| 94 | 'NEXT_JUMP_TIME' => $NextJumpTime ? pretty_time($NextJumpTime) : '', |
||
| 95 | )); |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | foreach(sn_get_groups('fleet') as $Ship) |
||
| 100 | { |
||
| 101 | if(($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0) |
||
| 102 | { |
||
| 103 | continue; |
||
| 104 | } |
||
| 105 | |||
| 106 | $template->assign_block_vars('fleet', array( |
||
| 107 | 'SHIP_ID' => $Ship, |
||
| 108 | 'SHIP_NAME' => $lang['tech'][$Ship], |
||
| 109 | 'SHIP_COUNT' => $ship_count, |
||
| 110 | 'SHIP_COUNT_TEXT' => HelperString::numberFloorAndFormat($ship_count), |
||
| 111 | )); |
||
| 112 | } |
||
| 113 | |||
| 114 | $template->assign_vars(array( |
||
| 115 | 'GATE_JUMP_REST_TIME' => uni_get_time_to_jump($planetrow), |
||
| 116 | 'gate_start_name' => $planetrow['name'], |
||
| 117 | 'gate_start_link' => uni_render_coordinates_href($planetrow, '', 3), |
||
| 118 | )); |
||
| 119 | |||
| 120 | SnTemplate::display($template, $lang['tech'][STRUC_MOON_GATE]); |
||
| 121 | } |
||
| 122 | else |
||
| 123 | { |
||
| 124 | SnTemplate::messageBox($lang['gate_no_src_ga'], $lang['tech'][STRUC_MOON_GATE], "overview.php", 10); |
||
| 125 | } |
||
| 126 | } |
||
| 127 | |||
| 128 | // ----------------------------------------------------------------------------------------------------------- |
||
| 129 | // History version |
||
| 130 | // 1.0 - Version from scrap .. y avait pas ... bin maintenant y a !! |
||
| 131 |