diff --git a/.travis.yml b/.travis.yml index 4f39bc8de..d770fded7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,35 +10,31 @@ cache: git: depth: 1 -compiler: - - gcc - - clang +matrix: + include: + - os: linux + compiler: gcc + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-7'] + env: CXX_P=g++-7 CC_P=gcc-7 -addons: - apt: - #ref: https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json - sources: - - ubuntu-toolchain-r-test - - llvm-toolchain-trusty-5.0 - #ref: https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise - packages: - - gcc-7 - - g++-7 - - clang-5.0 - - python3 + - os: linux + compiler: clang + addons: + apt: + sources: ['llvm-toolchain-trusty-5.0', 'ubuntu-toolchain-r-test'] + packages: ['clang-5.0', 'libstdc++6', 'libstdc++-6-dev'] + env: CXX_P=clang++-5.0 CC_P=clang-5.0 before_install: - cd pol-core/bin-build before_script: - echo 'Configure...' && echo -en 'travis_fold:start:script.configure\\r' - - export TRAVIS_CI=1 - - if [ "$CXX" = "g++" ]; then - export CXX="g++-7" CC="gcc-7"; - fi - - if [ "$CXX" = "clang++" ]; then - export CXX="clang++-5.0" CC="clang-5.0"; - fi + - export CXX=$CXX_P + - export CC=$CC_P - cmake ../.. - echo -en 'travis_fold:end:script.configure\\r' diff --git a/CMakeLists.txt b/CMakeLists.txt index bae38683a..99551b4a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,43 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) -PROJECT(polserver.com) -INCLUDE(ExternalProject) -INCLUDE(cmake/Benchmark.txt) -ADD_SUBDIRECTORY(lib/tinyxml) -ADD_SUBDIRECTORY(pol-core) +cmake_minimum_required(VERSION 3.0) + +project(polserver) + +set(POL_VERSION_STR "099") +set(POL_VERSION 99) +set(POL_VERSION_NAME "Break Everything Even Rudder") + +include(cmake/init.cmake) + +if (NOT DEFINED GIT_REVISION) + get_git_revision() +endif() + +message("####################################") +message("# ${PROJECT_NAME} - ${POL_VERSION_STR} #") +message("# - ${POL_VERSION_NAME} - #") +message("# - ${GIT_REVISION} - #") +message("####################################") + +include(CheckIncludeFiles) +include(ExternalProject) + + +include(cmake/utils.cmake) +include(cmake/release.cmake) +include(cmake/cotire.cmake) + + +detect_compiler() +detect_arch() +detect_platform() + +prepare_build() + +include(cmake/Boost.txt) +include(cmake/Curl.txt) +include(cmake/Benchmark.txt) + +add_subdirectory(lib/tinyxml) +add_subdirectory(pol-core) + +release() diff --git a/cmake/Benchmark.txt b/cmake/Benchmark.txt index eacc1c097..cf76fcc7b 100644 --- a/cmake/Benchmark.txt +++ b/cmake/Benchmark.txt @@ -1,17 +1,8 @@ -############################################################################### -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMakeEnvironment.txt) -IF (DEFINED ENABLE_BENCHMARK) -MESSAGE("####################################") -MESSAGE("##### Building POL - GOOGLE BENCHMARK") -MESSAGE("####################################") +if (DEFINED ENABLE_BENCHMARK) + message("* benchmark") + set(BENCHMARK_ENABLE_TESTING OFF) -############################################################## -# include CMake core -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMakeCore.txt) - -SET(BENCHMARK_ENABLE_TESTING OFF) - -add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../lib/google-benchmark/" "${CMAKE_CURRENT_BINARY_DIR}/lib/google-benchmark") - -ENDIF() + add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../lib/google-benchmark/" "${CMAKE_CURRENT_BINARY_DIR}/lib/google-benchmark" EXCLUDE_FROM_ALL) + set_compile_flags(benchmark 0) +endif() diff --git a/cmake/Boost.txt b/cmake/Boost.txt index b9546c4c5..8996a2625 100644 --- a/cmake/Boost.txt +++ b/cmake/Boost.txt @@ -1,15 +1,9 @@ -MESSAGE("####################################") -MESSAGE("##### Building POL - BOOST") -MESSAGE("####################################") +message("* boost") +set (BOOST_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../lib/boost_1_63_0") - -SET (BOOST_EXECUTED "true") -SET (BOOST_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../lib/boost_1_63_0") - -IF(NOT EXISTS "${BOOST_SOURCE_DIR}/boost") - -# build disabled no need currenty -ExternalProject_Add(boost +if(NOT EXISTS "${BOOST_SOURCE_DIR}/boost") + # build disabled no need currenty + ExternalProject_Add(boost URL "${BOOST_SOURCE_DIR}/../boost_1_63_0.tar.bz2" SOURCE_DIR "${BOOST_SOURCE_DIR}" # CONFIGURE_COMMAND ./bootstrap.sh @@ -30,11 +24,10 @@ ExternalProject_Add(boost # stage LOG_DOWNLOAD 1 BUILD_IN_SOURCE 1 -) + ) +else() + message("Boost already extracted") +endif() -ELSE() -MESSAGE("BOOST already unpacked") -ENDIF() - -SET (BOOST_LIBRARY_DIR "${BOOST_SOURCE_DIR}/lib/lib") +set (BOOST_LIBRARY_DIR "${BOOST_SOURCE_DIR}/lib/lib") diff --git a/cmake/CMakeCore.txt b/cmake/CMakeCore.txt deleted file mode 100755 index 7b5b3d679..000000000 --- a/cmake/CMakeCore.txt +++ /dev/null @@ -1,448 +0,0 @@ -##################################################################### -# -# Copyright (C) 2015 Thomas Volkert -# All rights reserved. -# -# The environment was provided for the POL project. Redistribution -# and use in source and binary forms, with or without modification, -# are permitted. However, this paragraph has to be included in its -# original form in every project. -# -##################################################################### - -INCLUDE(CheckLibraryExists) -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -# Default build type -SET(BUILD "Default" CACHE STRING "The build type, one of Default,Debug,Valgrind") - -############################################################## - -IF (DEFINED TARGET_NAME_BINARY) - MESSAGE("###########################################################################") - MESSAGE("##### Configuring binary \"${TARGET_NAME_BINARY}\"") - MESSAGE("###########################################################################") -ELSEIF (DEFINED TARGET_NAME_LIB) - MESSAGE("###########################################################################") - MESSAGE("##### Configuring library \"${TARGET_NAME_LIB}\"") - MESSAGE("###########################################################################") -ENDIF () - -############################################################## -# check if CMakeEnvironment.txt was parsed before -IF (NOT PRE_DEFINITIONS_EXECUTED) - MESSAGE("Including automatically the pre-definitions from CMakeEnvironment.txt..") - INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMakeEnvironment.txt) -ENDIF () - -############################################################## -# minimum required GCC version -IF (CLANG) - SET(REQUIRED_COMPILER_VERSION 3.4) -ELSE() - SET(REQUIRED_COMPILER_VERSION 4.7) -ENDIF() - -# check compiler version -IF(NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER ${REQUIRED_COMPILER_VERSION} AND NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL ${REQUIRED_COMPILER_VERSION}) - MESSAGE(FATAL_ERROR "You need at least compiler version ${REQUIRED_COMPILER_VERSION} and you run version ${CMAKE_CXX_COMPILER_VERSION}!") -ENDIF() - -############################################################## -# verbose command line output -IF (${CMAKE_VERBOSE_MAKEFILE} MATCHES "ON") - SET (FLAGS - ${FLAGS} - -v - ) -ENDIF() - -############################################################## -# app/lib versioning -IF (WINDOWS) - IF (DEFINED TARGET_NAME_BINARY) -#TODO INCLUDE(CMakeWindowsBinary.txt) - ELSE() -#TODO INCLUDE(CMakeWindowsLibrary.txt) - ENDIF() -ENDIF() - -############################################################## -# library search paths -IF(NOT WINDOWS) - SET (LIB_DIRS - ${LIB_DIRS} - /usr/local/lib - /usr/lib - /usr/lib${ARCH_BITS} - ) -ENDIF() -MESSAGE("### Library search path: ${LIB_DIRS}") - -############################################################## -# include dirs -IF(NOT WINDOWS) - SET (INCLUDE_DIRS - ${INCLUDE_DIRS} - /usr/local/include - ) -ENDIF() -MESSAGE("### Header search path: ${INCLUDE_DIRS}") - -############################################################## -# compile flags -IF (WINDOWS) - # TODO -ELSE() - IF (DEFINED FORCE_ARCH_BITS) - SET (FLAGS - ${FLAGS} - -m${FORCE_ARCH_BITS} - ) - ENDIF() - IF (${BUILD} MATCHES "Valgrind") - SET (FLAGS - ${FLAGS} - -O0 - ) - ELSEIF (NOT (${BUILD} MATCHES "Debug")) - SET (FLAGS - ${FLAGS} - -O2 - ) - ENDIF() - # position independent code to use it both for dynamic and static linking - SET (FLAGS - ${FLAGS} - -fPIC - ) -ENDIF() - -############################################################## -# differentiate between debug and release version -IF ( (${BUILD} MATCHES "Debug") OR (${BUILD} MATCHES "Valgrind") ) - IF (APPLE) - SET (FLAGS "${FLAGS} -g -DDEBUG_VERSION") - ELSEIF(WINDOWS) - SET (FLAGS "${FLAGS} /DDEBUG_VERSION") - ELSE() - SET (FLAGS "${FLAGS} -g -ggdb -DDEBUG_VERSION") - ENDIF() -ELSE () - IF(WINDOWS) - SET (FLAGS "${FLAGS} /DRELEASE_VERSION /DNDEBUG") - ELSE() - SET (FLAGS "${FLAGS} -DRELEASE_VERSION -DNDEBUG") - ENDIF() -ENDIF () - -############################################################## -# define minimum OS X version to which the binary is compatible -IF (APPLE) - SET(FLAGS - ${FLAGS} - -mmacosx-version-min=${MIN_SUPPORTED_OSX_VERSION} - ) -ENDIF() - -############################################################## -# stripping for all platforms excluding APPLE -IF (LINUX OR BSD) - IF (${BUILD} MATCHES "Release") - SET (LFLAGS "${LFLAGS} -s") - ENDIF() -ENDIF() - -############################################################## -# definitions -SET (DEFINITIONS - ${DEFINITIONS} - ${FEATURES} - -D__STDC_CONSTANT_MACROS - -D__STDC_FORMAT_MACROS - -D__STDC_LIMIT_MACROS - -D_REENTRANT - -DARCH_BITS=${ARCH_BITS} -) - -# "-D" options for compilation in WINDOWS environment -IF(WINDOWS) - SET (DEFINITIONS - ${DEFINITIONS} - ${DEFINITIONS_WINDOWS} - -DWINVER=0x0501 - -DWINDOWS - ) - IF (WIN32) - SET (DEFINITIONS - ${DEFINITIONS} - -DWIN32 - ) - ENDIF() - IF (WIN64) - SET (DEFINITIONS - ${DEFINITIONS} - -DWIN64 - ) - ENDIF() -ENDIF() - -# "-D" options for compilation in LINUX environment -IF (LINUX) - SET (DEFINITIONS - ${DEFINITIONS} - ${DEFINITIONS_LINUX} - -DLINUX - ) -ENDIF() - -# "-D" options for compilation in BSD environment -IF (BSD) - SET (DEFINITIONS - ${DEFINITIONS} - ${DEFINITIONS_BSD} - -DBSD - ) -ENDIF() - -# "-D" options for compilation in APPLE environment -IF (APPLE) - SET (DEFINITIONS - ${DEFINITIONS} - ${DEFINITIONS_APPLE} - -DAPPLE - -D_THREAD_SAFE - ) -ENDIF() - -############################################################## -# for win32 remove the "lib" prefix for dll's -IF (WINDOWS) - SET(CMAKE_SHARED_LIBRARY_PREFIX "") - SET(CMAKE_STATIC_LIBRARY_PREFIX "") - SET(CMAKE_IMPORT_LIBRARY_PREFIX "") -ENDIF (WINDOWS) - -############################################################## -# search for header files - needed for Visual Studio solution -IF(WINDOWS) - FOREACH(SOURCES_ENTRY ${SOURCES}) - GET_FILENAME_COMPONENT(SOURCES_ENTRY_PATH ${SOURCES_ENTRY} PATH) - GET_FILENAME_COMPONENT(SOURCES_ENTRY_NAME_WE ${SOURCES_ENTRY} NAME_WE) - SET(SOURCES_ENTRY_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCES_ENTRY_PATH}/${SOURCES_ENTRY_NAME_WE}.h) - IF(EXISTS "${SOURCES_ENTRY_HEADER}") - MESSAGE("Found automatically the header file: ${SOURCES_ENTRY_HEADER}") - SET(SOURCES - ${SOURCES} - ${SOURCES_ENTRY_HEADER} - ) - ENDIF() - ADD_DEFINITIONS("${DEFINITIONS_ENTRY}") - ENDFOREACH(SOURCES_ENTRY ${SOURCES}) -ENDIF() - -############################################################## -# add definitions for compilation -FOREACH(DEFINITIONS_ENTRY ${DEFINITIONS}) - ADD_DEFINITIONS("${DEFINITIONS_ENTRY}") -ENDFOREACH(DEFINITIONS_ENTRY ${DEFINITIONS}) - -############################################################## -# add flags for linking -FOREACH(LFLAGS_ENTRY ${LFLAGS}) - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LFLAGS_ENTRY}") - SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LFLAGS_ENTRY}") - SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LFLAGS_ENTRY}") -ENDFOREACH(LFLAGS_ENTRY ${LFLAGS}) - -############################################################## -# add flags for compilation -FOREACH(FLAGS_ENTRY ${FLAGS}) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS_ENTRY}") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS_ENTRY}") -ENDFOREACH(FLAGS_ENTRY ${FLAGS}) -MESSAGE("### Flags for C compiling: ${CMAKE_C_FLAGS}") -MESSAGE("### Flags for C++ compiling: ${CMAKE_CXX_FLAGS}") - -############################################################## -# add include paths -FOREACH(INCLUDE_DIRS_ENTRY ${INCLUDE_DIRS}) - INCLUDE_DIRECTORIES("${INCLUDE_DIRS_ENTRY}") -ENDFOREACH(INCLUDE_DIRS_ENTRY ${INCLUDE_DIRS}) - -############################################################## -# add library paths -FOREACH(LIB_DIRS_ENTRY ${LIB_DIRS}) - LINK_DIRECTORIES("${LIB_DIRS_ENTRY}") -ENDFOREACH(LIB_DIRS_ENTRY ${LIB_DIRS}) - -############################################################## -# generate library from given source files -IF (DEFINED TARGET_LIB_NAME) - # set libraries install_name for APPLE systems - IF (APPLE) - SET (LFLAGS - ${LFLAGS} - -Wl,-install_name,@rpath/lib${TARGET_LIB_NAME}.dylib - ) - ENDIF (APPLE) - - MESSAGE("### Flags for shared linking: ${CMAKE_SHARED_LINKER_FLAGS}") - MESSAGE("### Flags for module linking: ${CMAKE_MODULE_LINKER_FLAGS}") - - # build destination - SET(LIBRARY_OUTPUT_PATH ${TARGET_DIRECTORY}) - MESSAGE("### Library output path: ${TARGET_DIRECTORY}") - - # trigger library creation - IF(${BUILD_STATIC} MATCHES "ON") - MESSAGE("### Building DYNAMIC and STATIC LIBRARIES") - ADD_LIBRARY(${TARGET_LIB_NAME}_OBJECTS OBJECT ${SOURCES}) - ADD_LIBRARY(${TARGET_LIB_NAME} SHARED $) - ADD_LIBRARY(${TARGET_LIB_NAME}_static STATIC $) - ELSE() - MESSAGE("### Building only DYNAMIC LIBRARIES") - ADD_LIBRARY(${TARGET_LIB_NAME} SHARED ${SOURCES}) - ENDIF() - SET(TARGET_NAME - ${TARGET_LIB_NAME} - ) -ENDIF () -# generate program from given source files -IF (DEFINED TARGET_PROGRAM_NAME) - IF (WINDOWS) - MESSAGE("### Flags for Windows binary linking: ${CMAKE_EXE_LINKER_FLAGS}") - ENDIF (WINDOWS) - - # build destination - SET(EXECUTABLE_OUTPUT_PATH ${TARGET_DIRECTORY}) - MESSAGE("### Program output path: ${EXECUTABLE_OUTPUT_PATH}") - - # trigger program creation - IF(APPLE) -# ADD_EXECUTABLE(${TARGET_PROGRAM_NAME} MACOSX_BUNDLE ${SOURCES}) - ADD_EXECUTABLE(${TARGET_PROGRAM_NAME} ${SOURCES}) - ELSEIF (WINDOWS) - ADD_EXECUTABLE(${TARGET_PROGRAM_NAME} WIN32 ${SOURCES}) - ELSE () - IF(${BUILD_STATIC} MATCHES "ON") - ADD_LIBRARY(${TARGET_PROGRAM_NAME}_OBJECTS OBJECT ${SOURCES}) - ADD_EXECUTABLE(${TARGET_PROGRAM_NAME} $) - ADD_EXECUTABLE(${TARGET_PROGRAM_NAME}_static $) - ELSE() - ADD_EXECUTABLE(${TARGET_PROGRAM_NAME} ${SOURCES}) - ENDIF() - ENDIF () - SET(TARGET_NAME - ${TARGET_PROGRAM_NAME} - ) - # binary versioning - IF (${BINARY_WITH_VERSIONING} MATCHES "ON") - SET_TARGET_PROPERTIES(${TARGET_PROGRAM_NAME} PROPERTIES VERSION ${BINARY_VERSION}) - ENDIF() -ENDIF () - -############################################################## -# INSTALL library: define install target -IF (DEFINED INSTALL_LIBDIR) - MESSAGE("##### Libraries will be installed to " ${INSTALL_LIBDIR}) -ENDIF() -IF (DEFINED TARGET_LIB_NAME) - IF (DEFINED INSTALL_LIBDIR) - INSTALL(TARGETS ${TARGET_NAME} COMPONENT libraries RUNTIME DESTINATION ${INSTALL_LIBDIR} LIBRARY DESTINATION ${INSTALL_LIBDIR}) - ELSE() - IF(WINDOWS) - INSTALL(TARGETS ${TARGET_NAME} COMPONENT libraries RUNTIME DESTINATION . LIBRARY DESTINATION .) - ELSE() - INSTALL(TARGETS ${TARGET_NAME} COMPONENT libraries RUNTIME DESTINATION lib LIBRARY DESTINATION lib) - ENDIF() - ENDIF() -ENDIF () - -# INSTALL data files -IF (DEFINED INSTALL_DATADIR) - MESSAGE("##### Data files will be installed to " ${INSTALL_DATADIR}) -ENDIF() - -# INSTALL executable: define install target -IF (DEFINED TARGET_PROGRAM_NAME) - IF(WINDOWS) - INSTALL(TARGETS ${TARGET_NAME} RUNTIME DESTINATION . COMPONENT application) - ELSE() - INSTALL(TARGETS ${TARGET_NAME} BUNDLE DESTINATION . RUNTIME DESTINATION . PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT application) - ENDIF() -ENDIF() - -# INSTALL additional libraries: define install target -IF (WINDOWS) - MESSAGE("### Will additionally install Windows libraries: ${LIBS_WINDOWS_INSTALL}") - FOREACH(LIBS_WINDOWS_INSTALL_ENTRY ${LIBS_WINDOWS_INSTALL}) - GET_FILENAME_COMPONENT(LIBS_INSTALL_ENTRY_PATH_PREFIX ${LIBS_WINDOWS_INSTALL_ENTRY} PATH) - INSTALL(FILES release/win${ARCH_BITS}/${LIBS_WINDOWS_INSTALL_ENTRY} DESTINATION ./${LIBS_INSTALL_ENTRY_PATH_PREFIX} COMPONENT extlibraries) - ENDFOREACH(LIBS_WINDOWS_INSTALL_ENTRY ${LIBS_WINDOWS_INSTALL}) -ENDIF() -IF (LINUX) - MESSAGE("### Will additionally install Linux libraries: ${LIBS_LINUX_INSTALL}") - FOREACH(LIBS_LINUX_INSTALL_ENTRY ${LIBS_LINUX_INSTALL}) - GET_FILENAME_COMPONENT(LIBS_INSTALL_ENTRY_PATH_PREFIX ${LIBS_LINUX_INSTALL_ENTRY} PATH) - INSTALL(FILES release/linux${ARCH_BITS}/${LIBS_LINUX_INSTALL_ENTRY} DESTINATION lib/${LIBS_INSTALL_ENTRY_PATH_PREFIX} COMPONENT extlibraries) - ENDFOREACH(LIBS_LINUX_INSTALL_ENTRY ${LIBS_LINUX_INSTALL}) -ENDIF() -IF (APPLE) - MESSAGE("### Will additionally install OS X libraries: ${LIBS_APPLE_INSTALL}") - FOREACH(LIBS_APPLE_INSTALL_ENTRY ${LIBS_APPLE_INSTALL}) - GET_FILENAME_COMPONENT(LIBS_INSTALL_ENTRY_PATH_PREFIX ${LIBS_APPLE_INSTALL_ENTRY} PATH) - INSTALL(FILES release/apple${ARCH_BITS}/${LIBS_APPLE_INSTALL_ENTRY} DESTINATION lib/${LIBS_INSTALL_ENTRY_PATH_PREFIX} COMPONENT extlibraries) - ENDFOREACH(LIBS_APPLE_INSTALL_ENTRY ${LIBS_APPLE_INSTALL}) -ENDIF() - -############################################################## -# link to needed external libraries -IF (DEFINED TARGET_NAME) - IF (WINDOWS) - MESSAGE("### Linking dynamic Windows libraries: ${LIBS_WINDOWS}") - TARGET_LINK_LIBRARIES(${TARGET_NAME} ${LIBS_WINDOWS}) - ENDIF (WINDOWS) -ENDIF() - -# if nothing is set dont do anything -# workaround to use the same compiler flags defined above for google benchmark -IF (DEFINED TARGET_LIB_NAME OR DEFINED TARGET_PROGRAM_NAME) - - IF (APPLE) - # activate rpath - SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) - SET(CMAKE_BUILD_WITH_INSTALL_RPATH ON) - - MESSAGE("### Linking static Apple libraries: ${LIBS_APPLE_STATIC}") - SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-search_paths_first") - TARGET_LINK_LIBRARIES(${TARGET_NAME} ${LIBS_APPLE_STATIC}) - - MESSAGE("### Linking dynamic Apple libraries: ${LIBS_APPLE}") - TARGET_LINK_LIBRARIES(${TARGET_NAME} ${LIBS_APPLE}) - - MESSAGE("### Linking Apple frameworks: ${FRAMEWORKS_APPLE}") - FOREACH(FRAMEWORKS_APPLE_ENTRY ${FRAMEWORKS_APPLE}) - TARGET_LINK_LIBRARIES(${TARGET_NAME} "-framework ${FRAMEWORKS_APPLE_ENTRY}" ) - ENDFOREACH(FRAMEWORKS_APPLE_ENTRY ${FRAMEWORKS_APPLE}) - ENDIF (APPLE) - IF (BSD) - MESSAGE("### Linking static BSD libraries: ${LIBS_BSD_STATIC}") - # TARGET_LINK_LIBRARIES(${TARGET_NAME} ${LIBS_BSD_STATIC} ) - TARGET_LINK_LIBRARIES(${TARGET_NAME} -Wl,-Bstatic -Wl,-Bsymbolic ${LIBS_BSD_STATIC} -Wl,-Bdynamic ) - - MESSAGE("### Linking dynamic BSD libraries: ${LIBS_BSD}") - TARGET_LINK_LIBRARIES(${TARGET_NAME} ${LIBS_BSD}) - ENDIF (BSD) - - IF (LINUX) - MESSAGE("### Linking static Linux libraries: ${LIBS_LINUX_STATIC}") - TARGET_LINK_LIBRARIES(${TARGET_NAME} -Wl,-Bstatic -Wl,-Bsymbolic ${LIBS_LINUX_STATIC} -Wl,-Bdynamic ) - IF(${BUILD_STATIC} MATCHES "ON") - TARGET_LINK_LIBRARIES(${TARGET_NAME}_static -Wl,-Bstatic -Wl,-Bsymbolic ${LIBS_LINUX_STATIC_BIN_STATIC} -Wl,-Bdynamic ) - ENDIF() - - MESSAGE("### Linking dynamic Linux libraries: ${LIBS_LINUX}") - TARGET_LINK_LIBRARIES(${TARGET_NAME} ${LIBS_LINUX}) - ENDIF (LINUX) -ENDIF() diff --git a/cmake/CMakeEnvironment.txt b/cmake/CMakeEnvironment.txt deleted file mode 100644 index fca27b6c5..000000000 --- a/cmake/CMakeEnvironment.txt +++ /dev/null @@ -1,116 +0,0 @@ -############################################################################### -# -# Copyright (C) 2015 Thomas Volkert -# All rights reserved. -# -# The environment was provided for the POL project. Redistribution -# and use in source and binary forms, with or without modification, -# are permitted. However, this paragraph has to be included in its -# original form in every project. -# -############################################################################### - -MESSAGE("####################################") -MESSAGE("##### Preparing configuration") -MESSAGE("####################################") - -############################################################## -# every version information in the rest of the build system is generated from the following entries -INCLUDE (${CMAKE_CURRENT_LIST_DIR}/Version.txt) -set(BINARY_VERSION "${BINARY_VERSION_MAJOR}.${BINARY_VERSION_MINOR}.${BINARY_VERSION_PATCH}") - -############################################################## -# architecture -IF (NOT DEFINED FORCE_ARCH_BITS) - IF ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - set(ARCH_BITS "64") - MESSAGE("Detected architecture is 64 bit") - ELSEIF ("${CMAKE_SIZEOF_VOID_P}" EQUAL "4") - set(ARCH_BITS "32") - MESSAGE("Detected architecture is 32 bit") - ELSE() - MESSAGE("Unable to detect architecture of your system") - ENDIF() -ELSE() - set(ARCH_BITS - ${FORCE_ARCH_BITS} - ) - MESSAGE("Architecture was explicitly defined as ${FORCE_ARCH_BITS} bit") -ENDIF (NOT DEFINED FORCE_ARCH_BITS) - -############################################################## -# detect processor type -MESSAGE("Detected processor type is ${CMAKE_SYSTEM_PROCESSOR}") - -############################################################## -# detect compiler -IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - MESSAGE("Detected compiler type is Clang " ${CMAKE_CXX_COMPILER_VERSION}) - SET (CLANG "true") -ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - MESSAGE("Detected compiler type is GNU GCC " ${CMAKE_CXX_COMPILER_VERSION}) - SET (GCC "true") -ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") - MESSAGE("Detected compiler type is Intel C++ " ${CMAKE_CXX_COMPILER_VERSION}) - SET (INTELCPP "true") -ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - MESSAGE("Detected compiler type is Visual Studio C++ " ${CMAKE_CXX_COMPILER_VERSION}) - SET (VSCPP "true") -ENDIF() - -############################################################## -# detect FreeBSD -IF (${CMAKE_SYSTEM} MATCHES "FreeBSD.*") - SET (BSD "true") - - # clear LINUX variable, otherwise the source gets confused because cmake detects FreeBSD also as LINUX environment - SET (LINUX) - MESSAGE("Target system is FreeBSD") -ELSE() - MESSAGE("Target system is ${CMAKE_SYSTEM}") -ENDIF() - -############################################################## -# detect Linux -IF (UNIX AND NOT WIN32 AND NOT APPLE AND NOT BSD) - MESSAGE("Target system is Linux") - SET (LINUX "true") -ENDIF() - -############################################################## -# detect OS X -if (APPLE) - exec_program(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION) - string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION}) - if (DARWIN_VERSION LESS 10) - # 10.6 of Snow Leopard is minimum - MESSAGE(FATAL_ERROR "You need at least OS X Snow Leopard") - endif() - if (DARWIN_VERSION EQUAL 10) - MESSAGE("Target system is DARWIN version 10 from OS X Snow Leopard") - elseif (DARWIN_VERSION EQUAL 11) - MESSAGE("Target system is DARWIN version 11 from OS X Lion") - else() - message("Target system is DARWIN version ${DARWIN_VERSION}") - endif() -endif(APPLE) - -############################################################## -# detect Windows -IF (WIN32) - SET (WINDOWS "true") - IF ("${ARCH_BITS}" EQUAL "64") - MESSAGE("Target system is Windows64") - SET(WIN64 "true") - # undefine WIN32 - SET(WIN32) - ELSE() - MESSAGE("Target system is Windows32") - SET(WIN32 "true") - ENDIF() -ENDIF() - -############################################################## -SET (PRE_DEFINITIONS_EXECUTED "true") - -INCLUDE (${CMAKE_CURRENT_LIST_DIR}/POL.txt) \ No newline at end of file diff --git a/cmake/CMakeWindowsBinary.txt b/cmake/CMakeWindowsBinary.txt deleted file mode 100644 index f4da273e0..000000000 --- a/cmake/CMakeWindowsBinary.txt +++ /dev/null @@ -1,31 +0,0 @@ -############################################################################### -# -# Copyright (C) 2015 Thomas Volkert -# All rights reserved. -# -# The environment was provided for the POL project. Redistribution -# and use in source and binary forms, with or without modification, -# are permitted. However, this paragraph has to be included in its -# original form in every project. -# -############################################################################### - -MESSAGE("##### RC file generation for Windows build") - -############################################################## -# WINDOWS: create binary.rc automatically as additional object for linking process -IF(WINDOWS) - configure_file( - binary.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/binary.rc - @ONLY) -ENDIF() - -############################################################## -# WINDOWS: add binary.rc file to linking process -IF (WINDOWS) - SET (SOURCES - ${SOURCES} - ${CMAKE_CURRENT_BINARY_DIR}/binary.rc - ) -ENDIF() diff --git a/cmake/CMakeWindowsLibrary.txt b/cmake/CMakeWindowsLibrary.txt deleted file mode 100644 index 497c80a90..000000000 --- a/cmake/CMakeWindowsLibrary.txt +++ /dev/null @@ -1,29 +0,0 @@ -############################################################################### -# -# Copyright (C) 2015 Thomas Volkert -# All rights reserved. -# -# The environment was provided for the POL project. Redistribution -# and use in source and binary forms, with or without modification, -# are permitted. However, this paragraph has to be included in its -# original form in every project. -# -############################################################################### - -MESSAGE("##### RC file generation for Windows build") - -IF(WINDOWS) - ############################################################## - # WINDOWS: create library.rc automatically as additional object for linking process - configure_file( - library.rc.in - ${CMAKE_CURRENT_BINARY_DIR}/library.rc - @ONLY) - - ############################################################## - # WINDOWS: add binary.rc file to linking process - SET (SOURCES - ${SOURCES} - ${CMAKE_CURRENT_BINARY_DIR}/library.rc - ) -ENDIF() diff --git a/cmake/Curl.txt b/cmake/Curl.txt index ef4926763..3205c38b4 100644 --- a/cmake/Curl.txt +++ b/cmake/Curl.txt @@ -1,16 +1,9 @@ -MESSAGE("####################################") -MESSAGE("##### Building POL - CURL") -MESSAGE("####################################") - - -SET (CURL_EXECUTED "true") - +message("* curl") set(CURL_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../lib/curl") set(CURL_INSTALL_DIR "${CURL_SOURCE_DIR}/INSTALL") - IF(NOT EXISTS "${CURL_INSTALL_DIR}/include/curl/curl.h") -ExternalProject_Add(libcurl + ExternalProject_Add(libcurl URL "${CURL_SOURCE_DIR}/../curl-7.57.0.zip" SOURCE_DIR "${CURL_SOURCE_DIR}" INSTALL_DIR ${CURL_INSTALL_DIR} @@ -24,7 +17,7 @@ ExternalProject_Add(libcurl LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 -) + ) ELSE() MESSAGE("Curl already build") diff --git a/cmake/POL.txt b/cmake/POL.txt deleted file mode 100644 index 90484c617..000000000 --- a/cmake/POL.txt +++ /dev/null @@ -1,95 +0,0 @@ -############################################################################### - -MESSAGE("####################################") -MESSAGE("##### Preparing POL specific configuration") -MESSAGE("####################################") -MESSAGE("##### Build type is: " ${BUILD}) - -############################################################## - -# versioning -set(BINARY_WITH_VERSIONING OFF) - -# activate static builds -set(BUILD_STATIC OFF) - -# create global pol_config.h -INCLUDE (CheckIncludeFiles) -IF(WINDOWS) - SET(HAVE_OPENSSL true) - SET(HAVE_MYSQL true) -ELSE() - CHECK_INCLUDE_FILES (openssl/md5.h HAVE_OPENSSL) - CHECK_INCLUDE_FILES (mysql/mysql.h HAVE_MYSQL) -ENDIF() -CONFIGURE_FILE( - ${CMAKE_CURRENT_LIST_DIR}/env/pol_global_config.h.in - ${CMAKE_CURRENT_BINARY_DIR}/pol_global_config.h -) - -############################################################## -# compile FLAGS and INCLUDE dirs -IF(LINUX) - SET (FLAGS - ${FLAGS} - -D_GNU_SOURCE - -std=c++11 - -DINC_PASSERT=1 - -DTIXML_USE_STL - -W - -Wall - # -Wno-overloaded-virtual - # -Wno-switch - -Wno-unused - -Wno-long-long - -Wno-deprecated-declarations - -Wno-format - -Wno-unused-parameter - -Wno-unknown-pragmas - -fno-strict-aliasing - -Wno-unused-result - ) - IF(GCC) - SET (FLAGS - ${FLAGS} - -fopenmp - -Wno-unused-but-set-parameter - ) - ENDIF() - -ENDIF() -IF(WINDOWS) - SET (FLAGS - ${FLAGS} - /D"INC_PASSERT" - /D"TIXML_USE_STL" - /D"_WIN32" - /D"WIN32" - /D"NOMINMAX" - ) - SET (INCLUDE_DIRS - ${INCLUDE_DIRS} - ../../lib/mysql-connector-c-6.0.2-win32 - ) - -ENDIF() - -##### BOOST -IF (NOT BOOST_EXECUTED) - INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../cmake/Boost.txt) -ENDIF () -INCLUDE_DIRECTORIES(${BOOST_SOURCE_DIR}) -LINK_DIRECTORIES(${BOOST_LIBRARY_DIR}) - -##### CURL -IF (NOT CURL_EXECUTED) - INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../cmake/Curl.txt) -ENDIF () -INCLUDE_DIRECTORIES(BEFORE SYSTEM ${CURL_INSTALL_DIR}/include) -LINK_DIRECTORIES(${CURL_INSTALL_DIR}/lib) - -IF (DEFINED ENABLE_BENCHMARK) -INCLUDE_DIRECTORIES("${CMAKE_CURRENT_LIST_DIR}/../lib/google-benchmark/include") -ENDIF() - -INCLUDE_DIRECTORIES("${CMAKE_CURRENT_LIST_DIR}/../lib/picojson-1.3.0") diff --git a/cmake/Version.txt b/cmake/Version.txt deleted file mode 100644 index 3137e94b5..000000000 --- a/cmake/Version.txt +++ /dev/null @@ -1,5 +0,0 @@ -set(BINARY_VERSION_MAJOR "99") -set(BINARY_VERSION_MINOR "0") -set(BINARY_VERSION_PATCH "0") - -set(BINARY_VERSION_NAME "Break Everything Even Rudder") diff --git a/cmake/cotire.cmake b/cmake/cotire.cmake new file mode 100644 index 000000000..62cd23db9 --- /dev/null +++ b/cmake/cotire.cmake @@ -0,0 +1,4054 @@ +# - cotire (compile time reducer) +# +# See the cotire manual for usage hints. +# +#============================================================================= +# Copyright 2012-2017 Sascha Kratky +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, +# copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following +# conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +#============================================================================= + +if(__COTIRE_INCLUDED) + return() +endif() +set(__COTIRE_INCLUDED TRUE) + +# call cmake_minimum_required, but prevent modification of the CMake policy stack in include mode +# cmake_minimum_required also sets the policy version as a side effect, which we have to avoid +if (NOT CMAKE_SCRIPT_MODE_FILE) + cmake_policy(PUSH) +endif() +cmake_minimum_required(VERSION 2.8.12) +if (NOT CMAKE_SCRIPT_MODE_FILE) + cmake_policy(POP) +endif() + +set (COTIRE_CMAKE_MODULE_FILE "${CMAKE_CURRENT_LIST_FILE}") +set (COTIRE_CMAKE_MODULE_VERSION "1.7.10") + +# activate select policies +if (POLICY CMP0025) + # Compiler id for Apple Clang is now AppleClang + cmake_policy(SET CMP0025 NEW) +endif() + +if (POLICY CMP0026) + # disallow use of the LOCATION target property + cmake_policy(SET CMP0026 NEW) +endif() + +if (POLICY CMP0038) + # targets may not link directly to themselves + cmake_policy(SET CMP0038 NEW) +endif() + +if (POLICY CMP0039) + # utility targets may not have link dependencies + cmake_policy(SET CMP0039 NEW) +endif() + +if (POLICY CMP0040) + # target in the TARGET signature of add_custom_command() must exist + cmake_policy(SET CMP0040 NEW) +endif() + +if (POLICY CMP0045) + # error on non-existent target in get_target_property + cmake_policy(SET CMP0045 NEW) +endif() + +if (POLICY CMP0046) + # error on non-existent dependency in add_dependencies + cmake_policy(SET CMP0046 NEW) +endif() + +if (POLICY CMP0049) + # do not expand variables in target source entries + cmake_policy(SET CMP0049 NEW) +endif() + +if (POLICY CMP0050) + # disallow add_custom_command SOURCE signatures + cmake_policy(SET CMP0050 NEW) +endif() + +if (POLICY CMP0051) + # include TARGET_OBJECTS expressions in a target's SOURCES property + cmake_policy(SET CMP0051 NEW) +endif() + +if (POLICY CMP0053) + # simplify variable reference and escape sequence evaluation + cmake_policy(SET CMP0053 NEW) +endif() + +if (POLICY CMP0054) + # only interpret if() arguments as variables or keywords when unquoted + cmake_policy(SET CMP0054 NEW) +endif() + +if (POLICY CMP0055) + # strict checking for break() command + cmake_policy(SET CMP0055 NEW) +endif() + +include(CMakeParseArguments) +include(ProcessorCount) + +function (cotire_get_configuration_types _configsVar) + set (_configs "") + if (CMAKE_CONFIGURATION_TYPES) + list (APPEND _configs ${CMAKE_CONFIGURATION_TYPES}) + endif() + if (CMAKE_BUILD_TYPE) + list (APPEND _configs "${CMAKE_BUILD_TYPE}") + endif() + if (_configs) + list (REMOVE_DUPLICATES _configs) + set (${_configsVar} ${_configs} PARENT_SCOPE) + else() + set (${_configsVar} "None" PARENT_SCOPE) + endif() +endfunction() + +function (cotire_get_source_file_extension _sourceFile _extVar) + # get_filename_component returns extension from first occurrence of . in file name + # this function computes the extension from last occurrence of . in file name + string (FIND "${_sourceFile}" "." _index REVERSE) + if (_index GREATER -1) + math (EXPR _index "${_index} + 1") + string (SUBSTRING "${_sourceFile}" ${_index} -1 _sourceExt) + else() + set (_sourceExt "") + endif() + set (${_extVar} "${_sourceExt}" PARENT_SCOPE) +endfunction() + +macro (cotire_check_is_path_relative_to _path _isRelativeVar) + set (${_isRelativeVar} FALSE) + if (IS_ABSOLUTE "${_path}") + foreach (_dir ${ARGN}) + file (RELATIVE_PATH _relPath "${_dir}" "${_path}") + if (NOT _relPath OR (NOT IS_ABSOLUTE "${_relPath}" AND NOT "${_relPath}" MATCHES "^\\.\\.")) + set (${_isRelativeVar} TRUE) + break() + endif() + endforeach() + endif() +endmacro() + +function (cotire_filter_language_source_files _language _target _sourceFilesVar _excludedSourceFilesVar _cotiredSourceFilesVar) + if (CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) + set (_languageExtensions "${CMAKE_${_language}_SOURCE_FILE_EXTENSIONS}") + else() + set (_languageExtensions "") + endif() + if (CMAKE_${_language}_IGNORE_EXTENSIONS) + set (_ignoreExtensions "${CMAKE_${_language}_IGNORE_EXTENSIONS}") + else() + set (_ignoreExtensions "") + endif() + if (COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS) + set (_excludeExtensions "${COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS}") + else() + set (_excludeExtensions "") + endif() + if (COTIRE_DEBUG AND _languageExtensions) + message (STATUS "${_language} source file extensions: ${_languageExtensions}") + endif() + if (COTIRE_DEBUG AND _ignoreExtensions) + message (STATUS "${_language} ignore extensions: ${_ignoreExtensions}") + endif() + if (COTIRE_DEBUG AND _excludeExtensions) + message (STATUS "${_language} exclude extensions: ${_excludeExtensions}") + endif() + if (CMAKE_VERSION VERSION_LESS "3.1.0") + set (_allSourceFiles ${ARGN}) + else() + # as of CMake 3.1 target sources may contain generator expressions + # since we cannot obtain required property information about source files added + # through generator expressions at configure time, we filter them out + string (GENEX_STRIP "${ARGN}" _allSourceFiles) + endif() + set (_filteredSourceFiles "") + set (_excludedSourceFiles "") + foreach (_sourceFile ${_allSourceFiles}) + get_source_file_property(_sourceIsHeaderOnly "${_sourceFile}" HEADER_FILE_ONLY) + get_source_file_property(_sourceIsExternal "${_sourceFile}" EXTERNAL_OBJECT) + get_source_file_property(_sourceIsSymbolic "${_sourceFile}" SYMBOLIC) + if (NOT _sourceIsHeaderOnly AND NOT _sourceIsExternal AND NOT _sourceIsSymbolic) + cotire_get_source_file_extension("${_sourceFile}" _sourceExt) + if (_sourceExt) + list (FIND _ignoreExtensions "${_sourceExt}" _ignoreIndex) + if (_ignoreIndex LESS 0) + list (FIND _excludeExtensions "${_sourceExt}" _excludeIndex) + if (_excludeIndex GREATER -1) + list (APPEND _excludedSourceFiles "${_sourceFile}") + else() + list (FIND _languageExtensions "${_sourceExt}" _sourceIndex) + if (_sourceIndex GREATER -1) + # consider source file unless it is excluded explicitly + get_source_file_property(_sourceIsExcluded "${_sourceFile}" COTIRE_EXCLUDED) + if (_sourceIsExcluded) + list (APPEND _excludedSourceFiles "${_sourceFile}") + else() + list (APPEND _filteredSourceFiles "${_sourceFile}") + endif() + else() + get_source_file_property(_sourceLanguage "${_sourceFile}" LANGUAGE) + if ("${_sourceLanguage}" STREQUAL "${_language}") + # add to excluded sources, if file is not ignored and has correct language without having the correct extension + list (APPEND _excludedSourceFiles "${_sourceFile}") + endif() + endif() + endif() + endif() + endif() + endif() + endforeach() + # separate filtered source files from already cotired ones + # the COTIRE_TARGET property of a source file may be set while a target is being processed by cotire + set (_sourceFiles "") + set (_cotiredSourceFiles "") + foreach (_sourceFile ${_filteredSourceFiles}) + get_source_file_property(_sourceIsCotired "${_sourceFile}" COTIRE_TARGET) + if (_sourceIsCotired) + list (APPEND _cotiredSourceFiles "${_sourceFile}") + else() + get_source_file_property(_sourceCompileFlags "${_sourceFile}" COMPILE_FLAGS) + if (_sourceCompileFlags) + # add to excluded sources, if file has custom compile flags + list (APPEND _excludedSourceFiles "${_sourceFile}") + else() + list (APPEND _sourceFiles "${_sourceFile}") + endif() + endif() + endforeach() + if (COTIRE_DEBUG) + if (_sourceFiles) + message (STATUS "Filtered ${_target} ${_language} sources: ${_sourceFiles}") + endif() + if (_excludedSourceFiles) + message (STATUS "Excluded ${_target} ${_language} sources: ${_excludedSourceFiles}") + endif() + if (_cotiredSourceFiles) + message (STATUS "Cotired ${_target} ${_language} sources: ${_cotiredSourceFiles}") + endif() + endif() + set (${_sourceFilesVar} ${_sourceFiles} PARENT_SCOPE) + set (${_excludedSourceFilesVar} ${_excludedSourceFiles} PARENT_SCOPE) + set (${_cotiredSourceFilesVar} ${_cotiredSourceFiles} PARENT_SCOPE) +endfunction() + +function (cotire_get_objects_with_property_on _filteredObjectsVar _property _type) + set (_filteredObjects "") + foreach (_object ${ARGN}) + get_property(_isSet ${_type} "${_object}" PROPERTY ${_property} SET) + if (_isSet) + get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property}) + if (_propertyValue) + list (APPEND _filteredObjects "${_object}") + endif() + endif() + endforeach() + set (${_filteredObjectsVar} ${_filteredObjects} PARENT_SCOPE) +endfunction() + +function (cotire_get_objects_with_property_off _filteredObjectsVar _property _type) + set (_filteredObjects "") + foreach (_object ${ARGN}) + get_property(_isSet ${_type} "${_object}" PROPERTY ${_property} SET) + if (_isSet) + get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property}) + if (NOT _propertyValue) + list (APPEND _filteredObjects "${_object}") + endif() + endif() + endforeach() + set (${_filteredObjectsVar} ${_filteredObjects} PARENT_SCOPE) +endfunction() + +function (cotire_get_source_file_property_values _valuesVar _property) + set (_values "") + foreach (_sourceFile ${ARGN}) + get_source_file_property(_propertyValue "${_sourceFile}" ${_property}) + if (_propertyValue) + list (APPEND _values "${_propertyValue}") + endif() + endforeach() + set (${_valuesVar} ${_values} PARENT_SCOPE) +endfunction() + +function (cotire_resolve_config_properties _configurations _propertiesVar) + set (_properties "") + foreach (_property ${ARGN}) + if ("${_property}" MATCHES "") + foreach (_config ${_configurations}) + string (TOUPPER "${_config}" _upperConfig) + string (REPLACE "" "${_upperConfig}" _configProperty "${_property}") + list (APPEND _properties ${_configProperty}) + endforeach() + else() + list (APPEND _properties ${_property}) + endif() + endforeach() + set (${_propertiesVar} ${_properties} PARENT_SCOPE) +endfunction() + +function (cotire_copy_set_properties _configurations _type _source _target) + cotire_resolve_config_properties("${_configurations}" _properties ${ARGN}) + foreach (_property ${_properties}) + get_property(_isSet ${_type} ${_source} PROPERTY ${_property} SET) + if (_isSet) + get_property(_propertyValue ${_type} ${_source} PROPERTY ${_property}) + set_property(${_type} ${_target} PROPERTY ${_property} "${_propertyValue}") + endif() + endforeach() +endfunction() + +function (cotire_get_target_usage_requirements _target _config _targetRequirementsVar) + set (_targetRequirements "") + get_target_property(_librariesToProcess ${_target} LINK_LIBRARIES) + while (_librariesToProcess) + # remove from head + list (GET _librariesToProcess 0 _library) + list (REMOVE_AT _librariesToProcess 0) + if (_library MATCHES "^\\$<\\$:([A-Za-z0-9_:-]+)>$") + set (_library "${CMAKE_MATCH_1}") + elseif (_config STREQUAL "None" AND _library MATCHES "^\\$<\\$:([A-Za-z0-9_:-]+)>$") + set (_library "${CMAKE_MATCH_1}") + endif() + if (TARGET ${_library}) + list (FIND _targetRequirements ${_library} _index) + if (_index LESS 0) + list (APPEND _targetRequirements ${_library}) + # BFS traversal of transitive libraries + get_target_property(_libraries ${_library} INTERFACE_LINK_LIBRARIES) + if (_libraries) + list (APPEND _librariesToProcess ${_libraries}) + list (REMOVE_DUPLICATES _librariesToProcess) + endif() + endif() + endif() + endwhile() + set (${_targetRequirementsVar} ${_targetRequirements} PARENT_SCOPE) +endfunction() + +function (cotire_filter_compile_flags _language _flagFilter _matchedOptionsVar _unmatchedOptionsVar) + if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + set (_flagPrefix "[/-]") + else() + set (_flagPrefix "--?") + endif() + set (_optionFlag "") + set (_matchedOptions "") + set (_unmatchedOptions "") + foreach (_compileFlag ${ARGN}) + if (_compileFlag) + if (_optionFlag AND NOT "${_compileFlag}" MATCHES "^${_flagPrefix}") + # option with separate argument + list (APPEND _matchedOptions "${_compileFlag}") + set (_optionFlag "") + elseif ("${_compileFlag}" MATCHES "^(${_flagPrefix})(${_flagFilter})$") + # remember option + set (_optionFlag "${CMAKE_MATCH_2}") + elseif ("${_compileFlag}" MATCHES "^(${_flagPrefix})(${_flagFilter})(.+)$") + # option with joined argument + list (APPEND _matchedOptions "${CMAKE_MATCH_3}") + set (_optionFlag "") + else() + # flush remembered option + if (_optionFlag) + list (APPEND _matchedOptions "${_optionFlag}") + set (_optionFlag "") + endif() + # add to unfiltered options + list (APPEND _unmatchedOptions "${_compileFlag}") + endif() + endif() + endforeach() + if (_optionFlag) + list (APPEND _matchedOptions "${_optionFlag}") + endif() + if (COTIRE_DEBUG AND _matchedOptions) + message (STATUS "Filter ${_flagFilter} matched: ${_matchedOptions}") + endif() + if (COTIRE_DEBUG AND _unmatchedOptions) + message (STATUS "Filter ${_flagFilter} unmatched: ${_unmatchedOptions}") + endif() + set (${_matchedOptionsVar} ${_matchedOptions} PARENT_SCOPE) + set (${_unmatchedOptionsVar} ${_unmatchedOptions} PARENT_SCOPE) +endfunction() + +function (cotire_is_target_supported _target _isSupportedVar) + if (NOT TARGET "${_target}") + set (${_isSupportedVar} FALSE PARENT_SCOPE) + return() + endif() + get_target_property(_imported ${_target} IMPORTED) + if (_imported) + set (${_isSupportedVar} FALSE PARENT_SCOPE) + return() + endif() + get_target_property(_targetType ${_target} TYPE) + if (NOT _targetType MATCHES "EXECUTABLE|(STATIC|SHARED|MODULE|OBJECT)_LIBRARY") + set (${_isSupportedVar} FALSE PARENT_SCOPE) + return() + endif() + set (${_isSupportedVar} TRUE PARENT_SCOPE) +endfunction() + +function (cotire_get_target_compile_flags _config _language _target _flagsVar) + string (TOUPPER "${_config}" _upperConfig) + # collect options from CMake language variables + set (_compileFlags "") + if (CMAKE_${_language}_FLAGS) + set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS}") + endif() + if (CMAKE_${_language}_FLAGS_${_upperConfig}) + set (_compileFlags "${_compileFlags} ${CMAKE_${_language}_FLAGS_${_upperConfig}}") + endif() + if (_target) + # add target compile flags + get_target_property(_targetflags ${_target} COMPILE_FLAGS) + if (_targetflags) + set (_compileFlags "${_compileFlags} ${_targetflags}") + endif() + endif() + if (UNIX) + separate_arguments(_compileFlags UNIX_COMMAND "${_compileFlags}") + elseif(WIN32) + separate_arguments(_compileFlags WINDOWS_COMMAND "${_compileFlags}") + else() + separate_arguments(_compileFlags) + endif() + # target compile options + if (_target) + get_target_property(_targetOptions ${_target} COMPILE_OPTIONS) + if (_targetOptions) + list (APPEND _compileFlags ${_targetOptions}) + endif() + endif() + # interface compile options from linked library targets + if (_target) + set (_linkedTargets "") + cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets) + foreach (_linkedTarget ${_linkedTargets}) + get_target_property(_targetOptions ${_linkedTarget} INTERFACE_COMPILE_OPTIONS) + if (_targetOptions) + list (APPEND _compileFlags ${_targetOptions}) + endif() + endforeach() + endif() + # handle language standard properties + if (CMAKE_${_language}_STANDARD_DEFAULT) + # used compiler supports language standard levels + if (_target) + get_target_property(_targetLanguageStandard ${_target} ${_language}_STANDARD) + if (_targetLanguageStandard) + set (_type "EXTENSION") + get_property(_isSet TARGET ${_target} PROPERTY ${_language}_EXTENSIONS SET) + if (_isSet) + get_target_property(_targetUseLanguageExtensions ${_target} ${_language}_EXTENSIONS) + if (NOT _targetUseLanguageExtensions) + set (_type "STANDARD") + endif() + endif() + if (CMAKE_${_language}${_targetLanguageStandard}_${_type}_COMPILE_OPTION) + list (APPEND _compileFlags "${CMAKE_${_language}${_targetLanguageStandard}_${_type}_COMPILE_OPTION}") + endif() + endif() + endif() + endif() + # handle the POSITION_INDEPENDENT_CODE target property + if (_target) + get_target_property(_targetPIC ${_target} POSITION_INDEPENDENT_CODE) + if (_targetPIC) + get_target_property(_targetType ${_target} TYPE) + if (_targetType STREQUAL "EXECUTABLE" AND CMAKE_${_language}_COMPILE_OPTIONS_PIE) + list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_PIE}") + elseif (CMAKE_${_language}_COMPILE_OPTIONS_PIC) + list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_PIC}") + endif() + endif() + endif() + # handle visibility target properties + if (_target) + get_target_property(_targetVisibility ${_target} ${_language}_VISIBILITY_PRESET) + if (_targetVisibility AND CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY) + list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY}${_targetVisibility}") + endif() + get_target_property(_targetVisibilityInlines ${_target} VISIBILITY_INLINES_HIDDEN) + if (_targetVisibilityInlines AND CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN) + list (APPEND _compileFlags "${CMAKE_${_language}_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN}") + endif() + endif() + # platform specific flags + if (APPLE) + get_target_property(_architectures ${_target} OSX_ARCHITECTURES_${_upperConfig}) + if (NOT _architectures) + get_target_property(_architectures ${_target} OSX_ARCHITECTURES) + endif() + if (_architectures) + foreach (_arch ${_architectures}) + list (APPEND _compileFlags "-arch" "${_arch}") + endforeach() + endif() + if (CMAKE_OSX_SYSROOT) + if (CMAKE_${_language}_SYSROOT_FLAG) + list (APPEND _compileFlags "${CMAKE_${_language}_SYSROOT_FLAG}" "${CMAKE_OSX_SYSROOT}") + else() + list (APPEND _compileFlags "-isysroot" "${CMAKE_OSX_SYSROOT}") + endif() + endif() + if (CMAKE_OSX_DEPLOYMENT_TARGET) + if (CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG) + list (APPEND _compileFlags "${CMAKE_${_language}_OSX_DEPLOYMENT_TARGET_FLAG}${CMAKE_OSX_DEPLOYMENT_TARGET}") + else() + list (APPEND _compileFlags "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}") + endif() + endif() + endif() + if (COTIRE_DEBUG AND _compileFlags) + message (STATUS "Target ${_target} compile flags: ${_compileFlags}") + endif() + set (${_flagsVar} ${_compileFlags} PARENT_SCOPE) +endfunction() + +function (cotire_get_target_include_directories _config _language _target _includeDirsVar _systemIncludeDirsVar) + set (_includeDirs "") + set (_systemIncludeDirs "") + # default include dirs + if (CMAKE_INCLUDE_CURRENT_DIR) + list (APPEND _includeDirs "${CMAKE_CURRENT_BINARY_DIR}") + list (APPEND _includeDirs "${CMAKE_CURRENT_SOURCE_DIR}") + endif() + set (_targetFlags "") + cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags) + # parse additional include directories from target compile flags + if (CMAKE_INCLUDE_FLAG_${_language}) + string (STRIP "${CMAKE_INCLUDE_FLAG_${_language}}" _includeFlag) + string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}") + if (_includeFlag) + set (_dirs "") + cotire_filter_compile_flags("${_language}" "${_includeFlag}" _dirs _ignore ${_targetFlags}) + if (_dirs) + list (APPEND _includeDirs ${_dirs}) + endif() + endif() + endif() + # parse additional system include directories from target compile flags + if (CMAKE_INCLUDE_SYSTEM_FLAG_${_language}) + string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" _includeFlag) + string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}") + if (_includeFlag) + set (_dirs "") + cotire_filter_compile_flags("${_language}" "${_includeFlag}" _dirs _ignore ${_targetFlags}) + if (_dirs) + list (APPEND _systemIncludeDirs ${_dirs}) + endif() + endif() + endif() + # target include directories + get_directory_property(_dirs DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" INCLUDE_DIRECTORIES) + if (_target) + get_target_property(_targetDirs ${_target} INCLUDE_DIRECTORIES) + if (_targetDirs) + list (APPEND _dirs ${_targetDirs}) + endif() + get_target_property(_targetDirs ${_target} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) + if (_targetDirs) + list (APPEND _systemIncludeDirs ${_targetDirs}) + endif() + endif() + # interface include directories from linked library targets + if (_target) + set (_linkedTargets "") + cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets) + foreach (_linkedTarget ${_linkedTargets}) + get_target_property(_linkedTargetType ${_linkedTarget} TYPE) + if (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE AND NOT CMAKE_VERSION VERSION_LESS "3.4.0" AND + _linkedTargetType MATCHES "(STATIC|SHARED|MODULE|OBJECT)_LIBRARY") + # CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE refers to CMAKE_CURRENT_BINARY_DIR and CMAKE_CURRENT_SOURCE_DIR + # at the time, when the target was created. These correspond to the target properties BINARY_DIR and SOURCE_DIR + # which are only available with CMake 3.4 or later. + get_target_property(_targetDirs ${_linkedTarget} BINARY_DIR) + if (_targetDirs) + list (APPEND _dirs ${_targetDirs}) + endif() + get_target_property(_targetDirs ${_linkedTarget} SOURCE_DIR) + if (_targetDirs) + list (APPEND _dirs ${_targetDirs}) + endif() + endif() + get_target_property(_targetDirs ${_linkedTarget} INTERFACE_INCLUDE_DIRECTORIES) + if (_targetDirs) + list (APPEND _dirs ${_targetDirs}) + endif() + get_target_property(_targetDirs ${_linkedTarget} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) + if (_targetDirs) + list (APPEND _systemIncludeDirs ${_targetDirs}) + endif() + endforeach() + endif() + if (dirs) + list (REMOVE_DUPLICATES _dirs) + endif() + list (LENGTH _includeDirs _projectInsertIndex) + foreach (_dir ${_dirs}) + if (CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE) + cotire_check_is_path_relative_to("${_dir}" _isRelative "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}") + if (_isRelative) + list (LENGTH _includeDirs _len) + if (_len EQUAL _projectInsertIndex) + list (APPEND _includeDirs "${_dir}") + else() + list (INSERT _includeDirs _projectInsertIndex "${_dir}") + endif() + math (EXPR _projectInsertIndex "${_projectInsertIndex} + 1") + else() + list (APPEND _includeDirs "${_dir}") + endif() + else() + list (APPEND _includeDirs "${_dir}") + endif() + endforeach() + list (REMOVE_DUPLICATES _includeDirs) + list (REMOVE_DUPLICATES _systemIncludeDirs) + if (CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES) + list (REMOVE_ITEM _includeDirs ${CMAKE_${_language}_IMPLICIT_INCLUDE_DIRECTORIES}) + endif() + if (WIN32 AND NOT MINGW) + # convert Windows paths in include directories to CMake paths + if (_includeDirs) + set (_paths "") + foreach (_dir ${_includeDirs}) + file (TO_CMAKE_PATH "${_dir}" _path) + list (APPEND _paths "${_path}") + endforeach() + set (_includeDirs ${_paths}) + endif() + if (_systemIncludeDirs) + set (_paths "") + foreach (_dir ${_systemIncludeDirs}) + file (TO_CMAKE_PATH "${_dir}" _path) + list (APPEND _paths "${_path}") + endforeach() + set (_systemIncludeDirs ${_paths}) + endif() + endif() + if (COTIRE_DEBUG AND _includeDirs) + message (STATUS "Target ${_target} include dirs: ${_includeDirs}") + endif() + set (${_includeDirsVar} ${_includeDirs} PARENT_SCOPE) + if (COTIRE_DEBUG AND _systemIncludeDirs) + message (STATUS "Target ${_target} system include dirs: ${_systemIncludeDirs}") + endif() + set (${_systemIncludeDirsVar} ${_systemIncludeDirs} PARENT_SCOPE) +endfunction() + +function (cotire_get_target_export_symbol _target _exportSymbolVar) + set (_exportSymbol "") + get_target_property(_targetType ${_target} TYPE) + get_target_property(_enableExports ${_target} ENABLE_EXPORTS) + if (_targetType MATCHES "(SHARED|MODULE)_LIBRARY" OR + (_targetType STREQUAL "EXECUTABLE" AND _enableExports)) + get_target_property(_exportSymbol ${_target} DEFINE_SYMBOL) + if (NOT _exportSymbol) + set (_exportSymbol "${_target}_EXPORTS") + endif() + string (MAKE_C_IDENTIFIER "${_exportSymbol}" _exportSymbol) + endif() + set (${_exportSymbolVar} ${_exportSymbol} PARENT_SCOPE) +endfunction() + +function (cotire_get_target_compile_definitions _config _language _target _definitionsVar) + string (TOUPPER "${_config}" _upperConfig) + set (_configDefinitions "") + # CMAKE_INTDIR for multi-configuration build systems + if (NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") + list (APPEND _configDefinitions "CMAKE_INTDIR=\"${_config}\"") + endif() + # target export define symbol + cotire_get_target_export_symbol("${_target}" _defineSymbol) + if (_defineSymbol) + list (APPEND _configDefinitions "${_defineSymbol}") + endif() + # directory compile definitions + get_directory_property(_definitions DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMPILE_DEFINITIONS) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() + get_directory_property(_definitions DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMPILE_DEFINITIONS_${_upperConfig}) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() + # target compile definitions + get_target_property(_definitions ${_target} COMPILE_DEFINITIONS) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() + get_target_property(_definitions ${_target} COMPILE_DEFINITIONS_${_upperConfig}) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() + # interface compile definitions from linked library targets + set (_linkedTargets "") + cotire_get_target_usage_requirements(${_target} ${_config} _linkedTargets) + foreach (_linkedTarget ${_linkedTargets}) + get_target_property(_definitions ${_linkedTarget} INTERFACE_COMPILE_DEFINITIONS) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() + endforeach() + # parse additional compile definitions from target compile flags + # and don't look at directory compile definitions, which we already handled + set (_targetFlags "") + cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags) + cotire_filter_compile_flags("${_language}" "D" _definitions _ignore ${_targetFlags}) + if (_definitions) + list (APPEND _configDefinitions ${_definitions}) + endif() + list (REMOVE_DUPLICATES _configDefinitions) + if (COTIRE_DEBUG AND _configDefinitions) + message (STATUS "Target ${_target} compile definitions: ${_configDefinitions}") + endif() + set (${_definitionsVar} ${_configDefinitions} PARENT_SCOPE) +endfunction() + +function (cotire_get_target_compiler_flags _config _language _target _compilerFlagsVar) + # parse target compile flags omitting compile definitions and include directives + set (_targetFlags "") + cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags) + set (_flagFilter "D") + if (CMAKE_INCLUDE_FLAG_${_language}) + string (STRIP "${CMAKE_INCLUDE_FLAG_${_language}}" _includeFlag) + string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}") + if (_includeFlag) + set (_flagFilter "${_flagFilter}|${_includeFlag}") + endif() + endif() + if (CMAKE_INCLUDE_SYSTEM_FLAG_${_language}) + string (STRIP "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" _includeFlag) + string (REGEX REPLACE "^[-/]+" "" _includeFlag "${_includeFlag}") + if (_includeFlag) + set (_flagFilter "${_flagFilter}|${_includeFlag}") + endif() + endif() + set (_compilerFlags "") + cotire_filter_compile_flags("${_language}" "${_flagFilter}" _ignore _compilerFlags ${_targetFlags}) + if (COTIRE_DEBUG AND _compilerFlags) + message (STATUS "Target ${_target} compiler flags: ${_compilerFlags}") + endif() + set (${_compilerFlagsVar} ${_compilerFlags} PARENT_SCOPE) +endfunction() + +function (cotire_add_sys_root_paths _pathsVar) + if (APPLE) + if (CMAKE_OSX_SYSROOT AND CMAKE_${_language}_HAS_ISYSROOT) + foreach (_path IN LISTS ${_pathsVar}) + if (IS_ABSOLUTE "${_path}") + get_filename_component(_path "${CMAKE_OSX_SYSROOT}/${_path}" ABSOLUTE) + if (EXISTS "${_path}") + list (APPEND ${_pathsVar} "${_path}") + endif() + endif() + endforeach() + endif() + endif() + set (${_pathsVar} ${${_pathsVar}} PARENT_SCOPE) +endfunction() + +function (cotire_get_source_extra_properties _sourceFile _pattern _resultVar) + set (_extraProperties ${ARGN}) + set (_result "") + if (_extraProperties) + list (FIND _extraProperties "${_sourceFile}" _index) + if (_index GREATER -1) + math (EXPR _index "${_index} + 1") + list (LENGTH _extraProperties _len) + math (EXPR _len "${_len} - 1") + foreach (_index RANGE ${_index} ${_len}) + list (GET _extraProperties ${_index} _value) + if (_value MATCHES "${_pattern}") + list (APPEND _result "${_value}") + else() + break() + endif() + endforeach() + endif() + endif() + set (${_resultVar} ${_result} PARENT_SCOPE) +endfunction() + +function (cotire_get_source_compile_definitions _config _language _sourceFile _definitionsVar) + set (_compileDefinitions "") + if (NOT CMAKE_SCRIPT_MODE_FILE) + string (TOUPPER "${_config}" _upperConfig) + get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS) + if (_definitions) + list (APPEND _compileDefinitions ${_definitions}) + endif() + get_source_file_property(_definitions "${_sourceFile}" COMPILE_DEFINITIONS_${_upperConfig}) + if (_definitions) + list (APPEND _compileDefinitions ${_definitions}) + endif() + endif() + cotire_get_source_extra_properties("${_sourceFile}" "^[a-zA-Z0-9_]+(=.*)?$" _definitions ${ARGN}) + if (_definitions) + list (APPEND _compileDefinitions ${_definitions}) + endif() + if (COTIRE_DEBUG AND _compileDefinitions) + message (STATUS "Source ${_sourceFile} compile definitions: ${_compileDefinitions}") + endif() + set (${_definitionsVar} ${_compileDefinitions} PARENT_SCOPE) +endfunction() + +function (cotire_get_source_files_compile_definitions _config _language _definitionsVar) + set (_configDefinitions "") + foreach (_sourceFile ${ARGN}) + cotire_get_source_compile_definitions("${_config}" "${_language}" "${_sourceFile}" _sourceDefinitions) + if (_sourceDefinitions) + list (APPEND _configDefinitions "${_sourceFile}" ${_sourceDefinitions} "-") + endif() + endforeach() + set (${_definitionsVar} ${_configDefinitions} PARENT_SCOPE) +endfunction() + +function (cotire_get_source_undefs _sourceFile _property _sourceUndefsVar) + set (_sourceUndefs "") + if (NOT CMAKE_SCRIPT_MODE_FILE) + get_source_file_property(_undefs "${_sourceFile}" ${_property}) + if (_undefs) + list (APPEND _sourceUndefs ${_undefs}) + endif() + endif() + cotire_get_source_extra_properties("${_sourceFile}" "^[a-zA-Z0-9_]+$" _undefs ${ARGN}) + if (_undefs) + list (APPEND _sourceUndefs ${_undefs}) + endif() + if (COTIRE_DEBUG AND _sourceUndefs) + message (STATUS "Source ${_sourceFile} ${_property} undefs: ${_sourceUndefs}") + endif() + set (${_sourceUndefsVar} ${_sourceUndefs} PARENT_SCOPE) +endfunction() + +function (cotire_get_source_files_undefs _property _sourceUndefsVar) + set (_sourceUndefs "") + foreach (_sourceFile ${ARGN}) + cotire_get_source_undefs("${_sourceFile}" ${_property} _undefs) + if (_undefs) + list (APPEND _sourceUndefs "${_sourceFile}" ${_undefs} "-") + endif() + endforeach() + set (${_sourceUndefsVar} ${_sourceUndefs} PARENT_SCOPE) +endfunction() + +macro (cotire_set_cmd_to_prologue _cmdVar) + set (${_cmdVar} "${CMAKE_COMMAND}") + if (COTIRE_DEBUG) + list (APPEND ${_cmdVar} "--warn-uninitialized") + endif() + list (APPEND ${_cmdVar} "-DCOTIRE_BUILD_TYPE:STRING=$") + if (XCODE) + list (APPEND ${_cmdVar} "-DXCODE:BOOL=TRUE") + endif() + if (COTIRE_VERBOSE) + list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=ON") + elseif("${CMAKE_GENERATOR}" MATCHES "Makefiles") + list (APPEND ${_cmdVar} "-DCOTIRE_VERBOSE:BOOL=$(VERBOSE)") + endif() +endmacro() + +function (cotire_init_compile_cmd _cmdVar _language _compilerLauncher _compilerExe _compilerArg1) + if (NOT _compilerLauncher) + set (_compilerLauncher ${CMAKE_${_language}_COMPILER_LAUNCHER}) + endif() + if (NOT _compilerExe) + set (_compilerExe "${CMAKE_${_language}_COMPILER}") + endif() + if (NOT _compilerArg1) + set (_compilerArg1 ${CMAKE_${_language}_COMPILER_ARG1}) + endif() + string (STRIP "${_compilerArg1}" _compilerArg1) + if ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") + # compiler launcher is only supported for Makefile and Ninja + set (${_cmdVar} ${_compilerLauncher} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE) + else() + set (${_cmdVar} "${_compilerExe}" ${_compilerArg1} PARENT_SCOPE) + endif() +endfunction() + +macro (cotire_add_definitions_to_cmd _cmdVar _language) + foreach (_definition ${ARGN}) + if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + list (APPEND ${_cmdVar} "/D${_definition}") + else() + list (APPEND ${_cmdVar} "-D${_definition}") + endif() + endforeach() +endmacro() + +function (cotire_add_includes_to_cmd _cmdVar _language _includesVar _systemIncludesVar) + set (_includeDirs ${${_includesVar}} ${${_systemIncludesVar}}) + if (_includeDirs) + list (REMOVE_DUPLICATES _includeDirs) + foreach (_include ${_includeDirs}) + if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + file (TO_NATIVE_PATH "${_include}" _include) + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}") + else() + set (_index -1) + if ("${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}" MATCHES ".+") + list (FIND ${_systemIncludesVar} "${_include}" _index) + endif() + if (_index GREATER -1) + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_SYSTEM_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}") + else() + list (APPEND ${_cmdVar} "${CMAKE_INCLUDE_FLAG_${_language}}${CMAKE_INCLUDE_FLAG_SEP_${_language}}${_include}") + endif() + endif() + endforeach() + endif() + set (${_cmdVar} ${${_cmdVar}} PARENT_SCOPE) +endfunction() + +function (cotire_add_frameworks_to_cmd _cmdVar _language _includesVar _systemIncludesVar) + if (APPLE) + set (_frameworkDirs "") + foreach (_include ${${_includesVar}}) + if (IS_ABSOLUTE "${_include}" AND _include MATCHES "\\.framework$") + get_filename_component(_frameworkDir "${_include}" DIRECTORY) + list (APPEND _frameworkDirs "${_frameworkDir}") + endif() + endforeach() + set (_systemFrameworkDirs "") + foreach (_include ${${_systemIncludesVar}}) + if (IS_ABSOLUTE "${_include}" AND _include MATCHES "\\.framework$") + get_filename_component(_frameworkDir "${_include}" DIRECTORY) + list (APPEND _systemFrameworkDirs "${_frameworkDir}") + endif() + endforeach() + if (_systemFrameworkDirs) + list (APPEND _frameworkDirs ${_systemFrameworkDirs}) + endif() + if (_frameworkDirs) + list (REMOVE_DUPLICATES _frameworkDirs) + foreach (_frameworkDir ${_frameworkDirs}) + set (_index -1) + if ("${CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG}" MATCHES ".+") + list (FIND _systemFrameworkDirs "${_frameworkDir}" _index) + endif() + if (_index GREATER -1) + list (APPEND ${_cmdVar} "${CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG}${_frameworkDir}") + else() + list (APPEND ${_cmdVar} "${CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG}${_frameworkDir}") + endif() + endforeach() + endif() + endif() + set (${_cmdVar} ${${_cmdVar}} PARENT_SCOPE) +endfunction() + +macro (cotire_add_compile_flags_to_cmd _cmdVar) + foreach (_flag ${ARGN}) + list (APPEND ${_cmdVar} "${_flag}") + endforeach() +endmacro() + +function (cotire_check_file_up_to_date _fileIsUpToDateVar _file) + if (EXISTS "${_file}") + set (_triggerFile "") + foreach (_dependencyFile ${ARGN}) + if (EXISTS "${_dependencyFile}") + # IS_NEWER_THAN returns TRUE if both files have the same timestamp + # thus we do the comparison in both directions to exclude ties + if ("${_dependencyFile}" IS_NEWER_THAN "${_file}" AND + NOT "${_file}" IS_NEWER_THAN "${_dependencyFile}") + set (_triggerFile "${_dependencyFile}") + break() + endif() + endif() + endforeach() + if (_triggerFile) + if (COTIRE_VERBOSE) + get_filename_component(_fileName "${_file}" NAME) + message (STATUS "${_fileName} update triggered by ${_triggerFile} change.") + endif() + set (${_fileIsUpToDateVar} FALSE PARENT_SCOPE) + else() + if (COTIRE_VERBOSE) + get_filename_component(_fileName "${_file}" NAME) + message (STATUS "${_fileName} is up-to-date.") + endif() + set (${_fileIsUpToDateVar} TRUE PARENT_SCOPE) + endif() + else() + if (COTIRE_VERBOSE) + get_filename_component(_fileName "${_file}" NAME) + message (STATUS "${_fileName} does not exist yet.") + endif() + set (${_fileIsUpToDateVar} FALSE PARENT_SCOPE) + endif() +endfunction() + +macro (cotire_find_closest_relative_path _headerFile _includeDirs _relPathVar) + set (${_relPathVar} "") + foreach (_includeDir ${_includeDirs}) + if (IS_DIRECTORY "${_includeDir}") + file (RELATIVE_PATH _relPath "${_includeDir}" "${_headerFile}") + if (NOT IS_ABSOLUTE "${_relPath}" AND NOT "${_relPath}" MATCHES "^\\.\\.") + string (LENGTH "${${_relPathVar}}" _closestLen) + string (LENGTH "${_relPath}" _relLen) + if (_closestLen EQUAL 0 OR _relLen LESS _closestLen) + set (${_relPathVar} "${_relPath}") + endif() + endif() + elseif ("${_includeDir}" STREQUAL "${_headerFile}") + # if path matches exactly, return short non-empty string + set (${_relPathVar} "1") + break() + endif() + endforeach() +endmacro() + +macro (cotire_check_header_file_location _headerFile _insideIncludeDirs _outsideIncludeDirs _headerIsInside) + # check header path against ignored and honored include directories + cotire_find_closest_relative_path("${_headerFile}" "${_insideIncludeDirs}" _insideRelPath) + if (_insideRelPath) + # header is inside, but could be become outside if there is a shorter outside match + cotire_find_closest_relative_path("${_headerFile}" "${_outsideIncludeDirs}" _outsideRelPath) + if (_outsideRelPath) + string (LENGTH "${_insideRelPath}" _insideRelPathLen) + string (LENGTH "${_outsideRelPath}" _outsideRelPathLen) + if (_outsideRelPathLen LESS _insideRelPathLen) + set (${_headerIsInside} FALSE) + else() + set (${_headerIsInside} TRUE) + endif() + else() + set (${_headerIsInside} TRUE) + endif() + else() + # header is outside + set (${_headerIsInside} FALSE) + endif() +endmacro() + +macro (cotire_check_ignore_header_file_path _headerFile _headerIsIgnoredVar) + if (NOT EXISTS "${_headerFile}") + set (${_headerIsIgnoredVar} TRUE) + elseif (IS_DIRECTORY "${_headerFile}") + set (${_headerIsIgnoredVar} TRUE) + elseif ("${_headerFile}" MATCHES "\\.\\.|[_-]fixed" AND "${_headerFile}" MATCHES "\\.h$") + # heuristic: ignore C headers with embedded parent directory references or "-fixed" or "_fixed" in path + # these often stem from using GCC #include_next tricks, which may break the precompiled header compilation + # with the error message "error: no include path in which to search for header.h" + set (${_headerIsIgnoredVar} TRUE) + else() + set (${_headerIsIgnoredVar} FALSE) + endif() +endmacro() + +macro (cotire_check_ignore_header_file_ext _headerFile _ignoreExtensionsVar _headerIsIgnoredVar) + # check header file extension + cotire_get_source_file_extension("${_headerFile}" _headerFileExt) + set (${_headerIsIgnoredVar} FALSE) + if (_headerFileExt) + list (FIND ${_ignoreExtensionsVar} "${_headerFileExt}" _index) + if (_index GREATER -1) + set (${_headerIsIgnoredVar} TRUE) + endif() + endif() +endmacro() + +macro (cotire_parse_line _line _headerFileVar _headerDepthVar) + if (MSVC) + # cl.exe /showIncludes output looks different depending on the language pack used, e.g.: + # English: "Note: including file: C:\directory\file" + # German: "Hinweis: Einlesen der Datei: C:\directory\file" + # We use a very general regular expression, relying on the presence of the : characters + if (_line MATCHES "( +)([a-zA-Z]:[^:]+)$") + # Visual Studio compiler output + string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) + get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" ABSOLUTE) + else() + set (${_headerFileVar} "") + set (${_headerDepthVar} 0) + endif() + else() + if (_line MATCHES "^(\\.+) (.*)$") + # GCC like output + string (LENGTH "${CMAKE_MATCH_1}" ${_headerDepthVar}) + if (IS_ABSOLUTE "${CMAKE_MATCH_2}") + set (${_headerFileVar} "${CMAKE_MATCH_2}") + else() + get_filename_component(${_headerFileVar} "${CMAKE_MATCH_2}" REALPATH) + endif() + else() + set (${_headerFileVar} "") + set (${_headerDepthVar} 0) + endif() + endif() +endmacro() + +function (cotire_parse_includes _language _scanOutput _ignoredIncludeDirs _honoredIncludeDirs _ignoredExtensions _selectedIncludesVar _unparsedLinesVar) + if (WIN32) + # prevent CMake macro invocation errors due to backslash characters in Windows paths + string (REPLACE "\\" "/" _scanOutput "${_scanOutput}") + endif() + # canonize slashes + string (REPLACE "//" "/" _scanOutput "${_scanOutput}") + # prevent semicolon from being interpreted as a line separator + string (REPLACE ";" "\\;" _scanOutput "${_scanOutput}") + # then separate lines + string (REGEX REPLACE "\n" ";" _scanOutput "${_scanOutput}") + list (LENGTH _scanOutput _len) + # remove duplicate lines to speed up parsing + list (REMOVE_DUPLICATES _scanOutput) + list (LENGTH _scanOutput _uniqueLen) + if (COTIRE_VERBOSE OR COTIRE_DEBUG) + message (STATUS "Scanning ${_uniqueLen} unique lines of ${_len} for includes") + if (_ignoredExtensions) + message (STATUS "Ignored extensions: ${_ignoredExtensions}") + endif() + if (_ignoredIncludeDirs) + message (STATUS "Ignored paths: ${_ignoredIncludeDirs}") + endif() + if (_honoredIncludeDirs) + message (STATUS "Included paths: ${_honoredIncludeDirs}") + endif() + endif() + set (_sourceFiles ${ARGN}) + set (_selectedIncludes "") + set (_unparsedLines "") + # stack keeps track of inside/outside project status of processed header files + set (_headerIsInsideStack "") + foreach (_line IN LISTS _scanOutput) + if (_line) + cotire_parse_line("${_line}" _headerFile _headerDepth) + if (_headerFile) + cotire_check_header_file_location("${_headerFile}" "${_ignoredIncludeDirs}" "${_honoredIncludeDirs}" _headerIsInside) + if (COTIRE_DEBUG) + message (STATUS "${_headerDepth}: ${_headerFile} ${_headerIsInside}") + endif() + # update stack + list (LENGTH _headerIsInsideStack _stackLen) + if (_headerDepth GREATER _stackLen) + math (EXPR _stackLen "${_stackLen} + 1") + foreach (_index RANGE ${_stackLen} ${_headerDepth}) + list (APPEND _headerIsInsideStack ${_headerIsInside}) + endforeach() + else() + foreach (_index RANGE ${_headerDepth} ${_stackLen}) + list (REMOVE_AT _headerIsInsideStack -1) + endforeach() + list (APPEND _headerIsInsideStack ${_headerIsInside}) + endif() + if (COTIRE_DEBUG) + message (STATUS "${_headerIsInsideStack}") + endif() + # header is a candidate if it is outside project + if (NOT _headerIsInside) + # get parent header file's inside/outside status + if (_headerDepth GREATER 1) + math (EXPR _index "${_headerDepth} - 2") + list (GET _headerIsInsideStack ${_index} _parentHeaderIsInside) + else() + set (_parentHeaderIsInside TRUE) + endif() + # select header file if parent header file is inside project + # (e.g., a project header file that includes a standard header file) + if (_parentHeaderIsInside) + cotire_check_ignore_header_file_path("${_headerFile}" _headerIsIgnored) + if (NOT _headerIsIgnored) + cotire_check_ignore_header_file_ext("${_headerFile}" _ignoredExtensions _headerIsIgnored) + if (NOT _headerIsIgnored) + list (APPEND _selectedIncludes "${_headerFile}") + else() + # fix header's inside status on stack, it is ignored by extension now + list (REMOVE_AT _headerIsInsideStack -1) + list (APPEND _headerIsInsideStack TRUE) + endif() + endif() + if (COTIRE_DEBUG) + message (STATUS "${_headerFile} ${_ignoredExtensions} ${_headerIsIgnored}") + endif() + endif() + endif() + else() + if (MSVC) + # for cl.exe do not keep unparsed lines which solely consist of a source file name + string (FIND "${_sourceFiles}" "${_line}" _index) + if (_index LESS 0) + list (APPEND _unparsedLines "${_line}") + endif() + else() + list (APPEND _unparsedLines "${_line}") + endif() + endif() + endif() + endforeach() + list (REMOVE_DUPLICATES _selectedIncludes) + set (${_selectedIncludesVar} ${_selectedIncludes} PARENT_SCOPE) + set (${_unparsedLinesVar} ${_unparsedLines} PARENT_SCOPE) +endfunction() + +function (cotire_scan_includes _includesVar) + set(_options "") + set(_oneValueArgs COMPILER_ID COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_VERSION LANGUAGE UNPARSED_LINES SCAN_RESULT) + set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES + IGNORE_PATH INCLUDE_PATH IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH COMPILER_LAUNCHER) + cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) + if (NOT _option_LANGUAGE) + set (_option_LANGUAGE "CXX") + endif() + if (NOT _option_COMPILER_ID) + set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") + endif() + if (NOT _option_COMPILER_VERSION) + set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}") + endif() + cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_LAUNCHER}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") + cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) + cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) + cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) + cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) + cotire_add_makedep_flags("${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" _cmd) + # only consider existing source files for scanning + set (_existingSourceFiles "") + foreach (_sourceFile ${_sourceFiles}) + if (EXISTS "${_sourceFile}") + list (APPEND _existingSourceFiles "${_sourceFile}") + endif() + endforeach() + if (NOT _existingSourceFiles) + set (${_includesVar} "" PARENT_SCOPE) + return() + endif() + list (APPEND _cmd ${_existingSourceFiles}) + if (COTIRE_VERBOSE) + message (STATUS "execute_process: ${_cmd}") + endif() + if (_option_COMPILER_ID MATCHES "MSVC") + # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared + unset (ENV{VS_UNICODE_OUTPUT}) + endif() + execute_process( + COMMAND ${_cmd} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE _result + OUTPUT_QUIET + ERROR_VARIABLE _output) + if (_result) + message (STATUS "Result ${_result} scanning includes of ${_existingSourceFiles}.") + endif() + cotire_parse_includes( + "${_option_LANGUAGE}" "${_output}" + "${_option_IGNORE_PATH}" "${_option_INCLUDE_PATH}" + "${_option_IGNORE_EXTENSIONS}" + _includes _unparsedLines + ${_sourceFiles}) + if (_option_INCLUDE_PRIORITY_PATH) + set (_sortedIncludes "") + foreach (_priorityPath ${_option_INCLUDE_PRIORITY_PATH}) + foreach (_include ${_includes}) + string (FIND ${_include} ${_priorityPath} _position) + if (_position GREATER -1) + list (APPEND _sortedIncludes ${_include}) + endif() + endforeach() + endforeach() + if (_sortedIncludes) + list (INSERT _includes 0 ${_sortedIncludes}) + list (REMOVE_DUPLICATES _includes) + endif() + endif() + set (${_includesVar} ${_includes} PARENT_SCOPE) + if (_option_UNPARSED_LINES) + set (${_option_UNPARSED_LINES} ${_unparsedLines} PARENT_SCOPE) + endif() + if (_option_SCAN_RESULT) + set (${_option_SCAN_RESULT} ${_result} PARENT_SCOPE) + endif() +endfunction() + +macro (cotire_append_undefs _contentsVar) + set (_undefs ${ARGN}) + if (_undefs) + list (REMOVE_DUPLICATES _undefs) + foreach (_definition ${_undefs}) + list (APPEND ${_contentsVar} "#undef ${_definition}") + endforeach() + endif() +endmacro() + +macro (cotire_comment_str _language _commentText _commentVar) + if ("${_language}" STREQUAL "CMAKE") + set (${_commentVar} "# ${_commentText}") + else() + set (${_commentVar} "/* ${_commentText} */") + endif() +endmacro() + +function (cotire_write_file _language _file _contents _force) + get_filename_component(_moduleName "${COTIRE_CMAKE_MODULE_FILE}" NAME) + cotire_comment_str("${_language}" "${_moduleName} ${COTIRE_CMAKE_MODULE_VERSION} generated file" _header1) + cotire_comment_str("${_language}" "${_file}" _header2) + set (_contents "${_header1}\n${_header2}\n${_contents}") + if (COTIRE_DEBUG) + message (STATUS "${_contents}") + endif() + if (_force OR NOT EXISTS "${_file}") + file (WRITE "${_file}" "${_contents}") + else() + file (READ "${_file}" _oldContents) + if (NOT "${_oldContents}" STREQUAL "${_contents}") + file (WRITE "${_file}" "${_contents}") + else() + if (COTIRE_DEBUG) + message (STATUS "${_file} unchanged") + endif() + endif() + endif() +endfunction() + +function (cotire_generate_unity_source _unityFile) + set(_options "") + set(_oneValueArgs LANGUAGE) + set(_multiValueArgs + DEPENDS SOURCES_COMPILE_DEFINITIONS + PRE_UNDEFS SOURCES_PRE_UNDEFS POST_UNDEFS SOURCES_POST_UNDEFS PROLOGUE EPILOGUE) + cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + if (_option_DEPENDS) + cotire_check_file_up_to_date(_unityFileIsUpToDate "${_unityFile}" ${_option_DEPENDS}) + if (_unityFileIsUpToDate) + return() + endif() + endif() + set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) + if (NOT _option_PRE_UNDEFS) + set (_option_PRE_UNDEFS "") + endif() + if (NOT _option_SOURCES_PRE_UNDEFS) + set (_option_SOURCES_PRE_UNDEFS "") + endif() + if (NOT _option_POST_UNDEFS) + set (_option_POST_UNDEFS "") + endif() + if (NOT _option_SOURCES_POST_UNDEFS) + set (_option_SOURCES_POST_UNDEFS "") + endif() + set (_contents "") + if (_option_PROLOGUE) + list (APPEND _contents ${_option_PROLOGUE}) + endif() + if (_option_LANGUAGE AND _sourceFiles) + if ("${_option_LANGUAGE}" STREQUAL "CXX") + list (APPEND _contents "#ifdef __cplusplus") + elseif ("${_option_LANGUAGE}" STREQUAL "C") + list (APPEND _contents "#ifndef __cplusplus") + endif() + endif() + set (_compileUndefinitions "") + foreach (_sourceFile ${_sourceFiles}) + cotire_get_source_compile_definitions( + "${_option_CONFIGURATION}" "${_option_LANGUAGE}" "${_sourceFile}" _compileDefinitions + ${_option_SOURCES_COMPILE_DEFINITIONS}) + cotire_get_source_undefs("${_sourceFile}" COTIRE_UNITY_SOURCE_PRE_UNDEFS _sourcePreUndefs ${_option_SOURCES_PRE_UNDEFS}) + cotire_get_source_undefs("${_sourceFile}" COTIRE_UNITY_SOURCE_POST_UNDEFS _sourcePostUndefs ${_option_SOURCES_POST_UNDEFS}) + if (_option_PRE_UNDEFS) + list (APPEND _compileUndefinitions ${_option_PRE_UNDEFS}) + endif() + if (_sourcePreUndefs) + list (APPEND _compileUndefinitions ${_sourcePreUndefs}) + endif() + if (_compileUndefinitions) + cotire_append_undefs(_contents ${_compileUndefinitions}) + set (_compileUndefinitions "") + endif() + if (_sourcePostUndefs) + list (APPEND _compileUndefinitions ${_sourcePostUndefs}) + endif() + if (_option_POST_UNDEFS) + list (APPEND _compileUndefinitions ${_option_POST_UNDEFS}) + endif() + foreach (_definition ${_compileDefinitions}) + if (_definition MATCHES "^([a-zA-Z0-9_]+)=(.+)$") + list (APPEND _contents "#define ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}") + list (INSERT _compileUndefinitions 0 "${CMAKE_MATCH_1}") + else() + list (APPEND _contents "#define ${_definition}") + list (INSERT _compileUndefinitions 0 "${_definition}") + endif() + endforeach() + # use absolute path as source file location + get_filename_component(_sourceFileLocation "${_sourceFile}" ABSOLUTE) + if (WIN32) + file (TO_NATIVE_PATH "${_sourceFileLocation}" _sourceFileLocation) + endif() + list (APPEND _contents "#include \"${_sourceFileLocation}\"") + endforeach() + if (_compileUndefinitions) + cotire_append_undefs(_contents ${_compileUndefinitions}) + set (_compileUndefinitions "") + endif() + if (_option_LANGUAGE AND _sourceFiles) + list (APPEND _contents "#endif") + endif() + if (_option_EPILOGUE) + list (APPEND _contents ${_option_EPILOGUE}) + endif() + list (APPEND _contents "") + string (REPLACE ";" "\n" _contents "${_contents}") + if (COTIRE_VERBOSE) + message ("${_contents}") + endif() + cotire_write_file("${_option_LANGUAGE}" "${_unityFile}" "${_contents}" TRUE) +endfunction() + +function (cotire_generate_prefix_header _prefixFile) + set(_options "") + set(_oneValueArgs LANGUAGE COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_ID COMPILER_VERSION) + set(_multiValueArgs DEPENDS COMPILE_DEFINITIONS COMPILE_FLAGS + INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES IGNORE_PATH INCLUDE_PATH + IGNORE_EXTENSIONS INCLUDE_PRIORITY_PATH COMPILER_LAUNCHER) + cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + if (NOT _option_COMPILER_ID) + set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") + endif() + if (NOT _option_COMPILER_VERSION) + set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}") + endif() + if (_option_DEPENDS) + cotire_check_file_up_to_date(_prefixFileIsUpToDate "${_prefixFile}" ${_option_DEPENDS}) + if (_prefixFileIsUpToDate) + # create empty log file + set (_unparsedLinesFile "${_prefixFile}.log") + file (WRITE "${_unparsedLinesFile}" "") + return() + endif() + endif() + set (_prologue "") + set (_epilogue "") + if (_option_COMPILER_ID MATCHES "Clang") + set (_prologue "#pragma clang system_header") + elseif (_option_COMPILER_ID MATCHES "GNU") + set (_prologue "#pragma GCC system_header") + elseif (_option_COMPILER_ID MATCHES "MSVC") + set (_prologue "#pragma warning(push, 0)") + set (_epilogue "#pragma warning(pop)") + elseif (_option_COMPILER_ID MATCHES "Intel") + # Intel compiler requires hdrstop pragma to stop generating PCH file + set (_epilogue "#pragma hdrstop") + endif() + set (_sourceFiles ${_option_UNPARSED_ARGUMENTS}) + cotire_scan_includes(_selectedHeaders ${_sourceFiles} + LANGUAGE "${_option_LANGUAGE}" + COMPILER_LAUNCHER "${_option_COMPILER_LAUNCHER}" + COMPILER_EXECUTABLE "${_option_COMPILER_EXECUTABLE}" + COMPILER_ARG1 "${_option_COMPILER_ARG1}" + COMPILER_ID "${_option_COMPILER_ID}" + COMPILER_VERSION "${_option_COMPILER_VERSION}" + COMPILE_DEFINITIONS ${_option_COMPILE_DEFINITIONS} + COMPILE_FLAGS ${_option_COMPILE_FLAGS} + INCLUDE_DIRECTORIES ${_option_INCLUDE_DIRECTORIES} + SYSTEM_INCLUDE_DIRECTORIES ${_option_SYSTEM_INCLUDE_DIRECTORIES} + IGNORE_PATH ${_option_IGNORE_PATH} + INCLUDE_PATH ${_option_INCLUDE_PATH} + IGNORE_EXTENSIONS ${_option_IGNORE_EXTENSIONS} + INCLUDE_PRIORITY_PATH ${_option_INCLUDE_PRIORITY_PATH} + UNPARSED_LINES _unparsedLines + SCAN_RESULT _scanResult) + cotire_generate_unity_source("${_prefixFile}" + PROLOGUE ${_prologue} EPILOGUE ${_epilogue} LANGUAGE "${_option_LANGUAGE}" ${_selectedHeaders}) + set (_unparsedLinesFile "${_prefixFile}.log") + if (_unparsedLines) + if (COTIRE_VERBOSE OR _scanResult OR NOT _selectedHeaders) + list (LENGTH _unparsedLines _skippedLineCount) + message (STATUS "${_skippedLineCount} line(s) skipped, see ${_unparsedLinesFile}") + endif() + string (REPLACE ";" "\n" _unparsedLines "${_unparsedLines}") + endif() + file (WRITE "${_unparsedLinesFile}" "${_unparsedLines}") +endfunction() + +function (cotire_add_makedep_flags _language _compilerID _compilerVersion _flagsVar) + set (_flags ${${_flagsVar}}) + if (_compilerID MATCHES "MSVC") + # cl.exe options used + # /nologo suppresses display of sign-on banner + # /TC treat all files named on the command line as C source files + # /TP treat all files named on the command line as C++ source files + # /EP preprocess to stdout without #line directives + # /showIncludes list include files + set (_sourceFileTypeC "/TC") + set (_sourceFileTypeCXX "/TP") + if (_flags) + # append to list + list (APPEND _flags /nologo "${_sourceFileType${_language}}" /EP /showIncludes) + else() + # return as a flag string + set (_flags "${_sourceFileType${_language}} /EP /showIncludes") + endif() + elseif (_compilerID MATCHES "GNU") + # GCC options used + # -H print the name of each header file used + # -E invoke preprocessor + # -fdirectives-only do not expand macros, requires GCC >= 4.3 + if (_flags) + # append to list + list (APPEND _flags -H -E) + if (NOT "${_compilerVersion}" VERSION_LESS "4.3.0") + list (APPEND _flags "-fdirectives-only") + endif() + else() + # return as a flag string + set (_flags "-H -E") + if (NOT "${_compilerVersion}" VERSION_LESS "4.3.0") + set (_flags "${_flags} -fdirectives-only") + endif() + endif() + elseif (_compilerID MATCHES "Clang") + # Clang options used + # -H print the name of each header file used + # -E invoke preprocessor + # -fno-color-diagnostics don't prints diagnostics in color + if (_flags) + # append to list + list (APPEND _flags -H -E -fno-color-diagnostics) + else() + # return as a flag string + set (_flags "-H -E -fno-color-diagnostics") + endif() + elseif (_compilerID MATCHES "Intel") + if (WIN32) + # Windows Intel options used + # /nologo do not display compiler version information + # /QH display the include file order + # /EP preprocess to stdout, omitting #line directives + # /TC process all source or unrecognized file types as C source files + # /TP process all source or unrecognized file types as C++ source files + set (_sourceFileTypeC "/TC") + set (_sourceFileTypeCXX "/TP") + if (_flags) + # append to list + list (APPEND _flags /nologo "${_sourceFileType${_language}}" /EP /QH) + else() + # return as a flag string + set (_flags "${_sourceFileType${_language}} /EP /QH") + endif() + else() + # Linux / Mac OS X Intel options used + # -H print the name of each header file used + # -EP preprocess to stdout, omitting #line directives + # -Kc++ process all source or unrecognized file types as C++ source files + if (_flags) + # append to list + if ("${_language}" STREQUAL "CXX") + list (APPEND _flags -Kc++) + endif() + list (APPEND _flags -H -EP) + else() + # return as a flag string + if ("${_language}" STREQUAL "CXX") + set (_flags "-Kc++ ") + endif() + set (_flags "${_flags}-H -EP") + endif() + endif() + else() + message (FATAL_ERROR "cotire: unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") + endif() + set (${_flagsVar} ${_flags} PARENT_SCOPE) +endfunction() + +function (cotire_add_pch_compilation_flags _language _compilerID _compilerVersion _prefixFile _pchFile _hostFile _flagsVar) + set (_flags ${${_flagsVar}}) + if (_compilerID MATCHES "MSVC") + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + file (TO_NATIVE_PATH "${_hostFile}" _hostFileNative) + # cl.exe options used + # /Yc creates a precompiled header file + # /Fp specifies precompiled header binary file name + # /FI forces inclusion of file + # /TC treat all files named on the command line as C source files + # /TP treat all files named on the command line as C++ source files + # /Zs syntax check only + # /Zm precompiled header memory allocation scaling factor + set (_sourceFileTypeC "/TC") + set (_sourceFileTypeCXX "/TP") + if (_flags) + # append to list + list (APPEND _flags /nologo "${_sourceFileType${_language}}" + "/Yc${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}") + if (COTIRE_PCH_MEMORY_SCALING_FACTOR) + list (APPEND _flags "/Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}") + endif() + else() + # return as a flag string + set (_flags "/Yc\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + if (COTIRE_PCH_MEMORY_SCALING_FACTOR) + set (_flags "${_flags} /Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}") + endif() + endif() + elseif (_compilerID MATCHES "GNU|Clang") + # GCC / Clang options used + # -x specify the source language + # -c compile but do not link + # -o place output in file + # note that we cannot use -w to suppress all warnings upon pre-compiling, because turning off a warning may + # alter compile flags as a side effect (e.g., -Wwrite-string implies -fconst-strings) + set (_xLanguage_C "c-header") + set (_xLanguage_CXX "c++-header") + if (_flags) + # append to list + list (APPEND _flags "-x" "${_xLanguage_${_language}}" "-c" "${_prefixFile}" -o "${_pchFile}") + else() + # return as a flag string + set (_flags "-x ${_xLanguage_${_language}} -c \"${_prefixFile}\" -o \"${_pchFile}\"") + endif() + elseif (_compilerID MATCHES "Intel") + if (WIN32) + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + file (TO_NATIVE_PATH "${_hostFile}" _hostFileNative) + # Windows Intel options used + # /nologo do not display compiler version information + # /Yc create a precompiled header (PCH) file + # /Fp specify a path or file name for precompiled header files + # /FI tells the preprocessor to include a specified file name as the header file + # /TC process all source or unrecognized file types as C source files + # /TP process all source or unrecognized file types as C++ source files + # /Zs syntax check only + # /Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) + set (_sourceFileTypeC "/TC") + set (_sourceFileTypeCXX "/TP") + if (_flags) + # append to list + list (APPEND _flags /nologo "${_sourceFileType${_language}}" + "/Yc" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}" /Zs "${_hostFileNative}") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + list (APPEND _flags "/Wpch-messages") + endif() + else() + # return as a flag string + set (_flags "/Yc /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + set (_flags "${_flags} /Wpch-messages") + endif() + endif() + else() + # Linux / Mac OS X Intel options used + # -pch-dir location for precompiled header files + # -pch-create name of the precompiled header (PCH) to create + # -Kc++ process all source or unrecognized file types as C++ source files + # -fsyntax-only check only for correct syntax + # -Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) + get_filename_component(_pchDir "${_pchFile}" DIRECTORY) + get_filename_component(_pchName "${_pchFile}" NAME) + set (_xLanguage_C "c-header") + set (_xLanguage_CXX "c++-header") + set (_pchSuppressMessages FALSE) + if ("${CMAKE_${_language}_FLAGS}" MATCHES ".*-Wno-pch-messages.*") + set(_pchSuppressMessages TRUE) + endif() + if (_flags) + # append to list + if ("${_language}" STREQUAL "CXX") + list (APPEND _flags -Kc++) + endif() + list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-create" "${_pchName}" "-fsyntax-only" "${_hostFile}") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + if (NOT _pchSuppressMessages) + list (APPEND _flags "-Wpch-messages") + endif() + endif() + else() + # return as a flag string + set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-create \"${_pchName}\"") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + if (NOT _pchSuppressMessages) + set (_flags "${_flags} -Wpch-messages") + endif() + endif() + endif() + endif() + else() + message (FATAL_ERROR "cotire: unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") + endif() + set (${_flagsVar} ${_flags} PARENT_SCOPE) +endfunction() + +function (cotire_add_prefix_pch_inclusion_flags _language _compilerID _compilerVersion _prefixFile _pchFile _flagsVar) + set (_flags ${${_flagsVar}}) + if (_compilerID MATCHES "MSVC") + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) + # cl.exe options used + # /Yu uses a precompiled header file during build + # /Fp specifies precompiled header binary file name + # /FI forces inclusion of file + # /Zm precompiled header memory allocation scaling factor + if (_pchFile) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + if (_flags) + # append to list + list (APPEND _flags "/Yu${_prefixFileNative}" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}") + if (COTIRE_PCH_MEMORY_SCALING_FACTOR) + list (APPEND _flags "/Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}") + endif() + else() + # return as a flag string + set (_flags "/Yu\"${_prefixFileNative}\" /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + if (COTIRE_PCH_MEMORY_SCALING_FACTOR) + set (_flags "${_flags} /Zm${COTIRE_PCH_MEMORY_SCALING_FACTOR}") + endif() + endif() + else() + # no precompiled header, force inclusion of prefix header + if (_flags) + # append to list + list (APPEND _flags "/FI${_prefixFileNative}") + else() + # return as a flag string + set (_flags "/FI\"${_prefixFileNative}\"") + endif() + endif() + elseif (_compilerID MATCHES "GNU") + # GCC options used + # -include process include file as the first line of the primary source file + # -Winvalid-pch warns if precompiled header is found but cannot be used + # note: ccache requires the -include flag to be used in order to process precompiled header correctly + if (_flags) + # append to list + list (APPEND _flags "-Winvalid-pch" "-include" "${_prefixFile}") + else() + # return as a flag string + set (_flags "-Winvalid-pch -include \"${_prefixFile}\"") + endif() + elseif (_compilerID MATCHES "Clang") + # Clang options used + # -include process include file as the first line of the primary source file + # -include-pch include precompiled header file + # -Qunused-arguments don't emit warning for unused driver arguments + # note: ccache requires the -include flag to be used in order to process precompiled header correctly + if (_flags) + # append to list + list (APPEND _flags "-Qunused-arguments" "-include" "${_prefixFile}") + else() + # return as a flag string + set (_flags "-Qunused-arguments -include \"${_prefixFile}\"") + endif() + elseif (_compilerID MATCHES "Intel") + if (WIN32) + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileNative) + # Windows Intel options used + # /Yu use a precompiled header (PCH) file + # /Fp specify a path or file name for precompiled header files + # /FI tells the preprocessor to include a specified file name as the header file + # /Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) + if (_pchFile) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileNative) + if (_flags) + # append to list + list (APPEND _flags "/Yu" "/Fp${_pchFileNative}" "/FI${_prefixFileNative}") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + list (APPEND _flags "/Wpch-messages") + endif() + else() + # return as a flag string + set (_flags "/Yu /Fp\"${_pchFileNative}\" /FI\"${_prefixFileNative}\"") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + set (_flags "${_flags} /Wpch-messages") + endif() + endif() + else() + # no precompiled header, force inclusion of prefix header + if (_flags) + # append to list + list (APPEND _flags "/FI${_prefixFileNative}") + else() + # return as a flag string + set (_flags "/FI\"${_prefixFileNative}\"") + endif() + endif() + else() + # Linux / Mac OS X Intel options used + # -pch-dir location for precompiled header files + # -pch-use name of the precompiled header (PCH) to use + # -include process include file as the first line of the primary source file + # -Wpch-messages enable diagnostics related to pre-compiled headers (requires Intel XE 2013 Update 2) + if (_pchFile) + get_filename_component(_pchDir "${_pchFile}" DIRECTORY) + get_filename_component(_pchName "${_pchFile}" NAME) + set (_pchSuppressMessages FALSE) + if ("${CMAKE_${_language}_FLAGS}" MATCHES ".*-Wno-pch-messages.*") + set(_pchSuppressMessages TRUE) + endif() + if (_flags) + # append to list + list (APPEND _flags "-include" "${_prefixFile}" "-pch-dir" "${_pchDir}" "-pch-use" "${_pchName}") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + if (NOT _pchSuppressMessages) + list (APPEND _flags "-Wpch-messages") + endif() + endif() + else() + # return as a flag string + set (_flags "-include \"${_prefixFile}\" -pch-dir \"${_pchDir}\" -pch-use \"${_pchName}\"") + if (NOT "${_compilerVersion}" VERSION_LESS "13.1.0") + if (NOT _pchSuppressMessages) + set (_flags "${_flags} -Wpch-messages") + endif() + endif() + endif() + else() + # no precompiled header, force inclusion of prefix header + if (_flags) + # append to list + list (APPEND _flags "-include" "${_prefixFile}") + else() + # return as a flag string + set (_flags "-include \"${_prefixFile}\"") + endif() + endif() + endif() + else() + message (FATAL_ERROR "cotire: unsupported ${_language} compiler ${_compilerID} version ${_compilerVersion}.") + endif() + set (${_flagsVar} ${_flags} PARENT_SCOPE) +endfunction() + +function (cotire_precompile_prefix_header _prefixFile _pchFile _hostFile) + set(_options "") + set(_oneValueArgs COMPILER_EXECUTABLE COMPILER_ARG1 COMPILER_ID COMPILER_VERSION LANGUAGE) + set(_multiValueArgs COMPILE_DEFINITIONS COMPILE_FLAGS INCLUDE_DIRECTORIES SYSTEM_INCLUDE_DIRECTORIES SYS COMPILER_LAUNCHER) + cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + if (NOT _option_LANGUAGE) + set (_option_LANGUAGE "CXX") + endif() + if (NOT _option_COMPILER_ID) + set (_option_COMPILER_ID "${CMAKE_${_option_LANGUAGE}_ID}") + endif() + if (NOT _option_COMPILER_VERSION) + set (_option_COMPILER_VERSION "${CMAKE_${_option_LANGUAGE}_COMPILER_VERSION}") + endif() + cotire_init_compile_cmd(_cmd "${_option_LANGUAGE}" "${_option_COMPILER_LAUNCHER}" "${_option_COMPILER_EXECUTABLE}" "${_option_COMPILER_ARG1}") + cotire_add_definitions_to_cmd(_cmd "${_option_LANGUAGE}" ${_option_COMPILE_DEFINITIONS}) + cotire_add_compile_flags_to_cmd(_cmd ${_option_COMPILE_FLAGS}) + cotire_add_includes_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) + cotire_add_frameworks_to_cmd(_cmd "${_option_LANGUAGE}" _option_INCLUDE_DIRECTORIES _option_SYSTEM_INCLUDE_DIRECTORIES) + cotire_add_pch_compilation_flags( + "${_option_LANGUAGE}" "${_option_COMPILER_ID}" "${_option_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" "${_hostFile}" _cmd) + if (COTIRE_VERBOSE) + message (STATUS "execute_process: ${_cmd}") + endif() + if (_option_COMPILER_ID MATCHES "MSVC") + # cl.exe messes with the output streams unless the environment variable VS_UNICODE_OUTPUT is cleared + unset (ENV{VS_UNICODE_OUTPUT}) + elseif (_option_COMPILER_ID MATCHES "GNU|Clang") + if (_option_COMPILER_LAUNCHER MATCHES "ccache" OR + _option_COMPILER_EXECUTABLE MATCHES "ccache") + # Newer versions of Clang and GCC seem to embed a compilation timestamp into the precompiled header binary, + # which results in "file has been modified since the precompiled header was built" errors if ccache is used. + # We work around the problem by disabling ccache upon pre-compiling the prefix header. + set (ENV{CCACHE_DISABLE} "true") + endif() + endif() + execute_process( + COMMAND ${_cmd} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + RESULT_VARIABLE _result) + if (_result) + message (FATAL_ERROR "cotire: error ${_result} precompiling ${_prefixFile}.") + endif() +endfunction() + +function (cotire_check_precompiled_header_support _language _target _msgVar) + set (_unsupportedCompiler + "Precompiled headers not supported for ${_language} compiler ${CMAKE_${_language}_COMPILER_ID}") + if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC") + # supported since Visual Studio C++ 6.0 + # and CMake does not support an earlier version + set (${_msgVar} "" PARENT_SCOPE) + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU") + # GCC PCH support requires version >= 3.4 + if ("${CMAKE_${_language}_COMPILER_VERSION}" VERSION_LESS "3.4.0") + set (${_msgVar} "${_unsupportedCompiler} version ${CMAKE_${_language}_COMPILER_VERSION}." PARENT_SCOPE) + else() + set (${_msgVar} "" PARENT_SCOPE) + endif() + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Clang") + # all Clang versions have PCH support + set (${_msgVar} "" PARENT_SCOPE) + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Intel") + # Intel PCH support requires version >= 8.0.0 + if ("${CMAKE_${_language}_COMPILER_VERSION}" VERSION_LESS "8.0.0") + set (${_msgVar} "${_unsupportedCompiler} version ${CMAKE_${_language}_COMPILER_VERSION}." PARENT_SCOPE) + else() + set (${_msgVar} "" PARENT_SCOPE) + endif() + else() + set (${_msgVar} "${_unsupportedCompiler}." PARENT_SCOPE) + endif() + get_target_property(_launcher ${_target} ${_language}_COMPILER_LAUNCHER) + if (CMAKE_${_language}_COMPILER MATCHES "ccache" OR _launcher MATCHES "ccache") + if (DEFINED ENV{CCACHE_SLOPPINESS}) + if (NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "pch_defines" OR NOT "$ENV{CCACHE_SLOPPINESS}" MATCHES "time_macros") + set (${_msgVar} + "ccache requires the environment variable CCACHE_SLOPPINESS to be set to \"pch_defines,time_macros\"." + PARENT_SCOPE) + endif() + else() + if (_launcher MATCHES "ccache") + get_filename_component(_ccacheExe "${_launcher}" REALPATH) + else() + get_filename_component(_ccacheExe "${CMAKE_${_language}_COMPILER}" REALPATH) + endif() + execute_process( + COMMAND "${_ccacheExe}" "--print-config" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + RESULT_VARIABLE _result + OUTPUT_VARIABLE _ccacheConfig OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET) + if (_result OR NOT + _ccacheConfig MATCHES "sloppiness.*=.*time_macros" OR NOT + _ccacheConfig MATCHES "sloppiness.*=.*pch_defines") + set (${_msgVar} + "ccache requires configuration setting \"sloppiness\" to be set to \"pch_defines,time_macros\"." + PARENT_SCOPE) + endif() + endif() + endif() + if (APPLE) + # PCH compilation not supported by GCC / Clang for multi-architecture builds (e.g., i386, x86_64) + cotire_get_configuration_types(_configs) + foreach (_config ${_configs}) + set (_targetFlags "") + cotire_get_target_compile_flags("${_config}" "${_language}" "${_target}" _targetFlags) + cotire_filter_compile_flags("${_language}" "arch" _architectures _ignore ${_targetFlags}) + list (LENGTH _architectures _numberOfArchitectures) + if (_numberOfArchitectures GREATER 1) + string (REPLACE ";" ", " _architectureStr "${_architectures}") + set (${_msgVar} + "Precompiled headers not supported on Darwin for multi-architecture builds (${_architectureStr})." + PARENT_SCOPE) + break() + endif() + endforeach() + endif() +endfunction() + +macro (cotire_get_intermediate_dir _cotireDir) + # ${CMAKE_CFG_INTDIR} may reference a build-time variable when using a generator which supports configuration types + get_filename_component(${_cotireDir} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${COTIRE_INTDIR}" ABSOLUTE) +endmacro() + +macro (cotire_setup_file_extension_variables) + set (_unityFileExt_C ".c") + set (_unityFileExt_CXX ".cxx") + set (_prefixFileExt_C ".h") + set (_prefixFileExt_CXX ".hxx") + set (_prefixSourceFileExt_C ".c") + set (_prefixSourceFileExt_CXX ".cxx") +endmacro() + +function (cotire_make_single_unity_source_file_path _language _target _unityFileVar) + cotire_setup_file_extension_variables() + if (NOT DEFINED _unityFileExt_${_language}) + set (${_unityFileVar} "" PARENT_SCOPE) + return() + endif() + set (_unityFileBaseName "${_target}_${_language}${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}") + set (_unityFileName "${_unityFileBaseName}${_unityFileExt_${_language}}") + cotire_get_intermediate_dir(_baseDir) + set (_unityFile "${_baseDir}/${_unityFileName}") + set (${_unityFileVar} "${_unityFile}" PARENT_SCOPE) +endfunction() + +function (cotire_make_unity_source_file_paths _language _target _maxIncludes _unityFilesVar) + cotire_setup_file_extension_variables() + if (NOT DEFINED _unityFileExt_${_language}) + set (${_unityFileVar} "" PARENT_SCOPE) + return() + endif() + set (_unityFileBaseName "${_target}_${_language}${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}") + cotire_get_intermediate_dir(_baseDir) + set (_startIndex 0) + set (_index 0) + set (_unityFiles "") + set (_sourceFiles ${ARGN}) + foreach (_sourceFile ${_sourceFiles}) + get_source_file_property(_startNew "${_sourceFile}" COTIRE_START_NEW_UNITY_SOURCE) + math (EXPR _unityFileCount "${_index} - ${_startIndex}") + if (_startNew OR (_maxIncludes GREATER 0 AND NOT _unityFileCount LESS _maxIncludes)) + if (_index GREATER 0) + # start new unity file segment + math (EXPR _endIndex "${_index} - 1") + set (_unityFileName "${_unityFileBaseName}_${_startIndex}_${_endIndex}${_unityFileExt_${_language}}") + list (APPEND _unityFiles "${_baseDir}/${_unityFileName}") + endif() + set (_startIndex ${_index}) + endif() + math (EXPR _index "${_index} + 1") + endforeach() + list (LENGTH _sourceFiles _numberOfSources) + if (_startIndex EQUAL 0) + # there is only a single unity file + cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFiles) + elseif (_startIndex LESS _numberOfSources) + # end with final unity file segment + math (EXPR _endIndex "${_index} - 1") + set (_unityFileName "${_unityFileBaseName}_${_startIndex}_${_endIndex}${_unityFileExt_${_language}}") + list (APPEND _unityFiles "${_baseDir}/${_unityFileName}") + endif() + set (${_unityFilesVar} ${_unityFiles} PARENT_SCOPE) + if (COTIRE_DEBUG AND _unityFiles) + message (STATUS "unity files: ${_unityFiles}") + endif() +endfunction() + +function (cotire_unity_to_prefix_file_path _language _target _unityFile _prefixFileVar) + cotire_setup_file_extension_variables() + if (NOT DEFINED _unityFileExt_${_language}) + set (${_prefixFileVar} "" PARENT_SCOPE) + return() + endif() + set (_unityFileBaseName "${_target}_${_language}${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}") + set (_prefixFileBaseName "${_target}_${_language}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}") + string (REPLACE "${_unityFileBaseName}" "${_prefixFileBaseName}" _prefixFile "${_unityFile}") + string (REGEX REPLACE "${_unityFileExt_${_language}}$" "${_prefixFileExt_${_language}}" _prefixFile "${_prefixFile}") + set (${_prefixFileVar} "${_prefixFile}" PARENT_SCOPE) +endfunction() + +function (cotire_prefix_header_to_source_file_path _language _prefixHeaderFile _prefixSourceFileVar) + cotire_setup_file_extension_variables() + if (NOT DEFINED _prefixSourceFileExt_${_language}) + set (${_prefixSourceFileVar} "" PARENT_SCOPE) + return() + endif() + string (REGEX REPLACE "${_prefixFileExt_${_language}}$" "${_prefixSourceFileExt_${_language}}" _prefixSourceFile "${_prefixHeaderFile}") + set (${_prefixSourceFileVar} "${_prefixSourceFile}" PARENT_SCOPE) +endfunction() + +function (cotire_make_prefix_file_name _language _target _prefixFileBaseNameVar _prefixFileNameVar) + cotire_setup_file_extension_variables() + if (NOT _language) + set (_prefixFileBaseName "${_target}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}") + set (_prefixFileName "${_prefixFileBaseName}${_prefixFileExt_C}") + elseif (DEFINED _prefixFileExt_${_language}) + set (_prefixFileBaseName "${_target}_${_language}${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}") + set (_prefixFileName "${_prefixFileBaseName}${_prefixFileExt_${_language}}") + else() + set (_prefixFileBaseName "") + set (_prefixFileName "") + endif() + set (${_prefixFileBaseNameVar} "${_prefixFileBaseName}" PARENT_SCOPE) + set (${_prefixFileNameVar} "${_prefixFileName}" PARENT_SCOPE) +endfunction() + +function (cotire_make_prefix_file_path _language _target _prefixFileVar) + cotire_make_prefix_file_name("${_language}" "${_target}" _prefixFileBaseName _prefixFileName) + set (${_prefixFileVar} "" PARENT_SCOPE) + if (_prefixFileName) + if (NOT _language) + set (_language "C") + endif() + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang|Intel|MSVC") + cotire_get_intermediate_dir(_baseDir) + set (${_prefixFileVar} "${_baseDir}/${_prefixFileName}" PARENT_SCOPE) + endif() + endif() +endfunction() + +function (cotire_make_pch_file_path _language _target _pchFileVar) + cotire_make_prefix_file_name("${_language}" "${_target}" _prefixFileBaseName _prefixFileName) + set (${_pchFileVar} "" PARENT_SCOPE) + if (_prefixFileBaseName AND _prefixFileName) + cotire_check_precompiled_header_support("${_language}" "${_target}" _msg) + if (NOT _msg) + if (XCODE) + # For Xcode, we completely hand off the compilation of the prefix header to the IDE + return() + endif() + cotire_get_intermediate_dir(_baseDir) + if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC") + # MSVC uses the extension .pch added to the prefix header base name + set (${_pchFileVar} "${_baseDir}/${_prefixFileBaseName}.pch" PARENT_SCOPE) + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Clang") + # Clang looks for a precompiled header corresponding to the prefix header with the extension .pch appended + set (${_pchFileVar} "${_baseDir}/${_prefixFileName}.pch" PARENT_SCOPE) + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "GNU") + # GCC looks for a precompiled header corresponding to the prefix header with the extension .gch appended + set (${_pchFileVar} "${_baseDir}/${_prefixFileName}.gch" PARENT_SCOPE) + elseif (CMAKE_${_language}_COMPILER_ID MATCHES "Intel") + # Intel uses the extension .pchi added to the prefix header base name + set (${_pchFileVar} "${_baseDir}/${_prefixFileBaseName}.pchi" PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + +function (cotire_select_unity_source_files _unityFile _sourcesVar) + set (_sourceFiles ${ARGN}) + if (_sourceFiles AND "${_unityFile}" MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}_([0-9]+)_([0-9]+)") + set (_startIndex ${CMAKE_MATCH_1}) + set (_endIndex ${CMAKE_MATCH_2}) + list (LENGTH _sourceFiles _numberOfSources) + if (NOT _startIndex LESS _numberOfSources) + math (EXPR _startIndex "${_numberOfSources} - 1") + endif() + if (NOT _endIndex LESS _numberOfSources) + math (EXPR _endIndex "${_numberOfSources} - 1") + endif() + set (_files "") + foreach (_index RANGE ${_startIndex} ${_endIndex}) + list (GET _sourceFiles ${_index} _file) + list (APPEND _files "${_file}") + endforeach() + else() + set (_files ${_sourceFiles}) + endif() + set (${_sourcesVar} ${_files} PARENT_SCOPE) +endfunction() + +function (cotire_get_unity_source_dependencies _language _target _dependencySourcesVar) + set (_dependencySources "") + # depend on target's generated source files + get_target_property(_targetSourceFiles ${_target} SOURCES) + cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${_targetSourceFiles}) + if (_generatedSources) + # but omit all generated source files that have the COTIRE_EXCLUDED property set to true + cotire_get_objects_with_property_on(_excludedGeneratedSources COTIRE_EXCLUDED SOURCE ${_generatedSources}) + if (_excludedGeneratedSources) + list (REMOVE_ITEM _generatedSources ${_excludedGeneratedSources}) + endif() + # and omit all generated source files that have the COTIRE_DEPENDENCY property set to false explicitly + cotire_get_objects_with_property_off(_excludedNonDependencySources COTIRE_DEPENDENCY SOURCE ${_generatedSources}) + if (_excludedNonDependencySources) + list (REMOVE_ITEM _generatedSources ${_excludedNonDependencySources}) + endif() + if (_generatedSources) + list (APPEND _dependencySources ${_generatedSources}) + endif() + endif() + if (COTIRE_DEBUG AND _dependencySources) + message (STATUS "${_language} ${_target} unity source dependencies: ${_dependencySources}") + endif() + set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE) +endfunction() + +function (cotire_get_prefix_header_dependencies _language _target _dependencySourcesVar) + set (_dependencySources "") + # depend on target source files marked with custom COTIRE_DEPENDENCY property + get_target_property(_targetSourceFiles ${_target} SOURCES) + cotire_get_objects_with_property_on(_dependencySources COTIRE_DEPENDENCY SOURCE ${_targetSourceFiles}) + if (COTIRE_DEBUG AND _dependencySources) + message (STATUS "${_language} ${_target} prefix header dependencies: ${_dependencySources}") + endif() + set (${_dependencySourcesVar} ${_dependencySources} PARENT_SCOPE) +endfunction() + +function (cotire_generate_target_script _language _configurations _target _targetScriptVar _targetConfigScriptVar) + set (_targetSources ${ARGN}) + cotire_get_prefix_header_dependencies(${_language} ${_target} COTIRE_TARGET_PREFIX_DEPENDS ${_targetSources}) + cotire_get_unity_source_dependencies(${_language} ${_target} COTIRE_TARGET_UNITY_DEPENDS ${_targetSources}) + # set up variables to be configured + set (COTIRE_TARGET_LANGUAGE "${_language}") + get_target_property(COTIRE_TARGET_IGNORE_PATH ${_target} COTIRE_PREFIX_HEADER_IGNORE_PATH) + cotire_add_sys_root_paths(COTIRE_TARGET_IGNORE_PATH) + get_target_property(COTIRE_TARGET_INCLUDE_PATH ${_target} COTIRE_PREFIX_HEADER_INCLUDE_PATH) + cotire_add_sys_root_paths(COTIRE_TARGET_INCLUDE_PATH) + get_target_property(COTIRE_TARGET_PRE_UNDEFS ${_target} COTIRE_UNITY_SOURCE_PRE_UNDEFS) + get_target_property(COTIRE_TARGET_POST_UNDEFS ${_target} COTIRE_UNITY_SOURCE_POST_UNDEFS) + get_target_property(COTIRE_TARGET_MAXIMUM_NUMBER_OF_INCLUDES ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) + get_target_property(COTIRE_TARGET_INCLUDE_PRIORITY_PATH ${_target} COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH) + cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_PRE_UNDEFS COTIRE_TARGET_SOURCES_PRE_UNDEFS ${_targetSources}) + cotire_get_source_files_undefs(COTIRE_UNITY_SOURCE_POST_UNDEFS COTIRE_TARGET_SOURCES_POST_UNDEFS ${_targetSources}) + set (COTIRE_TARGET_CONFIGURATION_TYPES "${_configurations}") + foreach (_config ${_configurations}) + string (TOUPPER "${_config}" _upperConfig) + cotire_get_target_include_directories( + "${_config}" "${_language}" "${_target}" COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig} COTIRE_TARGET_SYSTEM_INCLUDE_DIRECTORIES_${_upperConfig}) + cotire_get_target_compile_definitions( + "${_config}" "${_language}" "${_target}" COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}) + cotire_get_target_compiler_flags( + "${_config}" "${_language}" "${_target}" COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig}) + cotire_get_source_files_compile_definitions( + "${_config}" "${_language}" COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig} ${_targetSources}) + endforeach() + get_target_property(COTIRE_TARGET_${_language}_COMPILER_LAUNCHER ${_target} ${_language}_COMPILER_LAUNCHER) + # set up COTIRE_TARGET_SOURCES + set (COTIRE_TARGET_SOURCES "") + foreach (_sourceFile ${_targetSources}) + get_source_file_property(_generated "${_sourceFile}" GENERATED) + if (_generated) + # use absolute paths for generated files only, retrieving the LOCATION property is an expensive operation + get_source_file_property(_sourceLocation "${_sourceFile}" LOCATION) + list (APPEND COTIRE_TARGET_SOURCES "${_sourceLocation}") + else() + list (APPEND COTIRE_TARGET_SOURCES "${_sourceFile}") + endif() + endforeach() + # copy variable definitions to cotire target script + get_cmake_property(_vars VARIABLES) + string (REGEX MATCHALL "COTIRE_[A-Za-z0-9_]+" _matchVars "${_vars}") + # omit COTIRE_*_INIT variables + string (REGEX MATCHALL "COTIRE_[A-Za-z0-9_]+_INIT" _initVars "${_matchVars}") + if (_initVars) + list (REMOVE_ITEM _matchVars ${_initVars}) + endif() + # omit COTIRE_VERBOSE which is passed as a CMake define on command line + list (REMOVE_ITEM _matchVars COTIRE_VERBOSE) + set (_contents "") + set (_contentsHasGeneratorExpressions FALSE) + foreach (_var IN LISTS _matchVars ITEMS + XCODE MSVC CMAKE_GENERATOR CMAKE_BUILD_TYPE CMAKE_CONFIGURATION_TYPES + CMAKE_${_language}_COMPILER_ID CMAKE_${_language}_COMPILER_VERSION + CMAKE_${_language}_COMPILER_LAUNCHER CMAKE_${_language}_COMPILER CMAKE_${_language}_COMPILER_ARG1 + CMAKE_INCLUDE_FLAG_${_language} CMAKE_INCLUDE_FLAG_SEP_${_language} + CMAKE_INCLUDE_SYSTEM_FLAG_${_language} + CMAKE_${_language}_FRAMEWORK_SEARCH_FLAG + CMAKE_${_language}_SYSTEM_FRAMEWORK_SEARCH_FLAG + CMAKE_${_language}_SOURCE_FILE_EXTENSIONS) + if (DEFINED ${_var}) + string (REPLACE "\"" "\\\"" _value "${${_var}}") + set (_contents "${_contents}set (${_var} \"${_value}\")\n") + if (NOT _contentsHasGeneratorExpressions) + if ("${_value}" MATCHES "\\$<.*>") + set (_contentsHasGeneratorExpressions TRUE) + endif() + endif() + endif() + endforeach() + # generate target script file + get_filename_component(_moduleName "${COTIRE_CMAKE_MODULE_FILE}" NAME) + set (_targetCotireScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_moduleName}") + cotire_write_file("CMAKE" "${_targetCotireScript}" "${_contents}" FALSE) + if (_contentsHasGeneratorExpressions) + # use file(GENERATE ...) to expand generator expressions in the target script at CMake generate-time + set (_configNameOrNoneGeneratorExpression "$<$:None>$<$>:$>") + set (_targetCotireConfigScript "${CMAKE_CURRENT_BINARY_DIR}/${_target}_${_language}_${_configNameOrNoneGeneratorExpression}_${_moduleName}") + file (GENERATE OUTPUT "${_targetCotireConfigScript}" INPUT "${_targetCotireScript}") + else() + set (_targetCotireConfigScript "${_targetCotireScript}") + endif() + set (${_targetScriptVar} "${_targetCotireScript}" PARENT_SCOPE) + set (${_targetConfigScriptVar} "${_targetCotireConfigScript}" PARENT_SCOPE) +endfunction() + +function (cotire_setup_pch_file_compilation _language _target _targetScript _prefixFile _pchFile _hostFile) + set (_sourceFiles ${ARGN}) + if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + # for Visual Studio and Intel, we attach the precompiled header compilation to the host file + # the remaining files include the precompiled header, see cotire_setup_pch_file_inclusion + if (_sourceFiles) + set (_flags "") + cotire_add_pch_compilation_flags( + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" "${_hostFile}" _flags) + set_property (SOURCE ${_hostFile} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_OUTPUTS "${_pchFile}") + # make object file generated from host file depend on prefix header + set_property (SOURCE ${_hostFile} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") + # mark host file as cotired to prevent it from being used in another cotired target + set_property (SOURCE ${_hostFile} PROPERTY COTIRE_TARGET "${_target}") + endif() + elseif ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") + # for makefile based generator, we add a custom command to precompile the prefix header + if (_targetScript) + cotire_set_cmd_to_prologue(_cmds) + list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "precompile" "${_targetScript}" "${_prefixFile}" "${_pchFile}" "${_hostFile}") + if (MSVC_IDE) + file (TO_NATIVE_PATH "${_pchFile}" _pchFileLogPath) + else() + file (RELATIVE_PATH _pchFileLogPath "${CMAKE_BINARY_DIR}" "${_pchFile}") + endif() + # make precompiled header compilation depend on the actual compiler executable used to force + # re-compilation when the compiler executable is updated. This prevents "created by a different GCC executable" + # warnings when the precompiled header is included. + get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" ABSOLUTE) + if (COTIRE_DEBUG) + message (STATUS "add_custom_command: OUTPUT ${_pchFile} ${_cmds} DEPENDS ${_prefixFile} ${_realCompilerExe} IMPLICIT_DEPENDS ${_language} ${_prefixFile}") + endif() + set_property (SOURCE "${_pchFile}" PROPERTY GENERATED TRUE) + add_custom_command( + OUTPUT "${_pchFile}" + COMMAND ${_cmds} + DEPENDS "${_prefixFile}" "${_realCompilerExe}" + IMPLICIT_DEPENDS ${_language} "${_prefixFile}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Building ${_language} precompiled header ${_pchFileLogPath}" + VERBATIM) + endif() + endif() +endfunction() + +function (cotire_setup_pch_file_inclusion _language _target _wholeTarget _prefixFile _pchFile _hostFile) + if (CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + # for Visual Studio and Intel, we include the precompiled header in all but the host file + # the host file does the precompiled header compilation, see cotire_setup_pch_file_compilation + set (_sourceFiles ${ARGN}) + list (LENGTH _sourceFiles _numberOfSourceFiles) + if (_numberOfSourceFiles GREATER 0) + # mark sources as cotired to prevent them from being used in another cotired target + set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") + set (_flags "") + cotire_add_prefix_pch_inclusion_flags( + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" _flags) + set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + # make object files generated from source files depend on precompiled header + set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}") + endif() + elseif ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") + set (_sourceFiles ${_hostFile} ${ARGN}) + if (NOT _wholeTarget) + # for makefile based generator, we force the inclusion of the prefix header for a subset + # of the source files, if this is a multi-language target or has excluded files + set (_flags "") + cotire_add_prefix_pch_inclusion_flags( + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" _flags) + set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + # mark sources as cotired to prevent them from being used in another cotired target + set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") + endif() + # make object files generated from source files depend on precompiled header + set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_pchFile}") + endif() +endfunction() + +function (cotire_setup_prefix_file_inclusion _language _target _prefixFile) + set (_sourceFiles ${ARGN}) + # force the inclusion of the prefix header for the given source files + set (_flags "") + set (_pchFile "") + cotire_add_prefix_pch_inclusion_flags( + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" _flags) + set_property (SOURCE ${_sourceFiles} APPEND_STRING PROPERTY COMPILE_FLAGS " ${_flags} ") + # mark sources as cotired to prevent them from being used in another cotired target + set_source_files_properties(${_sourceFiles} PROPERTIES COTIRE_TARGET "${_target}") + # make object files generated from source files depend on prefix header + set_property (SOURCE ${_sourceFiles} APPEND PROPERTY OBJECT_DEPENDS "${_prefixFile}") +endfunction() + +function (cotire_get_first_set_property_value _propertyValueVar _type _object) + set (_properties ${ARGN}) + foreach (_property ${_properties}) + get_property(_propertyValue ${_type} "${_object}" PROPERTY ${_property}) + if (_propertyValue) + set (${_propertyValueVar} ${_propertyValue} PARENT_SCOPE) + return() + endif() + endforeach() + set (${_propertyValueVar} "" PARENT_SCOPE) +endfunction() + +function (cotire_setup_combine_command _language _targetScript _joinedFile _cmdsVar) + set (_files ${ARGN}) + set (_filesPaths "") + foreach (_file ${_files}) + get_filename_component(_filePath "${_file}" ABSOLUTE) + list (APPEND _filesPaths "${_filePath}") + endforeach() + cotire_set_cmd_to_prologue(_prefixCmd) + list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "combine") + if (_targetScript) + list (APPEND _prefixCmd "${_targetScript}") + endif() + list (APPEND _prefixCmd "${_joinedFile}" ${_filesPaths}) + if (COTIRE_DEBUG) + message (STATUS "add_custom_command: OUTPUT ${_joinedFile} COMMAND ${_prefixCmd} DEPENDS ${_files}") + endif() + set_property (SOURCE "${_joinedFile}" PROPERTY GENERATED TRUE) + if (MSVC_IDE) + file (TO_NATIVE_PATH "${_joinedFile}" _joinedFileLogPath) + else() + file (RELATIVE_PATH _joinedFileLogPath "${CMAKE_BINARY_DIR}" "${_joinedFile}") + endif() + get_filename_component(_joinedFileBaseName "${_joinedFile}" NAME_WE) + get_filename_component(_joinedFileExt "${_joinedFile}" EXT) + if (_language AND _joinedFileBaseName MATCHES "${COTIRE_UNITY_SOURCE_FILENAME_SUFFIX}$") + set (_comment "Generating ${_language} unity source ${_joinedFileLogPath}") + elseif (_language AND _joinedFileBaseName MATCHES "${COTIRE_PREFIX_HEADER_FILENAME_SUFFIX}$") + if (_joinedFileExt MATCHES "^\\.c") + set (_comment "Generating ${_language} prefix source ${_joinedFileLogPath}") + else() + set (_comment "Generating ${_language} prefix header ${_joinedFileLogPath}") + endif() + else() + set (_comment "Generating ${_joinedFileLogPath}") + endif() + add_custom_command( + OUTPUT "${_joinedFile}" + COMMAND ${_prefixCmd} + DEPENDS ${_files} + COMMENT "${_comment}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + VERBATIM) + list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) + set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) +endfunction() + +function (cotire_setup_target_pch_usage _languages _target _wholeTarget) + if (XCODE) + # for Xcode, we attach a pre-build action to generate the unity sources and prefix headers + set (_prefixFiles "") + foreach (_language ${_languages}) + get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) + if (_prefixFile) + list (APPEND _prefixFiles "${_prefixFile}") + endif() + endforeach() + set (_cmds ${ARGN}) + list (LENGTH _prefixFiles _numberOfPrefixFiles) + if (_numberOfPrefixFiles GREATER 1) + # we also generate a generic, single prefix header which includes all language specific prefix headers + set (_language "") + set (_targetScript "") + cotire_make_prefix_file_path("${_language}" ${_target} _prefixHeader) + cotire_setup_combine_command("${_language}" "${_targetScript}" "${_prefixHeader}" _cmds ${_prefixFiles}) + else() + set (_prefixHeader "${_prefixFiles}") + endif() + if (COTIRE_DEBUG) + message (STATUS "add_custom_command: TARGET ${_target} PRE_BUILD ${_cmds}") + endif() + # because CMake PRE_BUILD command does not support dependencies, + # we check dependencies explicity in cotire script mode when the pre-build action is run + add_custom_command( + TARGET "${_target}" + PRE_BUILD ${_cmds} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Updating target ${_target} prefix headers" + VERBATIM) + # make Xcode precompile the generated prefix header with ProcessPCH and ProcessPCH++ + set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES") + set_target_properties(${_target} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${_prefixHeader}") + elseif ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") + # for makefile based generator, we force inclusion of the prefix header for all target source files + # if this is a single-language target without any excluded files + if (_wholeTarget) + set (_language "${_languages}") + # for Visual Studio and Intel, precompiled header inclusion is always done on the source file level + # see cotire_setup_pch_file_inclusion + if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) + if (_prefixFile) + get_property(_pchFile TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER) + set (_options COMPILE_OPTIONS) + cotire_add_prefix_pch_inclusion_flags( + "${_language}" "${CMAKE_${_language}_COMPILER_ID}" "${CMAKE_${_language}_COMPILER_VERSION}" + "${_prefixFile}" "${_pchFile}" _options) + set_property(TARGET ${_target} APPEND PROPERTY ${_options}) + endif() + endif() + endif() + endif() +endfunction() + +function (cotire_setup_unity_generation_commands _language _target _targetScript _targetConfigScript _unityFiles _cmdsVar) + set (_dependencySources "") + cotire_get_unity_source_dependencies(${_language} ${_target} _dependencySources ${ARGN}) + foreach (_unityFile ${_unityFiles}) + set_property (SOURCE "${_unityFile}" PROPERTY GENERATED TRUE) + # set up compiled unity source dependencies via OBJECT_DEPENDS + # this ensures that missing source files are generated before the unity file is compiled + if (COTIRE_DEBUG AND _dependencySources) + message (STATUS "${_unityFile} OBJECT_DEPENDS ${_dependencySources}") + endif() + if (_dependencySources) + # the OBJECT_DEPENDS property requires a list of full paths + set (_objectDependsPaths "") + foreach (_sourceFile ${_dependencySources}) + get_source_file_property(_sourceLocation "${_sourceFile}" LOCATION) + list (APPEND _objectDependsPaths "${_sourceLocation}") + endforeach() + set_property (SOURCE "${_unityFile}" PROPERTY OBJECT_DEPENDS ${_objectDependsPaths}) + endif() + if (WIN32 AND CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + # unity file compilation results in potentially huge object file, thus use /bigobj by default unter MSVC and Windows Intel + set_property (SOURCE "${_unityFile}" APPEND_STRING PROPERTY COMPILE_FLAGS "/bigobj") + endif() + cotire_set_cmd_to_prologue(_unityCmd) + list (APPEND _unityCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "unity" "${_targetConfigScript}" "${_unityFile}") + if (CMAKE_VERSION VERSION_LESS "3.1.0") + set (_unityCmdDepends "${_targetScript}") + else() + # CMake 3.1.0 supports generator expressions in arguments to DEPENDS + set (_unityCmdDepends "${_targetConfigScript}") + endif() + if (MSVC_IDE) + file (TO_NATIVE_PATH "${_unityFile}" _unityFileLogPath) + else() + file (RELATIVE_PATH _unityFileLogPath "${CMAKE_BINARY_DIR}" "${_unityFile}") + endif() + if (COTIRE_DEBUG) + message (STATUS "add_custom_command: OUTPUT ${_unityFile} COMMAND ${_unityCmd} DEPENDS ${_unityCmdDepends}") + endif() + add_custom_command( + OUTPUT "${_unityFile}" + COMMAND ${_unityCmd} + DEPENDS ${_unityCmdDepends} + COMMENT "Generating ${_language} unity source ${_unityFileLogPath}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + VERBATIM) + list (APPEND ${_cmdsVar} COMMAND ${_unityCmd}) + endforeach() + set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) +endfunction() + +function (cotire_setup_prefix_generation_command _language _target _targetScript _prefixFile _unityFiles _cmdsVar) + set (_sourceFiles ${ARGN}) + set (_dependencySources "") + cotire_get_prefix_header_dependencies(${_language} ${_target} _dependencySources ${_sourceFiles}) + cotire_set_cmd_to_prologue(_prefixCmd) + list (APPEND _prefixCmd -P "${COTIRE_CMAKE_MODULE_FILE}" "prefix" "${_targetScript}" "${_prefixFile}" ${_unityFiles}) + set_property (SOURCE "${_prefixFile}" PROPERTY GENERATED TRUE) + # make prefix header generation depend on the actual compiler executable used to force + # re-generation when the compiler executable is updated. This prevents "file not found" + # errors for compiler version specific system header files. + get_filename_component(_realCompilerExe "${CMAKE_${_language}_COMPILER}" ABSOLUTE) + if (COTIRE_DEBUG) + message (STATUS "add_custom_command: OUTPUT ${_prefixFile} COMMAND ${_prefixCmd} DEPENDS ${_unityFile} ${_dependencySources} ${_realCompilerExe}") + endif() + if (MSVC_IDE) + file (TO_NATIVE_PATH "${_prefixFile}" _prefixFileLogPath) + else() + file (RELATIVE_PATH _prefixFileLogPath "${CMAKE_BINARY_DIR}" "${_prefixFile}") + endif() + get_filename_component(_prefixFileExt "${_prefixFile}" EXT) + if (_prefixFileExt MATCHES "^\\.c") + set (_comment "Generating ${_language} prefix source ${_prefixFileLogPath}") + else() + set (_comment "Generating ${_language} prefix header ${_prefixFileLogPath}") + endif() + # prevent pre-processing errors upon generating the prefix header when a target's generated include file does not yet exist + # we do not add a file-level dependency for the target's generated files though, because we only want to depend on their existence + # thus we make the prefix header generation depend on a custom helper target which triggers the generation of the files + set (_preTargetName "${_target}${COTIRE_PCH_TARGET_SUFFIX}_pre") + if (TARGET ${_preTargetName}) + # custom helper target has already been generated while processing a different language + list (APPEND _dependencySources ${_preTargetName}) + else() + get_target_property(_targetSourceFiles ${_target} SOURCES) + cotire_get_objects_with_property_on(_generatedSources GENERATED SOURCE ${_targetSourceFiles}) + if (_generatedSources) + add_custom_target("${_preTargetName}" DEPENDS ${_generatedSources}) + cotire_init_target("${_preTargetName}") + list (APPEND _dependencySources ${_preTargetName}) + endif() + endif() + add_custom_command( + OUTPUT "${_prefixFile}" "${_prefixFile}.log" + COMMAND ${_prefixCmd} + DEPENDS ${_unityFiles} ${_dependencySources} "${_realCompilerExe}" + COMMENT "${_comment}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + VERBATIM) + list (APPEND ${_cmdsVar} COMMAND ${_prefixCmd}) + set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) +endfunction() + +function (cotire_setup_prefix_generation_from_unity_command _language _target _targetScript _prefixFile _unityFiles _cmdsVar) + set (_sourceFiles ${ARGN}) + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + # GNU and Clang require indirect compilation of the prefix header to make them honor the system_header pragma + cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile) + else() + set (_prefixSourceFile "${_prefixFile}") + endif() + cotire_setup_prefix_generation_command( + ${_language} ${_target} "${_targetScript}" + "${_prefixSourceFile}" "${_unityFiles}" ${_cmdsVar} ${_sourceFiles}) + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + # set up generation of a prefix source file which includes the prefix header + cotire_setup_combine_command(${_language} "${_targetScript}" "${_prefixFile}" _cmds ${_prefixSourceFile}) + endif() + set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) +endfunction() + +function (cotire_setup_prefix_generation_from_provided_command _language _target _targetScript _prefixFile _cmdsVar) + set (_prefixHeaderFiles ${ARGN}) + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + # GNU and Clang require indirect compilation of the prefix header to make them honor the system_header pragma + cotire_prefix_header_to_source_file_path(${_language} "${_prefixFile}" _prefixSourceFile) + else() + set (_prefixSourceFile "${_prefixFile}") + endif() + cotire_setup_combine_command(${_language} "${_targetScript}" "${_prefixSourceFile}" _cmds ${_prefixHeaderFiles}) + if (CMAKE_${_language}_COMPILER_ID MATCHES "GNU|Clang") + # set up generation of a prefix source file which includes the prefix header + cotire_setup_combine_command(${_language} "${_targetScript}" "${_prefixFile}" _cmds ${_prefixSourceFile}) + endif() + set (${_cmdsVar} ${${_cmdsVar}} PARENT_SCOPE) +endfunction() + +function (cotire_init_cotire_target_properties _target) + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER TRUE) + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD TRUE) + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_ADD_CLEAN SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_ADD_CLEAN FALSE) + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH "${CMAKE_SOURCE_DIR}") + cotire_check_is_path_relative_to("${CMAKE_BINARY_DIR}" _isRelative "${CMAKE_SOURCE_DIR}") + if (NOT _isRelative) + set_property(TARGET ${_target} APPEND PROPERTY COTIRE_PREFIX_HEADER_IGNORE_PATH "${CMAKE_BINARY_DIR}") + endif() + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PATH SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PATH "") + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH "") + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_PRE_UNDEFS SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_PRE_UNDEFS "") + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_POST_UNDEFS SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_POST_UNDEFS "") + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT SET) + if (NOT _isSet) + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_LINK_LIBRARIES_INIT "COPY_UNITY") + endif() + get_property(_isSet TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES SET) + if (NOT _isSet) + if (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES) + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES "${COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES}") + else() + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES "") + endif() + endif() +endfunction() + +function (cotire_make_target_message _target _languages _disableMsg _targetMsgVar) + get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) + get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) + string (REPLACE ";" " " _languagesStr "${_languages}") + math (EXPR _numberOfExcludedFiles "${ARGC} - 4") + if (_numberOfExcludedFiles EQUAL 0) + set (_excludedStr "") + elseif (COTIRE_VERBOSE OR _numberOfExcludedFiles LESS 4) + string (REPLACE ";" ", " _excludedStr "excluding ${ARGN}") + else() + set (_excludedStr "excluding ${_numberOfExcludedFiles} files") + endif() + set (_targetMsg "") + if (NOT _languages) + set (_targetMsg "Target ${_target} cannot be cotired.") + if (_disableMsg) + set (_targetMsg "${_targetMsg} ${_disableMsg}") + endif() + elseif (NOT _targetUsePCH AND NOT _targetAddSCU) + set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build and precompiled header.") + if (_disableMsg) + set (_targetMsg "${_targetMsg} ${_disableMsg}") + endif() + elseif (NOT _targetUsePCH) + if (_excludedStr) + set (_targetMsg "${_languagesStr} target ${_target} cotired without precompiled header ${_excludedStr}.") + else() + set (_targetMsg "${_languagesStr} target ${_target} cotired without precompiled header.") + endif() + if (_disableMsg) + set (_targetMsg "${_targetMsg} ${_disableMsg}") + endif() + elseif (NOT _targetAddSCU) + if (_excludedStr) + set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build ${_excludedStr}.") + else() + set (_targetMsg "${_languagesStr} target ${_target} cotired without unity build.") + endif() + else() + if (_excludedStr) + set (_targetMsg "${_languagesStr} target ${_target} cotired ${_excludedStr}.") + else() + set (_targetMsg "${_languagesStr} target ${_target} cotired.") + endif() + endif() + set (${_targetMsgVar} "${_targetMsg}" PARENT_SCOPE) +endfunction() + +function (cotire_choose_target_languages _target _targetLanguagesVar _wholeTargetVar) + set (_languages ${ARGN}) + set (_allSourceFiles "") + set (_allExcludedSourceFiles "") + set (_allCotiredSourceFiles "") + set (_targetLanguages "") + set (_pchEligibleTargetLanguages "") + get_target_property(_targetType ${_target} TYPE) + get_target_property(_targetSourceFiles ${_target} SOURCES) + get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) + get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) + set (_disableMsg "") + foreach (_language ${_languages}) + get_target_property(_prefixHeader ${_target} COTIRE_${_language}_PREFIX_HEADER) + get_target_property(_unityBuildFile ${_target} COTIRE_${_language}_UNITY_SOURCE) + if (_prefixHeader OR _unityBuildFile) + message (STATUS "cotire: target ${_target} has already been cotired.") + set (${_targetLanguagesVar} "" PARENT_SCOPE) + return() + endif() + if (_targetUsePCH AND "${_language}" MATCHES "^C|CXX$" AND DEFINED CMAKE_${_language}_COMPILER_ID) + if (CMAKE_${_language}_COMPILER_ID) + cotire_check_precompiled_header_support("${_language}" "${_target}" _disableMsg) + if (_disableMsg) + set (_targetUsePCH FALSE) + endif() + endif() + endif() + set (_sourceFiles "") + set (_excludedSources "") + set (_cotiredSources "") + cotire_filter_language_source_files(${_language} ${_target} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) + if (_sourceFiles OR _excludedSources OR _cotiredSources) + list (APPEND _targetLanguages ${_language}) + endif() + if (_sourceFiles) + list (APPEND _allSourceFiles ${_sourceFiles}) + endif() + list (LENGTH _sourceFiles _numberOfSources) + if (NOT _numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) + list (APPEND _pchEligibleTargetLanguages ${_language}) + endif() + if (_excludedSources) + list (APPEND _allExcludedSourceFiles ${_excludedSources}) + endif() + if (_cotiredSources) + list (APPEND _allCotiredSourceFiles ${_cotiredSources}) + endif() + endforeach() + set (_targetMsgLevel STATUS) + if (NOT _targetLanguages) + string (REPLACE ";" " or " _languagesStr "${_languages}") + set (_disableMsg "No ${_languagesStr} source files.") + set (_targetUsePCH FALSE) + set (_targetAddSCU FALSE) + endif() + if (_targetUsePCH) + if (_allCotiredSourceFiles) + cotire_get_source_file_property_values(_cotireTargets COTIRE_TARGET ${_allCotiredSourceFiles}) + list (REMOVE_DUPLICATES _cotireTargets) + string (REPLACE ";" ", " _cotireTargetsStr "${_cotireTargets}") + set (_disableMsg "Target sources already include a precompiled header for target(s) ${_cotireTargets}.") + set (_disableMsg "${_disableMsg} Set target property COTIRE_ENABLE_PRECOMPILED_HEADER to FALSE for targets ${_target},") + set (_disableMsg "${_disableMsg} ${_cotireTargetsStr} to get a workable build system.") + set (_targetMsgLevel SEND_ERROR) + set (_targetUsePCH FALSE) + elseif (NOT _pchEligibleTargetLanguages) + set (_disableMsg "Too few applicable sources.") + set (_targetUsePCH FALSE) + elseif (XCODE AND _allExcludedSourceFiles) + # for Xcode, we cannot apply the precompiled header to individual sources, only to the whole target + set (_disableMsg "Exclusion of source files not supported for generator Xcode.") + set (_targetUsePCH FALSE) + elseif (XCODE AND "${_targetType}" STREQUAL "OBJECT_LIBRARY") + # for Xcode, we cannot apply the required PRE_BUILD action to generate the prefix header to an OBJECT_LIBRARY target + set (_disableMsg "Required PRE_BUILD action not supported for OBJECT_LIBRARY targets for generator Xcode.") + set (_targetUsePCH FALSE) + endif() + endif() + set_property(TARGET ${_target} PROPERTY COTIRE_ENABLE_PRECOMPILED_HEADER ${_targetUsePCH}) + set_property(TARGET ${_target} PROPERTY COTIRE_ADD_UNITY_BUILD ${_targetAddSCU}) + cotire_make_target_message(${_target} "${_targetLanguages}" "${_disableMsg}" _targetMsg ${_allExcludedSourceFiles}) + if (_targetMsg) + if (NOT DEFINED COTIREMSG_${_target}) + set (COTIREMSG_${_target} "") + endif() + if (COTIRE_VERBOSE OR NOT "${_targetMsgLevel}" STREQUAL "STATUS" OR + NOT "${COTIREMSG_${_target}}" STREQUAL "${_targetMsg}") + # cache message to avoid redundant messages on re-configure + set (COTIREMSG_${_target} "${_targetMsg}" CACHE INTERNAL "${_target} cotire message.") + message (${_targetMsgLevel} "${_targetMsg}") + endif() + endif() + list (LENGTH _targetLanguages _numberOfLanguages) + if (_numberOfLanguages GREATER 1 OR _allExcludedSourceFiles) + set (${_wholeTargetVar} FALSE PARENT_SCOPE) + else() + set (${_wholeTargetVar} TRUE PARENT_SCOPE) + endif() + set (${_targetLanguagesVar} ${_targetLanguages} PARENT_SCOPE) +endfunction() + +function (cotire_compute_unity_max_number_of_includes _target _maxIncludesVar) + set (_sourceFiles ${ARGN}) + get_target_property(_maxIncludes ${_target} COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES) + if (_maxIncludes MATCHES "(-j|--parallel|--jobs) ?([0-9]*)") + set (_numberOfThreads "${CMAKE_MATCH_2}") + if (NOT _numberOfThreads) + # use all available cores + ProcessorCount(_numberOfThreads) + endif() + list (LENGTH _sourceFiles _numberOfSources) + math (EXPR _maxIncludes "(${_numberOfSources} + ${_numberOfThreads} - 1) / ${_numberOfThreads}") + elseif (NOT _maxIncludes MATCHES "[0-9]+") + set (_maxIncludes 0) + endif() + if (COTIRE_DEBUG) + message (STATUS "${_target} unity source max includes: ${_maxIncludes}") + endif() + set (${_maxIncludesVar} ${_maxIncludes} PARENT_SCOPE) +endfunction() + +function (cotire_process_target_language _language _configurations _target _wholeTarget _cmdsVar) + set (${_cmdsVar} "" PARENT_SCOPE) + get_target_property(_targetSourceFiles ${_target} SOURCES) + set (_sourceFiles "") + set (_excludedSources "") + set (_cotiredSources "") + cotire_filter_language_source_files(${_language} ${_target} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) + if (NOT _sourceFiles AND NOT _cotiredSources) + return() + endif() + set (_cmds "") + # check for user provided unity source file list + get_property(_unitySourceFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE_INIT) + if (NOT _unitySourceFiles) + set (_unitySourceFiles ${_sourceFiles} ${_cotiredSources}) + endif() + cotire_generate_target_script( + ${_language} "${_configurations}" ${_target} _targetScript _targetConfigScript ${_unitySourceFiles}) + # set up unity files for parallel compilation + cotire_compute_unity_max_number_of_includes(${_target} _maxIncludes ${_unitySourceFiles}) + cotire_make_unity_source_file_paths(${_language} ${_target} ${_maxIncludes} _unityFiles ${_unitySourceFiles}) + list (LENGTH _unityFiles _numberOfUnityFiles) + if (_numberOfUnityFiles EQUAL 0) + return() + elseif (_numberOfUnityFiles GREATER 1) + cotire_setup_unity_generation_commands( + ${_language} ${_target} "${_targetScript}" "${_targetConfigScript}" "${_unityFiles}" _cmds ${_unitySourceFiles}) + endif() + # set up single unity file for prefix header generation + cotire_make_single_unity_source_file_path(${_language} ${_target} _unityFile) + cotire_setup_unity_generation_commands( + ${_language} ${_target} "${_targetScript}" "${_targetConfigScript}" "${_unityFile}" _cmds ${_unitySourceFiles}) + cotire_make_prefix_file_path(${_language} ${_target} _prefixFile) + # set up prefix header + if (_prefixFile) + # check for user provided prefix header files + get_property(_prefixHeaderFiles TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT) + if (_prefixHeaderFiles) + cotire_setup_prefix_generation_from_provided_command( + ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" _cmds ${_prefixHeaderFiles}) + else() + cotire_setup_prefix_generation_from_unity_command( + ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" "${_unityFile}" _cmds ${_unitySourceFiles}) + endif() + # check if selected language has enough sources at all + list (LENGTH _sourceFiles _numberOfSources) + if (_numberOfSources LESS ${COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES}) + set (_targetUsePCH FALSE) + else() + get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) + endif() + if (_targetUsePCH) + cotire_make_pch_file_path(${_language} ${_target} _pchFile) + if (_pchFile) + # first file in _sourceFiles is passed as the host file + cotire_setup_pch_file_compilation( + ${_language} ${_target} "${_targetConfigScript}" "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) + cotire_setup_pch_file_inclusion( + ${_language} ${_target} ${_wholeTarget} "${_prefixFile}" "${_pchFile}" ${_sourceFiles}) + endif() + elseif (_prefixHeaderFiles) + # user provided prefix header must be included unconditionally + cotire_setup_prefix_file_inclusion(${_language} ${_target} "${_prefixFile}" ${_sourceFiles}) + endif() + endif() + # mark target as cotired for language + set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE "${_unityFiles}") + if (_prefixFile) + set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER "${_prefixFile}") + if (_targetUsePCH AND _pchFile) + set_property(TARGET ${_target} PROPERTY COTIRE_${_language}_PRECOMPILED_HEADER "${_pchFile}") + endif() + endif() + set (${_cmdsVar} ${_cmds} PARENT_SCOPE) +endfunction() + +function (cotire_setup_clean_target _target) + set (_cleanTargetName "${_target}${COTIRE_CLEAN_TARGET_SUFFIX}") + if (NOT TARGET "${_cleanTargetName}") + cotire_set_cmd_to_prologue(_cmds) + get_filename_component(_outputDir "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" ABSOLUTE) + list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "cleanup" "${_outputDir}" "${COTIRE_INTDIR}" "${_target}") + add_custom_target(${_cleanTargetName} + COMMAND ${_cmds} + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + COMMENT "Cleaning up target ${_target} cotire generated files" + VERBATIM) + cotire_init_target("${_cleanTargetName}") + endif() +endfunction() + +function (cotire_setup_pch_target _languages _configurations _target) + if ("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") + # for makefile based generators, we add a custom target to trigger the generation of the cotire related files + set (_dependsFiles "") + foreach (_language ${_languages}) + set (_props COTIRE_${_language}_PREFIX_HEADER COTIRE_${_language}_UNITY_SOURCE) + if (NOT CMAKE_${_language}_COMPILER_ID MATCHES "MSVC|Intel") + # Visual Studio and Intel only create precompiled header as a side effect + list (INSERT _props 0 COTIRE_${_language}_PRECOMPILED_HEADER) + endif() + cotire_get_first_set_property_value(_dependsFile TARGET ${_target} ${_props}) + if (_dependsFile) + list (APPEND _dependsFiles "${_dependsFile}") + endif() + endforeach() + if (_dependsFiles) + set (_pchTargetName "${_target}${COTIRE_PCH_TARGET_SUFFIX}") + add_custom_target("${_pchTargetName}" DEPENDS ${_dependsFiles}) + cotire_init_target("${_pchTargetName}") + cotire_add_to_pch_all_target(${_pchTargetName}) + endif() + else() + # for other generators, we add the "clean all" target to clean up the precompiled header + cotire_setup_clean_all_target() + endif() +endfunction() + +function (cotire_filter_object_libraries _target _objectLibrariesVar) + set (_objectLibraries "") + foreach (_source ${ARGN}) + if (_source MATCHES "^\\$$") + list (APPEND _objectLibraries "${_source}") + endif() + endforeach() + set (${_objectLibrariesVar} ${_objectLibraries} PARENT_SCOPE) +endfunction() + +function (cotire_collect_unity_target_sources _target _languages _unityTargetSourcesVar) + get_target_property(_targetSourceFiles ${_target} SOURCES) + set (_unityTargetSources ${_targetSourceFiles}) + foreach (_language ${_languages}) + get_property(_unityFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE) + if (_unityFiles) + # remove source files that are included in the unity source + set (_sourceFiles "") + set (_excludedSources "") + set (_cotiredSources "") + cotire_filter_language_source_files(${_language} ${_target} _sourceFiles _excludedSources _cotiredSources ${_targetSourceFiles}) + if (_sourceFiles OR _cotiredSources) + list (REMOVE_ITEM _unityTargetSources ${_sourceFiles} ${_cotiredSources}) + endif() + # add unity source files instead + list (APPEND _unityTargetSources ${_unityFiles}) + endif() + endforeach() + get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT) + if ("${_linkLibrariesStrategy}" MATCHES "^COPY_UNITY$") + cotire_filter_object_libraries(${_target} _objectLibraries ${_targetSourceFiles}) + if (_objectLibraries) + cotire_map_libraries("${_linkLibrariesStrategy}" _unityObjectLibraries ${_objectLibraries}) + list (REMOVE_ITEM _unityTargetSources ${_objectLibraries}) + list (APPEND _unityTargetSources ${_unityObjectLibraries}) + endif() + endif() + set (${_unityTargetSourcesVar} ${_unityTargetSources} PARENT_SCOPE) +endfunction() + +function (cotire_setup_unity_target_pch_usage _languages _target) + foreach (_language ${_languages}) + get_property(_unityFiles TARGET ${_target} PROPERTY COTIRE_${_language}_UNITY_SOURCE) + if (_unityFiles) + get_property(_userPrefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER_INIT) + get_property(_prefixFile TARGET ${_target} PROPERTY COTIRE_${_language}_PREFIX_HEADER) + if (_userPrefixFile AND _prefixFile) + # user provided prefix header must be included unconditionally by unity sources + cotire_setup_prefix_file_inclusion(${_language} ${_target} "${_prefixFile}" ${_unityFiles}) + endif() + endif() + endforeach() +endfunction() + +function (cotire_setup_unity_build_target _languages _configurations _target) + get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) + if (NOT _unityTargetName) + set (_unityTargetName "${_target}${COTIRE_UNITY_BUILD_TARGET_SUFFIX}") + endif() + # determine unity target sub type + get_target_property(_targetType ${_target} TYPE) + if ("${_targetType}" STREQUAL "EXECUTABLE") + set (_unityTargetSubType "") + elseif (_targetType MATCHES "(STATIC|SHARED|MODULE|OBJECT)_LIBRARY") + set (_unityTargetSubType "${CMAKE_MATCH_1}") + else() + message (WARNING "cotire: target ${_target} has unknown target type ${_targetType}.") + return() + endif() + # determine unity target sources + set (_unityTargetSources "") + cotire_collect_unity_target_sources(${_target} "${_languages}" _unityTargetSources) + # handle automatic Qt processing + get_target_property(_targetAutoMoc ${_target} AUTOMOC) + get_target_property(_targetAutoUic ${_target} AUTOUIC) + get_target_property(_targetAutoRcc ${_target} AUTORCC) + if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) + # if the original target sources are subject to CMake's automatic Qt processing, + # also include implicitly generated _automoc.cpp file + if (CMAKE_VERSION VERSION_LESS "3.8.0") + list (APPEND _unityTargetSources "${_target}_automoc.cpp") + set_property (SOURCE "${_target}_automoc.cpp" PROPERTY GENERATED TRUE) + else() + list (APPEND _unityTargetSources "${_target}_autogen/moc_compilation.cpp") + set_property (SOURCE "${_target}_autogen/moc_compilation.cpp" PROPERTY GENERATED TRUE) + endif() + endif() + # prevent AUTOMOC, AUTOUIC and AUTORCC properties from being set when the unity target is created + set (CMAKE_AUTOMOC OFF) + set (CMAKE_AUTOUIC OFF) + set (CMAKE_AUTORCC OFF) + if (COTIRE_DEBUG) + message (STATUS "add target ${_targetType} ${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}") + endif() + # generate unity target + if ("${_targetType}" STREQUAL "EXECUTABLE") + add_executable(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) + else() + add_library(${_unityTargetName} ${_unityTargetSubType} EXCLUDE_FROM_ALL ${_unityTargetSources}) + endif() + if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio") + # depend on original target's automoc target, if it exists + if (TARGET ${_target}_automoc) + add_dependencies(${_unityTargetName} ${_target}_automoc) + endif() + else() + if (_targetAutoMoc OR _targetAutoUic OR _targetAutoRcc) + # depend on the original target's implicity generated _automoc target + if (CMAKE_VERSION VERSION_LESS "3.8.0") + add_dependencies(${_unityTargetName} ${_target}_automoc) + else() + add_dependencies(${_unityTargetName} ${_target}_autogen) + endif() + endif() + endif() + # copy output location properties + set (_outputDirProperties + ARCHIVE_OUTPUT_DIRECTORY ARCHIVE_OUTPUT_DIRECTORY_ + LIBRARY_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY_ + RUNTIME_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY_) + if (COTIRE_UNITY_OUTPUT_DIRECTORY) + set (_setDefaultOutputDir TRUE) + if (IS_ABSOLUTE "${COTIRE_UNITY_OUTPUT_DIRECTORY}") + set (_outputDir "${COTIRE_UNITY_OUTPUT_DIRECTORY}") + else() + # append relative COTIRE_UNITY_OUTPUT_DIRECTORY to target's actual output directory + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} ${_outputDirProperties}) + cotire_resolve_config_properties("${_configurations}" _properties ${_outputDirProperties}) + foreach (_property ${_properties}) + get_property(_outputDir TARGET ${_target} PROPERTY ${_property}) + if (_outputDir) + get_filename_component(_outputDir "${_outputDir}/${COTIRE_UNITY_OUTPUT_DIRECTORY}" ABSOLUTE) + set_property(TARGET ${_unityTargetName} PROPERTY ${_property} "${_outputDir}") + set (_setDefaultOutputDir FALSE) + endif() + endforeach() + if (_setDefaultOutputDir) + get_filename_component(_outputDir "${CMAKE_CURRENT_BINARY_DIR}/${COTIRE_UNITY_OUTPUT_DIRECTORY}" ABSOLUTE) + endif() + endif() + if (_setDefaultOutputDir) + set_target_properties(${_unityTargetName} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${_outputDir}" + LIBRARY_OUTPUT_DIRECTORY "${_outputDir}" + RUNTIME_OUTPUT_DIRECTORY "${_outputDir}") + endif() + else() + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + ${_outputDirProperties}) + endif() + # copy output name + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + ARCHIVE_OUTPUT_NAME ARCHIVE_OUTPUT_NAME_ + LIBRARY_OUTPUT_NAME LIBRARY_OUTPUT_NAME_ + OUTPUT_NAME OUTPUT_NAME_ + RUNTIME_OUTPUT_NAME RUNTIME_OUTPUT_NAME_ + PREFIX _POSTFIX SUFFIX + IMPORT_PREFIX IMPORT_SUFFIX) + # copy compile stuff + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + COMPILE_DEFINITIONS COMPILE_DEFINITIONS_ + COMPILE_FLAGS COMPILE_OPTIONS + Fortran_FORMAT Fortran_MODULE_DIRECTORY + INCLUDE_DIRECTORIES + INTERPROCEDURAL_OPTIMIZATION INTERPROCEDURAL_OPTIMIZATION_ + POSITION_INDEPENDENT_CODE + C_COMPILER_LAUNCHER CXX_COMPILER_LAUNCHER + C_INCLUDE_WHAT_YOU_USE CXX_INCLUDE_WHAT_YOU_USE + C_VISIBILITY_PRESET CXX_VISIBILITY_PRESET VISIBILITY_INLINES_HIDDEN + C_CLANG_TIDY CXX_CLANG_TIDY) + # copy compile features + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + C_EXTENSIONS C_STANDARD C_STANDARD_REQUIRED + CXX_EXTENSIONS CXX_STANDARD CXX_STANDARD_REQUIRED + COMPILE_FEATURES) + # copy interface stuff + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + COMPATIBLE_INTERFACE_BOOL COMPATIBLE_INTERFACE_NUMBER_MAX COMPATIBLE_INTERFACE_NUMBER_MIN + COMPATIBLE_INTERFACE_STRING + INTERFACE_COMPILE_DEFINITIONS INTERFACE_COMPILE_FEATURES INTERFACE_COMPILE_OPTIONS + INTERFACE_INCLUDE_DIRECTORIES INTERFACE_SOURCES + INTERFACE_POSITION_INDEPENDENT_CODE INTERFACE_SYSTEM_INCLUDE_DIRECTORIES + INTERFACE_AUTOUIC_OPTIONS NO_SYSTEM_FROM_IMPORTED) + # copy link stuff + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + BUILD_WITH_INSTALL_RPATH INSTALL_RPATH INSTALL_RPATH_USE_LINK_PATH SKIP_BUILD_RPATH + LINKER_LANGUAGE LINK_DEPENDS LINK_DEPENDS_NO_SHARED + LINK_FLAGS LINK_FLAGS_ + LINK_INTERFACE_LIBRARIES LINK_INTERFACE_LIBRARIES_ + LINK_INTERFACE_MULTIPLICITY LINK_INTERFACE_MULTIPLICITY_ + LINK_SEARCH_START_STATIC LINK_SEARCH_END_STATIC + STATIC_LIBRARY_FLAGS STATIC_LIBRARY_FLAGS_ + NO_SONAME SOVERSION VERSION + LINK_WHAT_YOU_USE BUILD_RPATH) + # copy cmake stuff + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + IMPLICIT_DEPENDS_INCLUDE_TRANSFORM RULE_LAUNCH_COMPILE RULE_LAUNCH_CUSTOM RULE_LAUNCH_LINK) + # copy Apple platform specific stuff + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + BUNDLE BUNDLE_EXTENSION FRAMEWORK FRAMEWORK_VERSION INSTALL_NAME_DIR + MACOSX_BUNDLE MACOSX_BUNDLE_INFO_PLIST MACOSX_FRAMEWORK_INFO_PLIST MACOSX_RPATH + OSX_ARCHITECTURES OSX_ARCHITECTURES_ PRIVATE_HEADER PUBLIC_HEADER RESOURCE XCTEST + IOS_INSTALL_COMBINED XCODE_EXPLICIT_FILE_TYPE XCODE_PRODUCT_TYPE) + # copy Windows platform specific stuff + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + GNUtoMS + COMPILE_PDB_NAME COMPILE_PDB_NAME_ + COMPILE_PDB_OUTPUT_DIRECTORY COMPILE_PDB_OUTPUT_DIRECTORY_ + PDB_NAME PDB_NAME_ PDB_OUTPUT_DIRECTORY PDB_OUTPUT_DIRECTORY_ + VS_DESKTOP_EXTENSIONS_VERSION VS_DOTNET_REFERENCES VS_DOTNET_TARGET_FRAMEWORK_VERSION + VS_GLOBAL_KEYWORD VS_GLOBAL_PROJECT_TYPES VS_GLOBAL_ROOTNAMESPACE + VS_IOT_EXTENSIONS_VERSION VS_IOT_STARTUP_TASK + VS_KEYWORD VS_MOBILE_EXTENSIONS_VERSION + VS_SCC_AUXPATH VS_SCC_LOCALPATH VS_SCC_PROJECTNAME VS_SCC_PROVIDER + VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION + VS_WINRT_COMPONENT VS_WINRT_EXTENSIONS VS_WINRT_REFERENCES + WIN32_EXECUTABLE WINDOWS_EXPORT_ALL_SYMBOLS + DEPLOYMENT_REMOTE_DIRECTORY VS_CONFIGURATION_TYPE + VS_SDK_REFERENCES VS_USER_PROPS VS_DEBUGGER_WORKING_DIRECTORY) + # copy Android platform specific stuff + cotire_copy_set_properties("${_configurations}" TARGET ${_target} ${_unityTargetName} + ANDROID_API ANDROID_API_MIN ANDROID_GUI + ANDROID_ANT_ADDITIONAL_OPTIONS ANDROID_ARCH ANDROID_ASSETS_DIRECTORIES + ANDROID_JAR_DEPENDENCIES ANDROID_JAR_DIRECTORIES ANDROID_JAVA_SOURCE_DIR + ANDROID_NATIVE_LIB_DEPENDENCIES ANDROID_NATIVE_LIB_DIRECTORIES + ANDROID_PROCESS_MAX ANDROID_PROGUARD ANDROID_PROGUARD_CONFIG_PATH + ANDROID_SECURE_PROPS_PATH ANDROID_SKIP_ANT_STEP ANDROID_STL_TYPE) + # use output name from original target + get_target_property(_targetOutputName ${_unityTargetName} OUTPUT_NAME) + if (NOT _targetOutputName) + set_property(TARGET ${_unityTargetName} PROPERTY OUTPUT_NAME "${_target}") + endif() + # use export symbol from original target + cotire_get_target_export_symbol("${_target}" _defineSymbol) + if (_defineSymbol) + set_property(TARGET ${_unityTargetName} PROPERTY DEFINE_SYMBOL "${_defineSymbol}") + if ("${_targetType}" STREQUAL "EXECUTABLE") + set_property(TARGET ${_unityTargetName} PROPERTY ENABLE_EXPORTS TRUE) + endif() + endif() + cotire_init_target(${_unityTargetName}) + cotire_add_to_unity_all_target(${_unityTargetName}) + set_property(TARGET ${_target} PROPERTY COTIRE_UNITY_TARGET_NAME "${_unityTargetName}") +endfunction(cotire_setup_unity_build_target) + +function (cotire_target _target) + set(_options "") + set(_oneValueArgs "") + set(_multiValueArgs LANGUAGES CONFIGURATIONS) + cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + if (NOT _option_LANGUAGES) + get_property (_option_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) + endif() + if (NOT _option_CONFIGURATIONS) + cotire_get_configuration_types(_option_CONFIGURATIONS) + endif() + # check if cotire can be applied to target at all + cotire_is_target_supported(${_target} _isSupported) + if (NOT _isSupported) + get_target_property(_imported ${_target} IMPORTED) + get_target_property(_targetType ${_target} TYPE) + if (_imported) + message (WARNING "cotire: imported ${_targetType} target ${_target} cannot be cotired.") + else() + message (STATUS "cotire: ${_targetType} target ${_target} cannot be cotired.") + endif() + return() + endif() + # resolve alias + get_target_property(_aliasName ${_target} ALIASED_TARGET) + if (_aliasName) + if (COTIRE_DEBUG) + message (STATUS "${_target} is an alias. Applying cotire to aliased target ${_aliasName} instead.") + endif() + set (_target ${_aliasName}) + endif() + # check if target needs to be cotired for build type + # when using configuration types, the test is performed at build time + cotire_init_cotire_target_properties(${_target}) + if (NOT CMAKE_CONFIGURATION_TYPES) + if (CMAKE_BUILD_TYPE) + list (FIND _option_CONFIGURATIONS "${CMAKE_BUILD_TYPE}" _index) + else() + list (FIND _option_CONFIGURATIONS "None" _index) + endif() + if (_index EQUAL -1) + if (COTIRE_DEBUG) + message (STATUS "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} not cotired (${_option_CONFIGURATIONS})") + endif() + return() + endif() + endif() + # when not using configuration types, immediately create cotire intermediate dir + if (NOT CMAKE_CONFIGURATION_TYPES) + cotire_get_intermediate_dir(_baseDir) + file (MAKE_DIRECTORY "${_baseDir}") + endif() + # choose languages that apply to the target + cotire_choose_target_languages("${_target}" _targetLanguages _wholeTarget ${_option_LANGUAGES}) + if (NOT _targetLanguages) + return() + endif() + set (_cmds "") + foreach (_language ${_targetLanguages}) + cotire_process_target_language("${_language}" "${_option_CONFIGURATIONS}" ${_target} ${_wholeTarget} _cmd) + if (_cmd) + list (APPEND _cmds ${_cmd}) + endif() + endforeach() + get_target_property(_targetAddSCU ${_target} COTIRE_ADD_UNITY_BUILD) + if (_targetAddSCU) + cotire_setup_unity_build_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" ${_target}) + endif() + get_target_property(_targetUsePCH ${_target} COTIRE_ENABLE_PRECOMPILED_HEADER) + if (_targetUsePCH) + cotire_setup_target_pch_usage("${_targetLanguages}" ${_target} ${_wholeTarget} ${_cmds}) + cotire_setup_pch_target("${_targetLanguages}" "${_option_CONFIGURATIONS}" ${_target}) + if (_targetAddSCU) + cotire_setup_unity_target_pch_usage("${_targetLanguages}" ${_target}) + endif() + endif() + get_target_property(_targetAddCleanTarget ${_target} COTIRE_ADD_CLEAN) + if (_targetAddCleanTarget) + cotire_setup_clean_target(${_target}) + endif() +endfunction(cotire_target) + +function (cotire_map_libraries _strategy _mappedLibrariesVar) + set (_mappedLibraries "") + foreach (_library ${ARGN}) + if (_library MATCHES "^\\$$") + set (_libraryName "${CMAKE_MATCH_1}") + set (_linkOnly TRUE) + set (_objectLibrary FALSE) + elseif (_library MATCHES "^\\$$") + set (_libraryName "${CMAKE_MATCH_1}") + set (_linkOnly FALSE) + set (_objectLibrary TRUE) + else() + set (_libraryName "${_library}") + set (_linkOnly FALSE) + set (_objectLibrary FALSE) + endif() + if ("${_strategy}" MATCHES "COPY_UNITY") + cotire_is_target_supported(${_libraryName} _isSupported) + if (_isSupported) + # use target's corresponding unity target, if available + get_target_property(_libraryUnityTargetName ${_libraryName} COTIRE_UNITY_TARGET_NAME) + if (TARGET "${_libraryUnityTargetName}") + if (_linkOnly) + list (APPEND _mappedLibraries "$") + elseif (_objectLibrary) + list (APPEND _mappedLibraries "$") + else() + list (APPEND _mappedLibraries "${_libraryUnityTargetName}") + endif() + else() + list (APPEND _mappedLibraries "${_library}") + endif() + else() + list (APPEND _mappedLibraries "${_library}") + endif() + else() + list (APPEND _mappedLibraries "${_library}") + endif() + endforeach() + list (REMOVE_DUPLICATES _mappedLibraries) + set (${_mappedLibrariesVar} ${_mappedLibraries} PARENT_SCOPE) +endfunction() + +function (cotire_target_link_libraries _target) + cotire_is_target_supported(${_target} _isSupported) + if (NOT _isSupported) + return() + endif() + get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME) + if (TARGET "${_unityTargetName}") + get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT) + if (COTIRE_DEBUG) + message (STATUS "unity target ${_unityTargetName} link strategy: ${_linkLibrariesStrategy}") + endif() + if ("${_linkLibrariesStrategy}" MATCHES "^(COPY|COPY_UNITY)$") + get_target_property(_linkLibraries ${_target} LINK_LIBRARIES) + if (_linkLibraries) + cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkLibraries ${_linkLibraries}) + set_target_properties(${_unityTargetName} PROPERTIES LINK_LIBRARIES "${_unityLinkLibraries}") + if (COTIRE_DEBUG) + message (STATUS "unity target ${_unityTargetName} link libraries: ${_unityLinkLibraries}") + endif() + endif() + get_target_property(_interfaceLinkLibraries ${_target} INTERFACE_LINK_LIBRARIES) + if (_interfaceLinkLibraries) + cotire_map_libraries("${_linkLibrariesStrategy}" _unityLinkInterfaceLibraries ${_interfaceLinkLibraries}) + set_target_properties(${_unityTargetName} PROPERTIES INTERFACE_LINK_LIBRARIES "${_unityLinkInterfaceLibraries}") + if (COTIRE_DEBUG) + message (STATUS "unity target ${_unityTargetName} interface link libraries: ${_unityLinkInterfaceLibraries}") + endif() + endif() + endif() + endif() +endfunction(cotire_target_link_libraries) + +function (cotire_cleanup _binaryDir _cotireIntermediateDirName _targetName) + if (_targetName) + file (GLOB_RECURSE _cotireFiles "${_binaryDir}/${_targetName}*.*") + else() + file (GLOB_RECURSE _cotireFiles "${_binaryDir}/*.*") + endif() + # filter files in intermediate directory + set (_filesToRemove "") + foreach (_file ${_cotireFiles}) + get_filename_component(_dir "${_file}" DIRECTORY) + get_filename_component(_dirName "${_dir}" NAME) + if ("${_dirName}" STREQUAL "${_cotireIntermediateDirName}") + list (APPEND _filesToRemove "${_file}") + endif() + endforeach() + if (_filesToRemove) + if (COTIRE_VERBOSE) + message (STATUS "cleaning up ${_filesToRemove}") + endif() + file (REMOVE ${_filesToRemove}) + endif() +endfunction() + +function (cotire_init_target _targetName) + if (COTIRE_TARGETS_FOLDER) + set_target_properties(${_targetName} PROPERTIES FOLDER "${COTIRE_TARGETS_FOLDER}") + endif() + set_target_properties(${_targetName} PROPERTIES EXCLUDE_FROM_ALL TRUE) + if (MSVC_IDE) + set_target_properties(${_targetName} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE) + endif() +endfunction() + +function (cotire_add_to_pch_all_target _pchTargetName) + set (_targetName "${COTIRE_PCH_ALL_TARGET_NAME}") + if (NOT TARGET "${_targetName}") + add_custom_target("${_targetName}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + VERBATIM) + cotire_init_target("${_targetName}") + endif() + cotire_setup_clean_all_target() + add_dependencies(${_targetName} ${_pchTargetName}) +endfunction() + +function (cotire_add_to_unity_all_target _unityTargetName) + set (_targetName "${COTIRE_UNITY_BUILD_ALL_TARGET_NAME}") + if (NOT TARGET "${_targetName}") + add_custom_target("${_targetName}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + VERBATIM) + cotire_init_target("${_targetName}") + endif() + cotire_setup_clean_all_target() + add_dependencies(${_targetName} ${_unityTargetName}) +endfunction() + +function (cotire_setup_clean_all_target) + set (_targetName "${COTIRE_CLEAN_ALL_TARGET_NAME}") + if (NOT TARGET "${_targetName}") + cotire_set_cmd_to_prologue(_cmds) + list (APPEND _cmds -P "${COTIRE_CMAKE_MODULE_FILE}" "cleanup" "${CMAKE_BINARY_DIR}" "${COTIRE_INTDIR}") + add_custom_target(${_targetName} + COMMAND ${_cmds} + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + COMMENT "Cleaning up all cotire generated files" + VERBATIM) + cotire_init_target("${_targetName}") + endif() +endfunction() + +function (cotire) + set(_options "") + set(_oneValueArgs "") + set(_multiValueArgs LANGUAGES CONFIGURATIONS) + cmake_parse_arguments(_option "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + set (_targets ${_option_UNPARSED_ARGUMENTS}) + foreach (_target ${_targets}) + if (TARGET ${_target}) + cotire_target(${_target} LANGUAGES ${_option_LANGUAGES} CONFIGURATIONS ${_option_CONFIGURATIONS}) + else() + message (WARNING "cotire: ${_target} is not a target.") + endif() + endforeach() + foreach (_target ${_targets}) + if (TARGET ${_target}) + cotire_target_link_libraries(${_target}) + endif() + endforeach() +endfunction() + +if (CMAKE_SCRIPT_MODE_FILE) + + # cotire is being run in script mode + # locate -P on command args + set (COTIRE_ARGC -1) + foreach (_index RANGE ${CMAKE_ARGC}) + if (COTIRE_ARGC GREATER -1) + set (COTIRE_ARGV${COTIRE_ARGC} "${CMAKE_ARGV${_index}}") + math (EXPR COTIRE_ARGC "${COTIRE_ARGC} + 1") + elseif ("${CMAKE_ARGV${_index}}" STREQUAL "-P") + set (COTIRE_ARGC 0) + endif() + endforeach() + + # include target script if available + if ("${COTIRE_ARGV2}" MATCHES "\\.cmake$") + # the included target scripts sets up additional variables relating to the target (e.g., COTIRE_TARGET_SOURCES) + include("${COTIRE_ARGV2}") + endif() + + if (COTIRE_DEBUG) + message (STATUS "${COTIRE_ARGV0} ${COTIRE_ARGV1} ${COTIRE_ARGV2} ${COTIRE_ARGV3} ${COTIRE_ARGV4} ${COTIRE_ARGV5}") + endif() + + if (NOT COTIRE_BUILD_TYPE) + set (COTIRE_BUILD_TYPE "None") + endif() + string (TOUPPER "${COTIRE_BUILD_TYPE}" _upperConfig) + set (_includeDirs ${COTIRE_TARGET_INCLUDE_DIRECTORIES_${_upperConfig}}) + set (_systemIncludeDirs ${COTIRE_TARGET_SYSTEM_INCLUDE_DIRECTORIES_${_upperConfig}}) + set (_compileDefinitions ${COTIRE_TARGET_COMPILE_DEFINITIONS_${_upperConfig}}) + set (_compileFlags ${COTIRE_TARGET_COMPILE_FLAGS_${_upperConfig}}) + # check if target has been cotired for actual build type COTIRE_BUILD_TYPE + list (FIND COTIRE_TARGET_CONFIGURATION_TYPES "${COTIRE_BUILD_TYPE}" _index) + if (_index GREATER -1) + set (_sources ${COTIRE_TARGET_SOURCES}) + set (_sourcesDefinitions ${COTIRE_TARGET_SOURCES_COMPILE_DEFINITIONS_${_upperConfig}}) + else() + if (COTIRE_DEBUG) + message (STATUS "COTIRE_BUILD_TYPE=${COTIRE_BUILD_TYPE} not cotired (${COTIRE_TARGET_CONFIGURATION_TYPES})") + endif() + set (_sources "") + set (_sourcesDefinitions "") + endif() + set (_targetPreUndefs ${COTIRE_TARGET_PRE_UNDEFS}) + set (_targetPostUndefs ${COTIRE_TARGET_POST_UNDEFS}) + set (_sourcesPreUndefs ${COTIRE_TARGET_SOURCES_PRE_UNDEFS}) + set (_sourcesPostUndefs ${COTIRE_TARGET_SOURCES_POST_UNDEFS}) + + if ("${COTIRE_ARGV1}" STREQUAL "unity") + + if (XCODE) + # executing pre-build action under Xcode, check dependency on target script + set (_dependsOption DEPENDS "${COTIRE_ARGV2}") + else() + # executing custom command, no need to re-check for dependencies + set (_dependsOption "") + endif() + + cotire_select_unity_source_files("${COTIRE_ARGV3}" _sources ${_sources}) + + cotire_generate_unity_source( + "${COTIRE_ARGV3}" ${_sources} + LANGUAGE "${COTIRE_TARGET_LANGUAGE}" + SOURCES_COMPILE_DEFINITIONS ${_sourcesDefinitions} + PRE_UNDEFS ${_targetPreUndefs} + POST_UNDEFS ${_targetPostUndefs} + SOURCES_PRE_UNDEFS ${_sourcesPreUndefs} + SOURCES_POST_UNDEFS ${_sourcesPostUndefs} + ${_dependsOption}) + + elseif ("${COTIRE_ARGV1}" STREQUAL "prefix") + + if (XCODE) + # executing pre-build action under Xcode, check dependency on unity file and prefix dependencies + set (_dependsOption DEPENDS "${COTIRE_ARGV4}" ${COTIRE_TARGET_PREFIX_DEPENDS}) + else() + # executing custom command, no need to re-check for dependencies + set (_dependsOption "") + endif() + + set (_files "") + foreach (_index RANGE 4 ${COTIRE_ARGC}) + if (COTIRE_ARGV${_index}) + list (APPEND _files "${COTIRE_ARGV${_index}}") + endif() + endforeach() + + cotire_generate_prefix_header( + "${COTIRE_ARGV3}" ${_files} + COMPILER_LAUNCHER "${COTIRE_TARGET_${COTIRE_TARGET_LANGUAGE}_COMPILER_LAUNCHER}" + COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}" + COMPILER_ARG1 ${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ARG1} + COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" + COMPILER_VERSION "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" + LANGUAGE "${COTIRE_TARGET_LANGUAGE}" + IGNORE_PATH "${COTIRE_TARGET_IGNORE_PATH};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH}" + INCLUDE_PATH ${COTIRE_TARGET_INCLUDE_PATH} + IGNORE_EXTENSIONS "${CMAKE_${COTIRE_TARGET_LANGUAGE}_SOURCE_FILE_EXTENSIONS};${COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS}" + INCLUDE_PRIORITY_PATH ${COTIRE_TARGET_INCLUDE_PRIORITY_PATH} + INCLUDE_DIRECTORIES ${_includeDirs} + SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs} + COMPILE_DEFINITIONS ${_compileDefinitions} + COMPILE_FLAGS ${_compileFlags} + ${_dependsOption}) + + elseif ("${COTIRE_ARGV1}" STREQUAL "precompile") + + set (_files "") + foreach (_index RANGE 5 ${COTIRE_ARGC}) + if (COTIRE_ARGV${_index}) + list (APPEND _files "${COTIRE_ARGV${_index}}") + endif() + endforeach() + + cotire_precompile_prefix_header( + "${COTIRE_ARGV3}" "${COTIRE_ARGV4}" "${COTIRE_ARGV5}" + COMPILER_LAUNCHER "${COTIRE_TARGET_${COTIRE_TARGET_LANGUAGE}_COMPILER_LAUNCHER}" + COMPILER_EXECUTABLE "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER}" + COMPILER_ARG1 ${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ARG1} + COMPILER_ID "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_ID}" + COMPILER_VERSION "${CMAKE_${COTIRE_TARGET_LANGUAGE}_COMPILER_VERSION}" + LANGUAGE "${COTIRE_TARGET_LANGUAGE}" + INCLUDE_DIRECTORIES ${_includeDirs} + SYSTEM_INCLUDE_DIRECTORIES ${_systemIncludeDirs} + COMPILE_DEFINITIONS ${_compileDefinitions} + COMPILE_FLAGS ${_compileFlags}) + + elseif ("${COTIRE_ARGV1}" STREQUAL "combine") + + if (COTIRE_TARGET_LANGUAGE) + set (_combinedFile "${COTIRE_ARGV3}") + set (_startIndex 4) + else() + set (_combinedFile "${COTIRE_ARGV2}") + set (_startIndex 3) + endif() + set (_files "") + foreach (_index RANGE ${_startIndex} ${COTIRE_ARGC}) + if (COTIRE_ARGV${_index}) + list (APPEND _files "${COTIRE_ARGV${_index}}") + endif() + endforeach() + + if (XCODE) + # executing pre-build action under Xcode, check dependency on files to be combined + set (_dependsOption DEPENDS ${_files}) + else() + # executing custom command, no need to re-check for dependencies + set (_dependsOption "") + endif() + + if (COTIRE_TARGET_LANGUAGE) + cotire_generate_unity_source( + "${_combinedFile}" ${_files} + LANGUAGE "${COTIRE_TARGET_LANGUAGE}" + ${_dependsOption}) + else() + cotire_generate_unity_source("${_combinedFile}" ${_files} ${_dependsOption}) + endif() + + elseif ("${COTIRE_ARGV1}" STREQUAL "cleanup") + + cotire_cleanup("${COTIRE_ARGV2}" "${COTIRE_ARGV3}" "${COTIRE_ARGV4}") + + else() + message (FATAL_ERROR "cotire: unknown command \"${COTIRE_ARGV1}\".") + endif() + +else() + + # cotire is being run in include mode + # set up all variable and property definitions + + if (NOT DEFINED COTIRE_DEBUG_INIT) + if (DEFINED COTIRE_DEBUG) + set (COTIRE_DEBUG_INIT ${COTIRE_DEBUG}) + else() + set (COTIRE_DEBUG_INIT FALSE) + endif() + endif() + option (COTIRE_DEBUG "Enable cotire debugging output?" ${COTIRE_DEBUG_INIT}) + + if (NOT DEFINED COTIRE_VERBOSE_INIT) + if (DEFINED COTIRE_VERBOSE) + set (COTIRE_VERBOSE_INIT ${COTIRE_VERBOSE}) + else() + set (COTIRE_VERBOSE_INIT FALSE) + endif() + endif() + option (COTIRE_VERBOSE "Enable cotire verbose output?" ${COTIRE_VERBOSE_INIT}) + + set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS "inc;inl;ipp" CACHE STRING + "Ignore headers with the listed file extensions from the generated prefix header.") + + set (COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH "" CACHE STRING + "Ignore headers from these directories when generating the prefix header.") + + set (COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS "m;mm" CACHE STRING + "Ignore sources with the listed file extensions from the generated unity source.") + + set (COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES "3" CACHE STRING + "Minimum number of sources in target required to enable use of precompiled header.") + + if (NOT DEFINED COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT) + if (DEFINED COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES) + set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT ${COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES}) + elseif ("${CMAKE_GENERATOR}" MATCHES "JOM|Ninja|Visual Studio") + # enable parallelization for generators that run multiple jobs by default + set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT "-j") + else() + set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT "0") + endif() + endif() + set (COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES "${COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES_INIT}" CACHE STRING + "Maximum number of source files to include in a single unity source file.") + + if (NOT COTIRE_PREFIX_HEADER_FILENAME_SUFFIX) + set (COTIRE_PREFIX_HEADER_FILENAME_SUFFIX "_prefix") + endif() + if (NOT COTIRE_UNITY_SOURCE_FILENAME_SUFFIX) + set (COTIRE_UNITY_SOURCE_FILENAME_SUFFIX "_unity") + endif() + if (NOT COTIRE_INTDIR) + set (COTIRE_INTDIR "cotire") + endif() + if (NOT COTIRE_PCH_ALL_TARGET_NAME) + set (COTIRE_PCH_ALL_TARGET_NAME "all_pch") + endif() + if (NOT COTIRE_UNITY_BUILD_ALL_TARGET_NAME) + set (COTIRE_UNITY_BUILD_ALL_TARGET_NAME "all_unity") + endif() + if (NOT COTIRE_CLEAN_ALL_TARGET_NAME) + set (COTIRE_CLEAN_ALL_TARGET_NAME "clean_cotire") + endif() + if (NOT COTIRE_CLEAN_TARGET_SUFFIX) + set (COTIRE_CLEAN_TARGET_SUFFIX "_clean_cotire") + endif() + if (NOT COTIRE_PCH_TARGET_SUFFIX) + set (COTIRE_PCH_TARGET_SUFFIX "_pch") + endif() + if (MSVC) + # MSVC default PCH memory scaling factor of 100 percent (75 MB) is too small for template heavy C++ code + # use a bigger default factor of 170 percent (128 MB) + if (NOT DEFINED COTIRE_PCH_MEMORY_SCALING_FACTOR) + set (COTIRE_PCH_MEMORY_SCALING_FACTOR "170") + endif() + endif() + if (NOT COTIRE_UNITY_BUILD_TARGET_SUFFIX) + set (COTIRE_UNITY_BUILD_TARGET_SUFFIX "_unity") + endif() + if (NOT DEFINED COTIRE_TARGETS_FOLDER) + set (COTIRE_TARGETS_FOLDER "cotire") + endif() + if (NOT DEFINED COTIRE_UNITY_OUTPUT_DIRECTORY) + if ("${CMAKE_GENERATOR}" MATCHES "Ninja") + # generated Ninja build files do not work if the unity target produces the same output file as the cotired target + set (COTIRE_UNITY_OUTPUT_DIRECTORY "unity") + else() + set (COTIRE_UNITY_OUTPUT_DIRECTORY "") + endif() + endif() + + # define cotire cache variables + + define_property( + CACHED_VARIABLE PROPERTY "COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_PATH" + BRIEF_DOCS "Ignore headers from these directories when generating the prefix header." + FULL_DOCS + "The variable can be set to a semicolon separated list of include directories." + "If a header file is found in one of these directories or sub-directories, it will be excluded from the generated prefix header." + "If not defined, defaults to empty list." + ) + + define_property( + CACHED_VARIABLE PROPERTY "COTIRE_ADDITIONAL_PREFIX_HEADER_IGNORE_EXTENSIONS" + BRIEF_DOCS "Ignore includes with the listed file extensions from the generated prefix header." + FULL_DOCS + "The variable can be set to a semicolon separated list of file extensions." + "If a header file extension matches one in the list, it will be excluded from the generated prefix header." + "Includes with an extension in CMAKE__SOURCE_FILE_EXTENSIONS are always ignored." + "If not defined, defaults to inc;inl;ipp." + ) + + define_property( + CACHED_VARIABLE PROPERTY "COTIRE_UNITY_SOURCE_EXCLUDE_EXTENSIONS" + BRIEF_DOCS "Exclude sources with the listed file extensions from the generated unity source." + FULL_DOCS + "The variable can be set to a semicolon separated list of file extensions." + "If a source file extension matches one in the list, it will be excluded from the generated unity source file." + "Source files with an extension in CMAKE__IGNORE_EXTENSIONS are always excluded." + "If not defined, defaults to m;mm." + ) + + define_property( + CACHED_VARIABLE PROPERTY "COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES" + BRIEF_DOCS "Minimum number of sources in target required to enable use of precompiled header." + FULL_DOCS + "The variable can be set to an integer > 0." + "If a target contains less than that number of source files, cotire will not enable the use of the precompiled header for the target." + "If not defined, defaults to 3." + ) + + define_property( + CACHED_VARIABLE PROPERTY "COTIRE_MAXIMUM_NUMBER_OF_UNITY_INCLUDES" + BRIEF_DOCS "Maximum number of source files to include in a single unity source file." + FULL_DOCS + "This may be set to an integer >= 0." + "If 0, cotire will only create a single unity source file." + "If a target contains more than that number of source files, cotire will create multiple unity source files for it." + "Can be set to \"-j\" to optimize the count of unity source files for the number of available processor cores." + "Can be set to \"-j jobs\" to optimize the number of unity source files for the given number of simultaneous jobs." + "Is used to initialize the target property COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES." + "Defaults to \"-j\" for the generators Visual Studio, JOM or Ninja. Defaults to 0 otherwise." + ) + + # define cotire directory properties + + define_property( + DIRECTORY PROPERTY "COTIRE_ENABLE_PRECOMPILED_HEADER" + BRIEF_DOCS "Modify build command of cotired targets added in this directory to make use of the generated precompiled header." + FULL_DOCS + "See target property COTIRE_ENABLE_PRECOMPILED_HEADER." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_ADD_UNITY_BUILD" + BRIEF_DOCS "Add a new target that performs a unity build for cotired targets added in this directory." + FULL_DOCS + "See target property COTIRE_ADD_UNITY_BUILD." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_ADD_CLEAN" + BRIEF_DOCS "Add a new target that cleans all cotire generated files for cotired targets added in this directory." + FULL_DOCS + "See target property COTIRE_ADD_CLEAN." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_PREFIX_HEADER_IGNORE_PATH" + BRIEF_DOCS "Ignore headers from these directories when generating the prefix header." + FULL_DOCS + "See target property COTIRE_PREFIX_HEADER_IGNORE_PATH." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PATH" + BRIEF_DOCS "Honor headers from these directories when generating the prefix header." + FULL_DOCS + "See target property COTIRE_PREFIX_HEADER_INCLUDE_PATH." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH" + BRIEF_DOCS "Header paths matching one of these directories are put at the top of the prefix header." + FULL_DOCS + "See target property COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" + BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of each source file." + FULL_DOCS + "See target property COTIRE_UNITY_SOURCE_PRE_UNDEFS." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_POST_UNDEFS" + BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file after the inclusion of each source file." + FULL_DOCS + "See target property COTIRE_UNITY_SOURCE_POST_UNDEFS." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES" + BRIEF_DOCS "Maximum number of source files to include in a single unity source file." + FULL_DOCS + "See target property COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES." + ) + + define_property( + DIRECTORY PROPERTY "COTIRE_UNITY_LINK_LIBRARIES_INIT" + BRIEF_DOCS "Define strategy for setting up the unity target's link libraries." + FULL_DOCS + "See target property COTIRE_UNITY_LINK_LIBRARIES_INIT." + ) + + # define cotire target properties + + define_property( + TARGET PROPERTY "COTIRE_ENABLE_PRECOMPILED_HEADER" INHERITED + BRIEF_DOCS "Modify this target's build command to make use of the generated precompiled header." + FULL_DOCS + "If this property is set to TRUE, cotire will modify the build command to make use of the generated precompiled header." + "Irrespective of the value of this property, cotire will setup custom commands to generate the unity source and prefix header for the target." + "For makefile based generators cotire will also set up a custom target to manually invoke the generation of the precompiled header." + "The target name will be set to this target's name with the suffix _pch appended." + "Inherited from directory." + "Defaults to TRUE." + ) + + define_property( + TARGET PROPERTY "COTIRE_ADD_UNITY_BUILD" INHERITED + BRIEF_DOCS "Add a new target that performs a unity build for this target." + FULL_DOCS + "If this property is set to TRUE, cotire creates a new target of the same type that uses the generated unity source file instead of the target sources." + "Most of the relevant target properties will be copied from this target to the new unity build target." + "Target dependencies and linked libraries have to be manually set up for the new unity build target." + "The unity target name will be set to this target's name with the suffix _unity appended." + "Inherited from directory." + "Defaults to TRUE." + ) + + define_property( + TARGET PROPERTY "COTIRE_ADD_CLEAN" INHERITED + BRIEF_DOCS "Add a new target that cleans all cotire generated files for this target." + FULL_DOCS + "If this property is set to TRUE, cotire creates a new target that clean all files (unity source, prefix header, precompiled header)." + "The clean target name will be set to this target's name with the suffix _clean_cotire appended." + "Inherited from directory." + "Defaults to FALSE." + ) + + define_property( + TARGET PROPERTY "COTIRE_PREFIX_HEADER_IGNORE_PATH" INHERITED + BRIEF_DOCS "Ignore headers from these directories when generating the prefix header." + FULL_DOCS + "The property can be set to a list of directories." + "If a header file is found in one of these directories or sub-directories, it will be excluded from the generated prefix header." + "Inherited from directory." + "If not set, this property is initialized to \${CMAKE_SOURCE_DIR};\${CMAKE_BINARY_DIR}." + ) + + define_property( + TARGET PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PATH" INHERITED + BRIEF_DOCS "Honor headers from these directories when generating the prefix header." + FULL_DOCS + "The property can be set to a list of directories." + "If a header file is found in one of these directories or sub-directories, it will be included in the generated prefix header." + "If a header file is both selected by COTIRE_PREFIX_HEADER_IGNORE_PATH and COTIRE_PREFIX_HEADER_INCLUDE_PATH," + "the option which yields the closer relative path match wins." + "Inherited from directory." + "If not set, this property is initialized to the empty list." + ) + + define_property( + TARGET PROPERTY "COTIRE_PREFIX_HEADER_INCLUDE_PRIORITY_PATH" INHERITED + BRIEF_DOCS "Header paths matching one of these directories are put at the top of prefix header." + FULL_DOCS + "The property can be set to a list of directories." + "Header file paths matching one of these directories will be inserted at the beginning of the generated prefix header." + "Header files are sorted according to the order of the directories in the property." + "If not set, this property is initialized to the empty list." + ) + + define_property( + TARGET PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" INHERITED + BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of each target source file." + FULL_DOCS + "This may be set to a semicolon-separated list of preprocessor symbols." + "cotire will add corresponding #undef directives to the generated unit source file before each target source file." + "Inherited from directory." + "Defaults to empty string." + ) + + define_property( + TARGET PROPERTY "COTIRE_UNITY_SOURCE_POST_UNDEFS" INHERITED + BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file after the inclusion of each target source file." + FULL_DOCS + "This may be set to a semicolon-separated list of preprocessor symbols." + "cotire will add corresponding #undef directives to the generated unit source file after each target source file." + "Inherited from directory." + "Defaults to empty string." + ) + + define_property( + TARGET PROPERTY "COTIRE_UNITY_SOURCE_MAXIMUM_NUMBER_OF_INCLUDES" INHERITED + BRIEF_DOCS "Maximum number of source files to include in a single unity source file." + FULL_DOCS + "This may be set to an integer > 0." + "If a target contains more than that number of source files, cotire will create multiple unity build files for it." + "If not set, cotire will only create a single unity source file." + "Inherited from directory." + "Defaults to empty." + ) + + define_property( + TARGET PROPERTY "COTIRE__UNITY_SOURCE_INIT" + BRIEF_DOCS "User provided unity source file to be used instead of the automatically generated one." + FULL_DOCS + "If set, cotire will only add the given file(s) to the generated unity source file." + "If not set, cotire will add all the target source files to the generated unity source file." + "The property can be set to a user provided unity source file." + "Defaults to empty." + ) + + define_property( + TARGET PROPERTY "COTIRE__PREFIX_HEADER_INIT" + BRIEF_DOCS "User provided prefix header file to be used instead of the automatically generated one." + FULL_DOCS + "If set, cotire will add the given header file(s) to the generated prefix header file." + "If not set, cotire will generate a prefix header by tracking the header files included by the unity source file." + "The property can be set to a user provided prefix header file (e.g., stdafx.h)." + "Defaults to empty." + ) + + define_property( + TARGET PROPERTY "COTIRE_UNITY_LINK_LIBRARIES_INIT" INHERITED + BRIEF_DOCS "Define strategy for setting up unity target's link libraries." + FULL_DOCS + "If this property is empty or set to NONE, the generated unity target's link libraries have to be set up manually." + "If this property is set to COPY, the unity target's link libraries will be copied from this target." + "If this property is set to COPY_UNITY, the unity target's link libraries will be copied from this target with considering existing unity targets." + "Inherited from directory." + "Defaults to empty." + ) + + define_property( + TARGET PROPERTY "COTIRE__UNITY_SOURCE" + BRIEF_DOCS "Read-only property. The generated unity source file(s)." + FULL_DOCS + "cotire sets this property to the path of the generated single computation unit source file for the target." + "Defaults to empty string." + ) + + define_property( + TARGET PROPERTY "COTIRE__PREFIX_HEADER" + BRIEF_DOCS "Read-only property. The generated prefix header file." + FULL_DOCS + "cotire sets this property to the full path of the generated language prefix header for the target." + "Defaults to empty string." + ) + + define_property( + TARGET PROPERTY "COTIRE__PRECOMPILED_HEADER" + BRIEF_DOCS "Read-only property. The generated precompiled header file." + FULL_DOCS + "cotire sets this property to the full path of the generated language precompiled header binary for the target." + "Defaults to empty string." + ) + + define_property( + TARGET PROPERTY "COTIRE_UNITY_TARGET_NAME" + BRIEF_DOCS "The name of the generated unity build target corresponding to this target." + FULL_DOCS + "This property can be set to the desired name of the unity target that will be created by cotire." + "If not set, the unity target name will be set to this target's name with the suffix _unity appended." + "After this target has been processed by cotire, the property is set to the actual name of the generated unity target." + "Defaults to empty string." + ) + + # define cotire source properties + + define_property( + SOURCE PROPERTY "COTIRE_EXCLUDED" + BRIEF_DOCS "Do not modify source file's build command." + FULL_DOCS + "If this property is set to TRUE, the source file's build command will not be modified to make use of the precompiled header." + "The source file will also be excluded from the generated unity source file." + "Source files that have their COMPILE_FLAGS property set will be excluded by default." + "Defaults to FALSE." + ) + + define_property( + SOURCE PROPERTY "COTIRE_DEPENDENCY" + BRIEF_DOCS "Add this source file to dependencies of the automatically generated prefix header file." + FULL_DOCS + "If this property is set to TRUE, the source file is added to dependencies of the generated prefix header file." + "If the file is modified, cotire will re-generate the prefix header source upon build." + "Defaults to FALSE." + ) + + define_property( + SOURCE PROPERTY "COTIRE_UNITY_SOURCE_PRE_UNDEFS" + BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file before the inclusion of this source file." + FULL_DOCS + "This may be set to a semicolon-separated list of preprocessor symbols." + "cotire will add corresponding #undef directives to the generated unit source file before this file is included." + "Defaults to empty string." + ) + + define_property( + SOURCE PROPERTY "COTIRE_UNITY_SOURCE_POST_UNDEFS" + BRIEF_DOCS "Preprocessor undefs to place in the generated unity source file after the inclusion of this source file." + FULL_DOCS + "This may be set to a semicolon-separated list of preprocessor symbols." + "cotire will add corresponding #undef directives to the generated unit source file after this file is included." + "Defaults to empty string." + ) + + define_property( + SOURCE PROPERTY "COTIRE_START_NEW_UNITY_SOURCE" + BRIEF_DOCS "Start a new unity source file which includes this source file as the first one." + FULL_DOCS + "If this property is set to TRUE, cotire will complete the current unity file and start a new one." + "The new unity source file will include this source file as the first one." + "This property essentially works as a separator for unity source files." + "Defaults to FALSE." + ) + + define_property( + SOURCE PROPERTY "COTIRE_TARGET" + BRIEF_DOCS "Read-only property. Mark this source file as cotired for the given target." + FULL_DOCS + "cotire sets this property to the name of target, that the source file's build command has been altered for." + "Defaults to empty string." + ) + + message (STATUS "cotire ${COTIRE_CMAKE_MODULE_VERSION} loaded.") + +endif() diff --git a/cmake/env/pol_global_config.h.in b/cmake/env/pol_global_config.h.in index 6c8f356a3..83c332450 100644 --- a/cmake/env/pol_global_config.h.in +++ b/cmake/env/pol_global_config.h.in @@ -11,12 +11,10 @@ #cmakedefine HAVE_MYSQL #cmakedefine ENABLE_BENCHMARK -#define POL_VERSION_MAJOR @BINARY_VERSION_MAJOR@ -#define POL_VERSION_MINOR @BINARY_VERSION_MINOR@ -#define POL_VERSION_PATCH @BINARY_VERSION_PATCH@ -#define POL_VERSION_STR "@BINARY_VERSION@" -#define POL_VERSION_NAME "@BINARY_VERSION_NAME@" -#define POL_VERSION_ID "POL@BINARY_VERSION@ @BINARY_VERSION_NAME@" +#define POL_VERSION @POL_VERSION@ +#define POL_VERSION_STR "@POL_VERSION_STR@" +#define POL_VERSION_NAME "@POL_VERSION_NAME@" +#define POL_VERSION_ID "POL@POL_VERSION_STR@ @POL_VERSION_NAME@" #define POL_BUILD_DATE __DATE__ #define POL_BUILD_TIME __TIME__ #define POL_BUILD_ARCH_BITS_STR "@ARCH_BITS@" @@ -48,17 +46,32 @@ #if defined(LINUX) #define POL_BUILD_TARGET ("LINUX (" POL_BUILD_ARCH_BITS_STR "bit)" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK "" POL_BUILD_TARGET_TAG_PROFILE "" POL_REVISION_TAG) -#elif defined(WINDOWS) - #if (_MSC_VER <= 1700) - #define VS_VER "VS2012" - #elif (_MSC_VER <= 1800) - #define VS_VER "VS2013" - #elif (_MSC_VER <= 1900) - #define VS_VER "VS2015" - #endif - #define POL_BUILD_TARGET ("WINDOWS (" POL_BUILD_ARCH_BITS_STR "bit-" VS_VER ")" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK "" POL_BUILD_TARGET_TAG_PROFILE "" POL_REVISION_TAG) +#elif defined( WINDOWS ) +#if ( _MSC_VER <= 1700 ) +#define POL_BUILD_TARGET \ + ( "VS2012" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK \ + "" POL_BUILD_TARGET_TAG_PROFILE "" POL_64 "" POL_REVISION_TAG ) +#elif ( _MSC_VER <= 1800 ) +#define POL_BUILD_TARGET \ + ( "VS2013" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK \ + "" POL_BUILD_TARGET_TAG_PROFILE "" POL_64 "" POL_REVISION_TAG ) +#elif ( _MSC_VER <= 1900 ) +#define POL_BUILD_TARGET \ + ( "VS2015" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK \ + "" POL_BUILD_TARGET_TAG_PROFILE "" POL_64 "" POL_REVISION_TAG ) +#elif ( _MSC_VER <= 2000 ) +#define POL_BUILD_TARGET \ + ( "VS2017" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK \ + "" POL_BUILD_TARGET_TAG_PROFILE "" POL_64 "" POL_REVISION_TAG ) #else - #define POL_BUILD_TARGET ("[UNKNOWN]" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK "" POL_BUILD_TARGET_TAG_PROFILE "" POL_64 "" POL_REVISION_TAG) +#define POL_BUILD_TARGET \ + ( "[UNKNOWN]" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK \ + "" POL_BUILD_TARGET_TAG_PROFILE "" POL_64 "" POL_REVISION_TAG ) +#endif +#else +#define POL_BUILD_TARGET \ + ( "[UNKNOWN]" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK \ + "" POL_BUILD_TARGET_TAG_PROFILE "" POL_64 "" POL_REVISION_TAG ) #endif #endif /* POL_GLOBAL_CONFIG_H */ diff --git a/cmake/init.cmake b/cmake/init.cmake new file mode 100644 index 000000000..723b527f0 --- /dev/null +++ b/cmake/init.cmake @@ -0,0 +1,93 @@ + +macro(detect_compiler) + if( NOT CMAKE_BUILD_TYPE ) + set( CMAKE_BUILD_TYPE Release CACHE STRING + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." + FORCE + ) + endif() + if (${CMAKE_BUILD_TYPE} MATCHES "Debug") + set(debug 1) + set(release 0) + else() + set(debug 0) + set(release 1) + endif() + message("Build type: ${CMAKE_BUILD_TYPE} ${MinSizeRel}") + set(clang 0) + set(msvc 0) + set(gcc 0) + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(clang 1) + elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + set(msvc 1) + elseif (CMAKE_COMPILER_IS_GNUCXX) + set(gcc 1) + endif() + message("Compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}") +endmacro() + +macro(detect_arch) + if (NOT DEFINED FORCE_ARCH_BITS) + if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(ARCH_BITS "64") + message("Detected architecture is 64 bit") + elseif ("${CMAKE_SIZEOF_VOID_P}" EQUAL "4") + set(ARCH_BITS "32") + message("Detected architecture is 32 bit") + else() + message("Unable to detect architecture of your system") + endif() + set(FORCE_ARCH_BITS 0) + else() + set(ARCH_BITS ${FORCE_ARCH_BITS}) + set(FORCE_ARCH_BITS 1) + message("Architecture was explicitly defined as ${ARCH_BITS} bit") + endif() +endmacro() + +macro(detect_platform) + set (linux 0) + set (windows 0) + if (UNIX AND NOT WIN32) + message("Target system is Linux") + set (linux 1) + elseif (WIN32) + set (windows 1) + endif() +endmacro() + +macro(prepare_build) + set(CMAKE_INCLUDE_CURRENT_DIR ON) + + if(windows) + set(HAVE_OPENSSL true) + set(HAVE_MYSQL true) + else() + check_include_files (openssl/md5.h HAVE_OPENSSL) + check_include_files (mysql/mysql.h HAVE_MYSQL) + endif() + configure_file( + ${CMAKE_CURRENT_LIST_DIR}/cmake/env/pol_global_config.h.in + ${PROJECT_BINARY_DIR}/pol_global_config.h + ) +endmacro() + +macro(get_git_revision) + find_package(Git) + if(GIT_EXECUTABLE) + execute_process(COMMAND ${GIT_EXECUTABLE} + log -1 --pretty=format:%h + RESULT_VARIABLE status + OUTPUT_VARIABLE GIT_REVISION + ERROR_QUIET + ) + if (status) + set(GIT_REVISION "\"Unknown\"") + else() + set(GIT_REVISION "\"${GIT_REVISION}\"") + endif() + else() + set(GIT_REVISION "\"Unknown\"") + endif() +endmacro() diff --git a/cmake/release.cmake b/cmake/release.cmake new file mode 100644 index 000000000..46638356b --- /dev/null +++ b/cmake/release.cmake @@ -0,0 +1,13 @@ +macro(release) + string(TIMESTAMP curr_date "%Y-%m-%d") + if (${linux}) + set(system LINUX) + else() + set(system WINDOWS) + endif() + set(CPACK_PACKAGE_FILE_NAME "polserver${POL_VERSION_STR}-${system}-${curr_date}") + + set(CPACK_PACKAGE_DIRECTORY "${PROJECT_BINARY_DIR}/../bin") + set(CPACK_GENERATOR "ZIP") + include(CPack) +endmacro() diff --git a/cmake/utils.cmake b/cmake/utils.cmake new file mode 100644 index 000000000..1685d0ea1 --- /dev/null +++ b/cmake/utils.cmake @@ -0,0 +1,145 @@ +function(set_compile_flags target is_executable) + message("* ${target}") + target_include_directories(${target} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} #own folder + ${PROJECT_BINARY_DIR} #global config + ${BOOST_SOURCE_DIR} # boost + "${CMAKE_CURRENT_LIST_DIR}/../../lib" #format/.. + "${CMAKE_CURRENT_LIST_DIR}/../../lib/picojson-1.3.0" #pico + ) + + target_compile_definitions(${target} PRIVATE + INC_PASSERT=1 + __STDC_CONSTANT_MACROS + __STDC_FORMAT_MACROS + __STDC_LIMIT_MACROS + _REENTRANT + ARCH_BITS=${ARCH_BITS} + ) + if (${release}) + target_compile_definitions(${target} PRIVATE + RELEASE_VERSION + ) + endif() + + if (${debug}) + target_compile_definitions(${target} PRIVATE + DEBUG_VERSION + ) + endif() + + if (${linux}) + target_compile_definitions(${target} PRIVATE + _GNU_SOURCE + LINUX + ) + endif() + + if (${windows}) + target_compile_definitions(${target} PRIVATE + _WIN32 + WIN32 + NOMINMAX + WINDOWS + WINVER=0x0501 + ) + endif() + + target_compile_options(${target} PRIVATE + $<${linux}: + -std=c++11 + -fPIC + -W + -Wall + -Wno-unknown-pragmas + -Wno-unused-result + -Wno-unused-function + -Wno-format + -fno-strict-aliasing + > + + $<$: + -m${ARCH_BITS} + > + + $<$: + -ggdb + > + + $<${gcc}: + -fopenmp + > + ) + + if (${is_executable}) + if (${release} AND ${linux}) + target_link_libraries(${target} PUBLIC + -s # strip + ) + endif() + #search path for libs + # $<${linux}: + # -Wl,-R. + # -Wl,-R./lib + # -Wl,-R../lib + # -Wl,-R../../lib + # > + endif() + + if(${linux}) + link_directories( + /usr/local/lib + /usr/lib + /usr/lib${ARCH_BITS} + ) + endif() + + if(NOT EXISTS "${BOOST_SOURCE_DIR}/boost") + add_dependencies(${target} boost) + endif() + + set_target_properties(${target} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/../bin" + LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/../bin" + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/../bin" + ) + + #PCH SUPPORT + set(_pch_name "${CMAKE_CURRENT_SOURCE_DIR}/StdAfx.h") + if (EXISTS ${_pch_name}) + set_target_properties(${target} PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT ${_pch_name}) + cotire(${target}) + endif() + +endfunction() + +function(use_curl target) + find_library(curl_lib NAMES curl libcurl + PATHS ${CURL_INSTALL_DIR}/lib + NO_DEFAULT_PATH) + + target_include_directories(${target} + PUBLIC ${CURL_INSTALL_DIR}/include + ) + if(curl_lib) + target_link_libraries(${target} PUBLIC ${curl_lib}) + else() + target_link_libraries(${target} PUBLIC curl) + endif() +endfunction() + +function(use_benchmark target) + if (DEFINED ENABLE_BENCHMARK) + target_link_libraries(${target} PUBLIC benchmark) + endif() +endfunction() + +function(dist target dir) + install( + TARGETS ${target} + ARCHIVE DESTINATION ${dir} + LIBRARY DESTINATION ${dir} + RUNTIME DESTINATION ${dir} + COMPONENT polcore + ) +endfunction() diff --git a/lib/google-benchmark/CMakeLists.txt b/lib/google-benchmark/CMakeLists.txt index 3b4bef002..e3abf0fc6 100644 --- a/lib/google-benchmark/CMakeLists.txt +++ b/lib/google-benchmark/CMakeLists.txt @@ -1,5 +1,4 @@ cmake_minimum_required (VERSION 2.8.12) -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../../cmake/CMakeEnvironment.txt) project (benchmark) foreach(p diff --git a/lib/tinyxml/CMakeLists.txt b/lib/tinyxml/CMakeLists.txt index f759b846b..391c52652 100644 --- a/lib/tinyxml/CMakeLists.txt +++ b/lib/tinyxml/CMakeLists.txt @@ -1,50 +1,15 @@ -############################################################################### -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../../cmake/CMakeEnvironment.txt) +set(lib_name tinyxml) -MESSAGE("####################################") -MESSAGE("##### Building POL - TINYXML") -MESSAGE("####################################") - -############################################################################### -# define source files -SET (SOURCES # sorted ! - tinystr.cpp - tinyxml.cpp - tinyxmlerror.cpp - tinyxmlparser.cpp +add_library(${lib_name} STATIC #SHARED + # sorted ! + tinystr.cpp + tinyxml.cpp + tinyxmlerror.cpp + tinyxmlparser.cpp ) -############################################################## -# include dirs -SET (INCLUDE_DIRS - ./ +set_compile_flags(${lib_name} 0) + +target_compile_definitions(${lib_name} PUBLIC + TIXML_USE_STL ) - -############################################################## -# set directory for internal libs -SET (LIB_DIRS - ${LIB_DIRS} - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# link to the needed libs -SET (LIBS_LINUX -) - -############################################################## -# define target directory -SET (TARGET_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR}/../../pol-core/bin -) - -############################################################## -# define binary name -SET (TARGET_LIB_NAME - tinyxml -) - -############################################################## -# include CMake core -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CMakeCore.txt) - diff --git a/lib/tinyxml/tinyxmlparser.cpp b/lib/tinyxml/tinyxmlparser.cpp index 81b7eae96..a95ce96b9 100644 --- a/lib/tinyxml/tinyxmlparser.cpp +++ b/lib/tinyxml/tinyxmlparser.cpp @@ -111,14 +111,17 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng --output; *output = (char)((input | BYTE_MARK) & BYTE_MASK); input >>= 6; + // fall through case 3: --output; *output = (char)((input | BYTE_MARK) & BYTE_MASK); input >>= 6; + // fall through case 2: --output; *output = (char)((input | BYTE_MARK) & BYTE_MASK); input >>= 6; + // fall through case 1: --output; *output = (char)(input | FIRST_BYTE_MARK[*length]); diff --git a/pol-core/CMakeLists.txt b/pol-core/CMakeLists.txt index 277e28979..c9499837c 100644 --- a/pol-core/CMakeLists.txt +++ b/pol-core/CMakeLists.txt @@ -1,12 +1,12 @@ +add_subdirectory(clib) +add_subdirectory(bscript) +add_subdirectory(plib) +add_subdirectory(pol) +add_subdirectory(ecompile) +add_subdirectory(runecl) +add_subdirectory(uoconvert) +add_subdirectory(uotool) +add_subdirectory(poltool) -cmake_minimum_required(VERSION 2.8) - -ADD_SUBDIRECTORY(clib) -ADD_SUBDIRECTORY(bscript) -ADD_SUBDIRECTORY(plib) -ADD_SUBDIRECTORY(pol) -ADD_SUBDIRECTORY(ecompile) -ADD_SUBDIRECTORY(runecl) -ADD_SUBDIRECTORY(uoconvert) -ADD_SUBDIRECTORY(uotool) -ADD_SUBDIRECTORY(poltool) +add_subdirectory(doc) +add_subdirectory(support) diff --git a/pol-core/bin-build/.gitignore b/pol-core/bin-build/.gitignore index 73fb54635..ca7332748 100644 --- a/pol-core/bin-build/.gitignore +++ b/pol-core/bin-build/.gitignore @@ -3,4 +3,6 @@ /pol-core /*.tar.gz /compile_commands.json - +/CPack* +/install_manifest* +/boost* diff --git a/pol-core/bin-build/build_linux.sh b/pol-core/bin-build/build_linux.sh index 371daf439..8ca97aa39 100755 --- a/pol-core/bin-build/build_linux.sh +++ b/pol-core/bin-build/build_linux.sh @@ -1,27 +1,10 @@ #!/bin/sh CPU_CORES=`grep -c ^processor /proc/cpuinfo` -SYSTEM=`lsb_release -d -s` -PHYS_MEM=$((`grep MemTotal /proc/meminfo | awk '{print $2}'`)) -PHYS_MEM_GB=`echo "scale=1; ($PHYS_MEM / 1024 / 1024)" | bc -l` -CMAKE_VERSION=`cmake --version | grep 'cmake version' | awk '{print $3}'` +USED_CPU_CORES=$(($CPU_CORES + 1)) if [ -z "$CMAKE_BIN" ]; then CMAKE_BIN='cmake'; fi -echo "################################################################################" -echo "############# Starting build of POL from www.polserver.com #####################" -echo "################################################################################" -echo "System : $SYSTEM" -echo "CPU cores : $CPU_CORES" -echo "Memory size (GB) : $PHYS_MEM_GB" -echo "CMAKE version : $CMAKE_VERSION" - -echo "################################################################################" -echo "########################### Prepraring CMake ##################################" -echo "################################################################################" `$CMAKE_BIN ../..` -echo "################################################################################" -echo "########################### Compiling + Linking ###############################" -echo "################################################################################" -USED_CPU_CORES=$(($CPU_CORES + 1)) -echo "####################### Using $USED_CPU_CORES parallel compile jobs ########################" +echo "#### Using $USED_CPU_CORES parallel compile jobs ###" + make -j $USED_CPU_CORES diff --git a/pol-core/bin-build/build_linux_release.sh b/pol-core/bin-build/build_linux_release.sh index 00d9d8b96..e146194df 100755 --- a/pol-core/bin-build/build_linux_release.sh +++ b/pol-core/bin-build/build_linux_release.sh @@ -1,46 +1,5 @@ #!/bin/sh ./build_linux.sh -SOURCE_DIR_BUILD_BIN=../bin -DEST_DIR_DISTRI="RELEASE" -POL_RELEASE="099" -SYSTEM=`lsb_release -i -s` -DEST_TAR_FILE="../pol-LINUX-$POL_RELEASE-`date +%Y-%m-%d`-$SYSTEM.tar" -########################################################### -########################################################### - -echo "############## Creating directories" -mkdir -p $DEST_DIR_DISTRI -mkdir -p $DEST_DIR_DISTRI/scripts/modules -mkdir -p $DEST_DIR_DISTRI/config -mkdir -p $DEST_DIR_DISTRI/lib - -echo "############## Removing debug symbols and copying binaries to RELEASE folder" -strip -o $DEST_DIR_DISTRI/pol $SOURCE_DIR_BUILD_BIN/pol -strip -o $DEST_DIR_DISTRI/scripts/ecompile $SOURCE_DIR_BUILD_BIN/ecompile -strip -o $DEST_DIR_DISTRI/scripts/runecl $SOURCE_DIR_BUILD_BIN/runecl -strip -o $DEST_DIR_DISTRI/uoconvert $SOURCE_DIR_BUILD_BIN/uoconvert -strip -o $DEST_DIR_DISTRI/uotool $SOURCE_DIR_BUILD_BIN/uotool - -echo "############## Copying additionally needed files to RELEASE folder" -cp $SOURCE_DIR_BUILD_BIN/lib*.so* $DEST_DIR_DISTRI/lib -cp ../support/scripts/*.em $DEST_DIR_DISTRI/scripts/modules -cp ../support/scripts/ecompile.cfg.example $DEST_DIR_DISTRI/scripts -cp ../doc/core-changes.txt $DEST_DIR_DISTRI/ -cp ../doc/uoconvert.txt $DEST_DIR_DISTRI/ -cp ../doc/packethooks.txt $DEST_DIR_DISTRI/ -cp ../doc/packets.zip $DEST_DIR_DISTRI/ -cp ../support/uoconvert.cfg $DEST_DIR_DISTRI/ -cp ../support/boats.cfg $DEST_DIR_DISTRI/config -cp ../support/extobj.cfg $DEST_DIR_DISTRI/config -cp ../support/animxlate.cfg $DEST_DIR_DISTRI/config - -cd $DEST_DIR_DISTRI/ -echo "############## Creating release archive" -tar -cvf $DEST_TAR_FILE pol uoconvert uotool lib/lib*.so scripts/* config/*.cfg core-changes.txt uoconvert.txt uoconvert.cfg packethooks.txt packets.zip -echo "############## Compressing release archive" -gzip -f -9 $DEST_TAR_FILE -echo "############## Removing temporary files" -cd .. -rm -rf $DEST_DIR_DISTRI \ No newline at end of file +make package diff --git a/pol-core/bin/.gitignore b/pol-core/bin/.gitignore index 6906c48d7..638797cd7 100644 --- a/pol-core/bin/.gitignore +++ b/pol-core/bin/.gitignore @@ -7,4 +7,5 @@ *-dynamic *.so* *.a - +_CPack* +*.zip diff --git a/pol-core/bscript/CMakeLists.txt b/pol-core/bscript/CMakeLists.txt index ddfde9059..d4a4a38f7 100644 --- a/pol-core/bscript/CMakeLists.txt +++ b/pol-core/bscript/CMakeLists.txt @@ -1,14 +1,7 @@ -############################################################################### +set(lib_name bscript) -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../../cmake/CMakeEnvironment.txt) - -MESSAGE("####################################") -MESSAGE("##### Building BSCRIPT") -MESSAGE("####################################") - -############################################################################### -# define source files -SET (SOURCES # sorted ! +add_library(${lib_name} STATIC + # sorted ! berror.cpp blong.cpp bstruct.cpp @@ -38,51 +31,10 @@ SET (SOURCES # sorted ! userfunc.cpp ) -############################################################## -# include dirs -SET (INCLUDE_DIRS - ../ - ./ +set_compile_flags(${lib_name} 0) + +target_link_libraries(${lib_name} PUBLIC + clib + pthread ) -############################################################## -# set directory for internal libs -SET (LIB_DIRS - ${LIB_DIRS} - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# compile flags -IF(NOT WINDOWS) - SET (FLAGS - ${FLAGS} - -DINC_PASSERT=1 - ) -ENDIF() - -############################################################## -# link to the needed libs -SET (LIBS_LINUX - pthread -) - -############################################################## -# define target directory -SET (TARGET_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# define binary name -SET (TARGET_LIB_NAME - bscript -) - -############################################################## -# include CMake core -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CMakeCore.txt) - -IF(NOT EXISTS "${BOOST_SOURCE_DIR}/boost") -ADD_DEPENDENCIES(bscript boost) -ENDIF() diff --git a/pol-core/bscript/berror.cpp b/pol-core/bscript/berror.cpp index b7ffa87da..03cf7e1fd 100644 --- a/pol-core/bscript/berror.cpp +++ b/pol-core/bscript/berror.cpp @@ -5,8 +5,9 @@ #include "berror.h" -#include "impstr.h" + #include "contiter.h" +#include "impstr.h" namespace Pol { @@ -127,4 +128,4 @@ BObjectImp* BError::array_assign( BObjectImp* /*idx*/, BObjectImp* /*target*/, b return this; } } -} \ No newline at end of file +} diff --git a/pol-core/bscript/berror.h b/pol-core/bscript/berror.h index 45ce1486a..8a7b7bc8a 100644 --- a/pol-core/bscript/berror.h +++ b/pol-core/bscript/berror.h @@ -7,11 +7,22 @@ #ifndef BSCRIPT_BERROR_H #define BSCRIPT_BERROR_H -#include "bstruct.h" - #include #include +#include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" +#include "bobject.h" +#include "bstruct.h" + +namespace Pol +{ +namespace Bscript +{ +class ContIterator; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Bscript diff --git a/pol-core/bscript/blong.cpp b/pol-core/bscript/blong.cpp index d8e8cefae..b0e72813a 100644 --- a/pol-core/bscript/blong.cpp +++ b/pol-core/bscript/blong.cpp @@ -4,16 +4,14 @@ */ +#include +#include + +#include "../clib/stlutil.h" #include "berror.h" #include "bobject.h" #include "impstr.h" -#include "../clib/stlutil.h" - -#include -#include -#include - namespace Pol { namespace Bscript diff --git a/pol-core/bscript/bobject.h b/pol-core/bscript/bobject.h index a96175b48..847145cfd 100644 --- a/pol-core/bscript/bobject.h +++ b/pol-core/bscript/bobject.h @@ -25,7 +25,7 @@ #define INLINE_BOBJECTIMP_CTOR 1 #endif -#include "../../lib/format/format.h" +#include #include "../clib/fixalloc.h" #include "../clib/passert.h" diff --git a/pol-core/bscript/bscript-2012.vcxproj b/pol-core/bscript/bscript-2012.vcxproj deleted file mode 100644 index 03608a596..000000000 --- a/pol-core/bscript/bscript-2012.vcxproj +++ /dev/null @@ -1,273 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - bscript - {5005476B-7BD3-42A2-94CA-3AD2D0E2947C} - bscript - - - - StaticLibrary - false - MultiByte - v110_xp - - - StaticLibrary - false - MultiByte - v110 - - - StaticLibrary - false - MultiByte - v110 - - - StaticLibrary - false - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\Debug\ - .\Debug\x64/ - .\Debug\ - .\Debug\x64/ - .\Release\ - .\Release\x64/ - .\Release\ - .\Release\x64/ - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - Disabled - %(AdditionalIncludeDirectories) - _DEBUG;_LIB;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - .\Executor\Debug/bscript_executor.pch - .\Debug/ - .\Debug/ - .\Debug/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - .\Debug\bscript.lib - true - ..\..\lib\boost_1_55_0\lib\x86\lib - - - - - Disabled - %(AdditionalIncludeDirectories) - _DEBUG;_LIB;_WIN64;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - .\Executor\Debug/x64/bscript_executor.pch - .\Debug/x64/ - .\Debug/x64/ - .\Debug/x64/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - .\Debug\x64/bscript.lib - true - MachineX64 - ..\..\lib\boost_1_55_0\lib\x64\lib - - - - - %(AdditionalIncludeDirectories) - NDEBUG;_LIB;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - .\Release/bscript_executor.pch - .\Release/ - .\Release/ - .\Release/ - Level4 - true - ProgramDatabase - Default - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - .\Release\bscript.lib - true - ..\..\lib\boost_1_55_0\lib\x86\lib - - - - - %(AdditionalIncludeDirectories) - NDEBUG;_LIB;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - .\Release/x64/bscript_executor.pch - .\Release/x64/ - .\Release/x64/ - .\Release/x64/ - Level4 - true - ProgramDatabase - Default - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - .\Release\x64/bscript.lib - true - MachineX64 - ..\..\lib\boost_1_55_0\lib\x64\lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pol-core/bscript/bscript-2012.vcxproj.filters b/pol-core/bscript/bscript-2012.vcxproj.filters deleted file mode 100644 index 8e8917187..000000000 --- a/pol-core/bscript/bscript-2012.vcxproj.filters +++ /dev/null @@ -1,197 +0,0 @@ - - - - - {2754d24d-42b8-49d1-9c9b-ca7d634b1eca} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {64b93dce-b77e-4f11-a4da-4e0c8ad64be6} - h;hpp;hxx;hm;inl - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/pol-core/bscript/bstruct.cpp b/pol-core/bscript/bstruct.cpp index fbf6bfe8a..e89bd2842 100644 --- a/pol-core/bscript/bstruct.cpp +++ b/pol-core/bscript/bstruct.cpp @@ -10,29 +10,24 @@ #include "bstruct.h" +#include + +#include "../clib/passert.h" +#include "../clib/stlutil.h" #include "berror.h" -#include "impstr.h" +#include "bobject.h" #include "contiter.h" #include "executor.h" -#include "objmembers.h" +#include "impstr.h" #include "objmethods.h" -#include "../clib/stlutil.h" - -#include -#include - namespace Pol { namespace Bscript { -BStruct::BStruct() : BObjectImp( OTStruct ), contents_() -{ -} +BStruct::BStruct() : BObjectImp( OTStruct ), contents_() {} -BStruct::BStruct( BObjectType type ) : BObjectImp( type ), contents_() -{ -} +BStruct::BStruct( BObjectType type ) : BObjectImp( type ), contents_() {} BStruct::BStruct( const BStruct& other, BObjectType type ) : BObjectImp( type ), contents_() { @@ -473,4 +468,4 @@ const BStruct::Contents& BStruct::contents() const return contents_; } } -} \ No newline at end of file +} diff --git a/pol-core/bscript/bstruct.h b/pol-core/bscript/bstruct.h index 8a3744d12..d0a968137 100644 --- a/pol-core/bscript/bstruct.h +++ b/pol-core/bscript/bstruct.h @@ -13,12 +13,23 @@ #include "bobject.h" #endif -#include "../clib/maputil.h" - -#include #include +#include #include +#include "../clib/compilerspecifics.h" +#include "../clib/maputil.h" +#include "../clib/rawtypes.h" + +namespace Pol +{ +namespace Bscript +{ +class ContIterator; +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Bscript diff --git a/pol-core/bscript/compctx.cpp b/pol-core/bscript/compctx.cpp index 596e7ed3e..d9eaf7c17 100644 --- a/pol-core/bscript/compctx.cpp +++ b/pol-core/bscript/compctx.cpp @@ -7,7 +7,9 @@ #include "compctx.h" #include -#include +#include + +#include namespace Pol { @@ -65,7 +67,7 @@ int eatToCommentEnd( CompilerContext& ctx ) } return -1; } -} // namespace +} // namespace CompilerContext::CompilerContext() : s( NULL ), line( 1 ), filename( "" ), s_begin( NULL ), dbg_filenum( 0 ) @@ -176,6 +178,5 @@ void CompilerContext::printOnShort( fmt::Writer& writer ) const { writer << filename << ", Line " << line << "\n"; } - } } diff --git a/pol-core/bscript/compctx.h b/pol-core/bscript/compctx.h index 8f71a0b4e..12f04039a 100644 --- a/pol-core/bscript/compctx.h +++ b/pol-core/bscript/compctx.h @@ -8,7 +8,9 @@ #define BSCRIPT_COMPCTX_H #include -#include "../../lib/format/format.h" +#include + +#include namespace Pol { diff --git a/pol-core/bscript/compiler.cpp b/pol-core/bscript/compiler.cpp index 9ec1338c4..e5e4d8710 100644 --- a/pol-core/bscript/compiler.cpp +++ b/pol-core/bscript/compiler.cpp @@ -19,38 +19,33 @@ #include "compiler.h" +#include +#include +#include +#include +#include +#include +#include + +#include #include "../clib/clib.h" #include "../clib/filecont.h" #include "../clib/fileutil.h" +#include "../clib/logfacility.h" #include "../clib/passert.h" #include "../clib/stlutil.h" #include "../clib/strutil.h" -#include "../clib/logfacility.h" - #include "../plib/pkg.h" - #include "compctx.h" #include "compilercfg.h" #include "eprog.h" #include "fmodule.h" #include "modules.h" -#include "tokens.h" -#include "operator.h" -#include "token.h" -#include "verbtbl.h" -#include "filefmt.h" - #include "objmembers.h" - -#include -#include -#include -#include -#include - -#ifdef __unix__ -#include -#endif +#include "symcont.h" +#include "token.h" +#include "tokens.h" +#include "userfunc.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // disable deprecation warning for stricmp, fopen @@ -1308,9 +1303,9 @@ int Compiler::getDictionaryMembers( Expression& expr, CompilerContext& ctx ) // first get the key expression. Expression key_expression; - res = readexpr( key_expression, ctx, EXPR_FLAG_COMMA_TERM_ALLOWED | - EXPR_FLAG_DICTKEY_TERM_ALLOWED | - EXPR_FLAG_RIGHTBRACE_TERM_ALLOWED ); + res = readexpr( key_expression, ctx, + EXPR_FLAG_COMMA_TERM_ALLOWED | EXPR_FLAG_DICTKEY_TERM_ALLOWED | + EXPR_FLAG_RIGHTBRACE_TERM_ALLOWED ); if ( res < 0 ) return res; @@ -2362,13 +2357,15 @@ int Compiler::readFunctionDeclaration( CompilerContext& ctx, UserFunction& userf if ( funcName.id == TOK_FUNC ) { INFO_PRINT << "'" << funcName.tokval() << "' is already defined as a function.\n" - << "Near: " << curLine << "\n" << ctx; + << "Near: " << curLine << "\n" + << ctx; return -1; } else { INFO_PRINT << "Expected an identifier, got " << funcName << " instead.\n" - << "Near: " << curLine << "\n" << ctx; + << "Near: " << curLine << "\n" + << ctx; return -1; } } @@ -3063,10 +3060,10 @@ int Compiler::handleVarDeclare( CompilerContext& ctx, unsigned save_id ) return 0; -// FIXME: Dead code since ages, left here because I have no idea if bug or feature... -// // insert a consumer to eat the evaluated result from the expr. -// program->append( StoredToken( Mod_Basic, TOK_CONSUMER, TYP_UNARY_OPERATOR, 0 ) ); -// return 0; + // FIXME: Dead code since ages, left here because I have no idea if bug or feature... + // // insert a consumer to eat the evaluated result from the expr. + // program->append( StoredToken( Mod_Basic, TOK_CONSUMER, TYP_UNARY_OPERATOR, 0 ) ); + // return 0; } /* @@ -4086,8 +4083,8 @@ int Compiler::_getStatement( CompilerContext& ctx, int level ) case RSV_ENUM: return handleEnumDeclare( ctx ); - // DEPRECATED: - // case RSV_BEGIN: return handleBlock(ctx, level+1); + // DEPRECATED: + // case RSV_BEGIN: return handleBlock(ctx, level+1); default: INFO_PRINT << "Unhandled reserved word: " << token << "\n"; diff --git a/pol-core/bscript/compiler.h b/pol-core/bscript/compiler.h index 93d43d9c0..0dd6d8789 100644 --- a/pol-core/bscript/compiler.h +++ b/pol-core/bscript/compiler.h @@ -7,18 +7,33 @@ #ifndef H_COMPILER_H #define H_COMPILER_H +#include "../clib/compilerspecifics.h" +#include "compctx.h" +#include "tokens.h" #include "userfunc.h" #ifndef __PARSER_H #include "parser.h" #endif +#include +#include +#include +#include +#include + #include "../clib/maputil.h" #include "../clib/refptr.h" -#include -#include -#include +namespace Pol +{ +namespace Bscript +{ +class ModuleFunction; +class Token; +class UserFunction; +} // namespace Bscript +} // namespace Pol namespace Pol { @@ -92,6 +107,7 @@ public: bool varexists( const std::string& varname, unsigned& idx ) const; bool varexists( const std::string& varname ) const; unsigned int numVariables() const { return static_cast( variables_.size() ); } + private: Variables variables_; @@ -108,6 +124,7 @@ public: static int verbosity_level_; static void setCheckFileCase( bool check ) { check_filecase_ = check; } static void setVerbosityLevel( int vlev ) { verbosity_level_ = vlev; } + private: std::string current_file_path; diff --git a/pol-core/bscript/compilercfg.cpp b/pol-core/bscript/compilercfg.cpp index d14904067..c0dbb84fd 100644 --- a/pol-core/bscript/compilercfg.cpp +++ b/pol-core/bscript/compilercfg.cpp @@ -5,9 +5,12 @@ #include "compilercfg.h" + +#include + #include "../clib/Program/ProgramConfig.h" -#include "../clib/cfgfile.h" #include "../clib/cfgelem.h" +#include "../clib/cfgfile.h" #include "../clib/dirlist.h" #include "../clib/fileutil.h" diff --git a/pol-core/bscript/dbl.cpp b/pol-core/bscript/dbl.cpp index 6617cacfd..ce9d6dad4 100644 --- a/pol-core/bscript/dbl.cpp +++ b/pol-core/bscript/dbl.cpp @@ -4,17 +4,15 @@ */ +#include +#include +#include + +#include "../clib/stlutil.h" #include "berror.h" #include "bobject.h" #include "impstr.h" -#include "../clib/stlutil.h" - -#include -#include -#include -#include - namespace Pol { namespace Bscript diff --git a/pol-core/bscript/dict.cpp b/pol-core/bscript/dict.cpp index a238419d2..4e25b571b 100644 --- a/pol-core/bscript/dict.cpp +++ b/pol-core/bscript/dict.cpp @@ -9,29 +9,22 @@ #include "dict.h" -#include "executor.h" - -#include "berror.h" -#include "impstr.h" -#include "contiter.h" -#include "objmembers.h" -#include "objmethods.h" +#include #include "../clib/stlutil.h" - -#include +#include "berror.h" +#include "contiter.h" +#include "executor.h" +#include "impstr.h" +#include "objmethods.h" namespace Pol { namespace Bscript { -BDictionary::BDictionary() : BObjectImp( OTDictionary ), contents_() -{ -} +BDictionary::BDictionary() : BObjectImp( OTDictionary ), contents_() {} -BDictionary::BDictionary( BObjectType type ) : BObjectImp( type ), contents_() -{ -} +BDictionary::BDictionary( BObjectType type ) : BObjectImp( type ), contents_() {} BDictionary::BDictionary( const BDictionary& dict, BObjectType type ) : BObjectImp( type ), contents_() diff --git a/pol-core/bscript/dict.h b/pol-core/bscript/dict.h index 533236fd4..972fc3e35 100644 --- a/pol-core/bscript/dict.h +++ b/pol-core/bscript/dict.h @@ -16,8 +16,21 @@ #include "bobject.h" #endif -#include #include +#include +#include + +#include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" + +namespace Pol +{ +namespace Bscript +{ +class ContIterator; +class Executor; +} // namespace Bscript +} // namespace Pol namespace Pol { diff --git a/pol-core/bscript/eprog.cpp b/pol-core/bscript/eprog.cpp index 084be87c3..acdc039d3 100644 --- a/pol-core/bscript/eprog.cpp +++ b/pol-core/bscript/eprog.cpp @@ -4,14 +4,12 @@ */ #include "eprog.h" -#include "escriptv.h" -#include "fmodule.h" -#include "filefmt.h" - -#include "../clib/stlutil.h" #include -#include + +#include "../clib/refptr.h" +#include "escriptv.h" +#include "fmodule.h" namespace Pol { diff --git a/pol-core/bscript/eprog.h b/pol-core/bscript/eprog.h index 34287b769..848bd3b57 100644 --- a/pol-core/bscript/eprog.h +++ b/pol-core/bscript/eprog.h @@ -8,18 +8,18 @@ #ifndef BSCRIPT_EPROG_H #define BSCRIPT_EPROG_H -#include "symcont.h" -#include "token.h" - -#include "../clib/refptr.h" -#include "../clib/boostutils.h" - -#include "executortype.h" - #include +#include #include #include +#include "../clib/boostutils.h" +#include "../clib/rawtypes.h" +#include "../clib/refptr.h" +#include "executortype.h" +#include "symcont.h" +#include "token.h" + namespace Pol { namespace Plib diff --git a/pol-core/bscript/eprog2.cpp b/pol-core/bscript/eprog2.cpp index ee70a74b5..3478844f9 100644 --- a/pol-core/bscript/eprog2.cpp +++ b/pol-core/bscript/eprog2.cpp @@ -4,20 +4,24 @@ */ -// EPROG compiler-only functions -#include "eprog.h" -#include "escriptv.h" -#include "filefmt.h" -#include "fmodule.h" -#include "parser.h" -#include "userfunc.h" +#include +#include +#include #include "../clib/clib.h" -#include "../clib/passert.h" -#include "../clib/stlutil.h" #include "../clib/logfacility.h" - -#include +#include "../clib/passert.h" +#include "../clib/rawtypes.h" +#include "../clib/stlutil.h" +#include "compctx.h" +// EPROG compiler-only functions +#include "eprog.h" +#include "filefmt.h" +#include "fmodule.h" +#include "symcont.h" +#include "token.h" +#include "tokens.h" +#include "userfunc.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // deprecated POSIX fopen warning diff --git a/pol-core/bscript/eprog3.cpp b/pol-core/bscript/eprog3.cpp index 50d064166..c9d91d9cb 100644 --- a/pol-core/bscript/eprog3.cpp +++ b/pol-core/bscript/eprog3.cpp @@ -4,10 +4,13 @@ */ -#include "eprog.h" - #include +#include "eprog.h" +#include "symcont.h" +#include "token.h" +#include "tokens.h" + namespace Pol { namespace Bscript diff --git a/pol-core/bscript/eprog_read.cpp b/pol-core/bscript/eprog_read.cpp index 6d68a472f..3703ceff7 100644 --- a/pol-core/bscript/eprog_read.cpp +++ b/pol-core/bscript/eprog_read.cpp @@ -4,20 +4,22 @@ * - 2005/12/07 MuadDib: Added "Recompile required" to Bad version reports. */ -#include "eprog.h" - -#include "filefmt.h" -#include "escriptv.h" -#include "options.h" -#include "executor.h" -#include "objmethods.h" -#include "fmodule.h" - -#include "../clib/strutil.h" -#include "../clib/logfacility.h" - #include -#include +#include +#include + +#include "../clib/logfacility.h" +#include "../clib/rawtypes.h" +#include "../clib/strutil.h" +#include "eprog.h" +#include "executor.h" +#include "filefmt.h" +#include "fmodule.h" +#include "modules.h" +#include "objmethods.h" +#include "symcont.h" +#include "token.h" +#include "tokens.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // deprecated POSIX fopen warning @@ -259,8 +261,8 @@ int EScriptProgram::_readToken( Token& token, unsigned position ) const { throw std::runtime_error( "Symbol offset of " + Clib::decint( dt->strOffset ) + " exceeds symbol store length of " + - Clib::decint( symbols.length() ) + " at PC=" + - Clib::decint( position ) ); + Clib::decint( symbols.length() ) + + " at PC=" + Clib::decint( position ) ); } if ( dt->strOffset ) token.setStr( symbols.array() + dt->strOffset ); diff --git a/pol-core/bscript/escriptv.cpp b/pol-core/bscript/escriptv.cpp index 86c0a7c09..5d6a7e7ed 100644 --- a/pol-core/bscript/escriptv.cpp +++ b/pol-core/bscript/escriptv.cpp @@ -7,6 +7,8 @@ #include "escriptv.h" +#include "../clib/rawtypes.h" + namespace Pol { namespace Bscript @@ -20,4 +22,4 @@ int escript_program_count = 0; u64 escript_instr_cycles = 0; int escript_execinstr_calls = 0; } -} \ No newline at end of file +} diff --git a/pol-core/bscript/escrutil.cpp b/pol-core/bscript/escrutil.cpp index 9e2fbf58f..1d1ec0d65 100644 --- a/pol-core/bscript/escrutil.cpp +++ b/pol-core/bscript/escrutil.cpp @@ -6,12 +6,15 @@ #include "escrutil.h" + +#include +#include +#include +#include + #include "bobject.h" #include "impstr.h" -#include -#include - namespace Pol { namespace Bscript @@ -137,4 +140,4 @@ std::string normalize_ecl_filename( const std::string& filename ) return filename; } } -} \ No newline at end of file +} diff --git a/pol-core/bscript/execmodl.cpp b/pol-core/bscript/execmodl.cpp index b1ec99c38..e108d4a3f 100644 --- a/pol-core/bscript/execmodl.cpp +++ b/pol-core/bscript/execmodl.cpp @@ -6,14 +6,10 @@ #include "execmodl.h" -#include "../clib/clib.h" -#include "../clib/stlutil.h" - -#include "eprog.h" -#include "impstr.h" - #include +#include "executor.h" + namespace Pol { namespace Bscript diff --git a/pol-core/bscript/execmodl.h b/pol-core/bscript/execmodl.h index d846c07eb..0ab661bbf 100644 --- a/pol-core/bscript/execmodl.h +++ b/pol-core/bscript/execmodl.h @@ -12,14 +12,23 @@ #include "bobject.h" #endif -#include "../clib/boostutils.h" -#include "../clib/maputil.h" -#include "executor.h" - #include #include #include +#include "../clib/boostutils.h" +#include "../clib/compilerspecifics.h" +#include "../clib/maputil.h" +#include "executor.h" + +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +} // namespace Pol + #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable : 4996 ) @@ -29,8 +38,8 @@ namespace Pol { namespace Bscript { -class String; class ExecutorModule; +class String; typedef BObject* ( ExecutorModule::*ExecutorModuleFn )(); diff --git a/pol-core/bscript/executor.cpp b/pol-core/bscript/executor.cpp index d20270157..b3f64649c 100644 --- a/pol-core/bscript/executor.cpp +++ b/pol-core/bscript/executor.cpp @@ -15,36 +15,28 @@ #include "executor.h" -#include "berror.h" -#include "config.h" -#include "execmodl.h" - -#include "bstruct.h" -#include "dict.h" -#include "escriptv.h" -#include "eprog.h" -#include "impstr.h" -#include "modules.h" -#include "token.h" -#include "tokens.h" -#include "operator.h" -#include "contiter.h" -#include "filefmt.h" -#include "fmodule.h" - #include "../clib/clib.h" +#include "../clib/compilerspecifics.h" #include "../clib/logfacility.h" #include "../clib/passert.h" -#include "../clib/stlutil.h" #include "../clib/strutil.h" +#include "berror.h" +#include "config.h" +#include "contiter.h" +#include "dict.h" +#include "eprog.h" +#include "escriptv.h" +#include "execmodl.h" +#include "fmodule.h" +#include "impstr.h" +#include "token.h" +#include "tokens.h" #ifdef MEMORYLEAK #include "../clib/mlog.h" #endif -#include #include -#include -#include +#include #ifdef ESCRIPT_PROFILE #ifdef _WIN32 @@ -476,7 +468,7 @@ bool Executor::getObjArrayParam( unsigned param, ObjArray*& pobjarr ) void* Executor::getApplicPtrParam( unsigned param, const BApplicObjType* pointer_type ) { BApplicPtr* ap = - EXPLICIT_CAST(BApplicPtr*, BObjectImp*)( getParamImp( param, BObjectImp::OTApplicPtr ) ); + EXPLICIT_CAST( BApplicPtr*, BObjectImp* )( getParamImp( param, BObjectImp::OTApplicPtr ) ); if ( ap == NULL ) return NULL; @@ -499,8 +491,8 @@ void* Executor::getApplicPtrParam( unsigned param, const BApplicObjType* pointer BApplicObjBase* Executor::getApplicObjParam( unsigned param, const BApplicObjType* object_type ) { - BApplicObjBase* aob = - EXPLICIT_CAST(BApplicObjBase*, BObjectImp*)( getParamImp( param, BObjectImp::OTApplicObj ) ); + BApplicObjBase* aob = EXPLICIT_CAST( + BApplicObjBase*, BObjectImp* )( getParamImp( param, BObjectImp::OTApplicObj ) ); if ( aob == NULL ) return NULL; @@ -955,9 +947,7 @@ BObjectRef Executor::checkmember( BObject& left, const BObject& right ) } -ContIterator::ContIterator() : BObjectImp( BObjectImp::OTUnknown ) -{ -} +ContIterator::ContIterator() : BObjectImp( BObjectImp::OTUnknown ) {} BObject* ContIterator::step() { return NULL; @@ -2544,8 +2534,8 @@ void Executor::innerExec( const Instruction& ins ) const Token& token = ins.token; // this seems an ideal place for a table of function pointers ... - POLLOG.Format( "Script {} used undefined token {} at PC {}\n" ) << scriptname() << ins.token.id - << PC; + POLLOG.Format( "Script {} used undefined token {} at PC {}\n" ) + << scriptname() << ins.token.id << PC; switch ( ins.token.id ) { @@ -2686,7 +2676,7 @@ void Executor::innerExec( const Instruction& ins ) upperLocals2.push_back( Locals2 ); Locals2 = new BObjectRefVec; } - // NOTE fallthrough + // fallthrough case RSV_GOTO: // ins_goto PC = (unsigned)ins.token.lval; return; @@ -3062,9 +3052,7 @@ void Executor::innerExec( const Instruction& ins ) return; } -void Executor::ins_nop( const Instruction& /*ins*/ ) -{ -} +void Executor::ins_nop( const Instruction& /*ins*/ ) {} ExecInstrFunc Executor::GetInstrFunc( const Token& token ) { @@ -3445,7 +3433,7 @@ bool Executor::exec() passert( !error_ ); Clib::scripts_thread_script = scriptname(); - + set_running_to_completion( true ); while ( runnable() ) { diff --git a/pol-core/bscript/executor.h b/pol-core/bscript/executor.h index 30f265cca..6da545b02 100644 --- a/pol-core/bscript/executor.h +++ b/pol-core/bscript/executor.h @@ -23,32 +23,39 @@ #include "bobject.h" #endif -#include "eprog.h" - -#include "../clib/spinlock.h" - -#include -#include -#include #include #include +#include +#include +#include +#include + +#include +#include "../clib/refptr.h" +#include "../clib/spinlock.h" +#include "bobject.h" +#include "eprog.h" +#include "executortype.h" + namespace Pol { namespace Core { class UOExecutor; + void list_script( UOExecutor* uoexec ); } namespace Bscript { class Executor; +class ExecutorModule; +class ModuleFunction; class String; class Token; -class ModuleFunction; -class ExecutorModule; #ifdef ESCRIPT_PROFILE #include + struct profile_instr { unsigned long sum; @@ -245,9 +252,9 @@ public: void ins_set_member( const Instruction& ins ); void ins_set_member_consume( const Instruction& ins ); void ins_get_member( const Instruction& ins ); - void ins_get_member_id( const Instruction& ins ); // test id - void ins_set_member_id( const Instruction& ins ); // test id - void ins_set_member_id_consume( const Instruction& ins ); // test id + void ins_get_member_id( const Instruction& ins ); // test id + void ins_set_member_id( const Instruction& ins ); // test id + void ins_set_member_id_consume( const Instruction& ins ); // test id void ins_set_member_id_consume_plusequal( const Instruction& ins ); // test id void ins_set_member_id_consume_minusequal( const Instruction& ins ); // test id void ins_set_member_id_consume_timesequal( const Instruction& ins ); // test id @@ -372,7 +379,7 @@ private: ref_ptr prog_; bool prog_ok_; bool viewmode_; - + bool runs_to_completion_; bool debugging_; @@ -468,7 +475,6 @@ inline void Executor::set_running_to_completion( bool to_completion ) { runs_to_completion_ = to_completion; } - } } #endif diff --git a/pol-core/bscript/fmodule.cpp b/pol-core/bscript/fmodule.cpp index 493767a86..35ceb30f6 100644 --- a/pol-core/bscript/fmodule.cpp +++ b/pol-core/bscript/fmodule.cpp @@ -5,12 +5,10 @@ #include "fmodule.h" -#include "userfunc.h" - -#include "../clib/clib.h" - #include +#include "userfunc.h" + namespace Pol { namespace Bscript @@ -20,9 +18,7 @@ ModuleFunction::ModuleFunction( const char* fname, int i_nargs, UserFunction* i_ { } -ModuleFunction::~ModuleFunction() -{ -} +ModuleFunction::~ModuleFunction() {} FunctionalityModule::FunctionalityModule( const char* i_modname ) : have_indexes( false ), modulename( i_modname ) diff --git a/pol-core/bscript/fmodule.h b/pol-core/bscript/fmodule.h index 43d0e420b..bd3d2d18c 100644 --- a/pol-core/bscript/fmodule.h +++ b/pol-core/bscript/fmodule.h @@ -7,13 +7,14 @@ #ifndef FMODULE_H #define FMODULE_H -#include "../clib/maputil.h" -#include "../clib/boostutils.h" - #include +#include #include #include +#include "../clib/boostutils.h" +#include "../clib/maputil.h" + namespace Pol { namespace Bscript diff --git a/pol-core/bscript/impstr.h b/pol-core/bscript/impstr.h index 8c820790d..6bf27112a 100644 --- a/pol-core/bscript/impstr.h +++ b/pol-core/bscript/impstr.h @@ -11,8 +11,8 @@ #include "bobject.h" #endif -#include #include +#include namespace Pol { @@ -84,6 +84,7 @@ public: operator const char*() const { return value_.data(); } void remove( const char* s ); virtual bool isTrue() const POL_OVERRIDE { return !value_.empty(); } + public: virtual BObjectImp* selfPlusObjImp( const BObjectImp& objimp ) const POL_OVERRIDE; virtual BObjectImp* selfPlusObj( const BObjectImp& objimp ) const POL_OVERRIDE; diff --git a/pol-core/bscript/modules.h b/pol-core/bscript/modules.h index cdaed3965..e6667fce9 100644 --- a/pol-core/bscript/modules.h +++ b/pol-core/bscript/modules.h @@ -10,10 +10,7 @@ namespace Pol { namespace Bscript { -typedef enum -{ - Mod_Basic -} ModuleID; +typedef enum { Mod_Basic } ModuleID; } } #endif diff --git a/pol-core/bscript/object.cpp b/pol-core/bscript/object.cpp index 1a8097afc..01a98e1b6 100644 --- a/pol-core/bscript/object.cpp +++ b/pol-core/bscript/object.cpp @@ -8,27 +8,27 @@ * - 2009/12/21 Turley: ._method() call fix */ -#include "bobject.h" -#include "objmembers.h" -#include "objmethods.h" +#include +#include +#include +#include +#include "../clib/clib.h" +#include "../clib/fixalloc.h" +#include "../clib/logfacility.h" +#include "../clib/random.h" +#include "../clib/rawtypes.h" +#include "../clib/refptr.h" +#include "../clib/stlutil.h" #include "berror.h" +#include "bobject.h" #include "bstruct.h" #include "dict.h" -#include "escriptv.h" #include "executor.h" #include "impstr.h" #include "object.h" - -#include "../clib/clib.h" -#include "../clib/logfacility.h" -#include "../clib/random.h" -#include "../clib/stlutil.h" - -#include -#include -#include -#include +#include "objmembers.h" +#include "objmethods.h" #if BOBJECTIMP_DEBUG #include diff --git a/pol-core/bscript/objmembers.h b/pol-core/bscript/objmembers.h index b52834cd7..98d4b7d21 100644 --- a/pol-core/bscript/objmembers.h +++ b/pol-core/bscript/objmembers.h @@ -96,7 +96,7 @@ enum MemberID MBR_ATTACHED, MBR_CLIENTVERSION, MBR_REPORTABLES, // 60 - MBR_SCRIPT, // npc + MBR_SCRIPT, // npc MBR_NPCTEMPLATE, MBR_MASTER, MBR_PROCESS, @@ -105,15 +105,15 @@ enum MemberID MBR_SPEECH_FONT, MBR_USE_ADJUSTMENTS, MBR_RUN_SPEED, - MBR_LOCKED, // lockable //70 + MBR_LOCKED, // lockable //70 MBR_CORPSETYPE, // corpse - MBR_TILLERMAN, // boat + MBR_TILLERMAN, // boat MBR_PORTPLANK, MBR_STARBOARDPLANK, MBR_HOLD, // 75 MBR_HAS_OFFLINE_MOBILES, MBR_COMPONENTS, // house - MBR_ITEMS, // multi + MBR_ITEMS, // multi MBR_MOBILES, MBR_XEAST, // map //80 MBR_XWEST, @@ -121,11 +121,11 @@ enum MemberID MBR_YSOUTH, MBR_GUMPWIDTH, MBR_GUMPHEIGHT, // 85 - MBR_ISOPEN, // door - MBR_QUALITY, // equipment + MBR_ISOPEN, // door + MBR_QUALITY, // equipment MBR_HP, MBR_MAXHP_MOD, - MBR_MAXHP, // 90 + MBR_MAXHP, // 90 MBR_DMG_MOD, // weapon MBR_ATTRIBUTE, MBR_INTRINSIC, diff --git a/pol-core/bscript/objmethods.h b/pol-core/bscript/objmethods.h index aebaa3c97..4cd408f2a 100644 --- a/pol-core/bscript/objmethods.h +++ b/pol-core/bscript/objmethods.h @@ -26,7 +26,7 @@ namespace Bscript { enum MethodID { - MTH_ISA, // uobject //0 + MTH_ISA, // uobject //0 MTH_SET_MEMBER, // 1 MTH_GET_MEMBER, MTH_SETPOISONED, // character @@ -44,10 +44,10 @@ enum MethodID MTH_GETGOTTENITEM, // 15 MTH_CLEARGOTTENITEM, MTH_SETWARMODE, - MTH_SETMASTER, // npc + MTH_SETMASTER, // npc MTH_MOVE_OFFLINE_MOBILES, // boat - MTH_SETCUSTOM, // house //20 - MTH_GETPINS, // map + MTH_SETCUSTOM, // house //20 + MTH_GETPINS, // map MTH_INSERTPIN, MTH_APPENDPIN, MTH_ERASEPIN, @@ -65,7 +65,7 @@ enum MethodID MTH_SETPROP, MTH_ERASEPROP, MTH_PROPNAMES, - MTH_ISMEMBER, // guild + MTH_ISMEMBER, // guild MTH_ISALLYGUILD, // 40 MTH_ISENEMYGUILD, MTH_ADDMEMBER, @@ -96,12 +96,12 @@ enum MethodID MTH_SETSTRING, MTH_SETUNICODESTRING, MTH_GETSIZE, - MTH_SETSIZE, // 70 + MTH_SETSIZE, // 70 MTH_CREATEELEMENT, // datastore MTH_FINDELEMENT, MTH_DELETEELEMENT, MTH_SENDEVENT, // script - MTH_KILL, // 75 + MTH_KILL, // 75 MTH_LOADSYMBOLS, MTH_SET_UO_EXPANSION, MTH_CLEAR_EVENT_QUEUE, diff --git a/pol-core/bscript/objstrm.cpp b/pol-core/bscript/objstrm.cpp index da5af8029..95a80cfe8 100644 --- a/pol-core/bscript/objstrm.cpp +++ b/pol-core/bscript/objstrm.cpp @@ -7,7 +7,7 @@ #include "bobject.h" #include "impstr.h" -#include "../../lib/format/format.h" +#include #include namespace Pol @@ -88,7 +88,7 @@ void BLong::printOn( std::ostream& os ) const void BBoolean::printOn( std::ostream& os ) const { - os << (bval_ ? "true" : "false"); + os << ( bval_ ? "true" : "false" ); } } } diff --git a/pol-core/bscript/parser.cpp b/pol-core/bscript/parser.cpp index 26ff2fb6c..9501c1960 100644 --- a/pol-core/bscript/parser.cpp +++ b/pol-core/bscript/parser.cpp @@ -42,38 +42,29 @@ #include "parser.h" -#include "fmodule.h" -#include "modules.h" -#include "symcont.h" -#include "tokens.h" -#include "userfunc.h" -#include "verbtbl.h" -#include "compctx.h" - -#include "compilercfg.h" - -#include "objmembers.h" -#include "objmethods.h" - -#include "../clib/clib.h" -#include "../clib/logfacility.h" -#include "../clib/maputil.h" -#include "../clib/strutil.h" -#include "../clib/unittest.h" -#include "../clib/passert.h" #include #include -#include #include #include - -#include -#include -#include +#include #include #include -#include +#include +#include "../clib/clib.h" +#include "../clib/logfacility.h" +#include "../clib/passert.h" +#include "../clib/rawtypes.h" +#include "../clib/strutil.h" +#include "../clib/unittest.h" +#include "compctx.h" +#include "compilercfg.h" +#include "fmodule.h" +#include "modules.h" +#include "objmembers.h" +#include "objmethods.h" +#include "token.h" +#include "tokens.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // stricmp, strtok POSIX deprecation warning @@ -2001,7 +1992,8 @@ int SmartParser::getArgs( Expression& expr, CompilerContext& ctx ) res = IIP( expr, ctx, EXPR_FLAG_SEMICOLON_TERM_ALLOWED | EXPR_FLAG_COMMA_TERM_ALLOWED ); break; } - // FALLTHROUGH if left paren specified + // if left paren specified + // FALLTHROUGH default: // for more than one arg, or voluntary left paren on single // arg, so parens are required diff --git a/pol-core/bscript/parser.h b/pol-core/bscript/parser.h index f067b9dbc..31b5ef29f 100644 --- a/pol-core/bscript/parser.h +++ b/pol-core/bscript/parser.h @@ -8,10 +8,22 @@ #ifndef __PARSER_H #define __PARSER_H -#include #include +#include +#include #include "../clib/compilerspecifics.h" +#include "tokens.h" + +namespace Pol +{ +namespace Bscript +{ +class ModuleFunction; +class Token; +class UserFunction; +} // namespace Bscript +} // namespace Pol #ifndef __TOKEN_H #include "token.h" @@ -23,13 +35,14 @@ #include #include #include + namespace Pol { namespace Bscript { class CompilerContext; -typedef enum -{ + +typedef enum { PERR_NONE, PERR_UNEXRPAREN, // unexpected RIGHT Paren PERR_MISSLPAREN, @@ -138,6 +151,7 @@ class SmartParser : public Parser { public: virtual ~SmartParser() {} + protected: virtual int tryLiteral( Token& tok, CompilerContext& ctx ) POL_OVERRIDE; diff --git a/pol-core/bscript/str.cpp b/pol-core/bscript/str.cpp index 40fcfeb95..e87086ded 100644 --- a/pol-core/bscript/str.cpp +++ b/pol-core/bscript/str.cpp @@ -8,17 +8,17 @@ * sense. */ -#include "impstr.h" +#include +#include +#include #include "../clib/stlutil.h" #include "berror.h" #include "bobject.h" #include "executor.h" +#include "impstr.h" #include "objmethods.h" -#include -#include - #ifdef __GNUG__ #include #endif diff --git a/pol-core/bscript/symcont.cpp b/pol-core/bscript/symcont.cpp index 5156c2ca4..45ad96371 100644 --- a/pol-core/bscript/symcont.cpp +++ b/pol-core/bscript/symcont.cpp @@ -7,14 +7,12 @@ #include "symcont.h" -#include "../clib/strutil.h" -#include "../clib/logfacility.h" - #include -#include #include +#include -#include +#include "../clib/logfacility.h" +#include "../clib/strutil.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // deprecation warning for strcpy, fopen diff --git a/pol-core/bscript/symcont.h b/pol-core/bscript/symcont.h index 67bd1efa9..24569a6fc 100644 --- a/pol-core/bscript/symcont.h +++ b/pol-core/bscript/symcont.h @@ -9,6 +9,7 @@ #include +#include "../clib/compilerspecifics.h" #include "../clib/rawtypes.h" #ifndef __TOKENS_H @@ -36,7 +37,7 @@ public: BTokenType aType = TYP_CONTROL, unsigned aOffset = 0 //, // unsigned aNargs = 0 - ); + ); } POSTSTRUCT_PACK; #ifdef _MSC_VER #pragma pack( pop ) diff --git a/pol-core/bscript/tkn_strm.cpp b/pol-core/bscript/tkn_strm.cpp index 6e94d93f1..c2fb05421 100644 --- a/pol-core/bscript/tkn_strm.cpp +++ b/pol-core/bscript/tkn_strm.cpp @@ -4,14 +4,14 @@ */ -#include "token.h" -#include "tokens.h" -#include "modules.h" +#include +#include +#include #include "objmembers.h" #include "objmethods.h" - -#include +#include "token.h" +#include "tokens.h" namespace Pol { @@ -475,4 +475,4 @@ fmt::Writer& operator<<( fmt::Writer& w, const Token& tok ) return w; } } -} \ No newline at end of file +} diff --git a/pol-core/bscript/token.cpp b/pol-core/bscript/token.cpp index 1f12bc4f7..563090463 100644 --- a/pol-core/bscript/token.cpp +++ b/pol-core/bscript/token.cpp @@ -6,11 +6,8 @@ #include "token.h" -#include "../clib/esignal.h" - #include #include -#include namespace Pol { diff --git a/pol-core/bscript/token.h b/pol-core/bscript/token.h index d9bd56caf..f56f05915 100644 --- a/pol-core/bscript/token.h +++ b/pol-core/bscript/token.h @@ -14,11 +14,12 @@ #include "modules.h" #endif -#include "options.h" -#include "../../lib/format/format.h" - #include #include + +#include +#include "options.h" + namespace Pol { namespace Bscript @@ -38,15 +39,13 @@ public: BTokenId id; BTokenType type; double dval; - union - { + union { int precedence; int sourceFile; }; int dbg_filenum; int dbg_linenum; - union - { + union { int lval; const unsigned char* dataptr; }; diff --git a/pol-core/bscript/tokens.h b/pol-core/bscript/tokens.h index 4e4fe1ccd..e01fd9257 100644 --- a/pol-core/bscript/tokens.h +++ b/pol-core/bscript/tokens.h @@ -7,8 +7,10 @@ #ifndef __TOKENS_H #define __TOKENS_H -#include "../clib/stlutil.h" +#include + #include "../clib/rawtypes.h" +#include "../clib/stlutil.h" namespace Pol { diff --git a/pol-core/bscript/userfunc.cpp b/pol-core/bscript/userfunc.cpp index 7676d8ee6..8c8ce64bb 100644 --- a/pol-core/bscript/userfunc.cpp +++ b/pol-core/bscript/userfunc.cpp @@ -6,6 +6,9 @@ #include "userfunc.h" +#include + +#include #include "../clib/logfacility.h" namespace Pol @@ -49,8 +52,6 @@ UserFunction::UserFunction() { } -UserFunction::~UserFunction() -{ +UserFunction::~UserFunction() {} } } -} \ No newline at end of file diff --git a/pol-core/bscript/userfunc.h b/pol-core/bscript/userfunc.h index e7b8f0203..c6efc708e 100644 --- a/pol-core/bscript/userfunc.h +++ b/pol-core/bscript/userfunc.h @@ -7,12 +7,12 @@ #ifndef BSCRIPT_USERFUNC_H #define BSCRIPT_USERFUNC_H -#include "compctx.h" -#include "token.h" - +#include #include #include -#include + +#include "compctx.h" +#include "token.h" namespace Pol { diff --git a/pol-core/clib/CMakeLists.txt b/pol-core/clib/CMakeLists.txt index ade007051..6e026b2ce 100644 --- a/pol-core/clib/CMakeLists.txt +++ b/pol-core/clib/CMakeLists.txt @@ -1,14 +1,17 @@ -############################################################################### +set(lib_name clib) -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../../cmake/CMakeEnvironment.txt) +if(windows) + set (COND_SOURCES # sorted ! + ../../lib/StackWalker/StackWalker.cpp + mdump.cpp + msjexhnd.cpp + strexcpt.cpp + ) +endif() -MESSAGE("####################################") -MESSAGE("##### Building POL - CLIB") -MESSAGE("####################################") - -############################################################################### # define source files -SET (SOURCES # sorted ! +add_library(${lib_name} STATIC + # sorted ! ../../lib/format/format.cc Header_Windows.h Debugging/ExceptionParser.cpp @@ -48,72 +51,23 @@ SET (SOURCES # sorted ! wallclock.cpp wnsckt.cpp xmain.cpp + ${COND_SOURCES} ) -IF(WINDOWS) - SET (SOURCES # sorted ! - ${SOURCES} - ../../lib/StackWalker/StackWalker.cpp #TODO: cleanup for this hack - mdump.cpp - msjexhnd.cpp - strexcpt.cpp - ) -ENDIF() +set_compile_flags(${lib_name} 0) -############################################################## -# include dirs -SET (INCLUDE_DIRS - ../.. - ../ - ./ - ./Debugging - ./Program -) +use_benchmark(${lib_name}) -############################################################## -# set directory for internal libs -SET (LIB_DIRS - ${LIB_DIRS} - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# Linux specific dependencies -SET (LIBS_LINUX +if (${linux}) + target_link_libraries(${lib_name} PUBLIC crypto pthread -) -IF (DEFINED ENABLE_BENCHMARK) - SET (LIBS_LINUX - ${LIBS_LINUX} - benchmark ) -ENDIF() - -############################################################## -# Windows specific dependencies -SET (LIBS_WINDOWS +elseif(${windows}) + target_link_libraries(${lib_name} PUBLIC ws2_32 Psapi DbgHelp # crypto -) + ) +endif() -############################################################## -# define target directory -SET (TARGET_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# define binary name -SET (TARGET_LIB_NAME - clib -) - -############################################################## -# include CMake core -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CMakeCore.txt) - -IF(NOT EXISTS "${BOOST_SOURCE_DIR}/boost") -ADD_DEPENDENCIES(clib boost) -ENDIF() diff --git a/pol-core/clib/Debugging/ExceptionParser.cpp b/pol-core/clib/Debugging/ExceptionParser.cpp index 0f86d1c19..efb74a466 100644 --- a/pol-core/clib/Debugging/ExceptionParser.cpp +++ b/pol-core/clib/Debugging/ExceptionParser.cpp @@ -1,8 +1,9 @@ #include "ExceptionParser.h" + +#include #include "../Program/ProgramConfig.h" -#include "LogSink.h" -#include "../threadhelp.h" #include "../logfacility.h" +#include "../threadhelp.h" #ifdef WINDOWS #include "../pol_global_config_win.h" @@ -10,20 +11,21 @@ #include "pol_global_config.h" #endif +#include #include +#include #include #include -#include -#include +#include #ifndef WINDOWS #include +#include +#include #include #include -#include -#include #include -#include + #define SOCKET int #else #include "../Header_Windows.h" @@ -48,7 +50,8 @@ std::string ExceptionParser::m_programStart = Pol::Clib::Logging::LogSink::getTi /////////////////////////////////////////////////////////////////////////////// -namespace { +namespace +{ void getSignalDescription( int signal, string& signalName, string& signalDescription ) { switch ( signal ) @@ -313,7 +316,7 @@ void doHttpPOST( const string& host, const string& url, const string& content ) closesocket( socketFD ); #endif } -} // namespace +} // namespace void ExceptionParser::reportProgramAbort( const string& stackTrace, const string& reason ) { @@ -432,15 +435,11 @@ void ExceptionParser::handleExceptionSignal( int signal ) /////////////////////////////////////////////////////////////////////////////// -ExceptionParser::ExceptionParser() -{ -} +ExceptionParser::ExceptionParser() {} -ExceptionParser::~ExceptionParser() -{ -} +ExceptionParser::~ExceptionParser() {} -/////////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////////// #ifndef _WIN32 string ExceptionParser::getTrace() @@ -661,13 +660,9 @@ string ExceptionParser::getTrace() return result; } -void ExceptionParser::logAllStackTraces() -{ -} +void ExceptionParser::logAllStackTraces() {} -void ExceptionParser::initGlobalExceptionCatching() -{ -} +void ExceptionParser::initGlobalExceptionCatching() {} #endif // _WIN32 void ExceptionParser::configureProgramAbortReportingSystem( bool active, std::string server, diff --git a/pol-core/clib/Debugging/LogSink.cpp b/pol-core/clib/Debugging/LogSink.cpp index f1b0fab9f..6014e82d4 100644 --- a/pol-core/clib/Debugging/LogSink.cpp +++ b/pol-core/clib/Debugging/LogSink.cpp @@ -1,7 +1,9 @@ #include "LogSink.h" -#include "../clib.h" #include +#include + +#include "../clib.h" namespace Pol { @@ -14,13 +16,9 @@ using std::chrono::system_clock; /////////////////////////////////////////////////////////////////////////////// -LogSink::LogSink() -{ -} +LogSink::LogSink() {} -LogSink::~LogSink() -{ -} +LogSink::~LogSink() {} /////////////////////////////////////////////////////////////////////////////// diff --git a/pol-core/clib/Debugging/LogSink.h b/pol-core/clib/Debugging/LogSink.h index 4f3411b66..50ecf3179 100644 --- a/pol-core/clib/Debugging/LogSink.h +++ b/pol-core/clib/Debugging/LogSink.h @@ -6,11 +6,12 @@ Remove the include in all StdAfx.h files or live with the consequences :) #ifndef CLIB_LOG_SINK_H #define CLIB_LOG_SINK_H -#include "../../../lib/format/format.h" - #include +#include #include +#include + namespace Pol { namespace Clib diff --git a/pol-core/clib/Header_Windows.h b/pol-core/clib/Header_Windows.h index 89a35c440..8e15cbd9e 100644 --- a/pol-core/clib/Header_Windows.h +++ b/pol-core/clib/Header_Windows.h @@ -25,7 +25,7 @@ #include #include -#pragma warning( pop ) // unused typedef in dbghelp.h +#pragma warning( pop ) // unused typedef in dbghelp.h //#define snprintf _snprintf diff --git a/pol-core/clib/NTService.cpp b/pol-core/clib/NTService.cpp index a7fdf0927..f6b83a534 100644 --- a/pol-core/clib/NTService.cpp +++ b/pol-core/clib/NTService.cpp @@ -6,10 +6,10 @@ */ -#include "Header_Windows.h" -#include #include "NTService.h" +#include "Header_Windows.h" #include "ntservmsg.h" // Event message ids +#include #ifdef _MSC_VER #pragma warning( disable : 4996 ) diff --git a/pol-core/clib/Program/ProgramConfig.cpp b/pol-core/clib/Program/ProgramConfig.cpp index c2eb27218..40a4e6eaa 100644 --- a/pol-core/clib/Program/ProgramConfig.cpp +++ b/pol-core/clib/Program/ProgramConfig.cpp @@ -14,12 +14,8 @@ std::string ProgramConfig::m_programDir = ""; /////////////////////////////////////////////////////////////////////////////// -ProgramConfig::ProgramConfig() -{ -} -ProgramConfig::~ProgramConfig() -{ -} +ProgramConfig::ProgramConfig() {} +ProgramConfig::~ProgramConfig() {} /////////////////////////////////////////////////////////////////////////////// diff --git a/pol-core/clib/Program/ProgramMain.cpp b/pol-core/clib/Program/ProgramMain.cpp index ec63b164e..08744bde1 100644 --- a/pol-core/clib/Program/ProgramMain.cpp +++ b/pol-core/clib/Program/ProgramMain.cpp @@ -1,10 +1,10 @@ #include "ProgramMain.h" -#include "ProgramConfig.h" -#include "../Debugging/ExceptionParser.h" -#include "../clib.h" +#include + +#include "../Debugging/ExceptionParser.h" #include "../logfacility.h" -#include "../strexcpt.h" +#include "ProgramConfig.h" #ifdef WINDOWS #include "../pol_global_config_win.h" @@ -17,14 +17,16 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN -#include // for GetModuleFileName #include #include +#include // for GetModuleFileName + #pragma comment( lib, "psapi.lib" ) // 32bit is a bit dumb.. #else -#include -#include #endif +#include +#include +#include #include #include @@ -36,12 +38,8 @@ using namespace std; /////////////////////////////////////////////////////////////////////////////// -ProgramMain::ProgramMain() -{ -} -ProgramMain::~ProgramMain() -{ -} +ProgramMain::ProgramMain() {} +ProgramMain::~ProgramMain() {} /////////////////////////////////////////////////////////////////////////////// void ProgramMain::start( int argc, char* argv[] ) @@ -51,7 +49,8 @@ void ProgramMain::start( int argc, char* argv[] ) Clib::Logging::initLogging( &logger ); Clib::ExceptionParser::initGlobalExceptionCatching(); - setlocale( LC_TIME, "" ); + std::setlocale( LC_TIME, "" ); + int exitcode = 0; try @@ -150,8 +149,8 @@ bool ProgramMain::programArgsFind( const std::string& filter, std::string* rest case '-': if ( param.substr( 1, filter.size() ) == filter ) { - if (rest != nullptr ) - *rest = param.substr( 1 + filter.size(), param.size() - ( 1 + filter.size() ) ); + if ( rest != nullptr ) + *rest = param.substr( 1 + filter.size(), param.size() - ( 1 + filter.size() ) ); return true; } break; diff --git a/pol-core/clib/StdAfx.h b/pol-core/clib/StdAfx.h index 0fc6ebcb4..c63de3198 100644 --- a/pol-core/clib/StdAfx.h +++ b/pol-core/clib/StdAfx.h @@ -41,26 +41,26 @@ #include // 3rd Party Includes +#include #include #include #include #include -#include "../../lib/format/format.h" // Project Includes (be really really carefull what to include!) // explicit included since needed anyway for later includes -#include "compilerspecifics.h" #include "Debugging/LogSink.h" +#include "compilerspecifics.h" #include "message_queue.h" -#include "passert.h" +#include "fixalloc.h" #include "logfacility.h" +#include "passert.h" +#include "rawtypes.h" +#include "refptr.h" #include "stlutil.h" #include "strutil.h" -#include "rawtypes.h" -#include "fixalloc.h" -#include "refptr.h" #include "weakptr.h" #endif // _CLIB_STDAFX_H diff --git a/pol-core/clib/binaryfile.cpp b/pol-core/clib/binaryfile.cpp index 050e0f594..e7dd57c85 100644 --- a/pol-core/clib/binaryfile.cpp +++ b/pol-core/clib/binaryfile.cpp @@ -9,27 +9,23 @@ #include "binaryfile.h" +#include + #include "passert.h" #include "strutil.h" -#include - namespace Pol { namespace Clib { -BinaryFile::BinaryFile() -{ -} +BinaryFile::BinaryFile() {} BinaryFile::BinaryFile( const std::string& filename, std::ios::openmode mode ) : _filename( "" ) { Open( filename, mode ); } -BinaryFile::~BinaryFile() -{ -} +BinaryFile::~BinaryFile() {} void BinaryFile::Open( const std::string& filename, std::ios::openmode mode ) { @@ -108,4 +104,4 @@ size_t BinaryFile::sizeEstimate() const return size; } } -} \ No newline at end of file +} diff --git a/pol-core/clib/binaryfile.h b/pol-core/clib/binaryfile.h index 0d79caa5a..560baf4e5 100644 --- a/pol-core/clib/binaryfile.h +++ b/pol-core/clib/binaryfile.h @@ -8,6 +8,7 @@ #define CLIB_BINARYFILE_H #include +#include #include namespace Pol diff --git a/pol-core/clib/boostutils.h b/pol-core/clib/boostutils.h index a3e1c9ea4..b1fbe531a 100644 --- a/pol-core/clib/boostutils.h +++ b/pol-core/clib/boostutils.h @@ -17,17 +17,16 @@ #endif #ifdef DEBUG_FLYWEIGHT -#include -#include - #include #include -#include -#include -#include +#include #include #include -#include +#include +#include +#include +#include +#include #include "compilerspecifics.h" #endif @@ -65,8 +64,9 @@ class accessible_hashed_factory_class : public boost::flyweights::factory_marker }; typedef boost::multi_index::multi_index_container< - Entry, index_list, typename boost::mpl::if_, - std::allocator, Allocator>::type> + Entry, index_list, + typename boost::mpl::if_, std::allocator, + Allocator>::type> container_type; public: @@ -125,12 +125,14 @@ struct cprop_name_tag { }; typedef boost::flyweight, - FLYWEIGHT_HASH_FACTORY> cprop_name_flystring; + FLYWEIGHT_HASH_FACTORY> + cprop_name_flystring; struct cprop_value_tag { }; typedef boost::flyweight, - FLYWEIGHT_HASH_FACTORY> cprop_value_flystring; + FLYWEIGHT_HASH_FACTORY> + cprop_value_flystring; struct cfg_key_tag { }; @@ -140,22 +142,26 @@ struct object_name_tag { }; typedef boost::flyweight, - FLYWEIGHT_HASH_FACTORY> object_name_flystring; + FLYWEIGHT_HASH_FACTORY> + object_name_flystring; struct script_name_tag { }; typedef boost::flyweight, - FLYWEIGHT_HASH_FACTORY> script_name_flystring; + FLYWEIGHT_HASH_FACTORY> + script_name_flystring; struct npctemplate_name_tag { }; typedef boost::flyweight, - FLYWEIGHT_HASH_FACTORY> npctemplate_name_flystring; + FLYWEIGHT_HASH_FACTORY> + npctemplate_name_flystring; struct function_name_tag { }; typedef boost::flyweight, - FLYWEIGHT_HASH_FACTORY> function_name_flystring; + FLYWEIGHT_HASH_FACTORY> + function_name_flystring; /** * These types must be initialized before any static objects using them diff --git a/pol-core/clib/cfgfile.cpp b/pol-core/clib/cfgfile.cpp index c0697b995..b8d4b8fcf 100644 --- a/pol-core/clib/cfgfile.cpp +++ b/pol-core/clib/cfgfile.cpp @@ -9,18 +9,18 @@ #include "cfgfile.h" -#include "clib.h" -#include "clibopt.h" -#include "cfgelem.h" -#include "stlutil.h" -#include "strutil.h" -#include "logfacility.h" - -#include -#include +#include +#include #include #include -#include +#include + +#include +#include "cfgelem.h" +#include "clib.h" +#include "logfacility.h" +#include "stlutil.h" +#include "strutil.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // disable POSIX deprecation warnings for stricmp @@ -41,7 +41,7 @@ bool commentline( const std::string& str ) return ( ( str[0] == '#' ) || ( str.compare( 0, 2, "//" ) == 0 ) ); #endif } -} // namespace +} // namespace ConfigProperty::ConfigProperty( const char* name, const char* value ) : name_( name ), value_( value ) @@ -59,25 +59,17 @@ ConfigProperty::ConfigProperty( std::string* pname, std::string* pvalue ) pvalue->swap( value_ ); } -ConfigProperty::~ConfigProperty() -{ -} +ConfigProperty::~ConfigProperty() {} -ConfigElemBase::ConfigElemBase() : type_( "" ), rest_( "" ), _source( NULL ) -{ -} +ConfigElemBase::ConfigElemBase() : type_( "" ), rest_( "" ), _source( NULL ) {} size_t ConfigElemBase::estimateSize() const { return type_.capacity() + rest_.capacity() + sizeof( _source ); } -ConfigElem::ConfigElem() : ConfigElemBase() -{ -} +ConfigElem::ConfigElem() : ConfigElemBase() {} -ConfigElem::~ConfigElem() -{ -} +ConfigElem::~ConfigElem() {} size_t ConfigElem::estimateSize() const { @@ -790,7 +782,7 @@ bool ConfigFile::readline( std::string& strbuf ) char* nl = strchr( buffer, '\n' ); if ( nl ) { - if ( nl != buffer && *(nl-1) == '\r' ) + if ( nl != buffer && *( nl - 1 ) == '\r' ) --nl; *nl = '\0'; strbuf += buffer; diff --git a/pol-core/clib/cfgfile.h b/pol-core/clib/cfgfile.h index b4800b510..689dab163 100644 --- a/pol-core/clib/cfgfile.h +++ b/pol-core/clib/cfgfile.h @@ -23,17 +23,18 @@ #include #include +#include #include -#include "maputil.h" #include "compilerspecifics.h" +#include "maputil.h" namespace Pol { namespace Clib { -class ConfigElemBase; class ConfigElem; +class ConfigElemBase; class VectorConfigElem; class ConfigSource diff --git a/pol-core/clib/cfgsect.cpp b/pol-core/clib/cfgsect.cpp index 79a3cac26..c491ba256 100644 --- a/pol-core/clib/cfgsect.cpp +++ b/pol-core/clib/cfgsect.cpp @@ -9,8 +9,6 @@ #include "cfgelem.h" #include "cfgfile.h" -#include - namespace Pol { namespace Clib @@ -21,7 +19,7 @@ ConfigSection::ConfigSection( ConfigFile& cf, const std::string& sectname, unsig _cf.allowed_types_.insert( sectname.c_str() ); } -ConfigSection::~ConfigSection() +ConfigSection::~ConfigSection() noexcept(false) { if ( !_found && ( _flags & CST_MANDATORY ) ) { @@ -48,4 +46,4 @@ bool ConfigSection::matches( const ConfigElem& elem ) } } } -} \ No newline at end of file +} diff --git a/pol-core/clib/cfgsect.h b/pol-core/clib/cfgsect.h index 9ca6979a7..acaf76965 100644 --- a/pol-core/clib/cfgsect.h +++ b/pol-core/clib/cfgsect.h @@ -25,7 +25,7 @@ class ConfigSection public: ConfigSection( ConfigFile& cf, const std::string& sectname, unsigned flags = CST_MANDATORY | CST_UNIQUE ); - ~ConfigSection(); + ~ConfigSection() noexcept(false); ConfigSection& operator=( const ConfigSection& ) { return *this; } bool matches( const ConfigElem& elem ); diff --git a/pol-core/clib/clib-2012.vcxproj b/pol-core/clib/clib-2012.vcxproj deleted file mode 100644 index e20ed88fe..000000000 --- a/pol-core/clib/clib-2012.vcxproj +++ /dev/null @@ -1,329 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - clib - {7CD5572B-8A78-46C5-AC2D-39EE47ACD01A} - clib - - - - StaticLibrary - false - MultiByte - v110 - - - StaticLibrary - false - MultiByte - v110 - - - StaticLibrary - false - MultiByte - v110_xp - - - StaticLibrary - false - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\Release\ - .\Release\x64/ - .\Release\ - .\Release\x64/ - .\Debug\ - .\Debug\x64/ - .\Debug\ - .\Debug\x64/ - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - $(IncludePath) - $(IncludePath) - $(ReferencePath) - $(ReferencePath) - $(LibraryPath) - $(LibraryPath) - - - - true - %(AdditionalIncludeDirectories) - NDEBUG;_LIB;NOMINMAX;%(PreprocessorDefinitions) - true - Sync - MultiThreaded - false - true - true - .\Release/clib.pch - .\Release/ - .\Release/ - .\Release/ - Level4 - true - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - .\Release\clib.lib - true - ..\..\lib\boost_1_55_0\lib\x86\lib - - - - - true - %(AdditionalIncludeDirectories) - NDEBUG;_LIB;NOMINMAX;%(PreprocessorDefinitions) - true - Sync - MultiThreaded - false - true - true - .\Release/x64/clib.pch - .\Release/x64/ - .\Release/x64/ - .\Release/x64/ - Level4 - true - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - .\Release\x64/clib.lib - true - MachineX64 - ..\..\lib\boost_1_55_0\lib\x64\lib - - - - - /EHac %(AdditionalOptions) - Disabled - %(AdditionalIncludeDirectories) - _DEBUG;_LIB;NOMINMAX;%(PreprocessorDefinitions) - - - EnableFastChecks - MultiThreadedDebug - true - .\Debug/clib.pch - .\Debug/ - .\Debug/ - .\Debug/ - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - .\Debug\clib.lib - true - ..\..\lib\boost_1_55_0\lib\x86\lib - - - - - /EHac %(AdditionalOptions) - Disabled - %(AdditionalIncludeDirectories) - _DEBUG;_LIB;NOMINMAX;_WIN64;%(PreprocessorDefinitions) - - - EnableFastChecks - MultiThreadedDebug - true - .\Debug/x64/clib.pch - .\Debug/x64/ - .\Debug/x64/ - .\Debug/x64/ - Level4 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - .\Debug\x64/clib.lib - true - ..\..\lib\boost_1_55_0\lib\x64\lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pol-core/clib/clib-2012.vcxproj.filters b/pol-core/clib/clib-2012.vcxproj.filters deleted file mode 100644 index 4cfb2ab69..000000000 --- a/pol-core/clib/clib-2012.vcxproj.filters +++ /dev/null @@ -1,335 +0,0 @@ - - - - - {84831da0-079a-4609-a46e-dace29e7f832} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {82194515-44b9-4a2b-90d7-d62c197c4152} - h;hpp;hxx;hm;inl - - - {5847ce3c-0bd9-4c36-a96c-de8cedaf38b3} - - - {ac8f842c-1bdd-412c-ba83-563baa6fc512} - - - {ec9834bc-ae82-496c-b6f3-4fb73fb3c57b} - - - {de79a169-ffb0-4c0a-9e53-71afb0638fbd} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - tinyxml - - - tinyxml - - - tinyxml - - - tinyxml - - - format - - - Source Files - - - Source Files - - - stackwalker - - - Source Files - - - Debugging - - - Debugging - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - tinyxml - - - tinyxml - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - format - - - Header Files - - - Header Files - - - stackwalker - - - Header Files - - - Header Files - - - Debugging - - - Debugging - - - diff --git a/pol-core/clib/clib.h b/pol-core/clib/clib.h index aa55c6043..48b0e3059 100644 --- a/pol-core/clib/clib.h +++ b/pol-core/clib/clib.h @@ -16,8 +16,8 @@ #ifndef __STDDEF_H #include "stddef.h" #endif -#include #include "rawtypes.h" +#include /** * use instead of c-style (type) casts. @@ -53,7 +53,7 @@ int match( char* a, char* b ); char* strip( char* s ); #ifdef __STDIO_H /* well there you go, not portable... why not standard the idempotent mechanism? \ - */ + */ /** open a unique file in a directory, no sharing allowed, "w+b" */ FILE* uniqfile( char* directory, char* pathname ); #endif @@ -140,7 +140,7 @@ private: /// threadsafe version of localtime -inline std::tm localtime( const std::time_t &t ) +inline std::tm localtime( const std::time_t& t ) { std::tm result; #ifdef _MSC_VER diff --git a/pol-core/clib/clib_MD5.cpp b/pol-core/clib/clib_MD5.cpp index ab0e769bc..fad558b72 100644 --- a/pol-core/clib/clib_MD5.cpp +++ b/pol-core/clib/clib_MD5.cpp @@ -9,17 +9,17 @@ #include "clib_MD5.h" -#include "stlutil.h" -#include "logfacility.h" - -#include #include +#include #ifdef WINDOWS #include "pol_global_config_win.h" #else #include "pol_global_config.h" #endif +#include "logfacility.h" +#include "stlutil.h" + #ifdef WINDOWS #include "Header_Windows.h" #include @@ -90,6 +90,7 @@ void MD5_Cleanup() #elif defined( HAVE_OPENSSL ) #include + namespace Pol { namespace Clib diff --git a/pol-core/clib/clib_utils.cpp b/pol-core/clib/clib_utils.cpp index 2ef69e044..2003b2406 100644 --- a/pol-core/clib/clib_utils.cpp +++ b/pol-core/clib/clib_utils.cpp @@ -5,14 +5,13 @@ #include "clib.h" +#include "rawtypes.h" namespace Pol { namespace Clib { -OnlineStatistics::OnlineStatistics() : _count( 0 ), _max( 0 ), _mean( 0 ), _m2( 0 ) -{ -} +OnlineStatistics::OnlineStatistics() : _count( 0 ), _max( 0 ), _mean( 0 ), _m2( 0 ) {} void OnlineStatistics::update( double value ) { diff --git a/pol-core/clib/compilerspecifics.h b/pol-core/clib/compilerspecifics.h index b1430df55..acf51020d 100644 --- a/pol-core/clib/compilerspecifics.h +++ b/pol-core/clib/compilerspecifics.h @@ -38,7 +38,7 @@ Remove the include in all StdAfx.h files or live with the consequences :) // Note: POL_ANALYZER_NORETURN is just a hint for code analyzers (mostly clang-analyzer) and is not // used for code generation. I don't know of anything similar in the other analyzers and -//thought +// thought // of using POL_NORETURN here. Right now I'm not sure if this is needed at all. #ifndef POL_ANALYZER_NORETURN #ifndef __has_feature @@ -78,14 +78,14 @@ Remove the include in all StdAfx.h files or live with the consequences :) // the following code to handle NOEXCEPT was obtained // from http://stackoverflow.com/questions/18387640/how-to-deal-with-noexcept-in-visual-studio -#if !defined(HAS_NOEXCEPT) -#if defined(__clang__) -#if __has_feature(cxx_noexcept) +#if !defined( HAS_NOEXCEPT ) +#if defined( __clang__ ) +#if __has_feature( cxx_noexcept ) #define HAS_NOEXCEPT #endif #else -#if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46 || \ - defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026 +#if defined( __GXX_EXPERIMENTAL_CXX0X__ ) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46 || \ + defined( _MSC_FULL_VER ) && _MSC_FULL_VER >= 190023026 #define HAS_NOEXCEPT #endif #endif @@ -97,13 +97,13 @@ Remove the include in all StdAfx.h files or live with the consequences :) #endif #endif -#if (!defined(_MSC_VER) || _MSC_VER >= 1900) +#if ( !defined( _MSC_VER ) || _MSC_VER >= 1900 ) #define THREADLOCAL thread_local #else #define THREADLOCAL __declspec( thread ) #endif -#if (!defined(_MSC_VER) || _MSC_VER >= 1900) +#if ( !defined( _MSC_VER ) || _MSC_VER >= 1900 ) #define CONSTEXPR constexpr #else #define CONSTEXPR diff --git a/pol-core/clib/dirfunc.cpp b/pol-core/clib/dirfunc.cpp index 61f27b99b..f5c48e043 100644 --- a/pol-core/clib/dirfunc.cpp +++ b/pol-core/clib/dirfunc.cpp @@ -5,15 +5,15 @@ */ -#include #include +#include #include -#include #include #include +#include #include #include -#include +#include #pragma hdrstop @@ -122,7 +122,7 @@ void find_usefns( const char* dir, const char* fname ) else use_template = "%s\\%s"; } -} // namespace +} // namespace char* nodefile( const char* directory, const char* filename, int node ) { diff --git a/pol-core/clib/dirfunc.h b/pol-core/clib/dirfunc.h index 7950fa33f..b7a939235 100644 --- a/pol-core/clib/dirfunc.h +++ b/pol-core/clib/dirfunc.h @@ -3,8 +3,8 @@ #define __DIRFUNC_H #if defined( WINDOWS ) -#include #include "Header_Windows.h" +#include #else #include #endif diff --git a/pol-core/clib/dirlist.cpp b/pol-core/clib/dirlist.cpp index f86e4651a..df610c383 100644 --- a/pol-core/clib/dirlist.cpp +++ b/pol-core/clib/dirlist.cpp @@ -5,12 +5,14 @@ #include "dirlist.h" -#include "fileutil.h" + +#include #ifdef __unix__ #include #endif +#include "fileutil.h" #ifdef WINDOWS @@ -73,8 +75,8 @@ void DirList::next() } #else // non-brain dead places where we can use POSIX functions -#include #include + namespace Pol { namespace Clib @@ -84,9 +86,7 @@ DirList::DirList( const char* dirname ) dir_ = opendir( dirname ); next(); } -DirList::DirList() : dir_( NULL ) -{ -} +DirList::DirList() : dir_( NULL ) {} DirList::~DirList() { if ( dir_ != NULL ) diff --git a/pol-core/clib/dirlist.h b/pol-core/clib/dirlist.h index ea34d6e5b..4788e2105 100644 --- a/pol-core/clib/dirlist.h +++ b/pol-core/clib/dirlist.h @@ -12,8 +12,8 @@ #include "Header_Windows.h" #ifndef WINDOWS -#include #include +#include #endif namespace Pol diff --git a/pol-core/clib/esignal.cpp b/pol-core/clib/esignal.cpp index 929ef40a8..9356dfaec 100644 --- a/pol-core/clib/esignal.cpp +++ b/pol-core/clib/esignal.cpp @@ -5,9 +5,6 @@ #include "esignal.h" -#include "logfacility.h" - -#include "Header_Windows.h" #ifndef WINDOWS #include #endif diff --git a/pol-core/clib/fdump.cpp b/pol-core/clib/fdump.cpp index 705524bf4..daa30cfb4 100644 --- a/pol-core/clib/fdump.cpp +++ b/pol-core/clib/fdump.cpp @@ -4,10 +4,7 @@ */ -#include - #include "fdump.h" -#include "logfacility.h" namespace Pol { diff --git a/pol-core/clib/fdump.h b/pol-core/clib/fdump.h index 8e7442ba9..8f47765a0 100644 --- a/pol-core/clib/fdump.h +++ b/pol-core/clib/fdump.h @@ -7,7 +7,7 @@ #ifndef CLIB_FDUMP_H #define CLIB_FDUMP_H -#include "../../lib/format/format.h" +#include namespace Pol { diff --git a/pol-core/clib/filecont.cpp b/pol-core/clib/filecont.cpp index 9461c9f04..78705fea1 100644 --- a/pol-core/clib/filecont.cpp +++ b/pol-core/clib/filecont.cpp @@ -6,9 +6,9 @@ #include "filecont.h" -#include "logfacility.h" #include -#include + +#include "logfacility.h" // disables unsafe warning for fopen #ifdef _MSC_VER @@ -62,4 +62,4 @@ void FileContents::set_contents( const std::string& str ) contents_ = str; } } -} \ No newline at end of file +} diff --git a/pol-core/clib/fileutil.cpp b/pol-core/clib/fileutil.cpp index 0d7abd150..35181cee9 100644 --- a/pol-core/clib/fileutil.cpp +++ b/pol-core/clib/fileutil.cpp @@ -5,10 +5,12 @@ #include "fileutil.h" -#include "dirlist.h" +#include #include +#include "dirlist.h" + #ifdef LINUX #include #else diff --git a/pol-core/clib/fixalloc.h b/pol-core/clib/fixalloc.h index 38eb825ce..07ca75300 100644 --- a/pol-core/clib/fixalloc.h +++ b/pol-core/clib/fixalloc.h @@ -37,8 +37,7 @@ template class fixed_allocator { public: - union Buffer - { + union Buffer { Buffer* next; char data[N]; }; diff --git a/pol-core/clib/forspcnt.cpp b/pol-core/clib/forspcnt.cpp index 40b498b03..b7aeb1c0c 100644 --- a/pol-core/clib/forspcnt.cpp +++ b/pol-core/clib/forspcnt.cpp @@ -5,8 +5,8 @@ #include "Header_Windows.h" -#include #include "clib.h" +#include namespace Pol { diff --git a/pol-core/clib/iohelp.cpp b/pol-core/clib/iohelp.cpp index 03acc03ad..3a39822c4 100644 --- a/pol-core/clib/iohelp.cpp +++ b/pol-core/clib/iohelp.cpp @@ -6,7 +6,6 @@ #include "iohelp.h" -#include #include // note this is only useful if ofs.exceptions( std::ios_base::failbit | std::ios_base::badbit ) is diff --git a/pol-core/clib/iohelp.h b/pol-core/clib/iohelp.h index c55999d04..999e365f5 100644 --- a/pol-core/clib/iohelp.h +++ b/pol-core/clib/iohelp.h @@ -7,8 +7,8 @@ #ifndef CLIB_IOHELP_H #define CLIB_IOHELP_H -#include #include +#include namespace Pol { diff --git a/pol-core/clib/logfacility.cpp b/pol-core/clib/logfacility.cpp index db5b6614e..2c0b7fcc3 100644 --- a/pol-core/clib/logfacility.cpp +++ b/pol-core/clib/logfacility.cpp @@ -12,15 +12,17 @@ POLLOG.Format("hello {}") << "world"; */ #include "logfacility.h" -#include "clib.h" -#include "message_queue.h" +#include #include #include -#include -#include #include -#include +#include +#include +#include + +#include "clib.h" +#include "message_queue.h" namespace Pol { @@ -80,34 +82,31 @@ public: // blocks till the queue is empty void exit() { - send( [&]() - { - _done = true; - } ); + send( [&]() { _done = true; } ); _work_thread.join(); // wait for it } // send msg into queue void send( const msg& msg_ ) { _queue.push( msg_ ); } + private: // endless loop in thread void run() { - _work_thread = std::thread( [&]() - { - while ( !_done ) - { - try - { - msg func; - _queue.pop_wait( &func ); - func(); // execute - } - catch ( std::exception& msg ) - { - std::cout << msg.what() << std::endl; - } - } - } ); + _work_thread = std::thread( [&]() { + while ( !_done ) + { + try + { + msg func; + _queue.pop_wait( &func ); + func(); // execute + } + catch ( std::exception& msg ) + { + std::cout << msg.what() << std::endl; + } + } + } ); } bool _done; msg_queue _queue; @@ -115,9 +114,7 @@ private: }; -LogFacility::LogFacility() : _worker( new LogWorker ) -{ -} +LogFacility::LogFacility() : _worker( new LogWorker ) {} // note this blocks till the worker is finished LogFacility::~LogFacility() @@ -132,18 +129,17 @@ LogFacility::~LogFacility() template void LogFacility::save( fmt::Writer* message, const std::string& id ) { - _worker->send( [message, id]() - { - std::unique_ptr msg( message ); - try - { - getSink()->addMessage( msg.get(), id ); - } - catch ( std::exception& msg ) - { - std::cout << msg.what() << std::endl; - } - } ); + _worker->send( [message, id]() { + std::unique_ptr msg( message ); + try + { + getSink()->addMessage( msg.get(), id ); + } + catch ( std::exception& msg ) + { + std::cout << msg.what() << std::endl; + } + } ); } // register sink for later deconstruction @@ -155,28 +151,19 @@ void LogFacility::registerSink( LogSink* sink ) // disables debuglog void LogFacility::disableDebugLog() { - _worker->send( []() - { - getSink()->disable(); - } ); + _worker->send( []() { getSink()->disable(); } ); } // disables startlog ( activates pol.log ) void LogFacility::deinitializeStartLog() { - _worker->send( []() - { - getSink()->deinitialize_startlog(); - } ); + _worker->send( []() { getSink()->deinitialize_startlog(); } ); } // closes flex sink of given id void LogFacility::closeFlexLog( const std::string& id ) { - _worker->send( [id]() - { - getSink()->close( id ); - } ); + _worker->send( [id]() { getSink()->close( id ); } ); } // register new flex sink with given filename @@ -185,18 +172,16 @@ std::string LogFacility::registerFlexLogger( const std::string& logfilename, boo { auto promise = std::make_shared>(); auto ret = promise->get_future(); - _worker->send( - [=]() - { - try - { - promise->set_value( getSink()->create( logfilename, open_timestamp ) ); - } - catch ( ... ) - { - promise->set_exception( std::current_exception() ); - } - } ); + _worker->send( [=]() { + try + { + promise->set_value( getSink()->create( logfilename, open_timestamp ) ); + } + catch ( ... ) + { + promise->set_exception( std::current_exception() ); + } + } ); return ret.get(); // block wait till valid } @@ -205,23 +190,18 @@ void LogFacility::wait_for_empty_queue() { auto promise = std::make_shared>(); auto ret = promise->get_future(); - _worker->send( [=]() - { - promise->set_value( true ); - } ); + _worker->send( [=]() { promise->set_value( true ); } ); ret.get(); // block wait till valid } // Message default construct template -Message::Message() - : _formater( new fmt::Writer() ), _id( "" ) +Message::Message() : _formater( new fmt::Writer() ), _id( "" ) { } template -Message::Message( const std::string& id ) - : _formater( new fmt::Writer() ), _id( id ) +Message::Message( const std::string& id ) : _formater( new fmt::Writer() ), _id( id ) { } // directly fill on construction the formater with file, line and function @@ -261,12 +241,7 @@ Sink* getSink() // with later vc its automatically threadsafe (magic statics) static std::once_flag flag; static Sink* sink = new Sink(); - std::call_once( flag, - []( Sink* s ) - { - global_logger->registerSink( s ); - }, - sink ); + std::call_once( flag, []( Sink* s ) { global_logger->registerSink( s ); }, sink ); return sink; } @@ -380,9 +355,7 @@ bool LogSinkGenericFile::test_for_rollover( return true; } -LogSink_cout::LogSink_cout() : LogSink() -{ -} +LogSink_cout::LogSink_cout() : LogSink() {} // print given msg into std::cout void LogSink_cout::addMessage( fmt::Writer* msg ) { @@ -394,9 +367,7 @@ void LogSink_cout::addMessage( fmt::Writer* msg, const std::string& ) addMessage( msg ); } -LogSink_cerr::LogSink_cerr() : LogSink() -{ -} +LogSink_cerr::LogSink_cerr() : LogSink() {} // print given msg into std::cerr void LogSink_cerr::addMessage( fmt::Writer* msg ) { @@ -409,9 +380,7 @@ void LogSink_cerr::addMessage( fmt::Writer* msg, const std::string& ) } // on construction this opens not pol.log instead start.log -LogSink_pollog::LogSink_pollog() : LogSinkGenericFile( &startlogBehaviour ) -{ -} +LogSink_pollog::LogSink_pollog() : LogSinkGenericFile( &startlogBehaviour ) {} // performs the switch between start.log and pol.log void LogSink_pollog::deinitialize_startlog() @@ -424,14 +393,10 @@ void LogSink_pollog::deinitialize_startlog() } // on construction opens script.log -LogSink_scriptlog::LogSink_scriptlog() : LogSinkGenericFile( &scriptlogBehaviour ) -{ -} +LogSink_scriptlog::LogSink_scriptlog() : LogSinkGenericFile( &scriptlogBehaviour ) {} // on construction opens debug.log -LogSink_debuglog::LogSink_debuglog() : LogSinkGenericFile( &debuglogBehaviour ) -{ -} +LogSink_debuglog::LogSink_debuglog() : LogSinkGenericFile( &debuglogBehaviour ) {} // debug.log can be disabled void LogSink_debuglog::disable() @@ -455,16 +420,10 @@ void LogSink_debuglog::addMessage( fmt::Writer* msg, const std::string& ) } // on construction opens leak.log -LogSink_leaklog::LogSink_leaklog() : LogSinkGenericFile( &leaklogBehaviour ) -{ -} +LogSink_leaklog::LogSink_leaklog() : LogSinkGenericFile( &leaklogBehaviour ) {} -LogSink_flexlog::LogSink_flexlog() : LogSink() -{ -} -LogSink_flexlog::~LogSink_flexlog() -{ -} +LogSink_flexlog::LogSink_flexlog() : LogSink() {} +LogSink_flexlog::~LogSink_flexlog() {} // create and open new logfile with given name, returns unique id std::string LogSink_flexlog::create( std::string logfilename, bool open_timestamp ) @@ -502,8 +461,7 @@ void LogSink_flexlog::close( const std::string& id ) } template -LogSink_dual::LogSink_dual() - : LogSink() +LogSink_dual::LogSink_dual() : LogSink() { } // performs the sink with given msg for both sinks diff --git a/pol-core/clib/logfacility.h b/pol-core/clib/logfacility.h index 4aaeba5a7..4e10647d9 100644 --- a/pol-core/clib/logfacility.h +++ b/pol-core/clib/logfacility.h @@ -7,17 +7,17 @@ Remove the include in all StdAfx.h files or live with the consequences :) #ifndef CLIB_LOGFACILITY_H #define CLIB_LOGFACILITY_H -#include -#include -#include -#include -#include -#include +#include #include -#include "../../lib/format/format.h" +#include +#include +#include +#include +#include +#include -#include "compilerspecifics.h" #include "Debugging/LogSink.h" +#include "compilerspecifics.h" namespace Pol { @@ -173,6 +173,7 @@ public: ~Message(); // auto flush fmt::Writer& message() { return *( _formater.get() ); } + private: std::unique_ptr _formater; std::string _id; diff --git a/pol-core/clib/maputil.h b/pol-core/clib/maputil.h index 813d4a695..eb4d09843 100644 --- a/pol-core/clib/maputil.h +++ b/pol-core/clib/maputil.h @@ -7,9 +7,9 @@ #ifndef CLIB_MAPUTIL_H #define CLIB_MAPUTIL_H +#include "clib.h" #include #include -#include "clib.h" #ifdef _MSC_VER #pragma warning( push ) diff --git a/pol-core/clib/mdump.cpp b/pol-core/clib/mdump.cpp index ac42ee2f8..032e983c3 100644 --- a/pol-core/clib/mdump.cpp +++ b/pol-core/clib/mdump.cpp @@ -6,11 +6,11 @@ */ #include "mdump.h" -#include "strexcpt.h" -#include "passert.h" -#include "logfacility.h" -#include "threadhelp.h" #include "clib.h" +#include "logfacility.h" +#include "passert.h" +#include "strexcpt.h" +#include "threadhelp.h" #pragma warning( disable : 4091 ) // unused typedef #include "../../lib/StackWalker/StackWalker.h" @@ -181,15 +181,15 @@ LONG HiddenMiniDumper::TopLevelFilter( struct _EXCEPTION_POINTERS* pExceptionInf } else { - result.Format( "Failed to save dump file to '{}' (error {})" ) << dumppath.str() - << GetLastError(); + result.Format( "Failed to save dump file to '{}' (error {})" ) + << dumppath.str() << GetLastError(); } ::CloseHandle( hFile ); } else { - result.Format( "Failed to create dump file '{}' (error {})" ) << dumppath.str() - << GetLastError(); + result.Format( "Failed to create dump file '{}' (error {})" ) + << dumppath.str() << GetLastError(); } } print_backtrace(); @@ -198,8 +198,8 @@ LONG HiddenMiniDumper::TopLevelFilter( struct _EXCEPTION_POINTERS* pExceptionInf if ( result.size() > 0 ) { - POLLOG_ERROR << "##########################################################\n" << result.str() - << "\n" + POLLOG_ERROR << "##########################################################\n" + << result.str() << "\n" << "Last Script: " << scripts_thread_script << " PC: " << scripts_thread_scriptPC << "\n##########################################################\n"; } diff --git a/pol-core/clib/message_queue.h b/pol-core/clib/message_queue.h index e01d26eb7..86927778c 100644 --- a/pol-core/clib/message_queue.h +++ b/pol-core/clib/message_queue.h @@ -7,9 +7,9 @@ Remove the include in all StdAfx.h files or live with the consequences :) #ifndef MESSAGE_QUEUE_H #define MESSAGE_QUEUE_H #include -#include -#include #include +#include +#include #include @@ -59,8 +59,7 @@ private: }; template -message_queue::message_queue() - : _queue(), _mutex(), _notifier(), _cancel( false ) +message_queue::message_queue() : _queue(), _mutex(), _notifier(), _cancel( false ) { } diff --git a/pol-core/clib/opnew.cpp b/pol-core/clib/opnew.cpp index 7eb70ddcd..ece9a9bf3 100644 --- a/pol-core/clib/opnew.cpp +++ b/pol-core/clib/opnew.cpp @@ -17,19 +17,13 @@ #include "pol_global_config.h" #endif -#include "opnew.h" #include "logfacility.h" - -#include +#include "opnew.h" #ifdef _WIN32 #include #endif -#ifdef __linux__ -#include -#endif - #ifdef MEMORYLEAK #include diff --git a/pol-core/clib/passert.cpp b/pol-core/clib/passert.cpp index 2857dfc67..14915b343 100644 --- a/pol-core/clib/passert.cpp +++ b/pol-core/clib/passert.cpp @@ -9,24 +9,18 @@ #include "passert.h" -#include "Debugging/ExceptionParser.h" +#include +#include "Debugging/ExceptionParser.h" #include "esignal.h" #include "logfacility.h" #include "stlutil.h" -#include "threadhelp.h" -#include #ifdef WINDOWS #include "Header_Windows.h" #include "mdumpimp.h" #else -#include -#include -#include -#include #include -#include #endif namespace Pol diff --git a/pol-core/clib/passert.h b/pol-core/clib/passert.h index db8ad06ba..86773b2fd 100644 --- a/pol-core/clib/passert.h +++ b/pol-core/clib/passert.h @@ -6,7 +6,7 @@ * * @warning This header is part of the PCH\n * Remove the include in all StdAfx.h files or live with the consequences :) -*/ + */ #ifndef CLIB_PASSERT_H #define CLIB_PASSERT_H @@ -29,7 +29,6 @@ namespace Pol { namespace Clib { - // what to do on an assertion failure: extern bool passert_dump_stack; extern bool passert_shutdown; @@ -60,14 +59,12 @@ POL_NORETURN void passert_failed( const char* expr, const std::string& reason, c * Works the same way as assert(), but is not stripped at non-debug compilation time. * Use this for non-crucial assertions. */ -#define passert( exp ) \ - ( void )( ( exp ) || \ - ( Clib::passert_failed( #exp, __FILE__, __LINE__ ), 0 ) ); \ +#define passert( exp ) \ + (void)( ( exp ) || ( Clib::passert_failed( #exp, __FILE__, __LINE__ ), 0 ) ); \ passert_assume( exp ) /** Just like passert(), but allows to specify a reason as additional parameter */ -#define passert_r( exp, reason ) \ - ( void )( ( exp ) || \ - ( Clib::passert_failed( #exp, reason, __FILE__, __LINE__ ), 0 ) ); \ +#define passert_r( exp, reason ) \ + (void)( ( exp ) || ( Clib::passert_failed( #exp, reason, __FILE__, __LINE__ ), 0 ) ); \ passert_assume( exp ) #else @@ -80,12 +77,12 @@ POL_NORETURN void passert_failed( const char* expr, const std::string& reason, c * Works the same way as assert(), but is guaranteed to be never stripped. * Use this for critical assertions that can't be ignored. */ -#define passert_always( exp ) \ - ( void )( ( exp ) || ( Clib::passert_failed( #exp, __FILE__, __LINE__ ), 0 ) ); \ +#define passert_always( exp ) \ + (void)( ( exp ) || ( Clib::passert_failed( #exp, __FILE__, __LINE__ ), 0 ) ); \ passert_assume( exp ) /** Just like passert_always(), but allows to specify a reason as additional parameter */ -#define passert_always_r( exp, reason ) \ - ( void )( ( exp ) || ( Clib::passert_failed( #exp, reason, __FILE__, __LINE__ ), 0 ) ); \ +#define passert_always_r( exp, reason ) \ + (void)( ( exp ) || ( Clib::passert_failed( #exp, reason, __FILE__, __LINE__ ), 0 ) ); \ passert_assume( exp ) #if INC_PASSERT_PARANOID @@ -95,12 +92,12 @@ POL_NORETURN void passert_failed( const char* expr, const std::string& reason, c * time * Use this for trivial assertions: "I've proved it's impossible, but ..." */ -#define passert_paranoid( exp ) \ - ( void )( ( exp ) || ( Clib::passert_failed( #exp, __FILE__, __LINE__ ), 0 ) ); \ +#define passert_paranoid( exp ) \ + (void)( ( exp ) || ( Clib::passert_failed( #exp, __FILE__, __LINE__ ), 0 ) ); \ passert_assume( exp ) /** Just like passert_paranoid(), but allows to specify a reason as additional parameter */ -#define passert_paranoid_r( exp, reason ) \ - ( void )( ( exp ) || ( Clib::passert_failed( #exp, reason, __FILE__, __LINE__ ), 0 ) ); \ +#define passert_paranoid_r( exp, reason ) \ + (void)( ( exp ) || ( Clib::passert_failed( #exp, reason, __FILE__, __LINE__ ), 0 ) ); \ passert_assume( exp ) #else diff --git a/pol-core/clib/pol_global_config_win.h b/pol-core/clib/pol_global_config_win.h index b7fec5886..492968977 100644 --- a/pol-core/clib/pol_global_config_win.h +++ b/pol-core/clib/pol_global_config_win.h @@ -11,12 +11,10 @@ // #define HAVE_MYSQL // #define ENABLE_BENCHMARK -#define POL_VERSION_MAJOR 99 -#define POL_VERSION_MINOR 0 -#define POL_VERSION_PATCH 0 -#define POL_VERSION_STR "99.0.0" -#define POL_VERSION_NAME "Break Everything Even Rudder" -#define POL_VERSION_ID "99.0.1 Break Everything Even Rudder" +#define POL_VERSION 99 +#define POL_VERSION_STR "099" +#define POL_VERSION_NAME "Break Everything Even Rudder" +#define POL_VERSION_ID "POL099 Break Everything Even Rudder" #define POL_BUILD_DATE __DATE__ #define POL_BUILD_TIME __TIME__ @@ -59,15 +57,15 @@ #define POL_BUILD_TARGET \ ( "VS2012" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK \ "" POL_BUILD_TARGET_TAG_PROFILE "" POL_64 "" POL_REVISION_TAG ) -#elif( _MSC_VER <= 1800 ) +#elif ( _MSC_VER <= 1800 ) #define POL_BUILD_TARGET \ ( "VS2013" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK \ "" POL_BUILD_TARGET_TAG_PROFILE "" POL_64 "" POL_REVISION_TAG ) -#elif( _MSC_VER <= 1900 ) +#elif ( _MSC_VER <= 1900 ) #define POL_BUILD_TARGET \ ( "VS2015" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK \ "" POL_BUILD_TARGET_TAG_PROFILE "" POL_64 "" POL_REVISION_TAG ) -#elif( _MSC_VER <= 2000 ) +#elif ( _MSC_VER <= 2000 ) #define POL_BUILD_TARGET \ ( "VS2017" POL_BUILD_TARGET_TAG_PERGON "" POL_BUILD_TARGET_TAG_MEMLEAK \ "" POL_BUILD_TARGET_TAG_PROFILE "" POL_64 "" POL_REVISION_TAG ) diff --git a/pol-core/clib/random.cpp b/pol-core/clib/random.cpp index 3efc9a00a..64e16da92 100644 --- a/pol-core/clib/random.cpp +++ b/pol-core/clib/random.cpp @@ -50,4 +50,4 @@ int random_int_range( int minI, int maxI ) return distribution( generator ); } } -} \ No newline at end of file +} diff --git a/pol-core/clib/rawtypes.h b/pol-core/clib/rawtypes.h index 4c2565b36..be00b335d 100644 --- a/pol-core/clib/rawtypes.h +++ b/pol-core/clib/rawtypes.h @@ -63,5 +63,5 @@ static_assert( sizeof( wchar_t ) == 4, "size missmatch" ); #endif #endif - + #endif /* __STYPE_H */ diff --git a/pol-core/clib/refptr.h b/pol-core/clib/refptr.h index 9468e9d14..3da5c310b 100644 --- a/pol-core/clib/refptr.h +++ b/pol-core/clib/refptr.h @@ -138,8 +138,7 @@ inline unsigned int ref_counted::instance() const #endif template -ref_ptr::ref_ptr( T* ptr ) - : _ptr( ptr ) +ref_ptr::ref_ptr( T* ptr ) : _ptr( ptr ) { add_ref(); #if REFPTR_DEBUG @@ -147,8 +146,7 @@ ref_ptr::ref_ptr( T* ptr ) #endif } template -ref_ptr::ref_ptr( const ref_ptr& rptr ) - : _ptr(rptr.get()) +ref_ptr::ref_ptr( const ref_ptr& rptr ) : _ptr( rptr.get() ) { add_ref(); #if REFPTR_DEBUG @@ -157,11 +155,10 @@ ref_ptr::ref_ptr( const ref_ptr& rptr ) } template -ref_ptr::ref_ptr(ref_ptr&& rptr) POL_NOEXCEPT - : _ptr(rptr._ptr.exchange(nullptr)) +ref_ptr::ref_ptr( ref_ptr&& rptr ) POL_NOEXCEPT : _ptr( rptr._ptr.exchange( nullptr ) ) { #if REFPTR_DEBUG - --refptr_count; + --refptr_count; #endif } @@ -267,11 +264,11 @@ ref_ptr& ref_ptr::operator=( const ref_ptr& rptr ) } template -ref_ptr& ref_ptr::operator=(ref_ptr&& rptr) +ref_ptr& ref_ptr::operator=( ref_ptr&& rptr ) { - release(); - _ptr = rptr._ptr.exchange(nullptr); - return *this; + release(); + _ptr = rptr._ptr.exchange( nullptr ); + return *this; } template @@ -299,7 +296,7 @@ void ref_ptr::add_ref() template void ref_ptr::release() { - T* Pointee = _ptr.exchange(nullptr); + T* Pointee = _ptr.exchange( nullptr ); if ( Pointee ) { if ( 0 == Pointee->release( REFERER_PARAM( this ) ) ) diff --git a/pol-core/clib/sckutil.cpp b/pol-core/clib/sckutil.cpp index 648f039fc..66744898a 100644 --- a/pol-core/clib/sckutil.cpp +++ b/pol-core/clib/sckutil.cpp @@ -7,6 +7,7 @@ #include "sckutil.h" #include "esignal.h" +#include "strutil.h" #include "wnsckt.h" namespace Pol @@ -86,4 +87,4 @@ bool readstring( Socket& sck, std::string& s, unsigned int interchar_secs, unsig return false; } } -} \ No newline at end of file +} diff --git a/pol-core/clib/socketsvc.cpp b/pol-core/clib/socketsvc.cpp index 4f4151720..2b45cddea 100644 --- a/pol-core/clib/socketsvc.cpp +++ b/pol-core/clib/socketsvc.cpp @@ -4,14 +4,12 @@ */ +#include + #include "logfacility.h" #include "socketsvc.h" - -#include "passert.h" #include "strutil.h" #include "threadhelp.h" -#include "Header_Windows.h" -#include namespace Pol { @@ -52,9 +50,7 @@ SocketClientThread::SocketClientThread( SocketListener& SL ) : _sck() { SL.accept( _sck ); } -SocketClientThread::SocketClientThread( Socket& S ) : _sck( S ) -{ -} +SocketClientThread::SocketClientThread( Socket& S ) : _sck( S ) {} static void _thread_stub2( void* arg ) { diff --git a/pol-core/clib/spinlock.h b/pol-core/clib/spinlock.h index d3c34807c..1960f4969 100644 --- a/pol-core/clib/spinlock.h +++ b/pol-core/clib/spinlock.h @@ -36,9 +36,7 @@ inline SpinLock::SpinLock() { _lck.clear(); } -inline SpinLock::~SpinLock() -{ -} +inline SpinLock::~SpinLock() {} /** * Puts the caller in an endless busy loop until it acquires the lock diff --git a/pol-core/clib/stlutil.h b/pol-core/clib/stlutil.h index 0a2cd45ff..15b65b6b5 100644 --- a/pol-core/clib/stlutil.h +++ b/pol-core/clib/stlutil.h @@ -11,10 +11,10 @@ #ifndef STLUTIL_H #define STLUTIL_H +#include "Header_Windows.h" +#include "compilerspecifics.h" #include #include -#include "compilerspecifics.h" -#include "Header_Windows.h" namespace Pol { @@ -83,12 +83,11 @@ std::string tostring( const T& v ) return OSTRINGSTREAM_STR( os ); } -template -CONSTEXPR size_t arsize(T(&)[N]) +template +CONSTEXPR size_t arsize( T ( & )[N] ) { return N; } - } } diff --git a/pol-core/clib/stracpy.cpp b/pol-core/clib/stracpy.cpp index 0f693586a..c9183024b 100644 --- a/pol-core/clib/stracpy.cpp +++ b/pol-core/clib/stracpy.cpp @@ -4,10 +4,10 @@ */ -#include "Header_Windows.h" - #include -#include "string.h" +#include + +#include "Header_Windows.h" #include "clib.h" namespace Pol diff --git a/pol-core/clib/streamsaver.cpp b/pol-core/clib/streamsaver.cpp index 2a83e4989..3b0cfe54c 100644 --- a/pol-core/clib/streamsaver.cpp +++ b/pol-core/clib/streamsaver.cpp @@ -2,9 +2,8 @@ #include #include #include -#include + #include "streamsaver.h" -#include "logfacility.h" namespace Pol { @@ -13,12 +12,8 @@ namespace Clib const std::size_t flush_limit = 10000; // 500; /// BaseClass implements only writer operator logic -StreamWriter::StreamWriter() : _writer( new fmt::Writer ) -{ -} -StreamWriter::~StreamWriter() -{ -} +StreamWriter::StreamWriter() : _writer( new fmt::Writer ) {} +StreamWriter::~StreamWriter() {} fmt::Writer& StreamWriter::operator()() { @@ -95,13 +90,9 @@ void OFStreamWriter::flush_file() } /// ostream implementation (non threaded) -OStreamWriter::OStreamWriter() : StreamWriter(), _stream() -{ -} +OStreamWriter::OStreamWriter() : StreamWriter(), _stream() {} -OStreamWriter::OStreamWriter( std::ostream* stream ) : StreamWriter(), _stream( stream ) -{ -} +OStreamWriter::OStreamWriter( std::ostream* stream ) : StreamWriter(), _stream( stream ) {} OStreamWriter::~OStreamWriter() { @@ -109,9 +100,7 @@ OStreamWriter::~OStreamWriter() *_stream << _writer->str(); } -void OStreamWriter::init( const std::string& ) -{ -} +void OStreamWriter::init( const std::string& ) {} void OStreamWriter::flush() { @@ -147,35 +136,33 @@ ThreadedOFStreamWriter::ThreadedOFStreamWriter( std::ofstream* stream ) } void ThreadedOFStreamWriter::start_worker() { - _writethread = std::thread( [this]() - { - std::list writers; - // small helper lambda to write into stream - auto _write_to_stream = [&]( std::list& l ) - { - for ( const auto& _w : l ) - { - if ( _w->size() ) - *_stream << _w->str(); - } - }; - try - { - for ( ;; ) - { - writers.clear(); - _msg_queue.pop_wait( &writers ); - _write_to_stream( writers ); - } - } - catch ( writer_queue::Canceled& ) - { - } - writers.clear(); - _msg_queue.pop_remaining( &writers ); - _write_to_stream( writers ); - _stream->flush(); - } ); + _writethread = std::thread( [this]() { + std::list writers; + // small helper lambda to write into stream + auto _write_to_stream = [&]( std::list& l ) { + for ( const auto& _w : l ) + { + if ( _w->size() ) + *_stream << _w->str(); + } + }; + try + { + for ( ;; ) + { + writers.clear(); + _msg_queue.pop_wait( &writers ); + _write_to_stream( writers ); + } + } + catch ( writer_queue::Canceled& ) + { + } + writers.clear(); + _msg_queue.pop_remaining( &writers ); + _write_to_stream( writers ); + _stream->flush(); + } ); } ThreadedOFStreamWriter::~ThreadedOFStreamWriter() diff --git a/pol-core/clib/streamsaver.h b/pol-core/clib/streamsaver.h index 0c7a4f557..fdf47df09 100644 --- a/pol-core/clib/streamsaver.h +++ b/pol-core/clib/streamsaver.h @@ -3,10 +3,11 @@ #include #include -#include #include +#include #include -#include "../../lib/format/format.h" + +#include #include "compilerspecifics.h" #include "message_queue.h" #if 0 diff --git a/pol-core/clib/strexcpt.cpp b/pol-core/clib/strexcpt.cpp index 7b068ac47..6ad4e72cd 100644 --- a/pol-core/clib/strexcpt.cpp +++ b/pol-core/clib/strexcpt.cpp @@ -17,14 +17,14 @@ #if defined( WINDOWS ) #include "Header_Windows.h" -#include -#include "strexcpt.h" #include "msjexhnd.h" +#include "strexcpt.h" +#include #else +#include "passert.h" +#include #include #include -#include -#include "passert.h" #endif namespace Pol @@ -172,8 +172,8 @@ void alt_se_trans_func( unsigned int u, _EXCEPTION_POINTERS* pExp ) else { in_ex_handler = true; - POLLOG_INFO.Format( "Structured exception in {} compiled on {} at {}\n" ) << POL_BUILD_DATE - << POL_BUILD_TIME; + POLLOG_INFO.Format( "Structured exception in {} compiled on {} at {}\n" ) + << POL_BUILD_DATE << POL_BUILD_TIME; MSJExceptionHandler::MSJUnhandledExceptionFilter( pExp ); in_ex_handler = false; diff --git a/pol-core/clib/strset.cpp b/pol-core/clib/strset.cpp index 6e7ff91a5..75a66325f 100644 --- a/pol-core/clib/strset.cpp +++ b/pol-core/clib/strset.cpp @@ -7,8 +7,6 @@ #include "stlutil.h" -#include - namespace Pol { namespace Clib @@ -86,4 +84,4 @@ size_t StringSet::estimatedSize() const return size; } } -} \ No newline at end of file +} diff --git a/pol-core/clib/strset.h b/pol-core/clib/strset.h index cc210b80d..de5ff45bb 100644 --- a/pol-core/clib/strset.h +++ b/pol-core/clib/strset.h @@ -8,7 +8,6 @@ #define CLIB_STRSET_H #include - #include #include diff --git a/pol-core/clib/strutil.cpp b/pol-core/clib/strutil.cpp index 630ec35ec..cd152bd9f 100644 --- a/pol-core/clib/strutil.cpp +++ b/pol-core/clib/strutil.cpp @@ -10,11 +10,11 @@ #include "strutil.h" +#include + +#include "logfacility.h" #include "stlutil.h" #include "unittest.h" -#include "logfacility.h" - -#include namespace Pol { @@ -283,4 +283,4 @@ std::string strupper( const std::string& str ) return boost::to_upper_copy( str ); } } -} \ No newline at end of file +} diff --git a/pol-core/clib/threadhelp.cpp b/pol-core/clib/threadhelp.cpp index 9e8720049..0b40c55a9 100644 --- a/pol-core/clib/threadhelp.cpp +++ b/pol-core/clib/threadhelp.cpp @@ -13,16 +13,18 @@ #include "threadhelp.h" +#include +#include +#include + #include "esignal.h" #include "logfacility.h" #include "passert.h" -#include - #ifndef _WIN32 +#include #include #include -#include #endif #ifdef _MSC_VER @@ -38,9 +40,7 @@ std::atomic child_threads( 0 ); static int threads = 0; #ifdef _WIN32 -void init_threadhelp() -{ -} +void init_threadhelp() {} void thread_sleep_ms( unsigned millis ) { @@ -202,7 +202,7 @@ void create_thread( ThreadData* td, bool dec_child = false ) --child_threads; } else - { + { SetThreadName( threadid, threadName ); CloseHandle( h ); } @@ -343,44 +343,42 @@ void TaskThreadPool::init( unsigned int max_count, const std::string& name ) { for ( unsigned int i = 0; i < max_count; ++i ) { - _threads.emplace_back( [=]() - { - ThreadRegister register_thread( "TaskPool " + name ); - auto f = msg(); - try - { - while ( !_done ) - { - _msg_queue.pop_wait( &f ); - f(); - } - } - catch ( msg_queue::Canceled& ) - { - } - catch ( std::exception& ex ) - { - ERROR_PRINT << "Thread exception: " << ex.what() << "\n"; - Clib::force_backtrace( true ); - return; - } - // purge the queue empty - std::list remaining; - _msg_queue.pop_remaining( &remaining ); - for ( auto& _f : remaining ) - _f(); - } ); + _threads.emplace_back( [=]() { + ThreadRegister register_thread( "TaskPool " + name ); + auto f = msg(); + try + { + while ( !_done ) + { + _msg_queue.pop_wait( &f ); + f(); + } + } + catch ( msg_queue::Canceled& ) + { + } + catch ( std::exception& ex ) + { + ERROR_PRINT << "Thread exception: " << ex.what() << "\n"; + Clib::force_backtrace( true ); + return; + } + // purge the queue empty + std::list remaining; + _msg_queue.pop_remaining( &remaining ); + for ( auto& _f : remaining ) + _f(); + } ); } } TaskThreadPool::~TaskThreadPool() { // send both done and cancel to wake up all workers - _msg_queue.push( [&]() - { - _done = true; - _msg_queue.cancel(); - } ); + _msg_queue.push( [&]() { + _done = true; + _msg_queue.cancel(); + } ); for ( auto& thread : _threads ) thread.join(); } @@ -396,18 +394,17 @@ std::future TaskThreadPool::checked_push( const msg& msg ) { auto promise = std::make_shared>(); auto ret = promise->get_future(); - _msg_queue.push( [=]() - { - try - { - msg(); - promise->set_value( true ); - } - catch ( ... ) - { - promise->set_exception( std::current_exception() ); - } - } ); + _msg_queue.push( [=]() { + try + { + msg(); + promise->set_value( true ); + } + catch ( ... ) + { + promise->set_exception( std::current_exception() ); + } + } ); return ret; } @@ -449,31 +446,30 @@ void DynTaskThreadPool::PoolWorker::join() void DynTaskThreadPool::PoolWorker::run() { - _thread = std::thread( [&]() - { - ThreadRegister register_thread( _name ); - auto f = msg(); - try - { - while ( !_parent->_done && !Clib::exit_signalled ) - { - _parent->_msg_queue.pop_wait( &f ); - { - BusyGuard busy( &_busy ); - f(); - } - } - } - catch ( msg_queue::Canceled& ) - { - } - catch ( std::exception& ex ) - { - ERROR_PRINT << "Thread exception: " << ex.what() << "\n"; - Clib::force_backtrace( true ); - return; - } - } ); + _thread = std::thread( [&]() { + ThreadRegister register_thread( _name ); + auto f = msg(); + try + { + while ( !_parent->_done && !Clib::exit_signalled ) + { + _parent->_msg_queue.pop_wait( &f ); + { + BusyGuard busy( &_busy ); + f(); + } + } + } + catch ( msg_queue::Canceled& ) + { + } + catch ( std::exception& ex ) + { + ERROR_PRINT << "Thread exception: " << ex.what() << "\n"; + Clib::force_backtrace( true ); + return; + } + } ); } /// Creates a dynamic threadpool of workers. @@ -512,11 +508,10 @@ void DynTaskThreadPool::create_thread() DynTaskThreadPool::~DynTaskThreadPool() { // send both done and cancel to wake up all workers - _msg_queue.push( [&]() - { - _done = true; - _msg_queue.cancel(); - } ); + _msg_queue.push( [&]() { + _done = true; + _msg_queue.cancel(); + } ); for ( auto& thread : _threads ) thread->join(); } @@ -534,18 +529,17 @@ std::future DynTaskThreadPool::checked_push( const msg& msg ) auto promise = std::make_shared>(); auto ret = promise->get_future(); create_thread(); - _msg_queue.push( [=]() - { - try - { - msg(); - promise->set_value( true ); - } - catch ( ... ) - { - promise->set_exception( std::current_exception() ); - } - } ); + _msg_queue.push( [=]() { + try + { + msg(); + promise->set_value( true ); + } + catch ( ... ) + { + promise->set_exception( std::current_exception() ); + } + } ); return ret; } } diff --git a/pol-core/clib/threadhelp.h b/pol-core/clib/threadhelp.h index e8fbe788e..bc1b7d223 100644 --- a/pol-core/clib/threadhelp.h +++ b/pol-core/clib/threadhelp.h @@ -7,17 +7,19 @@ #ifndef CLIB_THREADHELP_H #define CLIB_THREADHELP_H -#include "Header_Windows.h" +#include +#include #include -#include -#include #include #include +#include +#include +#include +#include -#include "spinlock.h" +#include "Header_Windows.h" #include "message_queue.h" - -#include +#include "spinlock.h" namespace Pol { @@ -91,6 +93,7 @@ private: class DynTaskThreadPool : boost::noncopyable { class PoolWorker; + friend class PoolWorker; typedef std::function msg; typedef Clib::message_queue msg_queue; diff --git a/pol-core/clib/timer.cpp b/pol-core/clib/timer.cpp index 66e5fe7b1..0ed3d6066 100644 --- a/pol-core/clib/timer.cpp +++ b/pol-core/clib/timer.cpp @@ -2,30 +2,25 @@ #include "logfacility.h" -#include - namespace Pol { namespace Tools { void DebugT::print( const std::string& name, long long time ) { - INFO_PRINT << "\n----------------------------------\n" << name << ": " << time << " ms\n" + INFO_PRINT << "\n----------------------------------\n" + << name << ": " << time << " ms\n" << "----------------------------------\n"; } -void SilentT::print( const std::string&, long long ) -{ -} +void SilentT::print( const std::string&, long long ) {} template -Timer::Timer( std::string name ) - : _name( std::move( name ) ) +Timer::Timer( std::string name ) : _name( std::move( name ) ) { start(); } template -Timer::Timer() - : _name( "" ) +Timer::Timer() : _name( "" ) { start(); } @@ -67,9 +62,7 @@ void Timer::print() const } -HighPerfTimer::HighPerfTimer() : _start( Clock::now() ) -{ -} +HighPerfTimer::HighPerfTimer() : _start( Clock::now() ) {} HighPerfTimer::time_mu HighPerfTimer::ellapsed() const { diff --git a/pol-core/clib/tracebuf.cpp b/pol-core/clib/tracebuf.cpp index 704c2d71e..d192c8817 100644 --- a/pol-core/clib/tracebuf.cpp +++ b/pol-core/clib/tracebuf.cpp @@ -5,7 +5,6 @@ #include "tracebuf.h" -#include "logfacility.h" namespace Pol { @@ -36,4 +35,4 @@ void LogTraceBuffer() #endif } } -} \ No newline at end of file +} diff --git a/pol-core/clib/wallclock.cpp b/pol-core/clib/wallclock.cpp index dceece75b..c5c04e3a4 100644 --- a/pol-core/clib/wallclock.cpp +++ b/pol-core/clib/wallclock.cpp @@ -8,11 +8,8 @@ #ifndef _WIN32 #include -#include #endif -#include - namespace Pol { namespace Clib diff --git a/pol-core/clib/weakptr.h b/pol-core/clib/weakptr.h index 47437f203..46ae0713b 100644 --- a/pol-core/clib/weakptr.h +++ b/pol-core/clib/weakptr.h @@ -1,18 +1,18 @@ /** @file -* -* @par History -* -* @note ATTENTION -* This header is part of the PCH -* Remove the include in all StdAfx.h files or live with the consequences :) -*/ + * + * @par History + * + * @note ATTENTION + * This header is part of the PCH + * Remove the include in all StdAfx.h files or live with the consequences :) + */ #ifndef __WEAKPTR_H #define __WEAKPTR_H #include "refptr.h" -#include #include +#include // // weak_ptr_owner @@ -71,8 +71,7 @@ public: }; template -weak_ptr_link::weak_ptr_link() - : _ptr( 0 ) +weak_ptr_link::weak_ptr_link() : _ptr( 0 ) { } template @@ -92,8 +91,7 @@ void weak_ptr_link::set_weakptr( T* ptr ) } template -weak_ptr::weak_ptr( weak_ptr_link* wpl ) - : ref_ptr>( wpl ) +weak_ptr::weak_ptr( weak_ptr_link* wpl ) : ref_ptr>( wpl ) { } template @@ -135,8 +133,7 @@ T& weak_ptr::operator*() const } template -weak_ptr_owner::weak_ptr_owner() - : weak_ptr(new weak_ptr_link) +weak_ptr_owner::weak_ptr_owner() : weak_ptr( new weak_ptr_link ) { } template diff --git a/pol-core/clib/wnsckt.cpp b/pol-core/clib/wnsckt.cpp index 82ef00937..0d935ecbc 100644 --- a/pol-core/clib/wnsckt.cpp +++ b/pol-core/clib/wnsckt.cpp @@ -6,15 +6,13 @@ #include "wnsckt.h" -#include "esignal.h" -#include "strutil.h" -#include "logfacility.h" -#include "passert.h" - -#include #include #include +#include "esignal.h" +#include "logfacility.h" +#include "passert.h" +#include "strutil.h" #if defined( WINDOWS ) #define SOCKET_ERRNO( x ) WSA##x @@ -23,23 +21,20 @@ typedef int socklen_t; #else +#include +#include +#include #include #include -#include #include #include -#include -#include #include -#include -#include + #define SOCKET_ERRNO( x ) x #define socket_errno errno #endif -#include - #ifndef SCK_WATCH #define SCK_WATCH 0 #endif @@ -135,7 +130,7 @@ bool Socket::open( const char* ipaddr, unsigned short port ) #ifndef WINDOWS || _sck < 0 #endif - ) + ) { INFO_PRINT << "Unable to open socket in Socket::open()\n"; return false; @@ -260,8 +255,9 @@ bool Socket::select( unsigned int seconds, unsigned int useconds ) FD_ZERO( &fd ); FD_SET( _sck, &fd ); #ifndef _WIN32 - passert_r(_sck < FD_SETSIZE, "Select() implementation in Linux cant handle this many sockets at the same time." ) - nfds = _sck + 1; + passert_r( _sck < FD_SETSIZE, + "Select() implementation in Linux cant handle this many sockets at the same time." ) + nfds = _sck + 1; #endif int res; @@ -359,8 +355,8 @@ bool Socket::recvbyte( unsigned char* ch, unsigned int waitms ) { fd_set fd; - if (!connected()) - return false; + if ( !connected() ) + return false; #if SCK_WATCH INFO_PRINT << "{L;1}\n"; @@ -426,8 +422,8 @@ bool Socket::recvdata( void* vdest, unsigned len, unsigned int waitms ) while ( len ) { - if (!connected()) - return false; + if ( !connected() ) + return false; #if SCK_WATCH INFO_PRINT << "{L:" << len << "}\n"; @@ -435,7 +431,7 @@ bool Socket::recvdata( void* vdest, unsigned len, unsigned int waitms ) FD_ZERO( &fd ); FD_SET( _sck, &fd ); #ifndef _WIN32 - nfds = _sck + 1; + nfds = _sck + 1; #endif struct timeval tv; @@ -515,7 +511,7 @@ unsigned Socket::peek( void* vdest, unsigned len, unsigned int wait_sec ) { tv.tv_sec = wait_sec; tv.tv_usec = 0; - res = ::select(nfds, &fd, NULL, NULL, &tv); + res = ::select( nfds, &fd, NULL, NULL, &tv ); } while ( res < 0 && exit_signalled && socket_errno == SOCKET_ERRNO( EINTR ) ); if ( res == 0 ) diff --git a/pol-core/clib/wnsckt.h b/pol-core/clib/wnsckt.h index befab3129..19aab51e6 100644 --- a/pol-core/clib/wnsckt.h +++ b/pol-core/clib/wnsckt.h @@ -2,9 +2,11 @@ #define CLIB_WNSCKT_H #include + #include "Header_Windows.h" #ifndef WINDOWS #include + typedef int SOCKET; #ifndef INVALID_SOCKET #define INVALID_SOCKET ( SOCKET )( -1 ) diff --git a/pol-core/clib/xmain.cpp b/pol-core/clib/xmain.cpp index 8af05f5b1..4aa41942a 100644 --- a/pol-core/clib/xmain.cpp +++ b/pol-core/clib/xmain.cpp @@ -7,15 +7,15 @@ */ +#include +#include #if defined( WINDOWS ) #include "Header_Windows.h" + #pragma comment( lib, "psapi.lib" ) // 32bit is a bit dumb.. #else #include -#include #endif -#include -#include "clib.h" namespace Pol { diff --git a/pol-core/dist/dist-2012.vcxproj b/pol-core/dist/dist-2012.vcxproj deleted file mode 100644 index 385000074..000000000 --- a/pol-core/dist/dist-2012.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - dist - {1D3B3C40-100C-4C8E-8A58-AB49B5BD5A40} - dist - Win32Proj - - - - Utility - MultiByte - v110_xp - - - Utility - MultiByte - v110 - - - Application - MultiByte - v110 - - - Application - MultiByte - v110 - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - Debug\ - Debug\ - Debug\ - Debug\ - true - true - Release\ - Release\ - Release\ - Release\ - AllRules.ruleset - AllRules.ruleset - - - - - - - - Disabled - WIN32;_DEBUG;_CONSOLE;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - - - $(OutDir)dist.exe - true - $(OutDir)dist.pdb - Console - false - - - MachineX86 - - - - - Disabled - WIN32;_DEBUG;_CONSOLE;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - Level3 - ProgramDatabase - - - $(OutDir)dist.exe - true - $(OutDir)dist.pdb - Console - false - - - - - - - Build distribution archive - cd $(SolutionDir)dist -mkdist.bat $(Platform) debug - - - cd $(SolutionDir)dist -mkdist.bat $(Platform) clean - - - - - Build distribution archive - cd $(SolutionDir)dist -mkdist.bat $(Platform) dist - - - cd $(SolutionDir)dist -mkdist.bat $(Platform) clean - - - - - - - - - - - - - - - {701fab6a-5bea-49aa-8688-57f3637b2239} - false - - - {b1a8988c-6dd0-4f97-bfa3-d0fe74af33c9} - false - - - {9931ff8e-092b-4e67-8e99-e237e1a481eb} - false - - - {f8e03c1c-e402-4c84-826b-3bec82066686} - false - - - - - - \ No newline at end of file diff --git a/pol-core/dist/vcvars32-2003.bat b/pol-core/dist/vcvars32-2003.bat deleted file mode 100644 index 44c66b91e..000000000 --- a/pol-core/dist/vcvars32-2003.bat +++ /dev/null @@ -1 +0,0 @@ -"%VS71COMNTOOLS%vsvars32.bat" diff --git a/pol-core/dist/vcvars32-2008.bat b/pol-core/dist/vcvars32-2008.bat deleted file mode 100644 index a3ed97f0d..000000000 --- a/pol-core/dist/vcvars32-2008.bat +++ /dev/null @@ -1 +0,0 @@ -"%VS90COMNTOOLS%vsvars32.bat" diff --git a/pol-core/dist/vcvars32-2010.bat b/pol-core/dist/vcvars32-2010.bat deleted file mode 100644 index 3c9058569..000000000 --- a/pol-core/dist/vcvars32-2010.bat +++ /dev/null @@ -1 +0,0 @@ -"%VS100COMNTOOLS%vsvars32.bat" diff --git a/pol-core/dist/vcvars32-2013.bat b/pol-core/dist/vcvars32-2013.bat deleted file mode 100644 index 354176359..000000000 --- a/pol-core/dist/vcvars32-2013.bat +++ /dev/null @@ -1 +0,0 @@ -"%VS120COMNTOOLS%vsvars32.bat" diff --git a/pol-core/doc/CMakeLists.txt b/pol-core/doc/CMakeLists.txt new file mode 100644 index 000000000..61f869551 --- /dev/null +++ b/pol-core/doc/CMakeLists.txt @@ -0,0 +1,11 @@ +set(lib_name doc) + +install(FILES + core-changes.txt + packets.zip + uoconvert.txt + packethooks.txt + DESTINATION . +) + + diff --git a/pol-core/doc/doc-2012.vcxproj b/pol-core/doc/doc-2012.vcxproj deleted file mode 100644 index bcbb0161c..000000000 --- a/pol-core/doc/doc-2012.vcxproj +++ /dev/null @@ -1,85 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - doc - {701FAB6A-5BEA-49AA-8688-57F3637B2239} - doc - MakeFileProj - - - - Utility - false - v110_xp - - - Utility - false - v110 - - - Utility - false - v110 - - - Utility - false - v110 - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\Debug\ - .\Debug\ - .\Debug\ - .\Debug\ - .\Release\ - .\Release\ - .\Release\ - .\Release\ - - - - - - - - - - - - \ No newline at end of file diff --git a/pol-core/ecompile/CMakeLists.txt b/pol-core/ecompile/CMakeLists.txt index f7d8fc053..57e7096ba 100755 --- a/pol-core/ecompile/CMakeLists.txt +++ b/pol-core/ecompile/CMakeLists.txt @@ -1,71 +1,21 @@ -############################################################################### +set(ex_name ecompile) -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../../cmake/CMakeEnvironment.txt) - -MESSAGE("####################################") -MESSAGE("##### Building ECOMPILE") -MESSAGE("####################################") - -############################################################################### -# define source files -SET (SOURCES - ECompileMain.cpp +add_executable(${ex_name} + # sorted ! + ECompileMain.cpp ) + +set_compile_flags(${ex_name} 1) -############################################################## -# include dirs -SET (INCLUDE_DIRS - ../ - ./ +target_link_libraries(${ex_name} PUBLIC + bscript + clib + plib + pthread ) - -############################################################## -# compile flags -IF(NOT WINDOWS) - IF(GCC) - SET (FLAGS - ${FLAGS} - -Wl,-R. - -Wl,-R./lib - -Wl,-R../lib - -Wl,-R../../lib - ) - ENDIF() -ENDIF() - -############################################################## -# set directory for internal libs -SET (LIB_DIRS - ${LIB_DIRS} - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# link to the needed libs -SET (LIBS_LINUX - bscript - clib - plib - pthread -) -SET (LIBS_LINUX_STATIC_BIN_STATIC - bscript_static - clib_static - plib_static -) - -############################################################## -# define target directory -SET (TARGET_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# define binary name -SET (TARGET_PROGRAM_NAME - ecompile -) - -############################################################## -# include CMake core -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CMakeCore.txt) +if (${gcc}) + target_link_libraries(${ex_name} PUBLIC + -fopenmp + ) +endif() +dist(${ex_name} scripts) diff --git a/pol-core/ecompile/ECompileMain.cpp b/pol-core/ecompile/ECompileMain.cpp index 67e02d4c6..de27d15cc 100644 --- a/pol-core/ecompile/ECompileMain.cpp +++ b/pol-core/ecompile/ECompileMain.cpp @@ -1,33 +1,31 @@ #include "ECompileMain.h" +#include +#include +#include +#include +#include +#include + +#include +#include "../bscript/compiler.h" +#include "../bscript/compilercfg.h" +#include "../bscript/escriptv.h" +#include "../bscript/executor.h" +#include "../bscript/executortype.h" +#include "../bscript/filefmt.h" +#include "../bscript/parser.h" #include "../clib/Program/ProgramConfig.h" -#include "../clib/clib.h" +#include "../clib/Program/ProgramMain.h" #include "../clib/dirlist.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" #include "../clib/mdump.h" +#include "../clib/passert.h" #include "../clib/timer.h" - #include "../plib/pkg.h" #include "../plib/systemstate.h" -#include "../bscript/compilercfg.h" -#include "../bscript/filefmt.h" -#include "../bscript/parser.h" -#include "../bscript/userfunc.h" -#include "../bscript/compiler.h" -#include "../bscript/escriptv.h" -#include "../bscript/executor.h" -#include "../bscript/userfunc.h" - -#include -#include -#include -#include -#include - -#include - namespace Pol { namespace Bscript @@ -50,12 +48,8 @@ using namespace Pol::Bscript; /////////////////////////////////////////////////////////////////////////////// -ECompileMain::ECompileMain() : Pol::Clib::ProgramMain() -{ -} -ECompileMain::~ECompileMain() -{ -} +ECompileMain::ECompileMain() : Pol::Clib::ProgramMain() {} +ECompileMain::~ECompileMain() {} /////////////////////////////////////////////////////////////////////////////// void ECompileMain::showHelp() diff --git a/pol-core/ecompile/ECompileMain.h b/pol-core/ecompile/ECompileMain.h index 28febbdec..3ef71ca89 100644 --- a/pol-core/ecompile/ECompileMain.h +++ b/pol-core/ecompile/ECompileMain.h @@ -1,10 +1,10 @@ #ifndef E_COMPILE_MAIN_H #define E_COMPILE_MAIN_H -#include "../clib/Program/ProgramMain.h" - #include +#include "../clib/Program/ProgramMain.h" + namespace Pol { namespace ECompile diff --git a/pol-core/ecompile/ecompile-2012.vcxproj b/pol-core/ecompile/ecompile-2012.vcxproj deleted file mode 100644 index d0b2ec09f..000000000 --- a/pol-core/ecompile/ecompile-2012.vcxproj +++ /dev/null @@ -1,303 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - ecompile - {B1A8988C-6DD0-4F97-BFA3-D0FE74AF33C9} - ecompile - - - - Application - false - MultiByte - v110_xp - - - Application - false - MultiByte - v110 - - - Application - false - MultiByte - v110 - - - Application - false - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\Debug\ - .\Debug\x64/ - .\Debug\ - .\Debug\x64/ - true - true - .\Release\ - .\Release\x64/ - .\Release\ - .\Release\x64/ - false - false - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - .\Debug/ecompile.tlb - - - Disabled - %(AdditionalIncludeDirectories) - _DEBUG;WIN32;_CONSOLE;NOMINMAX;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - .\Debug/ecompile.pch - .\Debug/ - .\Debug/ - .\Debug/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /MACHINE:I386 %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Debug/ecompile.exe - true - ..\..\lib\boost_1_55_0\lib\x86\lib;%(AdditionalLibraryDirectories) - true - .\Debug/ecompile.pdb - Console - false - - - - - - - .\Debug/x64/ecompile.tlb - - - Disabled - %(AdditionalIncludeDirectories) - _DEBUG;WIN32;_CONSOLE;NOMINMAX;INC_PASSERT;TIXML_USE_STL;_WIN64;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - .\Debug/x64/ecompile.pch - .\Debug/x64/ - .\Debug/x64/ - .\Debug/x64/ - Level4 - true - ProgramDatabase - Default - true - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Debug/x64/ecompile.exe - true - ..\..\lib\boost_1_55_0\lib\x64\lib;%(AdditionalLibraryDirectories) - true - .\Debug/x64/ecompile.pdb - Console - false - - - - - - - .\Release/ecompile.tlb - - - %(AdditionalIncludeDirectories) - NDEBUG;WIN32;_CONSOLE;NOMINMAX;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - .\Release/ecompile.pch - .\Release/ - .\Release/ - .\Release/ - Level4 - true - ProgramDatabase - Default - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /MACHINE:I386 %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Release/ecompile.exe - true - ..\..\lib\boost_1_55_0\lib\x86\lib;%(AdditionalLibraryDirectories) - true - .\Release/ecompile.pdb - true - .\Release/ecompile.map - Console - false - - - 5.0 - - - - - .\Release/x64/ecompile.tlb - - - %(AdditionalIncludeDirectories) - NDEBUG;WIN32;_CONSOLE;NOMINMAX;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - .\Release/x64/ecompile.pch - .\Release/x64/ - .\Release/x64/ - .\Release/x64/ - Level4 - true - ProgramDatabase - Default - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Release/x64/ecompile.exe - true - ..\..\lib\boost_1_55_0\lib\x64\lib;%(AdditionalLibraryDirectories) - true - .\Release/x64/ecompile.pdb - true - .\Release/x64/ecompile.map - Console - false - - - 5.02 - true - - - - - - - - - - - - - - Document - true - true - true - true - true - true - true - - - - - - {5005476b-7bd3-42a2-94ca-3ad2d0e2947c} - false - - - {7cd5572b-8a78-46c5-ac2d-39ee47acd01a} - false - - - {d45c6577-00e3-4995-a909-9c704a472565} - false - - - - - - - \ No newline at end of file diff --git a/pol-core/ecompile/ecompile-2012.vcxproj.filters b/pol-core/ecompile/ecompile-2012.vcxproj.filters deleted file mode 100644 index 5f71c1976..000000000 --- a/pol-core/ecompile/ecompile-2012.vcxproj.filters +++ /dev/null @@ -1,34 +0,0 @@ - - - - - {d020153e-5b3c-4d7a-adc6-871f947ded96} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {66512246-5c23-4907-8f52-6aaa2181b164} - h;hpp;hxx;hm;inl - - - - - Source Files - - - - - Source Files - - - - - Header Files - - - - - - - - - \ No newline at end of file diff --git a/pol-core/globalsettings.props b/pol-core/globalsettings.props index 71861c9b6..4c84e3388 100644 --- a/pol-core/globalsettings.props +++ b/pol-core/globalsettings.props @@ -4,7 +4,7 @@ $(ExecutablePath) - ..\..\lib\boost_1_63_0;$(IncludePath) + ..\..\lib\boost_1_63_0;..\..\lib;$(IncludePath) $(LibraryPath) @@ -16,4 +16,4 @@ - \ No newline at end of file + diff --git a/pol-core/plib/CMakeLists.txt b/pol-core/plib/CMakeLists.txt index df103289f..8e838aec8 100644 --- a/pol-core/plib/CMakeLists.txt +++ b/pol-core/plib/CMakeLists.txt @@ -1,15 +1,8 @@ -############################################################################### +set(lib_name plib) -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../../cmake/CMakeEnvironment.txt) - -MESSAGE("####################################") -MESSAGE("##### Building POL - PLIB") -MESSAGE("####################################") - -############################################################################### -# define source files -SET (SOURCES # sorted ! - ../pol/uofile00.cpp # TODO: move all uofile*.cpp into the plib folder +add_library(${lib_name} STATIC + # sorted ! + ../pol/uofile00.cpp # TODO: move all uofile*.cpp into the plib folder ../pol/uofile01.cpp ../pol/uofile02.cpp ../uotool/uofile04.cpp @@ -29,44 +22,9 @@ SET (SOURCES # sorted ! systemstate.cpp ) -############################################################## -# include dirs -SET (INCLUDE_DIRS - ../.. - ../ - ./ +set_compile_flags(${lib_name} 0) + +target_link_libraries(${lib_name} PUBLIC + clib ) -############################################################## -# set directory for internal libs -SET (LIB_DIRS - ${LIB_DIRS} - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# link to the needed libs -SET (LIBS_LINUX - clib -) - -############################################################## -# define target directory -SET (TARGET_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# define binary name -SET (TARGET_LIB_NAME - plib -) - -############################################################## -# include CMake core -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CMakeCore.txt) - -IF(NOT EXISTS "${BOOST_SOURCE_DIR}/boost") -ADD_DEPENDENCIES(plib boost) -ENDIF() - diff --git a/pol-core/plib/filemapserver.cpp b/pol-core/plib/filemapserver.cpp index 760ace5a9..3bc829172 100644 --- a/pol-core/plib/filemapserver.cpp +++ b/pol-core/plib/filemapserver.cpp @@ -6,6 +6,8 @@ #include "filemapserver.h" +#include + #include "../clib/passert.h" namespace Pol @@ -51,4 +53,4 @@ size_t FileMapServer::sizeEstimate() const return sizeof( *this ) + MapServer::sizeEstimate() + _mapfile.sizeEstimate(); } } -} \ No newline at end of file +} diff --git a/pol-core/plib/filemapserver.h b/pol-core/plib/filemapserver.h index 73aecb8c7..fb4656dc3 100644 --- a/pol-core/plib/filemapserver.h +++ b/pol-core/plib/filemapserver.h @@ -7,13 +7,20 @@ #ifndef PLIB_FILEMAPSERVER_H #define PLIB_FILEMAPSERVER_H -#include "../clib/compilerspecifics.h" #include "../clib/binaryfile.h" - +#include "../clib/compilerspecifics.h" #include "mapblock.h" #include "mapcell.h" #include "mapserver.h" +namespace Pol +{ +namespace Plib +{ +class RealmDescriptor; +} // namespace Plib +} // namespace Pol + namespace Pol { namespace Plib diff --git a/pol-core/plib/fsa.h b/pol-core/plib/fsa.h index 88af6a979..23515935d 100644 --- a/pol-core/plib/fsa.h +++ b/pol-core/plib/fsa.h @@ -24,9 +24,9 @@ #ifndef FSA_H #define FSA_H -#include -#include #include "../clib/logfacility.h" +#include +#include namespace Pol { namespace Plib diff --git a/pol-core/plib/inmemorymapserver.cpp b/pol-core/plib/inmemorymapserver.cpp index c7c1f5641..2aa57b603 100644 --- a/pol-core/plib/inmemorymapserver.cpp +++ b/pol-core/plib/inmemorymapserver.cpp @@ -5,8 +5,9 @@ #include "inmemorymapserver.h" -#include "../clib/strutil.h" +#include "../clib/binaryfile.h" #include "../clib/passert.h" +#include "mapblock.h" namespace Pol { @@ -24,9 +25,7 @@ InMemoryMapServer::InMemoryMapServer( const RealmDescriptor& descriptor ) : MapS mapfile.Read( &_mapblocks[0], n_blocks ); } -InMemoryMapServer::~InMemoryMapServer() -{ -} +InMemoryMapServer::~InMemoryMapServer() {} MAPCELL InMemoryMapServer::GetMapCell( unsigned short x, unsigned short y ) const { diff --git a/pol-core/plib/inmemorymapserver.h b/pol-core/plib/inmemorymapserver.h index 6ba83a460..fe0c67606 100644 --- a/pol-core/plib/inmemorymapserver.h +++ b/pol-core/plib/inmemorymapserver.h @@ -7,14 +7,21 @@ #ifndef PLIB_INMEMORYMAPSERVER_H #define PLIB_INMEMORYMAPSERVER_H -#include "../clib/compilerspecifics.h" -#include "../clib/binaryfile.h" +#include +#include "../clib/binaryfile.h" +#include "../clib/compilerspecifics.h" #include "mapblock.h" #include "mapcell.h" #include "mapserver.h" -#include +namespace Pol +{ +namespace Plib +{ +class RealmDescriptor; +} // namespace Plib +} // namespace Pol namespace Pol { diff --git a/pol-core/plib/mapfunc.cpp b/pol-core/plib/mapfunc.cpp index 6e1825dac..fa4a63f25 100644 --- a/pol-core/plib/mapfunc.cpp +++ b/pol-core/plib/mapfunc.cpp @@ -7,17 +7,11 @@ */ #include "mapfunc.h" -#include "mapserver.h" #include "../clib/cfgelem.h" -#include "../clib/passert.h" #include "../clib/logfacility.h" - -#include "mapcell.h" -#include "mapshape.h" - -#include "../pol/uconst.h" #include "../pol/ustruct.h" +#include "mapcell.h" namespace Pol { @@ -133,7 +127,7 @@ u32 polflags_from_tileflags( unsigned short tile, u32 uoflags, bool use_no_shoot ( uoflags & ( Core::USTRUCT_TILE::FLAG_BLOCKING | Core::USTRUCT_TILE::FLAG_DOOR ) ) - ) + ) mapflags |= FLAG::BLOCKSIGHT; @@ -150,7 +144,7 @@ u32 polflags_from_tileflags( unsigned short tile, u32 uoflags, bool use_no_shoot ( uoflags & Core::USTRUCT_TILE::FLAG_WALL ) - ) + ) mapflags |= FLAG::BLOCKSIGHT; } diff --git a/pol-core/plib/mapfunc.h b/pol-core/plib/mapfunc.h index 2175d2f03..a79d55c7b 100644 --- a/pol-core/plib/mapfunc.h +++ b/pol-core/plib/mapfunc.h @@ -9,6 +9,7 @@ #define PLIB_MAPFUNC_H #include + #include "../clib/rawtypes.h" namespace Pol diff --git a/pol-core/plib/mapserver.cpp b/pol-core/plib/mapserver.cpp index 7b45449c7..4e96ad47b 100644 --- a/pol-core/plib/mapserver.cpp +++ b/pol-core/plib/mapserver.cpp @@ -6,16 +6,18 @@ #include "mapserver.h" -#include "filemapserver.h" -#include "inmemorymapserver.h" -#include "mapblock.h" -#include "mapshape.h" +#include +#include +#include #include "../clib/binaryfile.h" #include "../clib/passert.h" #include "../clib/strutil.h" - -#include +#include "filemapserver.h" +#include "inmemorymapserver.h" +#include "mapcell.h" +#include "mapshape.h" +#include "mapsolid.h" namespace Pol { @@ -31,9 +33,7 @@ MapServer::MapServer( const RealmDescriptor& descriptor ) : _descriptor( descrip LoadFirstLevelIndex(); } -MapServer::~MapServer() -{ -} +MapServer::~MapServer() {} void MapServer::LoadSolids() { diff --git a/pol-core/plib/mapserver.h b/pol-core/plib/mapserver.h index 10edf28b1..c24ef8a1d 100644 --- a/pol-core/plib/mapserver.h +++ b/pol-core/plib/mapserver.h @@ -7,17 +7,17 @@ #ifndef PLIB_MAPSERVER_H #define PLIB_MAPSERVER_H +#include + #include "mapsolid.h" #include "realmdescriptor.h" -#include - namespace Pol { namespace Plib { -struct MAPCELL; class MapShapeList; +struct MAPCELL; class MapServer { diff --git a/pol-core/plib/maptileserver.cpp b/pol-core/plib/maptileserver.cpp index b0753363a..5273ae488 100644 --- a/pol-core/plib/maptileserver.cpp +++ b/pol-core/plib/maptileserver.cpp @@ -19,9 +19,7 @@ MapTileServer::MapTileServer( const RealmDescriptor& descriptor ) _cur_block_index = 0; } -MapTileServer::~MapTileServer() -{ -} +MapTileServer::~MapTileServer() {} MAPTILE_CELL MapTileServer::GetMapTile( unsigned short x, unsigned short y ) { diff --git a/pol-core/plib/mapwriter.cpp b/pol-core/plib/mapwriter.cpp index d9a4ba70d..90daf4341 100644 --- a/pol-core/plib/mapwriter.cpp +++ b/pol-core/plib/mapwriter.cpp @@ -6,17 +6,16 @@ #include "mapwriter.h" -#include "mapserver.h" -#include "mapsolid.h" +#include #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/fileutil.h" #include "../clib/iohelp.h" - #include "../pol/uofile.h" +#include "mapcell.h" +#include "mapsolid.h" -#include namespace Pol { diff --git a/pol-core/plib/mapwriter.h b/pol-core/plib/mapwriter.h index ef1361d76..84d556d3b 100644 --- a/pol-core/plib/mapwriter.h +++ b/pol-core/plib/mapwriter.h @@ -8,11 +8,11 @@ #ifndef PLIB_MAPWRITER_H #define PLIB_MAPWRITER_H -#include "maptile.h" #include "mapblock.h" +#include "maptile.h" -#include #include +#include namespace Pol { @@ -54,6 +54,7 @@ public: unsigned width() const { return _width; } unsigned height() const { return _height; } + private: std::fstream::pos_type total_size(); diff --git a/pol-core/plib/pkg.cpp b/pol-core/plib/pkg.cpp index 23636abe0..bb10564fd 100644 --- a/pol-core/plib/pkg.cpp +++ b/pol-core/plib/pkg.cpp @@ -5,7 +5,8 @@ #include "pkg.h" -#include "systemstate.h" + +#include #ifdef WINDOWS #include "../clib/pol_global_config_win.h" #else @@ -14,21 +15,19 @@ #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" +#include "../clib/clib.h" #include "../clib/dirlist.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" -#include "../clib/maputil.h" #include "../clib/passert.h" #include "../clib/stlutil.h" #include "../clib/strutil.h" +#include "../plib/systemstate.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // stricmp deprecation warning #endif -#include -#include - namespace Pol { namespace Plib @@ -209,11 +208,11 @@ void Package::check_dependencies() const { if ( core_required_ ) { - if ( core_required_ > POL_VERSION_MAJOR ) // TODO: use a more fine grained check here + if ( core_required_ > POL_VERSION ) // TODO: use a more fine grained check here { ERROR_PRINT << "Error in package " << desc() << ":\n" << " Core version " << core_required_ << " is required, but version " - << POL_VERSION_MAJOR << " is running.\n"; + << POL_VERSION << " is running.\n"; throw std::runtime_error( "Package requires a newer core version" ); } } diff --git a/pol-core/plib/pkg.h b/pol-core/plib/pkg.h index 377ef18fa..827513586 100644 --- a/pol-core/plib/pkg.h +++ b/pol-core/plib/pkg.h @@ -9,6 +9,7 @@ #include #include + namespace Pol { namespace Clib diff --git a/pol-core/plib/plib-2012.vcxproj b/pol-core/plib/plib-2012.vcxproj deleted file mode 100644 index 7c2f551b4..000000000 --- a/pol-core/plib/plib-2012.vcxproj +++ /dev/null @@ -1,269 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - plib - {D45C6577-00E3-4995-A909-9C704A472565} - plib - - - - StaticLibrary - false - MultiByte - v110_xp - - - StaticLibrary - false - MultiByte - v110 - - - StaticLibrary - false - MultiByte - v110 - - - StaticLibrary - false - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\Debug\ - .\Debug\x64\ - .\Debug\ - .\Debug\x64\ - .\Release\ - .\Release\x64\ - .\Release\ - .\Release\x64\ - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - Disabled - %(AdditionalIncludeDirectories) - _DEBUG;_LIB;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - - - .\Debug/plib.pch - .\Debug/ - .\Debug/ - .\Debug/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;_LIB;%(PreprocessorDefinitions) - 0x0409 - - - .\Debug\plib.lib - true - ..\..\lib\boost_1_55_0\lib\x86\lib - - - - - Disabled - %(AdditionalIncludeDirectories) - _DEBUG;_LIB;_WIN64;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - - - .\Debug/x64/plib.pch - .\Debug/x64/ - .\Debug/x64/ - .\Debug/x64/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;_LIB;%(PreprocessorDefinitions) - 0x0409 - - - .\Debug\x64/plib.lib - true - ..\..\lib\boost_1_55_0\lib\x64\lib - - - - - %(AdditionalIncludeDirectories) - NDEBUG;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - - - .\Release/plib.pch - .\Release/ - .\Release/ - .\Release/ - Level4 - true - ProgramDatabase - Default - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - .\Release\plib.lib - true - ..\..\lib\boost_1_55_0\lib\x86\lib - - - - - %(AdditionalIncludeDirectories) - NDEBUG;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - - - .\Release/x64/plib.pch - .\Release/x64/ - .\Release/x64/ - .\Release/x64/ - Level4 - true - ProgramDatabase - Default - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - .\Release\x64/plib.lib - true - MachineX64 - ..\..\lib\boost_1_55_0\lib\x64\lib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pol-core/plib/plib-2012.vcxproj.filters b/pol-core/plib/plib-2012.vcxproj.filters deleted file mode 100644 index d14327299..000000000 --- a/pol-core/plib/plib-2012.vcxproj.filters +++ /dev/null @@ -1,165 +0,0 @@ - - - - - {698c0780-488d-4a4b-ab22-dab1c09e1731} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {48d3dd62-82f8-4aa5-8d7b-fdfe165b1877} - h;hpp;hxx;hm;inl - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - diff --git a/pol-core/plib/realmdescriptor.cpp b/pol-core/plib/realmdescriptor.cpp index eded177d0..21df9cdae 100644 --- a/pol-core/plib/realmdescriptor.cpp +++ b/pol-core/plib/realmdescriptor.cpp @@ -76,4 +76,4 @@ std::string RealmDescriptor::path( const std::string& filename ) const return file_path + "/" + filename; } } -} \ No newline at end of file +} diff --git a/pol-core/plib/realmdescriptor.h b/pol-core/plib/realmdescriptor.h index e8c8efc0c..9a8aea974 100644 --- a/pol-core/plib/realmdescriptor.h +++ b/pol-core/plib/realmdescriptor.h @@ -7,8 +7,8 @@ #ifndef PLIB_REALMDESCRIPTOR_H #define PLIB_REALMDESCRIPTOR_H -#include #include +#include namespace Pol { diff --git a/pol-core/plib/staticserver.cpp b/pol-core/plib/staticserver.cpp index 2f46e2831..800a4fc35 100644 --- a/pol-core/plib/staticserver.cpp +++ b/pol-core/plib/staticserver.cpp @@ -7,16 +7,14 @@ #include "staticserver.h" -#include "staticblock.h" +#include #include "../clib/binaryfile.h" +#include "../clib/logfacility.h" #include "../clib/passert.h" #include "../clib/stlutil.h" #include "../clib/timer.h" -#include "../clib/logfacility.h" - -#include -#include +#include "staticblock.h" namespace Pol { @@ -44,9 +42,7 @@ StaticServer::StaticServer( const RealmDescriptor& descriptor ) Validate(); } -StaticServer::~StaticServer() -{ -} +StaticServer::~StaticServer() {} void StaticServer::Validate() const { diff --git a/pol-core/plib/staticserver.h b/pol-core/plib/staticserver.h index 45df48c89..83f28a339 100644 --- a/pol-core/plib/staticserver.h +++ b/pol-core/plib/staticserver.h @@ -8,9 +8,18 @@ #ifndef PLIB_STATICSERVER_H #define PLIB_STATICSERVER_H +#include + #include "realmdescriptor.h" #include "staticblock.h" -#include + +namespace Pol +{ +namespace Plib +{ +class StaticEntryList; +} // namespace Plib +} // namespace Pol namespace Pol { diff --git a/pol-core/plib/stlastar.h b/pol-core/plib/stlastar.h index 2ac780e58..608e57c65 100644 --- a/pol-core/plib/stlastar.h +++ b/pol-core/plib/stlastar.h @@ -378,7 +378,7 @@ public: // methods // sort_heap( m_OpenList.begin(), m_OpenList.end(), HeapCompare_f() ); // assert( is_heap( m_OpenList.begin(), m_OpenList.end(), - //HeapCompare_f() ) ); + // HeapCompare_f() ) ); } // heap now unsorted @@ -588,6 +588,7 @@ public: // methods // Get the number of steps int GetStepCount() { return m_Steps; } + private: // methods // This is called when a search fails or is cancelled to free all used // memory diff --git a/pol-core/plib/systemstate.cpp b/pol-core/plib/systemstate.cpp index 56943c9d9..15c89710d 100644 --- a/pol-core/plib/systemstate.cpp +++ b/pol-core/plib/systemstate.cpp @@ -1,10 +1,9 @@ #include "systemstate.h" -#include "../pol/tiles.h" -#include "../clib/stlutil.h" -#include "pkg.h" -#include +#include "../clib/stlutil.h" +#include "../pol/tiles.h" +#include "pkg.h" namespace Pol { @@ -23,9 +22,7 @@ SystemState::SystemState() tiles_loaded( false ) { } -SystemState::~SystemState() -{ -} +SystemState::~SystemState() {} void SystemState::deinitialize() { diff --git a/pol-core/plib/uoexpansion.h b/pol-core/plib/uoexpansion.h index 098065b1f..2a3afc624 100644 --- a/pol-core/plib/uoexpansion.h +++ b/pol-core/plib/uoexpansion.h @@ -1,8 +1,8 @@ #ifndef PLIB_UOEXPANSION_H #define PLIB_UOEXPANSION_H -#include "../clib/rawtypes.h" #include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" namespace Pol { @@ -88,7 +88,7 @@ const char* getExpansionName( ExpansionVersion x ); class UOExpansion { public: - virtual ~UOExpansion() {}; + virtual ~UOExpansion(){}; virtual bool hasFeature( A9Feature feature ) const = 0; virtual bool hasFeature( B9Feature feature ) const = 0; virtual u32 A9Flags() const = 0; diff --git a/pol-core/pol-2012.sln b/pol-core/pol-2012.sln deleted file mode 100644 index abc8a280c..000000000 --- a/pol-core/pol-2012.sln +++ /dev/null @@ -1,130 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "clib", "clib\clib-2012.vcxproj", "{7CD5572B-8A78-46C5-AC2D-39EE47ACD01A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ecompile", "ecompile\ecompile-2012.vcxproj", "{B1A8988C-6DD0-4F97-BFA3-D0FE74AF33C9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "plib", "plib\plib-2012.vcxproj", "{D45C6577-00E3-4995-A909-9C704A472565}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runecl", "runecl\runecl-2012.vcxproj", "{F8E03C1C-E402-4C84-826B-3BEC82066686}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pol", "pol\pol-2012.vcxproj", "{9931FF8E-092B-4E67-8E99-E237E1A481EB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc", "doc\doc-2012.vcxproj", "{701FAB6A-5BEA-49AA-8688-57F3637B2239}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "support", "support\support-2012.vcxproj", "{D4F7092B-08EA-4CEF-94E8-3D1133CCA5B7}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uotool", "uotool\uotool-2012.vcxproj", "{96834D20-7421-46E7-B8DE-6FD2F7EAD7FE}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dist", "dist\dist-2012.vcxproj", "{1D3B3C40-100C-4C8E-8A58-AB49B5BD5A40}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "poltool", "poltool\poltool-2012.vcxproj", "{CD7D0525-5425-480A-8C18-6B04C599B7E9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uoconvert", "uoconvert\uoconvert-2012.vcxproj", "{CC6172A8-D7A4-4CC1-95FC-87A173E556F1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bscript", "bscript\bscript-2012.vcxproj", "{5005476B-7BD3-42A2-94CA-3AD2D0E2947C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7CD5572B-8A78-46C5-AC2D-39EE47ACD01A}.Debug|Win32.ActiveCfg = Debug|Win32 - {7CD5572B-8A78-46C5-AC2D-39EE47ACD01A}.Debug|Win32.Build.0 = Debug|Win32 - {7CD5572B-8A78-46C5-AC2D-39EE47ACD01A}.Debug|x64.ActiveCfg = Debug|x64 - {7CD5572B-8A78-46C5-AC2D-39EE47ACD01A}.Debug|x64.Build.0 = Debug|x64 - {7CD5572B-8A78-46C5-AC2D-39EE47ACD01A}.Release|Win32.ActiveCfg = Release|Win32 - {7CD5572B-8A78-46C5-AC2D-39EE47ACD01A}.Release|Win32.Build.0 = Release|Win32 - {7CD5572B-8A78-46C5-AC2D-39EE47ACD01A}.Release|x64.ActiveCfg = Release|x64 - {7CD5572B-8A78-46C5-AC2D-39EE47ACD01A}.Release|x64.Build.0 = Release|x64 - {B1A8988C-6DD0-4F97-BFA3-D0FE74AF33C9}.Debug|Win32.ActiveCfg = Debug|Win32 - {B1A8988C-6DD0-4F97-BFA3-D0FE74AF33C9}.Debug|Win32.Build.0 = Debug|Win32 - {B1A8988C-6DD0-4F97-BFA3-D0FE74AF33C9}.Debug|x64.ActiveCfg = Debug|x64 - {B1A8988C-6DD0-4F97-BFA3-D0FE74AF33C9}.Debug|x64.Build.0 = Debug|x64 - {B1A8988C-6DD0-4F97-BFA3-D0FE74AF33C9}.Release|Win32.ActiveCfg = Release|Win32 - {B1A8988C-6DD0-4F97-BFA3-D0FE74AF33C9}.Release|Win32.Build.0 = Release|Win32 - {B1A8988C-6DD0-4F97-BFA3-D0FE74AF33C9}.Release|x64.ActiveCfg = Release|x64 - {B1A8988C-6DD0-4F97-BFA3-D0FE74AF33C9}.Release|x64.Build.0 = Release|x64 - {D45C6577-00E3-4995-A909-9C704A472565}.Debug|Win32.ActiveCfg = Debug|Win32 - {D45C6577-00E3-4995-A909-9C704A472565}.Debug|Win32.Build.0 = Debug|Win32 - {D45C6577-00E3-4995-A909-9C704A472565}.Debug|x64.ActiveCfg = Debug|x64 - {D45C6577-00E3-4995-A909-9C704A472565}.Debug|x64.Build.0 = Debug|x64 - {D45C6577-00E3-4995-A909-9C704A472565}.Release|Win32.ActiveCfg = Release|Win32 - {D45C6577-00E3-4995-A909-9C704A472565}.Release|Win32.Build.0 = Release|Win32 - {D45C6577-00E3-4995-A909-9C704A472565}.Release|x64.ActiveCfg = Release|x64 - {D45C6577-00E3-4995-A909-9C704A472565}.Release|x64.Build.0 = Release|x64 - {F8E03C1C-E402-4C84-826B-3BEC82066686}.Debug|Win32.ActiveCfg = Debug|Win32 - {F8E03C1C-E402-4C84-826B-3BEC82066686}.Debug|Win32.Build.0 = Debug|Win32 - {F8E03C1C-E402-4C84-826B-3BEC82066686}.Debug|x64.ActiveCfg = Debug|x64 - {F8E03C1C-E402-4C84-826B-3BEC82066686}.Debug|x64.Build.0 = Debug|x64 - {F8E03C1C-E402-4C84-826B-3BEC82066686}.Release|Win32.ActiveCfg = Release|Win32 - {F8E03C1C-E402-4C84-826B-3BEC82066686}.Release|Win32.Build.0 = Release|Win32 - {F8E03C1C-E402-4C84-826B-3BEC82066686}.Release|x64.ActiveCfg = Release|x64 - {F8E03C1C-E402-4C84-826B-3BEC82066686}.Release|x64.Build.0 = Release|x64 - {9931FF8E-092B-4E67-8E99-E237E1A481EB}.Debug|Win32.ActiveCfg = Debug|Win32 - {9931FF8E-092B-4E67-8E99-E237E1A481EB}.Debug|Win32.Build.0 = Debug|Win32 - {9931FF8E-092B-4E67-8E99-E237E1A481EB}.Debug|x64.ActiveCfg = Debug|x64 - {9931FF8E-092B-4E67-8E99-E237E1A481EB}.Debug|x64.Build.0 = Debug|x64 - {9931FF8E-092B-4E67-8E99-E237E1A481EB}.Release|Win32.ActiveCfg = Release|Win32 - {9931FF8E-092B-4E67-8E99-E237E1A481EB}.Release|Win32.Build.0 = Release|Win32 - {9931FF8E-092B-4E67-8E99-E237E1A481EB}.Release|x64.ActiveCfg = Release|x64 - {9931FF8E-092B-4E67-8E99-E237E1A481EB}.Release|x64.Build.0 = Release|x64 - {701FAB6A-5BEA-49AA-8688-57F3637B2239}.Debug|Win32.ActiveCfg = Debug|Win32 - {701FAB6A-5BEA-49AA-8688-57F3637B2239}.Debug|Win32.Build.0 = Debug|Win32 - {701FAB6A-5BEA-49AA-8688-57F3637B2239}.Debug|x64.ActiveCfg = Debug|x64 - {701FAB6A-5BEA-49AA-8688-57F3637B2239}.Debug|x64.Build.0 = Debug|x64 - {701FAB6A-5BEA-49AA-8688-57F3637B2239}.Release|Win32.ActiveCfg = Release|Win32 - {701FAB6A-5BEA-49AA-8688-57F3637B2239}.Release|Win32.Build.0 = Release|Win32 - {701FAB6A-5BEA-49AA-8688-57F3637B2239}.Release|x64.ActiveCfg = Release|x64 - {701FAB6A-5BEA-49AA-8688-57F3637B2239}.Release|x64.Build.0 = Release|x64 - {D4F7092B-08EA-4CEF-94E8-3D1133CCA5B7}.Debug|Win32.ActiveCfg = Debug|Win32 - {D4F7092B-08EA-4CEF-94E8-3D1133CCA5B7}.Debug|x64.ActiveCfg = Debug|x64 - {D4F7092B-08EA-4CEF-94E8-3D1133CCA5B7}.Release|Win32.ActiveCfg = Release|Win32 - {D4F7092B-08EA-4CEF-94E8-3D1133CCA5B7}.Release|x64.ActiveCfg = Release|x64 - {96834D20-7421-46E7-B8DE-6FD2F7EAD7FE}.Debug|Win32.ActiveCfg = Debug|Win32 - {96834D20-7421-46E7-B8DE-6FD2F7EAD7FE}.Debug|Win32.Build.0 = Debug|Win32 - {96834D20-7421-46E7-B8DE-6FD2F7EAD7FE}.Debug|x64.ActiveCfg = Debug|x64 - {96834D20-7421-46E7-B8DE-6FD2F7EAD7FE}.Debug|x64.Build.0 = Debug|x64 - {96834D20-7421-46E7-B8DE-6FD2F7EAD7FE}.Release|Win32.ActiveCfg = Release|Win32 - {96834D20-7421-46E7-B8DE-6FD2F7EAD7FE}.Release|Win32.Build.0 = Release|Win32 - {96834D20-7421-46E7-B8DE-6FD2F7EAD7FE}.Release|x64.ActiveCfg = Release|x64 - {96834D20-7421-46E7-B8DE-6FD2F7EAD7FE}.Release|x64.Build.0 = Release|x64 - {1D3B3C40-100C-4C8E-8A58-AB49B5BD5A40}.Debug|Win32.ActiveCfg = Debug|Win32 - {1D3B3C40-100C-4C8E-8A58-AB49B5BD5A40}.Debug|x64.ActiveCfg = Debug|x64 - {1D3B3C40-100C-4C8E-8A58-AB49B5BD5A40}.Release|Win32.ActiveCfg = Release|Win32 - {1D3B3C40-100C-4C8E-8A58-AB49B5BD5A40}.Release|x64.ActiveCfg = Release|x64 - {CD7D0525-5425-480A-8C18-6B04C599B7E9}.Debug|Win32.ActiveCfg = Debug|Win32 - {CD7D0525-5425-480A-8C18-6B04C599B7E9}.Debug|Win32.Build.0 = Debug|Win32 - {CD7D0525-5425-480A-8C18-6B04C599B7E9}.Debug|x64.ActiveCfg = Debug|x64 - {CD7D0525-5425-480A-8C18-6B04C599B7E9}.Debug|x64.Build.0 = Debug|x64 - {CD7D0525-5425-480A-8C18-6B04C599B7E9}.Release|Win32.ActiveCfg = Release|Win32 - {CD7D0525-5425-480A-8C18-6B04C599B7E9}.Release|Win32.Build.0 = Release|Win32 - {CD7D0525-5425-480A-8C18-6B04C599B7E9}.Release|x64.ActiveCfg = Release|x64 - {CD7D0525-5425-480A-8C18-6B04C599B7E9}.Release|x64.Build.0 = Release|x64 - {CC6172A8-D7A4-4CC1-95FC-87A173E556F1}.Debug|Win32.ActiveCfg = Debug|Win32 - {CC6172A8-D7A4-4CC1-95FC-87A173E556F1}.Debug|Win32.Build.0 = Debug|Win32 - {CC6172A8-D7A4-4CC1-95FC-87A173E556F1}.Debug|x64.ActiveCfg = Debug|x64 - {CC6172A8-D7A4-4CC1-95FC-87A173E556F1}.Debug|x64.Build.0 = Debug|x64 - {CC6172A8-D7A4-4CC1-95FC-87A173E556F1}.Release|Win32.ActiveCfg = Release|Win32 - {CC6172A8-D7A4-4CC1-95FC-87A173E556F1}.Release|Win32.Build.0 = Release|Win32 - {CC6172A8-D7A4-4CC1-95FC-87A173E556F1}.Release|x64.ActiveCfg = Release|x64 - {CC6172A8-D7A4-4CC1-95FC-87A173E556F1}.Release|x64.Build.0 = Release|x64 - {5005476B-7BD3-42A2-94CA-3AD2D0E2947C}.Debug|Win32.ActiveCfg = Debug|Win32 - {5005476B-7BD3-42A2-94CA-3AD2D0E2947C}.Debug|Win32.Build.0 = Debug|Win32 - {5005476B-7BD3-42A2-94CA-3AD2D0E2947C}.Debug|x64.ActiveCfg = Debug|x64 - {5005476B-7BD3-42A2-94CA-3AD2D0E2947C}.Debug|x64.Build.0 = Debug|x64 - {5005476B-7BD3-42A2-94CA-3AD2D0E2947C}.Release|Win32.ActiveCfg = Release|Win32 - {5005476B-7BD3-42A2-94CA-3AD2D0E2947C}.Release|Win32.Build.0 = Release|Win32 - {5005476B-7BD3-42A2-94CA-3AD2D0E2947C}.Release|x64.ActiveCfg = Release|x64 - {5005476B-7BD3-42A2-94CA-3AD2D0E2947C}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(DPCodeReviewSolutionGUID) = preSolution - DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} - EndGlobalSection -EndGlobal diff --git a/pol-core/pol/CMakeLists.txt b/pol-core/pol/CMakeLists.txt index d6b43e1f2..a63ff75e0 100755 --- a/pol-core/pol/CMakeLists.txt +++ b/pol-core/pol/CMakeLists.txt @@ -1,24 +1,7 @@ -############################################################################### -# -# Copyright (C) 2015 Thomas Volkert -# All rights reserved. -# -# The environment was provided for the POL project. Redistribution -# and use in source and binary forms, with or without modification, -# are permitted. However, this paragraph has to be included in its -# original form in every project. -# -############################################################################### +set(ex_name pol) -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../../cmake/CMakeEnvironment.txt) - -MESSAGE("########################################################################") -MESSAGE("##### Building POL ${BINARY_VERSION} (${BINARY_VERSION_NAME})") -MESSAGE("########################################################################") - -############################################################################### -# define source files -SET (SOURCES # sorted ! +add_executable(${ex_name} + # sorted ! accounts/account.cpp accounts/accounts.cpp accounts/acscrobj.cpp @@ -230,82 +213,35 @@ SET (SOURCES # sorted ! xmlfilescrobj.cpp zone.cpp ) + +set_compile_flags(${ex_name} 1) +use_curl(${ex_name}) +use_benchmark(${ex_name}) -############################################################## -# include dirs -SET (INCLUDE_DIRS - ../ +target_link_libraries(${ex_name} PUBLIC + bscript + clib + plib + tinyxml + crypto + pthread + z ) +if (${gcc}) + target_link_libraries(${ex_name} PUBLIC + -fopenmp + ) +endif() -############################################################## -# set directory for internal libs -SET (LIB_DIRS - ${LIB_DIRS} - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# compile flags -IF(NOT WINDOWS) - SET (FLAGS - ${FLAGS} - -Wno-uninitialized #TODO: remove and fix the code - -Wno-ignored-qualifiers #TODO: remove and fix the code - ) - IF(GCC) - SET (FLAGS - ${FLAGS} - -Wl,-R. - -Wl,-R./lib - -Wl,-R../lib - -Wl,-R../../lib - ) - ENDIF() -ENDIF() +if(HAVE_MYSQL) + target_link_libraries(${ex_name} PUBLIC + mysqlclient + ) +endif() +if(DEFINED USE_BOOST_REGEX) + target_link_libraries(${ex_name} PUBLIC + boost_regex + ) +endif() -############################################################## -# link to the needed libs -SET (LIBS_LINUX - bscript - clib - plib - tinyxml - crypto - pthread - z - curl -) -IF(HAVE_MYSQL) - SET (LIBS_LINUX - ${LIBS_LINUX} - mysqlclient - ) - IF(DEFINED USE_BOOST_REGEX) - SET (LIBS_LINUX - ${LIBS_LINUX} - boost_regex - ) - ENDIF() -ENDIF() -SET (LIBS_LINUX_STATIC_BIN_STATIC - bscript_static - clib_static - plib_static - tinyxml_static -) - -############################################################## -# define target directory -SET (TARGET_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# define binary name -SET (TARGET_PROGRAM_NAME - pol -) - -############################################################## -# include CMake core -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CMakeCore.txt) +dist(${ex_name} .) diff --git a/pol-core/pol/PolMain.cpp b/pol-core/pol/PolMain.cpp index 4853a06c6..e97f683cb 100644 --- a/pol-core/pol/PolMain.cpp +++ b/pol-core/pol/PolMain.cpp @@ -1,6 +1,7 @@ #include "PolMain.h" -#include "pol.h" //TODO: remove this ugly hack asap again +#include "../clib/Program/ProgramMain.h" +#include "pol.h" namespace Pol { @@ -10,12 +11,8 @@ using namespace std; /////////////////////////////////////////////////////////////////////////////// -PolMain::PolMain() : ProgramMain() -{ -} -PolMain::~PolMain() -{ -} +PolMain::PolMain() : ProgramMain() {} +PolMain::~PolMain() {} /////////////////////////////////////////////////////////////////////////////// void PolMain::showHelp() { diff --git a/pol-core/pol/accounts/account.cpp b/pol-core/pol/accounts/account.cpp index 4bdb3bf5b..94464d9e4 100644 --- a/pol-core/pol/accounts/account.cpp +++ b/pol-core/pol/accounts/account.cpp @@ -9,21 +9,20 @@ #include "account.h" -#include "accounts.h" + +#include #include "../../clib/cfgelem.h" #include "../../clib/clib_MD5.h" +#include "../../clib/rawtypes.h" #include "../../clib/streamsaver.h" - -#include "../globals/uvars.h" #include "../../plib/systemstate.h" - +#include "../cmdlevel.h" +#include "../globals/uvars.h" #include "../mobile/charactr.h" #include "../network/client.h" -#include "../cmdlevel.h" #include "../polcfg.h" - -#include +#include "../uobject.h" namespace Pol { @@ -242,7 +241,7 @@ u16 Account::convert_uo_expansion( const std::string& expansion ) { const auto not_found = std::string::npos; - if (expansion.find("TOL") != not_found) + if ( expansion.find( "TOL" ) != not_found ) return Network::TOL; else if ( expansion.find( "HSA" ) != not_found ) return Network::HSA; diff --git a/pol-core/pol/accounts/account.h b/pol-core/pol/accounts/account.h index 1f2141425..4466a42a5 100644 --- a/pol-core/pol/accounts/account.h +++ b/pol-core/pol/accounts/account.h @@ -10,15 +10,14 @@ #ifndef ACCOUNT_H #define ACCOUNT_H +#include +#include + +#include "../../clib/refptr.h" +#include "../../clib/strset.h" #include "../proplist.h" #include "../reftypes.h" -#include "../../clib/strset.h" -#include "../../clib/refptr.h" - -#include -#include - namespace Pol { namespace Mobile @@ -78,7 +77,6 @@ private: Clib::StringSet options_; }; - } } #endif diff --git a/pol-core/pol/accounts/accounts.cpp b/pol-core/pol/accounts/accounts.cpp index 45d89b73a..7830f2c7b 100644 --- a/pol-core/pol/accounts/accounts.cpp +++ b/pol-core/pol/accounts/accounts.cpp @@ -13,26 +13,25 @@ #endif #include "accounts.h" -#include "account.h" -#include -#include +#include #include +#include +#include +#include -#include "../../clib/cfgfile.h" #include "../../clib/cfgelem.h" -#include "../../clib/fileutil.h" -#include "../../clib/passert.h" -#include "../../clib/timer.h" +#include "../../clib/cfgfile.h" +#include "../../clib/clib.h" #include "../../clib/logfacility.h" +#include "../../clib/passert.h" #include "../../clib/streamsaver.h" - +#include "../../clib/timer.h" #include "../../plib/systemstate.h" - -#include "../polcfg.h" -#include "../schedule.h" -#include "../globals/uvars.h" #include "../globals/state.h" +#include "../globals/uvars.h" +#include "../polsig.h" +#include "account.h" namespace Pol { @@ -248,4 +247,4 @@ void write_account_data_task( void ) write_account_data(); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/accounts/acscrobj.cpp b/pol-core/pol/accounts/acscrobj.cpp index 7b6abe266..d5d7d0081 100644 --- a/pol-core/pol/accounts/acscrobj.cpp +++ b/pol-core/pol/accounts/acscrobj.cpp @@ -22,30 +22,25 @@ #include "acscrobj.h" -#include "account.h" -#include "accounts.h" - -#include "../../clib/clib_MD5.h" +#include +#include #include "../../bscript/berror.h" #include "../../bscript/executor.h" #include "../../bscript/impstr.h" #include "../../bscript/objmembers.h" #include "../../bscript/objmethods.h" - +#include "../../clib/clib_MD5.h" #include "../../plib/systemstate.h" - +#include "../core.h" +#include "../globals/uvars.h" #include "../mobile/charactr.h" #include "../network/client.h" -#include "../cmdlevel.h" -#include "../core.h" -#include "../objecthash.h" #include "../polcfg.h" -#include "../realms.h" #include "../ufunc.h" #include "../uoscrobj.h" -#include "../uoexhelp.h" -#include "../globals/uvars.h" +#include "account.h" +#include "accounts.h" namespace Pol { @@ -360,7 +355,8 @@ Bscript::BObjectImp* AccountObjImp::call_method_id( const int id, Bscript::Execu break; } /// - /// account.Set_UO_Expansion( string ) : recognized values: TOL, HSA, SA, ML, SE, AOS, LBR, T2A (default) + /// account.Set_UO_Expansion( string ) : recognized values: TOL, HSA, SA, ML, SE, AOS, LBR, T2A + /// (default) /// this determines what flag is sent with packet 0xB9 during login. /// case MTH_SET_UO_EXPANSION: @@ -370,12 +366,11 @@ Bscript::BObjectImp* AccountObjImp::call_method_id( const int id, Bscript::Execu const String* expansion_str; if ( ex.getStringParam( 0, expansion_str ) ) { - if ( expansion_str->value().empty() || - ( expansion_str->value() == "TOL" ) || ( expansion_str->value() == "HSA" ) || - ( expansion_str->value() == "SA" ) || ( expansion_str->value() == "KR" ) || - ( expansion_str->value() == "ML" ) || ( expansion_str->value() == "SE" ) || - ( expansion_str->value() == "AOS" ) || ( expansion_str->value() == "LBR" ) || - ( expansion_str->value() == "T2A" ) ) + if ( expansion_str->value().empty() || ( expansion_str->value() == "TOL" ) || + ( expansion_str->value() == "HSA" ) || ( expansion_str->value() == "SA" ) || + ( expansion_str->value() == "KR" ) || ( expansion_str->value() == "ML" ) || + ( expansion_str->value() == "SE" ) || ( expansion_str->value() == "AOS" ) || + ( expansion_str->value() == "LBR" ) || ( expansion_str->value() == "T2A" ) ) { obj_->uo_expansion_ = obj_->convert_uo_expansion( expansion_str->value() ); for ( unsigned short i = 0; i < Plib::systemstate.config.character_slots; i++ ) @@ -387,7 +382,8 @@ Bscript::BObjectImp* AccountObjImp::call_method_id( const int id, Bscript::Execu } else return new BError( - "Invalid Parameter Value. Supported Values: \"\", T2A, LBR, AOS, SE, ML, KR, SA, HSA, TOL" ); + "Invalid Parameter Value. Supported Values: \"\", T2A, LBR, AOS, SE, ML, KR, SA, HSA, " + "TOL" ); } else return new BError( "Invalid Parameter Type" ); diff --git a/pol-core/pol/accounts/acscrobj.h b/pol-core/pol/accounts/acscrobj.h index e960c1efc..be4314d8e 100644 --- a/pol-core/pol/accounts/acscrobj.h +++ b/pol-core/pol/accounts/acscrobj.h @@ -8,11 +8,22 @@ #ifndef ACSCROBJ_H #define ACSCROBJ_H +#include "../../bscript/bobject.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" #include "../reftypes.h" -#ifndef BSCRIPT_BOBJECT_H -#include "../../bscript/bobject.h" -#endif +namespace Pol +{ +namespace Accounts +{ +class Account; +} // namespace Accounts +namespace Bscript +{ +class Executor; +} // namespace Bscript +} // namespace Pol namespace Pol { @@ -25,6 +36,7 @@ public: Account* operator->() { return acct.get(); } const Account* operator->() const { return acct.get(); } Account* Ptr() { return acct.get(); } + private: Core::AccountRef acct; }; diff --git a/pol-core/pol/action.h b/pol-core/pol/action.h index 690d47d7e..c3d747a1a 100644 --- a/pol-core/pol/action.h +++ b/pol-core/pol/action.h @@ -8,8 +8,8 @@ #ifndef ACTION_H #define ACTION_H -#include #include +#include #include "../clib/rawtypes.h" diff --git a/pol-core/pol/allocd.cpp b/pol-core/pol/allocd.cpp index eb19d431c..0452d307e 100644 --- a/pol-core/pol/allocd.cpp +++ b/pol-core/pol/allocd.cpp @@ -7,14 +7,11 @@ #include "allocd.h" +#include #ifdef _WIN32 #include #endif -#include -#include -#include "../clib/logfacility.h" - namespace Pol { namespace Core diff --git a/pol-core/pol/baseobject.h b/pol-core/pol/baseobject.h index fd0d721d7..e6550689f 100644 --- a/pol-core/pol/baseobject.h +++ b/pol-core/pol/baseobject.h @@ -41,7 +41,7 @@ protected: ULWObject( const ULWObject& ) = delete; ULWObject& operator=( const ULWObject& ) = delete; ~ULWObject() = default; - + public: bool orphan() const; diff --git a/pol-core/pol/binaryfilescrobj.cpp b/pol-core/pol/binaryfilescrobj.cpp index c35c763ee..0a192a8bb 100644 --- a/pol-core/pol/binaryfilescrobj.cpp +++ b/pol-core/pol/binaryfilescrobj.cpp @@ -7,17 +7,17 @@ #include "binaryfilescrobj.h" -#include "../clib/strutil.h" -#include "../clib/clib_endian.h" +#include +#include -#include "../bscript/executor.h" #include "../bscript/berror.h" +#include "../bscript/bobject.h" +#include "../bscript/executor.h" #include "../bscript/impstr.h" #include "../bscript/objmembers.h" #include "../bscript/objmethods.h" - -#include - +#include "../clib/clib_endian.h" +#include "../clib/rawtypes.h" namespace Pol { @@ -322,14 +322,12 @@ bool BBinaryfile::operator==( const Bscript::BObjectImp& objimp ) const return true; } else if ( objimp.isa( Bscript::BObjectImp::OTBoolean ) ) - return isTrue() == static_cast(objimp).isTrue(); + return isTrue() == static_cast( objimp ).isTrue(); return false; } -BinFile::BinFile() -{ -} +BinFile::BinFile() {} BinFile::BinFile( const std::string& filename, std::ios::openmode mode ) { diff --git a/pol-core/pol/binaryfilescrobj.h b/pol-core/pol/binaryfilescrobj.h index 9cf5b6108..e697743bf 100644 --- a/pol-core/pol/binaryfilescrobj.h +++ b/pol-core/pol/binaryfilescrobj.h @@ -12,9 +12,19 @@ #include "../bscript/bobject.h" #endif +#include +#include + +#include "../clib/compilerspecifics.h" #include "../clib/rawtypes.h" -#include +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +} // namespace Pol namespace Pol { diff --git a/pol-core/pol/bowsalut.cpp b/pol-core/pol/bowsalut.cpp index 2b45b4af8..eb78a48c7 100644 --- a/pol-core/pol/bowsalut.cpp +++ b/pol-core/pol/bowsalut.cpp @@ -6,27 +6,23 @@ */ -#include "action.h" +#include +#include #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" -#include "../clib/clib_endian.h" +#include "../clib/clib.h" #include "../clib/fileutil.h" -#include "../clib/strutil.h" -#include "../clib/stlutil.h" #include "../clib/logfacility.h" - +#include "../clib/rawtypes.h" +#include "../clib/stlutil.h" +#include "action.h" +#include "globals/uvars.h" #include "mobile/charactr.h" #include "network/client.h" -#include "network/packets.h" #include "network/packetdefs.h" #include "pktin.h" -#include "pktdef.h" -#include "uobject.h" -#include "globals/uvars.h" #include "uworld.h" -#include "ufunc.h" -#include "sockio.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // stricmp deprecation warning @@ -111,8 +107,7 @@ void load_anim_xlate_cfg( bool /*reload*/ ) std::sort( mobiletype.graphics.begin(), mobiletype.graphics.end() ); mobiletype.supports_mount = elem.remove_bool( "MountTranslation", false ); - auto split_str = []( const std::string& source ) -> std::vector - { + auto split_str = []( const std::string& source ) -> std::vector { ISTRINGSTREAM is( source ); std::string tmp; std::vector result; @@ -195,64 +190,62 @@ void send_action_to_inrange( const Mobile::Character* obj, UACTION action, { bool build = false; Network::MobileAnimationMsg msg( obj->serial_ext ); - WorldIterator::InVisualRange( - obj, [&]( Mobile::Character* zonechr ) + WorldIterator::InVisualRange( obj, [&]( Mobile::Character* zonechr ) { + if ( !build ) // only build if client in range + { + MobileTranslate::OldAnimDef oldanim; + oldanim.valid = true; + oldanim.action = static_cast( action ); + oldanim.framecount = framecount; + oldanim.repeatcount = repeatcount; + oldanim.backward = static_cast( backward ); + oldanim.repeatflag = static_cast( repeatflag ); + oldanim.delay = delay; + MobileTranslate::NewAnimDef newanim; + bool supports_mount = true; + build = true; + MobileTranslate const* translate = nullptr; + for ( const auto& translates : Core::gamestate.animation_translates ) { - if ( !build ) // only build if client in range + if ( translates.second.has_graphic( obj->graphic ) ) { - MobileTranslate::OldAnimDef oldanim; - oldanim.valid = true; - oldanim.action = static_cast( action ); - oldanim.framecount = framecount; - oldanim.repeatcount = repeatcount; - oldanim.backward = static_cast( backward ); - oldanim.repeatflag = static_cast( repeatflag ); - oldanim.delay = delay; - MobileTranslate::NewAnimDef newanim; - bool supports_mount = true; - build = true; - MobileTranslate const* translate = nullptr; - for ( const auto& translates : Core::gamestate.animation_translates ) - { - if ( translates.second.has_graphic( obj->graphic ) ) - { - translate = &translates.second; - supports_mount = translate->supports_mount; - break; - } - } - - if ( obj->on_mount() && supports_mount ) - { - if ( action < ACTION_RIDINGHORSE1 || action > ACTION_RIDINGHORSE7 ) - { - UACTION new_action = Core::gamestate.mount_action_xlate[action]; - if ( new_action == 0 ) - return; - action = new_action; - oldanim.action = static_cast( new_action ); - } - } - if ( translate != nullptr ) - { - oldanim = translate->old_anim[action]; - newanim = translate->new_anim[action]; - } - else - { - ERROR_PRINT << "Warning: undefined animXlate.cfg entry for graphic 0x" - << fmt::hexu( obj->graphic ) << "\n"; - } - - msg.update( newanim.anim, newanim.action, newanim.subaction, oldanim.action, - oldanim.framecount, oldanim.repeatcount, - static_cast( oldanim.backward ), - static_cast( oldanim.repeatflag ), oldanim.delay, - oldanim.valid, newanim.valid ); + translate = &translates.second; + supports_mount = translate->supports_mount; + break; } + } - msg.Send( zonechr->client ); - } ); + if ( obj->on_mount() && supports_mount ) + { + if ( action < ACTION_RIDINGHORSE1 || action > ACTION_RIDINGHORSE7 ) + { + UACTION new_action = Core::gamestate.mount_action_xlate[action]; + if ( new_action == 0 ) + return; + action = new_action; + oldanim.action = static_cast( new_action ); + } + } + if ( translate != nullptr ) + { + oldanim = translate->old_anim[action]; + newanim = translate->new_anim[action]; + } + else + { + ERROR_PRINT << "Warning: undefined animXlate.cfg entry for graphic 0x" + << fmt::hexu( obj->graphic ) << "\n"; + } + + msg.update( newanim.anim, newanim.action, newanim.subaction, oldanim.action, + oldanim.framecount, oldanim.repeatcount, + static_cast( oldanim.backward ), + static_cast( oldanim.repeatflag ), oldanim.delay, oldanim.valid, + newanim.valid ); + } + + msg.Send( zonechr->client ); + } ); } void handle_action( Network::Client* client, PKTIN_12* cmd ) diff --git a/pol-core/pol/cfgrepos.cpp b/pol-core/pol/cfgrepos.cpp index 2a832ca3a..684471628 100644 --- a/pol-core/pol/cfgrepos.cpp +++ b/pol-core/pol/cfgrepos.cpp @@ -16,30 +16,25 @@ #include "cfgrepos.h" -#include "polcfg.h" + +#include +#include +#include +#include +#include #include "../bscript/bobject.h" #include "../bscript/escrutil.h" #include "../bscript/impstr.h" - #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" #include "../clib/strutil.h" - #include "../plib/pkg.h" #include "../plib/systemstate.h" - #include "globals/ucfg.h" - -#include -#if !defined( _WIN32 ) -#include -#endif - -#include -#include +#include "polcfg.h" namespace Pol { @@ -57,9 +52,7 @@ StoredConfigElem::StoredConfigElem( Clib::ConfigElem& elem ) } } -StoredConfigElem::StoredConfigElem() -{ -} +StoredConfigElem::StoredConfigElem() {} // ToDo: we have to think over... it's a problem with script-inside references StoredConfigElem::~StoredConfigElem() @@ -118,9 +111,7 @@ size_t StoredConfigElem::estimateSize() const return size; } -StoredConfigFile::StoredConfigFile() : reload( false ), modified_( 0 ) -{ -} +StoredConfigFile::StoredConfigFile() : reload( false ), modified_( 0 ) {} // ToDo: we have to think over... it's a problem with script-inside references // StoredConfigFile::~StoredConfigFile( ) diff --git a/pol-core/pol/cfgrepos.h b/pol-core/pol/cfgrepos.h index 1761ccb94..fc4144113 100644 --- a/pol-core/pol/cfgrepos.h +++ b/pol-core/pol/cfgrepos.h @@ -17,12 +17,14 @@ #include "pol_global_config.h" #endif -#include "../clib/maputil.h" -#include "../clib/refptr.h" -#include "../clib/boostutils.h" - #include #include +#include +#include + +#include "../clib/boostutils.h" +#include "../clib/maputil.h" +#include "../clib/refptr.h" namespace Pol { @@ -32,8 +34,8 @@ class BObjectImp; } namespace Clib { -class ConfigFile; class ConfigElem; +class ConfigFile; } namespace Core { @@ -41,7 +43,8 @@ class StoredConfigElem : public ref_counted { private: typedef std::multimap, - Clib::ci_cmp_pred> PropImpList; + Clib::ci_cmp_pred> + PropImpList; public: StoredConfigElem( Clib::ConfigElem& elem ); diff --git a/pol-core/pol/checkpnt.cpp b/pol-core/pol/checkpnt.cpp index 7f3adce3e..da29ade67 100644 --- a/pol-core/pol/checkpnt.cpp +++ b/pol-core/pol/checkpnt.cpp @@ -6,9 +6,8 @@ #include "checkpnt.h" -#include "../plib/systemstate.h" #include "../clib/logfacility.h" - +#include "../plib/systemstate.h" #include "globals/state.h" namespace Pol @@ -24,13 +23,11 @@ void checkpoint( const char* msg, unsigned short minlvl /* = 11 */ ) } } -Checkpoint::Checkpoint( const char* file ) : _file( file ), _line( 0 ) -{ -} +Checkpoint::Checkpoint( const char* file ) : _file( file ), _line( 0 ) {} Checkpoint::~Checkpoint() { if ( _line ) POLLOG_ERROR << "Abnormal end after checkpoint: File " << _file << ", line " << _line << "\n"; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/checkpnt.h b/pol-core/pol/checkpnt.h index cbd8a7020..f4245b40f 100644 --- a/pol-core/pol/checkpnt.h +++ b/pol-core/pol/checkpnt.h @@ -21,6 +21,7 @@ public: void setvalue( unsigned line ) { _line = line; } void clear() { _line = 0; } + private: const char* _file; unsigned _line; diff --git a/pol-core/pol/clfunc.cpp b/pol-core/pol/clfunc.cpp index c147ca25f..b83665963 100644 --- a/pol-core/pol/clfunc.cpp +++ b/pol-core/pol/clfunc.cpp @@ -9,20 +9,14 @@ #include "clfunc.h" -#include "../clib/clib.h" -#include "../clib/clib_endian.h" -#include "../clib/passert.h" +#include +#include #include "mobile/charactr.h" -#include "network/client.h" -#include "network/clienttransmit.h" #include "network/packethelper.h" -#include "pktoutid.h" -#include "sockio.h" +#include "pktdef.h" #include "ufunc.h" -#include - namespace Pol { namespace Core diff --git a/pol-core/pol/clfunc.h b/pol-core/pol/clfunc.h index c788645f8..c764c40dc 100644 --- a/pol-core/pol/clfunc.h +++ b/pol-core/pol/clfunc.h @@ -4,28 +4,29 @@ #define __CLFUNC_H -#include "../clib/rawtypes.h" - -#include "network/packets.h" - // this is for NULLs found.. #include + +#include "../clib/rawtypes.h" +#include "network/packets.h" +#include "uconst.h" + namespace Pol { namespace Network { - class Client; +class Client; } namespace Mobile { - class Character; +class Character; } namespace Core { class UObject; void send_sysmessage_cl( Network::Client* client, // System message (lower left corner) - // Character *chr_from, + // Character *chr_from, unsigned int cliloc_num, const u16* arguments = 0, unsigned short font = DEFAULT_TEXT_FONT, unsigned short color = DEFAULT_TEXT_COLOR ); diff --git a/pol-core/pol/cmbtcfg.cpp b/pol-core/pol/cmbtcfg.cpp index 4b701e615..eb17f2e1d 100644 --- a/pol-core/pol/cmbtcfg.cpp +++ b/pol-core/pol/cmbtcfg.cpp @@ -10,13 +10,12 @@ #include "cmbtcfg.h" -#include "../plib/systemstate.h" #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" - +#include "../plib/systemstate.h" #include "globals/settings.h" namespace Pol @@ -51,4 +50,4 @@ void CombatConfig::read_combat_config() settingsManager.combat_config.send_attack_msg = elem.remove_bool( "SendAttackMsg", true ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/cmdlevel.cpp b/pol-core/pol/cmdlevel.cpp index 0be99f364..e050c2de6 100644 --- a/pol-core/pol/cmdlevel.cpp +++ b/pol-core/pol/cmdlevel.cpp @@ -7,24 +7,22 @@ #include "cmdlevel.h" -#include "../clib/cfgfile.h" +#include +#include + +#include "../bscript/bstruct.h" +#include "../bscript/impstr.h" #include "../clib/cfgelem.h" +#include "../clib/cfgfile.h" +#include "../clib/clib.h" #include "../clib/dirlist.h" #include "../clib/fileutil.h" #include "../clib/stlutil.h" #include "../clib/strutil.h" - -#include "../bscript/impstr.h" -#include "../bscript/bstruct.h" - #include "../plib/pkg.h" #include "../plib/systemstate.h" - #include "globals/uvars.h" -#include -#include - #ifdef _MSC_VER #pragma warning( disable : 4996 ) // stricmp POSIX deprecation warning #endif diff --git a/pol-core/pol/console.cpp b/pol-core/pol/console.cpp index 94d3b673f..744bdf1cf 100644 --- a/pol-core/pol/console.cpp +++ b/pol-core/pol/console.cpp @@ -6,32 +6,35 @@ #include "console.h" +#include +#include + +#include #include "../bscript/eprog.h" #include "../bscript/impstr.h" - #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" -#include "../clib/kbhit.h" #include "../clib/fileutil.h" -#include "../clib/stlutil.h" +#include "../clib/kbhit.h" #include "../clib/logfacility.h" - +#include "../clib/refptr.h" +#include "../clib/stlutil.h" #include "../plib/systemstate.h" - -#include "polcfg.h" +#include "globals/state.h" +#include "globals/uvars.h" #include "polsem.h" +#include "polsig.h" #include "scrdef.h" #include "scrsched.h" #include "scrstore.h" -#include "globals/uvars.h" -#include "globals/state.h" #ifdef _WIN32 #include #endif -#include +#include #include +#include #ifdef _MSC_VER #pragma warning( disable : 4996 ) // POSIX deprecation warning getch() diff --git a/pol-core/pol/containr.cpp b/pol-core/pol/containr.cpp index b5d46f9a9..3491efbbc 100644 --- a/pol-core/pol/containr.cpp +++ b/pol-core/pol/containr.cpp @@ -22,35 +22,28 @@ #include "containr.h" -#include "../clib/cfgfile.h" +#include +#include + #include "../clib/cfgelem.h" #include "../clib/logfacility.h" -#include "../clib/streamsaver.h" #include "../clib/passert.h" #include "../clib/random.h" -#include "../clib/stlutil.h" - -#include "network/client.h" -#include "mobile/charactr.h" -#include "core.h" -#include "item/equipmnt.h" +#include "../clib/streamsaver.h" +#include "globals/state.h" #include "item/itemdesc.h" -#include "multi/multi.h" +#include "mobile/charactr.h" +#include "network/client.h" +#include "profile.h" +#include "scrdef.h" +#include "scrsched.h" #include "statmsg.h" -#include "globals/ucfg.h" +#include "uconst.h" #include "ufunc.h" #include "umanip.h" -#include "globals/uvars.h" -#include "globals/settings.h" -#include "globals/state.h" -#include "uworld.h" -#include "objtype.h" -#include "sockio.h" -#include "scrsched.h" +#include "uobject.h" #include "uoscrobj.h" - -#include -#include +#include "uworld.h" namespace Pol diff --git a/pol-core/pol/containr.h b/pol-core/pol/containr.h index 6b69ef091..4ada9dc65 100644 --- a/pol-core/pol/containr.h +++ b/pol-core/pol/containr.h @@ -14,6 +14,12 @@ #ifndef CONTAINR_H #define CONTAINR_H +#include + +#include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" +#include "baseobject.h" +#include "dynproperties.h" #ifndef ITEM_H #include "item/item.h" #endif @@ -40,6 +46,38 @@ namespace Pol namespace Clib { class ConfigElem; +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class ObjArray; +} // namespace Bscript +namespace Clib +{ +class StreamWriter; +} // namespace Clib +namespace Core +{ +class UContainer; +} // namespace Core +namespace Items +{ +class ItemDesc; +} // namespace Items +namespace Mobile +{ +class NPC; +} // namespace Mobile +namespace Multi +{ +class UMulti; +} // namespace Multi +namespace Network +{ +class Client; +} // namespace Network +} // namespace Pol } namespace Mobile { diff --git a/pol-core/pol/core.cpp b/pol-core/pol/core.cpp index 61930cf4d..7138b904e 100644 --- a/pol-core/pol/core.cpp +++ b/pol-core/pol/core.cpp @@ -8,24 +8,23 @@ #include "core.h" -#include "realms.h" -#include "realms/realm.h" +#include +#include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" +#include "fnsearch.h" #include "globals/uvars.h" +#include "item/item.h" +#include "item/itemdesc.h" #include "mobile/charactr.h" +#include "multi/house.h" +#include "multi/multi.h" #include "network/cgdata.h" #include "network/client.h" -#include "fnsearch.h" -#include "item/itemdesc.h" - -#include "module/polsystemmod.h" -#include "multi/multi.h" -#include "multi/house.h" +#include "realms/realm.h" #include "ufunc.h" #include "uworld.h" -#include "polsem.h" - namespace Pol { namespace Core diff --git a/pol-core/pol/create.cpp b/pol-core/pol/create.cpp index b0439a106..fbde3cbc7 100644 --- a/pol-core/pol/create.cpp +++ b/pol-core/pol/create.cpp @@ -10,52 +10,47 @@ */ +#include +#include + +#include #include "../clib/clib_endian.h" -#include "../clib/fdump.h" #include "../clib/logfacility.h" -#include "../clib/random.h" -#include "../clib/strutil.h" - +#include "../clib/rawtypes.h" +#include "../clib/refptr.h" #include "../plib/systemstate.h" - #include "accounts/account.h" -#include "mobile/attribute.h" -#include "mobile/charactr.h" #include "clidata.h" -#include "network/client.h" +#include "containr.h" #include "gameclck.h" +#include "globals/network.h" +#include "globals/object_storage.h" +#include "globals/uvars.h" +#include "item/item.h" #include "layers.h" #include "mkscrobj.h" -#include "network/msgfiltr.h" -#include "network/msghandl.h" +#include "mobile/attribute.h" +#include "mobile/charactr.h" +#include "mobile/wornitems.h" +#include "module/osmod.h" +#include "module/uomod.h" +#include "network/client.h" #include "objtype.h" +#include "pktdef.h" #include "pktin.h" #include "polcfg.h" -#include "realms.h" -#include "realms/realm.h" -#include "scrdef.h" -#include "skilladv.h" -#include "sockio.h" +#include "realms/WorldChangeReasons.h" +#include "scrsched.h" +#include "scrstore.h" +#include "skillid.h" #include "startloc.h" #include "uconst.h" #include "ufunc.h" +#include "uoclient.h" +#include "uoexec.h" #include "uoskills.h" -#include "globals/uvars.h" -#include "globals/object_storage.h" -#include "globals/network.h" #include "uworld.h" -#include "../bscript/bobject.h" -#include "module/osmod.h" -#include "scrsched.h" -#include "scrstore.h" -#include "uoexec.h" -#include "module/uomod.h" -#include "containr.h" -#include "mobile/wornitems.h" - -#include -#include namespace Pol { diff --git a/pol-core/pol/crypt/blowfish.cpp b/pol-core/pol/crypt/blowfish.cpp index bab1228ac..229306d91 100644 --- a/pol-core/pol/crypt/blowfish.cpp +++ b/pol-core/pol/crypt/blowfish.cpp @@ -1,5 +1,7 @@ -#include +#include + #include "blowfish.h" +#include "cryptbase.h" // Crypt Boxes namespace Pol @@ -270,9 +272,7 @@ BlowFish::BlowFish() : table_index( 0 ), block_pos( 0 ), stream_pos( 0 ) { memset( &game_seed, 0, sizeof( game_seed ) ); } -BlowFish::~BlowFish() -{ -} +BlowFish::~BlowFish() {} // Public Member Functions diff --git a/pol-core/pol/crypt/crypt.cpp b/pol-core/pol/crypt/crypt.cpp index d63cc0865..edb459f2f 100644 --- a/pol-core/pol/crypt/crypt.cpp +++ b/pol-core/pol/crypt/crypt.cpp @@ -1,20 +1,21 @@ -#include -#include "crypt.h" -#include "logincrypt.h" + #include "../../clib/passert.h" +#include "../uconst.h" +#include "blowfish.h" +#include "crypt.h" +#include "cryptbase.h" +#include "logincrypt.h" +#include "md5.h" +#include "twofish.h" // NOCRYPT namespace Pol { namespace Crypt { -CCryptNoCrypt::CCryptNoCrypt() : CCryptBase() -{ -} +CCryptNoCrypt::CCryptNoCrypt() : CCryptBase() {} -CCryptNoCrypt::~CCryptNoCrypt() -{ -} +CCryptNoCrypt::~CCryptNoCrypt() {} int CCryptNoCrypt::Receive( void* buffer, int max_expected, SOCKET socket ) { @@ -30,13 +31,9 @@ void CCryptNoCrypt::Init( void* pvSeed, int type ) // BLOWFISH -CCryptBlowfish::CCryptBlowfish() : CCryptBaseCrypt(), bfish() -{ -} +CCryptBlowfish::CCryptBlowfish() : CCryptBaseCrypt(), bfish() {} -CCryptBlowfish::~CCryptBlowfish() -{ -} +CCryptBlowfish::~CCryptBlowfish() {} CCryptBlowfish::CCryptBlowfish( unsigned int masterKey1, unsigned int masterKey2 ) { @@ -97,13 +94,9 @@ void CCryptBlowfish::Decrypt( void* pvIn, void* pvOut, int len ) // BLOWFISH OLD -CCryptBlowfishOld::CCryptBlowfishOld() : CCryptBlowfish() -{ -} +CCryptBlowfishOld::CCryptBlowfishOld() : CCryptBlowfish() {} -CCryptBlowfishOld::~CCryptBlowfishOld() -{ -} +CCryptBlowfishOld::~CCryptBlowfishOld() {} CCryptBlowfishOld::CCryptBlowfishOld( unsigned int masterKey1, unsigned int masterKey2 ) { @@ -135,13 +128,9 @@ void CCryptBlowfishOld::Decrypt( void* pvIn, void* pvOut, int len ) // BLOWFISH 1.25.36 -CCrypt12536::CCrypt12536() : CCryptBlowfish() -{ -} +CCrypt12536::CCrypt12536() : CCryptBlowfish() {} -CCrypt12536::~CCrypt12536() -{ -} +CCrypt12536::~CCrypt12536() {} CCrypt12536::CCrypt12536( unsigned int masterKey1, unsigned int masterKey2 ) { @@ -173,13 +162,9 @@ void CCrypt12536::Decrypt( void* pvIn, void* pvOut, int len ) // BLOWFISH + TWOFISH -CCryptBlowfishTwofish::CCryptBlowfishTwofish() : CCryptBaseCrypt(), bfish(), tfish() -{ -} +CCryptBlowfishTwofish::CCryptBlowfishTwofish() : CCryptBaseCrypt(), bfish(), tfish() {} -CCryptBlowfishTwofish::~CCryptBlowfishTwofish() -{ -} +CCryptBlowfishTwofish::~CCryptBlowfishTwofish() {} CCryptBlowfishTwofish::CCryptBlowfishTwofish( unsigned int masterKey1, unsigned int masterKey2 ) { @@ -242,13 +227,9 @@ void CCryptBlowfishTwofish::Decrypt( void* pvIn, void* pvOut, int len ) // TWOFISH -CCryptTwofish::CCryptTwofish() : CCryptBaseCrypt(), tfish(), md5() -{ -} +CCryptTwofish::CCryptTwofish() : CCryptBaseCrypt(), tfish(), md5() {} -CCryptTwofish::~CCryptTwofish() -{ -} +CCryptTwofish::~CCryptTwofish() {} CCryptTwofish::CCryptTwofish( unsigned int masterKey1, unsigned int masterKey2 ) { diff --git a/pol-core/pol/crypt/crypt.h b/pol-core/pol/crypt/crypt.h index 55ab1dfc6..ff30fc03e 100644 --- a/pol-core/pol/crypt/crypt.h +++ b/pol-core/pol/crypt/crypt.h @@ -7,11 +7,12 @@ #ifndef __CRYPT_H__ #define __CRYPT_H__ -#include "cryptbase.h" -#include "twofish.h" -#include "blowfish.h" -#include "md5.h" #include "../../clib/compilerspecifics.h" +#include "../sockets.h" +#include "blowfish.h" +#include "cryptbase.h" +#include "md5.h" +#include "twofish.h" // NOCRYPT namespace Pol diff --git a/pol-core/pol/crypt/cryptbase.cpp b/pol-core/pol/crypt/cryptbase.cpp index 85e22aac7..2465f3f12 100644 --- a/pol-core/pol/crypt/cryptbase.cpp +++ b/pol-core/pol/crypt/cryptbase.cpp @@ -38,8 +38,10 @@ // ////////////////////////////////////////////////////////////////////// -#include +#include + #include "cryptbase.h" + namespace Pol { namespace Crypt @@ -69,12 +71,8 @@ namespace Crypt // Constructor / Destructor -CCryptBase::CCryptBase() -{ -} -CCryptBase::~CCryptBase() -{ -} +CCryptBase::CCryptBase() {} +CCryptBase::~CCryptBase() {} // Constructor / Destructor CCryptBaseCrypt::CCryptBaseCrypt() : CCryptBase(), lcrypt(), m_type( 0 ) @@ -82,8 +80,6 @@ CCryptBaseCrypt::CCryptBaseCrypt() : CCryptBase(), lcrypt(), m_type( 0 ) memset( &m_masterKey, 0, sizeof( m_masterKey ) ); memset( &encrypted_data, 0, sizeof( encrypted_data ) ); } -CCryptBaseCrypt::~CCryptBaseCrypt() -{ +CCryptBaseCrypt::~CCryptBaseCrypt() {} } } -} \ No newline at end of file diff --git a/pol-core/pol/crypt/cryptengine.cpp b/pol-core/pol/crypt/cryptengine.cpp index 86dab4310..b58b603a6 100644 --- a/pol-core/pol/crypt/cryptengine.cpp +++ b/pol-core/pol/crypt/cryptengine.cpp @@ -5,13 +5,10 @@ #include "cryptengine.h" -#include "cryptbase.h" -#include "crypt.h" - -#include "../polcfg.h" #include "../../clib/logfacility.h" -#include "../../clib/strutil.h" +#include "crypt.h" +#include "cryptkey.h" namespace Pol { diff --git a/pol-core/pol/crypt/cryptkey.cpp b/pol-core/pol/crypt/cryptkey.cpp index efe613811..162c9a540 100644 --- a/pol-core/pol/crypt/cryptkey.cpp +++ b/pol-core/pol/crypt/cryptkey.cpp @@ -16,9 +16,10 @@ #include "cryptkey.h" +#include + #include "../../clib/clib.h" #include "../../clib/logfacility.h" -#include #ifdef _MSC_VER #pragma warning( disable : 4996 ) // strnicmp POSIX deprecation warning @@ -230,4 +231,4 @@ bool compareVersion( int ver1major, int ver1minor, int ver1build, int ver2major, // AddClient("uorice", 0, 0, CRYPT_NOCRYPT); //dave added 3/14, avoid newbie // confusion } -} \ No newline at end of file +} diff --git a/pol-core/pol/crypt/logincrypt.cpp b/pol-core/pol/crypt/logincrypt.cpp index 7bffca7a4..41a0ef070 100644 --- a/pol-core/pol/crypt/logincrypt.cpp +++ b/pol-core/pol/crypt/logincrypt.cpp @@ -1,7 +1,6 @@ -#include +#include + #include "logincrypt.h" -#include "crypt.h" -#include "cryptbase.h" namespace Pol { @@ -17,9 +16,7 @@ LoginCrypt::LoginCrypt() : m_k1( 0 ), m_k2( 0 ) { memset( &lkey, 0, sizeof( lkey ) ); } -LoginCrypt::~LoginCrypt() -{ -} +LoginCrypt::~LoginCrypt() {} // Member Functions void LoginCrypt::Init( unsigned char* lseed, unsigned int k1, unsigned int k2 ) @@ -83,4 +80,4 @@ void LoginCrypt::Decrypt_1_25_36( unsigned char* in, unsigned char* out, int len } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/crypt/md5.cpp b/pol-core/pol/crypt/md5.cpp index 87ac2c947..fa2933d07 100644 --- a/pol-core/pol/crypt/md5.cpp +++ b/pol-core/pol/crypt/md5.cpp @@ -1,8 +1,7 @@ -#include #include + #include "md5.h" -#include "twofish.h" -#include "cryptbase.h" + namespace Pol { namespace Crypt @@ -80,9 +79,7 @@ MD5Crypt::MD5Crypt() : TableIdx( 0 ) { memset( &Digest, 0, sizeof( Digest ) ); } -MD5Crypt::~MD5Crypt() -{ -} +MD5Crypt::~MD5Crypt() {} // Public Member Functions @@ -303,4 +300,4 @@ void MD5Crypt::finish( md5_state* pms, unsigned char digest[16] ) digest[i] = (unsigned char)( pms->abcd[i >> 2] >> ( ( i & 3 ) << 3 ) ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/crypt/twofish.cpp b/pol-core/pol/crypt/twofish.cpp index 2c502f7e9..d8b288d0f 100644 --- a/pol-core/pol/crypt/twofish.cpp +++ b/pol-core/pol/crypt/twofish.cpp @@ -1,8 +1,8 @@ -#include #include -#include "twofish.h" -#include "cryptbase.h" + #include "../../clib/passert.h" +#include "twofish.h" + namespace Pol { namespace Crypt @@ -10,38 +10,40 @@ namespace Crypt // Crypt Table unsigned char P8x8[2][256] = { - {0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38, - 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C, 0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, 0x94, 0x48, - 0xF2, 0xD0, 0x8B, 0x30, 0x84, 0x54, 0xDF, 0x23, 0x19, 0x5B, 0x3D, 0x59, 0xF3, 0xAE, 0xA2, 0x82, - 0x63, 0x01, 0x83, 0x2E, 0xD9, 0x51, 0x9B, 0x7C, 0xA6, 0xEB, 0xA5, 0xBE, 0x16, 0x0C, 0xE3, 0x61, - 0xC0, 0x8C, 0x3A, 0xF5, 0x73, 0x2C, 0x25, 0x0B, 0xBB, 0x4E, 0x89, 0x6B, 0x53, 0x6A, 0xB4, 0xF1, - 0xE1, 0xE6, 0xBD, 0x45, 0xE2, 0xF4, 0xB6, 0x66, 0xCC, 0x95, 0x03, 0x56, 0xD4, 0x1C, 0x1E, 0xD7, - 0xFB, 0xC3, 0x8E, 0xB5, 0xE9, 0xCF, 0xBF, 0xBA, 0xEA, 0x77, 0x39, 0xAF, 0x33, 0xC9, 0x62, 0x71, - 0x81, 0x79, 0x09, 0xAD, 0x24, 0xCD, 0xF9, 0xD8, 0xE5, 0xC5, 0xB9, 0x4D, 0x44, 0x08, 0x86, 0xE7, - 0xA1, 0x1D, 0xAA, 0xED, 0x06, 0x70, 0xB2, 0xD2, 0x41, 0x7B, 0xA0, 0x11, 0x31, 0xC2, 0x27, 0x90, - 0x20, 0xF6, 0x60, 0xFF, 0x96, 0x5C, 0xB1, 0xAB, 0x9E, 0x9C, 0x52, 0x1B, 0x5F, 0x93, 0x0A, 0xEF, - 0x91, 0x85, 0x49, 0xEE, 0x2D, 0x4F, 0x8F, 0x3B, 0x47, 0x87, 0x6D, 0x46, 0xD6, 0x3E, 0x69, 0x64, - 0x2A, 0xCE, 0xCB, 0x2F, 0xFC, 0x97, 0x05, 0x7A, 0xAC, 0x7F, 0xD5, 0x1A, 0x4B, 0x0E, 0xA7, 0x5A, - 0x28, 0x14, 0x3F, 0x29, 0x88, 0x3C, 0x4C, 0x02, 0xB8, 0xDA, 0xB0, 0x17, 0x55, 0x1F, 0x8A, 0x7D, - 0x57, 0xC7, 0x8D, 0x74, 0xB7, 0xC4, 0x9F, 0x72, 0x7E, 0x15, 0x22, 0x12, 0x58, 0x07, 0x99, 0x34, - 0x6E, 0x50, 0xDE, 0x68, 0x65, 0xBC, 0xDB, 0xF8, 0xC8, 0xA8, 0x2B, 0x40, 0xDC, 0xFE, 0x32, 0xA4, + {0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, + 0x38, 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C, 0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, + 0x94, 0x48, 0xF2, 0xD0, 0x8B, 0x30, 0x84, 0x54, 0xDF, 0x23, 0x19, 0x5B, 0x3D, 0x59, 0xF3, + 0xAE, 0xA2, 0x82, 0x63, 0x01, 0x83, 0x2E, 0xD9, 0x51, 0x9B, 0x7C, 0xA6, 0xEB, 0xA5, 0xBE, + 0x16, 0x0C, 0xE3, 0x61, 0xC0, 0x8C, 0x3A, 0xF5, 0x73, 0x2C, 0x25, 0x0B, 0xBB, 0x4E, 0x89, + 0x6B, 0x53, 0x6A, 0xB4, 0xF1, 0xE1, 0xE6, 0xBD, 0x45, 0xE2, 0xF4, 0xB6, 0x66, 0xCC, 0x95, + 0x03, 0x56, 0xD4, 0x1C, 0x1E, 0xD7, 0xFB, 0xC3, 0x8E, 0xB5, 0xE9, 0xCF, 0xBF, 0xBA, 0xEA, + 0x77, 0x39, 0xAF, 0x33, 0xC9, 0x62, 0x71, 0x81, 0x79, 0x09, 0xAD, 0x24, 0xCD, 0xF9, 0xD8, + 0xE5, 0xC5, 0xB9, 0x4D, 0x44, 0x08, 0x86, 0xE7, 0xA1, 0x1D, 0xAA, 0xED, 0x06, 0x70, 0xB2, + 0xD2, 0x41, 0x7B, 0xA0, 0x11, 0x31, 0xC2, 0x27, 0x90, 0x20, 0xF6, 0x60, 0xFF, 0x96, 0x5C, + 0xB1, 0xAB, 0x9E, 0x9C, 0x52, 0x1B, 0x5F, 0x93, 0x0A, 0xEF, 0x91, 0x85, 0x49, 0xEE, 0x2D, + 0x4F, 0x8F, 0x3B, 0x47, 0x87, 0x6D, 0x46, 0xD6, 0x3E, 0x69, 0x64, 0x2A, 0xCE, 0xCB, 0x2F, + 0xFC, 0x97, 0x05, 0x7A, 0xAC, 0x7F, 0xD5, 0x1A, 0x4B, 0x0E, 0xA7, 0x5A, 0x28, 0x14, 0x3F, + 0x29, 0x88, 0x3C, 0x4C, 0x02, 0xB8, 0xDA, 0xB0, 0x17, 0x55, 0x1F, 0x8A, 0x7D, 0x57, 0xC7, + 0x8D, 0x74, 0xB7, 0xC4, 0x9F, 0x72, 0x7E, 0x15, 0x22, 0x12, 0x58, 0x07, 0x99, 0x34, 0x6E, + 0x50, 0xDE, 0x68, 0x65, 0xBC, 0xDB, 0xF8, 0xC8, 0xA8, 0x2B, 0x40, 0xDC, 0xFE, 0x32, 0xA4, 0xCA, 0x10, 0x21, 0xF0, 0xD3, 0x5D, 0x0F, 0x00, 0x6F, 0x9D, 0x36, 0x42, 0x4A, 0x5E, 0xC1, 0xE0}, - {0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, 0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, 0x4B, - 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1, 0x30, 0x0F, 0xF8, 0x1B, 0x87, 0xFA, 0x06, 0x3F, - 0x5E, 0xBA, 0xAE, 0x5B, 0x8A, 0x00, 0xBC, 0x9D, 0x6D, 0xC1, 0xB1, 0x0E, 0x80, 0x5D, 0xD2, 0xD5, - 0xA0, 0x84, 0x07, 0x14, 0xB5, 0x90, 0x2C, 0xA3, 0xB2, 0x73, 0x4C, 0x54, 0x92, 0x74, 0x36, 0x51, - 0x38, 0xB0, 0xBD, 0x5A, 0xFC, 0x60, 0x62, 0x96, 0x6C, 0x42, 0xF7, 0x10, 0x7C, 0x28, 0x27, 0x8C, - 0x13, 0x95, 0x9C, 0xC7, 0x24, 0x46, 0x3B, 0x70, 0xCA, 0xE3, 0x85, 0xCB, 0x11, 0xD0, 0x93, 0xB8, - 0xA6, 0x83, 0x20, 0xFF, 0x9F, 0x77, 0xC3, 0xCC, 0x03, 0x6F, 0x08, 0xBF, 0x40, 0xE7, 0x2B, 0xE2, - 0x79, 0x0C, 0xAA, 0x82, 0x41, 0x3A, 0xEA, 0xB9, 0xE4, 0x9A, 0xA4, 0x97, 0x7E, 0xDA, 0x7A, 0x17, - 0x66, 0x94, 0xA1, 0x1D, 0x3D, 0xF0, 0xDE, 0xB3, 0x0B, 0x72, 0xA7, 0x1C, 0xEF, 0xD1, 0x53, 0x3E, - 0x8F, 0x33, 0x26, 0x5F, 0xEC, 0x76, 0x2A, 0x49, 0x81, 0x88, 0xEE, 0x21, 0xC4, 0x1A, 0xEB, 0xD9, - 0xC5, 0x39, 0x99, 0xCD, 0xAD, 0x31, 0x8B, 0x01, 0x18, 0x23, 0xDD, 0x1F, 0x4E, 0x2D, 0xF9, 0x48, - 0x4F, 0xF2, 0x65, 0x8E, 0x78, 0x5C, 0x58, 0x19, 0x8D, 0xE5, 0x98, 0x57, 0x67, 0x7F, 0x05, 0x64, - 0xAF, 0x63, 0xB6, 0xFE, 0xF5, 0xB7, 0x3C, 0xA5, 0xCE, 0xE9, 0x68, 0x44, 0xE0, 0x4D, 0x43, 0x69, - 0x29, 0x2E, 0xAC, 0x15, 0x59, 0xA8, 0x0A, 0x9E, 0x6E, 0x47, 0xDF, 0x34, 0x35, 0x6A, 0xCF, 0xDC, - 0x22, 0xC9, 0xC0, 0x9B, 0x89, 0xD4, 0xED, 0xAB, 0x12, 0xA2, 0x0D, 0x52, 0xBB, 0x02, 0x2F, 0xA9, + {0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, 0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, + 0x4B, 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1, 0x30, 0x0F, 0xF8, 0x1B, 0x87, 0xFA, + 0x06, 0x3F, 0x5E, 0xBA, 0xAE, 0x5B, 0x8A, 0x00, 0xBC, 0x9D, 0x6D, 0xC1, 0xB1, 0x0E, 0x80, + 0x5D, 0xD2, 0xD5, 0xA0, 0x84, 0x07, 0x14, 0xB5, 0x90, 0x2C, 0xA3, 0xB2, 0x73, 0x4C, 0x54, + 0x92, 0x74, 0x36, 0x51, 0x38, 0xB0, 0xBD, 0x5A, 0xFC, 0x60, 0x62, 0x96, 0x6C, 0x42, 0xF7, + 0x10, 0x7C, 0x28, 0x27, 0x8C, 0x13, 0x95, 0x9C, 0xC7, 0x24, 0x46, 0x3B, 0x70, 0xCA, 0xE3, + 0x85, 0xCB, 0x11, 0xD0, 0x93, 0xB8, 0xA6, 0x83, 0x20, 0xFF, 0x9F, 0x77, 0xC3, 0xCC, 0x03, + 0x6F, 0x08, 0xBF, 0x40, 0xE7, 0x2B, 0xE2, 0x79, 0x0C, 0xAA, 0x82, 0x41, 0x3A, 0xEA, 0xB9, + 0xE4, 0x9A, 0xA4, 0x97, 0x7E, 0xDA, 0x7A, 0x17, 0x66, 0x94, 0xA1, 0x1D, 0x3D, 0xF0, 0xDE, + 0xB3, 0x0B, 0x72, 0xA7, 0x1C, 0xEF, 0xD1, 0x53, 0x3E, 0x8F, 0x33, 0x26, 0x5F, 0xEC, 0x76, + 0x2A, 0x49, 0x81, 0x88, 0xEE, 0x21, 0xC4, 0x1A, 0xEB, 0xD9, 0xC5, 0x39, 0x99, 0xCD, 0xAD, + 0x31, 0x8B, 0x01, 0x18, 0x23, 0xDD, 0x1F, 0x4E, 0x2D, 0xF9, 0x48, 0x4F, 0xF2, 0x65, 0x8E, + 0x78, 0x5C, 0x58, 0x19, 0x8D, 0xE5, 0x98, 0x57, 0x67, 0x7F, 0x05, 0x64, 0xAF, 0x63, 0xB6, + 0xFE, 0xF5, 0xB7, 0x3C, 0xA5, 0xCE, 0xE9, 0x68, 0x44, 0xE0, 0x4D, 0x43, 0x69, 0x29, 0x2E, + 0xAC, 0x15, 0x59, 0xA8, 0x0A, 0x9E, 0x6E, 0x47, 0xDF, 0x34, 0x35, 0x6A, 0xCF, 0xDC, 0x22, + 0xC9, 0xC0, 0x9B, 0x89, 0xD4, 0xED, 0xAB, 0x12, 0xA2, 0x0D, 0x52, 0xBB, 0x02, 0x2F, 0xA9, 0xD7, 0x61, 0x1E, 0xB4, 0x50, 0x04, 0xF6, 0xC2, 0x16, 0x25, 0x86, 0x56, 0x55, 0x09, 0xBE, 0x91}}; @@ -54,9 +56,7 @@ TwoFish::TwoFish() : seed( 0 ), dwIndex( 0 ), tabEnable( 0 ), pos( 0 ) memset( &tabUsed, 0, sizeof( tabUsed ) ); memset( &numRounds, 0, sizeof( numRounds ) ); } -TwoFish::~TwoFish() -{ -} +TwoFish::~TwoFish() {} // Public Member Functions @@ -136,12 +136,13 @@ unsigned int TwoFish::F32( unsigned int x, unsigned int* k32, int keyLen ) b[1] = p8( 14 )[b[1]] ^ _b( k32[3], 1 ); b[2] = p8( 24 )[b[2]] ^ _b( k32[3], 2 ); b[3] = p8( 34 )[b[3]] ^ _b( k32[3], 3 ); - // falls through + // fall through case 3: b[0] = p8( 03 )[b[0]] ^ _b( k32[2], 0 ); b[1] = p8( 13 )[b[1]] ^ _b( k32[2], 1 ); b[2] = p8( 23 )[b[2]] ^ _b( k32[2], 2 ); b[3] = p8( 33 )[b[3]] ^ _b( k32[2], 3 ); + // fall through case 2: b[0] = p8( 00 )[p8( 01 )[p8( 02 )[b[0]] ^ _b( k32[1], 0 )] ^ _b( k32[0], 0 )]; b[1] = p8( 10 )[p8( 11 )[p8( 12 )[b[1]] ^ _b( k32[1], 1 )] ^ _b( k32[0], 1 )]; diff --git a/pol-core/pol/dblclick.cpp b/pol-core/pol/dblclick.cpp index 2b0c227b7..55cfc6141 100644 --- a/pol-core/pol/dblclick.cpp +++ b/pol-core/pol/dblclick.cpp @@ -14,36 +14,35 @@ */ -#include "../clib/clib.h" -#include "../clib/clib_endian.h" -#include "../bscript/eprog.h" - -#include "../plib/systemstate.h" - -#include "network/client.h" -#include "network/packets.h" -#include "network/packethelper.h" -#include "network/clienttransmit.h" -#include "eventid.h" -#include "item/itemdesc.h" -#include "network/msghandl.h" -#include "mobile/charactr.h" -#include "mobile/npc.h" -#include "pktin.h" -#include "polcfg.h" -#include "realms.h" -#include "realms/realm.h" -#include "scrstore.h" -#include "ufunc.h" -#include "uoscrobj.h" -#include "multi/multi.h" -#include "objtype.h" -#include "containr.h" -#include "globals/uvars.h" - #include #include +#include "../bscript/eprog.h" +#include "../clib/clib_endian.h" +#include "../clib/rawtypes.h" +#include "../clib/refptr.h" +#include "../plib/systemstate.h" +#include "containr.h" +#include "eventid.h" +#include "gameclck.h" +#include "item/item.h" +#include "item/itemdesc.h" +#include "mobile/charactr.h" +#include "mobile/npc.h" +#include "network/client.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "objtype.h" +#include "pktdef.h" +#include "pktin.h" +#include "realms/realm.h" +#include "scrdef.h" +#include "scrsched.h" +#include "scrstore.h" +#include "ufunc.h" +#include "uobject.h" +#include "uoscrobj.h" + namespace Pol { namespace Core diff --git a/pol-core/pol/decay.cpp b/pol-core/pol/decay.cpp index dc2387e6b..9b0af190f 100644 --- a/pol-core/pol/decay.cpp +++ b/pol-core/pol/decay.cpp @@ -10,25 +10,27 @@ #include "decay.h" -#include "../clib/esignal.h" -#include "../plib/systemstate.h" +#include -#include "core.h" +#include "../clib/esignal.h" +#include "../clib/logfacility.h" +#include "../plib/systemstate.h" #include "gameclck.h" #include "globals/state.h" #include "globals/uvars.h" #include "item/item.h" #include "item/itemdesc.h" -#include "polclock.h" +#include "polcfg.h" #include "polsem.h" -#include "realms.h" #include "realms/realm.h" +#include "scrdef.h" #include "scrsched.h" #include "syshook.h" #include "ufunc.h" #include "uoscrobj.h" #include "uworld.h" + namespace Pol { namespace Core diff --git a/pol-core/pol/dice.cpp b/pol-core/pol/dice.cpp index a2719ea0e..da0284351 100644 --- a/pol-core/pol/dice.cpp +++ b/pol-core/pol/dice.cpp @@ -7,21 +7,21 @@ #include "dice.h" -#include "../clib/stlutil.h" -#include "../clib/logfacility.h" -#include "../clib/rawtypes.h" -#include "../clib/random.h" - #include -#include +#include +#include +#include + +#include "../clib/logfacility.h" +#include "../clib/random.h" +#include "../clib/rawtypes.h" +#include "../clib/stlutil.h" namespace Pol { namespace Core { -Dice::Dice() : die_count( 0 ), die_type( 0 ), plus_damage( 0 ) -{ -} +Dice::Dice() : die_count( 0 ), die_type( 0 ), plus_damage( 0 ) {} unsigned short Dice::roll() const { @@ -195,4 +195,4 @@ unsigned short Dice::max_value() const return static_cast( total ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/door.cpp b/pol-core/pol/door.cpp index 62b70f84f..58976eef7 100644 --- a/pol-core/pol/door.cpp +++ b/pol-core/pol/door.cpp @@ -5,14 +5,14 @@ #include "door.h" -#include "network/client.h" +#include + +#include "../clib/rawtypes.h" #include "item/itemdesc.h" -#include "objtype.h" +#include "network/client.h" #include "ufunc.h" #include "uworld.h" -#include "../clib/passert.h" - namespace Pol { diff --git a/pol-core/pol/door.h b/pol-core/pol/door.h index a803744c7..2569f6b46 100644 --- a/pol-core/pol/door.h +++ b/pol-core/pol/door.h @@ -7,6 +7,7 @@ #ifndef DOOR_H #define DOOR_H +#include "../clib/compilerspecifics.h" #ifndef LOCKABLE_H #include "lockable.h" #endif @@ -20,6 +21,14 @@ namespace Pol namespace Network { class Client; +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol } namespace Items { diff --git a/pol-core/pol/dropitem.cpp b/pol-core/pol/dropitem.cpp index a836c39d1..2cc5ca567 100644 --- a/pol-core/pol/dropitem.cpp +++ b/pol-core/pol/dropitem.cpp @@ -25,49 +25,43 @@ */ +#include +#include + #include "../bscript/berror.h" - -#include "../plib/systemstate.h" - -#include "fnsearch.h" -#include "getitem.h" -#include "layers.h" -#include "los.h" -#include "mkscrobj.h" -#include "mobile/charactr.h" -#include "network/msghandl.h" -#include "multi/boat.h" -#include "network/client.h" -#include "network/packets.h" -#include "network/packetdefs.h" -#include "network/clienttransmit.h" -#include "mobile/npc.h" -#include "objtype.h" -#include "pktboth.h" -#include "pktin.h" -#include "polcfg.h" -#include "realms.h" -#include "realms/realm.h" -#include "sfx.h" -#include "sockio.h" -#include "statmsg.h" -#include "storage.h" -#include "syshook.h" -#include "globals/ucfg.h" -#include "ufunc.h" -#include "uoscrobj.h" -#include "globals/uvars.h" -#include "uworld.h" -#include "containr.h" - #include "../clib/clib_endian.h" #include "../clib/logfacility.h" #include "../clib/passert.h" #include "../clib/random.h" -#include "../clib/stlutil.h" -#include "../clib/strutil.h" - -#include +#include "../clib/rawtypes.h" +#include "../plib/systemstate.h" +#include "containr.h" +#include "eventid.h" +#include "fnsearch.h" +#include "globals/uvars.h" +#include "item/item.h" +#include "los.h" +#include "mobile/charactr.h" +#include "mobile/npc.h" +#include "multi/multi.h" +#include "network/client.h" +#include "network/packetdefs.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "objtype.h" +#include "pktboth.h" +#include "pktdef.h" +#include "pktin.h" +#include "polcfg.h" +#include "realms/realm.h" +#include "reftypes.h" +#include "statmsg.h" +#include "storage.h" +#include "syshook.h" +#include "ufunc.h" +#include "uobject.h" +#include "uoscrobj.h" +#include "uworld.h" namespace Pol { diff --git a/pol-core/pol/dynproperties.h b/pol-core/pol/dynproperties.h index 96a2c3606..e42459430 100644 --- a/pol-core/pol/dynproperties.h +++ b/pol-core/pol/dynproperties.h @@ -42,19 +42,17 @@ #ifndef __POL_DYNPROPS_H #define __POL_DYNPROPS_H -#include "../clib/rawtypes.h" -#include "../clib/passert.h" - -#include "gameclck.h" - #include +#include +#include +#include #include #include #include -#include -#include -#include +#include "../clib/passert.h" +#include "../clib/rawtypes.h" +#include "gameclck.h" namespace Pol { @@ -213,7 +211,8 @@ class PropHolderContainer; // small property type no types above size 4, for bigger types boost::any will be used typedef boost::variant variant_storage; + gameclock_t> + variant_storage; template struct can_be_used_in_variant { @@ -314,6 +313,7 @@ public: protected: ~DynamicPropsHolder(); + private: void initProps(); std::unique_ptr _dynprops; @@ -327,12 +327,8 @@ private: //////////////// // ValueModPack -inline ValueModPack::ValueModPack( s16 value_ ) : value( value_ ), mod( 0 ) -{ -} -inline ValueModPack::ValueModPack() : value( 0 ), mod( 0 ) -{ -} +inline ValueModPack::ValueModPack( s16 value_ ) : value( value_ ), mod( 0 ) {} +inline ValueModPack::ValueModPack() : value( 0 ), mod( 0 ) {} inline bool ValueModPack::operator==( const ValueModPack& other ) const { return value == other.value && mod == other.mod; @@ -369,9 +365,7 @@ inline s16 ValueModPack::sum() const //////////////// // SkillStatCap -inline SkillStatCap::SkillStatCap() : statcap( 0 ), skillcap( 0 ) -{ -} +inline SkillStatCap::SkillStatCap() : statcap( 0 ), skillcap( 0 ) {} inline SkillStatCap::SkillStatCap( s16 statcap_, u16 skillcap_ ) : statcap( statcap_ ), skillcap( skillcap_ ) { @@ -383,9 +377,7 @@ inline bool SkillStatCap::operator==( const SkillStatCap& other ) const //////////////// // ExtStatBarFollowers -inline ExtStatBarFollowers::ExtStatBarFollowers() : followers( 0 ), followers_max( 0 ) -{ -} +inline ExtStatBarFollowers::ExtStatBarFollowers() : followers( 0 ), followers_max( 0 ) {} inline ExtStatBarFollowers::ExtStatBarFollowers( s8 followers_, s8 followers_max_ ) : followers( followers_ ), followers_max( followers_max_ ) { @@ -415,8 +407,7 @@ inline bool MovementCostMod::operator==( const MovementCostMod& other ) const //////////////// // PropHolder template -inline PropHolder::PropHolder( DynPropTypes type ) - : _type( type ), _value() +inline PropHolder::PropHolder( DynPropTypes type ) : _type( type ), _value() { } template @@ -441,8 +432,7 @@ inline V PropHolder::getValue() const //////////////// // PropHolderContainer template -inline PropHolderContainer::PropHolderContainer() - : _props() +inline PropHolderContainer::PropHolderContainer() : _props() { } @@ -508,12 +498,10 @@ inline void PropHolderContainer::addValuePointer( DynPropTypes type, V template inline void PropHolderContainer::removeValue( DynPropTypes type ) { - _props.erase( std::remove_if( _props.begin(), _props.end(), - [&type]( const PropHolder& x ) - { - return type == x._type; - } ), - _props.end() ); + _props.erase( + std::remove_if( _props.begin(), _props.end(), + [&type]( const PropHolder& x ) { return type == x._type; } ), + _props.end() ); } template @@ -602,9 +590,7 @@ static typename std::enable_if::value, void>::type re //////////////// // DynProps -inline DynProps::DynProps() : _prop_bits(), _props(), _any_props( nullptr ) -{ -} +inline DynProps::DynProps() : _prop_bits(), _props(), _any_props( nullptr ) {} inline bool DynProps::hasProperty( DynPropTypes type ) const { @@ -668,12 +654,9 @@ inline size_t DynProps::estimateSize() const //////////////// // DynamicPropsHolder -inline DynamicPropsHolder::DynamicPropsHolder() : _dynprops( nullptr ) -{ -} +inline DynamicPropsHolder::DynamicPropsHolder() : _dynprops( nullptr ) {} -inline DynamicPropsHolder::~DynamicPropsHolder() -{} +inline DynamicPropsHolder::~DynamicPropsHolder() {} inline void DynamicPropsHolder::initProps() { diff --git a/pol-core/pol/eqpitem.cpp b/pol-core/pol/eqpitem.cpp index d04c90825..5d4d721dd 100644 --- a/pol-core/pol/eqpitem.cpp +++ b/pol-core/pol/eqpitem.cpp @@ -7,21 +7,21 @@ */ -#include "../bscript/bobject.h" +#include #include "../clib/clib_endian.h" #include "../clib/logfacility.h" - -#include "realms/realm.h" -#include "network/client.h" -#include "network/msghandl.h" +#include "../clib/rawtypes.h" +#include "item/item.h" +#include "layers.h" #include "mobile/charactr.h" #include "multi/multi.h" +#include "network/client.h" +#include "pktdef.h" #include "pktin.h" +#include "realms/realm.h" +#include "reftypes.h" #include "ufunc.h" -#include "globals/uvars.h" - -#include namespace Pol { diff --git a/pol-core/pol/equipdsc.cpp b/pol-core/pol/equipdsc.cpp index 86c5222dd..a00df64ca 100644 --- a/pol-core/pol/equipdsc.cpp +++ b/pol-core/pol/equipdsc.cpp @@ -5,9 +5,6 @@ #include "equipdsc.h" -#include "../clib/cfgelem.h" -#include "../bscript/bstruct.h" - namespace Pol { @@ -25,7 +22,7 @@ void EquipDesc::PopulateStruct( Bscript::BStruct* descriptor ) const size_t EquipDesc::estimatedSize() const { return base::estimatedSize() + sizeof( bool ) /*is_intrinsic*/ - +sizeof( bool ); /*is_pc_intrinsic*/ + + sizeof( bool ); /*is_pc_intrinsic*/ } /* EquipDesc::EquipDesc() diff --git a/pol-core/pol/equipdsc.h b/pol-core/pol/equipdsc.h index 4239ee156..cfe047278 100644 --- a/pol-core/pol/equipdsc.h +++ b/pol-core/pol/equipdsc.h @@ -7,8 +7,18 @@ #ifndef EQUIPDSC_H #define EQUIPDSC_H +#include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" #include "item/itemdesc.h" +namespace Pol +{ +namespace Bscript +{ +class BStruct; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Clib diff --git a/pol-core/pol/exscrobj.cpp b/pol-core/pol/exscrobj.cpp index 5c158e77e..5f0a77d4f 100644 --- a/pol-core/pol/exscrobj.cpp +++ b/pol-core/pol/exscrobj.cpp @@ -14,20 +14,23 @@ #include "exscrobj.h" +#include +#include + #include "../bscript/berror.h" +#include "../bscript/bobject.h" #include "../bscript/dict.h" +#include "../bscript/executor.h" #include "../bscript/impstr.h" #include "../bscript/objmembers.h" #include "../bscript/objmethods.h" - -#include "module/uomod.h" -#include "module/osmod.h" -#include "uoexec.h" -#include "uoscrobj.h" - #include "../clib/strutil.h" #include "../plib/systemstate.h" - +#include "module/osmod.h" +#include "module/uomod.h" +#include "polcfg.h" +#include "uoexec.h" +#include "uoscrobj.h" namespace Pol { @@ -229,4 +232,4 @@ BObjectRef ScriptExObjImp::get_member( const char* membername ) return BObjectRef( UninitObject::create() ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/exscrobj.h b/pol-core/pol/exscrobj.h index c00e99c23..b28d64b34 100644 --- a/pol-core/pol/exscrobj.h +++ b/pol-core/pol/exscrobj.h @@ -13,7 +13,18 @@ #include "../bscript/bobject.h" #endif +#include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" #include "../clib/weakptr.h" + +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Core diff --git a/pol-core/pol/extobj.cpp b/pol-core/pol/extobj.cpp index b17f990ea..6a9b5dc24 100644 --- a/pol-core/pol/extobj.cpp +++ b/pol-core/pol/extobj.cpp @@ -13,8 +13,6 @@ #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/fileutil.h" -#include "../clib/rawtypes.h" - #include "globals/settings.h" namespace Pol diff --git a/pol-core/pol/fnsearch.cpp b/pol-core/pol/fnsearch.cpp index ac1bfc7d5..a349cf159 100644 --- a/pol-core/pol/fnsearch.cpp +++ b/pol-core/pol/fnsearch.cpp @@ -7,14 +7,14 @@ #include "fnsearch.h" -#include "../clib/stlutil.h" +#include #include "globals/object_storage.h" -#include "mobile/charactr.h" #include "item/item.h" -#include "storage.h" +#include "mobile/charactr.h" #include "multi/multi.h" -#include "uworld.h" +#include "objecthash.h" +#include "uobject.h" namespace Pol { diff --git a/pol-core/pol/fnsearch.h b/pol-core/pol/fnsearch.h index 0221afd26..61eec3b64 100644 --- a/pol-core/pol/fnsearch.h +++ b/pol-core/pol/fnsearch.h @@ -7,7 +7,9 @@ #ifndef FNSEARCH_H #define FNSEARCH_H +#include "../clib/rawtypes.h" #include "utype.h" + namespace Pol { namespace Items diff --git a/pol-core/pol/gameclck.cpp b/pol-core/pol/gameclck.cpp index 3c3fe257d..c3ecad238 100644 --- a/pol-core/pol/gameclck.cpp +++ b/pol-core/pol/gameclck.cpp @@ -6,14 +6,13 @@ #include "gameclck.h" -#include "polclock.h" -#include "globals/uvars.h" - -#include "../clib/stlutil.h" -#include "../clib/spinlock.h" - #include -#include +#include + +#include "../clib/spinlock.h" +#include "../clib/stlutil.h" +#include "globals/uvars.h" +#include "polclock.h" namespace Pol { @@ -65,4 +64,4 @@ gameclock_t read_gameclock() return gameclock; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/getitem.cpp b/pol-core/pol/getitem.cpp index 3da3e644c..ed7080303 100644 --- a/pol-core/pol/getitem.cpp +++ b/pol-core/pol/getitem.cpp @@ -15,27 +15,21 @@ #include "getitem.h" -#include "realms/realm.h" +#include -#include "multi/boat.h" +#include "../clib/clib_endian.h" +#include "../clib/rawtypes.h" +#include "containr.h" +#include "item/item.h" #include "mobile/charactr.h" #include "network/client.h" -#include "network/msghandl.h" - +#include "pktdef.h" #include "pktin.h" -#include "realms.h" +#include "reftypes.h" #include "statmsg.h" -#include "globals/uvars.h" #include "ufunc.h" #include "uobject.h" #include "uworld.h" -#include "containr.h" - -#include "../clib/clib_endian.h" -#include "../clib/stlutil.h" - - -#include /* How get_item works: diff --git a/pol-core/pol/getmsg.cpp b/pol-core/pol/getmsg.cpp index 134da2df1..0539719bd 100644 --- a/pol-core/pol/getmsg.cpp +++ b/pol-core/pol/getmsg.cpp @@ -4,23 +4,23 @@ */ +#include +#include + #include "../bscript/berror.h" #include "../bscript/impstr.h" - #include "../clib/clib_endian.h" +#include "../clib/logfacility.h" #include "../clib/rawtypes.h" - #include "item/item.h" #include "mobile/charactr.h" #include "module/osmod.h" #include "module/uomod.h" -#include "network/msghandl.h" #include "network/cgdata.h" #include "network/client.h" -#include "network/packets.h" #include "network/packethelper.h" +#include "network/packets.h" #include "pktboth.h" -#include "sockio.h" #include "ufunc.h" #include "uoexec.h" @@ -95,12 +95,12 @@ Bscript::BObjectImp* UOExecutorModule::mf_PromptInput() if ( !uoexec.suspend() ) { - DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" - << "\tCall to function UO::RequestInput():\n" - << "\tThe execution of this script can't be blocked!\n"; - return new Bscript::BError( "Script can't be blocked" ); + DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" + << "\tCall to function UO::RequestInput():\n" + << "\tThe execution of this script can't be blocked!\n"; + return new Bscript::BError( "Script can't be blocked" ); } - + Core::send_sysmessage( chr->client, prompt->data() ); chr->client->gd->prompt_uoemod = this; diff --git a/pol-core/pol/globals/memoryusage.cpp b/pol-core/pol/globals/memoryusage.cpp index ba04eb944..774b321e1 100644 --- a/pol-core/pol/globals/memoryusage.cpp +++ b/pol-core/pol/globals/memoryusage.cpp @@ -1,7 +1,9 @@ #include "memoryusage.h" +#include #include "../../clib/fileutil.h" #include "../../clib/logfacility.h" +#include "../../plib/systemstate.h" #include "multidefs.h" #include "network.h" #include "object_storage.h" @@ -11,8 +13,6 @@ #include "ucfg.h" #include "uvars.h" -#include "../../plib/systemstate.h" - #ifdef WINDOWS #include "../../clib/pol_global_config_win.h" #else diff --git a/pol-core/pol/globals/multidefs.cpp b/pol-core/pol/globals/multidefs.cpp index d6e93f6c6..34d207e7e 100644 --- a/pol-core/pol/globals/multidefs.cpp +++ b/pol-core/pol/globals/multidefs.cpp @@ -8,8 +8,9 @@ #include "multidefs.h" -#include "../multi/multidef.h" +#include +#include "../multi/multidef.h" namespace Pol { @@ -17,12 +18,8 @@ namespace Multi { MultiDefBuffer multidef_buffer; -MultiDefBuffer::MultiDefBuffer() : multidefs_by_multiid() -{ -} -MultiDefBuffer::~MultiDefBuffer() -{ -} +MultiDefBuffer::MultiDefBuffer() : multidefs_by_multiid() {} +MultiDefBuffer::~MultiDefBuffer() {} void MultiDefBuffer::deinitialize() { @@ -48,4 +45,4 @@ size_t MultiDefBuffer::estimateSize() const return size; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/globals/multidefs.h b/pol-core/pol/globals/multidefs.h index 39fcef04d..ea7aabb03 100644 --- a/pol-core/pol/globals/multidefs.h +++ b/pol-core/pol/globals/multidefs.h @@ -7,11 +7,11 @@ #ifndef GLOBALS_MULTIDEFS_H #define GLOBALS_MULTIDEFS_H -#include "../../clib/rawtypes.h" - -#include -#include #include +#include +#include + +#include "../../clib/rawtypes.h" namespace Pol { diff --git a/pol-core/pol/globals/network.cpp b/pol-core/pol/globals/network.cpp index c1da54209..c9d00f508 100644 --- a/pol-core/pol/globals/network.cpp +++ b/pol-core/pol/globals/network.cpp @@ -1,25 +1,25 @@ #include "network.h" +#include +#include + +#include "../../clib/logfacility.h" #include "../../clib/stlutil.h" #include "../../clib/threadhelp.h" - #include "../../plib/systemstate.h" - - #include "../accounts/account.h" +#include "../mobile/charactr.h" #include "../network/auxclient.h" -#include "../network/client.h" #include "../network/clienttransmit.h" #include "../network/cliface.h" #include "../network/msgfiltr.h" +#include "../network/msghandl.h" #include "../network/packethooks.h" #include "../network/packetinterface.h" -#include "../network/packets.h" -#include "../mobile/charactr.h" #include "../servdesc.h" +#include "../sockio.h" #include "../sqlscrobj.h" - -#include +#include "../uoclient.h" namespace Pol { @@ -67,12 +67,10 @@ NetworkManager::NetworkManager() Network::PacketRegistry::initialize_msg_handlers(); - curl_global_init(CURL_GLOBAL_DEFAULT); + curl_global_init( CURL_GLOBAL_DEFAULT ); } -NetworkManager::~NetworkManager() -{ -} +NetworkManager::~NetworkManager() {} void NetworkManager::kill_disconnected_clients() { Clients::iterator itr = clients.begin(); @@ -194,4 +192,4 @@ NetworkManager::Memory NetworkManager::estimateSize() const return usage; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/globals/network.h b/pol-core/pol/globals/network.h index 1830c1bdb..6920f16b4 100644 --- a/pol-core/pol/globals/network.h +++ b/pol-core/pol/globals/network.h @@ -7,29 +7,28 @@ #include "pol_global_config.h" #endif +#include +#include +#include +#include + +#include "../network/bannedips.h" #include "../network/iostats.h" #include "../network/msghandl.h" -#include "../network/bannedips.h" #include "../polstats.h" #include "../sockio.h" #include "../uoclient.h" -#include - -#include -#include -#include - namespace Pol { namespace Network { -class Client; -class UOClientInterface; class AuxService; +class Client; +class ClientTransmit; class PacketHookData; class PacketsSingleton; -class ClientTransmit; +class UOClientInterface; } namespace threadhelp { @@ -38,8 +37,8 @@ class DynTaskThreadPool; namespace Core { class MessageTypeFilter; -class ServerDescription; class SQLService; +class ServerDescription; typedef std::vector Clients; typedef std::vector Servers; @@ -54,6 +53,7 @@ public: void kill_disconnected_clients(); struct Memory; + Memory estimateSize() const; Clients clients; diff --git a/pol-core/pol/globals/object_storage.cpp b/pol-core/pol/globals/object_storage.cpp index 550fb1ba0..694d3647d 100644 --- a/pol-core/pol/globals/object_storage.cpp +++ b/pol-core/pol/globals/object_storage.cpp @@ -1,5 +1,8 @@ #include "object_storage.h" +#include + +#include "../objecthash.h" #include "../reftypes.h" #include "../uobject.h" @@ -23,9 +26,7 @@ ObjectStorageManager::ObjectStorageManager() { } -ObjectStorageManager::~ObjectStorageManager() -{ -} +ObjectStorageManager::~ObjectStorageManager() {} void ObjectStorageManager::deinitialize() diff --git a/pol-core/pol/globals/object_storage.h b/pol-core/pol/globals/object_storage.h index 25bf14815..f455f0443 100644 --- a/pol-core/pol/globals/object_storage.h +++ b/pol-core/pol/globals/object_storage.h @@ -2,16 +2,15 @@ #define GLOBALS_OBJ_STORAGE_H -#include "../../clib/rawtypes.h" -#include "../objecthash.h" -#include "../poltype.h" - #include - +#include #include #include #include -#include + +#include "../../clib/rawtypes.h" +#include "../objecthash.h" +#include "../poltype.h" namespace Pol { @@ -29,6 +28,7 @@ public: void deinitialize(); struct MemoryUsage; + MemoryUsage estimateSize() const; unsigned incremental_save_count; diff --git a/pol-core/pol/globals/script_internals.cpp b/pol-core/pol/globals/script_internals.cpp index 73d828d6a..dc8d856cc 100644 --- a/pol-core/pol/globals/script_internals.cpp +++ b/pol-core/pol/globals/script_internals.cpp @@ -1,16 +1,14 @@ #include "script_internals.h" -#include "../../clib/stlutil.h" +#include - -#include "../../plib/systemstate.h" // needed for config -#include "state.h" // needed for thread checkpoint - -#include "../module/osmod.h" - -#include "../uoexec.h" -#include "../polsig.h" #include "../../clib/logfacility.h" +#include "../../clib/passert.h" +#include "../../plib/systemstate.h" +#include "../module/osmod.h" +#include "../polsig.h" +#include "../uoexec.h" +#include "state.h" namespace Pol { @@ -25,8 +23,8 @@ ScriptScheduler scriptScheduler; const unsigned int ScriptScheduler::PID_MIN = 0x01000000; ScriptScheduler::ScriptScheduler() - : priority_divide(1), - scrstore(), + : priority_divide( 1 ), + scrstore(), runlist(), ranlist(), holdlist(), @@ -37,9 +35,7 @@ ScriptScheduler::ScriptScheduler() { } -ScriptScheduler::~ScriptScheduler() -{ -} +ScriptScheduler::~ScriptScheduler() {} // Note, when the program exits, each executor in these queues // will be deleted by cleanup_scripts() @@ -74,9 +70,8 @@ ScriptScheduler::Memory ScriptScheduler::estimateSize() const usage.script_size = sizeof( int ) /*priority_divide*/ + sizeof( unsigned int ) /*next_pid*/ - + - ( sizeof( unsigned int ) + sizeof( UOExecutor* ) + ( sizeof( void* ) * 3 + 1 ) / 2 ) * - pidlist.size(); + + ( sizeof( unsigned int ) + sizeof( UOExecutor* ) + ( sizeof( void* ) * 3 + 1 ) / 2 ) * + pidlist.size(); for ( const auto& script : scrstore ) { @@ -133,195 +128,196 @@ ScriptScheduler::Memory ScriptScheduler::estimateSize() const } -void ScriptScheduler::run_ready() { - - THREAD_CHECKPOINT(scripts, 110); - while (!runlist.empty()) - { - ExecList::iterator itr = runlist.begin(); - UOExecutor* ex = *itr; - passert_paranoid(ex != nullptr); - runlist.pop_front(); // remove it directly, since itr can get invalid during execution - - Module::OSExecutorModule* os_module = ex->os_module; - Clib::scripts_thread_script = ex->scriptname(); - - int inscount = 0; - int totcount = 0; - int insleft = os_module->priority / priority_divide; - if (insleft == 0) - insleft = 1; - - THREAD_CHECKPOINT(scripts, 111); - - while (ex->runnable()) - { - ++ex->instr_cycles; - THREAD_CHECKPOINT(scripts, 112); - Clib::scripts_thread_scriptPC = ex->PC; - ex->execInstr(); - - THREAD_CHECKPOINT(scripts, 113); - - if (os_module->blocked()) - { - ex->warn_runaway_on_cycle = - ex->instr_cycles + Plib::systemstate.config.runaway_script_threshold; - ex->runaway_cycles = 0; - break; - } - - if (ex->instr_cycles == ex->warn_runaway_on_cycle) - { - ex->runaway_cycles += Plib::systemstate.config.runaway_script_threshold; - if (os_module->warn_on_runaway) - { - fmt::Writer tmp; - tmp << "Runaway script[" << os_module->pid() << "]: " << ex->scriptname() << " (" - << ex->runaway_cycles << " cycles)\n"; - ex->show_context(tmp, ex->PC); - SCRIPTLOG << tmp.str(); - } - ex->warn_runaway_on_cycle += Plib::systemstate.config.runaway_script_threshold; - } - - if (os_module->critical) - { - ++inscount; - ++totcount; - if (inscount > 1000) - { - inscount = 0; - if (Plib::systemstate.config.report_critical_scripts) - { - fmt::Writer tmp; - tmp << "Critical script " << ex->scriptname() << " has run for " << totcount - << " instructions\n"; - ex->show_context(tmp, ex->PC); - ERROR_PRINT << tmp.str(); - } - } - continue; - } - - if (!--insleft) - { - break; - } - } - - // hmm, this new terminology (runnable()) is confusing - // in this case. Technically, something that is blocked - // isn't runnable. - if (!ex->runnable()) - { - if (ex->error() || ex->done) - { - THREAD_CHECKPOINT(scripts, 114); - - if ((ex->pParent != NULL) && ex->pParent->runnable()) - { - ranlist.push_back(ex); - // ranlist.splice( ranlist.end(), runlist, itr ); - ex->pParent->os_module->revive(); - } - else - { - // runlist.erase( itr ); - // Check if the script has a child script running - // Set the parent of the child script NULL to stop crashing when trying to return to - // parent script - if (ex->pChild != NULL) - ex->pChild->pParent = NULL; - - delete ex; - } - continue; - } - else if (!ex->os_module->blocked()) - { - THREAD_CHECKPOINT(scripts, 115); - - // runlist.erase( itr ); - ex->os_module->in_hold_list_ = Module::OSExecutorModule::DEBUGGER_LIST; - debuggerholdlist.insert(ex); - continue; - } - } - - if (ex->os_module->blocked()) - { - THREAD_CHECKPOINT(scripts, 116); - - if (ex->os_module->sleep_until_clock_) - { - ex->os_module->in_hold_list_ = Module::OSExecutorModule::TIMEOUT_LIST; - ex->os_module->hold_itr_ = holdlist.insert( - HoldList::value_type(ex->os_module->sleep_until_clock_, ex)); - } - else - { - ex->os_module->in_hold_list_ = Module::OSExecutorModule::NOTIMEOUT_LIST; - notimeoutholdlist.insert(ex); - } - - // runlist.erase( itr ); - --ex->sleep_cycles; // it'd get counted twice otherwise - --stateManager.profilevars.sleep_cycles; - - THREAD_CHECKPOINT(scripts, 117); - } - else - { - ranlist.push_back(ex); - // ranlist.splice( ranlist.end(), runlist, itr ); - } - } - THREAD_CHECKPOINT(scripts, 118); - - runlist.swap(ranlist); - THREAD_CHECKPOINT(scripts, 119); -} - -void ScriptScheduler::schedule(UOExecutor* exec) +void ScriptScheduler::run_ready() { - exec->setDebugLevel(Bscript::Executor::NONE); - enqueue(exec); + THREAD_CHECKPOINT( scripts, 110 ); + while ( !runlist.empty() ) + { + ExecList::iterator itr = runlist.begin(); + UOExecutor* ex = *itr; + passert_paranoid( ex != nullptr ); + runlist.pop_front(); // remove it directly, since itr can get invalid during execution + + Module::OSExecutorModule* os_module = ex->os_module; + Clib::scripts_thread_script = ex->scriptname(); + + int inscount = 0; + int totcount = 0; + int insleft = os_module->priority / priority_divide; + if ( insleft == 0 ) + insleft = 1; + + THREAD_CHECKPOINT( scripts, 111 ); + + while ( ex->runnable() ) + { + ++ex->instr_cycles; + THREAD_CHECKPOINT( scripts, 112 ); + Clib::scripts_thread_scriptPC = ex->PC; + ex->execInstr(); + + THREAD_CHECKPOINT( scripts, 113 ); + + if ( os_module->blocked() ) + { + ex->warn_runaway_on_cycle = + ex->instr_cycles + Plib::systemstate.config.runaway_script_threshold; + ex->runaway_cycles = 0; + break; + } + + if ( ex->instr_cycles == ex->warn_runaway_on_cycle ) + { + ex->runaway_cycles += Plib::systemstate.config.runaway_script_threshold; + if ( os_module->warn_on_runaway ) + { + fmt::Writer tmp; + tmp << "Runaway script[" << os_module->pid() << "]: " << ex->scriptname() << " (" + << ex->runaway_cycles << " cycles)\n"; + ex->show_context( tmp, ex->PC ); + SCRIPTLOG << tmp.str(); + } + ex->warn_runaway_on_cycle += Plib::systemstate.config.runaway_script_threshold; + } + + if ( os_module->critical ) + { + ++inscount; + ++totcount; + if ( inscount > 1000 ) + { + inscount = 0; + if ( Plib::systemstate.config.report_critical_scripts ) + { + fmt::Writer tmp; + tmp << "Critical script " << ex->scriptname() << " has run for " << totcount + << " instructions\n"; + ex->show_context( tmp, ex->PC ); + ERROR_PRINT << tmp.str(); + } + } + continue; + } + + if ( !--insleft ) + { + break; + } + } + + // hmm, this new terminology (runnable()) is confusing + // in this case. Technically, something that is blocked + // isn't runnable. + if ( !ex->runnable() ) + { + if ( ex->error() || ex->done ) + { + THREAD_CHECKPOINT( scripts, 114 ); + + if ( ( ex->pParent != NULL ) && ex->pParent->runnable() ) + { + ranlist.push_back( ex ); + // ranlist.splice( ranlist.end(), runlist, itr ); + ex->pParent->os_module->revive(); + } + else + { + // runlist.erase( itr ); + // Check if the script has a child script running + // Set the parent of the child script NULL to stop crashing when trying to return to + // parent script + if ( ex->pChild != NULL ) + ex->pChild->pParent = NULL; + + delete ex; + } + continue; + } + else if ( !ex->os_module->blocked() ) + { + THREAD_CHECKPOINT( scripts, 115 ); + + // runlist.erase( itr ); + ex->os_module->in_hold_list_ = Module::OSExecutorModule::DEBUGGER_LIST; + debuggerholdlist.insert( ex ); + continue; + } + } + + if ( ex->os_module->blocked() ) + { + THREAD_CHECKPOINT( scripts, 116 ); + + if ( ex->os_module->sleep_until_clock_ ) + { + ex->os_module->in_hold_list_ = Module::OSExecutorModule::TIMEOUT_LIST; + ex->os_module->hold_itr_ = + holdlist.insert( HoldList::value_type( ex->os_module->sleep_until_clock_, ex ) ); + } + else + { + ex->os_module->in_hold_list_ = Module::OSExecutorModule::NOTIMEOUT_LIST; + notimeoutholdlist.insert( ex ); + } + + // runlist.erase( itr ); + --ex->sleep_cycles; // it'd get counted twice otherwise + --stateManager.profilevars.sleep_cycles; + + THREAD_CHECKPOINT( scripts, 117 ); + } + else + { + ranlist.push_back( ex ); + // ranlist.splice( ranlist.end(), runlist, itr ); + } + } + THREAD_CHECKPOINT( scripts, 118 ); + + runlist.swap( ranlist ); + THREAD_CHECKPOINT( scripts, 119 ); } -unsigned int ScriptScheduler::get_new_pid(UOExecutor* exec) +void ScriptScheduler::schedule( UOExecutor* exec ) { - for (;;) - { - unsigned int newpid = next_pid++; - if (newpid < PID_MIN) - newpid = PID_MIN; - - // NOTE: The code below is pessimistic, is there a way to avoid checking the pidlist every time? (Nando, 06-Nov-2016) - - // newpid=0 should now never happen but leaving this - // check in place for extra code robustness - if (newpid != 0 && (pidlist.find(newpid) == pidlist.end())) - { - pidlist[newpid] = exec; - return newpid; - } - } + exec->setDebugLevel( Bscript::Executor::NONE ); + enqueue( exec ); } -bool ScriptScheduler::find_exec(unsigned int pid, UOExecutor** exec) { - auto itr = pidlist.find(pid); - if (itr != pidlist.end()) - { - *exec = (*itr).second; - return true; - } - else - { - *exec = NULL; - return false; - } +unsigned int ScriptScheduler::get_new_pid( UOExecutor* exec ) +{ + for ( ;; ) + { + unsigned int newpid = next_pid++; + if ( newpid < PID_MIN ) + newpid = PID_MIN; + + // NOTE: The code below is pessimistic, is there a way to avoid checking the pidlist every time? + // (Nando, 06-Nov-2016) + + // newpid=0 should now never happen but leaving this + // check in place for extra code robustness + if ( newpid != 0 && ( pidlist.find( newpid ) == pidlist.end() ) ) + { + pidlist[newpid] = exec; + return newpid; + } + } } +bool ScriptScheduler::find_exec( unsigned int pid, UOExecutor** exec ) +{ + auto itr = pidlist.find( pid ); + if ( itr != pidlist.end() ) + { + *exec = ( *itr ).second; + return true; + } + else + { + *exec = NULL; + return false; + } +} } } diff --git a/pol-core/pol/globals/script_internals.h b/pol-core/pol/globals/script_internals.h index cbf29e804..f01b99ecb 100644 --- a/pol-core/pol/globals/script_internals.h +++ b/pol-core/pol/globals/script_internals.h @@ -1,16 +1,15 @@ #ifndef GLOBALS_SCRIPT_INTERNALS_H #define GLOBALS_SCRIPT_INTERNALS_H -#include "../../clib/maputil.h" -#include "../../bscript/eprog.h" - -#include "../reftypes.h" - -#include "../polclock.h" #include #include -#include #include +#include + +#include "../../bscript/eprog.h" +#include "../../clib/maputil.h" +#include "../polclock.h" +#include "../reftypes.h" namespace Pol { @@ -31,10 +30,10 @@ public: static const unsigned int PID_MIN; int priority_divide; - + // Consider moving the ScriptStorage to a different class. // It's not even used here besides to calculate how much memory is used. - ScriptStorage scrstore; + ScriptStorage scrstore; ScriptScheduler(); ~ScriptScheduler(); @@ -58,81 +57,88 @@ public: const PidList& getPidlist(); - //void revive_timeout(UOExecutor* exec); - void revive_timeout(UOExecutor* exec, TimeoutHandle hold_itr); - void revive_notimeout(UOExecutor* exec); - void revive_debugged(UOExecutor* exec); + // void revive_timeout(UOExecutor* exec); + void revive_timeout( UOExecutor* exec, TimeoutHandle hold_itr ); + void revive_notimeout( UOExecutor* exec ); + void revive_debugged( UOExecutor* exec ); // Adds a new executor to the queue directly - void enqueue(UOExecutor* exec); + void enqueue( UOExecutor* exec ); // Sets up the executor before adding to the queue - void schedule(UOExecutor* exec); + void schedule( UOExecutor* exec ); // The following methods should go to a different class, // together with the pidlist and new_pid. - + // Gets new PID and store the executor in the pidlist - unsigned int get_new_pid(UOExecutor* exec); - - void free_pid(unsigned int pid); + unsigned int get_new_pid( UOExecutor* exec ); + + void free_pid( unsigned int pid ); // Finds an UOExecutor from a pid. Returns false if not found. - bool find_exec(unsigned int pid, UOExecutor** exec); + bool find_exec( unsigned int pid, UOExecutor** exec ); + - private: - ExecList runlist; - ExecList ranlist; - HoldList holdlist; - NoTimeoutHoldList notimeoutholdlist; - NoTimeoutHoldList debuggerholdlist; + ExecList runlist; + ExecList ranlist; + HoldList holdlist; + NoTimeoutHoldList notimeoutholdlist; + NoTimeoutHoldList debuggerholdlist; - PidList pidlist; - unsigned int next_pid; + PidList pidlist; + unsigned int next_pid; }; -const inline ExecList& ScriptScheduler::getRanlist() { - return ranlist; -} -const inline ExecList& ScriptScheduler::getRunlist() { - return runlist; -} -const inline HoldList& ScriptScheduler::getHoldlist() { - return holdlist; -} -const inline NoTimeoutHoldList& ScriptScheduler::getNoTimeoutHoldlist() { - return notimeoutholdlist; -} -const inline PidList& ScriptScheduler::getPidlist() { - return pidlist; -} - -inline void ScriptScheduler::revive_debugged(UOExecutor* exec) { - debuggerholdlist.erase(exec); - enqueue(exec); -} - -inline void ScriptScheduler::revive_timeout(UOExecutor* exec, TimeoutHandle hold_itr) +const inline ExecList& ScriptScheduler::getRanlist() { - holdlist.erase(hold_itr); - enqueue(exec); + return ranlist; } - -inline void ScriptScheduler::revive_notimeout(UOExecutor* exec) +const inline ExecList& ScriptScheduler::getRunlist() { - notimeoutholdlist.erase(exec); - enqueue(exec); + return runlist; } - -inline void ScriptScheduler::enqueue(UOExecutor* exec) +const inline HoldList& ScriptScheduler::getHoldlist() { - runlist.push_back(exec); + return holdlist; +} +const inline NoTimeoutHoldList& ScriptScheduler::getNoTimeoutHoldlist() +{ + return notimeoutholdlist; +} +const inline PidList& ScriptScheduler::getPidlist() +{ + return pidlist; } -inline void ScriptScheduler::free_pid(unsigned int pid) { - pidlist.erase(pid); +inline void ScriptScheduler::revive_debugged( UOExecutor* exec ) +{ + debuggerholdlist.erase( exec ); + enqueue( exec ); +} + +inline void ScriptScheduler::revive_timeout( UOExecutor* exec, TimeoutHandle hold_itr ) +{ + holdlist.erase( hold_itr ); + enqueue( exec ); +} + +inline void ScriptScheduler::revive_notimeout( UOExecutor* exec ) +{ + notimeoutholdlist.erase( exec ); + enqueue( exec ); +} + +inline void ScriptScheduler::enqueue( UOExecutor* exec ) +{ + runlist.push_back( exec ); +} + +inline void ScriptScheduler::free_pid( unsigned int pid ) +{ + pidlist.erase( pid ); } extern ScriptScheduler scriptScheduler; diff --git a/pol-core/pol/globals/settings.cpp b/pol-core/pol/globals/settings.cpp index 64105fecf..fa6248e42 100644 --- a/pol-core/pol/globals/settings.cpp +++ b/pol-core/pol/globals/settings.cpp @@ -1,10 +1,11 @@ #include "settings.h" -#include "../../plib/systemstate.h" -#include "../../clib/logfacility.h" -#include "../../clib/cfgfile.h" #include "../../clib/cfgelem.h" +#include "../../clib/cfgfile.h" #include "../../clib/fileutil.h" +#include "../../clib/logfacility.h" +#include "../../plib/systemstate.h" +#include "../watch.h" namespace Pol { @@ -27,14 +28,10 @@ SettingsManager::SettingsManager() { } -SettingsManager::~SettingsManager() -{ -} +SettingsManager::~SettingsManager() {} -void SettingsManager::deinitialize() -{ -} +void SettingsManager::deinitialize() {} size_t SettingsManager::estimateSize() const { diff --git a/pol-core/pol/globals/settings.h b/pol-core/pol/globals/settings.h index 49db6fde1..ded52c759 100644 --- a/pol-core/pol/globals/settings.h +++ b/pol-core/pol/globals/settings.h @@ -1,6 +1,8 @@ #ifndef GLOBALS_SETTINGS_H #define GLOBALS_SETTINGS_H +#include + #include "../cmbtcfg.h" #include "../extobj.h" #include "../movecost.h" @@ -10,8 +12,6 @@ #include "../ssopt.h" #include "../watch.h" -#include - namespace Pol { namespace Core diff --git a/pol-core/pol/globals/state.cpp b/pol-core/pol/globals/state.cpp index 61c175c65..b0c61a649 100644 --- a/pol-core/pol/globals/state.cpp +++ b/pol-core/pol/globals/state.cpp @@ -27,14 +27,10 @@ StateManager::StateManager() { } -StateManager::~StateManager() -{ -} +StateManager::~StateManager() {} -void StateManager::deinitialize() -{ -} +void StateManager::deinitialize() {} size_t StateManager::estimateSize() const { diff --git a/pol-core/pol/globals/state.h b/pol-core/pol/globals/state.h index 22c38a304..c70b6eb43 100644 --- a/pol-core/pol/globals/state.h +++ b/pol-core/pol/globals/state.h @@ -1,14 +1,16 @@ #ifndef GLOBALS_STATE_H #define GLOBALS_STATE_H +#include +#include +#include + #include "../../clib/clib.h" +#include "../../clib/rawtypes.h" #include "../polsig.h" #include "../profile.h" #include "../uobjcnt.h" -#include -#include - namespace Pol { namespace Core diff --git a/pol-core/pol/globals/ucfg.cpp b/pol-core/pol/globals/ucfg.cpp index 695972864..ddbe1d359 100644 --- a/pol-core/pol/globals/ucfg.cpp +++ b/pol-core/pol/globals/ucfg.cpp @@ -1,6 +1,8 @@ #include "ucfg.h" +#include + #include "../cfgrepos.h" #include "../module/datastoreimp.h" @@ -15,9 +17,7 @@ ConfigurationBuffer::ConfigurationBuffer() { } -ConfigurationBuffer::~ConfigurationBuffer() -{ -} +ConfigurationBuffer::~ConfigurationBuffer() {} void ConfigurationBuffer::deinitialize() { @@ -67,4 +67,4 @@ ConfigurationBuffer::Memory ConfigurationBuffer::estimateSize() const return usage; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/globals/ucfg.h b/pol-core/pol/globals/ucfg.h index b8ae890b4..8b6bab33b 100644 --- a/pol-core/pol/globals/ucfg.h +++ b/pol-core/pol/globals/ucfg.h @@ -8,15 +8,14 @@ #ifndef UCFG_H #define UCFG_H -#include "../../clib/maputil.h" -#include "../../clib/refptr.h" - -#include "../module/fileaccess.h" - #include -#include #include #include +#include + +#include "../../clib/maputil.h" +#include "../../clib/refptr.h" +#include "../module/fileaccess.h" namespace Pol { @@ -27,6 +26,7 @@ class DataStoreFile; namespace Core { class StoredConfigFile; + typedef ref_ptr ConfigFileRef; typedef std::map CfgFiles; @@ -41,6 +41,7 @@ public: ConfigurationBuffer(); ~ConfigurationBuffer(); struct Memory; + Memory estimateSize() const; void deinitialize(); diff --git a/pol-core/pol/globals/uvars.cpp b/pol-core/pol/globals/uvars.cpp index 36243d5c9..7be76b378 100644 --- a/pol-core/pol/globals/uvars.cpp +++ b/pol-core/pol/globals/uvars.cpp @@ -14,54 +14,50 @@ */ #include "uvars.h" -#include "multidefs.h" -#include "script_internals.h" -#include "network.h" -#include "settings.h" -#include "state.h" -#include "object_storage.h" -#include "ucfg.h" -#include "../../clib/clib.h" -#include "../../clib/logfacility.h" +#include + +#include "../../bscript/bobject.h" +#include "../../clib/boostutils.h" #include "../../clib/clib_MD5.h" -#include "../../clib/stlutil.h" - +#include "../../clib/logfacility.h" #include "../../plib/systemstate.h" - #include "../accounts/account.h" #include "../accounts/accounts.h" #include "../checkpnt.h" #include "../console.h" #include "../guardrgn.h" #include "../guilds.h" -#include "../item/item.h" +#include "../item/equipmnt.h" #include "../item/itemdesc.h" #include "../item/weapon.h" #include "../listenpt.h" #include "../loadunld.h" #include "../miscrgn.h" #include "../mobile/attribute.h" -#include "../mobile/charactr.h" #include "../multi/boat.h" -#include "../multi/multi.h" #include "../musicrgn.h" #include "../npctmpl.h" +#include "../objecthash.h" #include "../party.h" +#include "../polcfg.h" #include "../polsem.h" -#include "../proplist.h" -#include "../realms.h" +#include "../realms/realm.h" #include "../resource.h" #include "../scrstore.h" -#include "../sockio.h" #include "../spells.h" #include "../startloc.h" +#include "../storage.h" +#include "../syshook.h" #include "../syshookscript.h" -#include "../target.h" -#include "../tasks.h" -#include "../ufunc.h" +#include "../uoskills.h" #include "../uworld.h" #include "../vital.h" +#include "multidefs.h" +#include "network.h" +#include "object_storage.h" +#include "script_internals.h" +#include "ucfg.h" #ifdef _MSC_VER #pragma warning( \ diff --git a/pol-core/pol/globals/uvars.h b/pol-core/pol/globals/uvars.h index 077f87cf5..87ee24eaf 100644 --- a/pol-core/pol/globals/uvars.h +++ b/pol-core/pol/globals/uvars.h @@ -7,30 +7,34 @@ #ifndef __UVARS_H #define __UVARS_H -#include "../reftypes.h" +#include +#include +#include +#include +#include +#include +#include +#include #include "../../clib/maputil.h" - +#include "../../clib/rawtypes.h" +#include "../../clib/refptr.h" #include "../action.h" #include "../clidata.h" #include "../cmdlevel.h" #include "../layers.h" #include "../menu.h" +#include "../reftypes.h" #include "../region.h" #include "../schedule.h" #include "../storage.h" #include "../syshook.h" -#include "../textcmd.h" #include "../target.h" +#include "../tasks.h" +#include "../textcmd.h" #include "../uoskills.h" -#include -#include -#include -#include -#include - namespace Pol { namespace Realms @@ -39,10 +43,10 @@ class Realm; } namespace Items { -class UWeapon; +class Equipment; class Item; class ItemDesc; -class Equipment; +class UWeapon; } namespace Mobile { @@ -58,24 +62,24 @@ struct BoatShape; } namespace Core { -class StartingLocation; -class PropertyList; -class NpcTemplate; -class JusticeRegion; -class NoCastRegion; -class LightRegion; -class WeatherDef; -class MusicRegion; -class USpell; -class SpellCircle; -class Vital; -class ResourceDef; -class NpcTemplateElem; class ConsoleCommand; -class ListenPoint; -class Party; class Guild; +class JusticeRegion; +class LightRegion; +class ListenPoint; +class MusicRegion; +class NoCastRegion; +class NpcTemplate; +class NpcTemplateElem; +class Party; +class PropertyList; +class ResourceDef; +class SpellCircle; +class StartingLocation; class UOExecutor; +class USpell; +class Vital; +class WeatherDef; typedef std::vector CmdLevels; @@ -126,6 +130,7 @@ public: void deinitialize(); struct Memory; + Memory estimateSize() const; CmdLevels cmdlevels; diff --git a/pol-core/pol/guardrgn.cpp b/pol-core/pol/guardrgn.cpp index b846950f3..7b15f5b12 100644 --- a/pol-core/pol/guardrgn.cpp +++ b/pol-core/pol/guardrgn.cpp @@ -6,21 +6,17 @@ #include "guardrgn.h" -#include "../bscript/impstr.h" +#include -#include "mobile/charactr.h" -#include "polcfg.h" +#include "../bscript/bobject.h" +#include "../bscript/impstr.h" +#include "../clib/cfgelem.h" +#include "globals/uvars.h" +#include "network/cgdata.h" +#include "network/client.h" #include "scrdef.h" -#include "scrstore.h" #include "scrsched.h" #include "uoscrobj.h" -#include "globals/uvars.h" - -#include "network/client.h" -#include "network/cgdata.h" - -#include "../clib/cfgelem.h" -#include "../clib/fileutil.h" namespace Pol { @@ -103,4 +99,4 @@ bool JusticeRegion::RunNoCombatCheck( Network::Client* client ) return no_combat; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/guardrgn.h b/pol-core/pol/guardrgn.h index afda35f57..bff8a8db6 100644 --- a/pol-core/pol/guardrgn.h +++ b/pol-core/pol/guardrgn.h @@ -8,10 +8,20 @@ #ifndef GUARDRGN_H #define GUARDRGN_H -#include "region.h" - #include +#include "../clib/compilerspecifics.h" +#include "region.h" +#include "zone.h" + +namespace Pol +{ +namespace Clib +{ +class ConfigElem; +} // namespace Clib +} // namespace Pol + namespace Pol { namespace Network diff --git a/pol-core/pol/guilds.cpp b/pol-core/pol/guilds.cpp index 004288b53..32089a876 100644 --- a/pol-core/pol/guilds.cpp +++ b/pol-core/pol/guilds.cpp @@ -1,19 +1,20 @@ #include "guilds.h" -#include "../clib/streamsaver.h" +#include +#include + #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/cfgsect.h" #include "../clib/fileutil.h" - +#include "../clib/streamsaver.h" #include "../plib/systemstate.h" -#include "globals/uvars.h" - -#include "mobile/charactr.h" #include "fnsearch.h" -#include "uobject.h" +#include "globals/uvars.h" +#include "mobile/charactr.h" #include "ufunc.h" +#include "uobject.h" namespace Pol { @@ -273,4 +274,4 @@ size_t Guild::estimateSize() const _proplist.estimatedSize() + sizeof( bool ); /*_disbanded*/ } } -} \ No newline at end of file +} diff --git a/pol-core/pol/help.cpp b/pol-core/pol/help.cpp index 4c794148e..28f390a5f 100644 --- a/pol-core/pol/help.cpp +++ b/pol-core/pol/help.cpp @@ -3,11 +3,13 @@ * @par History */ +#include + #include "../bscript/eprog.h" +#include "../clib/refptr.h" #include "../plib/systemstate.h" #include "mobile/charactr.h" #include "network/client.h" -#include "network/msghandl.h" #include "pktin.h" #include "scrstore.h" diff --git a/pol-core/pol/irequest.cpp b/pol-core/pol/irequest.cpp index d13b51996..288b9bd24 100644 --- a/pol-core/pol/irequest.cpp +++ b/pol-core/pol/irequest.cpp @@ -6,34 +6,31 @@ */ -#include "mobile/attribute.h" -#include "mobile/charactr.h" - -#include "network/client.h" -#include "network/clienttransmit.h" -#include "network/msghandl.h" -#include "network/packethelper.h" - -#include "pktboth.h" -#include "pktin.h" -#include "polcfg.h" -#include "scrdef.h" -#include "scrstore.h" -#include "statmsg.h" -#include "uoskills.h" -#include "globals/network.h" -#include "globals/state.h" -#include "globals/settings.h" -#include "ufunc.h" -#include "party.h" +#include #include "../bscript/eprog.h" #include "../clib/clib_endian.h" -#include "../clib/fdump.h" -#include "../clib/clib.h" #include "../clib/logfacility.h" - +#include "../clib/rawtypes.h" +#include "../clib/refptr.h" #include "../plib/systemstate.h" +#include "globals/network.h" +#include "globals/settings.h" +#include "mobile/attribute.h" +#include "mobile/charactr.h" +#include "network/client.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "party.h" +#include "pktboth.h" +#include "pktdef.h" +#include "pktin.h" +#include "scrdef.h" +#include "scrstore.h" +#include "statmsg.h" +#include "ufunc.h" +#include "uoclient.h" +#include "uoskills.h" namespace Pol { diff --git a/pol-core/pol/item/armor.cpp b/pol-core/pol/item/armor.cpp index f4bf54595..79d8fba7e 100644 --- a/pol-core/pol/item/armor.cpp +++ b/pol-core/pol/item/armor.cpp @@ -6,27 +6,29 @@ #include "armor.h" -#include "item.h" + +#include +#include + +#include +#include "../../bscript/bstruct.h" +#include "../../bscript/impstr.h" +#include "../../clib/cfgelem.h" +#include "../../clib/logfacility.h" +#include "../../clib/passert.h" +#include "../../clib/streamsaver.h" +#include "../../clib/strutil.h" +#include "../../plib/pkg.h" +#include "../../plib/systemstate.h" +#include "../equipdsc.h" +#include "../extobj.h" +#include "../globals/settings.h" +#include "../layers.h" +#include "../tiles.h" +#include "../uobject.h" #include "armrtmpl.h" #include "itemdesc.h" -#include "../../bscript/bstruct.h" -#include "../../bscript/impstr.h" - -#include "../../clib/cfgelem.h" -#include "../../clib/clib_endian.h" -#include "../../clib/logfacility.h" -#include "../../clib/streamsaver.h" -#include "../../plib/pkg.h" -#include "../../plib/systemstate.h" - -#include "../tiles.h" -#include "../clidata.h" -#include "../layers.h" -#include "../ufunc.h" - -#include -#include namespace Pol { diff --git a/pol-core/pol/item/armor.h b/pol-core/pol/item/armor.h index 4fc976b61..d5c0e5954 100644 --- a/pol-core/pol/item/armor.h +++ b/pol-core/pol/item/armor.h @@ -8,14 +8,33 @@ #define ARMOR_H #include - -#include "../scrdef.h" - -#include "equipmnt.h" - #include #include +#include "../../bscript/bobject.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" +#include "../dynproperties.h" +#include "../scrdef.h" +#include "equipmnt.h" + +namespace Pol +{ +namespace Bscript +{ +class String; +class BStruct; +} +namespace Clib +{ +class StreamWriter; +class ConfigElem; +} +namespace Plib +{ +class Package; +} +} #define ARMOR_TMPL ( static_cast( tmpl ) ) namespace Pol diff --git a/pol-core/pol/item/equipmnt.cpp b/pol-core/pol/item/equipmnt.cpp index cf99905c6..39dad70e7 100644 --- a/pol-core/pol/item/equipmnt.cpp +++ b/pol-core/pol/item/equipmnt.cpp @@ -6,25 +6,30 @@ #include "equipmnt.h" -#include "weapon.h" -#include "armor.h" + +#include #include "../../clib/cfgelem.h" #include "../../clib/cfgfile.h" -#include "../../clib/random.h" +#include "../../clib/clib_endian.h" #include "../../clib/fileutil.h" - -#include "../ufunc.h" -#include "../globals/state.h" -#include "../globals/uvars.h" -#include "../globals/object_storage.h" - +#include "../../clib/passert.h" +#include "../../clib/random.h" +#include "../../clib/streamsaver.h" #include "../../plib/pkg.h" #include "../../plib/systemstate.h" - #include "../equipdsc.h" -#include "../tooltips.h" +#include "../globals/object_storage.h" +#include "../globals/state.h" +#include "../globals/uvars.h" +#include "../layers.h" #include "../mobile/charactr.h" +#include "../tooltips.h" +#include "../ufunc.h" +#include "armor.h" +#include "item.h" +#include "itemdesc.h" +#include "weapon.h" namespace Pol { diff --git a/pol-core/pol/item/equipmnt.h b/pol-core/pol/item/equipmnt.h index 2dccc090a..984a4a716 100644 --- a/pol-core/pol/item/equipmnt.h +++ b/pol-core/pol/item/equipmnt.h @@ -8,6 +8,24 @@ #define EQUIPMNT_H #include +#include + +#include "../../bscript/bobject.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" +#include "../baseobject.h" + +namespace Pol +{ +namespace Clib +{ +class StreamWriter; +} // namespace Clib +namespace Items +{ +class ItemDesc; +} // namespace Items +} // namespace Pol #ifndef ITEM_H #include "item.h" diff --git a/pol-core/pol/item/item.cpp b/pol-core/pol/item/item.cpp index 14ed22434..609bfaf25 100644 --- a/pol-core/pol/item/item.cpp +++ b/pol-core/pol/item/item.cpp @@ -11,36 +11,35 @@ */ #include "item.h" -#include "armor.h" -#include "../../clib/cfgelem.h" -#include "../../clib/clib_endian.h" -#include "../../clib/strutil.h" -#include "../../clib/streamsaver.h" +#include #include "../../bscript/berror.h" #include "../../bscript/eprog.h" - +#include "../../clib/cfgelem.h" +#include "../../clib/passert.h" +#include "../../clib/refptr.h" +#include "../../clib/streamsaver.h" #include "../../plib/mapcell.h" #include "../../plib/systemstate.h" - -#include "../ustruct.h" +#include "../clidata.h" #include "../containr.h" -#include "../ufunc.h" -#include "../network/client.h" -#include "../mobile/charactr.h" -#include "../item/itemdesc.h" -#include "../objtype.h" -#include "../../plib/pkg.h" -#include "../polcfg.h" -#include "../resource.h" -#include "../scrsched.h" -#include "../scrstore.h" -#include "../stackcfg.h" -#include "../tooltips.h" -#include "../uoscrobj.h" #include "../gameclck.h" #include "../globals/uvars.h" +#include "../mobile/charactr.h" +#include "../network/client.h" +#include "../objtype.h" +#include "../polcfg.h" +#include "../proplist.h" +#include "../resource.h" +#include "../scrdef.h" +#include "../scrsched.h" +#include "../scrstore.h" +#include "../tooltips.h" +#include "../ufunc.h" +#include "../uoscrobj.h" +#include "itemdesc.h" + namespace Pol { @@ -924,9 +923,7 @@ void Item::extricate() } } -void Item::spill_contents( Multi::UMulti* /*multi*/ ) -{ -} +void Item::spill_contents( Multi::UMulti* /*multi*/ ) {} unsigned int Item::weight_of( unsigned short amount ) const { diff --git a/pol-core/pol/item/item.h b/pol-core/pol/item/item.h index 10fe11999..8042cc94d 100644 --- a/pol-core/pol/item/item.h +++ b/pol-core/pol/item/item.h @@ -15,6 +15,16 @@ #include "pol_global_config.h" #endif +#include +#include + +#include "../../clib/boostutils.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" +#include "../baseobject.h" +#include "../dynproperties.h" +#include "../globals/settings.h" +#include "../layers.h" #include "../uobject.h" @@ -22,8 +32,18 @@ #include "../../bscript/bobject.h" #endif -#include "../layers.h" -#include "../globals/settings.h" +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +namespace Clib +{ +class ConfigElem; +class StreamWriter; +} // namespace Clib +} // namespace Pol namespace Pol { @@ -34,6 +54,7 @@ class UOExecutorModule; namespace Core { class UContainer; + std::string format_description( unsigned int polflags, const std::string& descdef, unsigned short amount, const std::string suffix ); } @@ -43,8 +64,8 @@ class Character; } namespace Multi { -class UMulti; class UHouse; +class UMulti; } namespace Network { diff --git a/pol-core/pol/item/item00.cpp b/pol-core/pol/item/item00.cpp index ed6b6b408..642463dfa 100644 --- a/pol-core/pol/item/item00.cpp +++ b/pol-core/pol/item/item00.cpp @@ -7,16 +7,16 @@ */ +#include + +#include "../baseobject.h" +#include "../gameclck.h" +#include "../globals/state.h" +#include "../resource.h" +#include "../uobjcnt.h" +#include "../uobject.h" #include "item.h" #include "itemdesc.h" -#include "../gameclck.h" -#include "../layers.h" -#include "../resource.h" -#include "../objtype.h" -#include "../ustruct.h" -#include "../globals/state.h" - -#include namespace Pol { diff --git a/pol-core/pol/item/itemcr.cpp b/pol-core/pol/item/itemcr.cpp index 07ca28680..23cee20db 100644 --- a/pol-core/pol/item/itemcr.cpp +++ b/pol-core/pol/item/itemcr.cpp @@ -9,49 +9,42 @@ */ +#include +#include + +#include +#include "../../clib/clib_endian.h" +#include "../../clib/logfacility.h" +#include "../../clib/passert.h" +#include "../../clib/rawtypes.h" +#include "../../plib/systemstate.h" +#include "../baseobject.h" +#include "../clidata.h" +#include "../containr.h" +#include "../door.h" +#include "../extobj.h" +#include "../globals/object_storage.h" +#include "../globals/settings.h" +#include "../globals/uvars.h" +#include "../lockable.h" +#include "../mobile/corpse.h" +#include "../module/uomod.h" +#include "../multi/boatcomp.h" +#include "../objtype.h" +#include "../polcfg.h" +#include "../resource.h" +#include "../scrdef.h" +#include "../scrsched.h" +#include "../spelbook.h" +#include "../ufunc.h" +#include "../umap.h" +#include "../uobject.h" +#include "armor.h" +#include "armrtmpl.h" #include "item.h" #include "itemdesc.h" #include "weapon.h" #include "wepntmpl.h" -#include "armor.h" -#include "armrtmpl.h" - -#include "../multi/boat.h" -#include "../multi/boatcomp.h" -#include "../multi/house.h" - -#include "../mobile/charactr.h" -#include "../mobile/corpse.h" - -#include "../network/client.h" - -#include "../containr.h" -#include "../door.h" -#include "../lockable.h" -#include "../umap.h" -#include "../objtype.h" -#include "../polcfg.h" -#include "../resource.h" -#include "../scrsched.h" -#include "../scrstore.h" -#include "../spells.h" -#include "../spelbook.h" -#include "../tiles.h" -#include "../ufunc.h" -#include "../uoscrobj.h" -#include "../globals/uvars.h" -#include "../globals/object_storage.h" - -#include "../../clib/cfgfile.h" -#include "../../clib/clib_endian.h" -#include "../../clib/logfacility.h" -#include "../../clib/strutil.h" - -#include "../../plib/systemstate.h" - -#include "../module/uomod.h" - -#include namespace Pol { @@ -146,9 +139,8 @@ Item* Item::create( const ItemDesc& id, u32 serial ) item = new Core::Map( static_cast( id ) ); } else if ( objtype == Core::settingsManager.extobj.port_plank || - objtype == - Core::settingsManager.extobj - .starboard_plank ) // ITEMDESCTODO make new ItemDesc type + objtype == Core::settingsManager.extobj + .starboard_plank ) // ITEMDESCTODO make new ItemDesc type { item = new Multi::UPlank( id ); } diff --git a/pol-core/pol/item/itemdesc.cpp b/pol-core/pol/item/itemdesc.cpp index 58a6fbc1f..126eaa0fd 100644 --- a/pol-core/pol/item/itemdesc.cpp +++ b/pol-core/pol/item/itemdesc.cpp @@ -15,31 +15,16 @@ #include "itemdesc.h" -#include "wepntmpl.h" -#include "armrtmpl.h" +#include +#include +#include +#include +#include +#include "../../bscript/bobject.h" #include "../../bscript/bstruct.h" #include "../../bscript/dict.h" -#include "../../bscript/escrutil.h" #include "../../bscript/impstr.h" - -#include "../../plib/mapcell.h" -#include "../../plib/pkg.h" -#include "../../plib/systemstate.h" - -#include "../cfgrepos.h" -#include "../clidata.h" -#include "../objtype.h" -#include "../multi/multidef.h" -#include "../resource.h" -#include "../polcfg.h" -#include "../syshookscript.h" -#include "../globals/ucfg.h" -#include "../ustruct.h" -#include "../uconst.h" -#include "../globals/uvars.h" -#include "../globals/settings.h" - #include "../../clib/cfgelem.h" #include "../../clib/cfgfile.h" #include "../../clib/esignal.h" @@ -48,6 +33,23 @@ #include "../../clib/passert.h" #include "../../clib/stlutil.h" #include "../../clib/strutil.h" +#include "../../plib/mapcell.h" +#include "../../plib/pkg.h" +#include "../../plib/systemstate.h" +#include "../clidata.h" +#include "../dice.h" +#include "../extobj.h" +#include "../globals/settings.h" +#include "../globals/uvars.h" +#include "../multi/multidef.h" +#include "../pktdef.h" +#include "../proplist.h" +#include "../resource.h" +#include "../syshookscript.h" +#include "../uconst.h" +#include "../uobject.h" +#include "armrtmpl.h" +#include "wepntmpl.h" namespace Pol { diff --git a/pol-core/pol/item/itemdesc.h b/pol-core/pol/item/itemdesc.h index ae645b4e4..6c2334b74 100644 --- a/pol-core/pol/item/itemdesc.h +++ b/pol-core/pol/item/itemdesc.h @@ -11,12 +11,25 @@ #include #include - +#include "../../clib/boostutils.h" +#include "../../clib/compilerspecifics.h" #include "../../clib/rawtypes.h" -#include "../uobject.h" -#include "../proplist.h" #include "../dice.h" +#include "../proplist.h" #include "../scrdef.h" +#include "../uobject.h" + +namespace Pol +{ +namespace Clib +{ +class ConfigElem; +} // namespace Clib +namespace Plib +{ +class Package; +} // namespace Plib +} // namespace Pol namespace Pol { diff --git a/pol-core/pol/item/weapon.cpp b/pol-core/pol/item/weapon.cpp index 19bc8625f..578def06f 100644 --- a/pol-core/pol/item/weapon.cpp +++ b/pol-core/pol/item/weapon.cpp @@ -8,41 +8,32 @@ #include "weapon.h" -#include "wepntmpl.h" -#include "../mobile/attribute.h" -#include "../mobile/charactr.h" - -#include "../polcfg.h" -#include "../realms.h" -#include "../skillid.h" -#include "../ufunc.h" -#include "../umanip.h" -#include "../globals/state.h" -#include "../globals/uvars.h" -#include "../globals/object_storage.h" -#include "../containr.h" -#include "../realms/realm.h" +#include +#include #include "../../bscript/bstruct.h" #include "../../bscript/impstr.h" - -#include "../../plib/pkg.h" -#include "../../plib/systemstate.h" - #include "../../clib/cfgelem.h" -#include "../../clib/clib_endian.h" #include "../../clib/logfacility.h" +#include "../../clib/passert.h" #include "../../clib/streamsaver.h" -#include "../../clib/random.h" - -#include -#include -#include -#include - -#include -#include +#include "../../clib/strutil.h" +#include "../../plib/systemstate.h" +#include "../containr.h" +#include "../dice.h" +#include "../equipdsc.h" +#include "../extobj.h" +#include "../globals/settings.h" +#include "../globals/uvars.h" +#include "../layers.h" +#include "../mobile/charactr.h" +#include "../realms/realm.h" +#include "../ufunc.h" +#include "../umanip.h" +#include "../uobject.h" +#include "itemdesc.h" +#include "wepntmpl.h" namespace Pol { diff --git a/pol-core/pol/item/weapon.h b/pol-core/pol/item/weapon.h index c8a14c430..80daa1311 100644 --- a/pol-core/pol/item/weapon.h +++ b/pol-core/pol/item/weapon.h @@ -9,28 +9,52 @@ #define WEAPON_H -#include "equipmnt.h" - -#include "../action.h" -#include "../scrdef.h" - #include #include #include +#include "../../bscript/bobject.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" +#include "../action.h" +#include "../dynproperties.h" +#include "../scrdef.h" +#include "equipmnt.h" + +namespace Pol +{ +namespace Clib +{ +class ConfigElem; +class StreamWriter; +} // namespace Clib +namespace Core +{ +class UContainer; +} // namespace Core +namespace Items +{ +class Item; +} // namespace Items +namespace Plib +{ +class Package; +} // namespace Plib +} // namespace Pol + #define WEAPON_TMPL ( static_cast( tmpl ) ) namespace Pol { namespace Mobile { -class Character; class Attribute; +class Character; } namespace Items { -class WeaponDesc; class UWeapon; +class WeaponDesc; class UWeapon : public Equipment diff --git a/pol-core/pol/landtile.cpp b/pol-core/pol/landtile.cpp index 04b8d7a6a..dab3da4fe 100644 --- a/pol-core/pol/landtile.cpp +++ b/pol-core/pol/landtile.cpp @@ -5,13 +5,13 @@ */ -#include "../plib/mapfunc.h" -#include "../plib/pkg.h" +#include #include "../clib/cfgelem.h" -#include "../clib/passert.h" #include "../clib/logfacility.h" - +#include "../clib/passert.h" +#include "../plib/mapfunc.h" +#include "../plib/pkg.h" #include "clidata.h" #include "globals/uvars.h" @@ -50,4 +50,4 @@ unsigned int landtile_flags( unsigned short landtile ) return gamestate.landtiles[landtile].flags; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/listenpt.cpp b/pol-core/pol/listenpt.cpp index b1e5c7343..0459d1a23 100644 --- a/pol-core/pol/listenpt.cpp +++ b/pol-core/pol/listenpt.cpp @@ -7,17 +7,17 @@ #include "listenpt.h" -#include "../clib/refptr.h" +#include +#include "../bscript/bobject.h" +#include "globals/settings.h" +#include "globals/uvars.h" #include "mobile/charactr.h" #include "module/osmod.h" -#include "uobject.h" +#include "uconst.h" #include "ufunc.h" #include "uoexec.h" #include "uoscrobj.h" -#include "globals/uvars.h" - -#include namespace Pol { @@ -28,9 +28,7 @@ ListenPoint::ListenPoint( UObject* obj, UOExecutor* uoexec, int range, int flags { } -ListenPoint::~ListenPoint() -{ -} +ListenPoint::~ListenPoint() {} const char* TextTypeToString( u8 texttype ) { diff --git a/pol-core/pol/listenpt.h b/pol-core/pol/listenpt.h index fe08154f8..4212fab7e 100644 --- a/pol-core/pol/listenpt.h +++ b/pol-core/pol/listenpt.h @@ -23,8 +23,8 @@ class Character; } namespace Core { -class UObject; class UOExecutor; +class UObject; class ListenPoint { diff --git a/pol-core/pol/loaddata.cpp b/pol-core/pol/loaddata.cpp index b31feba52..87ecd72ba 100644 --- a/pol-core/pol/loaddata.cpp +++ b/pol-core/pol/loaddata.cpp @@ -8,31 +8,29 @@ */ -#include "mobile/charactr.h" -#include "clidata.h" -#include "fnsearch.h" -#include "item/item.h" -#include "polcfg.h" -#include "polclass.h" -#include "loaddata.h" -#include "spelbook.h" -#include "uobject.h" -#include "globals/object_storage.h" -#include "globals/state.h" +#include +#include -#include "../clib/cfgfile.h" #include "../clib/cfgelem.h" +#include "../clib/cfgfile.h" #include "../clib/fileutil.h" +#include "../clib/logfacility.h" +#include "../clib/rawtypes.h" #include "../clib/strutil.h" #include "../clib/timer.h" -#include "../clib/logfacility.h" - #include "../plib/systemstate.h" - -#include -#include -#include -#include +#include "clidata.h" +#include "containr.h" +#include "fnsearch.h" +#include "globals/object_storage.h" +#include "globals/state.h" +#include "item/item.h" +#include "loaddata.h" +#include "mobile/charactr.h" +#include "objecthash.h" +#include "polclass.h" +#include "spelbook.h" +#include "uobject.h" namespace Pol { diff --git a/pol-core/pol/loaddata.h b/pol-core/pol/loaddata.h index 8dca0d095..3c5cb7b27 100644 --- a/pol-core/pol/loaddata.h +++ b/pol-core/pol/loaddata.h @@ -8,6 +8,7 @@ #define LOADDATA_H #include "poltype.h" + namespace Pol { namespace Mobile diff --git a/pol-core/pol/loadunld.cpp b/pol-core/pol/loadunld.cpp index cbe36ba5b..7d0cb9de2 100644 --- a/pol-core/pol/loadunld.cpp +++ b/pol-core/pol/loadunld.cpp @@ -9,29 +9,20 @@ #include "loadunld.h" -#include "item/armor.h" +#include + +#include "../clib/strutil.h" +#include "../plib/pkg.h" +#include "../plib/systemstate.h" #include "checkpnt.h" #include "cmbtcfg.h" #include "console.h" +#include "extobj.h" +#include "globals/settings.h" +#include "item/equipmnt.h" +#include "item/itemdesc.h" #include "objtype.h" #include "polcfg.h" -#include "stackcfg.h" -#include "ufunc.h" -#include "globals/uvars.h" -#include "item/weapon.h" -#include "item/wepntmpl.h" - -#include "../plib/pkg.h" -#include "../plib/systemstate.h" - -#include "../clib/cfgelem.h" -#include "../clib/cfgfile.h" -#include "../clib/fileutil.h" -#include "../clib/stlutil.h" -#include "../clib/strutil.h" - -#include -#include namespace Pol { diff --git a/pol-core/pol/lockable.cpp b/pol-core/pol/lockable.cpp index c8936bef8..dd12ca1ce 100644 --- a/pol-core/pol/lockable.cpp +++ b/pol-core/pol/lockable.cpp @@ -8,6 +8,7 @@ #include "../clib/cfgelem.h" #include "../clib/streamsaver.h" +#include "uobject.h" namespace Pol { diff --git a/pol-core/pol/lockable.h b/pol-core/pol/lockable.h index 958072155..11dd4da3e 100644 --- a/pol-core/pol/lockable.h +++ b/pol-core/pol/lockable.h @@ -7,6 +7,25 @@ #ifndef LOCKABLE_H #define LOCKABLE_H +#include "../clib/compilerspecifics.h" +#include "baseobject.h" + +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +} // namespace Bscript +namespace Clib +{ +class ConfigElem; +class StreamWriter; +} // namespace Clib +namespace Items +{ +class ItemDesc; +} // namespace Items +} // namespace Pol #ifndef ITEM_H #include "item/item.h" #endif diff --git a/pol-core/pol/login.cpp b/pol-core/pol/login.cpp index d7e3e90ca..9f40008ea 100644 --- a/pol-core/pol/login.cpp +++ b/pol-core/pol/login.cpp @@ -19,38 +19,31 @@ */ -#include "network/client.h" -#include "network/packets.h" -#include "network/packethelper.h" -#include "network/msghandl.h" -#include "network/clienttransmit.h" -#include "crypt/cryptbase.h" -#include "crypt/cryptengine.h" +#include +#include -#include "accounts/account.h" -#include "accounts/accounts.h" -#include "mobile/charactr.h" - -#include "core.h" -#include "pktin.h" -#include "polcfg.h" -#include "startloc.h" -#include "globals/uvars.h" -#include "globals/settings.h" -#include "servdesc.h" -#include "sockio.h" -#include "ufunc.h" - -#include "../clib/stlutil.h" -#include "../clib/clib_MD5.h" #include "../clib/clib.h" +#include "../clib/clib_MD5.h" #include "../clib/clib_endian.h" #include "../clib/logfacility.h" -#include "../clib/fdump.h" - +#include "../clib/rawtypes.h" #include "../plib/systemstate.h" - -#include +#include "accounts/account.h" +#include "accounts/accounts.h" +#include "core.h" +#include "crypt/cryptbase.h" +#include "globals/settings.h" +#include "globals/uvars.h" +#include "mobile/charactr.h" +#include "network/client.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "pktdef.h" +#include "pktin.h" +#include "polcfg.h" +#include "servdesc.h" +#include "startloc.h" +#include "ufunc.h" namespace Pol { @@ -198,8 +191,8 @@ void loginserver_login( Network::Client* client, PKTIN_80* msg ) } else { - POLLOG.Format( "gethostbyname(\"{}\") failed for server {}\n" ) << server->hostname - << server->name; + POLLOG.Format( "gethostbyname(\"{}\") failed for server {}\n" ) + << server->hostname << server->name; continue; } } @@ -229,9 +222,7 @@ void loginserver_login( Network::Client* client, PKTIN_80* msg ) } } -void handle_A4( Network::Client* /*client*/, PKTIN_A4* /*msg*/ ) -{ -} +void handle_A4( Network::Client* /*client*/, PKTIN_A4* /*msg*/ ) {} void handle_D9( Network::Client* client, PKTIN_D9* msg ) { @@ -455,8 +446,8 @@ void login2( Network::Client* client, PKTIN_91* msg ) // Gameserver login and c // Dave moved the max_clients check to pol.cpp so character cmdlevel could be checked. // - POLLOG.Format( "Account {} logged in from {}\n" ) << acct->name() - << Network::AddressToString( &client->ipaddr ); + POLLOG.Format( "Account {} logged in from {}\n" ) + << acct->name() << Network::AddressToString( &client->ipaddr ); // ENHANCEMENT: could authenticate with real loginservers. diff --git a/pol-core/pol/menu.cpp b/pol-core/pol/menu.cpp index 82f4fb2f1..6b4640053 100644 --- a/pol-core/pol/menu.cpp +++ b/pol-core/pol/menu.cpp @@ -6,21 +6,20 @@ #include "menu.h" -#include "../clib/logfacility.h" +#include +#include -#include "../clib/clib.h" #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" -#include "../clib/stlutil.h" +#include "../clib/clib.h" #include "../clib/fileutil.h" +#include "../clib/logfacility.h" #include "../clib/passert.h" - +#include "../clib/rawtypes.h" +#include "../clib/stlutil.h" #include "../plib/systemstate.h" - -#include "item/itemdesc.h" #include "globals/uvars.h" - -#include +#include "item/itemdesc.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // deprecation warning stricmp @@ -44,15 +43,14 @@ Menu::Menu() : menu_id( 0 ) title[0] = '\0'; } -Menu::Menu(const Menu& other) - : menu_id(other.menu_id), menuitems_(other.menuitems_) +Menu::Menu( const Menu& other ) : menu_id( other.menu_id ), menuitems_( other.menuitems_ ) { strzcpy( name, other.name, sizeof name ); strzcpy( title, other.title, sizeof title ); - + weakptr.set( this ); } -Menu& Menu::operator=(const Menu &rhs) +Menu& Menu::operator=( const Menu& rhs ) { Menu tmpMenu( rhs ); @@ -268,4 +266,4 @@ void Menu::read_menus() } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/menu.h b/pol-core/pol/menu.h index 1fecdce2d..ded329c93 100644 --- a/pol-core/pol/menu.h +++ b/pol-core/pol/menu.h @@ -10,10 +10,10 @@ #ifndef __CLIB_RAWTYPES_H #include "../clib/rawtypes.h" #endif -#include "../clib/weakptr.h" - -#include #include +#include + +#include "../clib/weakptr.h" namespace Pol { diff --git a/pol-core/pol/menusel.cpp b/pol-core/pol/menusel.cpp index 530fa339e..f317e7406 100644 --- a/pol-core/pol/menusel.cpp +++ b/pol-core/pol/menusel.cpp @@ -4,19 +4,16 @@ */ -#include "menu.h" - -#include "accounts/account.h" -#include "mobile/charactr.h" -#include "network/client.h" -#include "network/msghandl.h" -#include "pktin.h" -#include "ufunc.h" - -#include "../clib/clib.h" #include "../clib/clib_endian.h" #include "../clib/logfacility.h" #include "../clib/passert.h" +#include "../clib/rawtypes.h" +#include "accounts/account.h" +#include "menu.h" +#include "mobile/charactr.h" +#include "network/client.h" +#include "pktin.h" +#include "ufunc.h" namespace Pol { @@ -26,7 +23,8 @@ void handle_menu_selection( Network::Client* client, PKTIN_7D* msg ) { passert_paranoid( client ); - if ( !client->chr ) { + if ( !client->chr ) + { POLLOG.Format( "{} tried to use a menu without being in the game.\n" ) << client->acct->name(); return; } @@ -40,11 +38,11 @@ void handle_menu_selection( Network::Client* client, PKTIN_7D* msg ) if ( active_menu == nullptr ) { - POLLOG.Format( "{}/{} tried to use a menu, but none was active.\n" ) << client->acct->name() - << client->chr->name(); + POLLOG.Format( "{}/{} tried to use a menu, but none was active.\n" ) + << client->acct->name() << client->chr->name(); return; } - + u16 menu_id = cfBEu16( msg->menu_id ); if ( active_menu->menu_id != menu_id ) { @@ -90,4 +88,4 @@ void handle_menu_selection( Network::Client* client, PKTIN_7D* msg ) } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/miscmsg.cpp b/pol-core/pol/miscmsg.cpp index 5be7e40f7..747317c53 100644 --- a/pol-core/pol/miscmsg.cpp +++ b/pol-core/pol/miscmsg.cpp @@ -22,41 +22,44 @@ /* MISCMSG.CPP: Miscellaneous message handlers. Handlers shouldn't stay here long, only until they find a better home - but this is better than putting them in POL.CPP. */ -#include "multi/customhouses.h" -#include "multi/multi.h" +#include +#include +#include -#include "mobile/charactr.h" -#include "accounts/account.h" -#include "network/client.h" -#include "network/msghandl.h" -#include "network/packethelper.h" - -#include "fnsearch.h" -#include "cmbtcfg.h" -#include "pktboth.h" -#include "pktin.h" -#include "spells.h" -#include "tooltips.h" -#include "globals/uvars.h" -#include "ufunc.h" -#include "uoscrobj.h" -#include "sockio.h" -#include "unicode.h" - -#include "scrstore.h" -#include "polcfg.h" - -#include "../clib/clib.h" +#include +#include "../bscript/eprog.h" #include "../clib/clib_endian.h" #include "../clib/fdump.h" #include "../clib/logfacility.h" -#include "../clib/strutil.h" +#include "../clib/rawtypes.h" +#include "../clib/refptr.h" #include "../clib/stlutil.h" -#include "../bscript/eprog.h" #include "../plib/systemstate.h" - - -#include +#include "accounts/account.h" +#include "cmbtcfg.h" +#include "fnsearch.h" +#include "gameclck.h" +#include "globals/settings.h" +#include "globals/uvars.h" +#include "mobile/attribute.h" +#include "mobile/charactr.h" +#include "multi/customhouses.h" +#include "multi/multi.h" +#include "network/client.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "pktboth.h" +#include "pktdef.h" +#include "pktin.h" +#include "scrstore.h" +#include "sockio.h" +#include "spells.h" +#include "tooltips.h" +#include "uconst.h" +#include "ufunc.h" +#include "unicode.h" +#include "uobject.h" +#include "uoscrobj.h" namespace Pol { diff --git a/pol-core/pol/miscrgn.cpp b/pol-core/pol/miscrgn.cpp index 8a1a2c36c..899a81b07 100644 --- a/pol-core/pol/miscrgn.cpp +++ b/pol-core/pol/miscrgn.cpp @@ -8,13 +8,13 @@ #include "miscrgn.h" -#include "ufunc.h" -#include "realms.h" -#include "uworld.h" -#include "globals/uvars.h" -#include "realms/realm.h" +#include #include "../clib/cfgelem.h" +#include "../clib/rawtypes.h" +#include "globals/uvars.h" +#include "realms/realm.h" +#include "ufunc.h" namespace Pol { diff --git a/pol-core/pol/miscrgn.h b/pol-core/pol/miscrgn.h index 257d61eff..6f22fc66d 100644 --- a/pol-core/pol/miscrgn.h +++ b/pol-core/pol/miscrgn.h @@ -8,7 +8,17 @@ #define MISCRGN_H +#include "../clib/compilerspecifics.h" #include "region.h" +#include "zone.h" + +namespace Pol +{ +namespace Clib +{ +class ConfigElem; +} // namespace Clib +} // namespace Pol namespace Pol { diff --git a/pol-core/pol/mkscrobj.cpp b/pol-core/pol/mkscrobj.cpp index a539fce08..15ae6007b 100644 --- a/pol-core/pol/mkscrobj.cpp +++ b/pol-core/pol/mkscrobj.cpp @@ -5,7 +5,6 @@ #include "mkscrobj.h" - #include "uoscrobj.h" namespace Pol @@ -27,4 +26,4 @@ Bscript::BObjectImp* make_boatref( Multi::UBoat* boat ) return new Module::EUBoatRefObjImp( boat ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/mobile/attack.cpp b/pol-core/pol/mobile/attack.cpp index 752ba228c..021d16615 100644 --- a/pol-core/pol/mobile/attack.cpp +++ b/pol-core/pol/mobile/attack.cpp @@ -9,22 +9,17 @@ */ -#include "charactr.h" - -#include "../network/client.h" -#include "../network/cgdata.h" -#include "../network/msghandl.h" - -#include "../pktin.h" -#include "../ufunc.h" - -#include "../cmbtcfg.h" -#include "../guardrgn.h" -#include "../globals/settings.h" +#include #include "../../clib/clib_endian.h" - -#include +#include "../../clib/rawtypes.h" +#include "../cmbtcfg.h" +#include "../globals/settings.h" +#include "../guardrgn.h" +#include "../network/client.h" +#include "../pktin.h" +#include "../ufunc.h" +#include "charactr.h" namespace Pol { diff --git a/pol-core/pol/mobile/attribute.cpp b/pol-core/pol/mobile/attribute.cpp index 89963feff..9492987f4 100644 --- a/pol-core/pol/mobile/attribute.cpp +++ b/pol-core/pol/mobile/attribute.cpp @@ -6,14 +6,14 @@ #include "attribute.h" -#include "../../clib/cfgelem.h" -#include "../../clib/maputil.h" -#include "../../clib/passert.h" +#include +#include "../../clib/cfgelem.h" +#include "../../clib/passert.h" #include "../../plib/pkg.h" -#include "../syshook.h" -#include "../globals/uvars.h" #include "../globals/settings.h" +#include "../globals/uvars.h" +#include "../syshook.h" namespace Pol { @@ -127,4 +127,4 @@ void clean_attributes() Core::gamestate.attributes_byname.clear(); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/mobile/attribute.h b/pol-core/pol/mobile/attribute.h index a801ed7a5..51d0b58b4 100644 --- a/pol-core/pol/mobile/attribute.h +++ b/pol-core/pol/mobile/attribute.h @@ -7,10 +7,10 @@ #ifndef ATTRIBUTE_H #define ATTRIBUTE_H -#include "../scrdef.h" - -#include #include +#include + +#include "../scrdef.h" namespace Pol { diff --git a/pol-core/pol/mobile/boundbox.h b/pol-core/pol/mobile/boundbox.h index ac4694155..2598196e7 100644 --- a/pol-core/pol/mobile/boundbox.h +++ b/pol-core/pol/mobile/boundbox.h @@ -7,8 +7,8 @@ #ifndef __BOUNDBOX_H #define __BOUNDBOX_H -#include #include +#include namespace Pol { diff --git a/pol-core/pol/mobile/charactr.cpp b/pol-core/pol/mobile/charactr.cpp index 199bc14c6..1ca5cbd6f 100644 --- a/pol-core/pol/mobile/charactr.cpp +++ b/pol-core/pol/mobile/charactr.cpp @@ -87,89 +87,90 @@ #include "charactr.h" -#ifdef __GNUC__ -#include -#endif +#include +#include #include "../../clib/cfgelem.h" #include "../../clib/cfgfile.h" +#include "../../clib/clib.h" +#include "../../clib/clib_endian.h" #include "../../clib/esignal.h" #include "../../clib/fileutil.h" #include "../../clib/logfacility.h" -#include "../../clib/streamsaver.h" +#include "../../clib/passert.h" #include "../../clib/random.h" #include "../../clib/stlutil.h" -#include "../../clib/strutil.h" - +#include "../../clib/streamsaver.h" #include "../../plib/mapcell.h" #include "../../plib/systemstate.h" - #include "../accounts/account.h" #include "../accounts/accounts.h" -#include "../anim.h" #include "../checkpnt.h" #include "../clidata.h" #include "../cmbtcfg.h" #include "../cmdlevel.h" +#include "../containr.h" +#include "../dice.h" +#include "../extobj.h" #include "../fnsearch.h" +#include "../globals/settings.h" #include "../globals/state.h" #include "../globals/uvars.h" #include "../guardrgn.h" #include "../guilds.h" #include "../item/armor.h" +#include "../item/item.h" +#include "../item/itemdesc.h" #include "../item/weapon.h" #include "../item/wepntmpl.h" -#include "../lightlvl.h" +#include "../layers.h" #include "../mdelta.h" #include "../miscrgn.h" #include "../mkscrobj.h" #include "../module/osmod.h" #include "../module/uomod.h" -#include "../multi/boat.h" +#include "../movecost.h" +#include "../multi/customhouses.h" #include "../multi/house.h" +#include "../multi/multi.h" #include "../multi/multidef.h" #include "../musicrgn.h" #include "../network/cgdata.h" #include "../network/client.h" #include "../network/cliface.h" -#include "../network/packets.h" #include "../network/packetdefs.h" +#include "../network/packethelper.h" +#include "../network/packets.h" #include "../objtype.h" #include "../party.h" -#include "../pktboth.h" -#include "../pktout.h" -#include "../polcfg.h" +#include "../pktdef.h" #include "../polclass.h" +#include "../polsig.h" +#include "../polvar.h" +#include "../profile.h" +#include "../realms/WorldChangeReasons.h" #include "../realms/realm.h" -#include "../realms.h" #include "../schedule.h" +#include "../scrdef.h" #include "../scrsched.h" #include "../scrstore.h" #include "../sfx.h" #include "../skilladv.h" -#include "../skills.h" #include "../spelbook.h" #include "../statmsg.h" #include "../syshook.h" -#include "../target.h" #include "../ufunc.h" #include "../ufuncstd.h" -#include "../umanip.h" +#include "../uobjcnt.h" #include "../uoexec.h" #include "../uoscrobj.h" #include "../uworld.h" #include "../vital.h" - +#include "attribute.h" #include "corpse.h" #include "privupdater.h" -#include "ufacing.h" #include "wornitems.h" -#include "npc.h" // TODO: Remove this abomination! - -#include -#include - #ifdef _MSC_VER #pragma warning( disable : 4996 ) // stricmp deprecation warning #pragma warning( disable : 4505 ) // unreferenced local function has been removed @@ -969,7 +970,8 @@ void Character::readCommonProperties( Clib::ConfigElem& elem ) static_cast( elem.remove_int( "SKILLCAP", Core::SkillStatCap::DEFAULT.skillcap ) ) ) ); luck( static_cast( elem.remove_int( "LUCK", 0 ) ) ); followers( Core::ExtStatBarFollowers( - static_cast( elem.remove_int( "FOLLOWERS", Core::ExtStatBarFollowers::DEFAULT.followers ) ), + static_cast( + elem.remove_int( "FOLLOWERS", Core::ExtStatBarFollowers::DEFAULT.followers ) ), static_cast( elem.remove_int( "FOLLOWERSMAX", Core::ExtStatBarFollowers::DEFAULT.followers_max ) ) ) ); tithing( elem.remove_int( "TITHING", 0 ) ); @@ -1688,10 +1690,8 @@ void Character::on_poison_changed() { Network::HealthBarStatusUpdate msg( serial_ext, Network::HealthBarStatusUpdate::Color::GREEN, poisoned() ); - Core::WorldIterator::InVisualRange( this, [&]( Character* zonechr ) - { - msg.Send( zonechr->client ); - } ); + Core::WorldIterator::InVisualRange( + this, [&]( Character* zonechr ) { msg.Send( zonechr->client ); } ); } } } @@ -2110,11 +2110,9 @@ void Character::resurrect() send_warmode(); send_goxyz( client, this ); send_owncreate( client, this ); - Core::WorldIterator::InVisualRange( client->chr, [&]( Character* zonechr ) - { - send_remove_if_hidden_ghost( zonechr, - client ); - } ); + Core::WorldIterator::InVisualRange( client->chr, [&]( Character* zonechr ) { + send_remove_if_hidden_ghost( zonechr, client ); + } ); client->restart(); } @@ -2122,10 +2120,8 @@ void Character::resurrect() send_remove_character_to_nearby_cansee( this ); send_create_mobile_to_nearby_cansee( this ); - Core::WorldIterator::InRange( x, y, realm, 32, [&]( Character* chr ) - { - NpcPropagateEnteredArea( chr, this ); - } ); + Core::WorldIterator::InRange( + x, y, realm, 32, [&]( Character* chr ) { NpcPropagateEnteredArea( chr, this ); } ); } void Character::on_death( Items::Item* corpse ) @@ -2157,10 +2153,8 @@ void Character::on_death( Items::Item* corpse ) send_full_corpse( client, corpse ); send_goxyz( client, this ); - Core::WorldIterator::InVisualRange( client->chr, [&]( Character* zonechr ) - { - send_create_ghost( zonechr, client ); - } ); + Core::WorldIterator::InVisualRange( + client->chr, [&]( Character* zonechr ) { send_create_ghost( zonechr, client ); } ); client->restart(); } @@ -2278,15 +2272,13 @@ void Character::die() UPDATE_CHECKPOINT(); // small lambdas to reduce the mess inside the loops - auto _copy_item = [&]( Items::Item* _item ) - { // copy a item into the corpse + auto _copy_item = [&]( Items::Item* _item ) { // copy a item into the corpse Items::Item* copy = _item->clone(); copy->invisible( true ); copy->movable( false ); corpse->add( copy ); }; - auto _drop_item_to_world = [&]( Items::Item* _item ) - { // places the item onto the corpse coords + auto _drop_item_to_world = [&]( Items::Item* _item ) { // places the item onto the corpse coords _item->x = corpse->x; _item->y = corpse->y; _item->z = corpse->z; @@ -2497,9 +2489,9 @@ void Character::refresh_ar() if ( item == NULL ) continue; // Let's check all items as base, and handle their element_resists. - updateEquipableProperties( item ); - - if ( item->isa( Core::UOBJ_CLASS::CLASS_ARMOR ) ) + updateEquipableProperties( item ); + + if ( item->isa( Core::UOBJ_CLASS::CLASS_ARMOR ) ) { Items::UArmor* armor = static_cast( item ); std::set tmplzones = armor->tmplzones(); @@ -2692,70 +2684,67 @@ void PropagateMove( /*Client *client,*/ Character* chr ) MoveChrPkt msgmove( chr ); build_owncreate( chr, msgcreate.Get() ); - Core::WorldIterator::InVisualRange( - chr, [&]( Character* zonechr ) + Core::WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) { + Client* client = zonechr->client; + if ( zonechr == chr ) + return; + if ( !zonechr->is_visible_to_me( chr ) ) + return; + /* The two characters exist, and are in range of each other. + Character 'chr''s lastx and lasty coordinates are valid. + SO, if lastx/lasty are out of range of client->chr, we + should send a 'create' type message. If they are in range, + we should just send a move. + */ + if ( chr->move_reason == Character::MULTIMOVE ) + { + if ( client->ClientType & Network::CLIENTTYPE_7090 ) { - Client* client = zonechr->client; - if ( zonechr == chr ) - return; - if ( !zonechr->is_visible_to_me( chr ) ) - return; - /* The two characters exist, and are in range of each other. - Character 'chr''s lastx and lasty coordinates are valid. - SO, if lastx/lasty are out of range of client->chr, we - should send a 'create' type message. If they are in range, - we should just send a move. - */ - if ( chr->move_reason == Character::MULTIMOVE ) - { - if ( client->ClientType & Network::CLIENTTYPE_7090 ) - { - if ( chr->poisoned() ) // if poisoned send 0x17 for newer clients - msgpoison.Send( client ); + if ( chr->poisoned() ) // if poisoned send 0x17 for newer clients + msgpoison.Send( client ); - if ( chr->invul() ) // if invul send 0x17 for newer clients - msginvul.Send( client ); - return; - } - else - { + if ( chr->invul() ) // if invul send 0x17 for newer clients + msginvul.Send( client ); + return; + } + else + { // NOTE: uncomment this line to make movement smoother (no stepping anims) // but basically makes it very difficult to talk while the ship // is moving. #ifdef PERGON - send_remove_character( client, chr, msgremove ); + send_remove_character( client, chr, msgremove ); #else // send_remove_character( client, chr ); #endif - send_owncreate( client, chr, msgcreate.Get() ); - if ( chr->poisoned() ) - msgpoison.Send( client ); - if ( chr->invul() ) - msginvul.Send( client ); - } - } - else if ( Core::inrange( zonechr->x, zonechr->y, chr->lastx, chr->lasty ) ) - { - msgmove.Send( client ); - if ( chr->poisoned() ) - msgpoison.Send( client ); - if ( chr->invul() ) - msginvul.Send( client ); - } - else - { - send_owncreate( client, chr, msgcreate.Get() ); - if ( chr->poisoned() ) - msgpoison.Send( client ); - if ( chr->invul() ) - msginvul.Send( client ); - } - } ); + send_owncreate( client, chr, msgcreate.Get() ); + if ( chr->poisoned() ) + msgpoison.Send( client ); + if ( chr->invul() ) + msginvul.Send( client ); + } + } + else if ( Core::inrange( zonechr->x, zonechr->y, chr->lastx, chr->lasty ) ) + { + msgmove.Send( client ); + if ( chr->poisoned() ) + msgpoison.Send( client ); + if ( chr->invul() ) + msginvul.Send( client ); + } + else + { + send_owncreate( client, chr, msgcreate.Get() ); + if ( chr->poisoned() ) + msgpoison.Send( client ); + if ( chr->invul() ) + msginvul.Send( client ); + } + } ); // iter over all old in range players and send remove Core::WorldIterator::InRange( - chr->lastx, chr->lasty, chr->realm, RANGE_VISUAL, [&]( Character* zonechr ) - { + chr->lastx, chr->lasty, chr->realm, RANGE_VISUAL, [&]( Character* zonechr ) { Client* client = zonechr->client; if ( !zonechr->is_visible_to_me( chr ) ) return; @@ -2990,9 +2979,7 @@ void Character::inform_moved( Character* /*moved*/ ) { // consider moving PropagateMove here! } -void Character::inform_imoved( Character* /*chr*/ ) -{ -} +void Character::inform_imoved( Character* /*chr*/ ) {} void Character::set_opponent( Character* new_opponent, bool inform_old_opponent ) { @@ -3104,12 +3091,11 @@ void Character::set_warmode( bool i_warmode ) else { Network::MoveChrPkt msgmove( this ); - Core::WorldIterator::InVisualRange( this, [&]( Character* chr ) - { - if ( chr == this ) - return; - msgmove.Send( chr->client ); - } ); + Core::WorldIterator::InVisualRange( this, [&]( Character* chr ) { + if ( chr == this ) + return; + msgmove.Send( chr->client ); + } ); } } @@ -3602,15 +3588,13 @@ void Character::unhide() { if ( client != NULL ) send_owncreate( client, this ); - Core::WorldIterator::InVisualRange( - this, [&]( Character* chr ) - { - if ( chr == this ) - return; - if ( !chr->is_visible_to_me( this ) ) - return; - send_owncreate( chr->client, this ); - } ); + Core::WorldIterator::InVisualRange( this, [&]( Character* chr ) { + if ( chr == this ) + return; + if ( !chr->is_visible_to_me( this ) ) + return; + send_owncreate( chr->client, this ); + } ); // dave 12-21 added this hack to get enteredarea events fired when unhiding u16 oldlastx = lastx; @@ -3619,10 +3603,8 @@ void Character::unhide() lasty = 0; // tellmove(); - Core::WorldIterator::InRange( x, y, realm, 32, [&]( Character* chr ) - { - NpcPropagateMove( chr, this ); - } ); + Core::WorldIterator::InRange( + x, y, realm, 32, [&]( Character* chr ) { NpcPropagateMove( chr, this ); } ); lastx = oldlastx; lasty = oldlasty; } @@ -3948,8 +3930,7 @@ bool Character::CheckPushthrough() auto mobs = std::unique_ptr(); Core::WorldIterator::InRange( - newx, newy, realm, 0, [&]( Mobile::Character* _chr ) - { + newx, newy, realm, 0, [&]( Mobile::Character* _chr ) { if ( _chr->z >= z - 10 && _chr->z <= z + 10 && !_chr->dead() && ( is_visible_to_me( _chr ) || _chr->hidden() ) ) // add hidden mobs even if they're not visible to me @@ -3980,17 +3961,13 @@ void Character::tellmove() // TO DO: Place in realm change support so npcs know when you enter/leave one? if ( Core::pol_distance( lastx, lasty, x, y ) > 32 ) { - Core::WorldIterator::InRange( lastx, lasty, realm, 32, [&]( Character* chr ) - { - NpcPropagateMove( chr, this ); - } ); + Core::WorldIterator::InRange( + lastx, lasty, realm, 32, [&]( Character* chr ) { NpcPropagateMove( chr, this ); } ); } // Inform nearby NPCs that a movement has been made. - Core::WorldIterator::InRange( x, y, realm, 33, [&]( Character* chr ) - { - NpcPropagateMove( chr, this ); - } ); + Core::WorldIterator::InRange( + x, y, realm, 33, [&]( Character* chr ) { NpcPropagateMove( chr, this ); } ); check_attack_after_move(); @@ -4199,10 +4176,10 @@ unsigned int Character::guildid() const } /** -* Adds a new buff or overwrites an existing one for the character -* Sends packets to the client accordingly -* @author Bodom -*/ + * Adds a new buff or overwrites an existing one for the character + * Sends packets to the client accordingly + * @author Bodom + */ void Character::addBuff( u16 icon, u16 duration, u32 cl_name, u32 cl_descr, const std::vector& arguments ) { @@ -4217,11 +4194,11 @@ void Character::addBuff( u16 icon, u16 duration, u32 cl_name, u32 cl_descr, } /** -* Removes a buff for the character -* Sends packets to the client accordingly -* @author Bodom -* @return True when the buff has been found and removed, False when the buff was not present -*/ + * Removes a buff for the character + * Sends packets to the client accordingly + * @author Bodom + * @return True when the buff has been found and removed, False when the buff was not present + */ bool Character::delBuff( u16 icon ) { auto b = buffs_.find( icon ); @@ -4236,10 +4213,10 @@ bool Character::delBuff( u16 icon ) } /** -* Removes al buffs for the character -* Sends packets to the client accordingly -* @author Bodom -*/ + * Removes al buffs for the character + * Sends packets to the client accordingly + * @author Bodom + */ void Character::clearBuffs() { for ( auto it = buffs_.begin(); it != buffs_.end(); ++it ) @@ -4247,9 +4224,9 @@ void Character::clearBuffs() } /** -* Resends all buffs (with updated duration), usually called at (re)login -* @author Bodom -*/ + * Resends all buffs (with updated duration), usually called at (re)login + * @author Bodom + */ void Character::send_buffs() { if ( client == NULL ) diff --git a/pol-core/pol/mobile/charactr.h b/pol-core/pol/mobile/charactr.h index 1ff29df30..cec1605c7 100644 --- a/pol-core/pol/mobile/charactr.h +++ b/pol-core/pol/mobile/charactr.h @@ -32,27 +32,51 @@ #ifndef __CHARACTR_H #define __CHARACTR_H -#include "../../clib/passert.h" -#include "../gameclck.h" -#include "../polclock.h" -#include "../uobject.h" -#include "../action.h" -#include "../uconst.h" -#include "../skillid.h" -#include "../utype.h" - -#include "../../clib/weakptr.h" -#include "../../clib/strset.h" -#include "../reftypes.h" - -#include "attribute.h" - #include - -#include -#include #include #include +#include +#include + +#include "../../bscript/bobject.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/passert.h" +#include "../../clib/rawtypes.h" +#include "../../clib/refptr.h" +#include "../../clib/strset.h" +#include "../../clib/weakptr.h" +#include "../action.h" +#include "../baseobject.h" +#include "../dynproperties.h" +#include "../gameclck.h" +#include "../polclock.h" +#include "../reftypes.h" +#include "../skillid.h" +#include "../uconst.h" +#include "../uobject.h" +#include "../utype.h" +#include "attribute.h" + +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +namespace Clib +{ +class StreamWriter; +} // namespace Clib +namespace Core +{ +class UContainer; +class WornItemsContainer; +} // namespace Core +namespace Mobile +{ +class Character; +} // namespace Mobile +} // namespace Pol namespace Pol { @@ -82,22 +106,23 @@ class UWeapon; } namespace Core { -class RepSystem; -class MenuItem; +class Guild; class Menu; +class MenuItem; class OneShotTask; +class Party; +class RepSystem; +class SaveContext; class Spellbook; class TargetCursor; class UOExecutor; class USpell; class Vital; -class SaveContext; -class Party; -class Guild; -struct PKTIN_7D; struct PKTIN_00; +struct PKTIN_7D; struct PKTIN_8D; struct PKTIN_F8; + void ClientCreateChar( Network::Client* client, PKTIN_00* msg ); void ClientCreateCharKR( Network::Client* client, PKTIN_8D* msg ); void ClientCreateChar70160( Network::Client* client, PKTIN_F8* msg ); @@ -150,6 +175,7 @@ public: void lock( unsigned char lockstate ) { _lockstate = lockstate; } unsigned short cap() const { return _cap; } void cap( unsigned short cap ) { _cap = cap; } + private: unsigned short _base; short _temp; @@ -229,8 +255,8 @@ private: }; /** -* Represents a buff icon in the buff bar, see packet 0xDF documentation for more details -*/ + * Represents a buff icon in the buff bar, see packet 0xDF documentation for more details + */ struct Buff { // Polclock when the buff will end (only for displaying countdown) @@ -256,46 +282,46 @@ inline bool operator<( const reportable_t& lhs, const reportable_t& rhs ) enum class PRIV_FLAGS : u32 { - MOVE_ANY = 1 << 0, // should everything be moveable? - MOVE_ANY_DIST = 1 << 1, - RENAME_ANY = 1 << 2, // should everything be renameable? - CLOTHE_ANY = 1 << 3, - INVUL = 1 << 4, - SEE_HIDDEN = 1 << 5, - SEE_GHOSTS = 1 << 6, - HEAR_GHOSTS = 1 << 7, - SEE_INVIS_ITEMS = 1 << 8, - DBLCLICK_ANY = 1 << 9, - LOS_ANY = 1 << 19, // all targetting ignore LOS? - IGNORE_DOORS = 1 << 11, - FREEMOVE = 1 << 12, - FIRE_WHILE_MOVING = 1 << 13, - ATTACK_HIDDEN = 1 << 14, - HIDDEN_ATTACK = 1 << 15, - PLOG_ANY = 1 << 16, + MOVE_ANY = 1 << 0, // should everything be moveable? + MOVE_ANY_DIST = 1 << 1, + RENAME_ANY = 1 << 2, // should everything be renameable? + CLOTHE_ANY = 1 << 3, + INVUL = 1 << 4, + SEE_HIDDEN = 1 << 5, + SEE_GHOSTS = 1 << 6, + HEAR_GHOSTS = 1 << 7, + SEE_INVIS_ITEMS = 1 << 8, + DBLCLICK_ANY = 1 << 9, + LOS_ANY = 1 << 19, // all targetting ignore LOS? + IGNORE_DOORS = 1 << 11, + FREEMOVE = 1 << 12, + FIRE_WHILE_MOVING = 1 << 13, + ATTACK_HIDDEN = 1 << 14, + HIDDEN_ATTACK = 1 << 15, + PLOG_ANY = 1 << 16, CAN_BE_HEARD_AS_GHOST = 1 << 17, - RUN_WHILE_STEALTH = 1 << 18, - SPEEDHACK = 1 << 19, + RUN_WHILE_STEALTH = 1 << 18, + SPEEDHACK = 1 << 19, - ALL = ~0u, // all bits set + ALL = ~0u, // all bits set }; enum class MOB_FLAGS : u16 { READY_TO_SWING = 1 << 0, - MURDERER = 1 << 1, + MURDERER = 1 << 1, PARTY_CAN_LOOT = 1 << 2, TRADE_ACCEPTED = 1 << 3, - DEAD = 1 << 4, - HIDDEN = 1 << 5, - FROZEN = 1 << 6, - PARALYZED = 1 << 7, - WARMODE = 1 << 8, - POISONED = 1 << 9, - LOGGED_IN = 1 << 10, // for NPCs, this is always true. - CONNECTED = 1 << 11, - USE_ADJUSTMENTS = 1 << 12, // NPCs + DEAD = 1 << 4, + HIDDEN = 1 << 5, + FROZEN = 1 << 6, + PARALYZED = 1 << 7, + WARMODE = 1 << 8, + POISONED = 1 << 9, + LOGGED_IN = 1 << 10, // for NPCs, this is always true. + CONNECTED = 1 << 11, + USE_ADJUSTMENTS = 1 << 12, // NPCs }; // NOTES: @@ -312,7 +338,8 @@ class Character : public Core::UObject typedef std::set CharacterSet; public: - explicit Character( u32 objtype, Core::UOBJ_CLASS uobj_class = Core::UOBJ_CLASS::CLASS_CHARACTER ); + explicit Character( u32 objtype, + Core::UOBJ_CLASS uobj_class = Core::UOBJ_CLASS::CLASS_CHARACTER ); virtual ~Character(); private: @@ -731,7 +758,8 @@ protected: // BUFF/DEBUFF BAR public: - void addBuff( u16 icon, u16 duration, u32 cl_name, u32 cl_descr, const std::vector& arguments ); + void addBuff( u16 icon, u16 duration, u32 cl_name, u32 cl_descr, + const std::vector& arguments ); bool delBuff( u16 icon ); void clearBuffs(); void send_buffs(); @@ -826,7 +854,7 @@ public: public: DYN_PROPERTY( disable_skills_until, time_t, Core::PROP_DISABLE_SKILLS_UNTIL, 0 ); Core::TargetCursor* tcursor2; - weak_ptr menu; // TODO: Move this into the client's gamedata + weak_ptr menu; // TODO: Move this into the client's gamedata void ( *on_menu_selection )( Network::Client* client, Core::MenuItem* mi, Core::PKTIN_7D* msg ); void ( *on_popup_menu_selection )( Network::Client* client, u32 serial, u16 id ); diff --git a/pol-core/pol/mobile/chrcast.cpp b/pol-core/pol/mobile/chrcast.cpp index dcd8bd77e..ee14caaa6 100644 --- a/pol-core/pol/mobile/chrcast.cpp +++ b/pol-core/pol/mobile/chrcast.cpp @@ -5,20 +5,12 @@ */ -#include "charactr.h" +#include -#include "../../clib/clib.h" #include "../../clib/passert.h" - -#include "../module/cfgmod.h" -#include "../module/osmod.h" - #include "../polclock.h" -#include "../scrsched.h" #include "../spells.h" - -#include "../module/uomod.h" -#include "../uoexec.h" +#include "charactr.h" namespace Pol @@ -38,4 +30,4 @@ void Character::schedule_spell( Core::USpell* spell ) Core::polclock(), this, spell, true ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/mobile/chrituse.cpp b/pol-core/pol/mobile/chrituse.cpp index e8a39b7cf..aa77cf1dc 100644 --- a/pol-core/pol/mobile/chrituse.cpp +++ b/pol-core/pol/mobile/chrituse.cpp @@ -4,21 +4,24 @@ */ -#include "charactr.h" +#include +#include "../../bscript/bobject.h" +#include "../../bscript/eprog.h" #include "../../clib/logfacility.h" -#include "../module/cfgmod.h" +#include "../../clib/passert.h" +#include "../../clib/refptr.h" +#include "../../plib/systemstate.h" +#include "../item/item.h" +#include "../item/itemdesc.h" #include "../module/osmod.h" #include "../module/uomod.h" -#include "../polcfg.h" +#include "../scrdef.h" #include "../scrsched.h" +#include "../scrstore.h" #include "../uoexec.h" #include "../uoscrobj.h" -#include "../item/itemdesc.h" -#include "../scrstore.h" - -#include "../../clib/passert.h" -#include "../../plib/systemstate.h" +#include "charactr.h" namespace Pol { @@ -116,4 +119,4 @@ void Item::walk_on( Mobile::Character* chr ) } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/mobile/chrskuse.cpp b/pol-core/pol/mobile/chrskuse.cpp index 9e6ca3649..3a7a13836 100644 --- a/pol-core/pol/mobile/chrskuse.cpp +++ b/pol-core/pol/mobile/chrskuse.cpp @@ -4,11 +4,9 @@ */ +#include "../../bscript/eprog.h" #include "charactr.h" -#include "../uoexec.h" - - namespace Pol { namespace Mobile @@ -18,4 +16,4 @@ bool Character::start_skill_script( Bscript::EScriptProgram* prog ) return start_script( prog, true ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/mobile/corpse.cpp b/pol-core/pol/mobile/corpse.cpp index 50eac477d..1f078a635 100644 --- a/pol-core/pol/mobile/corpse.cpp +++ b/pol-core/pol/mobile/corpse.cpp @@ -9,12 +9,16 @@ #include "corpse.h" -#include "../../clib/cfgelem.h" -#include "../../clib/clib_endian.h" -#include "../../clib/streamsaver.h" +#include +#include "../../clib/cfgelem.h" +#include "../../clib/passert.h" +#include "../../clib/streamsaver.h" +#include "../containr.h" #include "../layers.h" #include "../ufunc.h" +#include "../uobject.h" + namespace Pol { diff --git a/pol-core/pol/mobile/corpse.h b/pol-core/pol/mobile/corpse.h index 095d7f7d4..66f14f2f6 100644 --- a/pol-core/pol/mobile/corpse.h +++ b/pol-core/pol/mobile/corpse.h @@ -1,7 +1,36 @@ #ifndef MOBILE_CORPSE_H #define MOBILE_CORPSE_H +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" #include "../containr.h" +#include "../item/item.h" + +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +} // namespace Bscript +namespace Clib +{ +class ConfigElem; +class StreamWriter; +} // namespace Clib +namespace Items +{ +class ContainerDesc; +class ItemDesc; +} // namespace Items +namespace Mobile +{ +class Character; +} // namespace Mobile +namespace Multi +{ +class UMulti; +} // namespace Multi +} // namespace Pol namespace Pol { diff --git a/pol-core/pol/mobile/npc.cpp b/pol-core/pol/mobile/npc.cpp index d671fcdb6..dc58aa981 100644 --- a/pol-core/pol/mobile/npc.cpp +++ b/pol-core/pol/mobile/npc.cpp @@ -25,61 +25,44 @@ */ #include "npc.h" -#include "../module/npcmod.h" -#include "attribute.h" -#include "wornitems.h" // refresh_ar() is the only one which needs this include... - -#include "../containr.h" -#include "../dice.h" -#include "../fnsearch.h" -#include "../globals/state.h" -#include "../globals/uvars.h" -#include "../item/weapon.h" -#include "../listenpt.h" -#include "../mdelta.h" -#include "../module/osmod.h" -#include "../module/unimod.h" -#include "../module/uomod.h" -#include "../multi/house.h" -#include "../network/client.h" -#include "../objtype.h" -#include "../pktout.h" -#include "../poltype.h" -#include "../realms/realm.h" -#include "../realms.h" -#include "../scrsched.h" -#include "../scrstore.h" -#include "../skilladv.h" -#include "../skills.h" -#include "../sockio.h" -#include "../ufunc.h" -#include "../ufuncinl.h" -#include "../uoexec.h" -#include "../uoexhelp.h" -#include "../uoscrobj.h" -#include "../uworld.h" -#include "../unicode.h" +#include #include "../../bscript/berror.h" -#include "../../bscript/eprog.h" -#include "../../bscript/execmodl.h" -#include "../../bscript/executor.h" -#include "../../bscript/impstr.h" -#include "../../bscript/modules.h" - #include "../../clib/cfgelem.h" -#include "../../clib/clib.h" -#include "../../clib/clib_endian.h" #include "../../clib/fileutil.h" #include "../../clib/logfacility.h" #include "../../clib/passert.h" #include "../../clib/random.h" -#include "../../clib/stlutil.h" +#include "../../clib/refptr.h" #include "../../clib/streamsaver.h" -#include "../../clib/strutil.h" +#include "../baseobject.h" +#include "../dice.h" +#include "../fnsearch.h" +#include "../globals/state.h" +#include "../globals/uvars.h" +#include "../item/armor.h" +#include "../item/weapon.h" +#include "../listenpt.h" +#include "../mdelta.h" +#include "../module/npcmod.h" +#include "../module/osmod.h" +#include "../module/uomod.h" +#include "../multi/multi.h" +#include "../npctmpl.h" +#include "../scrdef.h" +#include "../scrsched.h" +#include "../scrstore.h" +#include "../ufunc.h" +#include "../uobjcnt.h" +#include "../uobject.h" +#include "../uoexec.h" +#include "../uoscrobj.h" +#include "../uworld.h" +#include "attribute.h" +#include "charactr.h" +#include "wornitems.h" -#include /* An area definition is as follows: pt: (x,y) @@ -209,9 +192,8 @@ bool NPC::could_move( Core::UFACING fdir ) const tmp_newx = x + Core::move_delta[tmp_facing].xmove; tmp_newy = y + Core::move_delta[tmp_facing].ymove; current_boost = gradual_boost; - if ( !walk1 && - !realm->walkheight( this, tmp_newx, tmp_newy, z, &newz, &supporting_multi, &walkon_item, - ¤t_boost ) ) + if ( !walk1 && !realm->walkheight( this, tmp_newx, tmp_newy, z, &newz, &supporting_multi, + &walkon_item, ¤t_boost ) ) return false; } unsigned short newx = x + Core::move_delta[fdir].xmove; @@ -413,8 +395,7 @@ void NPC::readNpcProperties( Clib::ConfigElem& elem ) void NPC::loadEquipablePropertiesNPC( Clib::ConfigElem& elem ) { // for ar and elemental damage/resist the mod values are loaded before in character code! - auto diceValue = []( const std::string& dicestr, int* value ) -> bool - { + auto diceValue = []( const std::string& dicestr, int* value ) -> bool { Core::Dice dice; std::string errmsg; if ( !dice.load( dicestr.c_str(), &errmsg ) ) @@ -423,14 +404,10 @@ void NPC::loadEquipablePropertiesNPC( Clib::ConfigElem& elem ) *value = dice.roll(); return *value != 0; }; - auto apply = []( Core::ValueModPack v, int value ) -> Core::ValueModPack - { + auto apply = []( Core::ValueModPack v, int value ) -> Core::ValueModPack { return v.addToValue( static_cast( value ) ); }; - auto refresh = []( Core::ValueModPack v ) -> Core::ValueModPack - { - return v.addToValue( v.mod ); - }; + auto refresh = []( Core::ValueModPack v ) -> Core::ValueModPack { return v.addToValue( v.mod ); }; std::string tmp; int value; diff --git a/pol-core/pol/mobile/npc.h b/pol-core/pol/mobile/npc.h index 5291d82ff..9f5740478 100644 --- a/pol-core/pol/mobile/npc.h +++ b/pol-core/pol/mobile/npc.h @@ -21,13 +21,40 @@ #include "../item/armor.h" #endif -#include "../eventid.h" -#include "../npctmpl.h" - #include #include +#include #include +#include "../../bscript/bobject.h" +#include "../../clib/boostutils.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" +#include "../dynproperties.h" +#include "../eventid.h" +#include "../item/weapon.h" +#include "../npctmpl.h" +#include "../reftypes.h" +#include "../uconst.h" + +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +namespace Clib +{ +class StreamWriter; +} // namespace Clib +namespace Items +{ +class Item; +} // namespace Items +} // namespace Pol +template +class ref_ptr; + namespace Pol { namespace Clib @@ -40,8 +67,8 @@ class NPCExecutorModule; } namespace Core { -class UOExecutor; class RepSystem; +class UOExecutor; } namespace Mobile { diff --git a/pol-core/pol/mobile/privupdater.h b/pol-core/pol/mobile/privupdater.h index bdd9cb643..4290c064f 100644 --- a/pol-core/pol/mobile/privupdater.h +++ b/pol-core/pol/mobile/privupdater.h @@ -10,8 +10,8 @@ #endif #include "../../clib/passert.h" -#include "../uworld.h" #include "../ufunc.h" +#include "../uworld.h" namespace Pol { @@ -24,6 +24,7 @@ class PrivUpdater public: PrivUpdater( Character* chr, PRIV_FLAGS flag ); ~PrivUpdater(); + private: Character* chr_; PRIV_FLAGS flag_; @@ -55,10 +56,11 @@ private: PrivUpdater::PrivUpdater( Character* chr, PRIV_FLAGS flag ) - : chr_( chr ), - flag_( flag ), - oldvalue_( chr_ != nullptr ? chr_->cached_settings.get( flag_ ) : false ) -{} + : chr_( chr ), + flag_( flag ), + oldvalue_( chr_ != nullptr ? chr_->cached_settings.get( flag_ ) : false ) +{ +} PrivUpdater::~PrivUpdater() { @@ -69,21 +71,21 @@ PrivUpdater::~PrivUpdater() return; switch ( flag_ ) { - case PRIV_FLAGS::INVUL: - on_change_invul( chr_, newvalue ); - break; - case PRIV_FLAGS::SEE_GHOSTS: - on_change_see_ghosts( chr_, newvalue ); - break; - case PRIV_FLAGS::SEE_HIDDEN: - on_change_see_hidden( chr_, newvalue ); - break; - case PRIV_FLAGS::SEE_INVIS_ITEMS: - on_change_see_invis_items( chr_, newvalue ); - break; - default: - passert_always(0); - break; + case PRIV_FLAGS::INVUL: + on_change_invul( chr_, newvalue ); + break; + case PRIV_FLAGS::SEE_GHOSTS: + on_change_see_ghosts( chr_, newvalue ); + break; + case PRIV_FLAGS::SEE_HIDDEN: + on_change_see_hidden( chr_, newvalue ); + break; + case PRIV_FLAGS::SEE_INVIS_ITEMS: + on_change_see_invis_items( chr_, newvalue ); + break; + default: + passert_always( 0 ); + break; } } @@ -94,17 +96,13 @@ void PrivUpdater::on_change_see_hidden( Character* chr, bool enable ) if ( enable ) { - Core::WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) - { - enable_see_hidden( zonechr, chr ); - } ); + Core::WorldIterator::InVisualRange( + chr, [&]( Character* zonechr ) { enable_see_hidden( zonechr, chr ); } ); } else { - Core::WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) - { - disable_see_hidden( zonechr, chr ); - } ); + Core::WorldIterator::InVisualRange( + chr, [&]( Character* zonechr ) { disable_see_hidden( zonechr, chr ); } ); } } @@ -115,17 +113,13 @@ void PrivUpdater::on_change_see_ghosts( Character* chr, bool enable ) if ( enable ) { - Core::WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) - { - enable_see_ghosts( zonechr, chr ); - } ); + Core::WorldIterator::InVisualRange( + chr, [&]( Character* zonechr ) { enable_see_ghosts( zonechr, chr ); } ); } else { - Core::WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) - { - disable_see_ghosts( zonechr, chr ); - } ); + Core::WorldIterator::InVisualRange( + chr, [&]( Character* zonechr ) { disable_see_ghosts( zonechr, chr ); } ); } } @@ -137,18 +131,13 @@ void PrivUpdater::on_change_see_invis_items( Character* chr, bool enable ) if ( enable ) { - Core::WorldIterator::InVisualRange( chr, [&]( Items::Item* zoneitem ) - { - enable_see_invis_items( zoneitem, chr ); - } ); + Core::WorldIterator::InVisualRange( + chr, [&]( Items::Item* zoneitem ) { enable_see_invis_items( zoneitem, chr ); } ); } else { - Core::WorldIterator::InVisualRange( chr, [&]( Items::Item* zoneitem ) - { - disable_see_invis_items( zoneitem, - chr ); - } ); + Core::WorldIterator::InVisualRange( + chr, [&]( Items::Item* zoneitem ) { disable_see_invis_items( zoneitem, chr ); } ); } } @@ -159,20 +148,15 @@ void PrivUpdater::on_change_invul( Character* chr, bool enable ) if ( enable ) { - Core::WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) - { - enable_invul( zonechr, chr ); - } ); + Core::WorldIterator::InVisualRange( + chr, [&]( Character* zonechr ) { enable_invul( zonechr, chr ); } ); } else { Network::HealthBarStatusUpdate msg( chr->serial_ext, Network::HealthBarStatusUpdate::Color::YELLOW, false ); - Core::WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) - { - disable_invul( zonechr, chr, - msg ); - } ); + Core::WorldIterator::InVisualRange( + chr, [&]( Character* zonechr ) { disable_invul( zonechr, chr, msg ); } ); } } diff --git a/pol-core/pol/mobile/ufacing.cpp b/pol-core/pol/mobile/ufacing.cpp index f2709f055..fddae2275 100644 --- a/pol-core/pol/mobile/ufacing.cpp +++ b/pol-core/pol/mobile/ufacing.cpp @@ -1,12 +1,12 @@ #include "ufacing.h" -#include "charactr.h" - -#include "../uobject.h" -#include "../mdelta.h" - #include "../../clib/clib.h" #include "../../clib/random.h" +#include "../mdelta.h" +#include "../poltype.h" +#include "../uconst.h" +#include "../uobject.h" +#include "charactr.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // disable deprecation warning for stricmp @@ -25,7 +25,7 @@ MoveDelta move_delta[8] = {{0, -1}, // 0 is N UFACING away_cvt[8] = {FACING_S, FACING_SW, FACING_W, FACING_NW, FACING_N, FACING_NE, FACING_E, FACING_SE}; -std::array adjustments = {{0, +1, -1, +2, -2, +3, -3}}; +std::array adjustments = {{0, +1, -1, +2, -2, +3, -3}}; } namespace Mobile { diff --git a/pol-core/pol/mobile/ufacing.h b/pol-core/pol/mobile/ufacing.h index ea3868fb2..1c4b14037 100644 --- a/pol-core/pol/mobile/ufacing.h +++ b/pol-core/pol/mobile/ufacing.h @@ -19,7 +19,7 @@ namespace Core class UObject; extern UFACING away_cvt[8]; -extern std::array adjustments; +extern std::array adjustments; } namespace Mobile { diff --git a/pol-core/pol/mobile/wornitems.cpp b/pol-core/pol/mobile/wornitems.cpp index 505a5d580..da3b39c60 100644 --- a/pol-core/pol/mobile/wornitems.cpp +++ b/pol-core/pol/mobile/wornitems.cpp @@ -1,11 +1,17 @@ #include "wornitems.h" -#include "charactr.h" +#include "../../bscript/bobject.h" +#include "../../clib/passert.h" +#include "../containr.h" +#include "../extobj.h" +#include "../globals/settings.h" +#include "../item/item.h" #include "../item/itemdesc.h" +#include "../layers.h" #include "../objtype.h" -#include "../globals/uvars.h" -#include "../../clib/streamsaver.h" +#include "charactr.h" + namespace Pol { diff --git a/pol-core/pol/mobile/wornitems.h b/pol-core/pol/mobile/wornitems.h index f48129fd1..ecf95ae3e 100644 --- a/pol-core/pol/mobile/wornitems.h +++ b/pol-core/pol/mobile/wornitems.h @@ -1,8 +1,35 @@ #ifndef MOBILE_WORNITEMS_H #define MOBILE_WORNITEMS_H +#include + +#include "../../clib/compilerspecifics.h" #include "../containr.h" +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +} // namespace Bscript +namespace Clib +{ +class StreamWriter; +} // namespace Clib +namespace Core +{ +class UObject; +} // namespace Core +namespace Items +{ +class Item; +} // namespace Items +namespace Mobile +{ +class Character; +} // namespace Mobile +} // namespace Pol + namespace Pol { namespace Core diff --git a/pol-core/pol/module/attributemod.cpp b/pol-core/pol/module/attributemod.cpp index 68a505bbc..2f753d281 100644 --- a/pol-core/pol/module/attributemod.cpp +++ b/pol-core/pol/module/attributemod.cpp @@ -8,40 +8,40 @@ #include "attributemod.h" #include "../../bscript/berror.h" -#include "../../bscript/bobject.h" #include "../../bscript/impstr.h" - #include "../globals/uvars.h" #include "../mobile/attribute.h" #include "../mobile/charactr.h" #include "../network/cliface.h" #include "../skilladv.h" +#include "../skillid.h" #include "../uoexhelp.h" + namespace Pol { namespace Bscript { using namespace Module; template <> -TmplExecutorModule::FunctionTable - TmplExecutorModule::function_table = { - {"CheckSkill", &AttributeExecutorModule::mf_CheckSkill}, - {"GetAttributeName", &AttributeExecutorModule::mf_GetAttributeName}, - {"GetAttributeDefaultCap", &AttributeExecutorModule::mf_GetAttributeDefaultCap}, - {"GetAttribute", &AttributeExecutorModule::mf_GetAttribute}, - {"GetAttributeBaseValue", &AttributeExecutorModule::mf_GetAttributeBaseValue}, - {"GetAttributeTemporaryMod", &AttributeExecutorModule::mf_GetAttributeTemporaryMod}, - {"GetAttributeIntrinsicMod", &AttributeExecutorModule::mf_GetAttributeIntrinsicMod}, - {"GetAttributeLock", &AttributeExecutorModule::mf_GetAttributeLock}, - {"GetAttributeCap", &AttributeExecutorModule::mf_GetAttributeCap}, - {"SetAttributeCap", &AttributeExecutorModule::mf_SetAttributeCap}, - {"SetAttributeLock", &AttributeExecutorModule::mf_SetAttributeLock}, - {"SetAttributeBaseValue", &AttributeExecutorModule::mf_SetAttributeBaseValue}, - {"SetAttributeTemporaryMod", &AttributeExecutorModule::mf_SetAttributeTemporaryMod}, - {"AlterAttributeTemporaryMod", &AttributeExecutorModule::mf_AlterAttributeTemporaryMod}, - {"RawSkillToBaseSkill", &AttributeExecutorModule::mf_RawSkillToBase}, - {"BaseSkillToRawSkill", &AttributeExecutorModule::mf_BaseSkillToRaw}}; +TmplExecutorModule::FunctionTable + TmplExecutorModule::function_table = { + {"CheckSkill", &AttributeExecutorModule::mf_CheckSkill}, + {"GetAttributeName", &AttributeExecutorModule::mf_GetAttributeName}, + {"GetAttributeDefaultCap", &AttributeExecutorModule::mf_GetAttributeDefaultCap}, + {"GetAttribute", &AttributeExecutorModule::mf_GetAttribute}, + {"GetAttributeBaseValue", &AttributeExecutorModule::mf_GetAttributeBaseValue}, + {"GetAttributeTemporaryMod", &AttributeExecutorModule::mf_GetAttributeTemporaryMod}, + {"GetAttributeIntrinsicMod", &AttributeExecutorModule::mf_GetAttributeIntrinsicMod}, + {"GetAttributeLock", &AttributeExecutorModule::mf_GetAttributeLock}, + {"GetAttributeCap", &AttributeExecutorModule::mf_GetAttributeCap}, + {"SetAttributeCap", &AttributeExecutorModule::mf_SetAttributeCap}, + {"SetAttributeLock", &AttributeExecutorModule::mf_SetAttributeLock}, + {"SetAttributeBaseValue", &AttributeExecutorModule::mf_SetAttributeBaseValue}, + {"SetAttributeTemporaryMod", &AttributeExecutorModule::mf_SetAttributeTemporaryMod}, + {"AlterAttributeTemporaryMod", &AttributeExecutorModule::mf_AlterAttributeTemporaryMod}, + {"RawSkillToBaseSkill", &AttributeExecutorModule::mf_RawSkillToBase}, + {"BaseSkillToRawSkill", &AttributeExecutorModule::mf_BaseSkillToRaw}}; } namespace Module { diff --git a/pol-core/pol/module/attributemod.h b/pol-core/pol/module/attributemod.h index 609f2c4a5..71479680d 100644 --- a/pol-core/pol/module/attributemod.h +++ b/pol-core/pol/module/attributemod.h @@ -11,6 +11,16 @@ #define ATTRIBUTEEMOD_H #include "../../bscript/execmodl.h" + +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Module diff --git a/pol-core/pol/module/basiciomod.cpp b/pol-core/pol/module/basiciomod.cpp index cce44d153..ab7562150 100644 --- a/pol-core/pol/module/basiciomod.cpp +++ b/pol-core/pol/module/basiciomod.cpp @@ -6,13 +6,8 @@ #include "basiciomod.h" -#include "../../bscript/bobject.h" -#include "../../bscript/executor.h" -#include "../../bscript/impstr.h" - -#include "../../clib/clib.h" #include "../../clib/logfacility.h" -#include "../../clib/rawtypes.h" + namespace Pol { @@ -24,7 +19,7 @@ TmplExecutorModule::FunctionTable TmplExecutorModule::function_table = { {"print", &BasicIoExecutorModule::print}}; -} // namespace Bscript +} // namespace Bscript namespace Module { diff --git a/pol-core/pol/module/basiciomod.h b/pol-core/pol/module/basiciomod.h index 679f70ab5..d67c26eb4 100644 --- a/pol-core/pol/module/basiciomod.h +++ b/pol-core/pol/module/basiciomod.h @@ -9,6 +9,15 @@ #include "../../bscript/execmodl.h" +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Module diff --git a/pol-core/pol/module/basicmod.cpp b/pol-core/pol/module/basicmod.cpp index c46736ff3..8ddbea3c5 100644 --- a/pol-core/pol/module/basicmod.cpp +++ b/pol-core/pol/module/basicmod.cpp @@ -11,20 +11,19 @@ #include "basicmod.h" -#include "../../clib/clib.h" -#include "../../clib/rawtypes.h" -#include "../../clib/stlutil.h" -#include "../../clib/strutil.h" +#include +#include +#include +#include +#include #include "../../bscript/berror.h" #include "../../bscript/bobject.h" #include "../../bscript/dict.h" #include "../../bscript/executor.h" #include "../../bscript/impstr.h" +#include "../../clib/stlutil.h" -#include -#include -#include #ifdef _MSC_VER #pragma warning( disable : 4996 ) // stricmp, itoa and sprintf warnings @@ -572,112 +571,128 @@ Bscript::BObjectImp* BasicExecutorModule::mf_TypeOfInt() return new BLong( imp->typeOfInt() ); } -picojson::value recurseE2J(BObjectImp* v) { - if (v->isa(BObjectImp::OTString)) { - return picojson::value(v->getStringRep()); - } - else if (v->isa(BObjectImp::OTLong)) { - int intVal = static_cast(v)->value(); - return picojson::value(static_cast(intVal)); - } - else if (v->isa(BObjectImp::OTDouble)) { - return picojson::value(static_cast(v)->value()); - } - else if (v->isa(BObjectImp::OTBoolean)) { - return picojson::value(static_cast(v)->value()); - } - else if (v->isa(BObjectImp::OTArray)) { - ObjArray* arr = static_cast(v); - picojson::array jsonArr; +picojson::value recurseE2J( BObjectImp* v ) +{ + if ( v->isa( BObjectImp::OTString ) ) + { + return picojson::value( v->getStringRep() ); + } + else if ( v->isa( BObjectImp::OTLong ) ) + { + int intVal = static_cast( v )->value(); + return picojson::value( static_cast( intVal ) ); + } + else if ( v->isa( BObjectImp::OTDouble ) ) + { + return picojson::value( static_cast( v )->value() ); + } + else if ( v->isa( BObjectImp::OTBoolean ) ) + { + return picojson::value( static_cast( v )->value() ); + } + else if ( v->isa( BObjectImp::OTArray ) ) + { + ObjArray* arr = static_cast( v ); + picojson::array jsonArr; - for (const auto &elem : arr->ref_arr) - { - BObject* bo = elem.get(); - if (bo == nullptr) - continue; - BObjectImp* imp = bo->impptr(); - jsonArr.push_back(recurseE2J(imp)); - } - return picojson::value(jsonArr); - } - else if (v->isa(BObjectImp::OTStruct)) { - BStruct *bstruct = static_cast(v); - picojson::object jsonObj; - for (const auto& content : bstruct->contents()) - { - BObjectImp* imp = content.second->impptr(); - jsonObj.insert(std::pair( content.first , recurseE2J(imp) )); - - } - return picojson::value(jsonObj); - } - else if (v->isa(BObjectImp::OTDictionary)) { - BDictionary* cpropdict = static_cast(v); - picojson::object jsonObj; - for (const auto& content : cpropdict->contents()) - { - BObjectImp* imp = content.second->impptr(); - jsonObj.insert(std::pair(content.first->getStringRep(), recurseE2J(imp))); - - } - return picojson::value(jsonObj); - } - return picojson::value(); + for ( const auto& elem : arr->ref_arr ) + { + BObject* bo = elem.get(); + if ( bo == nullptr ) + continue; + BObjectImp* imp = bo->impptr(); + jsonArr.push_back( recurseE2J( imp ) ); + } + return picojson::value( jsonArr ); + } + else if ( v->isa( BObjectImp::OTStruct ) ) + { + BStruct* bstruct = static_cast( v ); + picojson::object jsonObj; + for ( const auto& content : bstruct->contents() ) + { + BObjectImp* imp = content.second->impptr(); + jsonObj.insert( std::pair( content.first, recurseE2J( imp ) ) ); + } + return picojson::value( jsonObj ); + } + else if ( v->isa( BObjectImp::OTDictionary ) ) + { + BDictionary* cpropdict = static_cast( v ); + picojson::object jsonObj; + for ( const auto& content : cpropdict->contents() ) + { + BObjectImp* imp = content.second->impptr(); + jsonObj.insert( std::pair( content.first->getStringRep(), + recurseE2J( imp ) ) ); + } + return picojson::value( jsonObj ); + } + return picojson::value(); } Bscript::BObjectImp* BasicExecutorModule::mf_PackJSON() { - BObjectImp* imp = exec.getParamImp(0); - return new String(recurseE2J(imp).serialize()); + BObjectImp* imp = exec.getParamImp( 0 ); + return new String( recurseE2J( imp ).serialize() ); } -Bscript::BObjectImp* recurseJ2E(const picojson::value& v) { - if (v.is()) { - return new String(v.get()); - } - else if (v.is()) { - // Possible improvement: separate into BLong and Double - return new Double(v.get()); - } - else if (v.is()) { - return new BBoolean(v.get()); - } - else if (v.is()) { - std::unique_ptr objarr(new ObjArray); - const picojson::array& arr = v.get(); - for (const auto& elem : arr) { - objarr->addElement(recurseJ2E(elem)); - } - return objarr.release(); - } - else if (v.is()) { - std::unique_ptr objstruct(new BStruct); - for (const auto& content : v.get()) - { - objstruct->addMember(content.first.c_str(), recurseJ2E(content.second) ); - } - return objstruct.release(); - } - else return UninitObject::create(); +Bscript::BObjectImp* recurseJ2E( const picojson::value& v ) +{ + if ( v.is() ) + { + return new String( v.get() ); + } + else if ( v.is() ) + { + // Possible improvement: separate into BLong and Double + return new Double( v.get() ); + } + else if ( v.is() ) + { + return new BBoolean( v.get() ); + } + else if ( v.is() ) + { + std::unique_ptr objarr( new ObjArray ); + const picojson::array& arr = v.get(); + for ( const auto& elem : arr ) + { + objarr->addElement( recurseJ2E( elem ) ); + } + return objarr.release(); + } + else if ( v.is() ) + { + std::unique_ptr objstruct( new BStruct ); + for ( const auto& content : v.get() ) + { + objstruct->addMember( content.first.c_str(), recurseJ2E( content.second ) ); + } + return objstruct.release(); + } + else + return UninitObject::create(); } Bscript::BObjectImp* BasicExecutorModule::mf_UnpackJSON() { - const String* str; + const String* str; - if (exec.getStringParam(0, str)) - { - picojson::value v; - std::string err = picojson::parse(v, str->data() ); - if (!err.empty()) { - return new BError(err); - } - return recurseJ2E(v); - } - else - { - return new BError("Invalid parameter type"); - } + if ( exec.getStringParam( 0, str ) ) + { + picojson::value v; + std::string err = picojson::parse( v, str->data() ); + if ( !err.empty() ) + { + return new BError( err ); + } + return recurseJ2E( v ); + } + else + { + return new BError( "Invalid parameter type" ); + } } Bscript::BObjectImp* BasicExecutorModule::mf_Boolean() @@ -686,18 +701,18 @@ Bscript::BObjectImp* BasicExecutorModule::mf_Boolean() if ( imp->isa( Bscript::BObjectImp::OTLong ) ) { BLong* plong = static_cast( imp ); - return new BBoolean(plong->value() != 0); + return new BBoolean( plong->value() != 0 ); } else if ( imp->isa( Bscript::BObjectImp::OTBoolean ) ) { - return new BBoolean(*static_cast(imp)); + return new BBoolean( *static_cast( imp ) ); } else { return new BError( "Boolean() expects an Integer or Boolean" ); } } -} // namespace Module +} // namespace Module namespace Bscript { @@ -731,6 +746,6 @@ TmplExecutorModule::FunctionTable {"TypeOfInt", &BasicExecutorModule::mf_TypeOfInt}, {"Boolean", &BasicExecutorModule::mf_Boolean}, {"PackJSON", &BasicExecutorModule::mf_PackJSON}, - {"UnpackJSON", &BasicExecutorModule::mf_UnpackJSON }}; + {"UnpackJSON", &BasicExecutorModule::mf_UnpackJSON}}; } } diff --git a/pol-core/pol/module/basicmod.h b/pol-core/pol/module/basicmod.h index f50f25873..d4f7c4542 100644 --- a/pol-core/pol/module/basicmod.h +++ b/pol-core/pol/module/basicmod.h @@ -7,6 +7,14 @@ #ifndef BSCRIPT_BASICMOD_H #define BSCRIPT_BASICMOD_H +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol #ifndef BSCRIPT_EXECMODL_H #include "../../bscript/execmodl.h" #endif @@ -16,7 +24,6 @@ namespace Pol { namespace Module { - class BasicExecutorModule : public Bscript::TmplExecutorModule { public: diff --git a/pol-core/pol/module/boatmod.cpp b/pol-core/pol/module/boatmod.cpp index c0279f17a..787eb4473 100644 --- a/pol-core/pol/module/boatmod.cpp +++ b/pol-core/pol/module/boatmod.cpp @@ -9,18 +9,15 @@ #include "boatmod.h" +#include + #include "../../bscript/berror.h" -#include "../../bscript/bobject.h" -#include "../../bscript/executor.h" -#include "../../bscript/impstr.h" - #include "../../clib/rawtypes.h" - -#include "../item/item.h" #include "../multi/boat.h" +#include "../multi/multi.h" #include "../realms/realm.h" +#include "../uconst.h" #include "../uoexhelp.h" -#include "../uoscrobj.h" namespace Pol { diff --git a/pol-core/pol/module/boatmod.h b/pol-core/pol/module/boatmod.h index eb91cf64f..b1dd7c979 100644 --- a/pol-core/pol/module/boatmod.h +++ b/pol-core/pol/module/boatmod.h @@ -10,6 +10,16 @@ #define BOATEMOD_H #include "../../bscript/execmodl.h" + +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Module diff --git a/pol-core/pol/module/cfgmod.cpp b/pol-core/pol/module/cfgmod.cpp index 5a2e16292..c3b3ee47e 100644 --- a/pol-core/pol/module/cfgmod.cpp +++ b/pol-core/pol/module/cfgmod.cpp @@ -7,53 +7,53 @@ #include "cfgmod.h" -#include "../cfgrepos.h" + +#include +#include +#include +#include #include "../../bscript/berror.h" #include "../../bscript/bobject.h" +#include "../../bscript/bstruct.h" #include "../../bscript/dict.h" +#include "../../bscript/execmodl.h" #include "../../bscript/executor.h" -#include "../../bscript/escrutil.h" #include "../../bscript/impstr.h" #include "../../bscript/objmembers.h" - #include "../../clib/rawtypes.h" +#include "../../clib/refptr.h" #include "../../clib/strutil.h" - #include "../../plib/pkg.h" - -#include -#include -#include +#include "../cfgrepos.h" namespace Pol { namespace Module { -class ConfigFileExecutorModule; } namespace Bscript { using namespace Module; template <> TmplExecutorModule::FunctionTable -TmplExecutorModule::function_table = { - {"ReadConfigFile", &ConfigFileExecutorModule::mf_ConfigFile}, - {"FindConfigElem", &ConfigFileExecutorModule::mf_FindConfigElement}, - {"GetElemProperty", &ConfigFileExecutorModule::mf_GetConfigString}, - {"GetConfigString", &ConfigFileExecutorModule::mf_GetConfigString}, - {"GetConfigStringArray", &ConfigFileExecutorModule::mf_GetConfigStringArray}, - {"GetConfigStringDictionary", &ConfigFileExecutorModule::mf_GetConfigStringDictionary}, - {"GetConfigInt", &ConfigFileExecutorModule::mf_GetConfigInt}, - {"GetConfigIntArray", &ConfigFileExecutorModule::mf_GetConfigIntArray}, - {"GetConfigReal", &ConfigFileExecutorModule::mf_GetConfigReal}, - {"GetConfigMaxIntKey", &ConfigFileExecutorModule::mf_GetConfigMaxIntKey}, - {"GetConfigStringKeys", &ConfigFileExecutorModule::mf_GetConfigStringKeys}, - {"GetConfigIntKeys", &ConfigFileExecutorModule::mf_GetConfigIntKeys}, - {"ListConfigElemProps", &ConfigFileExecutorModule::mf_ListConfigElemProps}, - {"AppendConfigFileElem", &ConfigFileExecutorModule::mf_AppendConfigFileElem}, - {"UnloadConfigFile", &ConfigFileExecutorModule::mf_UnloadConfigFile}, - {"LoadTusScpFile", &ConfigFileExecutorModule::mf_LoadTusScpFile}}; + TmplExecutorModule::function_table = { + {"ReadConfigFile", &ConfigFileExecutorModule::mf_ConfigFile}, + {"FindConfigElem", &ConfigFileExecutorModule::mf_FindConfigElement}, + {"GetElemProperty", &ConfigFileExecutorModule::mf_GetConfigString}, + {"GetConfigString", &ConfigFileExecutorModule::mf_GetConfigString}, + {"GetConfigStringArray", &ConfigFileExecutorModule::mf_GetConfigStringArray}, + {"GetConfigStringDictionary", &ConfigFileExecutorModule::mf_GetConfigStringDictionary}, + {"GetConfigInt", &ConfigFileExecutorModule::mf_GetConfigInt}, + {"GetConfigIntArray", &ConfigFileExecutorModule::mf_GetConfigIntArray}, + {"GetConfigReal", &ConfigFileExecutorModule::mf_GetConfigReal}, + {"GetConfigMaxIntKey", &ConfigFileExecutorModule::mf_GetConfigMaxIntKey}, + {"GetConfigStringKeys", &ConfigFileExecutorModule::mf_GetConfigStringKeys}, + {"GetConfigIntKeys", &ConfigFileExecutorModule::mf_GetConfigIntKeys}, + {"ListConfigElemProps", &ConfigFileExecutorModule::mf_ListConfigElemProps}, + {"AppendConfigFileElem", &ConfigFileExecutorModule::mf_AppendConfigFileElem}, + {"UnloadConfigFile", &ConfigFileExecutorModule::mf_UnloadConfigFile}, + {"LoadTusScpFile", &ConfigFileExecutorModule::mf_LoadTusScpFile}}; } namespace Module { diff --git a/pol-core/pol/module/cfgmod.h b/pol-core/pol/module/cfgmod.h index f8e157e5e..b9ff2ac42 100644 --- a/pol-core/pol/module/cfgmod.h +++ b/pol-core/pol/module/cfgmod.h @@ -7,9 +7,31 @@ #ifndef CFGEMOD_H #define CFGEMOD_H -#include "../../bscript/execmodl.h" +#include +#include +#include "../../bscript/bobject.h" +#include "../../bscript/execmodl.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" #include "../cfgrepos.h" + +namespace Pol +{ +namespace Bscript +{ +class Executor; +class ExecutorModule; +} // namespace Bscript +namespace Core +{ +class StoredConfigElem; +class StoredConfigFile; +} // namespace Core +} // namespace Pol +template +class ref_ptr; + namespace Pol { namespace Module diff --git a/pol-core/pol/module/clmod.cpp b/pol-core/pol/module/clmod.cpp index 664dde633..e46a8ddd4 100644 --- a/pol-core/pol/module/clmod.cpp +++ b/pol-core/pol/module/clmod.cpp @@ -8,11 +8,11 @@ #include "clmod.h" #include "../../bscript/berror.h" -#include "../../bscript/bobject.h" - +#include "../../clib/passert.h" +#include "../../clib/rawtypes.h" #include "../clfunc.h" #include "../mobile/charactr.h" -#include "../network/client.h" +#include "../pktdef.h" #include "../unicode.h" #include "../uoexhelp.h" @@ -27,8 +27,7 @@ TmplExecutorModule::FunctionTable {"SendSysMessageCL", &ClilocExecutorModule::mf_SendSysMessageCL}, {"PrintTextAboveCL", &ClilocExecutorModule::mf_PrintTextAboveCL}, - {"PrintTextAbovePrivateCL", &ClilocExecutorModule::mf_PrintTextAbovePrivateCL} -}; + {"PrintTextAbovePrivateCL", &ClilocExecutorModule::mf_PrintTextAbovePrivateCL}}; } namespace Module { diff --git a/pol-core/pol/module/clmod.h b/pol-core/pol/module/clmod.h index 1ee03999c..91704781d 100644 --- a/pol-core/pol/module/clmod.h +++ b/pol-core/pol/module/clmod.h @@ -8,6 +8,16 @@ #define CLILOCEMOD_H #include "../../bscript/execmodl.h" + +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Module diff --git a/pol-core/pol/module/datastore.cpp b/pol-core/pol/module/datastore.cpp index 72521d873..7ddd5e72f 100644 --- a/pol-core/pol/module/datastore.cpp +++ b/pol-core/pol/module/datastore.cpp @@ -9,29 +9,27 @@ #include "datastore.h" -#include "datastoreimp.h" + +#include +#include +#include #include "../../bscript/berror.h" +#include "../../bscript/bobject.h" +#include "../../bscript/bstruct.h" +#include "../../bscript/executor.h" #include "../../bscript/impstr.h" #include "../../bscript/objmethods.h" - #include "../../clib/cfgelem.h" #include "../../clib/cfgfile.h" #include "../../clib/fileutil.h" -#include "../../clib/maputil.h" -#include "../../clib/stlutil.h" +#include "../../clib/rawtypes.h" #include "../../clib/streamsaver.h" - #include "../../plib/pkg.h" #include "../../plib/systemstate.h" - -#include "../proplist.h" -#include "../uoexhelp.h" -#include "../polcfg.h" - #include "../globals/ucfg.h" - -#include +#include "../proplist.h" +#include "datastoreimp.h" namespace Pol { @@ -60,9 +58,7 @@ namespace Module Bscript::BApplicObjType datafileref_type; Bscript::BApplicObjType datafileelem_type; -DataFileContents::DataFileContents( DataStoreFile* dsf ) : dsf( dsf ), dirty( false ) -{ -} +DataFileContents::DataFileContents( DataStoreFile* dsf ) : dsf( dsf ), dirty( false ) {} DataFileContents::~DataFileContents() { @@ -690,9 +686,7 @@ size_t DataStoreFile::estimateSize() const } -DataFileElement::DataFileElement() : proplist( Core::CPropProfiler::Type::DATAFILEELEMENT ) -{ -} +DataFileElement::DataFileElement() : proplist( Core::CPropProfiler::Type::DATAFILEELEMENT ) {} DataFileElement::DataFileElement( Clib::ConfigElem& elem ) : proplist( Core::CPropProfiler::Type::DATAFILEELEMENT ) diff --git a/pol-core/pol/module/datastore.h b/pol-core/pol/module/datastore.h index 8d29cb50b..1521d8e2e 100644 --- a/pol-core/pol/module/datastore.h +++ b/pol-core/pol/module/datastore.h @@ -7,8 +7,19 @@ #ifndef DATASTORE_H #define DATASTORE_H +#include + #include "../../bscript/execmodl.h" +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Module diff --git a/pol-core/pol/module/datastoreimp.h b/pol-core/pol/module/datastoreimp.h index d55171fd3..39a540659 100644 --- a/pol-core/pol/module/datastoreimp.h +++ b/pol-core/pol/module/datastoreimp.h @@ -11,16 +11,16 @@ #include "../proplist.h" -#include #include +#include namespace Pol { namespace Clib { - class ConfigElem; - class ConfigFile; - class StreamWriter; +class ConfigElem; +class ConfigFile; +class StreamWriter; } namespace Plib { diff --git a/pol-core/pol/module/fileaccess.h b/pol-core/pol/module/fileaccess.h index 195b40959..93f68a194 100644 --- a/pol-core/pol/module/fileaccess.h +++ b/pol-core/pol/module/fileaccess.h @@ -9,9 +9,9 @@ #include "../../clib/maputil.h" -#include #include #include +#include namespace Pol { diff --git a/pol-core/pol/module/filemod.cpp b/pol-core/pol/module/filemod.cpp index 79a3fa85b..1ebe527d7 100644 --- a/pol-core/pol/module/filemod.cpp +++ b/pol-core/pol/module/filemod.cpp @@ -9,34 +9,27 @@ */ -#include "fileaccess.h" -#include "filemod.h" +#include +#include +#include +#include +#include "../../bscript/berror.h" +#include "../../bscript/bobject.h" +#include "../../bscript/impstr.h" #include "../../clib/cfgelem.h" #include "../../clib/cfgfile.h" #include "../../clib/clib.h" #include "../../clib/dirlist.h" #include "../../clib/fileutil.h" #include "../../clib/logfacility.h" -#include "../../clib/maputil.h" -#include "../../clib/stlutil.h" - -#include "../../bscript/berror.h" -#include "../../bscript/impstr.h" - #include "../../plib/pkg.h" - #include "../binaryfilescrobj.h" #include "../core.h" #include "../globals/ucfg.h" #include "../xmlfilescrobj.h" - -#include -#include - -#ifdef __unix__ -#include -#endif +#include "fileaccess.h" +#include "filemod.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // deprecated POSIX strerror warning @@ -251,8 +244,7 @@ bool FileAccess::AppliesToPath( const std::string& path, const Plib::Package* fi size_t FileAccess::estimateSize() const { size_t size = sizeof( FileAccess ); - for ( const auto& pkg : Packages ) - size += ( sizeof(void*) + 3 * sizeof( void* ) ); + size += Packages.size() * ( sizeof( void* ) + 3 * sizeof( void* ) ); for ( const auto& d : Directories ) size += sizeof( decltype( Directories )::value_type ) + d.second.capacity(); diff --git a/pol-core/pol/module/filemod.h b/pol-core/pol/module/filemod.h index c5112da3b..d3b236de2 100644 --- a/pol-core/pol/module/filemod.h +++ b/pol-core/pol/module/filemod.h @@ -10,6 +10,15 @@ #include "../../bscript/execmodl.h" +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class ExecutorModule; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Bscript diff --git a/pol-core/pol/module/guildmod.cpp b/pol-core/pol/module/guildmod.cpp index 131fff003..3c810a3af 100644 --- a/pol-core/pol/module/guildmod.cpp +++ b/pol-core/pol/module/guildmod.cpp @@ -9,32 +9,22 @@ #include "guildmod.h" -#include "../guilds.h" -#include "uomod.h" +#include #include "../../bscript/berror.h" #include "../../bscript/bobject.h" -#include "../../bscript/impstr.h" +#include "../../bscript/executor.h" #include "../../bscript/objmembers.h" #include "../../bscript/objmethods.h" - -#include "../../clib/refptr.h" -#include "../../clib/stlutil.h" - -#include "../../plib/systemstate.h" - -#include "../globals/uvars.h" -#include "../mobile/charactr.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" #include "../fnsearch.h" -#include "../polcfg.h" -#include "../proplist.h" -#include "../ufunc.h" -#include "../uobject.h" -#include "../uoscrobj.h" +#include "../globals/uvars.h" +#include "../guilds.h" +#include "../mobile/charactr.h" #include "../uoexhelp.h" - -#include +#include "../uoscrobj.h" namespace Pol { @@ -138,7 +128,7 @@ bool EGuildRefObjImp::operator==( const BObjectImp& objimp ) const return false; } else if ( objimp.isa( BObjectImp::OTBoolean ) ) - return isTrue() == static_cast(objimp).isTrue(); + return isTrue() == static_cast( objimp ).isTrue(); else return false; } diff --git a/pol-core/pol/module/guildmod.h b/pol-core/pol/module/guildmod.h index 95fda4c3e..f1a09e50a 100644 --- a/pol-core/pol/module/guildmod.h +++ b/pol-core/pol/module/guildmod.h @@ -9,6 +9,15 @@ #include "../../bscript/execmodl.h" +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Core diff --git a/pol-core/pol/module/httpmod.cpp b/pol-core/pol/module/httpmod.cpp index 763a6c392..257d647b2 100644 --- a/pol-core/pol/module/httpmod.cpp +++ b/pol-core/pol/module/httpmod.cpp @@ -4,18 +4,15 @@ */ #include "httpmod.h" + +#include "../../bscript/berror.h" +#include "../../bscript/impstr.h" +#include "../../clib/logfacility.h" +#include "../../clib/wnsckt.h" +#include "../../plib/systemstate.h" +#include "../uoexec.h" #include "osmod.h" -#include "../polcfg.h" -#include "../scrsched.h" -#include "../uoexec.h" - -#include "../../bscript/impstr.h" -#include "../../bscript/berror.h" - -#include "../../clib/logfacility.h" - -#include "../../plib/systemstate.h" namespace Pol { diff --git a/pol-core/pol/module/httpmod.h b/pol-core/pol/module/httpmod.h index 7380ffc44..e88ec4857 100644 --- a/pol-core/pol/module/httpmod.h +++ b/pol-core/pol/module/httpmod.h @@ -7,10 +7,19 @@ #ifndef __HTTPMOD_H #define __HTTPMOD_H +#include + #include "../../bscript/execmodl.h" #include "../../clib/wnsckt.h" -#include +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol namespace Pol { diff --git a/pol-core/pol/module/mathmod.cpp b/pol-core/pol/module/mathmod.cpp index 0c3e606f3..b9da62bce 100644 --- a/pol-core/pol/module/mathmod.cpp +++ b/pol-core/pol/module/mathmod.cpp @@ -9,10 +9,13 @@ #include "mathmod.h" +#include +#include + #include "../../bscript/berror.h" +#include "../../bscript/bobject.h" #include "../../bscript/impstr.h" -#include #ifdef _MSC_VER #pragma warning( disable : 4996 ) // disable deprecation warning sprintf diff --git a/pol-core/pol/module/mathmod.h b/pol-core/pol/module/mathmod.h index 00bf0af29..2a603044e 100644 --- a/pol-core/pol/module/mathmod.h +++ b/pol-core/pol/module/mathmod.h @@ -9,6 +9,16 @@ #define BSCRIPT_MATHEMOD_H #include "../../bscript/execmodl.h" + +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Module diff --git a/pol-core/pol/module/npcmod.cpp b/pol-core/pol/module/npcmod.cpp index 3935173fe..7092de208 100644 --- a/pol-core/pol/module/npcmod.cpp +++ b/pol-core/pol/module/npcmod.cpp @@ -6,61 +6,37 @@ #include "npcmod.h" -#include "osmod.h" -#include "unimod.h" -#include "uomod.h" - -#include "../containr.h" -#include "../dice.h" -#include "../eventid.h" -#include "../fnsearch.h" -#include "../globals/uvars.h" -#include "../item/weapon.h" -#include "../listenpt.h" -#include "../mobile/attribute.h" -#include "../mobile/boundbox.h" -#include "../mobile/npc.h" -#include "../mobile/ufacing.h" -#include "../network/client.h" -#include "../network/packets.h" -#include "../network/packethelper.h" -#include "../npctmpl.h" -#include "../objtype.h" -#include "../pktout.h" -#include "../poltype.h" -#include "../realms.h" -#include "../realms/realm.h" -#include "../scrsched.h" -#include "../scrstore.h" -#include "../skilladv.h" -#include "../skills.h" -#include "../sockio.h" -#include "../ufunc.h" -#include "../ufuncinl.h" -#include "../uoexec.h" -#include "../uoexhelp.h" -#include "../uoscrobj.h" -#include "../uworld.h" -#include "../unicode.h" +#include +#include +#include #include "../../bscript/berror.h" -#include "../../bscript/eprog.h" -#include "../../bscript/executor.h" -#include "../../bscript/modules.h" +#include "../../bscript/bobject.h" #include "../../bscript/impstr.h" - -#include "../../clib/cfgelem.h" #include "../../clib/clib.h" -#include "../../clib/clib_endian.h" -#include "../../clib/fileutil.h" +#include "../../clib/compilerspecifics.h" #include "../../clib/logfacility.h" -#include "../../clib/passert.h" #include "../../clib/random.h" +#include "../../clib/rawtypes.h" #include "../../clib/stlutil.h" #include "../../clib/strutil.h" +#include "../containr.h" +#include "../item/item.h" +#include "../mobile/boundbox.h" +#include "../mobile/charactr.h" +#include "../mobile/npc.h" +#include "../mobile/ufacing.h" +#include "../network/packethelper.h" +#include "../network/packets.h" +#include "../objtype.h" +#include "../pktdef.h" +#include "../poltype.h" +#include "../unicode.h" +#include "../uoscrobj.h" +#include "../uworld.h" +#include "osmod.h" +#include "unimod.h" -#include -#include #ifdef _MSC_VER #pragma warning( disable : 4996 ) // deprecation warning for stricmp @@ -749,8 +725,7 @@ BObjectImp* NPCExecutorModule::say() else range = Core::settingsManager.ssopt.speech_range; Core::WorldIterator::InRange( npc.x, npc.y, npc.realm, range, - [&]( Mobile::Character* chr ) - { + [&]( Mobile::Character* chr ) { if ( !chr->is_visible_to_me( &npc ) ) return; msg.Send( chr->client, len ); @@ -759,8 +734,7 @@ BObjectImp* NPCExecutorModule::say() if ( doevent >= 1 ) { Core::WorldIterator::InRange( - npc.x, npc.y, npc.realm, range, [&]( Mobile::Character* chr ) - { + npc.x, npc.y, npc.realm, range, [&]( Mobile::Character* chr ) { Mobile::NPC* othernpc = static_cast( chr ); if ( chr != &npc ) othernpc->on_pc_spoke( &npc, text, texttype ); @@ -836,8 +810,7 @@ BObjectImp* NPCExecutorModule::SayUC() else range = Core::settingsManager.ssopt.speech_range; Core::WorldIterator::InRange( npc.x, npc.y, npc.realm, range, - [&]( Mobile::Character* chr ) - { + [&]( Mobile::Character* chr ) { if ( !chr->is_visible_to_me( &npc ) ) return; talkmsg.Send( chr->client, len ); @@ -853,8 +826,7 @@ BObjectImp* NPCExecutorModule::SayUC() } ntextbuf[ntextbuflen++] = 0; Core::WorldIterator::InRange( - npc.x, npc.y, npc.realm, range, [&]( Mobile::Character* chr ) - { + npc.x, npc.y, npc.realm, range, [&]( Mobile::Character* chr ) { Mobile::NPC* othernpc = static_cast( chr ); if ( othernpc != &npc ) othernpc->on_pc_spoke( &npc, ntextbuf, texttype, gwtext, languc.c_str(), NULL ); @@ -973,7 +945,8 @@ BObjectImp* NPCExecutorModule::CreateItem() BObjectImp* NPCExecutorModule::makeboundingbox( /* areastring */ ) { - String* arealist = EXPLICIT_CAST(String*, BObjectImp*)( getParamImp( 0, BObjectImp::OTString ) ); + String* arealist = + EXPLICIT_CAST( String*, BObjectImp* )( getParamImp( 0, BObjectImp::OTString ) ); if ( arealist == NULL ) return new String( "" ); diff --git a/pol-core/pol/module/npcmod.h b/pol-core/pol/module/npcmod.h index 5feff820d..959db53d0 100644 --- a/pol-core/pol/module/npcmod.h +++ b/pol-core/pol/module/npcmod.h @@ -10,11 +10,21 @@ #ifndef NPCEMOD_H #define NPCEMOD_H +#include + #include "../../bscript/execmodl.h" #include "../reftypes.h" #include "../uconst.h" -#include +namespace Pol +{ +namespace Bscript +{ +class Executor; +template +class TmplExecutorModule; +} // namespace Bscript +} // namespace Pol namespace Pol { @@ -42,7 +52,7 @@ public: protected: OSExecutorModule* os_module; - + friend class Bscript::TmplExecutorModule; Bscript::BObjectImp* mf_Wander(); diff --git a/pol-core/pol/module/osmod.cpp b/pol-core/pol/module/osmod.cpp index dff0ebce0..46843f431 100644 --- a/pol-core/pol/module/osmod.cpp +++ b/pol-core/pol/module/osmod.cpp @@ -5,55 +5,50 @@ #include "osmod.h" -#include "npcmod.h" // necessary for reporting which npc is discarding events when the queue is full -#include "uomod.h" - -#include "../uoexec.h" -#include "../uoexhelp.h" - #include "../../bscript/berror.h" #include "../../bscript/bobject.h" -#include "../../bscript/eprog.h" -#include "../../bscript/executor.h" +#include "../../bscript/bstruct.h" #include "../../bscript/impstr.h" - -#include "../network/auxclient.h" -#include "../network/packethelper.h" - +#include "../../clib/logfacility.h" +#include "../../clib/rawtypes.h" +#include "../../clib/refptr.h" +#include "../../clib/sckutil.h" +#include "../../clib/threadhelp.h" +#include "../../clib/weakptr.h" +#include "../../plib/systemstate.h" +#include "../exscrobj.h" +#include "../globals/script_internals.h" +#include "../globals/state.h" +#include "../item/item.h" #include "../mobile/attribute.h" #include "../mobile/charactr.h" -#include "../mobile/npc.h" // needed only for reporting the NPC's position when the event queue is full - should refactor to decouple - -#include "../exscrobj.h" -#include "../globals/state.h" +#include "../mobile/npc.h" +#include "../network/auxclient.h" +#include "../network/packethelper.h" +#include "../network/packets.h" +#include "../pktdef.h" #include "../polcfg.h" #include "../poldbg.h" #include "../polsem.h" +#include "../profile.h" #include "../schedule.h" +#include "../scrdef.h" #include "../scrsched.h" #include "../scrstore.h" #include "../skills.h" -#include "../ufuncstd.h" -#include "../unicode.h" +#include "../ufunc.h" +#include "../uoexec.h" +#include "npcmod.h" +#include "uomod.h" -#include "../../clib/clib_endian.h" -#include "../../clib/logfacility.h" -#include "../../clib/passert.h" -#include "../../clib/sckutil.h" -#include "../../clib/socketsvc.h" -#include "../../clib/stlutil.h" -#include "../../clib/strutil.h" -#include "../../clib/threadhelp.h" -#include "../../clib/weakptr.h" - -#include "../../plib/systemstate.h" #pragma comment( lib, "crypt32.lib" ) -#include - #include +#include +#include +#include +#include #include -#include #ifdef _MSC_VER #pragma warning( disable : 4996 ) // stricmp POSIX deprecation warning @@ -1016,13 +1011,13 @@ struct PerfData std::unique_ptr elem( new BStruct ); elem->addMember( "name", new String( res[i].name ) ); elem->addMember( "instructions", new Double( static_cast( res[i].instructions ) ) ); - elem->addMember( "pid", new BLong( static_cast(res[i].pid) ) ); + elem->addMember( "pid", new BLong( static_cast( res[i].pid ) ) ); elem->addMember( "percent", new Double( res[i].instructions / sum_instr * 100.0 ) ); arr->addElement( elem.release() ); } std::unique_ptr result( new BStruct ); result->addMember( "scripts", arr.release() ); - result->addMember( "total_number_observed", new BLong( static_cast(res.size()) ) ); + result->addMember( "total_number_observed", new BLong( static_cast( res.size() ) ) ); result->addMember( "total_instructions", new Double( sum_instr ) ); data->uoexec_w.get_weakptr()->ValueStack.back().set( new BObject( result.release() ) ); diff --git a/pol-core/pol/module/osmod.h b/pol-core/pol/module/osmod.h index 552d8f9a0..5e2752b52 100644 --- a/pol-core/pol/module/osmod.h +++ b/pol-core/pol/module/osmod.h @@ -12,19 +12,36 @@ #include "../../bscript/execmodl.h" #endif +#include +#include +#include + +#include "../globals/script_internals.h" #include "../polclock.h" #include "../uoexhelp.h" -#include "../globals/script_internals.h" -#include -#include -#include +namespace Pol +{ +namespace Bscript +{ +class BObject; +class BObjectImp; +class Executor; +template +class TmplExecutorModule; +} // namespace Bscript +namespace Mobile +{ +class Character; +} // namespace Mobile +} // namespace Pol namespace Pol { namespace Core { class UOExecutor; + void run_ready( void ); void check_blocked( polclock_t* pclocksleft ); void deschedule_executor( UOExecutor* ex ); @@ -122,8 +139,8 @@ protected: friend class NPCExecutorModule; friend void step_scripts( void ); - // friend void Core::run_ready( void ); - friend class Core::ScriptScheduler; // TODO: REMOVE THIS AS SOON AS POSSIBLE!!! + // friend void Core::run_ready( void ); + friend class Core::ScriptScheduler; // TODO: REMOVE THIS AS SOON AS POSSIBLE!!! friend void Core::check_blocked( Core::polclock_t* pclocksleft ); friend void new_check_blocked( void ); friend void Core::deschedule_executor( Core::UOExecutor* ex ); @@ -140,9 +157,8 @@ inline bool OSExecutorModule::getCharacterParam( unsigned param, Mobile::Charact inline bool OSExecutorModule::blocked() const { - return blocked_; + return blocked_; } - } } diff --git a/pol-core/pol/module/partymod.cpp b/pol-core/pol/module/partymod.cpp index aafddd638..3ac6ff457 100644 --- a/pol-core/pol/module/partymod.cpp +++ b/pol-core/pol/module/partymod.cpp @@ -12,24 +12,28 @@ #endif #include "partymod.h" -#include "../party.h" -#include "../unicode.h" + +#include #include "../../bscript/berror.h" +#include "../../bscript/bobject.h" +#include "../../bscript/executor.h" #include "../../bscript/objmembers.h" #include "../../bscript/objmethods.h" -#include "../../bscript/bobject.h" -#include "../../clib/stlutil.h" -#include "../../clib/cfgelem.h" -#include "../network/client.h" -#include "../fnsearch.h" -#include "../proplist.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" #include "../clfunc.h" -#include "../uoscrobj.h" -#include "../uoexhelp.h" +#include "../fnsearch.h" +#include "../globals/settings.h" #include "../globals/uvars.h" - -#include +#include "../mobile/charactr.h" +#include "../party.h" +#include "../party_cfg.h" +#include "../pktdef.h" +#include "../syshook.h" +#include "../unicode.h" +#include "../uoexhelp.h" +#include "../uoscrobj.h" namespace Pol { @@ -111,7 +115,7 @@ bool EPartyRefObjImp::operator==( const BObjectImp& objimp ) const return false; } else if ( objimp.isa( Bscript::BObjectImp::OTBoolean ) ) - return isTrue() == static_cast(objimp).isTrue(); + return isTrue() == static_cast( objimp ).isTrue(); else return false; } diff --git a/pol-core/pol/module/partymod.h b/pol-core/pol/module/partymod.h index 3c0b534c9..8ea7f62b9 100644 --- a/pol-core/pol/module/partymod.h +++ b/pol-core/pol/module/partymod.h @@ -9,6 +9,15 @@ #include "../../bscript/execmodl.h" +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Core diff --git a/pol-core/pol/module/polsystemmod.cpp b/pol-core/pol/module/polsystemmod.cpp index 2c92c6790..024ee86b7 100644 --- a/pol-core/pol/module/polsystemmod.cpp +++ b/pol-core/pol/module/polsystemmod.cpp @@ -13,37 +13,39 @@ #include "polsystemmod.h" +#include +#include +#include + #include "../../bscript/berror.h" #include "../../bscript/bobject.h" #include "../../bscript/dict.h" #include "../../bscript/impstr.h" - #include "../../clib/clib.h" #include "../../clib/clib_MD5.h" -#include "../../clib/dirlist.h" +#include "../../clib/compilerspecifics.h" #include "../../clib/fileutil.h" +#include "../../clib/rawtypes.h" #include "../../clib/strutil.h" #include "../../clib/threadhelp.h" - #include "../../plib/pkg.h" #include "../../plib/systemstate.h" - #include "../cmdlevel.h" #include "../core.h" +#include "../globals/settings.h" #include "../globals/uvars.h" #include "../item/item.h" #include "../item/itemdesc.h" #include "../listenpt.h" #include "../packetscrobj.h" -#include "../polclock.h" +#include "../polcfg.h" +#include "../proplist.h" #include "../realms.h" #include "../realms/realm.h" #include "../tooltips.h" #include "../uobject.h" #include "../uoexhelp.h" -#include -#include #ifdef _MSC_VER #pragma warning( disable : 4996 ) // deprecation warning for stricmp @@ -66,6 +68,7 @@ public: const Plib::Package* operator->() const { return m_pPkg; } Plib::Package* Ptr() { return m_pPkg; } const Plib::Package* Ptr() const { return m_pPkg; } + private: Plib::Package* m_pPkg; }; diff --git a/pol-core/pol/module/polsystemmod.h b/pol-core/pol/module/polsystemmod.h index 02c821547..2acaa5f7f 100644 --- a/pol-core/pol/module/polsystemmod.h +++ b/pol-core/pol/module/polsystemmod.h @@ -9,6 +9,16 @@ #define POLSYSTEMEMOD_H #include "../../bscript/execmodl.h" + +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Module diff --git a/pol-core/pol/module/sqlmod.cpp b/pol-core/pol/module/sqlmod.cpp index b87ea2b3a..a5f3da7b5 100644 --- a/pol-core/pol/module/sqlmod.cpp +++ b/pol-core/pol/module/sqlmod.cpp @@ -3,19 +3,28 @@ * @par History */ +#ifdef WINDOWS +#include "../../clib/pol_global_config_win.h" +#else +#include "pol_global_config.h" +#endif + #include "sqlmod.h" +#include + #include "../../bscript/berror.h" -#include "../../bscript/bobject.h" #include "../../bscript/impstr.h" - #include "../../clib/logfacility.h" - +#include "../../clib/refptr.h" +#include "../../clib/weakptr.h" #include "../globals/network.h" #include "../polsem.h" #include "../sqlscrobj.h" +#include "../uoexec.h" #include "osmod.h" + namespace Pol { namespace Bscript @@ -51,8 +60,7 @@ BObjectImp* SQLExecutorModule::background_connect( weak_ptr uo const std::string username, const std::string password ) { - auto msg = [uoexec, host, username, password]() - { + auto msg = [uoexec, host, username, password]() { std::unique_ptr sql; { Core::PolLock lck; @@ -98,7 +106,7 @@ BObjectImp* SQLExecutorModule::background_connect( weak_ptr uo if ( !uoexec->suspend() ) { DEBUGLOG << "Script Error in '" << uoexec->scriptname() << "' PC=" << uoexec->PC << ": \n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } @@ -107,13 +115,12 @@ BObjectImp* SQLExecutorModule::background_connect( weak_ptr uo } Bscript::BObjectImp* SQLExecutorModule::background_select( weak_ptr uoexec, - Core::BSQLConnection* sql, const std::string db ) -{ - + Core::BSQLConnection* sql, + const std::string db ) +{ // The BSQLConnection shouldn't be destroyed before the lambda runs ref_ptr sqlRef( sql ); - auto msg = [uoexec, sqlRef, db]() - { + auto msg = [uoexec, sqlRef, db]() { if ( sqlRef == nullptr ) { Core::PolLock lck; @@ -134,7 +141,7 @@ Bscript::BObjectImp* SQLExecutorModule::background_select( weak_ptrValueStack.back().set( - new BObject( new BError( sqlRef->getLastError() ) ) ); + new BObject( new BError( sqlRef->getLastError() ) ) ); uoexec.get_weakptr()->os_module->revive(); } } @@ -154,7 +161,7 @@ Bscript::BObjectImp* SQLExecutorModule::background_select( weak_ptrsuspend() ) { DEBUGLOG << "Script Error in '" << uoexec->scriptname() << "' PC=" << uoexec->PC << ": \n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } Core::networkManager.sql_service->push( std::move( msg ) ); @@ -162,8 +169,9 @@ Bscript::BObjectImp* SQLExecutorModule::background_select( weak_ptr uoexec, - Core::BSQLConnection* sql, const std::string query, - const Bscript::ObjArray* params ) + Core::BSQLConnection* sql, + const std::string query, + const Bscript::ObjArray* params ) { // Copy and parse params before they will be deleted by this thread (go out of scope) Core::QueryParams sharedParams( nullptr ); @@ -181,10 +189,10 @@ Bscript::BObjectImp* SQLExecutorModule::background_query( weak_ptr sqlRef( sql ); - auto msg = [uoexec, sqlRef, query, sharedParams]() - { - if ( sqlRef == nullptr ) // TODO: this doesn't make any sense and should be checked before the lambda. Same happens in background_select(). + ref_ptr sqlRef( sql ); + auto msg = [uoexec, sqlRef, query, sharedParams]() { + if ( sqlRef == nullptr ) // TODO: this doesn't make any sense and should be checked before the + // lambda. Same happens in background_select(). { Core::PolLock lck; if ( !uoexec.exists() ) @@ -204,7 +212,7 @@ Bscript::BObjectImp* SQLExecutorModule::background_query( weak_ptrValueStack.back().set( - new BObject( new BError( sqlRef->getLastError() ) ) ); + new BObject( new BError( sqlRef->getLastError() ) ) ); uoexec.get_weakptr()->os_module->revive(); } } @@ -220,11 +228,11 @@ Bscript::BObjectImp* SQLExecutorModule::background_query( weak_ptrsuspend() ) { DEBUGLOG << "Script Error in '" << uoexec->scriptname() << "' PC=" << uoexec->PC << ": \n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } diff --git a/pol-core/pol/module/sqlmod.h b/pol-core/pol/module/sqlmod.h index fd63c74e4..49baa7719 100644 --- a/pol-core/pol/module/sqlmod.h +++ b/pol-core/pol/module/sqlmod.h @@ -7,9 +7,27 @@ #ifndef SQLMOD_H #define SQLMOD_H +#include + #include "../../bscript/execmodl.h" #include "../uoexec.h" +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +class ObjArray; +} // namespace Bscript +namespace Core +{ +class UOExecutor; +} // namespace Core +} // namespace Pol +template +class weak_ptr; + namespace Pol { namespace Core diff --git a/pol-core/pol/module/storagemod.cpp b/pol-core/pol/module/storagemod.cpp index ab5b780bd..114a7a4fb 100644 --- a/pol-core/pol/module/storagemod.cpp +++ b/pol-core/pol/module/storagemod.cpp @@ -7,16 +7,18 @@ #include "storagemod.h" -#include "../../bscript/bobject.h" +#include + #include "../../bscript/berror.h" #include "../../bscript/impstr.h" - +#include "../../clib/clib.h" #include "../globals/uvars.h" +#include "../item/item.h" #include "../realms.h" +#include "../storage.h" #include "../uoexhelp.h" #include "../uoscrobj.h" -#include namespace Pol { @@ -67,7 +69,7 @@ BObjectImp* StorageExecutorModule::mf_FindStorageArea() BObjectImp* StorageExecutorModule::mf_CreateStorageArea() { - String* name = EXPLICIT_CAST(String*, BObjectImp*)( getParamImp( 0, BObjectImp::OTString ) ); + String* name = EXPLICIT_CAST( String*, BObjectImp* )( getParamImp( 0, BObjectImp::OTString ) ); if ( name ) { Core::StorageArea* area = Core::gamestate.storage.create_area( name->value() ); @@ -80,7 +82,7 @@ BObjectImp* StorageExecutorModule::mf_CreateStorageArea() BObjectImp* StorageExecutorModule::mf_FindRootItemInStorageArea() { Core::StorageArea* area = - EXPLICIT_CAST(Core::StorageArea*, void*)( exec.getApplicPtrParam( 0, &storage_area_type ) ); + EXPLICIT_CAST( Core::StorageArea*, void* )( exec.getApplicPtrParam( 0, &storage_area_type ) ); const String* name = getStringParam( 1 ); if ( !area || !name ) @@ -97,7 +99,7 @@ BObjectImp* StorageExecutorModule::mf_FindRootItemInStorageArea() BObjectImp* StorageExecutorModule::mf_DestroyRootItemInStorageArea() { Core::StorageArea* area = - EXPLICIT_CAST(Core::StorageArea*, void*)( getApplicPtrParam( 0, &storage_area_type ) ); + EXPLICIT_CAST( Core::StorageArea*, void* )( getApplicPtrParam( 0, &storage_area_type ) ); const String* name = getStringParam( 1 ); if ( !area || !name ) @@ -110,7 +112,7 @@ BObjectImp* StorageExecutorModule::mf_DestroyRootItemInStorageArea() BObjectImp* StorageExecutorModule::mf_CreateRootItemInStorageArea() { Core::StorageArea* area = - EXPLICIT_CAST(Core::StorageArea*, void*)( getApplicPtrParam( 0, &storage_area_type ) ); + EXPLICIT_CAST( Core::StorageArea*, void* )( getApplicPtrParam( 0, &storage_area_type ) ); const String* name; const Items::ItemDesc* descriptor; diff --git a/pol-core/pol/module/storagemod.h b/pol-core/pol/module/storagemod.h index e5ef0f8c5..987a27827 100644 --- a/pol-core/pol/module/storagemod.h +++ b/pol-core/pol/module/storagemod.h @@ -11,6 +11,16 @@ #define STORAGEEMOD_H #include "../../bscript/execmodl.h" + +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Module diff --git a/pol-core/pol/module/unimod.cpp b/pol-core/pol/module/unimod.cpp index 2ce27fb6d..548f8125a 100644 --- a/pol-core/pol/module/unimod.cpp +++ b/pol-core/pol/module/unimod.cpp @@ -7,35 +7,28 @@ #include "unimod.h" +#include +#include + #include "../../bscript/berror.h" #include "../../bscript/bobject.h" #include "../../bscript/impstr.h" - #include "../../clib/clib_endian.h" #include "../../clib/logfacility.h" -#include "../../clib/stlutil.h" -#include "../../clib/strutil.h" - #include "../accounts/account.h" #include "../item/item.h" #include "../mobile/charactr.h" #include "../network/cgdata.h" #include "../network/client.h" -#include "../network/msghandl.h" #include "../network/packethelper.h" +#include "../network/packets.h" #include "../pktboth.h" -#include "../sockio.h" +#include "../pktdef.h" #include "../ufunc.h" #include "../unicode.h" +#include "../uoexec.h" #include "osmod.h" -#include -#include - -////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// namespace Pol { namespace Core @@ -147,8 +140,9 @@ using namespace Bscript; u16 gwtext[( SPEECH_MAX_LEN + 1 )]; UnicodeExecutorModule::UnicodeExecutorModule( Core::UOExecutor& exec ) - : TmplExecutorModule( "unicode", exec ), - uoexec( exec ), prompt_chr( NULL ) + : TmplExecutorModule( "unicode", exec ), + uoexec( exec ), + prompt_chr( NULL ) { } @@ -171,9 +165,9 @@ BObjectImp* UnicodeExecutorModule::mf_BroadcastUC() unsigned short color; unsigned short requiredCmdLevel; if ( getObjArrayParam( 0, oText ) && getStringParam( 1, lang ) && - getParam( 2, font ) && // todo: getFontParam - getParam( 3, color ) && // todo: getColorParam - getParam( 4, requiredCmdLevel ) ) // todo: getRequiredCmdLevelParam + getParam( 2, font ) && // todo: getFontParam + getParam( 3, color ) && // todo: getColorParam + getParam( 4, requiredCmdLevel ) ) // todo: getRequiredCmdLevelParam { size_t textlen = oText->ref_arr.size(); if ( textlen > SPEECH_MAX_LEN ) @@ -183,7 +177,8 @@ BObjectImp* UnicodeExecutorModule::mf_BroadcastUC() // lang->toUpper(); // Language codes are in upper-case :) if ( !Core::convertArrayToUC( oText, gwtext, textlen ) ) return new BError( "Invalid value in Unicode array." ); - Core::broadcast( gwtext, Clib::strupper( lang->value() ).c_str(), font, color, requiredCmdLevel ); + Core::broadcast( gwtext, Clib::strupper( lang->value() ).c_str(), font, color, + requiredCmdLevel ); return new BLong( 1 ); } else @@ -281,8 +276,8 @@ BObjectImp* UnicodeExecutorModule::mf_RequestInputUC() if ( !uoexec.suspend() ) { DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" - << "\tCall to function Unicode::RequestInputUC():\n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tCall to function Unicode::RequestInputUC():\n" + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } @@ -292,7 +287,7 @@ BObjectImp* UnicodeExecutorModule::mf_RequestInputUC() prompt_chr = chr; Core::send_unicode_prompt( chr->client, ctBEu32( item->serial ) ); - + return new BLong( 0 ); } else diff --git a/pol-core/pol/module/unimod.h b/pol-core/pol/module/unimod.h index b42831c13..6ea225b65 100644 --- a/pol-core/pol/module/unimod.h +++ b/pol-core/pol/module/unimod.h @@ -11,9 +11,32 @@ #include "../../bscript/execmodl.h" #endif +#include "../../clib/rawtypes.h" #include "../pktdef.h" #include "../uoexec.h" #include "../uoexhelp.h" + +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +} // namespace Bscript +namespace Core +{ +class UOExecutor; +class UObject; +} // namespace Core +namespace Items +{ +class Item; +} // namespace Items +namespace Mobile +{ +class Character; +} // namespace Mobile +} // namespace Pol + namespace Pol { namespace Module @@ -27,7 +50,7 @@ public: ~UnicodeExecutorModule(); Core::UOExecutor& uoexec; - + Bscript::BObjectImp* mf_PrintTextAboveUC(); // OverObject, Text, Font, Color Bscript::BObjectImp* mf_PrivateTextAboveUC(); // OverObject, Text, ToChar, Font, Color diff --git a/pol-core/pol/module/uomod.cpp b/pol-core/pol/module/uomod.cpp index d9dc9851d..c9d1e5431 100644 --- a/pol-core/pol/module/uomod.cpp +++ b/pol-core/pol/module/uomod.cpp @@ -73,43 +73,45 @@ #include "uomod.h" +#include +#include +#include +#include +#include + #include "../../bscript/berror.h" #include "../../bscript/bobject.h" +#include "../../bscript/bstruct.h" #include "../../bscript/dict.h" #include "../../bscript/impstr.h" -#include "../../bscript/token.h" - #include "../../clib/cfgelem.h" -#include "../../clib/cfgfile.h" #include "../../clib/clib.h" #include "../../clib/clib_endian.h" +#include "../../clib/compilerspecifics.h" #include "../../clib/esignal.h" #include "../../clib/logfacility.h" #include "../../clib/passert.h" -#include "../../clib/random.h" #include "../../clib/refptr.h" -#include "../../clib/stlutil.h" -#include "../../clib/strutil.h" -#include "../../clib/weakptr.h" - #include "../../plib/mapcell.h" #include "../../plib/mapshape.h" #include "../../plib/maptile.h" #include "../../plib/staticblock.h" +#include "../../plib/stlastar.h" #include "../../plib/systemstate.h" - #include "../action.h" #include "../cfgrepos.h" +#include "../clidata.h" #include "../containr.h" #include "../core.h" #include "../eventid.h" #include "../fnsearch.h" #include "../gameclck.h" #include "../globals/object_storage.h" -#include "../globals/state.h" #include "../globals/uvars.h" #include "../guardrgn.h" +#include "../item/item.h" #include "../item/itemdesc.h" +#include "../layers.h" #include "../lightlvl.h" #include "../listenpt.h" #include "../los.h" @@ -121,47 +123,45 @@ #include "../mobile/ufacing.h" #include "../multi/boat.h" #include "../multi/house.h" +#include "../multi/multi.h" #include "../multi/multidef.h" #include "../network/cgdata.h" #include "../network/client.h" -#include "../network/clienttransmit.h" -#include "../network/packets.h" #include "../network/packethelper.h" +#include "../network/packets.h" +#include "../npctmpl.h" #include "../objtype.h" #include "../pktboth.h" -#include "../pktin.h" +#include "../pktdef.h" #include "../polcfg.h" #include "../polclass.h" +#include "../polclock.h" +#include "../polsig.h" +#include "../profile.h" #include "../realms.h" #include "../realms/realm.h" #include "../resource.h" #include "../savedata.h" +#include "../scrdef.h" #include "../scrsched.h" #include "../scrstore.h" -#include "../skilladv.h" #include "../spells.h" #include "../target.h" +#include "../uconst.h" +#include "../udatfile.h" #include "../ufunc.h" #include "../uimport.h" #include "../umanip.h" #include "../unicode.h" +#include "../uobject.h" #include "../uoexec.h" #include "../uopathnode.h" #include "../uoscrobj.h" -#include "../ustruct.h" #include "../uworld.h" #include "../wthrtype.h" -#include "../zone.h" #include "cfgmod.h" #include "osmod.h" -#include -#include -#include -#include -#include - - namespace Pol { namespace Core @@ -551,11 +551,11 @@ BObjectImp* UOExecutorModule::broadcast() unsigned short color; unsigned short requiredCmdLevel; text = exec.paramAsString( 0 ); - if ( text && getParam( 1, font ) && // todo: getFontParam - getParam( 2, color ) && // todo: getColorParam - getParam(3, requiredCmdLevel)) // todo: getRequiredCmdLevelParam + if ( text && getParam( 1, font ) && // todo: getFontParam + getParam( 2, color ) && // todo: getColorParam + getParam( 3, requiredCmdLevel ) ) // todo: getRequiredCmdLevelParam { - Core::broadcast( text, font, color, requiredCmdLevel); + Core::broadcast( text, font, color, requiredCmdLevel ); return new BLong( 1 ); } else @@ -820,27 +820,29 @@ BObjectImp* UOExecutorModule::mf_Target() crstype = PKTBI_6C::CURSOR_TYPE_HELPFUL; else crstype = PKTBI_6C::CURSOR_TYPE_NEUTRAL; - - if ( !uoexec.suspend() ) { + + if ( !uoexec.suspend() ) + { DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" - << "\tCall to function UO::Target():\n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tCall to function UO::Target():\n" + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } - TargetCursor *tgt_cursor = nullptr; + TargetCursor* tgt_cursor = nullptr; - bool is_los_checked = (target_options & TGTOPT_CHECK_LOS) && !chr->ignores_line_of_sight(); - if ( is_los_checked ) + bool is_los_checked = ( target_options & TGTOPT_CHECK_LOS ) && !chr->ignores_line_of_sight(); + if ( is_los_checked ) { tgt_cursor = &gamestate.target_cursors.los_checked_script_cursor; } - else { + else + { tgt_cursor = &gamestate.target_cursors.nolos_checked_script_cursor; } tgt_cursor->send_object_cursor( chr->client, crstype ); - + chr->client->gd->target_cursor_uoemod = this; target_cursor_chr = chr; @@ -941,10 +943,11 @@ BObjectImp* UOExecutorModule::mf_TargetCoordinates() return new BError( "Client has an active target cursor" ); } - if ( !uoexec.suspend() ) { + if ( !uoexec.suspend() ) + { DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" - << "\tCall to function UO::TargetCoordinates():\n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tCall to function UO::TargetCoordinates():\n" + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } @@ -984,16 +987,17 @@ BObjectImp* UOExecutorModule::mf_TargetMultiPlacement() return new BError( "Object Type is out of range for Multis" ); } - if ( !uoexec.suspend() ) { + if ( !uoexec.suspend() ) + { DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" - << "\tCall to function UO::TargetMultiPlacement():\n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tCall to function UO::TargetMultiPlacement():\n" + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } chr->client->gd->target_cursor_uoemod = this; target_cursor_chr = chr; - + gamestate.target_cursors.multi_placement_cursor.send_placemulti( chr->client, objtype, flags, (s16)xoffset, (s16)yoffset, hue ); @@ -1341,17 +1345,12 @@ BObjectImp* UOExecutorModule::mf_CreateNpcFromTemplate() // characters.push_back( npc.get() ); SetCharacterWorldPosition( npc.get(), Realms::WorldChangeReason::NpcCreate ); - WorldIterator::InVisualRange( npc.get(), [&]( Character* zonechr ) - { - send_char_data( zonechr->client, - npc.get() ); - } ); + WorldIterator::InVisualRange( + npc.get(), [&]( Character* zonechr ) { send_char_data( zonechr->client, npc.get() ); } ); // dave added 2/3/3 send entered area events for npc create - Core::WorldIterator::InRange( x, y, realm, 32, [&]( Character* chr ) - { - NpcPropagateMove( chr, npc.get() ); - } ); + Core::WorldIterator::InRange( + x, y, realm, 32, [&]( Character* chr ) { NpcPropagateMove( chr, npc.get() ); } ); // FIXME: Need to add Walkon checks for multi right here if type is house. if ( dummy_multi ) { @@ -1610,7 +1609,7 @@ BObjectImp* UOExecutorModule::mf_SelectMenuItem() Menu* menu; if ( !getCharacterParam( exec, 0, chr ) || !getStaticOrDynamicMenuParam( 1, menu ) || - (chr->client->gd->menu_selection_uoemod != NULL) ) + ( chr->client->gd->menu_selection_uoemod != NULL ) ) { return new BError( "Invalid parameter" ); } @@ -1624,12 +1623,12 @@ BObjectImp* UOExecutorModule::mf_SelectMenuItem() { return new BError( "Menu too large" ); } - + if ( !uoexec.suspend() ) { DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" - << "\tCall to function UO::SelectMenuItem():\n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tCall to function UO::SelectMenuItem():\n" + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } @@ -2188,15 +2187,13 @@ BObjectImp* UOExecutorModule::mf_ListItemsNearLocation( /* x, y, z, range, realm } std::unique_ptr newarr( new ObjArray ); - WorldIterator::InRange( - x, y, realm, range, [&]( Item* item ) - { - if ( ( abs( item->x - x ) <= range ) && ( abs( item->y - y ) <= range ) ) - { - if ( ( z == LIST_IGNORE_Z ) || ( abs( item->z - z ) < CONST_DEFAULT_ZRANGE ) ) - newarr->addElement( item->make_ref() ); - } - } ); + WorldIterator::InRange( x, y, realm, range, [&]( Item* item ) { + if ( ( abs( item->x - x ) <= range ) && ( abs( item->y - y ) <= range ) ) + { + if ( ( z == LIST_IGNORE_Z ) || ( abs( item->z - z ) < CONST_DEFAULT_ZRANGE ) ) + newarr->addElement( item->make_ref() ); + } + } ); return newarr.release(); } @@ -2250,20 +2247,18 @@ BObjectImp* UOExecutorModule::mf_ListObjectsInBox( /* x1, y1, z1, x2, y2, z2, re internal_InBoxAreaChecks( x1, y1, z1, x2, y2, z2, realm ); std::unique_ptr newarr( new ObjArray ); - WorldIterator::InBox( x1, y1, x2, y2, realm, [&]( Mobile::Character* chr ) - { - if ( chr->z >= z1 && chr->z <= z2 ) - { - newarr->addElement( chr->make_ref() ); - } - } ); - WorldIterator::InBox( x1, y1, x2, y2, realm, [&]( Items::Item* item ) - { - if ( item->z >= z1 && item->z <= z2 ) - { - newarr->addElement( item->make_ref() ); - } - } ); + WorldIterator::InBox( x1, y1, x2, y2, realm, [&]( Mobile::Character* chr ) { + if ( chr->z >= z1 && chr->z <= z2 ) + { + newarr->addElement( chr->make_ref() ); + } + } ); + WorldIterator::InBox( x1, y1, x2, y2, realm, [&]( Items::Item* item ) { + if ( item->z >= z1 && item->z <= z2 ) + { + newarr->addElement( item->make_ref() ); + } + } ); return newarr.release(); } @@ -2299,13 +2294,12 @@ BObjectImp* UOExecutorModule::mf_ListMobilesInBox( /* x1, y1, z1, x2, y2, z2, re internal_InBoxAreaChecks( x1, y1, z1, x2, y2, z2, realm ); std::unique_ptr newarr( new ObjArray ); - WorldIterator::InBox( x1, y1, x2, y2, realm, [&]( Mobile::Character* chr ) - { - if ( chr->z >= z1 && chr->z <= z2 ) - { - newarr->addElement( chr->make_ref() ); - } - } ); + WorldIterator::InBox( x1, y1, x2, y2, realm, [&]( Mobile::Character* chr ) { + if ( chr->z >= z1 && chr->z <= z2 ) + { + newarr->addElement( chr->make_ref() ); + } + } ); return newarr.release(); } @@ -2361,8 +2355,7 @@ BObjectImp* UOExecutorModule::mf_ListMultisInBox( /* x1, y1, z1, x2, y2, z2, rea internal_InBoxAreaChecks( x1range, y1range, z1, x2range, y2range, z2, realm ); // search for multis. this is tricky, since the center might lie outside the box WorldIterator::InBox( - x1range, y1range, x2range, y2range, realm, [&]( Multi::UMulti* multi ) - { + x1range, y1range, x2range, y2range, realm, [&]( Multi::UMulti* multi ) { const Multi::MultiDef& md = multi->multidef(); if ( multi->x + md.minrx > x2 || // east of the box multi->x + md.maxrx < x1 || // west of the box @@ -2508,16 +2501,14 @@ BObjectImp* UOExecutorModule::mf_ListItemsNearLocationOfType( /* x, y, z, range, return new BError( "Invalid Coordinates for realm" ); } - WorldIterator::InRange( - x, y, realm, range, [&]( Items::Item* item ) - { - if ( ( item->objtype_ == objtype ) && ( abs( item->x - x ) <= range ) && - ( abs( item->y - y ) <= range ) ) - { - if ( ( z == LIST_IGNORE_Z ) || ( abs( item->z - z ) < CONST_DEFAULT_ZRANGE ) ) - newarr->addElement( item->make_ref() ); - } - } ); + WorldIterator::InRange( x, y, realm, range, [&]( Items::Item* item ) { + if ( ( item->objtype_ == objtype ) && ( abs( item->x - x ) <= range ) && + ( abs( item->y - y ) <= range ) ) + { + if ( ( z == LIST_IGNORE_Z ) || ( abs( item->z - z ) < CONST_DEFAULT_ZRANGE ) ) + newarr->addElement( item->make_ref() ); + } + } ); return newarr.release(); } @@ -2551,14 +2542,13 @@ BObjectImp* UOExecutorModule::mf_ListItemsAtLocation( /* x, y, z, realm */ ) } std::unique_ptr newarr( new ObjArray ); - WorldIterator::InRange( x, y, realm, 0, [&]( Items::Item* item ) - { - if ( ( item->x == x ) && ( item->y == y ) ) - { - if ( ( z == LIST_IGNORE_Z ) || ( item->z == z ) ) - newarr->addElement( item->make_ref() ); - } - } ); + WorldIterator::InRange( x, y, realm, 0, [&]( Items::Item* item ) { + if ( ( item->x == x ) && ( item->y == y ) ) + { + if ( ( z == LIST_IGNORE_Z ) || ( item->z == z ) ) + newarr->addElement( item->make_ref() ); + } + } ); return newarr.release(); } @@ -2582,14 +2572,12 @@ BObjectImp* UOExecutorModule::mf_ListGhostsNearLocation() return new BError( "Realm not found" ); std::unique_ptr newarr( new ObjArray ); - WorldIterator::InRange( - x, y, realm, range, [&]( Mobile::Character* chr ) - { - if ( chr->dead() && ( abs( chr->z - z ) < CONST_DEFAULT_ZRANGE ) ) - { - newarr->addElement( chr->make_ref() ); - } - } ); + WorldIterator::InRange( x, y, realm, range, [&]( Mobile::Character* chr ) { + if ( chr->dead() && ( abs( chr->z - z ) < CONST_DEFAULT_ZRANGE ) ) + { + newarr->addElement( chr->make_ref() ); + } + } ); return newarr.release(); } @@ -2640,8 +2628,7 @@ BObjectImp* UOExecutorModule::mf_ListMobilesNearLocationEx( /* x, y, z, range, f std::unique_ptr newarr( new ObjArray ); - auto fill_mobs = [&]( Mobile::Character* _chr ) - { + auto fill_mobs = [&]( Mobile::Character* _chr ) { if ( ( inc_hidden && _chr->hidden() ) || ( inc_dead && _chr->dead() ) || ( inc_concealed && _chr->concealed() ) || ( inc_normal && !( _chr->hidden() || _chr->dead() || _chr->concealed() ) ) ) @@ -2699,13 +2686,11 @@ BObjectImp* UOExecutorModule::mf_ListMobilesNearLocation( /* x, y, z, range, rea } std::unique_ptr newarr( new ObjArray ); - WorldIterator::InRange( - x, y, realm, range, [&]( Mobile::Character* chr ) - { - if ( ( !chr->concealed() ) && ( !chr->hidden() ) && ( !chr->dead() ) ) - if ( ( z == LIST_IGNORE_Z ) || ( abs( chr->z - z ) < CONST_DEFAULT_ZRANGE ) ) - newarr->addElement( chr->make_ref() ); - } ); + WorldIterator::InRange( x, y, realm, range, [&]( Mobile::Character* chr ) { + if ( ( !chr->concealed() ) && ( !chr->hidden() ) && ( !chr->dead() ) ) + if ( ( z == LIST_IGNORE_Z ) || ( abs( chr->z - z ) < CONST_DEFAULT_ZRANGE ) ) + newarr->addElement( chr->make_ref() ); + } ); return newarr.release(); } else @@ -2723,8 +2708,7 @@ BObjectImp* UOExecutorModule::mf_ListMobilesInLineOfSight() obj = obj->toplevel_owner(); std::unique_ptr newarr( new ObjArray ); WorldIterator::InRange( obj->x, obj->y, obj->realm, range, - [&]( Mobile::Character* chr ) - { + [&]( Mobile::Character* chr ) { if ( chr->dead() || chr->hidden() || chr->concealed() ) return; if ( chr == obj ) @@ -3075,7 +3059,8 @@ BObjectImp* UOExecutorModule::mf_Resurrect() if ( ~flags & RESURRECT_FORCELOCATION ) { // we want doors to block ghosts in this case. - bool doors_block = !( chr->graphic == UOBJ_GAMEMASTER || chr->cached_settings.get( PRIV_FLAGS::IGNORE_DOORS ) ); + bool doors_block = !( chr->graphic == UOBJ_GAMEMASTER || + chr->cached_settings.get( PRIV_FLAGS::IGNORE_DOORS ) ); short newz; Multi::UMulti* supporting_multi; Item* walkon_item; @@ -4761,18 +4746,16 @@ BObjectImp* UOExecutorModule::mf_ListItemsNearLocationWithFlag( } std::unique_ptr newarr( new ObjArray ); - WorldIterator::InRange( - x, y, realm, range, [&]( Item* item ) + WorldIterator::InRange( x, y, realm, range, [&]( Item* item ) { + if ( ( tile_uoflags( item->graphic ) & flags ) ) + { + if ( ( abs( item->x - x ) <= range ) && ( abs( item->y - y ) <= range ) ) { - if ( ( tile_uoflags( item->graphic ) & flags ) ) - { - if ( ( abs( item->x - x ) <= range ) && ( abs( item->y - y ) <= range ) ) - { - if ( ( z == LIST_IGNORE_Z ) || ( abs( item->z - z ) < CONST_DEFAULT_ZRANGE ) ) - newarr->addElement( new EItemRefObjImp( item ) ); - } - } - } ); + if ( ( z == LIST_IGNORE_Z ) || ( abs( item->z - z ) < CONST_DEFAULT_ZRANGE ) ) + newarr->addElement( new EItemRefObjImp( item ) ); + } + } + } ); return newarr.release(); } @@ -5109,23 +5092,21 @@ BObjectImp* UOExecutorModule::mf_FindPath() { POLLOG.Format( "[FindPath] Calling FindPath({}, {}, {}, {}, {}, {}, {}, 0x{:X}, {})\n" ) << x1 << y1 << z1 << x2 << y2 << z2 << strrealm->data() << flags << theSkirt; - POLLOG.Format( "[FindPath] search for Blockers inside {} {} {} {}\n" ) << xL << yL << xH - << yH; + POLLOG.Format( "[FindPath] search for Blockers inside {} {} {} {}\n" ) + << xL << yL << xH << yH; } AStarBlockers theBlockers( xL, xH, yL, yH ); if ( !( flags & FP_IGNORE_MOBILES ) ) { - WorldIterator::InBox( - xL, yL, xH, yH, realm, [&]( Mobile::Character* chr ) - { - theBlockers.AddBlocker( chr->x, chr->y, chr->z ); + WorldIterator::InBox( xL, yL, xH, yH, realm, [&]( Mobile::Character* chr ) { + theBlockers.AddBlocker( chr->x, chr->y, chr->z ); - if ( Plib::systemstate.config.loglevel >= 12 ) - POLLOG.Format( "[FindPath] add Blocker {} at {} {} {}\n" ) - << chr->name() << chr->x << chr->y << chr->z; - } ); + if ( Plib::systemstate.config.loglevel >= 12 ) + POLLOG.Format( "[FindPath] add Blocker {} at {} {} {}\n" ) + << chr->name() << chr->x << chr->y << chr->z; + } ); } // passed via GetSuccessors to realm->walkheight @@ -5341,18 +5322,18 @@ BObjectImp* UOExecutorModule::mf_UpdateMobile() if ( flags == 1 ) { if ( ( !chr->isa( UOBJ_CLASS::CLASS_NPC ) ) && ( chr->client ) ) // no npc and active client - send_owncreate( chr->client, chr ); // inform self + send_owncreate( chr->client, chr ); // inform self if ( ( chr->isa( UOBJ_CLASS::CLASS_NPC ) ) || ( chr->client ) ) // npc or active client - send_create_mobile_to_nearby_cansee( chr ); // inform other + send_create_mobile_to_nearby_cansee( chr ); // inform other else return new BError( "Mobile is offline" ); } else { if ( ( !chr->isa( UOBJ_CLASS::CLASS_NPC ) ) && ( chr->client ) ) // no npc and active client - send_move( chr->client, chr ); // inform self + send_move( chr->client, chr ); // inform self if ( ( chr->isa( UOBJ_CLASS::CLASS_NPC ) ) || ( chr->client ) ) // npc or active client - send_move_mobile_to_nearby_cansee( chr ); // inform other + send_move_mobile_to_nearby_cansee( chr ); // inform other else return new BError( "Mobile is offline" ); } @@ -5522,8 +5503,7 @@ BObjectImp* UOExecutorModule::mf_GetMidpointCircleCoords( /* xcenter, ycenter, r std::unique_ptr coords( new ObjArray ); std::vector> points; - auto add_point = [&coords]( int x, int y ) - { + auto add_point = [&coords]( int x, int y ) { std::unique_ptr point( new BStruct ); point->addMember( "x", new BLong( x ) ); point->addMember( "y", new BLong( y ) ); @@ -5565,7 +5545,7 @@ BObjectImp* UOExecutorModule::mf_GetMidpointCircleCoords( /* xcenter, ycenter, r return coords.release(); } -} // namespace Module +} // namespace Module namespace Bscript { diff --git a/pol-core/pol/module/uomod.h b/pol-core/pol/module/uomod.h index a24d07cda..b4845dcfa 100644 --- a/pol-core/pol/module/uomod.h +++ b/pol-core/pol/module/uomod.h @@ -31,8 +31,18 @@ #define H_UOMOD_H #include "../../bscript/execmodl.h" -#include "../reftypes.h" +#include "../../clib/rawtypes.h" #include "../poltype.h" +#include "../reftypes.h" + +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class ObjArray; +} // namespace Bscript +} // namespace Pol namespace Pol { @@ -43,9 +53,9 @@ class Realm; namespace Core { class Menu; -class UObject; class UContainer; class UOExecutor; +class UObject; } namespace Mobile { @@ -61,7 +71,6 @@ class UBoat; } namespace Module { - class UOExecutorModule : public Bscript::TmplExecutorModule { public: diff --git a/pol-core/pol/module/uomod2.cpp b/pol-core/pol/module/uomod2.cpp index 17fcc52ef..a48ace6e0 100644 --- a/pol-core/pol/module/uomod2.cpp +++ b/pol-core/pol/module/uomod2.cpp @@ -36,80 +36,74 @@ #include "pol_global_config.h" #endif -#include "uomod.h" -#include "osmod.h" -#include "../uoexec.h" +#include +#include +#include - -#ifdef MEMORYLEAK -#include "../../bscript/bobject.h" -#endif #include "../../bscript/berror.h" +#include "../../bscript/bobject.h" +#include "../../bscript/bstruct.h" +#include "../../bscript/eprog.h" #include "../../bscript/executor.h" #include "../../bscript/impstr.h" - +#include "../../clib/clib.h" #include "../../clib/clib_endian.h" -#include "../../clib/fdump.h" +#include "../../clib/compilerspecifics.h" #include "../../clib/logfacility.h" -#include "../../clib/fileutil.h" +#include "../../clib/passert.h" +#include "../../clib/rawtypes.h" +#include "../../clib/refptr.h" +#include "../../plib/pkg.h" +#include "../../plib/systemstate.h" +#include "../accounts/account.h" +#include "../accounts/accounts.h" +#include "../accounts/acscrobj.h" +#include "../containr.h" +#include "../core.h" +#include "../exscrobj.h" +#include "../globals/memoryusage.h" +#include "../globals/script_internals.h" +#include "../globals/state.h" +#include "../globals/uvars.h" +#include "../item/item.h" +#include "../item/itemdesc.h" +#include "../layers.h" +#include "../mobile/charactr.h" +#include "../mobile/npc.h" +#include "../multi/customhouses.h" +#include "../multi/house.h" +#include "../multi/multi.h" +#include "../multi/multidef.h" +#include "../network/cgdata.h" +#include "../network/client.h" +#include "../network/packethelper.h" +#include "../network/packetinterface.h" +#include "../network/packets.h" +#include "../objtype.h" +#include "../pktboth.h" +#include "../pktdef.h" +#include "../pktin.h" +#include "../polclass.h" +#include "../profile.h" +#include "../realms/realm.h" +#include "../reftypes.h" +#include "../scrstore.h" +#include "../sngclick.h" +#include "../statmsg.h" +#include "../tooltips.h" +#include "../uconst.h" +#include "../ufunc.h" +#include "../uobject.h" +#include "../uoexec.h" +#include "../uoscrobj.h" +#include "../uworld.h" +#include "osmod.h" +#include "uomod.h" #ifdef MEMORYLEAK #include "../../clib/opnew.h" #endif -#include "../../clib/strutil.h" -#include "../../clib/clib_MD5.h" -#include "../../clib/stlutil.h" - -#include "../realms/realm.h" - -#include "../../plib/pkg.h" -#include "../../plib/systemstate.h" - -#include "../accounts/account.h" -#include "../accounts/accounts.h" -#include "../accounts/acscrobj.h" -#include "../cfgrepos.h" -#include "../containr.h" -#include "../core.h" -#include "../exscrobj.h" -#include "../fnsearch.h" -#include "../globals/memoryusage.h" -#include "../globals/object_storage.h" -#include "../globals/state.h" -#include "../globals/uvars.h" -#include "../item/itemdesc.h" -#include "../menu.h" -#include "../mobile/charactr.h" -#include "../mobile/npc.h" -#include "../multi/house.h" -#include "../multi/multidef.h" -#include "../network/cgdata.h" -#include "../network/client.h" -#include "../network/clienttransmit.h" -#include "../network/iostats.h" -#include "../network/msghandl.h" -#include "../network/packets.h" -#include "../network/packethelper.h" -#include "../objtype.h" -#include "../pktboth.h" -#include "../pktin.h" -#include "../pktout.h" -#include "../polcfg.h" -#include "../polclass.h" -#include "../polstats.h" -#include "../realms.h" -#include "../scrsched.h" -#include "../scrstore.h" -#include "../sngclick.h" -#include "../sockio.h" -#include "../statmsg.h" -#include "../syshook.h" -#include "../tooltips.h" -#include "../ufunc.h" -#include "../uoscrobj.h" -#include "../uworld.h" -#include "../unicode.h" #ifdef USE_SYSTEM_ZLIB #include @@ -1102,10 +1096,11 @@ BObjectImp* UOExecutorModule::internal_SendUnCompressedGumpMenu( Character* chr, msg->offset = 1; msg->WriteFlipped( len ); - if ( !uoexec.suspend() ) { + if ( !uoexec.suspend() ) + { DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" - << "\tCall to function UO::SendDialogGump():\n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tCall to function UO::SendDialogGump():\n" + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } @@ -1229,10 +1224,11 @@ BObjectImp* UOExecutorModule::internal_SendCompressedGumpMenu( Character* chr, O msg->offset = 1; msg->WriteFlipped( len ); - if ( !uoexec.suspend() ) { + if ( !uoexec.suspend() ) + { DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" - << "\tCall to function UO::SendDialogGump():\n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tCall to function UO::SendDialogGump():\n" + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } @@ -1264,13 +1260,9 @@ private: BIntHash& operator=( const BIntHash& ); }; -BIntHash::BIntHash() : BObjectImp( OTUnknown ), contents_() -{ -} +BIntHash::BIntHash() : BObjectImp( OTUnknown ), contents_() {} -BIntHash::BIntHash( const BIntHash& ih ) : BObjectImp( OTUnknown ), contents_( ih.contents_ ) -{ -} +BIntHash::BIntHash( const BIntHash& ih ) : BObjectImp( OTUnknown ), contents_( ih.contents_ ) {} BObjectImp* BIntHash::copy() const { @@ -1613,14 +1605,15 @@ BObjectImp* UOExecutorModule::mf_SendTextEntryGump() u16 len = msg->offset; msg->offset = 1; msg->WriteFlipped( len ); - - if ( !uoexec.suspend() ) { + + if ( !uoexec.suspend() ) + { DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" - << "\tCall to function UO::SendTextEntryGump():\n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tCall to function UO::SendTextEntryGump():\n" + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } - + msg.Send( chr->client, len ); chr->client->gd->textentry_uoemod = this; textentry_chr = chr; @@ -1683,9 +1676,7 @@ private: PolCore& operator=( const PolCore& ); }; -PolCore::PolCore() : BObjectImp( OTPolCoreRef ) -{ -} +PolCore::PolCore() : BObjectImp( OTPolCoreRef ) {} BObjectImp* PolCore::copy() const { @@ -1744,7 +1735,7 @@ BObjectImp* GetRunningScriptList() BObjectImp* GetAllScriptList() { ObjArray* arr = new ObjArray; - + const ExecList& runlist = scriptScheduler.getRunlist(); const ExecList& ranlist = scriptScheduler.getRanlist(); const HoldList& holdlist = scriptScheduler.getHoldlist(); @@ -1893,7 +1884,7 @@ BObjectImp* GetCoreVariable( const char* corevar ) LONG_COREVAR( sysload_severity, stateManager.profilevars.last_sysload_nprocs ); // LONG_COREVAR( bytes_sent, polstats.bytes_sent ); // LONG_COREVAR( bytes_received, polstats.bytes_received ); - LONG_COREVAR( version, POL_VERSION_MAJOR ); + LONG_COREVAR( version, POL_VERSION ); LONG_COREVAR( systime, time( NULL ) ); LONG_COREVAR( events_per_min, GET_PROFILEVAR_PER_MIN( events ) ); LONG_COREVAR( skill_checks_per_min, GET_PROFILEVAR_PER_MIN( skill_checks ) ); @@ -2137,13 +2128,14 @@ BObjectImp* UOExecutorModule::mf_SendInstaResDialog() if ( chr->client->gd->resurrect_uoemod != NULL ) return new BError( "Client busy with another instares dialog" ); - if ( !uoexec.suspend() ) { + if ( !uoexec.suspend() ) + { DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" - << "\tCall to function UO::SendInstaResDialog():\n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tCall to function UO::SendInstaResDialog():\n" + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } - + PktHelper::PacketOut msg; msg->Write( RESURRECT_CHOICE_SELECT ); msg.Send( chr->client ); @@ -2200,16 +2192,17 @@ BObjectImp* UOExecutorModule::mf_SelectColor() msg->Write( item->serial_ext ); msg->offset += 2; // u16 unk msg->WriteFlipped( item->graphic ); - - if ( !uoexec.suspend() ) { + + if ( !uoexec.suspend() ) + { DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" - << "\tCall to function UO::SelectColor():\n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tCall to function UO::SelectColor():\n" + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } msg.Send( chr->client ); - + chr->client->gd->selcolor_uoemod = this; selcolor_chr = chr; return new BLong( 0 ); @@ -2352,8 +2345,8 @@ void read_book_page_handler( Client* client, PKTBI_66* msg ) Item* book = find_legal_item( client->chr, book_serial ); if ( book == NULL ) { - POLLOG.Format( "Unable to find book 0x{:X} for character 0x{:X}\n" ) << book_serial - << client->chr->serial; + POLLOG.Format( "Unable to find book 0x{:X} for character 0x{:X}\n" ) + << book_serial << client->chr->serial; return; } @@ -2469,8 +2462,8 @@ void open_book_handler( Client* client, PKTBI_93* msg ) Item* book = find_legal_item( client->chr, book_serial ); if ( book == NULL ) { - POLLOG.Format( "Unable to find book 0x{:X} for character 0x{:X}\n" ) << book_serial - << client->chr->serial; + POLLOG.Format( "Unable to find book 0x{:X} for character 0x{:X}\n" ) + << book_serial << client->chr->serial; return; } BObjectImpRefVec params; @@ -2765,7 +2758,8 @@ BObjectImp* UOExecutorModule::mf_SendPopUpMenu() msg.Send( chr->client, len ); // Cancel any previously waiting popup response - if ( chr->client->gd->popup_menu_selection_uoemod != NULL ) { + if ( chr->client->gd->popup_menu_selection_uoemod != NULL ) + { chr->client->gd->popup_menu_selection_uoemod->uoexec.os_module->revive(); chr->client->gd->popup_menu_selection_uoemod = NULL; @@ -2773,13 +2767,14 @@ BObjectImp* UOExecutorModule::mf_SendPopUpMenu() } // Suspend the script first - if ( !uoexec.suspend() ) { + if ( !uoexec.suspend() ) + { DEBUGLOG << "Script Error in '" << scriptname() << "' PC=" << exec.PC << ": \n" - << "\tCall to function UO::SendPopupMenu():\n" - << "\tThe execution of this script can't be blocked!\n"; + << "\tCall to function UO::SendPopupMenu():\n" + << "\tThe execution of this script can't be blocked!\n"; return new Bscript::BError( "Script can't be blocked" ); } - + // Prepare to restart the script once the response arrives chr->on_popup_menu_selection = popup_menu_selection_made; chr->client->gd->popup_menu_selection_uoemod = this; diff --git a/pol-core/pol/module/uomod3.cpp b/pol-core/pol/module/uomod3.cpp index e7c208098..de6cf964d 100644 --- a/pol-core/pol/module/uomod3.cpp +++ b/pol-core/pol/module/uomod3.cpp @@ -5,20 +5,13 @@ * - 2005/09/30 Shinigami: added Player Check to mf_SendStatus (crashed on NPCs) */ -#include "uomod.h" - #include "../../bscript/berror.h" -#include "../../bscript/impstr.h" - -#include "../mobile/attribute.h" #include "../mobile/charactr.h" -#include "../network/cliface.h" -#include "../skills.h" #include "../statmsg.h" #include "../uoexhelp.h" +#include "uomod.h" + -// f'ed packing: -#include "../vital.h" namespace Pol { namespace Module diff --git a/pol-core/pol/module/uomod4.cpp b/pol-core/pol/module/uomod4.cpp index 9a95d59ec..7d70ac415 100644 --- a/pol-core/pol/module/uomod4.cpp +++ b/pol-core/pol/module/uomod4.cpp @@ -11,24 +11,29 @@ Handles moving objects within a realm and from realm to realm. */ -#include "uomod.h" - -#include "../core.h" -#include "../exscrobj.h" -#include "../polclass.h" -#include "../realms.h" -#include "../ufunc.h" -#include "../uoscrobj.h" -#include "../uworld.h" -#include "../containr.h" -#include "../uoexhelp.h" +#include +#include #include "../../bscript/berror.h" -#include "../../bscript/executor.h" +#include "../../bscript/bobject.h" #include "../../bscript/impstr.h" - -#include "../../clib/strutil.h" -#include "../../clib/stlutil.h" +#include "../../clib/rawtypes.h" +#include "../containr.h" +#include "../core.h" +#include "../item/item.h" +#include "../mobile/charactr.h" +#include "../multi/boat.h" +#include "../polclass.h" +#include "../poltype.h" +#include "../realms.h" +#include "../realms/realm.h" +#include "../reftypes.h" +#include "../uconst.h" +#include "../ufunc.h" +#include "../uobject.h" +#include "../uoexhelp.h" +#include "../uworld.h" +#include "uomod.h" namespace Pol { @@ -100,11 +105,9 @@ BObjectImp* UOExecutorModule::internal_MoveCharacter( Character* chr, xcoord x, { // Realm and X Y Z change. // 8-26-05 Austin // Notify NPCs in the old realm that the player left the realm. - WorldIterator::InRange( chr->lastx, chr->lasty, oldrealm, 32, - [&]( Character* zonechr ) - { - NpcPropagateLeftArea( zonechr, chr ); - } ); + WorldIterator::InRange( + chr->lastx, chr->lasty, oldrealm, 32, + [&]( Character* zonechr ) { NpcPropagateLeftArea( zonechr, chr ); } ); send_remove_character_to_nearby( chr ); if ( chr->client != NULL ) diff --git a/pol-core/pol/module/utilmod.cpp b/pol-core/pol/module/utilmod.cpp index b20810382..9406ccd7c 100644 --- a/pol-core/pol/module/utilmod.cpp +++ b/pol-core/pol/module/utilmod.cpp @@ -9,18 +9,14 @@ #include "utilmod.h" -#include "../dice.h" +#include +#include #include "../../bscript/berror.h" -#include "../../bscript/executor.h" #include "../../bscript/impstr.h" - #include "../../clib/clib.h" #include "../../clib/random.h" -#include "../../clib/rawtypes.h" - -#include -#include +#include "../dice.h" namespace Pol { diff --git a/pol-core/pol/module/utilmod.h b/pol-core/pol/module/utilmod.h index 03f93e511..f3f81c9a8 100644 --- a/pol-core/pol/module/utilmod.h +++ b/pol-core/pol/module/utilmod.h @@ -10,6 +10,15 @@ #include "../../bscript/execmodl.h" +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Module diff --git a/pol-core/pol/module/vitalmod.cpp b/pol-core/pol/module/vitalmod.cpp index 0c871f77d..a0185f570 100644 --- a/pol-core/pol/module/vitalmod.cpp +++ b/pol-core/pol/module/vitalmod.cpp @@ -13,20 +13,15 @@ #include "../../bscript/berror.h" #include "../../bscript/bobject.h" #include "../../bscript/impstr.h" - #include "../cmbtcfg.h" #include "../globals/settings.h" #include "../mobile/attribute.h" #include "../mobile/charactr.h" -#include "../network/cliface.h" #include "../spells.h" -#include "../statmsg.h" #include "../ufunc.h" #include "../uoexhelp.h" #include "../vital.h" -#include - namespace Pol { namespace Bscript diff --git a/pol-core/pol/module/vitalmod.h b/pol-core/pol/module/vitalmod.h index 07095ec8e..7b17f9654 100644 --- a/pol-core/pol/module/vitalmod.h +++ b/pol-core/pol/module/vitalmod.h @@ -9,9 +9,24 @@ #ifndef VITALEMOD_H #define VITALEMOD_H +#include + #include "../../bscript/execmodl.h" #include "uomod.h" +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +namespace Module +{ +class UOExecutorModule; +} // namespace Module +} // namespace Pol + namespace Pol { namespace Mobile diff --git a/pol-core/pol/movecost.cpp b/pol-core/pol/movecost.cpp index 9dd01b658..a8106bc94 100644 --- a/pol-core/pol/movecost.cpp +++ b/pol-core/pol/movecost.cpp @@ -8,18 +8,19 @@ #include "movecost.h" -#include "mobile/charactr.h" - -#include "globals/settings.h" +#include +#include #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/fileutil.h" +#include "../clib/logfacility.h" #include "../clib/stlutil.h" #include "../clib/strutil.h" -#include "../clib/logfacility.h" - #include "../plib/systemstate.h" +#include "dynproperties.h" +#include "globals/settings.h" +#include "mobile/charactr.h" namespace Pol { @@ -166,4 +167,4 @@ void load_movecost( bool reload ) sizeof settingsManager.movecost_running ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/movecost.h b/pol-core/pol/movecost.h index a6de3cd0a..ad3db486a 100644 --- a/pol-core/pol/movecost.h +++ b/pol-core/pol/movecost.h @@ -7,6 +7,7 @@ #ifndef MOVECOST_H #define MOVECOST_H + namespace Pol { namespace Mobile diff --git a/pol-core/pol/movement.cpp b/pol-core/pol/movement.cpp index 75fc745bf..2f8508bdf 100644 --- a/pol-core/pol/movement.cpp +++ b/pol-core/pol/movement.cpp @@ -7,29 +7,23 @@ */ -#include "mobile/charactr.h" +#include +#include "../clib/rawtypes.h" +#include "mobile/charactr.h" #include "multi/customhouses.h" #include "multi/house.h" #include "multi/multi.h" - #include "network/client.h" -#include "network/msghandl.h" -#include "network/packets.h" -#include "network/packethelper.h" #include "network/packetdefs.h" -#include "network/clienttransmit.h" - +#include "network/packethelper.h" +#include "network/packets.h" +#include "pktdef.h" #include "pktin.h" -#include "pktout.h" -#include "pktboth.h" -#include "globals/uvars.h" +#include "uconst.h" #include "ufunc.h" #include "uworld.h" -#include - - namespace Pol { namespace Core @@ -71,19 +65,13 @@ void send_objects_newly_inrange( Network::Client* client ) { Mobile::Character* chr = client->chr; - WorldIterator::InVisualRange( chr, [&]( Mobile::Character* zonechr ) - { - send_char_if_newly_inrange( zonechr, client ); - } ); - WorldIterator::InVisualRange( chr, [&]( Items::Item* zoneitem ) - { - send_item_if_newly_inrange( zoneitem, client ); - } ); - WorldIterator::InRange( chr->x, chr->y, chr->realm, RANGE_VISUAL_LARGE_BUILDINGS, - [&]( Multi::UMulti* zonemulti ) - { - send_multi_if_newly_inrange( zonemulti, client ); - } ); + WorldIterator::InVisualRange( + chr, [&]( Mobile::Character* zonechr ) { send_char_if_newly_inrange( zonechr, client ); } ); + WorldIterator::InVisualRange( + chr, [&]( Items::Item* zoneitem ) { send_item_if_newly_inrange( zoneitem, client ); } ); + WorldIterator::InRange( + chr->x, chr->y, chr->realm, RANGE_VISUAL_LARGE_BUILDINGS, + [&]( Multi::UMulti* zonemulti ) { send_multi_if_newly_inrange( zonemulti, client ); } ); } void send_objects_newly_inrange_on_boat( Network::Client* client, u32 serial ) @@ -92,31 +80,26 @@ void send_objects_newly_inrange_on_boat( Network::Client* client, u32 serial ) if ( client->ClientType & Network::CLIENTTYPE_7090 ) { - WorldIterator::InVisualRange( chr, [&]( Mobile::Character* zonechr ) - { - Multi::UMulti* multi = - zonechr->realm->find_supporting_multi( - zonechr->x, zonechr->y, zonechr->z ); + WorldIterator::InVisualRange( chr, [&]( Mobile::Character* zonechr ) { + Multi::UMulti* multi = + zonechr->realm->find_supporting_multi( zonechr->x, zonechr->y, zonechr->z ); - if ( multi != NULL && multi->serial == serial ) - return; + if ( multi != NULL && multi->serial == serial ) + return; - send_char_if_newly_inrange( zonechr, client ); - } ); - WorldIterator::InVisualRange( chr, [&]( Items::Item* zoneitem ) - { - Multi::UMulti* multi = - zoneitem->realm->find_supporting_multi( - zoneitem->x, zoneitem->y, zoneitem->z ); + send_char_if_newly_inrange( zonechr, client ); + } ); + WorldIterator::InVisualRange( chr, [&]( Items::Item* zoneitem ) { + Multi::UMulti* multi = + zoneitem->realm->find_supporting_multi( zoneitem->x, zoneitem->y, zoneitem->z ); - if ( multi != NULL && multi->serial == serial ) - return; + if ( multi != NULL && multi->serial == serial ) + return; - send_item_if_newly_inrange( zoneitem, client ); - } ); + send_item_if_newly_inrange( zoneitem, client ); + } ); WorldIterator::InRange( chr->x, chr->y, chr->realm, RANGE_VISUAL_LARGE_BUILDINGS, - [&]( Multi::UMulti* zonemulti ) - { + [&]( Multi::UMulti* zonemulti ) { if ( zonemulti->serial == serial ) return; @@ -125,19 +108,13 @@ void send_objects_newly_inrange_on_boat( Network::Client* client, u32 serial ) } else { - WorldIterator::InVisualRange( chr, [&]( Mobile::Character* zonechr ) - { - send_char_if_newly_inrange( zonechr, client ); - } ); - WorldIterator::InVisualRange( chr, [&]( Items::Item* zoneitem ) - { - send_item_if_newly_inrange( zoneitem, client ); - } ); - WorldIterator::InRange( chr->x, chr->y, chr->realm, RANGE_VISUAL_LARGE_BUILDINGS, - [&]( Multi::UMulti* zonemulti ) - { - send_multi_if_newly_inrange( zonemulti, client ); - } ); + WorldIterator::InVisualRange( + chr, [&]( Mobile::Character* zonechr ) { send_char_if_newly_inrange( zonechr, client ); } ); + WorldIterator::InVisualRange( + chr, [&]( Items::Item* zoneitem ) { send_item_if_newly_inrange( zoneitem, client ); } ); + WorldIterator::InRange( + chr->x, chr->y, chr->realm, RANGE_VISUAL_LARGE_BUILDINGS, + [&]( Multi::UMulti* zonemulti ) { send_multi_if_newly_inrange( zonemulti, client ); } ); } } @@ -146,20 +123,14 @@ void remove_objects_inrange( Network::Client* client ) Mobile::Character* chr = client->chr; Network::RemoveObjectPkt msgremove( chr->serial_ext ); - WorldIterator::InVisualRange( chr, [&]( Mobile::Character* zonechar ) - { - send_remove_character( client, zonechar, - msgremove ); - } ); - WorldIterator::InVisualRange( chr, [&]( Items::Item* item ) - { - send_remove_object( client, item, msgremove ); - } ); - WorldIterator::InRange( chr->x, chr->y, chr->realm, RANGE_VISUAL_LARGE_BUILDINGS, - [&]( Multi::UMulti* multi ) - { - send_remove_object( client, multi, msgremove ); - } ); + WorldIterator::InVisualRange( chr, [&]( Mobile::Character* zonechar ) { + send_remove_character( client, zonechar, msgremove ); + } ); + WorldIterator::InVisualRange( + chr, [&]( Items::Item* item ) { send_remove_object( client, item, msgremove ); } ); + WorldIterator::InRange( + chr->x, chr->y, chr->realm, RANGE_VISUAL_LARGE_BUILDINGS, + [&]( Multi::UMulti* multi ) { send_remove_object( client, multi, msgremove ); } ); } diff --git a/pol-core/pol/multi/boat.cpp b/pol-core/pol/multi/boat.cpp index 645c482e2..30ae01ae6 100644 --- a/pol-core/pol/multi/boat.cpp +++ b/pol-core/pol/multi/boat.cpp @@ -17,54 +17,47 @@ #include "boat.h" -#include "boatcomp.h" -#include "multidef.h" + +#include +#include #include "../../bscript/berror.h" - #include "../../clib/cfgelem.h" #include "../../clib/cfgfile.h" #include "../../clib/clib_endian.h" +#include "../../clib/logfacility.h" #include "../../clib/passert.h" #include "../../clib/stlutil.h" -#include "../../clib/strutil.h" -#include "../../clib/logfacility.h" #include "../../clib/streamsaver.h" - #include "../../plib/systemstate.h" - -#include "../mobile/charactr.h" -#include "../network/client.h" -#include "../network/packets.h" -#include "../network/packethelper.h" -#include "../network/clienttransmit.h" -#include "../core.h" +#include "../containr.h" +#include "../extobj.h" #include "../fnsearch.h" +#include "../globals/object_storage.h" +#include "../globals/settings.h" +#include "../globals/uvars.h" +#include "../item/item.h" #include "../item/itemdesc.h" #include "../mdelta.h" #include "../mkscrobj.h" -#include "../objtype.h" -#include "../pktout.h" -#include "../realms.h" +#include "../mobile/charactr.h" +#include "../network/client.h" +#include "../network/packethelper.h" +#include "../network/packets.h" +#include "../pktdef.h" +#include "../polvar.h" #include "../realms/realm.h" #include "../scrsched.h" #include "../tiles.h" -#include "../tooltips.h" -#include "../ufunc.h" #include "../uconst.h" -#include "../ustruct.h" -#include "../globals/uvars.h" -#include "../globals/object_storage.h" +#include "../ufunc.h" +#include "../uobject.h" #include "../uworld.h" -#include "../containr.h" +#include "boatcomp.h" +#include "multi.h" +#include "multidef.h" -#include -#include -#include -#include -#include - namespace Pol { namespace Multi @@ -147,9 +140,7 @@ BoatShape::ComponentShape::ComponentShape( const std::string& str, const std::st } -BoatShape::BoatShape() -{ -} +BoatShape::BoatShape() {} BoatShape::BoatShape( Clib::ConfigElem& elem ) { std::string tmp_str; @@ -352,8 +343,7 @@ void UBoat::send_smooth_move_to_inrange( Core::UFACING move_dir, u8 speed, u16 n bool relative ) { Core::WorldIterator::InRange( - newx, newy, realm, RANGE_VISUAL_LARGE_BUILDINGS, [&]( Mobile::Character* zonechr ) - { + newx, newy, realm, RANGE_VISUAL_LARGE_BUILDINGS, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( inrange( client->chr, this ) && @@ -525,8 +515,7 @@ void UBoat::send_boat_newly_inrange( Network::Client* client ) void UBoat::send_display_boat_to_inrange( u16 oldx, u16 oldy ) { Core::WorldIterator::InRange( - x, y, realm, RANGE_VISUAL_LARGE_BUILDINGS, [&]( Mobile::Character* zonechr ) - { + x, y, realm, RANGE_VISUAL_LARGE_BUILDINGS, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( client->ClientType & Network::CLIENTTYPE_7090 ) @@ -538,8 +527,7 @@ void UBoat::send_display_boat_to_inrange( u16 oldx, u16 oldy ) } ); Core::WorldIterator::InRange( - oldx, oldy, this->realm, RANGE_VISUAL_LARGE_BUILDINGS, [&]( Mobile::Character* zonechr ) - { + oldx, oldy, this->realm, RANGE_VISUAL_LARGE_BUILDINGS, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( !inrange( client->chr, this ) ) // send remove to chrs only seeing the old loc @@ -845,8 +833,7 @@ void UBoat::move_travellers( Core::UFACING move_dir, const BoatContext& oldlocat } Core::WorldIterator::InRange( - item->x, item->y, realm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) - { + item->x, item->y, realm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( !( client->ClientType & Network::CLIENTTYPE_7090 ) ) @@ -854,8 +841,7 @@ void UBoat::move_travellers( Core::UFACING move_dir, const BoatContext& oldlocat } ); Core::WorldIterator::InRange( - oldx, oldy, oldrealm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) - { + oldx, oldy, oldrealm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( !inrange( client->chr, @@ -999,8 +985,7 @@ void UBoat::turn_travellers( RELATIVE_DIR dir, const BoatContext& oldlocation ) MoveItemWorldPosition( oldx, oldy, item, NULL ); Core::WorldIterator::InRange( - item->x, item->y, realm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) - { + item->x, item->y, realm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( !( client->ClientType & Network::CLIENTTYPE_7090 ) ) @@ -1008,8 +993,7 @@ void UBoat::turn_travellers( RELATIVE_DIR dir, const BoatContext& oldlocation ) } ); Core::WorldIterator::InRange( - oldx, oldy, realm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) - { + oldx, oldy, realm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( !inrange( client->chr, @@ -1274,8 +1258,7 @@ bool UBoat::move( Core::UFACING dir, u8 speed, bool relative ) move_components( realm ); Core::WorldIterator::InRange( - x, y, realm, RANGE_VISUAL_LARGE_BUILDINGS, [&]( Mobile::Character* zonechr ) - { + x, y, realm, RANGE_VISUAL_LARGE_BUILDINGS, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( client->ClientType & Network::CLIENTTYPE_7090 ) @@ -1295,8 +1278,7 @@ bool UBoat::move( Core::UFACING dir, u8 speed, bool relative ) } ); Core::WorldIterator::InRange( - oldx, oldy, realm, RANGE_VISUAL_LARGE_BUILDINGS, [&]( Mobile::Character* zonechr ) - { + oldx, oldy, realm, RANGE_VISUAL_LARGE_BUILDINGS, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( !inrange( client->chr, this ) ) // send remove to chrs only seeing the old loc @@ -1390,8 +1372,7 @@ void UBoat::transform_components( const BoatShape& old_boatshape, Realms::Realm* MoveItemWorldPosition( oldx, oldy, item, oldrealm ); Core::WorldIterator::InRange( - item->x, item->y, realm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) - { + item->x, item->y, realm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( !( client->ClientType & Network::CLIENTTYPE_7090 ) ) @@ -1399,8 +1380,7 @@ void UBoat::transform_components( const BoatShape& old_boatshape, Realms::Realm* } ); Core::WorldIterator::InRange( - oldx, oldy, oldrealm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) - { + oldx, oldy, oldrealm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( !inrange( client->chr, @@ -1418,8 +1398,7 @@ void UBoat::move_components( Realms::Realm* oldrealm ) auto end = Components.end(); auto itr2 = bshape.Componentshapes.begin(); auto end2 = bshape.Componentshapes.end(); - for ( ; itr != end && itr2 != end2; - ++itr, ++itr2 ) + for ( ; itr != end && itr2 != end2; ++itr, ++itr2 ) { Items::Item* item = itr->get(); if ( item != NULL ) @@ -1454,8 +1433,7 @@ void UBoat::move_components( Realms::Realm* oldrealm ) MoveItemWorldPosition( oldx, oldy, item, oldrealm ); Core::WorldIterator::InRange( - item->x, item->y, realm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) - { + item->x, item->y, realm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( !( client->ClientType & Network::CLIENTTYPE_7090 ) ) @@ -1463,8 +1441,7 @@ void UBoat::move_components( Realms::Realm* oldrealm ) } ); Core::WorldIterator::InRange( - oldx, oldy, oldrealm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) - { + oldx, oldy, oldrealm, RANGE_VISUAL, [&]( Mobile::Character* zonechr ) { Network::Client* client = zonechr->client; if ( !inrange( client->chr, @@ -1595,7 +1572,7 @@ void UBoat::readProperties( Clib::ConfigElem& elem ) { if ( BoatShape::objtype_is_component( item->objtype_ ) ) { - Components.push_back( Component(item) ); + Components.push_back( Component( item ) ); } else if ( on_ship( bc, item ) ) { @@ -1621,7 +1598,7 @@ void UBoat::readProperties( Clib::ConfigElem& elem ) { if ( BoatShape::objtype_is_component( item->objtype_ ) ) { - Components.push_back( Component(item) ); + Components.push_back( Component( item ) ); } } } @@ -1671,15 +1648,15 @@ Bscript::BObjectImp* UBoat::scripted_create( const Items::ItemDesc& descriptor, const MultiDef* md = MultiDefByMultiID( multiid ); if ( md == NULL ) { - return new Bscript::BError( "Multi definition not found for Boat, objtype=" + - Clib::hexint( descriptor.objtype ) + ", multiid=" + - Clib::hexint( multiid ) ); + return new Bscript::BError( + "Multi definition not found for Boat, objtype=" + Clib::hexint( descriptor.objtype ) + + ", multiid=" + Clib::hexint( multiid ) ); } if ( !Core::gamestate.boatshapes.count( descriptor.multiid ) ) { - return new Bscript::BError( "No boatshape for Boat in boats.cfg, objtype=" + - Clib::hexint( descriptor.objtype ) + ", multiid=" + - Clib::hexint( multiid ) ); + return new Bscript::BError( + "No boatshape for Boat in boats.cfg, objtype=" + Clib::hexint( descriptor.objtype ) + + ", multiid=" + Clib::hexint( multiid ) ); } if ( !navigable( *md, x, y, z, realm ) ) @@ -1744,7 +1721,7 @@ void UBoat::create_components() component->realm = realm; add_item_to_world( component ); update_item_to_inrange( component ); - Components.push_back( Component(component) ); + Components.push_back( Component( component ) ); } } @@ -1842,10 +1819,8 @@ Bscript::BObjectImp* destroy_boat( UBoat* boat ) boat->unregself(); Core::WorldIterator::InVisualRange( - boat, [&]( Mobile::Character* zonechr ) - { - Core::send_remove_object( zonechr->client, boat ); - } ); + boat, + [&]( Mobile::Character* zonechr ) { Core::send_remove_object( zonechr->client, boat ); } ); remove_multi_from_world( boat ); boat->destroy(); return new Bscript::BLong( 1 ); diff --git a/pol-core/pol/multi/boat.h b/pol-core/pol/multi/boat.h index 3a1d3d46b..b67aa5945 100644 --- a/pol-core/pol/multi/boat.h +++ b/pol-core/pol/multi/boat.h @@ -10,13 +10,48 @@ #ifndef BOAT_H #define BOAT_H -#include "multi.h" +#include +#include +#include +#include + +#include "../../bscript/bobject.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" #include "../poltype.h" #include "../reftypes.h" #include "../uconst.h" +#include "multi.h" -#include -#include +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +namespace Clib +{ +class ConfigElem; +class StreamWriter; +} // namespace Clib +namespace Core +{ +class UObject; +} // namespace Core +namespace Items +{ +class Item; +class ItemDesc; +} // namespace Items +namespace Mobile +{ +class Character; +} // namespace Mobile +namespace Network +{ +class Client; +} // namespace Network +} // namespace Pol namespace Pol { @@ -154,7 +189,8 @@ protected: void turn_travellers( RELATIVE_DIR dir, const BoatContext& oldlocation ); void turn_traveller_coords( Mobile::Character* chr, RELATIVE_DIR dir ); static bool on_ship( const BoatContext& bc, const Core::UObject* obj ); - void move_offline_mobiles( Core::xcoord new_x, Core::ycoord new_y, Core::zcoord new_z, Realms::Realm* new_realm ); + void move_offline_mobiles( Core::xcoord new_x, Core::ycoord new_y, Core::zcoord new_z, + Realms::Realm* new_realm ); const MultiDef& multi_ifturn( RELATIVE_DIR dir ); unsigned short multiid_ifturn( RELATIVE_DIR dir ); diff --git a/pol-core/pol/multi/boatcomp.cpp b/pol-core/pol/multi/boatcomp.cpp index 080b4815f..8d5872657 100644 --- a/pol-core/pol/multi/boatcomp.cpp +++ b/pol-core/pol/multi/boatcomp.cpp @@ -8,11 +8,15 @@ #include "boatcomp.h" +#include "../baseobject.h" +#include "../lockable.h" + namespace Pol { namespace Multi { -UPlank::UPlank( const Items::ItemDesc& descriptor ) : Core::ULockable( descriptor, Core::UOBJ_CLASS::CLASS_ITEM ) +UPlank::UPlank( const Items::ItemDesc& descriptor ) + : Core::ULockable( descriptor, Core::UOBJ_CLASS::CLASS_ITEM ) { } diff --git a/pol-core/pol/multi/boatcomp.h b/pol-core/pol/multi/boatcomp.h index 43670db40..ae57d695c 100644 --- a/pol-core/pol/multi/boatcomp.h +++ b/pol-core/pol/multi/boatcomp.h @@ -9,8 +9,25 @@ #ifndef BOATCOMP_H #define BOATCOMP_H -#include "boat.h" +#include "../../bscript/bobject.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" +#include "../../clib/refptr.h" +#include "../item/item.h" #include "../lockable.h" +#include "boat.h" + +namespace Pol +{ +namespace Items +{ +class ItemDesc; +} // namespace Items +namespace Multi +{ +class UBoat; +} // namespace Multi +} // namespace Pol namespace Pol { diff --git a/pol-core/pol/multi/customhousehelp.cpp b/pol-core/pol/multi/customhousehelp.cpp index f9ff56fde..3b972556d 100644 --- a/pol-core/pol/multi/customhousehelp.cpp +++ b/pol-core/pol/multi/customhousehelp.cpp @@ -6,8 +6,10 @@ */ -#include "customhouses.h" +#include "../../clib/rawtypes.h" #include "../../plib/systemstate.h" +#include "customhouses.h" + namespace Pol { namespace Multi @@ -192,9 +194,7 @@ CustomHouseElements::CustomHouseElements( u32 _height, u32 _width, s32 xoffset, SetWidth( _width ); SetHeight( _height ); } -CustomHouseElements::~CustomHouseElements() -{ -} +CustomHouseElements::~CustomHouseElements() {} void CustomHouseElements::SetHeight( u32 _height ) { diff --git a/pol-core/pol/multi/customhouses.cpp b/pol-core/pol/multi/customhouses.cpp index 335050054..c620365fb 100644 --- a/pol-core/pol/multi/customhouses.cpp +++ b/pol-core/pol/multi/customhouses.cpp @@ -21,13 +21,42 @@ #include "customhouses.h" +#include +#include +#include +#include + +#include "../../bscript/bstruct.h" #include "../../clib/cfgelem.h" #include "../../clib/clib_endian.h" -#include "../../clib/stlutil.h" #include "../../clib/logfacility.h" +#include "../../clib/passert.h" +#include "../../clib/stlutil.h" #include "../../clib/streamsaver.h" - #include "../../plib/systemstate.h" +#include "../clidata.h" +#include "../core.h" +#include "../globals/uvars.h" +#include "../item/item.h" +#include "../item/itemdesc.h" +#include "../mkscrobj.h" +#include "../mobile/charactr.h" +#include "../network/cgdata.h" +#include "../network/client.h" +#include "../network/packethelper.h" +#include "../network/packets.h" +#include "../pktboth.h" +#include "../pktout.h" +#include "../pktoutid.h" +#include "../realms/realm.h" +#include "../scrdef.h" +#include "../scrsched.h" +#include "../syshook.h" +#include "../ufunc.h" +#include "../uoscrobj.h" +#include "../uworld.h" +#include "house.h" +#include "multidef.h" #ifdef USE_SYSTEM_ZLIB #include @@ -35,32 +64,6 @@ #include "../../../lib/zlib/zlib.h" #endif -#include "../item/itemdesc.h" -#include "../mobile/charactr.h" -#include "../network/cgdata.h" -#include "../network/client.h" -#include "../network/packets.h" -#include "../network/packethelper.h" -#include "../network/clienttransmit.h" -#include "../core.h" -#include "../globals/uvars.h" -#include "house.h" -#include "multi.h" -#include "multidef.h" -#include "../fnsearch.h" -#include "../polcfg.h" -#include "../pktboth.h" -#include "../ufunc.h" -#include "../ustruct.h" -#include "../uworld.h" -#include "../syshook.h" -#include "../mkscrobj.h" -#include "../scrsched.h" -#include "../clidata.h" -#include "../uoscrobj.h" - -#include -#include namespace Pol { @@ -100,9 +103,7 @@ CustomHouseDesign::CustomHouseDesign( u32 _height, u32 _width, s32 xoffset, s32 InitDesign( _height, _width, xoffset, yoffset ); } -CustomHouseDesign::~CustomHouseDesign() -{ -} +CustomHouseDesign::~CustomHouseDesign() {} size_t CustomHouseDesign::estimatedSize() const { @@ -1045,10 +1046,8 @@ void CustomHousesSendFull( UHouse* house, Network::Client* client, int design ) void CustomHousesSendFullToInRange( UHouse* house, int design, int range ) { Core::WorldIterator::InRange( - house->x, house->y, house->realm, range, [&]( Mobile::Character* chr ) - { - CustomHousesSendFull( house, chr->client, design ); - } ); + house->x, house->y, house->realm, range, + [&]( Mobile::Character* chr ) { CustomHousesSendFull( house, chr->client, design ); } ); } void CustomHousesSendShort( UHouse* house, Network::Client* client ) diff --git a/pol-core/pol/multi/customhouses.h b/pol-core/pol/multi/customhouses.h index a13b3c632..5486a14c3 100644 --- a/pol-core/pol/multi/customhouses.h +++ b/pol-core/pol/multi/customhouses.h @@ -8,13 +8,13 @@ #ifndef _CUSTOMHOUSES_H #define _CUSTOMHOUSES_H -#include "../../clib/rawtypes.h" - -#include -#include -#include #include // for size_t #include // for testprint() +#include +#include +#include + +#include "../../clib/rawtypes.h" namespace Pol { diff --git a/pol-core/pol/multi/house.cpp b/pol-core/pol/multi/house.cpp index 98a293b85..ab72a7d79 100644 --- a/pol-core/pol/multi/house.cpp +++ b/pol-core/pol/multi/house.cpp @@ -12,47 +12,48 @@ * - 2012/02/02 Tomi: Added boat member MBR_MULTIID */ -#include - #include "house.h" -#include "multidef.h" +#include +#include + +#include #include "../../bscript/berror.h" #include "../../bscript/executor.h" #include "../../bscript/objmembers.h" #include "../../bscript/objmethods.h" - #include "../../clib/cfgelem.h" #include "../../clib/clib_endian.h" #include "../../clib/logfacility.h" #include "../../clib/passert.h" -#include "../../clib/stlutil.h" -#include "../../clib/strutil.h" +#include "../../clib/refptr.h" #include "../../clib/streamsaver.h" - #include "../../plib/mapcell.h" #include "../../plib/mapshape.h" #include "../../plib/systemstate.h" - -#include "../network/cgdata.h" #include "../core.h" #include "../fnsearch.h" +#include "../globals/object_storage.h" #include "../item/itemdesc.h" -#include "../objtype.h" -#include "../polcfg.h" -#include "../realms.h" +#include "../mobile/charactr.h" +#include "../module/osmod.h" +#include "../module/uomod.h" +#include "../network/cgdata.h" +#include "../network/client.h" #include "../realms/realm.h" +#include "../scrdef.h" #include "../scrsched.h" #include "../scrstore.h" -#include "../tiles.h" +#include "../uconst.h" #include "../ufunc.h" +#include "../uobject.h" #include "../uoexec.h" -#include "../module/uomod.h" -#include "../module/osmod.h" +#include "../uoexhelp.h" #include "../uoscrobj.h" -#include "../ustruct.h" -#include "../globals/object_storage.h" #include "../uworld.h" +#include "customhouses.h" +#include "multi.h" +#include "multidef.h" namespace Pol @@ -66,15 +67,13 @@ void UHouse::list_contents( const UHouse* house, ItemList& items_in, MobileList& short x2 = house->x + md.maxrx, y2 = house->y + md.maxry; Core::WorldIterator::InBox( - x1, y1, x2, y2, house->realm, [&]( Mobile::Character* chr ) - { + x1, y1, x2, y2, house->realm, [&]( Mobile::Character* chr ) { UMulti* multi = house->realm->find_supporting_multi( chr->x, chr->y, chr->z ); if ( const_cast( multi ) == house ) chrs_in.push_back( chr ); } ); Core::WorldIterator::InBox( - x1, y1, x2, y2, house->realm, [&]( Items::Item* item ) - { + x1, y1, x2, y2, house->realm, [&]( Items::Item* item ) { UMulti* multi = house->realm->find_supporting_multi( item->x, item->y, item->z ); if ( const_cast( multi ) == house ) { @@ -562,8 +561,8 @@ void UHouse::destroy_components() { Items::Item* item = components_.back().get(); if ( Plib::systemstate.config.loglevel >= 5 ) - POLLOG.Format( "Destroying component 0x{:X}, serial=0x{:X}\n" ) << item->objtype_ - << item->serial; + POLLOG.Format( "Destroying component 0x{:X}, serial=0x{:X}\n" ) + << item->objtype_ << item->serial; if ( !item->orphan() ) Core::destroy_item( item ); if ( Plib::systemstate.config.loglevel >= 5 ) @@ -737,8 +736,7 @@ bool objects_exist_in( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short wxL, wyL, wxH, wyH; Core::zone_convert_clip( x1, y1, realm, &wxL, &wyL ); Core::zone_convert_clip( x2, y2, realm, &wxH, &wyH ); - auto includes = [&]( const Core::UObject* obj ) - { + auto includes = [&]( const Core::UObject* obj ) { if ( obj->x >= x1 && obj->x <= x2 && obj->y >= y1 && obj->y <= y2 ) { return true; @@ -801,9 +799,9 @@ Bscript::BObjectImp* UHouse::scripted_create( const Items::ItemDesc& descriptor, const MultiDef* md = MultiDefByMultiID( descriptor.multiid ); if ( md == NULL ) { - return new Bscript::BError( "Multi definition not found for House, objtype=" + - Clib::hexint( descriptor.objtype ) + ", multiid=" + - Clib::hexint( descriptor.multiid ) ); + return new Bscript::BError( + "Multi definition not found for House, objtype=" + Clib::hexint( descriptor.objtype ) + + ", multiid=" + Clib::hexint( descriptor.multiid ) ); } if ( ( !realm->valid( x + md->minrx, y + md->minry, z + md->minrz ) ) || diff --git a/pol-core/pol/multi/house.h b/pol-core/pol/multi/house.h index 9a597994c..8d2e761c0 100644 --- a/pol-core/pol/multi/house.h +++ b/pol-core/pol/multi/house.h @@ -8,13 +8,51 @@ #ifndef _HOUSE_H #define _HOUSE_H -#include "customhouses.h" -#include "multi.h" -#include "../reftypes.h" - #include #include +#include "../../bscript/bobject.h" +#include "../../clib/compilerspecifics.h" +#include "../../clib/rawtypes.h" +#include "../item/item.h" +#include "../reftypes.h" +#include "../udatfile.h" +#include "customhouses.h" +#include "multi.h" + +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +namespace Clib +{ +class ConfigElem; +class StreamWriter; +} // namespace Clib +namespace Core +{ +class UObject; +} // namespace Core +namespace Items +{ +class ItemDesc; +} // namespace Items +namespace Mobile +{ +class Character; +} // namespace Mobile +namespace Plib +{ +class MapShapeList; +} // namespace Plib +namespace Realms +{ +class Realm; +} // namespace Realms +} // namespace Pol + namespace Pol { namespace Multi @@ -82,8 +120,10 @@ protected: virtual Bscript::BObjectImp* get_script_member_id( const int id ) const POL_OVERRIDE; /// id test virtual bool script_isa( unsigned isatype ) const POL_OVERRIDE; virtual class UHouse* as_house() POL_OVERRIDE; - virtual bool readshapes( Plib::MapShapeList& vec, short shape_x, short shape_y, short zbase ) POL_OVERRIDE; - virtual bool readobjects( Core::StaticList& vec, short obj_x, short obj_y, short zbase ) POL_OVERRIDE; + virtual bool readshapes( Plib::MapShapeList& vec, short shape_x, short shape_y, + short zbase ) POL_OVERRIDE; + virtual bool readobjects( Core::StaticList& vec, short obj_x, short obj_y, + short zbase ) POL_OVERRIDE; Bscript::ObjArray* component_list() const; Bscript::ObjArray* items_list() const; Bscript::ObjArray* mobiles_list() const; diff --git a/pol-core/pol/multi/multi.h b/pol-core/pol/multi/multi.h index ecb7390de..a813213b6 100644 --- a/pol-core/pol/multi/multi.h +++ b/pol-core/pol/multi/multi.h @@ -32,7 +32,7 @@ class BStruct; } namespace Plib { - class MapShapeList; +class MapShapeList; } namespace Realms { diff --git a/pol-core/pol/multi/multicfg.cpp b/pol-core/pol/multi/multicfg.cpp index 7b09a3d59..bc7af2194 100644 --- a/pol-core/pol/multi/multicfg.cpp +++ b/pol-core/pol/multi/multicfg.cpp @@ -5,13 +5,14 @@ */ -#include "../cfgrepos.h" - -#include "../../plib/pkg.h" -#include "../../plib/systemstate.h" +#include #include "../../clib/cfgfile.h" #include "../../clib/fileutil.h" +#include "../../clib/refptr.h" +#include "../../plib/pkg.h" +#include "../../plib/systemstate.h" +#include "../cfgrepos.h" namespace Pol { diff --git a/pol-core/pol/multi/multicr.cpp b/pol-core/pol/multi/multicr.cpp index eae73f775..b2b7c96cb 100644 --- a/pol-core/pol/multi/multicr.cpp +++ b/pol-core/pol/multi/multicr.cpp @@ -5,20 +5,19 @@ * Changes for multi related source file relocation */ -#include "boat.h" -#include "house.h" -#include "../item/itemdesc.h" -#include "../objtype.h" -#include "../ufunc.h" -#include "../uworld.h" -#include "../uoscrobj.h" -#include "../globals/object_storage.h" +#include #include "../../bscript/berror.h" - #include "../../clib/clib_endian.h" -#include "../../clib/strutil.h" #include "../../clib/logfacility.h" +#include "../../clib/rawtypes.h" +#include "../globals/object_storage.h" +#include "../item/itemdesc.h" +#include "../ufunc.h" +#include "boat.h" +#include "house.h" +#include "multi.h" + namespace Pol { @@ -81,4 +80,4 @@ Bscript::BObjectImp* UMulti::scripted_create( const Items::ItemDesc& descriptor, return new Bscript::BError( "Don't know what kind of multi to make" ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/multi/multidef.cpp b/pol-core/pol/multi/multidef.cpp index 2f1acc276..f70449b75 100644 --- a/pol-core/pol/multi/multidef.cpp +++ b/pol-core/pol/multi/multidef.cpp @@ -8,26 +8,16 @@ #include "multidef.h" -#include "boat.h" - -#include "../item/itemdesc.h" -#include "../objtype.h" -#include "../ustruct.h" -#include "../globals/uvars.h" -#include "../globals/multidefs.h" - -#include "../../plib/mapcell.h" -#include "../../plib/mapshape.h" -#include "../../plib/systemstate.h" +#include +#include +#include +#include "../../bscript/bstruct.h" #include "../../clib/cfgelem.h" #include "../../clib/cfgfile.h" #include "../../clib/passert.h" -#include "../../clib/stlutil.h" #include "../../clib/strutil.h" - -#include -#include +#include "../globals/multidefs.h" namespace Pol { @@ -103,9 +93,7 @@ MultiDef::MultiDef( Clib::ConfigElem& elem, u16 multiid ) } } -MultiDef::~MultiDef() -{ -} +MultiDef::~MultiDef() {} bool MultiDef::findcomponents( Components::const_iterator& beg, Components::const_iterator& end, short rx, short ry ) const diff --git a/pol-core/pol/multi/multidef.h b/pol-core/pol/multi/multidef.h index 624175fce..b794841c6 100644 --- a/pol-core/pol/multi/multidef.h +++ b/pol-core/pol/multi/multidef.h @@ -18,14 +18,14 @@ // unsigned int is z << 16 | objtype -#include "../udatfile.h" -#include "../../clib/rawtypes.h" - -#include -#include -#include #include #include +#include +#include +#include + +#include "../../clib/rawtypes.h" +#include "../udatfile.h" namespace Pol { diff --git a/pol-core/pol/multi/multidef2.cpp b/pol-core/pol/multi/multidef2.cpp index de1b7927e..59b7a9fb9 100644 --- a/pol-core/pol/multi/multidef2.cpp +++ b/pol-core/pol/multi/multidef2.cpp @@ -7,17 +7,14 @@ */ -#include "multidef.h" - -#include "../item/itemdesc.h" - -#include "../tiles.h" -#include "../objtype.h" -#include "../ustruct.h" - #include "../../plib/mapcell.h" #include "../../plib/mapshape.h" #include "../../plib/systemstate.h" +#include "../clidata.h" +#include "../item/itemdesc.h" +#include "../tiles.h" +#include "../udatfile.h" +#include "multidef.h" namespace Pol { @@ -107,4 +104,4 @@ bool MultiDef::readshapes( Plib::MapShapeList& vec, short x, short y, short zbas return result; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/multi/multis.cpp b/pol-core/pol/multi/multis.cpp index 57a9709e9..1278fc656 100644 --- a/pol-core/pol/multi/multis.cpp +++ b/pol-core/pol/multi/multis.cpp @@ -6,25 +6,20 @@ */ -#include "multi.h" -#include "multidef.h" - -#include "../../clib/passert.h" -#include "../../clib/strutil.h" -#include "../../clib/logfacility.h" +#include +#include "../../bscript/bobject.h" #include "../../bscript/bstruct.h" #include "../../bscript/objmembers.h" - -#include "../item/itemdesc.h" -#include "../objtype.h" +#include "../../clib/logfacility.h" +#include "../../clib/passert.h" +#include "../baseobject.h" #include "../globals/state.h" - -#include "../uobject.h" -#include "../ustruct.h" -#include "../polcfg.h" - -#include +#include "../item/item.h" +#include "../item/itemdesc.h" +#include "../uobjcnt.h" +#include "multi.h" +#include "multidef.h" namespace Pol { @@ -62,13 +57,9 @@ UHouse* UMulti::as_house() return NULL; } -void UMulti::register_object( UObject* /*obj*/ ) -{ -} +void UMulti::register_object( UObject* /*obj*/ ) {} -void UMulti::unregister_object( UObject* /*obj*/ ) -{ -} +void UMulti::unregister_object( UObject* /*obj*/ ) {} const char* UMulti::classname() const { diff --git a/pol-core/pol/musicrgn.cpp b/pol-core/pol/musicrgn.cpp index 3121e5d62..c95e3510a 100644 --- a/pol-core/pol/musicrgn.cpp +++ b/pol-core/pol/musicrgn.cpp @@ -8,7 +8,6 @@ #include "../clib/cfgelem.h" #include "../clib/random.h" - #include "globals/uvars.h" namespace Pol @@ -52,4 +51,4 @@ void read_music_zones() "MusicRegion Region" ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/musicrgn.h b/pol-core/pol/musicrgn.h index 57cf0d8fb..8e93be2fe 100644 --- a/pol-core/pol/musicrgn.h +++ b/pol-core/pol/musicrgn.h @@ -7,11 +7,21 @@ #ifndef MUSICRGN_H #define MUSICRGN_H -#include "region.h" - #include #include +#include "../clib/compilerspecifics.h" +#include "region.h" +#include "zone.h" + +namespace Pol +{ +namespace Clib +{ +class ConfigElem; +} // namespace Clib +} // namespace Pol + namespace Pol { namespace Core diff --git a/pol-core/pol/network/auxclient.cpp b/pol-core/pol/network/auxclient.cpp index e8c000ba3..bcdb1d124 100644 --- a/pol-core/pol/network/auxclient.cpp +++ b/pol-core/pol/network/auxclient.cpp @@ -13,29 +13,29 @@ #include "auxclient.h" +#include + #include "../../bscript/berror.h" +#include "../../bscript/bobject.h" #include "../../bscript/bstruct.h" +#include "../../bscript/executor.h" #include "../../bscript/impstr.h" - #include "../../clib/cfgelem.h" +#include "../../clib/clib.h" #include "../../clib/esignal.h" -#include "../../clib/sckutil.h" -#include "../../clib/stlutil.h" -#include "../../clib/strutil.h" -#include "../../clib/threadhelp.h" #include "../../clib/logfacility.h" - +#include "../../clib/sckutil.h" +#include "../../clib/socketsvc.h" +#include "../../clib/threadhelp.h" +#include "../../clib/wnsckt.h" #include "../../plib/pkg.h" -#include "../polsem.h" -#include "../scrsched.h" -#include "../sockets.h" -#include "../module/uomod.h" -#include "../module/osmod.h" #include "../globals/network.h" - -#include -#include -#include +#include "../module/osmod.h" +#include "../module/uomod.h" +#include "../polsem.h" +#include "../scrdef.h" +#include "../scrsched.h" +#include "../uoexec.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // stricmp deprecation @@ -235,10 +235,7 @@ void AuxClientThread::transmit( const Bscript::BObjectImp* value ) // defer transmit to not block server std::string tmp = _uoexec->auxsvc_assume_string ? value->getStringRep() : value->pack(); ++_transmit_counter; - Core::networkManager.auxthreadpool->push( [tmp, this]() - { - transmit( tmp ); - } ); + Core::networkManager.auxthreadpool->push( [tmp, this]() { transmit( tmp ); } ); } void AuxClientThread::transmit( const std::string& msg ) @@ -287,12 +284,10 @@ void AuxService::run() { Core::PolLock lock; AuxClientThread* client( new AuxClientThread( this, listener ) ); - Core::networkManager.auxthreadpool->push( - [client]() - { - std::unique_ptr _clientptr( client ); - _clientptr->run(); - } ); + Core::networkManager.auxthreadpool->push( [client]() { + std::unique_ptr _clientptr( client ); + _clientptr->run(); + } ); } } } diff --git a/pol-core/pol/network/auxclient.h b/pol-core/pol/network/auxclient.h index 39b569984..feda9fbf1 100644 --- a/pol-core/pol/network/auxclient.h +++ b/pol-core/pol/network/auxclient.h @@ -13,16 +13,34 @@ #include "../../bscript/bobject.h" #endif -#include "../../clib/socketsvc.h" -#include "../../clib/weakptr.h" - -#include "../scrdef.h" -#include "../uoexec.h" - #include #include #include +#include "../../clib/compilerspecifics.h" +#include "../../clib/refptr.h" +#include "../../clib/socketsvc.h" +#include "../../clib/weakptr.h" +#include "../scrdef.h" +#include "../uoexec.h" + +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +namespace Clib +{ +class Socket; +} // namespace Clib +namespace Core +{ +class UOExecutor; +} // namespace Core +} // namespace Pol +struct sockaddr; + namespace Pol { namespace Plib @@ -94,7 +112,7 @@ public: private: bool init(); bool ipAllowed( sockaddr MyPeer ); - void transmit(const std::string& msg); + void transmit( const std::string& msg ); AuxService* _auxservice; ref_ptr _auxconnection; weak_ptr _uoexec; diff --git a/pol-core/pol/network/bannedips.cpp b/pol-core/pol/network/bannedips.cpp index 9eef2084c..4b10a7f50 100644 --- a/pol-core/pol/network/bannedips.cpp +++ b/pol-core/pol/network/bannedips.cpp @@ -6,11 +6,13 @@ #include "bannedips.h" +#include + #include "../../clib/cfgelem.h" #include "../../clib/cfgfile.h" #include "../../clib/fileutil.h" -#include "client.h" #include "../globals/network.h" +#include "client.h" namespace Pol { @@ -75,4 +77,4 @@ void read_bannedips_config( bool initial_load ) } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/network/cgdata.cpp b/pol-core/pol/network/cgdata.cpp index aeebb01fa..22819ac4a 100644 --- a/pol-core/pol/network/cgdata.cpp +++ b/pol-core/pol/network/cgdata.cpp @@ -6,21 +6,19 @@ #include "cgdata.h" -#include "../fnsearch.h" + +#include #include "../containr.h" -#include "../multi/house.h" - - +#include "../fnsearch.h" #include "../mobile/npc.h" - #include "../module/osmod.h" #include "../module/unimod.h" #include "../module/uomod.h" +#include "../multi/customhouses.h" +#include "../multi/house.h" +#include "../multi/multi.h" #include "../uoexec.h" -#include "../unicode.h" - -#include namespace Pol { @@ -174,4 +172,4 @@ size_t ClientGameData::estimatedSize() const return size; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/network/cgdata.h b/pol-core/pol/network/cgdata.h index a9980a668..4a5029572 100644 --- a/pol-core/pol/network/cgdata.h +++ b/pol-core/pol/network/cgdata.h @@ -7,26 +7,26 @@ #ifndef CGDATA_H #define CGDATA_H -#include "../../clib/refptr.h" -#include "../reftypes.h" -#include "../../clib/rawtypes.h" - #include #include +#include "../../clib/rawtypes.h" +#include "../../clib/refptr.h" +#include "../reftypes.h" + namespace Pol { namespace Module { -class UnicodeExecutorModule; class UOExecutorModule; +class UnicodeExecutorModule; } namespace Core { class JusticeRegion; class MusicRegion; -class WeatherRegion; class UContainer; +class WeatherRegion; } namespace Network { diff --git a/pol-core/pol/network/client.cpp b/pol-core/pol/network/client.cpp index c9aefd8c1..6dc488f11 100644 --- a/pol-core/pol/network/client.cpp +++ b/pol-core/pol/network/client.cpp @@ -18,35 +18,35 @@ #include "client.h" -#include "../../clib/fdump.h" -#include "../../clib/logfacility.h" -#include "../../clib/stlutil.h" -#include "../../clib/strutil.h" //CNXBUG +#include +#include +#include #include "../../bscript/berror.h" - +#include "../../bscript/bstruct.h" +#include "../../clib/clib.h" +#include "../../clib/logfacility.h" +#include "../../clib/strutil.h" //CNXBUG +#include "../../clib/wallclock.h" #include "../accounts/account.h" -#include "cgdata.h" -#include "../mobile/charactr.h" -#include "cliface.h" #include "../crypt/cryptbase.h" #include "../crypt/cryptengine.h" -#include "msgfiltr.h" -#include "../polcfg.h" -#include "../polstats.h" -#include "../sockio.h" -#include "../module/unimod.h" -#include "../uoclient.h" -#include "../globals/uvars.h" -#include "../globals/state.h" #include "../globals/network.h" +#include "../globals/state.h" +#include "../mobile/charactr.h" +#include "../pktdef.h" +#include "../pktin.h" +#include "../polsig.h" +#include "../realms/WorldChangeReasons.h" +#include "../ufunc.h" // only in here temporarily, until logout-on-disconnect stuff is removed +#include "../unicode.h" +#include "../uoclient.h" +#include "../uoscrobj.h" #include "../uworld.h" #include "../xbuffer.h" -#include "../uoscrobj.h" -#include "../unicode.h" +#include "cgdata.h" +#include "cliface.h" -// only in here temporarily, until logout-on-disconnect stuff is removed -#include "../ufunc.h" #define PRE_ENCRYPT @@ -129,23 +129,20 @@ Client::Client( ClientInterface& aInterface, Crypt::TCryptInfo& encryption ) void Client::Delete( Client* client ) { - std::lock_guard lock( _SocketMutex ); // TODO: check if this is necessary + std::lock_guard lock( _SocketMutex ); // TODO: check if this is necessary client->PreDelete(); - delete client->cryptengine; // TODO: move this into a unique_ptr<> or at least ~Client() + delete client->cryptengine; // TODO: move this into a unique_ptr<> or at least ~Client() client->cryptengine = NULL; delete client; } -Client::~Client() -{ -} +Client::~Client() {} void Client::unregister() { - auto findClient = std::find( Core::networkManager.clients.begin(), - Core::networkManager.clients.end(), - this ); - Core::networkManager.clients.erase(findClient); // TODO: Make networkManager more OO + auto findClient = + std::find( Core::networkManager.clients.begin(), Core::networkManager.clients.end(), this ); + Core::networkManager.clients.erase( findClient ); // TODO: Make networkManager more OO Interface.deregister_client( this ); } @@ -380,30 +377,43 @@ void Client::setClientType( ClientTypeFlag type ) { case CLIENTTYPE_70331: ClientType |= CLIENTTYPE_70331; + // fall through case CLIENTTYPE_70300: ClientType |= CLIENTTYPE_70300; + // fall through case CLIENTTYPE_70130: ClientType |= CLIENTTYPE_70130; + // fall through case CLIENTTYPE_7090: ClientType |= CLIENTTYPE_7090; + // fall through case CLIENTTYPE_UOSA: ClientType |= CLIENTTYPE_UOSA; + // fall through case CLIENTTYPE_7000: ClientType |= CLIENTTYPE_7000; + // fall through case CLIENTTYPE_UOKR: ClientType |= CLIENTTYPE_UOKR; + // fall through case CLIENTTYPE_60142: ClientType |= CLIENTTYPE_60142; + // fall through case CLIENTTYPE_6017: ClientType |= CLIENTTYPE_6017; + // fall through case CLIENTTYPE_5020: ClientType |= CLIENTTYPE_5020; + // fall through case CLIENTTYPE_5000: ClientType |= CLIENTTYPE_5000; + // fall through case CLIENTTYPE_4070: ClientType |= CLIENTTYPE_4070; + // fall through case CLIENTTYPE_4000: ClientType |= CLIENTTYPE_4000; + // fall through default: break; } @@ -506,8 +516,8 @@ void Client::xmit( const void* data, unsigned short datalen ) if ( sckerr == SOCKET_ERRNO( EWOULDBLOCK ) ) { THREAD_CHECKPOINT( active_client, 205 ); - POLLOG_ERROR.Format( "Client#{}: Switching to queued data mode (1, {} bytes)\n" ) << instance_ - << datalen; + POLLOG_ERROR.Format( "Client#{}: Switching to queued data mode (1, {} bytes)\n" ) + << instance_ << datalen; THREAD_CHECKPOINT( active_client, 206 ); queue_data( data, datalen ); THREAD_CHECKPOINT( active_client, 207 ); diff --git a/pol-core/pol/network/client.h b/pol-core/pol/network/client.h index bf04fad33..d4459c659 100644 --- a/pol-core/pol/network/client.h +++ b/pol-core/pol/network/client.h @@ -22,29 +22,31 @@ #ifndef __CLIENT_H #define __CLIENT_H +#include +#include +#include +#include +#include +#include +#include + #include "../../clib/rawtypes.h" #include "../../clib/spinlock.h" #include "../../clib/wallclock.h" #include "../../clib/weakptr.h" - #include "../crypt/cryptkey.h" +#include "../pktdef.h" #include "../pktin.h" #include "../polclock.h" #include "../sockets.h" - -#include -#include -#include -#include - -#include +#include "../uconst.h" namespace Pol { namespace Bscript { -class BStruct; class BObjectImp; +class BStruct; } namespace Core { @@ -71,14 +73,17 @@ class ClientInterface; const u16 T2A = 0x01; const u16 LBR = 0x02; const u16 AOS = 0x04; -const u16 SE = 0x08; // set AOS-Flag in send_feature_enable() too for needed checks -const u16 ML = 0x10; // set SE- and AOS-Flag in send_feature_enable() too for needed checks -const u16 KR = 0x20; // set KR- and ML- and SE- and AOS-Flag in send_feature_enable() too for needed checks -const u16 SA = 0x40; // set SA- and KR- and SE- and AOS-Flag in send_feature_enable() too for needed checks -const u16 HSA = 0x80; // set HSA- and SA- and KR- and SE- and AOS-Flag in send_feature_enable() too - // for needed checks -const u16 TOL = 0x100; // set TOL- and HSA- and SA- and KR- and SE- and AOS-Flag in send_feature_enable() too - // for needed checks +const u16 SE = 0x08; // set AOS-Flag in send_feature_enable() too for needed checks +const u16 ML = 0x10; // set SE- and AOS-Flag in send_feature_enable() too for needed checks +const u16 KR = + 0x20; // set KR- and ML- and SE- and AOS-Flag in send_feature_enable() too for needed checks +const u16 SA = + 0x40; // set SA- and KR- and SE- and AOS-Flag in send_feature_enable() too for needed checks +const u16 HSA = 0x80; // set HSA- and SA- and KR- and SE- and AOS-Flag in send_feature_enable() too + // for needed checks +const u16 TOL = + 0x100; // set TOL- and HSA- and SA- and KR- and SE- and AOS-Flag in send_feature_enable() too + // for needed checks const u8 FLAG_GENDER = 0x01; const u8 FLAG_RACE = 0x02; @@ -145,7 +150,7 @@ public: bool isReallyConnected() const; bool isConnected() const; - void unregister(); // removes updater for vitals and takes client away from clientlist + void unregister(); // removes updater for vitals and takes client away from clientlist void closeConnection(); void transmit( const void* data, int len, bool needslock = false ); // for entire message or header only @@ -242,6 +247,7 @@ protected: void queue_data( const void* data, unsigned short datalen ); void transmit_encrypted( const void* data, int len ); void xmit( const void* data, unsigned short datalen ); + public: ClientGameData* gd; unsigned int instance_; diff --git a/pol-core/pol/network/clientio.cpp b/pol-core/pol/network/clientio.cpp index 58a4e6872..1a73a53b6 100644 --- a/pol-core/pol/network/clientio.cpp +++ b/pol-core/pol/network/clientio.cpp @@ -5,33 +5,30 @@ */ -#include "client.h" - -#include "iostats.h" -#include "packethooks.h" -#include "packets.h" -#include "packethelper.h" -#include "clienttransmit.h" - -#include "../ctable.h" -#include "../sockio.h" -#include "../sockets.h" - -#define OPT_LOG_CLIENT_DATA 0 - -#include "../config.h" +#include +#include +#include +#include +#include +#include "../../clib/fdump.h" +#include "../../clib/logfacility.h" +#include "../../clib/passert.h" +#include "../../clib/refptr.h" +#include "../../clib/spinlock.h" #include "../crypt/cryptbase.h" -#include "../crypt/cryptengine.h" -#include "../polstats.h" -#include "../globals/ucfg.h" +#include "../ctable.h" +#include "../globals/network.h" #include "../globals/state.h" #include "../packetscrobj.h" - #include "../polsem.h" -#include "../../clib/logfacility.h" -#include "../../clib/fdump.h" -#include "../../clib/passert.h" +#include "../polsig.h" +#include "../sockets.h" +#include "client.h" +#include "clienttransmit.h" +#include "packethelper.h" +#include "packethooks.h" +#include "packets.h" namespace Pol { diff --git a/pol-core/pol/network/clientthread.cpp b/pol-core/pol/network/clientthread.cpp index 2580775bc..0571c938f 100644 --- a/pol-core/pol/network/clientthread.cpp +++ b/pol-core/pol/network/clientthread.cpp @@ -1,39 +1,42 @@ #include "clientthread.h" -#include "client.h" -#include "cgdata.h" // This might not be needed if the client has a clear_gd() method -#include "msgfiltr.h" // Client could also have a method client->is_msg_allowed(), for example. Then this is not needed here. -#include "iostats.h" -#include "msghandl.h" -#include "packethelper.h" - -#include "../../clib/passert.h" - -#include "../accounts/account.h" -#include "../mobile/charactr.h" // This is mostly needed to check for the chr cmdlevel in the timeout, could also make a client->has_cmdlevel()? -#include "../crypt/cryptbase.h" -#include "../crypt/cryptengine.h" - -#include "../checkpnt.h" -#include "../polcfg.h" -#include "../core.h" -#include "../polclock.h" -#include "../polsem.h" -#include "../sockio.h" - -#include "../schedule.h" -#include "../scrsched.h" -#include "../uoscrobj.h" // Needed for running the logoff script -#include "../globals/uvars.h" -#include "../uworld.h" +#include +#include +#include +#include +#include +#include "../../bscript/bobject.h" #include "../../clib/esignal.h" #include "../../clib/fdump.h" #include "../../clib/logfacility.h" -#include "../../clib/stlutil.h" +#include "../../clib/passert.h" #include "../../clib/spinlock.h" - +#include "../../clib/stlutil.h" #include "../../plib/systemstate.h" +#include "../accounts/account.h" +#include "../core.h" +#include "../crypt/cryptbase.h" +#include "../mobile/charactr.h" +#include "../pktboth.h" +#include "../pktbothid.h" +#include "../pktdef.h" +#include "../pktinid.h" +#include "../polcfg.h" +#include "../polclock.h" +#include "../polsem.h" +#include "../schedule.h" +#include "../scrdef.h" +#include "../scrsched.h" +#include "../sockets.h" +#include "../uoscrobj.h" +#include "../uworld.h" +#include "cgdata.h" // This might not be needed if the client has a clear_gd() method +#include "client.h" +#include "msgfiltr.h" // Client could also have a method client->is_msg_allowed(), for example. Then this is not needed here. +#include "msghandl.h" +#include "packethelper.h" +#include "packets.h" #define CLIENT_CHECKPOINT( x ) client->checkpoint = x @@ -50,7 +53,7 @@ void call_chr_scripts( Mobile::Character* chr, const std::string& root_script_ec const std::string& pkg_script_ecl, bool offline = false ); -void report_weird_packet( Network::Client* client, const std::string& why ); // Defined below +void report_weird_packet( Network::Client* client, const std::string& why ); // Defined below bool client_io_thread( Network::Client* client, bool login ) { @@ -93,14 +96,16 @@ bool client_io_thread( Network::Client* client, bool login ) FD_ZERO( &c_send_fd ); checkpoint = 1; - SOCKET clientSocket = client->csocket; - if (clientSocket == INVALID_SOCKET) - break; + SOCKET clientSocket = client->csocket; + if ( clientSocket == INVALID_SOCKET ) + break; - // Non-Winsock implementations require nfds to be the largest socket value + 1 + // Non-Winsock implementations require nfds to be the largest socket value + 1 #ifndef _WIN32 - passert_r(clientSocket < FD_SETSIZE, "Select() implementation in Linux cant handle this many sockets at the same time." ) - nfds = clientSocket + 1; + passert_r( + clientSocket < FD_SETSIZE, + "Select() implementation in Linux cant handle this many sockets at the same time." ) + nfds = clientSocket + 1; #endif FD_SET( clientSocket, &c_recv_fd ); @@ -123,8 +128,7 @@ bool client_io_thread( Network::Client* client, bool login ) c_select_timeout.tv_usec = 0; } CLIENT_CHECKPOINT( 2 ); - res = select( nfds, &c_recv_fd, &c_send_fd, &c_err_fd, - &c_select_timeout ); + res = select( nfds, &c_recv_fd, &c_send_fd, &c_err_fd, &c_select_timeout ); CLIENT_CHECKPOINT( 3 ); } while ( res < 0 && !Clib::exit_signalled && socket_errno == SOCKET_ERRNO( EINTR ) ); checkpoint = 3; @@ -132,8 +136,8 @@ bool client_io_thread( Network::Client* client, bool login ) if ( res < 0 ) { int sckerr = socket_errno; - POLLOG.Format( "Client#{}: select res={}, sckerr={}\n" ) << client->instance_ << res - << sckerr; + POLLOG.Format( "Client#{}: select res={}, sckerr={}\n" ) + << client->instance_ << res << sckerr; break; } else if ( res == 0 ) @@ -304,8 +308,8 @@ bool client_io_thread( Network::Client* client, bool login ) CLIENT_CHECKPOINT( 11 ); PolLock lck; - if ( client->chr ) { - + if ( client->chr ) + { client->chr->disconnect_cleanup(); client->gd->clear(); client->chr->connected( false ); @@ -315,10 +319,10 @@ bool client_io_thread( Network::Client* client, bool login ) { CLIENT_CHECKPOINT( 12 ); Bscript::BObject bobj( - run_script_to_completion( sd, new Module::ECharacterRefObjImp( client->chr ) ) ); + run_script_to_completion( sd, new Module::ECharacterRefObjImp( client->chr ) ) ); if ( bobj.isa( Bscript::BObjectImp::OTLong ) ) { - const Bscript::BLong* blong = static_cast(bobj.impptr()); + const Bscript::BLong* blong = static_cast( bobj.impptr() ); seconds_wait = blong->value(); } } @@ -350,11 +354,9 @@ bool client_io_thread( Network::Client* client, bool login ) Mobile::Character* chr = client->chr; CLIENT_CHECKPOINT( 16 ); call_chr_scripts( chr, "scripts/misc/logoff.ecl", "logoff.ecl" ); - WorldIterator::InRange( chr->x, chr->y, chr->realm, 32, - [&]( Mobile::Character* zonechr ) - { - Mobile::NpcPropagateLeftArea( zonechr, chr ); - } ); + WorldIterator::InRange( + chr->x, chr->y, chr->realm, 32, + [&]( Mobile::Character* zonechr ) { Mobile::NpcPropagateLeftArea( zonechr, chr ); } ); } } } @@ -441,7 +443,7 @@ bool process_data( Network::Client* client ) // MSG is [MSGTYPE] [LENHI] [LENLO] [DATA ... ] client->message_length = ( client->buffer[1] << 8 ) + client->buffer[2]; - if (!valid_message_length(client, client->message_length)) + if ( !valid_message_length( client, client->message_length ) ) { // If the reported length is too short (less than 3 bytes) or // too big (larger than the client buffer), something very odd @@ -506,8 +508,8 @@ bool process_data( Network::Client* client ) try { - INFO_PRINT_TRACE( 10 ) << "Client#" << client->instance_ << ": message 0x" - << fmt::hexu( msgtype ) << "\n"; + INFO_PRINT_TRACE( 10 ) + << "Client#" << client->instance_ << ": message 0x" << fmt::hexu( msgtype ) << "\n"; CLIENT_CHECKPOINT( 26 ); packetHandler.func( client, client->buffer ); CLIENT_CHECKPOINT( 27 ); @@ -682,9 +684,8 @@ void report_weird_packet( Network::Client* client, const std::string& why ) { fmt::Writer tmp; tmp.Format( "Client#{}: {} type 0x{:X}, {} bytes (IP: {}, Account: {})\n" ) - << client->instance_ << why << (int)client->buffer[0] - << client->bytes_received << client->ipaddrAsString() - << ((client->acct != NULL) ? client->acct->name() : "None"); + << client->instance_ << why << (int)client->buffer[0] << client->bytes_received + << client->ipaddrAsString() << ( ( client->acct != NULL ) ? client->acct->name() : "None" ); if ( client->bytes_received <= 64 ) { @@ -707,7 +708,7 @@ void handle_unknown_packet( Network::Client* client ) report_weird_packet( client, "Unknown packet" ); } -// Called when POL receives an undefined packet. +// Called when POL receives an undefined packet. // Those have no registered size, so we must guess. void handle_undefined_packet( Network::Client* client ) { @@ -716,17 +717,17 @@ void handle_undefined_packet( Network::Client* client ) // Tries to read as much of it out as possible client->recv_remaining( sizeof client->buffer / 2 ); - + report_weird_packet( client, "Unexpected message" ); } // Handles variable-sized packets whose declared size is much larger than -// the receive buffer. This packet is most likely a client error, because +// the receive buffer. This packet is most likely a client error, because // the buffer should be big enough to handle anything sent by the known // clients. void handle_humongous_packet( Network::Client* client, unsigned int reported_size ) { - // Tries to read as much of it out as possible + // Tries to read as much of it out as possible // (the client will be disconnected, but this may // be useful for debugging) client->recv_remaining( sizeof client->buffer / 2 ); @@ -735,6 +736,5 @@ void handle_humongous_packet( Network::Client* client, unsigned int reported_siz tmp.Format( "Humongous packet (length {})", reported_size ); report_weird_packet( client, tmp.str() ); } - } } diff --git a/pol-core/pol/network/clientthread.h b/pol-core/pol/network/clientthread.h index 19c7fd4ea..3c538674f 100644 --- a/pol-core/pol/network/clientthread.h +++ b/pol-core/pol/network/clientthread.h @@ -16,7 +16,6 @@ bool check_inactivity( Network::Client* client ); void handle_unknown_packet( Network::Client* client ); void handle_undefined_packet( Network::Client* client ); void handle_humongous_packet( Network::Client* client, unsigned int reported_size ); - } } diff --git a/pol-core/pol/network/clienttransmit.cpp b/pol-core/pol/network/clienttransmit.cpp index b6c800110..f29052c12 100644 --- a/pol-core/pol/network/clienttransmit.cpp +++ b/pol-core/pol/network/clienttransmit.cpp @@ -1,20 +1,18 @@ #include "clienttransmit.h" -#include "client.h" -#include "../globals/network.h" + #include "../../clib/esignal.h" +#include "../../clib/rawtypes.h" +#include "../globals/network.h" #include "../polsem.h" +#include "client.h" namespace Pol { namespace Network { -ClientTransmit::ClientTransmit() : _transmitqueue() -{ -} +ClientTransmit::ClientTransmit() : _transmitqueue() {} -ClientTransmit::~ClientTransmit() -{ -} +ClientTransmit::~ClientTransmit() {} void ClientTransmit::Cancel() { @@ -69,7 +67,8 @@ void ClientTransmitThread() Core::PolLock lock; Client::Delete( data->client.get_weakptr() ); } - else if ( data->disconnects ) { + else if ( data->disconnects ) + { data->client->forceDisconnect(); } else if ( data->client->isReallyConnected() ) diff --git a/pol-core/pol/network/clienttransmit.h b/pol-core/pol/network/clienttransmit.h index 3dc6e87f9..b68c48e8b 100644 --- a/pol-core/pol/network/clienttransmit.h +++ b/pol-core/pol/network/clienttransmit.h @@ -1,16 +1,15 @@ #ifndef CLIENTSEND_H #define CLIENTSEND_H -#include "../../clib/rawtypes.h" -#include "../../clib/message_queue.h" -#include "../../clib/weakptr.h" - #include - #include #include #include +#include "../../clib/message_queue.h" +#include "../../clib/rawtypes.h" +#include "../../clib/weakptr.h" + namespace Pol { namespace Network diff --git a/pol-core/pol/network/cliface.cpp b/pol-core/pol/network/cliface.cpp index 2df20d914..8edd1fe94 100644 --- a/pol-core/pol/network/cliface.cpp +++ b/pol-core/pol/network/cliface.cpp @@ -5,28 +5,28 @@ */ -//#include "../../clib/clib_endian.h" - #include "cliface.h" -#include "client.h" +#include +#include +#include "../../clib/rawtypes.h" +#include "../globals/network.h" +#include "../globals/settings.h" +#include "../globals/state.h" +#include "../globals/uvars.h" #include "../mobile/attribute.h" #include "../mobile/charactr.h" -#include "../network/packets.h" #include "../network/packethelper.h" -#include "../network/clienttransmit.h" - #include "../party.h" -#include "../pktboth.h" #include "../statmsg.h" #include "../ufunc.h" #include "../uoclient.h" #include "../uoskills.h" -#include "../globals/settings.h" -#include "../globals/network.h" -#include "../globals/uvars.h" #include "../vital.h" +#include "client.h" +#include "packets.h" + namespace Pol { namespace Network @@ -40,9 +40,7 @@ ClientVitalUpdaters::ClientVitalUpdaters() : my_vital_changed( NULL ), others_vi { } -ClientAttributeUpdaters::ClientAttributeUpdaters() : my_attr_changed( NULL ), pUOSkill( nullptr ) -{ -} +ClientAttributeUpdaters::ClientAttributeUpdaters() : my_attr_changed( NULL ), pUOSkill( nullptr ) {} void ClientInterface::register_client( Client* client ) { diff --git a/pol-core/pol/network/iostats.cpp b/pol-core/pol/network/iostats.cpp index 14c9debeb..92c3f65dd 100644 --- a/pol-core/pol/network/iostats.cpp +++ b/pol-core/pol/network/iostats.cpp @@ -6,7 +6,7 @@ #include "iostats.h" -#include +#include namespace Pol { @@ -18,4 +18,4 @@ IOStats::IOStats() memset( &received, 0, sizeof received ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/network/msgfiltr.cpp b/pol-core/pol/network/msgfiltr.cpp index 0117012d6..9198ee754 100644 --- a/pol-core/pol/network/msgfiltr.cpp +++ b/pol-core/pol/network/msgfiltr.cpp @@ -11,12 +11,12 @@ #include "msgfiltr.h" -#include "../pktboth.h" -#include "../pktin.h" -#include "../globals/network.h" - #include +#include "../globals/network.h" +#include "../pktbothid.h" +#include "../pktinid.h" + namespace Pol { namespace Core @@ -63,4 +63,4 @@ void MessageTypeFilter::createMessageFilter() new MessageTypeFilter( MessageTypeFilter::NormallyDisabled, no_exceptions ) ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/network/msghandl.cpp b/pol-core/pol/network/msghandl.cpp index dbc14bb85..e8ec39af8 100644 --- a/pol-core/pol/network/msghandl.cpp +++ b/pol-core/pol/network/msghandl.cpp @@ -1,11 +1,17 @@ #include "msghandl.h" -#include "../../clib/passert.h" #include "../../clib/clib_endian.h" #include "../../clib/logfacility.h" -#include "client.h" +#include "../../clib/passert.h" +#include "../../clib/rawtypes.h" #include "../globals/network.h" +#include "../pktboth.h" +#include "../pktbothid.h" +#include "../pktin.h" #include "../pktinid.h" +#include "../pktout.h" +#include "../pktoutid.h" +#include "client.h" namespace Pol { @@ -86,8 +92,8 @@ void PacketRegistry::set_extended_handler( UEXTMSGID submsgtype, { if ( Core::networkManager.ext_handler_table[submsgtype].func ) { - ERROR_PRINT.Format( "Extended Message Handler {} (0x{:X}) multiply defined.\n" ) << submsgtype - << submsgtype; + ERROR_PRINT.Format( "Extended Message Handler {} (0x{:X}) multiply defined.\n" ) + << submsgtype << submsgtype; throw std::runtime_error( "Extended Message Handler multiply defined." ); } Core::networkManager.ext_handler_table[submsgtype].func = func; diff --git a/pol-core/pol/network/msghandl.h b/pol-core/pol/network/msghandl.h index 9c2c08bbb..5817800e2 100644 --- a/pol-core/pol/network/msghandl.h +++ b/pol-core/pol/network/msghandl.h @@ -11,6 +11,7 @@ #include "../pktboth.h" #include "../pktin.h" #include "../pktout.h" + namespace Pol { namespace Network diff --git a/pol-core/pol/network/packetdefs.cpp b/pol-core/pol/network/packetdefs.cpp index fcf769b81..5da9b75bf 100644 --- a/pol-core/pol/network/packetdefs.cpp +++ b/pol-core/pol/network/packetdefs.cpp @@ -1,12 +1,12 @@ #include "packetdefs.h" -#include "../../clib/logfacility.h" - +#include "../../clib/rawtypes.h" #include "../globals/settings.h" -#include "../uobject.h" -#include "../pktdef.h" #include "../mobile/charactr.h" +#include "../pktdef.h" +#include "../uobject.h" +#include "client.h" namespace Pol { @@ -372,9 +372,7 @@ void PlaySoundPkt::build() _p->WriteFlipped( _zcenter ); } -RemoveObjectPkt::RemoveObjectPkt( u32 serial_ext ) : _serial( serial_ext ), _p() -{ -} +RemoveObjectPkt::RemoveObjectPkt( u32 serial_ext ) : _serial( serial_ext ), _p() {} void RemoveObjectPkt::update( u32 serial ) { @@ -866,9 +864,7 @@ void HealthBarStatusUpdate::Send( Client* client ) } -MoveChrPkt::MoveChrPkt( const Mobile::Character* chr ) : PktSender(), _chr( chr ), _p() -{ -} +MoveChrPkt::MoveChrPkt( const Mobile::Character* chr ) : PktSender(), _chr( chr ), _p() {} void MoveChrPkt::build() { diff --git a/pol-core/pol/network/packetdefs.h b/pol-core/pol/network/packetdefs.h index 78765cf6d..4f6928882 100644 --- a/pol-core/pol/network/packetdefs.h +++ b/pol-core/pol/network/packetdefs.h @@ -2,10 +2,11 @@ #ifndef POL_PACKETDEFS_H #define POL_PACKETDEFS_H -#include "packets.h" -#include "packethelper.h" +#include "../../clib/compilerspecifics.h" #include "../../clib/rawtypes.h" #include "../action.h" +#include "packethelper.h" +#include "packets.h" namespace Pol { diff --git a/pol-core/pol/network/packethelper.h b/pol-core/pol/network/packethelper.h index 11fcfff4e..451e83316 100644 --- a/pol-core/pol/network/packethelper.h +++ b/pol-core/pol/network/packethelper.h @@ -1,10 +1,10 @@ #ifndef __PACKETHELPER_H #define __PACKETHELPER_H +#include "../globals/network.h" #include "client.h" #include "clienttransmit.h" #include "packets.h" -#include "../globals/network.h" namespace Pol { @@ -41,7 +41,7 @@ public: // be really really careful with this function // needs PolLock void SendDirect( Client* client, int len = -1 ) const; - T* operator->( void ) const; + T* operator->(void)const; T* Get(); }; @@ -86,7 +86,7 @@ void PacketOut::SendDirect( Client* client, int len ) const } template -T* PacketOut::operator->( void ) const +T* PacketOut::operator->(void)const { return pkt; } diff --git a/pol-core/pol/network/packethooks.cpp b/pol-core/pol/network/packethooks.cpp index 7a867088a..77e4d8044 100644 --- a/pol-core/pol/network/packethooks.cpp +++ b/pol-core/pol/network/packethooks.cpp @@ -19,26 +19,23 @@ #include "packethooks.h" +#include +#include +#include + #include "../../clib/cfgelem.h" -#include "../../clib/cfgfile.h" +#include "../../clib/clib.h" #include "../../clib/clib_endian.h" #include "../../clib/logfacility.h" -#include "../../clib/fileutil.h" +#include "../../clib/rawtypes.h" +#include "../../clib/refptr.h" #include "../../clib/strutil.h" - -#include "../../bscript/bobject.h" -#include "../../bscript/impstr.h" - #include "../../plib/pkg.h" - -#include "../accounts/account.h" -#include "../mobile/charactr.h" - -#include "../packetscrobj.h" -#include "../uoscrobj.h" -#include "../syshook.h" -#include "../polsem.h" #include "../globals/network.h" +#include "../mobile/charactr.h" +#include "../packetscrobj.h" +#include "../syshook.h" +#include "client.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // deprecation warnings for stricmp @@ -462,7 +459,7 @@ PacketHookData::PacketHookData() PacketHookData::~PacketHookData() { - std::map::iterator itr = SubCommands.begin(), end = SubCommands.end(); + std::map::iterator itr = SubCommands.begin(), end = SubCommands.end(); for ( ; itr != end; ++itr ) { delete itr->second; diff --git a/pol-core/pol/network/packethooks.h b/pol-core/pol/network/packethooks.h index c066cbba4..248460761 100644 --- a/pol-core/pol/network/packethooks.h +++ b/pol-core/pol/network/packethooks.h @@ -13,23 +13,25 @@ #ifndef PACKETHOOKS_H #define PACKETHOOKS_H +#include +#include +#include + #include "client.h" #include "msghandl.h" -#include -#include -#include +template +class ref_ptr; namespace Pol { namespace Core { -class ExportedFunction; class BPacket; +class ExportedFunction; } namespace Network { - class PacketHookData { public: diff --git a/pol-core/pol/network/packetinterface.h b/pol-core/pol/network/packetinterface.h index d7f3de4ad..0fa072067 100644 --- a/pol-core/pol/network/packetinterface.h +++ b/pol-core/pol/network/packetinterface.h @@ -2,9 +2,9 @@ #define __PACKETINTERFACE_H #include "../../clib/rawtypes.h" +#include #include #include -#include namespace Pol { diff --git a/pol-core/pol/network/packets.cpp b/pol-core/pol/network/packets.cpp index e5653e307..f599b05ed 100644 --- a/pol-core/pol/network/packets.cpp +++ b/pol-core/pol/network/packets.cpp @@ -9,11 +9,13 @@ #include "packets.h" -#include "packethelper.h" #include "../../clib/rawtypes.h" - -#include +#include "../../clib/spinlock.h" +#include "../pktboth.h" +#include "../pktbothid.h" +#include "packethelper.h" +#include "packetinterface.h" namespace Pol { @@ -159,9 +161,7 @@ size_t PacketsSingleton::estimateSize() const return size; } -PacketQueueSingle::PacketQueueSingle() : _packets(), _lock() -{ -} +PacketQueueSingle::PacketQueueSingle() : _packets(), _lock() {} PacketInterface* PacketQueueSingle::GetNext( u8 id, u16 /*sub*/ ) { // critical start @@ -210,9 +210,7 @@ size_t PacketQueueSingle::estimateSize() const return size; } -PacketQueueSubs::PacketQueueSubs() : _packets(), _lock() -{ -} +PacketQueueSubs::PacketQueueSubs() : _packets(), _lock() {} PacketQueueSubs::~PacketQueueSubs() { Clib::SpinLockGuard lock( _lock ); @@ -513,4 +511,4 @@ PacketInterface* GetPacket( u8 id, u16 sub ) } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/network/packets.h b/pol-core/pol/network/packets.h index b886e9013..f0ab499d7 100644 --- a/pol-core/pol/network/packets.h +++ b/pol-core/pol/network/packets.h @@ -7,7 +7,17 @@ #ifndef POL_PACKETS_H #define POL_PACKETS_H +#include +#include +#include +#include +#include +#include +#include +#include + #include "../../clib/clib_endian.h" +#include "../../clib/compilerspecifics.h" #include "../../clib/logfacility.h" #include "../../clib/passert.h" #include "../../clib/rawtypes.h" @@ -22,16 +32,6 @@ #include "../uconst.h" #include "packetinterface.h" -#include -#include - -#include -#include -#include -#include -#include -#include - #ifdef _MSC_VER #pragma warning( push ) #pragma warning( disable : 4996 ) // disable warning about strncpy @@ -351,7 +351,7 @@ public: // buffer for encrypted Data send with a dummy pktid // NOTE: redefine id if pkt 0x0 ever gets send -#define ENCRYPTEDPKTBUFFER static_cast(0) +#define ENCRYPTEDPKTBUFFER static_cast( 0 ) // Packet defs start typedef PacketWriterDefs::EmptyBufferTemplate EncryptedPktBuffer; @@ -401,7 +401,8 @@ typedef PacketWriterDefs::PacketTemplate PktOut_7C; typedef PacketWriterDefs::PacketTemplate PktOut_82; typedef PacketWriterDefs::PacketTemplate PktOut_88; typedef PacketWriterDefs::PacketTemplate PktOut_89; + 7 + ( 5 * ( Core::NUM_LAYERS + 1 ) ) + 1> + PktOut_89; typedef PacketWriterDefs::PacketTemplate PktOut_8C; typedef PacketWriterDefs::PacketTemplate PktOut_90; typedef PacketWriterDefs::PacketTemplate PktOut_93; @@ -433,39 +434,52 @@ typedef PacketWriterDefs::PacketTemplate PktOut_BA; typedef PacketWriterDefs::PacketTemplate PktOut_BC; typedef PacketWriterDefs::PacketTemplateSub PktOut_BF_Sub4; + 5 + 8> + PktOut_BF_Sub4; typedef PacketWriterDefs::PacketTemplateSub PktOut_BF_Sub6; + 0xFFFF> + PktOut_BF_Sub6; typedef PacketWriterDefs::PacketTemplateSub PktOut_BF_Sub8; + 5 + 1> + PktOut_BF_Sub8; typedef PacketWriterDefs::PacketTemplateSub PktOut_BF_Sub10; -typedef PacketWriterDefs::PacketTemplateSub< - Core::PKTBI_BF_ID, 3, Core::PKTBI_BF::TYPE_DISPLAY_POPUP_MENU, 0xFFFF> PktOut_BF_Sub14; -typedef PacketWriterDefs::PacketTemplateSub PktOut_BF_Sub16; + 5 + 8> + PktOut_BF_Sub10; typedef PacketWriterDefs::PacketTemplateSub PktOut_BF_Sub18; + Core::PKTBI_BF::TYPE_DISPLAY_POPUP_MENU, 0xFFFF> + PktOut_BF_Sub14; +typedef PacketWriterDefs::PacketTemplateSub + PktOut_BF_Sub16; typedef PacketWriterDefs::PacketTemplateSub< - Core::PKTBI_BF_ID, 3, Core::PKTBI_BF::TYPE_EXTENDED_STATS_OUT, 5 + 7> PktOut_BF_Sub19; -typedef PacketWriterDefs::PacketTemplateSub< - Core::PKTBI_BF_ID, 3, Core::PKTBI_BF::TYPE_NEW_SPELLBOOK, 5 + 18> PktOut_BF_Sub1B; -typedef PacketWriterDefs::PacketTemplateSub< - Core::PKTBI_BF_ID, 3, Core::PKTBI_BF::TYPE_CUSTOM_HOUSE_SHORT, 5 + 8> PktOut_BF_Sub1D; -typedef PacketWriterDefs::PacketTemplateSub< - Core::PKTBI_BF_ID, 3, Core::PKTBI_BF::TYPE_ACTIVATE_CUSTOM_HOUSE_TOOL, 5 + 12> PktOut_BF_Sub20; + Core::PKTBI_BF_ID, 3, Core::PKTBI_BF::TYPE_ENABLE_MAP_DIFFS, 5 + 4 + MAX_NUMER_REALMS * 8> + PktOut_BF_Sub18; +typedef PacketWriterDefs::PacketTemplateSub + PktOut_BF_Sub19; +typedef PacketWriterDefs::PacketTemplateSub + PktOut_BF_Sub1B; +typedef PacketWriterDefs::PacketTemplateSub + PktOut_BF_Sub1D; +typedef PacketWriterDefs::PacketTemplateSub + PktOut_BF_Sub20; typedef PacketWriterDefs::PacketTemplateSub PktOut_BF_Sub22; -typedef PacketWriterDefs::PacketTemplateSub< - Core::PKTBI_BF_ID, 3, Core::PKTBI_BF::TYPE_CHARACTER_RACE_CHANGER, 5 + 2> PktOut_BF_Sub2A; + 5 + 6> + PktOut_BF_Sub22; +typedef PacketWriterDefs::PacketTemplateSub + PktOut_BF_Sub2A; typedef PacketWriterDefs::PacketTemplate PktOut_C1; typedef PacketWriterDefs::PacketTemplate PktOut_C2; typedef PacketWriterDefs::PacketTemplate PktOut_C7; -typedef PacketWriterDefs::PacketTemplate PktOut_CC; +typedef PacketWriterDefs::PacketTemplate + PktOut_CC; typedef PacketWriterDefs::PacketTemplate PktOut_D6; typedef PacketWriterDefs::PacketTemplate PktOut_DC; typedef PacketWriterDefs::PacketTemplate PktOut_DD; diff --git a/pol-core/pol/npctemplates.cpp b/pol-core/pol/npctemplates.cpp index 653386d73..8dc353b0c 100644 --- a/pol-core/pol/npctemplates.cpp +++ b/pol-core/pol/npctemplates.cpp @@ -6,22 +6,22 @@ */ -#include "npctmpl.h" +#include +#include +#include +#include +#include #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" +#include "../clib/clib.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" -#include "../clib/stlutil.h" - #include "../plib/pkg.h" #include "../plib/systemstate.h" - #include "globals/uvars.h" +#include "npctmpl.h" -#include -#include -#include #ifdef _MSC_VER #pragma warning( disable : 4996 ) // deprecation warning for stricmp @@ -34,9 +34,7 @@ namespace Core { NpcTemplateConfigSource::NpcTemplateConfigSource( const Clib::ConfigFile& cf ) : _filename( cf.filename() ), _fileline( cf.element_line_start() ){}; -NpcTemplateConfigSource::NpcTemplateConfigSource() : _filename( "" ), _fileline( 0 ) -{ -} +NpcTemplateConfigSource::NpcTemplateConfigSource() : _filename( "" ), _fileline( 0 ) {} size_t NpcTemplateConfigSource::estimateSize() const { return _filename.capacity() + sizeof( unsigned int ); @@ -71,9 +69,7 @@ void NpcTemplateConfigSource::display_error( const std::string& msg, bool /*show } -NpcTemplateElem::NpcTemplateElem() -{ -} +NpcTemplateElem::NpcTemplateElem() {} NpcTemplateElem::NpcTemplateElem( const Clib::ConfigFile& cf, const Clib::ConfigElem& elem ) : _source( cf ), _elem( elem ) { @@ -218,4 +214,4 @@ void read_npc_templates() } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/npctmpl.cpp b/pol-core/pol/npctmpl.cpp index 9bc2445ea..82a32f295 100644 --- a/pol-core/pol/npctmpl.cpp +++ b/pol-core/pol/npctmpl.cpp @@ -7,18 +7,18 @@ #include "npctmpl.h" -#include "item/weapon.h" -#include "item/armor.h" -#include "syshookscript.h" -#include "globals/uvars.h" - -#include "../plib/pkg.h" -#include "../plib/systemstate.h" - +#include +#include "../clib/cfgelem.h" +#include "../clib/cfgfile.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" - -#include +#include "../plib/pkg.h" +#include "../plib/systemstate.h" +#include "globals/uvars.h" +#include "item/armor.h" +#include "item/equipmnt.h" +#include "item/weapon.h" +#include "syshookscript.h" namespace Pol { diff --git a/pol-core/pol/npctmpl.h b/pol-core/pol/npctmpl.h index 0b216ee93..ab59c9876 100644 --- a/pol-core/pol/npctmpl.h +++ b/pol-core/pol/npctmpl.h @@ -8,12 +8,14 @@ #ifndef NPCTMPL_H #define NPCTMPL_H -#include "../clib/cfgfile.h" -#include "../clib/cfgelem.h" - #include +#include #include +#include "../clib/cfgelem.h" +#include "../clib/cfgfile.h" +#include "../clib/compilerspecifics.h" + namespace Pol { namespace Plib @@ -22,8 +24,8 @@ class Package; } namespace Items { -class UWeapon; class UArmor; +class UWeapon; } namespace Core { diff --git a/pol-core/pol/objecthash.cpp b/pol-core/pol/objecthash.cpp index 37b6cf020..744e47e0c 100644 --- a/pol-core/pol/objecthash.cpp +++ b/pol-core/pol/objecthash.cpp @@ -7,21 +7,16 @@ #include "objecthash.h" -#include "accounts/account.h" -#include "mobile/charactr.h" - -#include "polcfg.h" -#include "ufunc.h" -#include "uobject.h" -#include "globals/uvars.h" -#include "globals/state.h" +#include #include "../clib/clib_endian.h" -#include "../clib/passert.h" #include "../clib/logfacility.h" #include "../clib/streamsaver.h" - #include "../plib/systemstate.h" +#include "accounts/account.h" +#include "globals/state.h" +#include "mobile/charactr.h" +#include "ufunc.h" namespace Pol @@ -278,4 +273,4 @@ void ObjectHash::RegisterCleanDeletedSerial( u32 serial ) clean_deleted.insert( serial ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/objecthash.h b/pol-core/pol/objecthash.h index 3a1f7e5e8..4a094f0e5 100644 --- a/pol-core/pol/objecthash.h +++ b/pol-core/pol/objecthash.h @@ -7,11 +7,20 @@ #ifndef __OBJECTHASH_H #define __OBJECTHASH_H -#include "reftypes.h" -#include "../clib/rawtypes.h" - #include #include +#include + +#include "../clib/rawtypes.h" +#include "reftypes.h" + +namespace Pol +{ +namespace Core +{ +class UObject; +} // namespace Core +} // namespace Pol namespace Pol { diff --git a/pol-core/pol/packetscrobj.cpp b/pol-core/pol/packetscrobj.cpp index d6371120e..09e8f33be 100644 --- a/pol-core/pol/packetscrobj.cpp +++ b/pol-core/pol/packetscrobj.cpp @@ -16,28 +16,26 @@ #include "packetscrobj.h" -#include "mobile/charactr.h" -#include "network/client.h" -#include "network/clienttransmit.h" +#include +#include -#include "polsem.h" -#include "realms.h" -#include "uoexhelp.h" -#include "uworld.h" -#include "unicode.h" -#include "globals/network.h" - -#include "../bscript/executor.h" #include "../bscript/berror.h" +#include "../bscript/bobject.h" +#include "../bscript/executor.h" #include "../bscript/impstr.h" #include "../bscript/objmembers.h" #include "../bscript/objmethods.h" - #include "../clib/clib_endian.h" #include "../clib/stlutil.h" -#include "../clib/strutil.h" - -#include +#include "globals/network.h" +#include "mobile/charactr.h" +#include "network/client.h" +#include "network/clienttransmit.h" +#include "realms.h" +#include "realms/realm.h" +#include "unicode.h" +#include "uoexhelp.h" +#include "uworld.h" namespace Pol { @@ -45,9 +43,7 @@ namespace Core { using namespace Bscript; -BPacket::BPacket() : BObjectImp( OTPacket ), is_variable_length( false ) -{ -} +BPacket::BPacket() : BObjectImp( OTPacket ), is_variable_length( false ) {} BPacket::BPacket( const BPacket& copyfrom ) : BObjectImp( OTPacket ), buffer( copyfrom.buffer ), @@ -76,9 +72,7 @@ BPacket::BPacket( const unsigned char* data, unsigned short length, bool variabl { is_variable_length = variable_len; } -BPacket::~BPacket() -{ -} +BPacket::~BPacket() {} BObjectRef BPacket::get_member_id( const int /*id*/ ) // id test { @@ -146,8 +140,7 @@ BObjectImp* BPacket::call_method_id( const int id, Executor& ex, bool /*forcebui unsigned short num_sent_to = 0; Core::WorldIterator::InRange( - x, y, realm, range, [&]( Mobile::Character* chr ) - { + x, y, realm, range, [&]( Mobile::Character* chr ) { Core::networkManager.clientTransmit->AddToQueue( chr->client, (void*)( &buffer[0] ), static_cast( buffer.size() ) ); num_sent_to++; @@ -561,4 +554,4 @@ BObjectImp* BPacket::SetSize( u16 newsize, bool /*giveReturn*/ ) return new BLong( oldsize ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/packetscrobj.h b/pol-core/pol/packetscrobj.h index 09fd71a89..196d61d6b 100644 --- a/pol-core/pol/packetscrobj.h +++ b/pol-core/pol/packetscrobj.h @@ -13,8 +13,19 @@ #include "../bscript/bobject.h" #endif +#include + +#include "../clib/compilerspecifics.h" #include "../clib/rawtypes.h" +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +} // namespace Pol + namespace Pol { namespace Core diff --git a/pol-core/pol/party.cpp b/pol-core/pol/party.cpp index 7329240da..ce78495f7 100644 --- a/pol-core/pol/party.cpp +++ b/pol-core/pol/party.cpp @@ -18,50 +18,47 @@ #endif #include "party.h" -#include "party_cfg.h" -#include "mobile/charactr.h" -#include "module/partymod.h" - -#include "network/client.h" -#include "network/packets.h" -#include "network/packethelper.h" -#include "network/clienttransmit.h" +#include +#include +#include +#include +#include #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/cfgsect.h" #include "../clib/clib_endian.h" #include "../clib/fileutil.h" -#include "../clib/refptr.h" -#include "../clib/stlutil.h" #include "../clib/logfacility.h" #include "../clib/streamsaver.h" - #include "../plib/systemstate.h" - #include "clfunc.h" #include "fnsearch.h" +#include "globals/network.h" +#include "globals/settings.h" +#include "globals/uvars.h" +#include "mobile/charactr.h" +#include "module/partymod.h" +#include "network/client.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "party_cfg.h" #include "pktboth.h" -#include "polcfg.h" +#include "pktdef.h" +#include "polclock.h" #include "schedule.h" #include "statmsg.h" #include "syshook.h" -#include "target.h" -#include "globals/settings.h" -#include "globals/uvars.h" -#include "realms/realm.h" -#include "unicode.h" #include "ufunc.h" +#include "unicode.h" +#include "uobject.h" +#include "uoclient.h" -#include "../bscript/berror.h" #ifdef MEMORYLEAK #include "../bscript/bobject.h" #endif -#include -#include -#include namespace Pol { @@ -354,10 +351,8 @@ void Party::add_offline_mem( u32 serial ) bool Party::remove_candidate( u32 serial ) { - auto itr = std::find_if( _candidates_serials.begin(), _candidates_serials.end(), [&]( u32& i ) - { - return i == serial; - } ); + auto itr = std::find_if( _candidates_serials.begin(), _candidates_serials.end(), + [&]( u32& i ) { return i == serial; } ); if ( itr != _candidates_serials.end() ) { _candidates_serials.erase( itr ); @@ -368,10 +363,8 @@ bool Party::remove_candidate( u32 serial ) bool Party::remove_member( u32 serial ) { - auto itr = std::find_if( _member_serials.begin(), _member_serials.end(), [&]( u32& i ) - { - return i == serial; - } ); + auto itr = std::find_if( _member_serials.begin(), _member_serials.end(), + [&]( u32& i ) { return i == serial; } ); if ( itr != _member_serials.end() ) { _member_serials.erase( itr ); @@ -382,11 +375,8 @@ bool Party::remove_member( u32 serial ) bool Party::remove_offline_mem( u32 serial ) { - auto itr = - std::find_if( _offlinemember_serials.begin(), _offlinemember_serials.end(), [&]( u32& i ) - { - return i == serial; - } ); + auto itr = std::find_if( _offlinemember_serials.begin(), _offlinemember_serials.end(), + [&]( u32& i ) { return i == serial; } ); if ( itr != _offlinemember_serials.end() ) { _offlinemember_serials.erase( itr ); @@ -397,10 +387,8 @@ bool Party::remove_offline_mem( u32 serial ) void Party::set_leader( u32 serial ) { - auto itr = std::find_if( _member_serials.begin(), _member_serials.end(), [&]( u32& i ) - { - return i == serial; - } ); + auto itr = std::find_if( _member_serials.begin(), _member_serials.end(), + [&]( u32& i ) { return i == serial; } ); if ( itr != _member_serials.end() ) { _member_serials.erase( itr ); @@ -835,11 +823,8 @@ void register_party_members() void disband_party( u32 leader ) { - auto itr = - std::find_if( gamestate.parties.begin(), gamestate.parties.end(), [&]( PartyRef& party ) - { - return party->is_leader( leader ); - } ); + auto itr = std::find_if( gamestate.parties.begin(), gamestate.parties.end(), + [&]( PartyRef& party ) { return party->is_leader( leader ); } ); if ( itr != gamestate.parties.end() ) { ( *itr )->disband(); diff --git a/pol-core/pol/party.h b/pol-core/pol/party.h index d793fc4da..5b97c66ea 100644 --- a/pol-core/pol/party.h +++ b/pol-core/pol/party.h @@ -7,9 +7,21 @@ #ifndef PARTY_H #define PARTY_H +#include +#include + +#include "../clib/rawtypes.h" #include "../clib/refptr.h" #include "proplist.h" -#include + +namespace Pol +{ +namespace Clib +{ +class ConfigElem; +} // namespace Clib +} // namespace Pol + namespace Pol { namespace Clib diff --git a/pol-core/pol/pktboth.h b/pol-core/pol/pktboth.h index ee6de2bdd..34bab30a2 100644 --- a/pol-core/pol/pktboth.h +++ b/pol-core/pol/pktboth.h @@ -473,8 +473,7 @@ struct PKTBI_B8_IN u8 msgtype; u16 msglen; u8 mode; - union - { + union { PKTBI_B8_IN_REQUEST profile_request; PKTBI_B8_IN_UPDATE profile_update; }; @@ -490,7 +489,7 @@ struct PKTBI_B8_IN // u16 msglen; // u32 serial; // char text[5*(SPEECH_MAX_LEN+1)]; // 1 Ascii variable array ( SPEECH_MAX_LEN+1) and 2 Unicode -//variable arrays 2*(SPEECH_MAX_LEN+1) each due to u16. +// variable arrays 2*(SPEECH_MAX_LEN+1) each due to u16. //}; // static_assert( sizeof(PKTBI_B8_OUT) == 1012, "size missmatch" ); @@ -613,15 +612,14 @@ static_assert( sizeof( PKTBI_BF_06_09 ) == 4, "size missmatch" ); struct PKTBI_BF_06 { u8 partycmd; - union - { + union { PKTBI_BF_06_01_IN partyadd; // client // PKTBI_BF_06_01_OUT partyaddout; //server PKTBI_BF_06_02_IN partyremove; // client // PKTBI_BF_06_02_OUT partyremoveout; //server // PKTBI_BF_06_02_LIST partyemptylist; //server PKTBI_BF_06_03 partymembermsg; // client/server - PKTBI_BF_06_04_IN partymsg; // client + PKTBI_BF_06_04_IN partymsg; // client // PKTBI_BF_06_04_OUT partymsgout; //server PKTBI_BF_06_06 partylootperm; // client // PKTBI_BF_06_07 invitemember; //server @@ -764,7 +762,7 @@ struct PKTBI_BF_1A // u16 graphic; // u16 scroll_offset; // u8 content[8];// first bit of first byte = spell #1, second bit of first byte = spell #2, first -//bit of second byte = spell #8, etc +// bit of second byte = spell #8, etc // // enum { SCROLL_OFFSET_REGULAR = 1, // SCROLL_OFFSET_NECRO = 101, @@ -773,7 +771,7 @@ struct PKTBI_BF_1A struct PKTBI_BF_1C { - u16 unk2; // 00 02 + u16 unk2; // 00 02 u16 selected_spell; // absolute spell number. 1-64, 101-etc }; @@ -829,8 +827,7 @@ struct PKTBI_BF_2A_RESULT // to change Hair, Beard and Color (maybe Race, but not in this Release) struct PKTBI_BF_RACE_CHANGER_RESULT { - union - { + union { // PKTBI_BF_2A_CALL_RACE_CHANGER call; PKTBI_BF_2A_RESULT result; }; @@ -848,21 +845,20 @@ struct PKTBI_BF u8 msgtype; u16 msglen; u16 subcmd; - union - { + union { u32 keys[6]; // BF.1: Cycling key-stack u32 addkey; // BF.2: Adding key to top of stack // PKTBI_BF_04 closegump; //BF.4 PKTBI_BF_05 screensize; // BF.5 - PKTBI_BF_06 partydata; // BF.6 + PKTBI_BF_06 partydata; // BF.6 // u8 cursorhue; // BF.8: Cursor Hue (0=Felucca,1=Trammel) - char client_lang[3]; // BF.B Client language (client message, sent once at login) + char client_lang[3]; // BF.B Client language (client message, sent once at login) u32 serial_closed_status_gump; // BF.C closed status gump - PKTBI_BF_0F clienttype; // BF.F clienttype (like char create/select) - PKTBI_BF_10 objectcache; // BF.10 + PKTBI_BF_0F clienttype; // BF.F clienttype (like char create/select) + PKTBI_BF_10 objectcache; // BF.10 u32 serial_request_popup_menu; // BF.13 - PKTBI_BF_14 displaypopup; // BF.14 - PKTBI_BF_15 popupselect; // BF.15 + PKTBI_BF_14 displaypopup; // BF.14 + PKTBI_BF_15 popupselect; // BF.15 // PKTBI_BF_16 closewindow; //BF.16 PKTBI_BF_17 codex; // BF.17 // PKTBI_BF_18 mapdiffs; //BF.18 @@ -874,9 +870,9 @@ struct PKTBI_BF PKTBI_BF_1E reqfullcustomhouse; // PKTBI_BF_20 activatehousetool; //BF.20 // PKTBI_BF_22 damage; //BF.22 - u8 se_spam; // BF.24 + u8 se_spam; // BF.24 PKTBI_BF_RACE_CHANGER_RESULT characterracechanger; // BF.2A - PKTBI_BF_32 toggleflying; // BF.32 + PKTBI_BF_32 toggleflying; // BF.32 }; enum @@ -1094,8 +1090,7 @@ struct PKTBI_D7 u16 msglen; u32 serial; u16 subcmd; - union - { + union { CH_ERASE ch_erase; CH_ADD ch_add; CH_ADD_MULTI ch_add_multi; diff --git a/pol-core/pol/pktdef.h b/pol-core/pol/pktdef.h index 410e0c573..225dbd58a 100644 --- a/pol-core/pol/pktdef.h +++ b/pol-core/pol/pktdef.h @@ -99,7 +99,7 @@ const u8 CHAR_FLAG1_INVISIBLE = 0x80; const u8 CHAR_FLAG1_WARMODE = 0x40; const u8 CHAR_FLAG1_YELLOWHEALTH = 0x08; const u8 CHAR_FLAG1_POISONED = 0x04; -const u8 CHAR_FLAG1_FLYING = 0x04; // since client 7.0 +const u8 CHAR_FLAG1_FLYING = 0x04; // since client 7.0 const u8 CHAR_FLAG1_CANALTER = 0x02; // only Paperdoll packet const u8 CHAR_FLAG1_GENDER = 0x02; const u8 CHAR_FLAG1_NORMAL = 0x00; diff --git a/pol-core/pol/pktin.h b/pol-core/pol/pktin.h index 96e97d5c0..022df1d72 100644 --- a/pol-core/pol/pktin.h +++ b/pol-core/pol/pktin.h @@ -17,8 +17,8 @@ #include "../clib/rawtypes.h" #include "layers.h" -#include "pktinid.h" #include "pktdef.h" +#include "pktinid.h" #include "uconst.h" namespace Pol { @@ -42,21 +42,21 @@ struct PKTIN_00 u32 logincount; u8 profession; char unk2[15]; - u8 Sex; // Byte 70 (0 if Human Male, 1 if Human Female, 2 if Elf Male, 3 if Elf Female) - u8 Strength; // Byte 71 - u8 Dexterity; // Byte 72 + u8 Sex; // Byte 70 (0 if Human Male, 1 if Human Female, 2 if Elf Male, 3 if Elf Female) + u8 Strength; // Byte 71 + u8 Dexterity; // Byte 72 u8 Intelligence; // Byte 73 u8 SkillNumber1; // Byte 74 - u8 SkillValue1; // Byte 75 + u8 SkillValue1; // Byte 75 u8 SkillNumber2; // Byte 76 - u8 SkillValue2; // Byte 77 + u8 SkillValue2; // Byte 77 u8 SkillNumber3; // Byte 78 - u8 SkillValue3; // Byte 79 - u16 SkinColor; // Byte 80-81 - u16 HairStyle; // Byte 82-83 - u16 HairColor; // Byte 84-85 - u16 BeardStyle; // Byte 86-87 - u16 BeardColor; // Byte 88-89 + u8 SkillValue3; // Byte 79 + u16 SkinColor; // Byte 80-81 + u16 HairStyle; // Byte 82-83 + u16 HairColor; // Byte 84-85 + u16 BeardStyle; // Byte 86-87 + u16 BeardColor; // Byte 88-89 u8 unk90; u8 StartIndex; // Byte 91 (actually a with unk90) u8 unk92; @@ -279,43 +279,43 @@ struct PKTIN_8D { u8 msgtype; // 0 u16 msglen; - u32 unk_1; // 3-6 - u32 char_slot; // 7-10 - char name[30]; // 11-40 + u32 unk_1; // 3-6 + u32 char_slot; // 7-10 + char name[30]; // 11-40 char password[30]; // 41-70 - u8 profession; // 71 - u8 flags; // 72 - u8 gender; // 73 - u8 race; // 74 0=human/1=elf/2=gargoyle - u8 strength; // 75 - u8 dexterity; // 76 - u8 intelligence; // 77 - u16 skin_color; // 78-79 - u32 unk_2; // 80-83 0x00000000 - u32 unk_3; // 84-87 0x00000000 - u8 skillnumber1; // 88 - u8 skillvalue1; // 89 - u8 skillnumber2; // 90 - u8 skillvalue2; // 91 - u8 skillnumber3; // 92 - u8 skillvalue3; // 93 - u8 skillnumber4; // 94 - u8 skillvalue4; // 95 - char unk_4[25]; // 96-121 all 00 - u8 unk_5; // 122 Always 0x0B? - u16 haircolor; // 133-134 - u16 hairstyle; // 135-136 - u8 unk_6; // 137 Always 0x0C? - u32 unk_7; // 138-141 0x00000000 - u8 unk_8; // 142 Always 0x0D? - u16 shirtcolor; // 143-144 - u16 pantscolor; // 145-146 - u8 unk_9; // 147 Always 0x0F? - u16 face_color; // 148-149 - u16 face_id; // 150-151 - u8 unk_10; // 152 - u16 beardcolor; // 153 - u16 beardstyle; // 154 + u8 profession; // 71 + u8 flags; // 72 + u8 gender; // 73 + u8 race; // 74 0=human/1=elf/2=gargoyle + u8 strength; // 75 + u8 dexterity; // 76 + u8 intelligence; // 77 + u16 skin_color; // 78-79 + u32 unk_2; // 80-83 0x00000000 + u32 unk_3; // 84-87 0x00000000 + u8 skillnumber1; // 88 + u8 skillvalue1; // 89 + u8 skillnumber2; // 90 + u8 skillvalue2; // 91 + u8 skillnumber3; // 92 + u8 skillvalue3; // 93 + u8 skillnumber4; // 94 + u8 skillvalue4; // 95 + char unk_4[25]; // 96-121 all 00 + u8 unk_5; // 122 Always 0x0B? + u16 haircolor; // 133-134 + u16 hairstyle; // 135-136 + u8 unk_6; // 137 Always 0x0C? + u32 unk_7; // 138-141 0x00000000 + u8 unk_8; // 142 Always 0x0D? + u16 shirtcolor; // 143-144 + u16 pantscolor; // 145-146 + u8 unk_9; // 147 Always 0x0F? + u16 face_color; // 148-149 + u16 face_id; // 150-151 + u8 unk_10; // 152 + u16 beardcolor; // 153 + u16 beardstyle; // 154 }; static_assert( sizeof( PKTIN_8D ) == 146, "size missmatch" ); @@ -534,23 +534,23 @@ struct PKTIN_F8 u32 logincount; u8 profession; char unk2[15]; - u8 Sex; // Byte 70 (0 if Human Male, 1 if Human Female, 2 if Elf Male, 3 if Elf Female) - u8 Strength; // Byte 71 - u8 Dexterity; // Byte 72 + u8 Sex; // Byte 70 (0 if Human Male, 1 if Human Female, 2 if Elf Male, 3 if Elf Female) + u8 Strength; // Byte 71 + u8 Dexterity; // Byte 72 u8 Intelligence; // Byte 73 u8 SkillNumber1; // Byte 74 - u8 SkillValue1; // Byte 75 + u8 SkillValue1; // Byte 75 u8 SkillNumber2; // Byte 76 - u8 SkillValue2; // Byte 77 + u8 SkillValue2; // Byte 77 u8 SkillNumber3; // Byte 78 - u8 SkillValue3; // Byte 79 + u8 SkillValue3; // Byte 79 u8 SkillNumber4; // Byte 80 - u8 SkillValue4; // Byte8 1 - u16 SkinColor; // Byte 82-83 - u16 HairStyle; // Byte 84-85 - u16 HairColor; // Byte 86-87 - u16 BeardStyle; // Byte 88-89 - u16 BeardColor; // Byte 90-91 + u8 SkillValue4; // Byte8 1 + u16 SkinColor; // Byte 82-83 + u16 HairStyle; // Byte 84-85 + u16 HairColor; // Byte 86-87 + u16 BeardStyle; // Byte 88-89 + u16 BeardColor; // Byte 90-91 u8 unk90; u8 StartIndex; // Byte 93 (actually a with unk90) u8 unk92; diff --git a/pol-core/pol/pktniid.h b/pol-core/pol/pktniid.h index 8bcbd4b48..d1030e3b7 100644 --- a/pol-core/pol/pktniid.h +++ b/pol-core/pol/pktniid.h @@ -43,4 +43,4 @@ #define PKTNI_64_ID 0x64 -#endif // PKTNIID_H \ No newline at end of file +#endif // PKTNIID_H diff --git a/pol-core/pol/pktout.h b/pol-core/pol/pktout.h index d79405a09..36d4ae529 100644 --- a/pol-core/pol/pktout.h +++ b/pol-core/pol/pktout.h @@ -22,8 +22,8 @@ #include "../clib/rawtypes.h" #include "layers.h" -#include "pktoutid.h" #include "pktdef.h" +#include "pktoutid.h" #include "uconst.h" namespace Pol { @@ -1098,7 +1098,7 @@ struct PKTOUT_9C // struct PKTOUT_BC { // u8 msgtype; // u8 season; enum { SEASON_SPRING = 0, SEASON_SUMMER, SEASON_FALL, SEASON_WINTER, -//SEASON_DESOLATION }; +// SEASON_DESOLATION }; // u8 playsound; enum { PLAYSOUND_NO = 0, PLAYSOUND_YES = 1 }; //}; // static_assert( sizeof(PKTOUT_BC) == 3, "size missmatch" ); @@ -1149,7 +1149,7 @@ struct PKTOUT_9C // u32 msgnumber; // char name[30]; // u16 arguments[(SPEECH_MAX_LEN) + 1]; // _little-endian_ Unicode string, tabs ('\t') separate the -//arguments +// arguments //}; // static_assert( sizeof( PKTOUT_C1 ) == 450, "size missmatch" ); @@ -1171,7 +1171,7 @@ struct PKTOUT_C4 // u16 explode_sound_num; //for moving effects, 0 otherwise // u32 itemid; //if target is item (type 2), 0 otherwise // u8 layer; //(of the character, e.g left hand, right hand, 0-5,7, 0xff: moving effect or target -//is no char) +// is no char) // u16 unk_effect; //for moving effect, 0 otherwise //}; @@ -1188,11 +1188,11 @@ struct PKTOUT_C4 // u32 msgnumber; // u8 flags; //0x2 unk, 0x4 message doesn't move, // //(flags & 0x1) == 0 signals affix is appended to the localization string, (flags & 0x1) == 1 -//signals to prepend. +// signals to prepend. // char name[30]; //u8 name[32]; // char affix[1]; //nullterminated, uh not just 1 byte // u16 arguments[1]; // _big-endian_ unicode string, tabs ('\t') seperate arguments, see 0xC1 for -//argument example +// argument example //}; struct CUSTOM_HOUSE_PLANE @@ -1215,9 +1215,9 @@ struct CUSTOM_HOUSE_PLANE_BUFFER struct PKTOUT_D8 { u8 msgtype; - u16 msglen; // flipped + u16 msglen; // flipped u8 compressiontype; // 0x03 currently supported for zlib compression type - u8 unk; // usually 0 + u8 unk; // usually 0 u32 serial; u32 revision; // incremented whenever content changes u16 numtiles; diff --git a/pol-core/pol/pol-2012.vcxproj b/pol-core/pol/pol-2012.vcxproj deleted file mode 100644 index 0bf25f433..000000000 --- a/pol-core/pol/pol-2012.vcxproj +++ /dev/null @@ -1,738 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - pol - {9931FF8E-092B-4E67-8E99-E237E1A481EB} - pol - - - - Application - false - MultiByte - v110 - - - Application - false - MultiByte - v110 - - - Application - false - MultiByte - v110_xp - - - Application - false - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\Release\ - .\Release\x64/ - .\Release\ - .\Release\x64/ - false - false - .\Debug\ - .\Debug\x64/ - .\Debug\ - .\Debug\x64/ - true - true - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - .\Release/pol.tlb - - - ..\..\lib\mysql-connector-c-6.0.2-win32\include;%(AdditionalIncludeDirectories) - NDEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - .\Release/pol.pch - .\Release/ - .\Release/ - .\Release/ - Level4 - true - ProgramDatabase - Default - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /MACHINE:I386 %(AdditionalOptions) - wsock32.lib;odbc32.lib;odbccp32.lib;libmysql.lib;%(AdditionalDependencies) - .\Release/pol.exe - true - ..\..\lib\boost_1_55_0\lib\x86\lib;..\..\lib\mysql-connector-c-6.0.2-win32\lib;%(AdditionalLibraryDirectories) - %(DelayLoadDLLs) - true - .\Release/pol.pdb - true - .\Release/pol.map - Console - true - false - - - 5.0 - - - - - .\Release/x64/pol.tlb - - - ..\..\lib\mysql-connector-c-6.0.2-winx64\include;%(AdditionalIncludeDirectories) - NDEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - .\Release/x64/pol.pch - .\Release/x64/ - .\Release/x64/ - .\Release/x64/ - Level4 - true - ProgramDatabase - Default - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - %(AdditionalOptions) - wsock32.lib;odbc32.lib;odbccp32.lib;libmysql.lib;%(AdditionalDependencies) - .\Release/x64/pol.exe - true - ..\..\lib\boost_1_55_0\lib\x64\lib;..\..\lib\mysql-connector-c-6.0.2-winx64\lib;%(AdditionalLibraryDirectories) - %(DelayLoadDLLs) - true - .\Release/x64/pol.pdb - true - .\Release/x64/pol.map - Console - true - false - - - 5.02 - MachineX64 - true - - - - - .\Debug/pol.tlb - - - Disabled - ..\..\lib\mysql-connector-c-6.0.2-win32\include;%(AdditionalIncludeDirectories) - _DEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - .\Debug/pol.pch - .\Debug/ - .\Debug/ - .\Debug/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /MACHINE:I386 %(AdditionalOptions) - wsock32.lib;odbc32.lib;odbccp32.lib;libmysql.lib;%(AdditionalDependencies) - .\Debug/pol.exe - true - ..\..\lib\boost_1_55_0\lib\x86\lib;..\..\lib\mysql-connector-c-6.0.2-win32\lib;%(AdditionalLibraryDirectories) - %(DelayLoadDLLs) - true - .\Debug/pol.pdb - Console - true - false - - - - - - - .\Debug/x64/pol.tlb - - - Disabled - ..\..\lib\mysql-connector-c-6.0.2-winx64\include;%(AdditionalIncludeDirectories) - _DEBUG;_CONSOLE;NOMINMAX;_WIN64;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - .\Debug/x64/pol.pch - .\Debug/x64/ - .\Debug/x64/ - .\Debug/x64/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - %(AdditionalOptions) - wsock32.lib;odbc32.lib;odbccp32.lib;libmysql.lib;%(AdditionalDependencies) - .\Debug/x64/pol.exe - true - ..\..\lib\boost_1_55_0\lib\x64\lib;..\..\lib\mysql-connector-c-6.0.2-winx64\lib;%(AdditionalLibraryDirectories) - %(DelayLoadDLLs) - true - .\Debug/x64/pol.pdb - Console - true - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Document - true - true - true - true - true - true - - - - - - {5005476b-7bd3-42a2-94ca-3ad2d0e2947c} - false - - - {7cd5572b-8a78-46c5-ac2d-39ee47acd01a} - false - - - {d45c6577-00e3-4995-a909-9c704a472565} - false - - - - - - - diff --git a/pol-core/pol/pol-2012.vcxproj.filters b/pol-core/pol/pol-2012.vcxproj.filters deleted file mode 100644 index 772f74c1d..000000000 --- a/pol-core/pol/pol-2012.vcxproj.filters +++ /dev/null @@ -1,1344 +0,0 @@ - - - - - {40588c7d-4bd8-46b3-9ec1-ea427127f4af} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {54cc4f5a-9df6-455f-b6f7-fb5c50c5dee8} - h;hpp;hxx;hm;inl - - - {23d5c811-97a9-4149-9902-9ea710a13b10} - - - {fbd991f4-a273-4489-b21f-5cfb7d8f976f} - - - {4ec05ab3-59f1-4b7d-9db9-e4129021979d} - - - {799d38d7-7d76-465d-9c66-a171602a7c01} - - - {f1358f64-4417-4d18-a020-5068c09a7f7d} - - - {417fdabe-c6c2-4998-86b4-70c4b84608d9} - - - {76f25f15-63fe-4444-863e-a9925afc4b38} - - - {2506fafa-c067-405a-9daa-c7fe44a3f69a} - - - {5fafd17c-854c-4243-91fd-b1bcc238760f} - - - {b093dcf4-0c75-4235-85ce-ede14f290c56} - - - {9974fe35-eaa2-4dd0-a1d4-11b9e0cd72b7} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - mobile - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - crypt - - - crypt - - - crypt - - - crypt - - - crypt - - - crypt - - - crypt - - - crypt - - - zlib - - - zlib - - - zlib - - - zlib - - - zlib - - - zlib - - - accounts - - - accounts - - - accounts - - - mobile - - - mobile - - - mobile - - - mobile - - - mobile - - - mobile - - - mobile - - - mobile - - - mobile - - - multi - - - multi - - - multi - - - multi - - - multi - - - multi - - - multi - - - multi - - - multi - - - multi - - - network - - - network - - - network - - - network - - - network - - - network - - - network - - - network - - - network - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - item - - - item - - - item - - - item - - - item - - - item - - - item - - - network - - - Source Files - - - Source Files - - - mobile - - - network - - - mobile - - - network - - - network - - - network - - - Source Files - - - Source Files - - - globals - - - globals - - - globals - - - globals - - - globals - - - globals - - - globals - - - globals - - - Source Files - - - globals - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - mobile - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - crypt - - - crypt - - - crypt - - - crypt - - - crypt - - - crypt - - - crypt - - - crypt - - - Resource Files - - - accounts - - - accounts - - - accounts - - - mobile - - - mobile - - - mobile - - - mobile - - - mobile - - - multi - - - multi - - - multi - - - multi - - - multi - - - multi - - - network - - - network - - - network - - - network - - - network - - - network - - - network - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - module - - - item - - - item - - - item - - - item - - - item - - - item - - - item - - - network - - - Header Files - - - Header Files - - - network - - - Header Files - - - Header Files - - - network - - - mobile - - - mobile - - - network - - - network - - - network - - - network - - - network - - - Header Files - - - globals - - - globals - - - globals - - - module - - - globals - - - globals - - - Header Files - - - globals - - - globals - - - Header Files - - - globals - - - Header Files - - - module - - - mobile - - - globals - - - - - Resource Files - - - - - Resource Files - - - - - - diff --git a/pol-core/pol/pol.cpp b/pol-core/pol/pol.cpp index bd9e3afc9..5cca12efe 100644 --- a/pol-core/pol/pol.cpp +++ b/pol-core/pol/pol.cpp @@ -58,117 +58,98 @@ #include "pol.h" -#include "../plib/pkg.h" +#include -#include "../bscript/escriptv.h" +#include +#include "../bscript/bobject.h" +#include "../clib/Debugging/ExceptionParser.h" +#include "../clib/clib_endian.h" +#include "../clib/esignal.h" +#include "../clib/fileutil.h" +#include "../clib/kbhit.h" +#include "../clib/logfacility.h" +#include "../clib/passert.h" +#include "../clib/rawtypes.h" +#include "../clib/refptr.h" +#include "../clib/stlutil.h" +#include "../clib/streamsaver.h" +#include "../clib/threadhelp.h" +#include "../clib/timer.h" +#include "../clib/tracebuf.h" +#include "../plib/pkg.h" +#include "../plib/systemstate.h" #include "accounts/account.h" -#include "allocd.h" #include "checkpnt.h" -#include "containr.h" #include "console.h" #include "core.h" #include "decay.h" +#include "extobj.h" #include "fnsearch.h" #include "gameclck.h" +#include "globals/network.h" +#include "globals/object_storage.h" +#include "globals/state.h" +#include "globals/uvars.h" #include "guardrgn.h" -#include "item/itemdesc.h" -#include "item/equipmnt.h" #include "item/armor.h" -#include "lightlvl.h" +#include "item/equipmnt.h" +#include "item/itemdesc.h" #include "loadunld.h" +#include "menu.h" #include "miscrgn.h" #include "mobile/charactr.h" -#include "multi/boat.h" #include "multi/house.h" #include "multi/multi.h" #include "musicrgn.h" #include "network/cgdata.h" #include "network/client.h" +#include "network/clientthread.h" #include "network/clienttransmit.h" #include "network/cliface.h" -#include "network/iostats.h" -#include "network/msgfiltr.h" -#include "network/msghandl.h" +#include "network/packethelper.h" #include "network/packethooks.h" #include "network/packets.h" -#include "network/packethelper.h" -#include "objtype.h" #include "party.h" #include "pktboth.h" +#include "pktdef.h" #include "pktin.h" -#include "pktout.h" #include "polcfg.h" #include "polclock.h" #include "poldbg.h" #include "polsem.h" -#include "testing/poltest.h" +#include "polsig.h" #include "polwww.h" -#include "realms.h" +#include "profile.h" +#include "realms/WorldChangeReasons.h" #include "realms/realm.h" #include "savedata.h" -#include "schedule.h" #include "scrdef.h" #include "scrsched.h" -#include "scrstore.h" #include "sockets.h" #include "sockio.h" -#include "tasks.h" -#include "ufunc.h" -#include "uoscrobj.h" -#include "globals/uvars.h" -#include "globals/network.h" -#include "globals/state.h" -#include "globals/object_storage.h" -#include "uworld.h" - -#include "stubdata.h" -#include "uimport.h" - #include "sqlscrobj.h" - -#include "network/clientthread.h" - -#include "../clib/clib_MD5.h" -#include "../clib/clib_endian.h" -#include "../clib/esignal.h" -#include "../clib/fdump.h" -#include "../clib/fileutil.h" -#include "../clib/kbhit.h" -#include "../clib/logfacility.h" -#include "../clib/passert.h" -#include "../clib/random.h" -#include "../clib/stlutil.h" -#include "../clib/strexcpt.h" -#include "../clib/strutil.h" -#include "../clib/threadhelp.h" -#include "../clib/timer.h" -#include "../clib/tracebuf.h" -#include "../clib/Debugging/ExceptionParser.h" - -#include "../plib/systemstate.h" +#include "ssopt.h" +#include "testing/poltest.h" +#include "ufunc.h" +#include "uimport.h" +#include "uoclient.h" +#include "uoscrobj.h" +#include "uworld.h" #ifndef NDEBUG #include "mobile/npc.h" #endif #ifdef _WIN32 -#include "../clib/mdump.h" #include + +#include "../clib/mdump.h" #endif #ifndef __clang__ #include #endif -#ifdef __unix__ -#include -#endif - -#ifndef _WIN32 -#include -#include -#endif - #ifdef __linux__ #include #endif @@ -176,9 +157,9 @@ #include #include - +#include +#include #include -#include #ifdef _MSC_VER #pragma warning( disable : 4127 ) // conditional expression is constant (needed because of FD_SET) @@ -241,18 +222,14 @@ void send_startup( Network::Client* client ) void send_inrange_items( Network::Client* client ) { - WorldIterator::InVisualRange( client->chr, [&]( Items::Item* item ) - { - send_item( client, item ); - } ); + WorldIterator::InVisualRange( + client->chr, [&]( Items::Item* item ) { send_item( client, item ); } ); } void send_inrange_multis( Network::Client* client ) { - WorldIterator::InVisualRange( client->chr, [&]( Multi::UMulti* multi ) - { - send_multi( client, multi ); - } ); + WorldIterator::InVisualRange( + client->chr, [&]( Multi::UMulti* multi ) { send_multi( client, multi ); } ); } void textcmd_startlog( Network::Client* client ); @@ -418,8 +395,8 @@ void char_select( Network::Client* client, PKTIN_5D* msg ) Mobile::Character* chosen_char = client->acct->get_character( charidx ); - POLLOG.Format( "Account {} selecting character {}\n" ) << client->acct->name() - << chosen_char->name(); + POLLOG.Format( "Account {} selecting character {}\n" ) + << client->acct->name() << chosen_char->name(); if ( Plib::systemstate.config.min_cmdlevel_to_login > chosen_char->cmdlevel() ) { @@ -510,10 +487,8 @@ void handle_resync_request( Network::Client* client, PKTBI_22_SYNC* /*msg*/ ) // packets (else this hangs 4.0.0e clients) Core::WorldIterator::InVisualRange( - client->chr, [&]( Mobile::Character* zonechr ) - { - send_client_char_data( zonechr, client ); - } ); + client->chr, + [&]( Mobile::Character* zonechr ) { send_client_char_data( zonechr, client ); } ); send_inrange_items( client ); send_inrange_multis( client ); @@ -743,7 +718,7 @@ void threadstatus_thread( void ) tmp << "*Thread Info*\n"; tmp << "Semaphore TID: " << locker << "\n"; - if (Plib::systemstate.config.log_traces_when_stuck) + if ( Plib::systemstate.config.log_traces_when_stuck ) Pol::Clib::ExceptionParser::logAllStackTraces(); tmp << "Scripts Thread Checkpoint: " << stateManager.polsig.scripts_thread_checkpoint << "\n"; @@ -890,11 +865,6 @@ void start_threads() checkpoint( "start sql service thread" ); start_sql_service(); #endif - -#ifndef _WIN32 -// checkpoint( "start catch_signals thread" ); -// start_thread( catch_signals_thread, "CatchSignals" ); -#endif } void check_incoming_data( void ) @@ -1000,7 +970,6 @@ unsigned int ref_counted::_ctor_calls; #endif void display_unreaped_orphan_instances(); - void display_reftypes(); void display_leftover_objects() @@ -1359,17 +1328,17 @@ int xmain_inner( bool testing ) << POL_VERSION_ID << POL_BUILD_TARGET << POL_BUILD_DATE << POL_BUILD_TIME; // if( 1 ) { - if ( Plib::systemstate.config.multithread == 0 ) { - POLLOG_INFO << - "\n" - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" - "WARNING: Threading is disabled (Multithread==0 in pol.cfg). \n" - " This setting is deprecated and will be removed from \n" - " the next version of POL. It may not even work now! \n" - " Only use this option if you really know what you are \n" - " doing. And you probably don't. \n" - "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" - "\n"; + if ( Plib::systemstate.config.multithread == 0 ) + { + POLLOG_INFO << "\n" + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" + "WARNING: Threading is disabled (Multithread==0 in pol.cfg). \n" + " This setting is deprecated and will be removed from \n" + " the next version of POL. It may not even work now! \n" + " Only use this option if you really know what you are \n" + " doing. And you probably don't. \n" + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" + "\n"; } POLLOG_INFO << "Game is active.\n"; } diff --git a/pol-core/pol/polcfg.cpp b/pol-core/pol/polcfg.cpp index 828e7cae1..e2eaba79d 100644 --- a/pol-core/pol/polcfg.cpp +++ b/pol-core/pol/polcfg.cpp @@ -13,29 +13,29 @@ #include "polcfg.h" -#include "core.h" -#include "globals/state.h" -#include "globals/uvars.h" -#include "objtype.h" -#include "schedule.h" -#include "tasks.h" - +#include +#include +#include +#include +#include +#include #include "../bscript/config.h" - +#include "../clib/Debugging/ExceptionParser.h" #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" -#include "../clib/Debugging/ExceptionParser.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" #include "../clib/mdump.h" #include "../clib/passert.h" #include "../clib/strutil.h" - #include "../plib/systemstate.h" - -#include -#include +#include "core.h" +#include "globals/state.h" +#include "globals/uvars.h" +#include "objtype.h" +#include "polsig.h" +#include "proplist.h" namespace Pol { diff --git a/pol-core/pol/polcfg.h b/pol-core/pol/polcfg.h index fae1cec76..1b1fe2530 100644 --- a/pol-core/pol/polcfg.h +++ b/pol-core/pol/polcfg.h @@ -12,6 +12,7 @@ #define POLCFG_H #include + #include "crypt/cryptkey.h" #if !defined( _WIN32 ) #include diff --git a/pol-core/pol/polclock.cpp b/pol-core/pol/polclock.cpp index b5d194eae..a36961b41 100644 --- a/pol-core/pol/polclock.cpp +++ b/pol-core/pol/polclock.cpp @@ -6,6 +6,8 @@ #include "polclock.h" +#include + #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include @@ -16,7 +18,6 @@ #include "globals/state.h" - namespace Pol { namespace Core @@ -128,4 +129,4 @@ void restart_pol_clocks() restart_poltime(); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/polclock.h b/pol-core/pol/polclock.h index 66f26460b..ec500a7b5 100644 --- a/pol-core/pol/polclock.h +++ b/pol-core/pol/polclock.h @@ -18,6 +18,7 @@ #define POLCLOCK_H #include + namespace Pol { namespace Core diff --git a/pol-core/pol/poldbg.cpp b/pol-core/pol/poldbg.cpp index 60330474f..ad312142c 100644 --- a/pol-core/pol/poldbg.cpp +++ b/pol-core/pol/poldbg.cpp @@ -11,34 +11,33 @@ #include "poldbg.h" -#include "polcfg.h" -#include "polsem.h" -#include "scrdef.h" -#include "scrsched.h" -#include "scrstore.h" - -#include "module/uomod.h" -#include "module/osmod.h" -#include "uoexec.h" -#include "globals/uvars.h" +#include +#include +#include #include "../bscript/berror.h" #include "../bscript/bobject.h" +#include "../bscript/bstruct.h" +#include "../bscript/eprog.h" +#include "../bscript/executor.h" #include "../bscript/impstr.h" - +#include "../clib/clib.h" +#include "../clib/compilerspecifics.h" #include "../clib/esignal.h" +#include "../clib/rawtypes.h" +#include "../clib/refptr.h" #include "../clib/sckutil.h" #include "../clib/socketsvc.h" #include "../clib/stlutil.h" #include "../clib/strutil.h" +#include "../clib/weakptr.h" #include "../clib/wnsckt.h" - #include "../plib/systemstate.h" - -#include -#include -#include -#include +#include "module/osmod.h" +#include "module/uomod.h" +#include "scrdef.h" +#include "scrsched.h" +#include "uoexec.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // stricmp deprecation warning @@ -154,6 +153,7 @@ public: typedef std::vector Results; bool process( const std::string& cmd, Results& results ); bool done() const { return _done; } + protected: std::string cmd_attach( unsigned pid ); std::string cmd_kill( unsigned pid ); @@ -467,7 +467,7 @@ std::string DebugContext::cmd_stacktrace( Results& results ) { ReturnContext rc; rc.PC = exec->PC; - rc.ValueStackDepth = static_cast(exec->ValueStack.size()); + rc.ValueStackDepth = static_cast( exec->ValueStack.size() ); stack.push_back( rc ); } upperLocals2.push_back( exec->Locals2 ); diff --git a/pol-core/pol/polfile1.cpp b/pol-core/pol/polfile1.cpp index f3a7d6144..94ecac042 100644 --- a/pol-core/pol/polfile1.cpp +++ b/pol-core/pol/polfile1.cpp @@ -7,35 +7,20 @@ */ -#include "polfile.h" - -#include "polcfg.h" -#include "uofilei.h" -#include "uofile.h" +#include +#include +#include "../clib/fileutil.h" +#include "../clib/logfacility.h" +#include "../clib/passert.h" +#include "../clib/rawtypes.h" #include "../plib/realmdescriptor.h" #include "../plib/staticblock.h" #include "../plib/systemstate.h" - -#include "item/itemdesc.h" +#include "clidata.h" +#include "uofile.h" #include "ustruct.h" -#include "../clib/cfgelem.h" -#include "../clib/cfgfile.h" -#include "../clib/fileutil.h" -#include "../clib/passert.h" -#include "../clib/random.h" -#include "../clib/stlutil.h" -#include "../clib/strutil.h" -#include "../clib/wallclock.h" -#include "../clib/logfacility.h" - -#ifdef __unix__ -#include -#endif - -#include - #ifdef _MSC_VER #pragma warning( disable : 4996 ) // disable deprecation warning fopen #endif @@ -174,11 +159,14 @@ int write_pol_static_files( const std::string& realm ) #ifndef NDEBUG - INFO_PRINT << statics << " statics written\n" << duplicates << " duplicates eliminated\n" - << illegales << " illegales eliminated\n" << empties << " empties\n" << nonempties - << " nonempties\n" << maxcount << " was the highest count\n"; + INFO_PRINT << statics << " statics written\n" + << duplicates << " duplicates eliminated\n" + << illegales << " illegales eliminated\n" + << empties << " empties\n" + << nonempties << " nonempties\n" + << maxcount << " was the highest count\n"; #endif return 0; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/polfile2.cpp b/pol-core/pol/polfile2.cpp index 8daad05b0..0ec67da30 100644 --- a/pol-core/pol/polfile2.cpp +++ b/pol-core/pol/polfile2.cpp @@ -4,21 +4,17 @@ * - 2009/12/02 Turley: added config.max_tile_id - Tomi */ - // TODO: consider joining this file with landtile.cpp, tiles.cpp and clidata.h and renaming it all // to something consistent. // TODO: encapsulate the tile[] vector here -#include "clidata.h" - -#include "tiles.h" -#include "polcfg.h" - -#include "../clib/passert.h" -#include "../plib/mapcell.h" -#include "../plib/systemstate.h" #include +#include "../clib/rawtypes.h" +#include "../plib/mapcell.h" +#include "../plib/systemstate.h" +#include "tiles.h" + namespace Pol { namespace Core @@ -98,4 +94,4 @@ unsigned short tileweight( unsigned short tilenum ) } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/polsem.cpp b/pol-core/pol/polsem.cpp index b40c2ecf5..fd1955c2e 100644 --- a/pol-core/pol/polsem.cpp +++ b/pol-core/pol/polsem.cpp @@ -6,11 +6,10 @@ #include "polsem.h" -#include "checkpnt.h" +#include #include "../clib/logfacility.h" #include "../clib/passert.h" -#include "../clib/strexcpt.h" #include "../clib/threadhelp.h" #include "../clib/tracebuf.h" @@ -19,7 +18,6 @@ #else #include #include -#include #endif namespace Pol @@ -185,9 +183,7 @@ void init_ipc_vars() pthread_attr_setdetachstate( &thread_attr, PTHREAD_CREATE_DETACHED ); } -void deinit_ipc_vars() -{ -} +void deinit_ipc_vars() {} void send_pulse() { @@ -273,4 +269,4 @@ void wait_for_ClientTransmit_pulse( unsigned int millis ) #endif } -} \ No newline at end of file +} diff --git a/pol-core/pol/polsig.cpp b/pol-core/pol/polsig.cpp index ab1958618..d6e31728b 100644 --- a/pol-core/pol/polsig.cpp +++ b/pol-core/pol/polsig.cpp @@ -7,10 +7,12 @@ #include "polsig.h" -#include "../bscript/eprog.h" +#include +#include + #include "../clib/esignal.h" -#include "../clib/threadhelp.h" #include "../clib/logfacility.h" +#include "../clib/threadhelp.h" #include "globals/state.h" #ifndef _WIN32 @@ -37,9 +39,7 @@ void install_signal_handlers() { Clib::enable_exit_signaller(); } -void signal_catch_thread() -{ -} +void signal_catch_thread() {} #else pthread_t main_pthread; @@ -60,9 +60,7 @@ void handle_SIGUSR1( int /*x*/ ) // LINUXTEST stateManager.polsig.report_status_signalled = true; } -void null_handler( int /*x*/ ) -{ -} +void null_handler( int /*x*/ ) {} void install_null_handler( int sig ) { diff --git a/pol-core/pol/polstats.cpp b/pol-core/pol/polstats.cpp index f6a4bb3a0..022b3a96f 100644 --- a/pol-core/pol/polstats.cpp +++ b/pol-core/pol/polstats.cpp @@ -9,8 +9,6 @@ namespace Pol { namespace Core { -PolStats::PolStats() : bytes_received( 0 ), bytes_sent( 0 ) -{ +PolStats::PolStats() : bytes_received( 0 ), bytes_sent( 0 ) {} } } -} \ No newline at end of file diff --git a/pol-core/pol/poltimer.h b/pol-core/pol/poltimer.h index de4c33391..ebc47903f 100644 --- a/pol-core/pol/poltimer.h +++ b/pol-core/pol/poltimer.h @@ -7,8 +7,8 @@ #ifndef POLTIMER_H #define POLTIMER_H -#include #include "polclock.h" +#include namespace Pol { namespace Core @@ -18,6 +18,7 @@ class PolTimer public: PolTimer() : start( polclock() ) {} void printOn( std::ostream& os ) { os << "elapsed: " << polclock() - start << " polclocks\n"; } + private: polclock_t start; }; diff --git a/pol-core/pol/polwww.cpp b/pol-core/pol/polwww.cpp index 9445955af..52b1487ed 100644 --- a/pol-core/pol/polwww.cpp +++ b/pol-core/pol/polwww.cpp @@ -14,34 +14,37 @@ #include "polwww.h" -#include "module/httpmod.h" -#include "module/uomod.h" -#include "uoexec.h" - -#include "../bscript/berror.h" +#include +#include +#include +#include +#include +#include #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/esignal.h" -#include "../clib/clib_endian.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" +#include "../clib/passert.h" +#include "../clib/refptr.h" #include "../clib/stlutil.h" -#include "../clib/strexcpt.h" #include "../clib/strutil.h" #include "../clib/threadhelp.h" #include "../clib/wnsckt.h" - #include "../plib/pkg.h" #include "../plib/systemstate.h" - +#include "globals/uvars.h" +#include "module/httpmod.h" +#include "module/uomod.h" #include "polcfg.h" #include "polsem.h" #include "scrdef.h" #include "scrsched.h" #include "scrstore.h" +#include "sockets.h" #include "sockio.h" -#include "globals/uvars.h" +#include "uoexec.h" #ifdef _WIN32 #include @@ -49,8 +52,6 @@ #include #endif -#include -#include #ifdef _MSC_VER #pragma warning( disable : 4127 ) // conditional expression is constant (needed because of FD_SET) @@ -111,11 +112,13 @@ void config_web_server() Plib::Package* pkg = ( *itr ); if ( pkg->provides_system_home_page() ) { - if ( gamestate.wwwroot_pkg == nullptr ) { + if ( gamestate.wwwroot_pkg == nullptr ) + { POLLOG.Format( "wwwroot package is {}\n" ) << pkg->desc(); gamestate.wwwroot_pkg = pkg; } - else { + else + { POLLOG.Format( "Package {} also provides a wwwroot, ignoring\n" ) << pkg->desc(); } } @@ -764,9 +767,7 @@ void http_func( SOCKET client_socket ) #ifdef _WIN32 -void init_http_thread_support() -{ -} +void init_http_thread_support() {} #else pthread_attr_t http_attr; void init_http_thread_support() @@ -882,10 +883,8 @@ void http_thread( void ) std::string addrstr = Network::AddressToString( &client_addr ); INFO_PRINT << "HTTP client connected from " << addrstr << "\n"; - worker_threads.push( [=]() - { - http_func( client_socket ); - } ); // copy socket into queue to keep it valid + worker_threads.push( + [=]() { http_func( client_socket ); } ); // copy socket into queue to keep it valid } } gamestate.mime_types.clear(); // cleanup on exit diff --git a/pol-core/pol/profile.h b/pol-core/pol/profile.h index c4b6f2340..f03f4b478 100644 --- a/pol-core/pol/profile.h +++ b/pol-core/pol/profile.h @@ -9,9 +9,9 @@ #define PROFILE_H #include "../clib/rawtypes.h" +#include #include #include -#include namespace Pol { diff --git a/pol-core/pol/proplist.cpp b/pol-core/pol/proplist.cpp index 9e85413f2..e507c7422 100644 --- a/pol-core/pol/proplist.cpp +++ b/pol-core/pol/proplist.cpp @@ -7,33 +7,27 @@ #include "proplist.h" -#include "../plib/systemstate.h" - -#include "../clib/cfgelem.h" -#include "../clib/stlutil.h" -#include "../clib/strutil.h" -#include "../clib/logfacility.h" -#include "../clib/streamsaver.h" +#include #include "../bscript/berror.h" -#include "../bscript/execmodl.h" +#include "../bscript/bobject.h" #include "../bscript/executor.h" #include "../bscript/impstr.h" #include "../bscript/objmethods.h" - +#include "../clib/cfgelem.h" +#include "../clib/logfacility.h" +#include "../clib/streamsaver.h" +#include "../clib/strutil.h" +#include "../plib/systemstate.h" #include "baseobject.h" - -#include +#include "polcfg.h" #define pf_endl '\n' namespace Pol { namespace Core { - -CPropProfiler::HitsCounter::HitsCounter() : hits( std::array{{0, 0, 0}} ) -{ -} +CPropProfiler::HitsCounter::HitsCounter() : hits( std::array{{0, 0, 0}} ) {} u64& CPropProfiler::HitsCounter::operator[]( size_t idx ) { @@ -80,9 +74,7 @@ CPropProfiler& CPropProfiler::instance() return instance; } -CPropProfiler::CPropProfiler() : _proplists( new PropLists() ), _hits( new Hits() ) -{ -} +CPropProfiler::CPropProfiler() : _proplists( new PropLists() ), _hits( new Hits() ) {} /** * Returns proplist type, internal usage @@ -181,12 +173,12 @@ void CPropProfiler::unregisterProplist( const PropertyList* proplist ) } /** -* Register a cprop action -* -* @param proplist Pointer to the registered list where this cprop resides -* @param name Name of the cprop -* @param key Index of the array key to update -*/ + * Register a cprop action + * + * @param proplist Pointer to the registered list where this cprop resides + * @param name Name of the cprop + * @param key Index of the array key to update + */ void CPropProfiler::cpropAction( const PropertyList* proplist, const std::string& name, const size_t key ) { diff --git a/pol-core/pol/proplist.h b/pol-core/pol/proplist.h index a9dd8017e..65930c36e 100644 --- a/pol-core/pol/proplist.h +++ b/pol-core/pol/proplist.h @@ -9,33 +9,34 @@ #ifndef PROPLIST_H #define PROPLIST_H +#include +#include +#include +#include +#include +#include +#include + #include "../clib/boostutils.h" #include "../clib/rawtypes.h" #include "../clib/spinlock.h" -#include - -#include -#include -#include -#include - - namespace Pol { namespace Bscript { -class Executor; class BObjectImp; +class Executor; } namespace Clib { -class StreamWriter; class ConfigElem; +class StreamWriter; } namespace Core { class PropertyList; + enum class UOBJ_CLASS : u8; /** @@ -98,6 +99,7 @@ private: u64& operator[]( size_t idx ); const u64& operator[]( size_t idx ) const; size_t sizeEstimate() const; + private: /// 0=read, 1=write, 2=erase std::array hits; @@ -151,7 +153,7 @@ public: bool operator==( const PropertyList& ) const; PropertyList& operator-( const std::set& ); // dave added 1/26/3 - void operator-=( const std::set& ); // dave added 1/26/3 + void operator-=( const std::set& ); // dave added 1/26/3 protected: typedef std::map Properties; diff --git a/pol-core/pol/realms.cpp b/pol-core/pol/realms.cpp index 505f949bd..659cae39f 100644 --- a/pol-core/pol/realms.cpp +++ b/pol-core/pol/realms.cpp @@ -10,20 +10,16 @@ #include "realms.h" -#include "storage.h" -#include "polcfg.h" -#include "globals/uvars.h" - -#include "realms/realm.h" -#include "../plib/mapserver.h" -#include "../plib/systemstate.h" +#include #include "../clib/dirlist.h" +#include "../clib/logfacility.h" #include "../clib/passert.h" #include "../clib/strutil.h" - #include "../clib/timer.h" -#include "../clib/logfacility.h" +#include "../plib/systemstate.h" +#include "globals/uvars.h" +#include "realms/realm.h" namespace Pol { diff --git a/pol-core/pol/realms.h b/pol-core/pol/realms.h index 3baa7a830..2160b7c45 100644 --- a/pol-core/pol/realms.h +++ b/pol-core/pol/realms.h @@ -11,8 +11,8 @@ #define REALMS_H #include -#include #include +#include namespace Pol { diff --git a/pol-core/pol/realms/WorldChangeReasons.h b/pol-core/pol/realms/WorldChangeReasons.h index 4176bc23d..863094273 100644 --- a/pol-core/pol/realms/WorldChangeReasons.h +++ b/pol-core/pol/realms/WorldChangeReasons.h @@ -20,4 +20,4 @@ enum class WorldChangeReason }; } } -#endif \ No newline at end of file +#endif diff --git a/pol-core/pol/realms/realm.cpp b/pol-core/pol/realms/realm.cpp index bfe8c08a6..7ecdb9dba 100644 --- a/pol-core/pol/realms/realm.cpp +++ b/pol-core/pol/realms/realm.cpp @@ -10,15 +10,14 @@ #include "realm.h" - #include "../../plib/mapserver.h" -#include "../../plib/staticserver.h" #include "../../plib/maptileserver.h" - -#include "../uworld.h" +#include "../../plib/realmdescriptor.h" +#include "../../plib/staticserver.h" #include "../mobile/charactr.h" #include "../poltype.h" -#include "../../clib/logfacility.h" +#include "../uworld.h" +#include "WorldChangeReasons.h" namespace Pol { diff --git a/pol-core/pol/realms/realm.h b/pol-core/pol/realms/realm.h index bb902adb4..b8d9d5b8d 100644 --- a/pol-core/pol/realms/realm.h +++ b/pol-core/pol/realms/realm.h @@ -10,25 +10,26 @@ #ifndef POL_REALM_H #define POL_REALM_H +#include +#include +#include +#include +#include + #include "../../plib/mapshape.h" #include "../../plib/realmdescriptor.h" #include "../uconst.h" #include "../udatfile.h" - #include "WorldChangeReasons.h" -#include -#include -#include - namespace Pol { namespace Core { +class ItemsVector; class ULWObject; struct Zone; -class ItemsVector; } namespace Mobile { @@ -45,10 +46,10 @@ class UMulti; namespace Plib { class MapServer; -struct MAPTILE_CELL; class MapTileServer; -class StaticServer; class StaticEntryList; +class StaticServer; +struct MAPTILE_CELL; } namespace Realms { diff --git a/pol-core/pol/realms/realmfunc.cpp b/pol-core/pol/realms/realmfunc.cpp index bed22f2c2..686e4a051 100644 --- a/pol-core/pol/realms/realmfunc.cpp +++ b/pol-core/pol/realms/realmfunc.cpp @@ -14,35 +14,34 @@ */ -#include "realm.h" +#include -#include "../../plib/realmdescriptor.h" +#include "../../clib/rawtypes.h" #include "../../plib/mapcell.h" #include "../../plib/mapserver.h" +#include "../../plib/mapshape.h" +#include "../../plib/maptile.h" +#include "../../plib/maptileserver.h" #include "../../plib/staticserver.h" #include "../../plib/systemstate.h" -#include "../../plib/mapshape.h" -#include "../../plib/maptileserver.h" - -#include "../tiles.h" -#include "../mobile/charactr.h" -#include "../network/cgdata.h" -#include "../network/client.h" +#include "../clidata.h" #include "../fnsearch.h" #include "../globals/uvars.h" -#include "../uworld.h" -#include "../item/item.h" #include "../item/itemdesc.h" +#include "../mobile/charactr.h" +#include "../multi/customhouses.h" +#include "../multi/house.h" #include "../multi/multi.h" #include "../multi/multidef.h" -#include "../multi/house.h" -#include "../multi/customhouses.h" -#include "../uconst.h" -#include "../clidata.h" +#include "../network/cgdata.h" +#include "../network/client.h" #include "../objtype.h" #include "../poltype.h" - -#include +#include "../tiles.h" +#include "../uconst.h" +#include "../udatfile.h" +#include "../uworld.h" +#include "realm.h" #define HULL_HEIGHT_BUFFER 2 namespace Pol @@ -63,8 +62,9 @@ bool Realm::lowest_standheight( unsigned short x, unsigned short y, short* z ) c { static Plib::MapShapeList vec; vec.clear(); - getmapshapes( vec, x, y, Plib::FLAG::MOVELAND | Plib::FLAG::MOVESEA | Plib::FLAG::BLOCKING | - Plib::FLAG::GRADUAL ); + getmapshapes( + vec, x, y, + Plib::FLAG::MOVELAND | Plib::FLAG::MOVESEA | Plib::FLAG::BLOCKING | Plib::FLAG::GRADUAL ); bool res = true; lowest_standheight( Core::MOVEMODE_LAND, vec, *z, &res, z ); @@ -122,9 +122,8 @@ void Realm::standheight( Core::MOVEMODE movemode, Plib::MapShapeList& shapes, sh } } if ( newz < shape.z && - shape.z < newz + - Core::settingsManager.ssopt - .default_character_height ) // space too small to stand? + shape.z < newz + Core::settingsManager.ssopt + .default_character_height ) // space too small to stand? { if ( !possible_shapes.empty() ) possible_shapes.pop_back(); // remove the last pos_shape @@ -624,61 +623,55 @@ bool Realm::dropheight( Plib::MapShapeList& shapes, short dropz, short chrz, sho void Realm::readmultis( Plib::MapShapeList& vec, unsigned short x, unsigned short y, unsigned int anyflags ) const { - Core::WorldIterator::InRange( - x, y, this, 64, [&]( Multi::UMulti* multi ) - { - Multi::UHouse* house = multi->as_house(); - if ( house != NULL && house->IsCustom() ) // readshapes switches to working design if the - // house is being edited, - // everyone in the house would use it for walking... - multi->readshapes( vec, s16( x ) - multi->x, s16( y ) - multi->y, multi->z ); - else - { - const Multi::MultiDef& def = multi->multidef(); - def.readshapes( vec, s16( x ) - multi->x, s16( y ) - multi->y, multi->z, anyflags ); - } - } ); + Core::WorldIterator::InRange( x, y, this, 64, [&]( Multi::UMulti* multi ) { + Multi::UHouse* house = multi->as_house(); + if ( house != NULL && house->IsCustom() ) // readshapes switches to working design if the + // house is being edited, + // everyone in the house would use it for walking... + multi->readshapes( vec, s16( x ) - multi->x, s16( y ) - multi->y, multi->z ); + else + { + const Multi::MultiDef& def = multi->multidef(); + def.readshapes( vec, s16( x ) - multi->x, s16( y ) - multi->y, multi->z, anyflags ); + } + } ); } void Realm::readmultis( Plib::MapShapeList& vec, unsigned short x, unsigned short y, unsigned int anyflags, MultiList& mvec ) const { - Core::WorldIterator::InRange( - x, y, this, 64, [&]( Multi::UMulti* multi ) + Core::WorldIterator::InRange( x, y, this, 64, [&]( Multi::UMulti* multi ) { + Multi::UHouse* house = multi->as_house(); + if ( house != NULL && house->IsCustom() ) + { + if ( multi->readshapes( vec, s16( x ) - multi->x, s16( y ) - multi->y, multi->z ) ) + mvec.push_back( multi ); + } + else + { + const Multi::MultiDef& def = multi->multidef(); + if ( def.readshapes( vec, s16( x ) - multi->x, s16( y ) - multi->y, multi->z, anyflags ) ) { - Multi::UHouse* house = multi->as_house(); - if ( house != NULL && house->IsCustom() ) - { - if ( multi->readshapes( vec, s16( x ) - multi->x, s16( y ) - multi->y, multi->z ) ) - mvec.push_back( multi ); - } - else - { - const Multi::MultiDef& def = multi->multidef(); - if ( def.readshapes( vec, s16( x ) - multi->x, s16( y ) - multi->y, multi->z, anyflags ) ) - { - mvec.push_back( multi ); - } - } - } ); + mvec.push_back( multi ); + } + } + } ); } void Realm::readmultis( Core::StaticList& vec, unsigned short x, unsigned short y ) const { - Core::WorldIterator::InRange( - x, y, this, 64, [&]( Multi::UMulti* multi ) - { - Multi::UHouse* house = multi->as_house(); - if ( house != NULL && house->IsCustom() ) // readshapes switches to working design if the - // house is being edited, - // everyone in the house would use it for walking... - multi->readobjects( vec, int( x ) - multi->x, int( y ) - multi->y, multi->z ); - else - { - const Multi::MultiDef& def = multi->multidef(); - def.readobjects( vec, int( x ) - multi->x, int( y ) - multi->y, multi->z ); - } - } ); + Core::WorldIterator::InRange( x, y, this, 64, [&]( Multi::UMulti* multi ) { + Multi::UHouse* house = multi->as_house(); + if ( house != NULL && house->IsCustom() ) // readshapes switches to working design if the + // house is being edited, + // everyone in the house would use it for walking... + multi->readobjects( vec, int( x ) - multi->x, int( y ) - multi->y, multi->z ); + else + { + const Multi::MultiDef& def = multi->multidef(); + def.readobjects( vec, int( x ) - multi->x, int( y ) - multi->y, multi->z ); + } + } ); } bool Realm::navigable( unsigned short x, unsigned short y, short z, short height = 0 ) const diff --git a/pol-core/pol/realms/realmlos.cpp b/pol-core/pol/realms/realmlos.cpp index d60ce4ce3..4d46b88fb 100644 --- a/pol-core/pol/realms/realmlos.cpp +++ b/pol-core/pol/realms/realmlos.cpp @@ -2,20 +2,16 @@ * * @par History */ -#include "../../clib/logfacility.h" +#include + #include "../../clib/compilerspecifics.h" -#include "realm.h" +#include "../../clib/rawtypes.h" #include "../../plib/mapcell.h" -#include "../../plib/mapserver.h" -#include "../../plib/inmemorymapserver.h" -#include "../../plib/mapshape.h" - -#include "../mobile/charactr.h" -#include "../uworld.h" // TODO move 'world' into Realm +#include "../baseobject.h" #include "../item/item.h" -#include "../clidata.h" - -#include +#include "../mobile/charactr.h" +#include "../uworld.h" +#include "realm.h" namespace Pol { @@ -56,8 +52,7 @@ const int los_range = 20; /** * @ingroup los3d */ -bool Realm::dynamic_item_blocks_los( unsigned short x, unsigned short y, short z, - LosCache& cache ) +bool Realm::dynamic_item_blocks_los( unsigned short x, unsigned short y, short z, LosCache& cache ) { for ( const auto& item : cache.dyn_items ) { @@ -78,7 +73,8 @@ bool Realm::dynamic_item_blocks_los( unsigned short x, unsigned short y, short z /** * @ingroup los3d */ -bool Realm::static_item_blocks_los( unsigned short x, unsigned short y, short z, LosCache& cache ) const +bool Realm::static_item_blocks_los( unsigned short x, unsigned short y, short z, + LosCache& cache ) const { if ( cache.last_x != x || cache.last_y != y ) { @@ -135,8 +131,7 @@ bool Realm::los_blocked( const Core::ULWObject& att, const Core::ULWObject& targ return false; } - return dynamic_item_blocks_los( x, y, z, cache ) || - static_item_blocks_los( x, y, z, cache ); + return dynamic_item_blocks_los( x, y, z, cache ) || static_item_blocks_los( x, y, z, cache ); } /// absolute value of a @@ -146,14 +141,14 @@ bool Realm::los_blocked( const Core::ULWObject& att, const Core::ULWObject& targ #define ZSGN( a ) ( ( ( a ) < 0 ) ? -1 : ( a ) > 0 ? 1 : 0 ) /** -* @ingroup los3d -*/ + * @ingroup los3d + */ bool Realm::has_los( const Core::ULWObject& att, const Core::ULWObject& tgt ) const { if ( att.isa( Core::UOBJ_CLASS::CLASS_CHARACTER ) ) { const Mobile::Character& chr = static_cast( att ); - if ( tgt.serial ) // remotes fail the realm check :( + if ( tgt.serial ) // remotes fail the realm check :( { bool remote; Items::Item* remote_container = chr.search_remote_containers( tgt.serial, &remote ); @@ -170,12 +165,12 @@ bool Realm::has_los( const Core::ULWObject& att, const Core::ULWObject& tgt ) co if ( att.realm != tgt.realm ) return false; } - // due to the nature of los check the same x,y coordinates get checked, cache the last used coords - // to reduce the expensive map/multi read per coordinate + // due to the nature of los check the same x,y coordinates get checked, cache the last used + // coords to reduce the expensive map/multi read per coordinate -#if (!defined(_MSC_VER) || _MSC_VER >= 1900) +#if ( !defined( _MSC_VER ) || _MSC_VER >= 1900 ) static THREADLOCAL LosCache cache; -#else // older ms support only primitive types :( +#else // older ms support only primitive types :( LosCache cache; #endif cache.last_x = 0xFFFF; @@ -184,10 +179,8 @@ bool Realm::has_los( const Core::ULWObject& att, const Core::ULWObject& tgt ) co cache.dyn_items.clear(); // pre filter dynitems Core::WorldIterator::InBox( - std::min( att.x, tgt.x ), std::min( att.y, tgt.y ), - std::max( att.x, tgt.x ), std::max( att.y, tgt.y ), - att.realm, [&]( Items::Item* item ) - { + std::min( att.x, tgt.x ), std::min( att.y, tgt.y ), std::max( att.x, tgt.x ), + std::max( att.y, tgt.y ), att.realm, [&]( Items::Item* item ) { u32 flags = Core::tile_flags( item->graphic ); if ( flags & Plib::FLAG::BLOCKSIGHT ) { diff --git a/pol-core/pol/reftypes.cpp b/pol-core/pol/reftypes.cpp index 00b3f106b..f5dfb91a9 100644 --- a/pol-core/pol/reftypes.cpp +++ b/pol-core/pol/reftypes.cpp @@ -5,14 +5,6 @@ #include "reftypes.h" -#include "uobject.h" -#include "mobile/charactr.h" -#include "item/item.h" -#include "mobile/npc.h" - -#include "../clib/logfacility.h" - -#include namespace Pol { diff --git a/pol-core/pol/reftypes.h b/pol-core/pol/reftypes.h index 2c8e470ee..2ce76722f 100644 --- a/pol-core/pol/reftypes.h +++ b/pol-core/pol/reftypes.h @@ -6,8 +6,8 @@ #ifndef REFTYPES_H #define REFTYPES_H - #include "../clib/refptr.h" + namespace Pol { namespace Accounts @@ -28,7 +28,7 @@ namespace Core { #ifdef NDEBUG // release mode -#define REFTYPE_DEBUG 0 +#define REFTYPE_DEBUG 0 #else // debug mode #define REFTYPE_DEBUG 0 diff --git a/pol-core/pol/region.cpp b/pol-core/pol/region.cpp index d78986243..8bc4698f8 100644 --- a/pol-core/pol/region.cpp +++ b/pol-core/pol/region.cpp @@ -7,17 +7,21 @@ #include "region.h" -#include "realms.h" -#include "uworld.h" -#include "globals/uvars.h" +#include +#include #include "../bscript/berror.h" #include "../bscript/impstr.h" - #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/fileutil.h" #include "../clib/stlutil.h" +#include "globals/uvars.h" +#include "poltype.h" +#include "proplist.h" +#include "realms.h" +#include "realms/realm.h" +#include "zone.h" namespace Pol { @@ -28,9 +32,7 @@ Region::Region( Clib::ConfigElem& elem, RegionId id ) { } -Region::~Region() -{ -} +Region::~Region() {} size_t Region::estimateSize() const { @@ -242,4 +244,4 @@ void read_region_data( RegionGroupBase& grp, const char* preferred_filename, } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/region.h b/pol-core/pol/region.h index 27b1f40a3..475e274d6 100644 --- a/pol-core/pol/region.h +++ b/pol-core/pol/region.h @@ -7,14 +7,14 @@ #ifndef REGION_H #define REGION_H +#include +#include + #include "../clib/compilerspecifics.h" #include "poltype.h" #include "proplist.h" #include "zone.h" -#include -#include - namespace Pol { namespace Bscript diff --git a/pol-core/pol/repsys.cpp b/pol-core/pol/repsys.cpp index c57b7505f..d6c1e41e9 100644 --- a/pol-core/pol/repsys.cpp +++ b/pol-core/pol/repsys.cpp @@ -9,29 +9,31 @@ #include "repsys.h" -#include "repsys_cfg.h" + +#include +#include #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/cfgsect.h" #include "../clib/logfacility.h" -#include "../clib/stlutil.h" - +#include "../clib/rawtypes.h" #include "cmbtcfg.h" -#include "mobile/charactr.h" #include "fnsearch.h" +#include "globals/settings.h" +#include "globals/state.h" #include "guilds.h" +#include "mobile/charactr.h" #include "mobile/npc.h" #include "npctmpl.h" +#include "party.h" +#include "pktdef.h" +#include "polsig.h" +#include "repsys_cfg.h" #include "schedule.h" #include "syshook.h" #include "ufunc.h" -#include "globals/uvars.h" -#include "globals/state.h" #include "uworld.h" -#include "party.h" - -#include // BUGS: // it looks like you can restart someone's aggressor timer by toggling war mode and setting @@ -42,8 +44,7 @@ namespace Pol { namespace Core { - -///Reputation System +/// Reputation System /// [1] Reputation System Configuration /// Reputation System Configuration is read from config/repsys.cfg @@ -759,10 +760,8 @@ void Character::restart_criminal_timer( Core::polclock_t until ) { if ( criminal_until_ < Core::polclock() ) { - Core::WorldIterator::InRange( x, y, realm, 32, [&]( Character* chr ) - { - NpcPropagateCriminal( chr, this ); - } ); + Core::WorldIterator::InRange( + x, y, realm, 32, [&]( Character* chr ) { NpcPropagateCriminal( chr, this ); } ); } criminal_until_ = until; } @@ -1098,9 +1097,8 @@ void Character::make_criminal( int level ) if ( level ) { Core::polclock_t timeout_at = - Core::polclock() + - level * Core::settingsManager.repsys_cfg.General.CriminalFlagInterval * - Core::POLCLOCKS_PER_SEC; + Core::polclock() + level * Core::settingsManager.repsys_cfg.General.CriminalFlagInterval * + Core::POLCLOCKS_PER_SEC; restart_criminal_timer( timeout_at ); Core::RepSystem::schedule_repsys_task( this, timeout_at + 1 ); @@ -1120,7 +1118,7 @@ void Character::make_criminal( int level ) void Character::make_murderer( bool newval ) { - bool refresh = ( mob_flags_.get ( MOB_FLAGS::MURDERER ) != newval ); + bool refresh = ( mob_flags_.get( MOB_FLAGS::MURDERER ) != newval ); set_dirty(); mob_flags_.change( MOB_FLAGS::MURDERER, newval ); diff --git a/pol-core/pol/resource.cpp b/pol-core/pol/resource.cpp index cfb4eb772..18a164faf 100644 --- a/pol-core/pol/resource.cpp +++ b/pol-core/pol/resource.cpp @@ -7,39 +7,29 @@ #include "resource.h" -#include "../plib/maptile.h" -#include "../plib/systemstate.h" - -#include "item/itemdesc.h" -#include "polcfg.h" -#include "polclock.h" -#include "realms.h" -#include "realms/realm.h" -#include "schedule.h" -#include "globals/uvars.h" -#include "globals/state.h" - #include "../bscript/berror.h" -#include "../bscript/bobject.h" -#include "../bscript/impstr.h" - #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" #include "../clib/passert.h" #include "../clib/random.h" -#include "../clib/stlutil.h" #include "../clib/streamsaver.h" - -#include +#include "../plib/maptile.h" +#include "../plib/systemstate.h" +#include "globals/state.h" +#include "globals/uvars.h" +#include "item/itemdesc.h" +#include "polcfg.h" +#include "polclock.h" +#include "polsig.h" +#include "realms/realm.h" namespace Pol { namespace Core { - -///Resource Management +/// Resource Management ResourceRegion::ResourceRegion( Clib::ConfigElem& elem, RegionId id ) : Region( elem, id ), tilecount_( 0 ), @@ -439,8 +429,11 @@ void read_resources_dat() void ResourceDef::write( Clib::StreamWriter& sw ) const { - sw() << "GlobalResourcePool " << name() << '\n' << "{" << '\n' << "\tUnits\t" << current_units_ - << '\n' << "}" << '\n' << '\n'; + sw() << "GlobalResourcePool " << name() << '\n' + << "{" << '\n' + << "\tUnits\t" << current_units_ << '\n' + << "}" << '\n' + << '\n'; for ( unsigned i = 0; i < regions_.size(); ++i ) { @@ -463,9 +456,13 @@ size_t ResourceDef::estimateSize() const void ResourceRegion::write( Clib::StreamWriter& sw, const std::string& resource_name ) const { - sw() << "RegionalResourcePool " << resource_name << '\n' << "{" << '\n' << "\tName\t" << name_ - << '\n' << "\tUnits\t" << units_ << '\n' << "#\t(regions/" << resource_name - << ".cfg: Capacity is " << capacity_ << ")" << '\n' << "}" << '\n' << '\n'; + sw() << "RegionalResourcePool " << resource_name << '\n' + << "{" << '\n' + << "\tName\t" << name_ << '\n' + << "\tUnits\t" << units_ << '\n' + << "#\t(regions/" << resource_name << ".cfg: Capacity is " << capacity_ << ")" << '\n' + << "}" << '\n' + << '\n'; // sw.flush(); } @@ -475,9 +472,8 @@ size_t ResourceRegion::estimateSize() const Region::estimateSize() + 5 * sizeof( unsigned int ) /*tilecount_ units_per_area_ seconds_per_regrow_ capacity_ units_*/ + sizeof( time_t ) /*last_regen_*/ - + - ( sizeof( unsigned int ) + sizeof( unsigned short ) + ( sizeof( void* ) * 3 + 1 ) / 2 ) * - depletions_.size(); + + ( sizeof( unsigned int ) + sizeof( unsigned short ) + ( sizeof( void* ) * 3 + 1 ) / 2 ) * + depletions_.size(); return size; } diff --git a/pol-core/pol/resource.h b/pol-core/pol/resource.h index 8d7da814c..d823fb3d6 100644 --- a/pol-core/pol/resource.h +++ b/pol-core/pol/resource.h @@ -7,13 +7,34 @@ #ifndef RESOURCE_H #define RESOURCE_H -#include "poltype.h" -#include "region.h" - #include +#include #include #include -#include +#include + +#include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" +#include "poltype.h" +#include "region.h" +#include "zone.h" + +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +} // namespace Bscript +namespace Clib +{ +class ConfigElem; +class StreamWriter; +} // namespace Clib +namespace Realms +{ +class Realm; +} // namespace Realms +} // namespace Pol namespace Pol { diff --git a/pol-core/pol/savedata.cpp b/pol-core/pol/savedata.cpp index e36cb7d1d..50becc286 100644 --- a/pol-core/pol/savedata.cpp +++ b/pol-core/pol/savedata.cpp @@ -7,28 +7,26 @@ #include "savedata.h" -#include "item/item.h" -#include "item/itemdesc.h" -#include "loaddata.h" -#include "polcfg.h" -#include "storage.h" -#include "globals/uvars.h" -#include "globals/object_storage.h" +#include +#include +#include #include "../clib/clib_endian.h" #include "../clib/fileutil.h" #include "../clib/iohelp.h" #include "../clib/logfacility.h" +#include "../clib/rawtypes.h" +#include "../clib/streamsaver.h" #include "../clib/strutil.h" #include "../clib/timer.h" #include "../plib/systemstate.h" - -#ifdef __unix__ -#include -#endif - -#include -#include +#include "globals/object_storage.h" +#include "globals/uvars.h" +#include "item/item.h" +#include "item/itemdesc.h" +#include "objecthash.h" +#include "storage.h" +#include "uobject.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // disable deprecation warning for unlink, strerror @@ -224,8 +222,8 @@ bool commit_incremental( const std::string& basename ) if ( rename( ndtfile.c_str(), datfile.c_str() ) ) { int err = errno; - POLLOG_ERROR.Format( "Unable to rename {} to {}: {} ({})\n" ) << ndtfile << datfile - << strerror( err ) << err; + POLLOG_ERROR.Format( "Unable to rename {} to {}: {} ({})\n" ) + << ndtfile << datfile << strerror( err ) << err; } } @@ -325,4 +323,4 @@ void commit_incremental_saves() } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/savedata.h b/pol-core/pol/savedata.h index 21af42bd1..410b192c8 100644 --- a/pol-core/pol/savedata.h +++ b/pol-core/pol/savedata.h @@ -7,11 +7,12 @@ #ifndef SAVEDATA_H #define SAVEDATA_H -#include "../clib/streamsaver.h" - +#include +#include #include #include -#include + +#include "../clib/streamsaver.h" namespace Pol { diff --git a/pol-core/pol/schedule.cpp b/pol-core/pol/schedule.cpp index 65c787d32..a8cd90b66 100644 --- a/pol-core/pol/schedule.cpp +++ b/pol-core/pol/schedule.cpp @@ -6,19 +6,17 @@ #include "schedule.h" -#include "polcfg.h" -#include "globals/uvars.h" -#include "globals/state.h" +#include +#include "../clib/logfacility.h" #include "../clib/passert.h" #include "../clib/tracebuf.h" -#include "../clib/logfacility.h" - #include "../plib/systemstate.h" - -#include -#include -#include +#include "globals/state.h" +#include "globals/uvars.h" +#include "polclock.h" +#include "polsig.h" +#include "profile.h" namespace Pol { @@ -45,9 +43,7 @@ ScheduledTask::ScheduledTask( polclock_t next_run_clock ) { } -ScheduledTask::~ScheduledTask() -{ -} +ScheduledTask::~ScheduledTask() {} void ScheduledTask::cancel() { diff --git a/pol-core/pol/schedule.h b/pol-core/pol/schedule.h index b59e1dfa9..f5c9fca8f 100644 --- a/pol-core/pol/schedule.h +++ b/pol-core/pol/schedule.h @@ -8,12 +8,12 @@ #ifndef __SCHEDULE_H #define __SCHEDULE_H -#include "../clib/compilerspecifics.h" -#include "polclock.h" - #include #include +#include "../clib/compilerspecifics.h" +#include "polclock.h" + namespace Pol { namespace Core @@ -31,6 +31,7 @@ public: static bool is_dirty() { return dirty_; } static void cleanse() { dirty_ = false; } static void mark_dirty() { dirty_ = true; } + private: static bool dirty_; }; diff --git a/pol-core/pol/scrdef.cpp b/pol-core/pol/scrdef.cpp index 40ba09504..67b83fb02 100644 --- a/pol-core/pol/scrdef.cpp +++ b/pol-core/pol/scrdef.cpp @@ -6,14 +6,9 @@ #include "scrdef.h" -#include "scrstore.h" -#include "../bscript/eprog.h" #include "../bscript/escrutil.h" - #include "../clib/fileutil.h" #include "../clib/logfacility.h" -#include "../clib/refptr.h" - #include "../plib/pkg.h" namespace Pol @@ -147,4 +142,4 @@ size_t ScriptDef::estimatedSize() const return sizeof( ScriptDef ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/scrdef.h b/pol-core/pol/scrdef.h index 4983085ee..e9adf6d50 100644 --- a/pol-core/pol/scrdef.h +++ b/pol-core/pol/scrdef.h @@ -7,9 +7,11 @@ #ifndef SCRDEF_H #define SCRDEF_H -#include "../clib/boostutils.h" +#include #include +#include "../clib/boostutils.h" + namespace Pol { namespace Plib diff --git a/pol-core/pol/scrsched.cpp b/pol-core/pol/scrsched.cpp index 70357f131..b8eb9dd17 100644 --- a/pol-core/pol/scrsched.cpp +++ b/pol-core/pol/scrsched.cpp @@ -15,21 +15,18 @@ #include "scrsched.h" -#include "scrdef.h" -#include "scrstore.h" - -#include "exscrobj.h" -#include "polcfg.h" -#include "polclock.h" -#include "poldbg.h" +#include +#include +#include +#include "../bscript/berror.h" +#include "../bscript/bobject.h" +#include "../clib/logfacility.h" +#include "../clib/passert.h" +#include "../clib/refptr.h" +#include "../plib/systemstate.h" +#include "globals/script_internals.h" #include "globals/state.h" - -#include "uoexec.h" -#include "module/uomod.h" -#include "module/osmod.h" - -// The ones below are required for the add_common_exmods(). Can't we move this somewhere else...? #include "module/attributemod.h" #include "module/basiciomod.h" #include "module/basicmod.h" @@ -39,33 +36,22 @@ #include "module/datastore.h" #include "module/filemod.h" #include "module/guildmod.h" +#include "module/httpmod.h" #include "module/mathmod.h" -#include "module/npcmod.h" +#include "module/osmod.h" #include "module/partymod.h" #include "module/polsystemmod.h" -#include "module/storagemod.h" #include "module/sqlmod.h" +#include "module/storagemod.h" #include "module/unimod.h" +#include "module/uomod.h" #include "module/utilmod.h" #include "module/vitalmod.h" -#include "unicode.h" - -#include "../bscript/bobject.h" -#include "../bscript/berror.h" -#include "../bscript/eprog.h" -#include "../bscript/executor.h" -#include "../bscript/impstr.h" - -#include "../clib/logfacility.h" -#include "../clib/clib_endian.h" -#include "../clib/passert.h" -#include "../clib/stlutil.h" -#include "../clib/strutil.h" - -#include "../plib/systemstate.h" - -#include -#include +#include "polsig.h" +#include "profile.h" +#include "scrdef.h" +#include "scrstore.h" +#include "uoexec.h" namespace Pol { @@ -73,20 +59,20 @@ namespace Core { bool find_uoexec( unsigned int pid, UOExecutor** pp_uoexec ) { - return scriptScheduler.find_exec(pid, pp_uoexec); + return scriptScheduler.find_exec( pid, pp_uoexec ); } void run_ready() { - scriptScheduler.run_ready(); + scriptScheduler.run_ready(); } void check_blocked( polclock_t* pclocksleft ) { polclock_t now_clock = polclock(); - stateManager.profilevars.sleep_cycles += scriptScheduler.getHoldlist().size() + - scriptScheduler.getNoTimeoutHoldlist().size(); + stateManager.profilevars.sleep_cycles += + scriptScheduler.getHoldlist().size() + scriptScheduler.getNoTimeoutHoldlist().size(); polclock_t clocksleft = POLCLOCKS_PER_SEC * 60; for ( ;; ) { @@ -262,7 +248,7 @@ Module::UOExecutorModule* start_script( const ScriptDef& script, Bscript::BObjec // throw runtime_error( "Error starting script." ); } - + scriptScheduler.schedule( ex.release() ); return uoemod; @@ -396,7 +382,7 @@ Bscript::BObjectImp* run_executor_to_completion( UOExecutor& ex, const ScriptDef ex.set_running_to_completion( true ); Clib::scripts_thread_script = ex.scriptname(); - + int i = 0; bool reported = false; while ( ex.runnable() ) @@ -783,4 +769,4 @@ void list_crit_scripts() list_crit_scripts( "ran", scriptScheduler.getRanlist() ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/scrsched.h b/pol-core/pol/scrsched.h index be3f2a83a..d52a1b519 100644 --- a/pol-core/pol/scrsched.h +++ b/pol-core/pol/scrsched.h @@ -26,8 +26,8 @@ class UOExecutorModule; } namespace Core { -class UOExecutor; class ScriptDef; +class UOExecutor; void step_scripts( polclock_t* clocksleft, bool* pactivity ); void start_script( const char* filename, Bscript::BObjectImp* param0, diff --git a/pol-core/pol/scrstore.cpp b/pol-core/pol/scrstore.cpp index 0d8e5ae1c..caa2701a2 100644 --- a/pol-core/pol/scrstore.cpp +++ b/pol-core/pol/scrstore.cpp @@ -7,16 +7,17 @@ #include "scrstore.h" -#include "scrdef.h" +#include #include "../bscript/eprog.h" - -#include "polcfg.h" -#include "globals/script_internals.h" -#include "globals/state.h" - #include "../clib/logfacility.h" +#include "../clib/rawtypes.h" #include "../clib/strutil.h" #include "../plib/systemstate.h" +#include "globals/script_internals.h" +#include "globals/state.h" +#include "polcfg.h" +#include "profile.h" +#include "scrdef.h" namespace Pol @@ -71,8 +72,7 @@ ref_ptr find_script( const std::string& name, bool comp { std::string tmpname = name; Clib::mklower( tmpname ); - scriptScheduler.scrstore.insert( - ScriptStorage::value_type( tmpname.c_str(), program ) ); + scriptScheduler.scrstore.insert( ScriptStorage::value_type( tmpname.c_str(), program ) ); } return program; @@ -103,8 +103,7 @@ ref_ptr find_script2( const ScriptDef& script, bool com { std::string tmpname = script.name(); Clib::mklower( tmpname ); - scriptScheduler.scrstore.insert( - ScriptStorage::value_type( tmpname.c_str(), program ) ); + scriptScheduler.scrstore.insert( ScriptStorage::value_type( tmpname.c_str(), program ) ); } return program; diff --git a/pol-core/pol/scrstore.h b/pol-core/pol/scrstore.h index 8a5784085..5cf466fe2 100644 --- a/pol-core/pol/scrstore.h +++ b/pol-core/pol/scrstore.h @@ -7,10 +7,10 @@ #ifndef SCRSTORE_H #define SCRSTORE_H -#include "../clib/refptr.h" - #include +#include "../clib/refptr.h" + namespace Pol { namespace Bscript diff --git a/pol-core/pol/skilladv.cpp b/pol-core/pol/skilladv.cpp index ff12aaa96..6cd350ccc 100644 --- a/pol-core/pol/skilladv.cpp +++ b/pol-core/pol/skilladv.cpp @@ -102,4 +102,4 @@ unsigned int base_to_raw( unsigned short base ) return raw; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/sngclick.cpp b/pol-core/pol/sngclick.cpp index 1345adb85..924896a1d 100644 --- a/pol-core/pol/sngclick.cpp +++ b/pol-core/pol/sngclick.cpp @@ -7,21 +7,21 @@ #include "sngclick.h" -#include "network/client.h" -#include "network/msghandl.h" +#include +#include +#include "../clib/clib_endian.h" +#include "../clib/passert.h" +#include "containr.h" #include "mobile/charactr.h" -#include "mobile/npc.h" - +#include "network/client.h" #include "pktin.h" #include "uconst.h" #include "ufunc.h" #include "ufuncstd.h" -#include "ustruct.h" +#include "uobject.h" #include "uworld.h" -#include "containr.h" -#include namespace Pol { diff --git a/pol-core/pol/sockio.cpp b/pol-core/pol/sockio.cpp index a16552ea8..112ff3a7b 100644 --- a/pol-core/pol/sockio.cpp +++ b/pol-core/pol/sockio.cpp @@ -6,20 +6,25 @@ #include "sockio.h" -#include "../clib/clib_endian.h" -#include "../clib/clib.h" -#include "../clib/strutil.h" -#include "../clib/logfacility.h" - -#include "globals/network.h" - #ifdef __unix__ #include + struct utsname my_utsname; #endif #include #include +#include +#include +#include + +#include "../clib/clib.h" +#include "../clib/clib_endian.h" +#include "../clib/logfacility.h" +#include "../clib/strutil.h" +#include "globals/network.h" +#include "sockets.h" + namespace Pol { @@ -243,7 +248,5 @@ PolSocket::PolSocket() FD_ZERO( &err_fd ); FD_ZERO( &send_fd ); } - - } } diff --git a/pol-core/pol/speech.cpp b/pol-core/pol/speech.cpp index 9920424b7..483403cfe 100644 --- a/pol-core/pol/speech.cpp +++ b/pol-core/pol/speech.cpp @@ -10,49 +10,36 @@ */ -#include "accounts/account.h" -#include "network/client.h" -#include "network/packets.h" -#include "network/packethelper.h" -#include "network/msghandl.h" - -#include "mobile/npc.h" +#include +#include +#include +#include +#include "../bscript/bobject.h" +#include "../bscript/impstr.h" +#include "../clib/clib_endian.h" +#include "../clib/logfacility.h" +#include "../clib/random.h" +#include "../clib/rawtypes.h" +#include "../plib/systemstate.h" +#include "globals/settings.h" +#include "globals/uvars.h" +#include "guilds.h" #include "listenpt.h" #include "mkscrobj.h" +#include "mobile/charactr.h" +#include "mobile/npc.h" +#include "network/client.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "pktdef.h" #include "pktin.h" -#include "pktout.h" -#include "polcfg.h" -#include "sockio.h" #include "syshook.h" #include "textcmd.h" #include "tildecmd.h" -#include "globals/uvars.h" -#include "globals/network.h" -#include "ufunc.h" #include "ufuncstd.h" #include "uworld.h" -#include "guilds.h" - -#include "../bscript/impstr.h" - -#include "../clib/clib_endian.h" -#include "../clib/clib.h" -#include "../clib/random.h" -#include "../clib/strutil.h" -#include "../clib/logfacility.h" -#include "../clib/fdump.h" - -#include "../plib/systemstate.h" - -#include -#include -#include - -#include -#include - namespace Pol { namespace Core @@ -146,8 +133,7 @@ void handle_processed_speech( Network::Client* client, char* textbuf, int textbu else range = Core::settingsManager.ssopt.speech_range; Core::WorldIterator::InRange( - chr->x, chr->y, chr->realm, range, [&]( Mobile::Character* other_chr ) - { + chr->x, chr->y, chr->realm, range, [&]( Mobile::Character* other_chr ) { Network::Client* client2 = other_chr->client; if ( client == client2 ) return; @@ -170,8 +156,7 @@ void handle_processed_speech( Network::Client* client, char* textbuf, int textbu if ( !chr->dead() ) { Core::WorldIterator::InRange( - chr->x, chr->y, chr->realm, range, [&]( Mobile::Character* otherchr ) - { + chr->x, chr->y, chr->realm, range, [&]( Mobile::Character* otherchr ) { Mobile::NPC* npc = static_cast( otherchr ); npc->on_pc_spoke( chr, textbuf, type ); } ); @@ -179,8 +164,7 @@ void handle_processed_speech( Network::Client* client, char* textbuf, int textbu else { Core::WorldIterator::InRange( - chr->x, chr->y, chr->realm, range, [&]( Mobile::Character* otherchr ) - { + chr->x, chr->y, chr->realm, range, [&]( Mobile::Character* otherchr ) { Mobile::NPC* npc = static_cast( otherchr ); npc->on_ghost_pc_spoke( chr, textbuf, type ); } ); @@ -356,8 +340,7 @@ void SendUnicodeSpeech( Network::Client* client, PKTIN_AD* msgin, u16* wtext, si else range = Core::settingsManager.ssopt.speech_range; Core::WorldIterator::InRange( - chr->x, chr->y, chr->realm, range, [&]( Mobile::Character* otherchr ) - { + chr->x, chr->y, chr->realm, range, [&]( Mobile::Character* otherchr ) { Network::Client* client2 = otherchr->client; if ( client == client2 ) return; @@ -380,8 +363,7 @@ void SendUnicodeSpeech( Network::Client* client, PKTIN_AD* msgin, u16* wtext, si if ( !chr->dead() ) { Core::WorldIterator::InRange( - chr->x, chr->y, chr->realm, range, [&]( Mobile::Character* otherchr ) - { + chr->x, chr->y, chr->realm, range, [&]( Mobile::Character* otherchr ) { Mobile::NPC* npc = static_cast( otherchr ); npc->on_pc_spoke( chr, ntext, msgin->type, wtext, msgin->lang, speechtokens ); } ); @@ -389,8 +371,7 @@ void SendUnicodeSpeech( Network::Client* client, PKTIN_AD* msgin, u16* wtext, si else { Core::WorldIterator::InRange( - chr->x, chr->y, chr->realm, range, [&]( Mobile::Character* otherchr ) - { + chr->x, chr->y, chr->realm, range, [&]( Mobile::Character* otherchr ) { Mobile::NPC* npc = static_cast( otherchr ); npc->on_ghost_pc_spoke( chr, ntext, msgin->type, wtext, msgin->lang, speechtokens ); } ); diff --git a/pol-core/pol/spelbook.cpp b/pol-core/pol/spelbook.cpp index ac67c365c..45c069524 100644 --- a/pol-core/pol/spelbook.cpp +++ b/pol-core/pol/spelbook.cpp @@ -10,27 +10,23 @@ #include "spelbook.h" -#include "item/itemdesc.h" -#include "spells.h" - -#include "mobile/charactr.h" -#include "network/packets.h" -#include "network/packethelper.h" -#include "network/clienttransmit.h" -#include "network/client.h" -#include "objtype.h" -#include "pktboth.h" -#include "polcfg.h" -#include "polclass.h" -#include "ufunc.h" +#include +#include #include "../clib/cfgelem.h" #include "../clib/logfacility.h" #include "../clib/streamsaver.h" -#include "../clib/clib_endian.h" #include "../plib/systemstate.h" - -#include +#include "baseobject.h" +#include "globals/uvars.h" +#include "item/itemdesc.h" +#include "mobile/charactr.h" +#include "network/client.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "polclass.h" +#include "ufunc.h" +#include "uobject.h" namespace Pol { @@ -61,9 +57,7 @@ Spellbook::Spellbook( const Items::SpellbookDesc& descriptor ) bitwise_contents[i] = 0; } -Spellbook::~Spellbook() -{ -} +Spellbook::~Spellbook() {} size_t Spellbook::estimatedSize() const { @@ -333,7 +327,8 @@ void Spellbook::calc_current_bitwise_contents() } } -USpellScroll::USpellScroll( const Items::ItemDesc& itemdesc ) : Item( itemdesc, UOBJ_CLASS::CLASS_ITEM ) +USpellScroll::USpellScroll( const Items::ItemDesc& itemdesc ) + : Item( itemdesc, UOBJ_CLASS::CLASS_ITEM ) { } @@ -403,10 +398,10 @@ void send_spellbook_contents( Network::Client* client, Spellbook& spellbook ) { msg->Write( 0x7FFFFFFFu - spellnumber ); msg->WriteFlipped( objtype ); - msg->offset++; // unk6 + msg->offset++; // unk6 msg->WriteFlipped( spellnumber ); // amount - msg->WriteFlipped( 1u ); // x - msg->WriteFlipped( 1u ); // y + msg->WriteFlipped( 1u ); // x + msg->WriteFlipped( 1u ); // y if ( client->ClientType & Network::CLIENTTYPE_6017 ) msg->Write( 0u ); // slotindex msg->Write( spellbook.serial_ext ); diff --git a/pol-core/pol/spelbook.h b/pol-core/pol/spelbook.h index 5bc640286..cb1ed1309 100644 --- a/pol-core/pol/spelbook.h +++ b/pol-core/pol/spelbook.h @@ -10,6 +10,9 @@ #ifndef __SPELBOOK_H #define __SPELBOOK_H +#include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" +#include "item/item.h" #ifndef CONTAINR_H #include "containr.h" #endif @@ -19,6 +22,23 @@ namespace Pol namespace Network { class Client; +namespace Pol +{ +namespace Bscript +{ +class BObjectImp; +class Executor; +} // namespace Bscript +namespace Clib +{ +class ConfigElem; +class StreamWriter; +} // namespace Clib +namespace Items +{ +class ItemDesc; +} // namespace Items +} // namespace Pol } namespace Items { diff --git a/pol-core/pol/spells.cpp b/pol-core/pol/spells.cpp index 97b17ef79..c9ab35029 100644 --- a/pol-core/pol/spells.cpp +++ b/pol-core/pol/spells.cpp @@ -8,37 +8,38 @@ #include "spells.h" -#include "spelbook.h" -#include "item/itemdesc.h" -#include "mobile/charactr.h" -#include "network/client.h" - -#include "polclass.h" - -#include "miscrgn.h" -#include "mkscrobj.h" -#include "objtype.h" -#include "pktin.h" -#include "polcfg.h" -#include "scrstore.h" -#include "syshook.h" -#include "target.h" -#include "ufunc.h" -#include "umanip.h" -#include "globals/state.h" -#include "vital.h" - -#include "../plib/pkg.h" -#include "../plib/systemstate.h" +#include +#include +#include +#include "../bscript/eprog.h" #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" -#include "../bscript/eprog.h" - -#include -#include +#include "../clib/refptr.h" +#include "../plib/pkg.h" +#include "../plib/systemstate.h" +#include "containr.h" +#include "globals/state.h" +#include "globals/uvars.h" +#include "item/item.h" +#include "item/itemdesc.h" +#include "layers.h" +#include "miscrgn.h" +#include "mkscrobj.h" +#include "mobile/charactr.h" +#include "network/client.h" +#include "pktin.h" +#include "polclass.h" +#include "polsig.h" +#include "scrstore.h" +#include "skillid.h" +#include "spelbook.h" +#include "syshook.h" +#include "ufunc.h" +#include "umanip.h" +#include "vital.h" namespace Pol { @@ -110,9 +111,7 @@ bool hands_are_free( Mobile::Character* chr ) return true; } -USpellParams::USpellParams() : manacost( 0 ), difficulty( 0 ), pointvalue( 0 ), delay( 0 ) -{ -} +USpellParams::USpellParams() : manacost( 0 ), difficulty( 0 ), pointvalue( 0 ), delay( 0 ) {} USpellParams::USpellParams( Clib::ConfigElem& elem ) : manacost( elem.remove_ushort( "MANA" ) ), @@ -123,9 +122,7 @@ USpellParams::USpellParams( Clib::ConfigElem& elem ) } -SpellCircle::SpellCircle( Clib::ConfigElem& elem ) : params( elem ) -{ -} +SpellCircle::SpellCircle( Clib::ConfigElem& elem ) : params( elem ) {} USpell::USpell( Clib::ConfigElem& elem, Plib::Package* pkg ) : pkg_( pkg ), diff --git a/pol-core/pol/spells.h b/pol-core/pol/spells.h index 5d503a47c..7aaf9747b 100644 --- a/pol-core/pol/spells.h +++ b/pol-core/pol/spells.h @@ -8,14 +8,17 @@ #define SPELLS_H #include -#include #include +#include +#include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" #include "action.h" -#include "scrdef.h" -#include "schedule.h" -#include "reftypes.h" #include "globals/uvars.h" +#include "polclock.h" +#include "reftypes.h" +#include "schedule.h" +#include "scrdef.h" namespace Pol { diff --git a/pol-core/pol/sqlscrobj.cpp b/pol-core/pol/sqlscrobj.cpp index 656dc7804..005e9a5be 100644 --- a/pol-core/pol/sqlscrobj.cpp +++ b/pol-core/pol/sqlscrobj.cpp @@ -6,34 +6,32 @@ #include "sqlscrobj.h" +#include +#include + +#include "../bscript/bobject.h" + + #ifdef HAVE_MYSQL -#include - -#include "../clib/strutil.h" -#include "../clib/stlutil.h" -#include "../clib/clib_endian.h" -#include "../clib/threadhelp.h" -#include "../clib/logfacility.h" -#include "../clib/esignal.h" - -#include "../bscript/executor.h" -#include "../bscript/execmodl.h" #include "../bscript/berror.h" #include "../bscript/impstr.h" #include "../bscript/objmembers.h" #include "../bscript/objmethods.h" - -#include "../plib/pkg.h" +#include "../clib/esignal.h" +#include "../clib/logfacility.h" +#include "../clib/threadhelp.h" #include "globals/network.h" // std::regex support is broken in GCC < 4.9. This define is a workaround for GCC 4.8. // TODO: remove this in future and just use std:: namespace #ifndef USE_BOOST_REGEX #include + #define REGEX_NSPACE std #else #include + #define REGEX_NSPACE boost #endif @@ -117,9 +115,7 @@ BObjectRef BSQLRow::OperSubscript( const BObject& obj ) return BObjectRef( new BError( "SQLRow keys must be integer" ) ); } } -BSQLRow::~BSQLRow() -{ -} +BSQLRow::~BSQLRow() {} Bscript::BObjectImp* BSQLRow::copy() const { return new BSQLRow( _result, _row, _fields ); @@ -182,9 +178,7 @@ int BSQLResultSet::affected_rows() const { return _affected_rows; } -BSQLResultSet::~BSQLResultSet() -{ -} +BSQLResultSet::~BSQLResultSet() {} bool BSQLResultSet::isTrue() const { return true; @@ -240,9 +234,7 @@ BSQLConnection::BSQLConnection( std::shared_ptr conn ) { } -BSQLConnection::~BSQLConnection() -{ -} +BSQLConnection::~BSQLConnection() {} std::string BSQLConnection::getStringRep() const { return "SQLConnection"; @@ -415,9 +407,7 @@ Bscript::BObjectImp* BSQLConnection::copy() const return new BSQLConnection( _conn ); } -BSQLConnection::ConnectionWrapper::ConnectionWrapper() : _conn( nullptr ) -{ -} +BSQLConnection::ConnectionWrapper::ConnectionWrapper() : _conn( nullptr ) {} BSQLConnection::ConnectionWrapper::~ConnectionWrapper() { if ( _conn ) @@ -435,12 +425,8 @@ MYSQL* BSQLConnection::ConnectionWrapper::ptr() return _conn; }; -ResultWrapper::ResultWrapper( MYSQL_RES* res ) : _result( res ) -{ -} -ResultWrapper::ResultWrapper() : _result( nullptr ) -{ -} +ResultWrapper::ResultWrapper( MYSQL_RES* res ) : _result( res ) {} +ResultWrapper::ResultWrapper() : _result( nullptr ) {} ResultWrapper::~ResultWrapper() { if ( _result ) @@ -482,12 +468,8 @@ void sql_service_thread_stub() } } -SQLService::SQLService() -{ -} -SQLService::~SQLService() -{ -} +SQLService::SQLService() {} +SQLService::~SQLService() {} void SQLService::stop() { _msgs.cancel(); diff --git a/pol-core/pol/sqlscrobj.h b/pol-core/pol/sqlscrobj.h index 113d68686..f9f33c5f6 100644 --- a/pol-core/pol/sqlscrobj.h +++ b/pol-core/pol/sqlscrobj.h @@ -15,7 +15,6 @@ #ifdef HAVE_MYSQL -#include "../bscript/bobject.h" #ifdef _WIN32 #include "../clib/Header_Windows.h" #include @@ -23,11 +22,22 @@ #include #endif -#include "../clib/message_queue.h" - #include #include +#include +#include "../bscript/bobject.h" +#include "../clib/compilerspecifics.h" +#include "../clib/message_queue.h" +#include "../clib/rawtypes.h" + +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +} // namespace Pol namespace Pol { namespace Core diff --git a/pol-core/pol/ssopt.cpp b/pol-core/pol/ssopt.cpp index aca54729e..ca2a61c6c 100644 --- a/pol-core/pol/ssopt.cpp +++ b/pol-core/pol/ssopt.cpp @@ -23,18 +23,19 @@ #include "ssopt.h" -#include "pktdef.h" -#include "globals/settings.h" -#include "mobile/attribute.h" +#include +#include +#include +#include +#include #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/fileutil.h" -#include "../clib/rawtypes.h" #include "../clib/logfacility.h" - -#include +#include "globals/settings.h" +#include "pktdef.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // deprecation warning for sprintf, strtok @@ -209,4 +210,4 @@ void ServSpecOpt::ssopt_parse_totalstats( Clib::ConfigElem& elem ) */ } } -} \ No newline at end of file +} diff --git a/pol-core/pol/stackcfg.cpp b/pol-core/pol/stackcfg.cpp index 9259687bf..b1985fda6 100644 --- a/pol-core/pol/stackcfg.cpp +++ b/pol-core/pol/stackcfg.cpp @@ -6,18 +6,16 @@ #include "stackcfg.h" -#include "../plib/pkg.h" -#include "../plib/systemstate.h" +#include -#include "../clib/fileutil.h" -#include "../clib/stlutil.h" -#include "../clib/strutil.h" #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" - +#include "../clib/fileutil.h" +#include "../clib/stlutil.h" +#include "../plib/pkg.h" +#include "../plib/systemstate.h" #include "globals/uvars.h" -#include namespace Pol { diff --git a/pol-core/pol/startloc.cpp b/pol-core/pol/startloc.cpp index a57de9686..b00947fc2 100644 --- a/pol-core/pol/startloc.cpp +++ b/pol-core/pol/startloc.cpp @@ -28,4 +28,4 @@ size_t StartingLocation::estimateSize() const return size; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/statmsg.cpp b/pol-core/pol/statmsg.cpp index 41f8a1849..3634d7262 100644 --- a/pol-core/pol/statmsg.cpp +++ b/pol-core/pol/statmsg.cpp @@ -12,19 +12,15 @@ #include "statmsg.h" #include "../clib/clib.h" - +#include "../clib/rawtypes.h" +#include "globals/network.h" +#include "globals/settings.h" #include "mobile/charactr.h" #include "network/client.h" -#include "network/packets.h" #include "network/packethelper.h" -#include "network/clienttransmit.h" - -#include "sockio.h" -#include "pktboth.h" +#include "network/packets.h" #include "ufunc.h" #include "uoclient.h" -#include "globals/settings.h" -#include "globals/network.h" namespace Pol @@ -228,7 +224,7 @@ void send_stat_locks( Network::Client* client, Mobile::Character* chr ) PacketOut msg; msg->WriteFlipped( 12u ); - msg->offset += 2; // sub + msg->offset += 2; // sub msg->Write( 0x02u ); // 2D Client = 0x02, KR = 0x05 msg->Write( chr->serial_ext ); msg->offset++; // unk diff --git a/pol-core/pol/storage.cpp b/pol-core/pol/storage.cpp index 8d3ea2dbe..6d6eb6374 100644 --- a/pol-core/pol/storage.cpp +++ b/pol-core/pol/storage.cpp @@ -7,29 +7,32 @@ #include "storage.h" -#include "item/item.h" -#include "containr.h" -#include "loaddata.h" - -#include "mkscrobj.h" -#include "fnsearch.h" -#include "polcfg.h" -#include "ufunc.h" -#include "globals/uvars.h" -#include "globals/object_storage.h" +#include +#include +#include +#include "../bscript/berror.h" +#include "../bscript/bobject.h" #include "../bscript/contiter.h" #include "../bscript/impstr.h" -#include "../bscript/berror.h" - -#include "../clib/logfacility.h" #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" +#include "../clib/clib.h" +#include "../clib/compilerspecifics.h" +#include "../clib/logfacility.h" +#include "../clib/rawtypes.h" #include "../clib/streamsaver.h" - #include "../plib/systemstate.h" - -#include +#include "containr.h" +#include "fnsearch.h" +#include "globals/object_storage.h" +#include "globals/uvars.h" +#include "item/item.h" +#include "loaddata.h" +#include "mkscrobj.h" +#include "polcfg.h" +#include "poltype.h" +#include "ufunc.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // deprecation warning for stricmp @@ -41,9 +44,7 @@ namespace Core { using namespace Bscript; -StorageArea::StorageArea( std::string name ) : _name( name ) -{ -} +StorageArea::StorageArea( std::string name ) : _name( name ) {} StorageArea::~StorageArea() { @@ -268,7 +269,10 @@ void Storage::print( Clib::StreamWriter& sw ) const { for ( const auto& area : areas ) { - sw() << "StorageArea" << '\n' << "{" << '\n' << "\tName\t" << area.first << '\n' << "}" << '\n' + sw() << "StorageArea" << '\n' + << "{" << '\n' + << "\tName\t" << area.first << '\n' + << "}" << '\n' << '\n'; area.second->print( sw ); sw() << '\n'; diff --git a/pol-core/pol/storage.h b/pol-core/pol/storage.h index a2b7913cb..a701e5fc0 100644 --- a/pol-core/pol/storage.h +++ b/pol-core/pol/storage.h @@ -11,11 +11,11 @@ #pragma warning( disable : 4786 ) #endif -#include "../clib/maputil.h" - #include #include +#include "../clib/maputil.h" + namespace Pol { namespace Items diff --git a/pol-core/pol/syshook.cpp b/pol-core/pol/syshook.cpp index a247aafe6..bc01b697e 100644 --- a/pol-core/pol/syshook.cpp +++ b/pol-core/pol/syshook.cpp @@ -7,24 +7,19 @@ #include "syshook.h" -#include "uoexec.h" -#include "syshookscript.h" -#include "scrdef.h" -#include "scrsched.h" -#include "scrstore.h" -#include "globals/uvars.h" - -#include "../plib/pkg.h" -#include "../plib/systemstate.h" - -#include "../bscript/eprog.h" +#include +#include +#include "../bscript/bobject.h" #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" - -#include +#include "../plib/pkg.h" +#include "../plib/systemstate.h" +#include "globals/uvars.h" +#include "scrdef.h" +#include "syshookscript.h" namespace Pol { diff --git a/pol-core/pol/syshookscript.cpp b/pol-core/pol/syshookscript.cpp index b71d9cb50..29aaa7352 100644 --- a/pol-core/pol/syshookscript.cpp +++ b/pol-core/pol/syshookscript.cpp @@ -7,15 +7,17 @@ #include "syshookscript.h" -#include "scrsched.h" - -#include "../bscript/executor.h" -#include "../bscript/berror.h" - -#include "../clib/logfacility.h" - +#include +#include #include +#include "../bscript/berror.h" +#include "../bscript/eprog.h" +#include "../bscript/executor.h" +#include "../clib/clib.h" +#include "../clib/logfacility.h" +#include "scrsched.h" + #ifdef _MSC_VER #pragma warning( disable : 4996 ) // disable deprecation warning for stricmp #endif @@ -32,9 +34,7 @@ ExportScript::ExportScript( const Plib::Package* pkg, std::string scriptname ) sd.config( scriptname, pkg, "", true ); } -ExportScript::ExportScript( const ScriptDef& isd ) : sd( isd ) -{ -} +ExportScript::ExportScript( const ScriptDef& isd ) : sd( isd ) {} bool ExportScript::Initialize() { @@ -617,4 +617,4 @@ size_t ExportScript::estimateSize() const return sd.estimatedSize() + uoexec.sizeEstimate(); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/syshookscript.h b/pol-core/pol/syshookscript.h index 2b1ee47c1..f780ac72a 100644 --- a/pol-core/pol/syshookscript.h +++ b/pol-core/pol/syshookscript.h @@ -7,11 +7,20 @@ #ifndef SYSHOOKSCRIPT_H #define SYSHOOKSCRIPT_H +#include +#include + +#include "../bscript/bobject.h" #include "scrdef.h" #include "uoexec.h" -#include -#include +namespace Pol +{ +namespace Bscript +{ +struct BackupStruct; +} // namespace Bscript +} // namespace Pol namespace Pol { diff --git a/pol-core/pol/target.cpp b/pol-core/pol/target.cpp index 59e0d4704..214a69159 100644 --- a/pol-core/pol/target.cpp +++ b/pol-core/pol/target.cpp @@ -9,32 +9,26 @@ #include "target.h" -#include "accounts/account.h" -#include "mobile/charactr.h" - -#include "item/itemdesc.h" -#include "multi/multi.h" - -#include "network/client.h" -#include "network/cgdata.h" -#include "network/clienttransmit.h" -#include "network/msghandl.h" -#include "network/packethelper.h" - -#include "fnsearch.h" -#include "objtype.h" -#include "realms.h" -#include "realms/realm.h" -#include "ufunc.h" -#include "globals/uvars.h" -#include "polclass.h" - -#include "guardrgn.h" +#include #include "../clib/clib_endian.h" #include "../clib/logfacility.h" - -#include +#include "../clib/rawtypes.h" +#include "accounts/account.h" +#include "fnsearch.h" +#include "globals/uvars.h" +#include "guardrgn.h" +#include "item/itemdesc.h" +#include "mobile/charactr.h" +#include "multi/multi.h" +#include "network/client.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "pktboth.h" +#include "polclass.h" +#include "realms/realm.h" +#include "ufunc.h" +#include "uobject.h" namespace Pol { diff --git a/pol-core/pol/target.h b/pol-core/pol/target.h index d1d0c3112..f840f4e1d 100644 --- a/pol-core/pol/target.h +++ b/pol-core/pol/target.h @@ -7,12 +7,12 @@ #ifndef __TARGET_H #define __TARGET_H +#include + #include "../clib/compilerspecifics.h" #include "../clib/rawtypes.h" - #include "pktboth.h" -#include namespace Pol { namespace Mobile diff --git a/pol-core/pol/tasks.cpp b/pol-core/pol/tasks.cpp index 6b803d577..8a660479f 100644 --- a/pol-core/pol/tasks.cpp +++ b/pol-core/pol/tasks.cpp @@ -11,34 +11,24 @@ #include "tasks.h" -#include "mobile/charactr.h" -#include "network/client.h" - -#include "cmbtcfg.h" -#include "decay.h" -#include "polcfg.h" -#include "polclock.h" -#include "realms.h" -#include "schedule.h" -#include "scrsched.h" -#include "sockio.h" -#include "statmsg.h" -#include "ufunc.h" -#include "globals/uvars.h" -#include "globals/state.h" -#include "globals/settings.h" -#include "globals/script_internals.h" -#include "uworld.h" -#include "vital.h" -#include "realms/realm.h" - -#include "../plib/systemstate.h" +#include #include "../bscript/berror.h" -#include "../bscript/escriptv.h" - -#include "../clib/clib_endian.h" #include "../clib/logfacility.h" +#include "../plib/systemstate.h" +#include "cmbtcfg.h" +#include "gameclck.h" +#include "globals/script_internals.h" +#include "globals/settings.h" +#include "globals/state.h" +#include "globals/uvars.h" +#include "mobile/charactr.h" +#include "polclock.h" +#include "polsig.h" +#include "profile.h" +#include "realms/realm.h" +#include "uworld.h" +#include "vital.h" #ifdef _MSC_VER #pragma warning( \ @@ -61,8 +51,7 @@ void regen_stats() unsigned wgridx, wgridy; - auto stat_regen = [&now_gameclock, &now]( Mobile::Character* chr ) - { + auto stat_regen = [&now_gameclock, &now]( Mobile::Character* chr ) { THREAD_CHECKPOINT( tasks, 402 ); if ( chr->has_lightoverride() ) @@ -239,13 +228,13 @@ void update_rpm( void ) << stateManager.profilevars.last_sysload << stateManager.profilevars.last_sysload_nprocs << stateManager.profilevars.last_cputime; if ( Plib::systemstate.config.log_sysload ) - POLLOG.Format( "sysload={} ({}) cputime={}\n" ) << stateManager.profilevars.last_sysload - << stateManager.profilevars.last_sysload_nprocs - << stateManager.profilevars.last_cputime; -// cout << "npc_searches:" << GET_PROFILEVAR_PER_MIN( npc_searches ) << " in " << -// GET_PROFILECLOCK_MS( npc_search ) << " ms" << endl; -// cout << "container_adds:" << GET_PROFILEVAR_PER_MIN( container_adds ) << endl; -// cout << "container_removes:" << GET_PROFILEVAR_PER_MIN( container_removes ) << endl; + POLLOG.Format( "sysload={} ({}) cputime={}\n" ) + << stateManager.profilevars.last_sysload << stateManager.profilevars.last_sysload_nprocs + << stateManager.profilevars.last_cputime; + // cout << "npc_searches:" << GET_PROFILEVAR_PER_MIN( npc_searches ) << " in " << + // GET_PROFILECLOCK_MS( npc_search ) << " ms" << endl; + // cout << "container_adds:" << GET_PROFILEVAR_PER_MIN( container_adds ) << endl; + // cout << "container_removes:" << GET_PROFILEVAR_PER_MIN( container_removes ) << endl; #ifndef NDEBUG INFO_PRINT << "activity: " << stateManager.profilevars.last_script_passes_activity @@ -255,12 +244,12 @@ void update_rpm( void ) stateManager.profilevars.last_mapcache_misses = stateManager.profilevars.mapcache_misses; if ( Plib::systemstate.config.watch_mapcache ) INFO_PRINT << "mapcache: hits=" << stateManager.profilevars.mapcache_hits - << ", misses=" << stateManager.profilevars.mapcache_misses - << ", rate=" << ( stateManager.profilevars.mapcache_hits - ? ( stateManager.profilevars.mapcache_hits * 100 / - ( stateManager.profilevars.mapcache_hits + - stateManager.profilevars.mapcache_misses ) ) - : 0 ) + << ", misses=" << stateManager.profilevars.mapcache_misses << ", rate=" + << ( stateManager.profilevars.mapcache_hits + ? ( stateManager.profilevars.mapcache_hits * 100 / + ( stateManager.profilevars.mapcache_hits + + stateManager.profilevars.mapcache_misses ) ) + : 0 ) << "%\n"; stateManager.profilevars.mapcache_hits = 0; stateManager.profilevars.mapcache_misses = 0; @@ -318,10 +307,10 @@ void update_rpm( void ) << ( stateManager.profilevars.last_rpm ? ( stateManager.profilevars.last_sipm / stateManager.profilevars.last_rpm ) : 0 ) - << " SC/R: " << ( stateManager.profilevars.last_rpm - ? ( stateManager.profilevars.last_scpm / - stateManager.profilevars.last_rpm ) - : 0 ) + << " SC/R: " + << ( stateManager.profilevars.last_rpm ? ( stateManager.profilevars.last_scpm / + stateManager.profilevars.last_rpm ) + : 0 ) << "\n"; } THREAD_CHECKPOINT( tasks, 399 ); @@ -337,7 +326,7 @@ void update_sysload() else { ++stateManager.profilevars.busy_sysload_cycles; - stateManager.profilevars.sysload_nprocs += scriptScheduler.getRunlist().size(); + stateManager.profilevars.sysload_nprocs += scriptScheduler.getRunlist().size(); } THREAD_CHECKPOINT( tasks, 299 ); } diff --git a/pol-core/pol/testing/poltest.cpp b/pol-core/pol/testing/poltest.cpp index 8d61ba376..c9324af89 100644 --- a/pol-core/pol/testing/poltest.cpp +++ b/pol-core/pol/testing/poltest.cpp @@ -4,6 +4,7 @@ */ #include "poltest.h" + #include "testenv.h" #ifdef WINDOWS diff --git a/pol-core/pol/testing/testdrop.cpp b/pol-core/pol/testing/testdrop.cpp index 993802b7f..13b736209 100644 --- a/pol-core/pol/testing/testdrop.cpp +++ b/pol-core/pol/testing/testdrop.cpp @@ -3,25 +3,21 @@ * @par History */ -#include "testenv.h" - +#include #include "../../clib/logfacility.h" -#include "../../plib/mapserver.h" #include "../globals/uvars.h" -#include "../multi/multi.h" #include "../realms/realm.h" -#include "../uconst.h" +#include "testenv.h" namespace Pol { namespace Testing { - namespace { // This code should mirror code in drop_item_on_ground void test_drop( unsigned short chrx, unsigned short chry, short chrz, unsigned short dropx, - unsigned short dropy, short dropz, bool exp_result, short exp_z ) + unsigned short dropy, short dropz, bool exp_result, short exp_z ) { fmt::Writer tmp; tmp << "POL DropHeight(" << chrx << "," << chry << "," << chrz << "," << dropx << "," << dropy @@ -52,7 +48,7 @@ void test_drop( unsigned short chrx, unsigned short chry, short chrz, unsigned s inc_successes(); INFO_PRINT << tmp.str() << "Ok!\n"; } -} // namespace +} // namespace void drop_test() { @@ -78,5 +74,5 @@ void drop_test() // a ramp in an orc fort test_drop( 5210, 3616, 0, 5210, 3615, 5, true, 2 ); } -} // namespace Testing -} // namespace Pol +} // namespace Testing +} // namespace Pol diff --git a/pol-core/pol/testing/testenv.cpp b/pol-core/pol/testing/testenv.cpp index 847e36d14..e1774573f 100644 --- a/pol-core/pol/testing/testenv.cpp +++ b/pol-core/pol/testing/testenv.cpp @@ -5,24 +5,22 @@ #include "testenv.h" +#include "../../bscript/bobject.h" #include "../../clib/cfgelem.h" #include "../../clib/cfgfile.h" +#include "../../clib/logfacility.h" #include "../../clib/passert.h" +#include "../../clib/rawtypes.h" #include "../globals/object_storage.h" #include "../globals/uvars.h" #include "../item/item.h" #include "../item/itemdesc.h" #include "../mobile/npc.h" #include "../multi/multi.h" -#include "../objecthash.h" -#include "../realms.h" -#include "../realms/WorldChangeReasons.h" -#include "../realms/realm.h" +#include "../npctmpl.h" #include "../ufunc.h" #include "../uworld.h" -#include - namespace Pol { namespace Testing diff --git a/pol-core/pol/testing/testlos.cpp b/pol-core/pol/testing/testlos.cpp index 70e241b79..d6c427ffb 100644 --- a/pol-core/pol/testing/testlos.cpp +++ b/pol-core/pol/testing/testlos.cpp @@ -13,23 +13,22 @@ #endif #ifdef ENABLE_BENCHMARK +#include "../module/uomod.h" +#include "../scrsched.h" +#include "../uoexec.h" +#include "../uoscrobj.h" #include #endif -#include "../../bscript/objmembers.h" #include "../../clib/logfacility.h" -#include "../../plib/mapserver.h" +#include "../../clib/rawtypes.h" #include "../globals/uvars.h" #include "../item/item.h" #include "../los.h" #include "../mobile/npc.h" #include "../realms/realm.h" -#include "../uconst.h" #include "../uobject.h" -#include "../uoexec.h" -#include "../uoscrobj.h" -#include "../scrsched.h" -#include "../module/uomod.h" + namespace Pol { namespace Testing @@ -157,7 +156,7 @@ static void BM_los( benchmark::State& state ) los_test(); } } -//BENCHMARK( BM_los ); +// BENCHMARK( BM_los ); static void BM_los100inside100outside( benchmark::State& state ) { @@ -166,36 +165,36 @@ static void BM_los100inside100outside( benchmark::State& state ) test_los( 1373, 1625, 59, 1379, 1625, 30, true ); } } -//BENCHMARK( BM_los100inside100outside ); +// BENCHMARK( BM_los100inside100outside ); static void BM_method( benchmark::State& state ) { std::unique_ptr ex( Core::create_script_executor() ); - auto uoemod = new Module::UOExecutorModule( *ex ); - ex->addModule( uoemod ); + auto uoemod = new Module::UOExecutorModule( *ex ); + ex->addModule( uoemod ); Items::Item* item = Items::Item::create( 0xffa1 ); - auto ref=new Module::EItemRefObjImp(item); - + auto ref = new Module::EItemRefObjImp( item ); + while ( state.KeepRunning() ) { - ref->call_method("test",*(ex.get())); -//for (int i=0;iget_member(Bscript::object_members[i].code); - //ref->get_member("x"); + ref->call_method( "test", *( ex.get() ) ); + // for (int i=0;iget_member(Bscript::object_members[i].code); + // ref->get_member("x"); } } BENCHMARK( BM_method ); static void BM_member_id( benchmark::State& state ) { Items::Item* item = Items::Item::create( 0xffa1 ); - auto ref=new Module::EItemRefObjImp(item); - + auto ref = new Module::EItemRefObjImp( item ); + while ( state.KeepRunning() ) { - ref->get_member_id(1); -//for (int i=0;iget_member(Bscript::object_members[i].code); - //ref->get_member("x"); + ref->get_member_id( 1 ); + // for (int i=0;iget_member(Bscript::object_members[i].code); + // ref->get_member("x"); } } BENCHMARK( BM_member_id ); diff --git a/pol-core/pol/testing/testmisc.cpp b/pol-core/pol/testing/testmisc.cpp index 8f3c29652..ee139227c 100644 --- a/pol-core/pol/testing/testmisc.cpp +++ b/pol-core/pol/testing/testmisc.cpp @@ -3,9 +3,10 @@ * @par History */ -#include "testenv.h" +#include #include "../../clib/logfacility.h" +#include "../../clib/rawtypes.h" #include "../../plib/maptile.h" #include "../dynproperties.h" #include "../globals/uvars.h" @@ -15,11 +16,7 @@ namespace Pol { namespace Testing { - -void dummy() -{ - -} +void dummy() {} void map_test() { @@ -52,5 +49,5 @@ void dynprops_test() INFO_PRINT << "size " << h.estimateSizeDynProps() << "\n"; } -} // namespace Testing -} // namespace Pol +} // namespace Testing +} // namespace Pol diff --git a/pol-core/pol/testing/testskill.cpp b/pol-core/pol/testing/testskill.cpp index 91d649cc4..ba5bd5802 100644 --- a/pol-core/pol/testing/testskill.cpp +++ b/pol-core/pol/testing/testskill.cpp @@ -33,7 +33,7 @@ void test_skilladv( unsigned int raw, unsigned short base ) INFO_PRINT << "Passed\n"; inc_successes(); } -} // namespace +} // namespace void skilladv_test() { @@ -102,5 +102,5 @@ void skilladv_test() } } -} // namespace Testing -} // namespace Pol +} // namespace Testing +} // namespace Pol diff --git a/pol-core/pol/testing/testwalk.cpp b/pol-core/pol/testing/testwalk.cpp index bbc159647..7e65aac6a 100644 --- a/pol-core/pol/testing/testwalk.cpp +++ b/pol-core/pol/testing/testwalk.cpp @@ -3,14 +3,11 @@ * @par History */ -#include "testenv.h" - #include "../../clib/logfacility.h" -#include "../../plib/mapserver.h" #include "../globals/uvars.h" #include "../realms/realm.h" #include "../uconst.h" -#include "../uobject.h" +#include "testenv.h" namespace Pol { @@ -321,5 +318,5 @@ void multiwalk_test() // try walking on a long boat, next to its plank test_walk( 1496, 1817, -2, 1495, 1817, true, -2 ); } -} // namespace Testing -} // namespace Pol +} // namespace Testing +} // namespace Pol diff --git a/pol-core/pol/textcmd.cpp b/pol-core/pol/textcmd.cpp index 2f4f60b9b..8d87e3e35 100644 --- a/pol-core/pol/textcmd.cpp +++ b/pol-core/pol/textcmd.cpp @@ -12,67 +12,60 @@ #include "textcmd.h" -#include "accounts/account.h" -#include "mobile/charactr.h" -#include "network/client.h" -#include "cmdlevel.h" - -#include "item/armor.h" -#include "item/weapon.h" -#include "item/itemdesc.h" - -#include "module/uomod.h" -#include "module/osmod.h" -#include "uoexec.h" - -#include "action.h" -#include "allocd.h" -#include "menu.h" -#include "mobile/npc.h" -#include "pktboth.h" -#include "polcfg.h" -#include "polclock.h" -#include "polsem.h" -#include "realms.h" -#include "realms/realm.h" -#include "schedule.h" -#include "scrsched.h" -#include "scrstore.h" -#include "target.h" -#include "tmpvars.h" -#include "uobject.h" -#include "ufunc.h" -#include "ufuncstd.h" -#include "uoscrobj.h" -#include "globals/uvars.h" -#include "globals/state.h" -#include "globals/network.h" -#include "uworld.h" -#include "repsys.h" -#include "fnsearch.h" -#include "unicode.h" - -#include "../plib/pkg.h" -#include "../plib/systemstate.h" +#include +#include +#include +#include +#include +#include +#include +#include #include "../bscript/berror.h" #include "../bscript/impstr.h" - #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" +#include "../clib/clib.h" #include "../clib/clib_endian.h" #include "../clib/esignal.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" #include "../clib/opnew.h" +#include "../clib/rawtypes.h" +#include "../clib/refptr.h" +#include "../clib/spinlock.h" #include "../clib/stlutil.h" #include "../clib/strutil.h" -#include "../clib/spinlock.h" #include "../clib/threadhelp.h" - -#include -#include -#include +#include "../plib/pkg.h" +#include "../plib/systemstate.h" +#include "accounts/account.h" +#include "allocd.h" +#include "clidata.h" +#include "globals/network.h" +#include "globals/state.h" +#include "globals/uvars.h" +#include "item/item.h" +#include "item/itemdesc.h" +#include "mobile/charactr.h" +#include "module/osmod.h" +#include "module/uomod.h" +#include "network/client.h" +#include "pktboth.h" +#include "polclock.h" +#include "repsys.h" +#include "scrdef.h" +#include "scrsched.h" +#include "scrstore.h" +#include "tmpvars.h" +#include "uconst.h" +#include "ufunc.h" +#include "ufuncstd.h" +#include "unicode.h" +#include "uoexec.h" +#include "uoscrobj.h" +#include "utype.h" +#include "uworld.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // disable warning for asctime, localtime, sprintf, strnicmp @@ -197,29 +190,23 @@ void textcmd_flag1( Network::Client* client, const char* text ) { tmp_flag1 = (u8)strtoul( text, NULL, 16 ); Core::WorldIterator::InVisualRange( - client->chr, [&]( Mobile::Character* zonechr ) - { - send_move_if_inrange2( zonechr, client ); - } ); + client->chr, + [&]( Mobile::Character* zonechr ) { send_move_if_inrange2( zonechr, client ); } ); } void textcmd_flag2( Network::Client* client, const char* text ) { tmp_flag2 = (u8)strtoul( text, NULL, 16 ); Core::WorldIterator::InVisualRange( - client->chr, [&]( Mobile::Character* zonechr ) - { - send_move_if_inrange2( zonechr, client ); - } ); + client->chr, + [&]( Mobile::Character* zonechr ) { send_move_if_inrange2( zonechr, client ); } ); } void textcmd_resendchars( Network::Client* client ) { Core::WorldIterator::InVisualRange( - client->chr, [&]( Mobile::Character* zonechr ) - { - send_client_char_data( zonechr, client ); - } ); + client->chr, + [&]( Mobile::Character* zonechr ) { send_client_char_data( zonechr, client ); } ); } void textcmd_shutdown( Network::Client* /*client*/ ) @@ -455,8 +442,7 @@ void textcmd_procs( Network::Client* client ) send_sysmessage( client, "Process Information:" ); send_sysmessage( - client, - "Running: " + Clib::decint( (unsigned int)( scriptScheduler.getRunlist().size() ) ) ); + client, "Running: " + Clib::decint( (unsigned int)( scriptScheduler.getRunlist().size() ) ) ); send_sysmessage( client, "Blocked: " + Clib::decint( (unsigned int)( scriptScheduler.getHoldlist().size() ) ) ); diff --git a/pol-core/pol/textcmd.h b/pol-core/pol/textcmd.h index dfb5284d3..7a638a66f 100644 --- a/pol-core/pol/textcmd.h +++ b/pol-core/pol/textcmd.h @@ -7,10 +7,10 @@ #define __TEXTCMD_H #include -#include "../clib/rawtypes.h" - #include +#include "../clib/rawtypes.h" + namespace Pol { namespace Network diff --git a/pol-core/pol/tildecmd.cpp b/pol-core/pol/tildecmd.cpp index 2b76a463a..6de621912 100644 --- a/pol-core/pol/tildecmd.cpp +++ b/pol-core/pol/tildecmd.cpp @@ -6,14 +6,15 @@ #include "tildecmd.h" -#include "polcfg.h" -#include "spells.h" +#include +#include +#include +#include #include "../clib/clib_endian.h" #include "../clib/logfacility.h" #include "../plib/systemstate.h" - -#include +#include "spells.h" namespace Pol { @@ -68,4 +69,4 @@ bool process_tildecommand( Network::Client* client, const u16* wtextbuf ) return false; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/tiles.cpp b/pol-core/pol/tiles.cpp index f70288bf2..2cabce2b8 100644 --- a/pol-core/pol/tiles.cpp +++ b/pol-core/pol/tiles.cpp @@ -7,18 +7,16 @@ #include "tiles.h" -#include "polcfg.h" -#include "../plib/mapcell.h" +#include + +#include "../clib/cfgelem.h" +#include "../clib/logfacility.h" +#include "../clib/passert.h" #include "../plib/mapfunc.h" #include "../plib/pkg.h" #include "../plib/systemstate.h" -#include "../clib/cfgelem.h" -#include "../clib/cfgfile.h" -#include "../clib/passert.h" -#include "../clib/logfacility.h" - namespace Pol { namespace Core @@ -49,4 +47,4 @@ void load_tiles_cfg() ERROR_PRINT << "Warning: No tiles loaded. Please check tiles.cfg\n"; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/tiles.h b/pol-core/pol/tiles.h index da136a970..5bf40f4e7 100644 --- a/pol-core/pol/tiles.h +++ b/pol-core/pol/tiles.h @@ -8,9 +8,10 @@ #ifndef TILES_H #define TILES_H -#include "../clib/rawtypes.h" #include +#include "../clib/rawtypes.h" + namespace Pol { namespace Core diff --git a/pol-core/pol/tiplstwn.cpp b/pol-core/pol/tiplstwn.cpp index d23dee869..b8047f5aa 100644 --- a/pol-core/pol/tiplstwn.cpp +++ b/pol-core/pol/tiplstwn.cpp @@ -4,13 +4,11 @@ */ -#include "tiplist.h" +#include #include "../clib/dirlist.h" #include "globals/uvars.h" -#include - namespace Pol { namespace Core diff --git a/pol-core/pol/tips.cpp b/pol-core/pol/tips.cpp index 034326b1a..5ee544f66 100644 --- a/pol-core/pol/tips.cpp +++ b/pol-core/pol/tips.cpp @@ -5,20 +5,15 @@ */ -#include "tiplist.h" - -#include "network/msghandl.h" -#include "network/packets.h" -#include "network/packethelper.h" -#include "pktin.h" -#include "pktout.h" -#include "sockio.h" -#include "globals/uvars.h" +#include #include "../clib/clib_endian.h" - -#include -#include +#include "../clib/rawtypes.h" +#include "globals/uvars.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "pktdef.h" +#include "pktin.h" namespace Pol { @@ -83,4 +78,4 @@ void handle_get_tip( Network::Client* client, PKTIN_A7* msg ) } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/tmpvars.cpp b/pol-core/pol/tmpvars.cpp index 95e51342f..3d2535aff 100644 --- a/pol-core/pol/tmpvars.cpp +++ b/pol-core/pol/tmpvars.cpp @@ -6,6 +6,8 @@ #include "tmpvars.h" +#include "../clib/rawtypes.h" + namespace Pol { namespace Core @@ -13,4 +15,4 @@ namespace Core u8 tmp_flag1; u8 tmp_flag2; } -} \ No newline at end of file +} diff --git a/pol-core/pol/tooltips.cpp b/pol-core/pol/tooltips.cpp index 13e15a755..44e6f7f62 100644 --- a/pol-core/pol/tooltips.cpp +++ b/pol-core/pol/tooltips.cpp @@ -12,19 +12,21 @@ #include "tooltips.h" +#include +#include + +#include "../clib/clib_endian.h" +#include "../clib/rawtypes.h" +#include "item/item.h" +#include "item/itemdesc.h" #include "mobile/charactr.h" #include "network/client.h" -#include "network/packets.h" -#include "network/packethelper.h" #include "network/packetdefs.h" -#include "network/clienttransmit.h" -#include "item/itemdesc.h" -#include "item/item.h" -#include "network/msghandl.h" -#include "pktboth.h" +#include "network/packethelper.h" +#include "network/packets.h" #include "pktin.h" #include "ufunc.h" -#include "globals/uvars.h" +#include "uobject.h" #include "uworld.h" namespace Pol @@ -79,8 +81,7 @@ void send_object_cache_to_inrange( const UObject* obj ) auto pkt_rev = Network::ObjRevisionPkt( obj->serial_ext, obj->rev() ); WorldIterator::InVisualRange( obj->toplevel_owner(), - [&]( Mobile::Character* chr ) - { + [&]( Mobile::Character* chr ) { pkt_rev.Send( chr->client ); // FIXME need to check character's // additional_legal_items. diff --git a/pol-core/pol/ufunc.cpp b/pol-core/pol/ufunc.cpp index 852484916..7728d03e5 100644 --- a/pol-core/pol/ufunc.cpp +++ b/pol-core/pol/ufunc.cpp @@ -40,63 +40,48 @@ #include "ufunc.h" -#include "accounts/account.h" +#include +#include +#include +#include +#include -#include "mobile/charactr.h" -#include "mobile/corpse.h" -#include "item/equipmnt.h" -#include "multi/multi.h" -#include "multi/multidef.h" - -#include "containr.h" - -#include "network/client.h" -#include "network/clienttransmit.h" -#include "network/packetdefs.h" - -#include "pktout.h" -#include "fnsearch.h" -#include "layers.h" -#include "lightlvl.h" -#include "objtype.h" -#include "polcfg.h" -#include "polclass.h" -#include "realms.h" -#include "realms/realm.h" -#include "repsys.h" -#include "sockio.h" -#include "statmsg.h" -#include "tmpvars.h" -#include "tooltips.h" -#include "uobject.h" -#include "uoclient.h" -#include "ustruct.h" -#include "globals/uvars.h" -#include "globals/state.h" -#include "globals/object_storage.h" -#include "uworld.h" -#include "mdelta.h" -#include "zone.h" -#include "miscrgn.h" -#include "network/cgdata.h" - -#include "objecthash.h" - - -#include "../plib/mapcell.h" -#include "../plib/systemstate.h" - -#include "../bscript/impstr.h" - -#include "../clib/clib.h" #include "../clib/clib_endian.h" #include "../clib/logfacility.h" #include "../clib/passert.h" -#include "../clib/stlutil.h" -#include "../clib/strutil.h" - -#include -#include +#include "../plib/mapcell.h" +#include "../plib/systemstate.h" +#include "accounts/account.h" +#include "containr.h" +#include "fnsearch.h" +#include "globals/network.h" +#include "globals/object_storage.h" +#include "globals/state.h" +#include "globals/uvars.h" +#include "item/item.h" +#include "layers.h" +#include "lightlvl.h" +#include "mdelta.h" +#include "miscrgn.h" +#include "mobile/charactr.h" +#include "mobile/corpse.h" +#include "multi/multi.h" +#include "multi/multidef.h" +#include "network/cgdata.h" +#include "network/client.h" +#include "network/packetdefs.h" +#include "network/packethelper.h" +#include "objecthash.h" +#include "objtype.h" +#include "pktdef.h" +#include "polcfg.h" +#include "polclass.h" +#include "realms/realm.h" +#include "statmsg.h" +#include "tooltips.h" +#include "uobject.h" +#include "uoclient.h" +#include "uworld.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // disable deprecation warning for sprintf @@ -175,7 +160,7 @@ void send_goxyz( Client* client, const Character* chr ) msg->Write( chr->get_flag1( client ) ); msg->WriteFlipped( chr->x ); msg->WriteFlipped( chr->y ); - msg->offset += 2; // unk15,16 + msg->offset += 2; // unk15,16 msg->Write( 0x80u | chr->facing ); // is it always right to set this flag? msg->Write( chr->z ); msg.Send( client ); @@ -398,35 +383,31 @@ void send_remove_character( Network::Client* client, const Mobile::Character* ch void send_remove_character_to_nearby( const Character* chr ) { Network::RemoveObjectPkt msgremove( chr->serial_ext ); - WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) - { - if ( zonechr == chr ) - return; - msgremove.Send( zonechr->client ); - } ); + WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) { + if ( zonechr == chr ) + return; + msgremove.Send( zonechr->client ); + } ); } void send_remove_character_to_nearby_cantsee( const Character* chr ) { Network::RemoveObjectPkt msgremove( chr->serial_ext ); - WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) - { - if ( zonechr == chr ) - return; - if ( !zonechr->is_visible_to_me( chr ) ) - msgremove.Send( zonechr->client ); - } ); + WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) { + if ( zonechr == chr ) + return; + if ( !zonechr->is_visible_to_me( chr ) ) + msgremove.Send( zonechr->client ); + } ); } void send_remove_character_to_nearby_cansee( const Character* chr ) { Network::RemoveObjectPkt msgremove( chr->serial_ext ); - WorldIterator::InVisualRange( - chr, [&]( Character* _chr ) - { - if ( _chr != chr && _chr->is_visible_to_me( chr ) ) - msgremove.Send( _chr->client ); - } ); + WorldIterator::InVisualRange( chr, [&]( Character* _chr ) { + if ( _chr != chr && _chr->is_visible_to_me( chr ) ) + msgremove.Send( _chr->client ); + } ); } void send_remove_object_if_inrange( Client* client, const Item* item ) @@ -451,10 +432,8 @@ void send_remove_object( Client* client, const UObject* object ) void send_remove_object_to_inrange( const UObject* centerObject ) { Network::RemoveObjectPkt msgremove( centerObject->serial_ext ); - Core::WorldIterator::InVisualRange( centerObject, [&]( Character* chr ) - { - msgremove.Send( chr->client ); - } ); + Core::WorldIterator::InVisualRange( + centerObject, [&]( Character* chr ) { msgremove.Send( chr->client ); } ); } void send_remove_object( Client* client, const UObject* item, RemoveObjectPkt& pkt ) @@ -693,10 +672,8 @@ void send_corpse_equip_inrange( const Item* item ) { const UCorpse* corpse = static_cast( item ); - WorldIterator::InVisualRange( corpse, [&]( Character* chr ) - { - send_corpse_equip( chr->client, corpse ); - } ); + WorldIterator::InVisualRange( + corpse, [&]( Character* chr ) { send_corpse_equip( chr->client, corpse ); } ); } // Item::sendto( Client* ) ?? @@ -737,29 +714,27 @@ void send_item_to_inrange( const Item* item ) auto pkt_remove = RemoveObjectPkt( item->serial_ext ); auto pkt_rev = ObjRevisionPkt( item->serial_ext, item->rev() ); - WorldIterator::InVisualRange( - item, [&]( Character* zonechr ) - { - if ( item->invisible() && !zonechr->client->chr->can_seeinvisitems() ) - { - pkt_remove.Send( zonechr->client ); - return; - } + WorldIterator::InVisualRange( item, [&]( Character* zonechr ) { + if ( item->invisible() && !zonechr->client->chr->can_seeinvisitems() ) + { + pkt_remove.Send( zonechr->client ); + return; + } - u8 flags = 0; - if ( zonechr->client->chr->can_move( item ) ) - flags |= ITEM_FLAG_FORCE_MOVABLE; - pkt.updateFlags( flags ); - pkt.Send( zonechr->client ); + u8 flags = 0; + if ( zonechr->client->chr->can_move( item ) ) + flags |= ITEM_FLAG_FORCE_MOVABLE; + pkt.updateFlags( flags ); + pkt.Send( zonechr->client ); - // if the item is a corpse, transmit items contained by it - if ( item->objtype_ == UOBJ_CORPSE ) - { - send_corpse( zonechr->client, item ); - } + // if the item is a corpse, transmit items contained by it + if ( item->objtype_ == UOBJ_CORPSE ) + { + send_corpse( zonechr->client, item ); + } - pkt_rev.Send( zonechr->client ); - } ); + pkt_rev.Send( zonechr->client ); + } ); } @@ -1045,19 +1020,15 @@ void play_sound_effect( const UObject* center, u16 effect ) { Network::PlaySoundPkt msg( PKTOUT_54_FLAG_SINGLEPLAY, effect - 1u, center->x, center->y, 0 ); // FIXME hearing range check perhaps? - WorldIterator::InVisualRange( center, [&]( Character* zonechr ) - { - msg.Send( zonechr->client ); - } ); + WorldIterator::InVisualRange( + center, [&]( Character* zonechr ) { msg.Send( zonechr->client ); } ); } void play_sound_effect_xyz( u16 cx, u16 cy, s8 cz, u16 effect, Realms::Realm* realm ) { Network::PlaySoundPkt msg( PKTOUT_54_FLAG_SINGLEPLAY, effect - 1u, cx, cy, cz ); - WorldIterator::InRange( cx, cy, realm, RANGE_VISUAL, [&]( Character* zonechr ) - { - msg.Send( zonechr->client ); - } ); + WorldIterator::InRange( + cx, cy, realm, RANGE_VISUAL, [&]( Character* zonechr ) { msg.Send( zonechr->client ); } ); } void play_sound_effect_private( const UObject* center, u16 effect, Character* forchr ) @@ -1075,13 +1046,10 @@ void play_moving_effect( const UObject* src, const UObject* dst, u16 effect, u8 Network::GraphicEffectPkt msg; msg.movingEffect( src, dst, effect, speed, loop, explode ); - WorldIterator::InVisualRange( src->toplevel_owner(), [&]( Character* zonechr ) - { - msg.Send( zonechr->client ); - } ); WorldIterator::InVisualRange( - dst->toplevel_owner(), [&]( Character* zonechr ) - { + src->toplevel_owner(), [&]( Character* zonechr ) { msg.Send( zonechr->client ); } ); + WorldIterator::InVisualRange( + dst->toplevel_owner(), [&]( Character* zonechr ) { if ( !inrange( zonechr, src ) ) // send to char only in range of dst msg.Send( zonechr->client ); } ); @@ -1093,13 +1061,10 @@ void play_moving_effect2( u16 xs, u16 ys, s8 zs, u16 xd, u16 yd, s8 zd, u16 effe Network::GraphicEffectPkt msg; msg.movingEffect( xs, ys, zs, xd, yd, zd, effect, speed, loop, explode ); - WorldIterator::InRange( xs, ys, realm, RANGE_VISUAL, [&]( Character* zonechr ) - { - msg.Send( zonechr->client ); - } ); WorldIterator::InRange( - xd, yd, realm, RANGE_VISUAL, [&]( Character* zonechr ) - { + xs, ys, realm, RANGE_VISUAL, [&]( Character* zonechr ) { msg.Send( zonechr->client ); } ); + WorldIterator::InRange( + xd, yd, realm, RANGE_VISUAL, [&]( Character* zonechr ) { if ( !inrange( zonechr, xs, ys ) ) // send to chrs only in range of dest msg.Send( zonechr->client ); } ); @@ -1110,22 +1075,16 @@ void play_lightning_bolt_effect( const UObject* center ) { Network::GraphicEffectPkt msg; msg.lightningBold( center ); - WorldIterator::InVisualRange( center->toplevel_owner(), - [&]( Character* zonechr ) - { - msg.Send( zonechr->client ); - } ); + WorldIterator::InVisualRange( + center->toplevel_owner(), [&]( Character* zonechr ) { msg.Send( zonechr->client ); } ); } void play_object_centered_effect( const UObject* center, u16 effect, u8 speed, u8 loop ) { Network::GraphicEffectPkt msg; msg.followEffect( center, effect, speed, loop ); - WorldIterator::InVisualRange( center->toplevel_owner(), - [&]( Character* zonechr ) - { - msg.Send( zonechr->client ); - } ); + WorldIterator::InVisualRange( + center->toplevel_owner(), [&]( Character* zonechr ) { msg.Send( zonechr->client ); } ); } void play_stationary_effect( u16 x, u16 y, s8 z, u16 effect, u8 speed, u8 loop, u8 explode, @@ -1133,10 +1092,8 @@ void play_stationary_effect( u16 x, u16 y, s8 z, u16 effect, u8 speed, u8 loop, { Network::GraphicEffectPkt msg; msg.stationaryEffect( x, y, z, effect, speed, loop, explode ); - WorldIterator::InRange( x, y, realm, RANGE_VISUAL, [&]( Character* zonechr ) - { - msg.Send( zonechr->client ); - } ); + WorldIterator::InRange( + x, y, realm, RANGE_VISUAL, [&]( Character* zonechr ) { msg.Send( zonechr->client ); } ); } void play_stationary_effect_ex( u16 x, u16 y, s8 z, Realms::Realm* realm, u16 effect, u8 speed, @@ -1144,10 +1101,8 @@ void play_stationary_effect_ex( u16 x, u16 y, s8 z, Realms::Realm* realm, u16 ef { Network::GraphicEffectExPkt msg; msg.stationaryEffect( x, y, z, effect, speed, duration, hue, render, effect3d ); - WorldIterator::InRange( x, y, realm, RANGE_VISUAL, [&]( Character* zonechr ) - { - msg.Send( zonechr->client ); - } ); + WorldIterator::InRange( + x, y, realm, RANGE_VISUAL, [&]( Character* zonechr ) { msg.Send( zonechr->client ); } ); } void play_object_centered_effect_ex( const UObject* center, u16 effect, u8 speed, u8 duration, @@ -1155,10 +1110,8 @@ void play_object_centered_effect_ex( const UObject* center, u16 effect, u8 speed { Network::GraphicEffectExPkt msg; msg.followEffect( center, effect, speed, duration, hue, render, layer, effect3d ); - WorldIterator::InVisualRange( center, [&]( Character* zonechr ) - { - msg.Send( zonechr->client ); - } ); + WorldIterator::InVisualRange( + center, [&]( Character* zonechr ) { msg.Send( zonechr->client ); } ); } void play_moving_effect_ex( const UObject* src, const UObject* dst, u16 effect, u8 speed, @@ -1169,16 +1122,12 @@ void play_moving_effect_ex( const UObject* src, const UObject* dst, u16 effect, msg.movingEffect( src, dst, effect, speed, duration, hue, render, direction, explode, effect3d, effect3dexplode, effect3dsound ); - WorldIterator::InVisualRange( src, [&]( Character* zonechr ) - { - msg.Send( zonechr->client ); - } ); WorldIterator::InVisualRange( - dst, [&]( Character* zonechr ) - { - if ( !inrange( zonechr, src ) ) // send to chrs only in range of dst - msg.Send( zonechr->client ); - } ); + src, [&]( Character* zonechr ) { msg.Send( zonechr->client ); } ); + WorldIterator::InVisualRange( dst, [&]( Character* zonechr ) { + if ( !inrange( zonechr, src ) ) // send to chrs only in range of dst + msg.Send( zonechr->client ); + } ); } void play_moving_effect2_ex( u16 xs, u16 ys, s8 zs, u16 xd, u16 yd, s8 zd, Realms::Realm* realm, @@ -1189,13 +1138,10 @@ void play_moving_effect2_ex( u16 xs, u16 ys, s8 zs, u16 xd, u16 yd, s8 zd, Realm msg.movingEffect( xs, ys, zs, xd, yd, zd, effect, speed, duration, hue, render, direction, explode, effect3d, effect3dexplode, effect3dsound ); - WorldIterator::InRange( xs, ys, realm, RANGE_VISUAL, [&]( Character* zonechr ) - { - msg.Send( zonechr->client ); - } ); WorldIterator::InRange( - xd, yd, realm, RANGE_VISUAL, [&]( Character* zonechr ) - { + xs, ys, realm, RANGE_VISUAL, [&]( Character* zonechr ) { msg.Send( zonechr->client ); } ); + WorldIterator::InRange( + xd, yd, realm, RANGE_VISUAL, [&]( Character* zonechr ) { if ( !inrange( zonechr, xs, ys ) ) // send to chrs only in range of dst msg.Send( zonechr->client ); } ); @@ -1268,22 +1214,24 @@ void send_sysmessage( Network::Client* client, const std::wstring& wtext, const send_sysmessage( client, uctext, lang, font, color ); } -void broadcast( const char* text, unsigned short font, unsigned short color, unsigned short requiredCmdLevel ) +void broadcast( const char* text, unsigned short font, unsigned short color, + unsigned short requiredCmdLevel ) { for ( auto& client : networkManager.clients ) { - if ( !client->ready || client->chr->cmdlevel_ < requiredCmdLevel) + if ( !client->ready || client->chr->cmdlevel_ < requiredCmdLevel ) continue; send_sysmessage( client, text, font, color ); } } -void broadcast( const u16* wtext, const char lang[4], unsigned short font, unsigned short color, unsigned short requiredCmdLevel ) +void broadcast( const u16* wtext, const char lang[4], unsigned short font, unsigned short color, + unsigned short requiredCmdLevel ) { for ( auto& client : networkManager.clients ) { - if ( !client->ready || client->chr->cmdlevel_ < requiredCmdLevel) + if ( !client->ready || client->chr->cmdlevel_ < requiredCmdLevel ) continue; send_sysmessage( client, wtext, lang, font, color ); @@ -1557,33 +1505,28 @@ void send_death_message( Character* chr_died, Item* corpse ) msg->Write( corpse->serial_ext ); msg->offset += 4; // u32 unk4_zero - WorldIterator::InVisualRange( corpse, [&]( Character* zonechr ) - { - if ( zonechr == chr_died ) - return; - msg.Send( zonechr->client ); - } ); + WorldIterator::InVisualRange( corpse, [&]( Character* zonechr ) { + if ( zonechr == chr_died ) + return; + msg.Send( zonechr->client ); + } ); } void transmit_to_inrange( const UObject* center, const void* msg, unsigned msglen ) { - WorldIterator::InVisualRange( - center, [&]( Character* zonechr ) - { - Core::networkManager.clientTransmit->AddToQueue( zonechr->client, msg, msglen ); - } ); + WorldIterator::InVisualRange( center, [&]( Character* zonechr ) { + Core::networkManager.clientTransmit->AddToQueue( zonechr->client, msg, msglen ); + } ); } void transmit_to_others_inrange( Character* center, const void* msg, unsigned msglen ) { - WorldIterator::InVisualRange( - center, [&]( Character* zonechr ) - { - Client* client = zonechr->client; - if ( zonechr == center ) - return; - Core::networkManager.clientTransmit->AddToQueue( client, msg, msglen ); - } ); + WorldIterator::InVisualRange( center, [&]( Character* zonechr ) { + Client* client = zonechr->client; + if ( zonechr == center ) + return; + Core::networkManager.clientTransmit->AddToQueue( client, msg, msglen ); + } ); } // DAVE made heavy changes to this 11/17 for speed. @@ -1670,14 +1613,11 @@ void move_item( Item* item, UFACING facing ) item->restart_decay_timer(); MoveItemWorldPosition( oldx, oldy, item, NULL ); - WorldIterator::InVisualRange( item, [&]( Character* zonechr ) - { - send_item( zonechr->client, item ); - } ); + WorldIterator::InVisualRange( + item, [&]( Character* zonechr ) { send_item( zonechr->client, item ); } ); Network::RemoveObjectPkt msgremove( item->serial_ext ); WorldIterator::InRange( - oldx, oldy, item->realm, RANGE_VISUAL, [&]( Character* zonechr ) - { + oldx, oldy, item->realm, RANGE_VISUAL, [&]( Character* zonechr ) { if ( !inrange( zonechr, item ) ) // not in range. If old loc was in range, send a delete. msgremove.Send( zonechr->client ); } ); @@ -1703,14 +1643,11 @@ void move_item( Item* item, unsigned short newx, unsigned short newy, signed cha item->restart_decay_timer(); MoveItemWorldPosition( oldx, oldy, item, oldrealm ); - WorldIterator::InVisualRange( item, [&]( Character* zonechr ) - { - send_item( zonechr->client, item ); - } ); + WorldIterator::InVisualRange( + item, [&]( Character* zonechr ) { send_item( zonechr->client, item ); } ); Network::RemoveObjectPkt msgremove( item->serial_ext ); WorldIterator::InRange( - oldx, oldy, oldrealm, RANGE_VISUAL, [&]( Character* zonechr ) - { + oldx, oldy, oldrealm, RANGE_VISUAL, [&]( Character* zonechr ) { if ( !inrange( zonechr, item ) ) // not in range. If old loc was in range, send a delete. msgremove.Send( zonechr->client ); } ); @@ -1727,10 +1664,8 @@ void send_multi_to_inrange( const Multi::UMulti* multi ) { auto pkt = SendWorldMulti( multi->serial_ext, multi->multidef().multiid, multi->x, multi->y, multi->z, multi->color ); - WorldIterator::InVisualRange( multi, [&]( Character* zonechr ) - { - pkt.Send( zonechr->client ); - } ); + WorldIterator::InVisualRange( + multi, [&]( Character* zonechr ) { pkt.Send( zonechr->client ); } ); } @@ -1963,25 +1898,23 @@ void send_create_mobile_if_nearby_cansee( Client* client, const Character* chr ) void send_create_mobile_to_nearby_cansee( const Character* chr ) { - WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) - { - if ( zonechr == chr ) - return; - if ( zonechr->is_visible_to_me( chr ) ) - send_owncreate( zonechr->client, chr ); - } ); + WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) { + if ( zonechr == chr ) + return; + if ( zonechr->is_visible_to_me( chr ) ) + send_owncreate( zonechr->client, chr ); + } ); } void send_move_mobile_to_nearby_cansee( const Character* chr ) { MoveChrPkt msgmove( chr ); - WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) - { - if ( zonechr == chr ) - return; - if ( zonechr->is_visible_to_me( chr ) ) - msgmove.Send( zonechr->client ); - } ); + WorldIterator::InVisualRange( chr, [&]( Character* zonechr ) { + if ( zonechr == chr ) + return; + if ( zonechr->is_visible_to_me( chr ) ) + msgmove.Send( zonechr->client ); + } ); } Character* UpdateCharacterWeight( Item* item ) @@ -2027,11 +1960,11 @@ void send_feature_enable( Client* client ) switch ( client->acct->uo_expansion_flag() ) { case TOL: - clientflag = 0x7387DF; - client->UOExpansionFlag = - TOL | HSA | SA | KR | ML | SE | - AOS; // TOL needs HSA- SA- KR- ML- SE- and AOS- features (and used checks) too - break; + clientflag = 0x7387DF; + client->UOExpansionFlag = + TOL | HSA | SA | KR | ML | SE | + AOS; // TOL needs HSA- SA- KR- ML- SE- and AOS- features (and used checks) too + break; case HSA: clientflag = 0x387DF; client->UOExpansionFlag = @@ -2133,7 +2066,7 @@ void send_map_difs( Client* client ) u32 max_map_id = mapinfo.rbegin()->first; PktHelper::PacketOut msg; - msg->offset += 4; // len+sub + msg->offset += 4; // len+sub msg->WriteFlipped( max_map_id + 1 ); // Number of maps for ( u32 i = 0; i <= max_map_id; i++ ) { @@ -2244,18 +2177,18 @@ void sendCharProfile( Character* chr, Character* of_who, const char* title, cons } /** -* Sends the packet for the buff bar -* @author Bodom, 2015-12-02 -* -* @param chr the Character to send the packet to -* @param icon the ID of the icon to show/remove -* @param show if true, shows/updates the icon; if false, removes the icon -* @param duration duration in seconds, only for displaying [ignored if show is false] -* @param cl_name name of the buff, cliloc id [ignored if show is false] -* @param cl_descr description of the buff, cliloc id [ignored if show is false] -* @param arguments arguments for cl_descr as unicode string, separated by spaces, without NULL -* terminator -*/ + * Sends the packet for the buff bar + * @author Bodom, 2015-12-02 + * + * @param chr the Character to send the packet to + * @param icon the ID of the icon to show/remove + * @param show if true, shows/updates the icon; if false, removes the icon + * @param duration duration in seconds, only for displaying [ignored if show is false] + * @param cl_name name of the buff, cliloc id [ignored if show is false] + * @param cl_descr description of the buff, cliloc id [ignored if show is false] + * @param arguments arguments for cl_descr as unicode string, separated by spaces, without NULL + * terminator + */ void send_buff_message( Character* chr, u16 icon, bool show, u16 duration, u32 cl_name, u32 cl_descr, std::vector arguments ) { diff --git a/pol-core/pol/ufunc.h b/pol-core/pol/ufunc.h index 35a8e97f1..154e30cf8 100644 --- a/pol-core/pol/ufunc.h +++ b/pol-core/pol/ufunc.h @@ -16,11 +16,10 @@ #include #include "../clib/rawtypes.h" - -#include "uconst.h" -#include "network/packets.h" - #include "core.h" +#include "network/packets.h" +#include "uconst.h" + namespace Pol { namespace Network @@ -47,9 +46,9 @@ class Realm; namespace Core { +class Menu; class UContainer; class UObject; -class Menu; void SetCurrentItemSerialNumber( u32 serial ); void SetCurrentCharSerialNumber( u32 serial ); @@ -180,9 +179,11 @@ void send_sysmessage( Network::Client* client, const u16* wtext, const char lang unsigned short font = DEFAULT_TEXT_FONT, unsigned short color = DEFAULT_TEXT_COLOR ); void broadcast( const char* text, unsigned short font = DEFAULT_TEXT_FONT, - unsigned short color = DEFAULT_TEXT_COLOR, unsigned short requiredCmdLevel = DEFAULT_TEXT_REQUIREDCMD ); + unsigned short color = DEFAULT_TEXT_COLOR, + unsigned short requiredCmdLevel = DEFAULT_TEXT_REQUIREDCMD ); void broadcast( const u16* wtext, const char lang[4], unsigned short font = DEFAULT_TEXT_FONT, - unsigned short color = DEFAULT_TEXT_COLOR, unsigned short requiredCmdLevel = DEFAULT_TEXT_REQUIREDCMD ); + unsigned short color = DEFAULT_TEXT_COLOR, + unsigned short requiredCmdLevel = DEFAULT_TEXT_REQUIREDCMD ); bool say_above( const UObject* obj, const char* text, unsigned short font = DEFAULT_TEXT_FONT, unsigned short color = DEFAULT_TEXT_COLOR, unsigned int journal_print = JOURNAL_PRINT_NAME ); diff --git a/pol-core/pol/ufunc2.cpp b/pol-core/pol/ufunc2.cpp index b5e60c1c0..7873b8238 100644 --- a/pol-core/pol/ufunc2.cpp +++ b/pol-core/pol/ufunc2.cpp @@ -7,25 +7,17 @@ */ +#include "../clib/rawtypes.h" +#include "containr.h" +#include "item/item.h" +#include "menu.h" +#include "mobile/charactr.h" +#include "network/client.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "tooltips.h" #include "ufunc.h" -#include "network/client.h" -#include "network/packets.h" -#include "network/packethelper.h" -#include "network/clienttransmit.h" -#include "sockio.h" -#include "menu.h" -#include "pktout.h" -#include "tooltips.h" -#include "uworld.h" -#include "mobile/npc.h" -#include "globals/uvars.h" -#include "containr.h" - -#include "../clib/clib_endian.h" -#include "../clib/clib.h" - -#include namespace Pol { diff --git a/pol-core/pol/uimport.cpp b/pol-core/pol/uimport.cpp index 36bb95cec..dcaf87249 100644 --- a/pol-core/pol/uimport.cpp +++ b/pol-core/pol/uimport.cpp @@ -13,62 +13,59 @@ #include "uimport.h" -#include "loaddata.h" -#include "accounts/account.h" -#include "accounts/accounts.h" -#include "mobile/charactr.h" -#include "item/itemdesc.h" - -#include "fnsearch.h" -#include "objtype.h" -#include "mobile/npc.h" -#include "polcfg.h" -#include "realms.h" -#include "realms/realm.h" -#include "resource.h" -#include "savedata.h" -#include "servdesc.h" -#include "sockio.h" -#include "startloc.h" -#include "storage.h" -#include "stubdata.h" -#include "globals/uvars.h" -#include "globals/network.h" -#include "globals/object_storage.h" -#include "globals/state.h" -#include "globals/settings.h" -#include "ufunc.h" -#include "uworld.h" -#include "multi/multi.h" -#include "multi/house.h" -#include "containr.h" - -#include "../plib/systemstate.h" +#include +#include +#include +#include +#include +#include +#include #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" +#include "../clib/clib.h" #include "../clib/clib_endian.h" #include "../clib/esignal.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" -#include "../clib/stlutil.h" -#include "../clib/strutil.h" -#include "../clib/timer.h" +#include "../clib/passert.h" +#include "../clib/rawtypes.h" #include "../clib/threadhelp.h" +#include "../clib/timer.h" +#include "../plib/systemstate.h" +#include "accounts/accounts.h" +#include "containr.h" +#include "fnsearch.h" +#include "gameclck.h" +#include "globals/network.h" +#include "globals/object_storage.h" +#include "globals/settings.h" +#include "globals/state.h" +#include "globals/uvars.h" +#include "item/item.h" +#include "item/itemdesc.h" +#include "loaddata.h" +#include "mobile/charactr.h" +#include "mobile/npc.h" +#include "multi/house.h" +#include "multi/multi.h" +#include "objecthash.h" +#include "poltype.h" +#include "polvar.h" +#include "resource.h" +#include "savedata.h" +#include "servdesc.h" +#include "startloc.h" +#include "storage.h" +#include "ufunc.h" +#include "uobject.h" +#include "uworld.h" + #ifndef __clang__ #include #endif -#include -#include -#include - -#include -#include -#include -#include - #ifdef _MSC_VER #pragma warning( disable : 4996 ) // disable warning deprecation of stricmp #endif @@ -202,8 +199,8 @@ Items::Item* read_item( Clib::ConfigElem& elem ) Items::Item* item = Items::Item::create( objtype, serial ); if ( item == NULL ) { - ERROR_PRINT.Format( "Unable to create item: objtype=0x{:X}, serial=0x{:X}" ) << objtype - << serial; + ERROR_PRINT.Format( "Unable to create item: objtype=0x{:X}, serial=0x{:X}" ) + << objtype << serial; if ( !Plib::systemstate.config.ignore_load_errors ) throw std::runtime_error( "Item::create failed!" ); else @@ -356,8 +353,8 @@ void read_multi( Clib::ConfigElem& elem ) Multi::UMulti* multi = Multi::UMulti::create( Items::find_itemdesc( objtype ), serial ); if ( multi == NULL ) { - ERROR_PRINT.Format( "Unable to create multi: objtype=0x{:X}, serial=0x{:X}\n" ) << objtype - << serial; + ERROR_PRINT.Format( "Unable to create multi: objtype=0x{:X}, serial=0x{:X}\n" ) + << objtype << serial; throw std::runtime_error( "Multi::create failed!" ); } multi->readProperties( elem ); @@ -440,8 +437,8 @@ void read_pol_dat() if ( settingsManager.polvar.DataWrittenBy == 0 ) { ERROR_PRINT - << "CoreVersion not found in " << polfile << "\n\n" << polfile - << " must contain a section similar to: \n" + << "CoreVersion not found in " << polfile << "\n\n" + << polfile << " must contain a section similar to: \n" << "System\n" << "{\n" << " CoreVersion 99\n" @@ -826,7 +823,7 @@ void write_global_properties( Clib::StreamWriter& sw ) void write_system_data( Clib::StreamWriter& sw ) { - sw() << "System" << pf_endl << "{" << pf_endl << "\tCoreVersion\t" << POL_VERSION_MAJOR << pf_endl + sw() << "System" << pf_endl << "{" << pf_endl << "\tCoreVersion\t" << POL_VERSION << pf_endl << "\tCoreVersionString\t" << POL_VERSION_ID << pf_endl << "\tCompileDate\t" << POL_BUILD_DATE << pf_endl << "\tCompileTime\t" << POL_BUILD_TIME << pf_endl << "\tLastItemSerialNumber\t" << GetCurrentItemSerialNumber() << pf_endl // dave 3/9/3 @@ -993,8 +990,8 @@ bool commit( const std::string& basename ) if ( unlink( bakfile_c ) ) { int err = errno; - POLLOG_ERROR.Format( "Unable to remove {}: {} ({})\n" ) << bakfile_c << strerror( err ) - << err; + POLLOG_ERROR.Format( "Unable to remove {}: {} ({})\n" ) + << bakfile_c << strerror( err ) << err; } } @@ -1004,8 +1001,8 @@ bool commit( const std::string& basename ) if ( rename( datfile_c, bakfile_c ) ) { int err = errno; - POLLOG_ERROR.Format( "Unable to rename {} to {}: {} ({})\n" ) << datfile_c << bakfile_c - << strerror( err ) << err; + POLLOG_ERROR.Format( "Unable to rename {} to {}: {} ({})\n" ) + << datfile_c << bakfile_c << strerror( err ) << err; } } @@ -1015,8 +1012,8 @@ bool commit( const std::string& basename ) if ( rename( ndtfile_c, datfile_c ) ) { int err = errno; - POLLOG_ERROR.Format( "Unable to rename {} to {}: {} ({})\n" ) << ndtfile_c << datfile_c - << strerror( err ) << err; + POLLOG_ERROR.Format( "Unable to rename {} to {}: {} ({})\n" ) + << ndtfile_c << datfile_c << strerror( err ) << err; } } @@ -1053,198 +1050,196 @@ int write_data( unsigned int& dirty_writes, unsigned int& clean_writes, long lon // the remaining operations are only pure buffered i/o auto critical_promise = std::make_shared>(); auto critical_future = critical_promise->get_future(); - SaveContext::finished = std::async( - std::launch::async, [&, critical_promise]() -> bool - { + SaveContext::finished = std::async( std::launch::async, [&, critical_promise]() -> bool { // limit the used thread #ifndef __clang__ - int max_threads = omp_get_max_threads(); - if ( max_threads > 1 ) - { - max_threads /= 2; - max_threads = std::max( 2, max_threads ); - } - omp_set_num_threads( max_threads ); + int max_threads = omp_get_max_threads(); + if ( max_threads > 1 ) + { + max_threads /= 2; + max_threads = std::max( 2, max_threads ); + } + omp_set_num_threads( max_threads ); #endif - try - { - SaveContext sc; - bool result = true; + try + { + SaveContext sc; + bool result = true; #pragma omp parallel sections - { + { #pragma omp section - { - threadhelp::ThreadRegister register_thread( "SaveSection: pol" ); - try - { - sc.pol() << "#" << pf_endl << "# Created by Version: " << POL_VERSION_ID << pf_endl - << "# Mobiles: " << get_mobile_count() << pf_endl - << "# Top-level Items: " << get_toplevel_item_count() << pf_endl << "#" - << pf_endl << pf_endl; - - write_system_data( sc.pol ); - write_global_properties( sc.pol ); - write_shadow_realms( sc.pol ); - } - catch ( ... ) - { - POLLOG_ERROR << "failed to store pol datafile!\n"; - Clib::force_backtrace(); - result = false; - } - } -#pragma omp section - { - threadhelp::ThreadRegister register_thread( "SaveSection: items" ); - try - { - write_items( sc.items ); - } - catch ( ... ) - { - POLLOG_ERROR << "failed to store items datafile!\n"; - Clib::force_backtrace(); - result = false; - } - } -#pragma omp section - { - threadhelp::ThreadRegister register_thread( "SaveSection: chars" ); - try - { - write_characters( sc ); - } - catch ( ... ) - { - POLLOG_ERROR << "failed to store character datafile!\n"; - Clib::force_backtrace(); - result = false; - } - } -#pragma omp section - { - threadhelp::ThreadRegister register_thread( "SaveSection: npcs" ); - try - { - write_npcs( sc ); - } - catch ( ... ) - { - POLLOG_ERROR << "failed to store npcs datafile!\n"; - Clib::force_backtrace(); - result = false; - } - } -#pragma omp section - { - threadhelp::ThreadRegister register_thread( "SaveSection: multis" ); - try - { - write_multis( sc.multis ); - } - catch ( ... ) - { - POLLOG_ERROR << "failed to store multis datafile!\n"; - Clib::force_backtrace(); - result = false; - } - } -#pragma omp section - { - threadhelp::ThreadRegister register_thread( "SaveSection: storage" ); - try - { - gamestate.storage.print( sc.storage ); - } - catch ( ... ) - { - POLLOG_ERROR << "failed to store storage datafile!\n"; - Clib::force_backtrace(); - result = false; - } - } -#pragma omp section - { - threadhelp::ThreadRegister register_thread( "SaveSection: resource" ); - try - { - write_resources_dat( sc.resource ); - } - catch ( ... ) - { - POLLOG_ERROR << "failed to store resource datafile!\n"; - Clib::force_backtrace(); - result = false; - } - } -#pragma omp section - { - threadhelp::ThreadRegister register_thread( "SaveSection: guilds" ); - try - { - write_guilds( sc.guilds ); - } - catch ( ... ) - { - POLLOG_ERROR << "failed to store guilds datafile!\n"; - Clib::force_backtrace(); - result = false; - } - } -#pragma omp section - { - threadhelp::ThreadRegister register_thread( "SaveSection: datastore" ); - try - { - Module::write_datastore( sc.datastore ); - // Atomically (hopefully) perform the switch. - Module::commit_datastore(); - } - catch ( ... ) - { - POLLOG_ERROR << "failed to store datastore datafile!\n"; - Clib::force_backtrace(); - result = false; - } - } -#pragma omp section - { - threadhelp::ThreadRegister register_thread( "SaveSection: party" ); - try - { - write_party( sc.party ); - } - catch ( ... ) - { - POLLOG_ERROR << "failed to store party datafile!\n"; - Clib::force_backtrace(); - result = false; - } - } - } - critical_promise->set_value( result ); // critical part end - } // deconstructor of the SaveContext flushes and joins the queues - catch ( ... ) { - POLLOG_ERROR << "failed to save datafiles!\n"; - Clib::force_backtrace(); - critical_promise->set_value( false ); // critical part end + threadhelp::ThreadRegister register_thread( "SaveSection: pol" ); + try + { + sc.pol() << "#" << pf_endl << "# Created by Version: " << POL_VERSION_ID << pf_endl + << "# Mobiles: " << get_mobile_count() << pf_endl + << "# Top-level Items: " << get_toplevel_item_count() << pf_endl << "#" + << pf_endl << pf_endl; + + write_system_data( sc.pol ); + write_global_properties( sc.pol ); + write_shadow_realms( sc.pol ); + } + catch ( ... ) + { + POLLOG_ERROR << "failed to store pol datafile!\n"; + Clib::force_backtrace(); + result = false; + } } - commit( "pol" ); - commit( "objects" ); - commit( "pcs" ); - commit( "pcequip" ); - commit( "npcs" ); - commit( "npcequip" ); - commit( "items" ); - commit( "multis" ); - commit( "storage" ); - commit( "resource" ); - commit( "guilds" ); - commit( "datastore" ); - commit( "parties" ); - return true; - } ); +#pragma omp section + { + threadhelp::ThreadRegister register_thread( "SaveSection: items" ); + try + { + write_items( sc.items ); + } + catch ( ... ) + { + POLLOG_ERROR << "failed to store items datafile!\n"; + Clib::force_backtrace(); + result = false; + } + } +#pragma omp section + { + threadhelp::ThreadRegister register_thread( "SaveSection: chars" ); + try + { + write_characters( sc ); + } + catch ( ... ) + { + POLLOG_ERROR << "failed to store character datafile!\n"; + Clib::force_backtrace(); + result = false; + } + } +#pragma omp section + { + threadhelp::ThreadRegister register_thread( "SaveSection: npcs" ); + try + { + write_npcs( sc ); + } + catch ( ... ) + { + POLLOG_ERROR << "failed to store npcs datafile!\n"; + Clib::force_backtrace(); + result = false; + } + } +#pragma omp section + { + threadhelp::ThreadRegister register_thread( "SaveSection: multis" ); + try + { + write_multis( sc.multis ); + } + catch ( ... ) + { + POLLOG_ERROR << "failed to store multis datafile!\n"; + Clib::force_backtrace(); + result = false; + } + } +#pragma omp section + { + threadhelp::ThreadRegister register_thread( "SaveSection: storage" ); + try + { + gamestate.storage.print( sc.storage ); + } + catch ( ... ) + { + POLLOG_ERROR << "failed to store storage datafile!\n"; + Clib::force_backtrace(); + result = false; + } + } +#pragma omp section + { + threadhelp::ThreadRegister register_thread( "SaveSection: resource" ); + try + { + write_resources_dat( sc.resource ); + } + catch ( ... ) + { + POLLOG_ERROR << "failed to store resource datafile!\n"; + Clib::force_backtrace(); + result = false; + } + } +#pragma omp section + { + threadhelp::ThreadRegister register_thread( "SaveSection: guilds" ); + try + { + write_guilds( sc.guilds ); + } + catch ( ... ) + { + POLLOG_ERROR << "failed to store guilds datafile!\n"; + Clib::force_backtrace(); + result = false; + } + } +#pragma omp section + { + threadhelp::ThreadRegister register_thread( "SaveSection: datastore" ); + try + { + Module::write_datastore( sc.datastore ); + // Atomically (hopefully) perform the switch. + Module::commit_datastore(); + } + catch ( ... ) + { + POLLOG_ERROR << "failed to store datastore datafile!\n"; + Clib::force_backtrace(); + result = false; + } + } +#pragma omp section + { + threadhelp::ThreadRegister register_thread( "SaveSection: party" ); + try + { + write_party( sc.party ); + } + catch ( ... ) + { + POLLOG_ERROR << "failed to store party datafile!\n"; + Clib::force_backtrace(); + result = false; + } + } + } + critical_promise->set_value( result ); // critical part end + } // deconstructor of the SaveContext flushes and joins the queues + catch ( ... ) + { + POLLOG_ERROR << "failed to save datafiles!\n"; + Clib::force_backtrace(); + critical_promise->set_value( false ); // critical part end + } + commit( "pol" ); + commit( "objects" ); + commit( "pcs" ); + commit( "pcequip" ); + commit( "npcs" ); + commit( "npcequip" ); + commit( "items" ); + commit( "multis" ); + commit( "storage" ); + commit( "resource" ); + commit( "guilds" ); + commit( "datastore" ); + commit( "parties" ); + return true; + } ); critical_future.wait(); // wait for end of critical part if ( Plib::systemstate.accounts_txt_dirty ) // write accounts extra, since it uses extra thread diff --git a/pol-core/pol/umap.cpp b/pol-core/pol/umap.cpp index 53fda5cb4..171599137 100644 --- a/pol-core/pol/umap.cpp +++ b/pol-core/pol/umap.cpp @@ -8,29 +8,26 @@ */ #include "umap.h" -#include "pktboth.h" -#include "poltype.h" -#include "sockio.h" -#include "ufunc.h" -#include "realms/realm.h" -#include "network/client.h" -#include "network/packets.h" -#include "network/packethelper.h" -#include "network/msghandl.h" -#include "item/itemdesc.h" -#include "fnsearch.h" +#include +#include +#include "../bscript/berror.h" #include "../bscript/bobject.h" #include "../bscript/bstruct.h" #include "../bscript/executor.h" -#include "../bscript/berror.h" #include "../bscript/objmethods.h" - #include "../clib/cfgelem.h" #include "../clib/clib_endian.h" -#include "../clib/stlutil.h" #include "../clib/streamsaver.h" +#include "item/itemdesc.h" +#include "network/client.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "pktboth.h" +#include "realms/realm.h" +#include "ufunc.h" +#include "uobject.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // disable deprecation warning sprintf, sscanf @@ -56,9 +53,7 @@ Map::Map( const Items::MapDesc& mapdesc ) { } -Map::~Map() -{ -} +Map::~Map() {} void Map::printProperties( Clib::StreamWriter& sw ) const { diff --git a/pol-core/pol/umap.h b/pol-core/pol/umap.h index ef6f321c4..18f32ba4c 100644 --- a/pol-core/pol/umap.h +++ b/pol-core/pol/umap.h @@ -7,6 +7,9 @@ #ifndef UMAP_H #define UMAP_H +#include "../bscript/bobject.h" +#include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" #ifndef ITEM_H #include "item/item.h" #endif @@ -16,6 +19,26 @@ namespace Pol namespace Bscript { class BObjectImp; +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +namespace Clib +{ +class ConfigElem; +class StreamWriter; +} // namespace Clib +namespace Items +{ +class ItemDesc; +} // namespace Items +namespace Network +{ +class Client; +} // namespace Network +} // namespace Pol } namespace Items { @@ -24,6 +47,7 @@ class MapDesc; namespace Core { struct PKTBI_56; + struct PinPoint { unsigned short x; diff --git a/pol-core/pol/unicode.cpp b/pol-core/pol/unicode.cpp index 8b882811c..fdbf6bc3c 100644 --- a/pol-core/pol/unicode.cpp +++ b/pol-core/pol/unicode.cpp @@ -7,8 +7,11 @@ #include "unicode.h" -#include "../clib/clib_endian.h" +#include + #include "../bscript/bobject.h" +#include "../clib/clib_endian.h" + namespace Pol { namespace Core diff --git a/pol-core/pol/unicode.h b/pol-core/pol/unicode.h index 5aaa68390..397fe7e59 100644 --- a/pol-core/pol/unicode.h +++ b/pol-core/pol/unicode.h @@ -9,6 +9,7 @@ #define POL_UNICODE_H #include + #include "../clib/rawtypes.h" namespace Pol diff --git a/pol-core/pol/uobjcnt.cpp b/pol-core/pol/uobjcnt.cpp index bf0054f92..9df94c470 100644 --- a/pol-core/pol/uobjcnt.cpp +++ b/pol-core/pol/uobjcnt.cpp @@ -21,4 +21,4 @@ UObjCount::UObjCount() { } } -} \ No newline at end of file +} diff --git a/pol-core/pol/uobject.cpp b/pol-core/pol/uobject.cpp index b3bd452b4..ff192b6f8 100644 --- a/pol-core/pol/uobject.cpp +++ b/pol-core/pol/uobject.cpp @@ -9,28 +9,31 @@ #include "uobject.h" +#include +#include +#include +#include + #include "../clib/cfgelem.h" -#include "../clib/clib_endian.h" #include "../clib/logfacility.h" #include "../clib/passert.h" +#include "../clib/rawtypes.h" +#include "../clib/refptr.h" #include "../clib/streamsaver.h" - #include "../plib/systemstate.h" - +#include "baseobject.h" +#include "clidata.h" +#include "dynproperties.h" #include "globals/state.h" -#include "item/item.h" #include "item/itemdesc.h" #include "objtype.h" -#include "polclass.h" #include "polcfg.h" +#include "proplist.h" #include "realms.h" #include "realms/realm.h" -#include "reftypes.h" #include "tooltips.h" -#include "ufunc.h" -#include "zone.h" - -#include +#include "uconst.h" +#include "uobjcnt.h" namespace Pol { @@ -375,13 +378,9 @@ bool UObject::setcolor( u16 newcolor ) return true; } -void UObject::on_color_changed() -{ -} +void UObject::on_color_changed() {} -void UObject::on_facing_changed() -{ -} +void UObject::on_facing_changed() {} bool UObject::saveonexit() const { diff --git a/pol-core/pol/uobject.h b/pol-core/pol/uobject.h index d3553e1ac..0a09b6c0d 100644 --- a/pol-core/pol/uobject.h +++ b/pol-core/pol/uobject.h @@ -16,23 +16,21 @@ #include "../clib/rawtypes.h" #endif +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../clib/boostutils.h" #include "../clib/refptr.h" #include "baseobject.h" #include "dynproperties.h" #include "proplist.h" -#include "../clib/boostutils.h" - -#include -#include - -#include -#include -#include -#include -#include -#include - #define pf_endl '\n' @@ -101,8 +99,7 @@ struct ElementDamages template ::value && !std::is_convertible::value - , int>::type = 0 > + std::is_enum::value && !std::is_convertible::value, int>::type = 0> struct AttributeFlags { typedef typename std::underlying_type::type enum_t; @@ -123,22 +120,23 @@ struct AttributeFlags remove( flag ); } void reset() { flags_ = 0; }; + private: enum_t flags_; }; enum class OBJ_FLAGS : u16 { - DIRTY = 1 << 0, // UObject flags + DIRTY = 1 << 0, // UObject flags SAVE_ON_EXIT = 1 << 1, - NEWBIE = 1 << 2, // Item flags - INSURED = 1 << 3, - MOVABLE = 1 << 4, - IN_USE = 1 << 5, - INVISIBLE = 1 << 6, - LOCKED = 1 << 7, // ULockable flag - CONTENT_TO_GRAVE = 1 << 8, // UCorpse flag - NO_DROP = 1 << 9, // Item flag + NEWBIE = 1 << 2, // Item flags + INSURED = 1 << 3, + MOVABLE = 1 << 4, + IN_USE = 1 << 5, + INVISIBLE = 1 << 6, + LOCKED = 1 << 7, // ULockable flag + CONTENT_TO_GRAVE = 1 << 8, // UCorpse flag + NO_DROP = 1 << 9, // Item flag NO_DROP_EXCEPTION = 1 << 10, // Container/Character flag }; @@ -319,7 +317,6 @@ inline bool IsItem( u32 serial ) { return ( serial & 0x40000000Lu ) ? true : false; } - } } diff --git a/pol-core/pol/uoclient.cpp b/pol-core/pol/uoclient.cpp index 9fa9017e4..bd7db7240 100644 --- a/pol-core/pol/uoclient.cpp +++ b/pol-core/pol/uoclient.cpp @@ -7,23 +7,22 @@ #include "uoclient.h" +#include + +#include "../clib/cfgelem.h" +#include "../plib/pkg.h" +#include "globals/network.h" #include "mobile/attribute.h" #include "skillid.h" -#include "vital.h" #include "syshookscript.h" -#include "globals/network.h" - -#include "../plib/pkg.h" -#include "../clib/cfgelem.h" +#include "vital.h" namespace Pol { namespace Core { -UoClientProtocol::UoClientProtocol() : EnableFlowControlPackets( false ) -{ -} +UoClientProtocol::UoClientProtocol() : EnableFlowControlPackets( false ) {} size_t UoClientProtocol::estimateSize() const { return sizeof( UoClientProtocol ); @@ -148,12 +147,11 @@ size_t UoClientGeneral::estimateSize() const void UoClientGeneral::deinitialize() { - if (method_script != nullptr) - { - delete method_script; - method_script = nullptr; - } -} - + if ( method_script != nullptr ) + { + delete method_script; + method_script = nullptr; + } +} } } diff --git a/pol-core/pol/uoclient.h b/pol-core/pol/uoclient.h index 5eee59e4b..f0466e71f 100644 --- a/pol-core/pol/uoclient.h +++ b/pol-core/pol/uoclient.h @@ -10,11 +10,11 @@ #ifndef UOCLIENT_H #define UOCLIENT_H -#include "crypt/cryptkey.h" - #include #include +#include "crypt/cryptkey.h" + namespace Pol { namespace Clib diff --git a/pol-core/pol/uoexec.cpp b/pol-core/pol/uoexec.cpp index e4e9770aa..3ba34bcd6 100644 --- a/pol-core/pol/uoexec.cpp +++ b/pol-core/pol/uoexec.cpp @@ -1,13 +1,14 @@ #include "uoexec.h" -#include "polclock.h" -#include "polcfg.h" - -#include "module/osmod.h" -#include "globals/settings.h" +#include +#include "../bscript/executor.h" #include "../clib/logfacility.h" #include "../plib/systemstate.h" +#include "globals/settings.h" +#include "module/osmod.h" +#include "polcfg.h" +#include "polclock.h" namespace Pol { @@ -57,13 +58,13 @@ bool UOExecutor::suspend() return false; os_module->suspend(); - return true; + return true; } bool UOExecutor::revive() { - os_module->revive(); - return true; + os_module->revive(); + return true; } std::string UOExecutor::state() @@ -81,4 +82,4 @@ size_t UOExecutor::sizeEstimate() const return sizeof( UOExecutor ) + base::sizeEstimate(); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/uoexec.h b/pol-core/pol/uoexec.h index fbc8f5fa3..3e0874aee 100644 --- a/pol-core/pol/uoexec.h +++ b/pol-core/pol/uoexec.h @@ -12,7 +12,13 @@ #include "../bscript/executor.h" #endif +#include +#include + +#include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" #include "../clib/weakptr.h" + namespace Pol { namespace Module @@ -27,8 +33,8 @@ class UOExecutor : public Bscript::Executor { typedef Bscript::Executor base; -public: // soon to be private ;) - Module::OSExecutorModule* os_module; +public: // soon to be private ;) + Module::OSExecutorModule* os_module; public: UOExecutor(); diff --git a/pol-core/pol/uoexhelp.cpp b/pol-core/pol/uoexhelp.cpp index c31012e83..50d651ce4 100644 --- a/pol-core/pol/uoexhelp.cpp +++ b/pol-core/pol/uoexhelp.cpp @@ -8,31 +8,30 @@ #include "uoexhelp.h" -#include "item/itemdesc.h" -#include "mobile/attribute.h" -#include "globals/uvars.h" -#include "globals/network.h" - -#include "fnsearch.h" -#include "polcfg.h" -#include "uoscrobj.h" -#include "ufunc.h" -#include "vital.h" +#include +#include +#include +#include #include "../bscript/berror.h" -#include "../bscript/execmodl.h" +#include "../bscript/bobject.h" #include "../bscript/executor.h" #include "../bscript/fmodule.h" #include "../bscript/impstr.h" -#include "../bscript/objmethods.h" - #include "../clib/logfacility.h" #include "../clib/strutil.h" -#include "../clib/stlutil.h" - #include "../plib/systemstate.h" - -#include +#include "fnsearch.h" +#include "globals/network.h" +#include "globals/uvars.h" +#include "item/itemdesc.h" +#include "mobile/attribute.h" +#include "mobile/charactr.h" +#include "multi/multi.h" +#include "network/client.h" +#include "uobject.h" +#include "uoscrobj.h" +#include "vital.h" namespace Pol { diff --git a/pol-core/pol/uofile00.cpp b/pol-core/pol/uofile00.cpp index bafd16961..fe615b3de 100644 --- a/pol-core/pol/uofile00.cpp +++ b/pol-core/pol/uofile00.cpp @@ -3,23 +3,16 @@ * @par History */ - #include "uofile.h" -#include "polcfg.h" -#include "polfile.h" -#include "udatfile.h" -#include "ustruct.h" +#include +#include #include "../clib/fileutil.h" #include "../clib/logfacility.h" #include "../clib/stlutil.h" - #include "../plib/systemstate.h" -#include -#include - #ifdef _MSC_VER #pragma warning( disable : 4996 ) // disable deprecation warning for fopen, etc #endif diff --git a/pol-core/pol/uofile01.cpp b/pol-core/pol/uofile01.cpp index 86bc16a08..f7796eac2 100644 --- a/pol-core/pol/uofile01.cpp +++ b/pol-core/pol/uofile01.cpp @@ -5,21 +5,15 @@ */ -#include "uofile.h" -#include "uofilei.h" - -#include "../plib/mapfunc.h" -#include "../plib/systemstate.h" - -#include "objtype.h" -#include "polfile.h" -#include "udatfile.h" -#include "ustruct.h" - -#include "../clib/passert.h" #include #include -#include + +#include "../clib/passert.h" +#include "../clib/rawtypes.h" +#include "../plib/systemstate.h" +#include "uofile.h" +#include "uofilei.h" +#include "ustruct.h" #ifdef _MSC_VER #pragma warning( disable : 4996 ) // deprecation warning for sprintf diff --git a/pol-core/pol/uofile02.cpp b/pol-core/pol/uofile02.cpp index 005214752..705c59466 100644 --- a/pol-core/pol/uofile02.cpp +++ b/pol-core/pol/uofile02.cpp @@ -7,22 +7,16 @@ */ +#include + +#include "../clib/logfacility.h" +#include "../clib/passert.h" +#include "../clib/rawtypes.h" +#include "../clib/stlutil.h" #include "uofile.h" #include "uofilei.h" - -#include "polcfg.h" -#include "polfile.h" -#include "udatfile.h" #include "ustruct.h" -#include "../clib/passert.h" -#include "../clib/stlutil.h" -#include "../clib/logfacility.h" - -#include -#include -#include - namespace Pol { @@ -196,4 +190,4 @@ void rawstaticfullread() rawstatic_init = true; } } -} \ No newline at end of file +} diff --git a/pol-core/pol/uofile06.cpp b/pol-core/pol/uofile06.cpp index 7f2e656b2..f0652c17e 100644 --- a/pol-core/pol/uofile06.cpp +++ b/pol-core/pol/uofile06.cpp @@ -4,17 +4,12 @@ */ -#include "uofile.h" -#include "uofilei.h" - -#include "polcfg.h" -#include "polfile.h" +#include "clidata.h" +#include "uconst.h" #include "udatfile.h" +#include "uofile.h" #include "ustruct.h" -#include -#include - namespace Pol { namespace Core @@ -133,7 +128,5 @@ void standheight( MOVEMODE movemode, StaticList& statics, unsigned short x, unsi *result_out = result; *newz_out = newz; } - - } } diff --git a/pol-core/pol/uofile07.cpp b/pol-core/pol/uofile07.cpp index a9c0ea45a..257380857 100644 --- a/pol-core/pol/uofile07.cpp +++ b/pol-core/pol/uofile07.cpp @@ -4,20 +4,10 @@ */ -#include "polcfg.h" -#include "polfile.h" +#include "clidata.h" #include "udatfile.h" -#include "ustruct.h" - #include "uofile.h" -#include "uofilei.h" - -#include "../clib/passert.h" - -#include -#include - -#include +#include "ustruct.h" namespace Pol { @@ -123,4 +113,4 @@ void readallstatics( StaticList& vec, unsigned short x, unsigned short y ) } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/uofile08.cpp b/pol-core/pol/uofile08.cpp index 0125df24b..a30fbf385 100644 --- a/pol-core/pol/uofile08.cpp +++ b/pol-core/pol/uofile08.cpp @@ -6,25 +6,18 @@ */ -#include "uofile.h" -#include "uofilei.h" - -#include "../plib/mapfunc.h" - -#include "clidata.h" -#include "objtype.h" -#include "polcfg.h" -#include "polfile.h" -#include "udatfile.h" -#include "ustruct.h" -#include "poltype.h" - -#include "../clib/passert.h" - #include -#include #include #include +#include + +#include "../clib/passert.h" +#include "../clib/rawtypes.h" +#include "clidata.h" +#include "poltype.h" +#include "uofile.h" +#include "uofilei.h" +#include "ustruct.h" namespace Pol { @@ -205,4 +198,4 @@ void safe_getmapinfo( unsigned short x, unsigned short y, short* z, USTRUCT_MAPI } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/uofilei.h b/pol-core/pol/uofilei.h index 8e9e2b3ee..bb552b6d0 100644 --- a/pol-core/pol/uofilei.h +++ b/pol-core/pol/uofilei.h @@ -7,9 +7,9 @@ #ifndef UOFILEI_H #define UOFILEI_H -#include #include "uconst.h" #include "udatfile.h" +#include namespace Pol { namespace Core diff --git a/pol-core/pol/uolisten.cpp b/pol-core/pol/uolisten.cpp index dab5c51a1..46c1ea123 100644 --- a/pol-core/pol/uolisten.cpp +++ b/pol-core/pol/uolisten.cpp @@ -5,26 +5,24 @@ */ -#include "uoclient.h" -#include "network/client.h" -#include "network/cliface.h" - -#include "core.h" -#include "polsem.h" -#include "sockio.h" -#include "globals/network.h" -#include "polcfg.h" +#include +#include +#include +#include "../clib/compilerspecifics.h" #include "../clib/esignal.h" #include "../clib/logfacility.h" #include "../clib/socketsvc.h" #include "../clib/stlutil.h" -#include "../clib/strutil.h" #include "../clib/threadhelp.h" +#include "../clib/wnsckt.h" #include "../plib/systemstate.h" - -#include -#include +#include "core.h" +#include "globals/network.h" +#include "network/client.h" +#include "network/cliface.h" +#include "polsem.h" +#include "uoclient.h" namespace Pol { @@ -173,4 +171,4 @@ void start_uo_client_listeners( void ) } } } -} \ No newline at end of file +} diff --git a/pol-core/pol/uoscrobj.cpp b/pol-core/pol/uoscrobj.cpp index 7bb8a7727..727bd98b3 100644 --- a/pol-core/pol/uoscrobj.cpp +++ b/pol-core/pol/uoscrobj.cpp @@ -51,55 +51,68 @@ #include "uoscrobj.h" +#include + +#include "../bscript/berror.h" +#include "../bscript/dict.h" +#include "../bscript/execmodl.h" +#include "../bscript/executor.h" +#include "../bscript/impstr.h" +#include "../bscript/objmembers.h" +#include "../bscript/objmethods.h" +#include "../clib/stlutil.h" #include "accounts/account.h" #include "accounts/acscrobj.h" -#include "item/armor.h" -#include "item/armrtmpl.h" -#include "mobile/attribute.h" -#include "multi/boatcomp.h" -#include "mobile/corpse.h" -#include "mobile/ufacing.h" -#include "network/packets.h" -#include "network/packethelper.h" #include "cmdlevel.h" +#include "containr.h" #include "door.h" +#include "dynproperties.h" +#include "equipdsc.h" #include "exscrobj.h" #include "fnsearch.h" -#include "module/guildmod.h" -#include "multi/house.h" -#include "umap.h" +#include "globals/network.h" +#include "globals/uvars.h" +#include "item/armor.h" +#include "item/equipmnt.h" +#include "item/item.h" +#include "item/itemdesc.h" +#include "item/weapon.h" +#include "lockable.h" +#include "mobile/charactr.h" +#include "mobile/corpse.h" #include "mobile/npc.h" -#include "objtype.h" +#include "mobile/ufacing.h" +#include "module/guildmod.h" +#include "module/partymod.h" +#include "module/uomod.h" +#include "multi/boat.h" +#include "multi/boatcomp.h" +#include "multi/house.h" +#include "multi/multi.h" +#include "network/client.h" +#include "network/packethelper.h" +#include "network/packets.h" +#include "npctmpl.h" +#include "pktdef.h" #include "polclass.h" +#include "polclock.h" +#include "poltype.h" +#include "proplist.h" #include "realms.h" #include "realms/realm.h" #include "spelbook.h" #include "statmsg.h" #include "syshookscript.h" #include "tooltips.h" +#include "uconst.h" #include "ufunc.h" -#include "item/weapon.h" -#include "item/wepntmpl.h" +#include "umap.h" +#include "unicode.h" +#include "uobject.h" +#include "uoclient.h" +#include "uoexec.h" #include "uoexhelp.h" #include "uworld.h" -#include "module/uomod.h" -#include "module/partymod.h" -#include "network/clienttransmit.h" -#include "globals/uvars.h" -#include "globals/network.h" -#include "unicode.h" - -#include "../bscript/berror.h" -#include "../bscript/dict.h" -#include "../bscript/escrutil.h" -#include "../bscript/execmodl.h" -#include "../bscript/impstr.h" -#include "../bscript/objmembers.h" -#include "../bscript/objmethods.h" - -#include "../clib/clib_endian.h" -#include "../clib/stlutil.h" -#include "../clib/strutil.h" namespace Pol { @@ -252,7 +265,7 @@ bool ECharacterRefObjImp::operator==( const BObjectImp& objimp ) const return false; } else if ( objimp.isa( Bscript::BObjectImp::OTBoolean ) ) - return isTrue() == static_cast(objimp).isTrue(); + return isTrue() == static_cast( objimp ).isTrue(); else return false; } @@ -436,7 +449,7 @@ bool EItemRefObjImp::operator==( const BObjectImp& objimp ) const return false; } else if ( objimp.isa( Bscript::BObjectImp::OTBoolean ) ) - return isTrue() == static_cast(objimp).isTrue(); + return isTrue() == static_cast( objimp ).isTrue(); else return false; } @@ -573,7 +586,7 @@ bool EUBoatRefObjImp::operator==( const BObjectImp& objimp ) const return false; } else if ( objimp.isa( Bscript::BObjectImp::OTBoolean ) ) - return isTrue() == static_cast(objimp).isTrue(); + return isTrue() == static_cast( objimp ).isTrue(); else return false; } @@ -715,7 +728,7 @@ bool EMultiRefObjImp::operator==( const BObjectImp& objimp ) const return false; } else if ( objimp.isa( Bscript::BObjectImp::OTBoolean ) ) - return isTrue() == static_cast(objimp).isTrue(); + return isTrue() == static_cast( objimp ).isTrue(); else return false; } @@ -951,7 +964,7 @@ BObjectImp* Item::get_script_member_id( const int id ) const return new BLong( fire_resist().sum() ); break; case MBR_COLD_RESIST: - return new BLong( cold_resist().sum()); + return new BLong( cold_resist().sum() ); break; case MBR_ENERGY_RESIST: return new BLong( energy_resist().sum() ); @@ -960,7 +973,7 @@ BObjectImp* Item::get_script_member_id( const int id ) const return new BLong( poison_resist().sum() ); break; case MBR_PHYSICAL_RESIST: - return new BLong( physical_resist().sum()); + return new BLong( physical_resist().sum() ); break; case MBR_FIRE_RESIST_MOD: return new BLong( fire_resist().mod ); @@ -978,19 +991,19 @@ BObjectImp* Item::get_script_member_id( const int id ) const return new BLong( physical_resist().mod ); break; case MBR_FIRE_DAMAGE: - return new BLong( fire_damage().sum()); + return new BLong( fire_damage().sum() ); break; case MBR_COLD_DAMAGE: - return new BLong( cold_damage().sum()); + return new BLong( cold_damage().sum() ); break; case MBR_ENERGY_DAMAGE: - return new BLong(energy_damage().sum()); + return new BLong( energy_damage().sum() ); break; case MBR_POISON_DAMAGE: - return new BLong( poison_damage().sum()); + return new BLong( poison_damage().sum() ); break; case MBR_PHYSICAL_DAMAGE: - return new BLong( physical_damage().sum()); + return new BLong( physical_damage().sum() ); break; case MBR_FIRE_DAMAGE_MOD: return new BLong( fire_damage().mod ); @@ -1018,7 +1031,7 @@ BObjectImp* Item::get_script_member_id( const int id ) const Module::UOExecutorModule* proc = process(); if ( proc ) { - Pol::Core::UOExecutor* executor = static_cast( &proc->exec ); + Core::UOExecutor* executor = static_cast( &proc->exec ); return new Core::ScriptExObjImp( executor ); } else @@ -1468,8 +1481,7 @@ BObjectImp* Item::script_method_id( const int id, Executor& ex ) else new_stack = this->remove_part_of_stack( amt ); - auto create_new_stack = [&]() -> BObjectImp* - { + auto create_new_stack = [&]() -> BObjectImp* { bool can_insert = newcontainer->can_insert_add_item( NULL, Core::UContainer::MT_CORE_MOVED, new_stack ); if ( !can_insert ) @@ -2053,7 +2065,6 @@ BObjectImp* Character::get_script_member_id( const int id ) const case MBR_LAST_TEXTCOLOR: return new BLong( last_textcolor() ); } - // if all else fails, returns nullptr return nullptr; } @@ -4283,7 +4294,7 @@ bool EClientRefObjImp::operator==( const BObjectImp& objimp ) const return false; } else if ( objimp.isa( Bscript::BObjectImp::OTBoolean ) ) - return isTrue() == static_cast(objimp).isTrue(); + return isTrue() == static_cast( objimp ).isTrue(); else return false; } diff --git a/pol-core/pol/uoscrobj.h b/pol-core/pol/uoscrobj.h index e9fa20f08..1070ce75b 100644 --- a/pol-core/pol/uoscrobj.h +++ b/pol-core/pol/uoscrobj.h @@ -11,24 +11,47 @@ #ifndef UOSCROBJ_H #define UOSCROBJ_H -#ifndef BSCRIPT_BOBJECT_H +#include + #include "../bscript/bobject.h" -#endif - #include "../bscript/bstruct.h" +#include "../clib/compilerspecifics.h" #include "../clib/passert.h" - +#include "../clib/rawtypes.h" +#include "../clib/refptr.h" +#include "../clib/weakptr.h" +#include "eventid.h" +#include "gameclck.h" +#include "globals/state.h" #include "mobile/charactr.h" +#include "multi/boat.h" #include "network/client.h" +#include "uobjcnt.h" #ifndef ITEM_H #include "item/item.h" #endif -#include "multi/boat.h" -#include "eventid.h" -#include "globals/state.h" +namespace Pol +{ +namespace Bscript +{ +class Executor; +} // namespace Bscript +namespace Core +{ +class UContainer; +} // namespace Core +namespace Mobile +{ +class NPC; +} // namespace Mobile +namespace Multi +{ +class UMulti; +} // namespace Multi +} // namespace Pol namespace Pol { diff --git a/pol-core/pol/uoskills.cpp b/pol-core/pol/uoskills.cpp index 0450a378e..6d08875e3 100644 --- a/pol-core/pol/uoskills.cpp +++ b/pol-core/pol/uoskills.cpp @@ -6,19 +6,13 @@ #include "uoskills.h" -#include "skillid.h" -#include "mobile/attribute.h" -#include "globals/uvars.h" -#include "globals/network.h" - -#include "../plib/pkg.h" +#include #include "../clib/cfgelem.h" -#include "../clib/stlutil.h" -#include "../clib/logfacility.h" - -#include -#include +#include "../plib/pkg.h" +#include "globals/uvars.h" +#include "mobile/attribute.h" +#include "skillid.h" namespace Pol { diff --git a/pol-core/pol/uoskills.h b/pol-core/pol/uoskills.h index 4d505517d..5763d0d37 100644 --- a/pol-core/pol/uoskills.h +++ b/pol-core/pol/uoskills.h @@ -8,6 +8,7 @@ #define UOSKILLS_H #include + namespace Pol { namespace Plib diff --git a/pol-core/pol/useskill.cpp b/pol-core/pol/useskill.cpp index 7b800ffc5..2159867f3 100644 --- a/pol-core/pol/useskill.cpp +++ b/pol-core/pol/useskill.cpp @@ -5,24 +5,23 @@ */ -#include "uoskills.h" -#include "skills.h" +#include +#include -#include "accounts/account.h" +#include "../bscript/eprog.h" +#include "../clib/refptr.h" +#include "../plib/systemstate.h" +#include "globals/network.h" #include "mobile/attribute.h" #include "mobile/charactr.h" #include "network/client.h" - #include "pktin.h" -#include "polcfg.h" -#include "scrstore.h" -#include "ufunc.h" #include "polclock.h" -#include "globals/uvars.h" -#include "globals/network.h" - -#include "../bscript/eprog.h" -#include "../plib/systemstate.h" +#include "scrdef.h" +#include "scrstore.h" +#include "skills.h" +#include "ufunc.h" +#include "uoskills.h" namespace Pol { diff --git a/pol-core/pol/uworld.cpp b/pol-core/pol/uworld.cpp index b1df51758..1ce15f92f 100644 --- a/pol-core/pol/uworld.cpp +++ b/pol-core/pol/uworld.cpp @@ -13,13 +13,16 @@ #include "uworld.h" -#include "realms.h" -#include "globals/uvars.h" +#include +#include #include "../clib/clib_endian.h" #include "../clib/logfacility.h" -#include "../clib/stlutil.h" -#include "../clib/strutil.h" +#include "../clib/passert.h" +#include "globals/uvars.h" +#include "item/item.h" +#include "mobile/charactr.h" +#include "multi/multi.h" namespace Pol { @@ -126,8 +129,7 @@ void SetCharacterWorldPosition( Mobile::Character* chr, Realms::WorldChangeReaso { Zone& zone = getzone( chr->x, chr->y, chr->realm ); - auto set_pos = [&]( ZoneCharacters& set ) - { + auto set_pos = [&]( ZoneCharacters& set ) { passert( std::find( set.begin(), set.end(), chr ) == set.end() ); set.push_back( chr ); }; @@ -148,8 +150,7 @@ void ClrCharacterWorldPosition( Mobile::Character* chr, Realms::WorldChangeReaso { Zone& zone = getzone( chr->x, chr->y, chr->realm ); - auto clear_pos = [&]( ZoneCharacters& set ) - { + auto clear_pos = [&]( ZoneCharacters& set ) { auto itr = std::find( set.begin(), set.end(), chr ); if ( itr == set.end() ) { @@ -183,8 +184,7 @@ void MoveCharacterWorldPosition( unsigned short oldx, unsigned short oldy, unsig if ( &oldzone != &newzone ) { - auto move_pos = [&]( ZoneCharacters& oldset, ZoneCharacters& newset ) - { + auto move_pos = [&]( ZoneCharacters& oldset, ZoneCharacters& newset ) { auto oldset_itr = std::find( oldset.begin(), oldset.end(), chr ); // ensure it's found in the old realm @@ -291,8 +291,8 @@ void find_missing_char_in_zone( Mobile::Character* chr, Realms::WorldChangeReaso found = std::find( _z.begin(), _z.end(), chr ) != _z.end(); } if ( found ) - POLLOG_ERROR.Format( "ClrCharacterWorldPosition: Found mob in zone ({},{})\n" ) << zonex - << zoney; + POLLOG_ERROR.Format( "ClrCharacterWorldPosition: Found mob in zone ({},{})\n" ) + << zonex << zoney; } } } @@ -364,8 +364,7 @@ void check_character_integrity() unsigned int gridwidth = realm->grid_width(); unsigned int gridheight = realm->grid_height(); - auto check_zone = []( Mobile::Character* chr, unsigned y, unsigned x ) - { + auto check_zone = []( Mobile::Character* chr, unsigned y, unsigned x ) { unsigned short wx, wy; zone_convert( chr->x, chr->y, &wx, &wy, chr->realm ); if ( wx != x || wy != y ) diff --git a/pol-core/pol/uworld.h b/pol-core/pol/uworld.h index 8d2373cfa..4006b934e 100644 --- a/pol-core/pol/uworld.h +++ b/pol-core/pol/uworld.h @@ -22,27 +22,19 @@ #ifndef __CHARACTR_H #include "mobile/charactr.h" #endif -#include "zone.h" +#include +#include #include "../clib/passert.h" +#include "../clib/rawtypes.h" +#include "../plib/realmdescriptor.h" +#include "realms/WorldChangeReasons.h" #include "realms/realm.h" - -#include +#include "uconst.h" +#include "zone.h" namespace Pol { -namespace Mobile -{ -class Character; -} -namespace Multi -{ -class UMulti; -} -namespace Items -{ -class Item; -} namespace Core { void add_item_to_world( Items::Item* item ); diff --git a/pol-core/pol/vital.cpp b/pol-core/pol/vital.cpp index 6f2f2f83e..c74e4c58b 100644 --- a/pol-core/pol/vital.cpp +++ b/pol-core/pol/vital.cpp @@ -7,20 +7,14 @@ #include "vital.h" -#include "checkpnt.h" -#include "syshook.h" -#include "globals/uvars.h" - -#include "../plib/pkg.h" +#include +#include #include "../clib/cfgelem.h" -#include "../clib/maputil.h" #include "../clib/passert.h" - -#include -#include -#include -#include +#include "../plib/pkg.h" +#include "checkpnt.h" +#include "globals/uvars.h" namespace Pol { @@ -143,4 +137,4 @@ void load_vitals_cfg() passert_always( gamestate.pVitalMana ); } } -} \ No newline at end of file +} diff --git a/pol-core/pol/vital.h b/pol-core/pol/vital.h index a966b0f3a..c652bc7c3 100644 --- a/pol-core/pol/vital.h +++ b/pol-core/pol/vital.h @@ -10,6 +10,7 @@ #include #include + namespace Pol { namespace Clib diff --git a/pol-core/pol/xmlfilescrobj.cpp b/pol-core/pol/xmlfilescrobj.cpp index 2c299c34a..746f7dbfb 100644 --- a/pol-core/pol/xmlfilescrobj.cpp +++ b/pol-core/pol/xmlfilescrobj.cpp @@ -6,31 +6,25 @@ #include "xmlfilescrobj.h" -#include "module/fileaccess.h" +#include -#include "../plib/pkg.h" - -#include "../bscript/executor.h" -#include "../bscript/execmodl.h" #include "../bscript/berror.h" +#include "../bscript/bobject.h" +#include "../bscript/bstruct.h" +#include "../bscript/executor.h" #include "../bscript/impstr.h" #include "../bscript/objmembers.h" #include "../bscript/objmethods.h" - -#include "../clib/strutil.h" #include "../clib/stlutil.h" -#include "../clib/clib_endian.h" - -#include +#include "../plib/pkg.h" +#include "module/fileaccess.h" namespace Pol { namespace Core { using namespace Bscript; -BXMLfile::BXMLfile() : Bscript::BObjectImp( OTXMLFile ), file(), _filename( "" ) -{ -} +BXMLfile::BXMLfile() : Bscript::BObjectImp( OTXMLFile ), file(), _filename( "" ) {} BXMLfile::BXMLfile( std::string filename ) : Bscript::BObjectImp( OTXMLFile ), file( filename.c_str() ), _filename( filename ) @@ -39,9 +33,7 @@ BXMLfile::BXMLfile( std::string filename ) return; } -BXMLfile::~BXMLfile() -{ -} +BXMLfile::~BXMLfile() {} BObjectRef BXMLfile::get_member_id( const int /*id*/ ) // id test { diff --git a/pol-core/pol/xmlfilescrobj.h b/pol-core/pol/xmlfilescrobj.h index d02db28a2..faf73b55f 100644 --- a/pol-core/pol/xmlfilescrobj.h +++ b/pol-core/pol/xmlfilescrobj.h @@ -11,8 +11,18 @@ #include "../bscript/bobject.h" #endif +#include +#include + #include "../bscript/contiter.h" -#include "../../lib/tinyxml/tinyxml.h" +#include "../clib/compilerspecifics.h" +#include "../clib/rawtypes.h" + +namespace Pol { +namespace Bscript { +class Executor; +} // namespace Bscript +} // namespace Pol namespace Pol { diff --git a/pol-core/pol/zone.cpp b/pol-core/pol/zone.cpp index 53e0aca96..d4875d21e 100644 --- a/pol-core/pol/zone.cpp +++ b/pol-core/pol/zone.cpp @@ -16,4 +16,4 @@ void XyToZone( xcoord x, ycoord y, unsigned* zonex, unsigned* zoney ) *zoney = y >> ZONE_SHIFT; } } -} \ No newline at end of file +} diff --git a/pol-core/poltool/CMakeLists.txt b/pol-core/poltool/CMakeLists.txt index 4278d4a80..4851953e2 100755 --- a/pol-core/poltool/CMakeLists.txt +++ b/pol-core/poltool/CMakeLists.txt @@ -1,69 +1,15 @@ -############################################################################### +set(ex_name poltool) -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../../cmake/CMakeEnvironment.txt) +add_executable(${ex_name} + # sorted ! + PolToolMain.cpp +) -MESSAGE("####################################") -MESSAGE("##### Building POLTOOL") -MESSAGE("####################################") +set_compile_flags(${ex_name} 1) -############################################################################### -# define source files -SET (SOURCES - PolToolMain.cpp -) - -############################################################## -# include dirs -SET (INCLUDE_DIRS - ../ - ./ +target_link_libraries(${ex_name} PUBLIC + clib + plib + z ) - -############################################################## -# set directory for internal libs -SET (LIB_DIRS - ${LIB_DIRS} - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# compile flags -IF(NOT WINDOWS) - IF(GCC) - SET (FLAGS - ${FLAGS} - -Wl,-R. - -Wl,-R./lib - -Wl,-R../lib - -Wl,-R../../lib - ) - ENDIF() -ENDIF() - -############################################################## -# link to the needed libs -SET (LIBS_LINUX - clib - plib - z -) -SET (LIBS_LINUX_STATIC_BIN_STATIC - clib_stic - plib_stic -) - -############################################################## -# define target directory -SET (TARGET_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# define binary name -SET (TARGET_PROGRAM_NAME - poltool -) - -############################################################## -# include CMake core -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CMakeCore.txt) +dist(${ex_name} .) diff --git a/pol-core/poltool/PolToolMain.cpp b/pol-core/poltool/PolToolMain.cpp index b83fb9317..ea6217e43 100644 --- a/pol-core/poltool/PolToolMain.cpp +++ b/pol-core/poltool/PolToolMain.cpp @@ -1,20 +1,21 @@ #include "PolToolMain.h" + +#include +#include + +#include +#include "../clib/Program/ProgramMain.h" #include "../clib/clib_endian.h" -#include "../clib/strutil.h" -#include "../clib/logfacility.h" #include "../clib/fileutil.h" +#include "../clib/logfacility.h" +#include "../clib/rawtypes.h" #include "../plib/mapcell.h" #include "../plib/mapfunc.h" #include "../plib/mapserver.h" -#include "../plib/filemapserver.h" #include "../plib/mapshape.h" -#include "../plib/realmdescriptor.h" #include "../plib/maptile.h" #include "../plib/maptileserver.h" - -#include -#include -#include +#include "../plib/realmdescriptor.h" #ifdef USE_SYSTEM_ZLIB #include #else @@ -29,12 +30,8 @@ using namespace std; /////////////////////////////////////////////////////////////////////////////// -PolToolMain::PolToolMain() : ProgramMain() -{ -} -PolToolMain::~PolToolMain() -{ -} +PolToolMain::PolToolMain() : ProgramMain() {} +PolToolMain::~PolToolMain() {} /////////////////////////////////////////////////////////////////////////////// void PolToolMain::showHelp() @@ -164,14 +161,10 @@ int PolToolMain::unpackCompressedGump() } size_t index = 0; - auto toInt = [&]( size_t i ) -> unsigned int - { + auto toInt = [&]( size_t i ) -> unsigned int { return ( bytes[i] << 24 ) | ( bytes[i + 1] << 16 ) | ( bytes[i + 2] << 8 ) | ( bytes[i + 3] ); }; - auto toShort = [&]( size_t i ) -> unsigned short - { - return ( bytes[i] << 8 ) | ( bytes[i + 1] ); - }; + auto toShort = [&]( size_t i ) -> unsigned short { return ( bytes[i] << 8 ) | ( bytes[i + 1] ); }; if ( bytes[index] != 0xdd ) return 1; ++index; @@ -195,7 +188,7 @@ int PolToolMain::unpackCompressedGump() index += 4; auto datalen = static_cast( toInt( index ) ); index += 4; - std::unique_ptr uncompressed(new unsigned char[datalen]); + std::unique_ptr uncompressed( new unsigned char[datalen] ); int res = uncompress( uncompressed.get(), &datalen, &bytes.data()[index], cbuflen ); if ( res < 0 ) return 1; @@ -217,7 +210,7 @@ int PolToolMain::unpackCompressedGump() index += 4; datalen = static_cast( toInt( index ) ); index += 4; - std::unique_ptr uncompressed2(new unsigned char[datalen]); + std::unique_ptr uncompressed2( new unsigned char[datalen] ); res = uncompress( uncompressed2.get(), &datalen, &bytes.data()[index], cbuflen ); if ( res < 0 ) return 1; diff --git a/pol-core/poltool/PolToolMain.h b/pol-core/poltool/PolToolMain.h index ee5db50db..b8c529396 100644 --- a/pol-core/poltool/PolToolMain.h +++ b/pol-core/poltool/PolToolMain.h @@ -1,7 +1,7 @@ #ifndef POL_TOOL_MAIN_H #define POL_TOOL_MAIN_H -#include +#include "../clib/Program/ProgramMain.h" namespace Pol { diff --git a/pol-core/poltool/poltool-2012.vcxproj b/pol-core/poltool/poltool-2012.vcxproj deleted file mode 100644 index ffeafd9fa..000000000 --- a/pol-core/poltool/poltool-2012.vcxproj +++ /dev/null @@ -1,286 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - poltool - {CD7D0525-5425-480A-8C18-6B04C599B7E9} - poltool - - - - Application - false - MultiByte - v110 - - - Application - false - MultiByte - v110 - - - Application - false - MultiByte - v110_xp - - - Application - false - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\Release\ - .\Release\x64/ - .\Release\ - .\Release\x64/ - false - false - .\Debug\ - .\Debug\x64/ - .\Debug\ - .\Debug\x64/ - true - true - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - .\Release/poltool.tlb - - - ..;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - .\Release/poltool.pch - .\Release/ - .\Release/ - .\Release/ - Level4 - true - ProgramDatabase - Default - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /MACHINE:I386 %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Release/poltool.exe - true - ..\..\lib\boost_1_55_0\lib\x86\lib;%(AdditionalLibraryDirectories) - true - .\Release/poltool.pdb - true - Console - false - - - 5.0 - - - - - .\Release/x64/poltool.tlb - - - ..;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - .\Release/x64/poltool.pch - .\Release/x64/ - .\Release/x64/ - .\Release/x64/ - Level4 - true - ProgramDatabase - Default - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Release/x64/poltool.exe - true - ..\..\lib\boost_1_55_0\lib\x64\lib;%(AdditionalLibraryDirectories) - true - .\Release/x64/poltool.pdb - true - Console - false - - - 5.02 - true - - - - - .\Debug/poltool.tlb - - - Disabled - ..;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - .\Debug/poltool.pch - .\Debug/ - .\Debug/ - .\Debug/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /MACHINE:I386 %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Debug/poltool.exe - true - ..\..\lib\boost_1_55_0\lib\x86\lib;%(AdditionalLibraryDirectories) - true - .\Debug/poltool.pdb - Console - false - - - - - - - .\Debug/x64/poltool.tlb - - - Disabled - ..;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;INC_PASSERT;TIXML_USE_STL;_WIN64;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - .\Debug/x64/poltool.pch - .\Debug/x64/ - .\Debug/x64/ - .\Debug/x64/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Debug/x64/poltool.exe - true - ..\..\lib\boost_1_55_0\lib\x64\lib;%(AdditionalLibraryDirectories) - true - .\Debug/x64/poltool.pdb - Console - false - - - - - - - - - - {7cd5572b-8a78-46c5-ac2d-39ee47acd01a} - false - - - {d45c6577-00e3-4995-a909-9c704a472565} - false - - - - - Document - true - true - true - true - true - true - - - - - - - \ No newline at end of file diff --git a/pol-core/runecl/CMakeLists.txt b/pol-core/runecl/CMakeLists.txt index 4a4728f1e..56bc36c4b 100755 --- a/pol-core/runecl/CMakeLists.txt +++ b/pol-core/runecl/CMakeLists.txt @@ -1,85 +1,31 @@ -############################################################################### +set(ex_name runecl) -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../../cmake/CMakeEnvironment.txt) - -MESSAGE("####################################") -MESSAGE("##### Building RUNECL") -MESSAGE("####################################") - -############################################################################### -# define source files -SET (SOURCES # sorted ! - ../pol/binaryfilescrobj.cpp - ../pol/cfgrepos.cpp - ../pol/dice.cpp - ../pol/globals/ucfg.cpp - ../pol/module/basiciomod.cpp - ../pol/module/basicmod.cpp - ../pol/module/cfgmod.cpp - ../pol/module/datastore.cpp - ../pol/module/filemod.cpp - ../pol/module/mathmod.cpp - ../pol/module/utilmod.cpp - ../pol/proplist.cpp - ../pol/xmlfilescrobj.cpp - RunEclMain.cpp +add_executable(${ex_name} + # sorted ! + ../pol/binaryfilescrobj.cpp + ../pol/cfgrepos.cpp + ../pol/dice.cpp + ../pol/globals/ucfg.cpp + ../pol/module/basiciomod.cpp + ../pol/module/basicmod.cpp + ../pol/module/cfgmod.cpp + ../pol/module/datastore.cpp + ../pol/module/filemod.cpp + ../pol/module/mathmod.cpp + ../pol/module/utilmod.cpp + ../pol/proplist.cpp + ../pol/xmlfilescrobj.cpp + RunEclMain.cpp ) + +set_compile_flags(${ex_name} 1) -############################################################## -# include dirs -SET (INCLUDE_DIRS - . - ../ +target_link_libraries(${ex_name} PUBLIC + bscript + clib + plib + tinyxml + pthread ) -############################################################## -# compile flags -IF(NOT WINDOWS) - IF(GCC) - SET (FLAGS - ${FLAGS} - -Wl,-R. - -Wl,-R./lib - -Wl,-R../lib - -Wl,-R../../lib - ) - ENDIF() -ENDIF() - -############################################################## -# set directory for internal libs -SET (LIB_DIRS - ${LIB_DIRS} - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# link to the needed libs -SET (LIBS_LINUX - bscript - clib - plib - tinyxml -) -SET (LIBS_LINUX_STATIC_BIN_STATIC - bscript_static - clib_static - plib_static - tinyxml_static -) - -############################################################## -# define target directory -SET (TARGET_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# define binary name -SET (TARGET_PROGRAM_NAME - runecl -) - -############################################################## -# include CMake core -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CMakeCore.txt) +dist(${ex_name} scripts) diff --git a/pol-core/runecl/RunEclMain.cpp b/pol-core/runecl/RunEclMain.cpp index 21c6b119d..586268124 100644 --- a/pol-core/runecl/RunEclMain.cpp +++ b/pol-core/runecl/RunEclMain.cpp @@ -5,30 +5,23 @@ #include "pol_global_config.h" #endif -#include "RunEclMain.h" - -#include "../clib/cfgelem.h" -#include "../clib/clib.h" -#include "../clib/fileutil.h" -#include "../clib/logfacility.h" -#include "../clib/stlutil.h" -#include "../clib/strutil.h" -#include "../clib/timer.h" - +#include +#include +#include +#include "../bscript/bobject.h" #include "../bscript/config.h" -#include "../bscript/eprog.h" -#include "../bscript/escriptv.h" #include "../bscript/execmodl.h" #include "../bscript/executor.h" #include "../bscript/filefmt.h" -#include "../bscript/object.h" -#include "../bscript/symcont.h" -#include "../bscript/token.h" -#include "../bscript/tokens.h" - +#include "../clib/Program/ProgramMain.h" +#include "../clib/boostutils.h" +#include "../clib/fileutil.h" +#include "../clib/logfacility.h" +#include "../clib/refptr.h" #include "../plib/pkg.h" #include "../plib/systemstate.h" +#include "RunEclMain.h" #include "../pol/module/basiciomod.h" #include "../pol/module/basicmod.h" @@ -41,13 +34,6 @@ #include "../pol/polcfg.h" #include "../pol/sqlscrobj.h" -#include -#include -#include - -#include -#include - namespace Pol { namespace Core diff --git a/pol-core/runecl/runecl-2012.vcxproj b/pol-core/runecl/runecl-2012.vcxproj deleted file mode 100644 index 15186c5f3..000000000 --- a/pol-core/runecl/runecl-2012.vcxproj +++ /dev/null @@ -1,328 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - runecl - {F8E03C1C-E402-4C84-826B-3BEC82066686} - runecl - - - - Application - false - MultiByte - v110_xp - - - Application - false - MultiByte - v110 - - - Application - false - MultiByte - v110 - - - Application - false - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\Debug\ - .\Debug\x64/ - .\Debug\ - .\Debug\x64/ - true - true - .\Release\ - .\Release\x64/ - .\Release\ - .\Release\x64/ - false - false - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - .\Debug/runecl.tlb - - - Disabled - ..\..\lib\mysql-connector-c-6.0.2-win32\include;%(AdditionalIncludeDirectories) - _DEBUG;_CONSOLE;NOMINMAX;NOACCESS_CHECKS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - - - .\Debug/runecl.pch - .\Debug/ - .\Debug/ - .\Debug/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /MACHINE:I386 %(AdditionalOptions) - odbc32.lib;odbccp32.lib;libmysql.lib;%(AdditionalDependencies) - .\Debug/runecl.exe - true - ..\..\lib\boost_1_55_0\lib\x86\lib;..\..\lib\mysql-connector-c-6.0.2-win32\lib;%(AdditionalLibraryDirectories) - true - .\Debug/runecl.pdb - Console - false - - - - - - - .\Debug/x64/runecl.tlb - - - Disabled - ..\..\lib\mysql-connector-c-6.0.2-winx64\include;%(AdditionalIncludeDirectories) - _DEBUG;_CONSOLE;NOMINMAX;_WIN64;NOACCESS_CHECKS;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - - - .\Debug/x64/runecl.pch - .\Debug/x64/ - .\Debug/x64/ - .\Debug/x64/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - %(AdditionalOptions) - odbc32.lib;odbccp32.lib;libmysql.lib;%(AdditionalDependencies) - .\Debug/x64/runecl.exe - true - ..\..\lib\boost_1_55_0\lib\x64\lib;..\..\lib\mysql-connector-c-6.0.2-winx64\lib;%(AdditionalLibraryDirectories) - true - .\Debug/x64/runecl.pdb - Console - false - - - - - - - .\Release/runecl.tlb - - - ..\..\lib\mysql-connector-c-6.0.2-win32\include;%(AdditionalIncludeDirectories) - NDEBUG;_CONSOLE;NOMINMAX;NOACCESS_CHECKS;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - - - .\Release/runecl.pch - .\Release/ - .\Release/ - .\Release/ - Level4 - true - ProgramDatabase - Default - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /MACHINE:I386 %(AdditionalOptions) - odbc32.lib;odbccp32.lib;libmysql.lib;%(AdditionalDependencies) - .\Release/runecl.exe - true - ..\..\lib\boost_1_55_0\lib\x86\lib;..\..\lib\mysql-connector-c-6.0.2-win32\lib;%(AdditionalLibraryDirectories) - true - .\Release/runecl.pdb - true - Console - false - - - 5.0 - - - - - .\Release/x64/runecl.tlb - - - ..\..\lib\mysql-connector-c-6.0.2-winx64\include;%(AdditionalIncludeDirectories) - NDEBUG;_CONSOLE;NOMINMAX;_WIN64;NOACCESS_CHECKS;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - - - .\Release/x64/runecl.pch - .\Release/x64/ - .\Release/x64/ - .\Release/x64/ - Level4 - true - ProgramDatabase - Default - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - %(AdditionalOptions) - odbc32.lib;odbccp32.lib;libmysql.lib;%(AdditionalDependencies) - .\Release/x64/runecl.exe - true - ..\..\lib\boost_1_55_0\lib\x64\lib;..\..\lib\mysql-connector-c-6.0.2-winx64\lib;%(AdditionalLibraryDirectories) - true - .\Release/x64/runecl.pdb - true - Console - false - - - 5.02 - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {5005476b-7bd3-42a2-94ca-3ad2d0e2947c} - false - - - {7cd5572b-8a78-46c5-ac2d-39ee47acd01a} - false - - - - - Document - true - true - true - true - true - true - - - - - - - \ No newline at end of file diff --git a/pol-core/support/CMakeLists.txt b/pol-core/support/CMakeLists.txt new file mode 100644 index 000000000..8146ec548 --- /dev/null +++ b/pol-core/support/CMakeLists.txt @@ -0,0 +1,21 @@ +set(lib_name support) + +install(FILES + uoconvert.cfg + pol.cfg + DESTINATION . +) +install(FILES + extobj.cfg + boats.cfg + animxlate.cfg + DESTINATION config +) +install(FILES + scripts/ecompile.cfg.example + DESTINATION scripts +) +install(DIRECTORY scripts/ + DESTINATION scripts + FILES_MATCHING PATTERN "*.em" +) diff --git a/pol-core/support/support-2012.vcxproj b/pol-core/support/support-2012.vcxproj deleted file mode 100644 index 290e46089..000000000 --- a/pol-core/support/support-2012.vcxproj +++ /dev/null @@ -1,108 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - support - {D4F7092B-08EA-4CEF-94E8-3D1133CCA5B7} - support - MakeFileProj - - - - Utility - false - v110_xp - - - Utility - false - v110 - - - Utility - false - v110 - - - Utility - false - v110 - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\Debug\ - .\Debug\ - .\Debug\ - .\Debug\ - .\Release\ - .\Release\ - .\Release\ - .\Release\ - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pol-core/support/support-2012.vcxproj.filters b/pol-core/support/support-2012.vcxproj.filters deleted file mode 100644 index b9a8073c5..000000000 --- a/pol-core/support/support-2012.vcxproj.filters +++ /dev/null @@ -1,78 +0,0 @@ - - - - - {23e9a4f5-2c18-4a12-bd5e-1089829a8682} - - - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - scripts - - - - - \ No newline at end of file diff --git a/pol-core/uoconvert/CMakeLists.txt b/pol-core/uoconvert/CMakeLists.txt index c6d47f748..d25927c11 100755 --- a/pol-core/uoconvert/CMakeLists.txt +++ b/pol-core/uoconvert/CMakeLists.txt @@ -1,70 +1,17 @@ -############################################################################### +set(ex_name uoconvert) -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../../cmake/CMakeEnvironment.txt) - -MESSAGE("####################################") -MESSAGE("##### Building UOCONVERT") -MESSAGE("####################################") - -############################################################################### -# define source files -SET (SOURCES # sorted ! - ../pol/polfile1.cpp - UoConvertMain.cpp +add_executable(${ex_name} + # sorted ! + ../pol/polfile1.cpp + UoConvertMain.cpp ) + +set_compile_flags(${ex_name} 1) -############################################################## -# include dirs -SET (INCLUDE_DIRS - . - ../ +target_link_libraries(${ex_name} PUBLIC + clib + plib + pthread ) -############################################################## -# compile flags -IF(NOT WINDOWS) - IF(GCC) - SET (FLAGS - ${FLAGS} - -Wl,-R. - -Wl,-R./lib - -Wl,-R../lib - -Wl,-R../../lib - ) - ENDIF() -ENDIF() - -############################################################## -# set directory for internal libs -SET (LIB_DIRS - ${LIB_DIRS} - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# link to the needed libs -SET (LIBS_LINUX - clib - plib - pthread -) -SET (LIBS_LINUX_STATIC_BIN_STATIC - clib_static - plib_static -) - -############################################################## -# define target directory -SET (TARGET_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# define binary name -SET (TARGET_PROGRAM_NAME - uoconvert -) - -############################################################## -# include CMake core -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CMakeCore.txt) +dist(${ex_name} .) diff --git a/pol-core/uoconvert/UoConvertMain.cpp b/pol-core/uoconvert/UoConvertMain.cpp index 2e89ce3bf..7c96e171a 100644 --- a/pol-core/uoconvert/UoConvertMain.cpp +++ b/pol-core/uoconvert/UoConvertMain.cpp @@ -1,36 +1,33 @@ #include "UoConvertMain.h" -#include "../pol/objtype.h" -#include "../pol/polcfg.h" +#include +#include +#include -#include "../pol/uofile.h" -#include "../pol/uofilei.h" -#include "../pol/udatfile.h" -#include "../pol/polfile.h" - -#include "../plib/mapcell.h" -#include "../plib/mapblock.h" -#include "../plib/mapsolid.h" -#include "../plib/mapfunc.h" -#include "../plib/mapserver.h" -#include "../plib/mapshape.h" -#include "../plib/mapwriter.h" -#include "../plib/realmdescriptor.h" -#include "../plib/systemstate.h" - -#include "../clib/stlutil.h" +#include "../clib/Program/ProgramMain.h" #include "../clib/cfgelem.h" #include "../clib/cfgfile.h" #include "../clib/fileutil.h" #include "../clib/logfacility.h" #include "../clib/passert.h" +#include "../clib/rawtypes.h" +#include "../clib/stlutil.h" #include "../clib/timer.h" - -#include -#include -#include -#include -#include +#include "../plib/mapcell.h" +#include "../plib/mapfunc.h" +#include "../plib/mapshape.h" +#include "../plib/mapsolid.h" +#include "../plib/maptile.h" +#include "../plib/mapwriter.h" +#include "../plib/realmdescriptor.h" +#include "../plib/systemstate.h" +#include "../pol/clidata.h" +#include "../pol/objtype.h" +#include "../pol/polfile.h" +#include "../pol/udatfile.h" +#include "../pol/uofile.h" +#include "../pol/uofilei.h" +#include "../pol/ustruct.h" namespace Pol { @@ -45,12 +42,8 @@ using namespace Pol::Plib; /////////////////////////////////////////////////////////////////////////////// -UoConvertMain::UoConvertMain() : Pol::Clib::ProgramMain() -{ -} -UoConvertMain::~UoConvertMain() -{ -} +UoConvertMain::UoConvertMain() : Pol::Clib::ProgramMain() {} +UoConvertMain::~UoConvertMain() {} /////////////////////////////////////////////////////////////////////////////// void UoConvertMain::showHelp() @@ -119,8 +112,8 @@ void display_flags() unsigned int polflags = Plib::polflags_from_tileflags( 0x4000, flags, cfg_use_no_shoot, cfg_LOS_through_windows ); unsigned moveland = ( polflags & Plib::FLAG::MOVELAND ) ? 1 : 0; - INFO_PRINT.Format( "{} {} {} {} {} {}: {}\n" ) << blocking << platform << walk << wall - << half << floor << moveland; + INFO_PRINT.Format( "{} {} {} {} {} {}: {}\n" ) + << blocking << platform << walk << wall << half << floor << moveland; } } } @@ -171,8 +164,8 @@ void create_maptile( const std::string& realmname ) safe_getmapinfo( x, y, &z, &mi ); if ( mi.landtile > 0x3FFF ) - INFO_PRINT.Format( "Tile 0x{:X} at ({},{},{}) is an invalid ID!\n" ) << mi.landtile << x - << y << z; + INFO_PRINT.Format( "Tile 0x{:X} at ({},{},{}) is an invalid ID!\n" ) + << mi.landtile << x << y << z; // for water, don't average with surrounding tiles. if ( landtile_uoflags( mi.landtile ) & Core::USTRUCT_TILE::FLAG_LIQUID ) @@ -475,8 +468,8 @@ void ProcessSolidBlock( unsigned short x_base, unsigned short y_base, MapWriter& safe_getmapinfo( x, y, &z, &mi ); if ( mi.landtile > 0x3FFF ) - INFO_PRINT.Format( "Tile 0x{:X} at ({},{},{}) is an invalid ID!\n" ) << mi.landtile << x - << y << z; + INFO_PRINT.Format( "Tile 0x{:X} at ({},{},{}) is an invalid ID!\n" ) + << mi.landtile << x << y << z; // for water, don't average with surrounding tiles. if ( landtile_uoflags( mi.landtile ) & USTRUCT_TILE::FLAG_LIQUID ) @@ -487,8 +480,8 @@ void ProcessSolidBlock( unsigned short x_base, unsigned short y_base, MapWriter& z = low_z; if ( mi.landtile > 0x3FFF ) - INFO_PRINT.Format( "Tile 0x{:X} at ({},{},{}) is an invalid ID!\n" ) << mi.landtile << x - << y << z; + INFO_PRINT.Format( "Tile 0x{:X} at ({},{},{}) is an invalid ID!\n" ) + << mi.landtile << x << y << z; unsigned int lt_flags = landtile_uoflags( mi.landtile ); if ( ~lt_flags & USTRUCT_TILE::FLAG_BLOCKING ) @@ -505,11 +498,12 @@ void ProcessSolidBlock( unsigned short x_base, unsigned short y_base, MapWriter& if ( lt_flags & USTRUCT_TILE::FLAG_WALL ) lt_height = 20; - readstatics( statics, x, y, USTRUCT_TILE::FLAG_BLOCKING | USTRUCT_TILE::FLAG_PLATFORM | - USTRUCT_TILE::FLAG_HALF_HEIGHT | USTRUCT_TILE::FLAG_LIQUID | - USTRUCT_TILE::FLAG_HOVEROVER + readstatics( statics, x, y, + USTRUCT_TILE::FLAG_BLOCKING | USTRUCT_TILE::FLAG_PLATFORM | + USTRUCT_TILE::FLAG_HALF_HEIGHT | USTRUCT_TILE::FLAG_LIQUID | + USTRUCT_TILE::FLAG_HOVEROVER // USTRUCT_TILE::FLAG__WALK - ); + ); for ( unsigned i = 0; i < statics.size(); ++i ) { diff --git a/pol-core/uoconvert/UoConvertMain.h b/pol-core/uoconvert/UoConvertMain.h index 93b0ef16f..3afde9d23 100644 --- a/pol-core/uoconvert/UoConvertMain.h +++ b/pol-core/uoconvert/UoConvertMain.h @@ -1,10 +1,10 @@ #ifndef UO_CONVERT_MAIN_H #define UO_CONVERT_MAIN_H -#include "../clib/Program/ProgramMain.h" - #include +#include "../clib/Program/ProgramMain.h" + namespace Pol { namespace UoConvert diff --git a/pol-core/uoconvert/uoconvert-2012.vcxproj b/pol-core/uoconvert/uoconvert-2012.vcxproj deleted file mode 100644 index 08875a333..000000000 --- a/pol-core/uoconvert/uoconvert-2012.vcxproj +++ /dev/null @@ -1,298 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - uoconvert - {CC6172A8-D7A4-4CC1-95FC-87A173E556F1} - uoconvert - - - - Application - false - MultiByte - v110 - - - Application - false - MultiByte - v110 - - - Application - false - MultiByte - v110_xp - - - Application - false - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\Release\ - .\Release\x64/ - .\Release\ - .\Release\x64/ - false - false - .\Debug\ - .\Debug\x64/ - .\Debug\ - .\Debug\x64/ - true - true - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - .\Release/uoconvert.tlb - - - %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NOMINMAX;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - - - .\Release/uoconvert.pch - .\Release/ - .\Release/ - .\Release/ - Level4 - true - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /MACHINE:I386 %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Release/uoconvert.exe - true - ..\..\lib\boost_1_55_0\lib\x86\lib;%(AdditionalLibraryDirectories) - true - .\Release/uoconvert.pdb - true - .\Release/uoconvert.map - Console - false - - - 5.0 - - - - - .\Release/x64/uoconvert.tlb - - - %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NOMINMAX;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - - - .\Release/x64/uoconvert.pch - .\Release/x64/ - .\Release/x64/ - .\Release/x64/ - Level4 - true - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Release/x64/uoconvert.exe - true - ..\..\lib\boost_1_55_0\lib\x64\lib;%(AdditionalLibraryDirectories) - true - .\Release/x64/uoconvert.pdb - true - .\Release/x64/uoconvert.map - Console - false - - - 5.02 - true - - - - - .\Debug/uoconvert.tlb - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NOMINMAX;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - .\Debug/uoconvert.pch - .\Debug/ - .\Debug/ - .\Debug/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /MACHINE:I386 %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Debug/uoconvert.exe - true - ..\..\lib\boost_1_55_0\lib\x86\lib;%(AdditionalLibraryDirectories) - true - .\Debug/uoconvert.pdb - Console - false - - - - - - - .\Debug/x64/uoconvert.tlb - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NOMINMAX;INC_PASSERT;TIXML_USE_STL;_WIN64;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - - - .\Debug/x64/uoconvert.pch - .\Debug/x64/ - .\Debug/x64/ - .\Debug/x64/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Debug/x64/uoconvert.exe - true - ..\..\lib\boost_1_55_0\lib\x64\lib;%(AdditionalLibraryDirectories) - true - .\Debug/x64/uoconvert.pdb - Console - false - - - - - - - Document - true - true - true - true - true - true - - - - - - - - - - - - - - - - {7cd5572b-8a78-46c5-ac2d-39ee47acd01a} - false - - - {d45c6577-00e3-4995-a909-9c704a472565} - false - - - - - - - \ No newline at end of file diff --git a/pol-core/uoconvert/uoconvert-2012.vcxproj.filters b/pol-core/uoconvert/uoconvert-2012.vcxproj.filters deleted file mode 100644 index ca75e5819..000000000 --- a/pol-core/uoconvert/uoconvert-2012.vcxproj.filters +++ /dev/null @@ -1,29 +0,0 @@ - - - - - {27f456ad-1e20-4c17-9e9a-d07df2ff343d} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - Resource Files - - - - - Resource Files - - - - - - - - - - - - - \ No newline at end of file diff --git a/pol-core/uotool/CMakeLists.txt b/pol-core/uotool/CMakeLists.txt index 60d07f209..98de111e4 100755 --- a/pol-core/uotool/CMakeLists.txt +++ b/pol-core/uotool/CMakeLists.txt @@ -1,72 +1,19 @@ -############################################################################### +set(ex_name uotool) -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/../../cmake/CMakeEnvironment.txt) - -MESSAGE("####################################") -MESSAGE("##### Building UOTOOL") -MESSAGE("####################################") - -############################################################################### -# define source files -SET (SOURCES # sorted ! - ../pol/globals/multidefs.cpp #TODO: ugly hack - ../pol/multi/multidef.cpp #TODO: ugly hack - what? same file name? - ../pol/polfile1.cpp #TODO: w00t - UoToolMain.cpp #note to me: never ever again suggest to introduce CMake in a C style C++ project which is full of linking magic +add_executable(${ex_name} + # sorted ! + ../pol/globals/multidefs.cpp + ../pol/multi/multidef.cpp + ../pol/polfile1.cpp + UoToolMain.cpp ) -############################################################## -# include dirs -SET (INCLUDE_DIRS - . - ../ +set_compile_flags(${ex_name} 1) + +target_link_libraries(${ex_name} PUBLIC + clib + plib + pthread ) -############################################################## -# compile flags -IF(NOT WINDOWS) - IF(GCC) - SET (FLAGS - ${FLAGS} - -Wl,-R. - -Wl,-R./lib - -Wl,-R../lib - -Wl,-R../../lib - ) - ENDIF() -ENDIF() - -############################################################## -# set directory for internal libs -SET (LIB_DIRS - ${LIB_DIRS} - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# link to the needed libs -SET (LIBS_LINUX - clib - plib - pthread -) -SET (LIBS_LINUX_STATIC_BIN_STATIC - clib_static - plib_static -) - -############################################################## -# define target directory -SET (TARGET_DIRECTORY - ${CMAKE_CURRENT_LIST_DIR}/../bin -) - -############################################################## -# define binary name -SET (TARGET_PROGRAM_NAME - uotool -) - -############################################################## -# include CMake core -INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CMakeCore.txt) +dist(${ex_name} .) diff --git a/pol-core/uotool/StdAfx.h b/pol-core/uotool/StdAfx.h index 368eba237..0b3d8bf15 100644 --- a/pol-core/uotool/StdAfx.h +++ b/pol-core/uotool/StdAfx.h @@ -20,9 +20,6 @@ #if !defined( _UOTOOL_STDAFX_H ) #define _UOTOOL_STDAFX_H -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#include - // include default pch #include "../clib/StdAfx.h" diff --git a/pol-core/uotool/UoToolMain.cpp b/pol-core/uotool/UoToolMain.cpp index e9b9955a4..925f7c5ef 100644 --- a/pol-core/uotool/UoToolMain.cpp +++ b/pol-core/uotool/UoToolMain.cpp @@ -1,28 +1,36 @@ #include "UoToolMain.h" -#include "uofile2.h" //TODO: remove this file ASAP !!! -#include "../pol/uofile.h" -#include "../pol/polcfg.h" -#include "../pol/polfile.h" -#include "../pol/uofilei.h" -#include "../pol/multi/multidef.h" -#include "../pol/globals/multidefs.h" -#include "../pol/objtype.h" -#include "../pol/poltype.h" +#include +#include +#include +#include +#include +#include +#include +#include "../clib/Program/ProgramMain.h" +#include "../clib/cfgelem.h" +#include "../clib/cfgfile.h" +#include "../clib/fdump.h" +#include "../clib/fileutil.h" +#include "../clib/logfacility.h" +#include "../clib/rawtypes.h" +#include "../clib/stlutil.h" +#include "../clib/strutil.h" #include "../plib/realmdescriptor.h" #include "../plib/staticblock.h" #include "../plib/systemstate.h" - -#include "../clib/strutil.h" -#include "../clib/stlutil.h" - -#include "../clib/cfgelem.h" -#include "../clib/cfgfile.h" -#include "../clib/fileutil.h" -#include "../clib/logfacility.h" -#include "../clib/fdump.h" -#include "../clib/passert.h" +#include "../pol/clidata.h" +#include "../pol/globals/multidefs.h" +#include "../pol/multi/multidef.h" +#include "../pol/objtype.h" +#include "../pol/polfile.h" +#include "../pol/uconst.h" +#include "../pol/udatfile.h" +#include "../pol/uofile.h" +#include "../pol/uofilei.h" +#include "../pol/ustruct.h" +#include "uofile2.h" //TODO: remove this file ASAP !!! namespace Pol { @@ -89,8 +97,8 @@ static int print_ctable() valout |= 1; inmask <<= 1; } - _tmp.Format( " {{ {:>2}, 0x{:04X}, 0x{:04X}}},\n" ) << ( keyid[i] & 0x0F ) - << ( keyid[i] >> 4 ) << valout; + _tmp.Format( " {{ {:>2}, 0x{:04X}, 0x{:04X}}},\n" ) + << ( keyid[i] & 0x0F ) << ( keyid[i] >> 4 ) << valout; } _tmp << "};\n"; INFO_PRINT << _tmp.str(); @@ -313,8 +321,8 @@ static int loschange( int /*argc*/, char** /*argv*/ ) if ( old_lostest != new_lostest ) { display_tileinfo( objtype, tile ); - INFO_PRINT.Format( " Old LOS: %s\n New LOS: %s\n" ) << ( old_lostest ? "true" : "false" ) - << ( new_lostest ? "true" : "false" ); + INFO_PRINT.Format( " Old LOS: %s\n New LOS: %s\n" ) + << ( old_lostest ? "true" : "false" ) << ( new_lostest ? "true" : "false" ); } } Core::clear_tiledata(); @@ -397,8 +405,9 @@ static int print_statics() } } } - INFO_PRINT << cnt << " statics exist.\n" << water << " water tiles exist.\n" << strange_water - << " strange water tiles exist.\n"; + INFO_PRINT << cnt << " statics exist.\n" + << water << " water tiles exist.\n" + << strange_water << " strange water tiles exist.\n"; Core::clear_tiledata(); return 0; } @@ -1146,12 +1155,8 @@ static int checkmultis() /////////////////////////////////////////////////////////////////////////////// -UoToolMain::UoToolMain() : Pol::Clib::ProgramMain() -{ -} -UoToolMain::~UoToolMain() -{ -} +UoToolMain::UoToolMain() : Pol::Clib::ProgramMain() {} +UoToolMain::~UoToolMain() {} /////////////////////////////////////////////////////////////////////////////// void UoToolMain::showHelp() diff --git a/pol-core/uotool/UoToolMain.h b/pol-core/uotool/UoToolMain.h index 5b2576eaf..f7c479c2b 100644 --- a/pol-core/uotool/UoToolMain.h +++ b/pol-core/uotool/UoToolMain.h @@ -1,10 +1,10 @@ #ifndef UO_TOOL_MAIN_H #define UO_TOOL_MAIN_H -#include "../clib/Program/ProgramMain.h" - #include +#include "../clib/Program/ProgramMain.h" + namespace Pol { namespace UoTool diff --git a/pol-core/uotool/uofile04.cpp b/pol-core/uotool/uofile04.cpp index 6bda0d305..24b4f6011 100644 --- a/pol-core/uotool/uofile04.cpp +++ b/pol-core/uotool/uofile04.cpp @@ -3,17 +3,13 @@ * @par History */ - -#include "../pol/uofile.h" -#include "../pol/uofilei.h" - -//#include "../pol/polcfg.h" -#include "../pol/udatfile.h" -#include "../pol/ustruct.h" +#include +#include #include "../clib/logfacility.h" - -#include +#include "../clib/rawtypes.h" +#include "../pol/uofilei.h" +#include "../pol/ustruct.h" namespace Pol { diff --git a/pol-core/uotool/uofile05.cpp b/pol-core/uotool/uofile05.cpp index 335030fbd..940a6828e 100644 --- a/pol-core/uotool/uofile05.cpp +++ b/pol-core/uotool/uofile05.cpp @@ -4,14 +4,11 @@ */ -#include "../pol/uofile.h" -#include "../pol/uofilei.h" - -#include "../pol/polcfg.h" -#include "../pol/udatfile.h" -#include "../pol/ustruct.h" +#include #include "../clib/logfacility.h" +#include "../pol/uofilei.h" +#include "../pol/ustruct.h" namespace Pol { @@ -41,4 +38,4 @@ void staticsmax() } } } -} \ No newline at end of file +} diff --git a/pol-core/uotool/uotool-2012.vcxproj b/pol-core/uotool/uotool-2012.vcxproj deleted file mode 100644 index 7d00c40f0..000000000 --- a/pol-core/uotool/uotool-2012.vcxproj +++ /dev/null @@ -1,295 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - uotool - {96834D20-7421-46E7-B8DE-6FD2F7EAD7FE} - uotool - - - - Application - false - MultiByte - v110_xp - - - Application - false - MultiByte - v110 - - - Application - false - MultiByte - v110 - - - Application - false - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\Debug\ - .\Debug\x64/ - .\Debug\ - .\Debug\x64/ - true - true - .\Release\ - .\Release\x64/ - .\Release\ - .\Release\x64/ - false - false - AllRules.ruleset - AllRules.ruleset - - - - - AllRules.ruleset - AllRules.ruleset - - - - - - - - .\Debug/uotool.tlb - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NOMINMAX;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - - - .\Debug/uotool.pch - .\Debug/ - .\Debug/ - .\Debug/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /MACHINE:I386 %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Debug/uotool.exe - true - ..\..\lib\boost_1_55_0\lib\x86\lib;%(AdditionalLibraryDirectories) - true - .\Debug/uotool.pdb - Console - false - - - - - - - .\Debug/x64/uotool.tlb - - - Disabled - %(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;NOMINMAX;INC_PASSERT;TIXML_USE_STL;_WIN64;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebug - true - - - .\Debug/x64/uotool.pch - .\Debug/x64/ - .\Debug/x64/ - .\Debug/x64/ - Level4 - true - ProgramDatabase - Default - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Debug/x64/uotool.exe - true - ..\..\lib\boost_1_55_0\lib\x64\lib;%(AdditionalLibraryDirectories) - true - .\Debug/x64/uotool.pdb - Console - false - - - - - - - .\Release/uotool.tlb - - - %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NOMINMAX;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - - - .\Release/uotool.pch - .\Release/ - .\Release/ - .\Release/ - Level4 - true - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - /MACHINE:I386 %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Release/uotool.exe - true - ..\..\lib\boost_1_55_0\lib\x86\lib;%(AdditionalLibraryDirectories) - true - .\Release/uotool.pdb - true - Console - false - - - 5.0 - - - - - .\Release/x64/uotool.tlb - - - %(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;NOMINMAX;INC_PASSERT;TIXML_USE_STL;%(PreprocessorDefinitions) - true - MultiThreaded - false - true - true - - - .\Release/x64/uotool.pch - .\Release/x64/ - .\Release/x64/ - .\Release/x64/ - Level4 - true - ProgramDatabase - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - %(AdditionalOptions) - odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - .\Release/x64/uotool.exe - true - ..\..\lib\boost_1_55_0\lib\x64\lib;%(AdditionalLibraryDirectories) - true - .\Release/x64/uotool.pdb - true - Console - false - - - 5.02 - true - - - - - - - - - - - {7cd5572b-8a78-46c5-ac2d-39ee47acd01a} - false - - - {d45c6577-00e3-4995-a909-9c704a472565} - false - - - - - Document - true - true - true - true - true - true - - - - - - - \ No newline at end of file