Commit c3240d15 authored by bitplane's avatar bitplane

Fixed Quake3Explorer and added codeblocks project. Ensure paths in...

Fixed Quake3Explorer and added codeblocks project. Ensure paths in createFileList end in /, fixed bug in mountPointReader

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2596 dfc29bdd-3216-0410-991c-e03cc46cb475
parent dd98649b
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Irrlicht Example 21 Quake 3 Explorer" />
<Option pch_mode="0" />
<Option compiler="gcc" />
<Build>
<Target title="Linux">
<Option platforms="Unix;" />
<Option output="../../bin/Linux/Quake3Explorer" prefix_auto="0" extension_auto="0" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-W" />
<Add option="-g" />
<Add option="-D_IRR_STATIC_LIB_" />
</Compiler>
<Linker>
<Add library="Xxf86vm" />
<Add library="GL" />
<Add directory="../../lib/Linux" />
</Linker>
</Target>
<Target title="Windows">
<Option platforms="Windows;" />
<Option output="../../bin/Win32-gcc/Quake3Explorer" prefix_auto="0" extension_auto="1" />
<Option type="1" />
<Option compiler="gcc" />
<Option projectResourceIncludeDirsRelation="1" />
<Compiler>
<Add option="-W" />
<Add option="-g" />
<Add directory="../../lib/Win32-gcc" />
</Compiler>
<Linker>
<Add directory="../../lib/Win32-gcc/" />
</Linker>
</Target>
</Build>
<VirtualTargets>
<Add alias="All" targets="Windows;" />
</VirtualTargets>
<Compiler>
<Add option="-W" />
<Add option="-g" />
<Add directory="../../include" />
</Compiler>
<Linker>
<Add library="Irrlicht" />
</Linker>
<Unit filename="main.cpp" />
<Unit filename="q3factory.cpp" />
<Unit filename="q3factory.h" />
<Unit filename="sound.cpp" />
<Unit filename="sound.h" />
<Extensions>
<code_completion />
<debugger />
<envvars />
</Extensions>
</Project>
</CodeBlocks_project_file>
...@@ -188,7 +188,7 @@ s32 GameData::save ( const string<c16> &filename ) ...@@ -188,7 +188,7 @@ s32 GameData::save ( const string<c16> &filename )
IFileSystem *fs = Device->getFileSystem(); IFileSystem *fs = Device->getFileSystem();
for ( i = 0; i != fs->getFileArchiveCount(); ++i ) for ( i = 0; i != fs->getFileArchiveCount(); ++i )
{ {
CurrentArchiveList.push_back ( fs->getFileArchive ( i )->getArchiveName() ); CurrentArchiveList.push_back ( fs->getFileArchive(i)->getFileList()->getPath() );
} }
// Store Player Position and Rotation // Store Player Position and Rotation
...@@ -209,7 +209,7 @@ s32 GameData::save ( const string<c16> &filename ) ...@@ -209,7 +209,7 @@ s32 GameData::save ( const string<c16> &filename )
file->write ( buf, (s32) strlen ( buf ) ); file->write ( buf, (s32) strlen ( buf ) );
for ( i = 0; i != fs->getFileArchiveCount(); ++i ) for ( i = 0; i != fs->getFileArchiveCount(); ++i )
{ {
snprintf ( buf, 128, "archive %s\n",stringc ( fs->getFileArchive ( i )->getArchiveName() ).c_str () ); snprintf ( buf, 128, "archive %s\n",stringc ( fs->getFileArchive(i)->getFileList()->getPath() ).c_str () );
file->write ( buf, (s32) strlen ( buf ) ); file->write ( buf, (s32) strlen ( buf ) );
} }
...@@ -843,7 +843,7 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName ) ...@@ -843,7 +843,7 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName )
bool exists = false; bool exists = false;
for ( i = 0; i != fs->getFileArchiveCount(); ++i ) for ( i = 0; i != fs->getFileArchiveCount(); ++i )
{ {
if ( fs->getFileArchive ( i )->getArchiveName() == archiveName ) if ( fs->getFileArchive(i)->getFileList()->getPath() == archiveName )
{ {
exists = true; exists = true;
break; break;
...@@ -874,6 +874,9 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName ) ...@@ -874,6 +874,9 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName )
case io::EFAT_ZIP: case io::EFAT_ZIP:
typeName = "ZIP"; typeName = "ZIP";
break; break;
case io::EFAT_GZIP:
typeName = "gzip";
break;
case io::EFAT_FOLDER: case io::EFAT_FOLDER:
typeName = "Mount"; typeName = "Mount";
break; break;
...@@ -888,7 +891,7 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName ) ...@@ -888,7 +891,7 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName )
} }
gui.ArchiveList->setCellText ( index, 0, typeName ); gui.ArchiveList->setCellText ( index, 0, typeName );
gui.ArchiveList->setCellText ( index, 1, archive->getArchiveName () ); gui.ArchiveList->setCellText ( index, 1, archive->getFileList()->getPath() );
} }
} }
...@@ -896,7 +899,7 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName ) ...@@ -896,7 +899,7 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName )
// browse the archives for maps // browse the archives for maps
if ( gui.MapList ) if ( gui.MapList )
{ {
gui.MapList->clear (); gui.MapList->clear();
IGUISpriteBank *bank = Game->Device->getGUIEnvironment()->getSpriteBank("sprite_q3map"); IGUISpriteBank *bank = Game->Device->getGUIEnvironment()->getSpriteBank("sprite_q3map");
if ( 0 == bank ) if ( 0 == bank )
......
...@@ -19,8 +19,9 @@ ...@@ -19,8 +19,9 @@
<Project filename="16.Quake3MapShader/Quake3MapShader.cbp" /> <Project filename="16.Quake3MapShader/Quake3MapShader.cbp" />
<Project filename="18.SplitScreen/SplitScreen.cbp" /> <Project filename="18.SplitScreen/SplitScreen.cbp" />
<Project filename="19.MouseAndJoystick/MouseAndJoystick.cbp" /> <Project filename="19.MouseAndJoystick/MouseAndJoystick.cbp" />
<Project filename="20.ManagedLights/ManagedLights.cbp" active="1" /> <Project filename="20.ManagedLights/ManagedLights.cbp" />
<Project filename="21.Quake3Explorer/Quake3Explorer.cbp" />
<Project filename="Demo/demo.cbp" /> <Project filename="Demo/demo.cbp" />
<Project filename="../source/Irrlicht/Irrlicht-gcc.cbp" /> <Project filename="../source/Irrlicht/Irrlicht-gcc.cbp" active="1" />
</Workspace> </Workspace>
</CodeBlocks_workspace_file> </CodeBlocks_workspace_file>
...@@ -43,27 +43,6 @@ enum E_FILE_ARCHIVE_TYPE ...@@ -43,27 +43,6 @@ enum E_FILE_ARCHIVE_TYPE
EFAT_UNKNOWN = MAKE_IRR_ID('u','n','k','n') EFAT_UNKNOWN = MAKE_IRR_ID('u','n','k','n')
}; };
/*
//! Base Info which all File archives must support on browsing
struct IFileArchiveEntry
{
IFileArchiveEntry() {}
core::string<c16> simpleFileName;
core::string<c16> path;
bool operator < (const IFileArchiveEntry& other) const
{
return path < other.path;
}
bool operator == (const IFileArchiveEntry& other) const
{
return path == other.path;
}
};
*/
//! The FileArchive manages archives and provides access to files inside them. //! The FileArchive manages archives and provides access to files inside them.
class IFileArchive : public virtual IReferenceCounted class IFileArchive : public virtual IReferenceCounted
{ {
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "irrArray.h" #include "irrArray.h"
#include "coreutil.h" #include "coreutil.h"
#include "os.h"
namespace irr namespace irr
{ {
namespace io namespace io
...@@ -85,6 +87,8 @@ u32 CFileList::addItem(const core::string<c16>& fullPath, u32 size, bool isDirec ...@@ -85,6 +87,8 @@ u32 CFileList::addItem(const core::string<c16>& fullPath, u32 size, bool isDirec
if (IgnorePaths) if (IgnorePaths)
entry.FullName = entry.Name; entry.FullName = entry.Name;
//os::Printer::log(Path.c_str(), entry.FullName);
Files.push_back(entry); Files.push_back(entry);
return Files.size() - 1; return Files.size() - 1;
......
...@@ -557,12 +557,15 @@ EFileSystemType CFileSystem::setFileListSystem(EFileSystemType listType) ...@@ -557,12 +557,15 @@ EFileSystemType CFileSystem::setFileListSystem(EFileSystemType listType)
IFileList* CFileSystem::createFileList() IFileList* CFileSystem::createFileList()
{ {
CFileList* r = 0; CFileList* r = 0;
core::string<c16> Path = getWorkingDirectory();
Path.replace('\\', '/');
if (lastChar(Path) != '/')
Path.append('/');
//! Construct a native filesystem //! Construct from native filesystem
if (FileSystemType == FILESYSTEM_NATIVE) if (FileSystemType == FILESYSTEM_NATIVE)
{ {
core::string<c16> fullPath; core::string<c16> fullPath;
core::string<c16> Path = getWorkingDirectory();
// -------------------------------------------- // --------------------------------------------
//! Windows version //! Windows version
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_WINDOWS_API_
...@@ -577,8 +580,7 @@ IFileList* CFileSystem::createFileList() ...@@ -577,8 +580,7 @@ IFileList* CFileSystem::createFileList()
{ {
do do
{ {
fullPath = WorkingDirectory[FILESYSTEM_NATIVE] + "/"; fullPath = Path + c_file.name;
fullPath += c_file.name;
r->addItem(fullPath, c_file.size, (_A_SUBDIR & c_file.attrib) != 0, 0); r->addItem(fullPath, c_file.size, (_A_SUBDIR & c_file.attrib) != 0, 0);
} }
...@@ -601,7 +603,7 @@ IFileList* CFileSystem::createFileList() ...@@ -601,7 +603,7 @@ IFileList* CFileSystem::createFileList()
r = new CFileList(Path, false, false); r = new CFileList(Path, false, false);
r->addItem(Path + "/..", 0, true, 0); r->addItem(Path + "..", 0, true, 0);
//! We use the POSIX compliant methods instead of scandir //! We use the POSIX compliant methods instead of scandir
DIR* dirHandle=opendir(Path.c_str()); DIR* dirHandle=opendir(Path.c_str());
...@@ -612,8 +614,7 @@ IFileList* CFileSystem::createFileList() ...@@ -612,8 +614,7 @@ IFileList* CFileSystem::createFileList()
{ {
u32 size = 0; u32 size = 0;
bool isDirectory = false; bool isDirectory = false;
fullPath = Path + "/"; fullPath = Path + dirEntry->d_name;
fullPath += dirEntry->d_name;
if((strcmp(dirEntry->d_name, ".")==0) || if((strcmp(dirEntry->d_name, ".")==0) ||
(strcmp(dirEntry->d_name, "..")==0)) (strcmp(dirEntry->d_name, "..")==0))
...@@ -643,18 +644,17 @@ IFileList* CFileSystem::createFileList() ...@@ -643,18 +644,17 @@ IFileList* CFileSystem::createFileList()
else else
{ {
//! create file list for the virtual filesystem //! create file list for the virtual filesystem
r = new CFileList(WorkingDirectory[FILESYSTEM_VIRTUAL], false, false); r = new CFileList(Path, false, false);
//! add relative navigation //! add relative navigation
SFileListEntry e2; SFileListEntry e2;
SFileListEntry e3; SFileListEntry e3;
//! PWD //! PWD
r->addItem(r->getPath() + "/.", 0, true, 0); r->addItem(Path + ".", 0, true, 0);
//! add parent dir if we can go up //! parent
if (WorkingDirectory[FILESYSTEM_VIRTUAL].size()) r->addItem(Path + "..", 0, true, 0);
r->addItem(r->getPath() + "/..", 0, true, 0);
//! merge archives //! merge archives
for (u32 i=0; i < FileArchives.size(); ++i) for (u32 i=0; i < FileArchives.size(); ++i)
...@@ -663,10 +663,9 @@ IFileList* CFileSystem::createFileList() ...@@ -663,10 +663,9 @@ IFileList* CFileSystem::createFileList()
for (u32 j=0; j < merge->getFileCount(); ++j) for (u32 j=0; j < merge->getFileCount(); ++j)
{ {
if (core::isInSameDirectory(WorkingDirectory[FILESYSTEM_VIRTUAL], merge->getFullFileName(j))) if (core::isInSameDirectory(Path, merge->getFullFileName(j)) == 0)
{ {
core::string<c16> fullPath = r->getPath() + "/"; core::string<c16> fullPath = merge->getFullFileName(j);
fullPath += merge->getFullFileName(j);
r->addItem(fullPath, merge->getFileSize(j), merge->isDirectory(j), 0); r->addItem(fullPath, merge->getFileSize(j), merge->isDirectory(j), 0);
} }
} }
......
...@@ -118,19 +118,23 @@ void CMountPointReader::buildDirectory() ...@@ -118,19 +118,23 @@ void CMountPointReader::buildDirectory()
IFileList * list = Parent->createFileList(); IFileList * list = Parent->createFileList();
const u32 size = list->getFileCount(); const u32 size = list->getFileCount();
for (u32 i = 0; i!= size; ++i) for (u32 i=0; i < size; ++i)
{ {
core::string<c16> full = list->getFullFileName(i);
full = full.subString(Path.size(), full.size() - Path.size());
if (!list->isDirectory(i)) if (!list->isDirectory(i))
{ {
addItem(list->getFullFileName(i), list->getFileSize(i), false, RealFileNames.size()); addItem(full, list->getFileSize(i), false, RealFileNames.size());
RealFileNames.push_back(list->getFullFileName(i)); RealFileNames.push_back(list->getFullFileName(i));
} }
else else
{ {
const core::string<c16>& full = list->getFullFileName(i);
const core::string<c16> rel = list->getFileName(i); const core::string<c16> rel = list->getFileName(i);
core::string<c16> pwd = Parent->getWorkingDirectory() + "/"; core::string<c16> pwd = Parent->getWorkingDirectory();
pwd += rel; if (core::lastChar(pwd) != '/')
pwd.append('/');
pwd.append(rel);
if ( rel != "." && rel != ".." ) if ( rel != "." && rel != ".." )
{ {
...@@ -151,18 +155,17 @@ IReadFile* CMountPointReader::createAndOpenFile(u32 index) ...@@ -151,18 +155,17 @@ IReadFile* CMountPointReader::createAndOpenFile(u32 index)
if (index >= Files.size()) if (index >= Files.size())
return 0; return 0;
return createReadFile( RealFileNames[Files[index].ID] ); return createReadFile(RealFileNames[Files[index].ID]);
} }
//! opens a file by file name //! opens a file by file name
IReadFile* CMountPointReader::createAndOpenFile(const core::string<c16>& filename) IReadFile* CMountPointReader::createAndOpenFile(const core::string<c16>& filename)
{ {
s32 index = findFile(filename, false); s32 index = findFile(filename, false);
if (index != -1)
if (index == -1) return createAndOpenFile(index);
else
return 0; return 0;
return createReadFile( RealFileNames[Files[index].ID] );
} }
......
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