Exemplo n.º 1
0
void DArray<T>::MarkUsed( int _index )
{
    AppAssert( _index < m_arraySize && _index >= 0 );
    AppAssert( shadow[_index] == 0 );
    
    shadow[_index] = 1;
}
Exemplo n.º 2
0
T DArray<T>::GetData( int index ) const
{
	AppAssert(index < m_arraySize && index >= 0);
	AppAssert(shadow[index] != 0);
	
	return array[index];
}
Exemplo n.º 3
0
inline const T& DArray<T>::operator [] (int _index) const
{
    AppAssert( _index < m_arraySize && _index >= 0 );
    AppAssert( shadow[_index] != 0 );
    
    return array[_index];    
}
Exemplo n.º 4
0
T *DArray<T>::GetPointer( int index ) const
{
    AppAssert( index < m_arraySize && index >= 0 );       
    AppAssert( shadow[index] != 0 );

    return &( array[index] );
}
Exemplo n.º 5
0
void BadaBitmap::copyBitmap(Osp::Graphics::Bitmap* bitmap)
{
	Osp::Graphics::BufferInfo bi;
	result r = bitmap->Lock(bi);
	AppAssertf(r == E_SUCCESS, "Locking failed in BadaBitmap::unlockImage with error %d", r);

	int pixelSize = 0; // size of pixel in bytes
	switch(bi.pixelFormat)
	{
		case Osp::Graphics::PIXEL_FORMAT_R8G8B8A8:
		{
			pixelSize = 4;
			break;
		}
		case Osp::Graphics::PIXEL_FORMAT_ARGB8888:
		{
			pixelSize = 4;
			break;
		}
		default:
		{
			AppAssertf(0, "Unsupported bitmap format in BadaBitmap::copyBitmap");
		}
	}

	int pixelCount = pixelSize * m_width * m_height;
	AppAssert(pixelCount != 0);
	AppAssert(m_pixels == null);
	m_pixels = new unsigned char[pixelCount];
	memcpy(m_pixels, bi.pPixels, pixelCount);

	bitmap->Unlock();
}
Exemplo n.º 6
0
void DArray<T>::RemoveData( int index )
{
    AppAssert( index < m_arraySize && index >= 0 );
    AppAssert( shadow[index] != 0 );
    
    shadow[index] = 0;
}
Exemplo n.º 7
0
inline T& DArray<T>::operator [] (int index)
{
    // assert used instead of SnlAssert
    // because this is inline
    AppAssert( index < m_arraySize && index >= 0 );
    AppAssert( shadow[index] != 0 );
    
    return array[index];    
}
Exemplo n.º 8
0
const char *FindCaseInsensitive ( const char *_fullPath )
{

    if ( !_fullPath )
        return NULL;

    static char retval[PATH_MAX];
    char *dir = NULL, *file = NULL;

    if ( (dir = GetDirectoryPart(_fullPath)) != NULL )
    {
        // Make our own copy of the result, since GetDirectoryPart
        // and GetFilenamePart use the same variable for temp
        // storage.
        dir = newStr(dir);
    }
    if ( !dir )
    {
        // No directory provided. Assume working directory.
        file = newStr(_fullPath);
    } else {
        // Kill the last slash
        dir[strlen(dir) - 1] = '\0';
        file = newStr(GetFilenamePart(_fullPath));
    }
    LList <char *> *files = ListDirectory(dir, file);

    delete [] dir; delete [] file; dir = file = NULL;

    // We shouldn't have found more than one match.
    AppAssert(files->Size() <= 1);

    // No results, so maybe the file does not exist.
    if ( files->Size() == 0 )
       return _fullPath;

    // Copy the corrected path back, and prepare to return it.
    memset ( retval, 0, sizeof ( retval ) );
    AppAssert ( strlen ( files->GetData(0) ) < PATH_MAX );
    strcpy ( retval, files->GetData(0) );

    // Negate the possibility of a memory access violation.
    // This way, we can simply strcpy the result inline without
    // worrying about a buffer overflow.
    AppAssert(strlen(retval) == strlen(_fullPath));

    while ( files->Size() )
	{
		char *data = files->GetData(0);
		files->RemoveData(0);
		delete [] data;
	}

    delete files;

    return retval;
}
Exemplo n.º 9
0
void FastDArray <T>::MarkUsed( int index )
{
    AppAssert( index < this->m_arraySize && index >= 0 );
    AppAssert( this->shadow[index] == 0 );
    
    this->shadow[index] = 1;
	++numused;
    RebuildFreeList();
}
Exemplo n.º 10
0
void FastDArray <T>::RemoveData( int index )
{
    AppAssert( index < this->m_arraySize && index >= 0 );
    AppAssert( this->shadow[index] != 0 );
    
	--numused;
    this->shadow[index] = 0;
    freelist[index] = firstfree;
	firstfree = index;
}
Exemplo n.º 11
0
bool EclMouseInButton( EclWindow *window, EclButton *button )
{
    AppAssert( window );
    AppAssert( button );

    return( mouseX >= window->m_x + button->m_x &&
            mouseX <= window->m_x + button->m_x + button->m_w &&
            mouseY >= window->m_y + button->m_y &&
            mouseY <= window->m_y + button->m_y + button->m_h );
}
Exemplo n.º 12
0
void
ThreadTestAppForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
{
    UiApp* pApp = UiApp::GetInstance();
    AppAssert(pApp);
    pApp->Terminate();
}
Exemplo n.º 13
0
//BackButton
void
Lanking::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
{
	SceneManager* pSceneManager = SceneManager::GetInstance();
	AppAssert(pSceneManager);
	pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
}
Exemplo n.º 14
0
int FastDArray <T>::PutData( const T &newdata )
{
    if ( firstfree == -1 )
	{
		// Must resize the array		
		Grow();
	}

    AppAssert(firstfree != -1);

    if ( firstfree == -1 )
	{
		// Must resize the array		
		Grow();
	}

	int freeslot = firstfree;
	int nextfree = freelist[freeslot];

    this->array[freeslot] = newdata;
	if ( this->shadow[freeslot] == 0 ) ++numused;
    this->shadow[freeslot] = 1;
	freelist[freeslot] = -2;
	firstfree = nextfree;
  
    return freeslot;
}
Exemplo n.º 15
0
BadaFileStream::BadaFileStream(File *ioFile, bool writeMode) :
	bufferIndex(0),
	bufferLength(0),
	writeMode(writeMode),
	file(ioFile) {
	AppAssert(ioFile != 0);
}
Exemplo n.º 16
0
void EclRegisterWindow ( EclWindow *window, EclWindow *parent )
{
    
    AppAssert( window );

    if ( EclGetWindow ( window->m_name ) )
    {
        AppReleaseAssert( false, "Window %s already exists", window->m_name );
    }

    if( parent && window->m_x == 0 && window->m_y == 0 )
    {
        // We should place the window in a decent locatiom
        int left = screenW / 2 - parent->m_x;
        int above = screenH / 2 - parent->m_y;
        if( left > window->m_w / 2 )    window->m_x = int( parent->m_x + parent->m_w * (float) rand() / (float) RAND_MAX );
        else                            window->m_x = int( parent->m_x - window->m_w * (float) rand() / (float) RAND_MAX );
        if( above > window->m_h / 2 )   window->m_y = int( parent->m_y + parent->m_h * (float) rand() / (float) RAND_MAX );
        else                            window->m_y = int( parent->m_y - window->m_h/2 * (float) rand() / (float) RAND_MAX );
    }

    if( window->m_x < 0 ) window->m_x = 0;
    if( window->m_y < 0 ) window->m_y = 0;
    if( window->m_x + window->m_w > screenW ) window->m_x = screenW - window->m_w;
    if( window->m_y + window->m_h > screenH ) window->m_y = screenH - window->m_h;

    windows.PutDataAtStart ( window );
    window->Create();

    EclSetCurrentFocus( window->m_name );
}
Exemplo n.º 17
0
void
EditPanel::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
{
	SceneManager* pSceneManager = SceneManager::GetInstance();
	AppAssert(pSceneManager);
	draw_timer.Cancel();
	pSceneManager->GoForward(ForwardSceneTransition(SCENE_MAIN_FORM, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
}
Exemplo n.º 18
0
bool EclMouseInWindow( EclWindow *window )
{
    AppAssert( window );

    return( mouseX >= window->m_x &&
            mouseX <= window->m_x + window->m_w &&
            mouseY >= window->m_y &&
            mouseY <= window->m_y + window->m_h );

}
void BTree<T>::RecursiveConvertIndexToDArray( DArray <char *> *darray, BTree<T> *btree )
{
    AppAssert(darray);
    
    if( !btree ) return;            // Base case
    
    if( btree->id ) darray->PutData( btree->id );
    
    RecursiveConvertIndexToDArray( darray, btree->Left () );
    RecursiveConvertIndexToDArray( darray, btree->Right() );
}
Exemplo n.º 20
0
void MatchMaker_RequestConnection( char *_targetIp, int _targetPort, Directory *_myDetails )
{
#ifdef WAN_PLAY_ENABLED
    AppDebugOut( "Requesting connection to %s:%d via matchmaker\n", _targetIp, _targetPort );

    Directory request( _myDetails );
    request.SetName     ( NET_MATCHMAKER_MESSAGE );
    request.CreateData  ( NET_METASERVER_COMMAND, NET_MATCHMAKER_REQUEST_CONNECT );
    request.CreateData  ( NET_MATCHMAKER_TARGETIP, _targetIp );
    request.CreateData  ( NET_MATCHMAKER_TARGETPORT, _targetPort );

    AppAssert( s_matchMakerIp );

    NetSocket socket;   
    NetRetCode result = socket.Connect( s_matchMakerIp, s_matchMakerPort );
    AppAssert( result == NetOk );

    MetaServer_SendDirectory( &request, &socket );
#endif
}
Exemplo n.º 21
0
void DArray<T>::PutData( const T &newdata, int index )
{
    AppAssert( index >= 0 );

    while( index >= m_arraySize )
    {
        Grow();
    }

    array[index] = newdata;
    shadow[index] = 1;
}
Exemplo n.º 22
0
const char *FindCaseInsensitive( char *_fullPath )
{
    AppAssert(strlen(_fullPath) < PATH_MAX);
    
    static char pathSoFar[PATH_MAX];
    pathSoFar[0] = '\0';
    
    while (true) {
        char *delimiter;
        
        // Skip to the next / or end-of-string
        for (delimiter = (char *)_fullPath; *delimiter && *delimiter != '/'; delimiter++);
        
        char component[PATH_MAX];
        AppAssert ( strlen(_fullPath) < PATH_MAX );
        strcpy( component, _fullPath );
        component[delimiter - _fullPath] = '\0';
    
        // Search for a match
        LList<char *> *matches = ListDirectory( pathSoFar, component, true );
        bool found = false;
    
        if (matches->Size() > 0) {
            strcpy(pathSoFar, matches->GetData( 0 ));
            found = true;
        }
    
        matches->EmptyAndDelete();
    
        // Failed to find a match, just return the original
        if (!found)
            return _fullPath;
        
        // Got to the end of the path, return it
        if (!*delimiter) 
            return pathSoFar;
        
        _fullPath = delimiter + 1;
    }
}
Exemplo n.º 23
0
void FastDArray <T>::PutData( const T &newdata, int index )
{
    AppAssert( index < this->m_arraySize && index >= 0 );       

    this->array[index] = newdata;

    if ( this->shadow[index] == 0 ) 
	{
		this->shadow[index] = 1;
		++numused;
		RebuildFreeList();
	}
}
Exemplo n.º 24
0
bool IsDirectory(const char *_fullPath)
{
#ifdef WIN32
    AppAssert( false );
    // To do
    return false;
#else
    struct stat s;
    int rc = stat(_fullPath, &s);
    if (rc != 0)
        return false;
    return (s.st_mode & S_IFDIR);
#endif
}
Exemplo n.º 25
0
BadaFilesystemNode::BadaFilesystemNode(const Common::String &root,
																			 const Common::String &nodePath) {
	// Make sure the string contains no slashes
	AppAssert(!nodePath.contains('/'));

	// We assume here that path is already normalized (hence don't bother to
	// call Common::normalizePath on the final path).
	Common::String newPath(root);
	if (root.lastChar() != '/') {
		newPath += '/';
	}
	newPath += nodePath;

	init(newPath);
}
Exemplo n.º 26
0
void EarthData::LoadCoastlines()
{
    double startTime = GetHighResTime();

    m_islands.EmptyAndDelete();

    int numIslands = 0;

    char coastFile[1024];
    if( g_preferences->GetInt(PREFS_GRAPHICS_LOWRESWORLD) == 0 )
    {
        strcpy(coastFile, "data/earth/coastlines.dat");
    }
    else
    {
        strcpy(coastFile, "data/earth/coastlines-low.dat");
    }

    TextReader *coastlines = g_fileSystem->GetTextReader( coastFile );
    AppAssert( coastlines && coastlines->IsOpen() );
    Island *island = NULL;
    
    while( coastlines->ReadLine() )
    {        
        char *line = coastlines->GetRestOfLine();
        if( line[0] == 'b' )
        {
            if( island )
            {           
                m_islands.PutData( island );                  
            }
            island = new Island();
            ++numIslands;
        }
        else
        {
            float longitude, latitude;
            sscanf( line, "%f %f", &longitude, &latitude );
            island->m_points.PutData( new Vector3<float>( longitude, latitude, 0.0f ) );            
        }
    }

    delete coastlines;

    double totalTime = GetHighResTime() - startTime;
    AppDebugOut( "Parsing Coastline data (%d islands) : %dms\n", numIslands, int( totalTime * 1000.0f ) );
}
Exemplo n.º 27
0
void MatchMaker_StartRequestingIdentity( NetSocketListener *_listener )
{
    AppAssert( s_matchMakerIp );

    if( _listener &&
        !MatchMaker_IsRequestingIdentity(_listener) )
    {
        AppDebugOut( "Started requesting public IP:port for socket %d\n", _listener->GetBoundSocketHandle() );

        MatchMakerListener *listener = new MatchMakerListener();
        listener->m_listener = _listener;

        s_listenersMutex.Lock();
        int index = s_listeners.PutData(listener);
        s_listenersMutex.Unlock();
        
        NetStartThread( RequestIdentityThread, _listener );
    }
}
Exemplo n.º 28
0
int HashTable<T>::PutData(char const *_key, T const &_data)
{
	// 
	// Make sure the table is big enough

	if (m_slotsFree * 2 <= m_size)
	{
		Grow();
	}


	//
	// Do the main insert

	unsigned int index = GetInsertPos(_key);
	AppAssert(m_keys[index] == NULL);
	m_keys[index] = newStr ( _key );
	m_data[index] = _data;
	m_slotsFree--;

	return index;
}
Exemplo n.º 29
0
void EarthData::LoadBorders()
{
    double startTime = GetHighResTime();
    
    m_borders.EmptyAndDelete();

    int numIslands = 0;    
    Island *island = NULL;

    TextReader *international = g_fileSystem->GetTextReader( "data/earth/international.dat" );
    AppAssert( international && international->IsOpen() );

    while( international->ReadLine() )
    {
        char *line = international->GetRestOfLine();        
        if( line[0] == 'b' )
        {
            if( island )
            {
                m_borders.PutData( island );                  
                ++numIslands;
            }
            island = new Island();            
        }
        else
        {
            float longitude, latitude;
            sscanf( line, "%f %f", &longitude, &latitude );
            island->m_points.PutData( new Vector3<float>( longitude, latitude, 0.0f ) );
        }
    }
    
    delete international;

    double totalTime = GetHighResTime() - startTime;
    AppDebugOut( "Parsing International data (%d islands) : %dms\n", numIslands, int( totalTime * 1000.0f ) );
}
Exemplo n.º 30
0
void App::RenderOwner()
{
    static char s_message[1024];
    static bool s_dealtWith = false;

    if( !s_dealtWith )
    {
        // First try to read data/world-encode.dat
        // If it is present open it, encode it into world.dat, then delete it
        TextFileReader *encode = new TextFileReader( "data/world-encode.txt" );
        if( encode->IsOpen() )
        {
            encode->ReadLine();
            char *encodeMe = encode->GetRestOfLine();
            TextFileWriter encodeTo( "data/world.dat", true );
            encodeTo.printf( "%s\n", encodeMe );
        }
        delete encode;
        DeleteThisFile( "data/world-encode.txt" );


        // Now open the encoded world.dat file
        // Decrypt the contents for printing onto the screen
        TextFileReader reader( "data/world.dat" );
        AppAssert( reader.IsOpen() );
        reader.ReadLine();
        char *line = reader.GetRestOfLine();
        sprintf( s_message, "%s", line );
        char *nextLine = strchr( s_message, '\n' );
        if( nextLine ) *nextLine = '\x0';
        //strupr( s_message );

        s_dealtWith = true;
    }

    g_renderer->Text( 10, g_windowManager->WindowH() - 20, Colour(255,50,50,255), 20, s_message );
}