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 Stu\Component\Building\BuildingFunctionEnum; |
11
|
|
|
use Stu\Component\Ship\AstronomicalMappingEnum; |
|
|
|
|
12
|
|
|
use Stu\Component\Ship\FlightSignatureVisibilityEnum; |
|
|
|
|
13
|
|
|
use Stu\Component\Spacecraft\System\SpacecraftSystemTypeEnum; |
14
|
|
|
use Stu\Lib\Map\VisualPanel\PanelBoundaries; |
15
|
|
|
use Stu\Module\PlayerSetting\Lib\UserEnum; |
|
|
|
|
16
|
|
|
use Stu\Orm\Entity\StarSystem; |
17
|
|
|
use Stu\Orm\Entity\StarSystemMap; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @extends EntityRepository<StarSystemMap> |
21
|
|
|
*/ |
22
|
|
|
final class StarSystemMapRepository extends EntityRepository implements StarSystemMapRepositoryInterface |
23
|
|
|
{ |
24
|
|
|
#[Override] |
25
|
|
|
public function getBySystemOrdered(int $starSystemId): array |
26
|
|
|
{ |
27
|
|
|
return $this->findBy( |
28
|
|
|
['systems_id' => $starSystemId], |
29
|
|
|
['sy' => 'asc', 'sx' => 'asc'] |
30
|
|
|
); |
31
|
|
|
} |
32
|
|
|
|
33
|
2 |
|
#[Override] |
34
|
|
|
public function getByCoordinates( |
35
|
|
|
int $starSystemId, |
36
|
|
|
int $sx, |
37
|
|
|
int $sy |
38
|
|
|
): ?StarSystemMap { |
39
|
2 |
|
return $this->findOneBy([ |
40
|
2 |
|
'systems_id' => $starSystemId, |
41
|
2 |
|
'sx' => $sx, |
42
|
2 |
|
'sy' => $sy |
43
|
2 |
|
]); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
#[Override] |
47
|
|
|
public function getByBoundaries(PanelBoundaries $boundaries): array |
48
|
|
|
{ |
49
|
|
|
return $this->getByCoordinateRange( |
50
|
|
|
$boundaries->getParentId(), |
51
|
|
|
$boundaries->getMinX(), |
52
|
|
|
$boundaries->getMaxX(), |
53
|
|
|
$boundaries->getMinY(), |
54
|
|
|
$boundaries->getMaxY() |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
#[Override] |
59
|
|
|
public function getByCoordinateRange( |
60
|
|
|
int $starSystemId, |
61
|
|
|
int $startSx, |
62
|
|
|
int $endSx, |
63
|
|
|
int $startSy, |
64
|
|
|
int $endSy, |
65
|
|
|
bool $sortAscending = true |
66
|
|
|
): array { |
67
|
|
|
return $this->getEntityManager() |
68
|
|
|
->createQuery( |
69
|
|
|
sprintf( |
70
|
|
|
'SELECT m FROM %1$s m |
71
|
|
|
WHERE m.systems_id = :starSystemId AND |
72
|
|
|
m.sx BETWEEN :startSx AND :endSx AND |
73
|
|
|
m.sy BETWEEN :startSy AND :endSy |
74
|
|
|
ORDER BY m.sy %2$s, m.sx %2$s', |
75
|
|
|
StarSystemMap::class, |
76
|
|
|
$sortAscending ? 'ASC' : 'DESC' |
77
|
|
|
) |
78
|
|
|
) |
79
|
|
|
->setParameters([ |
80
|
|
|
'starSystemId' => $starSystemId, |
81
|
|
|
'startSx' => $startSx, |
82
|
|
|
'endSx' => $endSx, |
83
|
|
|
'startSy' => $startSy, |
84
|
|
|
'endSy' => $endSy |
85
|
|
|
]) |
86
|
|
|
->getResult(); |
87
|
|
|
} |
88
|
|
|
|
89
|
4 |
|
#[Override] |
90
|
|
|
public function getMapLayerData(PanelBoundaries $boundaries, ResultSetMapping $rsm): array |
91
|
|
|
{ |
92
|
4 |
|
return $this->getEntityManager()->createNativeQuery( |
93
|
4 |
|
'SELECT sm.sx as x, sm.sy AS y, ft.type |
94
|
|
|
FROM stu_sys_map sm |
95
|
|
|
JOIN stu_location l |
96
|
|
|
ON sm.id = l.id |
97
|
|
|
JOIN stu_map_ftypes ft ON ft.id = l.field_id |
98
|
|
|
WHERE sm.sx BETWEEN :xStart AND :xEnd AND sm.sy BETWEEN :yStart AND :yEnd |
99
|
4 |
|
AND sm.systems_id = :systemId', |
100
|
4 |
|
$rsm |
101
|
4 |
|
)->setParameters([ |
102
|
4 |
|
'xStart' => $boundaries->getMinX(), |
103
|
4 |
|
'xEnd' => $boundaries->getMaxX(), |
104
|
4 |
|
'yStart' => $boundaries->getMinY(), |
105
|
4 |
|
'yEnd' => $boundaries->getMaxY(), |
106
|
4 |
|
'systemId' => $boundaries->getParentId() |
107
|
4 |
|
])->getResult(); |
108
|
|
|
} |
109
|
|
|
|
110
|
4 |
|
#[Override] |
111
|
|
|
public function getSpacecraftCountLayerData(PanelBoundaries $boundaries, ResultSetMapping $rsm): array |
112
|
|
|
{ |
113
|
4 |
|
return $this->getEntityManager()->createNativeQuery( |
114
|
4 |
|
'SELECT sm.id, sm.sx as x, sm.sy AS y, |
115
|
|
|
(SELECT count(DISTINCT b.id) FROM stu_spacecraft b |
116
|
|
|
WHERE sm.id = b.location_id |
117
|
|
|
AND NOT EXISTS (SELECT ss.id |
118
|
|
|
FROM stu_spacecraft_system ss |
119
|
|
|
WHERE b.id = ss.spacecraft_id |
120
|
|
|
AND ss.system_type = :cloakSystemId |
121
|
|
|
AND ss.mode > 1)) AS spacecraftcount, |
122
|
|
|
(SELECT count(DISTINCT c.id) FROM stu_spacecraft c |
123
|
|
|
WHERE sm.id = c.location_id |
124
|
|
|
AND EXISTS (SELECT ss2.id |
125
|
|
|
FROM stu_spacecraft_system ss2 |
126
|
|
|
WHERE c.id = ss2.spacecraft_id |
127
|
|
|
AND ss2.system_type = :cloakSystemId |
128
|
|
|
AND ss2.mode > 1)) AS cloakcount, |
129
|
|
|
(SELECT mft.effects FROM stu_map_ftypes mft |
130
|
|
|
WHERE l.field_id = mft.id) as effects |
131
|
|
|
FROM stu_sys_map sm |
132
|
|
|
JOIN stu_location l |
133
|
|
|
ON sm.id = l.id |
134
|
|
|
WHERE sm.sx BETWEEN :xStart AND :xEnd AND sm.sy BETWEEN :yStart AND :yEnd |
135
|
|
|
AND sm.systems_id = :systemId |
136
|
4 |
|
GROUP BY sm.id, sm.sy, sm.sx, l.field_id', |
137
|
4 |
|
$rsm |
138
|
4 |
|
)->setParameters([ |
139
|
4 |
|
'xStart' => $boundaries->getMinX(), |
140
|
4 |
|
'xEnd' => $boundaries->getMaxX(), |
141
|
4 |
|
'yStart' => $boundaries->getMinY(), |
142
|
4 |
|
'yEnd' => $boundaries->getMaxY(), |
143
|
4 |
|
'systemId' => $boundaries->getParentId(), |
144
|
4 |
|
'cloakSystemId' => SpacecraftSystemTypeEnum::CLOAK->value |
145
|
4 |
|
])->getResult(); |
146
|
|
|
} |
147
|
|
|
|
148
|
4 |
|
#[Override] |
149
|
|
|
public function getColonyShieldData(PanelBoundaries $boundaries, ResultSetMapping $rsm): array |
150
|
|
|
{ |
151
|
4 |
|
return $this->getEntityManager()->createNativeQuery( |
152
|
4 |
|
'SELECT sm.sx as x, sm.sy AS y, |
153
|
|
|
(SELECT COUNT(*) > 0 |
154
|
|
|
FROM stu_colony col |
155
|
|
|
JOIN stu_colonies_fielddata cfd |
156
|
|
|
ON col.id = cfd.colonies_id |
157
|
|
|
WHERE sm.id = col.starsystem_map_id |
158
|
|
|
AND cfd.aktiv = :active |
159
|
|
|
AND cfd.buildings_id IN ( |
160
|
|
|
SELECT bf.buildings_id |
161
|
|
|
FROM stu_buildings_functions bf |
162
|
|
|
WHERE bf.function = :shieldBuilding)) AS shieldstate |
163
|
|
|
FROM stu_sys_map sm |
164
|
|
|
WHERE sm.systems_id = :systemId |
165
|
4 |
|
AND sm.sx BETWEEN :xStart AND :xEnd AND sm.sy BETWEEN :yStart AND :yEnd', |
166
|
4 |
|
$rsm |
167
|
4 |
|
)->setParameters([ |
168
|
4 |
|
'xStart' => $boundaries->getMinX(), |
169
|
4 |
|
'xEnd' => $boundaries->getMaxX(), |
170
|
4 |
|
'yStart' => $boundaries->getMinY(), |
171
|
4 |
|
'yEnd' => $boundaries->getMaxY(), |
172
|
4 |
|
'systemId' => $boundaries->getParentId(), |
173
|
4 |
|
'active' => 1, |
174
|
4 |
|
'shieldBuilding' => BuildingFunctionEnum::SHIELD_GENERATOR |
175
|
4 |
|
])->getResult(); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
#[Override] |
179
|
|
|
public function getNormalBorderData(PanelBoundaries $boundaries, ResultSetMapping $rsm): array |
180
|
|
|
{ |
181
|
|
|
return $this->getEntityManager()->createNativeQuery( |
182
|
|
|
'SELECT sm.sx AS x, sm.sy AS y |
183
|
|
|
FROM stu_sys_map sm |
184
|
|
|
WHERE sm.systems_id = :systemId |
185
|
|
|
AND sm.sx BETWEEN :xStart AND :xEnd |
186
|
|
|
AND sm.sy BETWEEN :yStart AND :yEnd', |
187
|
|
|
$rsm |
188
|
|
|
)->setParameters([ |
189
|
|
|
'xStart' => $boundaries->getMinX(), |
190
|
|
|
'xEnd' => $boundaries->getMaxX(), |
191
|
|
|
'yStart' => $boundaries->getMinY(), |
192
|
|
|
'yEnd' => $boundaries->getMaxY(), |
193
|
|
|
'systemId' => $boundaries->getParentId() |
194
|
|
|
])->getResult(); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
#[Override] |
198
|
|
|
public function getRegionBorderData(PanelBoundaries $boundaries, ResultSetMapping $rsm): array |
199
|
|
|
{ |
200
|
|
|
return $this->getEntityManager()->createNativeQuery( |
201
|
|
|
'SELECT sm.sx AS x, sm.sy AS y |
202
|
|
|
FROM stu_sys_map sm |
203
|
|
|
WHERE sm.systems_id = :systemId |
204
|
|
|
AND sm.sx BETWEEN :xStart AND :xEnd |
205
|
|
|
AND sm.sy BETWEEN :yStart AND :yEnd', |
206
|
|
|
$rsm |
207
|
|
|
)->setParameters([ |
208
|
|
|
'xStart' => $boundaries->getMinX(), |
209
|
|
|
'xEnd' => $boundaries->getMaxX(), |
210
|
|
|
'yStart' => $boundaries->getMinY(), |
211
|
|
|
'yEnd' => $boundaries->getMaxY(), |
212
|
|
|
'systemId' => $boundaries->getParentId() |
213
|
|
|
])->getResult(); |
214
|
|
|
} |
215
|
|
|
|
216
|
|
|
// TODO: Show impassable only for cartographed systems. |
217
|
|
|
// Currently, it does not display any impassable areas. |
218
|
|
|
#[Override] |
219
|
|
|
public function getImpassableBorderData(PanelBoundaries $boundaries, ResultSetMapping $rsm): array |
220
|
|
|
{ |
221
|
|
|
return $this->getEntityManager()->createNativeQuery( |
222
|
|
|
'SELECT sm.sx AS x, sm.sy AS y, TRUE AS impassable, |
223
|
|
|
(SELECT mft.complementary_color FROM stu_map_ftypes mft JOIN stu_location l on l.id = sm.id where mft.id = l.field_id) AS complementary_color |
224
|
|
|
FROM stu_sys_map sm |
225
|
|
|
WHERE sm.systems_id = :systemId |
226
|
|
|
AND sm.sx BETWEEN :xStart AND :xEnd |
227
|
|
|
AND sm.sy BETWEEN :yStart AND :yEnd', |
228
|
|
|
$rsm |
229
|
|
|
)->setParameters([ |
230
|
|
|
'xStart' => $boundaries->getMinX(), |
231
|
|
|
'xEnd' => $boundaries->getMaxX(), |
232
|
|
|
'yStart' => $boundaries->getMinY(), |
233
|
|
|
'yEnd' => $boundaries->getMaxY(), |
234
|
|
|
'systemId' => $boundaries->getParentId() |
235
|
|
|
])->getResult(); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
#[Override] |
239
|
|
|
public function getCartographingData(PanelBoundaries $boundaries, ResultSetMapping $rsm, array $locations): array |
240
|
|
|
{ |
241
|
|
|
return $this->getEntityManager()->createNativeQuery( |
242
|
|
|
'SELECT DISTINCT |
243
|
|
|
sm.sx AS x, |
244
|
|
|
sm.sy AS y, |
245
|
|
|
CASE |
246
|
|
|
WHEN sm.id IN (:fieldIds) THEN TRUE ELSE FALSE |
247
|
|
|
END AS cartographing, |
248
|
|
|
(SELECT mft.complementary_color FROM stu_map_ftypes mft JOIN stu_location l on l.id = sm.id where mft.id = l.field_id) AS complementary_color |
249
|
|
|
FROM stu_sys_map sm |
250
|
|
|
WHERE sm.sx BETWEEN :xStart AND :xEnd |
251
|
|
|
AND sm.sy BETWEEN :yStart AND :yEnd |
252
|
|
|
AND sm.systems_id = :systemId |
253
|
|
|
ORDER BY cartographing DESC', |
254
|
|
|
$rsm |
255
|
|
|
)->setParameters([ |
256
|
|
|
'xStart' => $boundaries->getMinX(), |
257
|
|
|
'xEnd' => $boundaries->getMaxX(), |
258
|
|
|
'yStart' => $boundaries->getMinY(), |
259
|
|
|
'yEnd' => $boundaries->getMaxY(), |
260
|
|
|
'systemId' => $boundaries->getParentId(), |
261
|
|
|
'fieldIds' => $locations |
262
|
|
|
])->getResult(); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
|
266
|
|
|
#[Override] |
267
|
|
|
public function getAnomalyData(PanelBoundaries $boundaries, ResultSetMapping $rsm): array |
268
|
|
|
{ |
269
|
|
|
return $this->getEntityManager()->createNativeQuery( |
270
|
|
|
'SELECT sm.sx AS x, sm.sy AS y, |
271
|
|
|
(SELECT array_to_string(array(SELECT a.anomaly_type_id FROM stu_anomaly a WHERE a.location_id = sm.id), \',\')) as anomalytypes |
272
|
|
|
FROM stu_sys_map sm |
273
|
|
|
WHERE sm.systems_id = :systemId |
274
|
|
|
AND sm.sx BETWEEN :xStart AND :xEnd |
275
|
|
|
AND sm.sy BETWEEN :yStart AND :yEnd', |
276
|
|
|
$rsm |
277
|
|
|
)->setParameters([ |
278
|
|
|
'xStart' => $boundaries->getMinX(), |
279
|
|
|
'xEnd' => $boundaries->getMaxX(), |
280
|
|
|
'yStart' => $boundaries->getMinY(), |
281
|
|
|
'yEnd' => $boundaries->getMaxY(), |
282
|
|
|
'systemId' => $boundaries->getParentId() |
283
|
|
|
])->getResult(); |
284
|
|
|
} |
285
|
|
|
|
286
|
4 |
|
#[Override] |
287
|
|
|
public function getLssBlockadeLocations(PanelBoundaries $boundaries): array |
288
|
|
|
{ |
289
|
4 |
|
$rsm = new ResultSetMapping(); |
290
|
4 |
|
$rsm->addScalarResult('sx', 'x', 'integer'); |
291
|
4 |
|
$rsm->addScalarResult('sy', 'y', 'integer'); |
292
|
4 |
|
$rsm->addScalarResult('effects', 'effects', 'string'); |
293
|
|
|
|
294
|
4 |
|
return $this->getEntityManager()->createNativeQuery( |
295
|
4 |
|
'WITH bbox AS ( |
296
|
|
|
SELECT id, sx, sy |
297
|
|
|
FROM stu_sys_map |
298
|
|
|
WHERE systems_id = :systemId |
299
|
|
|
AND sx BETWEEN :xStart AND :xEnd |
300
|
|
|
AND sy BETWEEN :yStart AND :yEnd |
301
|
|
|
) |
302
|
|
|
SELECT sm.sx, sm.sy, mft.effects |
303
|
|
|
FROM bbox sm |
304
|
|
|
JOIN stu_location l ON sm.id = l.id |
305
|
4 |
|
JOIN stu_map_ftypes mft ON mft.id = l.field_id', |
306
|
4 |
|
$rsm |
307
|
4 |
|
)->setParameters([ |
308
|
4 |
|
'xStart' => $boundaries->getMinX(), |
309
|
4 |
|
'xEnd' => $boundaries->getMaxX(), |
310
|
4 |
|
'yStart' => $boundaries->getMinY(), |
311
|
4 |
|
'yEnd' => $boundaries->getMaxY(), |
312
|
4 |
|
'systemId' => $boundaries->getParentId() |
313
|
4 |
|
])->getResult(); |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
#[Override] |
317
|
|
|
public function getIgnoringSubspaceLayerData(PanelBoundaries $boundaries, int $ignoreUserId, ResultSetMapping $rsm): array |
318
|
|
|
{ |
319
|
|
|
$maxAge = time() - FlightSignatureVisibilityEnum::SIG_VISIBILITY_UNCLOAKED; |
320
|
|
|
|
321
|
|
|
return $this->getEntityManager()->createNativeQuery( |
322
|
|
|
'SELECT sm.sx as x, sm.sy AS y, mft.effects as effects, |
323
|
|
|
(select count(distinct fs1.ship_id) from stu_flight_sig fs1 |
324
|
|
|
where fs1.location_id = sm.id |
325
|
|
|
AND fs1.user_id != :ignoreUserId |
326
|
|
|
AND (fs1.from_direction = 1 OR fs1.to_direction = 1) |
327
|
|
|
AND fs1.time > :timeThreshold) as d1c, |
328
|
|
|
(select count(distinct fs2.ship_id) from stu_flight_sig fs2 |
329
|
|
|
where fs2.location_id = sm.id |
330
|
|
|
AND fs2.user_id != :ignoreUserId |
331
|
|
|
AND (fs2.from_direction = 2 OR fs2.to_direction = 2) |
332
|
|
|
AND fs2.time > :timeThreshold) as d2c, |
333
|
|
|
(select count(distinct fs3.ship_id) from stu_flight_sig fs3 |
334
|
|
|
where fs3.location_id = sm.id |
335
|
|
|
AND fs3.user_id != :ignoreUserId |
336
|
|
|
AND (fs3.from_direction = 3 OR fs3.to_direction = 3) |
337
|
|
|
AND fs3.time > :timeThreshold) as d3c, |
338
|
|
|
(select count(distinct fs4.ship_id) from stu_flight_sig fs4 |
339
|
|
|
where fs4.location_id = sm.id |
340
|
|
|
AND fs4.user_id != :ignoreUserId |
341
|
|
|
AND (fs4.from_direction = 4 OR fs4.to_direction = 4) |
342
|
|
|
AND fs4.time > :timeThreshold) as d4c |
343
|
|
|
FROM stu_sys_map sm |
344
|
|
|
JOIN stu_location l |
345
|
|
|
ON sm.id = l.id |
346
|
|
|
JOIN stu_map_ftypes mft |
347
|
|
|
ON l.field_id = mft.id |
348
|
|
|
WHERE sm.systems_id = :systemId |
349
|
|
|
AND sm.sx BETWEEN :xStart AND :xEnd AND sm.sy BETWEEN :yStart AND :yEnd', |
350
|
|
|
$rsm |
351
|
|
|
)->setParameters([ |
352
|
|
|
'xStart' => $boundaries->getMinX(), |
353
|
|
|
'xEnd' => $boundaries->getMaxX(), |
354
|
|
|
'yStart' => $boundaries->getMinY(), |
355
|
|
|
'yEnd' => $boundaries->getMaxY(), |
356
|
|
|
'systemId' => $boundaries->getParentId(), |
357
|
|
|
'ignoreUserId' => $ignoreUserId, |
358
|
|
|
'timeThreshold' => $maxAge |
359
|
|
|
])->getResult(); |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
#[Override] |
363
|
|
|
public function getShipSubspaceLayerData(PanelBoundaries $boundaries, int $shipId, ResultSetMapping $rsm): array |
364
|
|
|
{ |
365
|
|
|
$maxAge = time() - FlightSignatureVisibilityEnum::SIG_VISIBILITY_UNCLOAKED; |
366
|
|
|
|
367
|
|
|
return $this->getEntityManager()->createNativeQuery( |
368
|
|
|
'SELECT l.cx as x, l.cy as y, mft.effects as effects, |
369
|
|
|
(SELECT count(distinct fs1.ship_id) from stu_flight_sig fs1 |
370
|
|
|
WHERE fs1.location_id = l.id |
371
|
|
|
AND fs1.ship_id = :shipId |
372
|
|
|
AND (fs1.from_direction = 1 OR fs1.to_direction = 1) |
373
|
|
|
AND fs1.time > :timeThreshold) as d1c, |
374
|
|
|
(SELECT count(distinct fs2.ship_id) from stu_flight_sig fs2 |
375
|
|
|
WHERE fs2.location_id = l.id |
376
|
|
|
AND fs2.ship_id = :shipId |
377
|
|
|
AND (fs2.from_direction = 2 OR fs2.to_direction = 2) |
378
|
|
|
AND fs2.time > :timeThreshold) as d2c, |
379
|
|
|
(SELECT count(distinct fs3.ship_id) from stu_flight_sig fs3 |
380
|
|
|
WHERE fs3.location_id = l.id |
381
|
|
|
AND fs3.ship_id = :shipId |
382
|
|
|
AND (fs3.from_direction = 3 OR fs3.to_direction = 3) |
383
|
|
|
AND fs3.time > :timeThreshold) as d3c, |
384
|
|
|
(SELECT count(distinct fs4.ship_id) from stu_flight_sig fs4 |
385
|
|
|
WHERE fs4.location_id = l.id |
386
|
|
|
AND fs4.ship_id = :shipId |
387
|
|
|
AND (fs4.from_direction = 4 OR fs4.to_direction = 4) |
388
|
|
|
AND fs4.time > :timeThreshold) as d4c |
389
|
|
|
FROM stu_sys_map sm |
390
|
|
|
JOIN stu_location l |
391
|
|
|
ON sm.id = l.id |
392
|
|
|
JOIN stu_map_ftypes mft |
393
|
|
|
ON l.field_id = mft.id |
394
|
|
|
WHERE sm.systems_id = :systemId |
395
|
|
|
AND sm.sx BETWEEN :xStart AND :xEnd AND sm.sy BETWEEN :yStart AND :yEnd', |
396
|
|
|
$rsm |
397
|
|
|
)->setParameters([ |
398
|
|
|
'xStart' => $boundaries->getMinX(), |
399
|
|
|
'xEnd' => $boundaries->getMaxX(), |
400
|
|
|
'yStart' => $boundaries->getMinY(), |
401
|
|
|
'yEnd' => $boundaries->getMaxY(), |
402
|
|
|
'systemId' => $boundaries->getParentId(), |
403
|
|
|
'shipId' => $shipId, |
404
|
|
|
'timeThreshold' => $maxAge |
405
|
|
|
])->getResult(); |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
#[Override] |
409
|
|
|
public function getRandomSystemMapIdsForAstroMeasurement(int $starSystemId, int $location): array |
410
|
|
|
{ |
411
|
|
|
$result = []; |
412
|
|
|
|
413
|
|
|
$rsm = new ResultSetMapping(); |
414
|
|
|
$rsm->addScalarResult('id', 'id', 'integer'); |
415
|
|
|
|
416
|
|
|
$userColonyFields = $this->getEntityManager() |
417
|
|
|
->createNativeQuery( |
418
|
|
|
'SELECT sm.id as id |
419
|
|
|
FROM stu_sys_map sm |
420
|
|
|
WHERE sm.systems_id = :systemId |
421
|
|
|
AND sm.id != :location |
422
|
|
|
AND EXISTS (SELECT c.id |
423
|
|
|
FROM stu_colony c |
424
|
|
|
WHERE c.starsystem_map_id = sm.id |
425
|
|
|
AND c.user_id != :noOne) |
426
|
|
|
ORDER BY RANDOM() |
427
|
|
|
LIMIT 2', |
428
|
|
|
$rsm |
429
|
|
|
) |
430
|
|
|
->setParameters([ |
431
|
|
|
'systemId' => $starSystemId, |
432
|
|
|
'location' => $location, |
433
|
|
|
'noOne' => UserEnum::USER_NOONE |
434
|
|
|
]) |
435
|
|
|
->getResult(); |
436
|
|
|
|
437
|
|
|
$result = array_merge($result, $userColonyFields); |
438
|
|
|
|
439
|
|
|
$otherColonyFields = $this->getEntityManager() |
440
|
|
|
->createNativeQuery( |
441
|
|
|
'SELECT sm.id as id |
442
|
|
|
FROM stu_sys_map sm |
443
|
|
|
JOIN stu_location l |
444
|
|
|
ON sm.id = l.id |
445
|
|
|
JOIN stu_map_ftypes ft |
446
|
|
|
ON l.field_id = ft.id |
447
|
|
|
JOIN stu_colonies_classes cc |
448
|
|
|
ON ft.colonies_classes_id = cc.id |
449
|
|
|
WHERE sm.systems_id = :systemId |
450
|
|
|
AND ft.colonies_classes_id IS NOT NULL |
451
|
|
|
AND cc.type < 3 |
452
|
|
|
AND sm.id NOT IN (:ids) |
453
|
|
|
ORDER BY RANDOM() |
454
|
|
|
LIMIT :theLimit', |
455
|
|
|
$rsm |
456
|
|
|
) |
457
|
|
|
->setParameters([ |
458
|
|
|
'systemId' => $starSystemId, |
459
|
|
|
'ids' => $result !== [] ? $result : [0], |
460
|
|
|
'theLimit' => AstronomicalMappingEnum::MEASUREMENT_COUNT - count($result) |
461
|
|
|
]) |
462
|
|
|
->getResult(); |
463
|
|
|
|
464
|
|
|
$result = array_merge($result, $otherColonyFields); |
465
|
|
|
|
466
|
|
|
if (count($result) < AstronomicalMappingEnum::MEASUREMENT_COUNT) { |
467
|
|
|
$otherFields = $this->getEntityManager() |
468
|
|
|
->createNativeQuery( |
469
|
|
|
'SELECT sm.id as id |
470
|
|
|
FROM stu_sys_map sm |
471
|
|
|
JOIN stu_location l |
472
|
|
|
ON sm.id = l.id |
473
|
|
|
JOIN stu_map_ftypes ft |
474
|
|
|
ON l.field_id = ft.id |
475
|
|
|
WHERE sm.systems_id = :systemId |
476
|
|
|
AND ft.x_damage_system <= 10 |
477
|
|
|
AND ft.x_damage <= 10 |
478
|
|
|
ORDER BY RANDOM() |
479
|
|
|
LIMIT :theLimit', |
480
|
|
|
$rsm |
481
|
|
|
) |
482
|
|
|
->setParameters([ |
483
|
|
|
'systemId' => $starSystemId, |
484
|
|
|
'theLimit' => AstronomicalMappingEnum::MEASUREMENT_COUNT - count($result) |
485
|
|
|
]) |
486
|
|
|
->getResult(); |
487
|
|
|
|
488
|
|
|
$result = array_merge($result, $otherFields); |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
return array_map(fn(array $data) => $data['id'], $result); |
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
#[Override] |
495
|
|
|
public function prototype(): StarSystemMap |
496
|
|
|
{ |
497
|
|
|
return new StarSystemMap(); |
498
|
|
|
} |
499
|
|
|
|
500
|
|
|
#[Override] |
501
|
|
|
public function save(StarSystemMap $starSystemMap): void |
502
|
|
|
{ |
503
|
|
|
$em = $this->getEntityManager(); |
504
|
|
|
|
505
|
|
|
$em->persist($starSystemMap); |
506
|
|
|
} |
507
|
|
|
|
508
|
|
|
#[Override] |
509
|
|
|
public function truncateByStarSystem(StarSystem $starSystem): void |
510
|
|
|
{ |
511
|
|
|
$this->getEntityManager()->createQuery( |
512
|
|
|
sprintf( |
513
|
|
|
'DELETE FROM %s sm WHERE sm.systems_id = :systemId', |
514
|
|
|
StarSystemMap::class |
515
|
|
|
) |
516
|
|
|
) |
517
|
|
|
->setParameters(['systemId' => $starSystem->getId()]) |
518
|
|
|
->execute(); |
519
|
|
|
} |
520
|
|
|
} |
521
|
|
|
|
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