diff --git a/code/CMakeModules/FindMySQL.cmake b/code/CMakeModules/FindMySQL.cmake index b9970f63c..a00e36992 100644 --- a/code/CMakeModules/FindMySQL.cmake +++ b/code/CMakeModules/FindMySQL.cmake @@ -54,10 +54,14 @@ ELSE(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES) IF(MYSQL_INCLUDE_DIR) IF(MYSQL_LIBRARY_RELEASE) - SET(MYSQL_LIBRARIES "optimized;${MYSQL_LIBRARY_RELEASE}") + SET(MYSQL_LIBRARIES optimized ${MYSQL_LIBRARY_RELEASE}) IF(MYSQL_LIBRARY_DEBUG) - SET(MYSQL_LIBRARIES "${MYSQL_LIBRARIES};debug;${MYSQL_LIBRARY_DEBUG}") + SET(MYSQL_LIBRARIES ${MYSQL_LIBRARIES} debug ${MYSQL_LIBRARY_DEBUG}) ENDIF(MYSQL_LIBRARY_DEBUG) + FIND_PACKAGE(OpenSSL) + IF(OPENSSL_FOUND) + SET(MYSQL_LIBRARIES ${MYSQL_LIBRARIES} ${OPENSSL_LIBRARIES}) + ENDIF(OPENSSL_FOUND) ENDIF(MYSQL_LIBRARY_RELEASE) ENDIF(MYSQL_INCLUDE_DIR) diff --git a/code/CMakeModules/GetRevision.cmake b/code/CMakeModules/GetRevision.cmake index ee3fa2e90..d38215aba 100644 --- a/code/CMakeModules/GetRevision.cmake +++ b/code/CMakeModules/GetRevision.cmake @@ -25,7 +25,8 @@ MACRO(NOW RESULT) STRING(REGEX REPLACE ".*\n([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).*" "\\1-\\2-\\3 \\4:\\5:\\6" ${RESULT} "${DATETIME}") ENDIF(NOT DATETIME MATCHES "ERROR") ELSEIF(UNIX) - EXECUTE_PROCESS(COMMAND "date" "+'%Y-%m-%d %H:%M:%S'" OUTPUT_VARIABLE ${RESULT}) + EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE DATETIME) + STRING(REGEX REPLACE "([0-9: -]+).*" "\\1" ${RESULT} "${DATETIME}") ELSE (WIN32) MESSAGE(SEND_ERROR "date not implemented") SET(${RESULT} "0000-00-00 00:00:00") diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 846ba4039..e6bf57101 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -1,3 +1,11 @@ +# Force Release configuration for compiler checks +SET(CMAKE_TRY_COMPILE_CONFIGURATION "Release") + +# Force Release configuration by default +IF(NOT CMAKE_BUILD_TYPE) + SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) +ENDIF(NOT CMAKE_BUILD_TYPE) + ### # Helper macro that generates .pc and installs it. # Argument: name - the name of the .pc package, e.g. "nel-pacs.pc" @@ -5,7 +13,11 @@ MACRO(NL_GEN_PC name) IF(NOT WIN32 AND WITH_INSTALL_LIBRARIES) CONFIGURE_FILE(${name}.in "${CMAKE_CURRENT_BINARY_DIR}/${name}") - INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}" DESTINATION lib/pkgconfig) + IF(CMAKE_LIBRARY_ARCHITECTURE) + INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}" DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig) + ELSE(CMAKE_LIBRARY_ARCHITECTURE) + INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}" DESTINATION lib/pkgconfig) + ENDIF(CMAKE_LIBRARY_ARCHITECTURE) ENDIF(NOT WIN32 AND WITH_INSTALL_LIBRARIES) ENDMACRO(NL_GEN_PC) @@ -186,7 +198,7 @@ Remove the CMakeCache.txt file and try again from another folder, e.g.: rm CMakeCache.txt mkdir cmake cd cmake - cmake -G \"Unix Makefiles\" .. + cmake .. ") ENDIF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) @@ -231,6 +243,17 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) ### # Optional support ### + + # Check if CMake is launched from a Debian packaging script + SET(DEB_HOST_GNU_CPU $ENV{DEB_HOST_GNU_CPU}) + + # Don't strip if generating a .deb + IF(DEB_HOST_GNU_CPU) + OPTION(WITH_SYMBOLS "Keep debug symbols in binaries" ON ) + ELSE(DEB_HOST_GNU_CPU) + OPTION(WITH_SYMBOLS "Keep debug symbols in binaries" OFF) + ENDIF(DEB_HOST_GNU_CPU) + IF(WIN32) OPTION(WITH_STLPORT "With STLport support." ON ) ELSE(WIN32) @@ -334,6 +357,12 @@ MACRO(NL_SETUP_BUILD) SET(HOST_CPU ${CMAKE_SYSTEM_PROCESSOR}) + IF(HOST_CPU MATCHES "amd64") + SET(HOST_CPU "x86_64") + ELSEIF(HOST_CPU MATCHES "i.86") + SET(HOST_CPU "x86") + ENDIF(HOST_CPU MATCHES "amd64") + # Determine target CPU IF(NOT TARGET_CPU) SET(TARGET_CPU $ENV{DEB_HOST_GNU_CPU}) @@ -376,19 +405,27 @@ MACRO(NL_SETUP_BUILD) IF(TARGET_CPU STREQUAL "x86_64") SET(TARGET_X64 1) - SET(PLATFORM_CFLAGS "-DHAVE_X86_64") + SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DHAVE_X86_64") ELSEIF(TARGET_CPU STREQUAL "x86") SET(TARGET_X86 1) - SET(PLATFORM_CFLAGS "-DHAVE_X86") + SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DHAVE_X86") ENDIF(TARGET_CPU STREQUAL "x86_64") # Fix library paths suffixes for Debian MultiArch - IF(NOT CMAKE_LIBRARY_ARCHITECTURE) - SET(CMAKE_LIBRARY_ARCHITECTURE $ENV{DEB_HOST_MULTIARCH}) - ENDIF(NOT CMAKE_LIBRARY_ARCHITECTURE) + SET(DEBIAN_MULTIARCH $ENV{DEB_HOST_MULTIARCH}) + + IF(DEBIAN_MULTIARCH) + SET(CMAKE_LIBRARY_ARCHITECTURE ${DEBIAN_MULTIARCH}) + ENDIF(DEBIAN_MULTIARCH) IF(CMAKE_LIBRARY_ARCHITECTURE) - SET(CMAKE_LIBRARY_PATH "/lib/${CMAKE_LIBRARY_ARCHITECTURE};/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE};${CMAKE_LIBRARY_PATH}") + SET(CMAKE_LIBRARY_PATH /lib/${CMAKE_LIBRARY_ARCHITECTURE} /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_PATH}) + IF(TARGET_X64) + SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib64 /usr/lib64) + ENDIF(TARGET_X64) + IF(TARGET_X86) + SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib32 /usr/lib32) + ENDIF(TARGET_X86) ENDIF(CMAKE_LIBRARY_ARCHITECTURE) IF(MSVC) @@ -411,10 +448,10 @@ MACRO(NL_SETUP_BUILD) MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}") ENDIF(MSVC10) - SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zi /Zm1000 /MP /Gy-") + SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zm1000 /MP /Gy-") # Common link flags - SET(PLATFORM_LINKFLAGS "-DEBUG") + SET(PLATFORM_LINKFLAGS "") IF(TARGET_X64) # Fix a bug with Intellisense @@ -429,10 +466,17 @@ MACRO(NL_SETUP_BUILD) # Exceptions are only set for C++ SET(PLATFORM_CXXFLAGS "${PLATFORM_CFLAGS} /EHa") - SET(NL_DEBUG_CFLAGS "/MDd /RTC1 /D_DEBUG ${MIN_OPTIMIZATIONS}") - SET(NL_RELEASE_CFLAGS "/MD /D NDEBUG ${SPEED_OPTIMIZATIONS}") - SET(NL_DEBUG_LINKFLAGS "/NODEFAULTLIB:msvcrt /INCREMENTAL:YES") - SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO") + IF(WITH_SYMBOLS) + SET(NL_RELEASE_CFLAGS "/Zi ${NL_RELEASE_CFLAGS}") + SET(NL_RELEASE_LINKFLAGS "/DEBUG ${NL_RELEASE_LINKFLAGS}") + ELSE(WITH_SYMBOLS) + SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}") + ENDIF(WITH_SYMBOLS) + + SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${MIN_OPTIMIZATIONS} ${NL_DEBUG_CFLAGS}") + SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${SPEED_OPTIMIZATIONS} ${NL_RELEASE_CFLAGS}") + SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt /INCREMENTAL:YES ${NL_DEBUG_LINKFLAGS}") + SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}") ELSE(MSVC) IF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86") SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -m32 -march=i686") @@ -442,7 +486,11 @@ MACRO(NL_SETUP_BUILD) SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -m64") ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64") - SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -g -D_REENTRANT -pipe -ftemplate-depth-48 -Wall -ansi -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused -fno-strict-aliasing") + SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -D_REENTRANT -pipe -ftemplate-depth-48 -Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused -fno-strict-aliasing") + + IF(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -ansi") + ENDIF(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") IF(WITH_COVERAGE) SET(PLATFORM_CFLAGS "-fprofile-arcs -ftest-coverage ${PLATFORM_CFLAGS}") @@ -463,8 +511,16 @@ MACRO(NL_SETUP_BUILD) SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--no-undefined -Wl,--as-needed") ENDIF(NOT APPLE) - SET(NL_DEBUG_CFLAGS "-DNL_DEBUG -D_DEBUG") - SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O6") + IF(WITH_SYMBOLS) + SET(NL_RELEASE_CFLAGS "${NL_RELEASE_CFLAGS} -g") + ELSE(WITH_SYMBOLS) + IF(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + SET(NL_RELEASE_LINKFLAGS "-Wl,-s ${NL_RELEASE_LINKFLAGS}") + ENDIF(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + ENDIF(WITH_SYMBOLS) + + SET(NL_DEBUG_CFLAGS "-DNL_DEBUG -D_DEBUG ${NL_DEBUG_CFLAGS}") + SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O3 ${NL_RELEASE_CFLAGS}") ENDIF(MSVC) ENDMACRO(NL_SETUP_BUILD) @@ -615,30 +671,41 @@ MACRO(SETUP_EXTERNAL) ENDIF(WITH_EXTERNAL) IF(WIN32) - INCLUDE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake) + FIND_PACKAGE(External REQUIRED) + IF(MSVC10) IF(NOT MSVC10_REDIST_DIR) # If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist SET(MSVC10_REDIST_DIR "${EXTERNAL_PATH}/redist") ENDIF(NOT MSVC10_REDIST_DIR) - GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0_Config;InstallDir]" ABSOLUTE) - # VC_ROOT_DIR is set to "registry" when a key is not found - IF(VC_ROOT_DIR MATCHES "registry") - GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VCExpress\\10.0_Config;InstallDir]" ABSOLUTE) - IF(VC_ROOT_DIR MATCHES "registry") - MESSAGE(FATAL_ERROR "Unable to find VC++ 2010 directory!") - ENDIF(VC_ROOT_DIR MATCHES "registry") - ENDIF(VC_ROOT_DIR MATCHES "registry") - # convert IDE fullpath to VC++ path - STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR}) - ELSE(MSVC10) - IF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") + + IF(NOT VC_DIR) + IF(NOT VC_ROOT_DIR) + GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0_Config;InstallDir]" ABSOLUTE) + # VC_ROOT_DIR is set to "registry" when a key is not found + IF(VC_ROOT_DIR MATCHES "registry") + GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VCExpress\\10.0_Config;InstallDir]" ABSOLUTE) + IF(VC_ROOT_DIR MATCHES "registry") + FILE(TO_CMAKE_PATH $ENV{VS100COMNTOOLS} VC_ROOT_DIR) + IF(NOT VC_ROOT_DIR) + MESSAGE(FATAL_ERROR "Unable to find VC++ 2010 directory!") + ENDIF(NOT VC_ROOT_DIR) + ENDIF(VC_ROOT_DIR MATCHES "registry") + ENDIF(VC_ROOT_DIR MATCHES "registry") + ENDIF(NOT VC_ROOT_DIR) # convert IDE fullpath to VC++ path - STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${CMAKE_MAKE_PROGRAM}) - ELSE(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") - # convert compiler fullpath to VC++ path - STRING(REGEX REPLACE "VC/bin/.+" "VC" VC_DIR ${CMAKE_CXX_COMPILER}) - ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") + STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR}) + ENDIF(NOT VC_DIR) + ELSE(MSVC10) + IF(NOT VC_DIR) + IF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") + # convert IDE fullpath to VC++ path + STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${CMAKE_MAKE_PROGRAM}) + ELSE(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") + # convert compiler fullpath to VC++ path + STRING(REGEX REPLACE "VC/bin/.+" "VC" VC_DIR ${CMAKE_CXX_COMPILER}) + ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7") + ENDIF(NOT VC_DIR) ENDIF(MSVC10) ELSE(WIN32) IF(APPLE) @@ -659,12 +726,12 @@ MACRO(SETUP_EXTERNAL) IF(WITH_STLPORT) FIND_PACKAGE(STLport REQUIRED) INCLUDE_DIRECTORIES(${STLPORT_INCLUDE_DIR}) - IF(WIN32) + IF(MSVC) SET(VC_INCLUDE_DIR "${VC_DIR}/include") FIND_PACKAGE(WindowsSDK REQUIRED) # use VC++ and Windows SDK include paths INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR} ${WINSDK_INCLUDE_DIR}) - ENDIF(WIN32) + ENDIF(MSVC) ENDIF(WITH_STLPORT) ENDMACRO(SETUP_EXTERNAL) diff --git a/code/nel/include/nel/3d/computed_string.h b/code/nel/include/nel/3d/computed_string.h index 16fe70fcb..914fa324e 100644 --- a/code/nel/include/nel/3d/computed_string.h +++ b/code/nel/include/nel/3d/computed_string.h @@ -27,12 +27,16 @@ #include #include +namespace NLMISC { + +class CMatrix; + +} namespace NL3D { class CTextureFont; -class CMatrix; struct CComputedString; // *************************************************************************** diff --git a/code/nel/include/nel/3d/cube_grid.h b/code/nel/include/nel/3d/cube_grid.h index 427aed624..483ea8000 100644 --- a/code/nel/include/nel/3d/cube_grid.h +++ b/code/nel/include/nel/3d/cube_grid.h @@ -227,7 +227,7 @@ void CCubeGrid::compile() // build the _StaticGrid _StaticGrids[i].build(_Grids[i]); // And reset the grid. contReset is necessary to clean the CBlockMemory. - contReset(_Grids[i]); + NLMISC::contReset(_Grids[i]); } // done diff --git a/code/nel/include/nel/3d/index_buffer.h b/code/nel/include/nel/3d/index_buffer.h index 320a06020..7beaafe0b 100644 --- a/code/nel/include/nel/3d/index_buffer.h +++ b/code/nel/include/nel/3d/index_buffer.h @@ -782,7 +782,7 @@ inline void CIndexBuffer::lock (CIndexBufferRead &accessor, uint first, uint las // *************************************************************************** -inline void CIndexBuffer::unlock (uint first, uint end) +inline void CIndexBuffer::unlock (uint /* first */, uint /* end */) { nlassertex (_LockCounter!=0, ("Index buffer not locked")); nlassert (_LockedBuffer || (!isResident() && _NonResidentIndexes.empty())); diff --git a/code/nel/include/nel/3d/instance_lighter.h b/code/nel/include/nel/3d/instance_lighter.h index 7b1dbb6e7..8b1ccf80a 100644 --- a/code/nel/include/nel/3d/instance_lighter.h +++ b/code/nel/include/nel/3d/instance_lighter.h @@ -147,7 +147,7 @@ public: static void addTriangles (const IShape &shape, const NLMISC::CMatrix& modelMT, std::vector& triangleArray, sint instanceId); // Progress callback - virtual void progress (const char *message, float progress) {} + virtual void progress (const char * /* message */, float /* progress */) {} /// \name Static PointLights mgt. diff --git a/code/nel/include/nel/3d/ps_attrib.h b/code/nel/include/nel/3d/ps_attrib.h index fc17dc787..83549a7b0 100644 --- a/code/nel/include/nel/3d/ps_attrib.h +++ b/code/nel/include/nel/3d/ps_attrib.h @@ -96,7 +96,7 @@ public: try { newStart = new uint8[sizeof(T) * capacity + (1 << snapPower)]; - T *newTab = (T *) ( (uint) (newStart + (1 << snapPower)) & ~((1 << snapPower) - 1)); // snap to a page + T *newTab = (T *) ( (size_t) (newStart + (1 << snapPower)) & ~((1 << snapPower) - 1)); // snap to a page diff --git a/code/nel/include/nel/3d/ps_attrib_maker_bin_op.h b/code/nel/include/nel/3d/ps_attrib_maker_bin_op.h index 4370fdeaa..285fa9b26 100644 --- a/code/nel/include/nel/3d/ps_attrib_maker_bin_op.h +++ b/code/nel/include/nel/3d/ps_attrib_maker_bin_op.h @@ -157,7 +157,7 @@ public: } /// return true if an operation is supported. The default support all ops - bool supportOp(CPSBinOp::BinOp op) { return true; } + bool supportOp(CPSBinOp::BinOp /* op */) { return true; } /// get the current operator CPSBinOp::BinOp getOp(void) const { return _Op; } diff --git a/code/nel/include/nel/3d/ps_attrib_maker_bin_op_inline.h b/code/nel/include/nel/3d/ps_attrib_maker_bin_op_inline.h index c25c051a5..8d98a1544 100644 --- a/code/nel/include/nel/3d/ps_attrib_maker_bin_op_inline.h +++ b/code/nel/include/nel/3d/ps_attrib_maker_bin_op_inline.h @@ -57,13 +57,13 @@ inline CPlaneBasis PSBinOpModulate(CPlaneBasis p1, CPlaneBasis p2) } template <> -inline CPlaneBasis PSBinOpAdd(CPlaneBasis p1, CPlaneBasis p2) +inline CPlaneBasis PSBinOpAdd(CPlaneBasis /* p1 */, CPlaneBasis /* p2 */) { nlassert(0); // not allowed for now return CPlaneBasis(NLMISC::CVector::Null); } template <> -inline CPlaneBasis PSBinOpSubtract(CPlaneBasis p1, CPlaneBasis p2) +inline CPlaneBasis PSBinOpSubtract(CPlaneBasis /* p1 */, CPlaneBasis /* p2 */) { nlassert(0); // not allowed for now return CPlaneBasis(NLMISC::CVector::Null); diff --git a/code/nel/include/nel/3d/ps_attrib_maker_iterators.h b/code/nel/include/nel/3d/ps_attrib_maker_iterators.h index 8729ffb10..d9cfbcdd3 100644 --- a/code/nel/include/nel/3d/ps_attrib_maker_iterators.h +++ b/code/nel/include/nel/3d/ps_attrib_maker_iterators.h @@ -60,7 +60,7 @@ namespace NL3D { GET_INLINE float get() const { return float(rand() * (1 / double(RAND_MAX))); } // this may be optimized with a table... void advance() {} - void advance(uint quantity) {} + void advance(uint /* quantity */) {} }; /// this iterator just return the same value @@ -69,7 +69,7 @@ namespace NL3D float Value; GET_INLINE float get() const { return Value; } void advance() {} - void advance(uint quantity) {} + void advance(uint /* quantity */) {} }; /// iterator that use dist to compute the value diff --git a/code/nel/include/nel/3d/ps_direction.h b/code/nel/include/nel/3d/ps_direction.h index 609278a80..eb8bbd827 100644 --- a/code/nel/include/nel/3d/ps_direction.h +++ b/code/nel/include/nel/3d/ps_direction.h @@ -38,7 +38,7 @@ public : /** The direction is taken from a global vector defined in the particle system * NULL or an empty string as a name disable the use of a global value */ - virtual void enableGlobalVectorValue(const std::string &name) {} + virtual void enableGlobalVectorValue(const std::string &/* name */) {} virtual std::string getGlobalVectorValueName() const { return ""; } }; diff --git a/code/nel/include/nel/3d/ps_edit.h b/code/nel/include/nel/3d/ps_edit.h index d3e1a53de..8342868f8 100644 --- a/code/nel/include/nel/3d/ps_edit.h +++ b/code/nel/include/nel/3d/ps_edit.h @@ -65,13 +65,13 @@ struct IPSMover virtual bool supportNonUniformScaling(void) const { NL_PS_FUNC(supportNonUniformScaling); return false ; } // set the scale of the object (uniform scale). The default does nothing - virtual void setScale(uint32 index, float scale) {} ; + virtual void setScale(uint32 /* index */, float /* scale */) {} // set a non uniform scale (if supported) - virtual void setScale(uint32 index, const NLMISC::CVector &s) { NL_PS_FUNC(setScale); } + virtual void setScale(uint32 /* index */, const NLMISC::CVector &/* s */) { NL_PS_FUNC(setScale); } // get the scale of the object - virtual NLMISC::CVector getScale(uint32 index) const { NL_PS_FUNC(getScale); return NLMISC::CVector(1.f, 1.f, 1.f) ; } + virtual NLMISC::CVector getScale(uint32 /* index */) const { NL_PS_FUNC(getScale); return NLMISC::CVector(1.f, 1.f, 1.f) ; } /** some object may not store a whole matrix (e.g planes) * this return true if only a normal is needed to set the orientation of the object @@ -79,10 +79,10 @@ struct IPSMover virtual bool onlyStoreNormal(void) const { NL_PS_FUNC(onlyStoreNormal); return false ; } /// if the object only needs a normal, this return the normal. If not, is return (0, 0, 0) - virtual NLMISC::CVector getNormal(uint32 index) { NL_PS_FUNC(getNormal); return NLMISC::CVector::Null ; } + virtual NLMISC::CVector getNormal(uint32 /* index */) { NL_PS_FUNC(getNormal); return NLMISC::CVector::Null ; } /// if the object only stores a normal, this set the normal of the object. Otherwise it has no effect - virtual void setNormal(uint32 index, NLMISC::CVector n) { NL_PS_FUNC(setNormal); } + virtual void setNormal(uint32 /* index */, NLMISC::CVector /* n */) { NL_PS_FUNC(setNormal); } // set a new orthogonal matrix for the object virtual void setMatrix(uint32 index, const NLMISC::CMatrix &m) = 0 ; diff --git a/code/nel/include/nel/3d/ps_force.h b/code/nel/include/nel/3d/ps_force.h index 5e961dc43..15e28948a 100644 --- a/code/nel/include/nel/3d/ps_force.h +++ b/code/nel/include/nel/3d/ps_force.h @@ -87,9 +87,9 @@ public: * 'accumulate' set to false. * NB : works only with integrable forces */ - virtual void integrate(float date, CPSLocated *src, uint32 startIndex, uint32 numObjects, NLMISC::CVector *destPos = NULL, NLMISC::CVector *destSpeed = NULL, - bool accumulate = false, - uint posStride = sizeof(NLMISC::CVector), uint speedStride = sizeof(NLMISC::CVector) + virtual void integrate(float /* date */, CPSLocated * /* src */, uint32 /* startIndex */, uint32 /* numObjects */, NLMISC::CVector * /* destPos */ = NULL, NLMISC::CVector * /* destSpeed */ = NULL, + bool /* accumulate */ = false, + uint /* posStride */ = sizeof(NLMISC::CVector), uint /* speedStride */ = sizeof(NLMISC::CVector) ) const { nlassert(0); // not an integrable force @@ -100,11 +100,11 @@ public: * If the start date is lower than the creation date, the initial position is used * NB : works only with integrable forces */ - virtual void integrateSingle(float startDate, float deltaT, uint numStep, - const CPSLocated *src, uint32 indexInLocated, - NLMISC::CVector *destPos, - bool accumulate = false, - uint posStride = sizeof(NLMISC::CVector)) const + virtual void integrateSingle(float /* startDate */, float /* deltaT */, uint /* numStep */, + const CPSLocated * /* src */, uint32 /* indexInLocated */, + NLMISC::CVector * /* destPos */, + bool /* accumulate */ = false, + uint /* posStride */ = sizeof(NLMISC::CVector)) const { nlassert(0); // not an integrable force } @@ -170,7 +170,7 @@ public: virtual void setIntensityScheme(CPSAttribMaker *scheme); // deriver have here the opportunity to setup the functor object. The default does nothing - virtual void setupFunctor(uint32 indexInLocated) { } + virtual void setupFunctor(uint32 /* indexInLocated */) { } /// get the attribute maker for a non constant intensity CPSAttribMaker *getIntensityScheme(void) { return _IntensityScheme; } @@ -493,22 +493,22 @@ public: #ifdef NL_OS_WINDOWS __forceinline #endif - void operator() (const NLMISC::CVector &pos, NLMISC::CVector &speed, float invMass) - { + void operator() (const NLMISC::CVector &/* pos */, NLMISC::CVector &speed, float invMass) + { speed -= (CParticleSystem::EllapsedTime * _K * invMass * speed); - } + } - virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) - { - f.serialVersion(1); - // we don't save intensity info : it is saved by the owning object (and set before each use of this functor) - } + virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream) + { + f.serialVersion(1); + // we don't save intensity info : it is saved by the owning object (and set before each use of this functor) + } - // get the friction coefficient - float getK(void) const { return _K; } + // get the friction coefficient + float getK(void) const { return _K; } - // set the friction coefficient - void setK(float coeff) { _K = coeff; } + // set the friction coefficient + void setK(float coeff) { _K = coeff; } protected: // the friction coeff float _K; @@ -630,7 +630,7 @@ struct CPSTurbulForceFunc #ifdef NL_OS_WINDOWS __forceinline #endif - void operator() (const NLMISC::CVector &pos, NLMISC::CVector &speed, float invMass) + void operator() (const NLMISC::CVector &/* pos */, NLMISC::CVector &/* speed */, float /* invMass */) { nlassert(0); diff --git a/code/nel/include/nel/3d/static_quad_grid.h b/code/nel/include/nel/3d/static_quad_grid.h index 7890e12f4..5a0383c9e 100644 --- a/code/nel/include/nel/3d/static_quad_grid.h +++ b/code/nel/include/nel/3d/static_quad_grid.h @@ -172,7 +172,7 @@ template void CStaticQuadGrid::build(CQuadGrid &quadGrid) { clear(); - contReset(_Grid); + NLMISC::contReset(_Grid); // Copy from quadGrid, and init quads _Size= quadGrid.getSize(); diff --git a/code/nel/include/nel/3d/track_tcb.h b/code/nel/include/nel/3d/track_tcb.h index 8daf5cc2a..fc9c227e4 100644 --- a/code/nel/include/nel/3d/track_tcb.h +++ b/code/nel/include/nel/3d/track_tcb.h @@ -218,7 +218,7 @@ protected: date*= previous->OODeltaTime; NLMISC::clamp(date, 0,1); - date = ease(previous, date); + date = this->ease(previous, date); float hb[4]; this->computeHermiteBasis(date, hb); @@ -242,7 +242,7 @@ protected: ITrackKeyFramer::compile(); // Ease Precompute. - compileTCBEase(this->_MapKey, this->getLoopMode()); + this->compileTCBEase(this->_MapKey, this->getLoopMode()); // Tangents Precompute. @@ -314,7 +314,7 @@ private: float ksm,ksp,kdm,kdp; // compute tangents factors. - computeTCBFactors(key, timeBefore, time, timeAfter, rangeDelta, firstKey, endKey, isLoop, ksm,ksp,kdm,kdp); + this->computeTCBFactors(key, timeBefore, time, timeAfter, rangeDelta, firstKey, endKey, isLoop, ksm,ksp,kdm,kdp); // Delta. TKeyValueType delm, delp; @@ -413,7 +413,7 @@ public: ITrackKeyFramer::compile(); // Ease Precompute. - compileTCBEase(_MapKey, getLoopMode()); + this->compileTCBEase(_MapKey, getLoopMode()); TMapTimeCKey::iterator it; TMapTimeCKey::iterator itNext; diff --git a/code/nel/include/nel/3d/vertex_buffer.h b/code/nel/include/nel/3d/vertex_buffer.h index 83b2b90ea..a64ec0c2c 100644 --- a/code/nel/include/nel/3d/vertex_buffer.h +++ b/code/nel/include/nel/3d/vertex_buffer.h @@ -1223,7 +1223,7 @@ inline void CVertexBuffer::lock (CVertexBufferRead &accessor, uint first, uint l // -------------------------------------------------- -inline void CVertexBuffer::unlock (uint first, uint end) +inline void CVertexBuffer::unlock (uint /* first */, uint /* end */) { nlassertex (_LockCounter!=0, ("Vertex buffer not locked")); nlassert (_LockedBuffer || (!isResident() && _NonResidentVertices.empty())); diff --git a/code/nel/include/nel/misc/bit_mem_stream.h b/code/nel/include/nel/misc/bit_mem_stream.h index 8a1af34cc..b294d5454 100644 --- a/code/nel/include/nel/misc/bit_mem_stream.h +++ b/code/nel/include/nel/misc/bit_mem_stream.h @@ -209,6 +209,8 @@ public: { #ifdef NL_DEBUG std::swap(_DbgData, other._DbgData); +#else + nlunreferenced(other); #endif } @@ -225,6 +227,10 @@ public: TBMSSerialInfo serialItem( bitpos, size, type, _DbgData->NextSymbol ); _DbgData->List.push_back( serialItem ); _DbgData->NextSymbol = NULL; +#else + nlunreferenced(bitpos); + nlunreferenced(size); + nlunreferenced(type); #endif } @@ -258,6 +264,10 @@ public: nlwarning( "Missing reserve() corresponding to poke()" ); } _DbgData->NextSymbol = NULL; +#else + nlunreferenced(bitpos); + nlunreferenced(size); + nlunreferenced(type); #endif } @@ -266,6 +276,8 @@ public: { #ifdef NL_DEBUG _DbgData->NextSymbol = symbol; +#else + nlunreferenced(symbol); #endif } @@ -308,6 +320,8 @@ public: } //nlassert( bitpos < (*_List)[_CurrentBrowsedItem].BitPos ); // occurs if stream overflow } +#else + nlunreferenced(bitpos); #endif *eventId = -1; return std::string(); @@ -380,7 +394,7 @@ public: * If you are using the stream only in output mode, you can use this method as a faster version * of clear() *if you don't serialize pointers*. */ - void resetBufPos() + virtual void resetBufPos() { // This is ensured in CMemStream::CMemStream() and CMemStream::clear() //if ( (!isReading()) && _Buffer.empty() ) @@ -463,7 +477,7 @@ public: } /// See doc in CMemStream::bufferToFill() - uint8 *bufferToFill( uint32 msgsize ) + virtual uint8 *bufferToFill( uint32 msgsize ) { _FreeBits = 8; _DbgInfo.clear(); @@ -640,7 +654,7 @@ public: virtual void serial(ucstring &b); virtual void serial(CBitMemStream &b) { serialMemStream(b); } - virtual void serialMemStream(CBitMemStream &b); + virtual void serialMemStream(CMemStream &b); //@} @@ -787,11 +801,7 @@ void displayBitStream( const CBitMemStream& msg, sint beginbitpos, sint endbitpo inline std::string CBMSDbgInfo::getEventLegendAtBitPos( CBitMemStream& bms, sint32 eventId ) { #ifdef NL_DEBUG - if ( eventId == -1 ) - { - return std::string(); - } - else + if ( eventId != -1 ) { nlassert( eventId < (sint32)_DbgData->List.size() ); TBMSSerialInfo& serialItem = _DbgData->List[eventId]; // works only with a vector! @@ -800,8 +810,11 @@ inline std::string CBMSDbgInfo::getEventLegendAtBitPos( CBitMemStream& bms, sint bms.getSerialItem( serialItem ).c_str(), (serialItem.Symbol!=NULL)?serialItem.Symbol:"" ); } #else - return std::string(); + nlunreferenced(bms); + nlunreferenced(eventId); #endif + + return std::string(); } diff --git a/code/nel/include/nel/misc/diff_tool.h b/code/nel/include/nel/misc/diff_tool.h index 64989fcaf..2f291c6a0 100644 --- a/code/nel/include/nel/misc/diff_tool.h +++ b/code/nel/include/nel/misc/diff_tool.h @@ -501,8 +501,8 @@ namespace STRING_MANAGER // callback->onSwap(it - context.Reference.begin(), refCount, context); callback->onSwap(index, refCount, context); -// swap(*it, context.Reference[refCount]); - swap(context.Reference[index], context.Reference[refCount]); +// std::swap(*it, context.Reference[refCount]); + std::swap(context.Reference[index], context.Reference[refCount]); } } else if (getHashValue(context.Addition, addCount) != getHashValue(context.Reference, refCount)) diff --git a/code/nel/include/nel/misc/fast_id_map.h b/code/nel/include/nel/misc/fast_id_map.h new file mode 100644 index 000000000..dbd05bc76 --- /dev/null +++ b/code/nel/include/nel/misc/fast_id_map.h @@ -0,0 +1,151 @@ +/** + * \file fast_id_map.h + * \brief CFastIdMap + * \date 2012-04-10 19:28GMT + * \author Jan Boon (Kaetemi) + * CFastIdMap + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#ifndef NLMISC_FAST_ID_MAP_H +#define NLMISC_FAST_ID_MAP_H +#include + +// STL includes + +// NeL includes +#include + +// Project includes + +namespace NLMISC { + +/** + * \brief CFastIdMap + * \date 2012-04-10 19:28GMT + * \author Jan Boon (Kaetemi) + * This template allows for assigning unique uint32 identifiers to pointers. + * Useful when externally only exposing an identifier, when pointers may have been deleted. + * The identifier is made from two uint16's, one being the direct index in the identifier vector, + * and the other being a verification value that is increased when the identifier index is re-used. + * TId must be a typedef of uint32. + * TValue should be a pointer. + */ +template +class CFastIdMap +{ +protected: + struct CIdInfo + { + CIdInfo() { } + CIdInfo(uint16 verification, uint16 next, TValue value) : + Verification(verification), Next(next), Value(value) { } + uint16 Verification; + uint16 Next; + TValue Value; + }; + /// ID memory + std::vector m_Ids; + /// Nb of assigned IDs + uint m_Size; + /// Assigned IDs + uint16 m_Next; + +public: + CFastIdMap(TValue defaultValue) : m_Size(0), m_Next(0) + { + // Id 0 will contain the last available unused id, and be 0 if no more unused id's are available + // defaultValue will be returned when the ID is not found + m_Ids.push_back(CIdInfo(0, 0, defaultValue)); + } + + virtual ~CFastIdMap() { } + + void clear() + { + m_Ids.resize(1); + m_Ids[0].Next = 0; + } + + TId insert(TValue value) + { + // get next unused index + uint16 idx = m_Ids[0].Next; + if (idx == 0) + { + // size of used elements must be equal to the vector size minus one, when everything is allocated + nlassert((m_Ids.size() - 1) == m_Size); + + idx = m_Ids.size(); + uint16 verification = rand(); + m_Ids.push_back(CIdInfo(verification, m_Next, value)); + m_Next = idx; + return (TId)(((uint32)verification) << 16) & idx; + } + else + { + m_Ids[0].Next = m_Ids[idx].Next; // restore the last unused id + m_Ids[idx].Value = value; + return (TId)(((uint32)m_Ids[idx].Verification) << 16) & idx; + } + } + + void erase(TId id) + { + uint32 idx = ((uint32)id) & 0xFFFF; + uint16 verification = (uint16)(((uint32)id) >> 16); + if (m_Ids[idx].Verification == verification) + { + m_Ids[idx].Value = m_Ids[0].Value; // clean value for safety + m_Ids[idx].Verification = (uint16)(((uint32)m_Ids[idx].Verification + 1) & 0xFFFF); // change verification value, allow overflow :) + m_Ids[idx].Next = m_Ids[0].Next; // store the last unused id + m_Ids[0].Next = (uint16)idx; // set this as last unused id + } + else + { + nlwarning("Invalid ID"); + } + } + + TValue get(TId id) + { + uint32 idx = ((uint32)id) & 0xFFFF; + uint16 verification = (uint16)(((uint32)id) >> 16); + if (m_Ids[idx].Verification == verification) + { + return m_Ids[idx].Value; + } + else + { + nldebug("Invalid ID"); + return m_Ids[0].Value; + } + } + + inline uint size() { return m_Size; } + +}; /* class CFastIdMap */ + +} /* namespace NLMISC */ + +#endif /* #ifndef NLMISC_FAST_ID_MAP_H */ + +/* end of file */ diff --git a/code/nel/include/nel/misc/mem_stream.h b/code/nel/include/nel/misc/mem_stream.h index 2102129dd..1da99a48d 100644 --- a/code/nel/include/nel/misc/mem_stream.h +++ b/code/nel/include/nel/misc/mem_stream.h @@ -301,7 +301,7 @@ public: * If you are using the stream only in output mode, you can use this method as a faster version * of clear() *if you don't serialize pointers*. */ - void resetBufPos() { _Buffer.Pos = 0; } + virtual void resetBufPos() { _Buffer.Pos = 0; } /** * Resize the message buffer and fill data at position 0. @@ -340,7 +340,7 @@ public: * fill it with raw data using any filling function (warning: don't fill more than 'msgsize' * bytes!), then you are ready to read, using serial(), the data you've just filled. */ - uint8 *bufferToFill( uint32 msgsize ) + virtual uint8 *bufferToFill( uint32 msgsize ) { #ifdef NL_DEBUG nlassert( isReading() ); diff --git a/code/nel/include/nel/misc/mutex.h b/code/nel/include/nel/misc/mutex.h index e2205d666..1c01a6134 100644 --- a/code/nel/include/nel/misc/mutex.h +++ b/code/nel/include/nel/misc/mutex.h @@ -717,11 +717,11 @@ class CAutoMutex TMutex &_Mutex; // forbeden copy or assignent - CAutoMutex(const CAutoMutex &other) + CAutoMutex(const CAutoMutex &/* other */) { } - CAutoMutex &operator = (const CAutoMutex &other) + CAutoMutex &operator = (const CAutoMutex &/* other */) { return *this; } diff --git a/code/nel/include/nel/misc/p_thread.h b/code/nel/include/nel/misc/p_thread.h index cd027aa37..7e6a4d5a5 100644 --- a/code/nel/include/nel/misc/p_thread.h +++ b/code/nel/include/nel/misc/p_thread.h @@ -36,6 +36,12 @@ namespace NLMISC { class CPThread : public IThread { public: + enum TThreadState + { + ThreadStateNone, + ThreadStateRunning, + ThreadStateFinished, + }; /// Constructor CPThread( IRunnable *runnable, uint32 stackSize); @@ -48,6 +54,7 @@ public: virtual void wait(); virtual bool setCPUMask(uint64 cpuMask); virtual uint64 getCPUMask(); + virtual void setPriority(TThreadPriority priority); virtual std::string getUserName(); virtual IRunnable *getRunnable() @@ -58,10 +65,11 @@ public: /// Internal use IRunnable *Runnable; -private: - uint8 _State; // 0=not created, 1=started, 2=finished - uint32 _StackSize; + TThreadState _State; pthread_t _ThreadHandle; + +private: + uint32 _StackSize; }; /** diff --git a/code/nel/include/nel/misc/speaker_listener.h b/code/nel/include/nel/misc/speaker_listener.h index 7481e12c8..5f9f86352 100644 --- a/code/nel/include/nel/misc/speaker_listener.h +++ b/code/nel/include/nel/misc/speaker_listener.h @@ -118,7 +118,7 @@ namespace NLMISC _Speaker->registerListener(this); } - void unregisterListener(ISpeaker *speaker) + void unregisterListener(ISpeaker * /* speaker */) { nlassert(_Speaker != NULL); _Speaker->unregisterListener(this); diff --git a/code/nel/include/nel/misc/sstring.h b/code/nel/include/nel/misc/sstring.h index 513c681c9..fc17d67f5 100644 --- a/code/nel/include/nel/misc/sstring.h +++ b/code/nel/include/nel/misc/sstring.h @@ -55,7 +55,7 @@ public: /// ctor CSString(int i,const char *fmt="%d"); /// ctor - CSString(unsigned u,const char *fmt="%u"); + CSString(uint32 u,const char *fmt="%u"); /// ctor CSString(double d,const char *fmt="%f"); /// ctor @@ -76,14 +76,14 @@ public: char back() const; /// Return the n left hand most characters of a string - CSString left(unsigned count) const; + CSString left(uint32 count) const; /// Return the n right hand most characters of a string - CSString right(unsigned count) const; + CSString right(uint32 count) const; /// Return the string minus the n left hand most characters of a string - CSString leftCrop(unsigned count) const; + CSString leftCrop(uint32 count) const; /// Return the string minus the n right hand most characters of a string - CSString rightCrop(unsigned count) const; + CSString rightCrop(uint32 count) const; /// Return sub string up to but not including first instance of given character, starting at 'iterator' /// on exit 'iterator' indexes first character after extracted string segment @@ -116,9 +116,9 @@ public: /// Return sub string remaining after the first word CSString tailFromFirstWord() const; /// Count the number of words in a string - unsigned countWords() const; + uint32 countWords() const; /// Extract the given word - CSString word(unsigned idx) const; + CSString word(uint32 idx) const; /// Return first word or quote-encompassed sub-string - can remove extracted sub-string from source string CSString firstWordOrWords(bool truncateThis=false,bool useSlashStringEscape=true,bool useRepeatQuoteStringEscape=true); @@ -127,9 +127,9 @@ public: /// Return sub string following first word (or quote-encompassed sub-string) CSString tailFromFirstWordOrWords(bool useSlashStringEscape=true,bool useRepeatQuoteStringEscape=true) const; /// Count the number of words (or quote delimited sub-strings) in a string - unsigned countWordOrWords(bool useSlashStringEscape=true,bool useRepeatQuoteStringEscape=true) const; + uint32 countWordOrWords(bool useSlashStringEscape=true,bool useRepeatQuoteStringEscape=true) const; /// Extract the given words (or quote delimited sub-strings) - CSString wordOrWords(unsigned idx,bool useSlashStringEscape=true,bool useRepeatQuoteStringEscape=true) const; + CSString wordOrWords(uint32 idx,bool useSlashStringEscape=true,bool useRepeatQuoteStringEscape=true) const; /// Return first line - can remove extracted line from source string CSString firstLine(bool truncateThis=false); @@ -138,9 +138,9 @@ public: /// Return sub string remaining after the first line CSString tailFromFirstLine() const; /// Count the number of lines in a string - unsigned countLines() const; + uint32 countLines() const; /// Extract the given line - CSString line(unsigned idx) const; + CSString line(uint32 idx) const; /// A handy utility routine for knowing if a character is a white space character or not (' ','\t','\n','\r',26) static bool isWhiteSpace(char c); @@ -377,7 +377,7 @@ public: /// assignment operator CSString& operator=(int i); /// assignment operator - CSString& operator=(unsigned u); + CSString& operator=(uint32 u); /// assignment operator CSString& operator=(double d); @@ -561,7 +561,7 @@ inline CSString::CSString(int i,const char *fmt) *this=buf; } -inline CSString::CSString(unsigned u,const char *fmt) +inline CSString::CSString(uint32 u,const char *fmt) { char buf[1024]; sprintf(buf,fmt,u); @@ -611,26 +611,26 @@ inline char CSString::back() const return (*this)[size()-1]; } -inline CSString CSString::right(unsigned count) const +inline CSString CSString::right(uint32 count) const { if (count>=size()) return *this; return substr(size()-count); } -inline CSString CSString::rightCrop(unsigned count) const +inline CSString CSString::rightCrop(uint32 count) const { if (count>=size()) return CSString(); return substr(0,size()-count); } -inline CSString CSString::left(unsigned count) const +inline CSString CSString::left(uint32 count) const { return substr(0,count); } -inline CSString CSString::leftCrop(unsigned count) const +inline CSString CSString::leftCrop(uint32 count) const { if (count>=size()) return CSString(); @@ -639,7 +639,7 @@ inline CSString CSString::leftCrop(unsigned count) const inline CSString CSString::splitToWithIterator(char c,uint32& iterator) const { - unsigned i; + uint32 i; CSString result; for (i=iterator;i !!! - CSTLBlockAllocator(CBlockMemory *bm) + CSTLBlockAllocator(CBlockMemory * /* bm */) { } /// copy ctor diff --git a/code/nel/include/nel/misc/thread.h b/code/nel/include/nel/misc/thread.h index 82ef78a13..983e6b12a 100644 --- a/code/nel/include/nel/misc/thread.h +++ b/code/nel/include/nel/misc/thread.h @@ -68,6 +68,16 @@ public: } }; +/// Thread priorities, numbering follows Win32 for now +enum TThreadPriority +{ + ThreadPriorityLowest = -2, + ThreadPriorityLow = -1, + ThreadPriorityNormal = 0, + ThreadPriorityHigh = 1, + ThreadPriorityHighest = 2, +}; + /** * Thread base interface, must be implemented for all OS * \author Vianney Lecroart @@ -119,6 +129,9 @@ public: */ virtual uint64 getCPUMask()=0; + /// Set the thread priority. Thread must have been started before. + virtual void setPriority(TThreadPriority priority) = 0; + /** * Get the thread user name. * Under Linux return thread owner, under windows return the name of the logon user. diff --git a/code/nel/include/nel/misc/win_thread.h b/code/nel/include/nel/misc/win_thread.h index a2e8b5389..628942dde 100644 --- a/code/nel/include/nel/misc/win_thread.h +++ b/code/nel/include/nel/misc/win_thread.h @@ -49,6 +49,7 @@ public: virtual void wait(); virtual bool setCPUMask(uint64 cpuMask); virtual uint64 getCPUMask(); + virtual void setPriority(TThreadPriority priority); virtual std::string getUserName(); virtual IRunnable *getRunnable() @@ -69,8 +70,7 @@ public: void suspend(); // Resume the thread. No-op if already resumed void resume(); - // set priority as defined by "SetThreadpriority" - void setPriority(int priority); + // Priority boost void enablePriorityBoost(bool enabled); /// private use diff --git a/code/nel/include/nel/net/module_builder_parts.h b/code/nel/include/nel/net/module_builder_parts.h index b080e521f..d2e653315 100644 --- a/code/nel/include/nel/net/module_builder_parts.h +++ b/code/nel/include/nel/net/module_builder_parts.h @@ -188,8 +188,8 @@ namespace NLNET // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} - bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message) {return false;} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy * /* moduleProxy */) {} + bool fwdOnProcessModuleMessage(NLNET::IModuleProxy * /* sender */, const NLNET::CMessage &/* message */) {return false;} // check module up void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) diff --git a/code/nel/include/nel/net/transport_class.h b/code/nel/include/nel/net/transport_class.h index 2517da64b..f1110e492 100644 --- a/code/nel/include/nel/net/transport_class.h +++ b/code/nel/include/nel/net/transport_class.h @@ -335,7 +335,7 @@ protected: T *Value; - virtual void serialDefaultValue (NLMISC::IStream &f) + virtual void serialDefaultValue (NLMISC::IStream &/* f */) { // nothing } diff --git a/code/nel/include/nel/sound/audio_decoder.h b/code/nel/include/nel/sound/audio_decoder.h new file mode 100644 index 000000000..3babc1de1 --- /dev/null +++ b/code/nel/include/nel/sound/audio_decoder.h @@ -0,0 +1,107 @@ +/** + * \file audio_decoder.h + * \brief IAudioDecoder + * \date 2012-04-11 09:34GMT + * \author Jan Boon (Kaetemi) + * IAudioDecoder + */ + +/* + * Copyright (C) 2008-2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#ifndef NLSOUND_AUDIO_DECODER_H +#define NLSOUND_AUDIO_DECODER_H +#include + +// STL includes + +// NeL includes + +// Project includes + +namespace NLSOUND { + +/** + * \brief IAudioDecoder + * \date 2008-08-30 11:38GMT + * \author Jan Boon (Kaetemi) + * IAudioDecoder is only used by the driver implementation to stream + * music files into a readable format (it's a simple decoder interface). + * You should not call these functions (getSongTitle) on nlsound or user level, + * as a driver might have additional music types implemented. + * TODO: Split IAudioDecoder into IAudioDecoder (actual decoding) and IMediaDemuxer (stream splitter), and change the interface to make more sense. + * TODO: Allow user application to register more decoders. + * TODO: Look into libavcodec for decoding audio? + */ +class IAudioDecoder +{ +private: + // pointers + /// Stream from file created by IAudioDecoder + NLMISC::IStream *_InternalStream; + +public: + IAudioDecoder(); + virtual ~IAudioDecoder(); + + /// Create a new music buffer, may return NULL if unknown type, destroy with delete. Filepath lookup done here. If async is true, it will stream from hd, else it will load in memory first. + static IAudioDecoder *createAudioDecoder(const std::string &filepath, bool async, bool loop); + + /// Create a new music buffer from a stream, type is file extension like "ogg" etc. + static IAudioDecoder *createAudioDecoder(const std::string &type, NLMISC::IStream *stream, bool loop); + + /// Get information on a music file (only artist and title at the moment). + static bool getInfo(const std::string &filepath, std::string &artist, std::string &title); + + /// Get audio/container extensions that are currently supported by the nel sound library. + static void getMusicExtensions(std::vector &extensions); + + /// Return if a music extension is supported by the nel sound library. + static bool isMusicExtensionSupported(const std::string &extension); + + /// Get how many bytes the music buffer requires for output minimum. + virtual uint32 getRequiredBytes() = 0; + + /// Get an amount of bytes between minimum and maximum (can be lower than minimum if at end). + virtual uint32 getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum) = 0; + + /// Get the amount of channels (2 is stereo) in output. + virtual uint8 getChannels() = 0; + + /// Get the samples per second (often 44100) in output. + virtual uint getSamplesPerSec() = 0; + + /// Get the bits per sample (often 16) in output. + virtual uint8 getBitsPerSample() = 0; + + /// Get if the music has ended playing (never true if loop). + virtual bool isMusicEnded() = 0; + + /// Get the total time in seconds. + virtual float getLength() = 0; + + /// Set looping + virtual void setLooping(bool loop) = 0; +}; /* class IAudioDecoder */ + +} /* namespace NLSOUND */ + +#endif /* #ifndef NLSOUND_AUDIO_DECODER_H */ + +/* end of file */ diff --git a/code/nel/include/nel/sound/driver/music_buffer_vorbis.h b/code/nel/include/nel/sound/audio_decoder_vorbis.h similarity index 50% rename from code/nel/include/nel/sound/driver/music_buffer_vorbis.h rename to code/nel/include/nel/sound/audio_decoder_vorbis.h index 978f393da..bd7e45019 100644 --- a/code/nel/include/nel/sound/driver/music_buffer_vorbis.h +++ b/code/nel/include/nel/sound/audio_decoder_vorbis.h @@ -1,21 +1,33 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . +/** + * \file audio_decoder_vorbis.h + * \brief CAudioDecoderVorbis + * \date 2012-04-11 09:35GMT + * \author Jan Boon (Kaetemi) + * CAudioDecoderVorbis + */ -#ifndef NLSOUND_MUSIC_BUFFER_VORBIS_H -#define NLSOUND_MUSIC_BUFFER_VORBIS_H +/* + * Copyright (C) 2008-2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#ifndef NLSOUND_AUDIO_DECODER_VORBIS_H +#define NLSOUND_AUDIO_DECODER_VORBIS_H +#include // STL includes @@ -30,21 +42,20 @@ #endif // NeL includes +#include // Project includes -#include "music_buffer.h" -namespace NLSOUND -{ +namespace NLSOUND { /** - * \brief CMusicBufferVorbis + * \brief CAudioDecoderVorbis * \date 2008-08-30 11:38GMT * \author Jan Boon (Kaetemi) - * CMusicBufferVorbis - * Create trough IMusicBuffer, type "ogg" + * CAudioDecoderVorbis + * Create trough IAudioDecoder, type "ogg" */ -class CMusicBufferVorbis : public IMusicBuffer +class CAudioDecoderVorbis : public IAudioDecoder { protected: // outside pointers @@ -59,8 +70,8 @@ protected: sint32 _StreamOffset; sint32 _StreamSize; public: - CMusicBufferVorbis(NLMISC::IStream *stream, bool loop); - virtual ~CMusicBufferVorbis(); + CAudioDecoderVorbis(NLMISC::IStream *stream, bool loop); + virtual ~CAudioDecoderVorbis(); inline NLMISC::IStream *getStream() { return _Stream; } inline sint32 getStreamSize() { return _StreamSize; } inline sint32 getStreamOffset() { return _StreamOffset; } @@ -78,7 +89,7 @@ public: virtual uint8 getChannels(); /// Get the samples per second (often 44100) in output. - virtual uint32 getSamplesPerSec(); + virtual uint getSamplesPerSec(); /// Get the bits per sample (often 16) in output. virtual uint8 getBitsPerSample(); @@ -89,12 +100,12 @@ public: /// Get the total time in seconds. virtual float getLength(); - /// Get the size of uncompressed data in bytes. - virtual uint getUncompressedSize(); -}; /* class CMusicBufferVorbis */ + /// Set looping + virtual void setLooping(bool loop); +}; /* class CAudioDecoderVorbis */ } /* namespace NLSOUND */ -#endif /* #ifndef NLSOUND_MUSIC_BUFFER_VORBIS_H */ +#endif /* #ifndef NLSOUND_AUDIO_DECODER_VORBIS_H */ /* end of file */ diff --git a/code/nel/include/nel/sound/audio_mixer_user.h b/code/nel/include/nel/sound/audio_mixer_user.h index 7cd0de051..9c9fd5c86 100644 --- a/code/nel/include/nel/sound/audio_mixer_user.h +++ b/code/nel/include/nel/sound/audio_mixer_user.h @@ -34,6 +34,11 @@ #include "nel/sound/mixing_track.h" #include "nel/sound/sound.h" #include "nel/sound/music_channel_fader.h" +#include "nel/sound/group_controller_root.h" + +// Current version is 2, Ryzom Live uses 1 +// Provided to allow compatibility with old binary files +#define NLSOUND_SHEET_VERSION_BUILT 1 namespace NLLIGO { class CLigoConfig; @@ -51,26 +56,6 @@ namespace NLSOUND { class CMusicSoundManager; class IReverbEffect; -/// Hasher functor for hashed container with pointer key. -template -struct THashPtr : public std::unary_function -{ - static const size_t bucket_size = 4; - static const size_t min_buckets = 8; - size_t operator () (const Pointer &ptr) const - { - //CHashSet::hasher h; - // transtype the pointer into int then hash it - //return h.operator()(uint(uintptr_t(ptr))); - return (size_t)(uintptr_t)ptr; - } - inline bool operator() (const Pointer &ptr1, const Pointer &ptr2) const - { - // delegate the work to someone else as well? - return (uintptr_t)ptr1 < (uintptr_t)ptr2; - } -}; - /** * Implementation of UAudioMixer * @@ -197,6 +182,9 @@ public: /// Get a TSoundId from a name (returns NULL if not found) virtual TSoundId getSoundId( const NLMISC::TStringId &name ); + /// Gets the group controller for the given group tree path with separator '/', if it doesn't exist yet it will be created. + /// Examples: "music", "effects", "dialog", "music/background", "music/loading", "music/player", etcetera + virtual UGroupController *getGroupController(const std::string &path); /** Add a logical sound source (returns NULL if name not found). * If spawn is true, the source will auto-delete after playing. If so, the return USource* pointer @@ -204,9 +192,9 @@ public: * pass a callback function that will be called (if not NULL) just before deleting the spawned * source. */ - virtual USource *createSource( const NLMISC::TStringId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0 ); + virtual USource *createSource( const NLMISC::TStringId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL); /// Add a logical sound source (by sound id). To remove a source, just delete it. See createSource(const char*) - virtual USource *createSource( TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0 ); + virtual USource *createSource( TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL); /// Add a source which was created by an EnvSound void addSource( CSourceCommon *source ); /** Delete a logical sound source. If you don't call it, the source will be auto-deleted @@ -242,6 +230,8 @@ public: virtual uint getSourcesInstanceCount() const { return (uint)_Sources.size(); } /// Return the number of playing sources (slow) virtual uint getPlayingSourcesCount() const; + uint countPlayingSimpleSources() const; // debug + uint countSimpleSources() const; // debug /// Return the number of available tracks virtual uint getAvailableTracksCount() const; /// Return the number of used tracks @@ -415,6 +405,7 @@ public: /// Add a source for play as possible (for non discadable sound) void addSourceWaitingForPlay(CSourceCommon *source); + void removeSourceWaitingForPlay(CSourceCommon *source); /// Read all user controled var sheets void initUserVar(); @@ -431,8 +422,6 @@ private: // utility function for automatic sample bank loading. bool tryToLoadSampleBank(const std::string &sampleName); - - typedef CHashSet > TSourceContainer; typedef CHashSet > TMixerUpdateContainer; typedef CHashMap, THashPtr > TBufferToSourceContainer; // typedef std::multimap TTimedEventContainer; @@ -565,6 +554,9 @@ private: // Instance of the background music manager CMusicSoundManager *_BackgroundMusicManager; + /// Group controller + CGroupControllerRoot _GroupController; + public: struct TSampleBankHeader { diff --git a/code/nel/include/nel/sound/background_source.h b/code/nel/include/nel/sound/background_source.h index cdf044776..14ea1cf53 100644 --- a/code/nel/include/nel/sound/background_source.h +++ b/code/nel/include/nel/sound/background_source.h @@ -36,7 +36,7 @@ class CBackgroundSource : public CSourceCommon , public CAudioMixerUser::IMixerU { public: /// Constructor - CBackgroundSource (CBackgroundSound *backgroundSound=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0); + CBackgroundSource (CBackgroundSound *backgroundSound=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0, CGroupController *groupController = NULL); /// Destructor ~CBackgroundSource (); diff --git a/code/nel/include/nel/sound/complex_source.h b/code/nel/include/nel/sound/complex_source.h index d27b5af5b..d1135b1ad 100644 --- a/code/nel/include/nel/sound/complex_source.h +++ b/code/nel/include/nel/sound/complex_source.h @@ -34,7 +34,7 @@ class CComplexSource : public CSourceCommon, public CAudioMixerUser::IMixerEvent { public: /// Constructor - CComplexSource (CComplexSound *soundPattern=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0); + CComplexSource (CComplexSound *soundPattern=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0, CGroupController *groupController = NULL); /// Destructor ~CComplexSource (); diff --git a/code/nel/include/nel/sound/containers.h b/code/nel/include/nel/sound/containers.h new file mode 100644 index 000000000..bd4fe7fb9 --- /dev/null +++ b/code/nel/include/nel/sound/containers.h @@ -0,0 +1,67 @@ +/** + * \file containers.h + * \brief CContainers + * \date 2012-04-10 13:57GMT + * \author Unknown (Unknown) + * CContainers + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#ifndef NLSOUND_CONTAINERS_H +#define NLSOUND_CONTAINERS_H +#include + +// STL includes + +// NeL includes + +// Project includes + +namespace NLSOUND { + class CSourceCommon; + +/// Hasher functor for hashed container with pointer key. +template +struct THashPtr : public std::unary_function +{ + static const size_t bucket_size = 4; + static const size_t min_buckets = 8; + size_t operator () (const Pointer &ptr) const + { + //CHashSet::hasher h; + // transtype the pointer into int then hash it + //return h.operator()(uint(uintptr_t(ptr))); + return (size_t)(uintptr_t)ptr; + } + inline bool operator() (const Pointer &ptr1, const Pointer &ptr2) const + { + // delegate the work to someone else as well? + return (uintptr_t)ptr1 < (uintptr_t)ptr2; + } +}; + +typedef CHashSet > TSourceContainer; + +} /* namespace NLSOUND */ + +#endif /* #ifndef NLSOUND_CONTAINERS_H */ + +/* end of file */ diff --git a/code/nel/include/nel/sound/driver/buffer.h b/code/nel/include/nel/sound/driver/buffer.h index 5d488f1c7..27a8d9f00 100644 --- a/code/nel/include/nel/sound/driver/buffer.h +++ b/code/nel/include/nel/sound/driver/buffer.h @@ -48,6 +48,8 @@ public: /// Intel/DVI ADPCM format, only available for 1 channel at 16 bits per sample, encoded at 4 bits per sample. /// This is only implemented in the DSound and XAudio2 driver. FormatDviAdpcm = 11, + /// No format set. Used when a TBufferFormat value has not been set to any value yet. + FormatNotSet = (~0), }; /// The storage mode of this buffer. Also controls the X-RAM extension of OpenAL. enum TStorageMode diff --git a/code/nel/include/nel/sound/driver/music_buffer.h b/code/nel/include/nel/sound/driver/music_buffer.h deleted file mode 100644 index 571e27a31..000000000 --- a/code/nel/include/nel/sound/driver/music_buffer.h +++ /dev/null @@ -1,119 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NLSOUND_MUSIC_BUFFER_H -#define NLSOUND_MUSIC_BUFFER_H - -namespace NLMISC -{ - class IStream; - class CIFile; -} - -namespace NLSOUND -{ - - /* - * TODO: Streaming - * Some kind of decent streaming functionality, to get rid of the current music implementation. Audio decoding should be done on nlsound level. IBuffer needs a writable implementation, it allocates and owns the data memory, which can be written to by nlsound. When buffer is written, a function needs to be called to 'finalize' the buffer (so it can be submitted to OpenAL for example). - * Required interface functions, IBuffer: - * /// Allocate a new writable buffer. If this buffer was already allocated, the previous data is released. - * /// May return NULL if the format or frequency is not supported by the driver. - * uint8 *IBuffer::openWritable(uint size, TBufferFormat bufferFormat, uint8 channels, uint8 bitsPerSample, uint32 frequency); - * /// Tell that you are done writing to this buffer, so it can be copied over to hardware if needed. - * /// If keepLocal is true, a local copy of the buffer will be kept (so allocation can be re-used later). - * /// keepLocal overrides the OptionLocalBufferCopy flag. The buffer can use this function internally. - * void IBuffer::lockWritable(bool keepLocal); - * Required interface functions, ISource: - * /// Enable or disable the streaming facilities. - * void ISource::setStreaming(bool streaming); - * /// Submits a new buffer to the stream. A buffer of 100ms length is optimal for streaming. - * /// Should be called by a thread which checks countStreamingBuffers every 100ms - * void ISource::submitStreamingBuffer(IBuffer *buffer); - * /// Returns the number of buffers that are queued (includes playing buffer). 3 buffers is optimal. - * uint ISource::countStreamingBuffers(); - * Other required interface functions, ISource: - * /// Enable or disable 3d calculations (to send directly to speakers). - * void ISource::set3DMode(bool enable); - * For compatibility with music trough fmod, ISoundDriver: - * /// Returns true if the sound driver has a native implementation of IMusicChannel (bad!). - * /// If this returns false, use the nlsound music channel, which goes trough Ctrack/ISource, - * /// The nlsound music channel requires support for IBuffer/ISource streaming. - * bool ISoundDriver::hasMusicChannel(); - */ - -/** - * \brief IMusicBuffer - * \date 2008-08-30 11:38GMT - * \author Jan Boon (Kaetemi) - * IMusicBuffer is only used by the driver implementation to stream - * music files into a readable format (it's a simple decoder interface). - * You should not call these functions (getSongTitle) on nlsound or user level, - * as a driver might have additional music types implemented. - * TODO: Change IMusicBuffer to IAudioDecoder, and change the interface to make more sense. - * TODO: Allow user application to register more decoders. - * TODO: Look into libavcodec for decoding audio. - */ -class IMusicBuffer -{ -private: - // pointers - /// Stream from file created by IMusicBuffer - NLMISC::IStream *_InternalStream; - -public: - IMusicBuffer(); - virtual ~IMusicBuffer(); - - /// Create a new music buffer, may return NULL if unknown type, destroy with delete. Filepath lookup done here. If async is true, it will stream from hd, else it will load in memory first. - static IMusicBuffer *createMusicBuffer(const std::string &filepath, bool async, bool loop); - - /// Create a new music buffer from a stream, type is file extension like "ogg" etc. - static IMusicBuffer *createMusicBuffer(const std::string &type, NLMISC::IStream *stream, bool loop); - - /// Get information on a music file (only artist and title at the moment). - static bool getInfo(const std::string &filepath, std::string &artist, std::string &title); - - /// Get how many bytes the music buffer requires for output minimum. - virtual uint32 getRequiredBytes() =0; - - /// Get an amount of bytes between minimum and maximum (can be lower than minimum if at end). - virtual uint32 getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum) =0; - - /// Get the amount of channels (2 is stereo) in output. - virtual uint8 getChannels() =0; - - /// Get the samples per second (often 44100) in output. - virtual uint32 getSamplesPerSec() =0; - - /// Get the bits per sample (often 16) in output. - virtual uint8 getBitsPerSample() =0; - - /// Get if the music has ended playing (never true if loop). - virtual bool isMusicEnded() =0; - - /// Get the total time in seconds. - virtual float getLength() =0; - - /// Get the size of uncompressed data in bytes. - virtual uint getUncompressedSize() =0; -}; /* class IMusicBuffer */ - -} /* namespace NLSOUND */ - -#endif /* #ifndef NLSOUND_MUSIC_BUFFER_H */ - -/* end of file */ diff --git a/code/nel/include/nel/sound/driver/music_channel.h b/code/nel/include/nel/sound/driver/music_channel.h index 9878744c5..116865628 100644 --- a/code/nel/include/nel/sound/driver/music_channel.h +++ b/code/nel/include/nel/sound/driver/music_channel.h @@ -45,6 +45,9 @@ public: /// Stop the music previously loaded and played (the Memory is also freed) virtual void stop() =0; + /// Makes sure any resources are freed, but keeps available for next play call + virtual void reset() =0; + /// Pause the music previously loaded and played (the Memory is not freed) virtual void pause() =0; diff --git a/code/nel/include/nel/sound/driver/sound_driver.h b/code/nel/include/nel/sound/driver/sound_driver.h index 193026a42..c9551f16b 100644 --- a/code/nel/include/nel/sound/driver/sound_driver.h +++ b/code/nel/include/nel/sound/driver/sound_driver.h @@ -39,9 +39,11 @@ namespace NLSOUND #endif /* - * Sound sample format + * Deprecated sound sample format. + * For compatibility with old code. + * Do not modify. */ -enum TSampleFormat { SampleFormatUnknown, Mono8, Mono16ADPCM, Mono16, Stereo8, Stereo16 }; +enum TSampleFormat { Mono8, Mono16ADPCM, Mono16, Stereo8, Stereo16, SampleFormatUnknown = (~0) }; /** * Abstract sound driver (implemented in sound driver dynamic library) diff --git a/code/nel/include/nel/sound/driver/source.h b/code/nel/include/nel/sound/driver/source.h index 1858e6f24..b43c83914 100644 --- a/code/nel/include/nel/sound/driver/source.h +++ b/code/nel/include/nel/sound/driver/source.h @@ -353,7 +353,7 @@ public: * In streaming mode, the time spent during buffer outruns is not * counted towards the playback time, and the playback time is * be the current time position in the entire submitted queue. - * When using static buffers, the result is the tot time that the + * When using static buffers, the result is the total time that the * attached buffer has been playing. If the source is looping, the * time will be the total of all playbacks of the buffer. * When the source is stopped, this will return the time where the @@ -397,7 +397,7 @@ public: virtual void setSourceRelativeMode(bool mode = true) = 0; /// Get the source relative mode virtual bool getSourceRelativeMode() const = 0; - /// Set the min and max distances (default: 1, MAX_FLOAT) (3D mode only) + /// Set the min and max distances (default: 1, sqrt(MAX_FLOAT)) (3D mode only) virtual void setMinMaxDistances(float mindist, float maxdist, bool deferred = true) = 0; /// Get the min and max distances virtual void getMinMaxDistances(float& mindist, float& maxdist) const = 0; diff --git a/code/nel/include/nel/sound/group_controller.h b/code/nel/include/nel/sound/group_controller.h new file mode 100644 index 000000000..25b7034b6 --- /dev/null +++ b/code/nel/include/nel/sound/group_controller.h @@ -0,0 +1,102 @@ +/** + * \file group_controller.h + * \brief CGroupController + * \date 2012-04-10 09:29GMT + * \author Jan Boon (Kaetemi) + * CGroupController + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#ifndef NLSOUND_GROUP_CONTROLLER_H +#define NLSOUND_GROUP_CONTROLLER_H +#include + +// STL includes +#include +#include + +// NeL includes +#include +#include +#include + +// Project includes + +namespace NLSOUND { + class CGroupControllerRoot; + +/** + * \brief CGroupController + * \date 2012-04-10 09:29GMT + * \author Jan Boon (Kaetemi) + * CGroupController + */ +class CGroupController : public UGroupController +{ +public: + friend class CGroupControllerRoot; + +private: + CGroupController *m_Parent; + std::map m_Children; + + /// Gain as set by the interface + float m_Gain; + + /// Gain including parent gain + float m_FinalGain; + + int m_NbSourcesInclChild; + TSourceContainer m_Sources; + +public: + CGroupController(CGroupController *parent); + + /// \name UGroupController + //@{ + virtual void setGain(float gain) { NLMISC::clamp(gain, 0.0f, 1.0f); if (m_Gain != gain) { m_Gain = gain; updateSourceGain(); } } + virtual float getGain() { return m_Gain; } + //@} + + inline float getFinalGain() const { return m_FinalGain; } + + void addSource(CSourceCommon *source); + void removeSource(CSourceCommon *source); + + virtual std::string getPath(); + +protected: + virtual ~CGroupController(); // subnodes can only be deleted by the root + +private: + inline float calculateTotalGain() { return m_Gain; } + virtual void calculateFinalGain(); + virtual void increaseSources(); + virtual void decreaseSources(); + void updateSourceGain(); + +}; /* class CGroupController */ + +} /* namespace NLSOUND */ + +#endif /* #ifndef NLSOUND_GROUP_CONTROLLER_H */ + +/* end of file */ diff --git a/code/nel/include/nel/sound/group_controller_root.h b/code/nel/include/nel/sound/group_controller_root.h new file mode 100644 index 000000000..2081fa28a --- /dev/null +++ b/code/nel/include/nel/sound/group_controller_root.h @@ -0,0 +1,70 @@ +/** + * \file group_controller_root.h + * \brief CGroupControllerRoot + * \date 2012-04-10 09:44GMT + * \author Jan Boon (Kaetemi) + * CGroupControllerRoot + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#ifndef NLSOUND_GROUP_CONTROLLER_ROOT_H +#define NLSOUND_GROUP_CONTROLLER_ROOT_H +#include + +// STL includes + +// NeL includes +#include + +// Project includes +#include + +namespace NLSOUND { + +/** + * \brief CGroupControllerRoot + * \date 2012-04-10 09:44GMT + * \author Jan Boon (Kaetemi) + * CGroupControllerRoot + */ +class CGroupControllerRoot : public CGroupController, public NLMISC::CManualSingleton +{ +public: + CGroupControllerRoot(); + virtual ~CGroupControllerRoot(); + + /// Gets the group controller in a certain path with separator '/', if it doesn't exist yet it will be created. + CGroupController *getGroupController(const std::string &path); + +protected: + virtual std::string getPath(); + virtual void calculateFinalGain(); + virtual void increaseSources(); + virtual void decreaseSources(); + static bool isReservedName(const std::string &nodeName); + +}; /* class CGroupControllerRoot */ + +} /* namespace NLSOUND */ + +#endif /* #ifndef NLSOUND_GROUP_CONTROLLER_ROOT_H */ + +/* end of file */ diff --git a/code/nel/include/nel/sound/music_channel_fader.h b/code/nel/include/nel/sound/music_channel_fader.h index 4e6d35de4..8513c21e5 100644 --- a/code/nel/include/nel/sound/music_channel_fader.h +++ b/code/nel/include/nel/sound/music_channel_fader.h @@ -87,6 +87,8 @@ public: void init(ISoundDriver *soundDriver); void release(); + void reset(); + void update(); // time in seconds inline bool isInitOk() { return _SoundDriver != NULL; } diff --git a/code/nel/include/nel/sound/music_source.h b/code/nel/include/nel/sound/music_source.h index a23547c6c..be09c1837 100644 --- a/code/nel/include/nel/sound/music_source.h +++ b/code/nel/include/nel/sound/music_source.h @@ -35,7 +35,7 @@ class CMusicSource : public CSourceCommon { public: /// Constructor - CMusicSource (class CMusicSound *sound=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0); + CMusicSource (class CMusicSound *sound=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0, CGroupController *groupController = NULL); /// Destructor ~CMusicSource (); diff --git a/code/nel/include/nel/sound/simple_source.h b/code/nel/include/nel/sound/simple_source.h index ac2af0099..c330fd7fa 100644 --- a/code/nel/include/nel/sound/simple_source.h +++ b/code/nel/include/nel/sound/simple_source.h @@ -40,7 +40,7 @@ class CSimpleSource : public CSourceCommon, public CAudioMixerUser::IMixerEvent { public: /// Constructor - CSimpleSource(CSimpleSound *simpleSound = NULL, bool spawn = false, TSpawnEndCallback cb = 0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0); + CSimpleSource(CSimpleSound *simpleSound = NULL, bool spawn = false, TSpawnEndCallback cb = 0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0, CGroupController *groupController = NULL); /// Destructor virtual ~CSimpleSource(); @@ -97,14 +97,7 @@ public: * 1.0 -> no attenuation * values > 1 (amplification) not supported by most drivers */ - virtual void setGain( float gain ); - /** Set the gain amount (value inside [0, 1]) to map between 0 and the nominal gain - * (which is getSource()->getGain()). Does nothing if getSource() is null. - */ - virtual void setRelativeGain( float gain ); - /** Shift the frequency. 1.0f equals identity, each reduction of 50% equals a pitch shift - * of one octave. 0 is not a legal value. - */ + virtual void updateFinalGain(); virtual void setPitch( float pitch ); /// Set the source relative mode. If true, positions are interpreted relative to the listener position (default: false) virtual void setSourceRelativeMode( bool mode ); @@ -149,6 +142,8 @@ private: /// True when the sound is played muted and until the mixer event notifying the end. bool _PlayMuted; + bool _WaitingForPlay; + }; diff --git a/code/nel/include/nel/sound/sound.h b/code/nel/include/nel/sound/sound.h index 2112a0e73..e9d4f755c 100644 --- a/code/nel/include/nel/sound/sound.h +++ b/code/nel/include/nel/sound/sound.h @@ -30,6 +30,7 @@ namespace NLSOUND { class ISoundDriver; class IBuffer; class CSound; +class CGroupController; /// Sound names hash map @@ -60,8 +61,9 @@ public: SOUND_COMPLEX, SOUND_BACKGROUND, SOUND_CONTEXT, - SOUND_MUSIC, - SOUND_STREAM + SOUND_MUSIC, // soon to be deprecated hopefully + SOUND_STREAM, + SOUND_STREAM_FILE }; @@ -104,6 +106,8 @@ public: /// Return the max distance (if detailed()) virtual float getMaxDistance() const { return _MaxDist; } + inline CGroupController *getGroupController() const { return _GroupController; } + /// Set looping void setLooping( bool looping ) { _Looping = looping; } @@ -142,6 +146,9 @@ protected: /// An optional user var controler. NLMISC::TStringId _UserVarControler; + /// The group controller, always exists, owned by the audio mixer + CGroupController *_GroupController; + }; diff --git a/code/nel/include/nel/sound/source_common.h b/code/nel/include/nel/sound/source_common.h index 7781cfb02..1180fd68e 100644 --- a/code/nel/include/nel/sound/source_common.h +++ b/code/nel/include/nel/sound/source_common.h @@ -22,7 +22,7 @@ #include "nel/sound/u_stream_source.h" #include "nel/3d/cluster.h" #include "nel/sound/sound.h" - +#include "nel/sound/group_controller.h" namespace NLSOUND { @@ -36,11 +36,13 @@ public: SOURCE_SIMPLE, SOURCE_COMPLEX, SOURCE_BACKGROUND, - SOURCE_MUSIC, - SOURCE_STREAM + SOURCE_MUSIC, // DEPRECATED + SOURCE_STREAM, + SOURCE_STREAM_FILE }; - CSourceCommon(TSoundId id, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster); + /// When groupController is NULL it will use the groupcontroller specified in the TSoundId. You should manually specify the groupController if this source is a child of another source, so that the parent source controller of the user-specified .sound file is the one that will be used. + CSourceCommon(TSoundId id, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster, CGroupController *groupController); ~CSourceCommon(); @@ -63,6 +65,8 @@ public: void setGain( float gain ); void setRelativeGain( float gain ); float getRelativeGain() const; + /// Called whenever the gain is changed trough setGain, setRelativeGain or the group controller's gain settings change. + virtual void updateFinalGain() { } void setSourceRelativeMode( bool mode ); /// return the user param for the user callback void *getCallbackUserParam(void) const { return _CbUserParam; } @@ -74,6 +78,8 @@ public: virtual void getDirection( NLMISC::CVector& dir ) const { dir = _Direction; } /// Get the gain virtual float getGain() const { return _Gain; } + /// Get the final gain, including group controller changes. Use this when setting the physical source output gain. + inline float getFinalGain() const { return _Gain * _GroupController->getFinalGain(); } /// Get the pitch virtual float getPitch() const { return _Pitch; } /// Get the source relative mode @@ -99,15 +105,15 @@ public: /// \name Streaming source controls //@{ /// Set the sample format. (channels = 1, 2, ...; bitsPerSample = 8, 16; frequency = samples per second, 44100, ...) - virtual void setFormat(uint8 channels, uint8 bitsPerSample, uint32 frequency) { nlassert(false); } + virtual void setFormat(uint8 /* channels */, uint8 /* bitsPerSample */, uint32 /* frequency */) { nlassert(false); } /// Return the sample format information. - virtual void getFormat(uint8 &channels, uint8 &bitsPerSample, uint32 &frequency) const { nlassert(false); } + virtual void getFormat(uint8 &/* channels */, uint8 &/* bitsPerSample */, uint32 &/* frequency */) const { nlassert(false); } /// Get a writable pointer to the buffer of specified size. Use capacity to specify the required bytes. Returns NULL when all the buffer space is already filled. Call setFormat() first. - virtual uint8 *lock(uint capacity) { nlassert(false); return NULL; } + virtual uint8 *lock(uint /* capacity */) { nlassert(false); return NULL; } /// Notify that you are done writing to the locked buffer, so it can be copied over to hardware if needed. Set size to the number of bytes actually written to the buffer. Returns true if ok. - virtual bool unlock(uint size) { nlassert(false); return false; } + virtual bool unlock(uint /* size */) { nlassert(false); return false; } /// Get the recommended buffer size to use with lock()/unlock() - virtual void getRecommendedBufferSize(uint &samples, uint &bytes) const { nlassert(false); } + virtual void getRecommendedBufferSize(uint &/* samples */, uint &/* bytes */) const { nlassert(false); } /// Get the recommended sleep time based on the size of the last submitted buffer and the available buffer space virtual uint32 getRecommendedSleepTime() const { nlassert(false); return 0; } /// Return if there are still buffers available for playback. @@ -145,6 +151,9 @@ protected: /// An optional user var controler. NLMISC::TStringId _UserVarControler; + /// Group controller for gain + CGroupController *_GroupController; + }; } // NLSOUND diff --git a/code/nel/include/nel/sound/source_music_channel.h b/code/nel/include/nel/sound/source_music_channel.h new file mode 100644 index 000000000..7ec71fb66 --- /dev/null +++ b/code/nel/include/nel/sound/source_music_channel.h @@ -0,0 +1,100 @@ +/** + * \file source_music_channel.h + * \brief CSourceMusicChannel + * \date 2012-04-11 16:08GMT + * \author Jan Boon (Kaetemi) + * CSourceMusicChannel + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#ifndef NLSOUND_SOURCE_MUSIC_CHANNEL_H +#define NLSOUND_SOURCE_MUSIC_CHANNEL_H +#include + +// STL includes + +// NeL includes +#include +#include + +// Project includes + +namespace NLSOUND { + class CStreamFileSource; + +/** + * \brief CSourceMusicChannel + * \date 2012-04-11 16:08GMT + * \author Jan Boon (Kaetemi) + * CSourceMusicChannel + */ +class CSourceMusicChannel : public IMusicChannel +{ +public: + CSourceMusicChannel(); + virtual ~CSourceMusicChannel(); + + /** Play some music (.ogg etc...) + * NB: if an old music was played, it is first stop with stopMusic() + * \param filepath file path, CPath::lookup is done here + * \param async stream music from hard disk, preload in memory if false + * \param loop must be true to play the music in loop. + */ + virtual bool play(const std::string &filepath, bool async, bool loop); + + /// Stop the music previously loaded and played (the Memory is also freed) + virtual void stop(); + + /// Makes sure any resources are freed, but keeps available for next play call + virtual void reset(); + + /// Pause the music previously loaded and played (the Memory is not freed) + virtual void pause(); + + /// Resume the music previously paused + virtual void resume(); + + /// Return true if a song is finished. + virtual bool isEnded(); + + /// Return true if the song is still loading asynchronously and hasn't started playing yet (false if not async), used to delay fading + virtual bool isLoadingAsync(); + + /// Return the total length (in second) of the music currently played + virtual float getLength(); + + /** Set the music volume (if any music played). (volume value inside [0 , 1]) (default: 1) + * NB: the volume of music is NOT affected by IListener::setGain() + */ + virtual void setVolume(float gain); + +private: + CStreamFileSound m_Sound; + CStreamFileSource *m_Source; + float m_Gain; + +}; /* class CSourceMusicChannel */ + +} /* namespace NLSOUND */ + +#endif /* #ifndef NLSOUND_SOURCE_MUSIC_CHANNEL_H */ + +/* end of file */ diff --git a/code/nel/include/nel/sound/stream_file_sound.h b/code/nel/include/nel/sound/stream_file_sound.h new file mode 100644 index 000000000..8c1cc1634 --- /dev/null +++ b/code/nel/include/nel/sound/stream_file_sound.h @@ -0,0 +1,94 @@ +/** + * \file stream_file_sound.h + * \brief CStreamFileSound + * \date 2012-04-11 09:57GMT + * \author Jan Boon (Kaetemi) + * CStreamFileSound + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#ifndef NLSOUND_STREAM_FILE_SOUND_H +#define NLSOUND_STREAM_FILE_SOUND_H +#include + +// STL includes + +// NeL includes + +// Project includes +#include + +namespace NLSOUND { + class CSourceMusicChannel; + +/** + * \brief CStreamFileSound + * \date 2012-04-11 09:57GMT + * \author Jan Boon (Kaetemi) + * CStreamFileSound + */ +class CStreamFileSound : public CStreamSound +{ +public: + friend class CSourceMusicChannel; + +public: + CStreamFileSound(); + virtual ~CStreamFileSound(); + + /// Get the type of the sound. + virtual TSOUND_TYPE getSoundType() { return SOUND_STREAM_FILE; } + + /// Load the sound parameters from georges' form + virtual void importForm(const std::string& filename, NLGEORGES::UFormElm& formRoot); + + /// Used by the george sound plugin to check sound recursion (ie sound 'toto' use sound 'titi' witch also use sound 'toto' ...). + virtual void getSubSoundList(std::vector > &/* subsounds */) const { } + + /// Serialize the sound data. + virtual void serial(NLMISC::IStream &s); + + /// Return the length of the sound in ms + virtual uint32 getDuration() { return 0; } + + inline bool getAsync() { return m_Async; } + + inline const std::string &getFilePath() { return m_FilePath; } + +private: + /// Used by CSourceMusicChannel to set the filePath and default settings on other parameters. + void setMusicFilePath(const std::string &filePath, bool async = true, bool loop = false); + +private: + CStreamFileSound(const CStreamFileSound &); + CStreamFileSound &operator=(const CStreamFileSound &); + +private: + bool m_Async; + std::string m_FilePath; + +}; /* class CStreamFileSound */ + +} /* namespace NLSOUND */ + +#endif /* #ifndef NLSOUND_STREAM_FILE_SOUND_H */ + +/* end of file */ diff --git a/code/nel/include/nel/sound/stream_file_source.h b/code/nel/include/nel/sound/stream_file_source.h new file mode 100644 index 000000000..0cfee14d1 --- /dev/null +++ b/code/nel/include/nel/sound/stream_file_source.h @@ -0,0 +1,110 @@ +/** + * \file stream_file_source.h + * \brief CStreamFileSource + * \date 2012-04-11 09:57GMT + * \author Jan Boon (Kaetemi) + * CStreamFileSource + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#ifndef NLSOUND_STREAM_FILE_SOURCE_H +#define NLSOUND_STREAM_FILE_SOURCE_H +#include + +// STL includes + +// NeL includes +#include + +// Project includes +#include +#include + +namespace NLSOUND { + class IAudioDecoder; + +/** + * \brief CStreamFileSource + * \date 2012-04-11 09:57GMT + * \author Jan Boon (Kaetemi) + * CStreamFileSource + */ +class CStreamFileSource : public CStreamSource, private NLMISC::IRunnable +{ +public: + CStreamFileSource(CStreamFileSound *streamFileSound = NULL, bool spawn = false, TSpawnEndCallback cb = 0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0, CGroupController *groupController = NULL); + virtual ~CStreamFileSource(); + + /// Return the source type + TSOURCE_TYPE getType() const { return SOURCE_STREAM_FILE; } + + /// \name Playback control + //@{ + /// Play + virtual void play(); + /// Stop playing + virtual void stop(); + /// Get playing state. Return false even if the source has stopped on its own. + virtual bool isPlaying(); + /// Pause (following legacy music channel implementation) + void pause(); + /// Resume (following legacy music channel implementation) + void resume(); + /// check if song ended (following legacy music channel implementation) + bool isEnded(); + /// (following legacy music channel implementation) + float getLength(); + /// check if still loading (following legacy music channel implementation) + bool isLoadingAsync(); + //@} + + /// \name Decoding thread + //@{ + virtual void getName (std::string &result) const { result = "CStreamFileSource"; } + virtual void run(); + //@} + + // TODO: getTime + +private: + bool prepareDecoder(); + inline bool bufferMore(uint bytes); + +private: + CStreamFileSource(const CStreamFileSource &); + CStreamFileSource &operator=(const CStreamFileSource &); + +private: + inline CStreamFileSound *getStreamFileSound() { return static_cast(m_StreamSound); } + + NLMISC::IThread *m_Thread; + + IAudioDecoder *m_AudioDecoder; + + bool m_Paused; + +}; /* class CStreamFileSource */ + +} /* namespace NLSOUND */ + +#endif /* #ifndef NLSOUND_STREAM_FILE_SOURCE_H */ + +/* end of file */ diff --git a/code/nel/include/nel/sound/stream_sound.h b/code/nel/include/nel/sound/stream_sound.h index 39e6c733c..4b0debe0c 100644 --- a/code/nel/include/nel/sound/stream_sound.h +++ b/code/nel/include/nel/sound/stream_sound.h @@ -46,7 +46,7 @@ public: virtual void importForm(const std::string& filename, NLGEORGES::UFormElm& formRoot); /// Used by the george sound plugin to check sound recursion (ie sound 'toto' use sound 'titi' witch also use sound 'toto' ...). - virtual void getSubSoundList(std::vector > &subsounds) const { } + virtual void getSubSoundList(std::vector > &/* subsounds */) const { } /// Serialize the sound data. virtual void serial(NLMISC::IStream &s); diff --git a/code/nel/include/nel/sound/stream_source.h b/code/nel/include/nel/sound/stream_source.h index a5ac7c9f8..40ed82e11 100644 --- a/code/nel/include/nel/sound/stream_source.h +++ b/code/nel/include/nel/sound/stream_source.h @@ -41,7 +41,7 @@ namespace NLSOUND { class CStreamSource : public CSourceCommon { public: - CStreamSource(CStreamSound *streamSound = NULL, bool spawn = false, TSpawnEndCallback cb = 0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0); + CStreamSource(CStreamSound *streamSound = NULL, bool spawn = false, TSpawnEndCallback cb = 0, void *cbUserParam = 0, NL3D::CCluster *cluster = 0, CGroupController *groupController = NULL); virtual ~CStreamSource(); /// Return the sound binded to the source (or NULL if there is no sound) @@ -55,6 +55,9 @@ public: virtual void setLooping(bool l); /// Play virtual void play(); +protected: + void stopInt(); +public: /// Stop playing virtual void stop(); /// Get playing state. Return false even if the source has stopped on its own. @@ -80,18 +83,7 @@ public: virtual void setVelocity(const NLMISC::CVector& vel); /// Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional) virtual void setDirection(const NLMISC::CVector& dir); - /** Set the gain (volume value inside [0 , 1]). (default: 1) - * 0.0 -> silence - * 0.5 -> -6dB - * 1.0 -> no attenuation - * values > 1 (amplification) not supported by most drivers - */ - virtual void setGain(float gain); - - /** Set the gain amount (value inside [0, 1]) to map between 0 and the nominal gain - * (which is getSource()->getGain()). Does nothing if getSource() is null. - */ - virtual void setRelativeGain(float gain); + virtual void updateFinalGain(); /** Shift the frequency. 1.0f equals identity, each reduction of 50% equals a pitch shift * of one octave. 0 is not a legal value. */ @@ -118,6 +110,9 @@ public: virtual bool hasFilledBuffersAvailable() const; //@} + /// Prepare the buffers in this stream for the given maximum capacity. (TODO: Move this into UStreamSource) + void preAllocate(uint capacity); + /// Return the track CTrack *getTrack() { return m_Track; } @@ -125,7 +120,7 @@ private: CStreamSource(const CStreamSource &); CStreamSource &operator=(const CStreamSource &); -private: +protected: /// Return the source type TSOURCE_TYPE getType() const { return SOURCE_STREAM; } @@ -173,7 +168,13 @@ private: /// The bytes per second according to the buffer format uint m_BytesPerSecond; - + + /// Waiting for play for high priority sources + bool m_WaitingForPlay; + + /// Inverse pitch + float m_PitchInv; + }; /* class CStreamSource */ } /* namespace NLSOUND */ diff --git a/code/nel/include/nel/sound/u_audio_mixer.h b/code/nel/include/nel/sound/u_audio_mixer.h index e1c2a274e..c4702c3f8 100644 --- a/code/nel/include/nel/sound/u_audio_mixer.h +++ b/code/nel/include/nel/sound/u_audio_mixer.h @@ -20,6 +20,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" #include "nel/sound/u_source.h" +#include "nel/sound/u_group_controller.h" #include "nel/ligo/primitive.h" #include @@ -285,15 +286,19 @@ public: /// Get a TSoundId from a name (returns NULL if not found) virtual TSoundId getSoundId( const NLMISC::TStringId &name ) = 0; + /// Gets the group controller for the given group tree path with separator '/', if it doesn't exist yet it will be created. + /// Examples: "music", "effects", "dialog", "music/background", "music/loading", "music/player", etcetera + virtual UGroupController *getGroupController(const std::string &path) = 0; + /** Add a logical sound source (returns NULL if name not found). * If spawn is true, the source will auto-delete after playing. If so, the return USource* pointer * is valid only before the time when calling play() plus the duration of the sound. You can * pass a callback function that will be called (if not NULL) just before deleting the spawned * source. */ - virtual USource *createSource( const NLMISC::TStringId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context=0) = 0; + virtual USource *createSource(const NLMISC::TStringId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL) = 0; /// Add a logical sound source (by sound id). To remove a source, just delete it. See createSource(const char*) - virtual USource *createSource( TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context=0 ) = 0; + virtual USource *createSource(TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL) = 0; /** Use this method to set the listener position instead of using getListener->setPos(); * It's because we have to update the background sounds in this case. diff --git a/code/nel/include/nel/sound/u_group_controller.h b/code/nel/include/nel/sound/u_group_controller.h new file mode 100644 index 000000000..5aadeb25c --- /dev/null +++ b/code/nel/include/nel/sound/u_group_controller.h @@ -0,0 +1,65 @@ +/** + * \file u_group_controller.h + * \brief UGroupController + * \date 2012-04-10 12:49GMT + * \author Jan Boon (Kaetemi) + * UGroupController + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#ifndef NLSOUND_U_GROUP_CONTROLLER_H +#define NLSOUND_U_GROUP_CONTROLLER_H +#include + +// STL includes + +// NeL includes + +// Project includes + +#define NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER "sound:effects:game" +#define NLSOUND_SHEET_V1_DEFAULT_SOUND_MUSIC_GROUP_CONTROLLER "sound:music:game" +#define NLSOUND_SHEET_V1_DEFAULT_SOUND_STREAM_GROUP_CONTROLLER "sound:dialog:game" + +namespace NLSOUND { + +/** + * \brief UGroupController + * \date 2012-04-10 12:49GMT + * \author Jan Boon (Kaetemi) + * UGroupController + */ +class UGroupController +{ +public: + virtual void setGain(float gain) = 0; + virtual float getGain() = 0; + +protected: + virtual ~UGroupController() { } + +}; /* class UGroupController */ + +} /* namespace NLSOUND */ + +#endif /* #ifndef NLSOUND_U_GROUP_CONTROLLER_H */ + +/* end of file */ diff --git a/code/nel/samples/CMakeLists.txt b/code/nel/samples/CMakeLists.txt index 4f38264a0..5abcd985a 100644 --- a/code/nel/samples/CMakeLists.txt +++ b/code/nel/samples/CMakeLists.txt @@ -17,5 +17,5 @@ IF(WITH_PACS) ENDIF(WITH_PACS) IF(WITH_SOUND) - ADD_SUBDIRECTORY(sound_sources) + ADD_SUBDIRECTORY(sound) ENDIF(WITH_SOUND) diff --git a/code/nel/samples/sound/CMakeLists.txt b/code/nel/samples/sound/CMakeLists.txt new file mode 100644 index 000000000..6a7696fa4 --- /dev/null +++ b/code/nel/samples/sound/CMakeLists.txt @@ -0,0 +1,5 @@ + +ADD_SUBDIRECTORY(sound_sources) +ADD_SUBDIRECTORY(stream_file) +ADD_SUBDIRECTORY(stream_ogg_vorbis) + diff --git a/code/nel/samples/sound_sources/CMakeLists.txt b/code/nel/samples/sound/sound_sources/CMakeLists.txt similarity index 85% rename from code/nel/samples/sound_sources/CMakeLists.txt rename to code/nel/samples/sound/sound_sources/CMakeLists.txt index 4cf1ea427..b0f481e7c 100644 --- a/code/nel/samples/sound_sources/CMakeLists.txt +++ b/code/nel/samples/sound/sound_sources/CMakeLists.txt @@ -7,7 +7,7 @@ ADD_DEFINITIONS(-DNL_SOUND_DATA="\\"${NL_SHARE_PREFIX}/nl_sample_sound/\\"" ${LI INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) TARGET_LINK_LIBRARIES(nl_sample_sound_sources nelmisc nelsound) -NL_DEFAULT_PROPS(nl_sample_sound_sources "NeL, Samples: Sound System") +NL_DEFAULT_PROPS(nl_sample_sound_sources "NeL, Samples: Sound: Sound Sources") NL_ADD_RUNTIME_FLAGS(nl_sample_sound_sources) INSTALL(TARGETS nl_sample_sound_sources RUNTIME DESTINATION bin COMPONENT samplessound) diff --git a/code/nel/samples/sound_sources/data/DFN/alpha.typ b/code/nel/samples/sound/sound_sources/data/DFN/alpha.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/alpha.typ rename to code/nel/samples/sound/sound_sources/data/DFN/alpha.typ diff --git a/code/nel/samples/sound_sources/data/DFN/angle.typ b/code/nel/samples/sound/sound_sources/data/DFN/angle.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/angle.typ rename to code/nel/samples/sound/sound_sources/data/DFN/angle.typ diff --git a/code/nel/samples/sound_sources/data/DFN/backgound_sound_item.dfn b/code/nel/samples/sound/sound_sources/data/DFN/backgound_sound_item.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/backgound_sound_item.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/backgound_sound_item.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/background_flag_config.dfn b/code/nel/samples/sound/sound_sources/data/DFN/background_flag_config.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/background_flag_config.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/background_flag_config.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/background_sound.dfn b/code/nel/samples/sound/sound_sources/data/DFN/background_sound.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/background_sound.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/background_sound.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/basics/_typ.dfn b/code/nel/samples/sound/sound_sources/data/DFN/basics/_typ.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/basics/_typ.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/basics/_typ.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/basics/_type.typ b/code/nel/samples/sound/sound_sources/data/DFN/basics/_type.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/basics/_type.typ rename to code/nel/samples/sound/sound_sources/data/DFN/basics/_type.typ diff --git a/code/nel/samples/sound_sources/data/DFN/basics/boolean.typ b/code/nel/samples/sound/sound_sources/data/DFN/basics/boolean.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/basics/boolean.typ rename to code/nel/samples/sound/sound_sources/data/DFN/basics/boolean.typ diff --git a/code/nel/samples/sound_sources/data/DFN/basics/filename.typ b/code/nel/samples/sound/sound_sources/data/DFN/basics/filename.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/basics/filename.typ rename to code/nel/samples/sound/sound_sources/data/DFN/basics/filename.typ diff --git a/code/nel/samples/sound_sources/data/DFN/basics/float.typ b/code/nel/samples/sound/sound_sources/data/DFN/basics/float.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/basics/float.typ rename to code/nel/samples/sound/sound_sources/data/DFN/basics/float.typ diff --git a/code/nel/samples/sound_sources/data/DFN/basics/iboolean.typ b/code/nel/samples/sound/sound_sources/data/DFN/basics/iboolean.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/basics/iboolean.typ rename to code/nel/samples/sound/sound_sources/data/DFN/basics/iboolean.typ diff --git a/code/nel/samples/sound_sources/data/DFN/basics/int.typ b/code/nel/samples/sound/sound_sources/data/DFN/basics/int.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/basics/int.typ rename to code/nel/samples/sound/sound_sources/data/DFN/basics/int.typ diff --git a/code/nel/samples/sound_sources/data/DFN/basics/string.typ b/code/nel/samples/sound/sound_sources/data/DFN/basics/string.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/basics/string.typ rename to code/nel/samples/sound/sound_sources/data/DFN/basics/string.typ diff --git a/code/nel/samples/sound_sources/data/DFN/basics/typ.dfn b/code/nel/samples/sound/sound_sources/data/DFN/basics/typ.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/basics/typ.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/basics/typ.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/complex_sound.dfn b/code/nel/samples/sound/sound_sources/data/DFN/complex_sound.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/complex_sound.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/complex_sound.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/context_sound.dfn b/code/nel/samples/sound/sound_sources/data/DFN/context_sound.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/context_sound.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/context_sound.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/direction.dfn b/code/nel/samples/sound/sound_sources/data/DFN/direction.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/direction.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/direction.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/distance.typ b/code/nel/samples/sound/sound_sources/data/DFN/distance.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/distance.typ rename to code/nel/samples/sound/sound_sources/data/DFN/distance.typ diff --git a/code/nel/samples/sound_sources/data/DFN/doppler.typ b/code/nel/samples/sound/sound_sources/data/DFN/doppler.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/doppler.typ rename to code/nel/samples/sound/sound_sources/data/DFN/doppler.typ diff --git a/code/nel/samples/sound_sources/data/DFN/gain.typ b/code/nel/samples/sound/sound_sources/data/DFN/gain.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/gain.typ rename to code/nel/samples/sound/sound_sources/data/DFN/gain.typ diff --git a/code/nel/samples/sound_sources/data/DFN/listener.dfn b/code/nel/samples/sound/sound_sources/data/DFN/listener.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/listener.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/listener.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/mixer_config.dfn b/code/nel/samples/sound/sound_sources/data/DFN/mixer_config.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/mixer_config.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/mixer_config.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/music_sound.dfn b/code/nel/samples/sound/sound_sources/data/DFN/music_sound.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/music_sound.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/music_sound.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/parameter_id.typ b/code/nel/samples/sound/sound_sources/data/DFN/parameter_id.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/parameter_id.typ rename to code/nel/samples/sound/sound_sources/data/DFN/parameter_id.typ diff --git a/code/nel/samples/sound_sources/data/DFN/pattern_mode.typ b/code/nel/samples/sound/sound_sources/data/DFN/pattern_mode.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/pattern_mode.typ rename to code/nel/samples/sound/sound_sources/data/DFN/pattern_mode.typ diff --git a/code/nel/samples/sound_sources/data/DFN/priority.typ b/code/nel/samples/sound/sound_sources/data/DFN/priority.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/priority.typ rename to code/nel/samples/sound/sound_sources/data/DFN/priority.typ diff --git a/code/nel/samples/sound_sources/data/DFN/rolloff.typ b/code/nel/samples/sound/sound_sources/data/DFN/rolloff.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/rolloff.typ rename to code/nel/samples/sound/sound_sources/data/DFN/rolloff.typ diff --git a/code/nel/samples/sound_sources/data/DFN/simple_sound.dfn b/code/nel/samples/sound/sound_sources/data/DFN/simple_sound.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/simple_sound.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/simple_sound.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/sound.dfn b/code/nel/samples/sound/sound_sources/data/DFN/sound.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/sound.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/sound.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/sound_group.dfn b/code/nel/samples/sound/sound_sources/data/DFN/sound_group.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/sound_group.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/sound_group.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/sound_group_item.dfn b/code/nel/samples/sound/sound_sources/data/DFN/sound_group_item.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/sound_group_item.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/sound_group_item.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/soundbank.dfn b/code/nel/samples/sound/sound_sources/data/DFN/soundbank.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/soundbank.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/soundbank.dfn diff --git a/code/nel/samples/sound_sources/data/DFN/transposition.typ b/code/nel/samples/sound/sound_sources/data/DFN/transposition.typ similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/transposition.typ rename to code/nel/samples/sound/sound_sources/data/DFN/transposition.typ diff --git a/code/nel/samples/sound_sources/data/DFN/user_var_binding.dfn b/code/nel/samples/sound/sound_sources/data/DFN/user_var_binding.dfn similarity index 100% rename from code/nel/samples/sound_sources/data/DFN/user_var_binding.dfn rename to code/nel/samples/sound/sound_sources/data/DFN/user_var_binding.dfn diff --git a/code/nel/samples/sound_sources/data/animations/readme.txt b/code/nel/samples/sound/sound_sources/data/animations/readme.txt similarity index 100% rename from code/nel/samples/sound_sources/data/animations/readme.txt rename to code/nel/samples/sound/sound_sources/data/animations/readme.txt diff --git a/code/nel/samples/sound_sources/data/animations/test_anim.sound_anim b/code/nel/samples/sound/sound_sources/data/animations/test_anim.sound_anim similarity index 100% rename from code/nel/samples/sound_sources/data/animations/test_anim.sound_anim rename to code/nel/samples/sound/sound_sources/data/animations/test_anim.sound_anim diff --git a/code/nel/samples/sound_sources/data/background_sounds/background_sound.primitive b/code/nel/samples/sound/sound_sources/data/background_sounds/background_sound.primitive similarity index 100% rename from code/nel/samples/sound_sources/data/background_sounds/background_sound.primitive rename to code/nel/samples/sound/sound_sources/data/background_sounds/background_sound.primitive diff --git a/code/nel/samples/sound_sources/data/background_sounds/readme.txt b/code/nel/samples/sound/sound_sources/data/background_sounds/readme.txt similarity index 100% rename from code/nel/samples/sound_sources/data/background_sounds/readme.txt rename to code/nel/samples/sound/sound_sources/data/background_sounds/readme.txt diff --git a/code/nel/samples/sound_sources/data/cluster_sound/readme.txt b/code/nel/samples/sound/sound_sources/data/cluster_sound/readme.txt similarity index 100% rename from code/nel/samples/sound_sources/data/cluster_sound/readme.txt rename to code/nel/samples/sound/sound_sources/data/cluster_sound/readme.txt diff --git a/code/nel/samples/sound_sources/data/cluster_sound/test_clusters.sound_group b/code/nel/samples/sound/sound_sources/data/cluster_sound/test_clusters.sound_group similarity index 100% rename from code/nel/samples/sound_sources/data/cluster_sound/test_clusters.sound_group rename to code/nel/samples/sound/sound_sources/data/cluster_sound/test_clusters.sound_group diff --git a/code/nel/samples/sound_sources/data/default.mixer_config b/code/nel/samples/sound/sound_sources/data/default.mixer_config similarity index 100% rename from code/nel/samples/sound_sources/data/default.mixer_config rename to code/nel/samples/sound/sound_sources/data/default.mixer_config diff --git a/code/nel/samples/sound_sources/data/samplebank/base_samples/beep.wav b/code/nel/samples/sound/sound_sources/data/samplebank/base_samples/beep.wav similarity index 100% rename from code/nel/samples/sound_sources/data/samplebank/base_samples/beep.wav rename to code/nel/samples/sound/sound_sources/data/samplebank/base_samples/beep.wav diff --git a/code/nel/samples/sound_sources/data/samplebank/base_samples/tuut.wav b/code/nel/samples/sound/sound_sources/data/samplebank/base_samples/tuut.wav similarity index 100% rename from code/nel/samples/sound_sources/data/samplebank/base_samples/tuut.wav rename to code/nel/samples/sound/sound_sources/data/samplebank/base_samples/tuut.wav diff --git a/code/nel/samples/sound_sources/data/soundbank/beep.sound b/code/nel/samples/sound/sound_sources/data/soundbank/beep.sound similarity index 100% rename from code/nel/samples/sound_sources/data/soundbank/beep.sound rename to code/nel/samples/sound/sound_sources/data/soundbank/beep.sound diff --git a/code/nel/samples/sound_sources/data/soundbank/tuut.sound b/code/nel/samples/sound/sound_sources/data/soundbank/tuut.sound similarity index 100% rename from code/nel/samples/sound_sources/data/soundbank/tuut.sound rename to code/nel/samples/sound/sound_sources/data/soundbank/tuut.sound diff --git a/code/nel/samples/sound_sources/data/world_editor_classes.xml b/code/nel/samples/sound/sound_sources/data/world_editor_classes.xml similarity index 100% rename from code/nel/samples/sound_sources/data/world_editor_classes.xml rename to code/nel/samples/sound/sound_sources/data/world_editor_classes.xml diff --git a/code/nel/samples/sound_sources/main.cpp b/code/nel/samples/sound/sound_sources/main.cpp similarity index 100% rename from code/nel/samples/sound_sources/main.cpp rename to code/nel/samples/sound/sound_sources/main.cpp diff --git a/code/nel/samples/sound/stream_file/CMakeLists.txt b/code/nel/samples/sound/stream_file/CMakeLists.txt new file mode 100644 index 000000000..0552387cb --- /dev/null +++ b/code/nel/samples/sound/stream_file/CMakeLists.txt @@ -0,0 +1,12 @@ +FILE(GLOB SRC *.cpp *.h) + +ADD_EXECUTABLE(nl_sample_stream_file ${SRC}) + +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) + +TARGET_LINK_LIBRARIES(nl_sample_stream_file nelmisc nelsound) +NL_DEFAULT_PROPS(nl_sample_stream_file "NeL, Samples: Sound: Stream File") +NL_ADD_RUNTIME_FLAGS(nl_sample_stream_file) + +INSTALL(TARGETS nl_sample_stream_file RUNTIME DESTINATION bin COMPONENT samplessound) + diff --git a/code/nel/samples/sound/stream_file/base_samples.sample_bank b/code/nel/samples/sound/stream_file/base_samples.sample_bank new file mode 100644 index 000000000..8e9b5b898 Binary files /dev/null and b/code/nel/samples/sound/stream_file/base_samples.sample_bank differ diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/_typ.dfn b/code/nel/samples/sound/stream_file/data/DFN/basics/_typ.dfn new file mode 100644 index 000000000..2f8971932 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/_typ.dfn @@ -0,0 +1,6 @@ + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/_type.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/_type.typ new file mode 100644 index 000000000..233beca79 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/_type.typ @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/boolean.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/boolean.typ new file mode 100644 index 000000000..fb6821f08 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/boolean.typ @@ -0,0 +1,6 @@ + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/filename.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/filename.typ new file mode 100644 index 000000000..bdad39a48 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/filename.typ @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/float.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/float.typ new file mode 100644 index 000000000..250620f5e --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/float.typ @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/iboolean.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/iboolean.typ new file mode 100644 index 000000000..d29217bed --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/iboolean.typ @@ -0,0 +1,6 @@ + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/int.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/int.typ new file mode 100644 index 000000000..5b88c4fc4 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/int.typ @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/sint16.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/sint16.typ new file mode 100644 index 000000000..0adba3ad0 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/sint16.typ @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/sint32.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/sint32.typ new file mode 100644 index 000000000..ce470d5fe --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/sint32.typ @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/sint64.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/sint64.typ new file mode 100644 index 000000000..5b88c4fc4 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/sint64.typ @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/sint8.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/sint8.typ new file mode 100644 index 000000000..462eab92c --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/sint8.typ @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/string.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/string.typ new file mode 100644 index 000000000..89191b1eb --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/string.typ @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/typ.dfn b/code/nel/samples/sound/stream_file/data/DFN/basics/typ.dfn new file mode 100644 index 000000000..d3c9e1757 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/typ.dfn @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/uint16.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/uint16.typ new file mode 100644 index 000000000..d0e98aad1 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/uint16.typ @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/uint32.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/uint32.typ new file mode 100644 index 000000000..60dc00b3c --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/uint32.typ @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/uint64.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/uint64.typ new file mode 100644 index 000000000..936a619c8 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/uint64.typ @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/basics/uint8.typ b/code/nel/samples/sound/stream_file/data/DFN/basics/uint8.typ new file mode 100644 index 000000000..3dee1c5c8 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/basics/uint8.typ @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/alpha.typ b/code/nel/samples/sound/stream_file/data/DFN/sound/alpha.typ new file mode 100644 index 000000000..a6f7d3bff --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/alpha.typ @@ -0,0 +1,2 @@ + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/angle.typ b/code/nel/samples/sound/stream_file/data/DFN/sound/angle.typ new file mode 100644 index 000000000..db94698e0 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/angle.typ @@ -0,0 +1,2 @@ + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/backgound_sound_item.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/backgound_sound_item.dfn new file mode 100644 index 000000000..bbdfdf82a --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/backgound_sound_item.dfn @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Tue Oct 08 14:39:12 2002 (boucher) Dfn Structure = +Tue Oct 08 15:03:40 2002 (boucher) Dfn Structure = +Mon Oct 14 16:09:48 2002 (boucher) Dfn Structure = +Wed Oct 16 18:22:30 2002 (boucher) Dfn Structure = +Thu Dec 19 16:26:49 2002 (boucher) Dfn Structure = +Wed Apr 09 19:38:51 2003 (AmazingSound) Dfn Structure = + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/background_flag_config.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/background_flag_config.dfn new file mode 100644 index 000000000..bce6d82a8 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/background_flag_config.dfn @@ -0,0 +1,9 @@ + + + + + + + + Thu Jan 02 14:38:32 2003 (boucher) Dfn Structure = + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/background_sound.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/background_sound.dfn new file mode 100644 index 000000000..41288d7b8 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/background_sound.dfn @@ -0,0 +1,5 @@ + + + + Tue Oct 08 14:55:03 2002 (boucher) Dfn Structure = + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/complex_sound.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/complex_sound.dfn new file mode 100644 index 000000000..8164b9d7a --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/complex_sound.dfn @@ -0,0 +1,19 @@ + + + + + + + + + + + Tue Oct 08 14:29:42 2002 (boucher) Dfn Structure = +Tue Oct 08 14:35:40 2002 (boucher) Dfn Structure = +Thu Oct 10 16:15:18 2002 (boucher) Dfn Structure = +Fri Oct 11 10:26:17 2002 (boucher) Dfn Structure = +Fri Oct 11 11:14:25 2002 (boucher) Dfn Structure = +Fri Oct 11 11:15:41 2002 (boucher) Dfn Structure = +Fri Oct 11 16:01:43 2002 (boucher) Dfn Structure = +Wed Oct 16 11:36:41 2002 (boucher) Dfn Structure = + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/context_sound.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/context_sound.dfn new file mode 100644 index 000000000..f8d05e697 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/context_sound.dfn @@ -0,0 +1,5 @@ + + + + Thu Nov 07 14:01:21 2002 (boucher) Dfn Structure = + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/direction.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/direction.dfn new file mode 100644 index 000000000..190223cc1 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/direction.dfn @@ -0,0 +1,6 @@ + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/distance.typ b/code/nel/samples/sound/stream_file/data/DFN/sound/distance.typ new file mode 100644 index 000000000..0981c09a0 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/distance.typ @@ -0,0 +1,2 @@ + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/doppler.typ b/code/nel/samples/sound/stream_file/data/DFN/sound/doppler.typ new file mode 100644 index 000000000..2419f2d6c --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/doppler.typ @@ -0,0 +1,2 @@ + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/gain.typ b/code/nel/samples/sound/stream_file/data/DFN/sound/gain.typ new file mode 100644 index 000000000..2000b2652 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/gain.typ @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/listener.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/listener.dfn new file mode 100644 index 000000000..ba52b5af0 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/listener.dfn @@ -0,0 +1,5 @@ + + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/mixer_config.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/mixer_config.dfn new file mode 100644 index 000000000..61daec64b --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/mixer_config.dfn @@ -0,0 +1,14 @@ + + + + + + + + + + + Thu Jan 02 14:33:42 2003 (boucher) Dfn Structure = +Thu Jan 02 14:40:05 2003 (boucher) Dfn Structure = +Thu Jan 02 14:41:32 2003 (boucher) Dfn Structure = + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/music_sound.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/music_sound.dfn new file mode 100644 index 000000000..1935511b2 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/music_sound.dfn @@ -0,0 +1,13 @@ + + + + + + + + Tue Nov 02 11:28:10 2004 (berenguier) Dfn Structure = +Tue Nov 02 11:30:14 2004 (berenguier) Dfn Structure = +Tue Nov 02 11:40:09 2004 (berenguier) Dfn Structure = +Tue Nov 02 11:40:29 2004 (berenguier) Dfn Structure = +Wed Nov 03 10:54:07 2004 (berenguier) Dfn Structure = + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/parameter_id.typ b/code/nel/samples/sound/stream_file/data/DFN/sound/parameter_id.typ new file mode 100644 index 000000000..bc284afb2 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/parameter_id.typ @@ -0,0 +1,8 @@ + + + + + Mon Feb 10 17:31:53 2003 (boucher) Type Predef = +Mon Feb 10 17:31:53 2003 (boucher) Type Type = String +Mon Feb 10 17:31:53 2003 (boucher) Type UI = NonEditableCombo + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/pattern_mode.typ b/code/nel/samples/sound/stream_file/data/DFN/sound/pattern_mode.typ new file mode 100644 index 000000000..b0ac96de5 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/pattern_mode.typ @@ -0,0 +1,10 @@ + + + + + + Tue Oct 08 14:27:39 2002 (boucher) Type Default = Chained +Tue Oct 08 14:27:39 2002 (boucher) Type Predef = +Tue Oct 08 14:27:39 2002 (boucher) Type Type = String +Tue Oct 08 14:27:39 2002 (boucher) Type UI = NonEditableCombo + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/priority.typ b/code/nel/samples/sound/stream_file/data/DFN/sound/priority.typ new file mode 100644 index 000000000..d9bdbbd07 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/priority.typ @@ -0,0 +1,7 @@ + + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/rolloff.typ b/code/nel/samples/sound/stream_file/data/DFN/sound/rolloff.typ new file mode 100644 index 000000000..a5818a1a6 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/rolloff.typ @@ -0,0 +1,2 @@ + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/simple_sound.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/simple_sound.dfn new file mode 100644 index 000000000..60e97cc35 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/simple_sound.dfn @@ -0,0 +1,12 @@ + + + + + + + Wed Apr 09 21:13:23 2003 (AmazingSound) Dfn Structure = +Thu Apr 10 15:38:18 2003 (AmazingSound) Dfn Structure = +Thu Apr 10 16:24:05 2003 (AmazingSound) Dfn Structure = +Wed Apr 30 12:44:51 2003 (AmazingSound) Dfn Structure = +Wed Apr 30 12:45:39 2003 (AmazingSound) Dfn Structure = + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/sound.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/sound.dfn new file mode 100644 index 000000000..a8c336b0b --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/sound.dfn @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + Tue Oct 08 12:33:33 2002 (boucher) Dfn Structure = +Tue Oct 08 14:35:19 2002 (boucher) Dfn Structure = + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/sound_group.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/sound_group.dfn new file mode 100644 index 000000000..b058b36ff --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/sound_group.dfn @@ -0,0 +1,8 @@ + + + + Thu Jan 09 11:48:30 2003 (boucher) Dfn Structure = +Thu Jan 09 11:51:28 2003 (boucher) Dfn Structure = +Thu Jan 09 11:52:03 2003 (boucher) Dfn Structure = +Thu Jan 09 11:52:08 2003 (boucher) Dfn Structure = + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/sound_group_item.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/sound_group_item.dfn new file mode 100644 index 000000000..00420dbb9 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/sound_group_item.dfn @@ -0,0 +1,7 @@ + + + + + Thu Jan 09 11:47:55 2003 (boucher) Dfn Structure = +Thu Jan 09 11:53:15 2003 (boucher) Dfn Structure = + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/soundbank.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/soundbank.dfn new file mode 100644 index 000000000..38a60a89a --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/soundbank.dfn @@ -0,0 +1,4 @@ + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/stream_file_sound.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/stream_file_sound.dfn new file mode 100644 index 000000000..7293fc854 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/stream_file_sound.dfn @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/stream_sound.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/stream_sound.dfn new file mode 100644 index 000000000..82eaa9a6d --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/stream_sound.dfn @@ -0,0 +1,7 @@ + + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/transposition.typ b/code/nel/samples/sound/stream_file/data/DFN/sound/transposition.typ new file mode 100644 index 000000000..2d05a4471 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/transposition.typ @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/DFN/sound/user_var_binding.dfn b/code/nel/samples/sound/stream_file/data/DFN/sound/user_var_binding.dfn new file mode 100644 index 000000000..d2740f489 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/DFN/sound/user_var_binding.dfn @@ -0,0 +1,9 @@ + + + + + + Mon Feb 10 17:32:55 2003 (boucher) Dfn Structure = +Mon Feb 10 17:34:17 2003 (boucher) Dfn Structure = +Tue Feb 11 09:49:09 2003 (boucher) Dfn Structure = + diff --git a/code/nel/samples/sound/stream_file/data/animations/readme.txt b/code/nel/samples/sound/stream_file/data/animations/readme.txt new file mode 100644 index 000000000..43c7f150a --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/animations/readme.txt @@ -0,0 +1,3 @@ +This folder contains the sound track for animation. + +Put here all the .sound_anim file generated with NeL Object Viewer. \ No newline at end of file diff --git a/code/nel/samples/sound/stream_file/data/animations/test_anim.sound_anim b/code/nel/samples/sound/stream_file/data/animations/test_anim.sound_anim new file mode 100644 index 000000000..4377e81b6 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/animations/test_anim.sound_anim @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/background_sounds/background_sound.primitive b/code/nel/samples/sound/stream_file/data/background_sounds/background_sound.primitive new file mode 100644 index 000000000..26ff875f1 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/background_sounds/background_sound.primitive @@ -0,0 +1,144 @@ + + + + + + + + + class + audio + + + name + test_audio + + + + + class + sounds + + + name + sounds + + + + + + + + + class + sound_zone + + + name + test_zone + + + sound + beep.sound + + + + + + + + + + + class + sound_path + + + name + test_path + + + sound + tuut.sound + + + + + + + class + sound_point + + + name + test_point + + + sound + tuut.sound + + + + + + + class + sample_banks + + + name + sample_banks + + + + + + + + + bank_names + base_samples + + + class + sample_bank_zone + + + name + base_sample_zone + + + + + + + class + env_fx + + + name + env_fx + + + + + + + + + class + env_fx_zone + + + fx_name + BATHROOM + + + name + test_fx + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/background_sounds/readme.txt b/code/nel/samples/sound/stream_file/data/background_sounds/readme.txt new file mode 100644 index 000000000..6103b141c --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/background_sounds/readme.txt @@ -0,0 +1 @@ +This folder contains the background sound primitive files. \ No newline at end of file diff --git a/code/nel/samples/sound/stream_file/data/cluster_sound/readme.txt b/code/nel/samples/sound/stream_file/data/cluster_sound/readme.txt new file mode 100644 index 000000000..2668e737a --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/cluster_sound/readme.txt @@ -0,0 +1,11 @@ +This folder contains Georges sheets that link sound group defined in +the cluster system (edited in 3DS Max) to a sound sheet. + +This allow to put sound inside the cluster systems. + +Each sheet can contains any number of association. +It is a good practice to merge into a single sheet all +the sound groups/sound sheets thet belong the the +same building. + + \ No newline at end of file diff --git a/code/nel/samples/sound/stream_file/data/cluster_sound/test_clusters.sound_group b/code/nel/samples/sound/stream_file/data/cluster_sound/test_clusters.sound_group new file mode 100644 index 000000000..0ee91ba18 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/cluster_sound/test_clusters.sound_group @@ -0,0 +1,19 @@ + +
+ + + + + + + + + + + + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/default.mixer_config b/code/nel/samples/sound/stream_file/data/default.mixer_config new file mode 100644 index 000000000..fd9ca5a59 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/default.mixer_config @@ -0,0 +1,54 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fri Oct 15 15:26:53 2004 (boucher) .SampleBanks[0] = base_samples + diff --git a/code/nel/samples/sound/stream_file/data/samplebank/base_samples/beep.wav b/code/nel/samples/sound/stream_file/data/samplebank/base_samples/beep.wav new file mode 100644 index 000000000..8b4108a4c Binary files /dev/null and b/code/nel/samples/sound/stream_file/data/samplebank/base_samples/beep.wav differ diff --git a/code/nel/samples/sound/stream_file/data/samplebank/base_samples/tuut.wav b/code/nel/samples/sound/stream_file/data/samplebank/base_samples/tuut.wav new file mode 100644 index 000000000..bae70bc0f Binary files /dev/null and b/code/nel/samples/sound/stream_file/data/samplebank/base_samples/tuut.wav differ diff --git a/code/nel/samples/sound/stream_file/data/soundbank/beep.sound b/code/nel/samples/sound/stream_file/data/soundbank/beep.sound new file mode 100644 index 000000000..dbda3735c --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/soundbank/beep.sound @@ -0,0 +1,19 @@ + +
+ + + + + + + + + + + + Fri Oct 15 15:23:46 2004 (boucher) .SoundType = simple_sound.dfn +Fri Oct 15 15:23:46 2004 (boucher) .SoundType.Filename = beep.wav +Fri Oct 15 15:23:46 2004 (boucher) .SoundType.MaxDistance = 1000 +Fri Oct 15 15:23:46 2004 (boucher) .SoundType.MinDistance = 1.2 +Fri Oct 15 15:27:24 2004 (boucher) .SoundType.Alpha = + diff --git a/code/nel/samples/sound/stream_file/data/soundbank/default_stream.sound b/code/nel/samples/sound/stream_file/data/soundbank/default_stream.sound new file mode 100644 index 000000000..c757128fc --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/soundbank/default_stream.sound @@ -0,0 +1,20 @@ + +
+ + + + + + + + + + + + + Thu Jan 28 23:30:44 2010 (Kaetemi) .AbsolutePosition = false +Thu Jan 28 23:30:44 2010 (Kaetemi) .Priority = Highest +Thu Jan 28 23:30:44 2010 (Kaetemi) .SoundType = stream_sound.dfn +Thu Jan 28 23:30:44 2010 (Kaetemi) .SoundType.MaxDistance = 100000 +Thu Jan 28 23:30:44 2010 (Kaetemi) .SoundType.MinDistance = 200000 + diff --git a/code/nel/samples/sound/stream_file/data/soundbank/stream_file.sound b/code/nel/samples/sound/stream_file/data/soundbank/stream_file.sound new file mode 100644 index 000000000..a98ae3a3c --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/soundbank/stream_file.sound @@ -0,0 +1,18 @@ + +
+ + + + + + + + + + + + + + + + diff --git a/code/nel/samples/sound/stream_file/data/soundbank/tuut.sound b/code/nel/samples/sound/stream_file/data/soundbank/tuut.sound new file mode 100644 index 000000000..c45cfba63 --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/soundbank/tuut.sound @@ -0,0 +1,20 @@ + +
+ + + + + + + + + + + + + Fri Oct 15 15:24:54 2004 (boucher) .SoundType = simple_sound.dfn +Fri Oct 15 15:24:54 2004 (boucher) .SoundType.Alpha = 0.5 +Fri Oct 15 15:24:54 2004 (boucher) .SoundType.Filename = tuut.wav +Fri Oct 15 15:24:54 2004 (boucher) .SoundType.MaxDistance = 50 +Fri Oct 15 15:24:54 2004 (boucher) .SoundType.MinDistance = 5 + diff --git a/code/nel/samples/sound/stream_file/data/world_editor_classes.xml b/code/nel/samples/sound/stream_file/data/world_editor_classes.xml new file mode 100644 index 000000000..68ba22ace --- /dev/null +++ b/code/nel/samples/sound/stream_file/data/world_editor_classes.xml @@ -0,0 +1,382 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/code/nel/samples/sound/stream_file/stream_file.cpp b/code/nel/samples/sound/stream_file/stream_file.cpp new file mode 100644 index 000000000..623ee4ff0 --- /dev/null +++ b/code/nel/samples/sound/stream_file/stream_file.cpp @@ -0,0 +1,184 @@ +// NeL - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include + +// STL includes +#include +#ifdef NL_OS_WINDOWS +# include +#else +# include +#endif + +// NeL includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// For direct play/pause control. +// You should never include this! +#include + +// Project includes + +#ifndef NL_SOUND_DATA +#define NL_SOUND_DATA "." +#endif // NL_SOUND_DATA + +#define RYZOM_DATA "P:/data" +#define SAMPLE_OGG "Pyr Entrance.ogg" + +using namespace std; +using namespace NLMISC; +using namespace NLSOUND; + +namespace NLSAMPLE { + +static UAudioMixer *s_AudioMixer = NULL; +static USource *s_Source = NULL; +static CStreamFileSource *s_StreamFileSource = NULL; +static UGroupController *s_GroupController = NULL; + +static void initSample() +{ + if (!INelContext::isContextInitialised()) + new CApplicationContext(); + CPath::addSearchPath(NL_SOUND_DATA"/data", true, false); + + printf("Sample demonstrating OGG playback using stream file .sound sheets."); + printf("\n\n"); + + s_AudioMixer = UAudioMixer::createAudioMixer(); + + // Set the sample path before init, this allow the mixer to build the sample banks + s_AudioMixer->setSamplePath(NL_SOUND_DATA"/data/samplebank"); + // Packed sheet option, this mean we want packed sheet generated in 'data' folder + s_AudioMixer->setPackedSheetOption(NL_SOUND_DATA"/data", true); + + printf("Select NLSOUND Driver:\n"); + printf(" [1] FMod\n"); + printf(" [2] OpenAl\n"); + printf(" [3] DSound\n"); + printf(" [4] XAudio2\n"); + printf("> "); + int selection = getchar(); getchar(); + printf("\n"); + + // init with 8 tracks, EAX enabled, no ADPCM, and automatic sample bank loading + s_AudioMixer->init(8, true, false, NULL, true, (UAudioMixer::TDriver)(selection - '0')); + s_AudioMixer->setLowWaterMark(1); + + CVector initpos(0.0f, 0.0f, 0.0f); + CVector frontvec(0.0f, 1.0f, 0.0f); + CVector upvec(0.0f, 0.0f, 1.0f); + s_AudioMixer->getListener()->setPos(initpos); + s_AudioMixer->getListener()->setOrientation(frontvec, upvec); + + CPath::addSearchPath(RYZOM_DATA, true, false); + + //NLMISC::CHTimer::startBench(); + + s_Source = s_AudioMixer->createSource(CStringMapper::map("stream_file")); + nlassert(s_Source); + s_StreamFileSource = dynamic_cast(s_Source); + nlassert(s_StreamFileSource); + // s_Source->setSourceRelativeMode(true); + // s_Source->setPitch(2.0f); + + s_GroupController = s_AudioMixer->getGroupController("sound:dialog"); +} + +static void runSample() +{ + s_Source->play(); + + printf("Change volume with - and +\n"); + printf("Press ANY other key to exit\n"); + for (; ; ) + { +#ifdef NL_OS_WINDOWS + if (_kbhit()) + { + switch (_getch()) +#else + char ch; + if (read(0, &ch, 1)) + { + switch (ch) +#endif + { + case '+': + s_GroupController->setGain(s_GroupController->getGain() + 0.1f); + break; + case '-': + s_GroupController->setGain(s_GroupController->getGain() - 0.1f); + break; + case 'x': + s_Source->stop(); + break; + case 's': + s_Source->play(); + break; + case 'p': + s_StreamFileSource->pause(); + break; + case 'r': + s_StreamFileSource->resume(); + break; + case 'e': + s_AudioMixer->playMusic(SAMPLE_OGG, 1000, true, false); + break; + default: + return; + } + } + + s_AudioMixer->update(); + + nlSleep(40); + } +} + +static void releaseSample() +{ + //NLMISC::CHTimer::clear(); + s_GroupController = NULL; + s_StreamFileSource = NULL; + delete s_Source; s_Source = NULL; + delete s_AudioMixer; s_AudioMixer = NULL; +} + + + +} /* namespace NLSAMPLE */ + +int main() +{ + NLSAMPLE::initSample(); + NLSAMPLE::runSample(); + NLSAMPLE::releaseSample(); + return 0; +} + +/* end of file */ diff --git a/code/nel/samples/sound/stream_ogg_vorbis/CMakeLists.txt b/code/nel/samples/sound/stream_ogg_vorbis/CMakeLists.txt new file mode 100644 index 000000000..db978fc88 --- /dev/null +++ b/code/nel/samples/sound/stream_ogg_vorbis/CMakeLists.txt @@ -0,0 +1,12 @@ +FILE(GLOB SRC *.cpp *.h) + +ADD_EXECUTABLE(nl_sample_stream_ogg_vorbis ${SRC}) + +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) + +TARGET_LINK_LIBRARIES(nl_sample_stream_ogg_vorbis nelmisc nelsound) +NL_DEFAULT_PROPS(nl_sample_stream_ogg_vorbis "NeL, Samples: Sound: Stream OGG Vorbis") +NL_ADD_RUNTIME_FLAGS(nl_sample_stream_ogg_vorbis) + +INSTALL(TARGETS nl_sample_stream_ogg_vorbis RUNTIME DESTINATION bin COMPONENT samplessound) + diff --git a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp index 441eee932..e0f0df705 100644 --- a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp +++ b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp @@ -18,16 +18,10 @@ // STL includes #include -#include - -// 3rd Party includes #ifdef NL_OS_WINDOWS -# pragma warning( push ) -# pragma warning( disable : 4244 ) -#endif -#include -#ifdef NL_OS_WINDOWS -# pragma warning( pop ) +# include +#else +# include #endif // NeL includes @@ -40,6 +34,8 @@ #include #include #include +#include +#include #include // Project includes @@ -48,7 +44,7 @@ #define NL_SOUND_DATA "." #endif // NL_SOUND_DATA -#define SAMPLE_OGG "O:/src/samples/music_stream/data/aeon_1_10_mystic_river.ogg" +#define SAMPLE_OGG "D:/source/kaetemi/toverhex/src/samples/music_stream/data/aeon_1_10_mystic_river.ogg" using namespace std; using namespace NLMISC; @@ -56,275 +52,10 @@ using namespace NLSOUND; namespace NLSAMPLE { -/** - * \brief IAudioDecoder - * \date 2008-08-30 11:38GMT - * \author Jan Boon (Kaetemi) - * IAudioDecoder is only used by the driver implementation to stream - * music files into a readable format (it's a simple decoder interface). - * You should not call these functions (getSongTitle) on nlsound or user level, - * as a driver might have additional music types implemented. - * TODO: Split IAudioDecoder into IAudioDecoder (actual decoding) and IMediaDemuxer (stream splitter), and change the interface to make more sense. - * TODO: Allow user application to register more decoders. - * TODO: Look into libavcodec for decoding audio? - */ -class IAudioDecoder -{ -private: - // pointers - /// Stream from file created by IAudioDecoder - NLMISC::IStream *_InternalStream; - -public: - IAudioDecoder(); - virtual ~IAudioDecoder(); - - /// Create a new music buffer, may return NULL if unknown type, destroy with delete. Filepath lookup done here. If async is true, it will stream from hd, else it will load in memory first. - static IAudioDecoder *createAudioDecoder(const std::string &filepath, bool async, bool loop); - - /// Create a new music buffer from a stream, type is file extension like "ogg" etc. - static IAudioDecoder *createAudioDecoder(const std::string &type, NLMISC::IStream *stream, bool loop); - - /// Get information on a music file (only artist and title at the moment). - static bool getInfo(const std::string &filepath, std::string &artist, std::string &title); - - /// Get audio/container extensions that are currently supported by the nel sound library. - static void getMusicExtensions(std::vector &extensions); - - /// Return if a music extension is supported by the nel sound library. - static bool isMusicExtensionSupported(const std::string &extension); - - /// Get how many bytes the music buffer requires for output minimum. - virtual uint32 getRequiredBytes() = 0; - - /// Get an amount of bytes between minimum and maximum (can be lower than minimum if at end). - virtual uint32 getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum) = 0; - - /// Get the amount of channels (2 is stereo) in output. - virtual uint8 getChannels() = 0; - - /// Get the samples per second (often 44100) in output. - virtual uint getSamplesPerSec() = 0; - - /// Get the bits per sample (often 16) in output. - virtual uint8 getBitsPerSample() = 0; - - /// Get if the music has ended playing (never true if loop). - virtual bool isMusicEnded() = 0; - - /// Get the total time in seconds. - virtual float getLength() = 0; -}; /* class IAudioDecoder */ - -/** - * \brief CAudioDecoderVorbis - * \date 2008-08-30 11:38GMT - * \author Jan Boon (Kaetemi) - * CAudioDecoderVorbis - * Create trough IAudioDecoder, type "ogg" - */ -class CAudioDecoderVorbis : public IAudioDecoder -{ -protected: - // outside pointers - NLMISC::IStream *_Stream; - - // pointers - - // instances - OggVorbis_File _OggVorbisFile; - bool _Loop; - bool _IsMusicEnded; - sint32 _StreamOffset; - sint32 _StreamSize; -public: - CAudioDecoderVorbis(NLMISC::IStream *stream, bool loop); - virtual ~CAudioDecoderVorbis(); - inline NLMISC::IStream *getStream() { return _Stream; } - inline sint32 getStreamSize() { return _StreamSize; } - inline sint32 getStreamOffset() { return _StreamOffset; } - - /// Get information on a music file (only artist and title at the moment). - static bool getInfo(NLMISC::IStream *stream, std::string &artist, std::string &title); - - /// Get how many bytes the music buffer requires for output minimum. - virtual uint32 getRequiredBytes(); - - /// Get an amount of bytes between minimum and maximum (can be lower than minimum if at end). - virtual uint32 getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum); - - /// Get the amount of channels (2 is stereo) in output. - virtual uint8 getChannels(); - - /// Get the samples per second (often 44100) in output. - virtual uint getSamplesPerSec(); - - /// Get the bits per sample (often 16) in output. - virtual uint8 getBitsPerSample(); - - /// Get if the music has ended playing (never true if loop). - virtual bool isMusicEnded(); - - /// Get the total time in seconds. - virtual float getLength(); -}; /* class CAudioDecoderVorbis */ - -IAudioDecoder::IAudioDecoder() : _InternalStream(NULL) -{ - -} - -IAudioDecoder::~IAudioDecoder() -{ - if (_InternalStream) { delete _InternalStream; _InternalStream = NULL; } -} - -IAudioDecoder *IAudioDecoder::createAudioDecoder(const std::string &filepath, bool async, bool loop) -{ - string lookup = CPath::lookup(filepath, false); - if (lookup.empty()) - { - nlwarning("Music file %s does not exist!", filepath.c_str()); - return NULL; - } - string type = CFile::getExtension(filepath); - - CIFile *ifile = new CIFile(); - ifile->setCacheFileOnOpen(!async); - ifile->allowBNPCacheFileOnOpen(!async); - ifile->open(lookup); - - IAudioDecoder *mb = createAudioDecoder(type, ifile, loop); - - if (mb) mb->_InternalStream = ifile; - else delete ifile; - - return mb; -} - -IAudioDecoder *IAudioDecoder::createAudioDecoder(const std::string &type, NLMISC::IStream *stream, bool loop) -{ - if (!stream) - { - nlwarning("Stream is NULL"); - return NULL; - } - string type_lower = toLower(type); - if (type_lower == "ogg") - { - return new CAudioDecoderVorbis(stream, loop); - } - else - { - nlwarning("Music file type unknown: '%s'", type_lower.c_str()); - return NULL; - } -} - -bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, std::string &title) -{ - string lookup = CPath::lookup(filepath, false); - if (lookup.empty()) - { - nlwarning("Music file %s does not exist!", filepath.c_str()); - return false; - } - string type = CFile::getExtension(filepath); - string type_lower = toLower(type); - - if (type_lower == "ogg") - { - CIFile ifile; - ifile.setCacheFileOnOpen(false); - ifile.allowBNPCacheFileOnOpen(false); - ifile.open(lookup); - return CAudioDecoderVorbis::getInfo(&ifile, artist, title); - } - else - { - nlwarning("Music file type unknown: '%s'", type_lower.c_str()); - artist.clear(); title.clear(); - return false; - } -} - -/// Get audio/container extensions that are currently supported by the nel sound library. -void IAudioDecoder::getMusicExtensions(std::vector &extensions) -{ - extensions.push_back("ogg"); - // extensions.push_back("wav"); // TODO: Easy. -} - -/// Return if a music extension is supported by the nel sound library. -bool IAudioDecoder::isMusicExtensionSupported(const std::string &extension) -{ - return (extension == "ogg"); -} - -size_t vorbisReadFunc(void *ptr, size_t size, size_t nmemb, void *datasource) -{ - CAudioDecoderVorbis *audio_decoder_vorbis = (CAudioDecoderVorbis *)datasource; - NLMISC::IStream *stream = audio_decoder_vorbis->getStream(); - nlassert(stream->isReading()); - sint32 length = (sint32)(size * nmemb); - if (length > audio_decoder_vorbis->getStreamSize() - stream->getPos()) - length = audio_decoder_vorbis->getStreamSize() - stream->getPos(); - stream->serialBuffer((uint8 *)ptr, length); - return length; -} - -int vorbisSeekFunc(void *datasource, ogg_int64_t offset, int whence) -{ - if (whence == SEEK_CUR && offset == 0) - { - // nlwarning(NLSOUND_XAUDIO2_PREFIX "This seek call doesn't do a damn thing, wtf."); - return 0; // ooookkaaaaaayyy - } - - CAudioDecoderVorbis *audio_decoder_vorbis = (CAudioDecoderVorbis *)datasource; - - NLMISC::IStream::TSeekOrigin origin; - switch (whence) - { - case SEEK_SET: - origin = NLMISC::IStream::begin; - break; - case SEEK_CUR: - origin = NLMISC::IStream::current; - break; - case SEEK_END: - origin = NLMISC::IStream::end; - break; - default: - // nlwarning(NLSOUND_XAUDIO2_PREFIX "Seeking to fake origin."); - return -1; - } - - if (audio_decoder_vorbis->getStream()->seek(SEEK_SET ? audio_decoder_vorbis->getStreamOffset() + (sint32)offset : (sint32)offset, origin)) return 0; - else return -1; -} - -//int vorbisCloseFunc(void *datasource) -//{ -// //CAudioDecoderVorbis *audio_decoder_vorbis = (CAudioDecoderVorbis *)datasource; -//} - -long vorbisTellFunc(void *datasource) -{ - CAudioDecoderVorbis *audio_decoder_vorbis = (CAudioDecoderVorbis *)datasource; - return (long)(audio_decoder_vorbis->getStream()->getPos() - audio_decoder_vorbis->getStreamOffset()); -} - -static ov_callbacks OV_CALLBACKS_NLMISC_STREAM = { - (size_t (*)(void *, size_t, size_t, void *)) vorbisReadFunc, - (int (*)(void *, ogg_int64_t, int)) vorbisSeekFunc, - (int (*)(void *)) NULL, //vorbisCloseFunc, - (long (*)(void *)) vorbisTellFunc -}; - static UAudioMixer *s_AudioMixer = NULL; static UStreamSource *s_StreamSource = NULL; static IAudioDecoder *s_AudioDecoder = NULL; +static UGroupController *s_GroupController = NULL; static void initSample() { @@ -367,6 +98,9 @@ static void initSample() string sample = SAMPLE_OGG; s_AudioDecoder = IAudioDecoder::createAudioDecoder(sample, false, false); s_StreamSource->setFormat(s_AudioDecoder->getChannels(), s_AudioDecoder->getBitsPerSample(), (uint32)s_AudioDecoder->getSamplesPerSec()); + //s_StreamSource->setPitch(2.0f); + + s_GroupController = s_AudioMixer->getGroupController("sound:dialog"); } //CMutex *s_Mutex = NULL; @@ -404,15 +138,33 @@ static void runSample() s_StreamSource->play(); - printf("Press ANY key to exit\n"); + printf("Change volume with - and +\n"); + printf("Press ANY other key to exit\n"); while (!s_AudioDecoder->isMusicEnded()) { +#ifdef NL_OS_WINDOWS if (_kbhit()) { - _getch(); - return; + switch (_getch()) +#else + char ch; + if (read(0, &ch, 1)) + { + switch (ch) +#endif + { + case '+': + s_GroupController->setGain(s_GroupController->getGain() + 0.1f); + break; + case '-': + s_GroupController->setGain(s_GroupController->getGain() - 0.1f); + break; + default: + return; + } } bufferMore(bytes); + s_AudioMixer->update(); //if (!s_StreamSource->asUSource()->isst) //{ // printf("*!playing!*"); @@ -424,122 +176,32 @@ static void runSample() while (s_StreamSource->hasFilledBuffersAvailable()) { nlSleep(40); + s_AudioMixer->update(); } s_StreamSource->stop(); printf("End of song\n"); printf("Press ANY key to exit\n"); - while (!_kbhit()) { s_AudioMixer->update(); Sleep(10); } _getch(); +#ifdef NL_OS_WINDOWS + while (!_kbhit()) +#else + char ch; + while (!read(0, &ch, 1)) +#endif + { s_AudioMixer->update(); nlSleep(10); } return; } static void releaseSample() { //NLMISC::CHTimer::clear(); + s_GroupController = NULL; delete s_AudioDecoder; s_AudioDecoder = NULL; delete s_StreamSource; s_StreamSource = NULL; delete s_AudioMixer; s_AudioMixer = NULL; } -CAudioDecoderVorbis::CAudioDecoderVorbis(NLMISC::IStream *stream, bool loop) -: _Stream(stream), _Loop(loop), _StreamSize(0), _IsMusicEnded(false) -{ - _StreamOffset = stream->getPos(); - stream->seek(0, NLMISC::IStream::end); - _StreamSize = stream->getPos(); - stream->seek(_StreamOffset, NLMISC::IStream::begin); - ov_open_callbacks(this, &_OggVorbisFile, NULL, 0, OV_CALLBACKS_NLMISC_STREAM); -} - -CAudioDecoderVorbis::~CAudioDecoderVorbis() -{ - ov_clear(&_OggVorbisFile); -} - -/// Get information on a music file (only artist and title at the moment). -bool CAudioDecoderVorbis::getInfo(NLMISC::IStream *stream, std::string &artist, std::string &title) -{ - CAudioDecoderVorbis mbv(stream, false); // just opens and closes the oggvorbisfile thing :) - vorbis_comment *vc = ov_comment(&mbv._OggVorbisFile, -1); - char *title_c = vorbis_comment_query(vc, "title", 0); - if (title_c) title = title_c; else title.clear(); - char *artist_c = vorbis_comment_query(vc, "artist", 0); - if (artist_c) artist = artist_c; else artist.clear(); - return true; -} - -uint32 CAudioDecoderVorbis::getRequiredBytes() -{ - return 0; // no minimum requirement of bytes to buffer out -} - -uint32 CAudioDecoderVorbis::getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum) -{ - int current_section = 0; // ??? - if (_IsMusicEnded) return 0; - nlassert(minimum <= maximum); // can't have this.. - uint32 bytes_read = 0; - do - { - // signed 16-bit or unsigned 8-bit little-endian samples - int br = ov_read(&_OggVorbisFile, (char *)&buffer[bytes_read], maximum - bytes_read, - 0, // Specifies big or little endian byte packing. 0 for little endian, 1 for b ig endian. Typical value is 0. - getBitsPerSample() == 8 ? 1 : 2, - getBitsPerSample() == 8 ? 0 : 1, // Signed or unsigned data. 0 for unsigned, 1 for signed. Typically 1. - ¤t_section); - // nlinfo(NLSOUND_XAUDIO2_PREFIX "current_section: %i", current_section); - if (br <= 0) - { - if (br == 0) - { - if (_Loop) - { - ov_pcm_seek(&_OggVorbisFile, 0); - //_Stream->seek(0, NLMISC::IStream::begin); - } - else - { - _IsMusicEnded = true; - break; - } - } - else - { - nlwarning("ov_read: %i", br); - } - } - else bytes_read += (uint32)br; - } while (bytes_read < minimum); - return bytes_read; -} - -uint8 CAudioDecoderVorbis::getChannels() -{ - vorbis_info *vi = ov_info(&_OggVorbisFile, -1); - return (uint8)vi->channels; -} - -uint CAudioDecoderVorbis::getSamplesPerSec() -{ - vorbis_info *vi = ov_info(&_OggVorbisFile, -1); - return (uint)vi->rate; -} - -uint8 CAudioDecoderVorbis::getBitsPerSample() -{ - return 16; -} - -bool CAudioDecoderVorbis::isMusicEnded() -{ - return _IsMusicEnded; -} - -float CAudioDecoderVorbis::getLength() -{ - return (float)ov_time_total(&_OggVorbisFile, -1); -} } /* namespace NLSAMPLE */ diff --git a/code/nel/src/misc/bit_mem_stream.cpp b/code/nel/src/misc/bit_mem_stream.cpp index c050d9c61..007b95cbc 100644 --- a/code/nel/src/misc/bit_mem_stream.cpp +++ b/code/nel/src/misc/bit_mem_stream.cpp @@ -599,7 +599,7 @@ void CBitMemStream::append( const CBitMemStream& newBits ) /* * Serial bitmemstream */ -void CBitMemStream::serialMemStream(CBitMemStream &b) +void CBitMemStream::serialMemStream(CMemStream &b) { #ifdef LOG_ALL_TRAFFIC sint32 bitpos = getPosInBit(); diff --git a/code/nel/src/misc/bitmap_jpeg.cpp b/code/nel/src/misc/bitmap_jpeg.cpp index 835110d86..a4eaaa0b9 100644 --- a/code/nel/src/misc/bitmap_jpeg.cpp +++ b/code/nel/src/misc/bitmap_jpeg.cpp @@ -109,7 +109,7 @@ static void jpgDecompressSkip(j_decompress_ptr cinfo, long num_bytes) } } -static void jpgDecompressTerm(j_decompress_ptr cinfo) +static void jpgDecompressTerm(j_decompress_ptr /* cinfo */) { } diff --git a/code/nel/src/misc/co_task.cpp b/code/nel/src/misc/co_task.cpp index 1880be06c..c66941a40 100644 --- a/code/nel/src/misc/co_task.cpp +++ b/code/nel/src/misc/co_task.cpp @@ -237,12 +237,15 @@ namespace NLMISC _PImpl = new TCoTaskData(this); // _PImpl->_TaskThreadId = 0; // _PImpl->_ParentThreadId = 0; + nlunreferenced(stackSize); #else //NL_USE_THREAD_COTASK // allocate platform specific data storage _PImpl = new TCoTaskData; + nlunreferenced(stackSize); #if defined (NL_OS_WINDOWS) _PImpl->_Fiber = NULL; _PImpl->_ParentFiber = NULL; + nlunreferenced(stackSize); #elif defined(NL_OS_UNIX) // allocate the stack _PImpl->_Stack = new uint8[stackSize]; diff --git a/code/nel/src/misc/command.cpp b/code/nel/src/misc/command.cpp index 80d074386..f2b422d69 100644 --- a/code/nel/src/misc/command.cpp +++ b/code/nel/src/misc/command.cpp @@ -650,6 +650,9 @@ ICommand *CCommandRegistry::getCommand(const std::string &commandName) NLMISC_CATEGORISED_COMMAND(nel,help,"display help on a specific variable/commands or on all variables and commands", "[|]") { + nlunreferenced(rawCommandString); + nlunreferenced(quiet); + nlunreferenced(human); // nlassert (_Commands != NULL); // make sure we have a valid number of parameters diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 19be95367..d89708c4e 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -373,6 +373,10 @@ uint32 humanReadableToBytes (const string &str) NLMISC_CATEGORISED_COMMAND(nel,btohr, "Convert a bytes number into an human readable number", "") { + nlunreferenced(rawCommandString); + nlunreferenced(quiet); + nlunreferenced(human); + if (args.size() != 1) return false; @@ -384,6 +388,10 @@ NLMISC_CATEGORISED_COMMAND(nel,btohr, "Convert a bytes number into an human read NLMISC_CATEGORISED_COMMAND(nel,hrtob, "Convert a human readable number into a bytes number", "
") { + nlunreferenced(rawCommandString); + nlunreferenced(quiet); + nlunreferenced(human); + if (args.size() != 1) return false; @@ -446,6 +454,10 @@ uint32 fromHumanReadable (const std::string &str) NLMISC_CATEGORISED_COMMAND(nel,stohr, "Convert a second number into an human readable time", "") { + nlunreferenced(rawCommandString); + nlunreferenced(quiet); + nlunreferenced(human); + if (args.size() != 1) return false; @@ -529,8 +541,8 @@ void toUpper(char *str) std::string formatThousands(const std::string& s) { - int i, k; - int remaining = s.length() - 1; + sint i, k; + sint remaining = (sint)s.length() - 1; static std::string separator = NLMISC::CI18N::get("uiThousandsSeparator").toUtf8(); // Don't add separator if the number is < 10k @@ -540,7 +552,7 @@ std::string formatThousands(const std::string& s) do { - for (i = remaining, k = 0; i >= 0 && k < 3; --i, ++k ) + for (i = remaining, k = 0; i >= 0 && k < 3; --i, ++k ) { ns = s[i] + ns; // New char is added to front of ns if ( i > 0 && k == 2) ns = separator + ns; // j > 0 means still more digits @@ -829,6 +841,7 @@ int nlfseek64( FILE *stream, sint64 offset, int origin ) return fsetpos (stream, &pos64); #else // NL_OS_WINDOWS + // TODO: to fix for Linux and Mac OS X // This code doesn't work under windows : fseek() implementation uses a signed 32 bits offset. What ever we do, it can't seek more than 2 Go. // For the moment, i don't know if it works under linux for seek of more than 2 Go. @@ -871,6 +884,9 @@ sint64 nlftell64(FILE *stream) } else return -1; #else + nlunreferenced(stream); + + // TODO: implement for Linux and Mac OS X nlerror("Not implemented"); return -1; #endif @@ -885,9 +901,14 @@ sint64 nlftell64(FILE *stream) NLMISC_CATEGORISED_COMMAND(nel, sleep, "Freeze the service for N seconds (for debug purpose)", "") { + nlunreferenced(rawCommandString); + nlunreferenced(quiet); + nlunreferenced(human); + if(args.size() != 1) return false; - sint32 n = atoi (args[0].c_str()); + sint32 n; + fromString(args[0], n); log.displayNL ("Sleeping during %d seconds", n); @@ -897,6 +918,10 @@ NLMISC_CATEGORISED_COMMAND(nel, sleep, "Freeze the service for N seconds (for de NLMISC_CATEGORISED_COMMAND(nel, system, "Execute the command line using system() function call (wait until the end of the command)", "") { + nlunreferenced(rawCommandString); + nlunreferenced(quiet); + nlunreferenced(human); + if(args.size() != 1) return false; string cmd = args[0]; @@ -915,6 +940,10 @@ NLMISC_CATEGORISED_COMMAND(nel, system, "Execute the command line using system() NLMISC_CATEGORISED_COMMAND(nel, launchProgram, "Execute the command line using launcProgram() function call (launch in background task without waiting the end of the execution)", " ") { + nlunreferenced(rawCommandString); + nlunreferenced(quiet); + nlunreferenced(human); + if(args.size() != 2) return false; string cmd = args[0]; @@ -927,6 +956,10 @@ NLMISC_CATEGORISED_COMMAND(nel, launchProgram, "Execute the command line using l NLMISC_CATEGORISED_COMMAND(nel, killProgram, "kill a program given the pid", "") { + nlunreferenced(rawCommandString); + nlunreferenced(quiet); + nlunreferenced(human); + if(args.size() != 1) return false; uint32 pid; fromString(args[0], pid); @@ -1030,6 +1063,9 @@ bool openDoc (const char *document) } else return true; +#else + // TODO: implement for Linux and Mac OS X + nlunreferenced(document); #endif // NL_OS_WINDOWS return false; } diff --git a/code/nel/src/misc/fast_id_map.cpp b/code/nel/src/misc/fast_id_map.cpp new file mode 100644 index 000000000..f32d6edd8 --- /dev/null +++ b/code/nel/src/misc/fast_id_map.cpp @@ -0,0 +1,44 @@ +/** + * \file fast_id_map.cpp + * \brief CFastIdMap + * \date 2012-04-10 19:28GMT + * \author Jan Boon (Kaetemi) + * CFastIdMap + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#include +#include + +// STL includes + +// NeL includes +// #include + +// Project includes + +namespace NLMISC { + +void dummytoavoidthecompilerwarningfastidmap() { } + +} /* namespace NLMISC */ + +/* end of file */ diff --git a/code/nel/src/misc/p_thread.cpp b/code/nel/src/misc/p_thread.cpp index d4f1582b4..f752f4bdf 100644 --- a/code/nel/src/misc/p_thread.cpp +++ b/code/nel/src/misc/p_thread.cpp @@ -84,6 +84,17 @@ static void *ProxyFunc( void *arg ) // Run the code of the thread parent->Runnable->run(); + { + pthread_t thread_self = pthread_self(); + // Make sure the parent still cares + // If this thread was replaced with a new thread (which should not happen), + // and the IThread object has been deleted, this will likely crash. + if (parent->_ThreadHandle == thread_self) + parent->_State = CPThread::ThreadStateFinished; + else + throw EThread("Thread ended after being detached, this should not happen"); + } + // Allow some clean // pthread_exit(0); return NULL; @@ -96,7 +107,7 @@ static void *ProxyFunc( void *arg ) */ CPThread::CPThread(IRunnable *runnable, uint32 stackSize) : Runnable(runnable), - _State(0), + _State(ThreadStateNone), _StackSize(stackSize) {} @@ -106,10 +117,9 @@ CPThread::CPThread(IRunnable *runnable, uint32 stackSize) */ CPThread::~CPThread() { - if(_State == 1) - terminate(); // force the end of the thread if not already ended + terminate(); // force the end of the thread if not already ended - if(_State > 0) + if (_State != ThreadStateNone) pthread_detach(_ThreadHandle); // free allocated resources only if it was created } @@ -119,26 +129,51 @@ CPThread::~CPThread() void CPThread::start() { pthread_attr_t tattr; - pthread_t tid; int ret; - /* initialized with default attributes */ - ret = pthread_attr_init(&tattr); + if (_StackSize != 0) + { + /* initialized with default attributes */ + ret = pthread_attr_init(&tattr); - /* setting the size of the stack also */ - ret = pthread_attr_setstacksize(&tattr, _StackSize); + /* setting the size of the stack also */ + ret = pthread_attr_setstacksize(&tattr, _StackSize); + } + + bool detach_old_thread = false; + pthread_t old_thread_handle; + if (_State != ThreadStateNone) + { + if (_State == ThreadStateRunning) + { + // I don't know if this behaviour is allowed, but neither thread implementations + // check the start function, and both simply let the existing running thread for what it is... + // From now on, this is not allowed. + throw EThread("Starting a thread that is already started, existing thread will continue running, this should not happen"); + } + detach_old_thread = true; + old_thread_handle = _ThreadHandle; + } - if(pthread_create(&_ThreadHandle, _StackSize != 0 ? &tattr : 0, ProxyFunc, this) != 0) + if (pthread_create(&_ThreadHandle, _StackSize != 0 ? &tattr : NULL, ProxyFunc, this) != 0) { throw EThread("Cannot start new thread"); } - _State = 1; + _State = ThreadStateRunning; + + if (detach_old_thread) + { + // Docs don't say anything about what happens when pthread_create is called with existing handle referenced. + if (old_thread_handle == _ThreadHandle) + throw EThread("Thread handle did not change, this should not happen"); + // Don't care about old thread, free resources when it terminates. + pthread_detach(old_thread_handle); + } } bool CPThread::isRunning() { - // TODO : need a real implementation here that check thread status - return _State == 1; + return _State == ThreadStateRunning; } /* @@ -146,11 +181,11 @@ bool CPThread::isRunning() */ void CPThread::terminate() { - if(_State == 1) + if (_State == ThreadStateRunning) { // cancel only if started pthread_cancel(_ThreadHandle); - _State = 2; // set to finished + _State = ThreadStateFinished; // set to finished } } @@ -159,13 +194,24 @@ void CPThread::terminate() */ void CPThread::wait () { - if(_State == 1) + if (_State == ThreadStateRunning) { - if(pthread_join(_ThreadHandle, 0) != 0) + int error = pthread_join(_ThreadHandle, 0); + switch (error) { - throw EThread( "Cannot join with thread" ); + case 0: + break; + case EINVAL: + throw EThread("Thread is not joinable"); + case ESRCH: + throw EThread("No thread found with this id"); + case EDEADLK: + throw EThread("Deadlock detected or calling thread waits for itself"); + default: + throw EThread("Unknown thread join error"); } - _State = 2; // set to finished + if(_State != ThreadStateFinished) + throw EThread("Thread did not finish, this should not happen"); } } @@ -207,6 +253,34 @@ uint64 CPThread::getCPUMask() return cpuMask; } +void CPThread::setPriority(TThreadPriority priority) +{ + // TODO: Test this + sched_param sp; + switch (priority) + { + case ThreadPriorityHigh: + { + int minPrio = sched_get_priority_min(SCHED_FIFO); + int maxPrio = sched_get_priority_max(SCHED_FIFO); + sp.sched_priority = ((maxPrio - minPrio) / 4) + minPrio; + pthread_setschedparam(_ThreadHandle, SCHED_FIFO, &sp); + break; + } + case ThreadPriorityHighest: + { + int minPrio = sched_get_priority_min(SCHED_FIFO); + int maxPrio = sched_get_priority_max(SCHED_FIFO); + sp.sched_priority = ((maxPrio - minPrio) / 2) + minPrio; + pthread_setschedparam(_ThreadHandle, SCHED_FIFO, &sp); + break; + } + default: + sp.sched_priority = 0; + pthread_setschedparam(_ThreadHandle, SCHED_OTHER, &sp); + } +} + /* * getUserName */ diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index 0eaad3a7a..617c994b7 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -592,7 +592,7 @@ uint32 CSheetId::typeFromFileExtension(const std::string &fileExtension) { if (!_Initialised) init(false); - unsigned i; + uint i; for (i=0;i<_FileExtensions.size();i++) if (toLower(fileExtension)==_FileExtensions[i]) return i; diff --git a/code/nel/src/misc/sstring.cpp b/code/nel/src/misc/sstring.cpp index 4c37b1f1a..ef1584361 100644 --- a/code/nel/src/misc/sstring.cpp +++ b/code/nel/src/misc/sstring.cpp @@ -37,14 +37,14 @@ namespace NLMISC return token; } - unsigned int i; + uint i; CSString result; // skip leading junk for (i=0;i. + */ + +#include "stdsound.h" +#include + +// STL includes + +// NeL includes +#include +#include + +// Project includes +#include + +using namespace std; +using namespace NLMISC; + +namespace NLSOUND { + +IAudioDecoder::IAudioDecoder() : _InternalStream(NULL) +{ + +} + +IAudioDecoder::~IAudioDecoder() +{ + if (_InternalStream) { delete _InternalStream; _InternalStream = NULL; } +} + +IAudioDecoder *IAudioDecoder::createAudioDecoder(const std::string &filepath, bool async, bool loop) +{ + std::string lookup = CPath::lookup(filepath, false); + if (lookup.empty()) + { + nlwarning("Music file %s does not exist!", filepath.c_str()); + return NULL; + } + std::string type = CFile::getExtension(filepath); + + CIFile *ifile = new CIFile(); + ifile->setCacheFileOnOpen(!async); + ifile->allowBNPCacheFileOnOpen(!async); + ifile->open(lookup); + + IAudioDecoder *mb = createAudioDecoder(type, ifile, loop); + + if (mb) mb->_InternalStream = ifile; + else delete ifile; + + return mb; +} + +IAudioDecoder *IAudioDecoder::createAudioDecoder(const std::string &type, NLMISC::IStream *stream, bool loop) +{ + if (!stream) + { + nlwarning("Stream is NULL"); + return NULL; + } + std::string type_lower = toLower(type); + if (type_lower == "ogg") + { + return new CAudioDecoderVorbis(stream, loop); + } + else + { + nlwarning("Music file type unknown: '%s'", type_lower.c_str()); + return NULL; + } +} + +bool IAudioDecoder::getInfo(const std::string &filepath, std::string &artist, std::string &title) +{ + std::string lookup = CPath::lookup(filepath, false); + if (lookup.empty()) + { + nlwarning("Music file %s does not exist!", filepath.c_str()); + return false; + } + std::string type = CFile::getExtension(filepath); + std::string type_lower = NLMISC::toLower(type); + + if (type_lower == "ogg") + { + CIFile ifile; + ifile.setCacheFileOnOpen(false); + ifile.allowBNPCacheFileOnOpen(false); + ifile.open(lookup); + return CAudioDecoderVorbis::getInfo(&ifile, artist, title); + } + else + { + nlwarning("Music file type unknown: '%s'", type_lower.c_str()); + artist.clear(); title.clear(); + return false; + } +} + +/// Get audio/container extensions that are currently supported by the nel sound library. +void IAudioDecoder::getMusicExtensions(std::vector &extensions) +{ + extensions.push_back("ogg"); + // extensions.push_back("wav"); // TODO: Easy. +} + +/// Return if a music extension is supported by the nel sound library. +bool IAudioDecoder::isMusicExtensionSupported(const std::string &extension) +{ + return (extension == "ogg"); +} + +} /* namespace NLSOUND */ + +/* end of file */ diff --git a/code/nel/src/sound/driver/music_buffer_vorbis.cpp b/code/nel/src/sound/audio_decoder_vorbis.cpp similarity index 53% rename from code/nel/src/sound/driver/music_buffer_vorbis.cpp rename to code/nel/src/sound/audio_decoder_vorbis.cpp index 9d5543c62..e0b950fc4 100644 --- a/code/nel/src/sound/driver/music_buffer_vorbis.cpp +++ b/code/nel/src/sound/audio_decoder_vorbis.cpp @@ -1,38 +1,53 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . +/** + * \file audio_decoder_vorbis.cpp + * \brief CAudioDecoderVorbis + * \date 2012-04-11 09:35GMT + * \author Jan Boon (Kaetemi) + * CAudioDecoderVorbis + */ -#include "stdsound_lowlevel.h" +/* + * Copyright (C) 2008-2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#include "stdsound.h" +#include + +// STL includes + +// NeL includes +#include // Project includes -#include "nel/sound/driver/music_buffer_vorbis.h" using namespace std; using namespace NLMISC; -namespace NLSOUND -{ +namespace NLSOUND { size_t vorbisReadFunc(void *ptr, size_t size, size_t nmemb, void *datasource) { - CMusicBufferVorbis *music_buffer_vorbis = (CMusicBufferVorbis *)datasource; - NLMISC::IStream *stream = music_buffer_vorbis->getStream(); + CAudioDecoderVorbis *audio_decoder_vorbis = (CAudioDecoderVorbis *)datasource; + NLMISC::IStream *stream = audio_decoder_vorbis->getStream(); nlassert(stream->isReading()); sint32 length = (sint32)(size * nmemb); - if (length > music_buffer_vorbis->getStreamSize() - stream->getPos()) - length = music_buffer_vorbis->getStreamSize() - stream->getPos(); + if (length > audio_decoder_vorbis->getStreamSize() - stream->getPos()) + length = audio_decoder_vorbis->getStreamSize() - stream->getPos(); stream->serialBuffer((uint8 *)ptr, length); return length; } @@ -45,7 +60,7 @@ int vorbisSeekFunc(void *datasource, ogg_int64_t offset, int whence) return 0; // ooookkaaaaaayyy } - CMusicBufferVorbis *music_buffer_vorbis = (CMusicBufferVorbis *)datasource; + CAudioDecoderVorbis *audio_decoder_vorbis = (CAudioDecoderVorbis *)datasource; NLMISC::IStream::TSeekOrigin origin; switch (whence) @@ -64,19 +79,19 @@ int vorbisSeekFunc(void *datasource, ogg_int64_t offset, int whence) return -1; } - if (music_buffer_vorbis->getStream()->seek(SEEK_SET ? music_buffer_vorbis->getStreamOffset() + (sint32)offset : (sint32)offset, origin)) return 0; + if (audio_decoder_vorbis->getStream()->seek(SEEK_SET ? audio_decoder_vorbis->getStreamOffset() + (sint32)offset : (sint32)offset, origin)) return 0; else return -1; } //int vorbisCloseFunc(void *datasource) //{ -// //CMusicBufferVorbis *music_buffer_vorbis = (CMusicBufferVorbis *)datasource; +// //CAudioDecoderVorbis *audio_decoder_vorbis = (CAudioDecoderVorbis *)datasource; //} long vorbisTellFunc(void *datasource) { - CMusicBufferVorbis *music_buffer_vorbis = (CMusicBufferVorbis *)datasource; - return (long)(music_buffer_vorbis->getStream()->getPos() - music_buffer_vorbis->getStreamOffset()); + CAudioDecoderVorbis *audio_decoder_vorbis = (CAudioDecoderVorbis *)datasource; + return (long)(audio_decoder_vorbis->getStream()->getPos() - audio_decoder_vorbis->getStreamOffset()); } static ov_callbacks OV_CALLBACKS_NLMISC_STREAM = { @@ -86,8 +101,8 @@ static ov_callbacks OV_CALLBACKS_NLMISC_STREAM = { (long (*)(void *)) vorbisTellFunc }; -CMusicBufferVorbis::CMusicBufferVorbis(NLMISC::IStream *stream, bool loop) -: _Stream(stream), _Loop(loop), _IsMusicEnded(false) +CAudioDecoderVorbis::CAudioDecoderVorbis(NLMISC::IStream *stream, bool loop) +: _Stream(stream), _Loop(loop), _IsMusicEnded(false), _StreamSize(0) { _StreamOffset = stream->getPos(); stream->seek(0, NLMISC::IStream::end); @@ -96,15 +111,15 @@ CMusicBufferVorbis::CMusicBufferVorbis(NLMISC::IStream *stream, bool loop) ov_open_callbacks(this, &_OggVorbisFile, NULL, 0, OV_CALLBACKS_NLMISC_STREAM); } -CMusicBufferVorbis::~CMusicBufferVorbis() +CAudioDecoderVorbis::~CAudioDecoderVorbis() { ov_clear(&_OggVorbisFile); } /// Get information on a music file (only artist and title at the moment). -bool CMusicBufferVorbis::getInfo(NLMISC::IStream *stream, std::string &artist, std::string &title) +bool CAudioDecoderVorbis::getInfo(NLMISC::IStream *stream, std::string &artist, std::string &title) { - CMusicBufferVorbis mbv(stream, false); // just opens and closes the oggvorbisfile thing :) + CAudioDecoderVorbis mbv(stream, false); // just opens and closes the oggvorbisfile thing :) vorbis_comment *vc = ov_comment(&mbv._OggVorbisFile, -1); char *title_c = vorbis_comment_query(vc, "title", 0); if (title_c) title = title_c; else title.clear(); @@ -113,29 +128,27 @@ bool CMusicBufferVorbis::getInfo(NLMISC::IStream *stream, std::string &artist, s return true; } -uint32 CMusicBufferVorbis::getRequiredBytes() +uint32 CAudioDecoderVorbis::getRequiredBytes() { return 0; // no minimum requirement of bytes to buffer out } -uint32 CMusicBufferVorbis::getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum) +uint32 CAudioDecoderVorbis::getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum) { sint current_section = 0; // ??? if (_IsMusicEnded) return 0; nlassert(minimum <= maximum); // can't have this.. uint32 bytes_read = 0; - #ifdef NL_BIG_ENDIAN sint endianness = 1; #else sint endianness = 0; #endif - do { // signed 16-bit or unsigned 8-bit little-endian samples sint br = ov_read(&_OggVorbisFile, (char *)&buffer[bytes_read], maximum - bytes_read, - endianness, // Specifies big or little endian byte packing. 0 for little endian, 1 for big endian. Typical value is 0. + endianness, // Specifies big or little endian byte packing. 0 for little endian, 1 for b ig endian. Typical value is 0. getBitsPerSample() == 8 ? 1 : 2, getBitsPerSample() == 8 ? 0 : 1, // Signed or unsigned data. 0 for unsigned, 1 for signed. Typically 1. ¤t_section); @@ -162,58 +175,53 @@ uint32 CMusicBufferVorbis::getNextBytes(uint8 *buffer, uint32 minimum, uint32 ma // error switch(br) { - case OV_HOLE: + case OV_HOLE: nlwarning("ov_read returned OV_HOLE"); break; - - case OV_EINVAL: + case OV_EINVAL: nlwarning("ov_read returned OV_EINVAL"); break; - - case OV_EBADLINK: + case OV_EBADLINK: nlwarning("ov_read returned OV_EBADLINK"); break; - - default: + default: nlwarning("ov_read returned %d", br); } - - return 0; } } while (bytes_read < minimum); return bytes_read; } -uint8 CMusicBufferVorbis::getChannels() +uint8 CAudioDecoderVorbis::getChannels() { vorbis_info *vi = ov_info(&_OggVorbisFile, -1); return (uint8)vi->channels; } -uint32 CMusicBufferVorbis::getSamplesPerSec() +uint CAudioDecoderVorbis::getSamplesPerSec() { vorbis_info *vi = ov_info(&_OggVorbisFile, -1); - return vi->rate; + return (uint)vi->rate; } -uint8 CMusicBufferVorbis::getBitsPerSample() +uint8 CAudioDecoderVorbis::getBitsPerSample() { return 16; } -bool CMusicBufferVorbis::isMusicEnded() +bool CAudioDecoderVorbis::isMusicEnded() { return _IsMusicEnded; } -float CMusicBufferVorbis::getLength() +float CAudioDecoderVorbis::getLength() { return (float)ov_time_total(&_OggVorbisFile, -1); } -uint CMusicBufferVorbis::getUncompressedSize() +void CAudioDecoderVorbis::setLooping(bool loop) { - return (uint)ov_pcm_total(&_OggVorbisFile, -1) * (getBitsPerSample() / 2) * getChannels(); + _Loop = loop; } } /* namespace NLSOUND */ diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 367abd0e1..1a6c2d322 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -45,12 +45,15 @@ #include "nel/sound/context_sound.h" #include "nel/sound/music_source.h" #include "nel/sound/stream_source.h" +#include "nel/sound/stream_file_source.h" #include "nel/sound/simple_sound.h" #include "nel/sound/music_sound.h" #include "nel/sound/stream_sound.h" #include "nel/sound/sample_bank_manager.h" #include "nel/sound/sample_bank.h" #include "nel/sound/sound_bank.h" +#include "nel/sound/group_controller.h" +#include "nel/sound/containers.h" using namespace std; using namespace NLMISC; @@ -218,6 +221,7 @@ void CAudioMixerUser::writeProfile(std::string& out) */ out += "Sound mixer: \n"; out += "\tPlaying sources: " + toString (getPlayingSourcesCount()) + " \n"; + out += "\tPlaying simple sources: " + toString(countPlayingSimpleSources()) + " / " + toString(countSimpleSources()) + " \n"; out += "\tAvailable tracks: " + toString (getAvailableTracksCount()) + " \n"; out += "\tUsed tracks: " + toString (getUsedTracksCount()) + " \n"; // out << "\tMuted sources: " << nb << " \n"; @@ -248,6 +252,16 @@ void CAudioMixerUser::addSourceWaitingForPlay(CSourceCommon *source) _SourceWaitingForPlay.push_back(source); } +// ****************************************************************** + +void CAudioMixerUser::removeSourceWaitingForPlay(CSourceCommon *source) +{ + std::list::iterator it = find(_SourceWaitingForPlay.begin(), _SourceWaitingForPlay.end(), source); + if (it != _SourceWaitingForPlay.end()) + { + _SourceWaitingForPlay.erase(it); + } +} // ****************************************************************** @@ -256,8 +270,9 @@ void CAudioMixerUser::reset() _Leaving = true; _SourceWaitingForPlay.clear(); - - /* TODO: Stop music channels */ + + for (uint i = 0; i < _NbMusicChannelFaders; ++i) + _MusicChannelFaders[i].reset(); // Stop tracks uint i; @@ -1638,6 +1653,7 @@ void CAudioMixerUser::update() _MusicChannelFaders[i].update(); // Check all playing track and stop any terminated buffer. + std::list::size_type nbWaitingSources = _Sources.size(); for (i=0; i<_Tracks.size(); ++i) { if (!_Tracks[i]->isPlaying()) @@ -1649,13 +1665,14 @@ void CAudioMixerUser::update() } // try to play any waiting source. - if (!_SourceWaitingForPlay.empty()) + if (!_SourceWaitingForPlay.empty() && nbWaitingSources) { // check if the source still exist before trying to play it if (_Sources.find(_SourceWaitingForPlay.front()) != _Sources.end()) _SourceWaitingForPlay.front()->play(); // nldebug("Before POP Sources waiting : %u", _SourceWaitingForPlay.size()); _SourceWaitingForPlay.pop_front(); + --nbWaitingSources; // nldebug("After POP Sources waiting : %u", _SourceWaitingForPlay.size()); } } @@ -1689,7 +1706,7 @@ void CAudioMixerUser::update() // _Tracks[i]->DrvSource->setPos(source->getPos() * (1-css->PosAlpha) + css->Position*(css->PosAlpha)); _Tracks[i]->getPhysicalSource()->setPos(source->getPos() * (1-css->PosAlpha) + vpos*(css->PosAlpha)); // update the relative gain - _Tracks[i]->getPhysicalSource()->setGain(source->getRelativeGain()*source->getGain()*css->Gain); + _Tracks[i]->getPhysicalSource()->setGain(source->getFinalGain() * css->Gain); #if EAX_AVAILABLE == 1 if (_UseEax) { @@ -1826,10 +1843,14 @@ bool CAudioMixerUser::tryToLoadSampleBank(const std::string &sampleName) } } +UGroupController *CAudioMixerUser::getGroupController(const std::string &path) +{ + return static_cast(_GroupController.getGroupController(path)); +} // ****************************************************************** -USource *CAudioMixerUser::createSource( TSoundId id, bool spawn, TSpawnEndCallback cb, void *userParam, NL3D::CCluster *cluster, CSoundContext *context ) +USource *CAudioMixerUser::createSource( TSoundId id, bool spawn, TSpawnEndCallback cb, void *userParam, NL3D::CCluster *cluster, CSoundContext *context, UGroupController *groupController ) { #if NL_PROFILE_MIXER TTicks start = CTime::getPerformanceTime(); @@ -1915,7 +1936,7 @@ retrySound: } // Create source - CSimpleSource *source = new CSimpleSource( simpleSound, spawn, cb, userParam, cluster); + CSimpleSource *source = new CSimpleSource( simpleSound, spawn, cb, userParam, cluster, static_cast(groupController)); // nldebug("Mixer : source %p created", source); @@ -1939,28 +1960,35 @@ retrySound: { CStreamSound *streamSound = static_cast(id); // This is a stream thingy. - ret = new CStreamSource(streamSound, spawn, cb, userParam, cluster); + ret = new CStreamSource(streamSound, spawn, cb, userParam, cluster, static_cast(groupController)); + } + break; + case CSound::SOUND_STREAM_FILE: + { + CStreamFileSound *streamFileSound = static_cast(id); + // This is a stream file thingy. + ret = new CStreamFileSource(streamFileSound, spawn, cb, userParam, cluster, static_cast(groupController)); } break; case CSound::SOUND_COMPLEX: { CComplexSound *complexSound = static_cast(id); // This is a pattern sound. - ret = new CComplexSource(complexSound, spawn, cb, userParam, cluster); + ret = new CComplexSource(complexSound, spawn, cb, userParam, cluster, static_cast(groupController)); } break; case CSound::SOUND_BACKGROUND: { // This is a background sound. CBackgroundSound *bgSound = static_cast(id); - ret = new CBackgroundSource(bgSound, spawn, cb, userParam, cluster); + ret = new CBackgroundSource(bgSound, spawn, cb, userParam, cluster, static_cast(groupController)); } break; case CSound::SOUND_MUSIC: { // This is a background music sound CMusicSound *music_sound= static_cast(id); - ret = new CMusicSource(music_sound, spawn, cb, userParam, cluster); + ret = new CMusicSource(music_sound, spawn, cb, userParam, cluster, static_cast(groupController)); } break; case CSound::SOUND_CONTEXT: @@ -1974,7 +2002,7 @@ retrySound: CSound *sound = ctxSound->getContextSound(*context); if (sound != 0) { - ret = createSource(sound, spawn, cb, userParam, cluster); + ret = createSource(sound, spawn, cb, userParam, cluster, NULL, static_cast(groupController)); // Set the volume of the source according to the context volume if (ret != 0) { @@ -2007,9 +2035,9 @@ retrySound: // ****************************************************************** -USource *CAudioMixerUser::createSource( const NLMISC::TStringId &name, bool spawn, TSpawnEndCallback cb, void *userParam, NL3D::CCluster *cluster, CSoundContext *context) +USource *CAudioMixerUser::createSource( const NLMISC::TStringId &name, bool spawn, TSpawnEndCallback cb, void *userParam, NL3D::CCluster *cluster, CSoundContext *context, UGroupController *groupController) { - return createSource( getSoundId( name ), spawn, cb, userParam, cluster, context); + return createSource( getSoundId( name ), spawn, cb, userParam, cluster, context, groupController); } @@ -2147,6 +2175,32 @@ uint CAudioMixerUser::getPlayingSourcesCount() const return _PlayingSources; } + +// ****************************************************************** + +uint CAudioMixerUser::countPlayingSimpleSources() const +{ + uint count = 0; + for (TSourceContainer::const_iterator it(_Sources.begin()), end(_Sources.end()); it != end; ++it) + { + if ((*it)->getType() == CSourceCommon::SOURCE_SIMPLE && (*it)->isPlaying()) + ++count; + } + return count; +} + +uint CAudioMixerUser::countSimpleSources() const +{ + uint count = 0; + for (TSourceContainer::const_iterator it(_Sources.begin()), end(_Sources.end()); it != end; ++it) + { + if ((*it)->getType() == CSourceCommon::SOURCE_SIMPLE) + ++count; + } + return count; +} + + // ****************************************************************** uint CAudioMixerUser::getAvailableTracksCount() const diff --git a/code/nel/src/sound/background_source.cpp b/code/nel/src/sound/background_source.cpp index c2cb5206a..dbb14242a 100644 --- a/code/nel/src/sound/background_source.cpp +++ b/code/nel/src/sound/background_source.cpp @@ -26,8 +26,8 @@ namespace NLSOUND { -CBackgroundSource::CBackgroundSource(CBackgroundSound *backgroundSound, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster) -: CSourceCommon(backgroundSound, spawn, cb, cbUserParam, cluster) +CBackgroundSource::CBackgroundSource(CBackgroundSound *backgroundSound, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster, CGroupController *groupController) +: CSourceCommon(backgroundSound, spawn, cb, cbUserParam, cluster, groupController) { _BackgroundSound = backgroundSound; } @@ -119,7 +119,7 @@ void CBackgroundSource::play() for (; first != last; ++first) { TSubSource subSource; - subSource.Source = mixer->createSource(first->SoundName, false, 0, 0, _Cluster, 0); + subSource.Source = mixer->createSource(first->SoundName, false, 0, 0, _Cluster, NULL, _GroupController); if (subSource.Source != NULL) subSource.Source->setPriority(_Priority); subSource.Filter = first->Filter; diff --git a/code/nel/src/sound/complex_source.cpp b/code/nel/src/sound/complex_source.cpp index cd3d2925d..8fad61a53 100644 --- a/code/nel/src/sound/complex_source.cpp +++ b/code/nel/src/sound/complex_source.cpp @@ -25,8 +25,8 @@ using namespace NLMISC; namespace NLSOUND { -CComplexSource::CComplexSource (CComplexSound *soundPattern, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster) -: CSourceCommon(soundPattern, spawn, cb, cbUserParam, cluster), +CComplexSource::CComplexSource (CComplexSound *soundPattern, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster, CGroupController *groupController) +: CSourceCommon(soundPattern, spawn, cb, cbUserParam, cluster, groupController), _Source1(NULL), _Source2(NULL) { @@ -117,7 +117,7 @@ void CComplexSource::playStuf() else _FadeLength = 0; - _Source2 = mixer->createSource(sound, false, 0, 0, _Cluster); + _Source2 = mixer->createSource(sound, false, 0, 0, _Cluster, NULL, _GroupController); if (_Source2 == NULL) return; _Source2->setPriority(_Priority); @@ -155,7 +155,7 @@ void CComplexSource::playStuf() { CSound *sound = mixer->getSoundId(_PatternSound->getSound(soundSeq[_SoundSeqIndex++])); - _Source1 = mixer->createSource(sound, false, 0, 0, _Cluster); + _Source1 = mixer->createSource(sound, false, 0, 0, _Cluster, NULL, _GroupController); if (_Source1 == NULL) return; _Source1->setPriority(_Priority); @@ -202,7 +202,7 @@ void CComplexSource::playStuf() CSound *sound = mixer->getSoundId(*first); if (sound != NULL) { - USource *source = mixer->createSource(sound, false, 0, 0, _Cluster); + USource *source = mixer->createSource(sound, false, 0, 0, _Cluster, NULL, _GroupController); if (source != NULL) { source->setPriority(_Priority); @@ -512,7 +512,7 @@ void CComplexSource::onUpdate() // determine the XFade length (if next sound is too short. _FadeLength = minof(uint32(_PatternSound->getFadeLength()/_TickPerSecond), (sound2->getDuration()) / 2, (_Source1->getSound()->getDuration())/2); - _Source2 = mixer->createSource(sound2, false, 0, 0, _Cluster); + _Source2 = mixer->createSource(sound2, false, 0, 0, _Cluster, NULL, _GroupController); if (_Source2) { _Source2->setPriority(_Priority); @@ -641,7 +641,7 @@ void CComplexSource::onEvent() CSound *sound = mixer->getSoundId(_PatternSound->getSound(soundSeq[_SoundSeqIndex++])); - _Source1 = mixer->createSource(sound, false, 0, 0, _Cluster); + _Source1 = mixer->createSource(sound, false, 0, 0, _Cluster, NULL, _GroupController); if (_Source1 == NULL) { stop(); diff --git a/code/nel/src/sound/driver/CMakeLists.txt b/code/nel/src/sound/driver/CMakeLists.txt index 1a8391c41..90fbbb562 100644 --- a/code/nel/src/sound/driver/CMakeLists.txt +++ b/code/nel/src/sound/driver/CMakeLists.txt @@ -3,14 +3,7 @@ FILE(GLOB HEADERS ../../../include/nel/sound/driver/*.h) NL_TARGET_LIB(nelsnd_lowlevel ${HEADERS} ${SRC}) -INCLUDE_DIRECTORIES(${VORBIS_INCLUDE_DIR}) - -TARGET_LINK_LIBRARIES(nelsnd_lowlevel nelmisc ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY}) - -IF(WITH_STATIC) - # Add libogg dependency only if target is static because to libvorbisfile - TARGET_LINK_LIBRARIES(nelsnd_lowlevel ${OGG_LIBRARY}) -ENDIF(WITH_STATIC) +TARGET_LINK_LIBRARIES(nelsnd_lowlevel nelmisc) SET_TARGET_PROPERTIES(nelsnd_lowlevel PROPERTIES LINK_INTERFACE_LIBRARIES "") NL_DEFAULT_PROPS(nelsnd_lowlevel "NeL, Library: Sound Lowlevel") diff --git a/code/nel/src/sound/driver/fmod/music_channel_fmod.cpp b/code/nel/src/sound/driver/fmod/music_channel_fmod.cpp index 9c502ea1a..a64dddcfe 100644 --- a/code/nel/src/sound/driver/fmod/music_channel_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/music_channel_fmod.cpp @@ -249,6 +249,12 @@ void CMusicChannelFMod::stop() _CallBackEnded = false; } +void CMusicChannelFMod::reset() +{ + // don't care + stop(); +} + /** Pause the music previously loaded and played (the Memory is not freed) */ void CMusicChannelFMod::pause() diff --git a/code/nel/src/sound/driver/fmod/music_channel_fmod.h b/code/nel/src/sound/driver/fmod/music_channel_fmod.h index d9a17fd99..e91e38a8b 100644 --- a/code/nel/src/sound/driver/fmod/music_channel_fmod.h +++ b/code/nel/src/sound/driver/fmod/music_channel_fmod.h @@ -87,6 +87,9 @@ public: /// Stop the music previously loaded and played (the Memory is also freed) virtual void stop(); + /// Makes sure any resources are freed, but keeps available for next play call + virtual void reset(); + /// Pause the music previously loaded and played (the Memory is not freed) virtual void pause(); diff --git a/code/nel/src/sound/driver/fmod/source_fmod.cpp b/code/nel/src/sound/driver/fmod/source_fmod.cpp index 2ae9a0ea1..4ef2f89d5 100644 --- a/code/nel/src/sound/driver/fmod/source_fmod.cpp +++ b/code/nel/src/sound/driver/fmod/source_fmod.cpp @@ -413,6 +413,13 @@ bool CSourceFMod::getSourceRelativeMode() const // ****************************************************************** void CSourceFMod::setMinMaxDistances( float mindist, float maxdist, bool /* deferred */ ) { + static float maxSqrt = sqrt(std::numeric_limits::max()); + if (maxdist >= maxSqrt) + { + nlwarning("SOUND_DEV (FMod): Ridiculously high max distance set on source"); + maxdist = maxSqrt; + } + _MinDist= mindist; _MaxDist= maxdist; if(_FModChannel!=-1) diff --git a/code/nel/src/sound/driver/music_buffer.cpp b/code/nel/src/sound/driver/music_buffer.cpp deleted file mode 100644 index 40088d49e..000000000 --- a/code/nel/src/sound/driver/music_buffer.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdsound_lowlevel.h" - -#include "nel/sound/driver/music_buffer_vorbis.h" -#include "nel/sound/driver/music_buffer.h" - -using namespace std; -using namespace NLMISC; - -namespace NLSOUND -{ - -IMusicBuffer::IMusicBuffer() : _InternalStream(NULL) -{ - -} - -IMusicBuffer::~IMusicBuffer() -{ - if (_InternalStream) { delete _InternalStream; _InternalStream = NULL; } -} - -IMusicBuffer *IMusicBuffer::createMusicBuffer(const std::string &filepath, bool async, bool loop) -{ - string lookup = CPath::lookup(filepath, false); - if (lookup.empty()) - { - nlwarning("Music file %s does not exist!", filepath.c_str()); - return NULL; - } - string type = CFile::getExtension(filepath); - - CIFile *ifile = new CIFile(); - ifile->setAsyncLoading(async); - ifile->open(lookup); - - IMusicBuffer *mb = createMusicBuffer(type, ifile, loop); - - if (mb) mb->_InternalStream = ifile; - else delete ifile; - - return mb; -} - -IMusicBuffer *IMusicBuffer::createMusicBuffer(const std::string &type, NLMISC::IStream *stream, bool loop) -{ - if (!stream) - { - nlwarning("Stream is NULL"); - return NULL; - } - string type_lower = toLower(type); - if (type_lower == "ogg") - { - return new CMusicBufferVorbis(stream, loop); - } - else - { - nlwarning("Music file type unknown: '%s'", type_lower.c_str()); - return NULL; - } -} - -bool IMusicBuffer::getInfo(const std::string &filepath, std::string &artist, std::string &title) -{ - string lookup = CPath::lookup(filepath, false); - if (lookup.empty()) - { - nlwarning("Music file %s does not exist!", filepath.c_str()); - return false; - } - string type = CFile::getExtension(filepath); - string type_lower = toLower(type); - - if (type_lower == "ogg") - { - CIFile ifile; - ifile.setCacheFileOnOpen(false); - ifile.allowBNPCacheFileOnOpen(false); - ifile.open(lookup); - return CMusicBufferVorbis::getInfo(&ifile, artist, title); - } - else - { - nlwarning("Music file type unknown: '%s'", type_lower.c_str()); - artist.clear(); title.clear(); - return false; - } -} - -} /* namespace NLSOUND */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/openal/listener_al.cpp b/code/nel/src/sound/driver/openal/listener_al.cpp index 67eaf2478..da7e6bc31 100644 --- a/code/nel/src/sound/driver/openal/listener_al.cpp +++ b/code/nel/src/sound/driver/openal/listener_al.cpp @@ -145,9 +145,8 @@ void CListenerAL::getOrientation( NLMISC::CVector& front, NLMISC::CVector& u */ void CListenerAL::setGain( float gain ) { - CSoundDriverAL::getInstance()->setGain(gain); -// alListenerf( AL_GAIN, gain ); -// alTestError(); + alListenerf( AL_GAIN, gain ); + alTestError(); } @@ -156,15 +155,14 @@ void CListenerAL::setGain( float gain ) */ float CListenerAL::getGain() const { - return CSoundDriverAL::getInstance()->getGain(); -// ALfloat gain; -//#ifdef NL_OS_WINDOWS -// alGetListenerf( AL_GAIN, &gain ); -//#else -// alGetListenerfv( AL_GAIN, &gain ); -//#endif -// alTestError(); -// return gain; + ALfloat gain; +#ifdef NL_OS_WINDOWS + alGetListenerf( AL_GAIN, &gain ); +#else + alGetListenerfv( AL_GAIN, &gain ); +#endif + alTestError(); + return gain; } diff --git a/code/nel/src/sound/driver/openal/music_channel_al.cpp b/code/nel/src/sound/driver/openal/music_channel_al.cpp deleted file mode 100644 index b1849b33e..000000000 --- a/code/nel/src/sound/driver/openal/music_channel_al.cpp +++ /dev/null @@ -1,328 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdopenal.h" - -// Project includes -#include "sound_driver_al.h" -#include "source_al.h" -#include "buffer_al.h" -#include "music_channel_al.h" - -using namespace std; -using namespace NLMISC; - -namespace NLSOUND -{ - -CMusicChannelAL::CMusicChannelAL(CSoundDriverAL *soundDriver) -: _SoundDriver(soundDriver), _MusicBuffer(NULL), _Thread(NULL), _Buffer(NULL), _Source(NULL), _Playing(false), _Async(false), _Gain(1.0) -{ - // create a default source for music streaming - _Source = static_cast(_SoundDriver->createSource()); - _Source->setType(SourceMusic); - _Source->setStreamingBufferSize(32768); -} - -CMusicChannelAL::~CMusicChannelAL() -{ - release(); - if (_SoundDriver) { _SoundDriver->removeMusicChannel(this); _SoundDriver = NULL; } -} - -void CMusicChannelAL::release() -{ - // stop thread before deleting it - stop(); - - // delete thread - if (_Thread) - { - delete _Thread; - _Thread = NULL; - } - - // delete source - if (_Source) - { - delete _Source; - _Source = NULL; - } -} - -/// Fill IBuffer with data from IMusicBuffer -bool CMusicChannelAL::fillBuffer(IBuffer *buffer, uint length) -{ - if (!buffer || !length) - { - nlwarning("AL: No data to stream"); - return false; - } - - // fill buffer with music data - uint8 *tmp = buffer->lock(length); - if (tmp == NULL) - { - nlwarning("AL: Can't allocate %u bytes for buffer", length); - return false; - } - - uint32 size = _MusicBuffer->getNextBytes(tmp, length, length); - buffer->unlock(size); - - return size > 0; -} - -/// Use buffer format from IMusicBuffer -void CMusicChannelAL::setBufferFormat(IBuffer *buffer) -{ - if (!buffer) - { - nlwarning("AL: No buffer specified"); - return; - } - - // use the same format as music for buffers - buffer->setFormat(IBuffer::FormatPcm, _MusicBuffer->getChannels(), - _MusicBuffer->getBitsPerSample(), _MusicBuffer->getSamplesPerSec()); -} - -void CMusicChannelAL::run() -{ - bool first = true; - - // use queued buffers - do - { - // buffers to update - std::vector buffers; - - if (first) - { - // get all buffers to queue - _Source->getStreamingBuffers(buffers); - - // set format for each buffer - for(uint i = 0; i < buffers.size(); ++i) - setBufferFormat(buffers[i]); - } - else - { - // get unqueued buffers - _Source->getProcessedStreamingBuffers(buffers); - } - - // fill buffers - for(uint i = 0; i < buffers.size(); ++i) - { - if (!fillBuffer(buffers[i], _Source->getStreamingBufferSize())) - break; - - // add buffer to streaming buffers queue - _Source->submitStreamingBuffer(buffers[i]); - } - - // play the source - if (first) - { - _Source->play(); - first = false; - } - - // wait 100ms before rechecking buffers - nlSleep(100); - } - while(!_MusicBuffer->isMusicEnded() && _Playing); - - - // music finished without interruption - if (_Playing) - { - // wait until source is not playing - while(_Source->isPlaying() && _Playing) nlSleep(1000); - - _Source->stop(); - - _Playing = false; - } -} - -/// Play sync music -bool CMusicChannelAL::playSync() -{ - // use an unique buffer managed by CMusicChannelAL - _Buffer = _SoundDriver->createBuffer(); - - // set format - setBufferFormat(_Buffer); - - // fill data - fillBuffer(_Buffer, _MusicBuffer->getUncompressedSize()); - - // we don't need _MusicBuffer anymore because all is loaded into memory - if (_MusicBuffer) - { - delete _MusicBuffer; - _MusicBuffer = NULL; - } - - // delete previous queued buffers - _Source->setStreamingBuffersMax(0); - - // use this buffer as source - _Source->setStaticBuffer(_Buffer); - - // play the source - return _Source->play(); -} - -/** Play some music (.ogg etc...) - * NB: if an old music was played, it is first stop with stopMusic() - * \param filepath file path, CPath::lookup is done here - * \param async stream music from hard disk, preload in memory if false - * \param loop must be true to play the music in loop. - */ -bool CMusicChannelAL::play(const std::string &filepath, bool async, bool loop) -{ - // stop a previous music - stop(); - - // when not using async, we must load the whole file once - _MusicBuffer = IMusicBuffer::createMusicBuffer(filepath, async, async ? loop:false); - - if (_MusicBuffer) - { - _Async = async; - _Playing = true; - - _Source->setSourceRelativeMode(true); - - if (_Async) - { - // create the thread if it's not yet created - if (!_Thread) _Thread = IThread::create(this); - - if (!_Thread) - { - nlwarning("AL: Can't create a new thread"); - return false; - } - - // use 4 queued buffers - _Source->setStreamingBuffersMax(4); - - // we need to loop the source only if not async - _Source->setLooping(false); - - // start the thread - _Thread->start(); - } - else - { - // we need to loop the source only if not async - _Source->setLooping(loop); - - return playSync(); - } - } - else - { - nlwarning("AL: Can't stream file %s", filepath.c_str()); - return false; - } - - return true; -} - -/// Stop the music previously loaded and played (the Memory is also freed) -void CMusicChannelAL::stop() -{ - _Playing = false; - - _Source->stop(); - - // if not using async streaming, we manage static buffer ourself - if (!_Async && _Buffer) - { - _Source->setStaticBuffer(NULL); - delete _Buffer; - _Buffer = NULL; - } - - // wait until thread is finished - if (_Thread) - _Thread->wait(); - - if (_MusicBuffer) - { - delete _MusicBuffer; - _MusicBuffer = NULL; - } -} - -/// Pause the music previously loaded and played (the Memory is not freed) -void CMusicChannelAL::pause() -{ - _Source->pause(); -} - -/// Resume the music previously paused -void CMusicChannelAL::resume() -{ - _Source->play(); -} - -/// Return true if a song is finished. -bool CMusicChannelAL::isEnded() -{ - return !_Playing; -} - -/// Return true if the song is still loading asynchronously and hasn't started playing yet (false if not async), used to delay fading -bool CMusicChannelAL::isLoadingAsync() -{ - return _Async && _Playing && !_Source->isPlaying(); -} - -/// Return the total length (in second) of the music currently played -float CMusicChannelAL::getLength() -{ - if (_MusicBuffer) return _MusicBuffer->getLength(); - else return .0f; -} - -/** Set the music volume (if any music played). (volume value inside [0 , 1]) (default: 1) - * NB: in OpenAL driver, the volume of music IS affected by IListener::setGain() - */ -void CMusicChannelAL::setVolume(float gain) -{ - _Gain = gain; - _Source->setGain(gain); -} - -/// Update music -void CMusicChannelAL::update() -{ - // stop sync music once finished playing - if (_Playing && !_Async && !_Source->isPlaying()) - { - stop(); - } -} - -} /* namespace NLSOUND */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/openal/music_channel_al.h b/code/nel/src/sound/driver/openal/music_channel_al.h deleted file mode 100644 index 157c18810..000000000 --- a/code/nel/src/sound/driver/openal/music_channel_al.h +++ /dev/null @@ -1,106 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NLSOUND_MUSIC_CHANNEL_AL_H -#define NLSOUND_MUSIC_CHANNEL_AL_H - -#include "nel/sound/driver/music_channel.h" - -namespace NLSOUND -{ - class CSoundDriverAL; - class IMusicBuffer; - -/** - * \brief CMusicChannelAL - * \date 2010-07-27 16:56GMT - * \author Kervala - * CMusicChannelAL is an implementation of the IMusicChannel interface to run on OpenAL. - */ -class CMusicChannelAL : public IMusicChannel, public NLMISC::IRunnable -{ -protected: - // outside pointers - CSoundDriverAL* _SoundDriver; - - // pointers - IMusicBuffer* _MusicBuffer; - NLMISC::IThread* _Thread; - - IBuffer* _Buffer; - CSourceAL* _Source; - bool _Playing; - bool _Async; - - float _Gain; - - /// Fill IBuffer with data from IMusicBuffer - bool fillBuffer(IBuffer *buffer, uint length); - - /// Use buffer format from IMusicBuffer - void setBufferFormat(IBuffer *buffer); - - /// Declared in NLMISC::IRunnable interface - virtual void run(); - -public: - CMusicChannelAL(CSoundDriverAL *soundDriver); - virtual ~CMusicChannelAL(); - void release(); - - /** Play some music (.ogg etc...) - * NB: if an old music was played, it is first stop with stopMusic() - * \param filepath file path, CPath::lookup is done here - * \param async stream music from hard disk, preload in memory if false - * \param loop must be true to play the music in loop. - */ - virtual bool play(const std::string &filepath, bool async, bool loop); - - /// Stop the music previously loaded and played (the Memory is also freed) - virtual void stop(); - - /// Pause the music previously loaded and played (the Memory is not freed) - virtual void pause(); - - /// Resume the music previously paused - virtual void resume(); - - /// Return true if a song is finished. - virtual bool isEnded(); - - /// Return true if the song is still loading asynchronously and hasn't started playing yet (false if not async), used to delay fading - virtual bool isLoadingAsync(); - - /// Return the total length (in second) of the music currently played - virtual float getLength(); - - /** Set the music volume (if any music played). (volume value inside [0 , 1]) (default: 1) - * NB: in OpenAL driver, the volume of music IS affected by IListener::setGain() - */ - virtual void setVolume(float gain); - - /// Play sync music - bool playSync(); - - /// Update music - void update(); -}; /* class CMusicChannelAL */ - -} /* namespace NLSOUND */ - -#endif /* #ifndef NLSOUND_MUSIC_CHANNEL_AL_H */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/openal/sound_driver_al.cpp b/code/nel/src/sound/driver/openal/sound_driver_al.cpp index e94755c63..e7eaca3f6 100644 --- a/code/nel/src/sound/driver/openal/sound_driver_al.cpp +++ b/code/nel/src/sound/driver/openal/sound_driver_al.cpp @@ -16,7 +16,6 @@ #include "stdopenal.h" #include "sound_driver_al.h" -#include "music_channel_al.h" #include "buffer_al.h" #include "listener_al.h" #include "source_al.h" @@ -174,7 +173,7 @@ uint32 NLSOUND_interfaceVersion () */ CSoundDriverAL::CSoundDriverAL(ISoundDriver::IStringMapperProvider *stringMapper) : _StringMapper(stringMapper), _AlDevice(NULL), _AlContext(NULL), -_NbExpBuffers(0), _NbExpSources(0), _RolloffFactor(1.f), _MasterGain(1.f) +_NbExpBuffers(0), _NbExpSources(0), _RolloffFactor(1.f) { alExtInit(); } @@ -184,21 +183,16 @@ _NbExpBuffers(0), _NbExpSources(0), _RolloffFactor(1.f), _MasterGain(1.f) */ CSoundDriverAL::~CSoundDriverAL() { - // Release internal resources of all remaining IMusicChannel instances - if (_MusicChannels.size()) - { - nlwarning("AL: _MusicChannels.size(): '%u'", (uint32)_MusicChannels.size()); - set::iterator it(_MusicChannels.begin()), end(_MusicChannels.end()); - for (; it != end; ++it) delete *it; - _MusicChannels.clear(); - } + // WARNING: Only internal resources are released here, + // the created instances must still be released by the user! + // Remove the allocated (but not exported) source and buffer names- // Release internal resources of all remaining ISource instances if (_Sources.size()) { nlwarning("AL: _Sources.size(): '%u'", (uint32)_Sources.size()); set::iterator it(_Sources.begin()), end(_Sources.end()); - for (; it != end; ++it) delete *it; + for (; it != end; ++it) (*it)->release(); // CSourceAL will be deleted by user _Sources.clear(); } if (!_Buffers.empty()) alDeleteBuffers(compactAliveNames(_Buffers, alIsBuffer), &*_Buffers.begin()); @@ -207,7 +201,7 @@ CSoundDriverAL::~CSoundDriverAL() { nlwarning("AL: _Effects.size(): '%u'", (uint32)_Effects.size()); set::iterator it(_Effects.begin()), end(_Effects.end()); - for (; it != end; ++it) delete *it; + for (; it != end; ++it) (*it)->release(); // CEffectAL will be deleted by user _Effects.clear(); } @@ -619,16 +613,9 @@ void CSoundDriverAL::commit3DChanges() // Sync up sources & listener 3d position. if (getOption(OptionManualRolloff)) { - set::iterator it = _Sources.begin(), iend = _Sources.end(); - while(it != iend) - { + for (std::set::iterator it(_Sources.begin()), end(_Sources.end()); it != end; ++it) (*it)->updateManualRolloff(); - ++it; - } } - - // update the music (XFade etc...) - updateMusic(); } /// Write information about the driver to the output stream. @@ -656,23 +643,6 @@ void CSoundDriverAL::displayBench(NLMISC::CLog *log) NLMISC::CHTimer::display(log, CHTimer::TotalTime); } -/** Get music info. Returns false if the song is not found or the function is not implemented. - * \param filepath path to file, CPath::lookup done by driver - * \param artist returns the song artist (empty if not available) - * \param title returns the title (empty if not available) - */ -bool CSoundDriverAL::getMusicInfo(const std::string &filepath, std::string &artist, std::string &title) -{ - // add support for additional non-standard music file types info here - return IMusicBuffer::getInfo(filepath, artist, title); -} - -void CSoundDriverAL::updateMusic() -{ - set::iterator it(_MusicChannels.begin()), end(_MusicChannels.end()); - for (; it != end; ++it) (*it)->update(); -} - /// Remove a buffer void CSoundDriverAL::removeBuffer(CBufferAL *buffer) { @@ -695,35 +665,6 @@ void CSoundDriverAL::removeEffect(CEffectAL *effect) else nlwarning("AL: removeEffect already called"); } -/// Create a music channel -IMusicChannel *CSoundDriverAL::createMusicChannel() -{ - CMusicChannelAL *music_channel = new CMusicChannelAL(this); - _MusicChannels.insert(music_channel); - return static_cast(music_channel); -} - -/// (Internal) Remove a music channel (should be called by the destructor of the music channel class). -void CSoundDriverAL::removeMusicChannel(CMusicChannelAL *musicChannel) -{ - if (_MusicChannels.find(musicChannel) != _MusicChannels.end()) _MusicChannels.erase(musicChannel); - else nlwarning("AL: removeMusicChannel already called"); -} - -/// Set the gain -void CSoundDriverAL::setGain( float gain ) -{ - clamp(gain, 0.f, 1.f); - _MasterGain= gain; - // TODO: update all sources in not using manual rollof ? -} - -/// Get the gain -float CSoundDriverAL::getGain() -{ - return _MasterGain; -} - /// Delete a buffer or a source bool CSoundDriverAL::deleteItem( ALuint name, TDeleteFunctionAL aldeletefunc, vector& names ) { diff --git a/code/nel/src/sound/driver/openal/sound_driver_al.h b/code/nel/src/sound/driver/openal/sound_driver_al.h index 50bffa379..154bc6d78 100644 --- a/code/nel/src/sound/driver/openal/sound_driver_al.h +++ b/code/nel/src/sound/driver/openal/sound_driver_al.h @@ -19,13 +19,11 @@ #include -namespace NLSOUND -{ +namespace NLSOUND { class CBufferAL; class CListenerAL; class CSourceAL; class CEffectAL; - class CMusicChannelAL; // alGenBuffers, alGenSources //typedef ALAPI ALvoid ALAPIENTRY (*TGenFunctionAL) ( ALsizei, ALuint* ); @@ -82,8 +80,6 @@ private: std::set _Sources; // Allocated effects std::set _Effects; - /// Array with the allocated music channels created by client code. - std::set _MusicChannels; // Number of exported buffers (including any deleted buffers) uint _NbExpBuffers; // Number of exported sources (including any deleted sources) @@ -101,6 +97,10 @@ public: /// Destructor virtual ~CSoundDriverAL(); + inline ALCdevice *getAlDevice() { return _AlDevice; } + inline ALCcontext *getAlContext() { return _AlContext; } + inline float getRolloffFactor() { return _RolloffFactor; } + /// Return a list of available devices for the user. The value at index 0 is empty, and is used for automatic device selection. virtual void getDevices(std::vector &devices); /// Initialize the driver with a user selected device. If device.empty(), the default or most appropriate device is used. @@ -111,73 +111,46 @@ public: /// Return if an option is enabled (including those that cannot be disabled on this driver). virtual bool getOption(TSoundOptions option); - /// Commit all the changes made to 3D settings of listener and sources - virtual void commit3DChanges(); - + /// Create a sound buffer + virtual IBuffer *createBuffer(); /// Create the listener instance virtual IListener *createListener(); - /// Create a source, destroy with delete + /// Create a source virtual ISource *createSource(); - /// Create a sound buffer, destroy with delete - virtual IBuffer *createBuffer(); /// Create a reverb effect virtual IReverbEffect *createReverbEffect(); /// Return the maximum number of sources that can created virtual uint countMaxSources(); /// Return the maximum number of effects that can be created virtual uint countMaxEffects(); - - /// Write information about the driver to the output stream. - virtual void writeProfile(std::string& /* out */); - + virtual void startBench(); virtual void endBench(); virtual void displayBench(NLMISC::CLog * /* log */); - /// Create a music channel, destroy with destroyMusicChannel. - virtual IMusicChannel *createMusicChannel(); - - /** Get music info. Returns false if the song is not found or the function is not implemented. - * \param filepath path to file, CPath::lookup done by driver - * \param artist returns the song artist (empty if not available) - * \param title returns the title (empty if not available) - */ - virtual bool getMusicInfo(const std::string &filepath, std::string &artist, std::string &title); - - /// Get audio/container extensions that are supported natively by the driver implementation. - virtual void getMusicExtensions(std::vector & /* extensions */) const { } - /// Return if a music extension is supported by the driver's music channel. - virtual bool isMusicExtensionSupported(const std::string & /* extension */) const { return false; } - - ALCdevice *getAlDevice() { return _AlDevice; } - ALCcontext *getAlContext() { return _AlContext; } - float getRolloffFactor() { return _RolloffFactor; } /// Change the rolloff factor and apply to all sources void applyRolloffFactor(float f); + /// Commit all the changes made to 3D settings of listener and sources + virtual void commit3DChanges(); + + /// Write information about the driver to the output stream. + virtual void writeProfile(std::string& /* out */); + /// Remove a buffer void removeBuffer(CBufferAL *buffer); /// Remove a source void removeSource(CSourceAL *source); /// Remove an effect void removeEffect(CEffectAL *effect); - /// (Internal) Remove music channel (should be called by the destructor of the music channel class). - void removeMusicChannel(CMusicChannelAL *musicChannel); - /** Set the gain (volume value inside [0 , 1]). (default: 1) - * 0.0 -> silence - * 0.5 -> -6dB - * 1.0 -> no attenuation - * values > 1 (amplification) not supported by most drivers - */ - void setGain( float gain ); - - /// Get the gain - float getGain(); + /// Get audio/container extensions that are supported natively by the driver implementation. + virtual void getMusicExtensions(std::vector & /* extensions */) const { } + /// Return if a music extension is supported by the driver's music channel. + virtual bool isMusicExtensionSupported(const std::string & /* extension */) const { return false; } protected: - void updateMusic(); /// Allocate nb new buffers or sources void allocateNewItems( TGenFunctionAL algenfunc, TTestFunctionAL altestfunc, @@ -195,9 +168,6 @@ protected: /// Delete a buffer or a source bool deleteItem( ALuint name, TDeleteFunctionAL aldeletefunc, std::vector& names ); - - /// Master Volume [0,1] - float _MasterGain; }; diff --git a/code/nel/src/sound/driver/openal/source_al.cpp b/code/nel/src/sound/driver/openal/source_al.cpp index fe2dcb086..dab3123b1 100644 --- a/code/nel/src/sound/driver/openal/source_al.cpp +++ b/code/nel/src/sound/driver/openal/source_al.cpp @@ -15,55 +15,38 @@ // along with this program. If not, see . #include "stdopenal.h" -#include "source_al.h" #include "sound_driver_al.h" #include "listener_al.h" #include "effect_al.h" #include "buffer_al.h" +#include "source_al.h" #include "ext_al.h" +// #define NLSOUND_DEBUG_GAIN + using namespace std; using namespace NLMISC; -namespace NLSOUND +namespace NLSOUND { + +CSourceAL::CSourceAL(CSoundDriverAL *soundDriver) : +_SoundDriver(NULL), _Buffer(NULL), _Source(AL_NONE), +_DirectFilter(AL_FILTER_NULL), _EffectFilter(AL_FILTER_NULL), +_IsPlaying(false), _IsPaused(false), _StartTime(0), _IsStreaming(false), _RelativeMode(false), +_Pos(0.0f, 0.0f, 0.0f), _Gain(NLSOUND_DEFAULT_GAIN), _Alpha(1.0), +_MinDistance(1.0f), _MaxDistance(sqrt(numeric_limits::max())), +_Effect(NULL), _Direct(true), +_DirectGain(NLSOUND_DEFAULT_DIRECT_GAIN), _EffectGain(NLSOUND_DEFAULT_EFFECT_GAIN), +_DirectFilterType(ISource::FilterLowPass), _EffectFilterType(ISource::FilterLowPass), +_DirectFilterEnabled(false), _EffectFilterEnabled(false), +_DirectFilterPassGain(NLSOUND_DEFAULT_FILTER_PASS_GAIN), _EffectFilterPassGain(NLSOUND_DEFAULT_FILTER_PASS_GAIN) { - -CSourceAL::CSourceAL(CSoundDriverAL *soundDriver):ISource(), _SoundDriver(NULL), _Source(AL_NONE), - _DirectFilter(AL_FILTER_NULL), _EffectFilter(AL_FILTER_NULL) -{ - _IsPlaying = false; - _IsPaused = false; - _StartTime = 0; - - _Type = SourceSound; - _Buffer = NULL; - _BuffersMax = 0; - _BufferSize = 32768; - - _PosRelative = false; - _Gain = NLSOUND_DEFAULT_GAIN; - _Alpha = 0.0; - _Pos = CVector::Null; - _MinDistance = 1.0f; - _MaxDistance = numeric_limits::max(); - - _Effect = NULL; - _Direct = true; - _DirectGain = NLSOUND_DEFAULT_DIRECT_GAIN; - _EffectGain = NLSOUND_DEFAULT_EFFECT_GAIN; - _DirectFilterType = ISource::FilterLowPass; - _EffectFilterType = ISource::FilterLowPass; - _DirectFilterEnabled = false; - _EffectFilterEnabled = false; - _DirectFilterPassGain = NLSOUND_DEFAULT_FILTER_PASS_GAIN; - _EffectFilterPassGain = NLSOUND_DEFAULT_FILTER_PASS_GAIN; - // create the al source alGenSources(1, &_Source); alTestError(); - + // configure rolloff - if (!soundDriver || soundDriver->getOption(ISoundDriver::OptionManualRolloff)) + if (soundDriver->getOption(ISoundDriver::OptionManualRolloff)) { alSourcef(_Source, AL_ROLLOFF_FACTOR, 0); alTestError(); @@ -73,16 +56,15 @@ CSourceAL::CSourceAL(CSoundDriverAL *soundDriver):ISource(), _SoundDriver(NULL), alSourcef(_Source, AL_ROLLOFF_FACTOR, soundDriver->getRolloffFactor()); alTestError(); } - + // create filters - if (soundDriver && soundDriver->getOption(ISoundDriver::OptionEnvironmentEffects)) + if (soundDriver->getOption(ISoundDriver::OptionEnvironmentEffects)) { alGenFilters(1, &_DirectFilter); alFilteri(_DirectFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS); alFilterf(_DirectFilter, AL_LOWPASS_GAIN, NLSOUND_DEFAULT_DIRECT_GAIN); alFilterf(_DirectFilter, AL_LOWPASS_GAINHF, NLSOUND_DEFAULT_FILTER_PASS_GAIN); alTestError(); - alGenFilters(1, &_EffectFilter); alFilteri(_EffectFilter, AL_FILTER_TYPE, AL_FILTER_LOWPASS); alFilterf(_EffectFilter, AL_LOWPASS_GAIN, NLSOUND_DEFAULT_EFFECT_GAIN); @@ -103,8 +85,6 @@ CSourceAL::~CSourceAL() void CSourceAL::release() { - unqueueBuffers(); - removeBuffers(); if (_Source != AL_NONE) { alDeleteSources(1, &_Source); _Source = AL_NONE; } if (_DirectFilter != AL_FILTER_NULL) { alDeleteFilters(1, &_DirectFilter); _DirectFilter = AL_FILTER_NULL; } if (_EffectFilter != AL_FILTER_NULL) { alDeleteFilters(1, &_EffectFilter); _EffectFilter = AL_FILTER_NULL; } @@ -114,39 +94,21 @@ void CSourceAL::release() /// (Internal) Update the 3d changes. void CSourceAL::updateManualRolloff() { - CVector pos = getPos(); - - // make relative to listener (if not already!) - if (!_PosRelative) - pos -= CListenerAL::getInstance()->getPos(); - - float sqrdist = pos.sqrnorm(); - float rolloff = ISource::computeManualRolloff(_Alpha, sqrdist, _MinDistance, _MaxDistance); - float volume = _Gain * rolloff; - - // apply SFX volume - if (_SoundDriver && _Type == SourceSound) - volume *= _SoundDriver->getGain(); - - // set the attenuated volume - alSourcef(_Source, AL_GAIN, volume); + CVector distanceVector = _RelativeMode ? _Pos : (_Pos - CListenerAL::getInstance()->getPos()); + float distanceSquare = distanceVector.sqrnorm(); + float rolloff = ISource::computeManualRolloff(_Alpha, distanceSquare, _MinDistance, _MaxDistance); + alSourcef(_Source, AL_GAIN, _Gain * rolloff); alTestError(); -} - -/// Set type of the source -void CSourceAL::setType(TSourceType type) -{ - _Type = type; -} - -/// Get type of the source -TSourceType CSourceAL::getType() const -{ - return _Type; +#ifdef NLSOUND_DEBUG_GAIN + ALfloat gain; + alGetSourcef(_Source, AL_GAIN, &gain); + nlwarning("Called updateManualRolloff(), physical gain is %f, configured gain is %f, distanceSquare is %f, rolloff is %f", gain, _Gain, distanceSquare, rolloff); + alTestError(); +#endif } /// Enable or disable streaming mode. Source must be stopped to call this. -void CSourceAL::setStreaming(bool /* streaming */) +void CSourceAL::setStreaming(bool streaming) { nlassert(isStopped()); @@ -154,6 +116,7 @@ void CSourceAL::setStreaming(bool /* streaming */) alSourcei(_Source, AL_BUFFER, AL_NONE); alTestError(); _Buffer = NULL; + _IsStreaming = streaming; } /* Set the buffer that will be played (no streaming) @@ -199,11 +162,10 @@ void CSourceAL::submitStreamingBuffer(IBuffer *buffer) CBufferAL *bufferAL = static_cast(buffer); ALuint bufferName = bufferAL->bufferName(); nlassert(bufferName); - - // queue the buffer alSourceQueueBuffers(_Source, 1, &bufferName); alTestError(); - + _QueuedBuffers.push(bufferAL); + // Resume playback if the internal OpenAL source stopped due to buffer underrun. ALint srcstate; alGetSourcei(_Source, AL_SOURCE_STATE, &srcstate); @@ -218,11 +180,23 @@ void CSourceAL::submitStreamingBuffer(IBuffer *buffer) /// Return the amount of buffers in the queue (playing and waiting). 3 buffers is optimal. uint CSourceAL::countStreamingBuffers() const { + // a bit ugly here, but makes a much easier/simpler implementation on both drivers + ALint buffersProcessed; + alGetSourcei(_Source, AL_BUFFERS_PROCESSED, &buffersProcessed); + while (buffersProcessed) + { + ALuint bufferName = _QueuedBuffers.front()->bufferName(); + alSourceUnqueueBuffers(_Source, 1, &bufferName); + alTestError(); + const_cast &>(_QueuedBuffers).pop(); + --buffersProcessed; + } // return how many are left in the queue - ALint buffersQueued; - alGetSourcei(_Source, AL_BUFFERS_QUEUED, &buffersQueued); - alTestError(); - return (uint)buffersQueued; + //ALint buffersQueued; + //alGetSourcei(_SourceName, AL_BUFFERS_QUEUED, &buffersQueued); + //alTestError(); + //return (uint)buffersQueued; + return (uint)_QueuedBuffers.size(); } /// Set looping on/off for future playbacks (default: off) @@ -244,28 +218,44 @@ bool CSourceAL::getLooping() const /// Play the static buffer (or stream in and play) bool CSourceAL::play() { - if ( _Buffer != NULL ) +#ifdef NLSOUND_DEBUG_GAIN + if (_IsStreaming) + { + nlwarning("Called play on a streaming source"); + } +#endif + + // Commit 3D changes before starting play + if (_SoundDriver->getOption(ISoundDriver::OptionManualRolloff)) + updateManualRolloff(); + + if (_Buffer) { // Static playing mode _IsPaused = false; alSourcePlay(_Source); - _IsPlaying = alGetError() == AL_NO_ERROR; + _IsPlaying = (alGetError() == AL_NO_ERROR); if (_IsPlaying) _StartTime = CTime::getLocalTime(); return _IsPlaying; } - else + else if (_IsStreaming) { - // TODO: Verify streaming mode? _IsPaused = false; alSourcePlay(_Source); - _IsPlaying = true; - _StartTime = CTime::getLocalTime(); - return true; + _IsPlaying = (alGetError() == AL_NO_ERROR); + if (_IsPlaying) + _StartTime = CTime::getLocalTime(); // TODO: Played time should freeze when buffering fails, and be calculated based on the number of buffers played plus passed time. This is necessary for synchronizing animation with sound. + return _IsPlaying; // Streaming mode //nlwarning("AL: Cannot play null buffer; streaming not implemented" ); //nlstop; } + else + { + nlwarning("Invalid play call, not streaming and no static buffer assigned"); + return false; + } } /// Stop playing @@ -288,8 +278,14 @@ void CSourceAL::stop() _IsPaused = false; alSourceStop(_Source); alTestError(); - - unqueueBuffers(); + // unqueue buffers + while (_QueuedBuffers.size()) + { + ALuint bufferName = _QueuedBuffers.front()->bufferName(); + alSourceUnqueueBuffers(_Source, 1, &bufferName); + _QueuedBuffers.pop(); + alTestError(); + } // Streaming mode //nlwarning("AL: Cannot stop null buffer; streaming not implemented" ); //nlstop; @@ -379,8 +375,7 @@ bool CSourceAL::isPaused() const uint32 CSourceAL::getTime() { if (!_StartTime) return 0; - - return (uint32)(CTime::getLocalTime() - _StartTime); + return (uint32)(CTime::getLocalTime() - _StartTime); } /// Set the position vector. @@ -438,27 +433,28 @@ void CSourceAL::getDirection( NLMISC::CVector& dir ) const void CSourceAL::setGain(float gain) { _Gain = std::min(std::max(gain, NLSOUND_MIN_GAIN), NLSOUND_MAX_GAIN); - - if ((_SoundDriver == NULL) || !_SoundDriver->getOption(ISoundDriver::OptionManualRolloff)) + if (!_SoundDriver->getOption(ISoundDriver::OptionManualRolloff)) { - float gain = _Gain; - - // apply SFX volume - if (_SoundDriver && _Type == SourceSound) - gain *= _SoundDriver->getGain(); - - alSourcef(_Source, AL_GAIN, gain); + alSourcef(_Source, AL_GAIN, _Gain); alTestError(); } +#ifdef NLSOUND_DEBUG_GAIN + else + { + nlwarning("Called setGain(), manual rolloff, commit deferred to play or update, physical gain is %f, configured gain is %f", gain, _Gain); + } +#endif } /// Get the gain float CSourceAL::getGain() const { - //ALfloat gain; - //alGetSourcef(_Source, AL_GAIN, &gain); - //alTestError(); - //return gain; +#ifdef NLSOUND_DEBUG_GAIN + ALfloat gain; + alGetSourcef(_Source, AL_GAIN, &gain); + nlwarning("Called getGain(), physical gain is %f, configured gain is %f", gain, _Gain); + alTestError(); +#endif return _Gain; } @@ -481,7 +477,7 @@ float CSourceAL::getPitch() const /// Set the source relative mode. If true, positions are interpreted relative to the listener position. void CSourceAL::setSourceRelativeMode( bool mode ) { - _PosRelative = mode; + _RelativeMode = mode; alSourcei(_Source, AL_SOURCE_RELATIVE, mode?AL_TRUE:AL_FALSE ); alTestError(); } @@ -489,21 +485,28 @@ void CSourceAL::setSourceRelativeMode( bool mode ) /// Get the source relative mode (3D mode only) bool CSourceAL::getSourceRelativeMode() const { - return _PosRelative; -// ALint b; -// alGetSourcei(_Source, AL_SOURCE_RELATIVE, &b ); -// alTestError(); -// return (b==AL_TRUE); + //ALint b; + //alGetSourcei(_Source, AL_SOURCE_RELATIVE, &b ); + //alTestError(); + //return (b==AL_TRUE); + return _RelativeMode; } /// Set the min and max distances (3D mode only) void CSourceAL::setMinMaxDistances( float mindist, float maxdist, bool /* deferred */) { nlassert( (mindist >= 0.0f) && (maxdist >= 0.0f) ); + + static float maxSqrt = sqrt(std::numeric_limits::max()); + if (maxdist >= maxSqrt) + { + nlwarning("SOUND_DEV (OpenAL): Ridiculously high max distance set on source"); + maxdist = maxSqrt; + } + _MinDistance = mindist; _MaxDistance = maxdist; - - if (!_SoundDriver || !_SoundDriver->getOption(ISoundDriver::OptionManualRolloff)) + if (!_SoundDriver->getOption(ISoundDriver::OptionManualRolloff)) { alSourcef(_Source, AL_REFERENCE_DISTANCE, mindist); alSourcef(_Source, AL_MAX_DISTANCE, maxdist); @@ -805,122 +808,4 @@ float CSourceAL::getEffectFilterPassGain() const return _EffectFilterPassGain; } -/// Get already processed buffers and unqueue them -void CSourceAL::getProcessedStreamingBuffers(std::vector &buffers) -{ - // get the number of processed buffers - ALint buffersProcessed; - alGetSourcei(_Source, AL_BUFFERS_PROCESSED, &buffersProcessed); - alTestError(); - - // exit if more processed buffer than allocated ones - if ((uint)buffersProcessed > _BuffersMax) return; - - // unqueue all previously processed buffers and get their name - alSourceUnqueueBuffers(_Source, buffersProcessed, &(_BuffersName[0])); - alTestError(); - - // add each processed buffer to the array - for(uint i = 0; i < (uint)buffersProcessed; ++i) - { - // if buffer is found, return it - std::map::const_iterator it = _Buffers.find(_BuffersName[i]); - if (it != _Buffers.end()) - buffers.push_back(it->second); - } -} - -/// Get all existing buffers -void CSourceAL::getStreamingBuffers(std::vector &buffers) -{ - std::map::const_iterator it = _Buffers.begin(), iend = _Buffers.end(); - while(it != iend) - { - buffers.push_back(it->second); - ++it; - } -} - -/// Unqueue all buffers -void CSourceAL::unqueueBuffers() -{ - // get count of buffers in queue - uint count = countStreamingBuffers(); - - if (count > 0) - { - // unqueue all of them - alSourceUnqueueBuffers(_Source, count, &(_BuffersName[0])); - alTestError(); - } -} - -/// Delete all allocated buffers -void CSourceAL::removeBuffers() -{ - // delete each buffer - std::map::const_iterator it = _Buffers.begin(), iend = _Buffers.end(); - while(it != iend) - { - delete it->second; - ++it; - } - - _Buffers.clear(); -} - -/// Get available streaming buffers count -uint CSourceAL::getStreamingBuffersMax() const -{ - return _BuffersMax; -} - -/// Set available streaming buffers count and allocate them -void CSourceAL::setStreamingBuffersMax(uint buffers) -{ - // remember previous value - uint oldBuffersMax = _BuffersMax; - - _BuffersMax = buffers; - - // resize the temporary buffer names array - _BuffersName.resize(buffers); - - // remove all buffers - unqueueBuffers(); - removeBuffers(); - - for(uint i = 0; i < _BuffersMax; ++i) - { - try - { - // create a new buffer - CBufferAL *buffer = static_cast(_SoundDriver->createBuffer()); - // use StorageSoftware because buffers will be reused - // deleting and recreating them is a waste of time - buffer->setStorageMode(IBuffer::StorageSoftware); - _Buffers[buffer->bufferName()] = buffer; - } - catch(const ESoundDriverGenBuf &e) - { - nlwarning("Cannot create %d buffers. openal fails after %d buffers", buffers, i); - _BuffersMax = i; - _BuffersName.resize(i); - break; - } - } -} - -/// Set the default size for streaming buffers -void CSourceAL::setStreamingBufferSize(uint size) -{ - _BufferSize = size; -} - -/// Get the default size for streaming buffers -uint CSourceAL::getStreamingBufferSize() const -{ - return _BufferSize; -} - } // NLSOUND diff --git a/code/nel/src/sound/driver/openal/source_al.h b/code/nel/src/sound/driver/openal/source_al.h index b5611b997..53c77cb7f 100644 --- a/code/nel/src/sound/driver/openal/source_al.h +++ b/code/nel/src/sound/driver/openal/source_al.h @@ -17,17 +17,14 @@ #ifndef NL_SOURCE_AL_H #define NL_SOURCE_AL_H -#include "nel/sound/driver/source.h" +#include -namespace NLSOUND -{ +namespace NLSOUND { class IBuffer; class CBufferAL; class CSoundDriverAL; class CEffectAL; - enum TSourceType { SourceSound, SourceMusic }; - /** * OpenAL sound source * @@ -50,29 +47,22 @@ private: /// Sound driver CSoundDriverAL *_SoundDriver; + /// Assigned buffer object + CBufferAL *_Buffer; + std::queue _QueuedBuffers; + /// AL Handles ALuint _Source; ALuint _DirectFilter, _EffectFilter; - - /// Assigned buffer object - CBufferAL *_Buffer; - /// Queued buffers map (uint is buffer name) - std::map _Buffers; - - /// Temporary queued buffers array - std::vector _BuffersName; - /// Max count of queued buffers allowed - uint _BuffersMax; - /// Default size of a buffer - uint _BufferSize; - - /// Position is relative to listener - bool _PosRelative; - + /// Playing status bool _IsPlaying; bool _IsPaused; - NLMISC::TTime _StartTime; + NLMISC::TTime _StartTime; + + bool _IsStreaming; + bool _RelativeMode; + NLMISC::CVector _Pos; float _Gain; double _Alpha; @@ -90,9 +80,6 @@ private: TFilter _DirectFilterType, _EffectFilterType; bool _DirectFilterEnabled, _EffectFilterEnabled; float _DirectFilterPassGain, _EffectFilterPassGain; - - /// Source type can be SourceSound or SourceMusic - TSourceType _Type; public: /// Constructor @@ -104,13 +91,8 @@ public: void release(); /// Return the OpenAL source name - ALuint getSource() const { return _Source; } - - /// Set type of the source - void setType(TSourceType type); - /// Get type of the source - TSourceType getType() const; - + inline ALuint getSource() const { return _Source; } + /// (Internal) Set the effect send for this source, NULL to disable. void setEffect(CEffectAL *effect); /// (Internal) Setup the direct send filter. @@ -275,22 +257,6 @@ public: virtual float getEffectFilterPassGain() const; //@} - /// Get already processed buffers and unqueue them - void getProcessedStreamingBuffers(std::vector &buffers); - /// Get all existing buffers - void getStreamingBuffers(std::vector &buffers); - /// Unqueue all buffers - void unqueueBuffers(); - /// Delete all allocated buffers - void removeBuffers(); - /// Get available streaming buffers count - uint getStreamingBuffersMax() const; - /// Set available streaming buffers count and allocate them - void setStreamingBuffersMax(uint max); - /// Set the default size for streaming buffers - void setStreamingBufferSize(uint size); - /// Get the default size for streaming buffers - uint getStreamingBufferSize() const; }; } // NLSOUND diff --git a/code/nel/src/sound/driver/openal/stdopenal.h b/code/nel/src/sound/driver/openal/stdopenal.h index 12960d57f..1661ef6fe 100644 --- a/code/nel/src/sound/driver/openal/stdopenal.h +++ b/code/nel/src/sound/driver/openal/stdopenal.h @@ -58,6 +58,5 @@ #include "nel/sound/driver/source.h" #include "nel/sound/driver/listener.h" #include "nel/sound/driver/effect.h" -#include "nel/sound/driver/music_buffer.h" /* end of file */ diff --git a/code/nel/src/sound/driver/source.cpp b/code/nel/src/sound/driver/source.cpp index ace98ff81..2f96d74d8 100644 --- a/code/nel/src/sound/driver/source.cpp +++ b/code/nel/src/sound/driver/source.cpp @@ -26,15 +26,12 @@ namespace NLSOUND // common method used only with OptionManualRolloff. return the volume in 1/100th DB ( = mB) modified sint32 ISource::computeManualRollOff(sint32 volumeMB, sint32 mbMin, sint32 mbMax, double alpha, float sqrdist, float distMin, float distMax) { - // root square of max float value - static float maxSqrt = sqrt(std::numeric_limits::max()); - if (sqrdist < distMin * distMin) { // no attenuation return volumeMB; } - else if ((distMax < maxSqrt) && (sqrdist > distMax * distMax)) + else if (sqrdist > distMax * distMax) { // full attenuation return mbMin; diff --git a/code/nel/src/sound/driver/xaudio2/music_channel_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/music_channel_xaudio2.cpp deleted file mode 100644 index 4110ecf41..000000000 --- a/code/nel/src/sound/driver/xaudio2/music_channel_xaudio2.cpp +++ /dev/null @@ -1,248 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "stdxaudio2.h" - -// Project includes -#include "sound_driver_xaudio2.h" -#include "music_channel_xaudio2.h" - -using namespace std; -using namespace NLMISC; - -namespace NLSOUND { - -CMusicChannelXAudio2::CMusicChannelXAudio2(CSoundDriverXAudio2 *soundDriver) -: _MusicBuffer(NULL), _SourceVoice(NULL), _BufferPos(0), _SoundDriver(soundDriver), _Gain(1.0) -{ - nlwarning(NLSOUND_XAUDIO2_PREFIX "Initializing CMusicChannelXAudio2"); - - stop(); -} - -CMusicChannelXAudio2::~CMusicChannelXAudio2() -{ - release(); - if (_SoundDriver) { _SoundDriver->removeMusicChannel(this); _SoundDriver = NULL; } - - nlwarning(NLSOUND_XAUDIO2_PREFIX "Destroying CMusicChannelXAudio2"); -} - -void CMusicChannelXAudio2::release() -{ - nlwarning(NLSOUND_XAUDIO2_PREFIX "Releasing CMusicChannelXAudio2"); - - stop(); -} - -/** Play some music (.ogg etc...) - * NB: if an old music was played, it is first stop with stopMusic() - * \param filepath file path, CPath::lookup is done here - * \param async stream music from hard disk, preload in memory if false - * \param loop must be true to play the music in loop. - */ -bool CMusicChannelXAudio2::play(const std::string &filepath, bool async, bool loop) -{ - // nlinfo(NLSOUND_XAUDIO2_PREFIX "play %s %u", filepath.c_str(), (uint32)loop); - - _SoundDriver->performanceIncreaseMusicPlayCounter(); - - HRESULT hr; - - stop(); - - _MusicBuffer = IMusicBuffer::createMusicBuffer(filepath, async, loop); - - if (_MusicBuffer) - { - WAVEFORMATEX wfe; - wfe.cbSize = 0; - wfe.wFormatTag = WAVE_FORMAT_PCM; // todo: getFormat(); - wfe.nChannels = _MusicBuffer->getChannels(); - wfe.wBitsPerSample = _MusicBuffer->getBitsPerSample(); - wfe.nSamplesPerSec = _MusicBuffer->getSamplesPerSec(); - wfe.nBlockAlign = wfe.nChannels * wfe.wBitsPerSample / 8; - wfe.nAvgBytesPerSec = wfe.nSamplesPerSec * wfe.nBlockAlign; - - XAUDIO2_VOICE_DETAILS voice_details; - _SoundDriver->getMasteringVoice()->GetVoiceDetails(&voice_details); - - // nlinfo(NLSOUND_XAUDIO2_PREFIX "Creating music voice with %u channels, %u bits per sample, %u samples per sec, " - // "on mastering voice with %u channels, %u samples per sec", - // (uint32)wfe.nChannels, (uint32)wfe.wBitsPerSample, (uint32)wfe.nSamplesPerSec, - // (uint32)voice_details.InputChannels, (uint32)voice_details.InputSampleRate); - - if (FAILED(hr = _SoundDriver->getXAudio2()->CreateSourceVoice(&_SourceVoice, &wfe, XAUDIO2_VOICE_NOPITCH, 1.0f, this, NULL, NULL))) - { - nlwarning(NLSOUND_XAUDIO2_PREFIX "FAILED CreateSourceVoice"); - stop(); return false; - } - - _SourceVoice->SetVolume(_Gain); - _SourceVoice->Start(0); - } - else - { - nlwarning(NLSOUND_XAUDIO2_PREFIX "no _MusicBuffer"); - return false; - } - - return true; -} - -/// Stop the music previously loaded and played (the Memory is also freed) -void CMusicChannelXAudio2::stop() -{ - if (_SourceVoice) { _SourceVoice->DestroyVoice(); _SourceVoice = NULL; } - if (_MusicBuffer) { delete _MusicBuffer; _MusicBuffer = NULL; } - // memset(_Buffer, 0, sizeof(_Buffer)); - _BufferPos = 0; -} - -/** Pause the music previously loaded and played (the Memory is not freed) - */ -void CMusicChannelXAudio2::pause() -{ - if (_SourceVoice) _SourceVoice->Stop(0); -} - -/// Resume the music previously paused -void CMusicChannelXAudio2::resume() -{ - if (_SourceVoice) _SourceVoice->Start(0); -} - -/// Return true if a song is finished. -bool CMusicChannelXAudio2::isEnded() -{ - if (_MusicBuffer) - { - if (!_MusicBuffer->isMusicEnded()) - return false; - } - if (_SourceVoice) - { - XAUDIO2_VOICE_STATE voice_state; - _SourceVoice->GetState(&voice_state); - if (voice_state.BuffersQueued) - { - // nldebug(NLSOUND_XAUDIO2_PREFIX "isEnded() -> voice_state.BuffersQueued, wait ..."); - return false; - } - } - // nldebug(NLSOUND_XAUDIO2_PREFIX "isEnded() -> stop()"); - stop(); - return true; -} - -/// Return true if the song is still loading asynchronously and hasn't started playing yet (false if not async), used to delay fading -bool CMusicChannelXAudio2::isLoadingAsync() -{ - return false; -} - -/// Return the total length (in second) of the music currently played -float CMusicChannelXAudio2::getLength() -{ - if (_MusicBuffer) return _MusicBuffer->getLength(); - else return .0f; -} - -/** Set the music volume (if any music played). (volume value inside [0 , 1]) (default: 1) - * NB: the volume of music is NOT affected by IListener::setGain() - */ -void CMusicChannelXAudio2::setVolume(float gain) -{ - _Gain = gain; - if (_SourceVoice) _SourceVoice->SetVolume(gain); -} - -void CMusicChannelXAudio2::OnVoiceProcessingPassStart(UINT32 BytesRequired) -{ - if (BytesRequired > 0) - { - // nlwarning(NLSOUND_XAUDIO2_PREFIX "Bytes Required: %u", BytesRequired); // byte req to not have disruption - - if (_MusicBuffer) - { - uint32 minimum = BytesRequired * 2; // give some more than required :p - if (_MusicBuffer->getRequiredBytes() > minimum) minimum = _MusicBuffer->getRequiredBytes(); - if (minimum > sizeof(_Buffer) - _BufferPos) _BufferPos = 0; - uint32 maximum = sizeof(_Buffer) - _BufferPos; - uint8 *buffer = &_Buffer[_BufferPos]; - uint32 length = _MusicBuffer->getNextBytes(buffer, minimum, maximum); - _BufferPos += length; - - if (length) - { - XAUDIO2_BUFFER xbuffer; - xbuffer.AudioBytes = length; - xbuffer.Flags = 0; - xbuffer.LoopBegin = 0; - xbuffer.LoopCount = 0; - xbuffer.LoopLength = 0; - xbuffer.pAudioData = buffer; - xbuffer.pContext = NULL; // nothing here for now - xbuffer.PlayBegin = 0; - xbuffer.PlayLength = 0; - - _SourceVoice->SubmitSourceBuffer(&xbuffer); - } - else - { - // nldebug(NLSOUND_XAUDIO2_PREFIX "!length -> delete _MusicBuffer"); - // set member var to null before deleting it to avoid crashing main thread - IMusicBuffer *music_buffer = _MusicBuffer; - _MusicBuffer = NULL; delete music_buffer; - _SourceVoice->Discontinuity(); - } - } - } -} - -void CMusicChannelXAudio2::OnVoiceProcessingPassEnd() -{ - -} - -void CMusicChannelXAudio2::OnStreamEnd() -{ - -} - -void CMusicChannelXAudio2::OnBufferStart(void * /* pBufferContext */) -{ - -} - -void CMusicChannelXAudio2::OnBufferEnd(void * /* pBufferContext */) -{ - -} - -void CMusicChannelXAudio2::OnLoopEnd(void * /* pBufferContext */) -{ - -} - -void CMusicChannelXAudio2::OnVoiceError(void * /* pBufferContext */, HRESULT /* Error */) -{ - -} - -} /* namespace NLSOUND */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/music_channel_xaudio2.h b/code/nel/src/sound/driver/xaudio2/music_channel_xaudio2.h deleted file mode 100644 index ade13e25f..000000000 --- a/code/nel/src/sound/driver/xaudio2/music_channel_xaudio2.h +++ /dev/null @@ -1,117 +0,0 @@ -// NeL - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#ifndef NLSOUND_MUSIC_CHANNEL_XAUDIO2_H -#define NLSOUND_MUSIC_CHANNEL_XAUDIO2_H - -#include - -namespace NLSOUND { - class CSoundDriverXAudio2; - class IMusicBuffer; - -/** - * \brief CMusicChannelXAudio2 - * \date 2008-08-30 13:31GMT - * \author Jan Boon (Kaetemi) - * CMusicChannelXAudio2 is an implementation of the IMusicChannel interface to run on XAudio2. - * TODO: Properly decode the audio on a seperate thread. - * TODO: Change IMusicChannel to IAudioStream, and fix the interface to make more sense. - */ -class CMusicChannelXAudio2 : public IMusicChannel, IXAudio2VoiceCallback -{ -protected: - // outside pointers - CSoundDriverXAudio2 *_SoundDriver; - - // pointers - IMusicBuffer *_MusicBuffer; - IXAudio2SourceVoice *_SourceVoice; - // todo: thread for async loading of music buffer and source voice - // isasyncloading checks if thread exists - // isended checks if not async loading too - - // instances - uint8 _Buffer[64 * 1024]; // no specific reason, lol - uint32 _BufferPos; // 0 - float _Gain; - -public: - CMusicChannelXAudio2(CSoundDriverXAudio2 *soundDriver); - virtual ~CMusicChannelXAudio2(); - void release(); - -private: - // XAudio2 Callbacks - // Called just before this voice's processing pass begins. - STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired); - // Called just after this voice's processing pass ends. - STDMETHOD_(void, OnVoiceProcessingPassEnd) (THIS); - // Called when this voice has just finished playing a buffer stream - // (as marked with the XAUDIO2_END_OF_STREAM flag on the last buffer). - STDMETHOD_(void, OnStreamEnd) (THIS); - // Called when this voice is about to start processing a new buffer. - STDMETHOD_(void, OnBufferStart) (THIS_ void* pBufferContext); - // Called when this voice has just finished processing a buffer. - // The buffer can now be reused or destroyed. - STDMETHOD_(void, OnBufferEnd) (THIS_ void* pBufferContext); - // Called when this voice has just reached the end position of a loop. - STDMETHOD_(void, OnLoopEnd) (THIS_ void* pBufferContext); - // Called in the event of a critical error during voice processing, - // such as a failing XAPO or an error from the hardware XMA decoder. - // The voice may have to be destroyed and re-created to recover from - // the error. The callback arguments report which buffer was being - // processed when the error occurred, and its HRESULT code. - STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error); - -public: - /** Play some music (.ogg etc...) - * NB: if an old music was played, it is first stop with stopMusic() - * \param filepath file path, CPath::lookup is done here - * \param async stream music from hard disk, preload in memory if false - * \param loop must be true to play the music in loop. - */ - virtual bool play(const std::string &filepath, bool async, bool loop); - - /// Stop the music previously loaded and played (the Memory is also freed) - virtual void stop(); - - /// Pause the music previously loaded and played (the Memory is not freed) - virtual void pause(); - - /// Resume the music previously paused - virtual void resume(); - - /// Return true if a song is finished. - virtual bool isEnded(); - - /// Return true if the song is still loading asynchronously and hasn't started playing yet (false if not async), used to delay fading - virtual bool isLoadingAsync(); - - /// Return the total length (in second) of the music currently played - virtual float getLength(); - - /** Set the music volume (if any music played). (volume value inside [0 , 1]) (default: 1) - * NB: the volume of music is NOT affected by IListener::setGain() - */ - virtual void setVolume(float gain); -}; /* class CMusicChannelXAudio2 */ - -} /* namespace NLSOUND */ - -#endif /* #ifndef NLSOUND_MUSIC_CHANNEL_XAUDIO2_H */ - -/* end of file */ diff --git a/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp index 826f9973b..7c4ea9bbf 100644 --- a/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp +++ b/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.cpp @@ -19,7 +19,6 @@ // Project includes #include "listener_xaudio2.h" #include "source_xaudio2.h" -#include "music_channel_xaudio2.h" #include "effect_xaudio2.h" #include "sound_driver_xaudio2.h" @@ -132,8 +131,7 @@ CSoundDriverXAudio2::CSoundDriverXAudio2(ISoundDriver::IStringMapperProvider * / : _XAudio2(NULL), _MasteringVoice(NULL), _Listener(NULL), _SoundDriverOk(false), _CoInitOk(false), _OperationSetCounter(65536), _PerformanceCommit3DCounter(0), _PerformanceADPCMBufferSize(0), - _PerformancePCMBufferSize(0), _PerformanceMusicPlayCounter(0), - _PerformanceSourcePlayCounter(0) + _PerformancePCMBufferSize(0), _PerformanceSourcePlayCounter(0) { nlwarning(NLSOUND_XAUDIO2_PREFIX "Creating CSoundDriverXAudio2"); @@ -200,14 +198,6 @@ void CSoundDriverXAudio2::release() // WARNING: Only internal resources are released here, // the created instances must still be released by the user! - // Release internal resources of all remaining IMusicChannel instances - if (_MusicChannels.size()) - { - nlwarning(NLSOUND_XAUDIO2_PREFIX "_MusicChannels.size(): '%u'", (uint32)_MusicChannels.size()); - set::iterator it(_MusicChannels.begin()), end(_MusicChannels.end()); - for (; it != end; ++it) (*it)->release(); - _MusicChannels.clear(); - } // Release internal resources of all remaining ISource instances if (_Sources.size()) { @@ -396,14 +386,6 @@ void CSoundDriverXAudio2::destroySourceVoice(IXAudio2SourceVoice *sourceVoice) if (sourceVoice) sourceVoice->DestroyVoice(); } -/// Create a music channel -IMusicChannel *CSoundDriverXAudio2::createMusicChannel() -{ - CMusicChannelXAudio2 *music_channel = new CMusicChannelXAudio2(this); - _MusicChannels.insert(music_channel); - return static_cast(music_channel); -} - /// Create the listener instance IListener *CSoundDriverXAudio2::createListener() { @@ -481,7 +463,6 @@ void CSoundDriverXAudio2::writeProfile(std::string& out) + "\n\tPCMBufferSize: " + toString(_PerformancePCMBufferSize) + "\n\tADPCMBufferSize: " + toString(_PerformanceADPCMBufferSize) + "\n\tSourcePlayCounter: " + toString(_PerformanceSourcePlayCounter) - + "\n\tMusicPlayCounter: " + toString(_PerformanceMusicPlayCounter) + "\n\tCommit3DCounter: " + toString(_PerformanceCommit3DCounter) + "\nXAUDIO2_PERFORMANCE_DATA" + "\n\tAudioCyclesSinceLastQuery: " + toString(performance.AudioCyclesSinceLastQuery) @@ -519,17 +500,6 @@ void CSoundDriverXAudio2::displayBench(NLMISC::CLog *log) NLMISC::CHTimer::display(log, CHTimer::TotalTime); } -/** Get music info. Returns false if the song is not found or the function is not implemented. - * \param filepath path to file, CPath::lookup done by driver - * \param artist returns the song artist (empty if not available) - * \param title returns the title (empty if not available) - */ -bool CSoundDriverXAudio2::getMusicInfo(const std::string &filepath, std::string &artist, std::string &title) -{ - // add support for additional non-standard music file types info here - return IMusicBuffer::getInfo(filepath, artist, title); -} - /// Remove a buffer (should be called by the friend destructor of the buffer class) void CSoundDriverXAudio2::removeBuffer(CBufferXAudio2 *buffer) { @@ -543,13 +513,6 @@ void CSoundDriverXAudio2::removeSource(CSourceXAudio2 *source) if (_Sources.find(source) != _Sources.end()) _Sources.erase(source); else nlwarning("removeSource already called"); } - -/// (Internal) Remove a source (should be called by the destructor of the source class). -void CSoundDriverXAudio2::removeMusicChannel(CMusicChannelXAudio2 *musicChannel) -{ - if (_MusicChannels.find(musicChannel) != _MusicChannels.end()) _MusicChannels.erase(musicChannel); - else nlwarning("removeMusicChannel already called"); -} /// (Internal) Remove an effect (should be called by the destructor of the effect class) void CSoundDriverXAudio2::removeEffect(CEffectXAudio2 *effect) diff --git a/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.h b/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.h index 681d36254..bcf847a5f 100644 --- a/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.h +++ b/code/nel/src/sound/driver/xaudio2/sound_driver_xaudio2.h @@ -62,8 +62,6 @@ protected: std::set _Sources; /// Array with the allocated effects created by client code. std::set _Effects; - /// Array with the allocated music channels created by client code. - std::set _MusicChannels; /// Initialization Handle of X3DAudio. X3DAUDIO_HANDLE _X3DAudioHandle; //I /// Operation set counter @@ -73,7 +71,6 @@ protected: uint _PerformancePCMBufferSize; uint _PerformanceADPCMBufferSize; uint _PerformanceSourcePlayCounter; - uint _PerformanceMusicPlayCounter; uint _PerformanceCommit3DCounter; // user init vars @@ -108,8 +105,6 @@ public: } /// (Internal) Increase the source play counter by one. inline void performanceIncreaseSourcePlayCounter() { ++_PerformanceSourcePlayCounter; } - /// (Internal) Increase the music play counter by one. - inline void performanceIncreaseMusicPlayCounter() { ++_PerformanceMusicPlayCounter; } /// (Internal) Increase the commit 3d counter by one. inline void performanceIncreaseCommit3DCounter() { ++_PerformanceCommit3DCounter; } @@ -172,16 +167,6 @@ public: virtual void startBench(); virtual void endBench(); virtual void displayBench(NLMISC::CLog *log); - - /// Create a music channel, destroy with destroyMusicChannel. - virtual IMusicChannel *createMusicChannel(); - - /** Get music info. Returns false if the song is not found or the function is not implemented. - * \param filepath path to file, CPath::lookup done by driver - * \param artist returns the song artist (empty if not available) - * \param title returns the title (empty if not available) - */ - virtual bool getMusicInfo(const std::string &filepath, std::string &artist, std::string &title); /// Get audio/container extensions that are supported natively by the driver implementation. virtual void getMusicExtensions(std::vector & /* extensions */) const { } @@ -192,8 +177,6 @@ public: void removeBuffer(CBufferXAudio2 *buffer); /// (Internal) Remove a source (should be called by the destructor of the source class). void removeSource(CSourceXAudio2 *source); - /// (Internal) Remove a source (should be called by the destructor of the music channel class). - void removeMusicChannel(CMusicChannelXAudio2 *musicChannel); /// (Internal) Remove the listener (should be called by the destructor of the listener class) inline void removeListener(CListenerXAudio2 *listener) { nlassert(_Listener == listener); _Listener = NULL; } /// (Internal) Remove an effect (should be called by the destructor of the effect class) diff --git a/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp b/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp index 9c34beaf8..318a65a1a 100644 --- a/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp +++ b/code/nel/src/sound/driver/xaudio2/source_xaudio2.cpp @@ -42,7 +42,7 @@ _DirectFilterPassGain(NLSOUND_DEFAULT_FILTER_PASS_GAIN), _EffectFilterPassGain(N _DirectFilterLowFrequency(NLSOUND_DEFAULT_FILTER_PASS_LF), _DirectFilterHighFrequency(NLSOUND_DEFAULT_FILTER_PASS_HF), _EffectFilterLowFrequency(NLSOUND_DEFAULT_FILTER_PASS_LF), _EffectFilterHighFrequency(NLSOUND_DEFAULT_FILTER_PASS_HF), _IsPlaying(false), _IsPaused(false), _IsLooping(false), _Pitch(1.0f), -_Gain(1.0f), _MinDistance(1.0f), _MaxDistance(numeric_limits::max()), +_Gain(1.0f), _MinDistance(1.0f), _MaxDistance(sqrt(numeric_limits::max())), _AdpcmUtility(NULL), _Channels(0), _BitsPerSample(0), _BufferStreaming(false) { // nlwarning(NLSOUND_XAUDIO2_PREFIX "Inititializing CSourceXAudio2"); @@ -121,8 +121,7 @@ void CSourceXAudio2::commit3DChanges() { nlassert(_SourceVoice); - // Only mono buffers get 3d sound, multi-channel buffers go directly to the speakers (calculate rolloff too!!). - // Todo: stereo buffers calculate distance ? + // Only mono buffers get 3d sound, multi-channel buffers go directly to the speakers without any distance rolloff. if (_Channels > 1) { // _SoundDriver->getDSPSettings()->DstChannelCount = 1; @@ -494,8 +493,10 @@ bool CSourceXAudio2::initFormat(IBuffer::TBufferFormat bufferFormat, uint8 chann _SourceVoice->SetVolume(_Gain, _OperationSet); setupVoiceSends(); _SoundDriver->getXAudio2()->CommitChanges(_OperationSet); - - + + // Also commit any 3D settings that were already done + commit3DChanges(); + // test //XAUDIO2_VOICE_DETAILS voice_details; //_SourceVoice->GetVoiceDetails(&voice_details); @@ -535,7 +536,7 @@ bool CSourceXAudio2::preparePlay(IBuffer::TBufferFormat bufferFormat, uint8 chan // destroy adpcm utility (if it exists) delete _AdpcmUtility; _AdpcmUtility = NULL; // reset current stuff - _Format = (IBuffer::TBufferFormat)~0; + _Format = IBuffer::FormatNotSet; _Channels = 0; _BitsPerSample = 0; } @@ -582,6 +583,11 @@ bool CSourceXAudio2::play() { // nldebug(NLSOUND_XAUDIO2_PREFIX "play"); + // Commit 3D changes before starting play + if (_SourceVoice) + commit3DChanges(); + // else it is commit by the preparePlay > initFormat function + if (_IsPaused) { if (SUCCEEDED(_SourceVoice->Start(0))) _IsPaused = false; @@ -793,7 +799,14 @@ bool CSourceXAudio2::getSourceRelativeMode() const void CSourceXAudio2::setMinMaxDistances(float mindist, float maxdist, bool /* deferred */) { // nldebug(NLSOUND_XAUDIO2_PREFIX "setMinMaxDistances %f, %f", mindist, maxdist); - + + static float maxSqrt = sqrt(std::numeric_limits::max()); + if (maxdist >= maxSqrt) + { + nlwarning("SOUND_DEV (XAudio2): Ridiculously high max distance set on source"); + maxdist = maxSqrt; + } + _Emitter.InnerRadius = mindist; _MinDistance = mindist; _MaxDistance = maxdist; diff --git a/code/nel/src/sound/driver/xaudio2/stdxaudio2.h b/code/nel/src/sound/driver/xaudio2/stdxaudio2.h index c043f3949..1a1d766e7 100644 --- a/code/nel/src/sound/driver/xaudio2/stdxaudio2.h +++ b/code/nel/src/sound/driver/xaudio2/stdxaudio2.h @@ -57,7 +57,6 @@ #include "nel/sound/driver/listener.h" #include "nel/sound/driver/sound_driver.h" #include "nel/sound/driver/source.h" -#include "nel/sound/driver/music_buffer.h" // Defines #define NLSOUND_XAUDIO2_NAME "NeLSound XAudio2 Driver" diff --git a/code/nel/src/sound/group_controller.cpp b/code/nel/src/sound/group_controller.cpp new file mode 100644 index 000000000..d01e29252 --- /dev/null +++ b/code/nel/src/sound/group_controller.cpp @@ -0,0 +1,129 @@ +/** + * \file group_controller.cpp + * \brief CGroupController + * \date 2012-04-10 09:29GMT + * \author Jan Boon (Kaetemi) + * CGroupController + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#include "stdsound.h" +#include + +// STL includes + +// NeL includes +// #include +#include + +// Project includes + +using namespace std; +// using namespace NLMISC; + +namespace NLSOUND { + +CGroupController::CGroupController(CGroupController *parent) : + m_Parent(parent), m_Gain(1.0f), m_NbSourcesInclChild(0) +{ + +} + +CGroupController::~CGroupController() +{ + // If m_Sources is not empty, a crash is very likely. + nlassert(m_Sources.empty()); + + for (std::map::iterator it(m_Children.begin()), end(m_Children.end()); it != end; ++it) + { + delete it->second; + it->second = NULL; + } + m_Parent = NULL; +} + +void CGroupController::addSource(CSourceCommon *source) +{ + nlassert(this); + + m_Sources.insert(source); + increaseSources(); +} + +void CGroupController::removeSource(CSourceCommon *source) +{ + decreaseSources(); + m_Sources.erase(source); +} + +std::string CGroupController::getPath() // overridden by root +{ + for (std::map::iterator it(m_Parent->m_Children.begin()), end(m_Parent->m_Children.end()); it != end; ++it) + { + if (it->second == this) + { + const std::string &name = it->first; + std::string returnPath = m_Parent->getPath() + ":" + name; + return returnPath; + } + } + nlerror("Group Controller not child of parent"); + return ""; +} + +void CGroupController::calculateFinalGain() // overridden by root +{ + m_FinalGain = calculateTotalGain() * m_Parent->getFinalGain(); +} + +void CGroupController::updateSourceGain() +{ + // Dont update source gain when this controller is inactive. + if (m_NbSourcesInclChild) + { + calculateFinalGain(); + for (TSourceContainer::iterator it(m_Sources.begin()), end(m_Sources.end()); it != end; ++it) + (*it)->updateFinalGain(); + for (std::map::iterator it(m_Children.begin()), end(m_Children.end()); it != end; ++it) + (*it).second->updateSourceGain(); + } +} + +void CGroupController::increaseSources() // overridden by root +{ + ++m_NbSourcesInclChild; + m_Parent->increaseSources(); + + // Update source gain when this controller was inactive before but the parent was active before. + // Thus, when this controller was the root of inactive controllers. + if (m_NbSourcesInclChild == 1 && m_Parent->m_NbSourcesInclChild > 1) + updateSourceGain(); +} + +void CGroupController::decreaseSources() // overridden by root +{ + --m_NbSourcesInclChild; + m_Parent->decreaseSources(); +} + +} /* namespace NLSOUND */ + +/* end of file */ diff --git a/code/nel/src/sound/group_controller_root.cpp b/code/nel/src/sound/group_controller_root.cpp new file mode 100644 index 000000000..0f1c58e63 --- /dev/null +++ b/code/nel/src/sound/group_controller_root.cpp @@ -0,0 +1,127 @@ +/** + * \file group_controller_root.cpp + * \brief CGroupControllerRoot + * \date 2012-04-10 09:44GMT + * \author Jan Boon (Kaetemi) + * CGroupControllerRoot + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#include "stdsound.h" +#include + +// STL includes + +// NeL includes +// #include +#include + +// Project includes + +using namespace std; +// using namespace NLMISC; + +#define NLSOUND_GROUP_CONTROLLER_ROOT_PATH "sound" + +namespace NLSOUND { + +CGroupControllerRoot::CGroupControllerRoot() : CGroupController(NULL) +{ + +} + +CGroupControllerRoot::~CGroupControllerRoot() +{ + +} + +std::string CGroupControllerRoot::getPath() +{ + // The root node is always called sound + return NLSOUND_GROUP_CONTROLLER_ROOT_PATH; +} + +void CGroupControllerRoot::calculateFinalGain() +{ + m_FinalGain = calculateTotalGain(); +} + +void CGroupControllerRoot::increaseSources() +{ + ++m_NbSourcesInclChild; + + // Update source gain when this controller was inactive before. + if (m_NbSourcesInclChild == 1) + updateSourceGain(); +} + +void CGroupControllerRoot::decreaseSources() +{ + --m_NbSourcesInclChild; +} + +bool CGroupControllerRoot::isReservedName(const std::string &nodeName) +{ + // These node names are reserved, in case these category controllers can be integrated with CDB. + // I do not forsee any functionality for changing environment effect settings for entire categories. + // The nodeName parameter is already lowercase, see CGroupControllerRoot::getGroupController. + if (nodeName == NLSOUND_GROUP_CONTROLLER_ROOT_PATH) return true; // Root node name can only used by root. + if (nodeName == "gain") return true; + if (nodeName == "pitch") return true; + if (nodeName == "enable" || nodeName == "enabled") return true; + return false; +} + +CGroupController *CGroupControllerRoot::getGroupController(const std::string &path) +{ + std::vector pathNodes; + NLMISC::splitString(NLMISC::toLower(path), ":", pathNodes); + CGroupController *active = this; + if (pathNodes[0] != NLSOUND_GROUP_CONTROLLER_ROOT_PATH) + { + nlerror("Root node for group controller must always be 'sound', invalid group '%s' requested", path.c_str()); + } + for (std::vector::iterator it(pathNodes.begin() + 1), end(pathNodes.end()); it != end; ++it) + { + if (!(*it).empty()) + { + if (isReservedName(*it)) + { + nlerror("Attempt to use reserved node name '%s' in group controller path '%s'", (*it).c_str(), path.c_str()); + } + std::map::iterator found = active->m_Children.find(*it); + if (found == active->m_Children.end()) + { + active = new CGroupController(active); + active->m_Parent->m_Children[*it] = active; + } + else + { + active = (*found).second; + } + } + } + return active; +} + +} /* namespace NLSOUND */ + +/* end of file */ diff --git a/code/nel/src/sound/music_channel_fader.cpp b/code/nel/src/sound/music_channel_fader.cpp index ced739093..2fe9fb13c 100644 --- a/code/nel/src/sound/music_channel_fader.cpp +++ b/code/nel/src/sound/music_channel_fader.cpp @@ -20,6 +20,7 @@ // Project includes #include "nel/sound/driver/sound_driver.h" #include "nel/sound/driver/music_channel.h" +#include "nel/sound/source_music_channel.h" using namespace std; using namespace NLMISC; @@ -49,9 +50,16 @@ void CMusicChannelFader::init(ISoundDriver *soundDriver) _MusicFader[i].MusicChannel = _SoundDriver->createMusicChannel(); if (!_MusicFader[i].MusicChannel) { - release(); - nlwarning("No music channel available!"); - return; + if (_SoundDriver->getOption(ISoundDriver::OptionHasBufferStreaming)) + { + _MusicFader[i].MusicChannel = new CSourceMusicChannel(); + } + else + { + release(); + nlwarning("No music channel available!"); + return; + } } } } @@ -69,6 +77,15 @@ void CMusicChannelFader::release() } } +void CMusicChannelFader::reset() +{ + for (uint i = 0; i < _MaxMusicFader; ++i) if (_MusicFader[i].MusicChannel) + { + if (_MusicFader[i].MusicChannel) + _MusicFader[i].MusicChannel->reset(); + } +} + void CMusicChannelFader::update() { TTime current_time = CTime::getLocalTime(); diff --git a/code/nel/src/sound/music_sound.cpp b/code/nel/src/sound/music_sound.cpp index 2b192c3c6..803103dd9 100644 --- a/code/nel/src/sound/music_sound.cpp +++ b/code/nel/src/sound/music_sound.cpp @@ -20,6 +20,9 @@ #include "nel/misc/path.h" #include "nel/georges/u_form_elm.h" +#if NLSOUND_SHEET_VERSION_BUILT < 2 +# include "nel/sound/group_controller_root.h" +#endif using namespace std; using namespace NLMISC; @@ -72,6 +75,10 @@ void CMusicSound::importForm(const std::string& filename, NLGEORGES::UFormElm& root.getValueByName(_MinimumPlayTime, ".SoundType.MinimumPlayTime"); root.getValueByName(_TimeBeforeCanReplay, ".SoundType.TimeBeforeCanReplay"); +#if NLSOUND_SHEET_VERSION_BUILT < 2 + _GroupController = CGroupControllerRoot::getInstance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_MUSIC_GROUP_CONTROLLER); +#endif + } // *************************************************************************** @@ -97,6 +104,11 @@ void CMusicSound::serial(NLMISC::IStream &s) CStringMapper::serialString(s, _FileName); s.serial(_FadeInLength, _FadeOutLength); s.serial(_MinimumPlayTime, _TimeBeforeCanReplay); + +#if NLSOUND_SHEET_VERSION_BUILT < 2 + if (s.isReading()) _GroupController = CGroupControllerRoot::getInstance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_MUSIC_GROUP_CONTROLLER); +#endif + } // *************************************************************************** diff --git a/code/nel/src/sound/music_source.cpp b/code/nel/src/sound/music_source.cpp index a47914dde..e5595d9f4 100644 --- a/code/nel/src/sound/music_source.cpp +++ b/code/nel/src/sound/music_source.cpp @@ -26,8 +26,8 @@ namespace NLSOUND { // *************************************************************************** -CMusicSource::CMusicSource(CMusicSound *musicSound, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster) - : CSourceCommon(musicSound, spawn, cb, cbUserParam, cluster) +CMusicSource::CMusicSource(CMusicSound *musicSound, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster, CGroupController *groupController) + : CSourceCommon(musicSound, spawn, cb, cbUserParam, cluster, groupController) { _MusicSound= musicSound; } diff --git a/code/nel/src/sound/simple_source.cpp b/code/nel/src/sound/simple_source.cpp index fb0b7bc85..cce62cffd 100644 --- a/code/nel/src/sound/simple_source.cpp +++ b/code/nel/src/sound/simple_source.cpp @@ -28,11 +28,12 @@ using namespace NLMISC; namespace NLSOUND { -CSimpleSource::CSimpleSource(CSimpleSound *simpleSound, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster) - : CSourceCommon(simpleSound, spawn, cb, cbUserParam, cluster), +CSimpleSource::CSimpleSource(CSimpleSound *simpleSound, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster, CGroupController *groupController) + : CSourceCommon(simpleSound, spawn, cb, cbUserParam, cluster, groupController), _SimpleSound(simpleSound), _Track(NULL), - _PlayMuted(false) + _PlayMuted(false), + _WaitingForPlay(false) { nlassert(_SimpleSound != 0); @@ -133,6 +134,7 @@ void CSimpleSource::play() || (_RelativeMode ? getPos().sqrnorm() : (mixer->getListenPosVector() - getPos()).sqrnorm()) > _SimpleSound->getMaxDistance() * _SimpleSound->getMaxDistance()) { // The sample buffer is not available, don't play (we don't know the length) + _WaitingForPlay = false; if (_Spawn) { if (_SpawnEndCb != 0) @@ -166,7 +168,7 @@ void CSimpleSource::play() setDirection(_Direction); // because there is a workaround inside pSource->setVelocity(_Velocity); } - pSource->setGain(_Gain); + pSource->setGain(getFinalGain()); pSource->setSourceRelativeMode(_RelativeMode); pSource->setLooping(_Looping); pSource->setPitch(_Pitch); @@ -174,7 +176,14 @@ void CSimpleSource::play() // and play the sound bool play = pSource->play(); + +#ifdef NL_DEBUG nlassert(play); +#else + if (!play) + nlwarning("Failed to play physical sound source. This is a serious error"); +#endif + // nldebug("CSimpleSource %p : REAL play done", (CAudioMixerUser::IMixerEvent*)this); } else @@ -183,6 +192,7 @@ void CSimpleSource::play() { // This sound is not discardable, add it in waiting playlist mixer->addSourceWaitingForPlay(this); + _WaitingForPlay = true; return; } // there is no available track, just do a 'muted' play @@ -193,6 +203,7 @@ void CSimpleSource::play() } CSourceCommon::play(); + _WaitingForPlay = false; } /// Mixer event call when doing muted play @@ -219,6 +230,13 @@ void CSimpleSource::stop() // nldebug("CSimpleSource %p : stop", (CAudioMixerUser::IMixerEvent*)this); // nlassert(_Playing); + if (_WaitingForPlay) + { + nlassert(!_Playing); // cannot already be playing if waiting for play + CAudioMixerUser *mixer = CAudioMixerUser::instance(); + mixer->removeSourceWaitingForPlay(this); + } + if (!_Playing) return; @@ -312,36 +330,13 @@ void CSimpleSource::setDirection(const NLMISC::CVector& dir) } } - -/* Set the gain (volume value inside [0 , 1]). (default: 1) - * 0.0 -> silence - * 0.5 -> -6dB - * 1.0 -> no attenuation - * values > 1 (amplification) not supported by most drivers - */ -void CSimpleSource::setGain(float gain) +void CSimpleSource::updateFinalGain() { - CSourceCommon::setGain(gain); - // Set the gain if (hasPhysicalSource()) - { - getPhysicalSource()->setGain(gain); - } + getPhysicalSource()->setGain(getFinalGain()); } -void CSimpleSource::setRelativeGain(float gain) -{ - CSourceCommon::setRelativeGain(gain); - - // Set the gain - if (hasPhysicalSource()) - { - getPhysicalSource()->setGain(_Gain); - } -} - - /* Shift the frequency. 1.0f equals identity, each reduction of 50% equals a pitch shift * of one octave. 0 is not a legal value. */ diff --git a/code/nel/src/sound/sound.cpp b/code/nel/src/sound/sound.cpp index eed318cca..b1b644ed2 100644 --- a/code/nel/src/sound/sound.cpp +++ b/code/nel/src/sound/sound.cpp @@ -26,6 +26,10 @@ #include "nel/sound/context_sound.h" #include "nel/sound/music_sound.h" #include "nel/sound/stream_sound.h" +#include "nel/sound/stream_file_sound.h" + +#include "nel/sound/group_controller.h" +#include "nel/sound/group_controller_root.h" using namespace std; using namespace NLMISC; @@ -81,6 +85,11 @@ CSound *CSound::createSound(const std::string &filename, NLGEORGES::UFormElm& fo ret = new CStreamSound(); ret->importForm(filename, formRoot); } + else if (dfnName == "stream_file_sound.dfn") + { + ret = new CStreamFileSound(); + ret->importForm(filename, formRoot); + } else { nlassertex(false, ("SoundType unsuported : %s", dfnName.c_str())); @@ -106,7 +115,8 @@ CSound::CSound() : _Looping(false), _MinDist(1.0f), _MaxDist(1000000.0f), - _UserVarControler(CStringMapper::emptyId()) + _UserVarControler(CStringMapper::emptyId()), + _GroupController(NULL) { } @@ -134,6 +144,23 @@ void CSound::serial(NLMISC::IStream &s) std::string name = CStringMapper::unmap(_Name); s.serial(name); } + + nlassert(CGroupControllerRoot::getInstance()); // not sure +#if NLSOUND_SHEET_VERSION_BUILT < 2 + if (s.isReading()) _GroupController = static_cast(CAudioMixerUser::instance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER)); +#else + if (s.isReading()) + { + std::string groupControllerPath; + s.serial(groupControllerPath); + _GroupController = static_cast(CAudioMixerUser::instance()->getGroupController(groupControllerPath)); + } + else + { + std::string groupControllerPath = _GroupController->getPath(); + s.serial(groupControllerPath); + } +#endif } @@ -225,6 +252,16 @@ void CSound::importForm(const std::string& filename, NLGEORGES::UFormElm& roo default: _Priority = MidPri; } + + nlassert(CGroupControllerRoot::getInstance()); // not sure +#if NLSOUND_SHEET_VERSION_BUILT < 2 + _GroupController = CGroupControllerRoot::getInstance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER); +#else + std::string groupControllerPath; + root.getValueByName(groupControllerPath, ".GroupControllerPath"); + _GroupController = CGroupControllerRoot::getInstance()->getGroupController(groupControllerPath); +#endif + } diff --git a/code/nel/src/sound/sound_bank.cpp b/code/nel/src/sound/sound_bank.cpp index b4031b571..dd2076a72 100644 --- a/code/nel/src/sound/sound_bank.cpp +++ b/code/nel/src/sound/sound_bank.cpp @@ -23,6 +23,7 @@ #include "nel/sound/background_sound.h" #include "nel/sound/music_sound.h" #include "nel/sound/stream_sound.h" +#include "nel/sound/stream_file_sound.h" #include "nel/georges/u_form_loader.h" #include "nel/georges/u_form_elm.h" @@ -194,6 +195,9 @@ public: case CSound::SOUND_STREAM: Sound = new CStreamSound(); break; + case CSound::SOUND_STREAM_FILE: + Sound = new CStreamFileSound(); + break; default: Sound = 0; } diff --git a/code/nel/src/sound/source_common.cpp b/code/nel/src/sound/source_common.cpp index ce2b7e210..7b27deb03 100644 --- a/code/nel/src/sound/source_common.cpp +++ b/code/nel/src/sound/source_common.cpp @@ -25,7 +25,7 @@ using namespace NLMISC; namespace NLSOUND { -CSourceCommon::CSourceCommon(TSoundId id, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster) +CSourceCommon::CSourceCommon(TSoundId id, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster, CGroupController *groupController) : _Priority(MidPri), _Playing(false), _Looping(false), @@ -41,9 +41,11 @@ CSourceCommon::CSourceCommon(TSoundId id, bool spawn, TSpawnEndCallback cb, void _SpawnEndCb(cb), _CbUserParam(cbUserParam), _Cluster(cluster), - _UserVarControler(id->getUserVarControler()) + _UserVarControler(id->getUserVarControler()), + _GroupController(groupController ? groupController : id->getGroupController()) { CAudioMixerUser::instance()->addSource(this); + _GroupController->addSource(this); // get a local copy of the sound parameter _InitialGain = _Gain = id->getGain(); @@ -51,11 +53,11 @@ CSourceCommon::CSourceCommon(TSoundId id, bool spawn, TSpawnEndCallback cb, void _Looping = id->getLooping(); _Priority = id->getPriority(); _Direction = id->getDirectionVector(); - } CSourceCommon::~CSourceCommon() { + _GroupController->removeSource(this); CAudioMixerUser::instance()->removeSource(this); } @@ -177,6 +179,7 @@ void CSourceCommon::setGain( float gain ) { clamp(gain, 0.0f, 1.0f); _InitialGain = _Gain = gain; + updateFinalGain(); } /* Set the gain amount (value inside [0, 1]) to map between 0 and the nominal gain @@ -185,8 +188,8 @@ void CSourceCommon::setGain( float gain ) void CSourceCommon::setRelativeGain( float gain ) { clamp(gain, 0.0f, 1.0f); - _Gain = _InitialGain * gain; + updateFinalGain(); } /* diff --git a/code/nel/src/sound/source_music_channel.cpp b/code/nel/src/sound/source_music_channel.cpp new file mode 100644 index 000000000..34735f113 --- /dev/null +++ b/code/nel/src/sound/source_music_channel.cpp @@ -0,0 +1,140 @@ +/** + * \file source_music_channel.cpp + * \brief CSourceMusicChannel + * \date 2012-04-11 16:08GMT + * \author Jan Boon (Kaetemi) + * CSourceMusicChannel + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#include "stdsound.h" +#include + +// STL includes + +// NeL includes +// #include +#include + +// Project includes + +using namespace std; +// using namespace NLMISC; + +namespace NLSOUND { + +CSourceMusicChannel::CSourceMusicChannel() : m_Source(NULL), m_Gain(1.0f) +{ + +} + +CSourceMusicChannel::~CSourceMusicChannel() +{ + nlassert(!m_Source); + delete m_Source; + m_Source = NULL; +} + +bool CSourceMusicChannel::play(const std::string &filepath, bool async, bool loop) +{ + // delete previous source if any + // note that this waits for the source's thread to finish if the source was still playing + if (m_Source) + delete m_Source; + + m_Sound.setMusicFilePath(filepath, async, loop); + + m_Source = new CStreamFileSource(&m_Sound, false, NULL, NULL, NULL, NULL); + m_Source->setSourceRelativeMode(true); + m_Source->setPos(NLMISC::CVector::Null); + m_Source->setRelativeGain(m_Gain); + + m_Source->play(); + + return m_Source->isPlaying(); +} + +void CSourceMusicChannel::stop() +{ + // stop but don't delete the source, deleting source may cause waiting for thread + if (m_Source) + m_Source->stop(); +} + +void CSourceMusicChannel::reset() +{ + // forces the source to be deleted, happens when audio mixer is reset + delete m_Source; + m_Source = NULL; +} + +void CSourceMusicChannel::pause() +{ + if (m_Source) + m_Source->pause(); +} + +void CSourceMusicChannel::resume() +{ + if (m_Source) + m_Source->resume(); +} + +bool CSourceMusicChannel::isEnded() +{ + if (m_Source) + { + if (m_Source->isEnded()) + { + // we can delete the source now without worrying about thread wait + delete m_Source; + m_Source = NULL; + return true; + } + return false; + } + return true; +} + +bool CSourceMusicChannel::isLoadingAsync() +{ + if (m_Source) + return m_Source->isLoadingAsync(); + return false; +} + +float CSourceMusicChannel::getLength() +{ + if (m_Source) + return m_Source->getLength(); + return 0.0f; +} + +void CSourceMusicChannel::setVolume(float gain) +{ + m_Gain = gain; + if (m_Source) + m_Source->setRelativeGain(gain); +} + +} /* namespace NLSOUND */ + +/* end of file */ diff --git a/code/nel/src/sound/stream_file_sound.cpp b/code/nel/src/sound/stream_file_sound.cpp new file mode 100644 index 000000000..44da5a31d --- /dev/null +++ b/code/nel/src/sound/stream_file_sound.cpp @@ -0,0 +1,98 @@ +/** + * \file stream_file_sound.cpp + * \brief CStreamFileSound + * \date 2012-04-11 09:57GMT + * \author Jan Boon (Kaetemi) + * CStreamFileSound + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#include "stdsound.h" +#include + +// STL includes + +// NeL includes +// #include +#include + +// Project includes + +using namespace std; +// using namespace NLMISC; + +namespace NLSOUND { + +CStreamFileSound::CStreamFileSound() +{ + +} + +CStreamFileSound::~CStreamFileSound() +{ + +} + +void CStreamFileSound::importForm(const std::string &filename, NLGEORGES::UFormElm &root) +{ + // Call the base class + CStreamSound::importForm(filename, root); + + // Async + root.getValueByName(m_Async, ".SoundType.Async"); + + // FilePath + root.getValueByName(m_FilePath, ".SoundType.FilePath"); +} + +void CStreamFileSound::serial(NLMISC::IStream &s) +{ + CStreamSound::serial(s); + + s.serial(m_Async); + s.serial(m_FilePath); +} + +void CStreamFileSound::setMusicFilePath(const std::string &filePath, bool async, bool loop) +{ +#if !FINAL_VERSION + _Name = NLMISC::CStringMapper::map(std::string(""); +#else + _Name = NLMISC::CStringMapper::map(""); +#endif + _ConeInnerAngle = NLMISC::Pi * 2; + _ConeOuterAngle = NLMISC::Pi * 2; + _Looping = loop; + _Gain = 1.0f; + _ConeOuterGain = 1.0f; + _Direction = NLMISC::CVector(0.f, 0.f, 0.f); + _Pitch = 1.0f; + _Priority = HighestPri; + _MaxDist = 9000.0f; + _MinDist = 1000.0f; + m_Async = async; + m_FilePath = filePath; + _GroupController = CGroupControllerRoot::getInstance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_MUSIC_GROUP_CONTROLLER); +} + +} /* namespace NLSOUND */ + +/* end of file */ diff --git a/code/nel/src/sound/stream_file_source.cpp b/code/nel/src/sound/stream_file_source.cpp new file mode 100644 index 000000000..87164a9cd --- /dev/null +++ b/code/nel/src/sound/stream_file_source.cpp @@ -0,0 +1,384 @@ +/** + * \file stream_file_source.cpp + * \brief CStreamFileSource + * \date 2012-04-11 09:57GMT + * \author Jan Boon (Kaetemi) + * CStreamFileSource + */ + +/* + * Copyright (C) 2012 by authors + * + * This file is part of RYZOM CORE. + * RYZOM CORE is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * RYZOM CORE is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with RYZOM CORE. If not, see + * . + */ + +#include "stdsound.h" +#include + +// STL includes + +// NeL includes +// #include + +// Project includes +#include +#include + +using namespace std; +// using namespace NLMISC; + +// #define NLSOUND_STREAM_FILE_DEBUG + +namespace NLSOUND { + +CStreamFileSource::CStreamFileSource(CStreamFileSound *streamFileSound, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster, CGroupController *groupController) +: CStreamSource(streamFileSound, spawn, cb, cbUserParam, cluster, groupController), m_AudioDecoder(NULL), m_Paused(false) +{ + m_Thread = NLMISC::IThread::create(this); +} + +CStreamFileSource::~CStreamFileSource() +{ + stop(); + m_Thread->wait(); // thread must have stopped for delete! + delete m_Thread; + m_Thread = NULL; + delete m_AudioDecoder; + m_AudioDecoder = NULL; +} + +void CStreamFileSource::play() +{ + // note: CStreamSource will assert crash if already physically playing! + + + if (m_WaitingForPlay) + { + if (m_Thread->isRunning()) + { + if (m_NextBuffer || !m_FreeBuffers) + { +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("play waiting, play stream %s", getStreamFileSound()->getFilePath().c_str()); +#endif + CStreamSource::play(); + if (!_Playing && !m_WaitingForPlay) + { + nldebug("Stream file source playback not possible or necessary for some reason"); + } + } + else + { +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("play waiting, hop onto waiting list %s", getStreamFileSound()->getFilePath().c_str()); +#endif + m_WaitingForPlay = true; + CAudioMixerUser *mixer = CAudioMixerUser::instance(); + mixer->addSourceWaitingForPlay(this); + } + } + else + { + // thread went kaboom while not started playing yet, probably the audiodecoder cannot be started + // don't play + m_WaitingForPlay = false; + } + } + else if (!_Playing) + { +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("play go %s", getStreamFileSound()->getFilePath().c_str()); +#endif + //if (!m_WaitingForPlay) + //{ + // thread may be stopping from stop call + m_Thread->wait(); + //} + //else + //{ + // nlwarning("Already waiting for play"); + //} + if (!getStreamFileSound()->getAsync()) + { + if (!prepareDecoder()) + { + return; + } + } + // else load audiodecoder in thread + m_WaitingForPlay = true; + m_Thread->start(); + m_Thread->setPriority(NLMISC::ThreadPriorityHighest); + if (!getStreamFileSound()->getAsync()) + { + // wait until at least one buffer is ready + while (!(m_NextBuffer || !m_FreeBuffers) && m_WaitingForPlay && m_Thread->isRunning()) + { +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("wait buffer"); +#endif + NLMISC::nlSleep(100); + } + if (m_WaitingForPlay && m_Thread->isRunning()) + { + CStreamSource::play(); + if (!_Playing) + { + nlwarning("Failed to synchronously start playing a file stream source. This happens when all physical tracks are in use. Use a Highest Priority sound"); + } + } + } + else + { + CAudioMixerUser *mixer = CAudioMixerUser::instance(); + mixer->addSourceWaitingForPlay(this); + } + } + else + { + nlwarning("Already playing"); + } + + + /*if (!m_WaitingForPlay) + { + m_WaitingForPlay = true; + + m_Thread->wait(); // thread must have stopped to restart it! + + m_Thread->start(); + m_Thread->setPriority(NLMISC::ThreadPriorityHighest); + } + + CStreamSource::play();*/ +} + +void CStreamFileSource::stop() +{ +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("stop %s", getStreamFileSound()->getFilePath().c_str()); +#endif + + CStreamSource::stopInt(); + +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("stopInt ok"); +#endif + + if (_Spawn) + { + if (_SpawnEndCb != NULL) + _SpawnEndCb(this, _CbUserParam); + m_Thread->wait(); + delete this; + } + +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("stop ok"); +#endif + + // thread will check _Playing to stop +} + +bool CStreamFileSource::isPlaying() +{ +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("isPlaying"); +#endif + + return m_Thread->isRunning(); +} + +void CStreamFileSource::pause() +{ +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("pause"); +#endif + + if (!m_Paused) + { + // thread checks for this to not delete the audio decoder + m_Paused = true; + + // stop the underlying system + CStreamSource::stop(); + + // thread will check _Playing to stop + } + else + { + nlwarning("Already paused"); + } +} + +void CStreamFileSource::resume() +{ +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("resume"); +#endif + + if (m_Paused) + { + m_Thread->wait(); // thread must have stopped to restart it! + + play(); + } + else + { + nlwarning("Not paused"); + } +} + +bool CStreamFileSource::isEnded() +{ + return (!m_Thread->isRunning() && !_Playing && !m_WaitingForPlay && !m_Paused); +} + +float CStreamFileSource::getLength() +{ + return m_AudioDecoder->getLength(); +} + +bool CStreamFileSource::isLoadingAsync() +{ + return m_WaitingForPlay; +} + +bool CStreamFileSource::prepareDecoder() +{ + // creates a new decoder or keeps going with the current decoder if the stream was paused + + if (m_Paused) + { + // handle paused! + m_Paused = false; + } + else if (m_AudioDecoder) // audio decoder should normally not exist when not paused and starting the thread + { + nlwarning("CAudioDecoder already exists, possible thread race bug with pause"); + delete m_AudioDecoder; + m_AudioDecoder = NULL; + } + if (!m_AudioDecoder) + { + // load the file + m_AudioDecoder = IAudioDecoder::createAudioDecoder(getStreamFileSound()->getFilePath(), getStreamFileSound()->getAsync(), getStreamFileSound()->getLooping()); + if (!m_AudioDecoder) + { + nlwarning("Failed to create IAudioDecoder, likely invalid format"); + return false; + } + this->setFormat(m_AudioDecoder->getChannels(), m_AudioDecoder->getBitsPerSample(), (uint32)m_AudioDecoder->getSamplesPerSec()); + } + uint samples, bytes; + this->getRecommendedBufferSize(samples, bytes); + this->preAllocate(bytes * 2); + + return true; +} + +inline bool CStreamFileSource::bufferMore(uint bytes) // buffer from bytes (minimum) to bytes * 2 (maximum) +{ + uint8 *buffer = this->lock(bytes * 2); + if (buffer) + { + uint32 result = m_AudioDecoder->getNextBytes(buffer, bytes, bytes * 2); + this->unlock(result); + return true; + } + return false; +} + +void CStreamFileSource::run() +{ +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("run %s", getStreamFileSound()->getFilePath().c_str()); + uint dumpI = 0; +#endif + + bool looping = _Looping; + if (getStreamFileSound()->getAsync()) + { + if (!prepareDecoder()) + return; + } + uint samples, bytes; + this->getRecommendedBufferSize(samples, bytes); + uint32 recSleep = 40; + uint32 doSleep = 10; + while (_Playing || m_WaitingForPlay) + { + if (!m_AudioDecoder->isMusicEnded()) + { +#ifdef NLSOUND_STREAM_FILE_DEBUG + ++dumpI; + if (!(dumpI % 100)) + { + nldebug("buffer %s %s %s", _Playing ? "PLAYING" : "NP", m_WaitingForPlay ? "WAITING" : "NW", getStreamFileSound()->getFilePath().c_str()); + nldebug("gain %f", hasPhysicalSource() ? getPhysicalSource()->getGain() : -1.0f); + } +#endif + + bool newLooping = _Looping; + if (looping != newLooping) + { + m_AudioDecoder->setLooping(looping); + looping = newLooping; + } + + // reduce sleeping time if nothing was buffered + if (bufferMore(bytes)) recSleep = doSleep = this->getRecommendedSleepTime(); + else doSleep = recSleep >> 2; // /4 + NLMISC::nlSleep(doSleep); + } + else + { + // wait until done playing buffers + while (this->hasFilledBuffersAvailable() && (_Playing || m_WaitingForPlay)) + { +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("music ended, wait until done %s", getStreamFileSound()->getFilePath().c_str()); +#endif + NLMISC::nlSleep(40); + } + // stop the physical source + // if (hasPhysicalSource()) + // getPhysicalSource()->stop(); + // the audio mixer will call stop on the logical source + break; + } + } + if (m_Paused) + { + // don't delete anything + } + else + { + delete m_AudioDecoder; + m_AudioDecoder = NULL; + } + // drop buffers + m_FreeBuffers = 3; + m_NextBuffer = 0; + +#ifdef NLSOUND_STREAM_FILE_DEBUG + nldebug("run end %s", getStreamFileSound()->getFilePath().c_str()); +#endif +} + +} /* namespace NLSOUND */ + +/* end of file */ diff --git a/code/nel/src/sound/stream_sound.cpp b/code/nel/src/sound/stream_sound.cpp index 347fae987..e16158d4d 100644 --- a/code/nel/src/sound/stream_sound.cpp +++ b/code/nel/src/sound/stream_sound.cpp @@ -17,6 +17,10 @@ #include "stdsound.h" #include "nel/sound/stream_sound.h" +#if NLSOUND_SHEET_VERSION_BUILT < 2 +# include "nel/sound/group_controller_root.h" +#endif + namespace NLSOUND { CStreamSound::CStreamSound() @@ -31,14 +35,15 @@ CStreamSound::~CStreamSound() void CStreamSound::importForm(const std::string &filename, NLGEORGES::UFormElm &root) { - NLGEORGES::UFormElm *psoundType; + // cannot do this debug check because used also by CStreamFileSound + /*NLGEORGES::UFormElm *psoundType; std::string dfnName; // some basic checking. root.getNodeByName(&psoundType, ".SoundType"); nlassert(psoundType != NULL); psoundType->getDfnName(dfnName); - nlassert(dfnName == "stream_sound.dfn"); + nlassert(dfnName == "stream_sound.dfn");*/ // Call the base class CSound::importForm(filename, root); @@ -51,6 +56,11 @@ void CStreamSound::importForm(const std::string &filename, NLGEORGES::UFormElm & // Alpha root.getValueByName(m_Alpha, ".SoundType.Alpha"); + +#if NLSOUND_SHEET_VERSION_BUILT < 2 + _GroupController = CGroupControllerRoot::getInstance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_STREAM_GROUP_CONTROLLER); +#endif + } void CStreamSound::serial(NLMISC::IStream &s) @@ -59,6 +69,11 @@ void CStreamSound::serial(NLMISC::IStream &s) s.serial(_MinDist); s.serial(m_Alpha); + +#if NLSOUND_SHEET_VERSION_BUILT < 2 + if (s.isReading()) _GroupController = CGroupControllerRoot::getInstance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_STREAM_GROUP_CONTROLLER); +#endif + } } /* namespace NLSOUND */ diff --git a/code/nel/src/sound/stream_source.cpp b/code/nel/src/sound/stream_source.cpp index a5b167c8f..221b0529e 100644 --- a/code/nel/src/sound/stream_source.cpp +++ b/code/nel/src/sound/stream_source.cpp @@ -26,29 +26,37 @@ // using namespace std; using namespace NLMISC; +// #define NLSOUND_DEBUG_STREAM + namespace NLSOUND { -CStreamSource::CStreamSource(CStreamSound *streamSound, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster) - : CSourceCommon(streamSound, spawn, cb, cbUserParam, cluster), +CStreamSource::CStreamSource(CStreamSound *streamSound, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster, CGroupController *groupController) + : CSourceCommon(streamSound, spawn, cb, cbUserParam, cluster, groupController), m_StreamSound(streamSound), m_Alpha(0.0f), m_Track(NULL), m_FreeBuffers(3), m_NextBuffer(0), m_LastSize(0), - m_BytesPerSecond(0) + m_BytesPerSecond(0), + m_WaitingForPlay(false), + m_PitchInv(1.0f) { nlassert(m_StreamSound != 0); // get a local copy of the stream sound parameter m_Alpha = m_StreamSound->getAlpha();//m_Buffers + m_PitchInv = 1.0f / _Pitch; // create the three buffer objects CAudioMixerUser *mixer = CAudioMixerUser::instance(); ISoundDriver *driver = mixer->getSoundDriver(); m_Buffers[0] = driver->createBuffer(); + m_Buffers[0]->setStorageMode(IBuffer::StorageSoftware); m_Buffers[1] = driver->createBuffer(); + m_Buffers[1]->setStorageMode(IBuffer::StorageSoftware); m_Buffers[2] = driver->createBuffer(); + m_Buffers[2]->setStorageMode(IBuffer::StorageSoftware); } CStreamSource::~CStreamSource() @@ -107,6 +115,8 @@ bool CStreamSource::isPlaying() /// Set looping on/off for future playbacks (default: off) void CStreamSource::setLooping(bool l) { + CSourceCommon::setLooping(l); + //CAutoMutex autoMutex(m_BufferMutex); // //CSourceCommon::setLooping(l); @@ -146,13 +156,16 @@ void CStreamSource::play() if ((_RelativeMode ? getPos().sqrnorm() : (mixer->getListenPosVector() - getPos()).sqrnorm()) > m_StreamSound->getMaxDistance() * m_StreamSound->getMaxDistance()) { // Source is too far to play + m_WaitingForPlay = false; if (_Spawn) { if (_SpawnEndCb != NULL) _SpawnEndCb(this, _CbUserParam); delete this; } - // nldebug("CStreamSource %p : play FAILED !", (CAudioMixerUser::IMixerEvent*)this); +#ifdef NLSOUND_DEBUG_STREAM + nldebug("CStreamSource %p : play FAILED, source is too far away !", (CAudioMixerUser::IMixerEvent*)this); +#endif return; } @@ -166,24 +179,33 @@ void CStreamSource::play() ISource *pSource = getPhysicalSource(); nlassert(pSource != NULL); - for (uint i = 0; i < m_NextBuffer; ++i) + uint nbS = m_NextBuffer; + if (!m_NextBuffer && !m_FreeBuffers) nbS = 3; + for (uint i = 0; i < nbS; ++i) pSource->submitStreamingBuffer(m_Buffers[i]); // pSource->setPos( _Position, false); pSource->setPos(getVirtualPos(), false); + pSource->setMinMaxDistances(m_StreamSound->getMinDistance(), m_StreamSound->getMaxDistance(), false); if (!m_Buffers[0]->isStereo()) { - pSource->setMinMaxDistances(m_StreamSound->getMinDistance(), m_StreamSound->getMaxDistance(), false); setDirection(_Direction); // because there is a workaround inside pSource->setVelocity(_Velocity); } - pSource->setGain(_Gain); + else + { + pSource->setDirection(NLMISC::CVector::I); + pSource->setCone(float(Pi * 2), float(Pi * 2), 1.0f); + pSource->setVelocity(NLMISC::CVector::Null); + } + pSource->setGain(getFinalGain()); pSource->setSourceRelativeMode(_RelativeMode); // pSource->setLooping(_Looping); pSource->setPitch(_Pitch); pSource->setAlpha(m_Alpha); // and play the sound + nlassert(nbS); // must have buffered already! play = pSource->play(); // nldebug("CStreamSource %p : REAL play done", (CAudioMixerUser::IMixerEvent*)this); } @@ -193,11 +215,13 @@ void CStreamSource::play() { // This sound is not discardable, add it in waiting playlist mixer->addSourceWaitingForPlay(this); + m_WaitingForPlay = true; return; } else { // No source available, kill. + m_WaitingForPlay = false; if (_Spawn) { if (_SpawnEndCb != NULL) @@ -209,22 +233,67 @@ void CStreamSource::play() } if (play) + { CSourceCommon::play(); + m_WaitingForPlay = false; +#ifdef NLSOUND_DEBUG_STREAM + // Dump source info + nlwarning("--- DUMP SOURCE INFO ---"); + nlwarning(" * getLooping: %s", getPhysicalSource()->getLooping() ? "YES" : "NO"); + nlwarning(" * isPlaying: %s", getPhysicalSource()->isPlaying() ? "YES" : "NO"); + nlwarning(" * isStopped: %s", getPhysicalSource()->isStopped() ? "YES" : "NO"); + nlwarning(" * isPaused: %s", getPhysicalSource()->isPaused() ? "YES" : "NO"); + nlwarning(" * getPos: %f, %f, %f", getPhysicalSource()->getPos().x, getPhysicalSource()->getPos().y, getPhysicalSource()->getPos().z); + NLMISC::CVector v; + getPhysicalSource()->getVelocity(v); + nlwarning(" * getVelocity: %f, %f, %f", v.x, v.y, v.z); + getPhysicalSource()->getDirection(v); + nlwarning(" * getDirection: %f, %f, %f", v.x, v.y, v.z); + nlwarning(" * getGain: %f", getPhysicalSource()->getGain()); + nlwarning(" * getPitch: %f", getPhysicalSource()->getPitch()); + nlwarning(" * getSourceRelativeMode: %s", getPhysicalSource()->getSourceRelativeMode() ? "YES" : "NO"); + float a, b, c; + getPhysicalSource()->getMinMaxDistances(a, b); + nlwarning(" * getMinMaxDistances: %f, %f", a, b); + getPhysicalSource()->getCone(a, b, c); + nlwarning(" * getCone: %f, %f", a, b, c); + nlwarning(" * getDirect: %s", getPhysicalSource()->getDirect() ? "YES" : "NO"); + nlwarning(" * getDirectGain: %f", getPhysicalSource()->getDirectGain()); + nlwarning(" * isDirectFilterEnabled: %s", getPhysicalSource()->isDirectFilterEnabled() ? "YES" : "NO"); + nlwarning(" * getEffect: %s", getPhysicalSource()->getEffect() ? "YES" : "NO"); + nlwarning(" * getEffectGain: %f", getPhysicalSource()->getEffectGain()); + nlwarning(" * isEffectFilterEnabled: %s", getPhysicalSource()->isEffectFilterEnabled() ? "YES" : "NO"); +#endif + } } +#ifdef NL_DEBUG nlassert(play); +#else + if (!play) + nlwarning("Failed to play physical sound source. This is a serious error"); +#endif } -/// Stop playing -void CStreamSource::stop() +void CStreamSource::stopInt() { CAutoMutex autoMutex(m_BufferMutex); // nldebug("CStreamSource %p : stop", (CAudioMixerUser::IMixerEvent*)this); // nlassert(_Playing); + + if (m_WaitingForPlay) + { + nlassert(!_Playing); // cannot already be playing if waiting for play + CAudioMixerUser *mixer = CAudioMixerUser::instance(); + mixer->removeSourceWaitingForPlay(this); + } if (!_Playing) + { + m_WaitingForPlay = false; return; + } if (hasPhysicalSource()) releasePhysicalSource(); @@ -234,6 +303,14 @@ void CStreamSource::stop() m_FreeBuffers = 3; m_NextBuffer = 0; + m_WaitingForPlay = false; +} + +/// Stop playing +void CStreamSource::stop() +{ + stopInt(); + if (_Spawn) { if (_SpawnEndCb != NULL) @@ -294,28 +371,18 @@ void CStreamSource::setDirection(const NLMISC::CVector& dir) } } -void CStreamSource::setGain(float gain) +void CStreamSource::updateFinalGain() { CAutoMutex autoMutex(m_BufferMutex); - - CSourceCommon::setGain(gain); + if (hasPhysicalSource()) - getPhysicalSource()->setGain(gain); -} - -void CStreamSource::setRelativeGain(float gain) -{ - CAutoMutex autoMutex(m_BufferMutex); - - CSourceCommon::setRelativeGain(gain); - if (hasPhysicalSource()) - getPhysicalSource()->setGain(_Gain); + getPhysicalSource()->setGain(getFinalGain()); } void CStreamSource::setPitch(float pitch) { CAutoMutex autoMutex(m_BufferMutex); - + m_PitchInv = 1.0f / pitch; CSourceCommon::setPitch(pitch); if (hasPhysicalSource()) getPhysicalSource()->setPitch(pitch); @@ -382,7 +449,9 @@ bool CStreamSource::unlock(uint size) ++m_NextBuffer; m_NextBuffer %= 3; --m_FreeBuffers; if (hasPhysicalSource()) + { getPhysicalSource()->submitStreamingBuffer(buffer); + } m_LastSize = size; } @@ -406,8 +475,8 @@ void CStreamSource::getRecommendedBufferSize(uint &samples, uint &bytes) const uint32 CStreamSource::getRecommendedSleepTime() const { if (m_FreeBuffers > 0) return 0; - uint32 sleepTime = (uint32)((1000.0f * ((float)m_LastSize) / (float)m_BytesPerSecond) / _Pitch); - clamp(sleepTime, (uint32)0, (uint32)1000); + uint32 sleepTime = (uint32)((1000.0f * ((float)m_LastSize) / (float)m_BytesPerSecond) * m_PitchInv); + clamp(sleepTime, (uint32)0, (uint32)80); return sleepTime; } @@ -418,6 +487,19 @@ bool CStreamSource::hasFilledBuffersAvailable() const return m_FreeBuffers < 3; } +void CStreamSource::preAllocate(uint capacity) +{ + uint8 *b0 = m_Buffers[0]->lock(capacity); + memset(b0, 0, capacity); + m_Buffers[0]->unlock(capacity); + uint8 *b1 = m_Buffers[1]->lock(capacity); + memset(b1, 0, capacity); + m_Buffers[1]->unlock(capacity); + uint8 *b2 = m_Buffers[2]->lock(capacity); + memset(b2, 0, capacity); + m_Buffers[2]->unlock(capacity); +} + } /* namespace NLSOUND */ /* end of file */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/bnp_manager/bnp_file.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/bnp_manager/bnp_file.h index 7527b5dbd..7695ebc2f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/bnp_manager/bnp_file.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/bnp_manager/bnp_file.h @@ -74,7 +74,7 @@ public: * Append the header to a created bnp file * \param filename (consisting the whole path) */ - void appendHeader (const std::string &filename) {}; + void appendHeader (const std::string &filename) {} /** * Create a vector of all packed files inside the bnp file diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp index 416a418f1..df909f31a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/mission_compiler/mission_compiler_main_window.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -81,7 +81,7 @@ MissionCompilerMainWindow::MissionCompilerMainWindow(QWidget *parent) : connect(Core::ICore::instance(), SIGNAL(changeSettings()), this, SLOT(handleChangedSettings())); // Set the default data dir to the primitives path. - QSettings *settings = Core::ICore::instance()->settings(); + QSettings *settings = Core::ICore::instance()->settings(); settings->beginGroup(Core::Constants::DATA_PATH_SECTION); m_lastDir = settings->value(Core::Constants::PRIMITIVES_PATH).toString(); ui->dataDirEdit->setText(m_lastDir); @@ -381,7 +381,7 @@ bool MissionCompilerMainWindow::parsePrimForMissions(NLLIGO::IPrimitive const *p { std::string value; // if the node is a mission parse it - if (prim->getPropertyByName("class",value) && !stricmp(value.c_str(),"mission") ) + if (prim->getPropertyByName("class",value) && !NLMISC::stricmp(value.c_str(),"mission") ) { std::string name; prim->getPropertyByName("name",name); @@ -460,20 +460,20 @@ void MissionCompilerMainWindow::loadConfig() { } void MissionCompilerMainWindow::saveConfig() { - QSettings *settings = Core::ICore::instance()->settings(); - settings->beginGroup(MISSION_COMPILER_SECTION); - + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(MISSION_COMPILER_SECTION); + QStringList servers; for(int row = 0; row < ui->publishServersList->count(); row++) { QListWidgetItem *item = ui->publishServersList->item(row); if(item->checkState() == Qt::Checked) servers << item->text(); - } - - settings->setValue(SETTING_PUBLISH_SERVER_CHECKS, servers); - - settings->endGroup(); + } + + settings->setValue(SETTING_PUBLISH_SERVER_CHECKS, servers); + + settings->endGroup(); settings->sync(); } diff --git a/code/nel/tools/3d/tile_edit_qt/tile_listwidgetitem.h b/code/nel/tools/3d/tile_edit_qt/tile_listwidgetitem.h index b12be6437..4cf6ee1ae 100644 --- a/code/nel/tools/3d/tile_edit_qt/tile_listwidgetitem.h +++ b/code/nel/tools/3d/tile_edit_qt/tile_listwidgetitem.h @@ -21,17 +21,17 @@ #include "ui_tile_widget_qt.h" class CTile_ListWidgetItem : public QListWidgetItem - { - public: - CTile_ListWidgetItem ( QListWidget * parent, int type = Type ):QListWidgetItem(parent,type){}; +{ +public: + CTile_ListWidgetItem ( QListWidget * parent, int type = Type ):QListWidgetItem(parent,type){} CTile_ListWidgetItem(QWidget *parent = 0); void initWidget(const QPixmap&, const QString&); - private: - Ui::TileWidget ui; +private: + Ui::TileWidget ui; // Qpixmap tilePixmap; // QString tileLabel; - }; +}; #endif \ No newline at end of file diff --git a/code/nel/tools/georges/georges2csv/georges2csv.cpp b/code/nel/tools/georges/georges2csv/georges2csv.cpp index e10d06bf5..da89cc9bc 100644 --- a/code/nel/tools/georges/georges2csv/georges2csv.cpp +++ b/code/nel/tools/georges/georges2csv/georges2csv.cpp @@ -289,7 +289,7 @@ void addQuotesRoundString (std::string &valueString) std::string hold=valueString; valueString.erase(); valueString='\"'; - for (unsigned i=0;i_DownloadThreadPriority) { diff --git a/code/ryzom/client/src/cdb.h b/code/ryzom/client/src/cdb.h index 24c2dd5eb..f8ad3148a 100644 --- a/code/ryzom/client/src/cdb.h +++ b/code/ryzom/client/src/cdb.h @@ -302,10 +302,10 @@ public : virtual CCDBNodeLeaf *findLeafAtCount( uint& count ) = 0; /// Set the atomic branch flag (when all the modified nodes of a branch should be tranmitted at the same time) - void setAtomic( bool atomicBranch ) { _Atomic = atomicBranch; } + void setAtomic( bool atomicBranch ) { _AtomicFlag = atomicBranch; } /// Return true if the branch has the atomic flag - bool isAtomic() const { return _Atomic; } + bool isAtomic() const { return _AtomicFlag; } // test if the node is a leaf virtual bool isLeaf() const = 0; @@ -333,14 +333,14 @@ public : protected: /// Constructor - ICDBNode() : _Atomic(false) + ICDBNode() : _AtomicFlag(false) { if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper(); _Name = NLMISC::CStringMapper::emptyId(); } /// Constructor - ICDBNode (const std::string &name) : _Atomic(false) + ICDBNode (const std::string &name) : _AtomicFlag(false) { if (_DBSM == NULL) _DBSM = NLMISC::CStringMapper::createLocalMapper(); _Name = _DBSM->localMap(name); @@ -351,7 +351,7 @@ protected: void _buildFullName(NLMISC::CSString &fullName); /// Atomic flag: is the branch an atomic group, or is the leaf a member of an atomic group - bool _Atomic : 1; + bool _AtomicFlag : 1; /// Name of the node NLMISC::TStringId _Name; diff --git a/code/ryzom/client/src/ground_fx_manager.cpp b/code/ryzom/client/src/ground_fx_manager.cpp index 92267dd2a..2d3ce3810 100644 --- a/code/ryzom/client/src/ground_fx_manager.cpp +++ b/code/ryzom/client/src/ground_fx_manager.cpp @@ -64,7 +64,7 @@ CGroundFXManager::CGroundFXManager() : _MinSpeed(1.5f), _MaxSpeed(6.f), _SpeedWaterWalkFast(3.f), - _SpeedWaterSwimFast(3.f), + _SpeedWaterSwimFast(2.f), _MaxDist(50.f), _MaxNumFX(10), _NumFX(0), @@ -495,7 +495,7 @@ void CGroundFXManager::update(const NLMISC::CVectorD &camPos) break; case CInstance::Swim: if (speed == 0.f) fxName = "StepSwimIdle.ps"; - else if (speed > _SpeedWaterWalkFast) + else if (speed > _SpeedWaterSwimFast) { fxName = "StepSwimSpeed.ps"; fxNameUnderWater = "StepSwimSpeedUnderWater.ps"; diff --git a/code/ryzom/client/src/interface_v3/chat_filter.h b/code/ryzom/client/src/interface_v3/chat_filter.h index 7524d6c7f..d717d9fb5 100644 --- a/code/ryzom/client/src/interface_v3/chat_filter.h +++ b/code/ryzom/client/src/interface_v3/chat_filter.h @@ -37,7 +37,7 @@ class CChatInputFilter : public NLMISC::CRefCount, public CChatWindow::IObserver { public: CChatInputFilter() {FilterType= CChatGroup::say; DynamicChatDbIndex= 0;} - ~CChatInputFilter(); + virtual ~CChatInputFilter(); /** Display a msg in the chat. The msg will be forwarded to all the listening windows * Listening windows will blick only if there isnt a single visible listening window, so that the player can know if there's a message * \param windowVisible is not NULL, points a bool that will be filled with true if one of the window on the which the msg was displayed is visible. diff --git a/code/ryzom/client/src/interface_v3/interface_element.h b/code/ryzom/client/src/interface_v3/interface_element.h index 24982cad2..0202618ba 100644 --- a/code/ryzom/client/src/interface_v3/interface_element.h +++ b/code/ryzom/client/src/interface_v3/interface_element.h @@ -361,7 +361,7 @@ public: */ virtual void forceOpen() { setActive(true); } - virtual void enableBlink(int /* numBlinks */ = 0) {} + virtual void enableBlink(uint /* numBlinks */ = 0) {} virtual void disableBlink() {} virtual bool getBlink() const { return false; } diff --git a/code/ryzom/client/src/interfaces_manager/scroll_bar.h b/code/ryzom/client/src/interfaces_manager/scroll_bar.h index f9e42473a..5b2e248df 100644 --- a/code/ryzom/client/src/interfaces_manager/scroll_bar.h +++ b/code/ryzom/client/src/interfaces_manager/scroll_bar.h @@ -44,7 +44,7 @@ public: CScrollBar(uint id, float x, float y, float x_pixel, float y_pixel, float w, float h, float w_pixel, float h_pixel, bool vertical = true,CScrollableControl *ctrl = NULL); /// destructor - virtual ~CScrollBar() {}; + virtual ~CScrollBar() {} /// Display the control virtual void display(); diff --git a/code/ryzom/client/src/lua_ide_dll_nevrax/include/scintilla/Platform.h b/code/ryzom/client/src/lua_ide_dll_nevrax/include/scintilla/Platform.h index 5a07d109a..8a8d25ff0 100644 --- a/code/ryzom/client/src/lua_ide_dll_nevrax/include/scintilla/Platform.h +++ b/code/ryzom/client/src/lua_ide_dll_nevrax/include/scintilla/Platform.h @@ -277,8 +277,8 @@ private: Surface(const Surface &) {} Surface &operator=(const Surface &) { return *this; } public: - Surface() {}; - virtual ~Surface() {}; + Surface() {} + virtual ~Surface() {} static Surface *Allocate(); virtual void Init()=0; diff --git a/code/ryzom/client/src/r2/config_var.h b/code/ryzom/client/src/r2/config_var.h index 84c9f3891..674c38816 100644 --- a/code/ryzom/client/src/r2/config_var.h +++ b/code/ryzom/client/src/r2/config_var.h @@ -66,6 +66,22 @@ private: const T _Default; }; +// forward declarations for specialisations +std::string getConfigVarTypename(const float &dummy); +bool getConfigVarValue(CLuaObject &luaValue, float &dest); + +std::string getConfigVarTypename(const double &dummy); +bool getConfigVarValue(CLuaObject &luaValue, double &dest); + +std::string getConfigVarTypename(const sint32 &dummy); +bool getConfigVarValue(CLuaObject &luaValue, sint32 &dest); + +std::string getConfigVarTypename(const std::string &dummy); +bool getConfigVarValue(CLuaObject &luaValue, std::string &dest); + +std::string getConfigVarTypename(const NLMISC::CRGBA &dummy); +bool getConfigVarValue(CLuaObject &luaValue, NLMISC::CRGBA &dest); + template const T &CConfigVar::get() const { // Relies on R2 'getConfigVarValue' and 'getConfigVarTypename' functions specialization to retrieve the value (see below) diff --git a/code/ryzom/client/src/sound_manager.cpp b/code/ryzom/client/src/sound_manager.cpp index fb4b3708f..4d8827875 100644 --- a/code/ryzom/client/src/sound_manager.cpp +++ b/code/ryzom/client/src/sound_manager.cpp @@ -106,8 +106,11 @@ enum TFilterMapping // constructor //----------------------------------------------- CSoundManager::CSoundManager(IProgressCallback * /* progressCallBack */) -: _AudioMixer(NULL), - _EnvSoundRoot(NULL), +: _AudioMixer(NULL), + _GroupControllerEffects(NULL), + _GroupControllerEffectsGame(NULL), + _EnvSoundRoot(NULL), + _Sources(NULL), _UserEntitySoundLevel(1.0f) { _EnableBackgroundMusicAtTime= 0; @@ -137,9 +140,12 @@ CSoundManager::~CSoundManager() // detach the sound from the particule system NL3D::UParticleSystemSound::setPSSound(NULL); + _GroupControllerEffects = NULL; + _GroupControllerEffectsGame = NULL; + // free the audio mixer (and delete all sources) - if (_AudioMixer) - delete _AudioMixer; + delete _AudioMixer; + _AudioMixer = NULL; // release sound anim properly releaseSoundAnim(); @@ -403,6 +409,9 @@ void CSoundManager::reset () NL3D::UParticleSystemSound::setPSSound(NULL); + _GroupControllerEffects = NULL; + _GroupControllerEffectsGame = NULL; + delete _AudioMixer; _AudioMixer = NULL; @@ -421,7 +430,6 @@ void CSoundManager::reset () //--------------------------------------------------- void CSoundManager::init(IProgressCallback *progressCallBack) { - _NextId = 1; _EnvSoundRoot = NULL; _PlaySound = true; @@ -477,6 +485,10 @@ void CSoundManager::init(IProgressCallback *progressCallBack) */ new CSoundAnimManager(_AudioMixer); + // get the controller group for effects + _GroupControllerEffects = _AudioMixer->getGroupController("sound:effects"); + _GroupControllerEffectsGame = _AudioMixer->getGroupController("sound:effects:game"); + // restore the volume SoundMngr->setSFXVolume(ClientCfg.SoundSFXVolume); SoundMngr->setGameMusicVolume(ClientCfg.SoundGameMusicVolume); @@ -612,7 +624,7 @@ void CSoundManager::init(IProgressCallback *progressCallBack) // add a new source to the world, attached to the specified entity // return 0 if creation failed, sound id if creation was successful //----------------------------------------------- -uint32 CSoundManager::addSource( const NLMISC::TStringId &soundName, const NLMISC::CVector &position, bool play, bool loop, const CEntityId &id) +CSoundManager::TSourceId CSoundManager::addSource( const NLMISC::TStringId &soundName, const NLMISC::CVector &position, bool play, bool loop, const CEntityId &id) { uint32 retValue = 0; @@ -642,22 +654,16 @@ uint32 CSoundManager::addSource( const NLMISC::TStringId &soundName, const NLMIS pSource->play(); } + TSourceId sourceId = _Sources.insert(pSource); + // attach the source to the entity, if specified if (id != CEntityId::Unknown ) { - _AttachedSources.insert( TMultiMapEntityToSource::value_type( id, pSource ) ); + _AttachedSources.insert( TMultiMapEntityToSource::value_type( id, sourceId ) ); } - // set source id - retValue = _NextId; - - // add the new source - _Sources.insert( TMapIdToSource::value_type( _NextId, pSource ) ); - - ++_NextId; - // return the id of the source - return retValue; + return sourceId; } // addSource // @@ -726,26 +732,22 @@ bool CSoundManager::spawnSource(const NLMISC::TStringId &soundName, const NLMISC // removeSource: // remove a source //--------------------------------------------------- -void CSoundManager::removeSource( uint32 sourceId ) +void CSoundManager::removeSource(CSoundManager::TSourceId sourceId) { nldebug("remove the source : %d", sourceId); /// \todo Malkav : optimize speed nldebug("nb sources = %d", _Sources.size() ); - TMapIdToSource::iterator itS = _Sources.find( sourceId ); - if (itS != _Sources.end() ) + USource *pSource = _Sources.get(sourceId); + if (pSource) { - USource *pSource = (*itS).second; - if ( pSource == NULL ) - return; - TMultiMapEntityToSource::iterator it = _AttachedSources.begin();//, itOld; for ( ; it != _AttachedSources.end() ; ++it) { - if ( (*it).second == pSource ) + if ( (*it).second == sourceId ) { - (*it).second = NULL; + (*it).second = 0; // itOld = it; // ++it; @@ -759,8 +761,9 @@ nldebug("nb sources = %d", _Sources.size() ); } // delete the source -// _AudioMixer->removeSource (pSource); delete pSource; + // i think there was something going on here + _Sources.erase(sourceId); } } // removeSource // @@ -789,7 +792,7 @@ void CSoundManager::updateEntityPos( const CEntityId &id, const NLMISC::CVector for ( it = range.first; it != range.second ; ++it) { - (*it).second->setPos( pos ); + _Sources.get((*it).second)->setPos( pos ); } } // updateEntityPos // @@ -805,7 +808,7 @@ void CSoundManager::updateEntityVelocity( const CEntityId &id, const NLMISC::CVe for ( it = range.first; it != range.second ; ++it) { - (*it).second->setVelocity( velocity ); + _Sources.get((*it).second)->setVelocity( velocity ); } } // updateEntityVelocity // @@ -822,7 +825,7 @@ void CSoundManager::updateEntityDirection( const CEntityId &id, const NLMISC::CV for ( it = range.first; it != range.second ; ++it) { - (*it).second->setDirection( dir ); + _Sources.get((*it).second)->setDirection( dir ); } } // updateEntityOrientation // @@ -837,26 +840,15 @@ void CSoundManager::removeEntity( const CEntityId &id) TMultiMapEntityToSource::iterator it; const std::pair range = _AttachedSources.equal_range( id ); - - USource *pSource; + for ( it = range.first; it != range.second ; ++it) { - pSource = (*it).second; - if ( pSource != NULL) + TSourceId sourceId = (*it).second; + if (sourceId) { - TMapIdToSource::iterator itS = _Sources.begin();//, itOld; - - for ( ; itS != _Sources.end() ; ++itS) - { - if ( (*itS).second == pSource ) - { - (*itS).second = NULL; - _Sources.erase( itS ); - break; - } - } - // delete the source - delete (*it).second; + USource *pSource = _Sources.get(sourceId); + delete pSource; + _Sources.erase(sourceId); } } @@ -869,34 +861,24 @@ void CSoundManager::removeEntity( const CEntityId &id) //--------------------------------------------------- // setSoundPosition : //--------------------------------------------------- -void CSoundManager::setSoundPosition( uint32 soundId, const NLMISC::CVector &position) +void CSoundManager::setSoundPosition(TSourceId sourceId, const NLMISC::CVector &position) { if (!_PlaySound) return; - TMapIdToSource::iterator it = _Sources.find( soundId ); - if (it != _Sources.end() ) - { - nlassert( (*it).second ); - - (*it).second->setPos( position ); - } + USource *pSource = _Sources.get(sourceId); + if (pSource) pSource->setPos(position); } // setSoundPosition // //--------------------------------------------------- // loopSound : //--------------------------------------------------- -void CSoundManager::loopSound( uint32 soundId, bool loop) +void CSoundManager::loopSound(TSourceId sourceId, bool loop) { if (!_PlaySound) return; - TMapIdToSource::iterator it = _Sources.find( soundId ); - if (it != _Sources.end() ) - { - nlassert( (*it).second ); - - (*it).second->setLooping( loop ); - } + USource *pSource = _Sources.get(sourceId); + if (pSource) pSource->setLooping(loop); } // loopSound // @@ -904,19 +886,17 @@ void CSoundManager::loopSound( uint32 soundId, bool loop) // playSound : // start or stop playing sound //--------------------------------------------------- -void CSoundManager::playSound( uint32 soundId, bool play) +void CSoundManager::playSound(TSourceId sourceId, bool play) { if (!_PlaySound) return; - TMapIdToSource::iterator it = _Sources.find( soundId ); - if (it != _Sources.end() ) + USource *pSource = _Sources.get(sourceId); + if (pSource) { - nlassert( (*it).second ); - if (play) - (*it).second->play(); + pSource->play(); else - (*it).second->stop(); + pSource->stop(); } } // loopSound // @@ -926,16 +906,10 @@ void CSoundManager::playSound( uint32 soundId, bool play) // isPlaying : // return true if the source is playing //--------------------------------------------------- -bool CSoundManager::isPlaying( uint32 sourceId ) +bool CSoundManager::isPlaying(TSourceId sourceId) { - TMapIdToSource::iterator it = _Sources.find( sourceId ); - if (it != _Sources.end() ) - { - nlassert( (*it).second ); - - return ( (*it).second->isPlaying() ); - } - + USource *pSource = _Sources.get(sourceId); + if (pSource) return pSource->isPlaying(); return false; } // isPlaying // @@ -999,16 +973,10 @@ bool CSoundManager::setSoundForSource( uint32 sourceId, TSound sound, const CVec // setSourceGain : // set the gain of the specified source //--------------------------------------------------- -void CSoundManager::setSourceGain( uint32 sourceId, float gain) +void CSoundManager::setSourceGain(TSourceId sourceId, float gain) { - TMapIdToSource::const_iterator it = _Sources.find( sourceId ); - if (it != _Sources.end() ) - { - USource *pSource = (*it).second; - nlassert( pSource ); - - pSource->setGain( gain ); - } + USource *pSource = _Sources.get(sourceId); + if (pSource) pSource->setGain( gain ); } // setSourceGain // @@ -1016,17 +984,10 @@ void CSoundManager::setSourceGain( uint32 sourceId, float gain) // getSourceGain : // get the gain of the specified source (-1 if source not found) //--------------------------------------------------- -float CSoundManager::getSourceGain( uint32 sourceId ) +float CSoundManager::getSourceGain(TSourceId sourceId) { - TMapIdToSource::const_iterator it = _Sources.find( sourceId ); - if (it != _Sources.end() ) - { - USource *pSource = (*it).second; - nlassert( pSource ); - - return ( pSource->getGain() ); - } - + USource *pSource = _Sources.get(sourceId); + if (pSource) return pSource->getGain(); return -1; } // getSourceGain // @@ -1035,16 +996,10 @@ float CSoundManager::getSourceGain( uint32 sourceId ) // setSourcePitch : // set the Pitch of the specified source //--------------------------------------------------- -void CSoundManager::setSourcePitch( uint32 sourceId, float Pitch) +void CSoundManager::setSourcePitch(TSourceId sourceId, float Pitch) { - TMapIdToSource::const_iterator it = _Sources.find( sourceId ); - if (it != _Sources.end() ) - { - USource *pSource = (*it).second; - nlassert( pSource ); - - pSource->setPitch( Pitch ); - } + USource *pSource = _Sources.get(sourceId); + if (pSource) pSource->setPitch(Pitch); } // setSourcePitch // @@ -1052,17 +1007,10 @@ void CSoundManager::setSourcePitch( uint32 sourceId, float Pitch) // getSourcePitch : // get the Pitch of the specified source (-1 if source not found) //--------------------------------------------------- -float CSoundManager::getSourcePitch( uint32 sourceId ) +float CSoundManager::getSourcePitch(TSourceId sourceId) { - TMapIdToSource::const_iterator it = _Sources.find( sourceId ); - if (it != _Sources.end() ) - { - USource *pSource = (*it).second; - nlassert( pSource ); - - return ( pSource->getPitch() ); - } - + USource *pSource = _Sources.get(sourceId); + if (pSource) return pSource->getPitch(); return -1; } // getSourcePitch // @@ -1204,23 +1152,26 @@ void CSoundManager::playPositionedSounds( const CVector& /* pos */ ) list::iterator itPSnd; for( itPSnd = _PositionedSounds.begin(); itPSnd != _PositionedSounds.end(); ++itPSnd ) { - TMapIdToSource::const_iterator itSrc = _Sources.find( *itPSnd ); - if( itSrc == _Sources.end() ) + USource *pSource = _Sources.get(*itPSnd); + if (!pSource) { nlwarning(" : The source %d is unknown",*itPSnd); } - /* - if( (pos - (*itSrc).second.getPos()).norm() < ...) + else { - if( (*itSrc).second.pSource->isPlaying() == false ) + /* + if( (pos - (*itSrc).second.getPos()).norm() < ...) { - (*itSrc).second.pSource->play(); + if( (*itSrc).second.pSource->isPlaying() == false ) + { + (*itSrc).second.pSource->play(); + } + } + */ + if (!pSource->isPlaying()) + { + pSource->play(); } - } - */ - if( (*itSrc).second->isPlaying() == false ) - { - (*itSrc).second->play(); } } @@ -1597,7 +1548,8 @@ void CSoundManager::updateVolume() _AudioMixer->setEventMusicVolume(_GameMusicVolume); // update sfx volume - _AudioMixer->getListener()->setGain(_SFXVolume*_FadeSFXVolume); + _GroupControllerEffects->setGain(_SFXVolume); + _GroupControllerEffectsGame->setGain(_FadeSFXVolume); } } diff --git a/code/ryzom/client/src/sound_manager.h b/code/ryzom/client/src/sound_manager.h index 629d9a957..80401ea57 100644 --- a/code/ryzom/client/src/sound_manager.h +++ b/code/ryzom/client/src/sound_manager.h @@ -26,6 +26,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/vector.h" #include "nel/misc/config_file.h" +#include "nel/misc/fast_id_map.h" // game_share #include "nel/misc/entity_id.h" // sound @@ -45,8 +46,6 @@ namespace NLMISC class IProgressCallback; } - - /** * class managing all the sounds for the client * \author David Fleury @@ -55,9 +54,12 @@ namespace NLMISC */ class CSoundManager { +public: + typedef uint32 TSourceId; - typedef CHashMultiMap TMultiMapEntityToSource; - typedef std::map TMapIdToSource; +private: + typedef CHashMultiMap TMultiMapEntityToSource; + typedef NLMISC::CFastIdMap TMapIdToSource; /// Load the properties for this sound and aplly them. void loadProperties(const string &soundName, USource *source); @@ -86,7 +88,7 @@ public: /// Return the audio mixer instance pointer. NLSOUND::UAudioMixer *getMixer(); - uint32 addSource( const NLMISC::TStringId &soundName, const NLMISC::CVector &position, bool play = true , bool loop = false, const NLMISC::CEntityId &id = NLMISC::CEntityId::Unknown ); + TSourceId addSource( const NLMISC::TStringId &soundName, const NLMISC::CVector &position, bool play = true , bool loop = false, const NLMISC::CEntityId &id = NLMISC::CEntityId::Unknown ); /// spawn a new source to the world but sound manager don't keep any link and the sound will be automatically deleted when finnished bool spawnSource (const NLMISC::TStringId &soundName, NLSOUND::CSoundContext &context); @@ -98,7 +100,7 @@ public: * remove a source * \param uint32 source id */ - void removeSource( uint32 sourceId ); + void removeSource( TSourceId sourceId ); /** @@ -190,28 +192,28 @@ public: * \param uint32 source id * \param CVector& new position */ - void setSoundPosition( uint32 sourceId, const NLMISC::CVector &position); + void setSoundPosition( TSourceId sourceId, const NLMISC::CVector &position); /** * loop a sound (or stop looping) * \param uint32 source id * \param bool loop (true = loop) */ - void loopSound( uint32 sourceId, bool loop); + void loopSound( TSourceId sourceId, bool loop); /** * play or stop a sound * \param uint32 source id * \param bool play (true = play, false = stop) */ - void playSound( uint32 sourceId, bool play); + void playSound( TSourceId sourceId, bool play); /** * test whether the sepcified source is playing or not * \param uint32 source id * \return bool true if the source is playing */ - bool isPlaying( uint32 sourceId ); + bool isPlaying( TSourceId sourceId ); /** * select the env effect corresponding to tag @@ -236,14 +238,14 @@ public: * \param uint32 sourceId * \param float new gain (0-1) */ - void setSourceGain( uint32 sourceId, float gain); + void setSourceGain( TSourceId sourceId, float gain); /** * get source Gain * \param uint32 sourceId * \return float new gain (0-1) (-1 if source not found) */ - float getSourceGain( uint32 sourceId ); + float getSourceGain( TSourceId sourceId ); /** * set source Pitch @@ -251,14 +253,14 @@ public: * \param uint32 sourceId * \param float new Pitch (0-1) */ - void setSourcePitch( uint32 sourceId, float gain); + void setSourcePitch( TSourceId sourceId, float gain); /** * get source Pitch * \param uint32 sourceId * \return float new Pitch (0-1) (>0) (-1 if source not found) */ - float getSourcePitch( uint32 sourceId ); + float getSourcePitch( TSourceId sourceId ); /** * Play all the positioned sounds which are near the given position @@ -330,6 +332,12 @@ private: /// Pointer on the audio mixer object NLSOUND::UAudioMixer *_AudioMixer; + /// The root effects group controller for effects volume settings by the user + NLSOUND::UGroupController *_GroupControllerEffects; + + /// The root effects group controller for effects fading by the game + NLSOUND::UGroupController *_GroupControllerEffectsGame; + /// Pointer on the root of the environmental sounds tree (if any) NLSOUND::UEnvSound *_EnvSoundRoot; @@ -346,10 +354,7 @@ private: //CStepSounds _StepSounds; /// list of positioned sounds - std::list _PositionedSounds; - - /// the next value that will be used as id for the next sound to be created - uint32 _NextId; + std::list _PositionedSounds; /// Gain value for user entity sound. float _UserEntitySoundLevel; diff --git a/code/ryzom/common/src/game_share/data_set_base.h b/code/ryzom/common/src/game_share/data_set_base.h index 0db688aa5..54bd790ab 100644 --- a/code/ryzom/common/src/game_share/data_set_base.h +++ b/code/ryzom/common/src/game_share/data_set_base.h @@ -437,7 +437,7 @@ public: // PUBLIC because template friend classes are not supported /// Return the pointer to the property value template - void getPropPointerForList( TSharedListRow **ppt, TPropertyIndex propIndex, const TDataSetRow& entityIndex, T* typeHint ) const + void getPropPointerForList( TSharedListRow **ppt, TPropertyIndex propIndex, const TDataSetRow& entityIndex, T* /* typeHint */ ) const { #ifndef FAST_MIRROR nlassert( (propIndex != INVALID_PROPERTY_INDEX) && (propIndex < (TPropertyIndex)_PropertyContainer.PropertyValueArrays.size()) ); // Wrong property diff --git a/code/ryzom/common/src/game_share/deployment_configuration.cpp b/code/ryzom/common/src/game_share/deployment_configuration.cpp index 86059fc7e..625600331 100644 --- a/code/ryzom/common/src/game_share/deployment_configuration.cpp +++ b/code/ryzom/common/src/game_share/deployment_configuration.cpp @@ -795,7 +795,7 @@ namespace DEPCFG else { // put the number of info blocks to the stream - uint32 count= _InfoBlocks.size(); + uint32 count= (uint32)_InfoBlocks.size(); stream.serial(count); // put the info blocks to the stream one by one for (TInfoBlocks::iterator it= _InfoBlocks.begin(); it!=_InfoBlocks.end(); ++it) @@ -1203,7 +1203,7 @@ namespace DEPCFG DROP_IF(exeRecord.CfgEntries.empty(), "No 'cfg' entriesfound in: "+exeRecord.FullName, ++errors ); // add a refference from the domains' shard map to the exe... - _DomainExes[exeRecord.DomainName][exeRecord.ShardName].push_back(_ExeRecords.size()); + _DomainExes[exeRecord.DomainName][exeRecord.ShardName].push_back((uint32)_ExeRecords.size()); // we may have hit errors but we go ahead anyway as in the case of errors the whole thing will be cleared out anyway _ExeRecords.push_back(exeRecord); @@ -1508,7 +1508,7 @@ NLMISC_CATEGORISED_COMMAND(depcfg,dumpDepCfgShards,"dump the shard set for the d DEPCFG::SAppDescription app; DEPCFG::CDeploymentConfiguration::getInstance().getApp(*dit,*ait,app); uint32 cfgFileLines=app.CfgFile.countLines(); - uint32 numDataPacks= app.DataPacks.size(); + uint32 numDataPacks= (uint32)app.DataPacks.size(); log.displayNL(" -- App: %-20s: %s (cfg file length: %d lines, data packs used: %d)",app.AppName.c_str(),app.CmdLine.c_str(),cfgFileLines,numDataPacks); } } diff --git a/code/ryzom/common/src/game_share/inventories.h b/code/ryzom/common/src/game_share/inventories.h index 1fd1cab48..2dfbb85bf 100644 --- a/code/ryzom/common/src/game_share/inventories.h +++ b/code/ryzom/common/src/game_share/inventories.h @@ -349,7 +349,7 @@ namespace INVENTORIES /// Serial from/to bit stream template - void serialAll( NLMISC::CBitMemStream& bms, const CInventoryCategoryTemplate *templ=0 ) + void serialAll( NLMISC::CBitMemStream& bms, const CInventoryCategoryTemplate * /* templ */ =0 ) { bms.serial( _SlotIndex, CInventoryCategoryTemplate::SlotBitSize ); @@ -385,7 +385,7 @@ namespace INVENTORIES /// Serial from/to bit stream template - void serialOneProp( NLMISC::CBitMemStream& bms, const CInventoryCategoryTemplate *templ=0 ) + void serialOneProp( NLMISC::CBitMemStream& bms, const CInventoryCategoryTemplate * /* templ */ =0 ) { bms.serial( _SlotIndex, CInventoryCategoryTemplate::SlotBitSize ); bms.serial( _OneProp ); diff --git a/code/ryzom/common/src/game_share/mirror_prop_value.h b/code/ryzom/common/src/game_share/mirror_prop_value.h index 08e96761d..1bb4c7571 100644 --- a/code/ryzom/common/src/game_share/mirror_prop_value.h +++ b/code/ryzom/common/src/game_share/mirror_prop_value.h @@ -22,7 +22,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/stream.h" #include "mirrored_data_set.h" - +#include /** * Read-only handler of a value of a property. @@ -1318,4 +1318,4 @@ protected: #endif // NL_MIRROR_PROP_VALUE_H -/* End of mirror_prop_value.h */ \ No newline at end of file +/* End of mirror_prop_value.h */ diff --git a/code/ryzom/common/src/game_share/mirror_prop_value_inline.h b/code/ryzom/common/src/game_share/mirror_prop_value_inline.h index cd4c71f4a..2824977f3 100644 --- a/code/ryzom/common/src/game_share/mirror_prop_value_inline.h +++ b/code/ryzom/common/src/game_share/mirror_prop_value_inline.h @@ -25,6 +25,7 @@ #include "nel/misc/common.h" //#endif +#include /* * Activate this define if you want to set a value into the mirror only if it is different from the previous value @@ -937,7 +938,7 @@ CMirrorPropValueAlice& CMirrorPropValueAlicetempReassign( srcValue ); } return *this; } @@ -1005,7 +1006,7 @@ NLNET::TServiceId8 CMirrorPropValueAlice::getWriterSer if ( _InMirror ) return CMirrorPropValue::getWriterServiceId(); else - return ~0; + return NLNET::TServiceId8(std::numeric_limits::max()); } #endif diff --git a/code/ryzom/common/src/game_share/persistent_data_inline.h b/code/ryzom/common/src/game_share/persistent_data_inline.h index 2500c524d..9a682afdb 100644 --- a/code/ryzom/common/src/game_share/persistent_data_inline.h +++ b/code/ryzom/common/src/game_share/persistent_data_inline.h @@ -420,7 +420,9 @@ inline const CPersistentDataRecord::CArg& CPersistentDataRecord::popNextArg(TTok inline void CPersistentDataRecord::popNextArg(TToken token,CPersistentDataRecord::CArg& result) { #ifdef NL_DEBUG - BOMB_IF(peekNextToken()!=token,"Error on read code - token requested doesn't match token found",return); + BOMB_IF(peekNextToken()!=token,"Error on read code - token requested doesn't match token found",return); + #else + nlunreferenced(token); #endif peekNextArg(result); @@ -445,7 +447,6 @@ inline void CPersistentDataRecord::popNextArg(TToken token,CPersistentDataRecord ++_ArgOffset; ++_TokenOffset; } - return; } //inline CPersistentDataRecord::CArg CPersistentDataRecord::popNextArg(TToken token) diff --git a/code/ryzom/common/src/game_share/singleton_registry.h b/code/ryzom/common/src/game_share/singleton_registry.h index 516417c32..7a9cc0253 100644 --- a/code/ryzom/common/src/game_share/singleton_registry.h +++ b/code/ryzom/common/src/game_share/singleton_registry.h @@ -58,6 +58,7 @@ protected: // protect from untrolled instantiation // this method registers the singleton with the singleton registry IServiceSingleton(); + virtual ~IServiceSingleton() {} private: // prohibit copy diff --git a/code/ryzom/common/src/game_share/txt_command.h b/code/ryzom/common/src/game_share/txt_command.h index f8d2ec39e..054f1bc93 100644 --- a/code/ryzom/common/src/game_share/txt_command.h +++ b/code/ryzom/common/src/game_share/txt_command.h @@ -50,21 +50,21 @@ static CTxtCommandSetPtr<__CTxtCommandSet_##setName> setName; //------------------------------------------------------------------------------------------------- #define TXT_COMMAND(cmdName,setName,CONTEXT_CLASS)\ -struct __CTxtCommand_##cmdName: public ITxtCommand\ +struct __CTxtCommand_##cmdName##CONTEXT_CLASS: public ITxtCommand\ {\ - static __CTxtCommand_##cmdName* getInstance()\ + static __CTxtCommand_##cmdName##CONTEXT_CLASS* getInstance()\ {\ - static __CTxtCommand_##cmdName *p=NULL;\ - if (p==NULL) p= new __CTxtCommand_##cmdName;\ + static __CTxtCommand_##cmdName##CONTEXT_CLASS *p=NULL;\ + if (p==NULL) p= new __CTxtCommand_##cmdName##CONTEXT_CLASS;\ return p;\ }\ virtual const char* getName() const {return #cmdName;}\ virtual CTxtCommandResult execute(CONTEXT_CLASS& context,const NLMISC::CVectorSString& args,const NLMISC::CSString& rawArgs,const NLMISC::CSString& fullCmdLine);\ private:\ - __CTxtCommand_##cmdName() {}\ + __CTxtCommand_##cmdName##CONTEXT_CLASS() {}\ };\ -static ITxtCommandRegisterer<__CTxtCommand_##cmdName,__CTxtCommandSet_##setName> __CTxtCommand_##cmdName##_Registerer;\ -CTxtCommandResult __CTxtCommand_##cmdName::execute(CONTEXT_CLASS& context,const NLMISC::CVectorSString& args,const NLMISC::CSString& rawArgs,const NLMISC::CSString& fullCmdLine) +static ITxtCommandRegisterer<__CTxtCommand_##cmdName##CONTEXT_CLASS,__CTxtCommandSet_##setName> __CTxtCommand_##cmdName##CONTEXT_CLASS##_Registerer;\ +CTxtCommandResult __CTxtCommand_##cmdName##CONTEXT_CLASS::execute(CONTEXT_CLASS& context,const NLMISC::CVectorSString& args,const NLMISC::CSString& rawArgs,const NLMISC::CSString& fullCmdLine) //------------------------------------------------------------------------------------------------- diff --git a/code/ryzom/server/src/admin_modules/admin_modules_itf.h b/code/ryzom/server/src/admin_modules/admin_modules_itf.h index 3f430ed43..248ba6834 100644 --- a/code/ryzom/server/src/admin_modules/admin_modules_itf.h +++ b/code/ryzom/server/src/admin_modules/admin_modules_itf.h @@ -1829,9 +1829,9 @@ namespace ADMIN // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); @@ -1969,9 +1969,9 @@ namespace ADMIN // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); @@ -2202,9 +2202,9 @@ namespace ADMIN // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); diff --git a/code/ryzom/server/src/ai_service/ai_logic_action.h b/code/ryzom/server/src/ai_service/ai_logic_action.h index 631f9f620..452087b18 100644 --- a/code/ryzom/server/src/ai_service/ai_logic_action.h +++ b/code/ryzom/server/src/ai_service/ai_logic_action.h @@ -46,7 +46,7 @@ public: // note that actions are NOT responsible for deleting child actions virtual ~IAILogicAction() - {}; + {} // this is the execute 'callback' for the action type. // NOTE: This code should be fast and compact as it may be called very large numbers of times diff --git a/code/ryzom/server/src/ai_service/ai_profile_npc.h b/code/ryzom/server/src/ai_service/ai_profile_npc.h index 9fed6e662..f8ec911f4 100644 --- a/code/ryzom/server/src/ai_service/ai_profile_npc.h +++ b/code/ryzom/server/src/ai_service/ai_profile_npc.h @@ -633,7 +633,7 @@ public CMoveProfile { public: CGrpProfileFollowPlayer(CProfileOwner* owner, TDataSetRow const& playerRow, uint32 dispersionRadius); - virtual ~CGrpProfileFollowPlayer() {}; + virtual ~CGrpProfileFollowPlayer() {} void setBotStandProfile(AITYPES::TProfiles botStandProfileType, IAIProfileFactory* botStandProfileFactory); @@ -641,16 +641,16 @@ public: //@{ virtual void beginProfile(); virtual void updateProfile(uint ticksSinceLastUpdate); - virtual void endProfile() {}; + virtual void endProfile() {} virtual AITYPES::TProfiles getAIProfileType() const { return AITYPES::BOT_FOLLOW_POS; } virtual std::string getOneLineInfoString() const { return std::string("follow_player group profile"); } //@} - void stateChangeProfile() {}; + void stateChangeProfile() {} bool destinationReach() const; - void addBot (CBot* bot) {}; - void removeBot (CBot* bot) {}; + void addBot (CBot* bot) {} + void removeBot (CBot* bot) {} CPathCont* getPathCont (CBot const* bot) { return NULL; }; diff --git a/code/ryzom/server/src/ai_service/child_container.h b/code/ryzom/server/src/ai_service/child_container.h index 79ffa832c..ce2eb1d27 100644 --- a/code/ryzom/server/src/ai_service/child_container.h +++ b/code/ryzom/server/src/ai_service/child_container.h @@ -546,13 +546,13 @@ CAliasTreeOwner* CAliasCont::getAliasChildByAlias(uint32 alias) const template CAliasTreeOwner* CAliasCont::addAliasChild(CAliasTreeOwner* child) { - return NLMISC::type_cast(addChild(static_cast(child))); + return NLMISC::type_cast(this->addChild(static_cast(child))); } template CAliasTreeOwner* CAliasCont::addAliasChild(CAliasTreeOwner* child, uint32 index) { - return NLMISC::type_cast(addChild(static_cast(child), index)); + return NLMISC::type_cast(this->addChild(static_cast(child), index)); } template diff --git a/code/ryzom/server/src/ai_service/commands.cpp b/code/ryzom/server/src/ai_service/commands.cpp index a85e8fe1c..98063d7e3 100644 --- a/code/ryzom/server/src/ai_service/commands.cpp +++ b/code/ryzom/server/src/ai_service/commands.cpp @@ -844,7 +844,7 @@ public: } protected: private: - size_t _index; + uint32 _index; float _value; bool _detailled; mutable CLogStringWriter _stringWriter; diff --git a/code/ryzom/server/src/ai_service/continent.h b/code/ryzom/server/src/ai_service/continent.h index a9a265e7d..8b92cf6b9 100644 --- a/code/ryzom/server/src/ai_service/continent.h +++ b/code/ryzom/server/src/ai_service/continent.h @@ -529,6 +529,7 @@ class CLazyProcess : public NLMISC::CRefCount { public: + virtual ~CLazyProcess() {} /// Used to update some dependencies for instance road connections when the first next update of CContinent is called. virtual void update() const = 0; /// Used to check if there's no need to add another lazyprocess. @@ -1052,6 +1053,7 @@ class IGroupDesc : public NLMISC::CRefCount { public: + virtual ~IGroupDesc() {} virtual uint32 groupEnergyValue() const = 0; virtual float groupEnergyCoef() const = 0; virtual bool getCountMultiplierFlag() const = 0; diff --git a/code/ryzom/server/src/ai_service/family_profile.cpp b/code/ryzom/server/src/ai_service/family_profile.cpp index c01faf37f..f95f142c9 100644 --- a/code/ryzom/server/src/ai_service/family_profile.cpp +++ b/code/ryzom/server/src/ai_service/family_profile.cpp @@ -172,6 +172,7 @@ IAiFactory *_ProfileNpc=&_singleProfileNpc; extern IAiFactory *_ProfileTribe; // in another cpp. +NL_ISO_TEMPLATE_SPEC CAiFactoryContainer *CAiFactoryContainer::_Instance = NULL; CFamilyProfileFactory::CFamilyProfileFactory() { @@ -217,10 +218,6 @@ IFamilyProfile* CFamilyProfileFactory::createFamilyProfile(const TStringId &keyW return NULL; } - -NL_ISO_TEMPLATE_SPEC CAiFactoryContainer *CAiFactoryContainer::_Instance = NULL; - - IFamilyProfile* IFamilyProfile::createFamilyProfile(const TStringId &profileName, const IFamilyProfile::CtorParam& ctorParam) { return CFamilyProfileFactory::createFamilyProfile(profileName, ctorParam); diff --git a/code/ryzom/server/src/ai_service/family_profile.h b/code/ryzom/server/src/ai_service/family_profile.h index a07acab8a..b4df92d92 100644 --- a/code/ryzom/server/src/ai_service/family_profile.h +++ b/code/ryzom/server/src/ai_service/family_profile.h @@ -87,15 +87,15 @@ public: virtual void update() =0; /// Fill a vector of outpost id name assigned to tribe - virtual void fillOutpostNames(std::vector outpostNames) {}; + virtual void fillOutpostNames(std::vector outpostNames) {} /// Add an outpost for the tribe (nb : the family must be a tribe) - virtual void outpostAdd(NLMISC::TStringId outpostName) {}; + virtual void outpostAdd(NLMISC::TStringId outpostName) {} /// Remove an from the tribe - virtual void outpostRemove(NLMISC::TStringId outpostName) {}; + virtual void outpostRemove(NLMISC::TStringId outpostName) {} - virtual void outpostEvent(NLMISC::TStringId outpostName, ZCSTATE::TZcState state) {}; + virtual void outpostEvent(NLMISC::TStringId outpostName, ZCSTATE::TZcState state) {} - virtual void spawnBoss(NLMISC::TStringId outpostName) {}; + virtual void spawnBoss(NLMISC::TStringId outpostName) {} CGroupNpc *createNpcGroup(const CNpcZone *const zone, const CGroupDesc *const groupDesc); diff --git a/code/ryzom/server/src/ai_service/fx_entity.h b/code/ryzom/server/src/ai_service/fx_entity.h index 3fbf66b92..78f4bb37b 100644 --- a/code/ryzom/server/src/ai_service/fx_entity.h +++ b/code/ryzom/server/src/ai_service/fx_entity.h @@ -28,7 +28,7 @@ class CFxEntity { public: CFxEntity(CAIPos const& pos, NLMISC::CSheetId const& sheet); - ~CFxEntity(); + virtual ~CFxEntity(); NLMISC::CEntityId const& id() const; bool spawn(); void despawn(); diff --git a/code/ryzom/server/src/ai_service/script_compiler.cpp b/code/ryzom/server/src/ai_service/script_compiler.cpp index 03d0fe336..a9982ef48 100644 --- a/code/ryzom/server/src/ai_service/script_compiler.cpp +++ b/code/ryzom/server/src/ai_service/script_compiler.cpp @@ -1933,7 +1933,7 @@ void CSubRuleTracer::generateCode(CSmartPtr &cByteCode) const case CScriptVM::JUMP: byteCode.push_back(op); // + Jump offset. - size_t index; + uint32 index; NLMISC::fromString(param, index); jumpTable.add(CJumpRememberer(index)); byteCode.push_back(0); // Invalid @@ -1950,7 +1950,7 @@ void CSubRuleTracer::generateCode(CSmartPtr &cByteCode) const { if (str.find("Atof")!=string::npos) { - size_t index; + uint32 index; NLMISC::fromString(param, index); --index; string &strRef=_childTracers[index]->_TextValue; @@ -1962,7 +1962,7 @@ void CSubRuleTracer::generateCode(CSmartPtr &cByteCode) const if (str.find("String")!=string::npos) { - size_t index; + uint32 index; NLMISC::fromString(param, index); --index; string &strRef=_childTracers[index]->_TextValue; @@ -2021,7 +2021,7 @@ void CSubRuleTracer::generateCode(CSmartPtr &cByteCode) const if (str.find("Code")!=string::npos) { - size_t index; + uint32 index; NLMISC::fromString(param, index); --index; if (byteCode.size()==0) diff --git a/code/ryzom/server/src/ai_service/sheets.h b/code/ryzom/server/src/ai_service/sheets.h index 7526218c0..0473af4a9 100644 --- a/code/ryzom/server/src/ai_service/sheets.h +++ b/code/ryzom/server/src/ai_service/sheets.h @@ -644,6 +644,7 @@ class IRaceStats : public NLMISC::CRefCount { public: + virtual ~IRaceStats() {} virtual NLMISC::CSheetId SheetId() const = 0; virtual std::string Race() const = 0; }; diff --git a/code/ryzom/server/src/entities_game_service/building_manager/building_physical.h b/code/ryzom/server/src/entities_game_service/building_manager/building_physical.h index d37966aeb..d635ecd71 100644 --- a/code/ryzom/server/src/entities_game_service/building_manager/building_physical.h +++ b/code/ryzom/server/src/entities_game_service/building_manager/building_physical.h @@ -73,9 +73,9 @@ public: /// fill the icon param, send the description text to the user and store the resulting text id in the textId param. virtual void getClientDescription(uint16 roomIdx, uint16 ownerIndex, CCharacter * user, uint64 & icon, uint32 & textId )const = 0; /// callback called when all the appartments of a user must be removed - virtual void onPlayerDeletion( const NLMISC::CEntityId & userId ){}; + virtual void onPlayerDeletion( const NLMISC::CEntityId & userId ){} /// callback called when all the appartments of a guild must be removed - virtual void onGuildDeletion( uint32 guild ){}; + virtual void onGuildDeletion( uint32 guild ){} /// return true if the user is allowed to go in the building virtual bool isUserAllowed(CCharacter * user, uint16 ownerIdx, uint16 roomIdx) = 0; ///return the number of owner in this building ( return 1 for common buildings ) diff --git a/code/ryzom/server/src/entities_game_service/creature_manager/creature_manager.h b/code/ryzom/server/src/entities_game_service/creature_manager/creature_manager.h index 75b40c5c3..388c9f3b4 100644 --- a/code/ryzom/server/src/entities_game_service/creature_manager/creature_manager.h +++ b/code/ryzom/server/src/entities_game_service/creature_manager/creature_manager.h @@ -121,14 +121,14 @@ public: /// exception thrown when creature is unknown struct ECreature : public NLMISC::Exception { - ECreature( const NLMISC::CEntityId& id ) : Exception ("The creature "+id.toString()+" doesn't exist") {}; + ECreature( const NLMISC::CEntityId& id ) : Exception ("The creature "+id.toString()+" doesn't exist") {} }; /// structure describing an unaffected fauna group ( because the description is received before mirror update ) struct SUnaffectedFaunaGroup { SUnaffectedFaunaGroup(const TDataSetRow& entityIndex,TAIAlias groupAlias) - :EntityIndex( entityIndex ),GroupAlias( groupAlias ){}; + :EntityIndex( entityIndex ),GroupAlias( groupAlias ){} TDataSetRow EntityIndex; TAIAlias GroupAlias; }; diff --git a/code/ryzom/server/src/entities_game_service/egs_progress_callback.h b/code/ryzom/server/src/entities_game_service/egs_progress_callback.h index bb1fc9de6..78cbc356e 100644 --- a/code/ryzom/server/src/entities_game_service/egs_progress_callback.h +++ b/code/ryzom/server/src/entities_game_service/egs_progress_callback.h @@ -31,7 +31,7 @@ class CEGSProgressCallback : public NLMISC::IProgressCallback { public: CEGSProgressCallback():IProgressCallback() {} - virtual void progress (float progressValue) {}; + virtual void progress (float progressValue) {} virtual ~CEGSProgressCallback() {} }; diff --git a/code/ryzom/server/src/entities_game_service/egs_sheets/egs_sheets.h b/code/ryzom/server/src/entities_game_service/egs_sheets/egs_sheets.h index 41c1bcec4..a1619f5f4 100644 --- a/code/ryzom/server/src/entities_game_service/egs_sheets/egs_sheets.h +++ b/code/ryzom/server/src/entities_game_service/egs_sheets/egs_sheets.h @@ -74,7 +74,7 @@ public : /// exception thrown when a sheet is unknown struct ESheet : public NLMISC::Exception { - ESheet( const NLMISC::CSheetId& sheetId ) : Exception ("The sheet "+sheetId.toString()+" is unknown") {}; + ESheet( const NLMISC::CSheetId& sheetId ) : Exception ("The sheet "+sheetId.toString()+" is unknown") {} }; public: diff --git a/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_game_item.h b/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_game_item.h index 0ef0e0335..0840d01d1 100644 --- a/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_game_item.h +++ b/code/ryzom/server/src/entities_game_service/egs_sheets/egs_static_game_item.h @@ -429,7 +429,7 @@ struct SShield : public SArmor NL_INSTANCE_COUNTER_DECL(SShield); public: - inline SShield() : SArmor(),ShieldType(SHIELDTYPE::NONE),Unbreakable(false){}; + inline SShield() : SArmor(),ShieldType(SHIELDTYPE::NONE),Unbreakable(false){} virtual void serial(class NLMISC::IStream &f) { diff --git a/code/ryzom/server/src/entities_game_service/entity_manager/entity_base.h b/code/ryzom/server/src/entities_game_service/entity_manager/entity_base.h index 81e5b6cd8..fc3cd5903 100644 --- a/code/ryzom/server/src/entities_game_service/entity_manager/entity_base.h +++ b/code/ryzom/server/src/entities_game_service/entity_manager/entity_base.h @@ -140,7 +140,7 @@ public: _ExceptionString = std::string(" : Invalid stat name ") + var; return _ExceptionString.c_str(); } - virtual ~EInvalidStat() throw() {}; + virtual ~EInvalidStat() throw() {} private: mutable std::string _ExceptionString; }; @@ -820,7 +820,7 @@ public: /// Return the damage using current armor, done by an explosion (e.g. forage source explosion) virtual float getActualDamageFromExplosionWithArmor( float dmg ) const =0; - inline virtual void clearCurrentAction() {}; + inline virtual void clearCurrentAction() {} inline virtual void setCurrentAction(CLIENT_ACTION_TYPE::TClientActionType,NLMISC::TGameCycle) {} diff --git a/code/ryzom/server/src/entities_game_service/entity_manager/entity_manager.h b/code/ryzom/server/src/entities_game_service/entity_manager/entity_manager.h index 88f893c91..cf5422f1a 100644 --- a/code/ryzom/server/src/entities_game_service/entity_manager/entity_manager.h +++ b/code/ryzom/server/src/entities_game_service/entity_manager/entity_manager.h @@ -59,7 +59,7 @@ public: /// exception thrown when entity is unknown struct EEntity : public NLMISC::Exception { - EEntity( const NLMISC::CEntityId& id ) : Exception ("The entity "+id.toString()+" doesn't exist") {}; + EEntity( const NLMISC::CEntityId& id ) : Exception ("The entity "+id.toString()+" doesn't exist") {} }; /* // Success table for calculation of success probability and associate xp-gains diff --git a/code/ryzom/server/src/entities_game_service/game_item_manager/game_item_manager.h b/code/ryzom/server/src/entities_game_service/game_item_manager/game_item_manager.h index a0aee63fc..8bd4e6b90 100644 --- a/code/ryzom/server/src/entities_game_service/game_item_manager/game_item_manager.h +++ b/code/ryzom/server/src/entities_game_service/game_item_manager/game_item_manager.h @@ -61,7 +61,7 @@ public : /// exception thrown when a sheet is unknown struct ESheet : public NLMISC::Exception { - ESheet( const NLMISC::CSheetId& sheetId ) : Exception ("The sheet "+sheetId.toString()+" is unknown") {}; + ESheet( const NLMISC::CSheetId& sheetId ) : Exception ("The sheet "+sheetId.toString()+" is unknown") {} }; public: diff --git a/code/ryzom/server/src/entities_game_service/guild_manager/guild_unifier_itf.h b/code/ryzom/server/src/entities_game_service/guild_manager/guild_unifier_itf.h index 1280fe6c2..98a4f9229 100644 --- a/code/ryzom/server/src/entities_game_service/guild_manager/guild_unifier_itf.h +++ b/code/ryzom/server/src/entities_game_service/guild_manager/guild_unifier_itf.h @@ -490,9 +490,9 @@ namespace GU // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); diff --git a/code/ryzom/server/src/entities_game_service/guild_manager/guild_version_adapter.h b/code/ryzom/server/src/entities_game_service/guild_manager/guild_version_adapter.h index 2bb3464de..8b59b2a97 100644 --- a/code/ryzom/server/src/entities_game_service/guild_manager/guild_version_adapter.h +++ b/code/ryzom/server/src/entities_game_service/guild_manager/guild_version_adapter.h @@ -50,7 +50,7 @@ private: void adaptToVersion4(CGuild &guild) const; private: - CGuildVersionAdapter(){}; + CGuildVersionAdapter(){} /// unique instance static CGuildVersionAdapter* _Instance; }; diff --git a/code/ryzom/server/src/entities_game_service/harvest_source.cpp b/code/ryzom/server/src/entities_game_service/harvest_source.cpp index c655e2ebc..186615e45 100644 --- a/code/ryzom/server/src/entities_game_service/harvest_source.cpp +++ b/code/ryzom/server/src/entities_game_service/harvest_source.cpp @@ -90,6 +90,14 @@ sint8 ExplosionResetPeriod = 50; // 5 s CHarvestSource AutoSpawnSourceIniProperties; +/* + * Access to singleton + */ +CHarvestSourceManager *CHarvestSourceManager::getInstance() +{ + return (CHarvestSourceManager*)_Instance; +} + /* * Initialization of source manager */ @@ -103,7 +111,10 @@ void CHarvestSourceManager::init( TDataSetIndex baseRowIndex, TDataSetIndex size //AutoSpawnSourceIniProperties.setDistVis( 100 ); } - +void CHarvestSourceManager::release() +{ + delete (CHarvestSourceManager*)_Instance; +} /* * HarvestSource constructor diff --git a/code/ryzom/server/src/entities_game_service/harvest_source.h b/code/ryzom/server/src/entities_game_service/harvest_source.h index 59556115e..edd9c546a 100644 --- a/code/ryzom/server/src/entities_game_service/harvest_source.h +++ b/code/ryzom/server/src/entities_game_service/harvest_source.h @@ -391,13 +391,13 @@ class CHarvestSourceManager : public CSimpleEntityManager public: /// Singleton access - static CHarvestSourceManager *getInstance() { return (CHarvestSourceManager*)_Instance; } + static CHarvestSourceManager *getInstance(); /// Initialization void init( TDataSetIndex baseRowIndex, TDataSetIndex size ); /// Release - static void release() { delete (CHarvestSourceManager*)_Instance; } + static void release(); }; diff --git a/code/ryzom/server/src/entities_game_service/mission_manager/mission_event.h b/code/ryzom/server/src/entities_game_service/mission_manager/mission_event.h index 34ff36600..b5bb0fccd 100644 --- a/code/ryzom/server/src/entities_game_service/mission_manager/mission_event.h +++ b/code/ryzom/server/src/entities_game_service/mission_manager/mission_event.h @@ -94,7 +94,7 @@ public: static bool simMissionEvent(const std::vector< std::string > & script, NLMISC::CLog & log ); protected: - CMissionEvent(){}; + CMissionEvent(){} /// build an event from a script virtual bool buildFromScript( const std::vector< std::string > & script,NLMISC::CLog& log ) = 0; @@ -114,7 +114,7 @@ public: uint32 Mission; protected: friend class CMissionEvent; - CMissionEventMissionDone(){}; + CMissionEventMissionDone(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -130,7 +130,7 @@ public: std::string ScenarioTag; protected: friend class CMissionEvent; - CMissionEventTaggedRingScenarioDone(){}; + CMissionEventTaggedRingScenarioDone(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -158,7 +158,7 @@ public: uint32 Amount; protected: friend class CMissionEvent; - CMissionEventGiveMoney(){}; + CMissionEventGiveMoney(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -171,7 +171,7 @@ public: uint32 PlaceId; protected: friend class CMissionEvent; - CMissionEventVisitPlace(){}; + CMissionEventVisitPlace(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -184,7 +184,7 @@ public: std::vector Bricks; protected: friend class CMissionEvent; - CMissionEventCast(){}; + CMissionEventCast(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -196,7 +196,7 @@ public: :CMissionEvent(Kill, targetEntity, restriction){} protected: friend class CMissionEvent; - CMissionEventKill(){}; + CMissionEventKill(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -209,7 +209,7 @@ public: :CMissionEvent(KillPlayer, victimId){} protected: friend class CMissionEvent; - CMissionEventKillPlayer(){}; + CMissionEventKillPlayer(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -225,7 +225,7 @@ public: uint16 Quality; protected: friend class CMissionEvent; - CMissionEventBuyItem(){}; + CMissionEventBuyItem(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -241,7 +241,7 @@ public: uint16 Quality; protected: friend class CMissionEvent; - CMissionEventSellItem(){}; + CMissionEventSellItem(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -257,7 +257,7 @@ public: uint16 Quality; protected: friend class CMissionEvent; - CMissionEventForage(){}; + CMissionEventForage(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -283,7 +283,7 @@ public: uint Level; protected: friend class CMissionEvent; - CMissionEventSkillProgress(){}; + CMissionEventSkillProgress(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -295,7 +295,7 @@ public: :CMissionEvent(Target,targetEntity ){} protected: friend class CMissionEvent; - CMissionEventTarget(){}; + CMissionEventTarget(){} bool buildFromScript( const std::vector< std::string > & script,NLMISC::CLog& log ); }; @@ -311,7 +311,7 @@ public: uint16 Quality; protected: friend class CMissionEvent; - CMissionEventCraft(){}; + CMissionEventCraft(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -351,7 +351,7 @@ public: uint16 Quality; protected: friend class CMissionEvent; - CMissionEventLootItem(){}; + CMissionEventLootItem(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -366,7 +366,7 @@ public: uint16 Quality; protected: friend class CMissionEvent; - CMissionEventLootRm(){}; + CMissionEventLootRm(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -379,7 +379,7 @@ public: TAIAlias Alias; protected: friend class CMissionEvent; - CMissionEventKillGroup(){}; + CMissionEventKillGroup(){} bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log); }; @@ -390,7 +390,7 @@ public: :CMissionEvent(EndDynChat,TDataSetRow()){} protected: friend class CMissionEvent; - bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log){return false;}; + bool buildFromScript( const std::vector< std::string > & /* script */, NLMISC::CLog& /* log */){return false;} }; class CMissionEventDebug : public CMissionEvent @@ -400,7 +400,7 @@ public: :CMissionEvent(Debug,TDataSetRow()){} protected: friend class CMissionEvent; - bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log){return false;}; + bool buildFromScript( const std::vector< std::string > & /* script */, NLMISC::CLog& /* log */){return false;} }; @@ -412,7 +412,7 @@ public: uint32 Points; protected: friend class CMissionEvent; - bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log){return false;}; + bool buildFromScript( const std::vector< std::string > & /* script */, NLMISC::CLog& /* log */){return false;} }; class CMissionEventOutpostGain : public CMissionEvent @@ -422,7 +422,7 @@ public: :CMissionEvent(OutpostGain,TDataSetRow()){} protected: friend class CMissionEvent; - bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log){return false;}; + bool buildFromScript( const std::vector< std::string > & /* script */, NLMISC::CLog& /* log */){return false;} }; @@ -437,7 +437,7 @@ public: bool Guild; protected: friend class CMissionEvent; - bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log){return false;} + bool buildFromScript( const std::vector< std::string > & /* script */, NLMISC::CLog& /* log */){return false;} }; class CMissionEventQueueEntryOk: public CMissionEvent @@ -447,7 +447,7 @@ public: :CMissionEvent(QueueEntryOk, TDataSetRow()) {} protected: friend class CMissionEvent; - bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log) { return false; } + bool buildFromScript( const std::vector< std::string > & /* script */, NLMISC::CLog& /* log */){return false;} }; @@ -458,7 +458,7 @@ public: :CMissionEvent(QueueExit, TDataSetRow()) {} protected: friend class CMissionEvent; - bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log) { return false; } + bool buildFromScript( const std::vector< std::string > & /* script */, NLMISC::CLog& /* log */){return false;} }; class CMissionEventGroupSpawned : public CMissionEvent @@ -470,8 +470,8 @@ public: TAIAlias Alias; protected: friend class CMissionEvent; - CMissionEventGroupSpawned(){}; - bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log) { return false; } + CMissionEventGroupSpawned(){} + bool buildFromScript( const std::vector< std::string > & /* script */, NLMISC::CLog& /* log */){return false;} }; class CMissionEventGroupDespawned : public CMissionEvent @@ -483,8 +483,8 @@ public: TAIAlias Alias; protected: friend class CMissionEvent; - CMissionEventGroupDespawned(){}; - bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log) { return false; } + CMissionEventGroupDespawned(){} + bool buildFromScript( const std::vector< std::string > & /* script */, NLMISC::CLog& /* log */){return false;} }; #endif // RY_MISSION_EVENT_H diff --git a/code/ryzom/server/src/entities_game_service/mission_manager/mission_step_template.h b/code/ryzom/server/src/entities_game_service/mission_manager/mission_step_template.h index 132463bec..6e92fb23f 100644 --- a/code/ryzom/server/src/entities_game_service/mission_manager/mission_step_template.h +++ b/code/ryzom/server/src/entities_game_service/mission_manager/mission_step_template.h @@ -102,7 +102,7 @@ public: ///\name accessors //@{ /// return the step actions - inline const std::vector< IMissionAction* > & getActions(){ return _Actions; }; + inline const std::vector< IMissionAction* > & getActions(){ return _Actions; } /// set the out of order index of the step ( it is the index of the OOO/ANY bloc embedding the step ) 0xFF is invalid inline void setOOOStepIndex(uint32 idx){ _OOOStepIndex = idx; } ///\return the OOO index ( see previous line ) @@ -120,9 +120,9 @@ public: ///\set displayed value void setIconDisplayedOnStepNPC(bool displayed){ _IconDisplayedOnStepNPC = displayed;} /// return true if the step is in an OOO block which text wad overriden - bool isInOverridenOOO() { return _IsInOverridenOOO; }; + bool isInOverridenOOO() { return _IsInOverridenOOO; } /// set the isInOverridenOOO flag ( see previous method ) - void setAsInOverridenOOO() { _IsInOverridenOOO = true; }; + void setAsInOverridenOOO() { _IsInOverridenOOO = true; } /// return true if there is a roleplay text in this step bool isThereRoleplayText() { return !_RoleplayText.empty(); } /// check if the current player gift is ok @@ -130,7 +130,7 @@ public: /// retrieve the escort groups - virtual void getEscortGroups( std::vector< TAIAlias > & groups ){}; + virtual void getEscortGroups( std::vector< TAIAlias > & groups ){} virtual bool checkEscortFailure( bool groupWiped ){return false;} /// check the consistency of a text step diff --git a/code/ryzom/server/src/entities_game_service/modules/r2_give_item.h b/code/ryzom/server/src/entities_game_service/modules/r2_give_item.h index 9e56b8aea..a5d46c766 100644 --- a/code/ryzom/server/src/entities_game_service/modules/r2_give_item.h +++ b/code/ryzom/server/src/entities_game_service/modules/r2_give_item.h @@ -81,7 +81,7 @@ public: typedef std::map< TCreatureRowId, TCreatureItemRequest > TPendingRequest; // constructor - CR2GiveItem() {}; + CR2GiveItem() {} // destructor ~CR2GiveItem() {} diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/environmental_effect.cpp b/code/ryzom/server/src/entities_game_service/phrase_manager/environmental_effect.cpp index 984003b20..fabb37350 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/environmental_effect.cpp +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/environmental_effect.cpp @@ -67,3 +67,15 @@ NLMISC_DYNVARIABLE( uint, NbEnvironmentalEffects, "Number of environmental effec if ( get ) *pointer = CEnvironmentalEffectManager::getInstance()->nbEntities(); } + +/// Singleton access +CEnvironmentalEffectManager *CEnvironmentalEffectManager::getInstance() +{ + return (CEnvironmentalEffectManager*)_Instance; +} + +/// Release +void CEnvironmentalEffectManager::release() +{ + delete (CEnvironmentalEffectManager*)_Instance; +} diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/environmental_effect.h b/code/ryzom/server/src/entities_game_service/phrase_manager/environmental_effect.h index 0c81370a9..e53049cca 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/environmental_effect.h +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/environmental_effect.h @@ -89,10 +89,10 @@ class CEnvironmentalEffectManager : public CSimpleEntityManager& bricks, TDataSetRow actorRowId ) { return true; } + static bool validateSabrinaGrammar( const std::vector< const CStaticBrick* >& /* bricks */, TDataSetRow /* actorRowId */ ) { return true; } - virtual void setBrickSheets( const std::vector & bricks){} + virtual void setBrickSheets( const std::vector & /* bricks */){} virtual void setEnchantMode(bool){} inline void cyclic(bool b) { _CyclicPhrase = b; } diff --git a/code/ryzom/server/src/entities_game_service/phrase_manager/toxic_cloud.h b/code/ryzom/server/src/entities_game_service/phrase_manager/toxic_cloud.h index f0bcb46c5..d1cd98246 100644 --- a/code/ryzom/server/src/entities_game_service/phrase_manager/toxic_cloud.h +++ b/code/ryzom/server/src/entities_game_service/phrase_manager/toxic_cloud.h @@ -36,7 +36,7 @@ class CToxicCloud : public CEnvironmentalEffect NL_INSTANCE_COUNTER_DECL(CToxicCloud); public: - CToxicCloud() {}; + CToxicCloud() {} /// Init inline void init( const NLMISC::CVector& pos, float radius, sint32 dmgPerHit, NLMISC::TGameCycle updateFrequency, NLMISC::TGameCycle lifetime=ToxicCloudDefaultLifetime) diff --git a/code/ryzom/server/src/entities_game_service/player_manager/cdb.h b/code/ryzom/server/src/entities_game_service/player_manager/cdb.h index fccaff859..a2af677f7 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/cdb.h +++ b/code/ryzom/server/src/entities_game_service/player_manager/cdb.h @@ -216,7 +216,7 @@ public : /** * Inform a node of its parenthood */ - virtual void setParent(CCDBStructNodeBranch *parent) { nlassertex(0,("setParent() not overloaded for given node type!")); } + virtual void setParent(CCDBStructNodeBranch * /* parent */) { nlassertex(0,("setParent() not overloaded for given node type!")); } /** * get the parent of a node @@ -248,7 +248,7 @@ public : * Browse the tree, and for each atom branch encountered, call the callback passing the argument * provided and the index of the atom branch. */ - virtual void foreachAtomBranchCall( void (*callback)(void*,TCDBDataIndex), void *arg ) const {}; + virtual void foreachAtomBranchCall( void (*callback)(void*,TCDBDataIndex), void *arg ) const {} /** * Browse the tree, building the text id, and for each leaf encountered, call the callback @@ -288,10 +288,10 @@ public : TCDBDataIndex getDataIndex() const { return _DataIndex; } /// Set the atomic branch flag (when all the modified nodes of a branch should be tranmitted at the same time) - void setAtomic( bool atomicBranch ) { _Atomic = atomicBranch; } + void setAtomic( bool atomicBranch ) { _AtomicFlag = atomicBranch; } /// Return true if the branch has the atomic flag - bool isAtomic() const { return _Atomic; } + bool isAtomic() const { return _AtomicFlag; } /** Attach callback. Allow to attach a callback function that some code could call * when an instance of this node is changed. @@ -307,7 +307,7 @@ protected: ICDBStructNode() : _BankLabels(NULL), _DataIndex(CDB_INVALID_DATA_INDEX), - _Atomic(false), + _AtomicFlag(false), _ChangeCallback(NULL) {} @@ -325,7 +325,7 @@ protected: TCDBDataIndex _DataIndex; /// Atomic flag: is the branch an atomic group, or is the leaf a member of an atomic group - bool _Atomic; + bool _AtomicFlag; /// Optional callback pointer. TNodeChangeCallback _ChangeCallback; diff --git a/code/ryzom/server/src/entities_game_service/player_manager/cdb_branch.cpp b/code/ryzom/server/src/entities_game_service/player_manager/cdb_branch.cpp index f95777359..156f17f14 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/cdb_branch.cpp +++ b/code/ryzom/server/src/entities_game_service/player_manager/cdb_branch.cpp @@ -186,7 +186,7 @@ void ICDBStructNode::setLabel( const std::string& bankName ) */ void CCDBStructNodeBranch::initDataIndex( TCDBDataIndex& index ) { - if ( _Atomic ) + if ( _AtomicFlag ) { _DataIndex = index; checkIfNotMaxIndex(); @@ -207,7 +207,7 @@ void CCDBStructNodeBranch::initDataIndex( TCDBDataIndex& index ) */ void CCDBStructNodeBranch::initIdAndCallForEachIndex( CBinId& id, void (*callback)(ICDBStructNode*, void*), void *arg ) { - if ( _Atomic ) + if ( _AtomicFlag ) { callback( this, arg ); } @@ -537,7 +537,7 @@ TCDBDataIndex CCDBStructNodeBranch::findDataIndex( ICDBStructNode::CTextId& id ) */ void CCDBStructNodeBranch::foreachAtomBranchCall( void (*callback)(void*,TCDBDataIndex), void *arg ) const { - if ( _Atomic ) + if ( _AtomicFlag ) { callback( arg, _DataIndex ); } diff --git a/code/ryzom/server/src/entities_game_service/player_manager/cdb_synchronised.h b/code/ryzom/server/src/entities_game_service/player_manager/cdb_synchronised.h index 3968515d2..8e09617ad 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/cdb_synchronised.h +++ b/code/ryzom/server/src/entities_game_service/player_manager/cdb_synchronised.h @@ -50,12 +50,12 @@ public: /// exception thrown when database is not initialized struct EDBNotInit : public NLMISC::Exception { - EDBNotInit() : Exception("CDB: Property Database not initialized") {}; + EDBNotInit() : Exception("CDB: Property Database not initialized") {} }; struct ECDBNotFound : public NLMISC::Exception { - ECDBNotFound() : Exception("CDB: Property not found") {}; + ECDBNotFound() : Exception("CDB: Property not found") {} }; /*struct CPropForClientOnly diff --git a/code/ryzom/server/src/entities_game_service/player_manager/known_and_memorized_phrases.h b/code/ryzom/server/src/entities_game_service/player_manager/known_and_memorized_phrases.h index 646913107..f7fd1d851 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/known_and_memorized_phrases.h +++ b/code/ryzom/server/src/entities_game_service/player_manager/known_and_memorized_phrases.h @@ -126,7 +126,7 @@ private: private: // prevent copy constructor - CMemorizationSet(const CMemorizationSet &other) {}; + CMemorizationSet(const CMemorizationSet &other) {} // prevent copy operator CMemorizationSet &operator =(const CMemorizationSet&other) { return *this;} }; @@ -183,7 +183,7 @@ private: private: // prevent copy constructor - CPlayerPhraseMemory(const CMemorizationSet &other) {}; + CPlayerPhraseMemory(const CMemorizationSet &other) {} // prevent copy operator CPlayerPhraseMemory &operator =(const CMemorizationSet&other) { return *this;} }; diff --git a/code/ryzom/server/src/entities_game_service/player_manager/player_manager.h b/code/ryzom/server/src/entities_game_service/player_manager/player_manager.h index ecacee896..33e4a8ac9 100644 --- a/code/ryzom/server/src/entities_game_service/player_manager/player_manager.h +++ b/code/ryzom/server/src/entities_game_service/player_manager/player_manager.h @@ -166,13 +166,13 @@ public : /// exception thrown when player is unknown struct EPlayer : public NLMISC::Exception { - EPlayer( uint32 userId ) : Exception ("Player "+NLMISC::toString(userId)+" not found") {}; + EPlayer( uint32 userId ) : Exception ("Player "+NLMISC::toString(userId)+" not found") {} }; /// exception thrown when player's char is unknown struct EChar : public NLMISC::Exception { - EChar( const NLMISC::CEntityId& id ) : Exception ("The char "+id.toString()+" doesn't exist") {}; + EChar( const NLMISC::CEntityId& id ) : Exception ("The char "+id.toString()+" doesn't exist") {} }; ///init the manager diff --git a/code/ryzom/server/src/entities_game_service/progression/progression_pve.h b/code/ryzom/server/src/entities_game_service/progression/progression_pve.h index 4526c67f6..54cd5f0f2 100644 --- a/code/ryzom/server/src/entities_game_service/progression/progression_pve.h +++ b/code/ryzom/server/src/entities_game_service/progression/progression_pve.h @@ -64,7 +64,7 @@ public: }; /// ctor - CSkillProgress() {}; + CSkillProgress() {} /// dtor virtual ~CSkillProgress() { _SkillsProgress.clear(); } @@ -97,7 +97,7 @@ public: typedef std::map< TDataSetRow, CSkillProgress * > TSkillProgressPerOpponentContainer; /// ctor - CCharacterActions() {}; + CCharacterActions() {} /// dtor+ virtual ~CCharacterActions(); diff --git a/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_base.h b/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_base.h index c26b9f8bc..d48dcdb96 100644 --- a/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_base.h +++ b/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_base.h @@ -56,6 +56,8 @@ public: QuitTeam, }; + virtual ~IPVP() {} + /// get PVP mode to send to the client virtual PVP_MODE::TPVPMode getPVPMode() const = 0; diff --git a/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_interface.h b/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_interface.h index 8524320df..dd5c92b68 100644 --- a/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_interface.h +++ b/code/ryzom/server/src/entities_game_service/pvp_manager/pvp_interface.h @@ -38,6 +38,7 @@ class CGameItemPtr; class IPVPInterface : public NLMISC::CRefCount { public: + virtual ~IPVPInterface() {} ///\name PVP MODE FEATURES DEPENDANTS //@{ /// return pvp relation between the two players @@ -61,8 +62,6 @@ public: /// killed character in PvP faction virtual void characterKilledInPvPFaction( CCharacter * character, PVP_CLAN::TPVPClan looserFaction, sint32 factionPoint ) const = 0; //@} - -private: }; #endif // RY_PVP_INTERFACE_H diff --git a/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.h b/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.h index fac7fa505..b01bfaa9b 100644 --- a/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.h +++ b/code/ryzom/server/src/entities_game_service/shop_type/item_for_sale.h @@ -33,7 +33,7 @@ class IItemTrade : public NLMISC::CRefCount public: // virtual destructor - virtual ~IItemTrade() {}; + virtual ~IItemTrade() {} // sheet id virtual NLMISC::CSheetId getSheetId() const = 0; diff --git a/code/ryzom/server/src/entities_game_service/world_instances.h b/code/ryzom/server/src/entities_game_service/world_instances.h index eb8c2728c..63a70204d 100644 --- a/code/ryzom/server/src/entities_game_service/world_instances.h +++ b/code/ryzom/server/src/entities_game_service/world_instances.h @@ -56,7 +56,7 @@ public: struct IAIInstanceReady { virtual void onAiInstanceReady(const CReportStaticAIInstanceMsg &msg) = 0; - virtual void onAiInstanceDown(const CReportStaticAIInstanceMsg &msg) {}; // not mandatory + virtual void onAiInstanceDown(const CReportStaticAIInstanceMsg &msg) {} // not mandatory }; /// Singleton access diff --git a/code/ryzom/server/src/entities_game_service/zone_manager.h b/code/ryzom/server/src/entities_game_service/zone_manager.h index 5aeb2a4a0..065e4548f 100644 --- a/code/ryzom/server/src/entities_game_service/zone_manager.h +++ b/code/ryzom/server/src/entities_game_service/zone_manager.h @@ -318,7 +318,7 @@ public: }; // default constructor - CZoneManager() : DepositSearchTime(50) {}; + CZoneManager() : DepositSearchTime(50) {} ~CZoneManager(); diff --git a/code/ryzom/server/src/frontend_service/selection_generator.h b/code/ryzom/server/src/frontend_service/selection_generator.h index 6f94e2e68..048e391a4 100644 --- a/code/ryzom/server/src/frontend_service/selection_generator.h +++ b/code/ryzom/server/src/frontend_service/selection_generator.h @@ -42,10 +42,10 @@ public: typedef TSelectionLevel result_type; /// Initialization of a selection cycle - virtual void init( TSelectionLevel nblevels ) {}; + virtual void init( TSelectionLevel nblevels ) {} /// Change the number of levels without restarting the cycle - virtual void changeNbLevels( TSelectionLevel nblevels ) {}; + virtual void changeNbLevels( TSelectionLevel nblevels ) {} /// Return the next level to select virtual TSelectionLevel getNext() = 0; diff --git a/code/ryzom/server/src/general_utilities_service/gus_chat.h b/code/ryzom/server/src/general_utilities_service/gus_chat.h index 077f24506..2c49c14f8 100644 --- a/code/ryzom/server/src/general_utilities_service/gus_chat.h +++ b/code/ryzom/server/src/general_utilities_service/gus_chat.h @@ -71,6 +71,7 @@ namespace GUS //----------------------------------------------------------------------------- // Public interface //----------------------------------------------------------------------------- + virtual ~CChatChannel() {} // open the chat channel on all clients and set its name // If historySize is set other than 0, the the chat channel is diff --git a/code/ryzom/server/src/general_utilities_service/gus_client_manager.h b/code/ryzom/server/src/general_utilities_service/gus_client_manager.h index c6f8b3f07..6714e4185 100644 --- a/code/ryzom/server/src/general_utilities_service/gus_client_manager.h +++ b/code/ryzom/server/src/general_utilities_service/gus_client_manager.h @@ -93,6 +93,7 @@ namespace GUS class IConnectionHandler: public NLMISC::CRefCount { public: + virtual ~IConnectionHandler() {} virtual void connect(TClientId)=0; virtual void disconnect(TClientId)=0; }; diff --git a/code/ryzom/server/src/general_utilities_service/gus_mirror.h b/code/ryzom/server/src/general_utilities_service/gus_mirror.h index 096685d50..97e8d97c6 100644 --- a/code/ryzom/server/src/general_utilities_service/gus_mirror.h +++ b/code/ryzom/server/src/general_utilities_service/gus_mirror.h @@ -40,15 +40,15 @@ namespace GUS { public: // General callback - virtual void mirrorIsReady(CGusMirror *gusMirror) {}; - virtual void serviceMirrorUp(CGusMirror *gusMirror, const std::string &serviceName, NLNET::TServiceId serviceId) {}; - virtual void serviceMirrorDown(CGusMirror *gusMirror, const std::string &serviceName, NLNET::TServiceId serviceId) {}; - virtual void mirrorTickUpdate(CGusMirror *gusMirror) {}; + virtual void mirrorIsReady(CGusMirror *gusMirror) {} + virtual void serviceMirrorUp(CGusMirror *gusMirror, const std::string &serviceName, NLNET::TServiceId serviceId) {} + virtual void serviceMirrorDown(CGusMirror *gusMirror, const std::string &serviceName, NLNET::TServiceId serviceId) {} + virtual void mirrorTickUpdate(CGusMirror *gusMirror) {} // mirror updates - virtual void entityAdded(CGusMirror *gusMirror, CMirroredDataSet *dataSet, const TDataSetRow &entityIndex) {}; - virtual void entityRemoved(CGusMirror *gusMirror, CMirroredDataSet *dataSet, const TDataSetRow &entityIndex, const NLMISC::CEntityId *entityId) {}; - virtual void propertyChanged(CGusMirror *gusMirror, CMirroredDataSet *dataSet, const TDataSetRow &entityIndex, TPropertyIndex propIndex) {}; + virtual void entityAdded(CGusMirror *gusMirror, CMirroredDataSet *dataSet, const TDataSetRow &entityIndex) {} + virtual void entityRemoved(CGusMirror *gusMirror, CMirroredDataSet *dataSet, const TDataSetRow &entityIndex, const NLMISC::CEntityId *entityId) {} + virtual void propertyChanged(CGusMirror *gusMirror, CMirroredDataSet *dataSet, const TDataSetRow &entityIndex, TPropertyIndex propIndex) {} IMirrorModuleCallback(); virtual ~IMirrorModuleCallback(); diff --git a/code/ryzom/server/src/general_utilities_service/gus_module_factory.h b/code/ryzom/server/src/general_utilities_service/gus_module_factory.h index 57c39bf06..fc9a62d38 100644 --- a/code/ryzom/server/src/general_utilities_service/gus_module_factory.h +++ b/code/ryzom/server/src/general_utilities_service/gus_module_factory.h @@ -41,7 +41,7 @@ namespace GUS class IModuleBuilder: public NLMISC::CRefCount { public: - virtual ~IModuleBuilder() {}; + virtual ~IModuleBuilder() {} virtual const NLMISC::CSString& getName() const=0; virtual const NLMISC::CSString& getArgs() const=0; virtual const NLMISC::CSString& getDescription() const=0; diff --git a/code/ryzom/server/src/general_utilities_service/rfr_ryzom_file_retriever.cpp b/code/ryzom/server/src/general_utilities_service/rfr_ryzom_file_retriever.cpp index 6e0f4940f..014f679e4 100644 --- a/code/ryzom/server/src/general_utilities_service/rfr_ryzom_file_retriever.cpp +++ b/code/ryzom/server/src/general_utilities_service/rfr_ryzom_file_retriever.cpp @@ -472,9 +472,11 @@ bool CRyzomFileRetrieverImplementation::downloadBackupFiles(const CSString& shar continue; // generate a local filename for the downloaded file - CSString localFileName= NLMISC::CPath::standardizePath(localDirectory)+(fileName+"_"+fdc[i].FileName); - localFileName = localFileName.replace("/","_"); - localFileName = localFileName.replace(".","_"); + CSString fdcFileNameUnderscore = fdc[i].FileName; + fdcFileNameUnderscore = fdcFileNameUnderscore.replace("/","_"); + CSString localFileNameWithoutPath = fileName + "_" + fdcFileNameUnderscore; + localFileNameWithoutPath = localFileNameWithoutPath.replace(".","_"); + CSString localFileName = NLMISC::CPath::standardizePath(localDirectory) + localFileNameWithoutPath; nlinfo("Requesting file download: REMOTE:%s => LOCAL:%s",fdc[i].FileName.c_str(),localFileName.c_str()); // put in a request for the file to be retrieved diff --git a/code/ryzom/server/src/general_utilities_service/rs_remote_saves.h b/code/ryzom/server/src/general_utilities_service/rs_remote_saves.h index 5ab25b8ac..1d91279bf 100644 --- a/code/ryzom/server/src/general_utilities_service/rs_remote_saves.h +++ b/code/ryzom/server/src/general_utilities_service/rs_remote_saves.h @@ -68,6 +68,8 @@ namespace SAVES class CRemoteSavesManager: public NLMISC::CRefCount { public: + virtual ~CRemoteSavesManager() {} + static CRemoteSavesManager* getInstance(); // interface used by CRemoteSavesInterface objects in their ctor to declare themselves diff --git a/code/ryzom/server/src/general_utilities_service/saves_unit.h b/code/ryzom/server/src/general_utilities_service/saves_unit.h index 3ea79287a..9685aa7bb 100644 --- a/code/ryzom/server/src/general_utilities_service/saves_unit.h +++ b/code/ryzom/server/src/general_utilities_service/saves_unit.h @@ -141,6 +141,9 @@ namespace SAVES // ctor ISavesUnitElement(); + // dtor + virtual ~ISavesUnitElement() {} + // perform the 'rescan' operation for this element - verify whether anything has changed // the parent parameter is used to supply addNew(), addChange() and addDeleted() methods // to signal any detected changes diff --git a/code/ryzom/server/src/general_utilities_service/stat_char_commands.cpp b/code/ryzom/server/src/general_utilities_service/stat_char_commands.cpp index f72db4bbd..4a3b98bcd 100644 --- a/code/ryzom/server/src/general_utilities_service/stat_char_commands.cpp +++ b/code/ryzom/server/src/general_utilities_service/stat_char_commands.cpp @@ -128,7 +128,7 @@ NLMISC_CATEGORISED_COMMAND(Stats,listCharNames,"display the names of the charact std::vector files; NLMISC::CPath::getPathContent(STAT_GLOBALS::getInputFilePath().c_str(),false,false,true,files); - for (uint32 i=files.size();i--;) + for (uint32 i=(uint32)files.size();i--;) { if (!NLMISC::testWildCard(NLMISC::CFile::getFilename(files[i]),wildcard)) { @@ -227,7 +227,8 @@ NLMISC_CATEGORISED_COMMAND(Stats,jobsPromote,"pause execution of jobs","" if (args.size()!=1) return false; - uint32 idx= atoi(args[0].c_str()); + uint32 idx; + NLMISC::fromString(args[0], idx); if ( (idx==0 && args[0]!="0") ) { nlwarning("Argument is not a valid job id - should be a number"); @@ -249,7 +250,8 @@ NLMISC_CATEGORISED_COMMAND(Stats,JobUpdatesPerUpdate,"set or display the number if (args.size()==1) { - uint32 count= atoi(args[0].c_str()); + uint32 count; + NLMISC::fromString(args[0], count); if ( (count==0 && args[0]!="0") ) { nlwarning("Argument is not a valid number"); @@ -311,7 +313,8 @@ NLMISC_CATEGORISED_COMMAND(Stats,jobsDisplayDetails,"display detailed info for t case 1: { - uint32 idx= atoi(args[0].c_str()); + uint32 idx; + NLMISC::fromString(args[0], idx); if ( (idx==0 && args[0]!="0") ) { nlwarning("Argument is not a valid job id - should be a number"); @@ -476,8 +479,11 @@ NLMISC_CATEGORISED_COMMAND(Stats,charScanScriptDeleteLine,"","") return false; } + uint32 line; + NLMISC::fromString(args[0], line); + // line numbering starts at 1 so an invalid number will be inored anyway - return TheCharScanScriptFile->deleteLine(atoi(args[0].c_str())); + return TheCharScanScriptFile->deleteLine(line); } NLMISC_CATEGORISED_COMMAND(Stats,charScanScriptAddInfoExtractor,""," []") @@ -761,7 +767,7 @@ NLMISC_CATEGORISED_COMMAND(Stats,charScanScriptTestFilteredFileList,"list the se return false; // generating a new file list - if (args[0]==CSString("generate").left(args[0].size())) + if (args[0]==CSString("generate").left((uint)args[0].size())) { if (TheCharScanScriptFile==NULL) { @@ -796,7 +802,7 @@ NLMISC_CATEGORISED_COMMAND(Stats,charScanScriptTestFilteredFileList,"list the se } // displaying the last generated file list - if (args[0]==CSString("display").left(args[0].size())) + if (args[0]==CSString("display").left((uint)args[0].size())) { nlinfo("Filtered file list for the current job"); fdc.display(&log); diff --git a/code/ryzom/server/src/general_utilities_service/stat_char_filter_factory.cpp b/code/ryzom/server/src/general_utilities_service/stat_char_filter_factory.cpp index 6902fe6ad..7c5f850fe 100644 --- a/code/ryzom/server/src/general_utilities_service/stat_char_filter_factory.cpp +++ b/code/ryzom/server/src/general_utilities_service/stat_char_filter_factory.cpp @@ -63,7 +63,7 @@ void CCharFilterFactory::displayFilterList(NLMISC::CLog* log) { std::string s= _Filters[i]->getName(); if (s.size()>longestName) - longestName=s.size(); + longestName=(uint32)s.size(); } // iterate over the filters displaying names and description @@ -75,7 +75,7 @@ void CCharFilterFactory::displayFilterList(NLMISC::CLog* log) uint32 CCharFilterFactory::getFilterBuilderCount() { - return _Filters.size(); + return (uint32)_Filters.size(); } ICharFilterBuilder* CCharFilterFactory::getFilterBuilder(uint32 idx) diff --git a/code/ryzom/server/src/general_utilities_service/stat_char_filter_factory.h b/code/ryzom/server/src/general_utilities_service/stat_char_filter_factory.h index 656cc0cca..a96b7d6a5 100644 --- a/code/ryzom/server/src/general_utilities_service/stat_char_filter_factory.h +++ b/code/ryzom/server/src/general_utilities_service/stat_char_filter_factory.h @@ -52,6 +52,7 @@ public: class ICharFilterBuilder: public NLMISC::CRefCount { public: + virtual ~ICharFilterBuilder() {} virtual const char* getName()=0; virtual const char* getDescription()=0; virtual ICharFilter* build(const std::string& rawArgs)=0; diff --git a/code/ryzom/server/src/general_utilities_service/stat_char_info_extractor_factory.cpp b/code/ryzom/server/src/general_utilities_service/stat_char_info_extractor_factory.cpp index 0ff961def..da481cf03 100644 --- a/code/ryzom/server/src/general_utilities_service/stat_char_info_extractor_factory.cpp +++ b/code/ryzom/server/src/general_utilities_service/stat_char_info_extractor_factory.cpp @@ -63,7 +63,7 @@ void CCharInfoExtractorFactory::displayInfoExtractorList(NLMISC::CLog* log) { std::string s= _InfoExtractors[i]->getName(); if (s.size()>longestName) - longestName=s.size(); + longestName=(uint32)s.size(); } // iterate over the infoExtractors displaying names and description @@ -75,7 +75,7 @@ void CCharInfoExtractorFactory::displayInfoExtractorList(NLMISC::CLog* log) uint32 CCharInfoExtractorFactory::getInfoExtractorBuilderCount() { - return _InfoExtractors.size(); + return (uint32)_InfoExtractors.size(); } ICharInfoExtractorBuilder* CCharInfoExtractorFactory::getInfoExtractorBuilder(uint32 idx) diff --git a/code/ryzom/server/src/general_utilities_service/stat_char_info_extractor_factory.h b/code/ryzom/server/src/general_utilities_service/stat_char_info_extractor_factory.h index 868004c39..cd182c169 100644 --- a/code/ryzom/server/src/general_utilities_service/stat_char_info_extractor_factory.h +++ b/code/ryzom/server/src/general_utilities_service/stat_char_info_extractor_factory.h @@ -56,6 +56,7 @@ public: class ICharInfoExtractorBuilder: public NLMISC::CRefCount { public: + virtual ~ICharInfoExtractorBuilder() {} virtual const char* getName() const=0; virtual const char* getDescription() const=0; virtual const char* getFields() const=0; diff --git a/code/ryzom/server/src/general_utilities_service/stat_char_scan_script.cpp b/code/ryzom/server/src/general_utilities_service/stat_char_scan_script.cpp index 48db0b447..030239d1e 100644 --- a/code/ryzom/server/src/general_utilities_service/stat_char_scan_script.cpp +++ b/code/ryzom/server/src/general_utilities_service/stat_char_scan_script.cpp @@ -298,7 +298,7 @@ void CCharScanScriptCommandRegistry::displayScriptCommands(NLMISC::CLog* log) { std::string s= _ScriptCommands[i]->getName(); if (s.size()>longestName) - longestName=s.size(); + longestName=(uint32)s.size(); } // iterate over the script commands displaying names and description diff --git a/code/ryzom/server/src/general_utilities_service/stat_character_scan_job.cpp b/code/ryzom/server/src/general_utilities_service/stat_character_scan_job.cpp index 4b01b8574..9b85fb3b3 100644 --- a/code/ryzom/server/src/general_utilities_service/stat_character_scan_job.cpp +++ b/code/ryzom/server/src/general_utilities_service/stat_character_scan_job.cpp @@ -293,7 +293,7 @@ bool CCharacterScanJob::runForFile(const std::string& fileName) c.apply(pdr); // iterate over the filters executing their core code - for (uint32 i=_Filters.size();i--;) + for (uint32 i=(uint32)_Filters.size();i--;) { if (!_Filters[i]->evaluate(&c)) return true; diff --git a/code/ryzom/server/src/general_utilities_service/stat_file_list_builder_factory.cpp b/code/ryzom/server/src/general_utilities_service/stat_file_list_builder_factory.cpp index e6e860966..c05576c22 100644 --- a/code/ryzom/server/src/general_utilities_service/stat_file_list_builder_factory.cpp +++ b/code/ryzom/server/src/general_utilities_service/stat_file_list_builder_factory.cpp @@ -63,7 +63,7 @@ void CFileListBuilderFactory::displayFileListBuilderList(NLMISC::CLog* log) { std::string s= _FileLists[i]->getName(); if (s.size()>longestName) - longestName=s.size(); + longestName=(uint32)s.size(); } // iterate over the filters displaying names and description @@ -75,7 +75,7 @@ void CFileListBuilderFactory::displayFileListBuilderList(NLMISC::CLog* log) uint32 CFileListBuilderFactory::getFileListBuilderCount() { - return _FileLists.size(); + return (uint32)_FileLists.size(); } IFileListBuilderBuilder* CFileListBuilderFactory::getFileListBuilder(uint32 idx) diff --git a/code/ryzom/server/src/general_utilities_service/stat_file_list_builder_factory.h b/code/ryzom/server/src/general_utilities_service/stat_file_list_builder_factory.h index fbfb5dc61..367c0caa2 100644 --- a/code/ryzom/server/src/general_utilities_service/stat_file_list_builder_factory.h +++ b/code/ryzom/server/src/general_utilities_service/stat_file_list_builder_factory.h @@ -54,6 +54,7 @@ public: class IFileListBuilderBuilder: public NLMISC::CRefCount { public: + virtual ~IFileListBuilderBuilder() {} virtual const char* getName()=0; virtual const char* getDescription()=0; virtual IFileListBuilder* build(const std::string& rawArgs)=0; diff --git a/code/ryzom/server/src/general_utilities_service/stat_globals.cpp b/code/ryzom/server/src/general_utilities_service/stat_globals.cpp index af1150b0f..a959fb751 100644 --- a/code/ryzom/server/src/general_utilities_service/stat_globals.cpp +++ b/code/ryzom/server/src/general_utilities_service/stat_globals.cpp @@ -61,19 +61,19 @@ namespace STAT_GLOBALS NLMISC::CSString getInputFilePath(const NLMISC::CSString& path) { NLMISC::CSString pathRoot= NLMISC::CPath::standardizePath(InputFileDirectory.get()); - return (path.left(pathRoot.size())==pathRoot)? path: pathRoot+path; + return (path.left((uint)pathRoot.size())==pathRoot)? path: pathRoot+path; } NLMISC::CSString getScriptFilePath(const NLMISC::CSString& path) { NLMISC::CSString pathRoot= NLMISC::CPath::standardizePath(ScriptDirectory.get()); - return (path.left(pathRoot.size())==pathRoot)? path: pathRoot+path; + return (path.left((uint)pathRoot.size())==pathRoot)? path: pathRoot+path; } NLMISC::CSString getOutputFilePath(const NLMISC::CSString& path) { NLMISC::CSString pathRoot= NLMISC::CPath::standardizePath(OutputDirectory.get()); - return (path.left(pathRoot.size())==pathRoot)? path: pathRoot+path; + return (path.left((uint)pathRoot.size())==pathRoot)? path: pathRoot+path; } diff --git a/code/ryzom/server/src/general_utilities_service/stat_job_manager.cpp b/code/ryzom/server/src/general_utilities_service/stat_job_manager.cpp index 818c509d7..6c5a8c008 100644 --- a/code/ryzom/server/src/general_utilities_service/stat_job_manager.cpp +++ b/code/ryzom/server/src/general_utilities_service/stat_job_manager.cpp @@ -131,7 +131,7 @@ void CJobManager::serviceUpdate() uint32 CJobManager::addJob(NLMISC::CSmartPtr job) { nlassert(job!=NULL); - uint32 id= _Jobs.size(); + uint32 id= (uint32)_Jobs.size(); _UnfinishedJobs.push_back(id); _Jobs.push_back(job); return id; diff --git a/code/ryzom/server/src/general_utilities_service/stat_user_file_list_builders.cpp b/code/ryzom/server/src/general_utilities_service/stat_user_file_list_builders.cpp index 3f3bbb8c7..c2a5658d5 100644 --- a/code/ryzom/server/src/general_utilities_service/stat_user_file_list_builders.cpp +++ b/code/ryzom/server/src/general_utilities_service/stat_user_file_list_builders.cpp @@ -73,7 +73,8 @@ FILE_LIST_BUILDER(MinFileSize,"") return false; } - for (uint32 i=fdc.size();i--;) + uint32 ttlNumFiles= fdc.size(); + for (uint32 i=ttlNumFiles;i--;) { if (fdc[i].FileSize") return false; } - for (uint32 i=fdc.size();i--;) + uint32 ttlNumFiles= fdc.size(); + for (uint32 i=ttlNumFiles;i--;) { if (fdc[i].FileSize>maxSize) fdc.removeFile(i); diff --git a/code/ryzom/server/src/general_utilities_service/stats_guild_scan_job.h b/code/ryzom/server/src/general_utilities_service/stats_guild_scan_job.h index e75564e49..ebcc43e7e 100644 --- a/code/ryzom/server/src/general_utilities_service/stats_guild_scan_job.h +++ b/code/ryzom/server/src/general_utilities_service/stats_guild_scan_job.h @@ -53,7 +53,7 @@ public: private: // private data - internal to job - typedef enum { INIT, WORK, CLOSED, ERROR } TState; + enum TState { INIT, WORK, CLOSED, ERROR }; TState _State; uint32 _NextFile; CFileDescriptionContainer _Files; diff --git a/code/ryzom/server/src/gpm_service/cell.h b/code/ryzom/server/src/gpm_service/cell.h index 054156dbc..a4846a7a6 100644 --- a/code/ryzom/server/src/gpm_service/cell.h +++ b/code/ryzom/server/src/gpm_service/cell.h @@ -34,7 +34,7 @@ class CCell { public: /// default constructor - CCell() : _LastVisionUpdate(0) {}; + CCell() : _LastVisionUpdate(0) {} /// initialisation void init( sint32 cellId ) diff --git a/code/ryzom/server/src/input_output_service/chat_manager.h b/code/ryzom/server/src/input_output_service/chat_manager.h index 8fbc34deb..811bdc710 100644 --- a/code/ryzom/server/src/input_output_service/chat_manager.h +++ b/code/ryzom/server/src/input_output_service/chat_manager.h @@ -58,13 +58,13 @@ public : /// exception thrown when client is unknown struct EChatClient : public NLMISC::Exception { - EChatClient( const NLMISC::CEntityId& id ) : Exception ("Don't have chat infos for the char "+id.toString()) {}; + EChatClient( const NLMISC::CEntityId& id ) : Exception ("Don't have chat infos for the char "+id.toString()) {} }; /// exception thrown when group is unknown struct EChatGroup : public NLMISC::Exception { - EChatGroup( const TGroupId& gId ) : Exception ("Can't find the group "+gId.toString()) {}; + EChatGroup( const TGroupId& gId ) : Exception ("Can't find the group "+gId.toString()) {} }; /** diff --git a/code/ryzom/server/src/input_output_service/stdpch.h b/code/ryzom/server/src/input_output_service/stdpch.h index c1a8fea5c..743601942 100644 --- a/code/ryzom/server/src/input_output_service/stdpch.h +++ b/code/ryzom/server/src/input_output_service/stdpch.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include "nel/georges/load_form.h" diff --git a/code/ryzom/server/src/patchman_service/cpr_client_patch_repository.cpp b/code/ryzom/server/src/patchman_service/cpr_client_patch_repository.cpp index 9f24857ba..43d5f7d63 100644 --- a/code/ryzom/server/src/patchman_service/cpr_client_patch_repository.cpp +++ b/code/ryzom/server/src/patchman_service/cpr_client_patch_repository.cpp @@ -97,7 +97,7 @@ protected: static uint32 getFileVersion(const NLMISC::CSString& fileName) { // start at the back of the file name and scan forwards until we find a '/' or '\\' or ':' or a digit - uint32 i= fileName.size(); + uint32 i= (uint32)fileName.size(); while (i--) { char c= fileName[i]; diff --git a/code/ryzom/server/src/patchman_service/file_manager.cpp b/code/ryzom/server/src/patchman_service/file_manager.cpp index 4bd619cd6..7c37903a9 100644 --- a/code/ryzom/server/src/patchman_service/file_manager.cpp +++ b/code/ryzom/server/src/patchman_service/file_manager.cpp @@ -459,9 +459,9 @@ namespace PATCHMAN NLMISC::CPath::getPathContent(_Root+directoryName,false,true,false,pathContents); // run through the directories we found... - for (uint32 i=pathContents.size();i--;) + for (uint32 i=(uint32)pathContents.size();i--;) { - NLMISC::CSString childDirectoryName= NLMISC::CSString(pathContents[i]).leftCrop(_Root.size()); + NLMISC::CSString childDirectoryName= NLMISC::CSString(pathContents[i]).leftCrop((uint32)_Root.size()); // make sure they exist in the '_DirectoryTree' map _DirectoryTree[childDirectoryName]; @@ -484,14 +484,14 @@ namespace PATCHMAN NLMISC::CPath::getPathContent(_Root+directoryName,false,false,true,pathContents); // run through the files adding them to ourself - for (uint32 i=pathContents.size();i--;) + for (uint32 i=(uint32)pathContents.size();i--;) { // if the file is system file then skip it if (pathContents[i].find("/.")!=std::string::npos) continue; // construct the file name - NLMISC::CSString fileName= NLMISC::CSString(pathContents[i]).leftCrop(_Root.size()); + NLMISC::CSString fileName= NLMISC::CSString(pathContents[i]).leftCrop((uint32)_Root.size()); // get hold of the directory entry for this file (or create a new one if not exist) and update it _IndexFileIsUpToDate&= _DirectoryTree[directoryName][fileName].updateFileInfo(fileName,pathContents[i],SFileInfo::RECALCULATE_IF_CHANGED,updateListener); } @@ -601,7 +601,7 @@ namespace PATCHMAN // read in the file FILE* inf= fopen(fileName.c_str(),"rb"); BOMB_IF(inf==NULL,"Failed to open input file for reading: "+fileName,return false); - uint32 bytesRead=fread(&_CacheBuffer[newFileEntry.StartOffset],1,fileSize,inf); + uint32 bytesRead=(uint32)fread(&_CacheBuffer[newFileEntry.StartOffset],1,fileSize,inf); fclose(inf); BOMB_IF(bytesRead!=fileSize,"Failed to read data from input file: "+fileName,return false); @@ -732,7 +732,7 @@ NLMISC_CATEGORISED_COMMAND(patchman,fileManagerSave,"Save a file via the file ma CSString fileName= args[0]; CMemStream data; - data.serialBuffer((uint8*)(&args[1][0]),args[1].size()); + data.serialBuffer((uint8*)(&args[1][0]),(uint32)args[1].size()); CFileManager::getInstance().save(fileName,data); return true; diff --git a/code/ryzom/server/src/patchman_service/file_receiver.cpp b/code/ryzom/server/src/patchman_service/file_receiver.cpp index a3ca87da0..278f24059 100644 --- a/code/ryzom/server/src/patchman_service/file_receiver.cpp +++ b/code/ryzom/server/src/patchman_service/file_receiver.cpp @@ -347,7 +347,7 @@ namespace PATCHMAN // add the data to the file CSString& theBuffer= theRequest->DataSoFar; - uint32 oldSize= theBuffer.size(); + uint32 oldSize= (uint32)theBuffer.size(); theBuffer.resize(oldSize+data.getBufferSize()); memcpy(&(theBuffer[oldSize]), data.getBuffer(), data.getBufferSize()); @@ -355,7 +355,7 @@ namespace PATCHMAN if (theRequest->DataSoFar.size()>=theRequest->ExpectedFileSize) { // we've reached the end of file - _dealWithReceivedFile(sender,theRequest,NLNET::TBinBuffer((const uint8 *)&theRequest->DataSoFar[0],theRequest->DataSoFar.size())); + _dealWithReceivedFile(sender,theRequest,NLNET::TBinBuffer((const uint8 *)&theRequest->DataSoFar[0],(uint32)theRequest->DataSoFar.size())); return; } @@ -374,7 +374,7 @@ namespace PATCHMAN } // log our progress - _downloadLog(fileName,theRequest->DataSoFar.size(),theRequest->ExpectedFileSize); + _downloadLog(fileName,(uint32)theRequest->DataSoFar.size(),theRequest->ExpectedFileSize); } void CFileReceiver::cbFileDataFailure(NLNET::IModuleProxy *sender, const std::string &fileName) diff --git a/code/ryzom/server/src/patchman_service/file_repository.cpp b/code/ryzom/server/src/patchman_service/file_repository.cpp index d1d2d4b54..72881f587 100644 --- a/code/ryzom/server/src/patchman_service/file_repository.cpp +++ b/code/ryzom/server/src/patchman_service/file_repository.cpp @@ -332,7 +332,7 @@ namespace PATCHMAN CFileReceiverProxy rr(sender); if (ok && !result.empty()) { - rr.cbFileData(_Parent,fileName,startOffset,NLNET::TBinBuffer((const uint8 *)&result[0],result.size())); + rr.cbFileData(_Parent,fileName,startOffset,NLNET::TBinBuffer((const uint8 *)&result[0],(uint32)result.size())); } else { diff --git a/code/ryzom/server/src/patchman_service/module_admin_itf.h b/code/ryzom/server/src/patchman_service/module_admin_itf.h index d9649f603..a0d4aa34e 100644 --- a/code/ryzom/server/src/patchman_service/module_admin_itf.h +++ b/code/ryzom/server/src/patchman_service/module_admin_itf.h @@ -71,9 +71,9 @@ namespace PATCHMAN // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); @@ -211,9 +211,9 @@ namespace PATCHMAN // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); @@ -371,9 +371,9 @@ namespace PATCHMAN // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); @@ -504,9 +504,9 @@ namespace PATCHMAN // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); @@ -711,9 +711,9 @@ namespace PATCHMAN // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); @@ -911,9 +911,9 @@ namespace PATCHMAN // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); diff --git a/code/ryzom/server/src/patchman_service/pam_patchman_admin_module.cpp b/code/ryzom/server/src/patchman_service/pam_patchman_admin_module.cpp index 0eaf4f946..60efeee33 100644 --- a/code/ryzom/server/src/patchman_service/pam_patchman_admin_module.cpp +++ b/code/ryzom/server/src/patchman_service/pam_patchman_admin_module.cpp @@ -436,7 +436,7 @@ NLMISC_CLASS_COMMAND_IMPL(CPatchmanAdminModule, download) } // iterate over matching files, adding them to the download list - for (uint32 i=fileInfo.size();i--;) + for (uint i=(uint)fileInfo.size();i--;) { _DownloadRequests[fileInfo[i].FileName]= NLMISC::CPath::standardizePath(destination); requestFile(fileInfo[i].FileName); diff --git a/code/ryzom/server/src/patchman_service/patchman_tester.h b/code/ryzom/server/src/patchman_service/patchman_tester.h index ccab3d800..16a620c1c 100644 --- a/code/ryzom/server/src/patchman_service/patchman_tester.h +++ b/code/ryzom/server/src/patchman_service/patchman_tester.h @@ -38,6 +38,8 @@ namespace PATCHMAN class CPatchmanTester { public: + virtual ~CPatchmanTester() {} + // this is a singleton so it has a getInstance() method to get to the singleton instance static CPatchmanTester& getInstance(); diff --git a/code/ryzom/server/src/patchman_service/repository.cpp b/code/ryzom/server/src/patchman_service/repository.cpp index b71c11ef2..a63a96bcd 100644 --- a/code/ryzom/server/src/patchman_service/repository.cpp +++ b/code/ryzom/server/src/patchman_service/repository.cpp @@ -52,7 +52,7 @@ NLMISC::CSString getRepositoryIndexFileName(const NLMISC::CSString& repositoryNa uint32 getFileVersion(const NLMISC::CSString& fileName) { // start at the back of the file name and scan forwards until we find a '/' or '\\' or ':' or a digit - uint32 i= fileName.size(); + uint32 i= (uint32)fileName.size(); while (i--) { char c= fileName[i]; @@ -184,9 +184,9 @@ void CRepository::updateFile(NLMISC::CSString fileName) nldebug(("GUSREP_Updating repository entry for file: '"+fileName+"'").c_str()); // if the name of the file that has changed contains the target directory name then crop it - if (fileName.left(_TargetDirectory.size())==_TargetDirectory) + if (fileName.left((uint32)_TargetDirectory.size())==_TargetDirectory) { - fileName=fileName.leftCrop(_TargetDirectory.size()); + fileName=fileName.leftCrop((uint32)_TargetDirectory.size()); } // lookup the file in the map @@ -219,9 +219,9 @@ void CRepository::addFileStub(NLMISC::CSString fileName) nldebug(("GUSREP_Adding repository stub for file: '"+fileName+"'").c_str()); // if the name of the file that has changed contains the target directory name then crop it - if (fileName.left(_TargetDirectory.size())==_TargetDirectory) + if (fileName.left((uint32)_TargetDirectory.size())==_TargetDirectory) { - fileName=fileName.leftCrop(_TargetDirectory.size()); + fileName=fileName.leftCrop((uint32)_TargetDirectory.size()); } // make sure the file didn't already exist in the map @@ -258,7 +258,7 @@ uint32 CRepository::update() // get hold of the file name for the next file // CSString fileName= NLMISC::CFile::getFilename(theFile.FileName); - CSString fileName= theFile.FileName.leftCrop(_TargetDirectory.size()); + CSString fileName= theFile.FileName.leftCrop((uint32)_TargetDirectory.size()); // extract the version number from the file name and skip the file if it's too recent or the version number was invalid uint32 fileVersion= getFileVersion(fileName); @@ -345,7 +345,7 @@ void CRepository::setVersion(uint32 version) uint32 CRepository::size() const { - return _Files.size(); + return (uint32)_Files.size(); } const CRepository::CFilesMapEntry& CRepository::operator[](const NLMISC::CSString& key) const diff --git a/code/ryzom/server/src/patchman_service/service_main.cpp b/code/ryzom/server/src/patchman_service/service_main.cpp index aa0cfbffb..7e61baba8 100644 --- a/code/ryzom/server/src/patchman_service/service_main.cpp +++ b/code/ryzom/server/src/patchman_service/service_main.cpp @@ -115,12 +115,12 @@ void CTaskScheduler::update() // check to see if we've broken our max sheduled tasks record... if (_MaxTasks < _Tasks.size()) { - _MaxTasks = _Tasks.size(); + _MaxTasks = (uint32)_Tasks.size(); nldebug("New scheduled task record: %u",_MaxTasks); } // iterate over all scheduled tasks (we go backwards to simplify deletion of executed tasks as we go) - for (uint32 i=_Tasks.size();i--;) + for (uint32 i=(uint32)_Tasks.size();i--;) { // get a refference to the next task STask& theTask= _Tasks[i]; diff --git a/code/ryzom/server/src/pd_lib/pds_common.h b/code/ryzom/server/src/pd_lib/pds_common.h index 040c0354b..18cb93c4a 100644 --- a/code/ryzom/server/src/pd_lib/pds_common.h +++ b/code/ryzom/server/src/pd_lib/pds_common.h @@ -144,7 +144,7 @@ bool getProperty(xmlNodePtr node, const char* propName, T &result, const T &defa if (!NLMISC::CIXml::getPropertyString(res, node, propName)) { if (!quiet) - nlwarning("Couldn't get property '%s' in xml node, use '%s' value instead", propName, toString(defaultValue).c_str()); + nlwarning("Couldn't get property '%s' in xml node, use '%s' value instead", propName, NLMISC::toString(defaultValue).c_str()); result = defaultValue; return false; } diff --git a/code/ryzom/server/src/pd_support_service/stat_char_filter_factory.h b/code/ryzom/server/src/pd_support_service/stat_char_filter_factory.h index 656cc0cca..a96b7d6a5 100644 --- a/code/ryzom/server/src/pd_support_service/stat_char_filter_factory.h +++ b/code/ryzom/server/src/pd_support_service/stat_char_filter_factory.h @@ -52,6 +52,7 @@ public: class ICharFilterBuilder: public NLMISC::CRefCount { public: + virtual ~ICharFilterBuilder() {} virtual const char* getName()=0; virtual const char* getDescription()=0; virtual ICharFilter* build(const std::string& rawArgs)=0; diff --git a/code/ryzom/server/src/pd_support_service/stat_char_info_extractor_factory.h b/code/ryzom/server/src/pd_support_service/stat_char_info_extractor_factory.h index 868004c39..cd182c169 100644 --- a/code/ryzom/server/src/pd_support_service/stat_char_info_extractor_factory.h +++ b/code/ryzom/server/src/pd_support_service/stat_char_info_extractor_factory.h @@ -56,6 +56,7 @@ public: class ICharInfoExtractorBuilder: public NLMISC::CRefCount { public: + virtual ~ICharInfoExtractorBuilder() {} virtual const char* getName() const=0; virtual const char* getDescription() const=0; virtual const char* getFields() const=0; diff --git a/code/ryzom/server/src/pd_support_service/stat_file_list_builder_factory.h b/code/ryzom/server/src/pd_support_service/stat_file_list_builder_factory.h index fbfb5dc61..367c0caa2 100644 --- a/code/ryzom/server/src/pd_support_service/stat_file_list_builder_factory.h +++ b/code/ryzom/server/src/pd_support_service/stat_file_list_builder_factory.h @@ -54,6 +54,7 @@ public: class IFileListBuilderBuilder: public NLMISC::CRefCount { public: + virtual ~IFileListBuilderBuilder() {} virtual const char* getName()=0; virtual const char* getDescription()=0; virtual IFileListBuilder* build(const std::string& rawArgs)=0; diff --git a/code/ryzom/server/src/sabrina/faber_phrase.h b/code/ryzom/server/src/sabrina/faber_phrase.h index 8069dc4f6..4d85e8b53 100644 --- a/code/ryzom/server/src/sabrina/faber_phrase.h +++ b/code/ryzom/server/src/sabrina/faber_phrase.h @@ -64,21 +64,21 @@ public: /** * set the actor */ - virtual void setActor( const TDataSetRow &entityRowId ){}; + virtual void setActor( const TDataSetRow &entityRowId ){} /** * called at the end of the latency time */ - virtual void end(){}; + virtual void end(){} //@} ///\unused basic methods from CSPhrase //@{ - virtual void setPrimaryItem( CGameItemPtr itemPtr ){}; - virtual void setSecondaryItem( CGameItemPtr itemPtr ){}; - virtual void addConsumableItem( CGameItemPtr itemPtr ){}; - virtual void setPrimaryTarget( const TDataSetRow& ) {}; - virtual void addTargetEntity( const TDataSetRow& ) {}; + virtual void setPrimaryItem( CGameItemPtr itemPtr ){} + virtual void setSecondaryItem( CGameItemPtr itemPtr ){} + virtual void addConsumableItem( CGameItemPtr itemPtr ){} + virtual void setPrimaryTarget( const TDataSetRow& ) {} + virtual void addTargetEntity( const TDataSetRow& ) {} //@} inline const TDataSetRow & getActor() { return _ActorRowId;} diff --git a/code/ryzom/server/src/sabrina/harvest_phrase.h b/code/ryzom/server/src/sabrina/harvest_phrase.h index b5f290019..c300b1abd 100644 --- a/code/ryzom/server/src/sabrina/harvest_phrase.h +++ b/code/ryzom/server/src/sabrina/harvest_phrase.h @@ -62,11 +62,11 @@ public: ///\unused basic methods from CSPhrase //@{ - virtual void setPrimaryItem( CGameItemPtr itemPtr ){}; - virtual void setSecondaryItem( CGameItemPtr itemPtr ){}; - virtual void addConsumableItem( CGameItemPtr itemPtr ){}; - virtual void setPrimaryTarget( const TDataSetRow& ) {}; - virtual void addTargetEntity( const TDataSetRow& ) {}; + virtual void setPrimaryItem( CGameItemPtr itemPtr ){} + virtual void setSecondaryItem( CGameItemPtr itemPtr ){} + virtual void addConsumableItem( CGameItemPtr itemPtr ){} + virtual void setPrimaryTarget( const TDataSetRow& ) {} + virtual void addTargetEntity( const TDataSetRow& ) {} //@} //@} @@ -74,7 +74,7 @@ public: /** * set the actor */ - virtual void setActor( const TDataSetRow &entityRowId ){}; + virtual void setActor( const TDataSetRow &entityRowId ){} /** * called at the end of the latency time diff --git a/code/ryzom/server/src/sabrina/magic_phrase.h b/code/ryzom/server/src/sabrina/magic_phrase.h index fbfe5dee2..45ee645cd 100644 --- a/code/ryzom/server/src/sabrina/magic_phrase.h +++ b/code/ryzom/server/src/sabrina/magic_phrase.h @@ -78,17 +78,17 @@ public: virtual void execute(); virtual void apply(); virtual void stop(); - virtual void setPrimaryTarget( const TDataSetRow &entityRowId ){ _Targets[0] = entityRowId; }; - virtual void addTargetEntity( const TDataSetRow &entityRowId ){ _Targets.push_back(entityRowId);}; + virtual void setPrimaryTarget( const TDataSetRow &entityRowId ){ _Targets[0] = entityRowId; } + virtual void addTargetEntity( const TDataSetRow &entityRowId ){ _Targets.push_back(entityRowId);} //@} /// \name Unused virtual methods from CSPhrase //@{ virtual void setActor( const TDataSetRow & actorRowId ){ } - virtual void end(){}; - virtual void setPrimaryItem( CGameItemPtr itemPtr ){ }; - virtual void setSecondaryItem( CGameItemPtr itemPtr ){ }; - virtual void addConsumableItem( CGameItemPtr itemPtr ){ }; + virtual void end(){} + virtual void setPrimaryItem( CGameItemPtr itemPtr ){ } + virtual void setSecondaryItem( CGameItemPtr itemPtr ){ } + virtual void addConsumableItem( CGameItemPtr itemPtr ){ } //@} private: diff --git a/code/ryzom/server/src/sabrina/s_effect.h b/code/ryzom/server/src/sabrina/s_effect.h index ca34245ee..c706756eb 100644 --- a/code/ryzom/server/src/sabrina/s_effect.h +++ b/code/ryzom/server/src/sabrina/s_effect.h @@ -55,7 +55,7 @@ public: virtual bool update( uint32 & updateFlag ) = 0; /// callback called when the effect is actually removed. Does nothing by default - virtual void removed(){}; + virtual void removed(){} ///\name accessors //@{ diff --git a/code/ryzom/server/src/server_share/backup_service_itf.h b/code/ryzom/server/src/server_share/backup_service_itf.h index ed6aadc0d..5b1ffe352 100644 --- a/code/ryzom/server/src/server_share/backup_service_itf.h +++ b/code/ryzom/server/src/server_share/backup_service_itf.h @@ -63,9 +63,9 @@ namespace BS // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); @@ -185,9 +185,9 @@ namespace BS // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); diff --git a/code/ryzom/server/src/server_share/char_name_mapper_itf.h b/code/ryzom/server/src/server_share/char_name_mapper_itf.h index b7133fe9a..456bcc0c7 100644 --- a/code/ryzom/server/src/server_share/char_name_mapper_itf.h +++ b/code/ryzom/server/src/server_share/char_name_mapper_itf.h @@ -217,9 +217,9 @@ namespace CNM // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); @@ -330,9 +330,9 @@ namespace CNM // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); diff --git a/code/ryzom/server/src/server_share/chat_unifier_itf.h b/code/ryzom/server/src/server_share/chat_unifier_itf.h index 8b736a082..f284c8fbb 100644 --- a/code/ryzom/server/src/server_share/chat_unifier_itf.h +++ b/code/ryzom/server/src/server_share/chat_unifier_itf.h @@ -214,9 +214,9 @@ namespace CHATUNI // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); @@ -331,9 +331,9 @@ namespace CHATUNI // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); diff --git a/code/ryzom/server/src/server_share/command_executor_itf.h b/code/ryzom/server/src/server_share/command_executor_itf.h index dce7dce44..58a7f1c51 100644 --- a/code/ryzom/server/src/server_share/command_executor_itf.h +++ b/code/ryzom/server/src/server_share/command_executor_itf.h @@ -63,9 +63,9 @@ namespace CMDEXE // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); diff --git a/code/ryzom/server/src/server_share/entity_locator_itf.h b/code/ryzom/server/src/server_share/entity_locator_itf.h index 59459a82d..317ad5199 100644 --- a/code/ryzom/server/src/server_share/entity_locator_itf.h +++ b/code/ryzom/server/src/server_share/entity_locator_itf.h @@ -139,9 +139,9 @@ namespace ENTITYLOC // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); @@ -384,9 +384,9 @@ namespace ENTITYLOC // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); diff --git a/code/ryzom/server/src/server_share/logger_service_itf.h b/code/ryzom/server/src/server_share/logger_service_itf.h index 8996c1369..051cc85cb 100644 --- a/code/ryzom/server/src/server_share/logger_service_itf.h +++ b/code/ryzom/server/src/server_share/logger_service_itf.h @@ -983,9 +983,9 @@ namespace LGS // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); diff --git a/code/ryzom/server/src/server_share/mail_forum_itf.h b/code/ryzom/server/src/server_share/mail_forum_itf.h index aeaf0709b..b16cd7d24 100644 --- a/code/ryzom/server/src/server_share/mail_forum_itf.h +++ b/code/ryzom/server/src/server_share/mail_forum_itf.h @@ -63,9 +63,9 @@ namespace MFS // unused interceptors std::string fwdBuildModuleManifest() const { return std::string(); } - void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {}; - void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {}; + void fwdOnModuleUp(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleDown(NLNET::IModuleProxy *moduleProxy) {} + void fwdOnModuleSecurityChange(NLNET::IModuleProxy *moduleProxy) {} // process module message interceptor bool fwdOnProcessModuleMessage(NLNET::IModuleProxy *sender, const NLNET::CMessage &message); diff --git a/code/ryzom/server/src/server_share/mission_messages.h b/code/ryzom/server/src/server_share/mission_messages.h index d779b709d..9c03f1f91 100644 --- a/code/ryzom/server/src/server_share/mission_messages.h +++ b/code/ryzom/server/src/server_share/mission_messages.h @@ -56,7 +56,7 @@ public: property ("Length", PropUInt8, (uint8)0,Length); } - virtual void callback (const std::string &name, uint8 id) {}; + virtual void callback (const std::string &name, uint8 id) {} }; */ @@ -115,7 +115,7 @@ public: property ("RewardType", PropUInt8, (uint8)MISSION_DESC::NbReward, RewardType); } - virtual void callback (const std::string &name, uint8 id) {}; + virtual void callback (const std::string &name, uint8 id) {} }; */ diff --git a/code/ryzom/server/src/server_share/msg_ai_service.h b/code/ryzom/server/src/server_share/msg_ai_service.h index c62ca0283..132e56e1c 100644 --- a/code/ryzom/server/src/server_share/msg_ai_service.h +++ b/code/ryzom/server/src/server_share/msg_ai_service.h @@ -49,7 +49,7 @@ public: propertyCont ("Character", PropDataSetRow, Character); propertyCont ("Creature", PropDataSetRow, Creature); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -68,7 +68,7 @@ public: propertyCont ("Content", PropString, Content); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -94,7 +94,7 @@ public: propertyCont ("Params", PropString, Params); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -115,7 +115,7 @@ public: propertyCont ("GrpAlias", PropUInt32, GrpAlias); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -138,7 +138,7 @@ public: property ("TeamId", PropUInt16, CTEAM::InvalidTeamId, TeamId); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -160,7 +160,7 @@ public: // propertyCont ("OutpostNames", PropString, OutpostNames); // } // -// virtual void callback (const std::string &name, NLNET::TServiceId id) {}; +// virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} //}; //---------------------------------------------------------------------------- @@ -198,7 +198,7 @@ public: //// propertyCont ("Fames", PropString, DutyNames); // } // -// virtual void callback (const std::string &name, NLNET::TServiceId id) {}; +// virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} //}; //---------------------------------------------------------------------------- @@ -227,7 +227,7 @@ public: propertyCont ("Parameters", PropString, Parameters); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -253,7 +253,7 @@ public: // property ("GuildIndex", PropDataSetRow, TDataSetRow() ,GuildIndex); // } // -// virtual void callback (const std::string &name, NLNET::TServiceId id) {}; +// virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} //}; @@ -280,7 +280,7 @@ public: // property ("GuildId", PropDataSetRow, TDataSetRow() ,GuildId); // } // -// virtual void callback (const std::string &name, NLNET::TServiceId id) {}; +// virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} //}; //---------------------------------------------------------------------------- @@ -299,7 +299,7 @@ public: property ("BotRowId", PropDataSetRow, TDataSetRow() , BotRowId); property ("Heading", PropFloat,0.0f,Heading); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -317,7 +317,7 @@ public: property ("PlayerRowId", PropDataSetRow, TDataSetRow(), PlayerRowId); property ("TargetRowId", PropDataSetRow, TDataSetRow(), TargetRowId); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -336,7 +336,7 @@ public: property ("PlayerRowId", PropDataSetRow, TDataSetRow(), PlayerRowId); property ("CreatureRowId", PropDataSetRow, TDataSetRow(), CreatureRowId); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -365,7 +365,7 @@ public: property ("PlayerRowId", PropDataSetRow, TDataSetRow(), PlayerRowId); property ("TargetRowId", PropDataSetRow, TDataSetRow(), TargetRowId); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -394,7 +394,7 @@ public: property ("PlayerRowId", PropDataSetRow, TDataSetRow(), PlayerRowId); property ("TargetRowId", PropDataSetRow, TDataSetRow(), TargetRowId); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -410,7 +410,7 @@ public: className ("CAIPlayerRespawnMsg"); property ("PlayerRowId", PropDataSetRow, TDataSetRow(), PlayerRowId); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -428,7 +428,7 @@ public: property ("EntityRowId", PropDataSetRow, TDataSetRow(), EntityRowId); property ("AskerRowID", PropDataSetRow, TDataSetRow(), AskerRowID); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -448,7 +448,7 @@ public: property ("AskerRowID", PropDataSetRow, TDataSetRow(), AskerRowID); propertyCont ("Infos", PropString, Infos); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -466,7 +466,7 @@ public: property ("EntityRowId", PropDataSetRow, TDataSetRow(), EntityRowId); property ("EnableAggro", PropBool, true, EnableAggro); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -482,7 +482,7 @@ public: className ("CReportAICollisionAvailableMsg"); propertyCont ("ContinentsCollision", PropString, ContinentsCollision); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -500,7 +500,7 @@ public: property ("InstanceNumber", PropUInt32, uint32(0), InstanceNumber); property ("InstanceContinent", PropString, std::string(), InstanceContinent); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -520,7 +520,7 @@ public: property ("ActionName", PropString, std::string(), ActionName); property ("Url", PropString, std::string(), Url); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -536,7 +536,7 @@ public: className ("CReportAIInstanceDespawnMsg"); propertyCont ("InstanceNumbers", PropUInt32, InstanceNumbers); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; @@ -555,7 +555,7 @@ public: className ("CWarnBadInstanceMsg"); property ("InstanceNumber", PropUInt32, uint32(0), InstanceNumber); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -575,7 +575,7 @@ public: propertyCont ("ActionFlags", PropUInt8, ActionFlags); propertyVector ("Values", PropBool, Values); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} inline void push(TDataSetRow entity, uint8 flag, bool value) { @@ -599,7 +599,7 @@ public: propertyCont ("Entities", PropDataSetRow, Entities); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -620,7 +620,7 @@ public: propertyCont ("SetFull", PropUInt8, SetFull); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -639,7 +639,7 @@ public: propertyCont ("DeltaHp", PropSInt32, DeltaHp); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -657,7 +657,7 @@ public: property ("CreatureId", PropDataSetRow, TDataSetRow(), CreatureId); property ("NewMode", PropUInt8, (uint8)0, NewMode); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -673,7 +673,7 @@ public: className ("CCreatureDespawnMsg"); propertyCont ("Entities", PropDataSetRow, Entities); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; ///////////////////////////////////////////////////////////////////////////// @@ -934,7 +934,7 @@ public: property ("MissionAlias", PropUInt32, uint32(0xffffffff), MissionAlias); property ("DespawnTimeInTick", PropUInt32, uint32(0), DespawnTimeInTick); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -954,7 +954,7 @@ public: property ("GroupAlias", PropUInt32, uint32(0xffffffff), GroupAlias); property ("MissionAlias", PropUInt32, uint32(0xffffffff), MissionAlias); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -974,7 +974,7 @@ public: property ("GroupAlias", PropUInt32, uint32(0xffffffff), GroupAlias); property ("MissionAlias", PropUInt32, uint32(0xffffffff), MissionAlias); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -994,7 +994,7 @@ public: property ("GroupAlias", PropUInt32, uint32(0xffffffff), GroupAlias); property ("MissionAlias", PropUInt32, uint32(0xffffffff), MissionAlias); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; @@ -1046,7 +1046,7 @@ public: propertyCont ("Quantities", PropUInt32, Quantities); property ("MissionText", PropString, std::string(), MissionText); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------------------- @@ -1082,7 +1082,7 @@ public: propertyCont ("Quantities", PropUInt32, Quantities); property ("MissionText", PropString, std::string(), MissionText); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {} + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; @@ -1130,7 +1130,7 @@ public: propertyCont ("Params", PropString, Params); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} TFunEnum getFunEnum(const std::string& funName) const; diff --git a/code/ryzom/server/src/server_share/msg_gpm_service.h b/code/ryzom/server/src/server_share/msg_gpm_service.h index c4039be97..d985c8781 100644 --- a/code/ryzom/server/src/server_share/msg_gpm_service.h +++ b/code/ryzom/server/src/server_share/msg_gpm_service.h @@ -73,7 +73,7 @@ public: property("Type", PropUInt32, (uint32)Player, Type); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &name, NLNET::TServiceId id) {} }; diff --git a/code/ryzom/server/src/server_share/npc_description_messages.h b/code/ryzom/server/src/server_share/npc_description_messages.h index 051cbeb44..1c838ad80 100644 --- a/code/ryzom/server/src/server_share/npc_description_messages.h +++ b/code/ryzom/server/src/server_share/npc_description_messages.h @@ -47,8 +47,9 @@ std::string buildChatDebugString(const std::vector &ShopCategories, class CNpcChatProfile { public: - CNpcChatProfile() : /*_guildCreator(false),*/ /*_dynamicMissionGiver(false),*/ _Organization(0), _FilterExplicitActionTradeByPlayerRace(false), - _ExplicitActionSPType(EGSPD::CSPType::Unknown), _FilterExplicitActionTradeByBotRace(true){} + CNpcChatProfile() : /*_guildCreator(false),*/ /*_dynamicMissionGiver(false),*/ _FilterExplicitActionTradeByPlayerRace(false), + _ExplicitActionSPType(EGSPD::CSPType::Unknown), _FilterExplicitActionTradeByBotRace(true), + _DynamicMissionGiver(false), _Organization(0) {} CNpcChatProfile(const CNpcChatProfile &other0,const CNpcChatProfile &other1); virtual ~CNpcChatProfile() {} @@ -84,7 +85,7 @@ public: const std::string &getWebPageName() const { return _WebPageName; } const NLMISC::CSheetId &getOutpost() const { return _Outpost; } - const uint32 getOrganization() const { return _Organization; } + uint32 getOrganization() const { return _Organization; } protected: std::vector< RYMSG::TExplicitSale > _ExplicitSales; @@ -146,7 +147,7 @@ struct CCharacterBotChatBeginEnd : public CMirrorTransportClass propertyCont ("botChatEnd", PropUInt32, BotChatEnd); } - virtual void callback (const std::string &name, NLNET::TServiceId id) { } + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) { } }; struct CCharacterDynChatBeginEnd : public CMirrorTransportClass @@ -162,7 +163,7 @@ struct CCharacterDynChatBeginEnd : public CMirrorTransportClass propertyCont ("dnChatEnd", PropUInt32, DynChatEnd); } - virtual void callback (const std::string &name, NLNET::TServiceId id) { } + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) { } }; struct CCustomElementId diff --git a/code/ryzom/server/src/server_share/pet_interface_msg.h b/code/ryzom/server/src/server_share/pet_interface_msg.h index 09bbab13d..6571b271a 100644 --- a/code/ryzom/server/src/server_share/pet_interface_msg.h +++ b/code/ryzom/server/src/server_share/pet_interface_msg.h @@ -59,7 +59,7 @@ public: property ("CustomName", PropUCString, ucstring(""), CustomName); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; @@ -93,7 +93,7 @@ public: property ("PetMirrorRow", PropDataSetRow, TDataSetRow(), PetMirrorRow); property ("PetIndex", PropUInt16, (uint16)0, PetIdx); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; @@ -123,7 +123,7 @@ public: property ("Heading", PropFloat, 0.0f, Heading); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------- @@ -151,7 +151,7 @@ public: className ("CPetCommandConfirmationMsg"); property ("CommandError", PropUInt16, (uint16)NO_ERROR_COMMAND, CommandError); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; //---------------------------------------------------------------- @@ -171,7 +171,7 @@ public: property ("PetMirrorRow", PropDataSetRow, TDataSetRow(), PetMirrorRow); } - virtual void callback (const std::string &name, NLNET::TServiceId id) {}; + virtual void callback (const std::string &/* name */, NLNET::TServiceId /* id */) {} }; #endif //RY_PET_INTERFACE_MESSAGES_H diff --git a/code/ryzom/server/src/server_share/stat_db_tree.h b/code/ryzom/server/src/server_share/stat_db_tree.h index 8faaa85ee..7472a2092 100644 --- a/code/ryzom/server/src/server_share/stat_db_tree.h +++ b/code/ryzom/server/src/server_share/stat_db_tree.h @@ -95,13 +95,13 @@ class CStatDBLeaf : public IStatDBNode public: virtual ~CStatDBLeaf() {} - bool setNode(const std::string & path, IStatDBNodePtr node) { return false; } - IStatDBNodePtr getNode(const std::string & path) { return NULL; } - void getNodes(const std::string & pathPattern, std::vector & matchingNodes, - const std::string & currentPath) {} - IStatDBNodePtr removeNode(const std::string & path) { return NULL; } + bool setNode(const std::string & /* path */, IStatDBNodePtr /* node */) { return false; } + IStatDBNodePtr getNode(const std::string & /* path */) { return NULL; } + void getNodes(const std::string & /* pathPattern */, std::vector & /* matchingNodes */, + const std::string & /* currentPath */) {} + IStatDBNodePtr removeNode(const std::string & /* path */) { return NULL; } - virtual void acceptVisitor(CStatDBNodeVisitor & visitor, const std::string & currentPath) {} + virtual void acceptVisitor(CStatDBNodeVisitor & /* visitor */, const std::string & /* currentPath */) {} }; /** diff --git a/code/ryzom/server/src/server_share/stat_db_tree_visitor.h b/code/ryzom/server/src/server_share/stat_db_tree_visitor.h index 1d57a6491..98e7455d3 100644 --- a/code/ryzom/server/src/server_share/stat_db_tree_visitor.h +++ b/code/ryzom/server/src/server_share/stat_db_tree_visitor.h @@ -34,9 +34,9 @@ class CStatDBTableLeaf; class CStatDBNodeVisitor { public: - virtual void visitBranch(CStatDBBranch * branch, const std::string & path) {} - virtual void visitValueLeaf(CStatDBValueLeaf * valueLeaf, const std::string & path) {} - virtual void visitTableLeaf(CStatDBTableLeaf * tableLeaf, const std::string & path) {} + virtual void visitBranch(CStatDBBranch * /* branch */, const std::string & /* path */) {} + virtual void visitValueLeaf(CStatDBValueLeaf * /* valueLeaf */, const std::string & /* path */) {} + virtual void visitTableLeaf(CStatDBTableLeaf * /* tableLeaf */, const std::string & /* path */) {} protected: CStatDBNodeVisitor() {} diff --git a/code/ryzom/server/src/shard_unifier_service/database_mapping.h b/code/ryzom/server/src/shard_unifier_service/database_mapping.h index d6f9b8689..61df29e9a 100644 --- a/code/ryzom/server/src/shard_unifier_service/database_mapping.h +++ b/code/ryzom/server/src/shard_unifier_service/database_mapping.h @@ -111,9 +111,9 @@ namespace RSMGR CKnownUserPtr() : _FileName(NULL), _LineNum(0), - _Ptr(NULL), _NextPtr(NULL), - _PrevPtr(NULL) + _PrevPtr(NULL), + _Ptr(NULL) { } @@ -1091,9 +1091,9 @@ namespace RSMGR CGuildInvitePtr() : _FileName(NULL), _LineNum(0), - _Ptr(NULL), _NextPtr(NULL), - _PrevPtr(NULL) + _PrevPtr(NULL), + _Ptr(NULL) { } @@ -1231,9 +1231,9 @@ namespace RSMGR CPlayerRatingPtr() : _FileName(NULL), _LineNum(0), - _Ptr(NULL), _NextPtr(NULL), - _PrevPtr(NULL) + _PrevPtr(NULL), + _Ptr(NULL) { } @@ -1371,9 +1371,9 @@ namespace RSMGR CJournalEntryPtr() : _FileName(NULL), _LineNum(0), - _Ptr(NULL), _NextPtr(NULL), - _PrevPtr(NULL) + _PrevPtr(NULL), + _Ptr(NULL) { } diff --git a/code/ryzom/tools/client/client_config/base_dialog.h b/code/ryzom/tools/client/client_config/base_dialog.h index c81c8a207..4082968b4 100644 --- a/code/ryzom/tools/client/client_config/base_dialog.h +++ b/code/ryzom/tools/client/client_config/base_dialog.h @@ -34,7 +34,7 @@ class CBaseDialog : public CDialog public: /// Constructor - CBaseDialog (uint id, CWnd* pParent = NULL) : CDialog(id, pParent) {}; + CBaseDialog (uint id, CWnd* pParent = NULL) : CDialog(id, pParent) {} /// On ok virtual void OnOK (); diff --git a/code/ryzom/tools/leveldesign/georges_convert/string_ex.h b/code/ryzom/tools/leveldesign/georges_convert/string_ex.h index 69489c4ac..a395e8f42 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/string_ex.h +++ b/code/ryzom/tools/leveldesign/georges_convert/string_ex.h @@ -26,9 +26,9 @@ class CStringEx : public std::basic_string, std::al { public: - CStringEx() : std::basic_string, std::allocator >() {;} - CStringEx( char* _pc ) : std::basic_string, std::allocator >( (char *)_pc ) {}; - CStringEx( std::string _s ) : std::basic_string, std::allocator >( (std::string)_s) {}; + CStringEx() : std::basic_string, std::allocator >() {} + CStringEx( char* _pc ) : std::basic_string, std::allocator >( (char *)_pc ) {} + CStringEx( std::string _s ) : std::basic_string, std::allocator >( (std::string)_s) {} CStringEx( const char _c, int _i ) { append( _i, _c ); } virtual ~CStringEx(); diff --git a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.h b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.h index 8b61618a1..08b477e38 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.h +++ b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.h @@ -84,12 +84,12 @@ public: uint Item, SubItem, ColumnCount; uint DlgIndex; - virtual TItemEdit getItemEditMode (uint item, uint subItem) {return EditFixedCombo;}; + virtual TItemEdit getItemEditMode (uint item, uint subItem) {return EditFixedCombo;} virtual void getComboBoxStrings (uint item, uint subItem, std::vector &retStrings); - virtual void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse) { regAdr = ""; browse = false; }; - virtual void getNewItemText (uint item, uint subItem, std::string &ret) { ret = "new"; }; - virtual void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter) { defExt=""; defFilename=""; filter=""; defDir="";}; - virtual void onItemChanged (uint item, uint subItem) {}; + virtual void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse) { regAdr = ""; browse = false; } + virtual void getNewItemText (uint item, uint subItem, std::string &ret) { ret = "new"; } + virtual void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter) { defExt=""; defFilename=""; filter=""; defDir="";} + virtual void onItemChanged (uint item, uint subItem) {} void memComboBoxAsChange (bool selChange); void closeMemComboBox (bool update); diff --git a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h index 0fe05ab8c..29e10aa00 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h @@ -66,7 +66,7 @@ public: IFormWidget (CFormDialog *dialog, uint structId, const char *formName, TTypeSrc typeSrc, uint slot); // Destructor - virtual ~IFormWidget () {}; + virtual ~IFormWidget () {} // Update the text of the base label void updateLabel (); @@ -90,8 +90,8 @@ public: virtual bool extendableHeight () const; // Ok / cancel hit - virtual void onOk () {}; - virtual void onCancel () {}; + virtual void onOk () {} + virtual void onCancel () {} // Update widget date virtual void updateData (bool update = true) = 0; diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.h b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.h index 649a2927d..b6f9ef7f6 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.h +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.h @@ -311,7 +311,7 @@ public: class CGeorgesEditDocType : public CGeorgesEditDoc { protected: // create from serialization only - CGeorgesEditDocType() {}; + CGeorgesEditDocType() {} DECLARE_DYNCREATE(CGeorgesEditDocType) // Document is a type ? @@ -341,7 +341,7 @@ protected: class CGeorgesEditDocDfn : public CGeorgesEditDoc { protected: // create from serialization only - CGeorgesEditDocDfn() {}; + CGeorgesEditDocDfn() {} DECLARE_DYNCREATE(CGeorgesEditDocDfn) // Document is a dfn ? @@ -371,7 +371,7 @@ protected: class CGeorgesEditDocForm : public CGeorgesEditDoc { protected: // create from serialization only - CGeorgesEditDocForm() {}; + CGeorgesEditDocForm() {} DECLARE_DYNCREATE(CGeorgesEditDocForm) // Docuemnt is a form ? diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_interface.h b/code/ryzom/tools/leveldesign/georges_dll/georges_interface.h index 28ab22042..fbac91024 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_interface.h +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_interface.h @@ -61,7 +61,7 @@ enum TUI class IGeorges { public: - virtual ~IGeorges() {}; + virtual ~IGeorges() {} // Init the UI virtual void initUI (int m_nCmdShow, bool exeStandalone, HWND parent=NULL)=0; diff --git a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h index a796e7fe6..47d447c59 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h +++ b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h @@ -36,8 +36,8 @@ public: void outputString (const char *message); // From CDialog - void OnOK () {}; - void OnCancel (); + void OnOK () {} + void OnCancel () // Dialog Data //{{AFX_DATA(COutputConsoleDlg) diff --git a/code/ryzom/tools/leveldesign/georges_dll/plugin_interface.h b/code/ryzom/tools/leveldesign/georges_dll/plugin_interface.h index 4908d9474..36ad36062 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/plugin_interface.h +++ b/code/ryzom/tools/leveldesign/georges_dll/plugin_interface.h @@ -65,7 +65,7 @@ public: /** * Destructor must uninitialise the plugin interface */ - virtual ~IEditPlugin () {}; + virtual ~IEditPlugin () {} /// Window related @@ -157,7 +157,7 @@ public: /** * Destructor must uninitialise the plugin interface */ - virtual ~IEditDocumentPlugin () {}; + virtual ~IEditDocumentPlugin () {} /// Event message diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.h index 4cee69902..6af4bc18c 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.h @@ -62,7 +62,7 @@ public: /// The master dialog call this method when the document is changed/updated static void docChanged(); /// The docChanged static method call this method on each page. - virtual void onDocChanged() {}; + virtual void onDocChanged() {} }; diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFades.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFades.h index 306f39293..43a339225 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFades.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFades.h @@ -33,7 +33,7 @@ class CPageBgFades : public CPageBase // Construction public: - CPageBgFades() {}; + CPageBgFades() {} CPageBgFades(NLGEORGES::CSoundDialog *soundDialog); ~CPageBgFades(); diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFlags.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFlags.h index 6fab075c3..6e5c2488c 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFlags.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBgFlags.h @@ -46,7 +46,7 @@ class CPageBgFlags : public CPageBase // Construction public: - CPageBgFlags() {}; + CPageBgFlags() {} CPageBgFlags(NLGEORGES::CSoundDialog *soundDialog); ~CPageBgFlags(); diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComplex.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComplex.h index 7f9ed68ad..26ee864de 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComplex.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComplex.h @@ -35,7 +35,7 @@ class CPageComplex : public CPageBase // Construction public: - CPageComplex(){}; + CPageComplex(){} CPageComplex(NLGEORGES::CSoundDialog *soundDialog); ~CPageComplex(); diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComtext.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComtext.h index c34d6ef64..3c99f9089 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComtext.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageComtext.h @@ -34,7 +34,7 @@ class CPageComtext : public CPageBase // Construction public: - CPageComtext(){}; + CPageComtext(){} CPageComtext(NLGEORGES::CSoundDialog *soundDialog); ~CPageComtext(); diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PagePosition.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/PagePosition.h index 88f21c614..1510c2ea8 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PagePosition.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PagePosition.h @@ -41,7 +41,7 @@ class CPagePosition : public CPageBase // Construction public: - CPagePosition(){}; + CPagePosition(){} CPagePosition(NLGEORGES::CSoundDialog *soundDialog); ~CPagePosition(); diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageSimple.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageSimple.h index 8da0328dc..935f33acb 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageSimple.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageSimple.h @@ -36,7 +36,7 @@ class CPageSimple : public CPageBase // Construction public: - CPageSimple() {}; + CPageSimple() {} CPageSimple(NLGEORGES::CSoundDialog *soundDialog); ~CPageSimple(); diff --git a/code/ryzom/tools/leveldesign/mission_compiler_lib/step.h b/code/ryzom/tools/leveldesign/mission_compiler_lib/step.h index fdb1db4be..3a38f8689 100644 --- a/code/ryzom/tools/leveldesign/mission_compiler_lib/step.h +++ b/code/ryzom/tools/leveldesign/mission_compiler_lib/step.h @@ -89,7 +89,7 @@ public: IStep(CMissionData &md, NLLIGO::IPrimitive *prim); virtual ~IStep() {} - virtual void init(CMissionData &md, NLLIGO::IPrimitive *prim) {}; + virtual void init(CMissionData &md, NLLIGO::IPrimitive *prim) {} /// Get the step name diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/action.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/action.h index 511f2a16e..9145f4af4 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/action.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/action.h @@ -32,7 +32,7 @@ class IAction public: // Virtual destructor - virtual ~IAction () {}; + virtual ~IAction () {} // Do / undo virtual void undo () = 0; diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor/plugin_interface.h b/code/ryzom/tools/leveldesign/world_editor/world_editor/plugin_interface.h index d2c38ca58..2bbe143c1 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor/plugin_interface.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor/plugin_interface.h @@ -163,7 +163,7 @@ public: /// Init the plugin. The plugin receive the world editor interface. virtual void init(IPluginAccess *pluginAccess) =0; /// Delete the plugin. - virtual ~IPluginCallback() {}; + virtual ~IPluginCallback() {} /// The current region has changed. // virtual void primRegionChanged(const std::vector ®ions) = 0; diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/primitive_plugin.h b/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/primitive_plugin.h index 1ea94a512..7fcb78fc1 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/primitive_plugin.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/primitive_plugin.h @@ -51,9 +51,9 @@ public: CPrimitivePlugin(); - virtual void positionMoved(const NLMISC::CVector &position) {}; - virtual void lostPositionControl() {}; - virtual void onIdle() {}; + virtual void positionMoved(const NLMISC::CVector &position) {} + virtual void lostPositionControl() {} + virtual void onIdle() {} virtual void drawPrimitive(const NLLIGO::IPrimitive *primitive, const TRenderContext &renderContext); @@ -72,9 +72,9 @@ private: void serial (NLMISC::IStream &s); - static uint getVersion (); + static uint getVersion () - void removed() {}; + void removed() {} }; std::map _CreatureInfos; diff --git a/code/ryzom/tools/stats_scan/char_filter_factory.h b/code/ryzom/tools/stats_scan/char_filter_factory.h index ebfd2a964..35ee52a07 100644 --- a/code/ryzom/tools/stats_scan/char_filter_factory.h +++ b/code/ryzom/tools/stats_scan/char_filter_factory.h @@ -39,6 +39,7 @@ class CStatsScanCharacter; class ICharFilter: public NLMISC::CRefCount { public: + virtual ~ICharFilter() {} virtual std::string toString() const=0; virtual bool evaluate(const CStatsScanCharacter* c)=0; }; @@ -51,6 +52,7 @@ public: class ICharFilterBuilder: public NLMISC::CRefCount { public: + virtual ~ICharFilterBuilder() {} virtual const char* getName()=0; virtual const char* getDescription()=0; virtual ICharFilter* build(const std::string& rawArgs)=0; diff --git a/code/ryzom/tools/stats_scan/char_info_extractor_factory.h b/code/ryzom/tools/stats_scan/char_info_extractor_factory.h index 781a3d2d3..35e3e7b68 100644 --- a/code/ryzom/tools/stats_scan/char_info_extractor_factory.h +++ b/code/ryzom/tools/stats_scan/char_info_extractor_factory.h @@ -41,6 +41,7 @@ class CStatsScanCharacter; class ICharInfoExtractor: public NLMISC::CRefCount { public: + virtual ~ICharInfoExtractor() {} virtual std::string toString() const=0; virtual void execute(CCharacterScanJob* job,const CStatsScanCharacter* c)=0; }; @@ -53,6 +54,7 @@ public: class ICharInfoExtractorBuilder: public NLMISC::CRefCount { public: + virtual ~ICharInfoExtractorBuilder() {} virtual const char* getName()=0; virtual const char* getDescription()=0; virtual const char* getFields()=0; diff --git a/code/ryzom/tools/stats_scan/char_scan_script.h b/code/ryzom/tools/stats_scan/char_scan_script.h index 5f4a4d107..ac3a6780b 100644 --- a/code/ryzom/tools/stats_scan/char_scan_script.h +++ b/code/ryzom/tools/stats_scan/char_scan_script.h @@ -97,6 +97,7 @@ private: class ICharScanScriptCommand: public NLMISC::CRefCount { public: + virtual ~ICharScanScriptCommand() {} virtual const char* getName()=0; virtual const char* getSyntax()=0; virtual const char* getDescription()=0; diff --git a/code/ryzom/tools/stats_scan/job_manager.h b/code/ryzom/tools/stats_scan/job_manager.h index 136ac77be..a318cffdc 100644 --- a/code/ryzom/tools/stats_scan/job_manager.h +++ b/code/ryzom/tools/stats_scan/job_manager.h @@ -31,6 +31,9 @@ public: class IJob: public NLMISC::CRefCount { public: + // virtual dtor + virtual ~IJob() {} + // return true if the job is finished -> the job object can be deleted virtual bool finished()=0;