EyedropperStatusDisplay::~EyedropperStatusDisplay() { if( mOnSprite != NULL ) { freeSprite( mOnSprite ); } if( mOffSprite != NULL ) { freeSprite( mOffSprite ); } }
Font::~Font() { for( int i=0; i<256; i++ ) { if( mSpriteMap[i] != NULL ) { freeSprite( mSpriteMap[i] ); } } }
void entity_free(Entity **entity) { Entity *self; if (!entity)return; if (!*entity)return; self = *entity; freeSprite(&self->sprite); *entity = NULL; }
//------------------------------------------------------------ //------------------------------------------------------------ void Sprite::free() { if(0xFF != m_nSpriteObj) { hide(); PA_DeleteSprite(m_nScreen, m_nSpriteObj); freeSprite(m_nSpriteObj); m_nSpriteObj = 0xFF; } }
void Sprite::freeAllSprites() { int nLoop; // free all sprite one by one for(nLoop = (m_nFreeIndex - 1); nLoop >= 0; ++nLoop) { freeSprite(m_naNextAvailableSprite[ nLoop ]); } // reinit data structure for(nLoop = 0; nLoop < MAX_SPRITE_NUM; ++nLoop) { m_naNextAvailableSprite[ nLoop ] = nLoop; } m_naNextAvailableSprite[ MAX_SPRITE_NUM ] = 0xFF; m_nFreeIndex = 0; }
void freeTools() { for( int i=0; i<tools.size(); i++ ) { toolRecord r = *( tools.getElement( i ) ); delete [] r.name; delete [] r.description; delete [] r.descriptionPlural; freeSprite( r.sprite ); } tools.deleteAll(); if( idToIndexMap != NULL ) { delete [] idToIndexMap; idToIndexMap = NULL; } }
void initTools() { File elementsDir( NULL, "gameElements" ); if( !elementsDir.exists() || !elementsDir.isDirectory() ) { return; } File *toolsDir = elementsDir.getChildFile( "tools" ); if( toolsDir == NULL ) { return; } else if( !toolsDir->exists() || !toolsDir->isDirectory() ) { delete toolsDir; return; } int numTools; File **toolNameDirs = toolsDir->getChildFiles( &numTools ); delete toolsDir; if( toolNameDirs == NULL ) { return; } for( int i=0; i<numTools; i++ ) { File *f = toolNameDirs[i]; if( f->exists() && f->isDirectory() ) { char completeRecord = true; toolRecord r; r.name = f->getFileName(); r.description = NULL; r.descriptionPlural = NULL; r.sprite = NULL; File *infoFile = f->getChildFile( "info.txt" ); completeRecord = readInfoFile( infoFile, &( r.id ), &( r.description ) ); delete infoFile; if( completeRecord ) { File *pluralFile = f->getChildFile( "plural.txt" ); completeRecord = readPluralFile( pluralFile, &( r.descriptionPlural ) ); delete pluralFile; } if( completeRecord ) { // read reach, if present (if not, default to 1) r.reach = 1; File *reachFile = f->getChildFile( "reach.txt" ); if( reachFile->exists() ) { char *reach = reachFile->readFileContents(); sscanf( reach, "%d", &( r.reach ) ); delete [] reach; } delete reachFile; File *reachSigFile = f->getChildFile( "reachSignature.txt" ); char *reachSigContents = NULL; if( reachSigFile->exists() ) { reachSigContents = reachSigFile->readFileContents(); } delete reachSigFile; char reachSigOK = true; if( regenerateReachSignatures ) { // ignore reachSignature.txt and generate a new one char *newSig = computeReachSignature( &r ); File *childFile = f->getChildFile( "reachSignature.txt" ); if( childFile != NULL ) { childFile->writeToFile( newSig ); delete childFile; } delete [] newSig; } else if( reachSigContents == NULL ) { reachSigOK = false; } else { // else check it char *sig = trimWhitespace( reachSigContents ); char *trueSig = computeReachSignature( &r ); if( strcmp( trueSig, sig ) != 0 ) { reachSigOK = false; } delete [] sig; delete [] trueSig; } if( reachSigContents != NULL ) { delete [] reachSigContents; } if( !reachSigOK ) { char *dirName = f->getFullFileName(); char *message = autoSprintf( "%s\n%s", translate( "badReachSignature" ), dirName ); delete [] dirName; loadingFailed( message ); delete [] message; } // look for sprite TGA int numChildFiles; File **childFiles = f->getChildFiles( &numChildFiles ); char *tgaPath = NULL; char *shadeMapTgaPath = NULL; for( int j=0; j<numChildFiles; j++ ) { File *f = childFiles[j]; char *name = f->getFileName(); if( strstr( name, "_shadeMap.tga" ) != NULL ) { if( shadeMapTgaPath != NULL ) { delete [] shadeMapTgaPath; } shadeMapTgaPath = f->getFullFileName(); } else if( strstr( name, ".tga" ) != NULL ) { if( tgaPath != NULL ) { delete [] tgaPath; } tgaPath = f->getFullFileName(); } delete [] name; delete childFiles[j]; } delete [] childFiles; if( tgaPath != NULL ) { // assume only one orientation here // discard extras SpriteHandle readSprites[ MAX_ORIENTATIONS ]; int numOrientations = readShadeMappedSprites( tgaPath, shadeMapTgaPath, readSprites ); if( numOrientations == 0 ) { completeRecord = false; } else { r.sprite = readSprites[0]; for( int o=1; o<numOrientations; o++ ) { freeSprite( readSprites[o] ); } } } else { if( shadeMapTgaPath != NULL ) { delete [] shadeMapTgaPath; } completeRecord = false; } } if( completeRecord ) { if( r.id >= idSpaceSize ) { idSpaceSize = r.id + 1; } tools.push_back( r ); } else { delete [] r.name; if( r.description != NULL ) { delete [] r.description; } if( r.descriptionPlural != NULL ) { delete [] r.descriptionPlural; } if( r.sprite != NULL ) { freeSprite( r.sprite ); } } } delete f; } delete [] toolNameDirs; // build map idToIndexMap = new int[idSpaceSize]; for( int i=0; i<idSpaceSize; i++ ) { idToIndexMap[i] = -1; } for( int i=0; i<tools.size(); i++ ) { toolRecord r = *( tools.getElement( i ) ); idToIndexMap[r.id] = i; } }
void sdlMapLibere(sdlMap *sdMap) { freeSprite(sdMap->Terrain); freeSprite(sdMap->Path); freeSprite(sdMap->Ville); freeSprite(sdMap->Grotte); SDL_FreeSurface(getSdlMapEcran(sdMap)); freeSprite(sdMap->TowerAura); freeSprite(sdMap->TowerKnight); freeSprite(sdMap->TowerArcher); freeSprite(sdMap->TowerMage); freeSprite(sdMap->TowerCannon); freeSprite(sdMap->Life); freeSprite(sdMap->EnemyFly); freeSprite(sdMap->EnemyClassic); freeSprite(sdMap->EnemyBoss); freeSprite(sdMap->Projectile); freeSprite(sdMap->Cursor); freeSprite(sdMap->Range); freeSprite(sdMap->InterfaceBackground); freeMap(getSdlMap(sdMap)); freeInterface(getSdlMapInterface(sdMap)); TTF_CloseFont(sdMap->police); TTF_CloseFont(sdMap->policeMin); TTF_Quit(); SDL_Quit(); }