|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Orm\Repository; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\EntityRepository; |
|
8
|
|
|
use Doctrine\ORM\Query\ResultSetMapping; |
|
9
|
|
|
use Override; |
|
|
|
|
|
|
10
|
|
|
use RuntimeException; |
|
11
|
|
|
use Stu\Component\Ship\FlightSignatureVisibilityEnum; |
|
|
|
|
|
|
12
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
|
13
|
|
|
use Stu\Lib\Map\VisualPanel\PanelBoundaries; |
|
14
|
|
|
use Stu\Module\PlayerSetting\Lib\UserSettingEnum; |
|
15
|
|
|
use Stu\Module\Starmap\Lib\ExploreableStarMap; |
|
16
|
|
|
use Stu\Orm\Entity\LayerInterface; |
|
17
|
|
|
use Stu\Orm\Entity\Location; |
|
18
|
|
|
use Stu\Orm\Entity\Map; |
|
19
|
|
|
use Stu\Orm\Entity\MapInterface; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @extends EntityRepository<Map> |
|
23
|
|
|
*/ |
|
24
|
|
|
final class MapRepository extends EntityRepository implements MapRepositoryInterface |
|
25
|
|
|
{ |
|
26
|
|
|
#[Override] |
|
27
|
|
|
public function getAmountByLayer(LayerInterface $layer): int |
|
28
|
|
|
{ |
|
29
|
|
|
return $this->count([ |
|
30
|
|
|
'layer_id' => $layer->getId() |
|
31
|
|
|
]); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
#[Override] |
|
35
|
|
|
public function getAllOrdered(int $layerId): array |
|
36
|
|
|
{ |
|
37
|
|
|
return $this->getEntityManager() |
|
38
|
|
|
->createQuery( |
|
39
|
|
|
sprintf( |
|
40
|
|
|
'SELECT m FROM %s m |
|
41
|
|
|
JOIN %s l |
|
42
|
|
|
WITH m.id = l.id |
|
43
|
|
|
WHERE l.layer_id = :layerId |
|
44
|
|
|
ORDER BY l.cy, l.cx', |
|
45
|
|
|
Map::class, |
|
46
|
|
|
Location::class |
|
47
|
|
|
) |
|
48
|
|
|
) |
|
49
|
|
|
->setParameters([ |
|
50
|
|
|
'layerId' => $layerId |
|
51
|
|
|
]) |
|
52
|
|
|
->getResult(); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
#[Override] |
|
56
|
|
|
public function getAllWithSystem(int $layerId): array |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->getEntityManager() |
|
59
|
|
|
->createQuery( |
|
60
|
|
|
sprintf( |
|
61
|
|
|
'SELECT m FROM %s m INDEX BY m.id |
|
62
|
|
|
JOIN %s l |
|
63
|
|
|
WITH m.id = l.id |
|
64
|
|
|
WHERE l.layer_id = :layerId |
|
65
|
|
|
AND m.systems_id IS NOT null', |
|
66
|
|
|
Map::class, |
|
67
|
|
|
Location::class |
|
68
|
|
|
) |
|
69
|
|
|
) |
|
70
|
|
|
->setParameters([ |
|
71
|
|
|
'layerId' => $layerId |
|
72
|
|
|
]) |
|
73
|
|
|
->getResult(); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
#[Override] |
|
77
|
|
|
public function getAllWithoutSystem(int $layerId): array |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->getEntityManager() |
|
80
|
|
|
->createQuery( |
|
81
|
|
|
sprintf( |
|
82
|
|
|
'SELECT m FROM %s m INDEX BY m.id |
|
83
|
|
|
JOIN %s l |
|
84
|
|
|
WITH m.id = l.id |
|
85
|
|
|
WHERE l.layer_id = :layerId |
|
86
|
|
|
AND m.systems_id IS null', |
|
87
|
|
|
Map::class, |
|
88
|
|
|
Location::class |
|
89
|
|
|
) |
|
90
|
|
|
) |
|
91
|
|
|
->setParameters([ |
|
92
|
|
|
'layerId' => $layerId |
|
93
|
|
|
]) |
|
94
|
|
|
->getResult(); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
1 |
|
#[Override] |
|
98
|
|
|
public function getByCoordinates(?LayerInterface $layer, int $cx, int $cy): ?MapInterface |
|
99
|
|
|
{ |
|
100
|
1 |
|
if ($layer === null) { |
|
101
|
|
|
return null; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
1 |
|
return $this->findOneBy([ |
|
105
|
1 |
|
'layer_id' => $layer->getId(), |
|
106
|
1 |
|
'cx' => $cx, |
|
107
|
1 |
|
'cy' => $cy |
|
108
|
1 |
|
]); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
#[Override] |
|
112
|
|
|
public function getByCoordinateRange( |
|
113
|
|
|
int $layerId, |
|
114
|
|
|
int $startCx, |
|
115
|
|
|
int $endCx, |
|
116
|
|
|
int $startCy, |
|
117
|
|
|
int $endCy, |
|
118
|
|
|
bool $sortAscending = true |
|
119
|
|
|
): array { |
|
120
|
|
|
return $this->getEntityManager() |
|
121
|
|
|
->createQuery( |
|
122
|
|
|
sprintf( |
|
123
|
|
|
'SELECT m FROM %s m |
|
124
|
|
|
JOIN %s l |
|
125
|
|
|
WITH m.id = l.id |
|
126
|
|
|
WHERE l.cx BETWEEN :startCx AND :endCx |
|
127
|
|
|
AND l.cy BETWEEN :startCy AND :endCy |
|
128
|
|
|
AND l.layer_id = :layerId |
|
129
|
|
|
ORDER BY l.cy %3$s, l.cx %3$s', |
|
130
|
|
|
Map::class, |
|
131
|
|
|
Location::class, |
|
132
|
|
|
$sortAscending ? 'ASC' : 'DESC' |
|
133
|
|
|
) |
|
134
|
|
|
) |
|
135
|
|
|
->setParameters([ |
|
136
|
|
|
'layerId' => $layerId, |
|
137
|
|
|
'startCx' => $startCx, |
|
138
|
|
|
'endCx' => $endCx, |
|
139
|
|
|
'startCy' => $startCy, |
|
140
|
|
|
'endCy' => $endCy |
|
141
|
|
|
]) |
|
142
|
|
|
->getResult(); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
#[Override] |
|
146
|
|
|
public function save(MapInterface $map): void |
|
147
|
|
|
{ |
|
148
|
|
|
$em = $this->getEntityManager(); |
|
149
|
|
|
|
|
150
|
|
|
$em->persist($map); |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
1 |
|
#[Override] |
|
154
|
|
|
public function getBorderData(PanelBoundaries $boundaries, ResultSetMapping $rsm): array |
|
155
|
|
|
{ |
|
156
|
1 |
|
return $this->getEntityManager()->createNativeQuery( |
|
157
|
1 |
|
'SELECT l.cx AS x, l.cy AS y, |
|
158
|
|
|
(SELECT al.rgb_code FROM stu_alliances al |
|
159
|
|
|
JOIN stu_user u ON al.id = u.allys_id |
|
160
|
|
|
JOIN stu_spacecraft sc ON u.id = sc.user_id |
|
161
|
|
|
JOIN stu_station s ON sc.id = s.id |
|
162
|
|
|
JOIN stu_map ma ON ma.influence_area_id = s.influence_area_id |
|
163
|
|
|
WHERE ma.id = m.id AND ma.bordertype_id IS NULL AND ma.admin_region_id IS NULL) |
|
164
|
|
|
AS allycolor, |
|
165
|
|
|
(SELECT COALESCE(us.value, \'\') FROM stu_user u |
|
166
|
|
|
LEFT JOIN stu_user_setting us ON u.id = us.user_id |
|
167
|
|
|
JOIN stu_spacecraft sc ON u.id = sc.user_id |
|
168
|
|
|
JOIN stu_station s ON sc.id = s.id |
|
169
|
|
|
JOIN stu_map mu ON mu.influence_area_id = s.influence_area_id |
|
170
|
|
|
WHERE us.setting = :rgbCodeSetting |
|
171
|
|
|
AND mu.id = m.id AND mu.bordertype_id IS NULL AND mu.admin_region_id IS NULL) |
|
172
|
|
|
as usercolor, |
|
173
|
|
|
(SELECT mbt.color FROM stu_map_bordertypes mbt |
|
174
|
|
|
JOIN stu_map mb ON mb.bordertype_id = mbt.id |
|
175
|
|
|
WHERE mb.id = m.id AND mb.bordertype_id IS NOT NULL) |
|
176
|
|
|
AS factioncolor |
|
177
|
|
|
FROM stu_map m |
|
178
|
|
|
JOIN stu_location l |
|
179
|
|
|
ON m.id = l.id |
|
180
|
|
|
WHERE l.cx BETWEEN :xStart AND :xEnd |
|
181
|
|
|
AND l.cy BETWEEN :yStart AND :yEnd |
|
182
|
1 |
|
AND l.layer_id = :layerId', |
|
183
|
1 |
|
$rsm |
|
184
|
1 |
|
)->setParameters([ |
|
185
|
1 |
|
'xStart' => $boundaries->getMinX(), |
|
186
|
1 |
|
'xEnd' => $boundaries->getMaxX(), |
|
187
|
1 |
|
'yStart' => $boundaries->getMinY(), |
|
188
|
1 |
|
'yEnd' => $boundaries->getMaxY(), |
|
189
|
1 |
|
'layerId' => $boundaries->getParentId(), |
|
190
|
1 |
|
'rgbCodeSetting' => UserSettingEnum::RGB_CODE->value |
|
191
|
1 |
|
])->getResult(); |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
1 |
|
#[Override] |
|
195
|
|
|
public function getSpacecraftCountLayerData(PanelBoundaries $boundaries, ResultSetMapping $rsm): array |
|
196
|
|
|
{ |
|
197
|
1 |
|
return $this->getEntityManager()->createNativeQuery( |
|
198
|
1 |
|
'SELECT l.cx as x, l.cy AS y, |
|
199
|
|
|
(SELECT count(DISTINCT b.id) FROM stu_spacecraft b |
|
200
|
|
|
JOIN stu_location l2 |
|
201
|
|
|
ON b.location_id = l2.id |
|
202
|
|
|
WHERE l2.layer_id = l.layer_id |
|
203
|
|
|
AND l2.cx = l.cx |
|
204
|
|
|
AND l2.cy = l.cy |
|
205
|
|
|
AND NOT EXISTS (SELECT ss.id |
|
206
|
|
|
FROM stu_spacecraft_system ss |
|
207
|
|
|
WHERE b.id = ss.spacecraft_id |
|
208
|
|
|
AND ss.system_type = :cloakSystemId |
|
209
|
|
|
AND ss.mode > 1)) AS spacecraftcount, |
|
210
|
|
|
(SELECT count(DISTINCT c.id) FROM stu_spacecraft c |
|
211
|
|
|
JOIN stu_location l2 |
|
212
|
|
|
ON c.location_id = l2.id |
|
213
|
|
|
WHERE l2.layer_id = l.layer_id |
|
214
|
|
|
AND l2.cx = l.cx |
|
215
|
|
|
AND l2.cy = l.cy |
|
216
|
|
|
AND EXISTS (SELECT ss2.id |
|
217
|
|
|
FROM stu_spacecraft_system ss2 |
|
218
|
|
|
WHERE c.id = ss2.spacecraft_id |
|
219
|
|
|
AND ss2.system_type = :cloakSystemId |
|
220
|
|
|
AND ss2.mode > 1)) AS cloakcount |
|
221
|
|
|
FROM stu_location l |
|
222
|
|
|
WHERE l.cx BETWEEN :xStart AND :xEnd AND l.cy BETWEEN :yStart AND :yEnd |
|
223
|
|
|
AND l.layer_id = :layerId |
|
224
|
1 |
|
GROUP BY layer_id, x, y', |
|
225
|
1 |
|
$rsm |
|
226
|
1 |
|
)->setParameters([ |
|
227
|
1 |
|
'xStart' => $boundaries->getMinX(), |
|
228
|
1 |
|
'xEnd' => $boundaries->getMaxX(), |
|
229
|
1 |
|
'yStart' => $boundaries->getMinY(), |
|
230
|
1 |
|
'yEnd' => $boundaries->getMaxY(), |
|
231
|
1 |
|
'layerId' => $boundaries->getParentId(), |
|
232
|
1 |
|
'cloakSystemId' => SpacecraftSystemTypeEnum::CLOAK->value |
|
233
|
1 |
|
])->getResult(); |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
|
|
237
|
1 |
|
#[Override] |
|
238
|
|
|
public function getMapLayerData(PanelBoundaries $boundaries, ResultSetMapping $rsm): array |
|
239
|
|
|
{ |
|
240
|
1 |
|
return $this->getEntityManager()->createNativeQuery( |
|
241
|
1 |
|
'SELECT l.cx as x, l.cy AS y, ft.type |
|
242
|
|
|
FROM stu_map m |
|
243
|
|
|
JOIN stu_location l |
|
244
|
|
|
ON m.id = l.id |
|
245
|
|
|
JOIN stu_map_ftypes ft ON ft.id = l.field_id |
|
246
|
|
|
WHERE l.cx BETWEEN :xStart AND :xEnd AND l.cy BETWEEN :yStart AND :yEnd |
|
247
|
1 |
|
AND l.layer_id = :layerId', |
|
248
|
1 |
|
$rsm |
|
249
|
1 |
|
)->setParameters([ |
|
250
|
1 |
|
'xStart' => $boundaries->getMinX(), |
|
251
|
1 |
|
'xEnd' => $boundaries->getMaxX(), |
|
252
|
1 |
|
'yStart' => $boundaries->getMinY(), |
|
253
|
1 |
|
'yEnd' => $boundaries->getMaxY(), |
|
254
|
1 |
|
'layerId' => $boundaries->getParentId(), |
|
255
|
1 |
|
])->getResult(); |
|
256
|
|
|
} |
|
257
|
|
|
|
|
258
|
3 |
|
#[Override] |
|
259
|
|
|
public function getExplored(int $userId, int $layerId, int $startX, int $endX, int $cy): array |
|
260
|
|
|
{ |
|
261
|
3 |
|
$rsm = new ResultSetMapping(); |
|
262
|
3 |
|
$rsm->addEntityResult(ExploreableStarMap::class, 'm'); |
|
263
|
3 |
|
$rsm->addFieldResult('m', 'id', 'id'); |
|
264
|
3 |
|
$rsm->addFieldResult('m', 'cx', 'cx'); |
|
265
|
3 |
|
$rsm->addFieldResult('m', 'cy', 'cy'); |
|
266
|
3 |
|
$rsm->addFieldResult('m', 'field_id', 'field_id'); |
|
267
|
3 |
|
$rsm->addFieldResult('m', 'bordertype_id', 'bordertype_id'); |
|
268
|
3 |
|
$rsm->addFieldResult('m', 'user_id', 'user_id'); |
|
269
|
3 |
|
$rsm->addFieldResult('m', 'mapped', 'mapped'); |
|
270
|
3 |
|
$rsm->addFieldResult('m', 'system_name', 'system_name'); |
|
271
|
3 |
|
$rsm->addFieldResult('m', 'influence_area_id', 'influence_area_id'); |
|
272
|
3 |
|
$rsm->addFieldResult('m', 'region_id', 'region_id'); |
|
273
|
3 |
|
$rsm->addFieldResult('m', 'tradepost_id', 'tradepost_id'); |
|
274
|
3 |
|
$rsm->addFieldResult('m', 'region_description', 'region_description'); |
|
275
|
3 |
|
$rsm->addFieldResult('m', 'layer_id', 'layer_id'); |
|
276
|
|
|
|
|
277
|
3 |
|
return $this->getEntityManager() |
|
278
|
3 |
|
->createNativeQuery( |
|
279
|
3 |
|
'SELECT m.id, l.cx, l.cy, l.field_id, m.systems_id, m.bordertype_id, um.user_id, |
|
280
|
|
|
dbu.database_id as mapped, m.influence_area_id as influence_area_id, m.admin_region_id as region_id, |
|
281
|
|
|
sys.name as system_name, l.layer_id, |
|
282
|
|
|
(SELECT tp.id FROM stu_spacecraft s JOIN stu_trade_posts tp ON s.id = tp.station_id WHERE s.location_id = m.id) as tradepost_id, |
|
283
|
|
|
(SELECT mr.description FROM stu_map_regions mr JOIN stu_database_user dbu on dbu.user_id = :userId and mr.database_id = dbu.database_id WHERE m.region_id = mr.id) as region_description |
|
284
|
|
|
FROM stu_map m |
|
285
|
|
|
JOIN stu_location l |
|
286
|
|
|
ON m.id = l.id |
|
287
|
|
|
LEFT JOIN stu_user_map um |
|
288
|
|
|
ON um.cy = l.cy AND um.cx = l.cx AND um.user_id = :userId AND um.layer_id = l.layer_id |
|
289
|
|
|
LEFT JOIN stu_systems sys |
|
290
|
|
|
ON m.systems_id = sys.id |
|
291
|
|
|
LEFT JOIN stu_database_user dbu |
|
292
|
|
|
ON dbu.user_id = :userId |
|
293
|
|
|
AND sys.database_id = dbu.database_id |
|
294
|
|
|
WHERE l.cx BETWEEN :startX AND :endX |
|
295
|
|
|
AND l.cy = :cy |
|
296
|
|
|
AND l.layer_id = :layerId |
|
297
|
3 |
|
ORDER BY l.cx ASC', |
|
298
|
3 |
|
$rsm |
|
299
|
3 |
|
) |
|
300
|
3 |
|
->setParameters([ |
|
301
|
3 |
|
'layerId' => $layerId, |
|
302
|
3 |
|
'userId' => $userId, |
|
303
|
3 |
|
'startX' => $startX, |
|
304
|
3 |
|
'endX' => $endX, |
|
305
|
3 |
|
'cy' => $cy |
|
306
|
3 |
|
]) |
|
307
|
3 |
|
->getResult(); |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
#[Override] |
|
311
|
|
|
public function getWithEmptySystem(LayerInterface $layer): array |
|
312
|
|
|
{ |
|
313
|
|
|
return $this->getEntityManager() |
|
314
|
|
|
->createQuery( |
|
315
|
|
|
sprintf( |
|
316
|
|
|
'SELECT m from %s m |
|
317
|
|
|
JOIN %s l |
|
318
|
|
|
WITH m.id = l.id |
|
319
|
|
|
WHERE m.system_type_id IS NOT NULL |
|
320
|
|
|
AND m.systems_id IS NULL |
|
321
|
|
|
AND l.layer = :layer', |
|
322
|
|
|
Map::class, |
|
323
|
|
|
Location::class |
|
324
|
|
|
) |
|
325
|
|
|
) |
|
326
|
|
|
->setParameters([ |
|
327
|
|
|
'layer' => $layer |
|
328
|
|
|
]) |
|
329
|
|
|
->getResult(); |
|
330
|
|
|
} |
|
331
|
|
|
|
|
332
|
|
|
#[Override] |
|
333
|
|
|
public function getRandomMapIdsForAstroMeasurement(int $regionId, int $maxPercentage, int $location): array |
|
334
|
|
|
{ |
|
335
|
|
|
$rsm = new ResultSetMapping(); |
|
336
|
|
|
$rsm->addScalarResult('id', 'id', 'integer'); |
|
337
|
|
|
|
|
338
|
|
|
$mapIdResultSet = $this->getEntityManager() |
|
339
|
|
|
->createNativeQuery( |
|
340
|
|
|
'SELECT m.id FROM stu_map m |
|
341
|
|
|
JOIN stu_location l |
|
342
|
|
|
ON m.id = l.id |
|
343
|
|
|
JOIN stu_map_ftypes mf |
|
344
|
|
|
ON l.field_id = mf.id |
|
345
|
|
|
WHERE m.region_id = :regionId |
|
346
|
|
|
AND mf.passable = :true |
|
347
|
|
|
AND m.id != :loc |
|
348
|
|
|
ORDER BY RANDOM()', |
|
349
|
|
|
$rsm |
|
350
|
|
|
) |
|
351
|
|
|
->setParameters([ |
|
352
|
|
|
'regionId' => $regionId, |
|
353
|
|
|
'loc' => $location, |
|
354
|
|
|
'true' => true |
|
355
|
|
|
]) |
|
356
|
|
|
->getResult(); |
|
357
|
|
|
|
|
358
|
|
|
$amount = (int)ceil(count($mapIdResultSet) * $maxPercentage / 100); |
|
359
|
|
|
$subset = array_slice($mapIdResultSet, 0, $amount); |
|
360
|
|
|
|
|
361
|
|
|
return array_map(fn(array $data) => $data['id'], $subset); |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
#[Override] |
|
365
|
|
|
public function getRandomPassableUnoccupiedWithoutDamage(LayerInterface $layer, bool $isAtBorder = false): MapInterface |
|
366
|
|
|
{ |
|
367
|
|
|
$rsm = new ResultSetMapping(); |
|
368
|
|
|
$rsm->addScalarResult('id', 'id', 'integer'); |
|
369
|
|
|
|
|
370
|
|
|
$borderCriteria = $isAtBorder ? |
|
371
|
|
|
sprintf( |
|
372
|
|
|
'AND (l.cx in (1, %d) OR l.cy in (1, %d))', |
|
373
|
|
|
$layer->getWidth(), |
|
374
|
|
|
$layer->getHeight() |
|
375
|
|
|
) : ''; |
|
376
|
|
|
|
|
377
|
|
|
$randomMapId = (int)$this->getEntityManager() |
|
378
|
|
|
->createNativeQuery( |
|
379
|
|
|
sprintf( |
|
380
|
|
|
'SELECT m.id |
|
381
|
|
|
FROM stu_map m |
|
382
|
|
|
JOIN stu_location l |
|
383
|
|
|
ON m.id = l.id |
|
384
|
|
|
JOIN stu_map_ftypes mft |
|
385
|
|
|
ON l.field_id = mft.id |
|
386
|
|
|
WHERE NOT EXISTS (SELECT s.id FROM stu_spacecraft s WHERE s.location_id = m.id) |
|
387
|
|
|
AND l.layer_id = :layerId |
|
388
|
|
|
AND mft.x_damage = 0 |
|
389
|
|
|
AND mft.passable = :true |
|
390
|
|
|
%s |
|
391
|
|
|
ORDER BY RANDOM() |
|
392
|
|
|
LIMIT 1', |
|
393
|
|
|
$borderCriteria |
|
394
|
|
|
), |
|
395
|
|
|
$rsm |
|
396
|
|
|
) |
|
397
|
|
|
->setParameters([ |
|
398
|
|
|
'layerId' => $layer->getId(), |
|
399
|
|
|
'true' => true |
|
400
|
|
|
]) |
|
401
|
|
|
->getSingleScalarResult(); |
|
402
|
|
|
|
|
403
|
|
|
$map = $this->find($randomMapId); |
|
404
|
|
|
if ($map === null) { |
|
405
|
|
|
throw new RuntimeException('this should not happen'); |
|
406
|
|
|
} |
|
407
|
|
|
|
|
408
|
|
|
return $map; |
|
409
|
|
|
} |
|
410
|
|
|
|
|
411
|
|
|
#[Override] |
|
412
|
|
|
public function getIgnoringSubspaceLayerData(PanelBoundaries $boundaries, int $ignoreId, ResultSetMapping $rsm): array |
|
413
|
|
|
{ |
|
414
|
|
|
$maxAge = time() - FlightSignatureVisibilityEnum::SIG_VISIBILITY_UNCLOAKED; |
|
415
|
|
|
|
|
416
|
|
|
return $this->getEntityManager()->createNativeQuery( |
|
417
|
|
|
sprintf( |
|
418
|
|
|
'SELECT l.cx AS x, l.cy AS y, |
|
419
|
|
|
(SELECT count(distinct fs1.ship_id) from stu_flight_sig fs1 |
|
420
|
|
|
WHERE fs1.location_id = l.id |
|
421
|
|
|
AND fs1.user_id != %1$d |
|
422
|
|
|
AND (fs1.from_direction = 1 OR fs1.to_direction = 1) |
|
423
|
|
|
AND fs1.time > %2$d) as d1c, |
|
424
|
|
|
(SELECT count(distinct fs2.ship_id) from stu_flight_sig fs2 |
|
425
|
|
|
WHERE fs2.location_id = l.id |
|
426
|
|
|
AND fs2.user_id != %1$d |
|
427
|
|
|
AND (fs2.from_direction = 2 OR fs2.to_direction = 2) |
|
428
|
|
|
AND fs2.time > %2$d) as d2c, |
|
429
|
|
|
(SELECT count(distinct fs3.ship_id) from stu_flight_sig fs3 |
|
430
|
|
|
WHERE fs3.location_id = l.id |
|
431
|
|
|
AND fs3.user_id != %1$d |
|
432
|
|
|
AND (fs3.from_direction = 3 OR fs3.to_direction = 3) |
|
433
|
|
|
AND fs3.time > %2$d) as d3c, |
|
434
|
|
|
(SELECT count(distinct fs4.ship_id) from stu_flight_sig fs4 |
|
435
|
|
|
WHERE fs4.location_id = l.id |
|
436
|
|
|
AND fs4.user_id != %1$d |
|
437
|
|
|
AND (fs4.from_direction = 4 OR fs4.to_direction = 4) |
|
438
|
|
|
AND fs4.time > %2$d) as d4c |
|
439
|
|
|
FROM stu_location l |
|
440
|
|
|
WHERE l.cx BETWEEN :xStart AND :xEnd |
|
441
|
|
|
AND l.cy BETWEEN :yStart AND :yEnd |
|
442
|
|
|
AND l.layer_id = :layerId', |
|
443
|
|
|
$ignoreId, |
|
444
|
|
|
$maxAge |
|
445
|
|
|
), |
|
446
|
|
|
$rsm |
|
447
|
|
|
)->setParameters([ |
|
448
|
|
|
'xStart' => $boundaries->getMinX(), |
|
449
|
|
|
'xEnd' => $boundaries->getMaxX(), |
|
450
|
|
|
'yStart' => $boundaries->getMinY(), |
|
451
|
|
|
'yEnd' => $boundaries->getMaxY(), |
|
452
|
|
|
'layerId' => $boundaries->getParentId(), |
|
453
|
|
|
])->getResult(); |
|
454
|
|
|
} |
|
455
|
|
|
|
|
456
|
|
|
#[Override] |
|
457
|
|
|
public function getSubspaceLayerData(PanelBoundaries $boundaries, ResultSetMapping $rsm): array |
|
458
|
|
|
{ |
|
459
|
|
|
return $this->getEntityManager()->createNativeQuery( |
|
460
|
|
|
'SELECT l.cx as x, l.cy as y, |
|
461
|
|
|
(SELECT count(distinct fs1.ship_id) from stu_flight_sig fs1 |
|
462
|
|
|
WHERE fs1.location_id = l.id |
|
463
|
|
|
AND (fs1.from_direction = 1 OR fs1.to_direction = 1)) as d1c, |
|
464
|
|
|
(SELECT count(distinct fs2.ship_id) from stu_flight_sig fs2 |
|
465
|
|
|
WHERE fs2.location_id = l.id |
|
466
|
|
|
AND (fs2.from_direction = 2 OR fs2.to_direction = 2)) as d2c, |
|
467
|
|
|
(SELECT count(distinct fs3.ship_id) from stu_flight_sig fs3 |
|
468
|
|
|
WHERE fs3.location_id = l.id |
|
469
|
|
|
AND (fs3.from_direction = 3 OR fs3.to_direction = 3)) as d3c, |
|
470
|
|
|
(SELECT count(distinct fs4.ship_id) from stu_flight_sig fs4 |
|
471
|
|
|
WHERE fs4.location_id = l.id |
|
472
|
|
|
AND (fs4.from_direction = 4 OR fs4.to_direction = 4)) as d4c |
|
473
|
|
|
FROM stu_location l |
|
474
|
|
|
WHERE l.cx BETWEEN :xStart AND :xEnd |
|
475
|
|
|
AND l.cy BETWEEN :yStart AND :yEnd |
|
476
|
|
|
AND l.layer_id = :layerId', |
|
477
|
|
|
$rsm |
|
478
|
|
|
)->setParameters([ |
|
479
|
|
|
'xStart' => $boundaries->getMinX(), |
|
480
|
|
|
'xEnd' => $boundaries->getMaxX(), |
|
481
|
|
|
'yStart' => $boundaries->getMinY(), |
|
482
|
|
|
'yEnd' => $boundaries->getMaxY(), |
|
483
|
|
|
'layerId' => $boundaries->getParentId() |
|
484
|
|
|
])->getResult(); |
|
485
|
|
|
} |
|
486
|
|
|
|
|
487
|
|
|
#[Override] |
|
488
|
|
|
public function getUserSubspaceLayerData(PanelBoundaries $boundaries, int $userId, ResultSetMapping $rsm): array |
|
489
|
|
|
{ |
|
490
|
|
|
return $this->getEntityManager()->createNativeQuery( |
|
491
|
|
|
'SELECT l.cx as x, l.cy as y, |
|
492
|
|
|
(SELECT count(distinct fs1.ship_id) from stu_flight_sig fs1 |
|
493
|
|
|
WHERE fs1.location_id = l.id |
|
494
|
|
|
AND fs1.user_id = :userId |
|
495
|
|
|
AND (fs1.from_direction = 1 OR fs1.to_direction = 1)) as d1c, |
|
496
|
|
|
(SELECT count(distinct fs2.ship_id) from stu_flight_sig fs2 |
|
497
|
|
|
WHERE fs2.location_id = l.id |
|
498
|
|
|
AND fs2.user_id = :userId |
|
499
|
|
|
AND (fs2.from_direction = 2 OR fs2.to_direction = 2)) as d2c, |
|
500
|
|
|
(SELECT count(distinct fs3.ship_id) from stu_flight_sig fs3 |
|
501
|
|
|
WHERE fs3.location_id = l.id |
|
502
|
|
|
AND fs3.user_id = :userId |
|
503
|
|
|
AND (fs3.from_direction = 3 OR fs3.to_direction = 3)) as d3c, |
|
504
|
|
|
(SELECT count(distinct fs4.ship_id) from stu_flight_sig fs4 |
|
505
|
|
|
WHERE fs4.location_id = l.id |
|
506
|
|
|
AND fs4.user_id = :userId |
|
507
|
|
|
AND (fs4.from_direction = 4 OR fs4.to_direction = 4)) as d4c |
|
508
|
|
|
FROM stu_location l |
|
509
|
|
|
WHERE l.cx BETWEEN :xStart AND :xEnd |
|
510
|
|
|
AND l.cy BETWEEN :yStart AND :yEnd |
|
511
|
|
|
AND l.layer_id = :layerId', |
|
512
|
|
|
$rsm |
|
513
|
|
|
)->setParameters([ |
|
514
|
|
|
'xStart' => $boundaries->getMinX(), |
|
515
|
|
|
'xEnd' => $boundaries->getMaxX(), |
|
516
|
|
|
'yStart' => $boundaries->getMinY(), |
|
517
|
|
|
'yEnd' => $boundaries->getMaxY(), |
|
518
|
|
|
'layerId' => $boundaries->getParentId(), |
|
519
|
|
|
'userId' => $userId |
|
520
|
|
|
])->getResult(); |
|
521
|
|
|
} |
|
522
|
|
|
|
|
523
|
|
|
#[Override] |
|
524
|
|
|
public function getShipSubspaceLayerData(PanelBoundaries $boundaries, int $shipId, ResultSetMapping $rsm): array |
|
525
|
|
|
{ |
|
526
|
|
|
return $this->getEntityManager()->createNativeQuery( |
|
527
|
|
|
'SELECT l.cx as x, l.cy as y, |
|
528
|
|
|
(SELECT count(distinct fs1.ship_id) from stu_flight_sig fs1 |
|
529
|
|
|
WHERE fs1.location_id = l.id |
|
530
|
|
|
AND fs1.ship_id = :shipId |
|
531
|
|
|
AND (fs1.from_direction = 1 OR fs1.to_direction = 1)) as d1c, |
|
532
|
|
|
(SELECT count(distinct fs2.ship_id) from stu_flight_sig fs2 |
|
533
|
|
|
WHERE fs2.location_id = l.id |
|
534
|
|
|
AND fs2.ship_id = :shipId |
|
535
|
|
|
AND (fs2.from_direction = 2 OR fs2.to_direction = 2)) as d2c, |
|
536
|
|
|
(SELECT count(distinct fs3.ship_id) from stu_flight_sig fs3 |
|
537
|
|
|
WHERE fs3.location_id = l.id |
|
538
|
|
|
AND fs3.ship_id = :shipId |
|
539
|
|
|
AND (fs3.from_direction = 3 OR fs3.to_direction = 3)) as d3c, |
|
540
|
|
|
(SELECT count(distinct fs4.ship_id) from stu_flight_sig fs4 |
|
541
|
|
|
WHERE fs4.location_id = l.id |
|
542
|
|
|
AND fs4.ship_id = :shipId |
|
543
|
|
|
AND (fs4.from_direction = 4 OR fs4.to_direction = 4)) as d4c |
|
544
|
|
|
FROM stu_location l |
|
545
|
|
|
WHERE l.cx BETWEEN :xStart AND :xEnd |
|
546
|
|
|
AND l.cy BETWEEN :yStart AND :yEnd |
|
547
|
|
|
AND l.layer_id = :layerId', |
|
548
|
|
|
$rsm |
|
549
|
|
|
)->setParameters([ |
|
550
|
|
|
'xStart' => $boundaries->getMinX(), |
|
551
|
|
|
'xEnd' => $boundaries->getMaxX(), |
|
552
|
|
|
'yStart' => $boundaries->getMinY(), |
|
553
|
|
|
'yEnd' => $boundaries->getMaxY(), |
|
554
|
|
|
'layerId' => $boundaries->getParentId(), |
|
555
|
|
|
'shipId' => $shipId |
|
556
|
|
|
])->getResult(); |
|
557
|
|
|
} |
|
558
|
|
|
|
|
559
|
|
|
#[Override] |
|
560
|
|
|
public function getAllianceSubspaceLayerData(PanelBoundaries $boundaries, int $allianceId, ResultSetMapping $rsm): array |
|
561
|
|
|
{ |
|
562
|
|
|
return $this->getEntityManager()->createNativeQuery( |
|
563
|
|
|
'SELECT l.id, l.cx as x, l.cy as y, |
|
564
|
|
|
(SELECT count(distinct fs1.ship_id) from stu_flight_sig fs1 |
|
565
|
|
|
JOIN stu_user u1 ON fs1.user_id = u1.id |
|
566
|
|
|
WHERE fs1.location_id = l.id |
|
567
|
|
|
AND u1.allys_id = :allyId |
|
568
|
|
|
AND (fs1.from_direction = 1 OR fs1.to_direction = 1)) as d1c, |
|
569
|
|
|
(SELECT count(distinct fs2.ship_id) from stu_flight_sig fs2 |
|
570
|
|
|
JOIN stu_user u2 ON fs2.user_id = u2.id |
|
571
|
|
|
WHERE fs2.location_id = l.id |
|
572
|
|
|
AND u2.allys_id = :allyId |
|
573
|
|
|
AND (fs2.from_direction = 2 OR fs2.to_direction = 2)) as d2c, |
|
574
|
|
|
(SELECT count(distinct fs3.ship_id) from stu_flight_sig fs3 |
|
575
|
|
|
JOIN stu_user u3 ON fs3.user_id = u3.id |
|
576
|
|
|
WHERE fs3.location_id = l.id |
|
577
|
|
|
AND u3.allys_id = :allyId |
|
578
|
|
|
AND (fs3.from_direction = 3 OR fs3.to_direction = 3)) as d3c, |
|
579
|
|
|
(SELECT count(distinct fs4.ship_id) from stu_flight_sig fs4 |
|
580
|
|
|
JOIN stu_user u4 ON fs4.user_id = u4.id |
|
581
|
|
|
WHERE fs4.location_id = l.id |
|
582
|
|
|
AND u4.allys_id = :allyId |
|
583
|
|
|
AND (fs4.from_direction = 4 OR fs4.to_direction = 4)) as d4c |
|
584
|
|
|
FROM stu_location l |
|
585
|
|
|
WHERE l.cx BETWEEN :xStart AND :xEnd |
|
586
|
|
|
AND l.cy BETWEEN :yStart AND :yEnd |
|
587
|
|
|
AND l.layer_id = :layerId', |
|
588
|
|
|
$rsm |
|
589
|
|
|
)->setParameters([ |
|
590
|
|
|
'xStart' => $boundaries->getMinX(), |
|
591
|
|
|
'xEnd' => $boundaries->getMaxX(), |
|
592
|
|
|
'yStart' => $boundaries->getMinY(), |
|
593
|
|
|
'yEnd' => $boundaries->getMaxY(), |
|
594
|
|
|
'layerId' => $boundaries->getParentId(), |
|
595
|
|
|
'allyId' => $allianceId |
|
596
|
|
|
])->getResult(); |
|
597
|
|
|
} |
|
598
|
|
|
|
|
599
|
1 |
|
public function getUniqueInfluenceAreaIds(): array |
|
600
|
|
|
{ |
|
601
|
1 |
|
$rsm = new ResultSetMapping(); |
|
602
|
1 |
|
$rsm->addScalarResult('influence_area_id', 'influence_area_id', 'integer'); |
|
603
|
|
|
|
|
604
|
1 |
|
$query = $this->getEntityManager()->createNativeQuery( |
|
605
|
1 |
|
'SELECT DISTINCT influence_area_id |
|
606
|
|
|
FROM stu_map |
|
607
|
|
|
WHERE influence_area_id IS NOT NULL |
|
608
|
1 |
|
ORDER BY influence_area_id ASC', |
|
609
|
1 |
|
$rsm |
|
610
|
1 |
|
); |
|
611
|
|
|
|
|
612
|
1 |
|
return array_map('intval', array_column($query->getResult(), 'influence_area_id')); |
|
613
|
|
|
} |
|
614
|
|
|
} |
|
615
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths