|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @version 2015-04-11 11:47:49 39b14.2 |
|
5
|
|
|
* @copyright 2008-2015 Gorlum for Project "SuperNova.WS" |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
defined('INSIDE') || die(); |
|
9
|
|
|
|
|
10
|
|
|
require_once('db/db_queries.php'); |
|
11
|
|
|
|
|
12
|
|
|
// TODO: THIS FUNCTION IS OBSOLETE AND SHOULD BE REPLACED! |
|
13
|
|
|
// TODO - ТОЛЬКО ДЛЯ РЕСУРСОВ |
|
14
|
|
|
// $unit_list should have unique entrances! Recompress non-uniq entrances before pass param! |
|
15
|
|
|
/** |
|
16
|
|
|
* @param $user |
|
17
|
|
|
* @param $planet |
|
18
|
|
|
* @param array $unit_list |
|
19
|
|
|
* @param null $query |
|
|
|
|
|
|
20
|
|
|
*/ |
|
21
|
|
|
function db_change_resources(&$user, &$planet, $unit_list) { |
|
22
|
|
|
$group = sn_get_groups('resources_loot'); |
|
23
|
|
|
reset($unit_list); |
|
24
|
|
|
$locationType = sys_get_unit_location($user, $planet, key($unit_list)); |
|
25
|
|
|
|
|
26
|
|
|
$resourcesChange = array(); |
|
27
|
|
|
foreach($unit_list as $unit_id => $unit_amount) { |
|
28
|
|
|
if(!in_array($unit_id, $group)) { |
|
29
|
|
|
// TODO - remove later |
|
30
|
|
|
print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_resources() вызван для не-ресурсов!</h1>'); |
|
31
|
|
|
pdump(debug_backtrace()); |
|
32
|
|
|
die('db_change_resources() вызван для не-ресурсов!'); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
if(empty($unit_amount)) { |
|
36
|
|
|
continue; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
$resourcesChange[pname_resource_name($unit_id)] += $unit_amount; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
if($locationType == LOC_USER) { |
|
43
|
|
|
$locationId = $user['id']; |
|
44
|
|
|
} else { |
|
45
|
|
|
$locationId = $planet['id']; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
if (!empty($locationId) && !empty($resourcesChange)) { |
|
49
|
|
|
classSupernova::$gc->cacheOperator->db_upd_record_by_id( |
|
|
|
|
|
|
50
|
|
|
$locationType, |
|
51
|
|
|
$locationId, |
|
52
|
|
|
array(), |
|
53
|
|
|
$resourcesChange |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
function sn_db_transaction_check($transaction_should_be_started = null) { |
|
60
|
|
|
return classSupernova::$gc->db->getTransaction()->check($transaction_should_be_started); |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
function sn_db_transaction_start($level = '') { |
|
63
|
|
|
return classSupernova::$gc->db->getTransaction()->start($level); |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
function sn_db_transaction_commit() { |
|
66
|
|
|
return classSupernova::$gc->db->getTransaction()->commit(); |
|
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
function sn_db_transaction_rollback() { |
|
69
|
|
|
return classSupernova::$gc->db->getTransaction()->rollback(); |
|
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
function db_fetch(&$query) { |
|
75
|
|
|
return classSupernova::$gc->db->db_fetch($query); |
|
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
function db_escape($unescaped_string) { |
|
78
|
|
|
return classSupernova::$gc->db->db_escape($unescaped_string); |
|
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.