Merge branch 'feature/merge_ryzomcore170417' into 'develop'

Feature/merge ryzomcore170417

Closes #16, #18, #5, #3, #2, and #1

See merge request !30
This commit is contained in:
deed 2017-04-01 18:43:34 +02:00
commit 90d9f6da6c
2497 changed files with 27299 additions and 17024 deletions

View file

@ -19,7 +19,7 @@ Linux client build:
- echo "deb http://ftp.debian.org/debian/ jessie-backports non-free contrib main" >> /etc/apt/sources.list - echo "deb http://ftp.debian.org/debian/ jessie-backports non-free contrib main" >> /etc/apt/sources.list
- apt-get update - apt-get update
- apt-get -y upgrade - apt-get -y upgrade
- apt-get -t jessie-backports install libxml2 -y g++ gcc cmake libcurl4-openssl-dev libgl1-mesa-dev libjpeg-dev libpng-dev libopenal-dev libfreetype6-dev libxxf86vm-dev libxrandr-dev libxrender-dev libvorbis-dev libluabind-dev libboost-dev libmysqlclient-dev libssl-dev liblzma-dev libxml2-dev makeself - apt-get -t jessie-backports install libxml2 -y g++ gcc cmake libcurl4-openssl-dev libgl1-mesa-dev libjpeg-dev libpng-dev libopenal-dev libfreetype6-dev libxxf86vm-dev libxrandr-dev libxrender-dev libvorbis-dev libluabind-dev libboost-dev libmysqlclient-dev libssl-dev liblzma-dev libxml2-dev makeself libgif-dev
# Installation des dépendances des dépendances statiques (à commenter si construction de Khanat en mode dynamique) # Installation des dépendances des dépendances statiques (à commenter si construction de Khanat en mode dynamique)
# libxml2 : python-pyicu (support d'unicode), python-dev (support de... python) # libxml2 : python-pyicu (support d'unicode), python-dev (support de... python)
- apt-get install -y wget python-pyicu python-dev - apt-get install -y wget python-pyicu python-dev

View file

@ -1,9 +1,9 @@
# Ryzom Core [![Build Status](https://travis-ci.org/ryzom/ryzomcore.svg)](https://travis-ci.org/ryzom/ryzomcore) # Ryzom Core [![Build Status](https://travis-ci.org/ryzom/ryzomcore.svg)](https://travis-ci.org/ryzom/ryzomcore)
Ryzom Core is the open-source project related to Ryzom Game. Written in C++, Ryzom Core contains the whole code (client, server, tools) used to make the commercial MMORPG Ryzom. Ryzom Core is a toolkit for the development of massively multiplayer online universes. It provides the base technologies and a set of development methodologies for the development of both client and server code. Ryzom Core is the open-source project related to Ryzom Game. Written in C++, Ryzom Core contains the whole code (client, server, tools) used to make the commercial MMORPG Ryzom. Ryzom Core is a toolkit for the development of massively multiplayer online universes. It provides the base technologies and a set of development methodologies for the development of both client and server code.
Ryzom Core is open source and released under the terms of the GNU Affero General Public License 3.0 (GNU/AGPLv3) for the source code and the Creative Commons Attributions-ShareAlike 3.0 (CC-BY-SA) for the art assets. Which means you can create your own game using Ryzom Core, for more information on doing so check out Creating Your Own Game Using Ryzom Core. Ryzom Core is open source and released under the terms of the GNU Affero General Public License 3.0 (GNU/AGPLv3) for the source code and the Creative Commons Attributions-ShareAlike 3.0 (CC-BY-SA) for the art assets. Which means you can create your own game using Ryzom Core, for more information on doing so check out Creating Your Own Game Using Ryzom Core.
Modification par la Team Khaganat Modification par la Team Khaganat

View file

@ -63,10 +63,9 @@ SET(NL_VERSION_PATCH 0)
SET(YEAR "2004-${CURRENT_YEAR}") SET(YEAR "2004-${CURRENT_YEAR}")
SET(AUTHOR "Winch Gate and The Ryzom Core Community") SET(AUTHOR "Winch Gate and The Ryzom Core Community")
SET(RYZOM_VERSION_MAJOR 2) SET(RYZOM_VERSION_MAJOR 3)
SET(RYZOM_VERSION_MINOR 9) SET(RYZOM_VERSION_MINOR 1)
SET(RYZOM_VERSION_PATCH 0) SET(RYZOM_VERSION_PATCH 0)
SET(REVISION 0)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Redirect output files # Redirect output files

View file

@ -18,6 +18,7 @@ FIND_PATH(MAXSDK_DIR
PATHS PATHS
"$ENV{ADSK_3DSMAX_SDK_2012}/maxsdk" "$ENV{ADSK_3DSMAX_SDK_2012}/maxsdk"
"$ENV{3DSMAX_2011_SDK_PATH}/maxsdk" "$ENV{3DSMAX_2011_SDK_PATH}/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2017 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2010 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2009 SDK/maxsdk"
"$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk" "$ENV{PROGRAMFILES}/Autodesk/3ds Max 2008 SDK/maxsdk"
@ -36,12 +37,12 @@ FIND_PATH(MAXSDK_CS_INCLUDE_DIR bipexp.h
) )
IF(TARGET_X64) IF(TARGET_X64)
SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/x64/lib) SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/x64/lib ${MAXSDK_DIR}/lib/x64/Release)
ELSE() ELSE()
SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/lib) SET(MAXSDK_LIBRARY_DIRS ${MAXSDK_DIR}/lib)
ENDIF() ENDIF()
MACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME) MACRO(FIND_3DS_LIBRARY MYLIBRARY MYLIBRARYNAME)
FIND_LIBRARY(${MYLIBRARY} FIND_LIBRARY(${MYLIBRARY}
NAMES ${MYLIBRARYNAME} NAMES ${MYLIBRARYNAME}
HINTS HINTS
@ -73,8 +74,26 @@ if(MAXSDK_FOUND)
${MAXSDK_MAXUTIL_LIBRARY} ${MAXSDK_MAXUTIL_LIBRARY}
${MAXSDK_MAXSCRIPT_LIBRARY} ${MAXSDK_MAXSCRIPT_LIBRARY}
${MAXSDK_PARAMBLK2_LIBRARY} ${MAXSDK_PARAMBLK2_LIBRARY}
${MAXSDK_BMM_LIBRARY} ) ${MAXSDK_BMM_LIBRARY})
# parse maxversion.h to determine SDK version
IF(EXISTS "${MAXSDK_DIR}/include/maxversion.h")
FILE(STRINGS "${MAXSDK_DIR}/include/maxversion.h" LINES REGEX "#define MAX_PRODUCT_YEAR_NUMBER ([0-9]+)")
STRING(REGEX REPLACE ".+MAX_PRODUCT_YEAR_NUMBER ([0-9]+)" "\\1" MAXSDK_VERSION "${LINES}")
UNSET(LINES)
ELSE()
SET(MAXSDK_VERSION "Unknown")
ENDIF()
MESSAGE(STATUS "Found 3dsmax version ${MAXSDK_VERSION} in ${MAXSDK_DIR}")
# 3ds Max 2013 and later are always Unicode
IF(MAXSDK_VERSION VERSION_GREATER 2012)
SET(MAXSDK_DEFINITIONS -DUNICODE -D_UNICODE)
ELSE()
SET(MAXSDK_DEFINITIONS)
ENDIF()
ELSE() ELSE()
set(MAXSDK_LIBRARIES) set(MAXSDK_LIBRARIES)
ENDIF() ENDIF()

View file

@ -41,7 +41,7 @@ IF(MFC_FOUND)
LINK_DIRECTORIES(${MFC_LIBRARY_DIR}) LINK_DIRECTORIES(${MFC_LIBRARY_DIR})
# Set definitions for using MFC in DLL # Set definitions for using MFC in DLL
SET(MFC_DEFINITIONS -D_AFXDLL) SET(MFC_DEFINITIONS -D_AFXDLL -DUNICODE -D_UNICODE)
# Set CMake flag to use MFC DLL # Set CMake flag to use MFC DLL
SET(CMAKE_MFC_FLAG 2) SET(CMAKE_MFC_FLAG 2)

View file

@ -55,7 +55,15 @@ MACRO(DETECT_EXPRESS_VERSION _VERSION)
ENDIF() ENDIF()
ENDMACRO() ENDMACRO()
IF(MSVC12) IF(MSVC14)
DETECT_VC_VERSION("14.0")
SET(MSVC_TOOLSET "140")
IF(NOT MSVC14_REDIST_DIR)
# If you have VC++ 2015 Express, put x64/Microsoft.VC140.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC14_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF()
ELSEIF(MSVC12)
DETECT_VC_VERSION("12.0") DETECT_VC_VERSION("12.0")
SET(MSVC_TOOLSET "120") SET(MSVC_TOOLSET "120")
@ -98,7 +106,7 @@ IF(NOT VC_DIR)
ELSE() ELSE()
SET(_COMPILER ${CMAKE_C_COMPILER}) SET(_COMPILER ${CMAKE_C_COMPILER})
ENDIF() ENDIF()
STRING(REGEX REPLACE "/bin/.+" "" VC_DIR ${_COMPILER}) STRING(REGEX REPLACE "/(bin|BIN|Bin)/.+" "" VC_DIR ${_COMPILER})
ENDIF() ENDIF()
SET(VC_INCLUDE_DIR "${VC_DIR}/include") SET(VC_INCLUDE_DIR "${VC_DIR}/include")

View file

@ -60,12 +60,12 @@ IF(Mercurial_HG_EXECUTABLE)
EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} --version EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} --version
OUTPUT_VARIABLE Mercurial_VERSION_HG OUTPUT_VARIABLE Mercurial_VERSION_HG
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING(REGEX REPLACE ".*version ([\\.0-9]+).*" STRING(REGEX REPLACE ".*version ([\\.0-9]+).*"
"\\1" Mercurial_VERSION_HG "${Mercurial_VERSION_HG}") "\\1" Mercurial_VERSION_HG "${Mercurial_VERSION_HG}")
MACRO(Mercurial_WC_INFO dir prefix) MACRO(Mercurial_WC_INFO dir prefix)
EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} tip --template "{rev};{node};{tags};{author}" EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} log -r . --template "{rev};{node};{tags};{author}"
WORKING_DIRECTORY ${dir} WORKING_DIRECTORY ${dir}
OUTPUT_VARIABLE ${prefix}_WC_INFO OUTPUT_VARIABLE ${prefix}_WC_INFO
ERROR_VARIABLE Mercurial_hg_info_error ERROR_VARIABLE Mercurial_hg_info_error
@ -73,7 +73,7 @@ IF(Mercurial_HG_EXECUTABLE)
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(NOT ${Mercurial_hg_info_result} EQUAL 0) IF(NOT ${Mercurial_hg_info_result} EQUAL 0)
MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} tip\" failed with output:\n${Mercurial_hg_info_error}") MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} log\" failed with output:\n${Mercurial_hg_info_error}")
ELSE() ELSE()
LIST(LENGTH ${prefix}_WC_INFO _COUNT) LIST(LENGTH ${prefix}_WC_INFO _COUNT)
IF(_COUNT EQUAL 4) IF(_COUNT EQUAL 4)

View file

@ -255,8 +255,19 @@ MACRO(USE_CURRENT_WINSDK)
SET(WINSDK_VERSION "6.0A") SET(WINSDK_VERSION "6.0A")
ENDIF() ENDIF()
ELSEIF(MSVC80) ELSEIF(MSVC80)
IF(NOT MSVC_EXPRESS) SET(WINSDK_MSVC80_COMPATIBLES "7.1" "7.1A" "7.0" "7.0A" "6.1" "6.0" "6.0A" "5.2A")
# TODO: fix this version
# look for each Windows SDK supported by VC++ 2005 (7.1 is the latest)
FOREACH(_VERSION ${WINSDK_DETECTED_VERSIONS})
# look if this version of Windows SDK is installed
LIST(FIND WINSDK_MSVC80_COMPATIBLES ${_VERSION} _FOUND)
IF(NOT _FOUND EQUAL -1)
SET(WINSDK_VERSION "${_VERSION}")
BREAK()
ENDIF()
ENDFOREACH()
IF(NOT MSVC_EXPRESS AND NOT WINSDK_VERSION)
SET(WINSDK_VERSION "5.2A") SET(WINSDK_VERSION "5.2A")
ENDIF() ENDIF()
ELSE() ELSE()
@ -441,8 +452,8 @@ IF(WINSDK_INCLUDE_DIR)
SET(CMAKE_LIBRARY_PATH ${WINSDK_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH}) SET(CMAKE_LIBRARY_PATH ${WINSDK_LIBRARY_DIR} ${CMAKE_LIBRARY_PATH})
# Fix for using Windows SDK 7.1 with Visual C++ 2012 # Fix for using Windows SDK 7.1 with Visual C++ 2012, 2013 and 2015
IF(WINSDK_VERSION STREQUAL "7.1" AND MSVC11) IF(WINSDK_VERSION STREQUAL "7.1" AND (MSVC11 OR MSVC12 OR MSVC14))
ADD_DEFINITIONS(-D_USING_V110_SDK71_) ADD_DEFINITIONS(-D_USING_V110_SDK71_)
ENDIF() ENDIF()
ELSE() ELSE()

View file

@ -27,6 +27,16 @@ ELSE()
ENDIF() ENDIF()
ENDIF() ENDIF()
MACRO(APPEND_DEFINITION _NAME _VAL)
IF(CMAKE_VERSION VERSION_LESS "2.8.12")
# don't support logical expressions, append definition
LIST(APPEND ${_NAME} "-D${_VAL}")
ELSE()
# support logical expressions, use them
LIST(APPEND ${_NAME} "$<$<BOOL:${_VAL}>:-D$<JOIN:${_VAL},-D>>")
ENDIF()
ENDMACRO()
# Set PCH_FLAGS for common flags, PCH_ARCH_XXX_FLAGS for specific archs flags and PCH_ARCHS for archs # Set PCH_FLAGS for common flags, PCH_ARCH_XXX_FLAGS for specific archs flags and PCH_ARCHS for archs
MACRO(PCH_SET_COMPILE_FLAGS _target) MACRO(PCH_SET_COMPILE_FLAGS _target)
SET(PCH_FLAGS) SET(PCH_FLAGS)
@ -77,28 +87,28 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS) GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS)
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>") APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item})
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD}) GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>") APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item})
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS) GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS)
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>") APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item})
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS_${_UPPER_BUILD}) GET_DIRECTORY_PROPERTY(DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>") APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item})
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
@ -122,14 +132,14 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS) GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS)
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>") APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item})
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS_${_UPPER_BUILD}) GET_TARGET_PROPERTY(DEFINITIONS ${_target} COMPILE_DEFINITIONS_${_UPPER_BUILD})
IF(DEFINITIONS) IF(DEFINITIONS)
FOREACH(item ${DEFINITIONS}) FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>") APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item})
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
@ -151,7 +161,7 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
IF(_DEFINITIONS) IF(_DEFINITIONS)
FOREACH(item ${_DEFINITIONS}) FOREACH(item ${_DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS "$<$<BOOL:${item}>:-D$<JOIN:${item},-D>>") APPEND_DEFINITION(GLOBAL_DEFINITIONS ${item})
ENDFOREACH() ENDFOREACH()
ENDIF() ENDIF()
ENDIF() ENDIF()
@ -176,10 +186,23 @@ MACRO(PCH_SET_COMPILE_FLAGS _target)
ENDIF() ENDIF()
IF(CMAKE_VERSION VERSION_LESS "3.3.0") IF(CMAKE_VERSION VERSION_LESS "3.3.0")
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS) GET_DIRECTORY_PROPERTY(_DIRECTORY_FLAGS DEFINITIONS)
GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
LIST(APPEND _FLAGS ${_directory_flags}) IF(_DIRECTORY_FLAGS)
LIST(APPEND _FLAGS ${_directory_definitions}) SEPARATE_ARGUMENTS(_DIRECTORY_FLAGS)
FOREACH(item ${_DIRECTORY_FLAGS})
LIST(APPEND _FLAGS "${item}")
ENDFOREACH()
ENDIF()
GET_DIRECTORY_PROPERTY(_DIRECTORY_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
IF(_DIRECTORY_DEFINITIONS)
SEPARATE_ARGUMENTS(_DIRECTORY_DEFINITIONS)
FOREACH(item ${_DIRECTORY_DEFINITIONS})
LIST(APPEND _FLAGS "${item}")
ENDFOREACH()
ENDIF()
ENDIF() ENDIF()
# Format definitions # Format definitions
@ -282,8 +305,9 @@ MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS)
ENDIF() ENDIF()
IF(MSVC) IF(MSVC)
GET_PDB_FILENAME(PDB_FILE ${_PCH_current_target}) GET_PDB_FILENAME(_PDB_FILE ${_PCH_current_target})
SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj") SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${_PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj")
# Ninja PCH Support # Ninja PCH Support
# http://public.kitware.com/pipermail/cmake-developers/2012-March/003653.html # http://public.kitware.com/pipermail/cmake-developers/2012-March/003653.html
SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES OBJECT_OUTPUTS "${PCH_OUTPUT}.obj") SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES OBJECT_OUTPUTS "${PCH_OUTPUT}.obj")

View file

