diff --git a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp
index 83dec01e1..328850ecd 100644
--- a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp
+++ b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp
@@ -51,6 +51,14 @@ along with this program. If not, see .
Q_EXPORT_PLUGIN2(object_viewer_widget_qt, NLQT::CObjectViewerWidget)
#endif
+#if defined(NL_OS_WINDOWS)
+ typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+#elif defined(NL_OS_MAC)
+ typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e);
+#else
+ typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e);
+#endif
+
using namespace NLMISC;
using namespace NL3D;
using namespace std;
@@ -87,13 +95,13 @@ namespace NLQT
void CObjectViewerWidget::showEvent ( QShowEvent * event )
{
- if (!_mainTimer->isActive())
+ if (!_mainTimer->isActive())
{
_mainTimer->start(25);
}
}
- void CObjectViewerWidget::setNelContext(NLMISC::INelContext &nelContext)
+ void CObjectViewerWidget::setNelContext(NLMISC::INelContext &nelContext)
{
_LibContext = new CLibraryContext(nelContext);
}
@@ -260,7 +268,7 @@ namespace NLQT
// ...
// 09. Update Animations (playlists)
- // - Needs to be either before or after entities, not sure,
+ // - Needs to be either before or after entities, not sure,
// there was a problem with wrong order a while ago!!!
@@ -283,7 +291,7 @@ namespace NLQT
if (_isGraphicsInitialized && !getDriver()->isLost())
{
- // 01. Render Driver (background color)
+ // 01. Render Driver (background color)
renderDriver(); // clear all buffers
// 02. Render Sky (sky scene)
@@ -428,14 +436,14 @@ namespace NLQT
bool CObjectViewerWidget::loadMesh(const std::string &meshFileName, const std::string &skelFileName)
{
std::string fileName = CFile::getFilenameWithoutExtension(meshFileName);
- if ( _Entities.count(fileName) != 0)
+ if ( _Entities.count(fileName) != 0)
return false;
CPath::addSearchPath(CFile::getPath(meshFileName), false, false);
// create instance of the mesh character
UInstance Entity = _Scene->createInstance(meshFileName);
-
+
CAABBox bbox;
Entity.getShapeAABBox(bbox);
setCamera(_Scene, bbox , Entity, true);
@@ -456,7 +464,7 @@ namespace NLQT
entity._FileNameShape = meshFileName;
entity._FileNameSkeleton = skelFileName;
entity._Instance = Entity;
- if (!Skeleton.empty())
+ if (!Skeleton.empty())
{
entity._Skeleton = Skeleton;
entity._Skeleton.bindSkin (entity._Instance);
@@ -735,11 +743,38 @@ namespace NLQT
_Scene->animate ( fdelta);
}
+#ifdef USE_QT5
+
+ bool CObjectViewerWidget::nativeEvent(const QByteArray &eventType, void *message, long *result)
+ {
+ if (getDriver() && getDriver()->isActive())
+ {
+ NL3D::IDriver *driver = dynamic_cast(getDriver())->getDriver();
+ if (driver)
+ {
+ // see what to do with result
#if defined(NL_OS_WINDOWS)
+ MSG *msg = (MSG*)message;
+ winProc proc = (winProc)driver->getWindowProc();
+ return proc(driver, msg->hwnd, msg->message, msg->wParam, msg->lParam);
+#elif defined(NL_OS_MAC)
+ cocoaProc proc = (cocoaProc)driver->getWindowProc();
+ return proc(driver, message);
+#else
+ x11Proc proc = (x11Proc)driver->getWindowProc();
+ return proc(driver, message);
+#endif
+ }
+ }
- typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+ return false;
+ }
+
+#else
- bool CObjectViewerWidget::winEvent(MSG * message, long * result)
+#if defined(NL_OS_WINDOWS)
+
+ bool CObjectViewerWidget::winEvent(MSG *message, long *result)
{
if (getDriver() && getDriver()->isActive())
{
@@ -756,8 +791,6 @@ namespace NLQT
#elif defined(NL_OS_MAC)
- typedef bool (*cocoaProc)(NL3D::IDriver*, const void* e);
-
bool CObjectViewerWidget::macEvent(EventHandlerCallRef caller, EventRef event)
{
if(caller)
@@ -778,8 +811,6 @@ namespace NLQT
#elif defined(NL_OS_UNIX)
- typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e);
-
bool CObjectViewerWidget::x11Event(XEvent *event)
{
if (getDriver() && getDriver()->isActive())
@@ -796,4 +827,6 @@ namespace NLQT
}
#endif
+#endif
+
} /* namespace NLQT */
diff --git a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h
index fb6656679..69629ef40 100644
--- a/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h
+++ b/code/nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h
@@ -33,7 +33,7 @@ along with this program. If not, see .
#include "entity.h"
#include "interfaces.h"
-namespace NL3D
+namespace NL3D
{
class UDriver;
class UScene;
@@ -50,14 +50,14 @@ class QIcon;
namespace NLQT
@brief namespace NLQT
*/
-namespace NLQT
+namespace NLQT
{
- class CObjectViewerWidget:
- public QWidget,
+ class CObjectViewerWidget:
+ public QWidget,
public IObjectViewer
{
Q_OBJECT
- Q_INTERFACES(NLQT::IObjectViewer)
+ Q_INTERFACES(NLQT::IObjectViewer)
public:
/// Default constructor.
@@ -113,7 +113,7 @@ namespace NLQT
/// @param w - width window.
/// @param h - height window.
void setSizeViewport(uint16 w, uint16 h);
-
+
void setBloomEffect(bool enabled) { _BloomEffect = enabled; }
/// Select instance from the scene
@@ -166,19 +166,25 @@ namespace NLQT
virtual QString name() const {return ("ObjectViewerWidget");}
protected:
+#ifdef USE_QT5
+ virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result);
+#else
+
#if defined(NL_OS_WINDOWS)
virtual bool winEvent(MSG * message, long * result);
#elif defined(NL_OS_MAC)
virtual bool macEvent(EventHandlerCallRef caller, EventRef event);
#elif defined(NL_OS_UNIX)
virtual bool x11Event(XEvent *event);
+#endif
+
#endif
private Q_SLOTS:
void updateRender();
private:
-
+
/// Update the animation time for Particle System animation.
/// @param deltaTime - set the manual animation time.
void updateAnimatePS(uint64 deltaTime = 0);
diff --git a/code/nel/tools/3d/object_viewer_widget/src/stdpch.h b/code/nel/tools/3d/object_viewer_widget/src/stdpch.h
index 34aaaa7d0..2c5b38f92 100644
--- a/code/nel/tools/3d/object_viewer_widget/src/stdpch.h
+++ b/code/nel/tools/3d/object_viewer_widget/src/stdpch.h
@@ -56,4 +56,12 @@ along with this program. If not, see .
#include
#include
+#if defined(NL_OS_WINDOWS)
+#define NOMINMAX
+#include
+#elif defined(NL_OS_MAC)
+#else
+#include
+#endif
+
#endif
diff --git a/code/ryzom/client/src/3d_notes.cpp b/code/ryzom/client/src/3d_notes.cpp
index 618525de4..c53ac7ef1 100644
--- a/code/ryzom/client/src/3d_notes.cpp
+++ b/code/ryzom/client/src/3d_notes.cpp
@@ -280,11 +280,11 @@ NLMISC_COMMAND(gotoNote, "go to a note", "|")
if(i != 0) tok += " ";
tok += args[i];
}
- tok = strlwr(tok);
+ tok = toLower(tok);
list::iterator it;
for(it = Notes.Notes.begin(); it != Notes.Notes.end(); it++)
{
- string note = strlwr((*it).Note);
+ string note = toLower((*it).Note);
if(note.find(tok) != string::npos)
{
pos = (*it).Position;
diff --git a/code/ryzom/client/src/animation_fx_sheet.cpp b/code/ryzom/client/src/animation_fx_sheet.cpp
index 99175ad71..b5c778b11 100644
--- a/code/ryzom/client/src/animation_fx_sheet.cpp
+++ b/code/ryzom/client/src/animation_fx_sheet.cpp
@@ -64,8 +64,7 @@ void CAnimationFX::buildTrack(NL3D::UAnimationSet *as)
nlassert(Sheet != NULL);
if (!as) return;
if (Sheet->TrajectoryAnim.empty()) return;
- std::string animName = Sheet->TrajectoryAnim;
- NLMISC::strlwr(animName);
+ std::string animName = NLMISC::toLower(Sheet->TrajectoryAnim);
uint id = as->getAnimationIdByName(animName);
NL3D::UAnimation *anim = NULL;
if (id != NL3D::UAnimationSet::NotFound)
diff --git a/code/ryzom/client/src/client_sheets/automaton_list_sheet.cpp b/code/ryzom/client/src/client_sheets/automaton_list_sheet.cpp
index fe7cd002c..1f0b6565c 100644
--- a/code/ryzom/client/src/client_sheets/automaton_list_sheet.cpp
+++ b/code/ryzom/client/src/client_sheets/automaton_list_sheet.cpp
@@ -204,7 +204,7 @@ void CAutomatonStateSheet::build(const NLGEORGES::UFormElm &item, const string &
for(uint mode = 0; mode ")
if (args.size() == 0)
return false;
- if (!ClientCfg.AllowDebugLua && strlwr(args[0]) == "lua")
+ if (!ClientCfg.AllowDebugLua && toLower(args[0]) == "lua")
{
return false; // not allowed!!
}
@@ -1883,7 +1883,7 @@ NLMISC_COMMAND(pos, "Change the position of the user (in local only)", "_Stream->serialBuffer((uint8*)buffer, (uint)size);
- *processedSize = size;
- return SZ_OK;
- }
- catch (...)
- {
- return SZE_FAIL;
- }
- }
-
- // the seek function called by seven zip to seek inside stream
- static SZ_RESULT seekFunc(void *object, CFileSize pos)
- {
- try
- {
- CNel7ZipInStream *me = (CNel7ZipInStream*)object;
- bool ret= me->_Stream->seek(pos, NLMISC::IStream::begin);
- if (ret)
- return SZ_OK;
- else
- return SZE_FAIL;
- }
- catch (...)
- {
- return SZE_FAIL;
- }
- }
-};
-#endif
-
static std::string ClientRootPath;
// ****************************************************************************
@@ -2192,164 +2131,6 @@ void CPatchManager::getCorruptedFileInfo(const SFileToPatch &ftp, ucstring &sTra
toString("%.1f ", (float)ftp.FinalFileSize/1000000.f) + CI18N::get("uiMb") + ")";
}
-bool CPatchManager::unpack7Zip(const std::string &sevenZipFile, const std::string &destFileName)
-{
-#ifdef RZ_USE_SEVENZIP
- nlinfo("Uncompressing 7zip archive '%s' to '%s'", sevenZipFile.c_str(), destFileName.c_str());
-
- // init seven zip
- ISzAlloc allocImp;
- ISzAlloc allocTempImp;
- CArchiveDatabaseEx db;
-
- allocImp.Alloc = SzAlloc;
- allocImp.Free = SzFree;
-
- allocTempImp.Alloc = SzAllocTemp;
- allocTempImp.Free = SzFreeTemp;
-
- InitCrcTable();
- SzArDbExInit(&db);
-
- // unpack the file using the 7zip API
-
- CIFile input(sevenZipFile);
- CNel7ZipInStream inStr(&input);
-
- SZ_RESULT res = SzArchiveOpen(&inStr, &db, &allocImp, &allocTempImp);
- if (res != SZ_OK)
- {
- nlerror("Failed to open archive file %s", sevenZipFile.c_str());
- return false;
- }
-
- if (db.Database.NumFiles != 1)
- {
- nlerror("Seven zip archive with more than 1 file are unsupported");
- return false;
- }
-
- UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */
- Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */
- size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */
-
- size_t offset;
- size_t outSizeProcessed = 0;
-
- // get the first file
- CFileItem *f = db.Database.Files;
- res = SzExtract(&inStr, &db, 0,
- &blockIndex, &outBuffer, &outBufferSize,
- &offset, &outSizeProcessed,
- &allocImp, &allocTempImp);
-
- // write the extracted file
- FILE *outputHandle;
- UInt32 processedSize;
- char *fileName = f->Name;
- size_t nameLen = strlen(f->Name);
- for (; nameLen > 0; nameLen--)
- {
- if (f->Name[nameLen - 1] == '/')
- {
- fileName = f->Name + nameLen;
- break;
- }
- }
-
- outputHandle = fopen(destFileName.c_str(), "wb+");
- if (outputHandle == 0)
- {
- nlerror("Can not open output file '%s'", destFileName.c_str());
- return false;
- }
- processedSize = (UInt32)fwrite(outBuffer + offset, 1, outSizeProcessed, outputHandle);
- if (processedSize != outSizeProcessed)
- {
- nlerror("Failed to write %u char to output file '%s'", outSizeProcessed-processedSize, destFileName.c_str());
- return false;
- }
- fclose(outputHandle);
- allocImp.Free(outBuffer);
-
- // free 7z context
- SzArDbExFree(&db, allocImp.Free);
-
- // ok, all is fine, file is unpacked
- return true;
-#else
- return false;
-#endif
-}
-
-bool CPatchManager::unpackLZMA(const std::string &lzmaFile, const std::string &destFileName)
-{
-#ifdef RZ_USE_SEVENZIP
- nldebug("unpackLZMA : decompression the lzma file '%s' into output file '%s", lzmaFile.c_str(), destFileName.c_str());
- CIFile inStream(lzmaFile);
- uint32 inSize = inStream.getFileSize();
- auto_ptr inBuffer = auto_ptr(new uint8[inSize]);
- inStream.serialBuffer(inBuffer.get(), inSize);
-
- CLzmaDecoderState state;
-
- uint8 *pos = inBuffer.get();
- // read the lzma properties
- int ret = LzmaDecodeProperties(&state.Properties, (unsigned char*) pos, LZMA_PROPERTIES_SIZE);
- if (ret != 0)
- {
- nlwarning("Failed to decode lzma properies in file '%s'!", lzmaFile.c_str());
- return false;
- }
-
- if (inSize < LZMA_PROPERTIES_SIZE + 8)
- {
- nlwarning("Invalid file size, too small file '%s'", lzmaFile.c_str());
- return false;
- }
-
- // alloc the probs, making sure they are deleted in function exit
- size_t nbProb = LzmaGetNumProbs(&state.Properties);
- auto_ptr probs = auto_ptr(new CProb[nbProb]);
- state.Probs = probs.get();
-
- pos += LZMA_PROPERTIES_SIZE;
-
- // read the output file size
- size_t fileSize = 0;
- for (int i = 0; i < 8; i++)
- {
- //Byte b;
- if (pos >= inBuffer.get()+inSize)
- {
- nlassert(false);
- return false;
- }
- fileSize |= ((UInt64)*pos++) << (8 * i);
- }
-
- SizeT outProcessed = 0;
- SizeT inProcessed = 0;
- // allocate the output buffer
- auto_ptr outBuffer = auto_ptr(new uint8[fileSize]);
- // decompress the file in memory
- ret = LzmaDecode(&state, (unsigned char*) pos, (SizeT)(inSize-(pos-inBuffer.get())), &inProcessed, (unsigned char*)outBuffer.get(), (SizeT)fileSize, &outProcessed);
- if (ret != 0 || outProcessed != fileSize)
- {
- nlwarning("Failed to decode lzma file '%s'", lzmaFile.c_str());
- return false;
- }
-
- // store on output buffer
- COFile outStream(destFileName);
- outStream.serialBuffer(outBuffer.get(), (uint)fileSize);
-
- return true;
-#else
- return false;
-#endif
-}
-
// ****************************************************************************
// ****************************************************************************
diff --git a/code/ryzom/client/src/login_patch_seven_zip.cpp b/code/ryzom/client/src/login_patch_seven_zip.cpp
new file mode 100644
index 000000000..4ce8ac122
--- /dev/null
+++ b/code/ryzom/client/src/login_patch_seven_zip.cpp
@@ -0,0 +1,482 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+//
+// Includes
+//
+
+#include "stdpch.h"
+#include "login_patch.h"
+
+#define RZ_USE_SEVENZIP 1
+//#define RZ_USE_NEW_LZMA
+
+#ifdef RZ_USE_SEVENZIP
+
+#ifdef RZ_USE_NEW_LZMA
+
+#include "seven_zip/7z.h"
+#include "seven_zip/7zAlloc.h"
+#include "seven_zip/7zBuf.h"
+#include "seven_zip/7zCrc.h"
+#include "seven_zip/7zFile.h"
+#include "seven_zip/7zVersion.h"
+#include "seven_zip/LzmaDec.h"
+
+#else
+
+#include "seven_zip/7zCrc.h"
+#include "seven_zip/7zIn.h"
+#include "seven_zip/7zExtract.h"
+#include "seven_zip/LzmaDecode.h"
+
+#endif
+
+//
+// Namespaces
+//
+
+using namespace std;
+using namespace NLMISC;
+
+
+#ifdef RZ_USE_NEW_LZMA
+
+/// Input stream class for 7zip archive
+class CNel7ZipInStream : public ISeekInStream
+{
+ NLMISC::IStream *_Stream;
+
+public:
+ /// Constructor, only allow file stream because 7zip will 'seek' in the stream
+ CNel7ZipInStream(NLMISC::IStream *s)
+ : _Stream(s)
+ {
+ Read = readFunc;
+ Seek = seekFunc;
+ }
+
+ // the read function called by 7zip to read data
+ static SRes readFunc(void *object, void *buffer, size_t *size)
+ {
+ try
+ {
+ CNel7ZipInStream *me = (CNel7ZipInStream*)object;
+ uint len = (uint)*size;
+ me->_Stream->serialBuffer((uint8*)buffer, len);
+ return SZ_OK;
+ }
+ catch (...)
+ {
+ return SZ_ERROR_READ;
+ }
+ }
+
+ // the seek function called by seven zip to seek inside stream
+ static SRes seekFunc(void *object, Int64 *pos, ESzSeek origin)
+ {
+ try
+ {
+ CNel7ZipInStream *me = (CNel7ZipInStream*)object;
+ sint32 offset = (sint32)*pos;
+ bool ret = me->_Stream->seek(offset, (NLMISC::IStream::TSeekOrigin)origin);
+
+ if (ret)
+ {
+ *pos = (Int64)me->_Stream->getPos();
+ return SZ_OK;
+ }
+ }
+ catch (...)
+ {
+ }
+
+ return SZ_ERROR_READ;
+ }
+};
+
+#else
+
+/// Input stream class for 7zip archive
+class CNel7ZipInStream : public _ISzInStream
+{
+ NLMISC::IStream *_Stream;
+
+public:
+ /// Constructor, only allow file stream because 7zip will 'seek' in the stream
+ CNel7ZipInStream(NLMISC::IStream *s)
+ : _Stream(s)
+ {
+ Read = readFunc;
+ Seek = seekFunc;
+ }
+
+ // the read function called by 7zip to read data
+ static SZ_RESULT readFunc(void *object, void *buffer, size_t size, size_t *processedSize)
+ {
+ try
+ {
+ CNel7ZipInStream *me = (CNel7ZipInStream*)object;
+ me->_Stream->serialBuffer((uint8*)buffer, (uint)size);
+ *processedSize = size;
+ return SZ_OK;
+ }
+ catch (...)
+ {
+ return SZE_FAIL;
+ }
+ }
+
+ // the seek function called by seven zip to seek inside stream
+ static SZ_RESULT seekFunc(void *object, CFileSize pos)
+ {
+ try
+ {
+ CNel7ZipInStream *me = (CNel7ZipInStream*)object;
+ bool ret= me->_Stream->seek(pos, NLMISC::IStream::begin);
+ if (ret)
+ return SZ_OK;
+ else
+ return SZE_FAIL;
+ }
+ catch (...)
+ {
+ return SZE_FAIL;
+ }
+ }
+};
+
+#endif
+
+#endif
+
+bool CPatchManager::unpack7Zip(const std::string &sevenZipFile, const std::string &destFileName)
+{
+#ifdef RZ_USE_SEVENZIP
+ nlinfo("Uncompressing 7zip archive '%s' to '%s'", sevenZipFile.c_str(), destFileName.c_str());
+
+ // init seven zip
+ ISzAlloc allocImp;
+ allocImp.Alloc = SzAlloc;
+ allocImp.Free = SzFree;
+
+ ISzAlloc allocTempImp;
+ allocTempImp.Alloc = SzAllocTemp;
+ allocTempImp.Free = SzFreeTemp;
+
+ // wrap file in a CIFile
+ CIFile input(sevenZipFile);
+ CNel7ZipInStream inStr(&input);
+
+#ifdef RZ_USE_NEW_LZMA
+
+ CLookToRead lookStream;
+ lookStream.realStream = &inStr;
+ LookToRead_CreateVTable(&lookStream, False);
+ LookToRead_Init(&lookStream);
+
+ CrcGenerateTable();
+
+ CSzArEx db;
+ SzArEx_Init(&db);
+
+ // unpack the file using the 7zip API
+ SRes res = SzArEx_Open(&db, &lookStream.s, &allocImp, &allocTempImp);
+
+ if (res != SZ_OK)
+ {
+ nlerror("Failed to open archive file %s", sevenZipFile.c_str());
+ return false;
+ }
+
+ if (db.NumFiles != 1)
+ {
+ nlerror("Seven zip archive with more than 1 file are unsupported");
+ return false;
+ }
+
+ UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */
+ Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */
+ size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */
+
+ size_t offset;
+ size_t outSizeProcessed = 0;
+
+ // get the first file
+ res = SzArEx_Extract(&db, &lookStream.s, 0,
+ &blockIndex, &outBuffer, &outBufferSize,
+ &offset, &outSizeProcessed,
+ &allocImp, &allocTempImp);
+
+ // get the length of first file
+ size_t nameLen = SzArEx_GetFileNameUtf16(&db, 0, NULL);
+
+ ucstring filename;
+ filename.resize(nameLen);
+
+ // write filename into ucstring
+ SzArEx_GetFileNameUtf16(&db, 0, &filename[0]);
+
+ // write the extracted file
+ FILE *outputHandle = fopen(destFileName.c_str(), "wb+");
+
+ if (outputHandle == 0)
+ {
+ nlerror("Can not open output file '%s'", destFileName.c_str());
+ return false;
+ }
+
+ UInt32 processedSize = (UInt32)fwrite(outBuffer + offset, 1, outSizeProcessed, outputHandle);
+
+ if (processedSize != outSizeProcessed)
+ {
+ nlerror("Failed to write %u char to output file '%s'", outSizeProcessed-processedSize, destFileName.c_str());
+ return false;
+ }
+
+ fclose(outputHandle);
+
+ IAlloc_Free(&allocImp, outBuffer);
+
+ // free 7z context
+ SzArEx_Free(&db, &allocImp);
+
+#else
+
+ InitCrcTable();
+
+ CArchiveDatabaseEx db;
+ SzArDbExInit(&db);
+
+ // unpack the file using the 7zip API
+ SZ_RESULT res = SzArchiveOpen(&inStr, &db, &allocImp, &allocTempImp);
+
+ if (res != SZ_OK)
+ {
+ nlerror("Failed to open archive file %s", sevenZipFile.c_str());
+ return false;
+ }
+
+ if (db.Database.NumFiles != 1)
+ {
+ nlerror("Seven zip archive with more than 1 file are unsupported");
+ return false;
+ }
+
+ UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */
+ Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */
+ size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */
+
+ size_t offset;
+ size_t outSizeProcessed = 0;
+
+ // get the first file
+ CFileItem *f = db.Database.Files;
+ res = SzExtract(&inStr, &db, 0,
+ &blockIndex, &outBuffer, &outBufferSize,
+ &offset, &outSizeProcessed,
+ &allocImp, &allocTempImp);
+
+ // write the extracted file
+ FILE *outputHandle;
+ UInt32 processedSize;
+ char *fileName = f->Name;
+ size_t nameLen = strlen(f->Name);
+ for (; nameLen > 0; nameLen--)
+ {
+ if (f->Name[nameLen - 1] == '/')
+ {
+ fileName = f->Name + nameLen;
+ break;
+ }
+ }
+
+ outputHandle = fopen(destFileName.c_str(), "wb+");
+
+ if (outputHandle == 0)
+ {
+ nlerror("Can not open output file '%s'", destFileName.c_str());
+ return false;
+ }
+
+ processedSize = (UInt32)fwrite(outBuffer + offset, 1, outSizeProcessed, outputHandle);
+
+ if (processedSize != outSizeProcessed)
+ {
+ nlerror("Failed to write %u char to output file '%s'", outSizeProcessed-processedSize, destFileName.c_str());
+ return false;
+ }
+
+ fclose(outputHandle);
+ allocImp.Free(outBuffer);
+
+ // free 7z context
+ SzArDbExFree(&db, allocImp.Free);
+
+#endif
+
+ // ok, all is fine, file is unpacked
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool CPatchManager::unpackLZMA(const std::string &lzmaFile, const std::string &destFileName)
+{
+#ifdef RZ_USE_SEVENZIP
+ nldebug("unpackLZMA : decompression the lzma file '%s' into output file '%s", lzmaFile.c_str(), destFileName.c_str());
+
+ CIFile inStream(lzmaFile);
+ uint32 inSize = inStream.getFileSize();
+
+#ifdef RZ_USE_NEW_LZMA
+
+ if (inSize < LZMA_PROPS_SIZE + 8)
+ {
+ nlwarning("Invalid file size, too small file '%s'", lzmaFile.c_str());
+ return false;
+ }
+
+ // read the compressed file in buffer
+ auto_ptr inBuffer = auto_ptr(new uint8[inSize]);
+ inStream.serialBuffer(inBuffer.get(), inSize);
+
+ uint8 *pos = inBuffer.get();
+
+ pos += LZMA_PROPS_SIZE;
+
+ // read the output file size
+ size_t fileSize = 0;
+
+ for (int i = 0; i < 8; ++i)
+ {
+ if (pos >= inBuffer.get()+inSize)
+ {
+ nlassert(false);
+ return false;
+ }
+
+ fileSize |= ((UInt64)*pos++) << (8 * i);
+ }
+
+ // allocators
+ ISzAlloc allocImp;
+ allocImp.Alloc = SzAlloc;
+ allocImp.Free = SzFree;
+
+ CLzmaDec state;
+ LzmaDec_Construct(&state);
+
+ // allocate and decode props and probs
+ SRes res = LzmaDec_Allocate(&state, inBuffer.get(), LZMA_PROPS_SIZE, &allocImp);
+
+ if (res != 0)
+ {
+ nlwarning("Failed to decode lzma properies in file '%s'!", lzmaFile.c_str());
+ return false;
+ }
+
+ // allocate the output buffer
+ auto_ptr outBuffer = auto_ptr(new uint8[fileSize]);
+
+ // in and out file sizes
+ SizeT outProcessed = fileSize;
+ SizeT inProcessed = (SizeT)(inSize-(pos-inBuffer.get()));
+
+ LzmaDec_Init(&state);
+
+ // decompress the file in memory
+ ELzmaStatus status;
+ res = LzmaDec_DecodeToBuf(&state, (Byte*)outBuffer.get(), &outProcessed, (Byte*)pos, &inProcessed, LZMA_FINISH_ANY, &status);
+
+ // free memory
+ LzmaDec_Free(&state, &allocImp);
+
+ if (res != 0 || outProcessed != fileSize)
+ {
+ nlwarning("Failed to decode lzma file '%s' with status %d", lzmaFile.c_str(), (sint)status);
+ return false;
+ }
+
+#else
+
+ auto_ptr inBuffer = auto_ptr(new uint8[inSize]);
+ inStream.serialBuffer(inBuffer.get(), inSize);
+
+ CLzmaDecoderState state;
+
+ uint8 *pos = inBuffer.get();
+
+ // read the lzma properties
+ int res = LzmaDecodeProperties(&state.Properties, (unsigned char*) pos, LZMA_PROPERTIES_SIZE);
+ if (res != 0)
+ {
+ nlwarning("Failed to decode lzma properies in file '%s'!", lzmaFile.c_str());
+ return false;
+ }
+
+ if (inSize < LZMA_PROPERTIES_SIZE + 8)
+ {
+ nlwarning("Invalid file size, too small file '%s'", lzmaFile.c_str());
+ return false;
+ }
+
+ // alloc the probs, making sure they are deleted in function exit
+ size_t nbProb = LzmaGetNumProbs(&state.Properties);
+ auto_ptr probs = auto_ptr(new CProb[nbProb]);
+ state.Probs = probs.get();
+
+ pos += LZMA_PROPERTIES_SIZE;
+
+ // read the output file size
+ size_t fileSize = 0;
+ for (int i = 0; i < 8; i++)
+ {
+ if (pos >= inBuffer.get()+inSize)
+ {
+ nlassert(false);
+ return false;
+ }
+ fileSize |= ((UInt64)*pos++) << (8 * i);
+ }
+
+ SizeT outProcessed = 0;
+ SizeT inProcessed = 0;
+
+ // allocate the output buffer
+ auto_ptr outBuffer = auto_ptr(new uint8[fileSize]);
+
+ // decompress the file in memory
+ res = LzmaDecode(&state, (unsigned char*) pos, (SizeT)(inSize-(pos-inBuffer.get())), &inProcessed, (unsigned char*)outBuffer.get(), (SizeT)fileSize, &outProcessed);
+
+ if (res != 0 || outProcessed != fileSize)
+ {
+ nlwarning("Failed to decode lzma file '%s'", lzmaFile.c_str());
+ return false;
+ }
+
+#endif
+
+ // store on output buffer
+ COFile outStream(destFileName);
+ outStream.serialBuffer(outBuffer.get(), (uint)fileSize);
+
+ return true;
+#else
+ return false;
+#endif
+}
diff --git a/code/ryzom/client/src/teleport.cpp b/code/ryzom/client/src/teleport.cpp
index f5ec933a7..c85c938fa 100644
--- a/code/ryzom/client/src/teleport.cpp
+++ b/code/ryzom/client/src/teleport.cpp
@@ -97,16 +97,14 @@ void CTeleport::load(const std::string &/* filename */)
string destName;
if(tpElmt->getValueByName(destName, "name"))
{
- // All in UPPER CASE to not be CASE SENSITIVE.
- NLMISC::strlwr(destName);
-
// Get the position
CVector pos;
if(tpElmt->getValueByName(pos.x, "position.X")
&& tpElmt->getValueByName(pos.y, "position.Y")
&& tpElmt->getValueByName(pos.z, "position.Z"))
{
- _Destinations.insert(make_pair(destName, pos));
+ // All in UPPER CASE to not be CASE SENSITIVE.
+ _Destinations.insert(make_pair(NLMISC::toLower(destName), pos));
}
else
nlwarning("CTeleport::load: Cannot find the one of the key 'position.X or Y or Z' for the element %d.", i);