#include "munga.h" #pragma hdrstop #include "host.h" #include "entity.h" //############################################################################# //################################ Host ################################# //############################################################################# // //############################################################################# //############################################################################# // Host::Host( HostID host_ID, HostType host_type, const SOCKADDR_IN *network_address ): hostType(host_type), allEntitySocket(NULL), dynamicMasterEntitySocket(NULL), dynamicReplicantEntitySocket(NULL) { Verify(host_ID >= FirstLegalHostID); hostID = host_ID; if (network_address) networkAddress = *network_address; else memset(&networkAddress, 0, sizeof(networkAddress)); currentConnectStatus = NoNetworkConnectionStatus; } // //############################################################################# //############################################################################# // Host::~Host() { } // //############################################################################# //############################################################################# // Logical Host::TestInstance() const { Node::TestInstance(); Verify(hostID >= FirstLegalHostID); Verify( hostType == GameMachineHostType || hostType == MissionReviewHostType || hostType == ConsoleHostType ); Check(&allEntitySocket); Check(&dynamicMasterEntitySocket); Check(&dynamicReplicantEntitySocket); return True; } // //############################################################################# //############################################################################# // void Host::AddEntity(Entity *entity) { Check(this); Check(entity); // // Add entity to all socket // allEntitySocket.Add(entity); // // Conditionally add entity to aux sockets // switch (entity->GetInstance()) { case Entity::MasterInstance: case Entity::IndependantInstance: case Entity::HermitInstance: if (entity->IsDynamic()) { dynamicMasterEntitySocket.Add(entity); } break; case Entity::ReplicantInstance: if (entity->IsDynamic()) { dynamicReplicantEntitySocket.Add(entity); } break; default: Fail("Host::AddEntity - Should never reach here"); break; } } //~~~~~~~~~~~~~~~~~~~~~~~~~ Host__AllEntityIterator ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Host__AllEntityIterator::Host__AllEntityIterator(Host *host): SChainIteratorOf(&host->allEntitySocket) { } Host__AllEntityIterator::~Host__AllEntityIterator() { } //~~~~~~~~~~~~~~~~~~~~~ Host__DynamicMasterEntityIterator ~~~~~~~~~~~~~~~~~~~~~ Host__DynamicMasterEntityIterator:: Host__DynamicMasterEntityIterator(Host *host): SChainIteratorOf(&host->dynamicMasterEntitySocket) { } Host__DynamicMasterEntityIterator::~Host__DynamicMasterEntityIterator() { } //~~~~~~~~~~~~~~~~~~~~ Host__DynamicReplicantEntityIterator ~~~~~~~~~~~~~~~~~~~ Host__DynamicReplicantEntityIterator:: Host__DynamicReplicantEntityIterator(Host *host): SChainIteratorOf(&host->dynamicReplicantEntitySocket) { } Host__DynamicReplicantEntityIterator::~Host__DynamicReplicantEntityIterator() { }