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>
...@@ -13,7 +13,7 @@ Features: ...@@ -13,7 +13,7 @@ Features:
- Play music - Play music
You can download the Quake III Arena demo ( copyright id software ) You can download the Quake III Arena demo ( copyright id software )
at the following location: at the following location:
ftp://ftp.idsoftware.com/idstuff/quake3/win32/q3ademo.exe ftp://ftp.idsoftware.com/idstuff/quake3/win32/q3ademo.exe
Copyright 2006-2009 Burningwater, Thomas Alten Copyright 2006-2009 Burningwater, Thomas Alten
...@@ -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
...@@ -198,7 +198,7 @@ s32 GameData::save ( const string<c16> &filename ) ...@@ -198,7 +198,7 @@ s32 GameData::save ( const string<c16> &filename )
PlayerPosition = camera->getPosition (); PlayerPosition = camera->getPosition ();
PlayerRotation = camera->getRotation (); PlayerRotation = camera->getRotation ();
} }
IWriteFile *file = fs->createAndWriteFile ( filename ); IWriteFile *file = fs->createAndWriteFile ( filename );
if ( 0 == file ) if ( 0 == file )
return 0; return 0;
...@@ -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 ) );
} }
...@@ -231,7 +231,7 @@ struct Q3Player : public IAnimationEndCallBack ...@@ -231,7 +231,7 @@ struct Q3Player : public IAnimationEndCallBack
virtual void OnAnimationEnd(IAnimatedMeshSceneNode* node); virtual void OnAnimationEnd(IAnimatedMeshSceneNode* node);
void create ( IrrlichtDevice *device, void create ( IrrlichtDevice *device,
IQ3LevelMesh* mesh, IQ3LevelMesh* mesh,
ISceneNode *mapNode, ISceneNode *mapNode,
IMetaTriangleSelector *meta IMetaTriangleSelector *meta
...@@ -338,19 +338,19 @@ void Q3Player::create ( IrrlichtDevice *device, IQ3LevelMesh* mesh, ISceneNode * ...@@ -338,19 +338,19 @@ void Q3Player::create ( IrrlichtDevice *device, IQ3LevelMesh* mesh, ISceneNode *
} }
WeaponNode = smgr->addAnimatedMeshSceneNode( WeaponNode = smgr->addAnimatedMeshSceneNode(
weaponMesh, weaponMesh,
smgr->getActiveCamera(), smgr->getActiveCamera(),
10, 10,
vector3df( 0, 0, 0), vector3df( 0, 0, 0),
vector3df(-90,-90,90) vector3df(-90,-90,90)
); );
WeaponNode->setMaterialFlag(EMF_LIGHTING, false); WeaponNode->setMaterialFlag(EMF_LIGHTING, false);
WeaponNode->setMaterialTexture(0, driver->getTexture( "gun.jpg")); WeaponNode->setMaterialTexture(0, driver->getTexture( "gun.jpg"));
WeaponNode->setLoopMode ( false ); WeaponNode->setLoopMode ( false );
WeaponNode->setName ( "tommi the gun man" ); WeaponNode->setName ( "tommi the gun man" );
//create a collision auto response animator //create a collision auto response animator
ISceneNodeAnimator* anim = ISceneNodeAnimator* anim =
smgr->createCollisionResponseAnimator( meta, camera, smgr->createCollisionResponseAnimator( meta, camera,
vector3df(30,45,30), vector3df(30,45,30),
getGravity ( "earth" ), getGravity ( "earth" ),
...@@ -613,7 +613,7 @@ void CQuake3EventHandler::createTextures () ...@@ -613,7 +613,7 @@ void CQuake3EventHandler::createTextures ()
texture = driver->addTexture( buf, image ); texture = driver->addTexture( buf, image );
image->drop (); image->drop ();
} }
// fog // fog
for ( i = 0; i != 1; ++i ) for ( i = 0; i != 1; ++i )
{ {
...@@ -715,7 +715,7 @@ void CQuake3EventHandler::CreateGUI() ...@@ -715,7 +715,7 @@ void CQuake3EventHandler::CreateGUI()
else if ( core::equals ( aspect, 1.7777777f ) ) a = "16:9 widescreen"; else if ( core::equals ( aspect, 1.7777777f ) ) a = "16:9 widescreen";
else if ( core::equals ( aspect, 1.6f ) ) a = "16:10 widescreen"; else if ( core::equals ( aspect, 1.6f ) ) a = "16:10 widescreen";
else if ( core::equals ( aspect, 2.133333f ) ) a = "20:9 widescreen"; else if ( core::equals ( aspect, 2.133333f ) ) a = "20:9 widescreen";
snprintf ( buf, sizeof ( buf ), "%d x %d, %s",w, h, a ); snprintf ( buf, sizeof ( buf ), "%d x %d, %s",w, h, a );
gui.VideoMode->addItem ( stringw ( buf ).c_str(), val ); gui.VideoMode->addItem ( stringw ( buf ).c_str(), val );
} }
...@@ -804,7 +804,7 @@ void CQuake3EventHandler::CreateGUI() ...@@ -804,7 +804,7 @@ void CQuake3EventHandler::CreateGUI()
// create a visible Scene Tree // create a visible Scene Tree
env->addStaticText ( L"Scenegraph:", rect<s32>( dim.Width - 400, dim.Height - 400, dim.Width - 5,dim.Height - 380 ),false, false, gui.Window, -1, false ); env->addStaticText ( L"Scenegraph:", rect<s32>( dim.Width - 400, dim.Height - 400, dim.Width - 5,dim.Height - 380 ),false, false, gui.Window, -1, false );
gui.SceneTree = env->addTreeView( rect<s32>( dim.Width - 400, dim.Height - 380, dim.Width - 5, dim.Height - 40 ), gui.SceneTree = env->addTreeView( rect<s32>( dim.Width - 400, dim.Height - 380, dim.Width - 5, dim.Height - 40 ),
gui.Window, -1, true, true, false ); gui.Window, -1, true, true, false );
gui.SceneTree->setToolTipText ( L"Show the current Scenegraph" ); gui.SceneTree->setToolTipText ( L"Show the current Scenegraph" );
gui.SceneTree->getRoot()->clearChilds(); gui.SceneTree->getRoot()->clearChilds();
...@@ -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 )
...@@ -986,7 +989,7 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName ) ...@@ -986,7 +989,7 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName )
IGUIScrollBar * bar = (IGUIScrollBar*)gui.MapList->getElementFromId( 0 ); IGUIScrollBar * bar = (IGUIScrollBar*)gui.MapList->getElementFromId( 0 );
if ( bar ) if ( bar )
bar->setPos ( 0 ); bar->setPos ( 0 );
} }
} }
...@@ -1054,7 +1057,7 @@ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision ) ...@@ -1054,7 +1057,7 @@ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision )
add the geometry mesh to the Scene ( polygon & patches ) add the geometry mesh to the Scene ( polygon & patches )
The Geometry mesh is optimised for faster drawing The Geometry mesh is optimised for faster drawing
*/ */
IMesh *geometry = Mesh->getMesh(E_Q3_MESH_GEOMETRY); IMesh *geometry = Mesh->getMesh(E_Q3_MESH_GEOMETRY);
if ( 0 == geometry || geometry->getMeshBufferCount() == 0) if ( 0 == geometry || geometry->getMeshBufferCount() == 0)
return; return;
...@@ -1066,7 +1069,7 @@ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision ) ...@@ -1066,7 +1069,7 @@ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision )
ITriangleSelector * selector = 0; ITriangleSelector * selector = 0;
if (collision) if (collision)
Meta = smgr->createMetaTriangleSelector(); Meta = smgr->createMetaTriangleSelector();
//IMeshBuffer *b0 = geometry->getMeshBuffer(0); //IMeshBuffer *b0 = geometry->getMeshBuffer(0);
//s32 minimalNodes = b0 ? core::s32_max ( 2048, b0->getVertexCount() / 32 ) : 2048; //s32 minimalNodes = b0 ? core::s32_max ( 2048, b0->getVertexCount() / 32 ) : 2048;
...@@ -1079,7 +1082,7 @@ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision ) ...@@ -1079,7 +1082,7 @@ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision )
{ {
selector = smgr->createOctTreeTriangleSelector( geometry,MapParent, minimalNodes); selector = smgr->createOctTreeTriangleSelector( geometry,MapParent, minimalNodes);
//selector = smgr->createTriangleSelector ( geometry, MapParent ); //selector = smgr->createTriangleSelector ( geometry, MapParent );
Meta->addTriangleSelector( selector); Meta->addTriangleSelector( selector);
selector->drop (); selector->drop ();
} }
...@@ -1282,7 +1285,7 @@ void CQuake3EventHandler::SetGUIActive( s32 command) ...@@ -1282,7 +1285,7 @@ void CQuake3EventHandler::SetGUIActive( s32 command)
case 0: Game->guiActive = 0; inputState = !Game->guiActive; break; case 0: Game->guiActive = 0; inputState = !Game->guiActive; break;
case 1: Game->guiActive = 1; inputState = !Game->guiActive;;break; case 1: Game->guiActive = 1; inputState = !Game->guiActive;;break;
case 2: Game->guiActive ^= 1; inputState = !Game->guiActive;break; case 2: Game->guiActive ^= 1; inputState = !Game->guiActive;break;
case 3: case 3:
if ( camera ) if ( camera )
inputState = !camera->isInputReceiverEnabled(); inputState = !camera->isInputReceiverEnabled();
break; break;
...@@ -1537,7 +1540,7 @@ bool CQuake3EventHandler::OnEvent(const SEvent& eve) ...@@ -1537,7 +1540,7 @@ bool CQuake3EventHandler::OnEvent(const SEvent& eve)
static const c8 *dName[] = { "null", "software", "burning", static const c8 *dName[] = { "null", "software", "burning",
"d3d8", "d3d9", "opengl" }; "d3d8", "d3d9", "opengl" };
snprintf(buf, 256, "%s_%ls_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f.jpg", snprintf(buf, 256, "%s_%ls_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f.jpg",
dName[Game->Device->getVideoDriver()->getDriverType()], dName[Game->Device->getVideoDriver()->getDriverType()],
Game->CurrentMapName.c_str(), Game->CurrentMapName.c_str(),
...@@ -1565,7 +1568,7 @@ bool CQuake3EventHandler::OnEvent(const SEvent& eve) ...@@ -1565,7 +1568,7 @@ bool CQuake3EventHandler::OnEvent(const SEvent& eve)
} }
/* /*
// set debug map data on/off // set debug map data on/off
debugState = debugState == EDS_OFF ? debugState = debugState == EDS_OFF ?
EDS_NORMALS | EDS_MESH_WIRE_OVERLAY | EDS_BBOX_ALL: EDS_NORMALS | EDS_MESH_WIRE_OVERLAY | EDS_BBOX_ALL:
EDS_OFF; EDS_OFF;
*/ */
...@@ -1870,7 +1873,7 @@ void CQuake3EventHandler::createParticleImpacts( u32 now ) ...@@ -1870,7 +1873,7 @@ void CQuake3EventHandler::createParticleImpacts( u32 now )
{ {
pas = sm->addParticleSystemSceneNode(false, BulletParent, -1, Impacts[i].pos); pas = sm->addParticleSystemSceneNode(false, BulletParent, -1, Impacts[i].pos);
snprintf ( buf, 64, "bullet impact smoke at %.1f,%.1f,%1.f", snprintf ( buf, 64, "bullet impact smoke at %.1f,%.1f,%1.f",
Impacts[i].pos.X,Impacts[i].pos.Y,Impacts[i].pos.Z); Impacts[i].pos.X,Impacts[i].pos.Y,Impacts[i].pos.Z);
pas->setName ( buf ); pas->setName ( buf );
...@@ -1911,7 +1914,7 @@ void CQuake3EventHandler::createParticleImpacts( u32 now ) ...@@ -1911,7 +1914,7 @@ void CQuake3EventHandler::createParticleImpacts( u32 now )
/* /*
if (irrKlang) if (irrKlang)
{ {
audio::ISound* sound = audio::ISound* sound =
irrKlang->play3D(impactSound, Impacts[i].pos, false, false, true); irrKlang->play3D(impactSound, Impacts[i].pos, false, false, true);
if (sound) if (sound)
...@@ -1965,7 +1968,7 @@ void CQuake3EventHandler::Animate() ...@@ -1965,7 +1968,7 @@ void CQuake3EventHandler::Animate()
IVideoDriver * driver = Game->Device->getVideoDriver(); IVideoDriver * driver = Game->Device->getVideoDriver();
IAttributes * attr = smgr->getParameters(); IAttributes * attr = smgr->getParameters();
swprintf ( msg, 128, swprintf ( msg, 128,
L"Q3 %s [%s], FPS:%03d Tri:%.03fm Cull %d/%d nodes (%d,%d,%d)", L"Q3 %s [%s], FPS:%03d Tri:%.03fm Cull %d/%d nodes (%d,%d,%d)",
Game->CurrentMapName.c_str(), Game->CurrentMapName.c_str(),
driver->getName(), driver->getName(),
...@@ -1982,7 +1985,7 @@ void CQuake3EventHandler::Animate() ...@@ -1982,7 +1985,7 @@ void CQuake3EventHandler::Animate()
swprintf ( msg, 128, swprintf ( msg, 128,
L"%03d fps, F1 GUI on/off, F2 respawn, F3-F6 toggle Nodes, F7 Collision on/off" L"%03d fps, F1 GUI on/off, F2 respawn, F3-F6 toggle Nodes, F7 Collision on/off"
L", F8 Gravity on/off, Right Mouse Toggle GUI", L", F8 Gravity on/off, Right Mouse Toggle GUI",
Game->Device->getVideoDriver()->getFPS () Game->Device->getVideoDriver()->getFPS ()
); );
if ( gui.StatusLine ) if ( gui.StatusLine )
gui.StatusLine->setText ( msg ); gui.StatusLine->setText ( msg );
...@@ -1992,7 +1995,7 @@ void CQuake3EventHandler::Animate() ...@@ -1992,7 +1995,7 @@ void CQuake3EventHandler::Animate()
// idle.. // idle..
if ( player->Anim[1].flags & FIRED ) if ( player->Anim[1].flags & FIRED )
{ {
if ( strcmp ( player->animation, "idle" ) ) if ( strcmp ( player->animation, "idle" ) )
player->setAnim ( "idle" ); player->setAnim ( "idle" );
player->Anim[1].flags &= ~FIRED; player->Anim[1].flags &= ~FIRED;
...@@ -2015,7 +2018,7 @@ void runGame ( GameData *game ) ...@@ -2015,7 +2018,7 @@ void runGame ( GameData *game )
{ {
// could not create selected driver. // could not create selected driver.
game->retVal = 0; game->retVal = 0;
return; return;
} }
// create an event receiver based on current game data // create an event receiver based on current game data
...@@ -2116,7 +2119,7 @@ int IRRCALLCONV main(int argc, char* argv[]) ...@@ -2116,7 +2119,7 @@ int IRRCALLCONV main(int argc, char* argv[])
case 'd': game.deviceParam.DriverType = EDT_SOFTWARE; break; case 'd': game.deviceParam.DriverType = EDT_SOFTWARE; break;
case 'e': game.deviceParam.DriverType = EDT_BURNINGSVIDEO;break; case 'e': game.deviceParam.DriverType = EDT_BURNINGSVIDEO;break;
default: game.retVal = 3; break; default: game.retVal = 3; break;
} }
} }
runGame ( &game ); runGame ( &game );
} while ( game.retVal < 3 ); } while ( game.retVal < 3 );
......
...@@ -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