From 5e7190551e0bb8a6889f72415a132d6b32e7a95b Mon Sep 17 00:00:00 2001 From: false_genesis Date: Mon, 20 Apr 2009 10:02:18 +0000 Subject: [PATCH] * really use cached files (irrlicht uses full paths!) * fixed vc71 non-debug builds --- src/Client/GUI/CM2MeshFileLoader.cpp | 1 + src/Client/PseuWoW.cpp | 6 ++- src/Client/World/WorldSession.cpp | 31 +++++++----- src/dep/src/irrlicht/Irrlicht7.1.vcproj | 10 ++-- src/shared/tools.cpp | 64 +++++++++++++++++++++++++ src/shared/tools.h | 4 ++ 6 files changed, 97 insertions(+), 19 deletions(-) diff --git a/src/Client/GUI/CM2MeshFileLoader.cpp b/src/Client/GUI/CM2MeshFileLoader.cpp index cb1ee6f..b9abf0b 100644 --- a/src/Client/GUI/CM2MeshFileLoader.cpp +++ b/src/Client/GUI/CM2MeshFileLoader.cpp @@ -100,6 +100,7 @@ DEBUG(logdebug("Read %u/%u Vertices",M2MVertices.size(),header.nVertices)); std::string SkinName = MeshFile->getFileName(); SkinName = SkinName.substr(0, SkinName.length()-3) + "00.skin"; // FIX ME (and stuffextract) ! as we need more skins +_FixFileName(SkinName); io::IReadFile* SkinFile = io::IrrCreateIReadFileBasic(Device, SkinName.c_str()); if (!SkinFile) { diff --git a/src/Client/PseuWoW.cpp b/src/Client/PseuWoW.cpp index 727375e..9a224ef 100644 --- a/src/Client/PseuWoW.cpp +++ b/src/Client/PseuWoW.cpp @@ -162,12 +162,14 @@ bool PseuInstance::Init(void) _rmcontrol = new RemoteController(this,GetConf()->rmcontrolport); } +#if !(PLATFORM == PLATFORM_WIN32 && !defined(_CONSOLE)) if(GetConf()->enablecli) { log("Starting CLI..."); _cli = new CliRunnable(this); ZThread::Thread t(_cli); } +#endif if(_error) { @@ -188,11 +190,11 @@ bool PseuInstance::InitGUI(void) return false; } - if (!GetConf()->enablegui) + /*if (!GetConf()->enablegui) { logdebug("GUI: Can't start, gui disabled in config"); return false; - } + }*/ uint16 x,y,depth; uint8 driver; diff --git a/src/Client/World/WorldSession.cpp b/src/Client/World/WorldSession.cpp index ede391a..c910d5c 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -746,24 +746,31 @@ void WorldSession::PreloadDataBeforeEnterWorld(PlayerEnum& pl) log("Loading data before entering world..."); GetWorld()->GetMapMgr()->Update(pl._x, pl._y, pl._mapId); // make it load the map files - for(uint32 tiley = 0; tiley < 3; tiley++) + // preload additional map data only when the GUI is enabled + // TODO: at some later point we will need the geometry for correct collision calculation, etc... + if(GetInstance()->GetConf()->enablegui) { - for(uint32 tilex = 0; tilex < 3; tilex++) + for(uint32 tiley = 0; tiley < 3; tiley++) { - MapTile *maptile = GetWorld()->GetMapMgr()->GetNearTile(tilex - 1, tiley - 1); - if(maptile) + for(uint32 tilex = 0; tilex < 3; tilex++) { - for(uint32 i = 0; i < maptile->GetDoodadCount(); i++) + MapTile *maptile = GetWorld()->GetMapMgr()->GetNearTile(tilex - 1, tiley - 1); + if(maptile) { - Doodad *doo = maptile->GetDoodad(i); + for(uint32 i = 0; i < maptile->GetDoodadCount(); i++) + { + Doodad *doo = maptile->GetDoodad(i); - // it is useless to load the file here, since its loaded when irrlicht needs it and kept in the MeshCache for later use - //MemoryDataHolder::BackgroundLoadFile(doo->model); + // it is useless to load the file here, since its loaded when irrlicht needs it and kept in the MeshCache for later use + //MemoryDataHolder::BackgroundLoadFile(doo->model); - // but we need to preload the .skin files, since they are not held in the MeshCache - // TODO: load *all* necessary skin files, also fix stuffextract for this! - std::string skinfile = doo->model.substr(0, doo->model.length()-3) + "00.skin"; - MemoryDataHolder::BackgroundLoadFile(skinfile); + // but we need to preload the .skin files, since they are not held in the MeshCache + // TODO: load *all* necessary skin files, also fix stuffextract for this! + std::string skinfile = doo->model.substr(0, doo->model.length()-3) + "00.skin"; + skinfile = GetAbsolutePath(skinfile.c_str()); + _FixFileName(skinfile); + MemoryDataHolder::BackgroundLoadFile(skinfile); + } } } } diff --git a/src/dep/src/irrlicht/Irrlicht7.1.vcproj b/src/dep/src/irrlicht/Irrlicht7.1.vcproj index f00a578..2886646 100644 --- a/src/dep/src/irrlicht/Irrlicht7.1.vcproj +++ b/src/dep/src/irrlicht/Irrlicht7.1.vcproj @@ -81,7 +81,7 @@ Optimization="2" InlineFunctionExpansion="1" EnableIntrinsicFunctions="FALSE" - AdditionalIncludeDirectories="..\..\include\zlib;..\..\include\irrlicht" + AdditionalIncludeDirectories="..\..\include\zlib;..\..\include\irrlicht;..\..\include\DXSDK\include" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE" StringPooling="TRUE" ExceptionHandling="FALSE" @@ -143,7 +143,7 @@ EnableIntrinsicFunctions="TRUE" FavorSizeOrSpeed="0" OmitFramePointers="TRUE" - AdditionalIncludeDirectories="..\..\include\zlib;..\..\include\irrlicht" + AdditionalIncludeDirectories="..\..\include\zlib;..\..\include\irrlicht;..\..\include\DXSDK\include" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE" StringPooling="TRUE" ExceptionHandling="FALSE" @@ -202,7 +202,7 @@ # include # include +# include #else # include # include @@ -17,6 +18,11 @@ # include # endif # include +# include +#endif + +#ifndef MAX_PATH +#define MAX_PATH 1024 #endif @@ -269,3 +275,61 @@ std::string FilesizeFormat(uint32 b) } return buf; } + +//! Returns the string of the current working directory +std::string GetWorkingDir(void) +{ + char d[MAX_PATH]; +#if PLATFORM == PLATFORM_WIN32 + _getcwd(d, MAX_PATH); +#else + getcwd(d, MAX_PATH); +#endif + return d; +} + + +//! Changes the current Working Directory to the given string. +bool SetWorkingDir(const char *dir) +{ + bool success=false; +#ifdef _MSC_VER + success=(_chdir(dir) == 0); +#else + success=(chdir(dir) == 0); +#endif + return success; +} + + +std::string GetAbsolutePath(const char *filename) +{ + char *p = NULL; + +#if PLATFORM == PLATFORM_WIN32 + char fpath[MAX_PATH]; + p = _fullpath( fpath, filename, MAX_PATH); + +#else + char fpath[4096]; + fpath[0]=0; + p = realpath(filename, fpath); + if (!p) + { + // content in fpath is undefined at this point + if ('0'==fpath[0]) // seems like fpath wasn't altered + { + // at least remove a ./ prefix + if ('.'==filename[0] && '/'==filename[1]) + return &filename[2]; // skip first 2 chars + else + return filename; + } + else + return fpath; + } + +#endif + + return p; +} diff --git a/src/shared/tools.h b/src/shared/tools.h index 551a475..5b841ad 100644 --- a/src/shared/tools.h +++ b/src/shared/tools.h @@ -7,6 +7,7 @@ #define M_UNSETBIT(var,bit) ( (var)&=(~(1<<(bit))) ) #define M_HASBIT(var,bit) ( (var)&(1<<(bit)) ) + void printchex(std::string,bool); void printchex(char *in, uint32 len, bool); std::string stringToUpper(std::string); @@ -24,5 +25,8 @@ void _FixFileName(std::string&); std::string _PathToFileName(std::string); std::string NormalizeFilename(std::string); std::string FilesizeFormat(uint32); +std::string GetWorkingDir(void); +bool SetWorkingDir(const char*); +std::string GetAbsolutePath(const char*); #endif