From fad179731a138a569da5a3bd6d793311783320bf Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 12:29:34 +0100 Subject: [PATCH 01/16] Fixed: Compilation of tile_edit_qt with Qt 5 --HG-- branch : develop --- code/nel/tools/3d/tile_edit_qt/CMakeLists.txt | 33 +++++++---- .../tools/3d/tile_edit_qt/browser_model.cpp | 16 +----- code/nel/tools/3d/tile_edit_qt/common.cpp | 17 ++++++ code/nel/tools/3d/tile_edit_qt/common.h | 56 +++++++++++++++++++ .../tools/3d/tile_edit_qt/items_edit_dlg.cpp | 1 + .../tools/3d/tile_edit_qt/items_edit_dlg.h | 2 - code/nel/tools/3d/tile_edit_qt/main.cpp | 17 +++++- .../3d/tile_edit_qt/tile_browser_dlg.cpp | 20 ++----- .../tools/3d/tile_edit_qt/tile_browser_dlg.h | 4 -- .../tools/3d/tile_edit_qt/tile_edit_dlg.cpp | 9 +-- .../nel/tools/3d/tile_edit_qt/tile_edit_dlg.h | 2 - .../3d/tile_edit_qt/tile_listwidgetitem.cpp | 1 + .../3d/tile_edit_qt/tile_rotation_dlg.cpp | 1 + .../tools/3d/tile_edit_qt/tile_rotation_dlg.h | 4 -- .../nel/tools/3d/tile_edit_qt/tile_widget.cpp | 1 + code/nel/tools/3d/tile_edit_qt/tile_widget.h | 1 - .../nel/tools/3d/tile_edit_qt/tiles_model.cpp | 8 +-- code/nel/tools/3d/tile_edit_qt/tiles_model.h | 9 --- 18 files changed, 126 insertions(+), 76 deletions(-) create mode 100644 code/nel/tools/3d/tile_edit_qt/common.cpp create mode 100644 code/nel/tools/3d/tile_edit_qt/common.h diff --git a/code/nel/tools/3d/tile_edit_qt/CMakeLists.txt b/code/nel/tools/3d/tile_edit_qt/CMakeLists.txt index 18ced90ed..0fd5e72a0 100644 --- a/code/nel/tools/3d/tile_edit_qt/CMakeLists.txt +++ b/code/nel/tools/3d/tile_edit_qt/CMakeLists.txt @@ -1,8 +1,4 @@ -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/pic) -INCLUDE( ${QT_USE_FILE} ) - -FIND_PACKAGE(JPEG) -INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) FILE(GLOB TILE_EDIT_SRC *.cpp *.h) FILE(GLOB PIC_SRC pic/*.c pic/*.cpp) @@ -10,22 +6,35 @@ SET(TILE_EDIT_HDR items_edit_dlg.h tile_browser_dlg.h tile_edit_dlg.h tile_rotat SET(TILE_EDIT_UIS tile_widget_qt.ui tile_rotation_qt.ui tile_edit_qt.ui tile_browser_qt.ui items_edit_qt.ui) SET(TILE_EDIT_RCS tile_edit_qt.qrc) -QT4_ADD_RESOURCES( TILE_EDIT_RC_SRCS ${TILE_EDIT_RCS} ) -QT4_WRAP_UI( TILE_EDIT_UI_HDRS ${TILE_EDIT_UIS} ) -QT4_WRAP_CPP( TILE_EDIT_MOC_SRCS ${TILE_EDIT_HDR}) +IF(WITH_QT) + INCLUDE_DIRECTORIES(${QT_INCLUDES}) + INCLUDE(${QT_USE_FILE}) + + QT4_ADD_RESOURCES(TILE_EDIT_RC_SRCS ${TILE_EDIT_RCS}) + QT4_WRAP_UI(TILE_EDIT_UI_HDRS ${TILE_EDIT_UIS}) + QT4_WRAP_CPP(TILE_EDIT_MOC_SRCS ${TILE_EDIT_HDR}) + + ADD_DEFINITIONS(${QT_DEFINITIONS}) +ELSEIF(WITH_QT5) + QT5_ADD_RESOURCES(TILE_EDIT_RC_SRCS ${TILE_EDIT_RCS}) + QT5_WRAP_UI(TILE_EDIT_UI_HDRS ${TILE_EDIT_UIS}) + QT5_WRAP_CPP(TILE_EDIT_MOC_SRCS ${TILE_EDIT_HDR}) +ENDIF() + SOURCE_GROUP(QtResources FILES ${TILE_EDIT_UIS} ${TILE_EDIT_RCS}) SOURCE_GROUP(QtGeneratedUiHdr FILES ${TILE_EDIT_UI_HDRS}) SOURCE_GROUP(QtGeneratedMocSrc FILES ${TILE_EDIT_MOC_SRCS}) -SOURCE_GROUP(PICLibrary FILES ${PIC_SRC}) -ADD_EXECUTABLE(tile_edit_qt ${TILE_EDIT_SRC} ${PIC_SRC} ${TILE_EDIT_MOC_SRCS} ${TILE_EDIT_RC_SRCS} ${TILE_EDIT_UI_HDRS}) +ADD_EXECUTABLE(tile_edit_qt WIN32 ${TILE_EDIT_SRC} ${TILE_EDIT_MOC_SRCS} ${TILE_EDIT_RC_SRCS} ${TILE_EDIT_UI_HDRS}) -TARGET_LINK_LIBRARIES(tile_edit_qt ${QT_LIBRARIES} ${JPEG_LIBRARY} nelmisc nel3d) +TARGET_LINK_LIBRARIES(tile_edit_qt ${QT_LIBRARIES} nelmisc nel3d) NL_DEFAULT_PROPS(tile_edit_qt "NeL, Tools, 3D: Qt Tile Editor") NL_ADD_RUNTIME_FLAGS(tile_edit_qt) -ADD_DEFINITIONS(${QT_DEFINITIONS}) +IF(WITH_PCH) + ADD_NATIVE_PRECOMPILED_HEADER(tile_edit_qt ${CMAKE_CURRENT_SOURCE_DIR}/common.h ${CMAKE_CURRENT_SOURCE_DIR}/common.cpp) +ENDIF() INSTALL(TARGETS tile_edit_qt RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT tools3d) diff --git a/code/nel/tools/3d/tile_edit_qt/browser_model.cpp b/code/nel/tools/3d/tile_edit_qt/browser_model.cpp index 6b22e2f8e..bd26eb791 100644 --- a/code/nel/tools/3d/tile_edit_qt/browser_model.cpp +++ b/code/nel/tools/3d/tile_edit_qt/browser_model.cpp @@ -14,19 +14,9 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include +#include "common.h" #include "browser_model.h" -#include - -#include -#include -#include - -#include - -#include "pic/readpic.h" - using namespace std; using namespace NL3D; using namespace NLMISC; @@ -272,8 +262,8 @@ int TileList::addTile256 () bool TileList::setTile128 (int tile, const std::string& name, NL3D::CTile::TBitmap type) { // Remove the absolute path from the path name - std::string troncated=name; - if (RemovePath (troncated, tileBankBrowser.getAbsPath ().c_str())) + std::string troncated = name; + if (RemovePath(troncated, tileBankBrowser.getAbsPath ().c_str())) { vector tampon; uint Width; diff --git a/code/nel/tools/3d/tile_edit_qt/common.cpp b/code/nel/tools/3d/tile_edit_qt/common.cpp new file mode 100644 index 000000000..e415c3f6f --- /dev/null +++ b/code/nel/tools/3d/tile_edit_qt/common.cpp @@ -0,0 +1,17 @@ +// NeL - 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 . + +#include "common.h" diff --git a/code/nel/tools/3d/tile_edit_qt/common.h b/code/nel/tools/3d/tile_edit_qt/common.h new file mode 100644 index 000000000..685195251 --- /dev/null +++ b/code/nel/tools/3d/tile_edit_qt/common.h @@ -0,0 +1,56 @@ +// NeL - 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 . + +#ifndef COMMON_H +#define COMMON_H + +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) + #undef realloc + #undef free +#endif + +#include + +#ifdef Q_COMPILER_RVALUE_REFS +#undef Q_COMPILER_RVALUE_REFS +#endif + +#include +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#define USE_QT5 +#endif + +#ifdef USE_QT5 +#include +#include +#endif + +#include + +#include +#include +#include +#include +#include +#include + +#endif diff --git a/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.cpp b/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.cpp index 3fd9d3350..0ac2f2eda 100644 --- a/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.cpp +++ b/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.cpp @@ -1,3 +1,4 @@ +#include "common.h" #include #include #include "items_edit_dlg.h" diff --git a/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.h b/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.h index 0f65bcef5..73ed5b0b8 100644 --- a/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.h +++ b/code/nel/tools/3d/tile_edit_qt/items_edit_dlg.h @@ -1,8 +1,6 @@ #ifndef ITEMS_EDITDLG_H #define ITEMS_EDITDLG_H -#include -#include #include "ui_items_edit_qt.h" class CItems_edit_dlg : public QDialog diff --git a/code/nel/tools/3d/tile_edit_qt/main.cpp b/code/nel/tools/3d/tile_edit_qt/main.cpp index 2f3d51012..4a6ff4cbf 100644 --- a/code/nel/tools/3d/tile_edit_qt/main.cpp +++ b/code/nel/tools/3d/tile_edit_qt/main.cpp @@ -1,7 +1,20 @@ -#include -#include "nel/misc/app_context.h" +#include "common.h" + #include "tile_edit_dlg.h" +#ifdef QT_STATICPLUGIN + +#include + +#if defined(Q_OS_WIN32) + Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) +#elif defined(Q_OS_MAC) + Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin) +#elif defined(Q_OS_UNIX) + Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) +#endif + +#endif int main(int argc, char *argv[]) { diff --git a/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp b/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp index 037ac65e8..d73a9a969 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp @@ -14,18 +14,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include -#include -#include -#include -#include -#include -#include -#include "nel/3d/tile_bank.h" -#include "nel/misc/bitmap.h" -#include "nel/misc/file.h" -#include "pic/readpic.h" -#include "pic/pic.h" +#include "common.h" + #include "tile_browser_dlg.h" #include "tile_rotation_dlg.h" @@ -109,10 +99,10 @@ void CTile_browser_dlg::initDialog(const int& tileSetIndex) tileZoomButtonGroup->button(settings.value("browser/TileZoom").toInt())->setChecked(true); //GroupBox checkedIdChanged subscription - connect(tileTypeButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileTypeButtonGroup_clicked(int))); + connect(tileTypeButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileTypeButtonGroup_clicked(int))); connect(tileTextureButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileTextureButtonGroup_clicked(int))); - connect(tileLabelButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileLabelButtonGroup_clicked(int))); - connect(tileZoomButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileZoomButtonGroup_clicked(int))); + connect(tileLabelButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileLabelButtonGroup_clicked(int))); + connect(tileZoomButtonGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_tileZoomButtonGroup_clicked(int))); //Tile View Model tileViewModel = new tiles_model(this); diff --git a/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.h b/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.h index bfb45722c..b25bc4279 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.h +++ b/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.h @@ -17,14 +17,10 @@ #ifndef TILE_BROWSERDLG_H #define TILE_BROWSERDLG_H -#include -#include -#include #include "ui_tile_browser_qt.h" #include "tiles_model.h" #include "browser_model.h" - class CTile_browser_dlg : public QDialog { Q_OBJECT diff --git a/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.cpp b/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.cpp index 595067cd2..2b6612e9c 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.cpp @@ -14,14 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include -#include -#include -#include -#include -#include -#include -#include +#include "common.h" #include "tile_edit_dlg.h" #include "items_edit_dlg.h" #include "tile_browser_dlg.h" diff --git a/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.h b/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.h index 97d0dd760..88c32bd05 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.h +++ b/code/nel/tools/3d/tile_edit_qt/tile_edit_dlg.h @@ -17,8 +17,6 @@ #ifndef TILE_EDITDLG_H #define TILE_EDITDLG_H -#include -#include #include "ui_tile_edit_qt.h" class QCheckBox; diff --git a/code/nel/tools/3d/tile_edit_qt/tile_listwidgetitem.cpp b/code/nel/tools/3d/tile_edit_qt/tile_listwidgetitem.cpp index 475b9da73..9b70e4c24 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_listwidgetitem.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_listwidgetitem.cpp @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#include "common.h" #include "tile_listwidgetitem.h" //tile_listwidgetitem::tile_listwidgetitem(void) diff --git a/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.cpp b/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.cpp index c053bab8e..a1d4a2786 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.cpp @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#include "common.h" #include "tile_rotation_dlg.h" CTile_rotation_dlg::CTile_rotation_dlg(QWidget *parent, Qt::WindowFlags flags) diff --git a/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.h b/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.h index 1891873a5..852aa17ad 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.h +++ b/code/nel/tools/3d/tile_edit_qt/tile_rotation_dlg.h @@ -17,10 +17,6 @@ #ifndef TILE_ROTATIONDLG_H #define TILE_ROTATIONDLG_H - -#include -#include -#include #include "ui_tile_rotation_qt.h" class CTile_rotation_dlg : public QDialog diff --git a/code/nel/tools/3d/tile_edit_qt/tile_widget.cpp b/code/nel/tools/3d/tile_edit_qt/tile_widget.cpp index bd4a58b8c..d789e45c2 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_widget.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_widget.cpp @@ -1,3 +1,4 @@ +#include "common.h" #include #include "tile_widget.h" diff --git a/code/nel/tools/3d/tile_edit_qt/tile_widget.h b/code/nel/tools/3d/tile_edit_qt/tile_widget.h index e0ca41d10..994c4b8f4 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_widget.h +++ b/code/nel/tools/3d/tile_edit_qt/tile_widget.h @@ -1,7 +1,6 @@ #ifndef TILE_WIDGET_H #define TILE_WIDGET_H -#include #include "tiles_model.h" #include "ui_tile_widget_qt.h" diff --git a/code/nel/tools/3d/tile_edit_qt/tiles_model.cpp b/code/nel/tools/3d/tile_edit_qt/tiles_model.cpp index 252b39298..cbe6e05a1 100644 --- a/code/nel/tools/3d/tile_edit_qt/tiles_model.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tiles_model.cpp @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#include "common.h" #include #include "tiles_model.h" #include "tile_widget.h" @@ -57,10 +58,9 @@ QVariant tiles_model::data(const QModelIndex &index, int role) const if (role == Qt::DecorationRole || role == Qt::UserRole) { - CTile_Widget* wiwi = new CTile_Widget; - wiwi->initWidget( tiles.value(index.row()).getPixmap(), tiles.value(index.row()).getPixmapSide(), tiles.value(index.row()).getTileLabel() ); - QPixmap pixpix = QPixmap::grabWidget(wiwi, wiwi->contentsRect()); - delete wiwi; + CTile_Widget wiwi; + wiwi.initWidget(tiles.value(index.row()).getPixmap(), tiles.value(index.row()).getPixmapSide(), tiles.value(index.row()).getTileLabel()); + QPixmap pixpix = wiwi.grab(wiwi.contentsRect()); return pixpix; } else if (role == Qt::UserRole + 1) diff --git a/code/nel/tools/3d/tile_edit_qt/tiles_model.h b/code/nel/tools/3d/tile_edit_qt/tiles_model.h index b224adf3b..57aee8687 100644 --- a/code/nel/tools/3d/tile_edit_qt/tiles_model.h +++ b/code/nel/tools/3d/tile_edit_qt/tiles_model.h @@ -1,15 +1,6 @@ #ifndef TILESMODEL_H #define TILESMODEL_H -#include -#include -#include -#include -#include -#include -#include -#include - class TileModel { From 2923fe7c89fcc738a0316d343b8b413d1cbd9c91 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 12:31:13 +0100 Subject: [PATCH 02/16] Fixed: Remove dependency on Pic (NeL manages TGA and PNG itself, reused code by Kaetemi) --HG-- branch : develop --- .../tools/3d/tile_edit_qt/browser_model.cpp | 43 +- .../tools/3d/tile_edit_qt/pic/PIC_System.c | 134 ---- code/nel/tools/3d/tile_edit_qt/pic/Pic_BMP.c | 215 ------ code/nel/tools/3d/tile_edit_qt/pic/Pic_JPG.c | 160 ----- .../tools/3d/tile_edit_qt/pic/Pic_Manage.c | 654 ------------------ code/nel/tools/3d/tile_edit_qt/pic/Pic_TGA.c | 215 ------ code/nel/tools/3d/tile_edit_qt/pic/pic.h | 48 -- .../tools/3d/tile_edit_qt/pic/pic_private.h | 71 -- .../nel/tools/3d/tile_edit_qt/pic/readpic.cpp | 68 -- code/nel/tools/3d/tile_edit_qt/pic/readpic.h | 26 - 10 files changed, 37 insertions(+), 1597 deletions(-) delete mode 100644 code/nel/tools/3d/tile_edit_qt/pic/PIC_System.c delete mode 100644 code/nel/tools/3d/tile_edit_qt/pic/Pic_BMP.c delete mode 100644 code/nel/tools/3d/tile_edit_qt/pic/Pic_JPG.c delete mode 100644 code/nel/tools/3d/tile_edit_qt/pic/Pic_Manage.c delete mode 100644 code/nel/tools/3d/tile_edit_qt/pic/Pic_TGA.c delete mode 100644 code/nel/tools/3d/tile_edit_qt/pic/pic.h delete mode 100644 code/nel/tools/3d/tile_edit_qt/pic/pic_private.h delete mode 100644 code/nel/tools/3d/tile_edit_qt/pic/readpic.cpp delete mode 100644 code/nel/tools/3d/tile_edit_qt/pic/readpic.h diff --git a/code/nel/tools/3d/tile_edit_qt/browser_model.cpp b/code/nel/tools/3d/tile_edit_qt/browser_model.cpp index bd26eb791..68c28dbb8 100644 --- a/code/nel/tools/3d/tile_edit_qt/browser_model.cpp +++ b/code/nel/tools/3d/tile_edit_qt/browser_model.cpp @@ -24,6 +24,37 @@ using namespace NLMISC; extern CTileBank tileBankBrowser; static const char* comp[]={"Red", "Green", "Blue", "Alpha", ""}; +static bool loadPic(const string &path, std::vector &tampon, uint &width, uint &height) +{ + try + { + NLMISC::CIFile file; + if (file.open(path.c_str())) + { + NLMISC::CBitmap bitmap; + bitmap.load(file); + width = bitmap.getWidth(); + height = bitmap.getHeight(); + tampon.resize(width * height); + bitmap.convertToType(NLMISC::CBitmap::RGBA); + for (uint y = 0; y < height; ++y) + { + for (uint x = 0; x < width; ++x) + { + NLMISC::CRGBA c = bitmap.getPixelColor(x, y, 0); + c.R = (c.R * c.A) / 255; + c.G = (c.G * c.A) / 255; + c.B = (c.B * c.A) / 255; + tampon[(y * width) + x] = c; + } + } + return true; + } + } + catch (NLMISC::Exception& ) { } + return false; +} + bool RemovePath (std::string& path, const char* absolutePathToRemplace); // Rotate a buffer @@ -55,7 +86,7 @@ int loadPixmapBuffer(const std::string& path, std::vector& Buffer { uint Width; uint Height; - if (PIC_LoadPic(path, Buffer, Width, Height)) + if (loadPic(path, Buffer, Width, Height)) { while (rot) { @@ -268,7 +299,7 @@ bool TileList::setTile128 (int tile, const std::string& name, NL3D::CTile::TBitm vector tampon; uint Width; uint Height; - if (!PIC_LoadPic(tileBankBrowser.getAbsPath ()+troncated, tampon, Width, Height)) + if (!loadPic(tileBankBrowser.getAbsPath ()+troncated, tampon, Width, Height)) { return ( QMessageBox::Yes == QMessageBox::question( NULL, QObject::tr("Can't load bitmap."), QString( ((tileBankBrowser.getAbsPath ()+troncated)+"\nContinue ?").c_str() ), QMessageBox::Yes | QMessageBox::No)); } @@ -333,7 +364,7 @@ bool TileList::setTile256 (int tile, const std::string& name, NL3D::CTile::TBitm vector tampon; uint Width; uint Height; - if (!PIC_LoadPic(tileBankBrowser.getAbsPath ()+troncated, tampon, Width, Height)) + if (!loadPic(tileBankBrowser.getAbsPath ()+troncated, tampon, Width, Height)) { return ( QMessageBox::Yes == QMessageBox::question( NULL, QObject::tr("Can't load bitmap."), QString( ((tileBankBrowser.getAbsPath ()+troncated)+"\nContinue ?").c_str() ), QMessageBox::Yes | QMessageBox::No) ); @@ -399,7 +430,7 @@ bool TileList::setTileTransition (int tile, const std::string& name, NL3D::CTile vector tampon; uint Width; uint Height; - if (!PIC_LoadPic(tileBankBrowser.getAbsPath ()+troncated, tampon, Width, Height)) + if (!loadPic(tileBankBrowser.getAbsPath ()+troncated, tampon, Width, Height)) { return ( QMessageBox::Yes == QMessageBox::question( NULL, QObject::tr("Can't load bitmap."), QString( ((tileBankBrowser.getAbsPath ()+troncated)+"\nContinue ?").c_str() ), QMessageBox::Yes | QMessageBox::No) ); } @@ -463,7 +494,7 @@ bool TileList::setDisplacement (int tile, const std::string& name, NL3D::CTile:: vector tampon; uint Width; uint Height; - if (!PIC_LoadPic(tileBankBrowser.getAbsPath ()+troncated, tampon, Width, Height)) + if (!loadPic(tileBankBrowser.getAbsPath ()+troncated, tampon, Width, Height)) { return ( QMessageBox::Yes == QMessageBox::question( NULL, QObject::tr("Can't load bitmap"), QString( ((tileBankBrowser.getAbsPath ()+troncated)+"\nContinue ?").c_str() ), QMessageBox::Yes | QMessageBox::No) ); } @@ -506,7 +537,7 @@ bool TileList::setTileTransitionAlpha (int tile, const std::string& name, int ro vector tampon; uint Width; uint Height; - if (!PIC_LoadPic(tileBankBrowser.getAbsPath ()+troncated, tampon, Width, Height)) + if (!loadPic(tileBankBrowser.getAbsPath ()+troncated, tampon, Width, Height)) { return ( QMessageBox::Yes == QMessageBox::question( NULL, QObject::tr("Can't load bitmap"), QString( ((tileBankBrowser.getAbsPath ()+troncated)+"\nContinue ?").c_str() ), QMessageBox::Yes | QMessageBox::No) ); } diff --git a/code/nel/tools/3d/tile_edit_qt/pic/PIC_System.c b/code/nel/tools/3d/tile_edit_qt/pic/PIC_System.c deleted file mode 100644 index 498e5d302..000000000 --- a/code/nel/tools/3d/tile_edit_qt/pic/PIC_System.c +++ /dev/null @@ -1,134 +0,0 @@ -#include -#include -#if !defined(__APPLE__) -#include -#endif -#include -#include - -#define PIC_ERRSIZE 256 - -static size_t PIC_Sys_MEM_Allocated; -static size_t PIC_Sys_MEM_NbAllocs; - -#if defined(__APPLE__) -#define _msize malloc_size -#elif defined(__GNUC__) -#define _msize malloc_usable_size -#endif /* __GNUC__ */ - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -void *Pic_malloc(unsigned long size) -{ - void *mem; - mem=malloc(size); - if (mem) - { - PIC_Sys_MEM_Allocated+=size; - PIC_Sys_MEM_NbAllocs++; - } - return(mem); -} -/* ----- */ -void *Pic_calloc(size_t count, size_t size) -{ - void *mem; - mem=calloc(count,size); - if (mem) - { - PIC_Sys_MEM_Allocated+=(size*count); - PIC_Sys_MEM_NbAllocs++; - } - return(mem); -} -/* ----- */ -void Pic_free(void *memblock) -{ - size_t size; - size=_msize(memblock); - PIC_Sys_MEM_Allocated-=size; - PIC_Sys_MEM_NbAllocs--; - free(memblock); -} -/* ----- */ -size_t Pic__msize(void *memblock) -{ - return(_msize(memblock)); -} -/* ----- */ -size_t PIC_GetMemNbAllocs(void) -{ - return(PIC_Sys_MEM_NbAllocs); -} -/* ----- */ -size_t PIC_GetMemAllocated(void) -{ - return(PIC_Sys_MEM_Allocated); -} - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -static unsigned char PIC_ErrorFlag; -static unsigned char PIC_ErrorString[PIC_ERRSIZE]; -static unsigned char PIC_Sys_FnctActive=0; -static void (*PIC_Sys_Fnct)(void); - -void Pic_SetError(const char *msg, ...) -{ - unsigned char curerr[PIC_ERRSIZE],olderr[PIC_ERRSIZE]; - va_list args; - - va_start(args,msg); - vsprintf(curerr,msg,args); - va_end(args); - if ( (strlen(curerr)+strlen(PIC_ErrorString))>PIC_ERRSIZE ) return; - - if (PIC_ErrorFlag) - { - strcpy(olderr,PIC_ErrorString); - sprintf(PIC_ErrorString,"--- [PIC#%03d] :\n%s",PIC_ErrorFlag,curerr); - strcat(PIC_ErrorString,"\n"); - strcat(PIC_ErrorString,olderr); - } - else - { - sprintf(PIC_ErrorString,"--- [PIC#%03d] :\n%s",PIC_ErrorFlag,curerr); - } - PIC_ErrorFlag++; - if (PIC_Sys_FnctActive) PIC_Sys_Fnct(); - return; -} -/* ----- */ -char* PIC_GetError(void) -{ - return(PIC_ErrorString); -} -/* ----- */ -unsigned char PIC_Error(void) -{ - return(PIC_ErrorFlag); -} -/* ----- */ -void PIC_ResetError(void) -{ - strcpy(PIC_ErrorString,""); - PIC_ErrorFlag=0; -} -/* ----- */ -unsigned char PIC_OnErrorCall( void pFnct(void) ) -{ - if (pFnct != NULL) - { - PIC_Sys_Fnct=pFnct; - PIC_Sys_FnctActive=1; - } - else - { - PIC_Sys_FnctActive=0; - } - return(1); -} - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - diff --git a/code/nel/tools/3d/tile_edit_qt/pic/Pic_BMP.c b/code/nel/tools/3d/tile_edit_qt/pic/Pic_BMP.c deleted file mode 100644 index 1119766da..000000000 --- a/code/nel/tools/3d/tile_edit_qt/pic/Pic_BMP.c +++ /dev/null @@ -1,215 +0,0 @@ -#include -#include -#include - -#include "pic_private.h" -#include "pic.h" - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -#pragma pack(1) -typedef struct BMP_HEADER -{ - unsigned short bfType; - unsigned long bfSize; - unsigned short Res1; - unsigned short Res2; - unsigned long bfOffBits; - unsigned long biSize; - unsigned long biWidth; - unsigned long biHeight; - unsigned short biPlanes; - unsigned short biBitCount; - unsigned long biCompression; - unsigned long biSizeImage; - unsigned long biXPelsPerMeter; - unsigned long biYPelsPerMeter; - unsigned long biClrUsed; - unsigned long biClrImportant; -} BMP_HEADER; -#pragma pack() - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -unsigned long Pic_BMP_Write( const char *FileName, - unsigned char *pPal,unsigned char *pDatas, - unsigned long w, unsigned long h, unsigned long d) - -{ - FILE *file; - BMP_HEADER bmph; - unsigned long slsize; - unsigned char *scanline; - unsigned long i; - long x,y,rest; - unsigned char r,g,b; - - file=fopen(FileName,"wb"); - if (!file) - { - return(0); - } - memset(&bmph,0,sizeof(BMP_HEADER)); - bmph.bfType=19778; - bmph.bfSize=sizeof(BMP_HEADER); - bmph.bfSize+=w*h*d/8; - if (pPal) - { - bmph.bfSize+=(256*4); - } - bmph.bfOffBits=sizeof(BMP_HEADER); - if (pPal) - { - bmph.bfOffBits+=(256*4); - } - bmph.biSize=40;/*sizeof(BMP_HEADER);*/ - bmph.biWidth=w; - bmph.biHeight=h; - bmph.biPlanes=1; - bmph.biBitCount=(unsigned short)d; - bmph.biCompression=0; - bmph.biSizeImage=w*h*d/8; - - fwrite(&bmph,1,sizeof(BMP_HEADER),file); - if (pPal) - { - for(i=0 ; i<256 ; i++) - { - fwrite(&pPal[i*3+0],1,1,file); - fwrite(&pPal[i*3+1],1,1,file); - fwrite(&pPal[i*3+2],1,1,file); - fwrite(&pPal[i*3+2],1,1,file); - } - } - slsize=w*d/8; - scanline=Pic_calloc(1,slsize); - if (!scanline) - { - Pic_SetError("BMP_Write, not enough memory for scanline"); - return(0); - } - for(rest=0 ; ((w*d/8)+rest)%4!=0 ; rest++); - for(y=0 ; y<(long)h ; y++) - { - memcpy(scanline,&pDatas[(h-y-1)*slsize],slsize); - if (d==24) - { - for(x=0 ; x<(long)w ; x++) - { - b=scanline[x*3+0]; - g=scanline[x*3+1]; - r=scanline[x*3+2]; - scanline[x*3+0]=b; - scanline[x*3+1]=g; - scanline[x*3+2]=r; - } - } - fwrite(scanline,1,slsize,file); - if (rest) - { - fwrite(scanline,1,rest,file); - } - } - Pic_free(scanline); - fclose(file); - return(1); -} - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -unsigned long Pic_BMP_Read( const char *FileName, - unsigned char **ppPal, unsigned char **ppDatas, - unsigned long *pWidth, unsigned long *pHeight, - unsigned long *pDepth) -{ - FILE *file; - BMP_HEADER bmph; - unsigned char *pPal; - unsigned char *pDatas; - unsigned char *scanline; - long w,h,d; - long i,x,y,rest; - unsigned char r,g,b; - unsigned char pad[4]; - - pPal=NULL; - pDatas=NULL; - file=fopen(FileName,"rb"); - if (!file) - { - Pic_SetError("BMP_Read, unable to open %s",FileName); - return(0); - } - fread(&bmph,1,sizeof(BMP_HEADER),file); - *pWidth=w=bmph.biWidth; - *pHeight=h=bmph.biHeight; - *pDepth=d=bmph.biBitCount; - if (d!=8 && d!=24) - { - Pic_SetError("BMP_Read, number of bits per pixel unsupported"); - return(0); - } - if (*pDepth==8) - { - pPal=Pic_calloc(1,256*3); - if (!pPal) - { - Pic_SetError("BMP_Read, not enough memory for palette"); - return(0); - } - for(i=0 ; i<256 ; i++) - { - fread(&pPal[i*3+2],1,1,file); - fread(&pPal[i*3+1],1,1,file); - fread(&pPal[i*3+0],1,1,file); - fread(&pad[0],1,1,file); - } - } - pDatas=Pic_calloc(1,w*h*d/8); - if (!pDatas) - { - if (pPal) - { - Pic_free(pPal); - } - Pic_SetError("BMP_Read, not enough memory for datas"); - return(0); - } - scanline=Pic_calloc(1,w*h*d/8); - if (!scanline) - { - if (pPal) - { - Pic_free(pPal); - } - Pic_free(pDatas); - Pic_SetError("BMP_Read, not enough memory for scanline"); - return(0); - } - for(rest=0 ; (w+rest)%4!=0 ; rest++); - for(y=0 ; y -#include -#include -#include - -#include "jpeglib.h" -#include "pic_private.h" -#include "pic.h" - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -struct my_error_mgr -{ - struct jpeg_error_mgr pub; - jmp_buf setjmp_buffer; -}; -typedef struct my_error_mgr * my_error_ptr; - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -static unsigned char error; - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -void my_error_exit(j_common_ptr cinfo) -{ - my_error_ptr myerr = (my_error_ptr) cinfo->err; - error=1; - longjmp(myerr->setjmp_buffer, 1); -} - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -unsigned long Pic_JPG_Read(const char *FileName, unsigned char **ppPal, unsigned char **ppDatas, unsigned long *w, unsigned long *h) -{ - struct jpeg_decompress_struct cinfo; - struct my_error_mgr jerr; - FILE *file; - JSAMPARRAY buffer; - int row_stride,i; - unsigned char *pDatas,*pPal; - unsigned long ptr; - - error=0; - ptr=0; - file=fopen(FileName, "rb"); - if (!file) - { - Pic_SetError("JPG_Read, unable to open %s",FileName); - return(0); - } - cinfo.err = jpeg_std_error(&jerr.pub); - jerr.pub.error_exit = my_error_exit; - setjmp(jerr.setjmp_buffer); - if (error) - { - Pic_SetError("JPG_Read, internal decompression error"); - jpeg_destroy_decompress(&cinfo); - return(0); - } - jpeg_create_decompress(&cinfo); - jpeg_stdio_src(&cinfo, file); - (void) jpeg_read_header(&cinfo, TRUE); - *w=cinfo.image_width; - *h=cinfo.image_height; - if (!ppPal) - { - pDatas=Pic_calloc(1,(*w)*(*h)*3); - } - else - { - pDatas=Pic_calloc(1,(*w)*(*h)); - pPal=Pic_calloc(1,256*3); - if (!pPal) - { - Pic_SetError("JPG_Read, not enough memory for palette"); - return(0); - } - cinfo.desired_number_of_colors = 256; - cinfo.quantize_colors = TRUE; - cinfo.dither_mode = JDITHER_ORDERED; - } - if (!pDatas) - { - Pic_SetError("JPG_Read, not enough memory for pic"); - return(0); - } - (void) jpeg_start_decompress(&cinfo); - row_stride = cinfo.output_width * cinfo.output_components; - buffer = (*cinfo.mem->alloc_sarray) - ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); - while (cinfo.output_scanline < cinfo.output_height) - { - (void) jpeg_read_scanlines(&cinfo, buffer, 1); - memcpy(&pDatas[ptr],buffer[0],row_stride); - ptr+=row_stride; - } - *ppDatas=pDatas; - if (ppPal) - { - for(i=0 ; i<256 ; i++) - { - pPal[i*3+0]=cinfo.colormap[2][i]; - pPal[i*3+1]=cinfo.colormap[1][i]; - pPal[i*3+2]=cinfo.colormap[0][i]; - } - *ppPal=pPal; - } - (void) jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - fclose(file); - return(1); -} - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -unsigned long Pic_JPG_Write(const char *FileName, unsigned long Qual, unsigned char *pDatas, unsigned long w, unsigned long h) -{ - struct jpeg_compress_struct cinfo; - struct my_error_mgr jerr; - FILE *file; - JSAMPROW row_pointer[1]; - int row_stride; - - error=0; - file=fopen(FileName,"wb"); - if (!file) - { - Pic_SetError("JPG_Write, unable to open %s",FileName); - return(0); - } - jpeg_create_compress(&cinfo); - cinfo.err = jpeg_std_error(&jerr.pub); - jerr.pub.error_exit = my_error_exit; - setjmp(jerr.setjmp_buffer); - if (error) - { - Pic_SetError("JPG_Write, internal compression error"); - jpeg_destroy_compress(&cinfo); - return(0); - } - jpeg_stdio_dest(&cinfo, file); - cinfo.image_width = w; - cinfo.image_height = h; - cinfo.input_components = 3; - cinfo.in_color_space = JCS_RGB; - jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, Qual, TRUE); - jpeg_start_compress(&cinfo, TRUE); - row_stride = w * 3; - while(cinfo.next_scanline -#include "pic_private.h" -#include "pic.h" - -static unsigned long NbPics=0; -static PIC_PICTURE *HeadPic=NULL; - -#ifdef __GNUC__ -#include - -char *strupr(char *string) -{ - char *s; - - if (string) - { - for (s = string; *s; ++s) - *s = toupper(*s); - } - return string; -} -#endif /* __GNUC__ */ - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -static PIC_PICTURE *GetPic(unsigned long id) -{ - PIC_PICTURE *pic; - - for(pic=HeadPic ; pic ; pic=pic->Next) - { - if (pic->ID==id) - { - return(pic); - } - } - return(NULL); -} - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -unsigned long PIC_Load(char* FileName, unsigned char Quantize) -{ - unsigned char ext[4]; - unsigned long type; - unsigned long i,taken,id; - PIC_PICTURE *pic; - unsigned char *pDatas; - unsigned char *pPal; - unsigned long w,h,Depth; - unsigned long ret; - - /* --- Init */ - - ret=0; - type=0; - id=0; - taken=0; - w=0; - h=0; - Depth=0; - pic=NULL; - pDatas=NULL; - pPal=NULL; - /* --- Get 1st available ID */ - for(i=1 ; i<=NbPics+1 ; i++) - { - taken=0; - for(pic=HeadPic ; pic ; pic=pic->Next) - { - if (pic->ID==i) - { - taken=1; - break; - } - } - if (!taken) - { - id=i; - break; - } - } - if (!id) - { - Pic_SetError("Load, unable to create ID"); - return(0); - } - /* --- Load pic */ - if (FileName) - { - ext[0]=FileName[strlen(FileName)-3]; - ext[1]=FileName[strlen(FileName)-2]; - ext[2]=FileName[strlen(FileName)-1]; - ext[3]=0; - strupr(ext); - if ( !strcmp(ext,"JPG") ) - { - type=1; - } - else if ( !strcmp(ext,"TGA") ) - { - type=2; - } - else if ( !strcmp(ext,"BMP") ) - { - type=3; - } - - switch(type) - { - /* - JPG */ - case 1: - if (!Quantize) - { - Depth=24; - ret=Pic_JPG_Read(FileName,NULL,&pDatas,&w,&h); - } - else - { - Depth=8; - ret=Pic_JPG_Read(FileName,&pPal,&pDatas,&w,&h); - } - if (!ret) - { - Pic_SetError("Load, unable to load JPG file %s",FileName); - return(0); - } - break; - /* - TGA */ - case 2: - ret=Pic_TGA_Read(FileName,&pPal,&pDatas,&w,&h,&Depth); - if (!ret) - { - Pic_SetError("Load, unable to load TGA file %s",FileName); - return(0); - } - break; - /* - BMP */ - case 3: - ret=Pic_BMP_Read(FileName,&pPal,&pDatas,&w,&h,&Depth); - if (!ret) - { - Pic_SetError("Load, unable to load BMP file %s",FileName); - return(0); - } - break; - /* - Unknown */ - default: - Pic_SetError("Load, unknown extension for %s",FileName); - return(0); - } - } - - /* --- Create and place new pic struct */ - pic=Pic_calloc(1,sizeof(PIC_PICTURE)); - if (!pic) - { - Pic_SetError("Load, not enough memory for internal structure"); - return(0); - } - pic->Next=HeadPic; - HeadPic=pic; - NbPics++; - pic->ID=id; - pic->pDatas=pDatas; - pic->pPal=pPal; - pic->Width=w; - pic->Height=h; - pic->Depth=Depth; - return(id); -} - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -unsigned long PIC_Create(unsigned char* pPal, unsigned char* pDatas, unsigned long w, unsigned long h, unsigned long d) -{ - unsigned long i,taken,id; - PIC_PICTURE *pic; - - /* --- Init */ - id=0; - taken=0; - pic=NULL; - /* --- Get 1st available ID */ - for(i=1 ; i<=NbPics+1 ; i++) - { - taken=0; - for(pic=HeadPic ; pic ; pic=pic->Next) - { - if (pic->ID==i) - { - taken=1; - break; - } - } - if (!taken) - { - id=i; - break; - } - } - if (!id) - { - Pic_SetError("Create, unable to create ID"); - return(0); - } - /* --- Create pic */ - if (!pDatas) - { - pDatas=Pic_calloc(1,w*h*d/8); - if (!pDatas) - { - Pic_SetError("Create, not enough memory for datas"); - return(0); - } - } - if (d==8) - { - if (!pPal) - { - pPal=Pic_calloc(1,256*3); - if (!pPal) - { - Pic_SetError("Create, not enough memory for palette"); - return(0); - } - } - } - else - { - pPal=NULL; - } - /* --- Create and place new pic struct */ - pic=Pic_calloc(1,sizeof(PIC_PICTURE)); - if (!pic) - { - Pic_SetError("Create, not enough memory for internal structure"); - return(0); - } - pic->Next=HeadPic; - HeadPic=pic; - NbPics++; - pic->ID=id; - pic->pDatas=pDatas; - pic->pPal=pPal; - pic->Width=w; - pic->Height=h; - pic->Depth=d; - return(id); - -} - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -unsigned long PIC_GetInfos( unsigned long id, - unsigned char* *ppPal, unsigned char* *ppDatas, - unsigned long *pW, unsigned long *pH, unsigned long *pD) -{ - PIC_PICTURE *pic; - - pic=GetPic(id); - if (!pic) - { - Pic_SetError("GetInfos, picture internal structure not found"); - return(0); - } - if (ppPal) - { - *ppPal=pic->pPal; - } - if (ppDatas) - { - *ppDatas=pic->pDatas; - } - if (pW) - { - *pW=pic->Width; - } - if (pH) - { - *pH=pic->Height; - } - if (pD) - { - *pD=pic->Depth; - } - return(id); -} - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -static char* Conv8To24(unsigned long id) -{ - PIC_PICTURE *pic; - unsigned char *buf; - unsigned long i; - - pic=GetPic(id); - if (!pic) - { - Pic_SetError("Conv8To24, picture internal structure not found"); - return(NULL); - } - buf=Pic_malloc(pic->Width*pic->Height*3); - if (!buf) - { - Pic_SetError("Conv8To24, not enough memory for temporary buffer"); - return(NULL); - } - for(i=0 ; iWidth*pic->Height ; i++) - { - buf[i*3+0]=pic->pPal[pic->pDatas[i]*3+0]; - buf[i*3+1]=pic->pPal[pic->pDatas[i]*3+1]; - buf[i*3+2]=pic->pPal[pic->pDatas[i]*3+2]; - } - return(buf); -} - -/* ---------------------------------------- */ -static char* Conv8To16(unsigned long id) -{ - PIC_PICTURE *pic; - unsigned short *buf; - unsigned long i; - unsigned short r,g,b,pix16; - - pic=GetPic(id); - if (!pic) - { - Pic_SetError("Conv8To24, picture internal structure not found"); - return(NULL); - } - buf=(unsigned short*)Pic_malloc(pic->Width*pic->Height*2); - if (!buf) - { - Pic_SetError("Conv8To24, not enough memory for temporary buffer"); - return(NULL); - } - for(i=0 ; iWidth*pic->Height ; i++) - { - b=pic->pPal[pic->pDatas[i]*3+0]; - g=pic->pPal[pic->pDatas[i]*3+1]; - r=pic->pPal[pic->pDatas[i]*3+2]; - r>>=3; - g>>=3; g&=0x3E; - b>>=3; - pix16=(r<<10)+(g<<5)+b; - buf[i]=pix16; - } - return((unsigned char*)buf); -} - -/* ---------------------------------------- */ - -static char* Conv16To24(unsigned long id) -{ - PIC_PICTURE *pic; - unsigned short *pDatas; - unsigned char *buf; - unsigned long i; - unsigned short r,g,b; - - pic=GetPic(id); - if (!pic) - { - Pic_SetError("Conv16To24, picture internal structure not found"); - return(NULL); - } - buf=Pic_malloc(pic->Width*pic->Height*3); - if (!buf) - { - Pic_SetError("Conv16To24, not enough memory for temporary buffer"); - return(NULL); - } - pDatas=(unsigned short*)pic->pDatas; - for(i=0 ; iWidth*pic->Height ; i++) - { - r=(pDatas[i] & 0x7C00)>>(10-3); - g=(pDatas[i] & 0x03E0)>>(5-3); - b=(pDatas[i] & 0x001F)<<3; - buf[i*3+0]=(unsigned char)r; - buf[i*3+1]=(unsigned char)g; - buf[i*3+2]=(unsigned char)b; - } - return(buf); -} - -/* ---------------------------------------- */ - -static char* Conv24To16(unsigned long id) -{ - PIC_PICTURE *pic; - unsigned short *buf; - unsigned long i; - unsigned short r,g,b; - unsigned short pix16; - - pic=GetPic(id); - if (!pic) - { - Pic_SetError("Conv24To16, picture internal structure not found"); - return(NULL); - } - buf=(unsigned short*)Pic_malloc(pic->Width*pic->Height*2); - if (!buf) - { - Pic_SetError("Conv24To16, not enough memory for temporary buffer"); - return(NULL); - } - for(i=0 ; iWidth*pic->Height ; i++) - { - r=pic->pDatas[i*3+0]; - g=pic->pDatas[i*3+1]; - b=pic->pDatas[i*3+2]; - /* r : 5 bits forts (0x7C) */ - /* g : 5 bits (6e zapped) (0x3E) */ - /* b : 5 bits faibles (0x1F) */ - r>>=3; - g>>=3; g&=0x3E; - b>>=3; - pix16=(r<<10)+(g<<5)+b; - buf[i]=pix16; - } - return((unsigned char*)buf); -} - -/* ---------------------------------------- */ - -static char* ConvPic(PIC_PICTURE *pic, unsigned long type, char* pErr) -{ - unsigned char *buf; - unsigned long src,dst; - - *pErr=0; - buf=NULL; - src=pic->Depth; - if (type==PIC_TYPE_TGA8 || type==PIC_TYPE_BMP8) - { - dst=8; - } - if (type==PIC_TYPE_TGA16) - { - dst=16; - } - if (type==PIC_TYPE_JPG || type==PIC_TYPE_TGA24 || type==PIC_TYPE_BMP24) - { - dst=24; - } - /* --- */ - if (src==dst) - { - return(NULL); - } - /* --- */ - if (src==8 && dst==24) - { - buf=Conv8To24(pic->ID); - if (!buf) - { - *pErr=1; - } - return(buf); - } - if (src==8 && dst==16) - { - buf=Conv8To16(pic->ID); - if (!buf) - { - *pErr=1; - } - return(buf); - } - /* --- */ - if (src==16 && dst==24) - { - buf=Conv16To24(pic->ID); - if (!buf) - { - *pErr=1; - } - return(buf); - } - /* --- */ - if (src==24 && dst==16) - { - buf=Conv24To16(pic->ID); - if (!buf) - { - *pErr=1; - } - return(buf); - } - /* --- */ - if (src==24 && dst==8) - { - Pic_SetError("ConvPic, downsampling 24 to 8 bits unsupported"); - *pErr=1; - return(NULL); - } - Pic_SetError("ConvPic, conversion %d to %d unsupported",src,dst); - *pErr=1; - return(NULL); -} - -/* ---------------------------------------- */ - -unsigned long PIC_Save(unsigned long id, const char* FileName, unsigned long type, unsigned long qual) -{ - PIC_PICTURE *pic; - unsigned char err; - unsigned char *buf; - unsigned char *freeit; - unsigned long depth; - - freeit=NULL; - pic=GetPic(id); - if (!pic) - { - Pic_SetError("Save %s, picture internal structure not found",FileName); - return(0); - } - freeit=ConvPic(pic,type,&err); - if (err) - { - Pic_SetError("Save %s, error while converting picture",FileName); - return(0); - } - if (!freeit) - { - buf=pic->pDatas; - } - else - { - buf=freeit; - } - err=0; - switch(type) - { - /* --- */ - case PIC_TYPE_JPG: - if ( !Pic_JPG_Write(FileName,qual,buf,pic->Width,pic->Height) ) - { - if (freeit) - { - Pic_free(buf); - } - Pic_SetError("Save %s, error while saving JPG file",FileName); - err=1; - } - break; - /* --- */ - case PIC_TYPE_TGA8: - case PIC_TYPE_TGA16: - case PIC_TYPE_TGA24: - if (type==PIC_TYPE_TGA8) - { - depth=8; - } - if (type==PIC_TYPE_TGA16) - { - depth=16; - } - if (type==PIC_TYPE_TGA24) - { - depth=24; - } - if ( !Pic_TGA_Write(FileName,pic->pPal,buf,pic->Width,pic->Height,depth) ) - { - if (freeit) - { - Pic_free(freeit); - } - Pic_SetError("Save %s, error while saving TGA file",FileName); - err=1; - } - break; - /* --- */ - case PIC_TYPE_BMP8: - case PIC_TYPE_BMP24: - if (type==PIC_TYPE_BMP8) - { - depth=8; - } - if (type==PIC_TYPE_BMP24) - { - depth=24; - } - if ( !Pic_BMP_Write(FileName,pic->pPal,buf,pic->Width,pic->Height,depth) ) - { - if (freeit) - { - Pic_free(freeit); - } - Pic_SetError("Save %s, error while saving BMP file",FileName); - err=1; - } - break; - /* --- */ - default: - Pic_SetError("Save %s, unknow save format/type",FileName); - err=1; - break; - } - if (freeit) - { - Pic_free(freeit); - } - return(err-1); -} - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -unsigned long PIC_Destroy(unsigned long id) -{ - PIC_PICTURE *prevpic,*pic; - unsigned long found; - - prevpic=NULL; - found=0; - for(pic=HeadPic ; pic ; pic=pic->Next) - { - if (pic->ID==id) - { - found=1; - break; - } - prevpic=pic; - } - if (!found) - { - Pic_SetError("Destroy, picture internal structure not found"); - return(0); - } - if (prevpic) - { - prevpic->Next=pic->Next; - } - if (pic->pDatas) - { - Pic_free(pic->pDatas); - } - if (pic->pPal) - { - Pic_free(pic->pPal); - } - if (pic==HeadPic) - { - HeadPic=pic->Next; - } - Pic_free(pic); - return(1); -} - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ diff --git a/code/nel/tools/3d/tile_edit_qt/pic/Pic_TGA.c b/code/nel/tools/3d/tile_edit_qt/pic/Pic_TGA.c deleted file mode 100644 index 4c458dc83..000000000 --- a/code/nel/tools/3d/tile_edit_qt/pic/Pic_TGA.c +++ /dev/null @@ -1,215 +0,0 @@ -#include -#include -#include - -#include "pic_private.h" -#include "pic.h" - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -#pragma pack(1) -typedef struct TGA_HEADER -{ - unsigned char LengthID; - unsigned char CMapType; - unsigned char ImageType; - unsigned short Origin; - unsigned short Length; - unsigned char Depth; - unsigned short XOrg; - unsigned short YOrg; - unsigned short Width; - unsigned short Height; - unsigned char ImageDepth; - unsigned char Desc; -} TGA_HEADER; -#pragma pack() - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -unsigned long Pic_TGA_Read( const char *FileName, - unsigned char **ppPal, unsigned char **ppDatas, - unsigned long *pWidth, unsigned long *pHeight, - unsigned long *pDepth) -{ - FILE *file; - TGA_HEADER tgah; - long w,h,d; - unsigned long size; - unsigned char *pDatas; - unsigned char *pPal; - long x,y; - long slsize; - unsigned char *scanline; - unsigned char r,g,b; - long i; - int upSideDown; - - pDatas=NULL; - pPal=NULL; - file=fopen(FileName,"rb"); - if (!file) - { - Pic_SetError("TGA_Read, unable to open %s",FileName); - return(0); - } - fread(&tgah,1,sizeof(TGA_HEADER),file); - if (tgah.ImageType>3) - { - Pic_SetError("TGA_Read, unsupported TGA format"); - return(0); - } - *pWidth=w=tgah.Width; - *pHeight=h=tgah.Height; - *pDepth=d=tgah.ImageDepth; - upSideDown = ((tgah.Desc & (1 << 5))==0); - - size=tgah.Width*tgah.Height*(tgah.ImageDepth/8); - pDatas=Pic_malloc(size); - if (!pDatas) - { - Pic_SetError("TGA_Read, not enough memory"); - return(0); - } - if (*pDepth==8) - { - if (!ppPal) - { - Pic_free(pDatas); - Pic_SetError("TGA_Read, need a pointer to palette"); - return(0); - } - pPal=Pic_calloc(1,256*3); - if (!pPal) - { - Pic_SetError("TGA_Read, not enough memory for palette"); - return(0); - } - if (tgah.ImageType==1) - { - for(i=0 ; i<256*3 ; i+=3) - { - fread(&pPal[i+2],1,1,file); - fread(&pPal[i+1],1,1,file); - fread(&pPal[i+0],1,1,file); - } - } - *ppPal=pPal; - } - - slsize=w*d/8; - scanline=Pic_calloc(1,slsize); - if (!scanline) - { - if (pPal) - { - Pic_free(pPal); - } - Pic_free(pDatas); - Pic_SetError("TGA_Read, not enough memory for scanline"); - return(0); - } - for(y=0 ; y8) - { - tgah.CMapType=0; - tgah.ImageType=2; - tgah.Length=0; - tgah.Depth=0; - } - else - { - tgah.CMapType=1; - tgah.ImageType=1; - tgah.Length=256; - tgah.Depth=24; - } - tgah.Origin=0; - tgah.XOrg=0; - tgah.YOrg=0; - tgah.Width=(unsigned short)w; - tgah.Height=(unsigned short)h; - tgah.ImageDepth=(unsigned char)d; - tgah.Desc=0; - fwrite(&tgah,1,sizeof(TGA_HEADER),file); - if (d==8) - { - fwrite(pPal,1,256*3,file); - } - slsize=w*d/8; - scanline=Pic_calloc(1,slsize); - if (!scanline) - { - Pic_SetError("TGA_Write, not enough memory for scanline"); - return(0); - } - for(y=0 ; y<(long)h ; y++) - { - memcpy(scanline,&pDatas[(h-y-1)*slsize],slsize); - if (d==24) - { - for(x=0 ; x<(long)w ; x++) - { - r=scanline[x*3+0]; - g=scanline[x*3+1]; - b=scanline[x*3+2]; - scanline[x*3+0]=b; - scanline[x*3+1]=g; - scanline[x*3+2]=r; - } - } - fwrite(scanline,1,slsize,file); - } - Pic_free(scanline); - fclose(file); - return(1); -} diff --git a/code/nel/tools/3d/tile_edit_qt/pic/pic.h b/code/nel/tools/3d/tile_edit_qt/pic/pic.h deleted file mode 100644 index cec5a0ff0..000000000 --- a/code/nel/tools/3d/tile_edit_qt/pic/pic.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef _PIC_H_ -#define _PIC_H_ -#ifdef __cplusplus -extern "C" { -#endif - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -#define PIC_TYPE_JPG 1 -#define PIC_TYPE_TGA8 2 -#define PIC_TYPE_TGA16 3 -#define PIC_TYPE_TGA24 4 -#define PIC_TYPE_BMP8 5 -#define PIC_TYPE_BMP24 6 - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -/* - * Basic API - */ -extern unsigned long PIC_Load(char* FileName, unsigned char Quantize); - -extern unsigned long PIC_Create(unsigned char* pPal, unsigned char* pDatas, unsigned long w, unsigned long h, unsigned long d); - -extern unsigned long PIC_Save(unsigned long id, const char* FileName, unsigned long type, unsigned long qual); - -extern unsigned long PIC_GetInfos( unsigned long id, - unsigned char* *ppPal, unsigned char* *ppDatas, - unsigned long *pW, unsigned long *pH, unsigned long *pD); - - -extern unsigned long PIC_Destroy(unsigned long id); -/* - * System - */ -extern unsigned long PIC_GetMemNbAllocs(void); -extern unsigned long PIC_GetMemAllocated(void); -extern char* PIC_GetError(void); -extern unsigned char PIC_Error(void); -extern void PIC_ResetError(void); -extern unsigned char PIC_OnErrorCall( void pFnct(void) ); - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -#ifdef __cplusplus -} -#endif -#endif diff --git a/code/nel/tools/3d/tile_edit_qt/pic/pic_private.h b/code/nel/tools/3d/tile_edit_qt/pic/pic_private.h deleted file mode 100644 index 96b7a0e94..000000000 --- a/code/nel/tools/3d/tile_edit_qt/pic/pic_private.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef _PIC_PRIVATE_H_ -#define _PIC_PRIVATE_H_ -#ifdef __cplusplus -extern "C" { -#endif - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -typedef struct PIC_PICTURE -{ - unsigned long ID; - unsigned long Width; - unsigned long Height; - unsigned long Depth; - unsigned char *pDatas; - unsigned char *pPal; - struct PIC_PICTURE *Next; -} PIC_PICTURE; - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - - -/* - * JPG - */ - - -extern unsigned long Pic_JPG_Read( const char *FileName, - unsigned char **ppPal, unsigned char **ppDatas, - unsigned long *w, unsigned long *h); - -extern unsigned long Pic_JPG_Write( const char *FileName, - unsigned long Qual, - unsigned char *pDatas, - unsigned long w, unsigned long h); -/* - * TGA - */ -extern unsigned long Pic_TGA_Read( const char *FileName, - unsigned char **ppPal, unsigned char **ppDatas, - unsigned long *pWidth, unsigned long *pHeight, - unsigned long *pDepth); -extern unsigned long Pic_TGA_Write( const char *FileName, - unsigned char *pPal,unsigned char *pDatas, - unsigned long w, unsigned long h, unsigned long d); -/* - * BMP - */ -extern unsigned long Pic_BMP_Read( const char *FileName, - unsigned char **ppPal, unsigned char **ppDatas, - unsigned long *pWidth, unsigned long *pHeight, - unsigned long *pDepth); - -extern unsigned long Pic_BMP_Write( const char *FileName, - unsigned char *pPal,unsigned char *pDatas, - unsigned long w, unsigned long h, unsigned long d); -/* - * System - */ -extern void* Pic_malloc(size_t size); -extern void* Pic_calloc(size_t count, size_t size); -extern void Pic_free(void *memblock); -extern size_t Pic__msize(void *memblock); -extern void Pic_SetError(const char *msg, ...); - -/* ---------------------------------------------------------------------------------------------------------------------------------- */ - -#ifdef __cplusplus -} -#endif -#endif diff --git a/code/nel/tools/3d/tile_edit_qt/pic/readpic.cpp b/code/nel/tools/3d/tile_edit_qt/pic/readpic.cpp deleted file mode 100644 index 078a8fa4b..000000000 --- a/code/nel/tools/3d/tile_edit_qt/pic/readpic.cpp +++ /dev/null @@ -1,68 +0,0 @@ - - -#include -#include -#include "readpic.h" -#include "pic.h" -#include - - -//============================================================ -// Image API. -//============================================================ - - -bool PIC_LoadPic(const std::string &path, std::vector &tampon, uint &Width, uint &Height) -{ - uint32 id; - unsigned char *pal, *data; - unsigned long w,h,depth; - uint i; - - - // Loadons l'image. - id= PIC_Load((char*)path.c_str(), 0); - if(id==0) - return false; - PIC_GetInfos( id, &pal, &data, &w, &h, &depth); - Width=w; - Height=h; - - // On traduit en RGBA. - tampon.resize(w*h); - switch(depth) - { - case 8: - for(i=0;i -#include -using namespace std; -#include -#include - -//============================================================ -// API. -//============================================================ - - -bool PIC_LoadPic(const std::string &Path, std::vector &tampon, uint &Width, uint &Height); - - - -#endif From af14cbe3aa6242137cad53c966ec8724effe938b Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 12:31:53 +0100 Subject: [PATCH 03/16] Fixed: Allow to select PNG and TGA for bitmaps --HG-- branch : develop --- code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp b/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp index d73a9a969..063b4cf47 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp +++ b/code/nel/tools/3d/tile_edit_qt/tile_browser_dlg.cpp @@ -210,7 +210,7 @@ void CTile_browser_dlg::on_actionAddTile_triggered(bool checked) { QFileDialog::Options options; QString selectedFilter; - QStringList fileNames = QFileDialog::getOpenFileNames(this, "Choose Bitmap", QString(tileBankBrowser.getAbsPath().c_str()) , "Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options); + QStringList fileNames = QFileDialog::getOpenFileNames(this, "Choose Bitmap", QString(tileBankBrowser.getAbsPath().c_str()) , "All supported files (*.png;*.tga);;PNG Bitmap (*.png);;Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options); qSort(fileNames.begin(), fileNames.end()); @@ -284,7 +284,7 @@ void CTile_browser_dlg::on_actionReplaceImage_triggered(bool checked) { QFileDialog::Options options; QString selectedFilter; - QString fileName = QFileDialog::getOpenFileName(this, "Choose Bitmap", QString(tileBankBrowser.getAbsPath().c_str()) , "Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options); + QString fileName = QFileDialog::getOpenFileName(this, "Choose Bitmap", QString(tileBankBrowser.getAbsPath().c_str()) , "All supported files (*.png;*.tga);;PNG Bitmap (*.png);;Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options); if (!fileName.isEmpty()) { @@ -396,7 +396,7 @@ void CTile_browser_dlg::on_batchLoadPushButton_clicked() { QFileDialog::Options options; QString selectedFilter; - QString fileName = QFileDialog::getOpenFileName(this, tr("Choose Bitmap"), QString(tileBankBrowser.getAbsPath().c_str()) , tr("Targa Bitmap (*.tga);;PNG Image (*.png);;All Files (*.*);;"), &selectedFilter, options); + QString fileName = QFileDialog::getOpenFileName(this, tr("Choose Bitmap"), QString(tileBankBrowser.getAbsPath().c_str()) , tr("All supported files (*.png;*.tga);;PNG Bitmap (*.png);;Targa Bitmap (*.tga);;All Files (*.*);;"), &selectedFilter, options); QFileInfo fi(fileName); QString baseName = fi.baseName() ; @@ -497,7 +497,7 @@ void CTile_browser_dlg::on_exportBorderPushButton_clicked() // Select a file QFileDialog::Options options; QString selectedFilter; - QString fileName = QFileDialog::getSaveFileName(this, tr("Choose Bitmap"), QString(tileBankBrowser.getAbsPath().c_str()) , "Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options); + QString fileName = QFileDialog::getSaveFileName(this, tr("Choose Bitmap"), QString(tileBankBrowser.getAbsPath().c_str()) , "All supported files (*.png;*.tga);;PNG Bitmap (*.png);;Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options); if (!fileName.isEmpty()) { @@ -568,7 +568,7 @@ void CTile_browser_dlg::on_importBorderPushButton_clicked() { QFileDialog::Options options; QString selectedFilter; - QString fileName = QFileDialog::getOpenFileName(this, tr("Choose Bitmap"), QString(tileBankBrowser.getAbsPath().c_str()) , "Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options); + QString fileName = QFileDialog::getOpenFileName(this, tr("Choose Bitmap"), QString(tileBankBrowser.getAbsPath().c_str()) , "All supported files (*.png;*.tga);;PNG Bitmap (*.png);;Targa Bitmap(*.tga);;All Files (*.*);;", &selectedFilter, options); if (!fileName.isEmpty()) { From ec7699aca927a3cb77e2f6eb91ede30c814c3339 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 12:33:05 +0100 Subject: [PATCH 04/16] Fixed: Compilation of object_viewer_qt with Qt 5 --HG-- branch : develop --- code/CMakeModules/nel.cmake | 19 ++++++---- .../object_viewer_widget/src/CMakeLists.txt | 36 +++++++++++-------- .../src/object_viewer_widget.cpp | 3 ++ .../3d/object_viewer_widget/src/stdpch.h | 28 ++++++++++++++- 4 files changed, 64 insertions(+), 22 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index f90c8215c..d54325fcb 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -181,13 +181,14 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) IF(WITH_QT) OPTION(WITH_STUDIO "Build Core Studio" OFF ) ENDIF(WITH_QT) - + ### # Features ### OPTION(WITH_LOGGING "With Logging" ON ) OPTION(WITH_COVERAGE "With Code Coverage Support" OFF) OPTION(WITH_PCH "With Precompiled Headers" ON ) + OPTION(WITH_LOW_MEMORY "With low memory (use the least of RAM)" OFF) OPTION(FINAL_VERSION "Build in Final Version mode" ON ) # Default to static building on Windows. @@ -226,7 +227,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) OPTION(WITH_INSTALL_LIBRARIES "Install development files." ON ) OPTION(WITH_ASSIMP "Use assimp exporter" OFF) - + ### # GUI toolkits ### @@ -295,10 +296,10 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) OPTION(WITH_LIBOVR "With LibOVR support" OFF) OPTION(WITH_LIBVR "With LibVR support" OFF) OPTION(WITH_PERFHUD "With NVIDIA PerfHUD support" OFF) - + OPTION(WITH_SSE2 "With SSE2" ON ) OPTION(WITH_SSE3 "With SSE3" ON ) - + IF(NOT MSVC) OPTION(WITH_GCC_FPMATH_BOTH "With GCC -mfpmath=both" OFF) ENDIF(NOT MSVC) @@ -373,7 +374,7 @@ MACRO(NL_SETUP_BUILD) ELSEIF(HOST_CPU MATCHES "i.86") SET(HOST_CPU "x86") ENDIF(HOST_CPU MATCHES "(amd|AMD)64") - + # Determine target CPU # If not specified, use the same CPU as host @@ -808,7 +809,11 @@ MACRO(NL_SETUP_BUILD) ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64") ENDIF(APPLE) - ADD_PLATFORM_FLAGS("-D_REENTRANT -pipe -fno-strict-aliasing") + ADD_PLATFORM_FLAGS("-D_REENTRANT -fno-strict-aliasing") + + IF(NOT WITH_LOW_MEMORY) + ADD_PLATFORM_FLAGS("-pipe") + ENDIF() IF(WITH_COVERAGE) ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage") @@ -1083,7 +1088,7 @@ MACRO(SETUP_EXTERNAL) ENDIF(APPLE) ENDIF(WIN32) - # Android and iOS have pthread + # Android and iOS have pthread IF(ANDROID OR IOS) SET(CMAKE_USE_PTHREADS_INIT 1) SET(Threads_FOUND TRUE) diff --git a/code/nel/tools/3d/object_viewer_widget/src/CMakeLists.txt b/code/nel/tools/3d/object_viewer_widget/src/CMakeLists.txt index 0943f61fa..49fc99f40 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_widget/src/CMakeLists.txt @@ -2,18 +2,32 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${LIBXML2_INCLUDE_DIR} - ${NEL_INCLUDE_DIR} - ${QT_INCLUDES}) + ${NEL_INCLUDE_DIR}) -INCLUDE( ${QT_USE_FILE} ) +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS}) FILE(GLOB OBJECT_VIEWER_WIDGET_SRC *.cpp *.h) SET(OBJECT_VIEWER_WIDGET_HDR object_viewer_widget.h) -SET(QT_USE_QTGUI TRUE) -SET(QT_USE_QTOPENGL TRUE) +IF(WITH_QT) + INCLUDE_DIRECTORIES(${QT_INCLUDES}) + INCLUDE(${QT_USE_FILE}) -QT4_WRAP_CPP( OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR} ) + SET(QT_USE_QTGUI TRUE) + SET(QT_USE_QTOPENGL TRUE) + + QT4_WRAP_CPP(OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR}) + + ADD_DEFINITIONS(${QT_DEFINITIONS}) + ADD_DEFINITIONS(-DQT_NO_KEYWORDS) + ADD_DEFINITIONS(-DQT_PLUGIN) + ADD_DEFINITIONS(-DQT_SHARED) + #ADD_DEFINITIONS(-DQT_NO_DEBUG) + + SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY}) +ELSE() + QT5_WRAP_CPP(OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR}) +ENDIF() SOURCE_GROUP(QtGeneratedMocSrc FILES ${OBJECT_VIEWER_WIDGET_MOC_SRCS}) @@ -24,19 +38,13 @@ ADD_LIBRARY(object_viewer_widget_qt MODULE TARGET_LINK_LIBRARIES(object_viewer_widget_qt nelmisc nel3d - ${QT_LIBRARIES} - ${QT_QTOPENGL_LIBRARY}) - -ADD_DEFINITIONS(-DQT_NO_KEYWORDS ${LIBXML2_DEFINITIONS} ${QT_DEFINITIONS}) -ADD_DEFINITIONS(-DQT_PLUGIN) -ADD_DEFINITIONS(-DQT_SHARED) -#ADD_DEFINITIONS(-DQT_NO_DEBUG) + ${QT_LIBRARIES}) NL_DEFAULT_PROPS(object_viewer_widget_qt "NeL, Tools, 3D: Object Viewer Qt Widget") NL_ADD_RUNTIME_FLAGS(object_viewer_widget_qt) IF(WITH_PCH) ADD_NATIVE_PRECOMPILED_HEADER(object_viewer_widget_qt ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.h ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.cpp) -ENDIF(WITH_PCH) +ENDIF() #INSTALL(TARGETS object_viewer_widget_qt RUNTIME DESTINATION ${NL_BIN_PREFIX} COMPONENT runtime BUNDLE DESTINATION /Applications) 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 4d0936a1a..83dec01e1 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 @@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include "stdpch.h" #include "object_viewer_widget.h" // STL includes @@ -46,7 +47,9 @@ along with this program. If not, see . // Project includes +#ifndef USE_QT5 Q_EXPORT_PLUGIN2(object_viewer_widget_qt, NLQT::CObjectViewerWidget) +#endif using namespace NLMISC; using namespace NL3D; 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 48bf018dc..34aaaa7d0 100644 --- a/code/nel/tools/3d/object_viewer_widget/src/stdpch.h +++ b/code/nel/tools/3d/object_viewer_widget/src/stdpch.h @@ -20,7 +20,32 @@ along with this program. If not, see . #ifndef NL_STDPCH_H #define NL_STDPCH_H -#include +#if defined(_MSC_VER) && defined(_DEBUG) + #define _CRTDBG_MAP_ALLOC + #include + #include + #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) + #undef realloc + #undef free +#endif + +#include + +#ifdef Q_COMPILER_RVALUE_REFS +#undef Q_COMPILER_RVALUE_REFS +#endif + +#include +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#define USE_QT5 +#endif + +#ifdef USE_QT5 +#include +#include +#endif #include #include @@ -28,6 +53,7 @@ along with this program. If not, see . #include #include +#include #include #endif From 75eb7cb922032d96e6e1aa5f198a4da56f348323 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 12:33:58 +0100 Subject: [PATCH 05/16] Changed: Compile tile_edit_qt and object_viewer_widget if WITH_QT5 is defined --HG-- branch : develop --- code/nel/tools/3d/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/nel/tools/3d/CMakeLists.txt b/code/nel/tools/3d/CMakeLists.txt index 4a7b8a997..bb35cbb5f 100644 --- a/code/nel/tools/3d/CMakeLists.txt +++ b/code/nel/tools/3d/CMakeLists.txt @@ -62,10 +62,10 @@ IF(WITH_NEL_TOOLS AND WITH_3D) ENDIF(MFC_FOUND) ENDIF(WIN32) - IF(WITH_QT) + IF(WITH_QT OR WITH_QT5) ADD_SUBDIRECTORY(tile_edit_qt) ADD_SUBDIRECTORY(object_viewer_widget) - ENDIF(WITH_QT) + ENDIF() IF(WITH_NEL_TOOLS) FIND_PACKAGE(Squish) From 03c9c93fc166a16b8fe5b2d49efd6c1f132dcdca Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 12:35:21 +0100 Subject: [PATCH 06/16] Changed: Comments to support DXTC1a for textures with one level of transparency later --HG-- branch : develop --- code/nel/tools/3d/s3tc_compressor_lib/s3tc_compressor.cpp | 1 + code/nel/tools/3d/tga_2_dds/tga2dds.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/code/nel/tools/3d/s3tc_compressor_lib/s3tc_compressor.cpp b/code/nel/tools/3d/s3tc_compressor_lib/s3tc_compressor.cpp index 1ffeabf77..74e89be1e 100644 --- a/code/nel/tools/3d/s3tc_compressor_lib/s3tc_compressor.cpp +++ b/code/nel/tools/3d/s3tc_compressor_lib/s3tc_compressor.cpp @@ -43,6 +43,7 @@ static void compressMipMap(uint8 *pixSrc, sint width, sint height, vector Date: Wed, 6 Jan 2016 12:38:10 +0100 Subject: [PATCH 07/16] Changed: Allow to debug Lua in FV too --HG-- branch : develop --- code/ryzom/client/src/client_cfg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index 5cdd2b860..76d730156 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -1813,8 +1813,8 @@ void CClientConfig::setValues() READ_BOOL_DEV(DamageShieldEnabled) - READ_BOOL_DEV(AllowDebugLua) - READ_BOOL_DEV(DisplayLuaDebugInfo) + READ_BOOL_FV(AllowDebugLua) + READ_BOOL_FV(DisplayLuaDebugInfo) READ_BOOL_DEV(LuaDebugInfoGotoButtonEnabled) READ_STRING_DEV(LuaDebugInfoGotoButtonTemplate) From 76744b18c76b06d69281af98714e44cac250f7cf Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 12:39:58 +0100 Subject: [PATCH 08/16] Changed: Minor change --HG-- branch : develop --- code/nel/include/nel/georges/u_form_elm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/include/nel/georges/u_form_elm.h b/code/nel/include/nel/georges/u_form_elm.h index ebb950429..6ec80938f 100644 --- a/code/nel/include/nel/georges/u_form_elm.h +++ b/code/nel/include/nel/georges/u_form_elm.h @@ -225,7 +225,7 @@ public: /// Returns the type of the atom. NULL otherwise. - virtual const class UType *getType () = 0; + virtual const class UType *getType () = 0; /// Return true if the element is an atom virtual bool isAtom () const = 0; From 6efce5ba59f23c5553e2004998d7c930fcfa3473 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 12:42:10 +0100 Subject: [PATCH 09/16] Changed: Support for new key events --HG-- branch : develop --- code/nel/include/nel/misc/events.h | 5 +++++ code/nel/src/misc/events.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/code/nel/include/nel/misc/events.h b/code/nel/include/nel/misc/events.h index e05ef3d2f..c783a85eb 100644 --- a/code/nel/include/nel/misc/events.h +++ b/code/nel/include/nel/misc/events.h @@ -212,6 +212,11 @@ enum TKey KeyRCONTROL =0xA3, KeyLMENU =0xA4, KeyRMENU =0xA5, + KeyMUTE =0xAD, + KeyPLAYPAUSE =0xB3, + KeyVOLUMEDOWN =0xB4, + KeyVOLUMEUP =0xB5, + KeyCALC =0xB7, KeySEMICOLON =0xBA, KeyEQUALS =0xBB, KeyCOMMA =0xBC, diff --git a/code/nel/src/misc/events.cpp b/code/nel/src/misc/events.cpp index daa651ed7..6f85c5f7e 100644 --- a/code/nel/src/misc/events.cpp +++ b/code/nel/src/misc/events.cpp @@ -159,6 +159,11 @@ static const CStringConversion::CPair stringTable [] = { "KeyRCONTROL", KeyRCONTROL }, { "KeyLMENU", KeyLMENU }, { "KeyRMENU", KeyRMENU }, + { "KeyMUTE", KeyMUTE }, + { "KeyPLAYPAUSE", KeyPLAYPAUSE }, + { "KeyVOLUMEDOWN", KeyVOLUMEDOWN }, + { "KeyVOLUMEUP", KeyVOLUMEUP }, + { "KeyCALC", KeyCALC }, { "KeySEMICOLON", KeySEMICOLON }, { "KeyEQUALS", KeyEQUALS }, { "KeyCOMMA", KeyCOMMA }, From f323974dba183627545042745ff0d3aee12824e8 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 12:43:57 +0100 Subject: [PATCH 10/16] Changed: Don't fix files within panoply_maker, use textures_optimizer (but checks can be enabled) --HG-- branch : develop --- .../tools/3d/panoply_maker/panoply_maker.cpp | 121 ++---------------- 1 file changed, 9 insertions(+), 112 deletions(-) diff --git a/code/nel/tools/3d/panoply_maker/panoply_maker.cpp b/code/nel/tools/3d/panoply_maker/panoply_maker.cpp index 2c50dfc83..5676bb89a 100644 --- a/code/nel/tools/3d/panoply_maker/panoply_maker.cpp +++ b/code/nel/tools/3d/panoply_maker/panoply_maker.cpp @@ -65,7 +65,7 @@ struct CBuildInfo TColorMaskVect ColorMasks; // how to shift right the size of the src Bitmap for the .hlsinfo uint LowDefShift; - uint OptimizeTextures; // 0 = don't optimize, 1 = check, 2 = optimize + uint OptimizeTextures; // 0 = don't check, 1 = check }; @@ -351,7 +351,7 @@ int main(int argc, char* argv[]) } catch (const NLMISC::EUnknownVar &) { - // don't optimize files by default + // don't check files by default bi.OptimizeTextures = 0; } } @@ -667,55 +667,12 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str throw NLMISC::Exception("Failed to load bitmap"); } - // if bitmap is RGBA but has an alpha channel fully transparent, + // if bitmap is RGBA but has an alpha channel fully opaque (255), // we can save it as RGB to optimize it - if (bi.OptimizeTextures > 0 && depth == 32) + uint8 value = 0; + if (bi.OptimizeTextures > 0 && depth == 32 && srcBitmap.isAlphaUniform(&value) && value == 255) { - uint8 value = 0; - - // texture can be converted if all alphas are 255 - if (srcBitmap.isAlphaUniform(&value) && value == 255) - { - if (bi.OptimizeTextures > 1) - { - // make bitmap opaque - srcBitmap.makeOpaque(); - - // original depth is now 24 bits, since we discarded alpha channel - depth = 24; - - NLMISC::COFile os; - - if (os.open(fullInputBitmapPath)) - { - nlwarning("Optimizing texture %s...", fullInputBitmapPath.c_str()); - - std::string ext = CFile::getExtension(fullInputBitmapPath); - - // resave the texture in optimized same format - if (ext == "png") - { - srcBitmap.writePNG(os, 24); - } - else if (ext == "tga") - { - srcBitmap.writeTGA(os, 24); - } - else - { - nlwarning("Don't support %s format for texture, unable to save it", ext.c_str()); - } - } - else - { - nlwarning("Unable to save texture %s", fullInputBitmapPath.c_str()); - } - } - else - { - nlwarning("Texture %s can be optimized", fullInputBitmapPath.c_str()); - } - } + nlwarning("Texture %s can be optimized, run textures_optimizer", fullInputBitmapPath.c_str()); } if (srcBitmap.PixelFormat != NLMISC::CBitmap::RGBA) @@ -794,36 +751,10 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str throw NLMISC::Exception("Failed to load mask"); } - // convert color mask to grayscale (red is the new gray value) - if (li.Mask.getPixelFormat() == CBitmap::RGBA) + // display a warning if checks enabled + if (li.Mask.getPixelFormat() == CBitmap::RGBA && bi.OptimizeTextures > 0 && !li.Mask.isGrayscale()) { - // display a warning if checks enabled - if (bi.OptimizeTextures > 0 && !li.Mask.isGrayscale()) - { - nlwarning("Mask %s is using colors, results may by incorrect! Use OptimizeTextures = 2 to fix it.", maskFileName.c_str()); - } - - // get a pointer on original data - uint32 size = li.Mask.getPixels().size(); - uint32 *data = (uint32*)li.Mask.getPixels().getPtr(); - uint32 *endData = (uint32*)((uint8*)data + size); - - NLMISC::CRGBA *color = NULL; - - // process all pixels - while(data < endData) - { - color = (NLMISC::CRGBA*)data; - - // copy red value to green and blue, - // because only red is used for mask - color->B = color->G = color->R; - - // make opaque - color->A = 255; - - ++data; - } + nlwarning("Mask %s is using colors, results may by incorrect! Run textures_optimizer to fix it.", maskFileName.c_str()); } // convert image to real grayscale @@ -832,40 +763,6 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str li.Mask.convertToType(NLMISC::CBitmap::Luminance); } - // masks can be converted to grayscale files - if (bi.OptimizeTextures > 0 && maskDepth > 8) - { - if (bi.OptimizeTextures > 1) - { - NLMISC::COFile os; - - if (os.open(maskFileName)) - { - std::string ext = NLMISC::toLower(CFile::getExtension(maskFileName)); - - nlwarning("Optimizing mask %s...", maskFileName.c_str()); - - // resave the texture in optimized same format - if (ext == "png") - { - li.Mask.writePNG(os, 8); - } - else if (ext == "tga") - { - li.Mask.writeTGA(os, 8); - } - else - { - nlwarning("Don't support %s format for mask, unable to save it", ext.c_str()); - } - } - } - else - { - nlwarning("Mask %s can be optimized", maskFileName.c_str()); - } - } - /// make sure the mask has the same size if (li.Mask.getWidth() != srcBitmap.getWidth() || li.Mask.getHeight() != srcBitmap.getHeight()) From a53ff71469b5a76a7a66af9fc741f25c94a848b4 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 13:05:49 +0100 Subject: [PATCH 11/16] Changed: Replace strlwr by toLower --HG-- branch : develop --- .../input_output_service/parameter_traits.cpp | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/code/ryzom/server/src/input_output_service/parameter_traits.cpp b/code/ryzom/server/src/input_output_service/parameter_traits.cpp index a0b45fcf7..5aad15a57 100644 --- a/code/ryzom/server/src/input_output_service/parameter_traits.cpp +++ b/code/ryzom/server/src/input_output_service/parameter_traits.cpp @@ -584,19 +584,17 @@ public: std::string op1; if (cond.Property == "name") { - op1 = si.SheetName; + op1 = NLMISC::toLower(si.SheetName); } else if (cond.Property == "gender") { - op1 = si.Gender; + op1 = NLMISC::toLower(GSGENDER::toString(si.Gender)); } else { return CParameterTraitsEntity::eval(lang,charInfo, cond); } - NLMISC::strlwr(op1); - LOG("SM : (creature) eval condition for property %s [%s] %s [%s]", cond.Property.c_str(), op1.c_str(), OperatorNames[cond.Operator], cond.ReferenceStr.c_str()); switch(cond.Operator) @@ -987,7 +985,7 @@ public: return false; } const CStringManager::TSheetInfo &si = SM->getSheetInfo(sheetId); - op1 = si.SheetName; + op1 = NLMISC::toLower(si.SheetName); } else if (cond.Property == "gender") { @@ -997,15 +995,13 @@ public: nlwarning("Could not find character info for EId %s to check property %s", EId.toString().c_str(), cond.Property.c_str()); return false; } - op1 = GSGENDER::toString(charInfo->getGender()); + op1 = NLMISC::toLower(GSGENDER::toString(charInfo->getGender())); } else { return CParameterTraitsEntity::eval(lang,charInfo, cond); } - NLMISC::strlwr(op1); - LOG("SM : (player) eval condition for property %s [%s] %s [%s]", cond.Property.c_str(), op1.c_str(), OperatorNames[cond.Operator], cond.ReferenceStr.c_str()); switch(cond.Operator) @@ -1085,14 +1081,14 @@ public: } else if (cond.Property == "role") { - op1 = si.ChatProfile; + op1 = NLMISC::toLower(si.ChatProfile); } else if (cond.Property == "title") { // we need to retrieve the charInfo CCharacterInfos *ci = IOS->getCharInfos(EId); if (ci != NULL) - op1 = ci->Title; + op1 = NLMISC::toLower(ci->Title); else { nlwarning("No character info for bot %s, can't test property 'title' !", EId.toString().c_str()); @@ -1104,8 +1100,6 @@ public: return CParameterTraitsEntity::eval(lang, charInfo, cond); } - NLMISC::strlwr(op1); - LOG("SM : (bot) eval condition for property %s [%s] %s [%s]", cond.Property.c_str(), op1.c_str(), OperatorNames[cond.Operator], cond.ReferenceStr.c_str()); switch(cond.Operator) @@ -1460,18 +1454,17 @@ public: // check if checked property is gender or name if (cond.Property == "gender") { - value = GSGENDER::toString(charInfo->getGender()); + value = NLMISC::toLower(GSGENDER::toString(charInfo->getGender())); } else if (cond.Property == "name") { - value = charInfo->ShortName.toString(); + value = NLMISC::toLower(charInfo->ShortName.toString()); } else { return CParameterTraitsEntity::eval(lang,charInfo, cond); } - NLMISC::strlwr(value); LOG("SM : (self) eval condition for property %s [%s] %s [%s]", cond.Property.c_str(), value.c_str(), OperatorNames[cond.Operator], cond.ReferenceStr.c_str()); switch(cond.Operator) From 92fe9a655457265f7fcdfb9cfc7e18517aebe2ac Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 13:14:29 +0100 Subject: [PATCH 12/16] Fixed: Compilation --HG-- branch : develop --- .../server/src/ai_service/ai_script_data_manager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/ryzom/server/src/ai_service/ai_script_data_manager.cpp b/code/ryzom/server/src/ai_service/ai_script_data_manager.cpp index 553372d51..d7b25129d 100644 --- a/code/ryzom/server/src/ai_service/ai_script_data_manager.cpp +++ b/code/ryzom/server/src/ai_service/ai_script_data_manager.cpp @@ -90,15 +90,15 @@ using namespace NLNET; -// Automatic SaveShardRoot path standardization +// Automatic SaveShardRootGameShare path standardization void cbOnSaveShardRootModified( NLMISC::IVariable& var ) { var.fromString( CPath::standardizePath( var.toString() ) ); } -// (SaveShardRoot from game_share/backup_service_interface.cpp is not instanciated because nothing is used from that file) -extern NLMISC::CVariable SaveShardRoot; +// (SaveShardRootGameShare from game_share/backup_service_interface.cpp is not instanciated because nothing is used from that file) +extern NLMISC::CVariable SaveShardRootGameShare; CVariable PdrFilename("ai", "PdrFilename", "Pdr file containing AIScript variables", string("ai_persistent_var.pdr"), 0, true); @@ -174,7 +174,7 @@ CAIScriptDataManager::~CAIScriptDataManager() std::string CAIScriptDataManager::dirname() { - return SaveShardRoot.get()+"/"+IService::getInstance()->SaveFilesDirectory.toString()+"/ai_script_data"; + return SaveShardRootGameShare.get()+"/"+IService::getInstance()->SaveFilesDirectory.toString()+"/ai_script_data"; } //CConfigFile* CAIScriptDataManager::createFile(string name) From f0bfd6264e3a9f57d6e1f287fe8e54d256c08c74 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 13:15:01 +0100 Subject: [PATCH 13/16] Fixed: Big endian number --HG-- branch : develop --- code/ryzom/client/src/r2/dmc/client_edition_module.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp index 8e2cb5695..073be77cc 100644 --- a/code/ryzom/client/src/r2/dmc/client_edition_module.cpp +++ b/code/ryzom/client/src/r2/dmc/client_edition_module.cpp @@ -1511,6 +1511,10 @@ bool CClientEditionModule::loadUserComponent(const std::string& filename, bool m nlwarning("Error while reading %s", filename.c_str()); } +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(uncompressedFileLength); +#endif + fclose(file); // Test if data are not too big From 80ae07c8b344e6b64b44a9de87d2491e02c13487 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 13:17:07 +0100 Subject: [PATCH 14/16] Changed: Minor changes --HG-- branch : develop --- code/nel/src/3d/ps_located.cpp | 2 +- code/nel/src/misc/sstring.cpp | 38 +++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/code/nel/src/3d/ps_located.cpp b/code/nel/src/3d/ps_located.cpp index 9be0baf41..5409f3480 100644 --- a/code/nel/src/3d/ps_located.cpp +++ b/code/nel/src/3d/ps_located.cpp @@ -2607,8 +2607,8 @@ CPSLocatedBindable *CPSLocated::unbind(uint index) CPSLocatedBindable *lb = _LocatedBoundCont[index]; lb->setOwner(NULL); _LocatedBoundCont.erase(_LocatedBoundCont.begin() + index); - return lb; CHECK_PS_INTEGRITY + return lb; } /// *************************************************************************************** diff --git a/code/nel/src/misc/sstring.cpp b/code/nel/src/misc/sstring.cpp index 833553f21..5f5702d01 100644 --- a/code/nel/src/misc/sstring.cpp +++ b/code/nel/src/misc/sstring.cpp @@ -17,6 +17,10 @@ #include "stdmisc.h" #include "nel/misc/sstring.h" +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + namespace NLMISC { @@ -225,14 +229,14 @@ namespace NLMISC return false; // iterate from size-2 to 1 - for (uint32 i=(uint32)size()-1; --i;) + for (uint i=(uint)size()-1; --i;) if (!isValidFileNameChar((*this)[i]) && (*this)[i]!=' ') return false; } else { // iterate from size-1 to 0 - for (uint32 i=(uint32)size(); i--;) + for (uint i=(uint)size(); i--;) if (!isValidFileNameChar((*this)[i])) return false; } @@ -253,7 +257,7 @@ namespace NLMISC return false; // iterate from size-1 to 1 - for (uint32 i=(uint32)size(); --i;) + for (uint i=(uint)size(); --i;) if (!isValidKeywordChar((*this)[i])) return false; @@ -489,9 +493,9 @@ namespace NLMISC CSString s=strip(); while(!s.empty()) { - uint32 pre=(uint32)s.size(); + uint pre=(uint)s.size(); result.push_back(s.firstWord(true)); - uint32 post=(uint32)s.size(); + uint post=(uint)s.size(); if (post>=pre) return false; } @@ -503,9 +507,9 @@ namespace NLMISC CSString s=*this; while(!s.empty()) { - uint32 pre=(uint32)s.size(); + uint pre=(uint)s.size(); result.push_back(s.firstWordOrWords(true,useSlashStringEscape,useRepeatQuoteStringEscape)); - uint32 post=(uint32)s.size(); + uint post=(uint)s.size(); if (post>=pre) return false; } @@ -520,8 +524,8 @@ namespace NLMISC if (s.contains('\r')) s=s.replace("\r",""); - uint32 it=0; - uint32 len= (uint32)s.size(); + uint it=0; + uint len= (uint)s.size(); while(it=pre) return false; } @@ -568,7 +572,7 @@ namespace NLMISC while(!s.empty()) { - uint32 pre=(uint32)s.size(); + uint pre=(uint)s.size(); result.push_back(s.splitToOneOfSeparators( separators,true,useAngleBrace,useSlashStringEscape, useRepeatQuoteStringEscape,!retainSeparators )); @@ -586,7 +590,7 @@ namespace NLMISC } } - uint32 post=(uint32)s.size(); + uint post=(uint)s.size(); if (post>=pre) return false; } @@ -716,7 +720,7 @@ namespace NLMISC for (i=0;i Date: Wed, 6 Jan 2016 13:19:48 +0100 Subject: [PATCH 15/16] Changed: Code simplification --HG-- branch : develop --- code/nel/src/misc/bitmap.cpp | 38 +++++++++--------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index 67557b5cf..00cf7c293 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -2599,7 +2599,7 @@ uint8 CBitmap::readTGA( NLMISC::IStream &f) case 10: { uint8 packet; - uint8 pixel[4]; + uint8 pixel[4] = {0}; uint32 imageSize = width*height; uint32 readSize = 0; uint8 upSideDown = ((desc & (1 << 5))==0); @@ -2617,20 +2617,10 @@ uint8 CBitmap::readTGA( NLMISC::IStream &f) } for (i=0; i < (packet & 0x7F) + 1; i++) { - if(imageDepth==32) - { - _Data[0][dstId++]= pixel[2]; - _Data[0][dstId++]= pixel[1]; - _Data[0][dstId++]= pixel[0]; - _Data[0][dstId++]= pixel[3]; - } - if(imageDepth==24) - { - _Data[0][dstId++]= pixel[2]; - _Data[0][dstId++]= pixel[1]; - _Data[0][dstId++]= pixel[0]; - _Data[0][dstId++]= 0; - } + _Data[0][dstId++]= pixel[2]; + _Data[0][dstId++]= pixel[1]; + _Data[0][dstId++]= pixel[0]; + _Data[0][dstId++]= pixel[3]; } } else // packet Raw @@ -2641,20 +2631,10 @@ uint8 CBitmap::readTGA( NLMISC::IStream &f) { f.serial(pixel[j]); } - if(imageDepth==32) - { - _Data[0][dstId++]= pixel[2]; - _Data[0][dstId++]= pixel[1]; - _Data[0][dstId++]= pixel[0]; - _Data[0][dstId++]= pixel[3]; - } - if(imageDepth==24) - { - _Data[0][dstId++]= pixel[2]; - _Data[0][dstId++]= pixel[1]; - _Data[0][dstId++]= pixel[0]; - _Data[0][dstId++]= 0; - } + _Data[0][dstId++]= pixel[2]; + _Data[0][dstId++]= pixel[1]; + _Data[0][dstId++]= pixel[0]; + _Data[0][dstId++]= pixel[3]; } } readSize += (packet & 0x7F) + 1; From ecb47bc2dc4b879d716ce0d54656736b0565abf7 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 6 Jan 2016 13:21:47 +0100 Subject: [PATCH 16/16] Changed: Remove unused variable --HG-- branch : develop --- code/nel/src/misc/bitmap.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index 00cf7c293..60ca9a752 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -2376,7 +2376,6 @@ uint8 CBitmap::readTGA( NLMISC::IStream &f) if(!f.isReading()) return 0; - uint32 size; uint32 x,y; sint32 slsize; uint8 *scanline; @@ -2452,7 +2451,6 @@ uint8 CBitmap::readTGA( NLMISC::IStream &f) _Width = width; _Height = height; - size = _Width * _Height * (imageDepth/8); switch(imageType) {