Completed
Push — work-fleets ( 77ad6e...489db6 )
by SuperNova.WS
06:17
created
includes/classes/DBStaticUnit.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     }
25 25
 
26 26
     if (SnCache::isUnitLocatorNotSet($location_type, $location_id)) {
27
-      $got_data = classSupernova::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions());
27
+      $got_data = classSupernova::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions());
28 28
       if (!empty($got_data) && is_array($got_data)) {
29 29
         foreach ($got_data as $unit_id => $unit_data) {
30 30
           SnCache::setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data);
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 
60 60
   public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) {
61 61
     $query = classSupernova::$db->doSelect(
62
-      "SELECT unit_snid, sum(unit_level) as `qty`  FROM {{unit}} WHERE `unit_player_id` = {$user_id} " .
63
-      ($unit_type ? "AND `unit_type` = {$unit_type} " : '') .
64
-      ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') .
62
+      "SELECT unit_snid, sum(unit_level) as `qty`  FROM {{unit}} WHERE `unit_player_id` = {$user_id} ".
63
+      ($unit_type ? "AND `unit_type` = {$unit_type} " : '').
64
+      ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '').
65 65
       'GROUP BY `unit_snid`'
66 66
     );
67 67
     $result = array();
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     WHERE
82 82
       f.fleet_owner = {$user_id} AND
83 83
       (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id})
84
-      AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() .
85
-      " LIMIT 1" .
84
+      AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions().
85
+      " LIMIT 1".
86 86
       ($for_update ? ' FOR UPDATE' : ''));
87 87
   }
88 88
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
   public static function db_unit_list_laboratories($user_id) {
91 91
     return classSupernova::$db->doSelect("SELECT DISTINCT unit_location_id AS `id`
92 92
     FROM {{unit}}
93
-    WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");");
93
+    WHERE unit_player_id = {$user_id} AND unit_location_type = ".LOC_PLANET." AND unit_level > 0 AND unit_snid IN (".STRUC_LABORATORY.", ".STRUC_LABORATORY_NANO.");");
94 94
   }
95 95
 
96 96
   public static function db_unit_set_by_id($unit_id, $set) {
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 
109 109
   public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id = 0, $unit_snid = 0) {
110 110
     return classSupernova::db_del_record_list(LOC_UNIT,
111
-      "`unit_location_type` = {$unit_location_type}" .
112
-      ($unit_location_id = idval($unit_location_id) ? " AND `unit_location_id` = {$unit_location_id}" : '') .
113
-      ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') .
111
+      "`unit_location_type` = {$unit_location_type}".
112
+      ($unit_location_id = idval($unit_location_id) ? " AND `unit_location_id` = {$unit_location_id}" : '').
113
+      ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : '').
114 114
       ($unit_snid = idval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : ''));
115 115
   }
116 116
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     return classSupernova::$db->doSelect(
119 119
       "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount
120 120
     FROM `{{unit}}`
121
-    WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() .
121
+    WHERE unit_level > 0 AND " . self::db_unit_time_restrictions().
122 122
       " GROUP BY unit_player_id, unit_type, unit_snid, unit_level"
123 123
     );
124 124
   }
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
 
131 131
 
132 132
   public static function db_unit_list_admin_delete_mercenaries_finished() {
133
-    return classSupernova::$db->doDelete("DELETE FROM `{{unit}}` WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ") AND unit_type = " . UNIT_MERCENARIES);
133
+    return classSupernova::$db->doDelete("DELETE FROM `{{unit}}` WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.") AND unit_type = ".UNIT_MERCENARIES);
134 134
   }
135 135
 
136 136
   public static function db_unit_list_admin_set_mercenaries_expire_time($default_length) {
137 137
     return classSupernova::$db->doUpdate(
138 138
       "UPDATE `{{unit}}`
139 139
     SET
140
-      unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW . "),
141
-      unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length) . ")
140
+      unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW."),
141
+      unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length).")
142 142
     WHERE unit_type = " . UNIT_MERCENARIES
143 143
     );
144 144
   }
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 
164 164
     $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id');
