/*!
\b parameters:

\arg \b pSu             Pointer to a new surface object

\b Operation:

This function returns 1 (true) if the parameter surface object exists and it is satisfactory deleted from the manager.
*/
bool IND_SurfaceManager::remove(IND_Surface *pSu) {
	g_debug->header("Freeing surface", 5);

	if (!_ok || !pSu) {
		writeMessage();
		return 0;
	}

	// Search object
	bool mIs = 0;
	list <IND_Surface *>::iterator mSurfaceListIter;
	for (mSurfaceListIter  = _listSurfaces->begin();
	        mSurfaceListIter != _listSurfaces->end();
	        mSurfaceListIter++) {
		if ((*mSurfaceListIter) == pSu) {
			mIs = 1;
			break;
		}
	}

	if (!mIs) {
		writeMessage();
		return 0;
	}

	// ----- Free object -----

	// Quit from list
	delFromlist(pSu);

	g_debug->header("Ok", 6);

	return 1;
}
/**
 * This function returns 1 (true) if the 3d Mesh object passed as parameter exists and is
 * deleted from the manager successfully.
 * @param pMe			Pointer to an 3d Mesh object.
 */
bool IND_3dMeshManager::remove(IND_3dMesh *pMe) {
	g_debug->header("Freeing 3d Mesh", 5);

	if (!_ok || !pMe) {
		writeMessage();
		return 0;
	}

	// Search object
	bool mIs = 0;
	list <IND_3dMesh *>::iterator _listIter;
	for (_listIter  = _list3dMesh->begin();
	        _listIter != _list3dMesh->end();
	        _listIter++) {
		if ((*_listIter) == pMe) {
			mIs = 1;
			break;
		}
	}

	// Not found
	if (!mIs) {
		writeMessage();
		return 0;
	}

	// ----- Free object -----

	g_debug->header("Freeing 3d mesh:", 3);
	g_debug->dataChar(pMe->GetMeshName(), 1);

	// Quit from list
	delFromlist(pMe);

	// Free mesh
	if (pMe->_3dMesh._animController) {
		pMe->_3dMesh._animController->Release();
		pMe->_3dMesh._animController = 0;
	}

	// free hierarchy
	if (pMe->_3dMesh._frameRoot) {
		// Create a mesh heirarchy class to control the removal of memory for the frame heirarchy
		XMeshHierarchy memoryAllocator;
		D3DXFrameDestroy(pMe->_3dMesh._frameRoot, &memoryAllocator);
		pMe->_3dMesh._frameRoot = 0;
	}

	// Free bones
	if (pMe->_3dMesh._boneMatrices) {
		DISPOSEARRAY(pMe->_3dMesh._boneMatrices);
	}

	// Free the pointer
	DISPOSE(pMe);

	g_debug->header("Ok", 6);

	return 1;
}
Exemplo n.º 3
0
/**
 * Returns 1(true) if the image object passed as parameter exists and it is
 * deleted from the manager successfully.
 * @param pIm						Pointer to an image object.
 */
bool IND_ImageManager::remove(IND_Image *pIm) {
	g_debug->header("Freeing image", DebugApi::LogHeaderBegin);

	if (!_ok || !pIm) {
		writeMessage();
		return 0;
	}

	// Search object
	bool mIs = 0;
	list <IND_Image *>::iterator mImageListIter;
	for (mImageListIter  = _listImages->begin();
	        mImageListIter != _listImages->end();
	        mImageListIter++) {
		if ((*mImageListIter) == pIm) {
			mIs = 1;
			break;
		}
	}

	// Not found
	if (!mIs) {
		writeMessage();
		return 0;
	}

	// ----- Free object -----

	g_debug->header("File name:", DebugApi::LogHeaderInfo);
	g_debug->dataChar(pIm->getName(), 1);

    // Free image
	FreeImage_Unload(pIm->getFreeImageHandle());
    
	// Quit from list
	delFromlist(pIm);

	g_debug->header("Ok", DebugApi::LogHeaderEnd);

	return 1;
}
/**
 * Returns 1 (true) if the font object type 1 passed as a parameter exists
 * and it is deleted from the manager successfully.
 * @param pFo						Pointer to font object type 1
 */
bool IND_FontManager::remove(IND_Font  *pFo) {
	g_debug->header("Freeing font", DebugApi::LogHeaderBegin);

	if (!_ok) {
		writeMessage();
		return 0;
	}

	// Search object
	bool mIs = 0;
	list <IND_Font *>::iterator mFontListIter;
	for (mFontListIter  = _listFonts->begin();
	        mFontListIter != _listFonts->end();
	        mFontListIter++) {
		if ((*mFontListIter) == pFo) {
			mIs = 1;
			break;
		}
	}

	// Not found
	if (!mIs) {
		writeMessage();
		return 0;
	}

	// ----- Free object -----

	g_debug->header("File name:", DebugApi::LogHeaderInfo);
	g_debug->dataChar(pFo->getFileName(), 1);
    
	// Quit from list
	delFromlist(pFo);

	g_debug->header("Ok", DebugApi::LogHeaderEnd);

	return 1;
}