38 m_system(pClient->SystemMgr())
74 if (cur.second->IsMoving()) {
76 ntime = cur.second->GetMoveTime();
87 for (
auto cur : m_activeProbeMap) {
89 cur.second->StartStateTimer(duration);
93 _log(SCAN__TRACE,
"ProcessScan() - probes - active:%u, total:%u, duration: %u, idle: %s", \
94 m_activeProbeMap.size(),
m_probeMap.size(), duration, idle?
"true":
"false");
112 float dot(0), acDP(0), angle(args.ScanAngle/2);
113 std::vector<SystemEntity*> seVec;
115 const GPoint U(args.x, args.y, args.z);
117 _log(SCAN__TRACE,
"ConeScan() - query returned %u objects within range. angle is %.3f", seVec.size(), angle);
119 for (
auto cur : seVec ) {
120 GVector VR(vertex, cur->GetPosition());
122 dot = U.dotProduct(VR);
126 DirectionScanResult res;
127 res.id = cur->GetID();
128 res.typeID = cur->GetSelf()->typeID();
129 res.groupID = cur->GetSelf()->groupID();
130 list->AddItem(res.Encode());
132 _log(SCAN__TRACE,
"ConeScan() - tested %s(%u). dot %.5f, acDP %.5f, result %s", cur->GetName(), cur->GetID(), dot, acDP, test?
"true":
"false");
141 if ((dict ==
nullptr) or dict->
empty()) {
142 _log(SCAN__MESSAGE,
"Scan::RequestScans() called by %s in %s using ship scanner.", \
145 OnSystemScanStarted ossst;
147 ossst.duration = duration;
148 ossst.scanProbesDict =
new PyDict();
155 _log(SCAN__MESSAGE,
"Scan::RequestScans() called by %s in %s using %u probes.",\
160 for (; cItr != dict->
end(); ++cItr) {
163 std::map<uint32, ProbeSE*>::iterator pItr =
m_probeMap.find(probeID);
165 _log(SCAN__ERROR,
"Probe %u wasnt found in the probeMap for %s(%u)", \
173 Call_ProbeDataObj
args;
174 if (!
args.Decode(cItr->second)) {
175 _log(SERVICE__ERROR,
"Scan::RequestScans::DecodeProbeData: Failed to decode arguments.");
191 pItr->second->UpdateProbe(data);
196 std::map<uint32, ProbeSE*>::iterator itr =
m_activeProbeMap.find(cur.first);
213 spd.expiry = cur.second->GetExpiryTime();
214 spd.maxDeviation = cur.second->GetDeviation();
215 spd.probeID = cur.first;
216 spd.state = cur.second->GetState();
217 spd.rangeStep = cur.second->GetRangeStep();
218 spd.scanRange = cur.second->GetScanRange();
219 spd.scanStrength = cur.second->GetScanStrength();
220 spd.typeID = cur.second->GetSelf()->typeID();
221 pos = cur.second->GetPosition();
229 oed_tuple->
SetItem(1, srp.Encode());
232 spd.destination = spd.pos;
236 OnSystemScanStarted ossst;
238 ossst.duration = duration;
239 ossst.scanProbesDict = probeDict;
241 ev->
Dump(SCAN__RSPDUMP,
"sss- ");
249 std::vector<CosmicSignature> anom;
260 for (
auto anoms : anom) {
261 SystemScanResult ssr;
262 ssr.typeID = anoms.sigTypeID;
263 ssr.scanGroupID = anoms.scanGroupID;
264 ssr.groupID = anoms.sigGroupID;
265 ssr.strengthAttributeID = anoms.scanAttributeID;
266 ssr.dungeonName = anoms.sigName;
267 ssr.id = anoms.sigID;
269 ssr.degraded =
false;
271 ssr.certainty = anoms.sigStrength;
273 ScanResultPos ssr_oed;
274 ssr_oed.x = anoms.position.x;
275 ssr_oed.y = anoms.position.y;
276 ssr_oed.z = anoms.position.z;
279 oed_tuple->
SetItem(1, ssr_oed.Encode());
281 resultList->
AddItem(ssr.Encode());
284 OnSystemScanStopped osss;
285 osss.systemScanResult = resultList;
287 osss.scanProbesDict =
new PyDict();
288 osss.absentTargets =
new PyList();
290 ev->
Dump(SCAN__RSPDUMP,
"ssr- ");
300 std::vector<CosmicSignature> sig, anom;
304 for (
auto anoms : anom) {
305 SystemScanResult ssr;
306 ssr.typeID = anoms.sigTypeID;
307 ssr.scanGroupID = anoms.scanGroupID;
308 ssr.groupID = anoms.sigGroupID;
309 ssr.strengthAttributeID = anoms.scanAttributeID;
310 ssr.dungeonName = anoms.sigName;
311 ssr.id = anoms.sigID;
313 ssr.degraded =
false;
315 ssr.certainty = anoms.sigStrength;
316 ssr.pos =
new PyToken(
"foo.Vector3");
335 ScanResultPos ssr_oed;
336 ssr_oed.x = anoms.position.x;
337 ssr_oed.y = anoms.position.y;
338 ssr_oed.z = anoms.position.z;
342 oed_tuple->
SetItem(1, ssr_oed.Encode());
344 resultList->AddItem(ssr.Encode());
348 for (
auto sigs : sig) {
354 SystemScanResult ssr;
356 ssr.dungeonName = sigs.sigName;
357 ssr.typeID = sigs.sigTypeID;
358 ssr.groupID = sigs.sigGroupID;
359 ssr.scanGroupID = sigs.scanGroupID;
360 ssr.strengthAttributeID = sigs.scanAttributeID;
361 ssr.degraded =
false;
364 ssr.probeID = data.
probes;
366 ScanResultPos ssr_oed;
373 oed_tuple->
SetItem(1, ssr_oed.Encode());
375 resultList->AddItem(ssr.Encode());
384 spd.expiry = cur.second->GetExpiryTime();
385 spd.maxDeviation = cur.second->GetDeviation();
386 pos = cur.second->GetPosition();
387 ScanResultPos ssr_oed;
394 oed_tuple->
SetItem(1, ssr_oed.Encode());
396 spd.destination = spd.pos;
397 spd.probeID = cur.first;
398 spd.state = cur.second->GetState();
399 spd.rangeStep = cur.second->GetRangeStep();
400 spd.scanRange = cur.second->GetScanRange();
401 spd.scanStrength = cur.second->GetScanStrength();
402 spd.typeID = cur.second->GetSelf()->typeID();
411 OnSystemScanStopped osssp;
412 osssp.scanProbesDict = probeDict;
413 osssp.systemScanResult = resultList;
414 osssp.absentTargets = absentList;
416 ev->
Dump(SCAN__RSPDUMP,
"psr- ");
448 std::vector<ProbeSE*> probeVec;
452 cur.second->SetRing(
false);
453 cur.second->SetSphere(
false);
458 if (cur.second->CanScanShips()) {
459 dist = cur.second->GetPosition().distance(data.
sig.
position);
460 if (cur.second->GetScanRange() > dist) {
462 probeVec.push_back(cur.second);
464 _log(SCAN__DEBUG,
"Scan::GetProbeDataForSig() scan range for probe %u: %.2fAU, distance to signal '%s' -> %.2fAU - %s",\
468 _log(SCAN__TRACE,
"Scan::GetProbeDataForSig() probe %u cannot scan signal %s", cur.first, data.
sig.
sigName.c_str());
476 _log(SCAN__TRACE,
"Scan::GetProbeDataForSig() probe %u cannot scan signal %s", cur.first, data.
sig.
sigName.c_str());
492 dist = cur.second->GetPosition().distance(data.
sig.
position);
493 if (cur.second->GetScanRange() > dist) {
495 probeVec.push_back(cur.second);
497 _log(SCAN__DEBUG,
"Scan::GetProbeDataForSig() scan range for probe %u: %.2fAU, distance to signal '%s' -> %.2fAU - %s",\
505 _log(SCAN__TRACE,
"Scan::GetProbeDataForSig() probeVec size: %u for signal %s (%s)", \
508 if (probeVec.empty())
513 if (probeVec.size() > 1) {
520 for (
auto cur : probeVec) {
522 pos = cur->GetPosition();
523 ScanResultPos ssr_oed;
530 oed_tuple->
SetItem(1, ssr_oed.Encode());
564 ScanResultPos ssr_oed;
565 ssr_oed.x = probeVec.at(0)->GetPosition().x;
566 ssr_oed.y = probeVec.at(0)->GetPosition().y;
567 ssr_oed.z = probeVec.at(0)->GetPosition().z;
571 oed_tuple->
SetItem(1, ssr_oed.Encode());
573 if (probeVec.at(0)->IsSphere())
583 uint8 probeCount = probeVec.size();
584 float probeMultiplier(0.0f);
587 case 1: probeMultiplier = 0.25774312594204907;
break;
588 case 2: probeMultiplier = 0.5130245854773758;
break;
589 case 3: probeMultiplier = 0.7234132613571191;
break;
590 case 4: probeMultiplier = 0.8824741410676007;
break;
591 case 5: probeMultiplier = 0.9963325352118082;
break;
592 case 6: probeMultiplier = 1.0754155621393995;
break;
593 case 7: probeMultiplier = 1.1296251734489133;
break;
594 case 8: probeMultiplier = 1.1666968137637062;
break;
599 float scanStr1(0), rangeMod1(0), dist1(0), scanStr2(0), rangeMod2(0), dist2(0), angleMod(0);
600 if (probeCount == 1) {
601 dist1 = probeVec.at(0)->GetPosition().distance(point);
602 rangeMod1 = probeVec.at(0)->GetRangeModifier(dist1);
603 scanStr1 = probeVec.at(0)->GetScanStrength();
604 data.
deviation = probeVec.at(0)->GetDeviation() *1.3;
606 _log(SCAN__TRACE,
"Scan::GetSignalData(1) dist: %.3fAU, rangeMod: %.5f, scanStr: %.5f", \
613 if (probeVec.at(0)->HasMaxSkill())
615 std::map<float, std::pair<ProbeSE*, ProbeSE*>> angleMap;
617 float probeSig1(0), probeSig2(0);
619 std::map<float, std::pair<ProbeSE*, ProbeSE*>>::reverse_iterator itr = angleMap.rbegin(), end = angleMap.rend();
620 for (; itr != end; ++itr) {
625 angleMod = sin(itr->first / 2);
627 dist1 = itr->second.first->GetPosition().distance(point);
628 rangeMod1 = itr->second.first->GetRangeModifier(dist1);
629 scanStr1 = itr->second.first->GetScanStrength();
630 probeSig1 = data.
sig.
sigStrength * angleMod * probeMultiplier * (scanStr1 / rangeMod1);
633 dist2 = itr->second.second->GetPosition().distance(point);
634 rangeMod2 = itr->second.second->GetRangeModifier(dist2);
635 scanStr2 = itr->second.second->GetScanStrength();
636 probeSig2 = data.
sig.
sigStrength * angleMod * probeMultiplier * (scanStr2 / rangeMod2);
639 data.
deviation += itr->second.first->GetDeviation();
640 data.
deviation += itr->second.second->GetDeviation();
641 _log(SCAN__TRACE,
"Scan::GetSignalData(%u) #%u - angle %.3f (P1 %u, P2 %u) - dist: %.3fAU, %.3fAU, rangeMod: %.5f, %.5f, scanStr: %.5f, %.5f, angleMod: %.4f, multiplier: %.5f, probeSig: %.5f, %.5f", \
643 rangeMod1, rangeMod2, scanStr1, scanStr2, angleMod, probeMultiplier, probeSig1, probeSig2);
655 if ((data.
certainty < 0.05) and (probeCount == 1)) {
656 probeVec.at(0)->SetSphere(
true);
657 }
else if ((data.
certainty < 0.08) and (probeCount == 2) ) {
659 probeVec.at(0)->SetRing(
true);
660 probeVec.at(1)->SetRing(
true);
677 _log(SCAN__TRACE,
"Scan::GetSignalData() - certainty for signal %s(%s) is %.5f (sigStrength:%.5f) \n Deviation: %.0fm (%.3f AU)", \
683 uint8 count(probeVec.size()), x(0),
y(1);
684 float dot(0.0f), angle(0.0f);
687 p1 = probeVec.at(x++);
692 for (
auto cur : probeVec) {
693 if ((cur ==
nullptr) or (p1 == cur))
695 GVector v2(cur->GetPosition(), sigPos);
697 dot = v1.dotProduct(v2);
700 if (angleMap.find(angle) != angleMap.end())
703 angleMap[angle] = std::make_pair(p1, cur);
704 _log(SCAN__DEBUG,
"Scan::CalcProbeAngles() - adding angle %.3f, p1 %u, p2 %u to map",\
705 (angle), p1->
GetID(), cur->GetID());
void SendNotification(const PyAddress &dest, EVENotificationStream ¬i, bool seq=true)
void GetSignatureList(std::vector< CosmicSignature > &sig)
void AddProbe(ProbeSE *pProbe)
uint32 GetSystemID() const
itemID[count] Create count or of the specified() x() y(z)-Jump to the specified position in space.Stopped." ) COMMAND( translocate
#define _log(type, fmt,...)
PyRep * GetItem(size_t index) const
Returns Python object.
bool GetProbeDataForSig(SignalData &data)
double Rad2Deg(double rad)
void GetSignalData(SignalData &data, std::vector< ProbeSE * > &probeVec)
const char * GetScanGroupName(uint8 groupID=0)
int32 GetCharacterID() const
void SystemScanStarted(uint16 duration)
void RemoveProbe(ProbeSE *pProbe)
static uint32 IntegerValueU32(PyRep *pRep)
void CalcProbeAngles(GPoint &sigPos, std::vector< ProbeSE * > &probeVec, std::map< float, std::pair< ProbeSE *, ProbeSE * >> &angleMap)
void Dump(FILE *into, const char *pfx) const
Dumps object to file.
const GPoint & GetPosition() const
GaExpInl GaFloat normalize()
AnomalyMgr * GetAnomMgr()
void SetItem(size_t index, PyRep *object)
Stores Python object.
SystemManager * SystemMgr() const
static const GPoint NULL_ORIGIN(0, 0, 0)
void RequestScans(PyDict *dict)
void SetScan(Scan *pScan)
std::map< uint32, ProbeSE * > m_probeMap
PyRep * ConeScan(Call_ConeScan args)
void SetScanTimer(uint16 time, bool useProbe=false)
ShipItemRef GetShip() const
const char * GetName() const
void GetAllEntities(std::vector< CosmicSignature > &vector)
std::map< uint32, ProbeSE * > m_activeProbeMap
if(sConfig.world.saveOnMove)
void GetAnomalyList(std::vector< CosmicSignature > &sig)
const_iterator begin() const
Python token (eg. class name).
int64 max(int64 x, int64 y=0)
storage_type::const_iterator const_iterator
EvilNumber GetAttribute(const uint16 attrID) const
void DScan(int64 range, const GPoint &pos, std::vector< SystemEntity * > &vector)
void ProcessScan(bool useProbe=false)
const_iterator end() const
std::string GetSystemName() const
void SetItem(PyRep *key, PyRep *value)
SetItem adds or sets a database entry.
static const int64 ONE_AU_IN_METERS