@ -367,7 +367,11 @@ ENDMACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
MACRO(ADD_PLATFORM_FLAGS _FLAGS) MACRO(ADD_PLATFORM_FLAGS _FLAGS)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} ${_FLAGS}") SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} ${_FLAGS}")
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${_FLAGS}") SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${_FLAGS}")
ENDMACRO(ADD_PLATFORM_FLAGS) ENDMACRO()
MACRO(ADD_PLATFORM_LINKFLAGS _FLAGS)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${_FLAGS}")
ENDMACRO()
MACRO(NL_SETUP_BUILD) MACRO(NL_SETUP_BUILD)
@ -390,9 +394,13 @@ MACRO(NL_SETUP_BUILD)
ENDIF() ENDIF()
ENDIF() ENDIF()
SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR}) IF(CMAKE_CXX_LIBRARY_ARCHITECTURE)
SET(HOST_CPU ${CMAKE_CXX_LIBRARY_ARCHITECTURE})
ELSE()
SET(HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR})
ENDIF()
IF(HOST_CPU MATCHES "(amd|AMD)64") IF(HOST_CPU MATCHES "(amd|AMD|x86_)64")
SET(HOST_CPU "x86_64") SET(HOST_CPU "x86_64")
ELSEIF(HOST_CPU MATCHES "i.86") ELSEIF(HOST_CPU MATCHES "i.86")
SET(HOST_CPU "x86") SET(HOST_CPU "x86")
@ -402,10 +410,10 @@ MACRO(NL_SETUP_BUILD)
# If not specified, use the same CPU as host # If not specified, use the same CPU as host
IF(NOT TARGET_CPU) IF(NOT TARGET_CPU)
SET(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR}) SET(TARGET_CPU ${HOST_CPU})
ENDIF() ENDIF()
IF(TARGET_CPU MATCHES "(amd|AMD)64") IF(TARGET_CPU MATCHES "(amd|AMD|x86_)64")
SET(TARGET_CPU "x86_64") SET(TARGET_CPU "x86_64")
ELSEIF(TARGET_CPU MATCHES "i.86") ELSEIF(TARGET_CPU MATCHES "i.86")
SET(TARGET_CPU "x86") SET(TARGET_CPU "x86")
@ -413,7 +421,7 @@ MACRO(NL_SETUP_BUILD)
IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
SET(CLANG ON) SET(CLANG ON)
MESSAGE(STATUS "Using Clang compiler") MESSAGE(STATUS "Using Clang ${CMAKE_CXX_COMPILER_VERSION} compiler")
ENDIF() ENDIF()
IF(CMAKE_GENERATOR MATCHES "Xcode") IF(CMAKE_GENERATOR MATCHES "Xcode")
@ -426,6 +434,11 @@ MACRO(NL_SETUP_BUILD)
MESSAGE(STATUS "Generating NMake project") MESSAGE(STATUS "Generating NMake project")
ENDIF() ENDIF()
IF(CMAKE_GENERATOR MATCHES "Ninja")
SET(NINJA ON)
MESSAGE(STATUS "Generating Ninja project")
ENDIF()
# If target and host CPU are the same # If target and host CPU are the same
IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING) IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING)
# x86-compatible CPU # x86-compatible CPU
@ -474,6 +487,9 @@ MACRO(NL_SETUP_BUILD)
SET(TARGET_X86 1) SET(TARGET_X86 1)
ELSEIF(TARGET_CPU STREQUAL "x86") ELSEIF(TARGET_CPU STREQUAL "x86")
SET(TARGET_X86 1) SET(TARGET_X86 1)
ELSEIF(TARGET_CPU STREQUAL "arm64")
SET(TARGET_ARM 1)
SET(TARGET_ARM64 1)
ELSEIF(TARGET_CPU STREQUAL "armv7s") ELSEIF(TARGET_CPU STREQUAL "armv7s")
SET(TARGET_ARM 1) SET(TARGET_ARM 1)
SET(TARGET_ARMV7S 1) SET(TARGET_ARMV7S 1)
@ -493,6 +509,10 @@ MACRO(NL_SETUP_BUILD)
ENDIF() ENDIF()
IF(TARGET_ARM) IF(TARGET_ARM)
IF(TARGET_ARM64)
ADD_PLATFORM_FLAGS("-DHAVE_ARM64")
ENDIF()
IF(TARGET_ARMV7S) IF(TARGET_ARMV7S)
ADD_PLATFORM_FLAGS("-DHAVE_ARMV7S") ADD_PLATFORM_FLAGS("-DHAVE_ARMV7S")
ENDIF() ENDIF()
@ -541,10 +561,6 @@ MACRO(NL_SETUP_BUILD)
ENDIF() ENDIF()
IF(MSVC) IF(MSVC)
IF(MSVC_VERSION EQUAL "1700" AND NOT MSVC11)
SET(MSVC11 ON)
ENDIF()
# Ignore default include paths # Ignore default include paths
ADD_PLATFORM_FLAGS("/X") ADD_PLATFORM_FLAGS("/X")
@ -555,31 +571,31 @@ MACRO(NL_SETUP_BUILD)
# without inlining it's unusable, use custom optimizations again # without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}") SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC12) ELSEIF(MSVC12)
ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") ADD_PLATFORM_FLAGS("/Gy-")
# /Ox is working with VC++ 2013, but custom optimizations don't exist # /Ox is working with VC++ 2013, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again # without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}") SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC11) ELSEIF(MSVC11)
ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") ADD_PLATFORM_FLAGS("/Gy-")
# /Ox is working with VC++ 2012, but custom optimizations don't exist # /Ox is working with VC++ 2012, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again # without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}") SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC10) ELSEIF(MSVC10)
ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") ADD_PLATFORM_FLAGS("/Gy-")
# /Ox is working with VC++ 2010, but custom optimizations don't exist # /Ox is working with VC++ 2010, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again # without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}") SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC90) ELSEIF(MSVC90)
ADD_PLATFORM_FLAGS("/Gy- /MP /Zm1000") ADD_PLATFORM_FLAGS("/Gy-")
# don't use a /O[012x] flag if you want custom optimizations # don't use a /O[012x] flag if you want custom optimizations
SET(RELEASE_CFLAGS "/Ob2 /Oi /Ot /Oy /GT /GF /GS- ${RELEASE_CFLAGS}") SET(RELEASE_CFLAGS "/Ob2 /Oi /Ot /Oy /GT /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again # without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Ob1 /GF- ${DEBUG_CFLAGS}") SET(DEBUG_CFLAGS "/Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC80) ELSEIF(MSVC80)
ADD_PLATFORM_FLAGS("/Gy- /Wp64 /Zm1000") ADD_PLATFORM_FLAGS("/Gy- /Wp64")
# don't use a /O[012x] flag if you want custom optimizations # don't use a /O[012x] flag if you want custom optimizations
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}") SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again # without inlining it's unusable, use custom optimizations again
@ -588,16 +604,19 @@ MACRO(NL_SETUP_BUILD)
MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")
ENDIF() ENDIF()
ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /wd4250") ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /D_WIN32 /DWIN32 /D_WINDOWS /wd4250")
# huge PCH
ADD_PLATFORM_FLAGS("/Zm1000")
IF(TARGET_X64) IF(TARGET_X64)
# Fix a bug with Intellisense # Fix a bug with Intellisense
ADD_PLATFORM_FLAGS("/D_WIN64") ADD_PLATFORM_FLAGS("/D_WIN64")
# Fix a compilation error for some big C++ files # Fix a compilation error for some big C++ files
SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} /bigobj") ADD_PLATFORM_FLAGS("/bigobj")
ELSE() ELSE()
# Allows 32 bits applications to use 3 GB of RAM # Allows 32 bits applications to use 3 GB of RAM
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /LARGEADDRESSAWARE") ADD_PLATFORM_LINKFLAGS("/LARGEADDRESSAWARE")
ENDIF() ENDIF()
# Exceptions are only set for C++ # Exceptions are only set for C++
@ -780,7 +799,7 @@ MACRO(NL_SETUP_BUILD)
ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
ENDIF() ENDIF()
IF(TARGET_ARMV7) IF(TARGET_ARMV7)
@ -790,7 +809,7 @@ MACRO(NL_SETUP_BUILD)
ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
ENDIF() ENDIF()
IF(TARGET_ARMV6) IF(TARGET_ARMV6)
@ -800,7 +819,7 @@ MACRO(NL_SETUP_BUILD)
ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}") ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}") ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}") ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
ENDIF() ENDIF()
ENDIF() ENDIF()
@ -812,20 +831,27 @@ MACRO(NL_SETUP_BUILD)
ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SIMULATOR_SYSROOT}") ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SIMULATOR_SYSROOT}")
ADD_PLATFORM_FLAGS("${XARCH}-mios-simulator-version-min=${IOS_VERSION}") ADD_PLATFORM_FLAGS("${XARCH}-mios-simulator-version-min=${IOS_VERSION}")
IF(CMAKE_OSX_DEPLOYMENT_TARGET) IF(CMAKE_OSX_DEPLOYMENT_TARGET)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") ADD_PLATFORM_LINKFLAGS("${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}")
ENDIF() ENDIF()
ENDIF() ENDIF()
ELSE() ELSE()
# Always force -mmacosx-version-min to override environement variable # Always force -mmacosx-version-min to override environement variable
IF(CMAKE_OSX_DEPLOYMENT_TARGET) IF(CMAKE_OSX_DEPLOYMENT_TARGET)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}") IF(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.7")
MESSAGE(FATAL_ERROR "Minimum target for OS X is 10.7 but you're using ${CMAKE_OSX_DEPLOYMENT_TARGET}")
ENDIF()
ADD_PLATFORM_LINKFLAGS("-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}")
ENDIF() ENDIF()
ENDIF() ENDIF()
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-headerpad_max_install_names") # use libc++ under OX X to be able to use new C++ features (and else it'll use GCC 4.2.1 STL)
# minimum target is now OS X 10.7
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -stdlib=libc++")
ADD_PLATFORM_LINKFLAGS("-Wl,-headerpad_max_install_names")
IF(HAVE_FLAG_SEARCH_PATHS_FIRST) IF(HAVE_FLAG_SEARCH_PATHS_FIRST)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-search_paths_first") ADD_PLATFORM_LINKFLAGS("-Wl,-search_paths_first")
ENDIF() ENDIF()
ENDIF() ENDIF()
ELSE() ELSE()
@ -838,7 +864,13 @@ MACRO(NL_SETUP_BUILD)
ENDIF() ENDIF()
ENDIF() ENDIF()
ADD_PLATFORM_FLAGS("-D_REENTRANT -fno-strict-aliasing") # use c++0x standard to use std::unique_ptr and std::shared_ptr
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -std=c++0x")
ADD_PLATFORM_FLAGS("-D_REENTRANT")
# hardening
ADD_PLATFORM_FLAGS("-D_FORTIFY_SOURCE=2")
IF(NOT WITH_LOW_MEMORY) IF(NOT WITH_LOW_MEMORY)
ADD_PLATFORM_FLAGS("-pipe") ADD_PLATFORM_FLAGS("-pipe")
@ -849,7 +881,19 @@ MACRO(NL_SETUP_BUILD)
ENDIF() ENDIF()
IF(WITH_WARNINGS) IF(WITH_WARNINGS)
ADD_PLATFORM_FLAGS("-Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused") ADD_PLATFORM_FLAGS("-Wall")
ELSE()
# Check wrong formats in printf-like functions
ADD_PLATFORM_FLAGS("-Wformat -Werror=format-security")
ENDIF()
# never display these warnings because they are minor
ADD_PLATFORM_FLAGS("-Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-value")
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "6.0.0")
ADD_PLATFORM_FLAGS("-Wno-unused-local-typedefs")
ELSEIF(CLANG)
ADD_PLATFORM_FLAGS("-Wno-unused-private-field -Wno-unused-local-typedef")
ENDIF() ENDIF()
IF(ANDROID) IF(ANDROID)
@ -859,37 +903,33 @@ MACRO(NL_SETUP_BUILD)
ADD_PLATFORM_FLAGS("-Wa,--noexecstack") ADD_PLATFORM_FLAGS("-Wa,--noexecstack")
IF(TARGET_ARM) IF(TARGET_ARM)
ADD_PLATFORM_FLAGS("-fpic -fstack-protector") ADD_PLATFORM_FLAGS("-fpic")
ADD_PLATFORM_FLAGS("-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__") ADD_PLATFORM_FLAGS("-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__")
IF(TARGET_ARMV7) IF(TARGET_ARMV7)
ADD_PLATFORM_FLAGS("-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16") ADD_PLATFORM_FLAGS("-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -march=armv7-a -Wl,--fix-cortex-a8") ADD_PLATFORM_LINKFLAGS("-march=armv7-a -Wl,--fix-cortex-a8")
ELSEIF(TARGET_ARMV5) ELSEIF(TARGET_ARMV5)
ADD_PLATFORM_FLAGS("-march=armv5te -mtune=xscale -msoft-float") ADD_PLATFORM_FLAGS("-march=armv5te -mtune=xscale -msoft-float")
ENDIF() ENDIF()
SET(TARGET_THUMB ON) SET(TARGET_THUMB ON)
IF(TARGET_THUMB) IF(TARGET_THUMB)
ADD_PLATFORM_FLAGS("-mthumb -fno-strict-aliasing -finline-limit=64") ADD_PLATFORM_FLAGS("-mthumb -finline-limit=64")
SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -marm") SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -marm")
ELSE() ELSE()
ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300") ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300")
SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -fno-strict-aliasing")
SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -fstrict-aliasing")
ENDIF() ENDIF()
ELSEIF(TARGET_X86) ELSEIF(TARGET_X86)
# Optimizations for Intel Atom # Optimizations for Intel Atom
ADD_PLATFORM_FLAGS("-march=i686 -mtune=atom -mstackrealign -msse3 -mfpmath=sse -m32 -flto -ffast-math -funroll-loops") ADD_PLATFORM_FLAGS("-march=i686 -mtune=atom -mstackrealign -msse3 -mfpmath=sse -m32 -flto -ffast-math -funroll-loops")
ADD_PLATFORM_FLAGS("-fstack-protector -funswitch-loops -finline-limit=300") ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300")
SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -fstrict-aliasing")
SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -fno-strict-aliasing")
ELSEIF(TARGET_MIPS) ELSEIF(TARGET_MIPS)
ADD_PLATFORM_FLAGS("-fpic -finline-functions -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -fno-strict-aliasing") ADD_PLATFORM_FLAGS("-fpic -finline-functions -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers")
SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -funswitch-loops -finline-limit=300") SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -funswitch-loops -finline-limit=300")
ENDIF() ENDIF()
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") ADD_PLATFORM_LINKFLAGS("-Wl,-z,noexecstack")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -L${PLATFORM_ROOT}/usr/lib") ADD_PLATFORM_LINKFLAGS("-L${PLATFORM_ROOT}/usr/lib")
ENDIF() ENDIF()
IF(APPLE) IF(APPLE)
@ -897,14 +937,30 @@ MACRO(NL_SETUP_BUILD)
ENDIF() ENDIF()
# Fix "relocation R_X86_64_32 against.." error on x64 platforms # Fix "relocation R_X86_64_32 against.." error on x64 platforms
IF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS AND NOT MINGW) IF(NOT MINGW)
ADD_PLATFORM_FLAGS("-fPIC") ADD_PLATFORM_FLAGS("-fPIC")
ENDIF() ENDIF()
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ftemplate-depth-48") SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ftemplate-depth-48")
# hardening
ADD_PLATFORM_FLAGS("-fstack-protector --param=ssp-buffer-size=4")
# If -fstack-protector or -fstack-protector-all enabled, enable too new warnings and fix possible link problems
IF(WITH_WARNINGS)
ADD_PLATFORM_FLAGS("-Wstack-protector")
ENDIF()
# Fix undefined reference to `__stack_chk_fail' error
ADD_PLATFORM_LINKFLAGS("-lc")
IF(NOT APPLE) IF(NOT APPLE)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--no-undefined -Wl,--as-needed") ADD_PLATFORM_LINKFLAGS("-Wl,--no-undefined -Wl,--as-needed")
ENDIF()
IF(NOT APPLE)
# hardening
ADD_PLATFORM_LINKFLAGS("-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now")
ENDIF() ENDIF()
IF(WITH_SYMBOLS) IF(WITH_SYMBOLS)
@ -920,7 +976,7 @@ MACRO(NL_SETUP_BUILD)
SET(NL_DEBUG_CFLAGS "-g -DNL_DEBUG -D_DEBUG ${NL_DEBUG_CFLAGS}") SET(NL_DEBUG_CFLAGS "-g -DNL_DEBUG -D_DEBUG ${NL_DEBUG_CFLAGS}")
SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O3 ${NL_RELEASE_CFLAGS}") SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O3 ${NL_RELEASE_CFLAGS}")
ENDIF() ENDIF()
ENDMACRO(NL_SETUP_BUILD) ENDMACRO()
MACRO(NL_SETUP_BUILD_FLAGS) MACRO(NL_SETUP_BUILD_FLAGS)
SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE) SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE)

View file

@ -1,5 +1,3 @@
PROJECT(NeL CXX C)
IF(WITH_STATIC_DRIVERS) IF(WITH_STATIC_DRIVERS)
ADD_DEFINITIONS(-DNL_STATIC) ADD_DEFINITIONS(-DNL_STATIC)
ENDIF() ENDIF()
@ -17,7 +15,6 @@ IF(WITH_3D)
IF(WITH_NEL_CEGUI) IF(WITH_NEL_CEGUI)
FIND_PACKAGE(CEGUI) FIND_PACKAGE(CEGUI)
ENDIF() ENDIF()
ENDIF() ENDIF()
IF(WITH_SOUND) IF(WITH_SOUND)

View file

@ -19,6 +19,8 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/misc/bit_set.h" #include "nel/misc/bit_set.h"
#include "nel/misc/smart_ptr.h"
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>

View file

