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
master
bitplane 2009-08-13 05:28:19 +00:00
parent dd98649ba5
commit c3240d1561
7 changed files with 128 additions and 76 deletions

View File

@ -0,0 +1,63 @@
<?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>

View File

@ -13,7 +13,7 @@ Features:
- Play music
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
Copyright 2006-2009 Burningwater, Thomas Alten
@ -188,7 +188,7 @@ s32 GameData::save ( const string<c16> &filename )
IFileSystem *fs = Device->getFileSystem();
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
@ -198,7 +198,7 @@ s32 GameData::save ( const string<c16> &filename )
PlayerPosition = camera->getPosition ();
PlayerRotation = camera->getRotation ();
}
IWriteFile *file = fs->createAndWriteFile ( filename );
if ( 0 == file )
return 0;
@ -209,7 +209,7 @@ s32 GameData::save ( const string<c16> &filename )
file->write ( buf, (s32) strlen ( buf ) );
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 ) );
}
@ -231,7 +231,7 @@ struct Q3Player : public IAnimationEndCallBack
virtual void OnAnimationEnd(IAnimatedMeshSceneNode* node);
void create ( IrrlichtDevice *device,
void create ( IrrlichtDevice *device,
IQ3LevelMesh* mesh,
ISceneNode *mapNode,
IMetaTriangleSelector *meta
@ -338,19 +338,19 @@ void Q3Player::create ( IrrlichtDevice *device, IQ3LevelMesh* mesh, ISceneNode *
}
WeaponNode = smgr->addAnimatedMeshSceneNode(
weaponMesh,
weaponMesh,
smgr->getActiveCamera(),
10,
vector3df( 0, 0, 0),
vector3df(-90,-90,90)
);
);
WeaponNode->setMaterialFlag(EMF_LIGHTING, false);
WeaponNode->setMaterialTexture(0, driver->getTexture( "gun.jpg"));
WeaponNode->setLoopMode ( false );
WeaponNode->setName ( "tommi the gun man" );
//create a collision auto response animator
ISceneNodeAnimator* anim =
ISceneNodeAnimator* anim =
smgr->createCollisionResponseAnimator( meta, camera,
vector3df(30,45,30),
getGravity ( "earth" ),
@ -613,7 +613,7 @@ void CQuake3EventHandler::createTextures ()
texture = driver->addTexture( buf, image );
image->drop ();
}
// fog
for ( i = 0; i != 1; ++i )
{
@ -715,7 +715,7 @@ void CQuake3EventHandler::CreateGUI()
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, 2.133333f ) ) a = "20:9 widescreen";
snprintf ( buf, sizeof ( buf ), "%d x %d, %s",w, h, a );
gui.VideoMode->addItem ( stringw ( buf ).c_str(), val );
}
@ -804,7 +804,7 @@ void CQuake3EventHandler::CreateGUI()
// 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 );
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.SceneTree->setToolTipText ( L"Show the current Scenegraph" );
gui.SceneTree->getRoot()->clearChilds();
@ -843,7 +843,7 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName )
bool exists = false;
for ( i = 0; i != fs->getFileArchiveCount(); ++i )
{
if ( fs->getFileArchive ( i )->getArchiveName() == archiveName )
if ( fs->getFileArchive(i)->getFileList()->getPath() == archiveName )
{
exists = true;
break;
@ -874,6 +874,9 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName )
case io::EFAT_ZIP:
typeName = "ZIP";
break;
case io::EFAT_GZIP:
typeName = "gzip";
break;
case io::EFAT_FOLDER:
typeName = "Mount";
break;
@ -888,7 +891,7 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName )
}
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 )
// browse the archives for maps
if ( gui.MapList )
{
gui.MapList->clear ();
gui.MapList->clear();
IGUISpriteBank *bank = Game->Device->getGUIEnvironment()->getSpriteBank("sprite_q3map");
if ( 0 == bank )
@ -986,7 +989,7 @@ void CQuake3EventHandler::AddArchive ( const core::string<c16>& archiveName )
IGUIScrollBar * bar = (IGUIScrollBar*)gui.MapList->getElementFromId( 0 );
if ( bar )
bar->setPos ( 0 );
}
}
@ -1054,7 +1057,7 @@ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision )
add the geometry mesh to the Scene ( polygon & patches )
The Geometry mesh is optimised for faster drawing
*/
IMesh *geometry = Mesh->getMesh(E_Q3_MESH_GEOMETRY);
if ( 0 == geometry || geometry->getMeshBufferCount() == 0)
return;
@ -1066,7 +1069,7 @@ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision )
ITriangleSelector * selector = 0;
if (collision)
Meta = smgr->createMetaTriangleSelector();
Meta = smgr->createMetaTriangleSelector();
//IMeshBuffer *b0 = geometry->getMeshBuffer(0);
//s32 minimalNodes = b0 ? core::s32_max ( 2048, b0->getVertexCount() / 32 ) : 2048;
@ -1079,7 +1082,7 @@ void CQuake3EventHandler::LoadMap ( const stringw &mapName, s32 collision )
{
selector = smgr->createOctTreeTriangleSelector( geometry,MapParent, minimalNodes);
//selector = smgr->createTriangleSelector ( geometry, MapParent );
Meta->addTriangleSelector( selector);
Meta->addTriangleSelector( selector);
selector->drop ();
}
@ -1282,7 +1285,7 @@ void CQuake3EventHandler::SetGUIActive( s32 command)
case 0: Game->guiActive = 0; inputState = !Game->guiActive; break;
case 1: Game->guiActive = 1; inputState = !Game->guiActive;;break;
case 2: Game->guiActive ^= 1; inputState = !Game->guiActive;break;
case 3:
case 3:
if ( camera )
inputState = !camera->isInputReceiverEnabled();
break;
@ -1537,7 +1540,7 @@ bool CQuake3EventHandler::OnEvent(const SEvent& eve)
static const c8 *dName[] = { "null", "software", "burning",
"d3d8", "d3d9", "opengl" };
snprintf(buf, 256, "%s_%ls_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f.jpg",
dName[Game->Device->getVideoDriver()->getDriverType()],
Game->CurrentMapName.c_str(),
@ -1565,7 +1568,7 @@ bool CQuake3EventHandler::OnEvent(const SEvent& eve)
}
/*
// set debug map data on/off
debugState = debugState == EDS_OFF ?
debugState = debugState == EDS_OFF ?
EDS_NORMALS | EDS_MESH_WIRE_OVERLAY | EDS_BBOX_ALL:
EDS_OFF;
*/
@ -1870,7 +1873,7 @@ void CQuake3EventHandler::createParticleImpacts( u32 now )
{
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);
pas->setName ( buf );
@ -1911,7 +1914,7 @@ void CQuake3EventHandler::createParticleImpacts( u32 now )
/*
if (irrKlang)
{
audio::ISound* sound =
audio::ISound* sound =
irrKlang->play3D(impactSound, Impacts[i].pos, false, false, true);
if (sound)
@ -1965,7 +1968,7 @@ void CQuake3EventHandler::Animate()
IVideoDriver * driver = Game->Device->getVideoDriver();
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)",
Game->CurrentMapName.c_str(),
driver->getName(),
@ -1982,7 +1985,7 @@ void CQuake3EventHandler::Animate()
swprintf ( msg, 128,
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",
Game->Device->getVideoDriver()->getFPS ()
Game->Device->getVideoDriver()->getFPS ()
);
if ( gui.StatusLine )
gui.StatusLine->setText ( msg );
@ -1992,7 +1995,7 @@ void CQuake3EventHandler::Animate()
// idle..
if ( player->Anim[1].flags & FIRED )
{
if ( strcmp ( player->animation, "idle" ) )
if ( strcmp ( player->animation, "idle" ) )
player->setAnim ( "idle" );
player->Anim[1].flags &= ~FIRED;
@ -2015,7 +2018,7 @@ void runGame ( GameData *game )
{
// could not create selected driver.
game->retVal = 0;
return;
return;
}
// create an event receiver based on current game data
@ -2116,7 +2119,7 @@ int IRRCALLCONV main(int argc, char* argv[])
case 'd': game.deviceParam.DriverType = EDT_SOFTWARE; break;
case 'e': game.deviceParam.DriverType = EDT_BURNINGSVIDEO;break;
default: game.retVal = 3; break;
}
}
}
runGame ( &game );
} while ( game.retVal < 3 );

View File

@ -19,8 +19,9 @@
<Project filename="16.Quake3MapShader/Quake3MapShader.cbp" />
<Project filename="18.SplitScreen/SplitScreen.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="../source/Irrlicht/Irrlicht-gcc.cbp" />
<Project filename="../source/Irrlicht/Irrlicht-gcc.cbp" active="1" />
</Workspace>
</CodeBlocks_workspace_file>

View File

@ -43,27 +43,6 @@ enum E_FILE_ARCHIVE_TYPE
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.
class IFileArchive : public virtual IReferenceCounted
{

View File

@ -7,6 +7,8 @@
#include "irrArray.h"
#include "coreutil.h"
#include "os.h"
namespace irr
{
namespace io
@ -85,6 +87,8 @@ u32 CFileList::addItem(const core::string<c16>& fullPath, u32 size, bool isDirec
if (IgnorePaths)
entry.FullName = entry.Name;
//os::Printer::log(Path.c_str(), entry.FullName);
Files.push_back(entry);
return Files.size() - 1;

View File

@ -557,12 +557,15 @@ EFileSystemType CFileSystem::setFileListSystem(EFileSystemType listType)
IFileList* CFileSystem::createFileList()
{
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)
{
core::string<c16> fullPath;
core::string<c16> Path = getWorkingDirectory();
// --------------------------------------------
//! Windows version
#ifdef _IRR_WINDOWS_API_
@ -577,8 +580,7 @@ IFileList* CFileSystem::createFileList()
{
do
{
fullPath = WorkingDirectory[FILESYSTEM_NATIVE] + "/";
fullPath += c_file.name;
fullPath = Path + c_file.name;
r->addItem(fullPath, c_file.size, (_A_SUBDIR & c_file.attrib) != 0, 0);
}
@ -601,7 +603,7 @@ IFileList* CFileSystem::createFileList()
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
DIR* dirHandle=opendir(Path.c_str());
@ -612,8 +614,7 @@ IFileList* CFileSystem::createFileList()
{
u32 size = 0;
bool isDirectory = false;
fullPath = Path + "/";
fullPath += dirEntry->d_name;
fullPath = Path + dirEntry->d_name;
if((strcmp(dirEntry->d_name, ".")==0) ||
(strcmp(dirEntry->d_name, "..")==0))
@ -643,18 +644,17 @@ IFileList* CFileSystem::createFileList()
else
{
//! create file list for the virtual filesystem
r = new CFileList(WorkingDirectory[FILESYSTEM_VIRTUAL], false, false);
r = new CFileList(Path, false, false);
//! add relative navigation
SFileListEntry e2;
SFileListEntry e3;
//! PWD
r->addItem(r->getPath() + "/.", 0, true, 0);
r->addItem(Path + ".", 0, true, 0);
//! add parent dir if we can go up
if (WorkingDirectory[FILESYSTEM_VIRTUAL].size())
r->addItem(r->getPath() + "/..", 0, true, 0);
//! parent
r->addItem(Path + "..", 0, true, 0);
//! merge archives
for (u32 i=0; i < FileArchives.size(); ++i)
@ -663,10 +663,9 @@ IFileList* CFileSystem::createFileList()
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() + "/";
fullPath += merge->getFullFileName(j);
core::string<c16> fullPath = merge->getFullFileName(j);
r->addItem(fullPath, merge->getFileSize(j), merge->isDirectory(j), 0);
}
}

View File

@ -118,19 +118,23 @@ void CMountPointReader::buildDirectory()
IFileList * list = Parent->createFileList();
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))
{
addItem(list->getFullFileName(i), list->getFileSize(i), false, RealFileNames.size());
addItem(full, list->getFileSize(i), false, RealFileNames.size());
RealFileNames.push_back(list->getFullFileName(i));
}
else
{
const core::string<c16>& full = list->getFullFileName(i);
const core::string<c16> rel = list->getFileName(i);
core::string<c16> pwd = Parent->getWorkingDirectory() + "/";
pwd += rel;
core::string<c16> pwd = Parent->getWorkingDirectory();
if (core::lastChar(pwd) != '/')
pwd.append('/');
pwd.append(rel);
if ( rel != "." && rel != ".." )
{
@ -151,18 +155,17 @@ IReadFile* CMountPointReader::createAndOpenFile(u32 index)
if (index >= Files.size())
return 0;
return createReadFile( RealFileNames[Files[index].ID] );
return createReadFile(RealFileNames[Files[index].ID]);
}
//! opens a file by file name
IReadFile* CMountPointReader::createAndOpenFile(const core::string<c16>& filename)
{
s32 index = findFile(filename, false);
if (index == -1)
if (index != -1)
return createAndOpenFile(index);
else
return 0;
return createReadFile( RealFileNames[Files[index].ID] );
}