/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Benjamin Wuest co-programmer: ... */ /* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_NETWORK module For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput */ #define DEBUG_MODULE_NETWORK #include "factory.h" #include "network_stream.h" /* include your own header */ #include "network_game_manager.h" /* using namespace std is default, this needs to be here */ using namespace std; /*! * Standard constructor */ NetworkGameManager::NetworkGameManager() { /* set the class id for the base object */ this->setClassID(CL_ENTITY_MANAGER, "EntityManager"); } /*! * Standard destructor */ NetworkGameManager::~NetworkGameManager() { for ( int i = 0; iisA(CL_SYNCHRONIZEABLE) ) { Synchronizeable * s = dynamic_cast(b); s->setUniqueID( uniqueID ); s->setOwner( owner ); this->networkStream->connectSynchronizeable( *s ); } else { PRINTF(1)("Class with ID %d is not a synchronizeable!", (int)classID); delete b; } } /** * Removes a entity on this host * @param uniqueID: unique ID assigned with the entity to remove */ void NetworkGameManager::doRemoveEntity( int uniqueID ) { SynchronizeableList::const_iterator it,e; it = this->networkStream->getSyncBegin(); e = this->networkStream->getSyncEnd(); while ( it != e ) { if ( (*it)->getUniqueID() == uniqueID ) { delete *it; break; } } } /** * Tell the synchronizeable that a user's synchronizeable is out of sync * @param uniqueID: unique ID assigned with the entity which is out of sync * @param userID: user ID who's synchronizeable is out of sync */ void NetworkGameManager::doRequestSync( int uniqueID, int userID ) { SynchronizeableList::const_iterator it,e; it = this->networkStream->getSyncBegin(); e = this->networkStream->getSyncEnd(); while ( it != e ) { if ( (*it)->getUniqueID() == uniqueID ) { (*it)->requestSync( userID ); break; } } }