示例#1
0
GeneralMatrix* GeneralMatrix::Transpose(TransposedMatrix* tm, MatrixType mt)
{
   GeneralMatrix* gm1;

   if (Compare(Type().t(),mt))
   {
      REPORT
      gm1 = mt.New(ncols,nrows,tm);
      for (int i=0; i<ncols; i++)
      {
         MatrixRow mr(gm1, StoreOnExit+DirectPart, i);
         MatrixCol mc(this, mr.Data(), LoadOnEntry, i);
      }
   }
   else
   {
      REPORT
      gm1 = mt.New(ncols,nrows,tm);
      MatrixRow mr(this, LoadOnEntry);
      MatrixCol mc(gm1, StoreOnExit+DirectPart);
      int i = nrows;
      while (i--) { mc.Copy(mr); mr.Next(); mc.Next(); }
   }
   tDelete(); gm1->ReleaseAndDelete(); return gm1;
}
示例#2
0
void SSMail::UpdateUserLayer( const float deltaTime )
{
	// Clear all subscribers user mailboxes
	for ( int i = 0; i < m_Subscribers.size( ); ++i )
	{
		m_Subscribers[i]->ClearUserMailbox( );
	}

	// Delete all user messages that were sent last update
	for ( int i = 0; i < m_DeliveredUserMessages.size( ); ++i )
		tDelete( m_DeliveredUserMessages[i] );
	m_DeliveredUserMessages.clear( );

	// Get messages for the user layer
	const Message* message;
	while ( PopUserQueue( message ) )
	{
		bool ShouldPush = false;

		for ( int i = 0; i < m_Subscribers.size(); ++i )
		{
			if ( m_Subscribers[i]->GetUserInterests() & message->Type ) // Check if the subscriber is interested in the message
				m_Subscribers[i]->AddUserMessage( message );	// Give the subscriber a reference to the message
		}
		m_DeliveredUserMessages.push_back( message ); // Save a reference to the message so that it can be deleted when all subscribers are done with it
	}
}
示例#3
0
void SSGameLobby::Shutdown()
{
	m_ConnectionState = ConnectionState::EnteringIP;
	for ( int i = 0; i < MAX_PLAYERS; ++i )
	{
		if ( m_ConnectedPlayerEntries[i].IsAI )
			ChangeReserveAI( i, false );
	}
	g_GUI.DeleteObject( m_WindowNameLobby );	
	g_GUI.DeleteObject( m_WindowNameEnterIP );
	g_NetworkEngine.UnRegisterCallback( m_NetworkCallbackHandle );

	for ( auto& levelTextures : m_LevelTextures )
	{
		tDelete( levelTextures.second );
	}

	m_LevelTextures.clear( );
	m_ResearchStations.clear( );
	m_ResourceSpawns.clear( );

	g_SSChat.SetChatState( SSChat::CHATSTATE_INGAME );
	g_SubsystemManager.RestartSubsystem( "Chat" );
	m_ColourEntries.clear();
	g_SSMail.UnregisterSubscriber( this );
}
示例#4
0
void SSHowTo::Shutdown()
{
	g_GUI.DeleteObject( m_WindowName );

	for( gfx::Texture* texture : m_Textures )
		tDelete( texture );
	m_Textures.clear();
}
示例#5
0
PacketPump::~PacketPump( )
{
	const Message* p;
	for ( auto& sendQueuePair : m_SendQueues )
	{
		while ( sendQueuePair.second->Consume( p ) )	// Delete all enqueued packets
			tDelete( p );
		pDelete( sendQueuePair.second );				// Delete the queue
	}

}
示例#6
0
int main(int argc, char *argv[])
{
    DLList myList;
    myList = getDLList(stdin);
    showDLList(stdout, myList);
    assert(validDLList(myList));
    tInsertBefore(myList);
    tInsertAfter(myList);
    tDelete(myList);
    return 0;
}
示例#7
0
void SSMail::Shutdown( )
{
	// Clear all subscribers sim mailboxes
	for ( int i = 0; i < m_Subscribers.size( ); ++i )
	{
		m_Subscribers[i]->ClearSimMailbox( );
	}

	// Delete all undelivered messages
	while ( !m_SimMessagesQueue.empty() )
	{
		tDelete( m_SimMessagesQueue.top().second );
		m_SimMessagesQueue.pop();
	}

	// Delete the messages that were delivered last frame
	for ( int i = 0; i < m_DeliveredSimMessages.size( ); ++i )
		tDelete( m_DeliveredSimMessages[i] );

	Subsystem::Shutdown();
}
示例#8
0
gfx::ShaderProgram::~ShaderProgram ( void )
{
    if ( m_LoadedShaders )
    {
        for ( rVector<Shader*>::iterator it = m_Shaders.begin(); it != m_Shaders.end(); ++it )
        {
			tDelete( *it );
        }
        m_Shaders.clear();
    }

    glDeleteProgram ( m_Handle );
}
示例#9
0
void SSResourceManager::Shutdown( )
{
	m_Resources.clear( );
	m_ResourceModels.clear( );

	m_ResourceSpawn.clear( );
	if ( m_InitialSpawn )
	{
		tDelete( m_InitialSpawn );
		m_InitialSpawn = nullptr;
	}

	m_FirstSpawnDelay = RESOURCE_SPAWN_INITIAL_DELAY;
}
示例#10
0
void PacketPump::RemoveQueue( const short queueID )
{
	auto itemToRemove = m_SendQueues.find( queueID );
	if ( itemToRemove != m_SendQueues.end( ) )
	{
		LocklessQueue<const Message*>* queueToRemove = itemToRemove->second;
		m_SendQueues.erase( itemToRemove );		// Remove the queue from the list of available queues so that no more packets gets sent to it
		const Message* p;
		while ( queueToRemove->Consume( p ) )	// Delete all packets waiting to be sent
			tDelete( p );
		pDelete( queueToRemove );				// Delete the queue itself
	}
	else
		Logger::Log( "Attempted to remove nonixistent SendQueue", "PacketPump", LogSeverity::WARNING_MSG );
}
示例#11
0
void SSMail::UpdateSimLayer( const float timeStep )
{
	// Clear all subscribers sim mailboxes
	for ( int i = 0; i < m_Subscribers.size( ); ++i )
	{
		m_Subscribers[i]->ClearSimMailbox( );
	}

	// Delete all sim messages that were sent last update
	for ( int i = 0; i < m_DeliveredSimMessages.size( ); ++i )
		tDelete( m_DeliveredSimMessages[i] );
	m_DeliveredSimMessages.clear( );
	
	// Get messages for the current frame
	while ( !m_SimMessagesQueue.empty() && m_SimMessagesQueue.top().first <= g_GameData.GetFrameCount() )
	{
		if ( m_SimMessagesQueue.top().first < g_GameData.GetFrameCount() )
			Logger::Log( "SSMail pushed a late message (Target frame was " + rToString( m_SimMessagesQueue.top().first ) + " and current frame is " + rToString( g_GameData.GetFrameCount() ), "SSMail", LogSeverity::WARNING_MSG );

		const Message* message = m_SimMessagesQueue.top().second;
		m_SimMessagesQueue.pop();

		bool ShouldPush = false;
		if ( g_GameModeSelector.GetCurrentGameMode().IsNetworked )
		{
			if ( g_NetworkInfo.AmIHost() )
				ShouldPush = true;
			else if ( message->CreatedFromPacket )
				ShouldPush = true;
			else if ( g_SSNetworkOutput.GetSimInterests() & message->Type )
				g_SSNetworkOutput.AddSimMessage( message );
		}
		else 
			ShouldPush = true;

		if ( ShouldPush )
		{
			for ( int i = 0; i < m_Subscribers.size(); ++i )
			{
				if ( m_Subscribers[i]->GetSimInterests() & message->Type ) // Check if the subscriber is interested in the message
					m_Subscribers[i]->AddSimMessage( message );	// Give the subscriber a reference to the message
			}
		}

		m_DeliveredSimMessages.push_back( message ); // Save a reference to the message so that it can be deleted when all subscribers are done with it
	}
}
示例#12
0
//+----------------------------------------------------------------------------+
//|void Cleanup(void)
//\----------------------------------------------------------------------------+
void SoundSDL::Cleanup(void)
{
	if(m_AudioCVT)
	{
		pDelete(m_AudioCVT);
		m_AudioCVT = nullptr;
	}

	if(m_BufferData)
	{
		tDelete(m_BufferData);
		m_BufferData = nullptr;
	}

	if(m_AudioFile)
	{
		pDelete(m_AudioFile);
		m_AudioFile = nullptr;
	}
	
	m_AudioEngine = nullptr;
	m_Name = "";
};
示例#13
0
bool gfx::ShaderProgram::Recompile()
{
    if ( !m_LoadedShaders )
    {
        for ( auto it : m_Shaders )
        {
            it->Recompile();
        }
        glDeleteProgram ( m_Handle );
        m_Validated = false;
        return Init ( m_Shaders, false );;
    }
    else
    {
        //clear up old shader
        for ( rVector<Shader*>::iterator i = m_Shaders.begin(); i != m_Shaders.end(); i++ )
        {
			tDelete( *i );
        }
        m_Shaders.clear();
        glDeleteProgram ( m_Handle );
        //reinit the program
		if(m_Defines.IsEmpty())
		{
			LoadCompleteShaderProgramFromFile ( m_Filename, false );
		}
		else 
		{
			LoadCompleteShaderProgramFromFile ( m_Filename, false, m_Defines );
		}
        
        m_Validated = false;
        return true;
    }

}
示例#14
0
void SSResourceManager::UpdateSimLayer( const float timestep )
{
	fVector<int> resourceCounts( m_Resources.size( ) );
	for ( auto& it : resourceCounts )
		it = 0;

	// Get number of resources on spawn point
	Entity entityID = 0;
	for ( auto& entity : g_EntityManager.GetEntityMasks( ) )
	{
		if ( entity & GetDenseComponentFlag<ResourceComponent>( ) )
		{
			ResourceComponent* resourceComponent = GetDenseComponent<ResourceComponent>( entityID );
			if ( resourceComponent->SpawnedBy != -1 )
				++resourceCounts[resourceComponent->SpawnedBy];
		}
		++entityID;
	}

	// Initiate resource drop
	m_FirstSpawnDelay -= timestep;
	if ( m_FirstSpawnDelay <= 0.0f && m_InitialSpawn == nullptr )
	{
		int spawnID = 0;
		for ( auto& resource : m_Resources )
		{
			float respawnRate = m_RespawnTypes[resource.RespawnType].RespawnRate;

			resource.LastSpawn -= timestep;
			if ( resource.LastSpawn <= 0.0f )
			{
				resource.LastSpawn = respawnRate / 2.0f + respawnRate * (float) g_Randomizer.SimGenerateRandom( );

				float dropOrgX			= 50.0f * (2.0f * (float) g_Randomizer.SimGenerateRandom( ) - 1.0f);
				float dropOrgZ			= 50.0f * (2.0f * (float) g_Randomizer.SimGenerateRandom( ) - 1.0f);
				glm::vec3 spawnOffset	= glm::vec3( dropOrgX, RESOURCE_RESPAWN_DROP_HEIGHT, dropOrgZ );

				int respawnCount		= GetRespawnAmount( resourceCounts[spawnID], resource.RespawnType );

				for ( int i = 0; i < respawnCount; ++i )
				{
					float		spawnAngle			= (float) g_Randomizer.SimGenerateRandom( ) * glm::pi<float>( ) * 2.0f;
					float		spawnDist			= (float) g_Randomizer.SimGenerateRandom( ) * resource.RespawnRadius;

					glm::vec3	spawnPos;
					spawnPos.x						= resource.Position.x + glm::cos( spawnAngle ) * spawnDist;
					spawnPos.z						= resource.Position.z + glm::sin( spawnAngle ) * spawnDist;
					spawnPos.y						= gfx::g_GFXTerrain.GetHeightAtWorldCoord( spawnPos.x, spawnPos.z );

					float		orientationAngle	= (float) g_Randomizer.SimGenerateRandom( ) * glm::pi<float>( ) * 2.0f;
					glm::quat	spawnOrientation	= glm::rotate( resource.Orientation, orientationAngle, glm::vec3( 0.0f, 1.0f, 0.0f ) );

					pString		model				= m_ResourceModels.at( g_Randomizer.SimRand( 0, (unsigned int) m_ResourceModels.size( ) ) );

					DropResource( spawnPos, resource.Scale, spawnOrientation, model, spawnOffset, spawnID );					
				}
			}

			++spawnID;
		}
	}

	// Drop in initial resources
	else if ( m_FirstSpawnDelay <= 0.0f && m_InitialSpawn )
	{
		for ( auto& resource : *m_InitialSpawn )
			DropResource( resource.Position, resource.Scale, resource.Orientation, resource.ModelPath, glm::vec3( 0.0f, RESOURCE_RESPAWN_DROP_HEIGHT, 0.0f ), -1 );
		tDelete( m_InitialSpawn );
		m_InitialSpawn = nullptr;

		m_FirstSpawnDelay = RESOURCE_SPAWN_INITIAL_DELAY;
	}

	// Update resource drops
	for ( auto& drop : m_ResourceSpawn )
	{
		if ( drop.Active )
		{
			drop.DropTime -= timestep;
			if ( drop.DropTime <= 0.0f )
			{
				drop.Active = false;
				if ( drop.Effect )
					drop.Effect->TimeToLive = drop.Effect->ParticlesTimeToLive;

				EntityFactory::CreateResource( drop.Position.x, drop.Position.z, drop.Scale, drop.Orientation, drop.ModelPath.c_str( ), drop.SpawnedBy );
				g_SSMiniMap.PingLocation( drop.Position );
			}
		}
	}
}