165 165
     if (!empty($temp['unit_id'])) {
166
-      $result = (bool)classSupernova::db_upd_record_list(
166
+      $result = (bool) classSupernova::db_upd_record_list(
167 167
         LOC_UNIT, "`unit_level` = `unit_level` + ($unit_value)", "`unit_id` = {$temp['unit_id']}"
168 168
       );
169 169
     } else {
170 170
       $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id;
171 171
       $unitType = get_unit_param($unit_id, P_UNIT_TYPE);
172
-      $result = (bool)classSupernova::db_ins_record(
172
+      $result = (bool) classSupernova::db_ins_record(
173 173
         LOC_UNIT,
174 174
         "unit_player_id = {$user['id']}, 
175 175
         unit_location_type = {$unit_location}, 
Please login to merge, or discard this patch.
includes/classes/DBStaticPlanet.php 1 patch
Spacing   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -55,11 +55,10 @@  discard block
 block discarded – undo
55 55
   }
56 56
 
57 57
   public static function db_planet_by_vector($vector, $prefix = '', $for_update = false, $fields = '*') {
58
-    $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0;
59
-    $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0;
60
-    $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0;
61
-    $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) :
62
-      (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
58
+    $galaxy = isset($vector[$prefix.'galaxy']) ? intval($vector[$prefix.'galaxy']) : 0;
59
+    $system = isset($vector[$prefix.'system']) ? intval($vector[$prefix.'system']) : 0;
60
+    $planet = isset($vector[$prefix.'planet']) ? intval($vector[$prefix.'planet']) : 0;
61
+    $planet_type = isset($vector[$prefix.'planet_type']) ? intval($vector[$prefix.'planet_type']) : (isset($vector[$prefix.'type']) ? intval($vector[$prefix.'type']) : 0);
63 62
     $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type;
64 63
 
65 64
     return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields);
@@ -85,7 +84,7 @@  discard block
 block discarded – undo
85 84
     }
86 85
 
87 86
     return classSupernova::db_get_record_list(LOC_PLANET,
88
-      "`parent_planet` = {$parent_id} AND `planet_type` = " . PT_MOON, true);
87
+      "`parent_planet` = {$parent_id} AND `planet_type` = ".PT_MOON, true);
89 88
   }
90 89
 
91 90
   public static function db_planet_by_id_and_owner($planet_id, $owner_id, $for_update = false, $fields = '*') {
@@ -106,7 +105,7 @@  discard block
 block discarded – undo
106 105
     }
107 106
 
108 107
     return classSupernova::db_get_record_list(LOC_PLANET,
109
-      "`planet_type` = " . PT_MOON . " AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}");
108
+      "`planet_type` = ".PT_MOON." AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}");
110 109
   }
111 110
 
112 111
   public static function db_planet_list_in_system($galaxy, $system) {
@@ -132,7 +131,7 @@  discard block
 block discarded – undo
132 131
     );
133 132
     $order_by = classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT];
134 133
     empty($sort_orders[$order_by]) ? $order_by = SORT_ID : false;
135
-    $order_by = $sort_orders[$order_by] . ' ' . (classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC');
134
+    $order_by = $sort_orders[$order_by].' '.(classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC');
136 135
 
137 136
     // Compilating query
138 137
     return classSupernova::db_get_record_list(LOC_PLANET,
@@ -157,7 +156,7 @@  discard block
 block discarded – undo
157 156
       $fieldName = pname_resource_name($resourceId);
158 157
       $value = "{$fieldName} = {$fieldName} + ('{$value}')";
159 158
     }
160
-    if($query = implode(',', $planetRowFieldChanges)) {
159
+    if ($query = implode(',', $planetRowFieldChanges)) {
161 160
       classSupernova::$gc->db->doUpdate("UPDATE `{{planets}}` SET {$query} WHERE id = {$planetId}");
162 161
     }
163 162
   }
@@ -208,7 +207,7 @@  discard block
 block discarded – undo
208 207
       return false;
209 208
     }
210 209
     classSupernova::db_del_record_by_id(LOC_PLANET, $planet_id);
211
-    classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLANET . " AND `unit_location_id` = " . $planet_id);
210
+    classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = ".LOC_PLANET." AND `unit_location_id` = ".$planet_id);
212 211
 
213 212
     // Очереди очистятся автоматически по FOREIGN KEY
214 213
     return true;
@@ -220,7 +219,7 @@  discard block
 block discarded – undo
220 219
       return false;
221 220
     }
222 221
     classSupernova::db_del_record_list(LOC_PLANET, "`id_owner` = {$si_owner_id}");
223
-    classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLANET . " AND `unit_player_id` = " . $si_owner_id);
222
+    classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = ".LOC_PLANET." AND `unit_player_id` = ".$si_owner_id);
224 223
 
225 224
     // Очереди очистятся автоматически по FOREIGN KEY
226 225
     return true;
Please login to merge, or discard this patch.