-
Notifications
You must be signed in to change notification settings - Fork 35
/
fleetretreat.php
64 lines (48 loc) · 1.65 KB
/
fleetretreat.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
<?php
define('INSIDE', true);
$_EnginePath = './';
include($_EnginePath.'common.php');
include($_EnginePath.'modules/flightControl/_includes.php');
include($_EnginePath.'includes/functions/FleetControl_Retreat.php');
use UniEngine\Engine\Modules\FlightControl\Enums\RetreatResultType;
loggedCheck();
includeLang('fleet');
function retreatFleet($fleetId, &$user) {
if ($fleetId <= 0) {
return RetreatResultType::ErrorCantRetreatAnymore;
}
$retreatResult = FleetControl_Retreat("`fleet_id` = {$fleetId} AND `fleet_owner` = {$user['id']}");
if ($retreatResult['Rows'] == 0) {
return RetreatResultType::ErrorCantRetreatAnymore;
}
if (isset($retreatResult['Errors'][$fleetId])) {
if ($retreatResult['Errors'][$fleetId] == 1) {
return RetreatResultType::ErrorMissileStrikeRetreat;
}
if ($retreatResult['Errors'][$fleetId] == 2) {
return RetreatResultType::ErrorCantRetreatAnymore;
}
}
if (isset($retreatResult['Types'][$fleetId])) {
if ($retreatResult['Types'][$fleetId] == 1) {
return RetreatResultType::SuccessTurnedBack;
}
if ($retreatResult['Types'][$fleetId] == 2) {
return RetreatResultType::SuccessRetreated;
}
}
return RetreatResultType::ErrorCantRetreatAnymore;
}
function handleRetreatRequest() {
global $_User;
$fleetId = (
isset($_POST['fleetid']) ?
floor(floatval($_POST['fleetid'])) :
0
);
$retreatResultCode = retreatFleet($fleetId, $_User);
header("Location: fleet.php?ret=1&m={$retreatResultCode}");
safeDie();
}
handleRetreatRequest();
?>