//-----------------------------------------------------------------------------------------------
const Texture* BitmapFont::GetTextureAtlas( unsigned int atlasIndex ) const
{
	FATAL_ASSERTION( atlasIndex < numberOfTextureAtlases, "Font Error",
		"Attempted to access the texture atlas array with an out-of-bounds index." );

	return textureAtlases[ atlasIndex ];
}
Ejemplo n.º 2
0
void* SignPostAllocator::Alloc(size_t size)
{
	size_t alloc_size = size + sizeof(sign_post);
	sign_post *iter = posts;

	while (iter != nullptr)
	{
		if (iter->free && iter->size >= alloc_size)
			break;

		iter = iter->next;
	}	
	FATAL_ASSERTION(iter != nullptr, "Alloc Failed.");
	

	iter->free = false;

	char* iter_buffer = (char*)iter + sizeof(sign_post);
	sign_post* next_signpost = (sign_post*)(iter_buffer + size);
	next_signpost->free = true;
	next_signpost->prev = iter;
	next_signpost->next = iter->next;
	next_signpost->size = iter->size - alloc_size;

	iter->size = size;
	iter->next = next_signpost;

	return iter_buffer;
}
//-----------------------------------------------------------------------------------------------
const Glyph& BitmapFont::GetGlyphForCharacter( char character ) const
{
	GlyphRegistry::const_iterator fontIterator = glyphData.find( character );
	FATAL_ASSERTION( fontIterator != glyphData.end(), "Font Error", "Unable to find glyph for font." );

	return fontIterator->second;
}
//-----------------------------------------------------------------------------------------------
inline const TouchPoint& TouchScreen::GetTouchPointAtIndex( unsigned int index ) const
{
	FATAL_ASSERTION( index < m_currentTouches.size(), "Touchscreen Error",
		"An attempt was made to access a touch index that was out of range." );

	return *m_currentTouches[ index ];
}
Ejemplo n.º 5
0
HashBufferJob::HashBufferJob( const char* bufferToHash, size_t sizeOfBuffer, const std::string& eventToFireUponCompletion, JobPriorityLevel jobPriorityLevel /* = JOB_PRIORITY_AVERAGE */ ) :
    AsyncJob( eventToFireUponCompletion, jobPriorityLevel ),
    m_bufferToHash( bufferToHash ),
    m_sizeOfBuffer( sizeOfBuffer ),
    m_hashValue( 0 ),
    m_hashComplete( false )
{
    FATAL_ASSERTION( bufferToHash != nullptr, "Error: Cannot hash a buffer which has a value of nullptr" );
}
Ejemplo n.º 6
0
//-----------------------------------------------------------------------------------------------
void Server::SetPortToBindToFromParameters( NamedProperties& parameters )
{
	std::string portAsString;

	parameters.Get( "param1", portAsString );

	FATAL_ASSERTION( portAsString != "", "Command: port did not receive the correct parameters.\nport expects a non empty string." );

	m_currentServerPort = u_short( atoi( portAsString.c_str() ) );
}
Ejemplo n.º 7
0
//-----------------------------------------------------------------------------------------------
void Server::SetServerIpFromParameters( NamedProperties& parameters )
{
	std::string ipAddressAsString;

	parameters.Get( "param1", ipAddressAsString );

	FATAL_ASSERTION( ipAddressAsString != "", "Command: ip did not receive the correct parameters.\nip expects a non empty string." );

	m_currentServerIPAddressAsString = ipAddressAsString;
}
Ejemplo n.º 8
0
size_t LoadFileJob::determineSizeOfFile( FILE* fileToDetermineSize ) {

    FATAL_ASSERTION( fileToDetermineSize != nullptr, "Error: Cannot determine size of a FILE which is nullptr" );

    size_t startPosition = 0;
    size_t endPosition = 0;

    startPosition = ftell( fileToDetermineSize );
    fseek( fileToDetermineSize, 0, SEEK_END );
    endPosition = ftell( fileToDetermineSize );
    fseek( fileToDetermineSize, startPosition, SEEK_SET );

    return endPosition;
}
Ejemplo n.º 9
0
void SignPostAllocator::Free(void* ptr)
{
	char *iter_buffer = (char*)ptr;
	sign_post *post = (sign_post*)(iter_buffer - sizeof(sign_post));

	FATAL_ASSERTION(post->free == false, "Free Failed");

	// check previous or next, see if they're free, or both are free
	if ((post->prev != nullptr) && (post->prev->free)
		&& (post->next != nullptr) && (post->next->free))
	{
		size_t size = post->prev->size + post->size + post->next->size + 2 * sizeof(sign_post);// 2 this post and next post, previous is staying
		sign_post* prev = post->prev;
		prev->size = size;
		if (post->next->next!=nullptr)
		{
			post->next->next->prev = prev;
		}	
		prev->next = post->next->next;
		
	}
	else if ((post->prev != nullptr) && (post->prev->free))
	{
		size_t size = post->prev->size + post->size + sizeof(sign_post);
		sign_post *prev = post->prev;
		prev->size = size;
		if (post->next!=nullptr)
		{
			post->next->prev = prev;
		}		
		prev->next = post->next;		
	}
	else if ((post->next != nullptr) && (post->next->free))
	{
		post->size = post->next->size + post->size + sizeof(sign_post);
		if (post->next->next!=nullptr)
		{
			post->next->next->prev = post;
		}		
		post->next = post->next->next;
		post->free = true;
	}
	else
		post->free = true;
}
Ejemplo n.º 10
0
void LoadFileJob::executeJob() {

    FILE* fileToLoad = fopen( m_filePathToLoad.c_str(), "rb" );
    FATAL_ASSERTION( fileToLoad != nullptr, "Error: Failed to load file in LoadFileJob. The file path specified did not result in a file being loaded" );

    size_t sizeOfFile = determineSizeOfFile( fileToLoad );
    char* fileBuffer = new char[sizeOfFile];

    fread( fileBuffer, sizeof( char ), sizeOfFile, fileToLoad );

    fclose( fileToLoad );

    m_namedPropertiesForEventCompletion.setProperty( LF_BYTE_BUFFER_RESULT_STRING, fileBuffer );
    m_namedPropertiesForEventCompletion.setProperty( LF_SIZE_OF_FILE_BYTES_STRING, sizeOfFile );
    m_namedPropertiesForEventCompletion.setProperty( LF_FILE_PATH_STRING, m_filePathToLoad );
    m_namedPropertiesForEventCompletion.setProperty( LF_FILE_NAME_STRING, m_fileName );

    m_jobCompleted = true;
}
Ejemplo n.º 11
0
void SignPostAllocator::Deinit()
{
	FATAL_ASSERTION((posts->next == nullptr) && (posts->prev == nullptr) && (posts->free), "Deinit failed");
	free(buffer);
}