74 _log(DESTINY__BUBBLE_TRACE,
"SystemBubble::Constructor - Created new bubble %u(%p) at (%.2f,%.2f,%.2f)[%.1f].",\
145 if (itr->second ==
nullptr) {
149 pDSE = itr->second->GetDynamicSE();
150 if (pDSE ==
nullptr) {
162 wanderers.push_back(pDSE);
163 _log(DESTINY__WARNING,
"SystemBubble::ProcessWander() - entity %u is in %u but this is %u.", \
170 wanderers.push_back(pDSE);
172 _log(DESTINY__WARNING,
"SystemBubble::ProcessWander() - entity %u(sys:%u) not in bubble %u for systemID %u.", \
190 _log(DESTINY__BUBBLE_TRACE,
"SystemBubble::Add() - Tried to add Static Entity %u to bubble %u, but it is already in here.",\
198 _log(DESTINY__BUBBLE_TRACE,
"SystemBubble::Add() - Entity %s(%u) is static or global or both.", pSE->
GetName(), pSE->
GetID() );
206 _log(DESTINY__BUBBLE_TRACE,
"SystemBubble::Add() - Tried to add Dynamic Entity %u to bubble %u, but it is already in here.",\
211 _log(DESTINY__BUBBLE_TRACE,
"SystemBubble::Add() - Adding entity %u to bubble %u. Dist to center: %.2f", \
217 double rangeToStar = direction.length();
219 _log(DESTINY__BUBBLE_DEBUG,
"SystemBubble::Add() - Distance to Star %.2f AU. %u/%u Entities in bubble %u",\
243 m_players[pClient->GetCharacterID()] = pClient;
263 _log(DESTINY__BUBBLE_TRACE,
"SystemBubble::Remove() - Removing entity %u from bubble %u", pSE->
GetID(),
m_bubbleID);
281 sLog.Warning(
"SystemBubble::Remove()",
"Removing entity %u from bubble %u", pSE->
GetID(),
m_bubbleID);
290 _log(DESTINY__BUBBLE_TRACE,
"SystemBubble::RemoveExclusive() - Removing entity %u from bubble %u", pSE->
GetID(),
m_bubbleID);
330 if (itemRef->
typeID() == 17774)
344 std::map<uint32, SystemEntity*>::const_iterator itr =
m_dynamicEntities.find(entityID);
361 if (cur.second->DestinyMgr() !=
nullptr)
362 if (cur.second->DestinyMgr()->IsCloaked())
364 into.emplace(cur.first, cur.second);
374 into.emplace(cur.first, cur.second);
384 into.push_back(cur.second);
399 into.push_back(cur.second);
409 if (cur.second->IsWreckSE())
411 if (cur.second->IsObjectEntity())
420 if (cur.second->IsNPCSE())
434 _log(DESTINY__BUBBLE_DEBUG,
"SystemBubble::InBubble(%u) - center: %.1f,%.1f,%.1f - distance: %.1f, check: %s", \
450 _log(DESTINY__BUBBLE_DEBUG,
"SystemBubble::IsOverlap(%u) - center: %.1f,%.1f,%.1f - distance: %.1f, check: %s", \
462 if (cur.second->isGlobal())
463 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Global.", cur.second->GetName(), cur.second->GetID() );
464 if (cur.second->IsShipSE()) {
465 if (cur.second->HasPilot()) {
466 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Player Ship.", cur.second->GetName(), cur.second->GetID() ); found =
true;
468 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Empty Player Ship.", cur.second->GetName(), cur.second->GetID() ); found =
true;
471 if (cur.second->IsNPCSE()) {
472 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is NPC.", cur.second->GetName(), cur.second->GetID() ); found =
true;
474 if (cur.second->IsJumpBridgeSE()) {
475 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is JumpBridge.", cur.second->GetName(), cur.second->GetID() ); found =
true;
477 if (cur.second->IsTCUSE()) {
478 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is TCU.", cur.second->GetName(), cur.second->GetID() ); found =
true;
480 if (cur.second->IsSBUSE()) {
481 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is SBU.", cur.second->GetName(), cur.second->GetID() ); found =
true;
483 if (cur.second->IsIHubSE()) {
484 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is IHub.", cur.second->GetName(), cur.second->GetID() ); found =
true;
486 if (cur.second->IsCOSE()) {
487 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Customs Office.", cur.second->GetName(), cur.second->GetID() ); found =
true;
489 if (cur.second->IsTowerSE()) {
490 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Tower.", cur.second->GetName(), cur.second->GetID() ); found =
true;
492 if (cur.second->IsPOSSE() and !found) {
493 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is other POS.", cur.second->GetName(), cur.second->GetID() ); found =
true;
495 if (cur.second->IsContainerSE()) {
496 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Container.", cur.second->GetName(), cur.second->GetID() ); found =
true;
498 if (cur.second->IsWreckSE()) {
499 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Wreck.", cur.second->GetName(), cur.second->GetID() ); found =
true;
501 if (cur.second->IsOutpostSE()) {
502 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Outpost.", cur.second->GetName(), cur.second->GetID() ); found =
true;
504 if (cur.second->IsAsteroidSE()) {
505 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Asteroid.", cur.second->GetName(), cur.second->GetID() ); found =
true;
507 if (cur.second->IsDeployableSE()) {
508 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Deployable.", cur.second->GetName(), cur.second->GetID() ); found =
true;
510 if (cur.second->IsStaticEntity() and !found) {
511 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Static.", cur.second->GetName(), cur.second->GetID() ); found =
true;
513 if (cur.second->IsItemEntity() and !found) {
514 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Item.", cur.second->GetName(), cur.second->GetID() ); found =
true;
516 if (cur.second->IsObjectEntity() and !found) {
517 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Object.", cur.second->GetName(), cur.second->GetID() ); found =
true;
519 if (cur.second->IsDynamicEntity() and !found) {
520 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is Dynamic.", cur.second->GetName(), cur.second->GetID() ); found =
true;
523 sLog.Warning(
"SystemBubble::PrintEntityList()",
"entity %s(%u) is None of the Above.", cur.second->GetName(), cur.second->GetID() );
535 if (pClient ==
nullptr)
545 destinyBuffer->
Append(head);
548 addballs.slims =
new PyList();
551 if (cur.second->DestinyMgr() !=
nullptr)
552 if (cur.second->DestinyMgr()->IsCloaked())
554 if (!cur.second->IsMissileSE() or !cur.second->IsFieldSE())
555 addballs.damageDict[cur.first] = cur.second->MakeDamageState();
556 addballs.slims->AddItem(
new PyObject(
"foo.SlimItem", cur.second->MakeSlimItem() ) );
557 cur.second->EncodeDestiny( *destinyBuffer );
560 if (addballs.slims->empty()) {
565 addballs.state =
new PyBuffer( &destinyBuffer );
567 _log(DESTINY__MESSAGE,
"SystemBubble::SendAddBalls() to %s", pClient->
GetName());
569 addballs.Dump( DESTINY__BALL_DUMP,
" " );
570 _log( DESTINY__BALL_DECODE,
" Ball Decoded:" );
572 Destiny::DumpUpdate( DESTINY__BALL_DECODE, &( addballs.state->content() )[0], (
uint32)addballs.state->content().size() );
573 PyTuple* t = addballs.Encode();
585 if (pClient ==
nullptr)
595 destinyBuffer->
Append(head);
599 addballs2.extraBallData =
new PyList();
602 if (cur.second->IsMissileSE() or cur.second->IsContainerSE()) {
603 addballs2.extraBallData->AddItem(cur.second->MakeSlimItem());
606 balls->
SetItem(0, cur.second->MakeSlimItem());
607 balls->
SetItem(1, cur.second->MakeDamageState());
608 addballs2.extraBallData->AddItem(balls);
610 cur.second->EncodeDestiny(*destinyBuffer);
613 if (addballs2.extraBallData->size() < 1) {
618 addballs2.state =
new PyBuffer(&destinyBuffer);
621 _log( DESTINY__MESSAGE,
"SystemBubble::SendAddBalls2() to %s", pClient->
GetName());
623 addballs2.Dump( DESTINY__BALL_DUMP,
" " );
630 _log( DESTINY__BALL_DECODE,
" Ball Decoded:" );
632 Destiny::DumpUpdate( DESTINY__BALL_DECODE, &( addballs2.state->content() )[0], (
uint32)addballs2.state->content().size() );
633 PyTuple* t = addballs2.Encode();
650 destinyBuffer->
Append( head );
655 addballs.state =
new PyBuffer( &destinyBuffer );
659 addballs.slims =
new PyList();
662 _log(DESTINY__BUBBLE_TRACE,
"SystemBubble::AddBallExclusive() - Adding entity %u to bubble %u", pSE->
GetID(),
m_bubbleID);
664 addballs.Dump( DESTINY__BALL_DUMP,
" " );
665 _log( DESTINY__BALL_DECODE,
" Ball Decoded:" );
667 Destiny::DumpUpdate( DESTINY__BALL_DECODE, &( addballs.state->content() )[0], (
uint32)addballs.state->content().size() );
669 PyTuple* t = addballs.Encode();
697 RemoveBallsFromBP removeball;
698 removeball.balls.push_back(about_who->
GetID());
700 _log(DESTINY__MESSAGE,
"SystemBubble::RemoveBall()");
702 removeball.Dump( DESTINY__BALL_DUMP,
" " );
704 PyTuple *tmp = removeball.Encode();
711 RemoveBallFromBP removeball;
712 removeball.entityID = about_who->
GetID();
716 _log(DESTINY__MESSAGE,
"SystemBubble::RemoveBallExclusive()");
718 removeball.Dump( DESTINY__BALL_DUMP,
" " );
720 PyTuple *tmp = removeball.Encode();
733 if ((pClient ==
nullptr) or pClient->
IsDock() or pClient->
IsDocked())
736 RemoveBallsFromBP remove_balls;
739 remove_balls.balls.push_back(cur.first);
741 if (remove_balls.balls.empty())
744 _log( DESTINY__MESSAGE,
"SystemBubble::RemoveBalls() - sending to %s", pClient->
GetName());
746 remove_balls.Dump( DESTINY__BALL_DUMP,
" " );
748 PyTuple* tmp = remove_balls.Encode();
767 line->
SetItem(2,
new PyInt(cur.second->GetControllerID()));
769 line->
SetItem(4,
new PyInt(cur.second->GetSelf()->typeID()));
770 line->
SetItem(5,
new PyInt(cur.second->GetControllerOwnerID()));
780 return new PyObject(
"util.Rowset", dict);
788 du.entityID = dse.first;
789 du.x = dse.second->GetPosition().x;
790 du.y = dse.second->GetPosition().y;
791 du.z = dse.second->GetPosition().z;
793 player.second->GetShipSE()->DestinyMgr()->SendSingleDestinyUpdate(&up);
800 if (dse.second->IsNPCSE())
801 dse.second->GetNPCSE()->CmdDropLoot();
811 cur.second->Delete();
828 std::string str =
"Center Marker for Bubble #", desc =
"Bubble Center";
900 if ( cRef.get() ==
nullptr) {
901 _log(DESTINY__WARNING,
"MarkBubble() could not create Item for %s (%s)", name.c_str(), desc.c_str());
908 if (cSE ==
nullptr) {
909 _log(DESTINY__WARNING,
"MarkBubble() could not create SE for %s (%s)", name.c_str(), desc.c_str());
933 for (std::vector<PyTuple *>::iterator cur = updates.begin(); cur != updates.end(); ++cur)
940 for (std::vector<PyTuple *>::iterator cur = events.begin(); cur != events.end(); ++cur)
949 (*payload)->Dump(DESTINY__BUBBLECAST_DUMP,
" ");
951 _log( DESTINY__BUBBLECAST,
"Bubblecast %s update to %s(%u)", desc, cur.second->GetName(), cur.first );
953 cur.second->QueueDestinyUpdate(payload);
962 if (cur.second->GetShipSE() != pSE) {
963 _log( DESTINY__BUBBLECAST,
"Exclusive Bubblecast %s update to %s(%u)", desc, cur.second->GetName(), cur.first );
965 cur.second->QueueDestinyUpdate(payload);
973 (*payload)->Dump(DESTINY__BUBBLECAST_DUMP,
" ");
975 _log( DESTINY__BUBBLECAST,
"Bubblecast %s event to %s(%u)", desc, cur.second->GetName(), cur.first );
977 cur.second->QueueDestinyEvent(payload);
984 _log( DESTINY__BUBBLECAST,
"BubblecastNotify %s to %s(%u)", notifyType, cur.second->GetName(), cur.first );
986 cur.second->SendNotification( notifyType, idType, payload, seq );
void Append(const T &value)
Appends a single value to buffer.
#define sConfig
A macro for easier access to the singleton.
void SetGlobal(bool set=false)
virtual DroneSE * GetDroneSE()
void MarkBubble(const GPoint &position, std::string &name, std::string &desc, bool center=false)
void AddEntity(SystemEntity *pSE, bool addSignal=true)
std::map< uint32, SystemEntity * > m_dynamicEntities
std::map< uint32, SystemEntity * > m_markers
void GetEntityVec(std::vector< SystemEntity * > &into) const
void BubblecastDestinyUpdateExclusive(PyTuple **payload, const char *desc, SystemEntity *pSE) const
void AddBallExclusive(SystemEntity *about_who)
#define _log(type, fmt,...)
void SendAddBalls(SystemEntity *to_who)
SystemBubble * SysBubble()
bool InBubble(const GPoint &pt, bool inWarp=false) const
void GetEntities(std::map< uint32, SystemEntity * > &into) const
void SendAddBalls2(SystemEntity *to_who)
void SetItemString(size_t index, const char *str)
Stores Python string.
virtual Client * GetPilot()
int32 GetCharacterID() const
void BubblecastSendNotification(const char *notifyType, const char *idType, PyTuple **payload, bool seq=true)
std::map< uint32, DroneSE * > m_drones
const float GetSystemSecurityRating()
PyObject * GetDroneState() const
SystemBubble(SystemManager *pSystem, const GPoint ¢er, double radius)
const GPoint & GetPosition() const
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
SystemEntity * GetRandomEntity()
#define is_log_enabled(type)
#define sLog
Evaluates to a NewLog instance.
virtual PyDict * MakeSlimItem()
void BubblecastDestiny(std::vector< PyTuple * > &updates, std::vector< PyTuple * > &events, const char *desc) const
DestinyManager * DestinyMgr()
SystemManager * SystemMgr()
void RemoveBallExclusive(SystemEntity *about_who)
void GetAllEntities(std::map< uint32, SystemEntity * > &into) const
Generic class for buffers.
void SetGate(uint32 gateID)
void BubblecastDestinyEvent(std::vector< PyTuple * > &events, const char *desc) const
PyTuple * MakeDamageState()
void SetItem(size_t index, PyRep *object)
Stores Python object.
static const GPoint NULL_ORIGIN(0, 0, 0)
void RemoveEntity(SystemEntity *pSE)
void SetBelt(InventoryItemRef itemRef)
void SetItem(size_t index, PyRep *object)
Stores Python object.
void SetSpawnTimer(bool isBelt=false)
static InventoryItemRef SpawnTemp(ItemData &data)
bool Check(bool reset=true)
const char * GetName() const
std::map< uint32, Client * > m_players
const char * GetName() const
void ResetBubbleRatSpawn()
bool IsOverlap(const GPoint &pt) const
void QueueDestinyUpdate(PyTuple **update, bool DoPackage=false, bool IsSetState=false)
void RemoveExclusive(SystemEntity *pSE)
static RefPtr StaticCast(const RefPtr< Y > &oth)
Acts as static_cast from one RefPtr to another.
if(sConfig.world.saveOnMove)
PyServiceMgr * GetServiceMgr()
virtual void EncodeDestiny(Buffer &into)
Python token (eg. class name).
void RemoveBall(SystemEntity *about_who)
int64 MakeRandomInt(int64 low, int64 high)
Generates random integer from interval [low; high].
void ProcessWander(std::vector< SystemEntity * > &wanderers)
void Remove(SystemEntity *pSE)
void DumpUpdate(LogType into, const uint8 *data, uint32 len)
void DoSpawnForBubble(SystemBubble *pBubble)
SystemEntity *const GetEntity(uint32 entityID) const
std::map< uint32, SystemEntity * > m_entities
void RemoveBalls(SystemEntity *to_who)
void BubblecastDestinyUpdate(std::vector< PyTuple * > &updates, const char *desc) const
GaExpInl GaFloat distance(const GaVec3 &oth) const
void RegisterBelt(InventoryItemRef itemRef)
virtual bool IsStaticEntity()
void Add(SystemEntity *pSE)
void SetItemString(const char *key, PyRep *value)
SetItemString adds or sets a database entry.
static const int64 ONE_AU_IN_METERS
void GetPlayers(std::vector< Client * > &into) const
void CheckSpawn(uint16 bubbleID)
void Start(uint32 setTimerTime=0, bool changeResetTimer=true)
static const float BUBBLE_RADIUS_METERS