@ -21,13 +21,17 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/misc/smart_ptr.h" #include "nel/misc/smart_ptr.h"
#include "nel/3d/animatable.h" #include "nel/3d/animatable.h"
#include "nel/3d/track.h" #include "nel/3d/track.h"
#include <map> #include <map>
namespace NL3D namespace NL3D
{ {
class CScene;
// *************************************************************************** // ***************************************************************************
/** /**
* An animated lightmap * An animated lightmap

View file

@ -93,7 +93,7 @@ public:
uint addAnimation (const char* fileName, const char* animName, bool displayMissingFileWarning = true) uint addAnimation (const char* fileName, const char* animName, bool displayMissingFileWarning = true)
{ {
// Allocate an animation // Allocate an animation
std::auto_ptr<CAnimation> anim (new CAnimation); CUniquePtr<CAnimation> anim (new CAnimation);
// Read it // Read it
NLMISC::CIFile file; NLMISC::CIFile file;
@ -130,7 +130,7 @@ public:
virtual uint addSkeletonWeight (const char* fileName, const char* skelName) virtual uint addSkeletonWeight (const char* fileName, const char* skelName)
{ {
// Allocate an animation // Allocate an animation
std::auto_ptr<CSkeletonWeight> skeletonWeight (new CSkeletonWeight); CUniquePtr<CSkeletonWeight> skeletonWeight (new CSkeletonWeight);
// Read it // Read it
NLMISC::CIFile file; NLMISC::CIFile file;

View file

@ -88,7 +88,7 @@ private:
public: public:
std::string MeshName; std::string MeshName;
public: public:
CMeshLoad (const std::string &meshName, IShape **ppShp, IDriver *pDriver, const CVector &position, uint selectedTexture); CMeshLoad (const std::string &meshName, IShape **ppShp, IDriver *pDriver, const NLMISC::CVector &position, uint selectedTexture);
void run (void); void run (void);
void getName (std::string &result) const; void getName (std::string &result) const;
}; };
@ -122,7 +122,7 @@ private:
CTextureFile *TextureFile; CTextureFile *TextureFile;
bool *Signal; bool *Signal;
public: public:
CTextureLoad(CTextureFile *textureFile, bool *psgn, const CVector &position) CTextureLoad(CTextureFile *textureFile, bool *psgn, const NLMISC::CVector &position)
: TextureFile(textureFile), Signal(psgn) : TextureFile(textureFile), Signal(psgn)
{ {
Position = position; Position = position;

View file

@ -152,7 +152,7 @@ private:
struct CTextureLodToSort struct CTextureLodToSort
{ {
CTextureLod *Lod; CTextureLod *Lod;
CVector Position; NLMISC::CVector Position;
bool operator<(const CTextureLodToSort &other) const bool operator<(const CTextureLodToSort &other) const
{ {
return Lod->Weight<other.Lod->Weight; return Lod->Weight<other.Lod->Weight;

View file

@ -20,6 +20,7 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/misc/vector.h" #include "nel/misc/vector.h"
#include "nel/misc/plane.h" #include "nel/misc/plane.h"
#include "nel/misc/aabbox.h"
namespace NL3D { namespace NL3D {
@ -39,16 +40,16 @@ public:
/** build the camera collision as a cone or a cylinder /** build the camera collision as a cone or a cylinder
*/ */
void build(const CVector &start, const CVector &end, float radius, bool cone); void build(const NLMISC::CVector &start, const NLMISC::CVector &end, float radius, bool cone);
/** build the camera collision as a simple ray /** build the camera collision as a simple ray
*/ */
void buildRay(const CVector &start, const CVector &end); void buildRay(const NLMISC::CVector &start, const NLMISC::CVector &end);
/** compute the intersection of the Camera Volume against the triangle, and minimize /** compute the intersection of the Camera Volume against the triangle, and minimize
* minDist (actual square of distance) with min sqr distance of the poly. * minDist (actual square of distance) with min sqr distance of the poly.
*/ */
void minimizeDistanceAgainstTri(const CVector &p0, const CVector &p1, const CVector &p2, float &sqrMinDist); void minimizeDistanceAgainstTri(const NLMISC::CVector &p0, const NLMISC::CVector &p1, const NLMISC::CVector &p2, float &sqrMinDist);
/** Compute into this the camera collision 'other' mul by 'matrix' /** Compute into this the camera collision 'other' mul by 'matrix'
* NB: for cone Radius, suppose uniform scale, else will have strange result (a uniform scale is deduced) * NB: for cone Radius, suppose uniform scale, else will have strange result (a uniform scale is deduced)
@ -69,9 +70,9 @@ private:
enum {MaxNPlanes=6}; enum {MaxNPlanes=6};
// The start of the camera raycast // The start of the camera raycast
CVector _Start; NLMISC::CVector _Start;
// The end of the camera raycast // The end of the camera raycast
CVector _End; NLMISC::CVector _End;
// The radius (at end only if cone) // The radius (at end only if cone)
float _Radius; float _Radius;
// cone or cylinder? // cone or cylinder?
@ -83,8 +84,8 @@ private:
NLMISC::CAABBox _BBox; NLMISC::CAABBox _BBox;
// Temp Data for minimizeDistanceAgainstTri // Temp Data for minimizeDistanceAgainstTri
CVector _ArrayIn[3+MaxNPlanes]; NLMISC::CVector _ArrayIn[3+MaxNPlanes];
CVector _ArrayOut[3+MaxNPlanes]; NLMISC::CVector _ArrayOut[3+MaxNPlanes];
// The pyramid representing the camera collision volume. Nb: local to start for precision problems // The pyramid representing the camera collision volume. Nb: local to start for precision problems
NLMISC::CPlane _Pyramid[MaxNPlanes]; NLMISC::CPlane _Pyramid[MaxNPlanes];
@ -97,10 +98,10 @@ private:
float _MaxRadiusProj; float _MaxRadiusProj;
float _OODeltaRadiusProj; float _OODeltaRadiusProj;
float _RayLen; float _RayLen;
CVector _RayNorm; NLMISC::CVector _RayNorm;
// simpler method for simple ray // simpler method for simple ray
void intersectRay(const CVector &p0, const CVector &p1, const CVector &p2, float &sqrMinDist); void intersectRay(const NLMISC::CVector &p0, const NLMISC::CVector &p1, const NLMISC::CVector &p2, float &sqrMinDist);
}; };

View file

@ -22,6 +22,7 @@ namespace NL3D
class UDriver; class UDriver;
class UCamera; class UCamera;
class CCloudScape; class CCloudScape;
class CScene;
/// implementation of UWaterInstance methods /// implementation of UWaterInstance methods
class CCloudScapeUser : public UCloudScape class CCloudScapeUser : public UCloudScape

View file

@ -120,7 +120,7 @@ public:
void setWorldMatrix (const NLMISC::CMatrix &WM); void setWorldMatrix (const NLMISC::CMatrix &WM);
bool isRoot() { return _LocalVolume.size() == 0; } bool isRoot() { return _LocalVolume.empty(); }
//\name Sound related. //\name Sound related.
//@{ //@{

View file

@ -84,7 +84,7 @@ public:
void setTextureFile (const char* file); void setTextureFile (const char* file);
/** /**
* Add a coarse mesh in the manager. If an error occured, it returns CantAddCoarseMesh. * Add a coarse mesh in the manager. If an error occurred, it returns CantAddCoarseMesh.
* \param vBuffer the VertexBuffer pre-transformed / Colored. Size MUST be numVertices*NL3D_COARSEMESH_VERTEX_FORMAT_MGR * \param vBuffer the VertexBuffer pre-transformed / Colored. Size MUST be numVertices*NL3D_COARSEMESH_VERTEX_FORMAT_MGR
* \param indexBuffer containing triangles that will be inserted. * \param indexBuffer containing triangles that will be inserted.
* \return false if the mesh can't be added to this pass BECAUSE OF TOO MANY VERTICES or TOO MANY PRIMITIVES reason * \return false if the mesh can't be added to this pass BECAUSE OF TOO MANY VERTICES or TOO MANY PRIMITIVES reason

View file

@ -48,7 +48,7 @@ public:
static void releaseInstance(); static void releaseInstance();
/// convert a HLS (0..255) to a RGBA. /// convert a HLS (0..255) to a RGBA.
CRGBA convert(uint H, uint L, uint S); NLMISC::CRGBA convert(uint H, uint L, uint S);
/// convert a RGBA bitmap into another RGBA, with HLS decal (0..255, -255..+255, -255..+255). /// convert a RGBA bitmap into another RGBA, with HLS decal (0..255, -255..+255, -255..+255).
void convertRGBABitmap(NLMISC::CBitmap &dst, const NLMISC::CBitmap &src, uint8 dh, sint dl, sint ds); void convertRGBABitmap(NLMISC::CBitmap &dst, const NLMISC::CBitmap &src, uint8 dh, sint dl, sint ds);
@ -75,7 +75,7 @@ private:
uint8 H,L,S,A; uint8 H,L,S,A;
}; };
CRGBA _HueTable[HueTableSize]; NLMISC::CRGBA _HueTable[HueTableSize];
CHLSA _Color16ToHLS[65536]; CHLSA _Color16ToHLS[65536];
/// Constructor /// Constructor

View file

@ -27,7 +27,8 @@
#ifndef NL3D_GPU_PROGRAM_PARAMS_H #ifndef NL3D_GPU_PROGRAM_PARAMS_H
#define NL3D_GPU_PROGRAM_PARAMS_H #define NL3D_GPU_PROGRAM_PARAMS_H
#include <nel/misc/types_nl.h>
#include "nel/misc/types_nl.h"
// STL includes // STL includes
#include <map> #include <map>
@ -167,7 +168,7 @@ private:
std::map<std::string, size_t> m_MapName; // map from name to offset std::map<std::string, size_t> m_MapName; // map from name to offset
size_t m_First; size_t m_First;
size_t m_Last; size_t m_Last;
static const size_t s_End = -1; static const size_t s_End;
}; /* class CGPUProgramParams */ }; /* class CGPUProgramParams */

View file

@ -26,6 +26,7 @@
namespace NL3D namespace NL3D
{ {
class CInstanceGroup;
// *************************************************************************** // ***************************************************************************
/** /**
@ -106,14 +107,14 @@ public:
public: public:
/// Debug: build a colored Grid mesh of SunContribution. /// Debug: build a colored Grid mesh of SunContribution.
void buildSunDebugMesh(CMesh::CMeshBuild &meshBuild, CMeshBase::CMeshBaseBuild &meshBaseBuild, const CVector &deltaPos=CVector::Null); void buildSunDebugMesh(CMesh::CMeshBuild &meshBuild, CMeshBase::CMeshBaseBuild &meshBaseBuild, const NLMISC::CVector &deltaPos= NLMISC::CVector::Null);
/// Debug: build a colored Grid mesh of PointLight. R= pointLight1 id. G= PointLight2 id. B= The multiplier used to show Ids. /// Debug: build a colored Grid mesh of PointLight. R= pointLight1 id. G= PointLight2 id. B= The multiplier used to show Ids.
void buildPLDebugMesh(CMesh::CMeshBuild &meshBuild, CMeshBase::CMeshBaseBuild &meshBaseBuild, const CVector &deltaPos, const CInstanceGroup &igOut); void buildPLDebugMesh(CMesh::CMeshBuild &meshBuild, CMeshBase::CMeshBaseBuild &meshBaseBuild, const NLMISC::CVector &deltaPos, const CInstanceGroup &igOut);
private: private:
void addDebugMeshFaces(CMesh::CMeshBuild &meshBuild, CSurface &surface, uint vId0, void addDebugMeshFaces(CMesh::CMeshBuild &meshBuild, CSurface &surface, uint vId0,
const std::vector<CRGBA> &colors); const std::vector<NLMISC::CRGBA> &colors);
}; };

View file

@ -716,7 +716,7 @@ private:
bool _RefineMode; bool _RefineMode;
float _FarTransition; float _FarTransition;
uint _TileMaxSubdivision; uint _TileMaxSubdivision;
// For VertexProgram. true if change has occured in threshold since the last render(). // For VertexProgram. true if change has occurred in threshold since the last render().
float _VPThresholdChange; float _VPThresholdChange;
/// \name VertexBuffer mgt. /// \name VertexBuffer mgt.

View file

@ -692,7 +692,7 @@ private:
{ {
NLMISC::CMatrix TexMat[IDRV_MAT_MAXTEXTURES]; NLMISC::CMatrix TexMat[IDRV_MAT_MAXTEXTURES];
}; };
std::auto_ptr<CUserTexMat> _TexUserMat; // user texture matrix CUniquePtr<CUserTexMat> _TexUserMat; // user texture matrix
public: public:
// Private. For Driver only. // Private. For Driver only.

View file

@ -47,7 +47,7 @@ public:
float a31, a32, a33, a34; float a31, a32, a33, a34;
// Copy from a matrix. // Copy from a matrix.
void set(const CMatrix &mat) void set(const NLMISC::CMatrix &mat)
{ {
const float *m =mat.get(); const float *m =mat.get();
a11= m[0]; a12= m[4]; a13= m[8] ; a14= m[12]; a11= m[0]; a12= m[4]; a13= m[8] ; a14= m[12];
@ -57,14 +57,14 @@ public:
// mulSetvector. NB: in should be different as v!! (else don't work). // mulSetvector. NB: in should be different as v!! (else don't work).
void mulSetVector(const CVector &in, CVector &out) void mulSetVector(const NLMISC::CVector &in, NLMISC::CVector &out)
{ {
out.x= (a11*in.x + a12*in.y + a13*in.z); out.x= (a11*in.x + a12*in.y + a13*in.z);
out.y= (a21*in.x + a22*in.y + a23*in.z); out.y= (a21*in.x + a22*in.y + a23*in.z);
out.z= (a31*in.x + a32*in.y + a33*in.z); out.z= (a31*in.x + a32*in.y + a33*in.z);
} }
// mulSetpoint. NB: in should be different as v!! (else don't work). // mulSetpoint. NB: in should be different as v!! (else don't work).
void mulSetPoint(const CVector &in, CVector &out) void mulSetPoint(const NLMISC::CVector &in, NLMISC::CVector &out)
{ {
out.x= (a11*in.x + a12*in.y + a13*in.z + a14); out.x= (a11*in.x + a12*in.y + a13*in.z + a14);
out.y= (a21*in.x + a22*in.y + a23*in.z + a24); out.y= (a21*in.x + a22*in.y + a23*in.z + a24);
@ -73,14 +73,14 @@ public:
// mulSetvector. NB: in should be different as v!! (else don't work). // mulSetvector. NB: in should be different as v!! (else don't work).
void mulSetVector(const CVector &in, float scale, CVector &out) void mulSetVector(const NLMISC::CVector &in, float scale, NLMISC::CVector &out)
{ {
out.x= (a11*in.x + a12*in.y + a13*in.z) * scale; out.x= (a11*in.x + a12*in.y + a13*in.z) * scale;
out.y= (a21*in.x + a22*in.y + a23*in.z) * scale; out.y= (a21*in.x + a22*in.y + a23*in.z) * scale;
out.z= (a31*in.x + a32*in.y + a33*in.z) * scale; out.z= (a31*in.x + a32*in.y + a33*in.z) * scale;
} }
// mulSetpoint. NB: in should be different as v!! (else don't work). // mulSetpoint. NB: in should be different as v!! (else don't work).
void mulSetPoint(const CVector &in, float scale, CVector &out) void mulSetPoint(const NLMISC::CVector &in, float scale, NLMISC::CVector &out)
{ {
out.x= (a11*in.x + a12*in.y + a13*in.z + a14) * scale; out.x= (a11*in.x + a12*in.y + a13*in.z + a14) * scale;
out.y= (a21*in.x + a22*in.y + a23*in.z + a24) * scale; out.y= (a21*in.x + a22*in.y + a23*in.z + a24) * scale;
@ -89,14 +89,14 @@ public:
// mulAddvector. NB: in should be different as v!! (else don't work). // mulAddvector. NB: in should be different as v!! (else don't work).
void mulAddVector(const CVector &in, float scale, CVector &out) void mulAddVector(const NLMISC::CVector &in, float scale, NLMISC::CVector &out)
{ {
out.x+= (a11*in.x + a12*in.y + a13*in.z) * scale; out.x+= (a11*in.x + a12*in.y + a13*in.z) * scale;
out.y+= (a21*in.x + a22*in.y + a23*in.z) * scale; out.y+= (a21*in.x + a22*in.y + a23*in.z) * scale;
out.z+= (a31*in.x + a32*in.y + a33*in.z) * scale; out.z+= (a31*in.x + a32*in.y + a33*in.z) * scale;
} }
// mulAddpoint. NB: in should be different as v!! (else don't work). // mulAddpoint. NB: in should be different as v!! (else don't work).
void mulAddPoint(const CVector &in, float scale, CVector &out) void mulAddPoint(const NLMISC::CVector &in, float scale, NLMISC::CVector &out)
{ {
out.x+= (a11*in.x + a12*in.y + a13*in.z + a14) * scale; out.x+= (a11*in.x + a12*in.y + a13*in.z + a14) * scale;
out.y+= (a21*in.x + a22*in.y + a23*in.z + a24) * scale; out.y+= (a21*in.x + a22*in.y + a23*in.z + a24) * scale;

View file

@ -124,7 +124,7 @@ private:
double _LastSceneTime; double _LastSceneTime;
// maximum amplitude vector for each level. Stored in mesh because same for all instances. // maximum amplitude vector for each level. Stored in mesh because same for all instances.
CVector _MaxDeltaPos[HrcDepth]; NLMISC::CVector _MaxDeltaPos[HrcDepth];
float _MaxVertexMove; float _MaxVertexMove;
// MBR Cache // MBR Cache

View file

@ -841,7 +841,7 @@ public:
/// return true when there are still emitters in the system /// return true when there are still emitters in the system
bool hasEmitters(void) const; bool hasEmitters() const;
/// return true when there are still particles /// return true when there are still particles
bool hasParticles() const; bool hasParticles() const;

View file

@ -87,7 +87,7 @@ private:
{ {
public: public:
CParticleSystemModel *Model; CParticleSystemModel *Model;
CMatrix OldAncestorMatOrRelPos; // last matrix of ancestor skeleton or relative matrix of ps to its ancestor (see flag below) NLMISC::CMatrix OldAncestorMatOrRelPos; // last matrix of ancestor skeleton or relative matrix of ps to its ancestor (see flag below)
bool IsRelMatrix; // gives usage of the field OldAncestorMatOrRelPos bool IsRelMatrix; // gives usage of the field OldAncestorMatOrRelPos
bool HasAncestorSkeleton; // has the system an ancestor skeleton ? bool HasAncestorSkeleton; // has the system an ancestor skeleton ?
public: public:

View file

@ -163,10 +163,10 @@ class CParticleSystemProcess : public NLMISC::IStreamable
virtual void setMatrixMode(TPSMatrixMode matrixMode); virtual void setMatrixMode(TPSMatrixMode matrixMode);
/// tells whether there are alive entities / particles in the system /// tells whether there are alive entities / particles in the system
virtual bool hasParticles(void) const { return false ; } virtual bool hasParticles() const { return false ; }
/// tells whether there are alive emitters / particles in the system /// tells whether there are alive emitters / particles in the system
virtual bool hasEmitters(void) const { return false ; } virtual bool hasEmitters() const { return false ; }
/// max number of faces wanted by this process (for load balancing) /// max number of faces wanted by this process (for load balancing)

View file

@ -92,9 +92,9 @@ public:
void setWorldMatrix (const NLMISC::CMatrix &WM); void setWorldMatrix (const NLMISC::CMatrix &WM);
void setName (std::string &name) { _Name = name; } void setName (const std::string &name) { _Name = name; }
std::string getName () { return _Name; } std::string getName () const { return _Name; }
void open (bool opened) { _Opened = opened; } void open (bool opened) { _Opened = opened; }
bool isOpened () { return _Opened; } bool isOpened () { return _Opened; }

View file

@ -282,7 +282,7 @@ inline float CPSAttribMakerBinOp<float>::getMaxValue(void) const
template <class T> template <class T>
inline CPSAttribMakerBinOp<T>::CPSAttribMakerBinOp(const CPSAttribMakerBinOp &other) : CPSAttribMaker<T>(other) // parent copy ctor inline CPSAttribMakerBinOp<T>::CPSAttribMakerBinOp(const CPSAttribMakerBinOp &other) : CPSAttribMaker<T>(other) // parent copy ctor
{ {
std::auto_ptr<CPSAttribMaker<T> > a0(NLMISC::safe_cast<CPSAttribMaker<T> *>(other._Arg[0]->clone())) CUniquePtr<CPSAttribMaker<T> > a0(NLMISC::safe_cast<CPSAttribMaker<T> *>(other._Arg[0]->clone()))
, a1(NLMISC::safe_cast<CPSAttribMaker<T> *>(other._Arg[1]->clone())); , a1(NLMISC::safe_cast<CPSAttribMaker<T> *>(other._Arg[1]->clone()));
this->_Op = other._Op; this->_Op = other._Op;
this->_Size = other._Size; this->_Size = other._Size;

View file

@ -1463,7 +1463,7 @@ public:
CPSAttribMakerMemoryBase(const CPSAttribMakerMemoryBase &src) : CPSAttribMaker<T>(src) // parent copy ctor CPSAttribMakerMemoryBase(const CPSAttribMakerMemoryBase &src) : CPSAttribMaker<T>(src) // parent copy ctor
{ {
nlassert(src._Scheme); nlassert(src._Scheme);
std::auto_ptr<CPSAttribMaker<T> > s(NLMISC::safe_cast<CPSAttribMaker<T> *>(src._Scheme->clone())); CUniquePtr<CPSAttribMaker<T> > s(NLMISC::safe_cast<CPSAttribMaker<T> *>(src._Scheme->clone()));
this->_T = src._T; this->_T = src._T;
this->_DefaultValue = src._DefaultValue; this->_DefaultValue = src._DefaultValue;
this->_Scheme = s.release(); this->_Scheme = s.release();

View file

@ -24,6 +24,8 @@
#include "nel/misc/rgba.h" #include "nel/misc/rgba.h"
#include "nel/misc/traits_nl.h" #include "nel/misc/traits_nl.h"
#include <iterator>
namespace NL3D { namespace NL3D {
/* /*
@ -480,7 +482,11 @@ void CPSValueGradientFunc<T>::setValuesUnpacked(const T *valueTab, uint32 numVal
_MaxValue = _MinValue = valueTab[0]; _MaxValue = _MinValue = valueTab[0];
_NbValues = (numValues - 1) * nbStages; _NbValues = (numValues - 1) * nbStages;
_Tab.resize(_NbValues + 1); _Tab.resize(_NbValues + 1);
#ifdef NL_COMP_VC14
std::copy(valueTab, valueTab + _NbValues + 1, stdext::make_checked_array_iterator(&_Tab[0], _Tab.size()));
#else
std::copy(valueTab, valueTab + _NbValues + 1, &_Tab[0]); std::copy(valueTab, valueTab + _NbValues + 1, &_Tab[0]);
#endif
} }

View file

@ -51,14 +51,14 @@ public:
//@} //@}
/// Return this bindable type /// Return this bindable type
uint32 getType(void) const { return PSEmitter; } uint32 getType() const { return PSEmitter; }
/// Return priority for emitters /// Return priority for emitters
virtual uint32 getPriority(void) const { return 500; } virtual uint32 getPriority() const { return 500; }
/// Return true if this located bindable derived class holds alive emitters /// Return true if this located bindable derived class holds alive emitters
virtual bool hasEmitters(void) { nlassert(_Owner); return _Owner->getSize() != 0; } virtual bool hasEmitters() const { nlassert(_Owner); return _Owner->getSize() != 0; }
virtual void step(TPSProcessPass pass); virtual void step(TPSProcessPass pass);
@ -76,7 +76,7 @@ public:
/// Display the emitter in edition mode /// Display the emitter in edition mode
virtual void showTool(void); virtual void showTool();
/** Set the type of located to be emitted. The default is NULL which mean that no emission will occur /** Set the type of located to be emitted. The default is NULL which mean that no emission will occur
* \return true if the operation could be performed. It can fail when this cause the system the system to last forever, * \return true if the operation could be performed. It can fail when this cause the system the system to last forever,
@ -90,9 +90,9 @@ public:
virtual void notifyTargetRemoved(CPSLocated *ptr); virtual void notifyTargetRemoved(CPSLocated *ptr);
/// Get emitted type. /// Get emitted type.
CPSLocated *getEmittedType(void) { return _EmittedType; } CPSLocated *getEmittedType() { return _EmittedType; }
/// Get const ptr on emitted type /// Get const ptr on emitted type
const CPSLocated *getEmittedType(void) const { return _EmittedType; } const CPSLocated *getEmittedType() const { return _EmittedType; }
/** The type of emission. /** The type of emission.
@ -336,7 +336,7 @@ protected:
* should not be called directly. Call CPSLocated::resize instead * should not be called directly. Call CPSLocated::resize instead
*/ */
virtual void resize(uint32 size); virtual void resize(uint32 size);
virtual void bounceOccured(uint32 index, TAnimationTime timeToNextSimStep); virtual void bounceOccurred(uint32 index, TAnimationTime timeToNextSimStep);
void updateMaxCountVect(); void updateMaxCountVect();

View file

@ -66,14 +66,14 @@ class CParticleSystem;
/// This structure helps to perform the collision step, by telling which collisionner is the nearest if there are several candidate /// This structure helps to perform the collision step, by telling which collisionner is the nearest if there are several candidate
/// a distance of -1 indicates that no collisions occured /// a distance of -1 indicates that no collisions occurred
struct CPSCollisionInfo struct CPSCollisionInfo
{ {
CPSCollisionInfo *Next; CPSCollisionInfo *Next;
float Dist; // Distance to the nearest collider, or -1 if not collision occured float Dist; // Distance to the nearest collider, or -1 if not collision occurred
NLMISC::CVector NewPos; NLMISC::CVector NewPos;
NLMISC::CVector NewSpeed; // The speed of particle after a collision occured. After the updated of collision it is swapped with the post-collision speed NLMISC::CVector NewSpeed; // The speed of particle after a collision occurred. After the updated of collision it is swapped with the post-collision speed
CPSZone *CollisionZone; // The zone on which the bounce occured, can be useful to check the behaviour in case of collision CPSZone *CollisionZone; // The zone on which the bounce occurred, can be useful to check the behaviour in case of collision
uint32 Index; uint32 Index;
CPSCollisionInfo() CPSCollisionInfo()
{ {
@ -449,14 +449,14 @@ public:
void setName(const std::string &name) { _Name = name; } void setName(const std::string &name) { _Name = name; }
/// get the located bindable name (edition purpose) /// get the located bindable name (edition purpose)
std::string getName(void) const { return _Name; } std::string getName() const { return _Name; }
/// tells whether there are alive entities / particles in the system /// tells whether there are alive entities / particles in the system
virtual bool hasParticles(void) const; virtual bool hasParticles() const;
/// tells whether there are alive emitters / particles in the system /// tells whether there are alive emitters / particles in the system
virtual bool hasEmitters(void) const; virtual bool hasEmitters() const;
/** Enable the to force LOD degradation. This will suppress instances immediately, (during the motion pass) so that /** Enable the to force LOD degradation. This will suppress instances immediately, (during the motion pass) so that
* there won't be more than maxNbInstance * dist / maxDist instances. This may not be desirable * there won't be more than maxNbInstance * dist / maxDist instances. This may not be desirable
@ -468,7 +468,7 @@ public:
/** Test whether LOD degradation was activated /** Test whether LOD degradation was activated
* \see forceLODDegradation() * \see forceLODDegradation()
*/ */
bool hasLODDegradation(void) const { return _LODDegradation; } bool hasLODDegradation() const { return _LODDegradation; }
/// for the CPSLocated to reevaluate the max number of faces it may need /// for the CPSLocated to reevaluate the max number of faces it may need
@ -853,11 +853,11 @@ public:
*/ */
void setLOD(TPSLod lod) { _LOD = lod; } void setLOD(TPSLod lod) { _LOD = lod; }
/// get the valid lods for that object /// get the valid lods for that object
TPSLod getLOD(void) const { return _LOD; } TPSLod getLOD() const { return _LOD; }
/// tells whether there are alive entities / particles /// tells whether there are alive entities / particles
virtual bool hasParticles(void) const { return false; } virtual bool hasParticles() const { return false; }
/// tells whether there are alive emitters /// tells whether there are alive emitters
virtual bool hasEmitters(void) const { return false; } virtual bool hasEmitters() const { return false; }
/** set the extern ID of this located bindable. 0 means no extern access. The map of ID-locatedBindable. Is in th /** set the extern ID of this located bindable. 0 means no extern access. The map of ID-locatedBindable. Is in th
* particle system, so this located bindable must have been attached to a particle system, otherwise an assertion is raised * particle system, so this located bindable must have been attached to a particle system, otherwise an assertion is raised
*/ */
@ -906,10 +906,10 @@ protected:
*/ */
virtual void resize(uint32 size) = 0; virtual void resize(uint32 size) = 0;
/** a bounce occured, so some action could be done. The default behaviour does nothing /** a bounce occurred, so some action could be done. The default behaviour does nothing
* \param index the index of the element that bounced * \param index the index of the element that bounced
*/ */
virtual void bounceOccured(uint32 /* index */, TAnimationTime /* timeToNextsimStep */) {} virtual void bounceOccurred(uint32 /* index */, TAnimationTime /* timeToNextsimStep */) {}
/** show an drawing to represent the object, and in red if it is selected /** show an drawing to represent the object, and in red if it is selected
* \param tab : a table of 2 * nbSeg vector. only the x and y coordinates are used * \param tab : a table of 2 * nbSeg vector. only the x and y coordinates are used

View file

@ -590,7 +590,7 @@ protected:
void serial(NLMISC::IStream &f) throw(NLMISC::EStream); void serial(NLMISC::IStream &f) throw(NLMISC::EStream);
}; };
typedef std::auto_ptr<CGlobalTexAnims> PGlobalTexAnims; typedef CUniquePtr<CGlobalTexAnims> PGlobalTexAnims;
PGlobalTexAnims _GlobalTexAnims; PGlobalTexAnims _GlobalTexAnims;
float _GlobalAnimDate; float _GlobalAnimDate;

View file

@ -120,7 +120,7 @@ protected:
/** /**
* This set speed of a located so that it looks like bouncing on a surface * This set speed of a located so that it looks like bouncing on a surface
* \param locatedIndex the index * \param locatedIndex the index
* \param bouncePoint the position where the collision occured * \param bouncePoint the position where the collision occurred
* \param surfNormal the normal of the surface at the collision point (this must be a unit vector) * \param surfNormal the normal of the surface at the collision point (this must be a unit vector)
* \elasticity 1 = full bounce, 0 = no bounce (contact) * \elasticity 1 = full bounce, 0 = no bounce (contact)
* \ellapsedTime the time ellapsed * \ellapsedTime the time ellapsed

View file

@ -654,7 +654,7 @@ template<class T> typename CQuadGrid<T>::CIterator CQuadGrid<T>::erase(typename
if(!ptr->Selected) if(!ptr->Selected)
next= NULL; next= NULL;
// delete the object. // delete the object.
_NodeBlockMemory.free(ptr); _NodeBlockMemory.freeBlock(ptr);
return CIterator((CNode*)next); return CIterator((CNode*)next);

View file

@ -53,7 +53,7 @@ public:
public: public:
// Simple Definition of a mesh used to test against Ray // Simple Definition of a mesh used to test against Ray
std::vector<CVector> Vertices; std::vector<NLMISC::CVector> Vertices;
std::vector<uint32> Triangles; std::vector<uint32> Triangles;
/// Empty? /// Empty?

View file

@ -28,6 +28,8 @@
#include "nel/3d/shadow_map_manager.h" #include "nel/3d/shadow_map_manager.h"
#include "nel/3d/u_scene.h" #include "nel/3d/u_scene.h"
#include "nel/3d/vertex_program.h" #include "nel/3d/vertex_program.h"
#include "nel/3d/transform.h"
#include <vector> #include <vector>

View file

@ -22,7 +22,7 @@
#include "nel/misc/smart_ptr.h" #include "nel/misc/smart_ptr.h"
#include "nel/misc/vector.h" #include "nel/misc/vector.h"
#include "nel/misc/aabbox.h" #include "nel/misc/aabbox.h"
#include "nel/misc/class_id.h"
#include "nel/3d/texture.h" #include "nel/3d/texture.h"
#include "nel/3d/shape.h" #include "nel/3d/shape.h"

View file

@ -51,7 +51,7 @@ public:
* The usage of this matrix is for UV projection: XYZ= WorldProjectionMatrix * UVW. * The usage of this matrix is for UV projection: XYZ= WorldProjectionMatrix * UVW.
* NB: Vj (ie for W) is mapped such that Vp means NearClip of the shadow and Vp+Vj means FarClip of the shadow * NB: Vj (ie for W) is mapped such that Vp means NearClip of the shadow and Vp+Vj means FarClip of the shadow
*/ */
CMatrix LocalProjectionMatrix; NLMISC::CMatrix LocalProjectionMatrix;
/** Computed at shadow casting time. They are clipping planes used to clip receivers (mirror of the OBB). /** Computed at shadow casting time. They are clipping planes used to clip receivers (mirror of the OBB).
* Receivers may use them to clip sub received parts (as they which) * Receivers may use them to clip sub received parts (as they which)
@ -63,7 +63,7 @@ public:
/** Computed at shadow casting time. This is the LocalPos Bouding Box containing the shadow (AxisAligned). /** Computed at shadow casting time. This is the LocalPos Bouding Box containing the shadow (AxisAligned).
* \see generateClipInfoFromMatrix() * \see generateClipInfoFromMatrix()
*/ */
CAABBox LocalBoundingBox; NLMISC::CAABBox LocalBoundingBox;
// Filled by ShadowMapManager. This is the Last Frame Id we had update the texture. // Filled by ShadowMapManager. This is the Last Frame Id we had update the texture.
@ -114,13 +114,13 @@ public:
* driver->setupModelMatrix(localPosMatrix); * driver->setupModelMatrix(localPosMatrix);
* Then render his mesh. * Then render his mesh.
*/ */
void buildCasterCameraMatrix(const CVector &lightDir, const CMatrix &localPosMatrix, const CAABBox &bbShape, CMatrix &cameraMatrix); void buildCasterCameraMatrix(const NLMISC::CVector &lightDir, const NLMISC::CMatrix &localPosMatrix, const NLMISC::CAABBox &bbShape, NLMISC::CMatrix &cameraMatrix);
/** From the Camera matrix computed with buildCasterCameraMatrix, compute the LocalProjectionMatrix, which modify the /** From the Camera matrix computed with buildCasterCameraMatrix, compute the LocalProjectionMatrix, which modify the
* J axis according to backPoint and Shadow Depth. * J axis according to backPoint and Shadow Depth.
* NB: automatically calls the buildClipInfoFromMatrix() method * NB: automatically calls the buildClipInfoFromMatrix() method
*/ */
void buildProjectionInfos(const CMatrix &cameraMatrix, const CVector &backPoint, float shadowMaxDepth); void buildProjectionInfos(const NLMISC::CMatrix &cameraMatrix, const NLMISC::CVector &backPoint, float shadowMaxDepth);
/** The ShadowMap Caster can call this method after setting LocalProjectionMatrix. It computes auto the /** The ShadowMap Caster can call this method after setting LocalProjectionMatrix. It computes auto the
* LocalClipPlanes and LocalBoundingBox from it. NB: don't use it if you use buildProjectionInfos(). * LocalClipPlanes and LocalBoundingBox from it. NB: don't use it if you use buildProjectionInfos().
@ -158,13 +158,13 @@ class CShadowMapProjector
{ {
public: public:
CShadowMapProjector(); CShadowMapProjector();
void setWorldSpaceTextMat(const CMatrix &ws); void setWorldSpaceTextMat(const NLMISC::CMatrix &ws);
void applyToMaterial(const CMatrix &receiverWorldMatrix, CMaterial &material); void applyToMaterial(const NLMISC::CMatrix &receiverWorldMatrix, CMaterial &material);
private: private:
CMatrix _WsTextMat; NLMISC::CMatrix _WsTextMat;
CMatrix _XYZToUWVMatrix; NLMISC::CMatrix _XYZToUWVMatrix;
CMatrix _XYZToWUVMatrix; NLMISC::CMatrix _XYZToWUVMatrix;
}; };

View file

@ -29,7 +29,8 @@
namespace NL3D { namespace NL3D {
class CTransform; class CTransform;
class CScene;
// *************************************************************************** // ***************************************************************************

View file

@ -33,9 +33,9 @@ namespace NL3D
class CShadowVertex class CShadowVertex
{ {
public: public:
CVector Vertex; NLMISC::CVector Vertex;
uint32 MatrixId; uint32 MatrixId;
void serial(NLMISC::IStream &f) void serial(NLMISC::IStream &f)
{ {
(void)f.serialVersion(0); (void)f.serialVersion(0);
@ -82,7 +82,7 @@ public:
* if don't intersect, dist2D="nearest distance to the ray", and distZ=0 * if don't intersect, dist2D="nearest distance to the ray", and distZ=0
* \param computeDist2D if false and don't intersect, then return dist2D=FLT_MAX, and distZ=0 * \param computeDist2D if false and don't intersect, then return dist2D=FLT_MAX, and distZ=0
*/ */
bool getRayIntersection(const CMatrix &toRaySpace, class CSkeletonModel &skeleton, bool getRayIntersection(const NLMISC::CMatrix &toRaySpace, class CSkeletonModel &skeleton,
const std::vector<uint32> &matrixInfluences, float &dist2D, float &distZ, bool computeDist2D); const std::vector<uint32> &matrixInfluences, float &dist2D, float &distZ, bool computeDist2D);
private: private:

View file

@ -54,7 +54,7 @@ public:
virtual NLMISC::CQuat getOrientation() const = 0; virtual NLMISC::CQuat getOrientation() const = 0;
/// Set the GUI reference /// Set the GUI reference
virtual void setInterfaceMatrix(const NL3D::CMatrix &matrix) = 0; virtual void setInterfaceMatrix(const NLMISC::CMatrix &matrix) = 0;
/// Get GUI center (1 = width, 1 = height, 0 = center) /// Get GUI center (1 = width, 1 = height, 0 = center)
virtual void getInterface2DShift(uint cid, float &x, float &y, float distance) const = 0; virtual void getInterface2DShift(uint cid, float &x, float &y, float distance) const = 0;

View file

@ -44,16 +44,16 @@ public:
public: public:
/// Target controled or direction controled. Default to DirectionMode /// Target controled or direction controled. Default to DirectionMode
TMode Mode; TMode Mode;
/// \name Target and Direction specific /// \name Target and Direction specific
// @{ // @{
/// For TargetMode, the world Position of the target. /// For TargetMode, the world Position of the target.
CVector WorldTarget; NLMISC::CVector WorldTarget;
/// For TargetMode only, the Pos of eyes relative to the bone controlled. Default to (0,0,0) /// For TargetMode only, the Pos of eyes relative to the bone controlled. Default to (0,0,0)
CVector EyePos; NLMISC::CVector EyePos;
/// For DirectionMode, the WorldRotation to apply to the bone. NB: modified in execute() if TargetMode /// For DirectionMode, the WorldRotation to apply to the bone. NB: modified in execute() if TargetMode
CQuat CurrentWorldDirection; NLMISC::CQuat CurrentWorldDirection;
// @} // @}
/// \name Common /// \name Common
@ -61,13 +61,13 @@ public:
/** This enable or disable the ctrl. When disabled or enabled, the ctrl ensure /** This enable or disable the ctrl. When disabled or enabled, the ctrl ensure
* that the movement does not "pop", respecting MaxAngularVelocity. Default to true. * that the movement does not "pop", respecting MaxAngularVelocity. Default to true.
*/ */
bool Enabled; bool Enabled;
/// This give The World Orientation when the Mesh is in bind Pos (default to "LookBack"). /// This give The World Orientation when the Mesh is in bind Pos (default to "LookBack").
CQuat DefaultWorldDirection; NLMISC::CQuat DefaultWorldDirection;
/// The Maximum angle of rotation that can be performed between the Default Direction and Current Direction. Default to Pi/3 /// The Maximum angle of rotation that can be performed between the Default Direction and Current Direction. Default to Pi/3
float MaxAngle; float MaxAngle;
/// The Maximum Angular Velocity the ctrl can perform. Default to 2*Pi per second. /// The Maximum Angular Velocity the ctrl can perform. Default to 2*Pi per second.
float MaxAngularVelocity; float MaxAngularVelocity;
// @} // @}
@ -77,19 +77,19 @@ public:
virtual ~CTargetAnimCtrl(); virtual ~CTargetAnimCtrl();
/// Called at compute() time. /// Called at compute() time.
virtual void execute(CSkeletonModel *model, CBone *bone); virtual void execute(CSkeletonModel *model, CBone *bone);
private: private:
/// The last rotation computed (in LocalSkeleton Space). Used to smooth transition /// The last rotation computed (in LocalSkeleton Space). Used to smooth transition
CQuat _LastLSRotation; NLMISC::CQuat _LastLSRotation;
/// This tells that a Enable/Disable transition is in progress. /// This tells that a Enable/Disable transition is in progress.
bool _LastEnabled; bool _LastEnabled;
bool _EnableToDisableTransition; bool _EnableToDisableTransition;
CQuat getCurrentLSRotationFromBone(CSkeletonModel *model, CBone *bone); NLMISC::CQuat getCurrentLSRotationFromBone(CSkeletonModel *model, CBone *bone);
}; };

View file

@ -54,16 +54,16 @@ public:
bool isSharingEnabled() const { return !_DisableSharing; } bool isSharingEnabled() const { return !_DisableSharing; }
// set the ambiant/ diffuse color to be added to the embossed texture // set the ambiant/ diffuse color to be added to the embossed texture
void setAmbient(CRGBA ambient) { _Ambient = ambient; touch(); } void setAmbient(NLMISC::CRGBA ambient) { _Ambient = ambient; touch(); }
void setDiffuse(CRGBA diffuse) { _Diffuse = diffuse; touch(); } void setDiffuse(NLMISC::CRGBA diffuse) { _Diffuse = diffuse; touch(); }
// Set the direction of light (usually should be normalized). The bitmap is in the x,y plane // Set the direction of light (usually should be normalized). The bitmap is in the x,y plane
void setLightDir(const NLMISC::CVector &lightDir) { _LightDir = lightDir; touch(); } void setLightDir(const NLMISC::CVector &lightDir) { _LightDir = lightDir; touch(); }
// set a factor for the slope // set a factor for the slope
void setSlopeFactor(float factor) { _SlopeFactor = factor; touch(); } void setSlopeFactor(float factor) { _SlopeFactor = factor; touch(); }
// //
CRGBA getAmbient() const { return _Ambient; } NLMISC::CRGBA getAmbient() const { return _Ambient; }
CRGBA getDiffuse() const { return _Diffuse; } NLMISC::CRGBA getDiffuse() const { return _Diffuse; }
const CVector &getLightDir() const { return _LightDir; } const NLMISC::CVector &getLightDir() const { return _LightDir; }
float getSlopeFactor() const { return _SlopeFactor; } float getSlopeFactor() const { return _SlopeFactor; }
@ -75,8 +75,8 @@ protected:
// inherited from ITexture. Generate this bumpmap pixels // inherited from ITexture. Generate this bumpmap pixels
virtual void doGenerate(bool async = false); virtual void doGenerate(bool async = false);
NLMISC::CSmartPtr<ITexture> _HeightMap; NLMISC::CSmartPtr<ITexture> _HeightMap;
CRGBA _Ambient; NLMISC::CRGBA _Ambient;
CRGBA _Diffuse; NLMISC::CRGBA _Diffuse;
NLMISC::CVector _LightDir; NLMISC::CVector _LightDir;
bool _DisableSharing; bool _DisableSharing;
float _SlopeFactor; float _SlopeFactor;

View file

@ -140,7 +140,7 @@ public:
private: private:
void clearTile (CTile::TBitmap type); void clearTile (CTile::TBitmap type);
void free () void freeBlock ()
{ {
nlassert ((_Flags&=NL3D_CTILE_FREE_FLAG)==0); nlassert ((_Flags&=NL3D_CTILE_FREE_FLAG)==0);
_Flags|=NL3D_CTILE_FREE_FLAG; _Flags|=NL3D_CTILE_FREE_FLAG;

View file

@ -32,6 +32,7 @@ using NLMISC::CQuat;
class ILogicInfo; class ILogicInfo;
class CCluster; class CCluster;
class ITransformable;
// *************************************************************************** // ***************************************************************************
/** /**

View file

@ -48,7 +48,7 @@ public:
/// PointLights. Used at CVegetableManager::updateLighting() to get current colors of pointLights. /// PointLights. Used at CVegetableManager::updateLighting() to get current colors of pointLights.
CPointLightNamed *PointLight[MaxNumLight]; CPointLightNamed *PointLight[MaxNumLight];
/// Direction of the light. the direction to the instance should be precomputed. /// Direction of the light. the direction to the instance should be precomputed.
CVector Direction[MaxNumLight]; NLMISC::CVector Direction[MaxNumLight];
/// Factor to be multiplied by color of the light. Actually it is the attenuation factor. /// Factor to be multiplied by color of the light. Actually it is the attenuation factor.
uint PointLightFactor[MaxNumLight]; uint PointLightFactor[MaxNumLight];

View file

@ -69,7 +69,7 @@ public:
bool allocate(uint numVertices, uint &indexStart); bool allocate(uint numVertices, uint &indexStart);
/// free a subset of the VB. nlstop if subset not found... /// free a subset of the VB. nlstop if subset not found...
void free(uint indexStart); void freeBlock(uint indexStart);
// @} // @}

View file

@ -21,6 +21,7 @@
// //
#include "nel/3d/texture_cube.h" #include "nel/3d/texture_cube.h"
#include "nel/3d/texture_blank.h" #include "nel/3d/texture_blank.h"
#include "nel/3d/animation_time.h"
namespace NL3D namespace NL3D

View file

@ -79,7 +79,7 @@ public:
/** Set the userPos (relative to the height map coordinates). This is needed because a height map can't be used with large surface (such as a sea). /** Set the userPos (relative to the height map coordinates). This is needed because a height map can't be used with large surface (such as a sea).
* As a consequence, the height map is only valid below the user (e.g from user.x - 0.5 * size to user.x + 0.5 *size). * As a consequence, the height map is only valid below the user (e.g from user.x - 0.5 * size to user.x + 0.5 *size).
* When setPos is called, and if a move has occured, new area of the height field are set to 0 * When setPos is called, and if a move has occurred, new area of the height field are set to 0
* The pos set will be taken in account when buffers have been swapped (e.g when the propagation time as ellapsed) * The pos set will be taken in account when buffers have been swapped (e.g when the propagation time as ellapsed)
*/ */
void setUserPos(sint x, sint y); void setUserPos(sint x, sint y);

View file

@ -22,7 +22,7 @@
#include "form_elm.h" #include "form_elm.h"
#include "header.h" #include "header.h"
extern bool convertFormFile (const char *oldFileName, const char *newFileName); extern bool convertFormFile (const std::string &oldFileName, const std::string &newFileName);
namespace NLGEORGES namespace NLGEORGES
{ {
@ -35,7 +35,7 @@ class UFormElm;
class CForm : public UForm class CForm : public UForm
{ {
friend class CFormLoader; friend class CFormLoader;
friend bool convertFormFile (const char *oldFileName, const char *newFileName); friend bool convertFormFile (const std::string &oldFileName, const std::string &newFileName);
public: public:
enum { HeldElementCount = 4 }; enum { HeldElementCount = 4 };
@ -73,12 +73,12 @@ public:
// ** IO functions // ** IO functions
// Set the filename before saving the form // Set the filename before saving the form
void write (xmlDocPtr doc, const char *filename); void write (xmlDocPtr doc, const std::string &filename);
// ** Parent access // ** Parent access
// Insert parent before parent indexed "before". // Insert parent before parent indexed "before".
bool insertParent (uint before, const char *filename, CForm *parent); bool insertParent (uint before, const std::string &filename, CForm *parent);
// Remove a parent from parent list // Remove a parent from parent list
void removeParent (uint parent); void removeParent (uint parent);
@ -97,7 +97,7 @@ public:
const std::string &getFilename () const; const std::string &getFilename () const;
// Error handling // Error handling
void warning (bool exception, const char *function, const char *format, ... ) const; void warning (bool exception, const std::string &function, const char *format, ... ) const;
private: private:
@ -114,7 +114,7 @@ private:
// CFormLoader call it // CFormLoader call it
// Set the filename before reading the form // Set the filename before reading the form
void read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const char *filename); void read (xmlNodePtr node, CFormLoader &loader, CFormDfn *dfn, const std::string &filename);
// Called by read // Called by read
void readParent (const char *parent, CFormLoader &loader); void readParent (const char *parent, CFormLoader &loader);

View file

@ -24,7 +24,7 @@
#include "header.h" #include "header.h"
#include "type.h" #include "type.h"
bool convertDfnFile (const char *oldFileName, const char *newFileName); bool convertDfnFile (const std::string &oldFileName, const std::string &newFileName);
namespace NLGEORGES namespace NLGEORGES
{ {
@ -41,7 +41,7 @@ class CFormDfn : public UFormDfn
friend class CFormElm; friend class CFormElm;
friend class CFormLoader; friend class CFormLoader;
friend class CFormElmStruct; friend class CFormElmStruct;
friend bool convertDfnFile (const char *oldFileName, const char *newFileName); friend bool convertDfnFile (const std::string &oldFileName, const std::string &newFileName);
public: public:
// Default cstr // Default cstr
@ -60,7 +60,7 @@ public:
friend class CFormElm; friend class CFormElm;
friend class CFormDfn; friend class CFormDfn;
friend class CFormElmStruct; friend class CFormElmStruct;
friend bool convertDfnFile (const char *oldFileName, const char *newFileName); friend bool convertDfnFile (const std::string &oldFileName, const std::string &newFileName);
public: public:
CEntry () CEntry ()
@ -85,12 +85,12 @@ public:
TEntryType getType () const; TEntryType getType () const;
// Set as a type // Set as a type
void setType (CFormLoader &loader, const char *filename); void setType (CFormLoader &loader, const std::string &filename);
void setType (TEntryType type); void setType (TEntryType type);
// Set as a dfn // Set as a dfn
void setDfn (CFormLoader &loader, const char *filename); void setDfn (CFormLoader &loader, const std::string &filename);
// Set as a dfn pointer // Set as a dfn pointer
void setDfnPointer (); void setDfnPointer ();
@ -99,7 +99,7 @@ public:
const std::string &getName () const; const std::string &getName () const;
// Set element Name // Set element Name
void setName (const char *name); void setName (const std::string &name);
// Get the filename // Get the filename
const std::string &getFilename() const; const std::string &getFilename() const;
@ -108,16 +108,16 @@ public:
const std::string &getFilenameExt() const; const std::string &getFilenameExt() const;
// Set the filename // Set the filename
void setFilename (const char *def); void setFilename (const std::string &def);
// Set the filename extension // Set the filename extension
void setFilenameExt (const char *ext); void setFilenameExt (const std::string &ext);
// Get default value // Get default value
const std::string &getDefault () const; const std::string &getDefault () const;
// Set default value // Set default value
void setDefault (const char *def); void setDefault (const std::string &def);
// Set array flag // Set array flag
void setArrayFlag (bool flag); void setArrayFlag (bool flag);
@ -167,7 +167,7 @@ public:
void removeEntry( uint idx ); void removeEntry( uint idx );
// ** IO functions // ** IO functions
void write (xmlDocPtr root, const char *filename); void write (xmlDocPtr root, const std::string &filename);
// Count parent DFN // Count parent DFN
uint countParentDfn (uint32 round=0) const; uint countParentDfn (uint32 round=0) const;
@ -185,7 +185,7 @@ public:
void setNumParent (uint size); void setNumParent (uint size);
// Set a parent // Set a parent
void setParent (uint parent, CFormLoader &loader, const char *filename); void setParent (uint parent, CFormLoader &loader, const std::string &filename);
// Get a parent // Get a parent
CFormDfn *getParent (uint parent) const; CFormDfn *getParent (uint parent) const;
@ -232,7 +232,7 @@ public:
CFileHeader Header; CFileHeader Header;
// Error handling // Error handling
void warning (bool exception, const char *function, const char *format, ... ) const; void warning (bool exception, const std::string &function, const char *format, ... ) const;
private: private:
// The parents array // The parents array
@ -249,7 +249,7 @@ private:
private: private:
// Read method called by the form loader // Read method called by the form loader
void read (xmlNodePtr doc, CFormLoader &loader, bool forceLoad, const char *filename); void read (xmlNodePtr doc, CFormLoader &loader, bool forceLoad, const std::string &filename);
}; };
} // NLGEORGES } // NLGEORGES

View file

@ -62,30 +62,30 @@ public:
virtual void getFormName (std::string &result, const CFormElm *child=NULL) const = 0; virtual void getFormName (std::string &result, const CFormElm *child=NULL) const = 0;
// From UFormElm // From UFormElm
virtual bool getNodeByName (const UFormElm **result, const char *name, TWhereIsNode *where, bool verbose, uint32 round=0) const; virtual bool getNodeByName (const UFormElm **result, const std::string &name, TWhereIsNode *where, bool verbose, uint32 round=0) const;
virtual bool getNodeByName (UFormElm **result, const char *name, TWhereIsNode *where, bool verbose, uint32 round=0); virtual bool getNodeByName (UFormElm **result, const std::string &name, TWhereIsNode *where, bool verbose, uint32 round=0);
virtual bool getValueByName (std::string &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; virtual bool getValueByName (std::string &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const;
virtual bool getValueByName (sint8 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; virtual bool getValueByName (sint8 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const;
virtual bool getValueByName (uint8 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; virtual bool getValueByName (uint8 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const;
virtual bool getValueByName (sint16 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; virtual bool getValueByName (sint16 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const;
virtual bool getValueByName (uint16 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; virtual bool getValueByName (uint16 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const;
virtual bool getValueByName (sint32 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; virtual bool getValueByName (sint32 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const;
virtual bool getValueByName (uint32 &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; virtual bool getValueByName (uint32 &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const;
virtual bool getValueByName (float &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; virtual bool getValueByName (float &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const;
virtual bool getValueByName (double &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; virtual bool getValueByName (double &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const;
virtual bool getValueByName (bool &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; virtual bool getValueByName (bool &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const;
virtual bool getValueByName (NLMISC::CRGBA &result, const char *name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const; virtual bool getValueByName (NLMISC::CRGBA &result, const std::string &name, TEval evaluate, TWhereIsValue *where, uint32 round=0) const;
virtual bool setValueByName (const char *value, const char *name, bool *created); virtual bool setValueByName (const std::string &value, const std::string &name, bool *created);
virtual bool setValueByName (sint8 value, const char *name, bool *created); virtual bool setValueByName (sint8 value, const std::string &name, bool *created);
virtual bool setValueByName (uint8 value, const char *name, bool *created); virtual bool setValueByName (uint8 value, const std::string &name, bool *created);
virtual bool setValueByName (sint16 value, const char *name, bool *created); virtual bool setValueByName (sint16 value, const std::string &name, bool *created);
virtual bool setValueByName (uint16 value, const char *name, bool *created); virtual bool setValueByName (uint16 value, const std::string &name, bool *created);
virtual bool setValueByName (sint32 value, const char *name, bool *created); virtual bool setValueByName (sint32 value, const std::string &name, bool *created);
virtual bool setValueByName (uint32 value, const char *name, bool *created); virtual bool setValueByName (uint32 value, const std::string &name, bool *created);
virtual bool setValueByName (float value, const char *name, bool *created); virtual bool setValueByName (float value, const std::string &name, bool *created);
virtual bool setValueByName (double value, const char *name, bool *created); virtual bool setValueByName (double value, const std::string &name, bool *created);
virtual bool setValueByName (bool value, const char *name, bool *created); virtual bool setValueByName (bool value, const std::string &name, bool *created);
virtual bool setValueByName (NLMISC::CRGBA value, const char *name, bool *created); virtual bool setValueByName (NLMISC::CRGBA value, const std::string &name, bool *created);
virtual UFormElm *getParent () const; virtual UFormElm *getParent () const;
virtual const CType *getType (); virtual const CType *getType ();
virtual bool isArray () const; virtual bool isArray () const;
@ -127,16 +127,16 @@ public:
// ** Convert functions // ** Convert functions
inline bool convertValue (sint8 &result, const char *value) const; inline bool convertValue (sint8 &result, const std::string &value) const;
inline bool convertValue (uint8 &result, const char *value) const; inline bool convertValue (uint8 &result, const std::string &value) const;
inline bool convertValue (sint16 &result, const char *value) const; inline bool convertValue (sint16 &result, const std::string &value) const;
inline bool convertValue (uint16 &result, const char *value) const; inline bool convertValue (uint16 &result, const std::string &value) const;
inline bool convertValue (sint32 &result, const char *value) const; inline bool convertValue (sint32 &result, const std::string &value) const;
inline bool convertValue (uint32 &result, const char *value) const; inline bool convertValue (uint32 &result, const std::string &value) const;
inline bool convertValue (float &result, const char *value) const; inline bool convertValue (float &result, const std::string &value) const;
inline bool convertValue (double &result, const char *value) const; inline bool convertValue (double &result, const std::string &value) const;
inline bool convertValue (bool &result, const char *value) const; inline bool convertValue (bool &result, const std::string &value) const;
inline bool convertValue (NLMISC::CRGBA &result, const char *value) const; inline bool convertValue (NLMISC::CRGBA &result, const std::string &value) const;
// ** Get dependencies // ** Get dependencies
virtual void getDependencies (std::set<std::string> &dependencies) const = 0; virtual void getDependencies (std::set<std::string> &dependencies) const = 0;
@ -144,7 +144,7 @@ public:
// ** Internal node access // ** Internal node access
// Create a node by name. If the node already exists, return it // Create a node by name. If the node already exists, return it
bool createNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, bool createNodeByName (const std::string &, const CFormDfn **parentDfn, uint &indexDfn,
const CFormDfn **nodeDfn, const CType **nodeType, const CFormDfn **nodeDfn, const CType **nodeType,
CFormElm **node, UFormDfn::TEntryType &type, CFormElm **node, UFormDfn::TEntryType &type,
bool &array, bool &created); bool &array, bool &created);
@ -153,13 +153,13 @@ public:
* Delete a node by name. If the node already exists, return it * Delete a node by name. If the node already exists, return it
*Delete its parent if not used *Delete its parent if not used
*/ */
bool deleteNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, bool deleteNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn,
const CFormDfn **nodeDfn, const CType **nodeType, const CFormDfn **nodeDfn, const CType **nodeType,
CFormElm **node, UFormDfn::TEntryType &type, CFormElm **node, UFormDfn::TEntryType &type,
bool &array); bool &array);
// Search for a node by name // Search for a node by name
bool getNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, bool getNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn,
const CFormDfn **nodeDfn, const CType **nodeType, const CFormDfn **nodeDfn, const CType **nodeType,
CFormElm **node, UFormDfn::TEntryType &type, CFormElm **node, UFormDfn::TEntryType &type,
bool &array, bool &parentVDfnArray, bool verbose, uint32 round) const; bool &array, bool &parentVDfnArray, bool verbose, uint32 round) const;
@ -168,7 +168,7 @@ public:
* Insert an array node by name * Insert an array node by name
* The index asked must be < the size of the array. * The index asked must be < the size of the array.
*/ */
bool arrayInsertNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, bool arrayInsertNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn,
const CFormDfn **nodeDfn, const CType **nodeType, const CFormDfn **nodeDfn, const CType **nodeType,
CFormElm **node, UFormDfn::TEntryType &type, CFormElm **node, UFormDfn::TEntryType &type,
bool &array, bool verbose, uint arrayIndex) const; bool &array, bool verbose, uint arrayIndex) const;
@ -177,7 +177,7 @@ public:
* Delete an array node by name * Delete an array node by name
* The index asked must be < the size of the array. * The index asked must be < the size of the array.
*/ */
bool arrayDeleteNodeByName (const char *name, const CFormDfn **parentDfn, uint &indexDfn, bool arrayDeleteNodeByName (const std::string &name, const CFormDfn **parentDfn, uint &indexDfn,
const CFormDfn **nodeDfn, const CType **nodeType, const CFormDfn **nodeDfn, const CType **nodeType,
CFormElm **node, UFormDfn::TEntryType &type, CFormElm **node, UFormDfn::TEntryType &type,
bool &array, bool verbose, uint arrayIndex) const; bool &array, bool verbose, uint arrayIndex) const;
@ -199,7 +199,7 @@ protected:
* Then, else (*parentDfn / indexDfn ) or *node must be defined. * Then, else (*parentDfn / indexDfn ) or *node must be defined.
* Other values are for result only. * Other values are for result only.
*/ */
static bool getInternalNodeByName (CForm *form, const char *name, const CFormDfn **parentDfn, uint &indexDfn, static bool getInternalNodeByName (CForm *form, const std::string &name, const CFormDfn **parentDfn, uint &indexDfn,
const CFormDfn **nodeDfn, const CType **nodeType, const CFormDfn **nodeDfn, const CType **nodeType,
CFormElm **node, UFormDfn::TEntryType &type, CFormElm **node, UFormDfn::TEntryType &type,
bool &array, TNodeAction action, bool &created, bool &parentVDfnArray, bool verbose, uint32 round); bool &array, TNodeAction action, bool &created, bool &parentVDfnArray, bool verbose, uint32 round);
@ -215,7 +215,7 @@ public:
static const char* tokenize (const char *name, std::string &str, uint &errorIndex, uint &code); static const char* tokenize (const char *name, std::string &str, uint &errorIndex, uint &code);
// ** IO functions // ** IO functions
virtual xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName = NULL, bool forceWrite = false) const = 0; virtual xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName = "", bool forceWrite = false) const = 0;
protected: protected:
@ -235,8 +235,8 @@ protected:
uint32 Round; uint32 Round;
// Error handling // Error handling
static void warning (bool exception, const char *formName, const char *formFileName, const char *function, const char *format, ... ); static void warning (bool exception, const std::string &formName, const std::string &formFileName, const std::string &function, const char *format, ... );
virtual void warning (bool exception, const char *function, const char *format, ... ) const; virtual void warning (bool exception, const std::string &function, const char *format, ... ) const;
private: private:
// Tokens // Tokens
@ -298,7 +298,7 @@ public:
// From CFormElm // From CFormElm
bool isUsed (const CForm *form) const; bool isUsed (const CForm *form) const;
xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite = false) const; xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName, bool forceWrite = false) const;
void unlink (CFormElm *child); void unlink (CFormElm *child);
void getFormName (std::string &result, const CFormElm *child) const; void getFormName (std::string &result, const CFormElm *child) const;
void getDependencies (std::set<std::string> &dependencies) const; void getDependencies (std::set<std::string> &dependencies) const;
@ -310,7 +310,7 @@ public:
std::vector<CFormElmStructElm> Elements; std::vector<CFormElmStructElm> Elements;
// Error handling // Error handling
virtual void warning (bool exception, const char *function, const char *format, ... ) const; virtual void warning (bool exception, const std::string &function, const char *format, ... ) const;
}; };
/** /**
@ -332,13 +332,13 @@ public:
// From CFormElm // From CFormElm
bool isUsed (const CForm *form) const; bool isUsed (const CForm *form) const;
xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite = false) const; xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName, bool forceWrite = false) const;
// Call by CFormLoader // Call by CFormLoader
void read (xmlNodePtr node, CFormLoader &loader, CForm *form); void read (xmlNodePtr node, CFormLoader &loader, CForm *form);
// Error handling // Error handling
virtual void warning (bool exception, const char *function, const char *format, ... ) const; virtual void warning (bool exception, const std::string &function, const char *format, ... ) const;
}; };
/** /**
@ -377,7 +377,7 @@ public:
bool getArrayValue (NLMISC::CRGBA &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const; bool getArrayValue (NLMISC::CRGBA &result, uint arrayIndex, TEval evaluate, TWhereIsValue *where) const;
// From CFormElm // From CFormElm
xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite = false) const; xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName, bool forceWrite = false) const;
bool setParent (CFormElm *parent); bool setParent (CFormElm *parent);
void unlink (CFormElm *child); void unlink (CFormElm *child);
bool isUsed (const CForm *form) const; bool isUsed (const CForm *form) const;
@ -406,7 +406,7 @@ public:
std::vector<CElement> Elements; std::vector<CElement> Elements;
// Error handling // Error handling
virtual void warning (bool exception, const char *function, const char *format, ... ) const; virtual void warning (bool exception, const std::string &function, const char *format, ... ) const;
}; };
/** /**
@ -429,7 +429,7 @@ public:
const CType *Type; const CType *Type;
// From CFormElm // From CFormElm
xmlNodePtr write (xmlNodePtr node, const CForm *form, const char *structName, bool forceWrite = false) const; xmlNodePtr write (xmlNodePtr node, const CForm *form, const std::string &structName, bool forceWrite = false) const;
bool setParent (CFormElm *parent); bool setParent (CFormElm *parent);
void getFormName (std::string &result, const CFormElm *child) const; void getFormName (std::string &result, const CFormElm *child) const;
void getDependencies (std::set<std::string> &dependencies) const; void getDependencies (std::set<std::string> &dependencies) const;
@ -453,7 +453,7 @@ public:
bool getValue (NLMISC::CRGBA &result, TEval evaluate) const; bool getValue (NLMISC::CRGBA &result, TEval evaluate) const;
// Set the value, the elt been used // Set the value, the elt been used
void setValue (const char *value); void setValue (const std::string &value);
// Get the raw value. Does not care about any parent or default values // Get the raw value. Does not care about any parent or default values
void getValue (std::string &result) const; void getValue (std::string &result) const;
@ -463,14 +463,14 @@ private:
std::string Value; std::string Value;
// Error handling // Error handling
virtual void warning (bool exception, const char *function, const char *format, ... ) const; virtual void warning (bool exception, const std::string &function, const char *format, ... ) const;
}; };
// *************************************************************************** // ***************************************************************************
// CFormElm inlines // CFormElm inlines
// *************************************************************************** // ***************************************************************************
inline bool CFormElm::convertValue (sint8 &result, const char *value) const inline bool CFormElm::convertValue (sint8 &result, const std::string &value) const
{ {
float tmp; float tmp;
if (NLMISC::fromString(value, tmp)) if (NLMISC::fromString(value, tmp))
@ -482,14 +482,14 @@ inline bool CFormElm::convertValue (sint8 &result, const char *value) const
else else
{ {
// Error message // Error message
warning (false, "convertValue", "Can't convert the string \"%s\" in sint8.", value); warning (false, "convertValue", "Can't convert the string \"%s\" in sint8.", value.c_str());
} }
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
inline bool CFormElm::convertValue (uint8 &result, const char *value) const inline bool CFormElm::convertValue (uint8 &result, const std::string &value) const
{ {
float tmp; float tmp;
if (NLMISC::fromString(value, tmp)) if (NLMISC::fromString(value, tmp))
@ -501,14 +501,14 @@ inline bool CFormElm::convertValue (uint8 &result, const char *value) const
else else
{ {
// Error message // Error message
warning (false, "convertValue", "Can't convert the string \"%s\" in uint8.", value); warning (false, "convertValue", "Can't convert the string \"%s\" in uint8.", value.c_str());
} }
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
inline bool CFormElm::convertValue (sint16 &result, const char *value) const inline bool CFormElm::convertValue (sint16 &result, const std::string &value) const
{ {
float tmp; float tmp;
if (NLMISC::fromString(value, tmp)) if (NLMISC::fromString(value, tmp))
@ -520,14 +520,14 @@ inline bool CFormElm::convertValue (sint16 &result, const char *value) const
else else
{ {
// Error message // Error message
warning (false, "convertValue", "Can't convert the string \"%s\" in sint16.", value); warning (false, "convertValue", "Can't convert the string \"%s\" in sint16.", value.c_str());
} }
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
inline bool CFormElm::convertValue (uint16 &result, const char *value) const inline bool CFormElm::convertValue (uint16 &result, const std::string &value) const
{ {
float tmp; float tmp;
if (NLMISC::fromString(value, tmp)) if (NLMISC::fromString(value, tmp))
@ -539,14 +539,14 @@ inline bool CFormElm::convertValue (uint16 &result, const char *value) const
else else
{ {
// Error message // Error message
warning (false, "convertValue", "Can't convert the string \"%s\" in uint16.", value); warning (false, "convertValue", "Can't convert the string \"%s\" in uint16.", value.c_str());
} }
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
inline bool CFormElm::convertValue (sint32 &result, const char *value) const inline bool CFormElm::convertValue (sint32 &result, const std::string &value) const
{ {
float tmp; float tmp;
if (NLMISC::fromString(value, tmp)) if (NLMISC::fromString(value, tmp))
@ -558,14 +558,14 @@ inline bool CFormElm::convertValue (sint32 &result, const char *value) const
else else
{ {
// Error message // Error message
warning (false, "convertValue", "Can't convert the string \"%s\" in sint32.", value); warning (false, "convertValue", "Can't convert the string \"%s\" in sint32.", value.c_str());
} }
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
inline bool CFormElm::convertValue (uint32 &result, const char *value) const inline bool CFormElm::convertValue (uint32 &result, const std::string &value) const
{ {
float tmp; float tmp;
if (NLMISC::fromString(value, tmp)) if (NLMISC::fromString(value, tmp))
@ -577,14 +577,14 @@ inline bool CFormElm::convertValue (uint32 &result, const char *value) const
else else
{ {
// Error message // Error message
warning (false, "convertValue", "Can't convert the string \"%s\" in uint32.", value); warning (false, "convertValue", "Can't convert the string \"%s\" in uint32.", value.c_str());
} }
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
inline bool CFormElm::convertValue (float &result, const char *value) const inline bool CFormElm::convertValue (float &result, const std::string &value) const
{ {
if (NLMISC::fromString(value, result)) if (NLMISC::fromString(value, result))
{ {
@ -593,16 +593,16 @@ inline bool CFormElm::convertValue (float &result, const char *value) const
else else
{ {
// Error message // Error message
warning (false, "convertValue", "Can't convert the string \"%s\" in float.", value); warning (false, "convertValue", "Can't convert the string \"%s\" in float.", value.c_str());
} }
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
inline bool CFormElm::convertValue (double &result, const char *value) const inline bool CFormElm::convertValue (double &result, const std::string &value) const
{ {
float tmp; double tmp;
if (NLMISC::fromString(value, tmp)) if (NLMISC::fromString(value, tmp))
{ {
result = tmp; result = tmp;
@ -611,14 +611,14 @@ inline bool CFormElm::convertValue (double &result, const char *value) const
else else
{ {
// Error message // Error message
warning (false, "convertValue", "Can't convert the string \"%s\" in double.", value); warning (false, "convertValue", "Can't convert the string \"%s\" in double.", value.c_str());
} }
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
inline bool CFormElm::convertValue (bool &result, const char *value) const inline bool CFormElm::convertValue (bool &result, const std::string &value) const
{ {
int tmp; int tmp;
if (NLMISC::fromString(value, tmp)) if (NLMISC::fromString(value, tmp))
@ -628,7 +628,7 @@ inline bool CFormElm::convertValue (bool &result, const char *value) const
} }
else else
{ {
std::string temp = NLMISC::toLower(std::string(value)); std::string temp = NLMISC::toLower(value);
if (strcmp (temp.c_str (), "true") == 0) if (strcmp (temp.c_str (), "true") == 0)
{ {
result = true; result = true;
@ -642,17 +642,17 @@ inline bool CFormElm::convertValue (bool &result, const char *value) const
} }
// Error message // Error message
warning (false, "convertValue", "Can't convert the string \"%s\" in boolean.", value); warning (false, "convertValue", "Can't convert the string \"%s\" in boolean.", value.c_str());
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
inline bool CFormElm::convertValue (NLMISC::CRGBA &result, const char *value) const inline bool CFormElm::convertValue (NLMISC::CRGBA &result, const std::string &value) const
{ {
float r, g, b; float r, g, b;
if (sscanf (value, "%f,%f,%f", &r, &g, &b) == 3) if (sscanf (value.c_str(), "%f,%f,%f", &r, &g, &b) == 3)
{ {
NLMISC::clamp (r, 0.f, 255.f); NLMISC::clamp (r, 0.f, 255.f);
NLMISC::clamp (g, 0.f, 255.f); NLMISC::clamp (g, 0.f, 255.f);
@ -664,7 +664,7 @@ inline bool CFormElm::convertValue (NLMISC::CRGBA &result, const char *value) co
} }
// Error message // Error message
warning (false, "convertValue", "Can't convert the string \"%s\" in RGB color.", value); warning (false, "convertValue", "Can't convert the string \"%s\" in RGB color.", value.c_str());
return false; return false;
} }

View file

@ -42,18 +42,18 @@ class CFormLoader : public UFormLoader
public: public:
virtual ~CFormLoader(); virtual ~CFormLoader();
// From UFormLoader // From UFormLoader
UForm *loadForm (const char *filename); UForm *loadForm (const std::string &filename);
UFormDfn *loadFormDfn (const char *filename); UFormDfn *loadFormDfn (const std::string &filename);
UType *loadFormType (const char *filename); UType *loadFormType (const std::string &filename);
// Load type and formDfn // Load type and formDfn
CType *loadType (const char *filename); CType *loadType (const std::string &filename);
CFormDfn *loadFormDfn (const char *filename, bool forceLoad); CFormDfn *loadFormDfn (const std::string &filename, bool forceLoad);
private: private:
// Error handling // Error handling
virtual void warning (bool exception, const char *function, const char *format, ... ) const; virtual void warning (bool exception, const std::string &function, const char *format, ... ) const;
typedef std::map<std::string, NLMISC::CRefPtr<CType> > TTypeMap; typedef std::map<std::string, NLMISC::CRefPtr<CType> > TTypeMap;
typedef std::map<std::string, NLMISC::CRefPtr<CFormDfn> > TFormDfnMap; typedef std::map<std::string, NLMISC::CRefPtr<CFormDfn> > TFormDfnMap;

View file

@ -44,10 +44,10 @@ public:
}; };
/// Add a log /// Add a log
void addLog (const char *log); void addLog(const std::string &log);
/// Set the comment /// Set the comment
void setComments (const char *comments); void setComments (const std::string &comments);
/// Major version number /// Major version number
uint32 MajorVersion; uint32 MajorVersion;
@ -72,7 +72,7 @@ public:
static const char *getStateString (TState state); static const char *getStateString (TState state);
// Error handling // Error handling
void warning (bool exception, const char *function, const char *format, ... ) const; void warning (bool exception, const std::string &function, const char *format, ... ) const;
}; };
} // NLGEORGES } // NLGEORGES

View file

@ -385,7 +385,7 @@ void loadForm (const std::vector<std::string> &sheetFilters, const std::string &
} }
} }
if(NeededToRecompute.size() > 0) if(!NeededToRecompute.empty())
nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size()); nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size());
// free the georges loader if necessary // free the georges loader if necessary
@ -748,7 +748,7 @@ void loadForm2(const std::vector<std::string> &sheetFilters, const std::string &
} }
} }
if(NeededToRecompute.size() > 0) if(!NeededToRecompute.empty())
nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size()); nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size());
// free the georges loader if necessary // free the georges loader if necessary
@ -865,7 +865,7 @@ void loadForm (const std::vector<std::string> &sheetFilters, const std::string &
} }
// make sure the CSheetId singleton has been properly initialised // make sure the CSheetId singleton has been properly initialised
NLMISC::CSheetId::init(updatePackedSheet); // NLMISC::CSheetId::init(updatePackedSheet);
// load the packed sheet if exists // load the packed sheet if exists
try try
@ -1304,7 +1304,7 @@ void loadFormNoPackedSheet (const std::vector<std::string> &sheetFilters, std::m
} }
} }
if(NeededToRecompute.size() > 0) if(!NeededToRecompute.empty())
nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size()); nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size());
// free the georges loader if necessary // free the georges loader if necessary
@ -1393,7 +1393,7 @@ void loadFormNoPackedSheet2 (const std::vector<std::string> &sheetFilters, std::
} }
} }
if(NeededToRecompute.size() > 0) if(!NeededToRecompute.empty())
nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size()); nlinfo ("%d seconds to recompute %d sheets", (uint32)(NLMISC::CTime::getLocalTime()-start)/1000, NeededToRecompute.size());
// free the georges loader if necessary // free the georges loader if necessary

View file

@ -80,7 +80,7 @@ public:
// Evaluate a node // Evaluate a node
bool getValue (std::string &result, const class CForm *form, const class CFormElmAtom *node, const class CFormDfn &parentDfn, bool getValue (std::string &result, const class CForm *form, const class CFormElmAtom *node, const class CFormDfn &parentDfn,
uint parentIndex, UFormElm::TEval evaluate, uint32 *where, uint32 round, const char *formName) const; uint parentIndex, UFormElm::TEval evaluate, uint32 *where, uint32 round, const std::string &formName) const;
// Definitions // Definitions
class CDefinition class CDefinition
@ -114,8 +114,8 @@ public:
private: private:
// Error handling // Error handling
virtual void warning (bool exception, const char *formName, const char *formFilename, const char *function, const char *format, ... ) const; virtual void warning (bool exception, const std::string &formName, const std::string &formFilename, const std::string &function, const char *format, ... ) const;
virtual void warning2 (bool exception, const char *function, const char *format, ... ) const; virtual void warning2 (bool exception, const std::string &function, const char *format, ... ) const;
// Type names // Type names
static const char *TypeNames[]; static const char *TypeNames[];

View file

@ -78,8 +78,8 @@ public:
* "position.x" : get the element named x in the struct named position * "position.x" : get the element named x in the struct named position
* "entities[2].color" : get the node named color in the second element of the entities array * "entities[2].color" : get the node named color in the second element of the entities array
*/ */
virtual bool getNodeByName (const UFormElm **result, const char *name, TWhereIsNode *where = NULL, bool reserved=true, uint32 round=0) const = 0; virtual bool getNodeByName (const UFormElm **result, const std::string &name, TWhereIsNode *where = NULL, bool reserved=true, uint32 round=0) const = 0;
virtual bool getNodeByName (UFormElm **result, const char *name, TWhereIsNode *where = NULL, bool reserved=true, uint32 round=0) = 0; virtual bool getNodeByName (UFormElm **result, const std::string &name, TWhereIsNode *where = NULL, bool reserved=true, uint32 round=0) = 0;
/// Where a value has been found /// Where a value has been found
@ -104,19 +104,19 @@ public:
* \return true if the result has been filled, false if the value has not been found or the cast has failed or the evaluation has failed. * \return true if the result has been filled, false if the value has not been found or the cast has failed or the evaluation has failed.
* \see getNodeByName () * \see getNodeByName ()
*/ */
virtual bool getValueByName (std::string &result, const char *namename, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; virtual bool getValueByName (std::string &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0;
virtual bool getValueByName (sint8 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; virtual bool getValueByName (sint8 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0;
virtual bool getValueByName (uint8 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; virtual bool getValueByName (uint8 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0;
virtual bool getValueByName (sint16 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; virtual bool getValueByName (sint16 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0;
virtual bool getValueByName (uint16 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; virtual bool getValueByName (uint16 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0;
virtual bool getValueByName (sint32 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; virtual bool getValueByName (sint32 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0;
virtual bool getValueByName (uint32 &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; virtual bool getValueByName (uint32 &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0;
virtual bool getValueByName (float &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; virtual bool getValueByName (float &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0;
virtual bool getValueByName (double &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; virtual bool getValueByName (double &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0;
virtual bool getValueByName (bool &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; virtual bool getValueByName (bool &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0;
/// Warning, only R, G and B members are filled, not A. /// Warning, only R, G and B members are filled, not A.
virtual bool getValueByName (NLMISC::CRGBA &result, const char *name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0; virtual bool getValueByName (NLMISC::CRGBA &result, const std::string &name, TEval evaluate = Eval, TWhereIsValue *where = NULL, uint32 round=0) const = 0;
/** /**
* Set a form value with its name. If the node doesn't exist, it is created. * Set a form value with its name. If the node doesn't exist, it is created.
@ -129,17 +129,17 @@ public:
* true if the value has been created, false it the value has been filled. * true if the value has been created, false it the value has been filled.
* \return true if the value has been set, false if the value has not been found or hasn't been created. * \return true if the value has been set, false if the value has not been found or hasn't been created.
*/ */
virtual bool setValueByName (const char *value, const char *name, bool *created = NULL) = 0; virtual bool setValueByName (const std::string &value, const std::string &name, bool *created = NULL) = 0;
virtual bool setValueByName (sint8 value, const char *name, bool *created = NULL) = 0; virtual bool setValueByName (sint8 value, const std::string &name, bool *created = NULL) = 0;
virtual bool setValueByName (uint8 value, const char *name, bool *created = NULL) = 0; virtual bool setValueByName (uint8 value, const std::string &name, bool *created = NULL) = 0;
virtual bool setValueByName (sint16 value, const char *name, bool *created = NULL) = 0; virtual bool setValueByName (sint16 value, const std::string &name, bool *created = NULL) = 0;
virtual bool setValueByName (uint16 value, const char *name, bool *created = NULL) = 0; virtual bool setValueByName (uint16 value, const std::string &name, bool *created = NULL) = 0;
virtual bool setValueByName (sint32 value, const char *name, bool *created = NULL) = 0; virtual bool setValueByName (sint32 value, const std::string &name, bool *created = NULL) = 0;
virtual bool setValueByName (uint32 value, const char *name, bool *created = NULL) = 0; virtual bool setValueByName (uint32 value, const std::string &name, bool *created = NULL) = 0;
virtual bool setValueByName (float value, const char *name, bool *created = NULL) = 0; virtual bool setValueByName (float value, const std::string &name, bool *created = NULL) = 0;
virtual bool setValueByName (double value, const char *name, bool *created = NULL) = 0; virtual bool setValueByName (double value, const std::string &name, bool *created = NULL) = 0;
virtual bool setValueByName (bool value, const char *name, bool *created = NULL) = 0; virtual bool setValueByName (bool value, const std::string &name, bool *created = NULL) = 0;
virtual bool setValueByName (NLMISC::CRGBA value, const char *name, bool *created = NULL) = 0; virtual bool setValueByName (NLMISC::CRGBA value, const std::string &name, bool *created = NULL) = 0;
// ** Array element methods // ** Array element methods

View file

@ -43,19 +43,19 @@ public:
* *
* The pointer on the form must be held in a CSmartPtr<UForm>. Returns NULL if the form can't be loaded. * The pointer on the form must be held in a CSmartPtr<UForm>. Returns NULL if the form can't be loaded.
*/ */
virtual UForm *loadForm (const char *filename) = 0; virtual UForm *loadForm (const std::string &filename) = 0;
/** Load a DFN, use NMISC::CPath to find the file. /** Load a DFN, use NMISC::CPath to find the file.
* *
* The pointer on the form must be held in a CSmartPtr<UFormDfn>. Returns NULL if the DFN can't be loaded. * The pointer on the form must be held in a CSmartPtr<UFormDfn>. Returns NULL if the DFN can't be loaded.
*/ */
virtual UFormDfn *loadFormDfn (const char *filename) = 0; virtual UFormDfn *loadFormDfn (const std::string &filename) = 0;
/** Load a type, use NMISC::CPath to find the file. /** Load a type, use NMISC::CPath to find the file.
* *
* The pointer on the form must be held in a CSmartPtr<UType>. Returns NULL if the type can't be loaded. * The pointer on the form must be held in a CSmartPtr<UType>. Returns NULL if the type can't be loaded.
*/ */
virtual UType *loadFormType (const char *filename) = 0; virtual UType *loadFormType (const std::string &filename) = 0;
/// Create a form loader /// Create a form loader
static UFormLoader *createLoader (); static UFormLoader *createLoader ();

View file

@ -321,7 +321,7 @@ namespace NLGUI
// \name internal methods // \name internal methods
// Add a group in the current parent group // Add a group in the current parent group
void addGroup (CInterfaceGroup *group, uint beginSpace); void addHtmlGroup (CInterfaceGroup *group, uint beginSpace);
// Get the current parent group // Get the current parent group
CInterfaceGroup *getCurrentGroup(); CInterfaceGroup *getCurrentGroup();

View file

@ -191,6 +191,7 @@ namespace NLGUI
int luaGetLineFromId(CLuaState &ls); int luaGetLineFromId(CLuaState &ls);
int luaIsSeparator(CLuaState &ls); int luaIsSeparator(CLuaState &ls);
int luaAddLine(CLuaState &ls); int luaAddLine(CLuaState &ls);
int luaAddIconLine(CLuaState &ls);
int luaAddLineAtIndex(CLuaState &ls); int luaAddLineAtIndex(CLuaState &ls);
int luaAddSeparator(CLuaState &ls); int luaAddSeparator(CLuaState &ls);
int luaAddSeparatorAtIndex(CLuaState &ls); int luaAddSeparatorAtIndex(CLuaState &ls);
@ -210,6 +211,7 @@ namespace NLGUI
REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu); REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu);
REFLECT_LUA_METHOD("isSeparator", luaIsSeparator); REFLECT_LUA_METHOD("isSeparator", luaIsSeparator);
REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id
REFLECT_LUA_METHOD("addIconLine", luaAddIconLine); // name, ah, ah_params, id, texture
REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id
REFLECT_LUA_METHOD("addSeparator", luaAddSeparator); REFLECT_LUA_METHOD("addSeparator", luaAddSeparator);
REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex); REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex);
@ -278,6 +280,7 @@ namespace NLGUI
*/ */
CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const; CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const;
void initOptions(CInterfaceGroup *parent); void initOptions(CInterfaceGroup *parent);
CViewBitmap *createIcon(CInterfaceElement *parentPos, const std::string &texture);
CViewBitmap *createCheckBox(bool checked); CViewBitmap *createCheckBox(bool checked);
CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center); CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center);
}; };

View file

@ -206,12 +206,6 @@ namespace NLGUI
invalidateContent(); invalidateContent();
} }
// Set the HTML group used for links
void setBrowseGroup (CInterfaceElement *group)
{
_BrowseGroup = group;
}
/// \from CInterfaceElement /// \from CInterfaceElement
void onInvalidateContent(); void onInvalidateContent();
sint32 getMaxUsedW() const; sint32 getMaxUsedW() const;
@ -293,9 +287,6 @@ namespace NLGUI
// The links // The links
std::vector<CLink> _Links; std::vector<CLink> _Links;
// The HTML group used
CInterfaceElement *_BrowseGroup;
private: private:
std::string _HardText; std::string _HardText;
uint32 _TextId; uint32 _TextId;

View file

@ -64,7 +64,7 @@ namespace NLGUI
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
// to be called by CGroupTable // to be called by CGroupTable
bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex); bool parseCell (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex);
// If the cell is a new line. This is the first <td> after a <tr> // If the cell is a new line. This is the first <td> after a <tr>
bool NewLine; bool NewLine;

View file

@ -208,7 +208,7 @@ namespace NLGUI
CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, const std::pair<std::string, std::string> *templateParams, uint numParams, bool updateLinks = true); CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, const std::pair<std::string, std::string> *templateParams, uint numParams, bool updateLinks = true);
CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, std::vector<std::pair<std::string, std::string> > &templateParams, bool updateLinks = true) CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, std::vector<std::pair<std::string, std::string> > &templateParams, bool updateLinks = true)
{ {
if (templateParams.size() > 0) if (!templateParams.empty())
return createGroupInstance(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks); return createGroupInstance(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks);
else else
return createGroupInstance(templateName, parentID, NULL, 0, updateLinks); return createGroupInstance(templateName, parentID, NULL, 0, updateLinks);
@ -222,7 +222,7 @@ namespace NLGUI
CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, const std::pair<std::string,std::string> *templateParams, uint numParams, bool updateLinks /* = true */); CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, const std::pair<std::string,std::string> *templateParams, uint numParams, bool updateLinks /* = true */);
CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, std::vector<std::pair<std::string, std::string> > &templateParams, bool updateLinks = true) CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, std::vector<std::pair<std::string, std::string> > &templateParams, bool updateLinks = true)
{ {
if (templateParams.size() > 0) if (!templateParams.empty())
return createUIElement(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks); return createUIElement(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks);
else else
return createUIElement(templateName, parentID, NULL, 0, updateLinks); return createUIElement(templateName, parentID, NULL, 0, updateLinks);

View file

@ -72,8 +72,8 @@ namespace NLGUI
bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL ); bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL );
/// float operations /// float operations
void setDouble (double value) {setSInt64((sint64&) value);} void setDouble(double value);
double getDouble () const {sint64 i = getSInt64(); return (double &) i; } double getDouble() const;
void readDouble (const char* value, const std::string& id); void readDouble (const char* value, const std::string& id);
/// sint32 operations /// sint32 operations

View file

@ -90,7 +90,7 @@ namespace NLGUI
virtual std::string luaWhat() const throw() {return NLMISC::toString("LUAError: %s", what());} virtual std::string luaWhat() const throw() {return NLMISC::toString("LUAError: %s", what());}
}; };
// A parse error occured // A parse error occurred
class ELuaParseError : public ELuaError class ELuaParseError : public ELuaError
{ {
public: public:
@ -117,7 +117,7 @@ namespace NLGUI
std::string _Reason; std::string _Reason;
}; };
// A execution error occured // A execution error occurred
class ELuaExecuteError : public ELuaError class ELuaExecuteError : public ELuaError
{ {
public: public:
@ -128,7 +128,7 @@ namespace NLGUI
virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaExecuteError: %s", what());} virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaExecuteError: %s", what());}
}; };
// A bad cast occured when using lua_checkcast // A bad cast occurred when using lua_checkcast
class ELuaBadCast : public ELuaError class ELuaBadCast : public ELuaError
{ {
public: public:

View file

@ -50,10 +50,21 @@ namespace NLGUI
void setHTMLView( CGroupHTML *html); void setHTMLView( CGroupHTML *html);
bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col); bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col);
void setActionOnLeftClick(const std::string &actionHandler) { _AHOnLeftClick = actionHandler; };
void setParamsOnLeftClick(const std::string &actionParams) { _AHOnLeftClickParams = actionParams; };
const std::string &getActionOnLeftClick() const { return _AHOnLeftClick; }
const std::string &getParamsOnLeftClick() const { return _AHOnLeftClickParams; }
protected: protected:
// The main HTML group // The main HTML group
CGroupHTML *HTML; CGroupHTML *HTML;
// Left mouse click action
// Don't use CStringShared as URLs change past values would be permanently remembered.
std::string _AHOnLeftClick;
std::string _AHOnLeftClickParams;
}; };
} }

View file

@ -38,14 +38,17 @@ namespace NLGUI
void resetPointerPos (); void resetPointerPos ();
void setPointerDown (bool pd); void setPointerDown (bool pd);
void setPointerMiddleDown (bool pd);
void setPointerRightDown (bool pd);
void setPointerDownString (const std::string &s); void setPointerDownString (const std::string &s);
void getPointerPos (sint32 &x, sint32 &y); void getPointerPos (sint32 &x, sint32 &y);
void getPointerDispPos (sint32 &x, sint32 &y); void getPointerDispPos (sint32 &x, sint32 &y);
void getPointerOldPos (sint32 &x, sint32 &y); void getPointerOldPos (sint32 &x, sint32 &y);
void getPointerDownPos (sint32 &x, sint32 &y); bool getPointerDown (sint32 &x, sint32 &y);
bool getPointerDown (); bool getPointerMiddleDown (sint32 &x, sint32 &y);
bool getPointerRightDown (sint32 &x, sint32 &y);
std::string getPointerDownString (); std::string getPointerDownString ();
bool getPointerDrag (); bool getPointerDrag ();
@ -70,6 +73,12 @@ namespace NLGUI
bool _PointerDown; // Is the pointer down ? bool _PointerDown; // Is the pointer down ?
sint32 _PointerDownX; // Pointer down position sint32 _PointerDownX; // Pointer down position
sint32 _PointerDownY; sint32 _PointerDownY;
bool _PointerMiddleDown; // Is the middle pointer down ?
sint32 _PointerMiddleDownX; // Pointer middle down position
sint32 _PointerMiddleDownY;
bool _PointerRightDown; // Is the right pointer down ?
sint32 _PointerRightDownX; // Pointer right down position
sint32 _PointerRightDownY;
std::string _PointerDownString; // What is under the pointer at the down position std::string _PointerDownString; // What is under the pointer at the down position
bool _PointerDrag; // Is the pointer down and we have moved ? bool _PointerDrag; // Is the pointer down and we have moved ?
bool _PointerVisible; // Is the pointer visible or hidden ? bool _PointerVisible; // Is the pointer visible or hidden ?

View file

@ -502,7 +502,7 @@ namespace NLGUI
const CEventDescriptorKey& getLastKeyEvent() const{ return lastKeyEvent; } const CEventDescriptorKey& getLastKeyEvent() const{ return lastKeyEvent; }
IParser* getParser() const{ return parser; } IParser* getParser() const{ return _Parser; }
/// Retrieves the Id of the currently selected widgets /// Retrieves the Id of the currently selected widgets
void getEditorSelection( std::vector< std::string > &selection ); void getEditorSelection( std::vector< std::string > &selection );
@ -536,7 +536,7 @@ namespace NLGUI
CWidgetManager(); CWidgetManager();
~CWidgetManager(); ~CWidgetManager();
IParser *parser; IParser *_Parser;
static CWidgetManager *instance; static CWidgetManager *instance;
std::vector< SMasterGroup > _MasterGroups; std::vector< SMasterGroup > _MasterGroups;

View file

@ -49,13 +49,13 @@ public:
* This file will try to open the file ligo class description file (XML) using the LigoClass as file name. * This file will try to open the file ligo class description file (XML) using the LigoClass as file name.
* It will try first to load directly the file and then to lookup the file in NLMISC::CPath. * It will try first to load directly the file and then to lookup the file in NLMISC::CPath.
*/ */
bool readConfigFile (const char *fileName, bool parsePrimitiveComboContent); bool readConfigFile (const std::string &fileName, bool parsePrimitiveComboContent);
/** /**
* This file will read the file ligo class description file (XML) using the LigoClass as file name. * This file will read the file ligo class description file (XML) using the LigoClass as file name.
* It will try first to load directly the file and then to lookup the file in NLMISC::CPath. * It will try first to load directly the file and then to lookup the file in NLMISC::CPath.
*/ */
bool readPrimitiveClass (const char *fileName, bool parsePrimitiveComboContent); bool readPrimitiveClass (const std::string &fileName, bool parsePrimitiveComboContent);
bool reloadIndexFile(const std::string &indexFileName = std::string()); bool reloadIndexFile(const std::string &indexFileName = std::string());
@ -100,14 +100,14 @@ public:
/// Build a standard human readable alias string /// Build a standard human readable alias string
std::string aliasToString(uint32 fullAlias); std::string aliasToString(uint32 fullAlias);
/// Read a standard human readable alias string /// Read a standard human readable alias string
uint32 aliasFromString(std::string fullAlias); uint32 aliasFromString(const std::string &fullAlias);
// Get a primitive class // Get a primitive class
const CPrimitiveClass *getPrimitiveClass (const NLLIGO::IPrimitive &primitive) const; const CPrimitiveClass *getPrimitiveClass (const NLLIGO::IPrimitive &primitive) const;
// Get a primitive class // Get a primitive class
const CPrimitiveClass *getPrimitiveClass (const char *className) const; const CPrimitiveClass *getPrimitiveClass (const std::string &className) const;
// Get the primitive color // Get the primitive color
NLMISC::CRGBA getPrimitiveColor (const NLLIGO::IPrimitive &primitive); NLMISC::CRGBA getPrimitiveColor (const NLLIGO::IPrimitive &primitive);
@ -134,10 +134,10 @@ public:
bool canBeRoot (const NLLIGO::IPrimitive &primitive); bool canBeRoot (const NLLIGO::IPrimitive &primitive);
// Read a property from an XML file // Read a property from an XML file
bool getPropertyString (std::string &result, const char *filename, xmlNodePtr xmlNode, const char *propName); bool getPropertyString (std::string &result, const std::string &filename, xmlNodePtr xmlNode, const std::string &propName);
// Output error message // Output error message
void syntaxError (const char *filename, xmlNodePtr xmlNode, const char *format, ...); void syntaxError (const std::string &filename, xmlNodePtr xmlNode, const char *format, ...);
virtual void errorMessage (const char *format, ... ); virtual void errorMessage (const char *format, ... );
// Access to the config string // Access to the config string
@ -157,7 +157,7 @@ public:
private: private:
// Init primitive class manager // Init primitive class manager
bool initPrimitiveClass (const char *filename); bool initPrimitiveClass (const std::string &ilename);
// The primitive class manager // The primitive class manager
std::map<std::string, CPrimitiveClass> _PrimitiveClasses; std::map<std::string, CPrimitiveClass> _PrimitiveClasses;

View file

@ -18,7 +18,7 @@
#define NL_MATERIAL_LIGO_H #define NL_MATERIAL_LIGO_H
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "zone_template.h" #include "nel/ligo/zone_template.h"
// NeL include // NeL include
//#include "3d/zone.h" //#include "3d/zone.h"

View file

@ -83,9 +83,8 @@ class CPropertyString : public IProperty
{ {
public: public:
CPropertyString () {} CPropertyString () {}
CPropertyString (const char *str);
CPropertyString (const std::string &str); CPropertyString (const std::string &str);
CPropertyString (const char *str, bool _default); CPropertyString (const std::string &str, bool _default);
virtual ~CPropertyString () {} virtual ~CPropertyString () {}
std::string String; std::string String;
@ -287,42 +286,42 @@ public:
* If the property already exist, the method does nothing and returns false. * If the property already exist, the method does nothing and returns false.
* The pointer will be deleted by the primitive using the ::delete operator. * The pointer will be deleted by the primitive using the ::delete operator.
**/ **/
bool addPropertyByName (const char *property_name, IProperty *result); bool addPropertyByName (const std::string &property_name, IProperty *result);
/** /**
* Get a property with its name * Get a property with its name
**/ **/
bool getPropertyByName (const char *property_name, const IProperty *&result) const; bool getPropertyByName (const std::string &property_name, const IProperty *&result) const;
/** /**
* Get a property with its name * Get a property with its name
**/ **/
bool getPropertyByName (const char *property_name, IProperty *&result) const; bool getPropertyByName (const std::string &property_name, IProperty *&result) const;
/** /**
* Get a string property with its name. Return false if the property is not found or is not a string property. * Get a string property with its name. Return false if the property is not found or is not a string property.
**/ **/
bool getPropertyByName (const char *property_name, std::string *&result) const; bool getPropertyByName (const std::string &property_name, std::string *&result) const;
/** /**
* Get a string array property with its name. Return false if the property is not found or is not a string array property. * Get a string array property with its name. Return false if the property is not found or is not a string array property.
**/ **/
bool getPropertyByName (const char *property_name, std::vector<std::string> *&result) const; bool getPropertyByName (const std::string &property_name, std::vector<std::string> *&result) const;
/** /**
* Get a string property with its name. Return false if the property is not found or is not a string property. * Get a string property with its name. Return false if the property is not found or is not a string property.
**/ **/
bool getPropertyByName (const char *property_name, std::string &result) const; bool getPropertyByName (const std::string &property_name, std::string &result) const;
/** /**
* Get a string array property with its name. Return false if the property is not found or is not a string array property. * Get a string array property with its name. Return false if the property is not found or is not a string array property.
**/ **/
bool getPropertyByName (const char *property_name, const std::vector<std::string> *&result) const; bool getPropertyByName (const std::string &property_name, const std::vector<std::string> *&result) const;
/** /**
* Get a color property with its name. Return false if the property is not found or is not a string array property. * Get a color property with its name. Return false if the property is not found or is not a string array property.
**/ **/
bool getPropertyByName (const char *property_name, NLMISC::CRGBA &result) const; bool getPropertyByName (const std::string &property_name, NLMISC::CRGBA &result) const;
/** /**
* Remove a property * Remove a property
@ -333,7 +332,7 @@ public:
/** /**
* Remove a property by its name * Remove a property by its name
**/ **/
bool removePropertyByName (const char *property_name); bool removePropertyByName (const std::string &property_name);
/** /**
* Remove all the properties * Remove all the properties
@ -347,10 +346,10 @@ public:
void initDefaultValues (CLigoConfig &config); void initDefaultValues (CLigoConfig &config);
// Read the primitive, calls initDefaultValue (CLigoConfig &config) // Read the primitive, calls initDefaultValue (CLigoConfig &config)
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &property_name, uint version, CLigoConfig &config);
// Write the primitive // Write the primitive
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &property_name) const;
// Get the vertices // Get the vertices
virtual uint getNumVector () const = 0; virtual uint getNumVector () const = 0;
@ -435,7 +434,7 @@ protected:
virtual CPrimVector *getPrimVector (); virtual CPrimVector *getPrimVector ();
// Read the primitive // Read the primitive
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config);
// \name From IPrimitive // \name From IPrimitive
virtual IPrimitive *copy () const; virtual IPrimitive *copy () const;
@ -474,10 +473,10 @@ protected:
virtual CPrimVector *getPrimVector (); virtual CPrimVector *getPrimVector ();
// Read the primitive // Read the primitive
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config);
// Write the primitive // Write the primitive
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// \name From IPrimitive // \name From IPrimitive
virtual IPrimitive *copy () const; virtual IPrimitive *copy () const;
@ -509,10 +508,10 @@ protected:
virtual CPrimVector *getPrimVector (); virtual CPrimVector *getPrimVector ();
// Read the primitive // Read the primitive
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config);
// Write the primitive // Write the primitive
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// \name From IPrimitive // \name From IPrimitive
virtual IPrimitive *copy () const; virtual IPrimitive *copy () const;
@ -568,10 +567,10 @@ protected:
virtual CPrimVector *getPrimVector (); virtual CPrimVector *getPrimVector ();
// Read the primitive // Read the primitive
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config);
// Write the primitive // Write the primitive
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// \name From IPrimitive // \name From IPrimitive
virtual IPrimitive *copy () const; virtual IPrimitive *copy () const;
@ -632,9 +631,9 @@ public:
uint32 getFullAlias() const; uint32 getFullAlias() const;
// Read the primitive // Read the primitive
virtual bool read (xmlNodePtr xmlNode, const char *filename, uint version, CLigoConfig &config); virtual bool read (xmlNodePtr xmlNode, const std::string &filename, uint version, CLigoConfig &config);
// Write the primitive // Write the primitive
virtual void write (xmlNodePtr xmlNode, const char *filename) const; virtual void write (xmlNodePtr xmlNode, const std::string &filename) const;
// Create a copy of this primitive // Create a copy of this primitive
virtual IPrimitive *copy () const; virtual IPrimitive *copy () const;
// serial for binary save // serial for binary save
@ -686,13 +685,13 @@ public:
void convert (const CPrimRegion &region); void convert (const CPrimRegion &region);
// Read the primitive // Read the primitive
bool read (xmlNodePtr xmlNode, const char *filename, CLigoConfig &config); bool read (xmlNodePtr xmlNode, const std::string &filename, CLigoConfig &config);
// Write the primitive // Write the primitive
void write (xmlDocPtr xmlNode, const char *filename) const; void write (xmlDocPtr xmlNode, const std::string &filename) const;
// Write the primitive // Write the primitive
void write (xmlNodePtr root, const char *filename) const; void write (xmlNodePtr root, const std::string &filename) const;
// serial the primitive. Used for binary files. // serial the primitive. Used for binary files.
void serial(NLMISC::IStream &f); void serial(NLMISC::IStream &f);

View file

@ -108,6 +108,7 @@ namespace NLMISC
{ {
public: public:
CApplicationContext(); CApplicationContext();
virtual ~CApplicationContext();
virtual void *getSingletonPointer(const std::string &singletonName); virtual void *getSingletonPointer(const std::string &singletonName);
virtual void setSingletonPointer(const std::string &singletonName, void *ptr); virtual void setSingletonPointer(const std::string &singletonName, void *ptr);

View file

@ -112,7 +112,8 @@ public:
// A BNP structure // A BNP structure
struct BNP struct BNP
{ {
BNP() : FileNames(NULL), ThreadFileId(0), CacheFileOnOpen(false), AlwaysOpened(false), InternalUse(false), OffsetFromBeginning(0) { } BNP();
~BNP();
// FileName of the BNP. important to open it in getFile() (for other threads or if not always opened). // FileName of the BNP. important to open it in getFile() (for other threads or if not always opened).
std::string BigFileName; std::string BigFileName;
@ -163,6 +164,7 @@ private:
{ {
public: public:
CThreadFileArray(); CThreadFileArray();
~CThreadFileArray();
// Allocate a FileId for a BNP. // Allocate a FileId for a BNP.
uint32 allocate(); uint32 allocate();

View file

@ -636,11 +636,17 @@ public:
/** Get the pixel at the given coorrdinate. /** Get the pixel at the given coordinate.
* Works in RGBA and DXTC modes. * Works in RGBA and DXTC modes.
* Outside of the bitmap it returns Black (or if mipmap is not found) * Outside of the bitmap it returns Black (or if mipmap is not found)
*/ */
CRGBA getPixelColor(sint x, sint y, uint32 numMipMap = 0) const; CRGBA getPixelColor(sint x, sint y, uint32 numMipMap = 0) const;
/** Set the pixel at the given coordinate.
* Works in RGBA mode only.
*/
void setPixelColor(sint x, sint y, CRGBA c, uint32 numMipMap = 0);
/** /**
* Horizontal flip (all the columns are flipped) * Horizontal flip (all the columns are flipped)
* Works only with RGBA, and DXTC formats (only if w/h is a power of 2) * Works only with RGBA, and DXTC formats (only if w/h is a power of 2)

View file

@ -132,7 +132,7 @@ public:
} }
/// delete an element allocated with this manager. dtor is called. NULL is tested. /// delete an element allocated with this manager. dtor is called. NULL is tested.
void free(T* ptr) void freeBlock(T* ptr)
{ {
if(!ptr) if(!ptr)
return; return;

View file

@ -40,20 +40,20 @@ public:
/// Return the value of the property. /// Return the value of the property.
inline sint64 getValue64() { return _Property; } inline sint64 getValue64() const { return _Property; }
/// Set the value of the property (set '_Changed' flag with 'true'). /// Set the value of the property (set '_Changed' flag with 'true').
void setValue64 (sint64 prop); void setValue64 (sint64 prop);
inline sint32 getValue32() { return *((sint32*)&_Property); } inline sint32 getValue32() const { return (sint32)(_Property & 0xffffffff); }
void setValue32 (sint32 prop); void setValue32 (sint32 prop);
inline sint16 getValue16() { return *((sint16*)&_Property); } inline sint16 getValue16() const { return (sint16)(_Property & 0xffff); }
void setValue16 (sint16 prop); void setValue16 (sint16 prop);
inline sint8 getValue8() { return *((sint8*)&_Property); } inline sint8 getValue8() const { return (sint8)(_Property & 0xff); }
void setValue8 (sint8 prop); void setValue8 (sint8 prop);
inline bool getValueBool() { return (_Property!=(sint64)0 ); } inline bool getValueBool() const { return (_Property!=(sint64)0 ); }
void setValueBool (bool prop); void setValueBool (bool prop);
inline CRGBA getValueRGBA() inline CRGBA getValueRGBA() const
{ {
CRGBA col; CRGBA col;
col.R = (uint8)(_Property&0xff); col.R = (uint8)(_Property&0xff);
@ -65,11 +65,11 @@ public:
void setValueRGBA (const CRGBA &color); void setValueRGBA (const CRGBA &color);
/// Return the value of the property before the database change /// Return the value of the property before the database change
inline sint64 getOldValue64() { return _oldProperty; } inline sint64 getOldValue64() const { return _oldProperty; }
inline sint32 getOldValue32() { return *((sint32*)&_oldProperty); } inline sint32 getOldValue32() const { return (sint32)(_oldProperty & 0xffffffff); }
inline sint16 getOldValue16() { return *((sint16*)&_oldProperty); } inline sint16 getOldValue16() const { return (sint16)(_oldProperty & 0xffff); }
inline sint8 getOldValue8() { return *((sint8*)&_oldProperty); } inline sint8 getOldValue8() const { return (sint8)(_oldProperty & 0xff); }
inline bool getOldValueBool() { return (_oldProperty!=(sint64)0 ); } inline bool getOldValueBool() const { return (_oldProperty!=(sint64)0 ); }
/// Return the type of the property. /// Return the type of the property.

View file

@ -201,7 +201,9 @@ namespace NLMISC
*/ */
void sleep(uint milliseconds); void sleep(uint milliseconds);
/** Release internal instance.
*/
static void releaseInstance();
}; };

View file

@ -286,6 +286,15 @@ inline sint nlstricmp(const char *lhs, const std::string &rhs) { return stricmp(
#define wideToUtf8(str) (ucstring((ucchar*)str).toUtf8()) #define wideToUtf8(str) (ucstring((ucchar*)str).toUtf8())
#define utf8ToWide(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str()) #define utf8ToWide(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str())
// macros helper to convert UTF-8 std::string and TCHAR*
#ifdef _UNICODE
#define tStrToUtf8(str) (ucstring((ucchar*)(LPCWSTR)str).toUtf8())
#define utf8ToTStr(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str())
#else
#define tStrToUtf8(str) (std::string((LPCSTR)str))
#define utf8ToTStr(str) (str.c_str())
#endif
// wrapper for fopen to be able to open files with an UTF-8 filename // wrapper for fopen to be able to open files with an UTF-8 filename
FILE* nlfopen(const std::string &filename, const std::string &mode); FILE* nlfopen(const std::string &filename, const std::string &mode);
@ -469,6 +478,22 @@ template <class T> void explode (const T &src, const T &sep, std::vector<T> &res
while(pos != std::string::npos); while(pos != std::string::npos);
} }
/** Join a string (or ucstring) from a vector of strings with *sep* as separator. If sep can be more than 1 char, in this case,
* we find the entire sep to separator (it s not a set of possible separator)
*/
template <class T, class U> void join(const std::vector<T>& strings, const U& separator, T &res)
{
res.clear();
for (uint i = 0, len = strings.size(); i<len; ++i)
{
// add in separators before all but the first string
if (!res.empty()) res += separator;
// append next string
res += strings[i];
}
}
/* All the code above is used to add our types (uint8, ...) in the stringstream (used by the toString() function). /* All the code above is used to add our types (uint8, ...) in the stringstream (used by the toString() function).
* So we can use stringstream operator << and >> with all NeL simple types (except for ucchar and ucstring) * So we can use stringstream operator << and >> with all NeL simple types (except for ucchar and ucstring)
@ -665,10 +690,10 @@ inline int nlisprint(int c)
#endif #endif
// Open an url in a browser // Open an url in a browser
bool openURL (const char *url); bool openURL (const std::string &url);
// Open a document // Open a document
bool openDoc (const char *document); bool openDoc (const std::string &document);
// AntiBug method that return an epsilon if x==0, else x // AntiBug method that return an epsilon if x==0, else x
inline float favoid0(float x) inline float favoid0(float x)
@ -689,6 +714,25 @@ inline T iavoid0(T x)
return x; return x;
} }
// Helper to convert in memory between types of different sizes
union C64BitsParts
{
// unsigned
uint64 u64[1];
uint32 u32[2];
uint16 u16[4];
uint8 u8[8];
// signed
sint64 i64[1];
sint32 i32[2];
sint16 i16[4];
sint8 i8[8];
// floats
double d[1];
float f[2];
};
} // NLMISC } // NLMISC

View file

@ -55,7 +55,7 @@ public:
// allocated a block of n bytes // allocated a block of n bytes
void *alloc(uint numBytes); void *alloc(uint numBytes);
// deallocate a block // deallocate a block
void free(void *block, uint numBytes); void freeBlock(void *block, uint numBytes);
// compute the total number of bytes allocated since init // compute the total number of bytes allocated since init
// NB : freed block are not subtracted from that total !! // NB : freed block are not subtracted from that total !!
uint getNumAllocatedBytes() const { return _NumAllocatedBytes; } uint getNumAllocatedBytes() const { return _NumAllocatedBytes; }

View file

@ -151,8 +151,8 @@ void setCrashAlreadyReported(bool state);
* Note 2 : To show a warning under GCC, use #warning "Your warning here", * Note 2 : To show a warning under GCC, use #warning "Your warning here",
* see nel/net/net_manager.h for an example on how to use these correctly. * see nel/net/net_manager.h for an example on how to use these correctly.
*/ */
#define NL_LOC_MSG __FILE__"("NL_MACRO_TO_STR(__LINE__)") : Message: " #define NL_LOC_MSG __FILE__ "(" NL_MACRO_TO_STR(__LINE__) ") : Message: "
#define NL_LOC_WRN __FILE__"("NL_MACRO_TO_STR(__LINE__)") : Warning Msg: " #define NL_LOC_WRN __FILE__ "(" NL_MACRO_TO_STR(__LINE__) ") : Warning Msg: "
/** /**

View file

@ -45,7 +45,7 @@ public:
/// alloc a block /// alloc a block
void *alloc(); void *alloc();
/// destroy and dealloc a block /// destroy and dealloc a block
void free(void *block); void freeBlock(void *block);
// //
uint getNumBytesPerBlock() const { return _NumBytesPerBlock; } uint getNumBytesPerBlock() const { return _NumBytesPerBlock; }
uint getNumBlockPerChunk() const { return _NumBlockPerChunk; } uint getNumBlockPerChunk() const { return _NumBlockPerChunk; }

View file

@ -65,7 +65,7 @@ public:
*/ */
void *allocate(uint size); void *allocate(uint size);
/// free a block allocated with alloate(). no-op if NULL. nlstop() if don't find this block. /// free a block allocated with alloate(). no-op if NULL. nlstop() if don't find this block.
void free(void *ptr); void freeBlock(void *ptr);
// ********************* // *********************

View file

@ -120,11 +120,11 @@ public:
/** Get the first child node pointer named childName. NULL if no node named childName. /** Get the first child node pointer named childName. NULL if no node named childName.
*/ */
static xmlNodePtr getFirstChildNode (xmlNodePtr parent, const char *childName); static xmlNodePtr getFirstChildNode (xmlNodePtr parent, const std::string &childName);
/** Get the next child node pointer name childName, brother of previous. NULL if no node named childName. /** Get the next child node pointer name childName, brother of previous. NULL if no node named childName.
*/ */
static xmlNodePtr getNextChildNode (xmlNodePtr last, const char *childName); static xmlNodePtr getNextChildNode (xmlNodePtr last, const std::string &childName);
/** Get the first child node pointer of type. NULL if no node of type. /** Get the first child node pointer of type. NULL if no node of type.
*/ */
@ -136,7 +136,7 @@ public:
/** Count number of sub node named with a given name for a given node. /** Count number of sub node named with a given name for a given node.
*/ */
static uint countChildren (xmlNodePtr node, const char *childName); static uint countChildren (xmlNodePtr node, const std::string &childName);
/** Count number of sub node of type for a given node. /** Count number of sub node of type for a given node.
*/ */
@ -147,22 +147,22 @@ public:
* *
* Returns true and the result if the property has been found, else false. * Returns true and the result if the property has been found, else false.
*/ */
static bool getPropertyString (std::string &result, xmlNodePtr node, const char *property); static bool getPropertyString (std::string &result, xmlNodePtr node, const std::string &property);
/** /**
* Read an integer property - if the property is not found the default value is returned * Read an integer property - if the property is not found the default value is returned
*/ */
static int getIntProperty(xmlNodePtr node, const char *property, int defaultValue); static int getIntProperty(xmlNodePtr node, const std::string &property, int defaultValue);
/** /**
* Read a floating point property - if the property is not found the default value is returned * Read a floating point property - if the property is not found the default value is returned
*/ */
static double getFloatProperty(xmlNodePtr node, const char *property, float defaultValue); static double getFloatProperty(xmlNodePtr node, const std::string &property, float defaultValue);
/** /**
* Read a string property - if the property is not found the default value is returned * Read a string property - if the property is not found the default value is returned
*/ */
static std::string getStringProperty(xmlNodePtr node, const char *property, const std::string& defaultValue); static std::string getStringProperty(xmlNodePtr node, const std::string &property, const std::string& defaultValue);
/** /**
* Read the content of the node as a string * Read the content of the node as a string
@ -171,6 +171,11 @@ public:
*/ */
static bool getContentString (std::string &result, xmlNodePtr node); static bool getContentString (std::string &result, xmlNodePtr node);
/**
* Release meory used by libxml2, to only call before exit.
*/
static void releaseLibXml();
private: private:
/// From IStream /// From IStream
@ -193,12 +198,12 @@ private:
virtual void serialBuffer(uint8 *buf, uint len); virtual void serialBuffer(uint8 *buf, uint len);
virtual void serialBit(bool &bit); virtual void serialBit(bool &bit);
virtual bool xmlPushBeginInternal (const char *nodeName); virtual bool xmlPushBeginInternal (const std::string &nodeName);
virtual bool xmlPushEndInternal (); virtual bool xmlPushEndInternal ();
virtual bool xmlPopInternal (); virtual bool xmlPopInternal ();
virtual bool xmlSetAttribInternal (const char *attribName); virtual bool xmlSetAttribInternal (const std::string &attribName);
virtual bool xmlBreakLineInternal (); virtual bool xmlBreakLineInternal ();
virtual bool xmlCommentInternal (const char *comment); virtual bool xmlCommentInternal (const std::string &comment);
// Internal functions // Internal functions
void serialSeparatedBufferIn ( std::string &value, bool checkSeparator = true ); void serialSeparatedBufferIn ( std::string &value, bool checkSeparator = true );

View file

@ -46,7 +46,7 @@ public:
double getSamplingPeriod() const { return _SamplingPeriod; } double getSamplingPeriod() const { return _SamplingPeriod; }
// Reset smoother. The next returned position will be the exact position of mouse (no smoothing with previous position is done) // Reset smoother. The next returned position will be the exact position of mouse (no smoothing with previous position is done)
void reset(); void reset();
// \return trueif no sampling has occured since last resetor construction // \return trueif no sampling has occurred since last resetor construction
bool isReseted() const { return !_Init; } bool isReseted() const { return !_Init; }
// Sample pos, and return smoothed position // Sample pos, and return smoothed position
CVector2f samplePos(const CVector2f &wantedPos, double date); CVector2f samplePos(const CVector2f &wantedPos, double date);

View file

@ -95,7 +95,7 @@ public:
* \param version is the version to write in the XML header. Default is 1.0. * \param version is the version to write in the XML header. Default is 1.0.
* \return true if initialisation is successful, false if the stream passed is not an output stream. * \return true if initialisation is successful, false if the stream passed is not an output stream.
*/ */
bool init (IStream *stream, const char *version="1.0"); bool init (IStream *stream, const std::string &version = "1.0");
/** Return the error string. /** Return the error string.
* if not empty, something wrong appends * if not empty, something wrong appends
@ -120,7 +120,7 @@ public:
/** Return true if the string is valid to be stored in a XML property without modification. /** Return true if the string is valid to be stored in a XML property without modification.
*/ */
static bool isStringValidForProperties (const char *str); static bool isStringValidForProperties (const std::string &str);
private: private:
@ -144,15 +144,15 @@ private:
virtual void serialBuffer(uint8 *buf, uint len); virtual void serialBuffer(uint8 *buf, uint len);
virtual void serialBit(bool &bit); virtual void serialBit(bool &bit);
virtual bool xmlPushBeginInternal (const char *nodeName); virtual bool xmlPushBeginInternal (const std::string &nodeName);
virtual bool xmlPushEndInternal (); virtual bool xmlPushEndInternal ();
virtual bool xmlPopInternal (); virtual bool xmlPopInternal ();
virtual bool xmlSetAttribInternal (const char *attribName); virtual bool xmlSetAttribInternal (const std::string &attribName);
virtual bool xmlBreakLineInternal (); virtual bool xmlBreakLineInternal ();
virtual bool xmlCommentInternal (const char *comment); virtual bool xmlCommentInternal (const std::string &comment);
// Internal functions // Internal functions
void serialSeparatedBufferOut( const char *value ); void serialSeparatedBufferOut( const std::string &value );
inline void flushContentString (); inline void flushContentString ();
// Push mode // Push mode

View file

@ -49,7 +49,7 @@ public:
*/ */
void *alloc(uint size); void *alloc(uint size);
// free an object that has previously been allocated with alloc. size should be remembered by the caller. // free an object that has previously been allocated with alloc. size should be remembered by the caller.
void free(void *); void freeBlock(void *);
// get the number of allocated objects // get the number of allocated objects
uint getNumAllocatedBlocks() const; uint getNumAllocatedBlocks() const;
# ifdef NL_DEBUG # ifdef NL_DEBUG
@ -82,7 +82,11 @@ private:
// NL_USES_DEFAULT_ARENA_OBJECT_ALLOCATOR // for fast alloc // NL_USES_DEFAULT_ARENA_OBJECT_ALLOCATOR // for fast alloc
# define NL_USES_DEFAULT_ARENA_OBJECT_ALLOCATOR \ # define NL_USES_DEFAULT_ARENA_OBJECT_ALLOCATOR \
void *operator new(size_t size) { return NLMISC::CObjectArenaAllocator::getDefaultAllocator().alloc((uint) size); }\ void *operator new(size_t size) { return NLMISC::CObjectArenaAllocator::getDefaultAllocator().alloc((uint) size); }\
void operator delete(void *block) { NLMISC::CObjectArenaAllocator::getDefaultAllocator().free(block); } void *operator new(size_t size, int _BlockUse, char const* _FileName, int _LineNumber) { return NLMISC::CObjectArenaAllocator::getDefaultAllocator().alloc((uint) size); }\
void *operator new(size_t size, char const* _FileName, int _LineNumber) { return NLMISC::CObjectArenaAllocator::getDefaultAllocator().alloc((uint) size); }\
void operator delete(void *block) { NLMISC::CObjectArenaAllocator::getDefaultAllocator().freeBlock(block); }\
void operator delete(void *block, int _BlockUse, char const* _FileName, int _LineNumber) { NLMISC::CObjectArenaAllocator::getDefaultAllocator().freeBlock(block); } \
void operator delete(void *block, char const* _FileName, int _LineNumber) { NLMISC::CObjectArenaAllocator::getDefaultAllocator().freeBlock(block); }
} }

View file

@ -209,7 +209,7 @@ public:
* \param relativePath is the path to make relative to basePath. * \param relativePath is the path to make relative to basePath.
* return true if relativePath as been done relative to basePath, false is relativePath has not been changed. * return true if relativePath as been done relative to basePath, false is relativePath has not been changed.
*/ */
bool makePathRelative (const char *basePath, std::string &relativePath); bool makePathRelative (const std::string &basePath, std::string &relativePath);
/** If File in this list is added more than one in an addSearchPath, it doesn't launch a warning. /** If File in this list is added more than one in an addSearchPath, it doesn't launch a warning.
*/ */
@ -505,7 +505,7 @@ public:
* \param relativePath is the path to make relative to basePath. * \param relativePath is the path to make relative to basePath.
* return true if relativePath as been done relative to basePath, false is relativePath has not been changed. * return true if relativePath as been done relative to basePath, false is relativePath has not been changed.
*/ */
static bool makePathRelative (const char *basePath, std::string &relativePath); static bool makePathRelative(const std::string &basePath, std::string &relativePath);
/** Make path absolute /** Make path absolute
* \param relativePath - The relative path * \param relativePath - The relative path

View file

@ -90,7 +90,7 @@ public:
/* /*
* Free all the elements allocated since last free(). Memory is kept for next allocations. * Free all the elements allocated since last free(). Memory is kept for next allocations.
*/ */
void free () void freeBlock ()
{ {
typename std::list< std::vector<T> >::iterator ite=_BlockList.begin(); typename std::list< std::vector<T> >::iterator ite=_BlockList.begin();
while (ite!=_BlockList.end()) while (ite!=_BlockList.end())

View file

@ -108,7 +108,7 @@ template <class TPtr, class TKey, class TResourceFinder>
class CResourcePtr class CResourcePtr
{ {
private: private:
CRefCount::CPtrInfo *pinfo; // A ptr to the handle of the object. CRefCount::CPtrInfoBase *pinfo; // A ptr to the handle of the object.
TKey Key; // The key used to find the pointer TKey Key; // The key used to find the pointer
mutable TPtr *Ptr; // A cache for pinfo->Ptr. Useful to speed up ope->() and ope*() mutable TPtr *Ptr; // A cache for pinfo->Ptr. Useful to speed up ope->() and ope*()

View file

@ -61,7 +61,7 @@ template <class TPtr, class TKey, class TResourceFinder> SMART_INLINE void CReso
if(pinfo->Ptr) if(pinfo->Ptr)
{ {
// Inform the Object that no more CResourcePtr points on it. // Inform the Object that no more CResourcePtr points on it.
((TPtr*)(pinfo->Ptr))->pinfo= static_cast<CRefCount::CPtrInfo*>(&CRefCount::NullPtrInfo); ((TPtr*)(pinfo->Ptr))->pinfo = &CRefCount::NullPtrInfo;
} }
// Then delete the pinfo. // Then delete the pinfo.
delete pinfo; delete pinfo;
@ -74,7 +74,7 @@ template <class TPtr, class TKey, class TResourceFinder> SMART_INLINE void CReso
// Cons - dest. // Cons - dest.
template <class TPtr, class TKey, class TResourceFinder> inline CResourcePtr<TPtr, TKey, TResourceFinder>::CResourcePtr() template <class TPtr, class TKey, class TResourceFinder> inline CResourcePtr<TPtr, TKey, TResourceFinder>::CResourcePtr()
{ {
pinfo= static_cast<CRefCount::CPtrInfo*>(&CRefCount::NullPtrInfo); pinfo = &CRefCount::NullPtrInfo;
Ptr= NULL; Ptr= NULL;
REF_TRACE("Smart()"); REF_TRACE("Smart()");
@ -95,7 +95,7 @@ template <class TPtr, class TKey, class TResourceFinder> inline CResourcePtr<TPt
pinfo->RefCount++; pinfo->RefCount++;
} }
else else
pinfo= static_cast<CRefCount::CPtrInfo*>(&CRefCount::NullPtrInfo); pinfo = &CRefCount::NullPtrInfo;
REF_TRACE("Smart(TPtr*)"); REF_TRACE("Smart(TPtr*)");
} }
@ -117,7 +117,7 @@ template <class TPtr, class TKey, class TResourceFinder> inline CResourcePtr<TPt
REF_TRACE("~Smart()"); REF_TRACE("~Smart()");
unRef(); unRef();
pinfo= static_cast<CRefCount::CPtrInfo*>(&CRefCount::NullPtrInfo); pinfo = &CRefCount::NullPtrInfo;
Ptr= NULL; Ptr= NULL;
} }
@ -142,7 +142,7 @@ template <class TPtr, class TKey, class TResourceFinder> CResourcePtr<TPtr, TKey
else else
{ {
unRef(); unRef();
pinfo= static_cast<CRefCount::CPtrInfo*>(&CRefCount::NullPtrInfo); pinfo = &CRefCount::NullPtrInfo;
} }
@ -179,7 +179,7 @@ template <class TPtr, class TKey, class TResourceFinder> void CResourcePtr<T>::k
// First, release the refptr. // First, release the refptr.
unRef(); unRef();
pinfo= static_cast<CRefCount::CPtrInfo*>(&CRefCount::NullPtrInfo); pinfo = &CRefCount::NullPtrInfo;
Ptr= NULL; Ptr= NULL;
// Then delete the pointer. // Then delete the pointer.
@ -196,7 +196,7 @@ template <class TPtr, class TKey, class TResourceFinder> inline CResourcePtr<TPt
// Refresh the Ptr. // Refresh the Ptr.
Ptr= (TPtr*)pinfo->Ptr; Ptr= (TPtr*)pinfo->Ptr;
if (pinfo != static_cast<CRefCount::CPtrInfo*>(&CRefCount::NullPtrInfo)) if (pinfo != &CRefCount::NullPtrInfo)
{ {
// Does the pointer has been deleted ? // Does the pointer has been deleted ?
if (Ptr == NULL) if (Ptr == NULL)
@ -310,7 +310,7 @@ template <class TPtr, class TKey, class TResourceFinder> void CStaticResourcePtr
// First, release the refptr. // First, release the refptr.
unRef(); unRef();
pinfo= static_cast<CRefCount::CPtrInfo*>(&CRefCount::NullPtrInfo); pinfo = &CRefCount::NullPtrInfo;
Ptr= NULL; Ptr= NULL;
// Then delete the pointer. // Then delete the pointer.

View file

@ -29,7 +29,7 @@ struct CHashKey
CHashKey (const unsigned char Message_Digest[20]) CHashKey (const unsigned char Message_Digest[20])
{ {
HashKeyString = ""; HashKeyString.clear();
for(sint i = 0; i < 20 ; ++i) for(sint i = 0; i < 20 ; ++i)
{ {
HashKeyString += Message_Digest[i]; HashKeyString += Message_Digest[i];
@ -45,7 +45,7 @@ struct CHashKey
} }
else if (str.size() == 40) else if (str.size() == 40)
{ {
HashKeyString = ""; HashKeyString.clear();
for(uint i = 0; i < str.size(); i+=2) for(uint i = 0; i < str.size(); i+=2)
{ {
uint8 val; uint8 val;

Some files were not shown because too many files have changed in this diff Show more