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