Commit b9c1b18f authored by hybrid's avatar hybrid

Small code cleaning.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1417 dfc29bdd-3216-0410-991c-e03cc46cb475
parent b9d47be0
...@@ -171,10 +171,8 @@ const c8* CFileList::getFullFileName(u32 index) ...@@ -171,10 +171,8 @@ const c8* CFileList::getFullFileName(u32 index)
bool CFileList::isDirectory(u32 index) const bool CFileList::isDirectory(u32 index) const
{ {
bool ret; bool ret = false;
if (index >= Files.size()) if (index < Files.size())
ret = false;
else
ret = Files[index].isDirectory; ret = Files[index].isDirectory;
_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
......
...@@ -26,26 +26,22 @@ public: ...@@ -26,26 +26,22 @@ public:
CFileList(); CFileList();
//! Returns the amount of files in the filelist. //! Returns the amount of files in the filelist.
//! \return /** \return Amount of files and directories in the file list. */
//! Returns the amount of files and directories in the file list.
virtual u32 getFileCount() const; virtual u32 getFileCount() const;
//! Gets the name of a file in the list, based on an index. //! Gets the name of a file in the list, based on an index.
//! \param index is the zero based index of the file which name should /** \param index is the zero based index of the file which name should
//! be returned. The index has to be smaller than the amount getFileCount() returns. be returned. The index has to be smaller than the amount getFileCount() returns.
//! \return \return The file name of the file. Returns 0, if an error occured. */
//! Returns the file name of the file. Returns 0, if an error occured.
virtual const c8* getFileName(u32 index) const; virtual const c8* getFileName(u32 index) const;
//! Gets the full name of a file in the list, path included, based on an index. //! Gets the full name of a file in the list, path included, based on an index.
virtual const c8* getFullFileName(u32 index); virtual const c8* getFullFileName(u32 index);
//! Returns of the file is a directory //! Returns of the file is a directory
//! \param index is the zero based index of the file which name should /** \param index is the zero based index of the file which name should
//! be returned. The index has to be smaller than the amount getFileCount() returns. be returned. The index has to be smaller than the amount getFileCount() returns.
//! \return \return True if the file is a directory, else false. */
//! Returns true, if the file is a directory, and false, if it is not.
//! If an error occurs, the result is undefined.
virtual bool isDirectory(u32 index) const; virtual bool isDirectory(u32 index) const;
private: private:
......
...@@ -218,24 +218,19 @@ bool CFileSystem::changeWorkingDirectoryTo(const c8* newDirectory) ...@@ -218,24 +218,19 @@ bool CFileSystem::changeWorkingDirectoryTo(const c8* newDirectory)
core::stringc CFileSystem::getAbsolutePath(const core::stringc& filename) const core::stringc CFileSystem::getAbsolutePath(const core::stringc& filename) const
{ {
c8 *p=0; c8 *p=0;
core::stringc ret;
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_WINDOWS_API_
#if !defined ( _WIN32_WCE ) #if !defined ( _WIN32_WCE )
c8 fpath[_MAX_PATH]; c8 fpath[_MAX_PATH];
p = _fullpath( fpath, filename.c_str(), _MAX_PATH); p = _fullpath( fpath, filename.c_str(), _MAX_PATH);
ret = p;
#endif #endif
#elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_)) #elif (defined(_IRR_POSIX_API_) || defined(_IRR_OSX_PLATFORM_))
c8 fpath[4096]; c8 fpath[4096];
p = realpath(filename.c_str(), fpath); p = realpath(filename.c_str(), fpath);
ret = p;
#endif #endif
return ret; return core::stringc(p);
} }
......
...@@ -12,17 +12,14 @@ namespace io ...@@ -12,17 +12,14 @@ namespace io
CMemoryReadFile::CMemoryReadFile(void* memory, long len, const c8* fileName, bool d) CMemoryReadFile::CMemoryReadFile(void* memory, long len, const c8* fileName, bool d)
: Buffer(memory), Len(len), Pos(0), deleteMemoryWhenDropped(d) : Buffer(memory), Len(len), Pos(0), Filename(fileName), deleteMemoryWhenDropped(d)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CMemoryReadFile"); setDebugName("CMemoryReadFile");
#endif #endif
Filename = fileName;
} }
CMemoryReadFile::~CMemoryReadFile() CMemoryReadFile::~CMemoryReadFile()
{ {
if (deleteMemoryWhenDropped) if (deleteMemoryWhenDropped)
...@@ -30,7 +27,6 @@ CMemoryReadFile::~CMemoryReadFile() ...@@ -30,7 +27,6 @@ CMemoryReadFile::~CMemoryReadFile()
} }
//! returns how much was read //! returns how much was read
s32 CMemoryReadFile::read(void* buffer, u32 sizeToRead) s32 CMemoryReadFile::read(void* buffer, u32 sizeToRead)
{ {
...@@ -74,7 +70,6 @@ bool CMemoryReadFile::seek(long finalPos, bool relativeMovement) ...@@ -74,7 +70,6 @@ bool CMemoryReadFile::seek(long finalPos, bool relativeMovement)
} }
//! returns size of file //! returns size of file
long CMemoryReadFile::getSize() const long CMemoryReadFile::getSize() const
{ {
...@@ -82,7 +77,6 @@ long CMemoryReadFile::getSize() const ...@@ -82,7 +77,6 @@ long CMemoryReadFile::getSize() const
} }
//! returns where in the file we are. //! returns where in the file we are.
long CMemoryReadFile::getPos() const long CMemoryReadFile::getPos() const
{ {
...@@ -90,7 +84,6 @@ long CMemoryReadFile::getPos() const ...@@ -90,7 +84,6 @@ long CMemoryReadFile::getPos() const
} }
//! returns name of file //! returns name of file
const c8* CMemoryReadFile::getFileName() const const c8* CMemoryReadFile::getFileName() const
{ {
...@@ -98,7 +91,6 @@ const c8* CMemoryReadFile::getFileName() const ...@@ -98,7 +91,6 @@ const c8* CMemoryReadFile::getFileName() const
} }
IReadFile* createMemoryReadFile(void* memory, long size, const c8* fileName, bool deleteMemoryWhenDropped) IReadFile* createMemoryReadFile(void* memory, long size, const c8* fileName, bool deleteMemoryWhenDropped)
{ {
CMemoryReadFile* file = new CMemoryReadFile(memory, size, fileName, deleteMemoryWhenDropped); CMemoryReadFile* file = new CMemoryReadFile(memory, size, fileName, deleteMemoryWhenDropped);
......
...@@ -21,16 +21,16 @@ namespace io ...@@ -21,16 +21,16 @@ namespace io
{ {
public: public:
//! Constructor
CMemoryReadFile(void* memory, long len, const c8* fileName, bool deleteMemoryWhenDropped); CMemoryReadFile(void* memory, long len, const c8* fileName, bool deleteMemoryWhenDropped);
//! Destructor
virtual ~CMemoryReadFile(); virtual ~CMemoryReadFile();
//! returns how much was read //! returns how much was read
virtual s32 read(void* buffer, u32 sizeToRead); virtual s32 read(void* buffer, u32 sizeToRead);
//! changes position in file, returns true if successful //! changes position in file, returns true if successful
//! if relativeMovement==true, the pos is changed relative to current pos,
//! otherwise from begin of file
virtual bool seek(long finalPos, bool relativeMovement = false); virtual bool seek(long finalPos, bool relativeMovement = false);
//! returns size of file //! returns size of file
...@@ -44,10 +44,10 @@ namespace io ...@@ -44,10 +44,10 @@ namespace io
private: private:
core::stringc Filename;
void *Buffer; void *Buffer;
long Len; long Len;
long Pos; long Pos;
core::stringc Filename;
bool deleteMemoryWhenDropped; bool deleteMemoryWhenDropped;
}; };
......
...@@ -11,18 +11,16 @@ namespace io ...@@ -11,18 +11,16 @@ namespace io
CReadFile::CReadFile(const c8* fileName) CReadFile::CReadFile(const c8* fileName)
: File(0), FileSize(0) : File(0), FileSize(0), Filename(fileName)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CReadFile"); setDebugName("CReadFile");
#endif #endif
Filename = fileName;
openFile(); openFile();
} }
CReadFile::~CReadFile() CReadFile::~CReadFile()
{ {
if (File) if (File)
...@@ -30,7 +28,6 @@ CReadFile::~CReadFile() ...@@ -30,7 +28,6 @@ CReadFile::~CReadFile()
} }
//! returns how much was read //! returns how much was read
s32 CReadFile::read(void* buffer, u32 sizeToRead) s32 CReadFile::read(void* buffer, u32 sizeToRead)
{ {
...@@ -41,7 +38,6 @@ s32 CReadFile::read(void* buffer, u32 sizeToRead) ...@@ -41,7 +38,6 @@ s32 CReadFile::read(void* buffer, u32 sizeToRead)
} }
//! changes position in file, returns true if successful //! changes position in file, returns true if successful
//! if relativeMovement==true, the pos is changed relative to current pos, //! if relativeMovement==true, the pos is changed relative to current pos,
//! otherwise from begin of file //! otherwise from begin of file
...@@ -54,7 +50,6 @@ bool CReadFile::seek(long finalPos, bool relativeMovement) ...@@ -54,7 +50,6 @@ bool CReadFile::seek(long finalPos, bool relativeMovement)
} }
//! returns size of file //! returns size of file
long CReadFile::getSize() const long CReadFile::getSize() const
{ {
...@@ -62,7 +57,6 @@ long CReadFile::getSize() const ...@@ -62,7 +57,6 @@ long CReadFile::getSize() const
} }
//! returns where in the file we are. //! returns where in the file we are.
long CReadFile::getPos() const long CReadFile::getPos() const
{ {
...@@ -70,7 +64,6 @@ long CReadFile::getPos() const ...@@ -70,7 +64,6 @@ long CReadFile::getPos() const
} }
//! opens the file //! opens the file
void CReadFile::openFile() void CReadFile::openFile()
{ {
......
...@@ -22,7 +22,6 @@ IImageWriter* createImageWriterBMP(); ...@@ -22,7 +22,6 @@ IImageWriter* createImageWriterBMP();
CSoftwareTexture2::CSoftwareTexture2(IImage* image, const char* name, bool generateMipLevels, bool isRenderTarget) CSoftwareTexture2::CSoftwareTexture2(IImage* image, const char* name, bool generateMipLevels, bool isRenderTarget)
: ITexture(name), MipMapLOD(0), HasMipMaps(generateMipLevels), IsRenderTarget(isRenderTarget) : ITexture(name), MipMapLOD(0), HasMipMaps(generateMipLevels), IsRenderTarget(isRenderTarget)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("CSoftwareTexture2"); setDebugName("CSoftwareTexture2");
#endif #endif
...@@ -37,13 +36,12 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const char* name, bool gener ...@@ -37,13 +36,12 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const char* name, bool gener
{ {
core::dimension2d<s32> optSize; core::dimension2d<s32> optSize;
core::dimension2d<s32> origSize = image->getDimension(); OrigSize = image->getDimension();
OrigSize = origSize;
optSize.Width = getTextureSizeFromSurfaceSize(origSize.Width); optSize.Width = getTextureSizeFromSurfaceSize(OrigSize.Width);
optSize.Height = getTextureSizeFromSurfaceSize(origSize.Height); optSize.Height = getTextureSizeFromSurfaceSize(OrigSize.Height);
if ( origSize == optSize ) if ( OrigSize == optSize )
{ {
MipMap[0] = new CImage(BURNINGSHADER_COLOR_FORMAT, image); MipMap[0] = new CImage(BURNINGSHADER_COLOR_FORMAT, image);
} }
...@@ -60,8 +58,8 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const char* name, bool gener ...@@ -60,8 +58,8 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const char* name, bool gener
} }
} }
regenerateMipMapLevels (); regenerateMipMapLevels();
setCurrentMipMapLOD ( 0 ); setCurrentMipMapLOD(0);
} }
...@@ -71,7 +69,7 @@ CSoftwareTexture2::~CSoftwareTexture2() ...@@ -71,7 +69,7 @@ CSoftwareTexture2::~CSoftwareTexture2()
for ( s32 i = 0; i!= SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) for ( s32 i = 0; i!= SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i )
{ {
if ( MipMap[i] ) if ( MipMap[i] )
MipMap[i]->drop (); MipMap[i]->drop();
} }
} }
...@@ -105,7 +103,7 @@ void CSoftwareTexture2::regenerateMipMapLevels() ...@@ -105,7 +103,7 @@ void CSoftwareTexture2::regenerateMipMapLevels()
for ( i = 1; i!= SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) for ( i = 1; i!= SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i )
{ {
if ( MipMap[i] ) if ( MipMap[i] )
MipMap[i]->drop (); MipMap[i]->drop();
} }
core::dimension2d<s32> newSize; core::dimension2d<s32> newSize;
...@@ -120,9 +118,9 @@ void CSoftwareTexture2::regenerateMipMapLevels() ...@@ -120,9 +118,9 @@ void CSoftwareTexture2::regenerateMipMapLevels()
newSize.Height = core::s32_max ( 1, currentSize.Height >> SOFTWARE_DRIVER_2_MIPMAPPING_SCALE ); newSize.Height = core::s32_max ( 1, currentSize.Height >> SOFTWARE_DRIVER_2_MIPMAPPING_SCALE );
MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize); MipMap[i] = new CImage(BURNINGSHADER_COLOR_FORMAT, newSize);
MipMap[0]->copyToScalingBoxFilter ( MipMap[i], 0 ); MipMap[0]->copyToScalingBoxFilter( MipMap[i], 0 );
c = MipMap[i]; c = MipMap[i];
i += 1; ++i;
} }
} }
......
...@@ -60,8 +60,8 @@ CXXFLAGS += -pg ...@@ -60,8 +60,8 @@ CXXFLAGS += -pg
endif endif
CFLAGS := -fexpensive-optimizations -O3 -DPNG_THREAD_UNSAFE_OK -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES CFLAGS := -fexpensive-optimizations -O3 -DPNG_THREAD_UNSAFE_OK -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES
sharedlib sharedlib_win32 : CXXFLAGS += -fpic sharedlib : CXXFLAGS += -fpic
sharedlib sharedlib_win32 : CFLAGS += -fpic sharedlib : CFLAGS += -fpic
#multilib handling #multilib handling
ifeq ($(HOSTTYPE), x86_64) ifeq ($(HOSTTYPE), x86_64)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment