void ReplicationManagerClient::ReadAndDoUpdateAction( InputMemoryBitStream& inInputStream, int inNetworkId ) { GameObjectPtr gameObject = NetworkManagerClient::sInstance->GetGameObject( inNetworkId ); // Should be good gameObject->Read( inInputStream ); }
void NetworkManagerClient::HandleGameObjectState( InputMemoryBitStream& inInputStream ) { //copy the mNetworkIdToGameObjectMap so that anything that doesn't get an updated can be destroyed... IntToGameObjectMap objectsToDestroy = mNetworkIdToGameObjectMap; int stateCount; inInputStream.Read( stateCount ); if( stateCount > 0 ) { for( int stateIndex = 0; stateIndex < stateCount; ++stateIndex ) { int networkId; uint32_t fourCC; inInputStream.Read( networkId ); inInputStream.Read( fourCC ); GameObjectPtr go; auto itGO = mNetworkIdToGameObjectMap.find( networkId ); //didn't find it, better create it! if( itGO == mNetworkIdToGameObjectMap.end() ) { go = GameObjectRegistry::sInstance->CreateGameObject( fourCC ); go->SetNetworkId( networkId ); AddToNetworkIdToGameObjectMap( go ); } else { //found it go = itGO->second; } //now we can update into it go->Read( inInputStream ); objectsToDestroy.erase( networkId ); } } //anything left gets the axe DestroyGameObjectsInMap( objectsToDestroy ); }
// TODO: This should be managed by some sort of packet class void ReplicationManagerClient::ReadAndDoCreateAction( InputMemoryBitStream& inInputStream, int inNetworkId ) { uint32_t fourCCName; inInputStream.Read( fourCCName ); GameObjectPtr gameObject = NetworkManagerClient::sInstance->GetGameObject( inNetworkId ); if ( !gameObject ) { gameObject = GameObjectRegistry::sInstance->CreateGameObject( fourCCName ); gameObject->SetNetworkId( inNetworkId ); NetworkManagerClient::sInstance->AddToNetworkIdToGameObjectMap( gameObject ); } gameObject->Read( inInputStream ); // Read state }